跳转至

defineSetupPluginEntry

轻量级 setup-entry.ts 文件的入口辅助函数,以及与之搭配的窄范围设置辅助函数族。属于插件入口点参考的一部分。

defineSetupPluginEntry

导入: openclaw/plugin-sdk/channel-core

用于轻量级 setup-entry.ts 文件。仅返回 { plugin },不包含运行时或 CLI 接线。

import { defineSetupPluginEntry } from "openclaw/plugin-sdk/channel-core";

export default defineSetupPluginEntry(myChannelPlugin);

当频道被禁用或未配置时,OpenClaw 会加载此入口而不是完整入口。有关何时重要,请参阅设置和配置。

将 defineSetupPluginEntry(...) 与以下窄范围设置辅助函数族搭配使用:

导入 用途
openclaw/plugin-sdk/setup-runtime 运行时安全的设置辅助函数:createSetupTranslator、导入安全的设置补丁适配器、查找备注输出、promptResolvedAllowFrom、splitSetupEntries、委托设置代理
openclaw/plugin-sdk/channel-setup 可选安装设置界面
openclaw/plugin-sdk/channel-dm-policy 用于设置流程的账户感知 DM 策略描述符
openclaw/plugin-sdk/setup-tools 设置/安装 CLI、归档和文档辅助函数
openclaw/plugin-sdk/archive 有界 TAR/gzip 成员检查、归档提取和单条目读取
openclaw/plugin-sdk/root-walk 带预算、根目录受限的目录遍历
openclaw/plugin-sdk/secret-file 固定密钥读取和先写入者获胜创建

inspectTarArchive({ archivePath, timeoutMs, limits, entryFilter, onFiltered }) 返回一个有界的、冻结的已接受 { path, kind, size } TAR/gzip 成员列表, 而不创建已提取的目录树。它使用 fs-safe 的完整准入和零剥离提取策略, 而不是 tar 显示输出。路径使用现有的规范归档标识;LF 和 Unicode 拼写保持不变。使用匹配的 filter/limit 设置,并在后续提取时保留或验证相同的归档字节:检查结果不是可重用的写入权限。只有已解析的 结果才是完整准入证据;filter 回调可能先于后续策略失败发生。成员清单不会合成隐式父目录, 因此整树使用者必须单独授权这些父路径。

将重量级 SDK、CLI 注册和长生命周期运行时服务保留在完整入口中。

将设置和运行时界面拆分的捆绑工作区频道可以改用来自 openclaw/plugin-sdk/channel-entry-contract 的 defineBundledChannelSetupEntry(...)。它允许设置 入口保留设置安全的 plugin/secrets 导出,同时仍然暴露运行时 setter:

import { defineBundledChannelSetupEntry } from "openclaw/plugin-sdk/channel-entry-contract";

export default defineBundledChannelSetupEntry({
  importMetaUrl: import.meta.url,
  plugin: {
    specifier: "./channel-plugin-api.js",
    exportName: "myChannelPlugin",
  },
  runtime: {
    specifier: "./runtime-api.js",
    exportName: "setMyChannelRuntime",
  },
  registerSetupRuntime(api) {
    api.registerHttpRoute({
      path: "/my-channel/events",
      auth: "plugin",
      handler: async (req, res) => {
        /* setup-safe route */
      },
    });
  },
});

仅当设置流程确实需要针对未配置频道的轻量级运行时 setter 或设置安全的 gateway 界面时,才使用此方法。 registerSetupRuntime 仅在 "setup-runtime" 加载时运行;请将其限制为仅配置路由或该设置流程所需的方法。

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 cl/openclaw