十年匠心定制 · 商业建站与技术教学双线并行 咨询热线:400-886-1026 service@lmnt.cn
ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

BOOT.md 示例

BOOT.md 示例 BOOT.md 示例【免费下载链接】openclawThe AI that really does things. Any OS. Any Platform. The lobster way. 项目地址: https://gitcode.com/GitHub_Trending/cl/openclaw检查系统状态调用 status 工具确认网关健康。通知运维使用 message 工具channel 为slacktarget 为#ops-alerts发送网关已启动BOOT 检查完成。### 规则三以静默令牌 NO_REPLY 结尾 由于最终回复投递被关闭Agent 在完成清单后需要回复一个特殊的**静默令牌** NO_REPLY大小写不限any letter case表示“无需对外输出”。模板原文为 Then reply with the silent token NO_REPLY, in any letter case. 在源码 [boot.ts](https://link.gitcode.com/i/ab690cc2d03b641616265a73d9abf0ef) 中这一行为被进一步落实构造提示词时明确要求模型——如果清单要求发消息使用 message 工具并携带 channel 与 target发完消息或无需关注时仅回复 NO_REPLY 令牌。NO_REPLY 来自 src/auto-reply/tokens.js 的 SILENT_REPLY_TOKEN 常量。 ## 运行语义每个工作区一次失败不阻塞 模板文档和 [bundled-hooks.md](https://link.gitcode.com/i/471aa01c6457be32fd92e6cfae6e0e55) 共同勾勒出 boot-md 的完整运行语义 | 语义 | 说明 | | --- | --- | | 触发时机 | 网关每次启动gateway:startup 事件 | | 文件条件 | 存在且内容非空白缺失或空白文件被跳过 | | 运行粒度 | 每个解析后的 Agent 工作区一次 | | 共享工作区 | 多个 Agent 共享同一工作区时只运行一次由先选中的 Agent 执行 | | 执行方式 | 通过 Agent 运行执行指令不是 shell 脚本也不是引导文件注入 | | 会话模型 | 每次运行使用全新的临时会话 agent:id:boot:run-id成功或失败后清理 | | 会话隔离 | 已有会话及其历史不受影响、完整保留 | | 失败处理 | 顺序执行单条失败仅记日志不阻止后续任务 | “每个工作区一次”这一点在源码中有直接印证[handler.ts](https://link.gitcode.com/i/a324d8e101ba6aba519ca2a04a906b48) 中钩子遍历 listAgentIds(cfg) 得到的所有 Agent通过 resolveAgentWorkspaceDir 解析各自工作区再用 seenWorkspaces 集合去重最后把每个去重后的工作区包装成一个 StartupTask 交给 runStartupTasks 统一调度 ts const seenWorkspaces new Setstring(); // Multiple agents may share a workspace. Startup tasks are keyed by workspace // so BOOT.md is not executed repeatedly for the same files. const tasks: StartupTask[] listAgentIds(cfg) .map((agentId) { const workspaceDir resolveAgentWorkspaceDir(cfg, agentId); return { agentId, workspaceDir }; }) .filter(({ workspaceDir }) { if (seenWorkspaces.has(workspaceDir)) { return false; } seenWorkspaces.add(workspaceDir); return true; }) .map(({ agentId, workspaceDir }) ({ source: boot-md as const, agentId, workspaceDir, run: () runBootOnce({ cfg, deps, workspaceDir, agentId }), })); await runStartupTasks({ tasks, log });源码级原理一次 BOOT 运行的全链路runBootOncesrc/gateway/boot.ts是 BOOT.md 执行的核心函数其完整调用链揭示了模板文档中每条规则背后的实现1. 读取文件与校验文件路径固定为workspaceDir/BOOT.md常量BOOT_FILENAME先通过fs.realpath解析符号链接允许 BOOT.md 是指向普通文件的软链接同时保留目录/权限/大小限制的报错能力通过readRegularFile读取大小上限为 16 MiBMAX_BOOT_FILE_BYTES内容trim()后为空则返回skipped不执行任何指令。2. 构造引导提示词buildBootPrompt把 BOOT.md 内容包装进“内部运行时上下文”分隔符INTERNAL_RUNTIME_CONTEXT_BEGIN/INTERNAL_RUNTIME_CONTEXT_END并附加系统指令You are running a boot check. Follow BOOT.md instructions exactly. ... If BOOT.md asks you to send a message, use the message tool (actionsend with channel target). Use the target field (not to) for message tool destinations. After sending with the message tool, reply with ONLY: SILENT_REPLY_TOKEN. If nothing needs attention, reply with ONLY: SILENT_REPLY_TOKEN.【免费下载链接】openclawThe AI that really does things. Any OS. Any Platform. The lobster way. 项目地址: https://gitcode.com/GitHub_Trending/cl/openclaw创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表