@yiyi_zhang/laoshi 0.1.1 → 0.2.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/adapters/dsh/plugin/index.mjs +1 -1
  3. package/adapters/dsh/plugin/package.json +1 -1
  4. package/adapters/mogao/adapter.ts +46 -0
  5. package/adapters/mogao/install.mjs +31 -0
  6. package/adapters/mogao/make-expert.mjs +63 -0
  7. package/adapters/mogao/mogao-runtime.ts +457 -0
  8. package/adapters/mogao/skill/setup.md +21 -0
  9. package/bin/install.mjs +8 -2
  10. package/bin/req.mjs +8 -0
  11. package/contracts/agent-runtime.md +3 -0
  12. package/docs/design/mogao-expert.md +101 -0
  13. package/engine/src/api.ts +5 -5
  14. package/engine/src/code-review.ts +2 -2
  15. package/engine/src/control.ts +6 -6
  16. package/engine/src/danger-guard.ts +7 -0
  17. package/engine/src/doctor.ts +1 -1
  18. package/engine/src/features.ts +2 -2
  19. package/engine/src/integration-cmd.ts +2 -2
  20. package/engine/src/launch.ts +44 -6
  21. package/engine/src/locations.ts +15 -1
  22. package/engine/src/main.ts +3 -0
  23. package/engine/src/permission-cmd.ts +56 -0
  24. package/engine/src/platform.ts +5 -0
  25. package/engine/src/preflight.ts +2 -2
  26. package/engine/src/runtime-loader.ts +2 -0
  27. package/engine/src/runtime.ts +5 -0
  28. package/engine/src/skills-render.ts +10 -6
  29. package/engine/src/state.ts +23 -1
  30. package/package.json +1 -1
  31. package/site-dist/404.html +2 -2
  32. package/site-dist/assets/{app.Df99UgrJ.js → app.DMAHANCl.js} +1 -1
  33. package/site-dist/assets/changelog.md.Q8QGpuBY.js +1 -0
  34. package/site-dist/assets/chunks/@localSearchIndexroot.CQdjFK3w.js +1 -0
  35. package/site-dist/assets/chunks/{VPLocalSearchBox.IEhP6Gw5.js → VPLocalSearchBox.COsLwqWS.js} +1 -1
  36. package/site-dist/assets/chunks/{theme.DHubfO7g.js → theme.CeR3HD86.js} +2 -2
  37. package/site-dist/assets/{guide_getting-started.md.BZTWiHhH.js → guide_getting-started.md.Bytaz3L8.js} +1 -1
  38. package/site-dist/assets/{guide_getting-started.md.BZTWiHhH.lean.js → guide_getting-started.md.Bytaz3L8.lean.js} +1 -1
  39. package/site-dist/assets/{reference_contracts_agent-runtime.md.Bu8q-uGl.js → reference_contracts_agent-runtime.md.TK7Lhwdf.js} +1 -1
  40. package/site-dist/changelog.html +5 -5
  41. package/site-dist/guide/dsh.html +4 -4
  42. package/site-dist/guide/getting-started.html +5 -5
  43. package/site-dist/guide/how-it-works.html +4 -4
  44. package/site-dist/guide/index.html +4 -4
  45. package/site-dist/guide/install.html +4 -4
  46. package/site-dist/guide/intranet.html +4 -4
  47. package/site-dist/guide/maintainer.html +4 -4
  48. package/site-dist/guide/phases.html +4 -4
  49. package/site-dist/guide/project.html +4 -4
  50. package/site-dist/guide/user.html +4 -4
  51. package/site-dist/hashmap.json +1 -1
  52. package/site-dist/index.html +4 -4
  53. package/site-dist/reference/adr/0001-new-repo-core-and-adapters.html +4 -4
  54. package/site-dist/reference/adr/0002-two-orchestration-modes.html +4 -4
  55. package/site-dist/reference/adr/0003-generate-once-then-lock.html +4 -4
  56. package/site-dist/reference/adr/0004-external-contracts-stay-stable.html +4 -4
  57. package/site-dist/reference/adr/0005-skill-names.html +4 -4
  58. package/site-dist/reference/adr/0006-deterministic-engine-platform-capabilities.html +4 -4
  59. package/site-dist/reference/adr/0007-one-install-many-repos.html +4 -4
  60. package/site-dist/reference/adr/0008-capability-sources-and-platform-plugin.html +4 -4
  61. package/site-dist/reference/adr/index.html +4 -4
  62. package/site-dist/reference/commands.html +4 -4
  63. package/site-dist/reference/config.html +4 -4
  64. package/site-dist/reference/contracts/agent-runtime.html +5 -5
  65. package/site-dist/reference/contracts/cli-json.html +4 -4
  66. package/site-dist/reference/contracts/feature-files.html +4 -4
  67. package/site-dist/reference/contracts/index.html +4 -4
  68. package/site-dist/reference/contracts/notifier-event.html +4 -4
  69. package/site-dist/reference/contracts/result-file.html +4 -4
  70. package/site-dist/reference/contracts/spec.html +4 -4
  71. package/site-dist/reference/contracts/state.html +4 -4
  72. package/site-dist/reference/contracts/usage-record.html +4 -4
  73. package/site-dist/reference/contracts/verify.html +4 -4
  74. package/site-dist/reference/design/adapter-guide.html +4 -4
  75. package/site-dist/reference/design/architecture.html +4 -4
  76. package/site-dist/reference/design/builtin-capabilities.html +4 -4
  77. package/site-dist/reference/design/platform-vocabulary.html +4 -4
  78. package/site-dist/reference/scope.html +4 -4
  79. package/skills/laoshi/SKILL.md +3 -0
  80. package/skills/laoshi-doctor/SKILL.md +2 -0
  81. package/skills/laoshi-retro/SKILL.md +2 -0
  82. package/skills/laoshi-setup/SKILL.md +3 -0
  83. package/site-dist/assets/changelog.md.Df8vFhjK.js +0 -1
  84. package/site-dist/assets/chunks/@localSearchIndexroot.n-0kN-N0.js +0 -1
  85. /package/site-dist/assets/{changelog.md.Df8vFhjK.lean.js → changelog.md.Q8QGpuBY.lean.js} +0 -0
  86. /package/site-dist/assets/{reference_contracts_agent-runtime.md.Bu8q-uGl.lean.js → reference_contracts_agent-runtime.md.TK7Lhwdf.lean.js} +0 -0
package/bin/install.mjs CHANGED
@@ -55,7 +55,13 @@ dsh 的选项:--dsh-home <DSH_HOME> --profile <名称> --dsh-bin <dsh 的 bin.
55
55
  process.exit(0);
56
56
  }
57
57
  const dry = args["dry-run"] || args.check;
58
- const home = path.resolve(args.home ?? process.env.LAOSHI_HOME ?? path.join(os.homedir(), ".laoshi"));
58
+ // Without --home or LAOSHI_HOME: the install root this program was installed into with npm
59
+ // (<root>/npm/…/node_modules, as engine/src/locations.ts programHome finds it), else ~/.laoshi.
60
+ const programHome = (() => {
61
+ const m = /^(.*)[\\/]npm[\\/](?:lib[\\/])?node_modules[\\/]/.exec(kit);
62
+ return m && fs.existsSync(path.join(m[1], "config.json")) ? m[1] : null;
63
+ })();
64
+ const home = path.resolve(args.home ?? process.env.LAOSHI_HOME ?? programHome ?? path.join(os.homedir(), ".laoshi"));
59
65
  const configPath = path.join(home, "config.json");
60
66
  const recordPath = path.join(home, "install.json");
61
67
 
@@ -171,7 +177,7 @@ const config = existing ?? { platform: mod.platformConfig(args) };
171
177
 
172
178
  // ---------------------------------------------------------------------------------------------
173
179
  section("skill");
174
- const targets = [...mod.skillTargets(args, config), ...args.target.map((t) => ({ dir: path.resolve(t), label: `自定义目录 ${path.resolve(t)}` }))];
180
+ const targets = [...mod.skillTargets(args, config, process.env, home), ...args.target.map((t) => ({ dir: path.resolve(t), label: `自定义目录 ${path.resolve(t)}` }))];
175
181
  const rendered = fs.mkdtempSync(path.join(os.tmpdir(), "laoshi-skills-"));
176
182
  const renderConfig = path.join(rendered, "config.json");
177
183
  fs.writeFileSync(renderConfig, JSON.stringify(config));
package/bin/req.mjs CHANGED
@@ -35,6 +35,8 @@ const HELP = `laoshi ${version}(${kitRoot})
35
35
  laoshi checklist <需求> 验收清单:按验收标准逐条勾选,提交后写成验收记录
36
36
  laoshi ui-check <网址> [--prototype <原型文件>] [--width 1280,390]
37
37
  不靠看图检查网页:显示不全、遮挡、超出屏幕、文字太淡、报错,和原型对文字
38
+ laoshi permission <需求> approve|deny [理由]
39
+ 批准或拒绝步骤等待批准的操作,并接着运行(平台在对话里问人时用)
38
40
  laoshi reply <需求> <回复> 把回答或方案意见转给需求的对话(需求插件的"等你处理"用它)
39
41
  laoshi integration test [需求] 只显示对接外部系统时会执行的命令,不真正调用
40
42
  laoshi start --from <系统>:<卡号> 从需求管理系统中的一张卡片开始需求(没有人开着对话也可以)
@@ -185,6 +187,12 @@ switch (command) {
185
187
  case "reply":
186
188
  code = needTsx() ? node([tsxCli, path.join(kitRoot, "engine", "src", "reply.ts"), ...rest]) : 1;
187
189
  break;
190
+ case "permission":
191
+ // Answers a step's pending approval, then continues the run (the step picks up the answer).
192
+ code = needTsx() ? node([tsxCli, path.join(kitRoot, "engine", "src", "permission-cmd.ts"), ...rest]) : 1;
193
+ if (code === 0) code = node([launcher, "--resume", ...feature(rest.slice(0, 1), true)]);
194
+ else if (code === 3) code = 0;
195
+ break;
188
196
  case "sync":
189
197
  code = needTsx() ? node([tsxCli, path.join(kitRoot, "engine", "src", "integration-cmd.ts"), "sync", ...rest]) : 1;
190
198
  break;
@@ -48,6 +48,9 @@
48
48
  | `createWorktree(request)`、`waitForWorkspaceSetup(id, timeoutMs)` | `--worktree`(`worktree.ts`)和联合需求(`joint.ts`) | ⚠ 创建失败是硬错误。没有平台工作区的适配器,可以在适配器内用 `git worktree` 实现并返回 `{ workspaceId, directory }`;`waitForWorkspaceSetup` 可恒返回 `{ status: "none" }` |
49
49
  | `startSessionAgent(input)` | 从卡片接单(`card-cmd.ts`):为需求新开一个顶层会话 | 没有则不能用接单器 |
50
50
  | `scheduleNewAgent(input)` | 需求总览的定时发送(`digest.ts --schedule`) | 返回 `null` 时该功能关闭 |
51
+ | `answerPermission(agentId, requestId, approve, reason)` | `laoshi permission <需求> approve\|deny`(`permission-cmd.ts`):平台的审批不能在它自己的界面里回答、由对话问人时,laoshi 转达人的决定;`requestId` 为 `null` 表示现在等待的那一个 | 没有时,审批按平台自己的方式处理(如 Paseo、dsh 的界面) |
52
+
53
+ 适配器还可以声明 `runsInChat`(`PlatformAdapter`):平台只在对话的一个轮次内保留对话的机器时,引擎不能在后台运行,`launch.ts` 让它在对话的命令里运行,给对话的消息(`notifyAgent`)写进 `chat.log` 并显示在命令输出里。状态文件记下运行引擎的机器(`host`),另一台机器上记录的进程不算还在运行。
51
54
 
52
55
  ## 调度
53
56
 
@@ -0,0 +1,101 @@
1
+ # laoshi 作为摸高上的"专家"
2
+
3
+ - 状态:已定形态(B1);第 5 节第 1~4 项已实现([adapters/mogao](../../adapters/mogao/README.md):适配器、专家包 `make-expert.mjs`;假 `aimax` 上的端到端检查通过),第 5、6 项(沙箱里的真实运行、参赛材料)待做。
4
+ - 背景:摸高的数字工程师挑战赛,赛题是在平台中提交 skill 或专家(多个 skill 的组合)。laoshi 本身就是一组 skill(`/laoshi` 入口、手册、方法、原则)加一个确定性的流水线引擎,天然是一个专家。
5
+
6
+ ## 1. 约束(来自摸底)
7
+
8
+ | 约束 | 对 laoshi 的影响 |
9
+ | --- | --- |
10
+ | 每个对话轮次一个容器,轮次结束容器就没了;轮内的多次执行共用容器 | 引擎不能跨轮常驻。引擎在对话的一次执行里运行(超过 60 秒转为后台会话,对话轮询);每一步做完都写回状态,轮次结束时没做完的步骤,下一轮 `laoshi resume` 接着做 |
11
+ | 只有 `/data/workspace`、`/data/.aimax` 持久 | 安装根、程序、需求状态放在工作区:`LAOSHI_HOME=/data/workspace/.laoshi`;`$HOME` 不持久,每条命令都要带上这个变量 |
12
+ | `aimax run` 能在指定目录同步起一个带完整工具的 agent,返回 JSON;能用 `-s` 续接;能并发 | 步骤 agent 就用它起,和 Paseo、dsh 上一样,每一步是一个新的 agent,评审独立 |
13
+ | 审批:`run` 遇到要批准的命令立即返回 `paused`,之后 `resume` / `cancel` | 和 laoshi 现有的"等待批准"对应:引擎停下,把要批准的内容告诉使用者,使用者在对话里回答后续跑 |
14
+ | 进度:`--callback-url` 推送工具调用、用量和结束事件 | 引擎在本机起一个接收端,用于危险命令拦截、大目录搜索打断、最近活动和用量统计 |
15
+ | 没有定时、没有向对话推送消息的方式 | 进展作为引擎的输出回到对话;"预约开始""自动继续"降级为"告诉使用者下一步说什么" |
16
+ | npm 走内网镜像,公网不通 | 第一次使用时从镜像安装 `@yiyi_zhang/laoshi`(固定版本,约 40 秒);模型用平台的 |
17
+ | 沙箱自带的工具少,但可以装在工作区并保留(mvn 已确认可用) | 项目需要的构建工具装在工作区(如 `/data/workspace/.laoshi/tools/`),路径写进项目的验证方法和服务定义;每条命令都要带上这些路径 |
18
+
19
+ laoshi 现有的设计正好有两块可以直接用:
20
+
21
+ - **续跑**:引擎每一步的结果都存在 `state.json` 里,重新运行会跳过已完成的步骤(`laoshi resume`)。轮次结束打断了引擎,下一轮接着做即可。
22
+ - **平台用词和 skill 渲染**:skill 和提示词里与平台有关的说法都是 `{{platform.<词>}}`,按平台渲染(M2e),加一个平台只需要一份适配器。
23
+
24
+ ## 2. 形态:B1(引擎 + 摸高适配器)
25
+
26
+ ```text
27
+ 使用者 ──对话──► 摸高对话 agent(加载 laoshi 专家的 skill)
28
+ │ 执行一条命令(超过 60 秒转为后台会话,对话轮询它的输出)
29
+ ▼
30
+ laoshi start / resume <需求> ← laoshi 引擎(状态在工作区)
31
+ │ 每一步:aimax run --project-dir <仓库> --output json --callback-url <本机> --timeout …
32
+ ▼
33
+ 步骤 agent(新会话,带工具)── paused ──► 引擎停下,告诉使用者要批准什么
34
+ │ 使用者回答 → laoshi reply → aimax resume / cancel
35
+ ▼
36
+ 校验结果文件、质量门、写回状态 → 下一步 …… → 需要人决定的点或完成:输出给对话
37
+ ```
38
+
39
+ 不选 B2(对话 agent 自己做每一步)的原因:`aimax run` 已经能起独立的 agent,用它流程保证更强、评审独立,而且和 Paseo、dsh 共用同一套引擎,不需要 [in-chat-orchestration](in-chat-orchestration.md) 里还没验证的"外包执行"。
40
+
41
+ 形态丙(纯 skill,不带引擎)始终可用:访谈、需求说明、验收标准、如实报告这些方法 skill 不依赖引擎,可以作为专家的最小版本先提交。
42
+
43
+ ## 3. 摸高适配器(`adapters/mogao`)
44
+
45
+ 运行时把 laoshi 的 `AgentRuntime` 映射到 `aimax` 命令行:
46
+
47
+ | laoshi 需要 | 摸高上怎么做 |
48
+ | --- | --- |
49
+ | `verifyOrigin`、发起的对话 | `AIMAX_SESSION_ID`;对话的工作目录就是当前目录 |
50
+ | `startAgent` | 在后台起 `aimax run --project-dir <目录> --message <提示词> --output json --timeout <步骤时限> --callback-url <本机接收端>`,记下进程和(回调里拿到的)`sessionId` |
51
+ | `wait` | 等进程结束,解析 JSON:正常结束 → `idle`;有 `paused` → `permission`(附 `requestId`、标题);`error` 为超时 → `timeout`;其他 `error` → `error` |
52
+ | `followUp` | `aimax run -s <sessionId> --message <文本> …` |
53
+ | `interruptAgent` | 结束这个 `aimax run` 进程,再用 `-s` 续接并给出新指令 |
54
+ | `attachAgent` | 按 `sessionId` 续接(另一个进程、下一轮也可以) |
55
+ | 批准 / 拒绝 | `aimax resume -d /data -s <会话> --request-id <id> --input-json '{"action":"approve"\|"deny"}'`;停止步骤时 `aimax cancel` |
56
+ | `recentActivity`、`runningTool`、`toolCalls` | 回调的 `tool_start` / `tool_end`(命令、退出码、输出摘要;**写日志前脱敏**) |
57
+ | 用量 | 回调的 `usage`、结果 JSON 的 `usage` |
58
+ | `notifyAgent`(进展发回对话) | 能力为 none:进展写进引擎的输出和进度日志,对话 agent 转述 |
59
+ | 定时(`scheduleMessage` 等) | none |
60
+ | 工作区、服务 | builtin(`git worktree`、`.laoshi/services.json`),和 dsh 一样 |
61
+ | 各角色的模型 | 默认用对话的模型;`aimax run` 能否指定模型待确认 |
62
+ | 用词 | 平台名"摸高",会话、工作区、"说'继续'"代替定时提醒 |
63
+
64
+ ## 4. 安装
65
+
66
+ 摸高上没有"安装器"这一步。专家的入口 skill 在第一次使用时:
67
+
68
+ 1. 检查 `/data/workspace/.laoshi/npm` 下有没有约定版本的 `@yiyi_zhang/laoshi`,没有就 `npm install --prefix /data/workspace/.laoshi/npm @yiyi_zhang/laoshi@<版本>`(内网镜像,约 40 秒)。
69
+ 2. 运行 `laoshi install --platform mogao`:写安装级配置;skill 由平台从专家加载,所以这一步不复制 skill。
70
+ 3. 之后每条命令都写成 `LAOSHI_HOME=/data/workspace/.laoshi node /data/workspace/.laoshi/npm/node_modules/@yiyi_zhang/laoshi/bin/req.mjs …`(skill 渲染时把这一串换成占位符,使用者看不到)。
71
+
72
+ 专家提交时带上按摸高渲染好的 skill。
73
+
74
+ ## 5. 要做的事
75
+
76
+ | # | 内容 | 依赖 |
77
+ | --- | --- | --- |
78
+ | 1 | `adapters/mogao`:运行时(`aimax run` / `resume` / `cancel`、回调接收端)、用词、能力声明、身份(`AIMAX_SESSION_ID`、`AIMAX_USER_NAME`)、安装模块;用一个假的 `aimax` 脚本(按第二、三轮记录的 JSON 和回调格式)做测试 | 无 |
79
+ | 2 | 引擎在对话里运行:输出给对话看的进展(没有推送时);轮次结束被打断后 `resume` 能接上正在做的步骤(用 `sessionId` 续接,而不是重做) | 第 1 项 |
80
+ | 3 | 危险命令拦截:把读出、外发平台凭据环境变量的命令列为危险;工具输出写日志前脱敏 | 第 1 项 |
81
+ | 4 | 专家的入口 skill:首次安装、启动和继续、转述进展和审批 | 第 1、2 项 |
82
+ | 5 | 在摸高沙箱里端到端验证:一个小需求从对齐到可验收(含一次审批、一次轮次中断后续跑),一个 Java 项目(工作区里的 mvn) | 第 4 项,需要使用者在沙箱里配合 |
83
+ | 6 | 参赛材料:演示、评估用例结果(隐藏验收、如实率)、说明文档 | 第 5 项 |
84
+
85
+ ## 6. 参赛的亮点
86
+
87
+ - **不是写代码的助手,而是"把需求做到可验收"的专家**:给测试、产品、项目经理用,每个要拍板的地方都停下来等人。
88
+ - **流程由程序保证**:顺序、评审轮次、质量门、危险命令拦截、密钥扫描由引擎执行,不靠模型自觉。
89
+ - **用足平台能力**:每一步是平台的一个独立 agent(`aimax run`),审批用平台的 HITL,工具调用和用量来自平台回调,平台插件(知识库等)步骤里也能用。
90
+ - **能和平台已有的 skill 组合**:摸高上已有 SDD、PRD、测试用例等场景 skill,可以作为某一步的方法(例如验收用例),体现"多 skill 组合"。
91
+ - **跨平台**:同一套流程已经在 Paseo、DeepSeek Harness 上运行,摸高是第三个平台。
92
+ - **结果可度量**:评估用例带隐藏验收,`laoshi stats` 统计交付周期、返工、等待和 token。
93
+
94
+ ## 7. 待确认与风险
95
+
96
+ - **一轮对话最长能持续多久**:引擎在一次执行(后台会话)里运行,对话要一直轮询到需要人决定的点。轮次有总时限时,引擎每做完一步都已写回状态,下一轮 `laoshi resume` 接着做,只是使用者要多说一次"继续"。
97
+ - **提示词怎么传给 `aimax run`**:步骤提示词可能较长(几十 KB),要确认 `--message` 之外有没有从文件或标准输入读取的方式;没有时用"读这个文件并照做"的短消息代替。
98
+ - **能否按角色指定模型**:`aimax run` 有没有模型参数;没有时所有角色用同一个模型,评审只靠"新会话、不带实现上下文"保持独立。
99
+ - **平台凭据在步骤 agent 的环境里**:命令能读到,靠危险命令拦截和日志脱敏降低风险;最好请平台提供不把凭据传给子进程的选项。
100
+ - **token**:每次 `aimax run` 约 1.4 万 token 的系统提示、没有缓存命中,一个标准档需求的步骤数乘上去,要在用时和 token 估算里体现。
101
+ - **评审在谁的沙箱里试用、能否第一次使用时从内网镜像安装**:决定专家能否依赖 npm 包,否则要把程序随专家一起提交。
package/engine/src/api.ts CHANGED
@@ -28,7 +28,7 @@ import { configView } from "./config-view.js";
28
28
  import { pruneIndex, readIndex, registerRequirement, requirementKey } from "./records.js";
29
29
  import { listWorktreeRecords } from "./worktree.js";
30
30
  import { readHumanReview } from "./code-review.js";
31
- import { isAlive, type PipelineState, readState, statePath, type StepRecord } from "./state.js";
31
+ import { engineAlive, readState, statePath, type PipelineState, type StepRecord } from "./state.js";
32
32
  import { notStartedNotice } from "./messages.js";
33
33
  import { scanOutcomes } from "./outcomes.js";
34
34
  import { parsePeriod, summarizeRuns } from "./stats.js";
@@ -79,10 +79,10 @@ export type Attention = "approval" | "business" | "permission" | "interrupted" |
79
79
  /** What a person needs to do about a requirement, if anything. */
80
80
  export function attentionOf(state: Pick<PipelineState, "status" | "pid" | "outcome" | "waitingPermission"> | null): Attention {
81
81
  if (!state) return null;
82
- if (state.status === "running" && state.waitingPermission && isAlive(state.pid)) return "permission";
82
+ if (state.status === "running" && state.waitingPermission && engineAlive(state)) return "permission";
83
83
  if (state.status === "waiting_for_approval") return "approval";
84
84
  if (state.status === "waiting_for_business") return "business";
85
- if (state.status === "failed" || (state.status === "running" && !isAlive(state.pid))) return "interrupted";
85
+ if (state.status === "failed" || (state.status === "running" && !engineAlive(state))) return "interrupted";
86
86
  if (state.status === "completed" && state.outcome === "not_completed") return "not_completed";
87
87
  return null;
88
88
  }
@@ -102,7 +102,7 @@ function readStateSafe(repo: string, featureDir: string): PipelineState | null {
102
102
  }
103
103
 
104
104
  function currentSteps(state: PipelineState | null) {
105
- if (!state || state.status !== "running" || !isAlive(state.pid)) return [];
105
+ if (!state || state.status !== "running" || !engineAlive(state)) return [];
106
106
  return state.history.filter((h) => h.outcome === "running").map((h) => ({ key: h.key, title: stepName(h, state), agentId: h.agentId }));
107
107
  }
108
108
 
@@ -213,7 +213,7 @@ function item(repo: string, branch: string | null, featureDir: string, extra: {
213
213
  branch: state?.branch ?? summary.branch,
214
214
  stage: summary.stage,
215
215
  status: state?.status ?? null,
216
- running: !!state && state.status === "running" && isAlive(state.pid),
216
+ running: !!state && state.status === "running" && engineAlive(state),
217
217
  phase: state?.phase ?? null,
218
218
  attention: attentionOf(state) ?? (notStarted ? "not_started" : null),
219
219
  current: currentSteps(state),
@@ -10,7 +10,7 @@ import { section } from "./checklist.js";
10
10
  import { ownersFor, readCodeowners } from "./codeowners.js";
11
11
  import { KIT_ROOT } from "./locations.js";
12
12
  import { appendEvent, requirementRef } from "./records.js";
13
- import { isAlive, readState, statePath } from "./state.js";
13
+ import { engineAlive, readState, statePath } from "./state.js";
14
14
  import { readWorktreeRecord } from "./worktree.js";
15
15
  import { scrubOriginEnv } from "./runtime-loader.js";
16
16
 
@@ -315,7 +315,7 @@ export function buildCodeReview(repo: string, featureDir: string): CodeReviewDat
315
315
  reviewers: { suggested: o.all, byFile: o.byFile, source: owners?.file ?? null },
316
316
  human: human ? { ...human, stale: human.status === "approved" && !!head && human.head !== head } : null,
317
317
  status: state?.status ?? null,
318
- running: !!state && state.status === "running" && isAlive(state.pid),
318
+ running: !!state && state.status === "running" && engineAlive(state),
319
319
  };
320
320
  }
321
321
 
@@ -5,7 +5,7 @@ import { describeActivity } from "./activity.js";
5
5
  import { describeExternal } from "./integrations.js";
6
6
  import { PHASE_MODE_LABELS, PROFILE_LABELS, type PipelineConfig, REQUIREMENT_TYPE_LABELS } from "./config.js";
7
7
  import type { AgentRuntime, RuntimeFactory } from "./runtime.js";
8
- import { currentLockHolder, isAlive, type PipelineState, readState, type StepRecord, writeState } from "./state.js";
8
+ import { currentLockHolder, engineAlive, readState, type PipelineState, type StepRecord, writeState } from "./state.js";
9
9
  import { stepTitle } from "./playbooks.js";
10
10
  import { describeTotals, totals } from "./usage.js";
11
11
  import { wordsFor } from "./runtime-loader.js";
@@ -55,7 +55,7 @@ export function stepName(record: StepRecord, state: Pick<PipelineState, "type" |
55
55
 
56
56
  export function describeStatus(state: PipelineState | null, featureDir: string, now = new Date()): string {
57
57
  if (!state) return `需求 ${featureDir} 还没有启动过开发流水线。`;
58
- const running = state.status === "running" && isAlive(state.pid);
58
+ const running = state.status === "running" && engineAlive(state);
59
59
  const statusText = running
60
60
  ? "运行中"
61
61
  : state.status === "running"
@@ -167,15 +167,15 @@ export async function stopPipeline(input: StopInput): Promise<{ stopped: boolean
167
167
  };
168
168
  }
169
169
 
170
- const wasAlive = isAlive(state.pid);
170
+ const wasAlive = engineAlive(state);
171
171
  if (wasAlive) {
172
172
  try {
173
173
  process.kill(state.pid, "SIGTERM");
174
174
  } catch {
175
175
  // Already gone.
176
176
  }
177
- for (let i = 0; i < 20 && isAlive(state.pid); i++) await input.sleep(250);
178
- if (isAlive(state.pid)) {
177
+ for (let i = 0; i < 20 && engineAlive(state); i++) await input.sleep(250);
178
+ if (engineAlive(state)) {
179
179
  try {
180
180
  process.kill(state.pid, "SIGKILL");
181
181
  } catch {
@@ -242,7 +242,7 @@ export async function describeLiveActivity(
242
242
  timeoutMs = 8000,
243
243
  now = new Date(),
244
244
  ): Promise<string[]> {
245
- if (!state || state.status !== "running" || !isAlive(state.pid)) return [];
245
+ if (!state || state.status !== "running" || !engineAlive(state)) return [];
246
246
  const running = state.history.filter((h) => h.attempt === state.attempt && h.outcome === "running" && h.agentId).slice(0, 3);
247
247
  const lines: string[] = [];
248
248
  for (const record of running) {
@@ -84,6 +84,13 @@ function judgeSegment(words: string[], repo: string | null, home: string): Dange
84
84
  const sub = rest.find((w) => !w.startsWith("-"))?.toLowerCase() ?? "";
85
85
  const has = (re: RegExp) => rest.some((w) => re.test(w));
86
86
 
87
+ // Credentials the platform puts in the environment of step agents (tokens, keys): reading them out
88
+ // puts them in the output, in files or in requests.
89
+ const secretVar = words.map((w) => /(?:\$\{?|%|\$env:)([A-Za-z_][A-Za-z0-9_]*(?:TOKEN|SECRET|API_?KEY|PASSWORD|PASSWD|CREDENTIAL)[A-Za-z0-9_]*)/i.exec(w)?.[1]).find(Boolean);
90
+ if (secretVar) return { label: `读出凭据环境变量(${secretVar})`, why: "平台的凭据不能出现在输出、文件或网络请求里" };
91
+ if (cmd === "printenv" && (rest.length === 0 || rest.some((w) => /(TOKEN|SECRET|API_?KEY|PASSWORD|PASSWD|CREDENTIAL)/i.test(w))))
92
+ return { label: "列出环境变量(含凭据)", why: "平台的凭据不能出现在输出、文件或网络请求里" };
93
+
87
94
  if (cmd === "git") {
88
95
  // Skip global options (-C dir, -c k=v) to find the git command.
89
96
  let i = 0;
@@ -326,7 +326,7 @@ function project(repo: string, adapter: PlatformAdapter): void {
326
326
  function identity(repo: string | null): void {
327
327
  section("安装根与身份");
328
328
  const home = homeOf();
329
- const how = { LAOSHI_HOME: "环境变量 LAOSHI_HOME", REQ_KIT_HOME: "环境变量 REQ_KIT_HOME(req-kit 的旧名,可以改用 LAOSHI_HOME)", default: "默认位置", legacy: "req-kit 的旧目录(还没有 ~/.laoshi)" }[home.source];
329
+ const how = { LAOSHI_HOME: "环境变量 LAOSHI_HOME", REQ_KIT_HOME: "环境变量 REQ_KIT_HOME(req-kit 的旧名,可以改用 LAOSHI_HOME)", default: "默认位置", program: "程序安装在它的 npm 目录里", legacy: "req-kit 的旧目录(还没有 ~/.laoshi)" }[home.source];
330
330
  report("ok", `安装根:${home.dir}(${how})`);
331
331
  report("ok", `使用者:${userOf()}${process.env.LAOSHI_USER?.trim() ? "(环境变量 LAOSHI_USER)" : ""}`);
332
332
  if (repo) {
@@ -10,7 +10,7 @@ import path from "node:path";
10
10
  import { PROFILE_LABELS, type ProfileName } from "./config.js";
11
11
  import { samePath } from "./paths.js";
12
12
  import { isSpecConfirmed, specProfile } from "./preflight.js";
13
- import { isAlive } from "./state.js";
13
+ import { engineAlive } from "./state.js";
14
14
  import { describeTotals, totals } from "./usage.js";
15
15
 
16
16
  export const FEATURES_DIR = path.join("docs", "features");
@@ -102,7 +102,7 @@ function stageOf(confirmed: boolean, state: RawState | null, acceptance: string
102
102
  }
103
103
  switch (state.status) {
104
104
  case "running":
105
- return state.pid && isAlive(state.pid) ? "开发中" : "已中断(可继续)";
105
+ return state.pid && engineAlive({ pid: state.pid, host: (state as { host?: string }).host }) ? "开发中" : "已中断(可继续)";
106
106
  case "waiting_for_business":
107
107
  return "等待需求方决定";
108
108
  case "waiting_for_approval":
@@ -23,7 +23,7 @@ import {
23
23
  syncIntegration,
24
24
  } from "./integrations.js";
25
25
  import { defaultConfigPath } from "./locations.js";
26
- import { acquireLock, isAlive, type PipelineState, readState, statePath, writeState } from "./state.js";
26
+ import { acquireLock, engineAlive, readState, statePath, type PipelineState, writeState } from "./state.js";
27
27
 
28
28
  /** The event that describes where a requirement is now. */
29
29
  export function eventForState(state: Pick<PipelineState, "status" | "phase" | "pid">): IntegrationEvent {
@@ -116,7 +116,7 @@ async function main(argv: string[]): Promise<number> {
116
116
  console.log(`${featureDir} 还没有启动过开发流水线,没有要同步的。`);
117
117
  return 0;
118
118
  }
119
- if (state.status === "running" && isAlive(state.pid)) {
119
+ if (state.status === "running" && engineAlive(state)) {
120
120
  console.log("流水线正在运行:它会在下一个阶段变化时自动补发。现在不需要 req sync。");
121
121
  return 0;
122
122
  }
@@ -19,7 +19,7 @@ import { describeLiveActivity, describeStatus, stopPipeline } from "./control.js
19
19
  import { trackRequirement } from "./records.js";
20
20
  import { describeFeatures, featuresWithRuns, findWorktreeRun, listFeatures, resolveFeatureArg } from "./features.js";
21
21
  import { checkChatCwd, normalizeFeatureDir, preflight, type PreflightResult, specProfile, verifyPhaseProblem } from "./preflight.js";
22
- import { loadRuntimeFactory, wordsFor } from "./runtime-loader.js";
22
+ import { adapterFor, loadRuntimeFactory, wordsFor } from "./runtime-loader.js";
23
23
  import type { AgentRuntime } from "./runtime.js";
24
24
  import { remainingLine, typical, typicalLine } from "./estimate.js";
25
25
  import { ensurePipelineDir, hashFile, isAlive, pipelineDir, readState, statePath } from "./state.js";
@@ -382,16 +382,21 @@ if (args.worktree) {
382
382
  ensurePipelineDir(checked.repo, checked.featureDir);
383
383
  const logPath = path.join(pipelineDir(checked.repo, checked.featureDir), "pipeline.log");
384
384
  const out = fs.openSync(logPath, "a");
385
+ // A platform that keeps the chat's machine only for one turn (PlatformAdapter.runsInChat): the
386
+ // engine runs in this command, and what it tells the chat is written here, in chat.log.
387
+ const inChat = adapterFor(loaded.config).runsInChat === true;
388
+ const chatOut = path.join(pipelineDir(checked.repo, checked.featureDir), "chat.log");
389
+ if (inChat) fs.writeFileSync(chatOut, "");
385
390
 
386
391
  // Re-use this process's loader flags (tsx registers itself through execArgv).
387
392
  const child = spawn(process.execPath, [...process.execArgv, path.join(ENGINE_DIR, "src", "main.ts"), ...launchArgv(args)], {
388
393
  cwd: checked.repo,
389
- detached: true,
394
+ detached: !inChat,
390
395
  windowsHide: true,
391
396
  stdio: ["ignore", out, out],
392
- env: process.env,
397
+ env: inChat ? { ...process.env, LAOSHI_CHAT_OUT: chatOut } : process.env,
393
398
  });
394
- child.unref();
399
+ if (!inChat) child.unref();
395
400
 
396
401
  const modeText: Record<string, string> = {
397
402
  fresh: "新启动",
@@ -414,8 +419,8 @@ const profile =
414
419
  console.log(
415
420
  [
416
421
  checked.entersVerify
417
- ? `已在后台开始测试验证阶段(${PROFILE_LABELS[profile]}档),进程 ${child.pid}。提测说明:${checked.featureDir}/handoff.md`
418
- : `已在后台启动(${args.approve && checked.mode.kind === "resume-reuse" ? "已确认方案,开始写代码" : modeText[checked.mode.kind]},${PROFILE_LABELS[profile]}档${phaseMode === "continuous" ? "" : `,执行方式:${PHASE_MODE_LABELS[phaseMode]}`}),进程 ${child.pid}。`,
422
+ ? `已${inChat ? "" : "在后台"}开始测试验证阶段(${PROFILE_LABELS[profile]}档),进程 ${child.pid}。提测说明:${checked.featureDir}/handoff.md`
423
+ : `已${inChat ? "" : "在后台"}启动(${args.approve && checked.mode.kind === "resume-reuse" ? "已确认方案,开始写代码" : modeText[checked.mode.kind]},${PROFILE_LABELS[profile]}档${phaseMode === "continuous" ? "" : `,执行方式:${PHASE_MODE_LABELS[phaseMode]}`}),进程 ${child.pid}。`,
419
424
  !checked.entersVerify && phaseMode === "gated"
420
425
  ? `研发完成(写好提测说明)后会停下来通知这个对话,等待测试验证${args.verifyAt ? `;已安排在 ${describeTime(new Date(args.verifyAt))} 之后自动开始测试验证` : ""}。`
421
426
  : !checked.entersVerify && phaseMode === "develop-only"
@@ -441,3 +446,36 @@ console.log(
441
446
  .filter(Boolean)
442
447
  .join("\n"),
443
448
  );
449
+
450
+ if (inChat) process.exit(await followInChat(child, chatOut));
451
+
452
+ /**
453
+ * Shows what the engine tells the chat while it runs in this command, until it stops (finished,
454
+ * or waiting for people). The chat reads this command's output; the platform ends the machine
455
+ * with the chat's turn, so the chat keeps waiting for this command rather than ending its turn.
456
+ */
457
+ async function followInChat(engine: import("node:child_process").ChildProcess, file: string): Promise<number> {
458
+ console.log("流水线在这条命令里运行,进展会显示在下面;命令结束前请不要结束这一轮对话(对话结束时运行会中断,之后用继续命令接着做)。");
459
+ let shown = 0;
460
+ const show = () => {
461
+ try {
462
+ const text = fs.readFileSync(file, "utf8");
463
+ if (text.length > shown) {
464
+ process.stdout.write(text.slice(shown));
465
+ shown = text.length;
466
+ }
467
+ } catch {
468
+ // Not written yet.
469
+ }
470
+ };
471
+ const code = await new Promise<number>((resolve) => {
472
+ const timer = setInterval(show, 1000);
473
+ engine.on("exit", (c) => {
474
+ clearInterval(timer);
475
+ resolve(c ?? 1);
476
+ });
477
+ });
478
+ show();
479
+ console.log(code === 0 ? "流水线已停下(上面是最后的消息)。" : `流水线进程以退出码 ${code} 结束,详情见运行日志:${logPath}`);
480
+ return code;
481
+ }
@@ -29,7 +29,19 @@ export function kitHome(env: NodeJS.ProcessEnv = process.env): string {
29
29
  return homeOf(env).dir;
30
30
  }
31
31
 
32
- export type HomeSource = "LAOSHI_HOME" | "REQ_KIT_HOME" | "default" | "legacy";
32
+ export type HomeSource = "LAOSHI_HOME" | "REQ_KIT_HOME" | "default" | "legacy" | "program";
33
+
34
+ /**
35
+ * The install root this program was installed into with npm (`npm install --prefix <root>/npm`,
36
+ * as the one-step install does when the global directory is not writable): the root, when it has
37
+ * an install-level config. Platforms whose home directory does not last (a new machine per chat
38
+ * turn) find the install root this way without LAOSHI_HOME.
39
+ */
40
+ export function programHome(kitRoot: string = KIT_ROOT): string | null {
41
+ const m = /^(.*)[\\/]npm[\\/](?:lib[\\/])?node_modules[\\/]/.exec(kitRoot);
42
+ if (!m) return null;
43
+ return fs.existsSync(path.join(m[1], "config.json")) ? m[1] : null;
44
+ }
33
45
 
34
46
  /** The install root and how it was chosen (for doctor). */
35
47
  export function homeOf(env: NodeJS.ProcessEnv = process.env, home: string = os.homedir()): { dir: string; source: HomeSource } {
@@ -37,6 +49,8 @@ export function homeOf(env: NodeJS.ProcessEnv = process.env, home: string = os.h
37
49
  if (laoshi) return { dir: path.resolve(laoshi), source: "LAOSHI_HOME" };
38
50
  const legacyEnv = env.REQ_KIT_HOME?.trim();
39
51
  if (legacyEnv) return { dir: path.resolve(legacyEnv), source: "REQ_KIT_HOME" };
52
+ const installedInto = programHome();
53
+ if (installedInto) return { dir: installedInto, source: "program" };
40
54
  const preferred = path.join(home, ".laoshi");
41
55
  const legacy = path.join(home, ".req-kit");
42
56
  if (!fs.existsSync(preferred) && fs.existsSync(path.join(legacy, "config.json"))) return { dir: legacy, source: "legacy" };
@@ -4,6 +4,7 @@
4
4
  import { pendingHumanReview, writeHumanReview } from "./code-review.js";
5
5
  import { execFileSync } from "node:child_process";
6
6
  import fs from "node:fs";
7
+ import os from "node:os";
7
8
  import path from "node:path";
8
9
  import { approveCommand, LAUNCHER, parseLaunchArgs, resumeCommand, statusCommand, verifyCommand } from "./cli-args.js";
9
10
  import { dequeuedMessage, queuedMessage, watchdogPrompt } from "./messages.js";
@@ -137,6 +138,7 @@ async function main(): Promise<number> {
137
138
  // laoshi M2d: which adapter ran it, for troubleshooting.
138
139
  adapter: { id: config.platform.adapter },
139
140
  pid: process.pid,
141
+ host: os.hostname(),
140
142
  startedAt: now,
141
143
  updatedAt: now,
142
144
  results: {},
@@ -171,6 +173,7 @@ async function main(): Promise<number> {
171
173
  // laoshi M2d: which adapter ran it, for troubleshooting.
172
174
  adapter: { id: config.platform.adapter },
173
175
  pid: process.pid,
176
+ host: os.hostname(),
174
177
  results: startOver ? {} : mode.previous.results,
175
178
  stopReason: null,
176
179
  outcome: null,
@@ -0,0 +1,56 @@
1
+ // `laoshi permission <需求> approve|deny [理由]`: answers a step agent's pending approval on platforms
2
+ // whose approvals are answered through laoshi (AgentRuntime.answerPermission), e.g. where the chat
3
+ // asks the person and the engine runs in the chat's command. `laoshi` then continues the run.
4
+ import { locate } from "./api.js";
5
+ import { DEFAULT_CONFIG, loadConfig, type PipelineConfig } from "./config.js";
6
+ import { defaultConfigPath } from "./locations.js";
7
+ import { loadRuntimeFactory, wordsFor } from "./runtime-loader.js";
8
+ import { engineAlive, readState, statePath } from "./state.js";
9
+
10
+ async function main(argv: string[]): Promise<number> {
11
+ const [feature, answer, ...reasonWords] = argv;
12
+ if (!feature || !["approve", "deny"].includes(answer ?? "")) {
13
+ console.error("用法:laoshi permission <需求> approve|deny [理由]");
14
+ return 2;
15
+ }
16
+ const { repo, featureDir } = locate(process.cwd(), feature);
17
+ const state = readState(statePath(repo, featureDir));
18
+ const waiting = state?.waitingPermission;
19
+ if (!waiting) {
20
+ console.error(`${featureDir} 现在没有步骤在等待批准。`);
21
+ return 1;
22
+ }
23
+ let config: PipelineConfig;
24
+ try {
25
+ config = loadConfig(defaultConfigPath(), repo).config;
26
+ } catch {
27
+ config = DEFAULT_CONFIG;
28
+ }
29
+ const runtime = await (await loadRuntimeFactory())({ config, log: () => undefined });
30
+ try {
31
+ if (!runtime.answerPermission) {
32
+ console.error(`在${wordsFor(config).name}上请按流水线的提示在它自己的界面里批准或拒绝。`);
33
+ return 1;
34
+ }
35
+ const approve = answer === "approve";
36
+ const reason = reasonWords.join(" ").trim() || (approve ? "需求方批准" : "需求方拒绝");
37
+ await runtime.answerPermission(waiting.agentId, null, approve, reason);
38
+ console.log(`已${approve ? "批准" : "拒绝"}「${waiting.stepTitle}」步骤等待的操作:${waiting.requests.join(";")}`);
39
+ // A run still going picks the answer up by itself; exit code 3 tells `laoshi` not to start another.
40
+ if (state.status === "running" && engineAlive(state)) {
41
+ console.log("流水线还在运行,会自动接着做。");
42
+ return 3;
43
+ }
44
+ } finally {
45
+ await runtime.close().catch(() => undefined);
46
+ }
47
+ return 0;
48
+ }
49
+
50
+ main(process.argv.slice(2)).then(
51
+ (code) => process.exit(code),
52
+ (error: Error) => {
53
+ console.error(`没有处理:${error.message}`);
54
+ process.exit(1);
55
+ },
56
+ );
@@ -61,6 +61,11 @@ export interface PlatformAdapter {
61
61
  * when the platform uses laoshi's builtin services.
62
62
  */
63
63
  skillSetup?: string;
64
+ /**
65
+ * The platform keeps a chat's machine only while the chat's turn lasts, so the engine cannot run
66
+ * in the background: it runs in the chat's command, which shows what it tells the chat.
67
+ */
68
+ runsInChat?: boolean;
64
69
  /** Heading of the platform section in `doctor`. */
65
70
  doctorTitle: string;
66
71
  /** The platform section of `doctor` (connection, versions, profiles), when not --offline. */
@@ -15,7 +15,7 @@ import {
15
15
  } from "./config.js";
16
16
  import { gitInfo } from "./git.js";
17
17
  import { samePath } from "./paths.js";
18
- import { currentLockHolder, isAlive, type PipelineState, readState, statePath } from "./state.js";
18
+ import { currentLockHolder, engineAlive, readState, statePath, type PipelineState } from "./state.js";
19
19
  import { originFromEnv, wordsFor } from "./runtime-loader.js";
20
20
 
21
21
  export interface LaunchArgs {
@@ -261,7 +261,7 @@ export function preflight(
261
261
  throw new PreflightError(hint);
262
262
  } else if (args.reviewFix) {
263
263
  // 1.14: the person's code review (plugin) asked for changes; the spec itself did not change.
264
- if (previous.status === "running" && isAlive(previous.pid)) throw new PreflightError("流水线正在运行,等它结束后再处理人工评审意见。");
264
+ if (previous.status === "running" && engineAlive(previous)) throw new PreflightError("流水线正在运行,等它结束后再处理人工评审意见。");
265
265
  const pending = pendingHumanReview(path.join(repo, featureDir));
266
266
  if (!pending) throw new PreflightError("没有待处理的人工代码评审意见(在插件的代码审查页上提交\"退回修改\"后才有)。");
267
267
  mode = { kind: "resume-from-design", previous, reason: `人工代码评审提出了 ${pending.items.length} 条修改意见(见 code-review.md 的"人工评审"一节和 changes.md),需求说明不变,从方案设计开始只处理这些意见` };
@@ -2,6 +2,7 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { pathToFileURL } from "node:url";
4
4
  import { dshAdapter } from "../../adapters/dsh/adapter.js";
5
+ import { mogaoAdapter } from "../../adapters/mogao/adapter.js";
5
6
  import { paseoAdapter } from "../../adapters/paseo/adapter.js";
6
7
  import { withBuiltins } from "./builtin/index.js";
7
8
  import type { AgentProfile, PipelineConfig } from "./config.js";
@@ -15,6 +16,7 @@ import { defaultConfigPath } from "./locations.js";
15
16
  const ADAPTERS: Record<string, PlatformAdapter> = {
16
17
  paseo: paseoAdapter,
17
18
  dsh: dshAdapter,
19
+ mogao: mogaoAdapter,
18
20
  };
19
21
 
20
22
  export const ADAPTER_IDS = Object.keys(ADAPTERS);
@@ -175,6 +175,11 @@ export interface AgentRuntime {
175
175
  /** A platform schedule that starts a fresh agent on `cron` (e.g. to run a command weekly). */
176
176
  scheduleNewAgent(input: ScheduledAgent): Promise<string | null>;
177
177
  cancelSchedule(id: string): Promise<void>;
178
+ /**
179
+ * Answers a step agent's pending approval on the platform's behalf (platforms whose approvals
180
+ * cannot be answered in their own interface); `requestId` null for the one now pending.
181
+ */
182
+ answerPermission?(agentId: string, requestId: string | null, approve: boolean, reason: string): Promise<void>;
178
183
  close(): Promise<void>;
179
184
  }
180
185