@mininglamp-oss/octo-runtime 1.1.8 → 1.1.10

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 (164) hide show
  1. package/README.md +1 -1
  2. package/apps/cli/README.md +3 -1
  3. package/{node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-configuration.d.ts → apps/cli/dist/adapter-configuration.d.ts} +1 -0
  4. package/{node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-configuration.js → apps/cli/dist/adapter-configuration.js} +1 -0
  5. package/apps/cli/dist/adapter-configurations.d.ts +1 -1
  6. package/apps/cli/dist/adapter-configurations.js +1 -1
  7. package/apps/cli/dist/adapters.d.ts +7 -0
  8. package/apps/cli/dist/adapters.js +51 -0
  9. package/apps/cli/dist/build-info.json +2 -2
  10. package/apps/cli/dist/command-tree.js +3 -1
  11. package/apps/cli/dist/help.js +1 -1
  12. package/apps/cli/dist/index.js +4 -0
  13. package/apps/cli/dist/main.d.ts +2 -0
  14. package/apps/cli/dist/main.js +10 -12
  15. package/apps/cli/dist/manifest.json +0 -5
  16. package/apps/cli/dist/output.js +7 -9
  17. package/apps/cli/dist/playboard-interrupt.d.ts +6 -0
  18. package/apps/cli/dist/playboard-interrupt.js +86 -0
  19. package/apps/cli/dist/playboard.d.ts +2 -0
  20. package/apps/cli/dist/playboard.js +20 -12
  21. package/dist/public/executor-kernel.d.ts +2 -3
  22. package/dist/public/executor-kernel.js +1 -2
  23. package/dist/public/protocol.d.ts +1 -1
  24. package/dist/public/protocol.js +1 -1
  25. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  26. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  27. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  28. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  29. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  30. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.d.ts +1 -0
  31. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +200 -106
  32. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/async-questions.d.ts +27 -0
  33. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/async-questions.js +205 -0
  34. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.d.ts +30 -0
  35. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.js +223 -0
  36. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  37. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-V5W6ZTYC.js → chunk-FGFEM7JP.js} +1 -1
  38. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-CFKMMCO6.js → chunk-R3PDZLX5.js} +3 -3
  39. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-LO34KB7D.js → chunk-TSRZVLIG.js} +1 -1
  40. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/dsh-sdk-NOTICE.txt +2 -2
  41. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +1 -1
  42. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +5 -5
  43. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +2 -2
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +2 -2
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
  46. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
  47. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  48. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  49. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  50. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/gateway.d.ts +3 -0
  51. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/gateway.js +57 -13
  52. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +3 -2
  53. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +4 -2
  54. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  55. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  56. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
  57. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
  58. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/approval.js +2 -0
  59. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/reasoning.js +1 -2
  60. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.d.ts +1 -1
  61. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.js +12 -30
  62. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
  63. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configuration.d.ts +3 -0
  64. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configuration.js +125 -0
  65. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.d.ts +1 -1
  66. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.js +1 -1
  67. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.d.ts +7 -0
  68. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +51 -0
  69. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  70. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +3 -1
  71. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/help.js +1 -1
  72. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/index.js +4 -0
  73. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.d.ts +2 -0
  74. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +10 -12
  75. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +0 -5
  76. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +7 -9
  77. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard-interrupt.d.ts +6 -0
  78. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard-interrupt.js +86 -0
  79. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.d.ts +2 -0
  80. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +20 -12
  81. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +23 -24
  82. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/launchd.d.ts +2 -2
  83. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/launchd.js +12 -11
  84. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
  85. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/experience.js +2 -1
  86. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +8 -7
  87. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +33 -11
  88. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.js +9 -2
  89. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +6 -3
  90. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  91. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.d.ts +30 -0
  92. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.js +199 -0
  93. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.d.ts +2 -0
  94. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.js +2 -0
  95. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/execution-source.d.ts +17 -0
  96. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/execution-source.js +21 -0
  97. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.d.ts +9 -9
  98. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.js +3 -3
  99. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +2 -6
  100. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +3 -6
  101. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.d.ts +14 -13
  102. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.js +84 -187
  103. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +5 -8
  104. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +77 -53
  105. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.d.ts +5 -1
  106. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.js +15 -3
  107. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -12
  108. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +6 -2
  109. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +2 -0
  110. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.js +14 -0
  111. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js +4 -0
  112. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/interaction-card.js +2 -1
  113. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/session-command.d.ts +9 -0
  114. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/session-command.js +71 -0
  115. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
  116. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/im-channel.js +14 -0
  117. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
  118. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/assets/{index-B127MhT-.js → index-BLMf2Etg.js} +2 -4
  119. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/index.html +1 -1
  120. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
  121. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/context-loader.js +1 -1
  122. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
  123. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.d.ts +1 -0
  124. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.js +1 -0
  125. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.d.ts +2 -0
  126. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +4 -1
  127. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +3 -0
  128. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +63 -12
  129. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +110 -20
  130. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +7 -4
  131. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +28 -6
  132. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +2 -0
  133. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/questions.d.ts +9 -0
  134. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/questions.js +84 -0
  135. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.d.ts +1 -1
  136. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +11 -5
  137. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  138. package/package.json +26 -28
  139. package/packages/octo-runtime-protocol/schema/protocol.schema.json +157 -41
  140. package/apps/cli/dist/worker.d.ts +0 -1
  141. package/apps/cli/dist/worker.js +0 -18
  142. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/app-server.d.ts +0 -63
  143. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/app-server.js +0 -846
  144. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.d.ts +0 -54
  145. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.js +0 -154
  146. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +0 -15
  147. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/worker.d.ts +0 -1
  148. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/worker.js +0 -18
  149. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/heartbeat.d.ts +0 -16
  150. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/heartbeat.js +0 -59
  151. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/manifest-adapters.d.ts +0 -6
  152. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/manifest-adapters.js +0 -88
  153. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/module-specifier.d.ts +0 -1
  154. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/module-specifier.js +0 -2
  155. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.d.ts +0 -42
  156. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.js +0 -292
  157. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/rpc.d.ts +0 -62
  158. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/rpc.js +0 -661
  159. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runner.d.ts +0 -2
  160. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runner.js +0 -5
  161. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/serve.d.ts +0 -10
  162. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/serve.js +0 -96
  163. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.d.ts +0 -15
  164. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.js +0 -279
@@ -1,10 +1,10 @@
1
+ import { loadCliAdapters } from "./adapters.js";
1
2
  import { runExtraCommand, commandError } from "./extra-commands.js";
2
3
  import net from "node:net";
3
4
  import { randomUUID } from "node:crypto";
4
5
  import { once } from "node:events";
5
6
  import { lstat, mkdir } from "node:fs/promises";
6
7
  import { join, resolve } from "node:path";
7
- import { fileURLToPath } from "node:url";
8
8
  import { attachKernel, acknowledgeOrphanCleanup, inspectOrphanCleanup, createKernelService } from "@mininglamp-oss/octo-runtime-executor-kernel";
9
9
  import { componentEndpoint, createExtraService } from "@mininglamp-oss/octo-runtime-host-sdk";
10
10
  import { getExtra, readExtra, setExtra } from "./extras.js";
@@ -179,6 +179,7 @@ export async function runCli(args, dependencies = {}) {
179
179
  return 0;
180
180
  }
181
181
  if (positional[0] === "playboard" && positional.length === 1) {
182
+ dependencies.onPlayboardRun?.();
182
183
  const { runPlayboard } = await import("./playboard.js");
183
184
  return runPlayboard({
184
185
  home,
@@ -186,7 +187,8 @@ export async function runCli(args, dependencies = {}) {
186
187
  manifest: flags.manifest,
187
188
  input,
188
189
  output: dependencies.output,
189
- env: dependencies.env
190
+ env: dependencies.env,
191
+ handleSignals: !dependencies.onPlayboardRun
190
192
  });
191
193
  }
192
194
  if (positional[0] === "adapter" && positional[1] === "list" && positional.length === 2) {
@@ -254,19 +256,15 @@ export async function runCli(args, dependencies = {}) {
254
256
  logging: { directory: join(home, "logs") },
255
257
  endpoint,
256
258
  stateDirectory: kernelStateDirectory,
257
- workerEntrypoint: fileURLToPath(new URL("./worker.js", import.meta.url)),
258
- adapterModules: resolveAdapterModules(manifest),
259
- adapterConfigurations: await readCliAdapterConfigurations(paths.profileRoot, config?.adapters, manifest, dependencies.env ?? process.env),
260
- env: {
261
- ...(dependencies.env ?? process.env),
262
- OCTO_RUNTIME_HOME: home,
263
- OCTO_RUNTIME_CLI_PROFILE_ROOT: paths.profileRoot,
264
- OCTO_RUNTIME_CLI_SYNC_OPENCLAW_TOOLS: "1",
265
- OCTO_RUNTIME_LOGS_DIRECTORY: join(home, "logs")
266
- }
259
+ adapters: await loadCliAdapters(resolveAdapterModules(manifest), {
260
+ profileRoot: paths.profileRoot,
261
+ syncOpenClawTools: true
262
+ }),
263
+ adapterConfigurations: await readCliAdapterConfigurations(paths.profileRoot, config?.adapters, manifest, dependencies.env ?? process.env)
267
264
  });
268
265
  }
269
266
  else {
267
+ // CLI 的 Gateway 等 Extra 独立托管;ExtraService 内部 attach 已有 Kernel,不创建执行内核。
270
268
  const registration = await readExtra(paths, component, manifest);
271
269
  const module = registration.enabled === false
272
270
  ? { name: registration.name, default: () => () => { } }
@@ -61,11 +61,6 @@
61
61
  "module": "@mininglamp-oss/octo-runtime-adapter-qoderclicn",
62
62
  "export": "qoderCliCnAdapter"
63
63
  },
64
- {
65
- "type": "zcode-gui",
66
- "module": "@mininglamp-oss/octo-runtime-adapter-zcode-gui",
67
- "export": "zcodeGuiAdapter"
68
- },
69
64
  {
70
65
  "type": "antigravity",
71
66
  "module": "@mininglamp-oss/octo-runtime-adapter-antigravity",
@@ -14,24 +14,22 @@ export function formatStatus(name, snapshot) {
14
14
  const runtime = record(snapshot.runtime);
15
15
  const business = record(runtime.status);
16
16
  const ipc = runtime.available === false ? "unavailable" : "ready";
17
+ // 查询失败的 enabled=false 只是兼容占位值,不代表已确认关闭自启。
18
+ const managerQueryFailed = service.state === "unknown" && service.detail && /^[A-Z][A-Z0-9_]+$/.test(service.detail);
19
+ const autostart = managerQueryFailed ? "unknown" : service.enabled ? "on" : "off";
17
20
  const lines = [
18
- `${name} service: ${service.state} autostart: ${service.enabled ? "on" : "off"} IPC: ${ipc}`,
21
+ `${name} service: ${service.state} autostart: ${autostart} IPC: ${ipc}`,
19
22
  ` Manager: ${service.manager}${service.pid ? ` PID: ${service.pid}` : runtime.pid ? ` PID: ${text(runtime.pid)}` : ""}`
20
23
  ];
21
24
  if (runtime.execution_ready !== undefined)
22
- lines.push(` Worker: ${runtime.execution_ready ? "ready" : "unavailable"}`);
23
- const recovery = record(record(runtime.worker).recovery);
24
- if (recovery.code) {
25
- lines.push(` Recovery: ${text(recovery.stage)} (${text(recovery.code)})${recovery.retry_at ? ` Next retry: ${text(recovery.retry_at)}` : ""}`);
26
- lines.push(" Diagnostics: octo-runtime executor-kernel logs --follow (use the same --home)");
27
- }
25
+ lines.push(` Execution: ${runtime.execution_ready ? "ready" : "unavailable"}`);
28
26
  if (runtime.available === false)
29
27
  lines.push(` Reason: ${text(record(runtime.error).code ?? "COMPONENT_UNAVAILABLE")}`);
30
28
  if (service.lastExitCode !== undefined && service.lastExitCode !== 0)
31
29
  lines.push(` Last exit: ${service.lastExitCode}`);
32
30
  if (service.definitionPath)
33
31
  lines.push(` Definition: ${service.definitionPath}`);
34
- if (service.state === "unknown" && service.detail && /^[A-Z][A-Z0-9_]+$/.test(service.detail))
32
+ if (managerQueryFailed)
35
33
  lines.push(` Manager status: ${service.detail}`);
36
34
  const summarize = (value, depth = 0) => {
37
35
  if (Array.isArray(value))
@@ -125,7 +123,7 @@ export function describeError(error, fallback = "COMMAND_FAILED") {
125
123
  EXTRA_MODULE_MIGRATION_REQUIRED: "The saved module differs from manifest.json. Review both declarations, then save matching module text or omit module from the Extra configuration.",
126
124
  MANIFEST_INVALID: "Check manifest.json: version must be 1 and adapters/extras must be valid arrays without duplicate keys.",
127
125
  MANAGER_UNAVAILABLE: "Run doctor and check the current user's native service manager.",
128
- COMPONENT_UNAVAILABLE: "Check component status and the service logs; the IPC or worker is not ready.",
126
+ COMPONENT_UNAVAILABLE: "Check component status and the service logs; the IPC endpoint or execution service is not ready.",
129
127
  SERVICE_PROCESS_EXITED: "The service exited unexpectedly. Check its logs and configuration.",
130
128
  SERVICE_INITIALIZATION_FAILED: "Check the component configuration, manifest and service logs.",
131
129
  SERVICE_DISABLED: "Enable this component with install --autostart=true, then start it."
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 仅 CLI 可执行入口在确认 playboard 命令后安装,监听持续到本进程退出。
3
+ * 人工停止不等待 import、Run 终态或 Kernel close;SDK 不使用此策略。
4
+ * 命令返回但清理失败时仍须能停止残留进程树;信号监听本身不维持事件循环。
5
+ */
6
+ export declare function installPlayboardInterrupt(): void;
@@ -0,0 +1,86 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { writeSync } from "node:fs";
3
+ /**
4
+ * 仅 CLI 可执行入口在确认 playboard 命令后安装,监听持续到本进程退出。
5
+ * 人工停止不等待 import、Run 终态或 Kernel close;SDK 不使用此策略。
6
+ * 命令返回但清理失败时仍须能停止残留进程树;信号监听本身不维持事件循环。
7
+ */
8
+ export function installPlayboardInterrupt() {
9
+ let stopping = false;
10
+ const stop = (code) => {
11
+ if (stopping)
12
+ return;
13
+ stopping = true;
14
+ diagnostic("PLAYBOARD_FORCE_STOP: execution and cleanup are unconfirmed");
15
+ try {
16
+ if (process.platform === "win32") {
17
+ // 保持 leader 存活,由系统按 PID 回收树;不能先退出再查找后代。
18
+ execFileSync("taskkill.exe", ["/PID", String(process.pid), "/T", "/F"], {
19
+ stdio: "ignore",
20
+ windowsHide: true,
21
+ timeout: 2000
22
+ });
23
+ }
24
+ else {
25
+ // Adapter 可创建独立组,不能只杀当前组,更不能按 node/应用名匹配。
26
+ // 选择本次 CLI 的可识别后代,先杀最深层再退出自身,不触及兄弟服务。
27
+ const listing = execFileSync("/bin/ps", ["-axo", "pid=,ppid="], {
28
+ encoding: "utf8",
29
+ timeout: 2000,
30
+ maxBuffer: 8 * 1024 * 1024
31
+ });
32
+ const children = new Map();
33
+ for (const line of listing.split("\n")) {
34
+ const match = /^\s*(\d+)\s+(\d+)\s*$/.exec(line);
35
+ if (!match)
36
+ continue;
37
+ const pid = Number(match[1]), parent = Number(match[2]);
38
+ if (pid <= 1 || pid === process.pid)
39
+ continue;
40
+ const group = children.get(parent) ?? [];
41
+ group.push(pid);
42
+ children.set(parent, group);
43
+ }
44
+ const owned = [process.pid];
45
+ const seen = new Set(owned);
46
+ for (let i = 0; i < owned.length; i++)
47
+ for (const pid of children.get(owned[i]) ?? [])
48
+ if (!seen.has(pid)) {
49
+ seen.add(pid);
50
+ owned.push(pid);
51
+ }
52
+ let failed = false;
53
+ for (const pid of owned.slice(1).reverse()) {
54
+ try {
55
+ process.kill(pid, "SIGKILL");
56
+ }
57
+ catch (error) {
58
+ if (error.code !== "ESRCH")
59
+ failed = true;
60
+ }
61
+ }
62
+ if (failed)
63
+ diagnostic("PLAYBOARD_TREE_STOP_UNCONFIRMED");
64
+ }
65
+ }
66
+ catch {
67
+ // 查询/终止失败不能继续吞掉人工退出;不声称未知或已重新归属的后代已停止。
68
+ diagnostic("PLAYBOARD_TREE_STOP_UNCONFIRMED");
69
+ }
70
+ finally {
71
+ process.exit(code);
72
+ }
73
+ };
74
+ const interrupt = () => stop(130);
75
+ const terminate = () => stop(143);
76
+ process.on("SIGINT", interrupt);
77
+ process.on("SIGTERM", terminate);
78
+ }
79
+ function diagnostic(message) {
80
+ try {
81
+ writeSync(2, `${message}\n`);
82
+ }
83
+ catch {
84
+ // stderr 已关闭时仍执行定向强退。
85
+ }
86
+ }
@@ -1,4 +1,6 @@
1
1
  export interface PlayboardOptions {
2
+ /** CLI 可执行入口已接管强退时关闭本函数的协作信号监听;不在此退出宿主。 */
3
+ handleSignals?: boolean;
2
4
  input: NodeJS.ReadableStream;
3
5
  output?: (line: string) => void | Promise<void>;
4
6
  env?: NodeJS.ProcessEnv;
@@ -1,9 +1,9 @@
1
+ import { loadCliAdapters } from "./adapters.js";
1
2
  import { defaultRuntimeHome, runtimePaths, readJsonFile } from "./state.js";
2
3
  import { loadCliManifest } from "./module-manifest.js";
3
4
  import { readCliAdapterConfigurations } from "./adapter-configurations.js";
4
5
  import { resolveAdapterModules } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
5
6
  import { createKernelService } from "@mininglamp-oss/octo-runtime-executor-kernel";
6
- import { fileURLToPath } from "node:url";
7
7
  import { componentEndpoint } from "@mininglamp-oss/octo-runtime-host-sdk";
8
8
  import { mkdtemp, rm } from "node:fs/promises";
9
9
  import { tmpdir } from "node:os";
@@ -45,6 +45,12 @@ export async function runPlayboard(options) {
45
45
  if (!value || typeof value !== "object" || Array.isArray(value))
46
46
  throw new TypeError("playboard stdin must contain one JSON input object");
47
47
  const input = identifyInvokeInput(value);
48
+ // full_access 是本 CLI 宿主的缺省策略;显式策略(包括非法值)交给共享入口校验,
49
+ // 不覆盖 Context,也不改变 SDK 的 ask 默认值。
50
+ if (!Object.hasOwn(input, "approvalMode") &&
51
+ !(Array.isArray(input.contexts?.items) &&
52
+ input.contexts.items.some((item) => item?.namespace === "octo.security" && item.name === "approval_policy")))
53
+ input.approvalMode = "full_access";
48
54
  const profile = options.profile ?? "default";
49
55
  const home = options.home ?? defaultRuntimeHome(options.env);
50
56
  runtimePaths(home, profile); // Validate the selected profile before starting resources.
@@ -70,8 +76,10 @@ export async function runPlayboard(options) {
70
76
  };
71
77
  if (!options.output)
72
78
  process.stdout.on("error", onOutputError);
73
- process.once("SIGINT", onInterrupt);
74
- process.once("SIGTERM", onTerminate);
79
+ if (options.handleSignals !== false) {
80
+ process.once("SIGINT", onInterrupt);
81
+ process.once("SIGTERM", onTerminate);
82
+ }
75
83
  let kernel;
76
84
  let outcome;
77
85
  let primaryFailure;
@@ -82,13 +90,10 @@ export async function runPlayboard(options) {
82
90
  const configuration = await readJsonFile(paths.profileConfig);
83
91
  kernel = createKernelService({
84
92
  endpoint: process.platform === "win32" ? componentEndpoint(temporary) : join(temporary, "k.sock"),
85
- workerEntrypoint: fileURLToPath(new URL("./worker.js", import.meta.url)),
86
- adapterModules: resolveAdapterModules(manifest),
87
- env: {
88
- ...(options.env ?? process.env),
89
- OCTO_RUNTIME_CLI_PROFILE_ROOT: paths.profileRoot,
90
- OCTO_RUNTIME_CLI_SYNC_OPENCLAW_TOOLS: "0"
91
- },
93
+ adapters: await loadCliAdapters(resolveAdapterModules(manifest), {
94
+ profileRoot: paths.profileRoot,
95
+ syncOpenClawTools: false
96
+ }),
92
97
  adapterConfigurations: await readCliAdapterConfigurations(paths.profileRoot, configuration?.adapters, manifest, options.env ?? process.env)
93
98
  });
94
99
  await kernel.initialize({ signal: controller.signal });
@@ -98,8 +103,11 @@ export async function runPlayboard(options) {
98
103
  if (("kind" in frame &&
99
104
  frame.kind === "control" &&
100
105
  frame.control.type === "interaction" &&
101
- frame.control.status === "pending") ||
102
- (!("kind" in frame) && frame.type === "interaction.requested")) {
106
+ frame.control.status === "pending" &&
107
+ frame.control.responseRequired !== false) ||
108
+ (!("kind" in frame) &&
109
+ frame.type === "interaction.requested" &&
110
+ frame.payload.responseRequired !== false)) {
103
111
  throw new Error("PLAYBOARD_INTERACTION_REQUIRED: one-shot stdin cannot answer provider interactions");
104
112
  }
105
113
  if ("kind" in frame &&
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-cli",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,29 +9,28 @@
9
9
  "types": "./dist/index.d.ts",
10
10
  "dependencies": {
11
11
  "commander": "15.0.0",
12
- "@mininglamp-oss/octo-runtime-adapter-dsh": "1.1.8",
13
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.8",
12
+ "@mininglamp-oss/octo-runtime-adapter-dsh": "1.1.10",
13
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.10",
14
14
  "json5": "2.2.3",
15
- "@mininglamp-oss/octo-runtime-extra-channel-gateway": "1.1.8",
16
- "@mininglamp-oss/octo-runtime-host-sdk": "1.1.8",
17
- "@mininglamp-oss/octo-runtime-adapter-openclaw": "1.1.8",
18
- "@mininglamp-oss/octo-runtime-cross-service": "1.1.8",
19
- "@mininglamp-oss/octo-runtime-protocol": "1.1.8",
20
- "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.8",
21
- "@mininglamp-oss/octo-runtime-executor-core": "1.1.8",
22
- "@mininglamp-oss/octo-runtime-adapter-antigravity": "1.1.8",
23
- "@mininglamp-oss/octo-runtime-adapter-claude-code": "1.1.8",
24
- "@mininglamp-oss/octo-runtime-adapter-codebuddy": "1.1.8",
25
- "@mininglamp-oss/octo-runtime-adapter-codex": "1.1.8",
26
- "@mininglamp-oss/octo-runtime-adapter-hermes": "1.1.8",
27
- "@mininglamp-oss/octo-runtime-adapter-grok-build": "1.1.8",
28
- "@mininglamp-oss/octo-runtime-adapter-kimi-code": "1.1.8",
29
- "@mininglamp-oss/octo-runtime-adapter-mcode": "1.1.8",
30
- "@mininglamp-oss/octo-runtime-adapter-opencode": "1.1.8",
31
- "@mininglamp-oss/octo-runtime-adapter-qodercli": "1.1.8",
32
- "@mininglamp-oss/octo-runtime-adapter-qoderclicn": "1.1.8",
33
- "@mininglamp-oss/octo-runtime-adapter-zcode-gui": "1.1.8",
34
- "@mininglamp-oss/octo-runtime-extra-channel-wecom": "1.1.8",
35
- "@mininglamp-oss/octo-runtime-extra-webui": "1.1.8"
15
+ "@mininglamp-oss/octo-runtime-extra-channel-gateway": "1.1.10",
16
+ "@mininglamp-oss/octo-runtime-host-sdk": "1.1.10",
17
+ "@mininglamp-oss/octo-runtime-adapter-openclaw": "1.1.10",
18
+ "@mininglamp-oss/octo-runtime-cross-service": "1.1.10",
19
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.10",
20
+ "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.10",
21
+ "@mininglamp-oss/octo-runtime-executor-core": "1.1.10",
22
+ "@mininglamp-oss/octo-runtime-adapter-antigravity": "1.1.10",
23
+ "@mininglamp-oss/octo-runtime-adapter-claude-code": "1.1.10",
24
+ "@mininglamp-oss/octo-runtime-adapter-codebuddy": "1.1.10",
25
+ "@mininglamp-oss/octo-runtime-adapter-codex": "1.1.10",
26
+ "@mininglamp-oss/octo-runtime-adapter-hermes": "1.1.10",
27
+ "@mininglamp-oss/octo-runtime-adapter-grok-build": "1.1.10",
28
+ "@mininglamp-oss/octo-runtime-adapter-kimi-code": "1.1.10",
29
+ "@mininglamp-oss/octo-runtime-adapter-mcode": "1.1.10",
30
+ "@mininglamp-oss/octo-runtime-adapter-opencode": "1.1.10",
31
+ "@mininglamp-oss/octo-runtime-adapter-qodercli": "1.1.10",
32
+ "@mininglamp-oss/octo-runtime-adapter-qoderclicn": "1.1.10",
33
+ "@mininglamp-oss/octo-runtime-extra-channel-wecom": "1.1.10",
34
+ "@mininglamp-oss/octo-runtime-extra-webui": "1.1.10"
36
35
  }
37
36
  }
@@ -13,14 +13,14 @@ export declare class LaunchdUserBackend implements ServiceBackend {
13
13
  constructor(options?: ServiceBackendOptions);
14
14
  /** Report whether `launchctl` can address this user's `gui/<uid>` domain; no plist is written. */
15
15
  probe(): Promise<ServiceProbe>;
16
- /** Return what launchd is actually using plus whether the installed plist differs from `spec`. */
16
+ /** 只返回已确认的原生状态与定义漂移;查询失败抛错,调用方不得视为停止或已启用。 */
17
17
  inspect(spec: ServiceSpec): Promise<ServiceStatus>;
18
18
  /**
19
19
  * Leave the LaunchAgent plist and disabled override matching `spec`.
20
20
  * A stopped job stays stopped; a loaded job is reloaded only when plist content changed.
21
21
  */
22
22
  install(spec: ServiceSpec): Promise<void>;
23
- /** Finish with no loaded LaunchAgent and no plist; Runtime home data remains untouched. */
23
+ /** 确认 job 消失后才删除 plist;查询或停止失败保留定义供重试,不修改 Home 数据。 */
24
24
  uninstall(spec: ServiceSpec): Promise<void>;
25
25
  /** Clear launchd's disabled override; this affects future activation but does not bootstrap now. */
26
26
  enable(spec: ServiceSpec): Promise<void>;
@@ -2,7 +2,7 @@
2
2
  import { mkdir } from "node:fs/promises";
3
3
  import { dirname, join } from "node:path";
4
4
  import { setTimeout as sleep } from "node:timers/promises";
5
- import { definitionDrift, escapeXml, normalizeServiceSpec, readDefinition, removeDefinition, runCommand, writeDefinition } from "./common.js";
5
+ import { assertCommandSucceeded, definitionDrift, escapeXml, normalizeServiceSpec, readDefinition, removeDefinition, runCommand, writeDefinition } from "./common.js";
6
6
  import { ServiceError } from "./errors.js";
7
7
  import { NodeCommandRunner } from "./runner.js";
8
8
  const LABEL = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
@@ -62,7 +62,7 @@ export class LaunchdUserBackend {
62
62
  };
63
63
  }
64
64
  }
65
- /** Return what launchd is actually using plus whether the installed plist differs from `spec`. */
65
+ /** 只返回已确认的原生状态与定义漂移;查询失败抛错,调用方不得视为停止或已启用。 */
66
66
  async inspect(spec) {
67
67
  const normalized = this.#normalize(spec);
68
68
  const label = launchdLabel(normalized);
@@ -112,7 +112,7 @@ export class LaunchdUserBackend {
112
112
  await this.#bootstrap(definitionPath);
113
113
  }
114
114
  }
115
- /** Finish with no loaded LaunchAgent and no plist; Runtime home data remains untouched. */
115
+ /** 确认 job 消失后才删除 plist;查询或停止失败保留定义供重试,不修改 Home 数据。 */
116
116
  async uninstall(spec) {
117
117
  const normalized = this.#normalize(spec);
118
118
  const label = launchdLabel(normalized);
@@ -191,19 +191,19 @@ export class LaunchdUserBackend {
191
191
  #target(label) {
192
192
  return `${this.#domain()}/${label}`;
193
193
  }
194
- #print(label) {
195
- return runCommand(this.#runner, this.kind, this.#launchctl, ["print", this.#target(label)], {
196
- checked: false,
197
- env: this.#environment
198
- });
194
+ /** 仅接受目标服务的明确缺失;域、权限和超时错误不能释放管理器所有权。 */
195
+ async #print(label) {
196
+ const result = await runCommand(this.#runner, this.kind, this.#launchctl, ["print", this.#target(label)], { checked: false, env: this.#environment });
197
+ const missing = new RegExp(`^Could not find service "${escapeRegExp(label)}" in domain for user gui: ${this.#uid}\\r?$`, "m");
198
+ if (result.exitCode !== 113 || !missing.test(result.stderr || result.stdout)) {
199
+ assertCommandSucceeded(result, this.kind);
200
+ }
201
+ return result;
199
202
  }
200
203
  async #disabled(label) {
201
204
  const result = await runCommand(this.#runner, this.kind, this.#launchctl, ["print-disabled", this.#domain()], {
202
- checked: false,
203
205
  env: this.#environment
204
206
  });
205
- if (result.exitCode !== 0)
206
- return false;
207
207
  const match = result.stdout.match(new RegExp(`["']?${escapeRegExp(label)}["']?\\s*=>\\s*(true|false|enabled|disabled)`));
208
208
  return match?.[1] === "true" || match?.[1] === "disabled";
209
209
  }
@@ -217,6 +217,7 @@ export class LaunchdUserBackend {
217
217
  env: this.#environment
218
218
  });
219
219
  }
220
+ /** 首次查询与停止后轮询均须确认缺失;任何查询失败都保留 plist 并传播。 */
220
221
  async #bootout(label, timeoutSeconds) {
221
222
  if ((await this.#print(label)).exitCode !== 0)
222
223
  return;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-cross-service",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "private": true,
5
5
  "description": "Native user-service lifecycle backends for Octo Runtime",
6
6
  "type": "module",
@@ -90,7 +90,8 @@ export class InvocationExperience {
90
90
  }
91
91
  if (event.type === "tool_call.update")
92
92
  output.push(...this.#finish(`tool:${event.payload.id}`, canonicalTerminalStatus(payload.status)));
93
- if (event.type === "interaction.requested")
93
+ // 异步问题等待的是用户回答,不表示 Provider 暂停执行。
94
+ if (event.type === "interaction.requested" && event.payload.delivery !== "async")
94
95
  output.push(...this.#begin(`interaction:${event.payload.interactionId}`, payload.kind === "approval" ? "waiting_approval" : "waiting_input", { type: "interaction", id: String(payload.interactionId) }));
95
96
  if (event.type === "interaction.resolved")
96
97
  output.push(...this.#finish(`interaction:${String(payload.interactionId)}`, payload.status === "resolved" ? "completed" : "cancelled"));
@@ -21,9 +21,10 @@ export interface HostedAdapterMetadata {
21
21
  unavailableReason?: string | null;
22
22
  }
23
23
  /**
24
- * The minimal contract any Octo Runtime adapter must implement.
25
- * invoke may wrap a CLI subprocess, ACP, WebSocket or an in-process
26
- * implementation, as long as it emits a canonical event stream.
24
+ * Adapter 的最小注册合同;必须声明实际支持的输出模式。
25
+ * invoke 可封装子进程、ACP、WebSocket 或进程内实现,按 context.protocolMode
26
+ * 返回 canonical 事件或 native/控制输出;native-only 不要求生成 canonical 事件。
27
+ * Adapter 负责本轮取消和资源清理,Core 在清理结束后发布执行终态。
27
28
  */
28
29
  export interface HostedAdapter {
29
30
  metadata: HostedAdapterMetadata;
@@ -43,7 +44,7 @@ export interface ExecutorShutdownResult {
43
44
  }
44
45
  /**
45
46
  * 唯一的进程内执行实现:校验输入/Adapter 输出、补齐消息生命周期、约束单个终态并传递取消。
46
- * Kernel worker 和显式进程内接入共用本类;它不拥有独立 Kernel、业务会话或 IM 投递。
47
+ * 由 Kernel 在宿主进程持有;它不拥有 RPC 端点、业务会话或 IM 投递。
47
48
  * 接入方须消费流并在退出时检查 shutdown 的 cleanup 结果;终态不能替代资源回收确认。
48
49
  */
49
50
  export declare class AgentExecutor {
@@ -67,15 +68,15 @@ export declare class AgentExecutor {
67
68
  * signal、执行环境和容量限制来自本次 environment,不从业务会话或其他 Run 继承。
68
69
  */
69
70
  invokeFrames(input: InvokeInput, environment?: InvokeEnvironment): AsyncGenerator<HostFrame>;
70
- /** Run the adapter's own environment probe; return an unchecked-available status when there is no probe. */
71
+ /** 保留 Adapter 的 this 与同步返回合同;实际异步探测完成前由 Core 持有,关闭后不再发起探测。 */
71
72
  probe(adapterType: string, options?: AdapterProbeOptions): unknown;
72
73
  /** 请求取消活动执行;true 仅表示已触发 abort,仍须消费终态并等待 Adapter 清理。 */
73
74
  cancel(invocationId: string, reason?: string): boolean;
74
- /** Route an answer only to the adapter instance that owns the active invocation. */
75
+ /** 仅将回答路由到原活动调用;终态后返回稳定失效码,不转交其他 Adapter 或轮次。 */
75
76
  respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
76
77
  respondNative(invocationId: string, response: NativeInteractionResponse): Promise<void>;
77
78
  /**
78
- * 停止接纳并取消未终结执行,在 timeoutMs 内等待 Adapter 清理;不负责业务投递收尾。
79
+ * 停止接纳并取消未终结执行,在 timeoutMs 内等待 Adapter 清理及实际 probe;不负责业务投递收尾。
79
80
  * 并发调用共用当前尝试;超时或清理失败返回 incomplete 和遗留身份,不冒充资源已回收。
80
81
  */
81
82
  shutdown(reason?: string, timeoutMs?: number): Promise<ExecutorShutdownResult>;
@@ -6,14 +6,14 @@ import { sanitizePublicValue } from "@mininglamp-oss/octo-runtime-adapter-sdk";
6
6
  export { prepareInvokeInput } from "./invoke-input.js";
7
7
  export { resolveLocalContext, localRuntimeLimits } from "./context.js";
8
8
  export { prepareRunContext } from "./execution-preparation.js";
9
- import { createInputInvoke, assertInvokeRequestSize, assertProtocolSupport, assertAdapterProtocolSupport, assertHostFrame, assertHostFrameIdentity, assertNativeInteractionResponse, resolveHostInvokeOptions, protocolError, assertCanonicalEvent, assertInteractionResponse, assertInvokeRequest, failurePayload, isStreamCapacityReason, resolveStreamLimitPolicy, streamCapacityError, isTerminal } from "@mininglamp-oss/octo-runtime-protocol";
9
+ import { createInputInvoke, assertInvokeRequestSize, assertProtocolSupport, assertAdapterProtocolSupport, assertHostFrame, assertHostFrameIdentity, assertNativeInteractionResponse, resolveHostInvokeOptions, protocolError, assertCanonicalEvent, assertInteractionResponse, assertInvokeRequest, failurePayload, isCodexLocalFailure, isStreamCapacityReason, resolveStreamLimitPolicy, streamCapacityError, isTerminal } from "@mininglamp-oss/octo-runtime-protocol";
10
10
  import { InvocationExperience } from "./experience.js";
11
11
  import { withModelContexts } from "./model-input.js";
12
12
  import { noopRuntimeLog } from "@mininglamp-oss/octo-runtime-adapter-sdk";
13
13
  import { AdapterWatchdogTimeoutError, InvocationWatchdog } from "./watchdog.js";
14
14
  /**
15
15
  * 唯一的进程内执行实现:校验输入/Adapter 输出、补齐消息生命周期、约束单个终态并传递取消。
16
- * Kernel worker 和显式进程内接入共用本类;它不拥有独立 Kernel、业务会话或 IM 投递。
16
+ * 由 Kernel 在宿主进程持有;它不拥有 RPC 端点、业务会话或 IM 投递。
17
17
  * 接入方须消费流并在退出时检查 shutdown 的 cleanup 结果;终态不能替代资源回收确认。
18
18
  */
19
19
  export class AgentExecutor {
@@ -40,6 +40,8 @@ export class AgentExecutor {
40
40
  #activeAdapters = new Map();
41
41
  // 资源所有权独立于活动执行/终态:清理未确认的 owner 必须留存,供 shutdown 返回真实遗留项。
42
42
  #owners = new Map();
43
+ // probe 的展示超时只结束等待;底层宿主函数仍在运行,必须计入实际关闭事实。
44
+ #probes = new Set();
43
45
  #state = "open";
44
46
  #shutdownAttempt;
45
47
  #shutdownResult;
@@ -63,13 +65,16 @@ export class AgentExecutor {
63
65
  }
64
66
  /** Report installed provider identity separately from adapter registration. */
65
67
  async describe(configurations = {}) {
68
+ this.#assertOpen();
66
69
  return Promise.all([...this.#adapters.values()].map(async (adapter) => {
67
70
  let probe = {};
68
71
  let unavailableReason = adapter.probe ? "probe_invalid" : "probe_missing";
69
72
  let timer;
70
73
  try {
71
74
  const result = await Promise.race([
72
- Promise.resolve().then(() => adapter.probe?.(configurations[adapter.metadata.type])),
75
+ Promise.resolve().then(() => adapter.probe
76
+ ? this.probe(adapter.metadata.type, configurations[adapter.metadata.type])
77
+ : undefined),
73
78
  new Promise((resolve) => {
74
79
  timer = setTimeout(() => {
75
80
  unavailableReason = "probe_timeout";
@@ -803,7 +808,10 @@ export class AgentExecutor {
803
808
  ? nativeFailureCode
804
809
  : "HOST_EXECUTION_FAILED",
805
810
  message: String(failure.message),
806
- ...(isStreamCapacityReason(nativeFailureCode) ? { failure: failure.failure } : {})
811
+ ...(isStreamCapacityReason(nativeFailureCode) ||
812
+ (adapterType === "codex" && isCodexLocalFailure(failure.failure))
813
+ ? { failure: failure.failure }
814
+ : {})
807
815
  }
808
816
  };
809
817
  yield {
@@ -851,14 +859,27 @@ export class AgentExecutor {
851
859
  }
852
860
  }
853
861
  }
854
- /** Run the adapter's own environment probe; return an unchecked-available status when there is no probe. */
862
+ /** 保留 Adapter 的 this 与同步返回合同;实际异步探测完成前由 Core 持有,关闭后不再发起探测。 */
855
863
  probe(adapterType, options) {
864
+ this.#assertOpen();
856
865
  const adapter = this.#adapters.get(adapterType);
857
866
  if (!adapter)
858
867
  throw new Error(`unknown adapter: ${adapterType}`);
859
868
  if (!adapter.probe)
860
869
  return { available: true, adapterType, unchecked: true };
861
- return adapter.probe(options);
870
+ const result = adapter.probe(options);
871
+ if (result === null ||
872
+ (typeof result !== "object" && typeof result !== "function") ||
873
+ typeof result.then !== "function")
874
+ return result;
875
+ // 统一 Promise/thenable,调用方也消费同一 Promise,不能重复驱动一次性的 thenable。
876
+ const pending = Promise.resolve(result);
877
+ this.#probes.add(pending);
878
+ const settled = () => {
879
+ this.#probes.delete(pending);
880
+ };
881
+ void pending.then(settled, settled);
882
+ return pending;
862
883
  }
863
884
  /** 请求取消活动执行;true 仅表示已触发 abort,仍须消费终态并等待 Adapter 清理。 */
864
885
  cancel(invocationId, reason = "cancelled") {
@@ -870,12 +891,12 @@ export class AgentExecutor {
870
891
  this.#log("info", "invoke.cancel_accepted", { invocation_id: invocationId });
871
892
  return true;
872
893
  }
873
- /** Route an answer only to the adapter instance that owns the active invocation. */
894
+ /** 仅将回答路由到原活动调用;终态后返回稳定失效码,不转交其他 Adapter 或轮次。 */
874
895
  async respondInteraction(invocationId, response) {
875
896
  assertInteractionResponse(response);
876
897
  const adapter = this.#activeAdapters.get(invocationId);
877
898
  if (!adapter || this.#acceptedTerminals.has(invocationId)) {
878
- throw new Error(`invocation is not active: ${invocationId}`);
899
+ throw protocolError("INTERACTION_NOT_ACTIVE", `invocation is not active: ${invocationId}`);
879
900
  }
880
901
  if (this.#modes.get(invocationId) !== "canonical")
881
902
  throw protocolError("EXECUTION_PROTOCOL_MISMATCH");
@@ -894,7 +915,7 @@ export class AgentExecutor {
894
915
  await adapter.respondNative(invocationId, response);
895
916
  }
896
917
  /**
897
- * 停止接纳并取消未终结执行,在 timeoutMs 内等待 Adapter 清理;不负责业务投递收尾。
918
+ * 停止接纳并取消未终结执行,在 timeoutMs 内等待 Adapter 清理及实际 probe;不负责业务投递收尾。
898
919
  * 并发调用共用当前尝试;超时或清理失败返回 incomplete 和遗留身份,不冒充资源已回收。
899
920
  */
900
921
  shutdown(reason = "executor shutdown", timeoutMs = 2_500) {
@@ -905,7 +926,7 @@ export class AgentExecutor {
905
926
  if (this.#shutdownResult?.cleanup === "complete")
906
927
  return Promise.resolve(this.#shutdownResult);
907
928
  this.#state = "closing";
908
- const pending = [];
929
+ const pending = [...this.#probes];
909
930
  for (const [id, owner] of this.#owners) {
910
931
  if (!this.#acceptedTerminals.has(id))
911
932
  owner.controller.abort(reason);
@@ -917,7 +938,8 @@ export class AgentExecutor {
917
938
  const failedCleanupInvocationIds = Object.freeze([...this.#owners].filter(([, owner]) => owner.cleanupState === "failed").map(([id]) => id));
918
939
  const result = Object.freeze({
919
940
  state: "closed",
920
- cleanup: unresolvedInvocationIds.length ? "incomplete" : "complete",
941
+ // probe 不属于某个 invocation,不能伪造 invocationId;仍在途时独立阻止 complete。
942
+ cleanup: unresolvedInvocationIds.length || this.#probes.size ? "incomplete" : "complete",
921
943
  unresolvedInvocationIds,
922
944
  failedCleanupInvocationIds
923
945
  });