@mininglamp-oss/octo-runtime 1.1.10 → 1.1.11

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 (170) hide show
  1. package/README.md +1 -1
  2. package/apps/cli/README.md +1 -1
  3. package/apps/cli/dist/adapters.js +40 -14
  4. package/apps/cli/dist/build-info.json +2 -2
  5. package/apps/cli/dist/command-tree.js +2 -3
  6. package/apps/cli/dist/extras.js +11 -1
  7. package/apps/cli/dist/index.js +14 -1
  8. package/apps/cli/dist/main.js +58 -23
  9. package/apps/cli/dist/module-manifest.js +21 -3
  10. package/apps/cli/dist/output.d.ts +19 -1
  11. package/apps/cli/dist/output.js +179 -27
  12. package/apps/cli/dist/playboard.js +2 -2
  13. package/apps/cli/dist/state.d.ts +5 -2
  14. package/apps/cli/dist/state.js +48 -13
  15. package/dist/public/codex.d.ts +1 -0
  16. package/dist/public/codex.js +1 -0
  17. package/dist/public/executor-kernel.d.ts +4 -0
  18. package/dist/public/executor-kernel.js +2 -0
  19. package/dist/public/extra.d.ts +1 -1
  20. package/dist/public/host.d.ts +5 -0
  21. package/dist/public/host.js +2 -0
  22. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  23. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +20 -0
  24. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  25. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  26. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  27. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  28. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.d.ts +6 -6
  29. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +68 -253
  30. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +11 -6
  31. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +198 -52
  32. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.d.ts +58 -0
  33. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.js +650 -0
  34. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.d.ts +3 -0
  35. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.js +15 -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/package.json +3 -3
  38. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
  39. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  40. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  41. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  42. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  43. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +2 -0
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
  46. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
  47. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/activity.d.ts +5 -0
  48. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.d.ts +25 -0
  49. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.js +1 -0
  50. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +3 -0
  51. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
  52. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +40 -14
  53. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  54. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +2 -3
  55. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extras.js +11 -1
  56. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/index.js +14 -1
  57. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +58 -23
  58. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.js +21 -3
  59. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.d.ts +19 -1
  60. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +179 -27
  61. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +2 -2
  62. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.d.ts +5 -2
  63. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.js +48 -13
  64. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +23 -23
  65. package/node_modules/@mininglamp-oss/octo-runtime-client/build-info.json +5 -0
  66. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/async-question-reply.d.ts +30 -0
  67. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/async-question-reply.js +199 -0
  68. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/browser.d.ts +1 -0
  69. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/browser.js +1 -0
  70. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.d.ts +10 -0
  71. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.js +465 -0
  72. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/index.d.ts +6 -0
  73. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/index.js +6 -0
  74. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/internal.d.ts +4 -0
  75. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/internal.js +5 -0
  76. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/invocation-lifecycle.d.ts +59 -0
  77. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/invocation-lifecycle.js +287 -0
  78. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/notification.d.ts +1 -0
  79. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/notification.js +1 -0
  80. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/protocol.d.ts +1 -0
  81. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/protocol.js +1 -0
  82. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/runtime-path.d.ts +21 -0
  83. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/runtime-path.js +138 -0
  84. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-catalog.d.ts +8 -0
  85. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-catalog.js +65 -0
  86. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-diagnostics.d.ts +82 -0
  87. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-diagnostics.js +371 -0
  88. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/submission-error.d.ts +10 -0
  89. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/submission-error.js +23 -0
  90. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/types.d.ts +72 -0
  91. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/types.js +10 -0
  92. package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +54 -0
  93. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-configuration-fixtures.json +1219 -0
  94. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-fixtures.json +5988 -0
  95. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-client.behavior.json +56 -0
  96. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc-fixtures.json +53 -0
  97. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc.schema.json +538 -0
  98. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/native-invoke-fixtures.json +116 -0
  99. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +4525 -0
  100. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/run-protocol-fixtures.json +761 -0
  101. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/runtime-selection-fixtures.json +663 -0
  102. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/session-name-fixtures.json +191 -0
  103. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
  104. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +26 -18
  105. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +151 -11
  106. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  107. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.d.ts +1 -30
  108. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.js +2 -199
  109. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.d.ts +1 -10
  110. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.js +2 -446
  111. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/endpoint.js +2 -0
  112. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.d.ts +2 -0
  113. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.js +13 -2
  114. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +4 -1
  115. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +4 -1
  116. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.d.ts +1 -53
  117. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.js +2 -280
  118. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/lifecycle.d.ts +5 -10
  119. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/lifecycle.js +4 -1
  120. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-home.d.ts +20 -0
  121. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-home.js +180 -0
  122. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +31 -8
  123. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.d.ts +5 -2
  124. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.js +48 -5
  125. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-catalog.d.ts +1 -0
  126. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-catalog.js +1 -0
  127. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-diagnostics.d.ts +1 -0
  128. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-diagnostics.js +1 -0
  129. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-logging.d.ts +4 -0
  130. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-logging.js +18 -0
  131. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.d.ts +1 -10
  132. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.js +2 -23
  133. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/types.d.ts +2 -72
  134. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/types.js +2 -10
  135. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +5 -4
  136. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/extra.js +1 -1
  137. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/ports.d.ts +2 -2
  138. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
  139. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/extra.js +1 -1
  140. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/ports.d.ts +2 -2
  141. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
  142. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/index.js +4 -4
  143. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
  144. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.d.ts +1 -1
  145. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.js +12 -5
  146. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/errors.d.ts +5 -1
  147. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/errors.js +9 -0
  148. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/execution.d.ts +44 -0
  149. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/execution.js +207 -0
  150. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-config.js +23 -3
  151. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-service.d.ts +27 -4
  152. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-service.js +133 -25
  153. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extras.d.ts +10 -3
  154. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extras.js +18 -4
  155. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/home.d.ts +5 -6
  156. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/home.js +33 -45
  157. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/identity.js +6 -0
  158. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.d.ts +4 -0
  159. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.js +3 -0
  160. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +5 -4
  161. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.d.ts +7 -0
  162. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.js +1 -0
  163. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +19 -0
  164. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +3 -1
  165. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +1 -0
  166. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.d.ts +5 -0
  167. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.js +65 -0
  168. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  169. package/package.json +33 -27
  170. package/packages/octo-runtime-protocol/schema/protocol.schema.json +42 -0
@@ -1,13 +1,72 @@
1
1
  import { ServiceError } from "@mininglamp-oss/octo-runtime-cross-service";
2
2
  import { RuntimeLogging } from "@mininglamp-oss/octo-runtime-adapter-sdk";
3
- import { open, readdir } from "node:fs/promises";
3
+ import { describeStartupError, formatStartupDiagnostic, restoreStartupDiagnostic, safeStartupValue, startupPathDiagnostic, STARTUP_CATALOG } from "@mininglamp-oss/octo-runtime-executor-kernel";
4
+ import { constants } from "node:fs";
5
+ import { randomUUID } from "node:crypto";
6
+ import { open, readdir, mkdir, rename, rm, lstat } from "node:fs/promises";
4
7
  import { join } from "node:path";
8
+ /** doctor 仅投影已取得的常驻快照;同 PID 合并角色,层级表示所有权而非猜测 OS PPID。 */
9
+ export function residentProcesses(snapshots) {
10
+ const processes = [];
11
+ const pid = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : undefined;
12
+ const add = (entry) => {
13
+ const existing = entry.pid &&
14
+ processes.find((value) => value.pid === entry.pid &&
15
+ value.observation === "alive" &&
16
+ entry.observation === "alive" &&
17
+ value.owner_pid === entry.owner_pid &&
18
+ value.service_id === entry.service_id &&
19
+ value.incarnation === entry.incarnation);
20
+ if (existing)
21
+ existing.roles.push(...entry.roles.filter((role) => !existing.roles.includes(role)));
22
+ else
23
+ processes.push(entry);
24
+ };
25
+ for (const [name, snapshot] of Object.entries(snapshots)) {
26
+ const runtime = record(snapshot.runtime);
27
+ const actualPid = pid(runtime.pid);
28
+ const managedPid = pid(snapshot.service.pid);
29
+ add({
30
+ ...(actualPid || managedPid ? { pid: actualPid ?? managedPid } : {}),
31
+ roles: [name === "executor-kernel" ? "Host/Kernel" : `Extra:${name}`],
32
+ state: actualPid ? "running" : snapshot.service.state,
33
+ observation: actualPid ? "alive" : "unknown"
34
+ });
35
+ if (!Array.isArray(runtime.service_processes))
36
+ continue;
37
+ for (const value of runtime.service_processes.slice(0, 256)) {
38
+ const service = record(value);
39
+ add({
40
+ ...(pid(service.pid) ? { pid: pid(service.pid) } : {}),
41
+ owner_pid: pid(service.owner_pid),
42
+ roles: [`${text(service.provider)} app-server`],
43
+ state: text(service.state),
44
+ observation: text(service.observation),
45
+ service_id: text(service.service_id),
46
+ incarnation: typeof service.incarnation === "number" ? service.incarnation : undefined
47
+ });
48
+ }
49
+ }
50
+ return processes;
51
+ }
52
+ export function formatResidentProcesses(processes) {
53
+ const lines = ["Resident processes (ownership):"];
54
+ for (const entry of processes.filter((value) => !value.owner_pid)) {
55
+ lines.push(` ${entry.roles.join(", ")} PID ${entry.pid ?? "unknown"} ${entry.state} (${entry.observation})`);
56
+ for (const child of processes.filter((value) => entry.pid && value.owner_pid === entry.pid))
57
+ lines.push(` +-- ${child.roles.join(", ")} PID ${child.pid ?? "-"} ${child.state} (${child.observation}) incarnation ${child.incarnation ?? "-"} service ${child.service_id ?? "-"}`);
58
+ }
59
+ for (const entry of processes.filter((value) => value.owner_pid && !processes.some((parent) => parent.pid === value.owner_pid)))
60
+ lines.push(` ${entry.roles.join(", ")} PID ${entry.pid ?? "-"} ${entry.state} (${entry.observation}) owner PID ${entry.owner_pid}`);
61
+ return lines.join("\n");
62
+ }
5
63
  const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value)
6
64
  ? value
7
65
  : {};
8
66
  const text = (value) => String(value)
9
67
  .replace(/\p{Cc}/gu, " ")
10
68
  .slice(0, 200);
69
+ const stableCode = (value) => typeof value === "string" && /^[A-Z][A-Z0-9_]{1,100}$/.test(value) ? value : undefined;
11
70
  /** 展示公开状态的摘要,不为输出克隆完整 session/delivery 集合。JSON 模式保留原结果。 */
12
71
  export function formatStatus(name, snapshot) {
13
72
  const service = snapshot.service;
@@ -87,26 +146,36 @@ export function formatStatus(name, snapshot) {
87
146
  return lines.join("\n");
88
147
  }
89
148
  /** 只保留受控错误码和管理器元信息;异常正文及任意 stderr 可能含凭据,不能直出。 */
90
- export function describeError(error, fallback = "COMMAND_FAILED") {
91
- const stableCode = (value) => typeof value === "string" && /^[A-Z][A-Z0-9_]{1,100}$/.test(value) ? value : undefined;
92
- const value = record(error);
93
- const code = stableCode(value.code) ??
94
- (error instanceof Error ? stableCode(error.message) : undefined) ??
149
+ export function describeError(error, fallback = "COMMAND_FAILED", startup) {
150
+ const field = (value, key) => {
151
+ try {
152
+ return value !== null && typeof value === "object"
153
+ ? Object.getOwnPropertyDescriptor(value, key)?.value
154
+ : undefined;
155
+ }
156
+ catch {
157
+ return undefined;
158
+ }
159
+ };
160
+ const code = stableCode(field(error, "code")) ??
161
+ (error instanceof Error ? stableCode(field(error, "message")) : undefined) ??
95
162
  fallback;
96
- const cause = record(value.cause);
97
- const causeCode = stableCode(cause.code) ?? stableCode(cause.message);
163
+ const cause = field(error, "cause");
164
+ const causeCode = stableCode(field(cause, "code")) ?? stableCode(field(cause, "message"));
165
+ const projection = describeStartupError(error, startup);
166
+ const pathDiagnostic = startupPathDiagnostic(projection);
167
+ const diagnostic = startup ||
168
+ pathDiagnostic ||
169
+ field(field(error, "diagnostic"), "domain") === "startup" ||
170
+ projection.causes.some((cause) => cause.component && cause.phase)
171
+ ? projection
172
+ : undefined;
98
173
  const hints = {
99
174
  COMMAND_FAILED: "The command failed. Check the native manager, configuration and service logs.",
100
- ENOENT: "The component endpoint or required file does not exist. Check installation and service status.",
101
- ECONNREFUSED: "The component is not accepting IPC connections. Check its process and logs.",
102
175
  KERNEL_UNAVAILABLE: "Kernel is unavailable. Check executor-kernel status; Extras can remain running.",
103
176
  INVALID_ARGUMENTS: "Use --help to see the available commands and flags.",
104
- SETUP_IN_PROGRESS: "Another component lifecycle operation is in progress. Wait for it to finish, then retry.",
105
- ORPHAN_CLEANUP_INCOMPLETE: "Run doctor with the same --home to inspect the manifest. After stopping all orphan tools, run executor-kernel recover --acknowledge-orphan-cleanup, then start again.",
106
177
  ORPHAN_CLEANUP_OWNER_ALIVE: "The original Kernel or worker is still alive or its identity cannot be verified. Stop it safely before acknowledging cleanup.",
107
178
  ORPHAN_CLEANUP_NOT_PENDING: "There is no valid incomplete orphan cleanup to acknowledge. Run doctor with the same --home.",
108
- SERVICE_NOT_INSTALLED: "Run this component's install command, then start it.",
109
- NOT_INSTALLED: "Run this component's install command, then start it.",
110
179
  EXTRA_COMMAND_FAILED: "The Extra command failed. No private backend error is printed; check its input and configuration, then retry.",
111
180
  EXTRA_CONFIG_CONFLICT: "Configuration changed after this command read it. Read the latest configuration and retry.",
112
181
  EXTRA_COMMAND_LOAD_FAILED: "The selected Extra command module or one of its dependencies is broken. Check its package and commands export; lifecycle commands remain available.",
@@ -116,33 +185,75 @@ export function describeError(error, fallback = "COMMAND_FAILED") {
116
185
  EXTRA_COMMAND_NOT_FOUND: "Unknown command. Use --help on the service command to see available subcommands.",
117
186
  EXTRA_COMMAND_CANCELLED: "The command was cancelled. Any save that already completed remains persisted.",
118
187
  EXTRA_COMMAND_STDIN_REQUIRED: "Pipe the required input through stdin; do not put credentials in command arguments.",
119
- EXTRA_NOT_REGISTERED: "Save the service configuration using its configure or extraset subcommand before starting it.",
120
188
  EXTRA_MANIFEST_DECLARATION_REQUIRED: "Install this Extra alongside the global Runtime, or add its name and module to the selected Home manifest.json (extras array), then retry.",
121
- EXTRA_NAME_MISMATCH: "The selected Extra must export the same name as its catalog entry. Check the reported package origin.",
122
- EXTRA_MODULE_LOAD_FAILED: "Check the selected catalog declaration, discovery diagnostics, installation and ESM exports; reinstall it or select a valid Home manifest entry, then retry.",
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.",
124
- MANIFEST_INVALID: "Check manifest.json: version must be 1 and adapters/extras must be valid arrays without duplicate keys.",
125
- MANAGER_UNAVAILABLE: "Run doctor and check the current user's native service manager.",
126
- COMPONENT_UNAVAILABLE: "Check component status and the service logs; the IPC endpoint or execution service is not ready.",
127
- SERVICE_PROCESS_EXITED: "The service exited unexpectedly. Check its logs and configuration.",
128
- SERVICE_INITIALIZATION_FAILED: "Check the component configuration, manifest and service logs.",
129
- SERVICE_DISABLED: "Enable this component with install --autostart=true, then start it."
189
+ 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."
130
190
  };
131
191
  return {
132
192
  code,
133
- message: hints[code] ?? "Check --help, component status and service logs for this operation.",
193
+ message: diagnostic?.explanation ??
194
+ STARTUP_CATALOG[code]?.action ??
195
+ hints[code] ??
196
+ "Check --help, component status and service logs for this operation.",
134
197
  ...(causeCode ? { cause_code: causeCode } : {}),
198
+ ...(diagnostic ? { diagnostic } : {}),
199
+ ...(pathDiagnostic
200
+ ? { startup: pathDiagnostic, ...(diagnostic?.cleanup ? { cleanup: diagnostic.cleanup } : {}) }
201
+ : {}),
135
202
  ...(error instanceof ServiceError
136
- ? { backend: error.backend, command: error.command, exit_code: error.exitCode }
203
+ ? {
204
+ backend: error.backend,
205
+ command: typeof error.command === "string" ? safeStartupValue(error.command) : undefined,
206
+ exit_code: error.exitCode
207
+ }
137
208
  : {})
138
209
  };
139
210
  }
211
+ /** 保留兼容 code/cause_code;共享启动结构决定动态解释与下一步。 */
212
+ export function formatErrorDetails(failure) {
213
+ return failure.diagnostic ? formatStartupDiagnostic(failure.diagnostic) : failure.message;
214
+ }
140
215
  /** 前台启动失败沿既有白名单和小时轮转落盘;不捕获任意进程 stdout/stderr。 */
141
216
  export async function recordStartupFailure(directory, component, error) {
217
+ if (!/^[a-z][a-z0-9-]{0,63}$/.test(component))
218
+ return;
219
+ // Home 校验失败不得由诊断日志递归补建根目录(#306)。
220
+ if (startupPathDiagnostic(describeStartupError(error)))
221
+ return;
142
222
  const logging = new RuntimeLogging({ directory });
143
223
  try {
144
- const log = component === "executor-kernel" ? logging.kernel : logging.extra(component);
224
+ // 单份最近失败记录拥有独立有界文件;不放宽通用日志的配置/异常白名单。
225
+ const diagnostic = describeStartupError(error, { component, phase: "initializing" });
145
226
  const failure = describeError(error, "SERVICE_INITIALIZATION_FAILED");
227
+ const file = join(directory, `startup-${component}.json`);
228
+ const temporary = `${file}.${randomUUID()}.tmp`;
229
+ try {
230
+ const line = JSON.stringify({
231
+ schema_version: 1,
232
+ time: new Date().toISOString(),
233
+ component,
234
+ code: failure.code,
235
+ ...(failure.cause_code ? { cause_code: failure.cause_code } : {}),
236
+ diagnostic
237
+ });
238
+ if (Buffer.byteLength(line) <= 262144) {
239
+ await mkdir(directory, { recursive: true, mode: 0o700 });
240
+ const handle = await open(temporary, "wx", 0o600);
241
+ try {
242
+ await handle.writeFile(line);
243
+ }
244
+ finally {
245
+ await handle.close();
246
+ }
247
+ await rename(temporary, file);
248
+ }
249
+ }
250
+ catch {
251
+ // 诊断落盘失败不能覆盖原始启动/清理错误,调用方仍持有完整安全投影。
252
+ }
253
+ finally {
254
+ await rm(temporary, { force: true }).catch(() => undefined);
255
+ }
256
+ const log = component === "executor-kernel" ? logging.kernel : logging.extra(component);
146
257
  if (failure.cause_code)
147
258
  log("error", "cli.initialization_cause", { code: failure.cause_code });
148
259
  log("error", "cli.initialization_failed", { code: failure.code });
@@ -153,6 +264,47 @@ export async function recordStartupFailure(directory, component, error) {
153
264
  }
154
265
  /** 只读本次 start 后的白名单失败事件;每个轮转文件最多读取末尾 64 KiB。 */
155
266
  export async function readStartupFailure(directory, component, since) {
267
+ if (!/^[a-z][a-z0-9-]{0,63}$/.test(component))
268
+ return undefined;
269
+ try {
270
+ const file = await open(join(directory, `startup-${component}.json`), constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
271
+ try {
272
+ const stat = await file.stat();
273
+ if (!constants.O_NOFOLLOW) {
274
+ const entry = await lstat(join(directory, `startup-${component}.json`));
275
+ if (!entry.isFile() || entry.dev !== stat.dev || entry.ino !== stat.ino)
276
+ return undefined;
277
+ }
278
+ if (stat.isFile() && stat.size <= 262144) {
279
+ const bytes = Buffer.alloc(262145);
280
+ let length = 0;
281
+ while (length < bytes.length) {
282
+ const { bytesRead } = await file.read(bytes, length, bytes.length - length, null);
283
+ if (!bytesRead)
284
+ break;
285
+ length += bytesRead;
286
+ }
287
+ if (length > 262144)
288
+ return undefined;
289
+ const row = record(JSON.parse(bytes.subarray(0, length).toString("utf8")));
290
+ if (row.schema_version === 1 &&
291
+ row.component === component &&
292
+ typeof row.time === "string" &&
293
+ Date.parse(row.time) >= since) {
294
+ const diagnostic = restoreStartupDiagnostic(row.diagnostic);
295
+ const code = stableCode(row.code), causeCode = stableCode(row.cause_code);
296
+ if (diagnostic && code)
297
+ return Object.assign(new Error(code, causeCode ? { cause: new Error(causeCode) } : undefined), { diagnostic });
298
+ }
299
+ }
300
+ }
301
+ finally {
302
+ await file.close();
303
+ }
304
+ }
305
+ catch {
306
+ // 缺失、损坏或旧版本记录继续走既有白名单日志,不影响真实就绪等待。
307
+ }
156
308
  const root = component === "executor-kernel" ? directory : join(directory, "extras");
157
309
  const prefix = component === "executor-kernel" ? "kernel-" : `${component}-`;
158
310
  try {
@@ -2,7 +2,6 @@ import { loadCliAdapters } from "./adapters.js";
2
2
  import { defaultRuntimeHome, runtimePaths, readJsonFile } from "./state.js";
3
3
  import { loadCliManifest } from "./module-manifest.js";
4
4
  import { readCliAdapterConfigurations } from "./adapter-configurations.js";
5
- import { resolveAdapterModules } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
6
5
  import { createKernelService } from "@mininglamp-oss/octo-runtime-executor-kernel";
7
6
  import { componentEndpoint } from "@mininglamp-oss/octo-runtime-host-sdk";
8
7
  import { mkdtemp, rm } from "node:fs/promises";
@@ -89,8 +88,9 @@ export async function runPlayboard(options) {
89
88
  const manifest = await loadCliManifest(home, options.manifest);
90
89
  const configuration = await readJsonFile(paths.profileConfig);
91
90
  kernel = createKernelService({
91
+ home: temporary,
92
92
  endpoint: process.platform === "win32" ? componentEndpoint(temporary) : join(temporary, "k.sock"),
93
- adapters: await loadCliAdapters(resolveAdapterModules(manifest), {
93
+ adapters: await loadCliAdapters(manifest.adapters, {
94
94
  profileRoot: paths.profileRoot,
95
95
  syncOpenClawTools: false
96
96
  }),
@@ -49,10 +49,13 @@ export interface RuntimePaths {
49
49
  openclawRoot: string;
50
50
  setupLock: string;
51
51
  pid: string;
52
- socket: string;
53
52
  logs: string;
54
53
  }
55
- export declare function defaultRuntimeHome(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string;
54
+ export declare function defaultRuntimeHome(env?: NodeJS.ProcessEnv): string;
55
+ /** CLI 明确接受相对 --home 并转为绝对路径;不展开 ~,空值必须失败。 */
56
+ export declare function selectRuntimeHome(input: string | undefined, env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string;
57
+ /** 根目录只由 CLI 准备;先检查完整预算,创建失败保留原 path/errno,不换根。 */
58
+ export declare function prepareRuntimeHome(home: string): Promise<void>;
56
59
  export declare function runtimePaths(home: string, profile: string, platform?: NodeJS.Platform): RuntimePaths;
57
60
  /** Call under the Home setup lock; this label is shared by all profiles, not an authentication key. */
58
61
  export declare function ensureMachineIdentity(paths: RuntimePaths): Promise<MachineIdentity>;
@@ -2,12 +2,17 @@ import { createHash, randomUUID } from "node:crypto";
2
2
  import { access, chmod, link, mkdir, open, readFile, rename, rm, rmdir } from "node:fs/promises";
3
3
  import { homedir } from "node:os";
4
4
  import { basename, dirname, join, resolve } from "node:path";
5
- import { componentEndpoint } from "@mininglamp-oss/octo-runtime-host-sdk";
5
+ import { componentEndpoint, normalizeRuntimeHome, assertRuntimePath, runtimePathFailure, validateRuntimeHome } from "@mininglamp-oss/octo-runtime-host-sdk";
6
+ import { withStartupContext } from "@mininglamp-oss/octo-runtime-executor-kernel";
6
7
  const PROFILE_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
7
8
  const RESERVED_PROFILE_NAMES = new Set([
8
9
  "config.json",
9
10
  "credentials",
10
11
  "extras",
12
+ "executor-kernel.sock",
13
+ "executor-kernel.sock.owner",
14
+ "executor-kernel.sock.owner.recovery",
15
+ "executor-kernel.sock.runs",
11
16
  "identity",
12
17
  "machine.json",
13
18
  "logs",
@@ -18,20 +23,43 @@ const RESERVED_PROFILE_NAMES = new Set([
18
23
  "sockets",
19
24
  "state.db"
20
25
  ]);
21
- export function defaultRuntimeHome(env = process.env, platform = process.platform) {
22
- if (env.OCTO_RUNTIME_HOME?.trim())
23
- return resolve(env.OCTO_RUNTIME_HOME.trim());
24
- if (platform === "win32") {
25
- const localAppData = env.LOCALAPPDATA?.trim();
26
- if (localAppData)
27
- return resolve(localAppData, "OctoRuntime");
26
+ export function defaultRuntimeHome(env = process.env) {
27
+ return normalizeRuntimeHome(join(env.HOME?.trim() || homedir(), ".octo-runtime"));
28
+ }
29
+ /** CLI 明确接受相对 --home 并转为绝对路径;不展开 ~,空值必须失败。 */
30
+ export function selectRuntimeHome(input, env, platform = process.platform) {
31
+ if (input === undefined)
32
+ return normalizeRuntimeHome(defaultRuntimeHome(env), platform);
33
+ if (typeof input !== "string" || !input.trim() || input.startsWith("~"))
34
+ return normalizeRuntimeHome(input, platform);
35
+ return normalizeRuntimeHome(resolve(input), platform);
36
+ }
37
+ /** 根目录只由 CLI 准备;先检查完整预算,创建失败保留原 path/errno,不换根。 */
38
+ export async function prepareRuntimeHome(home) {
39
+ const selected = normalizeRuntimeHome(home);
40
+ componentEndpoint(selected);
41
+ assertRuntimePath(join(selected, "run", `kernel-invocations.json.acknowledged.${"0".repeat(36)}.json`), "kernel-state");
42
+ try {
43
+ await mkdir(selected, { recursive: true, mode: 0o700 });
28
44
  }
29
- return resolve(env.HOME?.trim() || homedir(), ".octo-runtime");
45
+ catch (error) {
46
+ if (isNodeError(error, "EEXIST"))
47
+ validateRuntimeHome(selected);
48
+ throw runtimePathFailure(error, selected, "home", "mkdir");
49
+ }
50
+ validateRuntimeHome(selected);
30
51
  }
31
52
  export function runtimePaths(home, profile, platform = process.platform) {
32
53
  assertProfileName(profile);
33
- const absoluteHome = resolve(home);
54
+ const absoluteHome = normalizeRuntimeHome(home, platform);
34
55
  const profileRoot = join(absoluteHome, profile);
56
+ // CLI 的身份/锁原子写另有后缀,不可只检查 Home 或 hash pipe 的短地址。
57
+ for (const path of [
58
+ join(profileRoot, "credentials", `runtime-token.json.${"0".repeat(10)}.${"0".repeat(36)}.tmp`),
59
+ join(absoluteHome, "run", `kernel-invocations.json.acknowledged.${"0".repeat(36)}.json`),
60
+ join(absoluteHome, "run", `.reclaim-${"0".repeat(64)}.${"0".repeat(10)}.${"0".repeat(36)}.tmp`)
61
+ ])
62
+ assertRuntimePath(path, "cli-state", platform);
35
63
  return {
36
64
  home: absoluteHome,
37
65
  rootConfig: join(absoluteHome, "config.json"),
@@ -43,7 +71,6 @@ export function runtimePaths(home, profile, platform = process.platform) {
43
71
  openclawRoot: join(profileRoot, "adapters", "openclaw"),
44
72
  setupLock: join(absoluteHome, "run", "setup.lock"),
45
73
  pid: join(absoluteHome, "run", "executor-kernel.pid"),
46
- socket: componentEndpoint(absoluteHome, "executor-kernel", platform),
47
74
  logs: join(absoluteHome, "logs")
48
75
  };
49
76
  }
@@ -141,8 +168,16 @@ export async function readJsonFile(path) {
141
168
  if (isNodeError(error, "ENOENT"))
142
169
  return undefined;
143
170
  if (error instanceof SyntaxError)
144
- throw new Error(`invalid JSON file: ${path}`, { cause: error });
145
- throw error;
171
+ throw withStartupContext(new Error(`invalid JSON file: ${path}`, { cause: error }), {
172
+ component: "cli",
173
+ phase: "created",
174
+ context: { path, resource: "configuration", operation: "read-json" }
175
+ }, "LOCAL_STATE_INVALID");
176
+ throw withStartupContext(error, {
177
+ component: "cli",
178
+ phase: "created",
179
+ context: { path, resource: "configuration", operation: "read" }
180
+ });
146
181
  }
147
182
  }
148
183
  export async function writeJsonAtomic(path, value) {
@@ -0,0 +1 @@
1
+ export { codexAdapter, createCodexAdapter } from "@mininglamp-oss/octo-runtime-adapter-codex";
@@ -0,0 +1 @@
1
+ export { codexAdapter, createCodexAdapter } from "@mininglamp-oss/octo-runtime-adapter-codex";
@@ -1,3 +1,7 @@
1
1
  export { attachKernel, AsyncQuestionReply, KernelError, isInvocationNotSubmitted, createKernelService, ServiceInitializationError } from "@mininglamp-oss/octo-runtime-executor-kernel";
2
2
  export type { HostedAdapter } from "@mininglamp-oss/octo-runtime-executor-core";
3
+ export { STARTUP_CATALOG, describeStartupError, formatStartupDiagnostic, restoreStartupDiagnostic, StartupError } from "@mininglamp-oss/octo-runtime-executor-kernel";
4
+ export type { StartupCatalogEntry, StartupDiagnostic, StartupContext, StartupCause, StartupLocation } from "@mininglamp-oss/octo-runtime-executor-kernel";
3
5
  export type { KernelClient, AsyncQuestionReplyResult, KernelInvocationRecord, KernelInvocationDrainResult, KernelInvocationLifecycle, KernelService, KernelServiceOptions, KernelServiceStatus, ServiceCleanupResult, ServiceLifecycle, ServicePhase, KernelStatus, LookupKey, RunRef, RunSnapshot } from "@mininglamp-oss/octo-runtime-executor-kernel";
6
+ export { RuntimeHomeError, normalizeRuntimeHome, validateRuntimeHome, assertRuntimePath, assertIpcEndpoint } from "@mininglamp-oss/octo-runtime-executor-kernel";
7
+ export type { StartupPathDiagnostic } from "@mininglamp-oss/octo-runtime-executor-kernel";
@@ -1 +1,3 @@
1
1
  export { attachKernel, AsyncQuestionReply, KernelError, isInvocationNotSubmitted, createKernelService, ServiceInitializationError } from "@mininglamp-oss/octo-runtime-executor-kernel";
2
+ export { STARTUP_CATALOG, describeStartupError, formatStartupDiagnostic, restoreStartupDiagnostic, StartupError } from "@mininglamp-oss/octo-runtime-executor-kernel";
3
+ export { RuntimeHomeError, normalizeRuntimeHome, validateRuntimeHome, assertRuntimePath, assertIpcEndpoint } from "@mininglamp-oss/octo-runtime-executor-kernel";
@@ -1,5 +1,5 @@
1
1
  export * from "./protocol.js";
2
- export type { ExtraContext, RuntimeLog, RuntimeLogLevel, ExtraDisposer, ExtraInitializer, ExtraPlugin, ExtraPluginModule, ExtraRegistration, ExtraStatus, ExtraStatusHandler, JsonObject, JsonValue } from "@mininglamp-oss/octo-runtime-host-sdk/extra";
2
+ export type { ExtraContext, ExtraExecution, ExtraExecutionContext, RuntimeLog, RuntimeLogLevel, ExtraDisposer, ExtraInitializer, ExtraPlugin, ExtraPluginModule, ExtraRegistration, ExtraStatus, ExtraStatusHandler, JsonObject, JsonValue } from "@mininglamp-oss/octo-runtime-host-sdk/extra";
3
3
  export { ExtraPlugins } from "@mininglamp-oss/octo-runtime-host-sdk/extra";
4
4
  export type { ExtraDescriptor, StoredExtra } from "@mininglamp-oss/octo-runtime-host-sdk/extra-config";
5
5
  export * from "@mininglamp-oss/octo-runtime-host-sdk/extra-commands";
@@ -1,5 +1,10 @@
1
1
  export { createExtraService, componentEndpoint, componentServiceId, homeHash, normalizedHome } from "@mininglamp-oss/octo-runtime-host-sdk";
2
2
  export type { ExtraService, ExtraServiceOptions, ExtraServiceStatus } from "@mininglamp-oss/octo-runtime-host-sdk";
3
+ export type { ExtraExecution, ExtraExecutionContext } from "@mininglamp-oss/octo-runtime-host-sdk";
3
4
  export type { RuntimeLoggingOptions, ExtraStatusRecord } from "@mininglamp-oss/octo-runtime-host-sdk";
4
5
  export { createKernelService, ServiceInitializationError } from "./executor-kernel.js";
6
+ export { STARTUP_CATALOG, describeStartupError, formatStartupDiagnostic, restoreStartupDiagnostic, StartupError } from "./executor-kernel.js";
7
+ export type { StartupCatalogEntry, StartupDiagnostic, StartupContext, StartupCause, StartupLocation } from "./executor-kernel.js";
5
8
  export type { KernelService, KernelServiceOptions, KernelServiceStatus, ServiceCleanupResult, ServiceLifecycle, ServicePhase } from "./executor-kernel.js";
9
+ export { RuntimeHomeError, normalizeRuntimeHome, validateRuntimeHome, assertRuntimePath, assertIpcEndpoint } from "@mininglamp-oss/octo-runtime-executor-kernel";
10
+ export type { StartupPathDiagnostic } from "@mininglamp-oss/octo-runtime-executor-kernel";
@@ -1,2 +1,4 @@
1
1
  export { createExtraService, componentEndpoint, componentServiceId, homeHash, normalizedHome } from "@mininglamp-oss/octo-runtime-host-sdk";
2
2
  export { createKernelService, ServiceInitializationError } from "./executor-kernel.js";
3
+ export { STARTUP_CATALOG, describeStartupError, formatStartupDiagnostic, restoreStartupDiagnostic, StartupError } from "./executor-kernel.js";
4
+ export { RuntimeHomeError, normalizeRuntimeHome, validateRuntimeHome, assertRuntimePath, assertIpcEndpoint } from "@mininglamp-oss/octo-runtime-executor-kernel";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-acp-client",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -9,7 +9,7 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.10",
13
- "@mininglamp-oss/octo-runtime-protocol": "1.1.10"
12
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.11",
13
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.11"
14
14
  }
15
15
  }
@@ -475,6 +475,26 @@ export function createAcpAdapter(definition, { acpClientFactory = spawnAcpClient
475
475
  await client.close();
476
476
  }
477
477
  if (invocationFailed) {
478
+ // 原生 spawn 拒绝属于启动失败;只有上面的 close 成功后才发布失败终态。
479
+ // 若继续抛出,Core 无法区分执行错误与生成器 finally 失败,会保留未确认 owner。
480
+ // 不推广到任意迭代错误:清理异常仍从 finally 抛出,容量等错误仍保留原对象。
481
+ if (invocationError instanceof Error &&
482
+ "code" in invocationError &&
483
+ typeof invocationError.code === "string" &&
484
+ "syscall" in invocationError &&
485
+ typeof invocationError.syscall === "string" &&
486
+ invocationError.syscall.startsWith("spawn ")) {
487
+ yield {
488
+ protocolVersion: 2,
489
+ type: "run.failed",
490
+ payload: {
491
+ code: invocationError.code,
492
+ message: invocationError.message,
493
+ adapterType: definition.type
494
+ }
495
+ };
496
+ return;
497
+ }
478
498
  // 有明确错误码的容量等结构化错误保留原对象;普通内建子类仍交给适配器归一化。
479
499
  if (invocationError instanceof Error &&
480
500
  "code" in invocationError &&
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-acp",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -9,8 +9,8 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@mininglamp-oss/octo-runtime-protocol": "1.1.10",
13
- "@mininglamp-oss/octo-runtime-acp-client": "1.1.10",
14
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.10"
12
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.11",
13
+ "@mininglamp-oss/octo-runtime-acp-client": "1.1.11",
14
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.11"
15
15
  }
16
16
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-antigravity",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -10,7 +10,7 @@
10
10
  "README.md"
11
11
  ],
12
12
  "dependencies": {
13
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.10",
14
- "@mininglamp-oss/octo-runtime-protocol": "1.1.10"
13
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.11",
14
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.11"
15
15
  }
16
16
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-claude-code",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
7
7
  "dependencies": {
8
- "@mininglamp-oss/octo-runtime-protocol": "1.1.10",
9
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.10"
8
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.11",
9
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.11"
10
10
  },
11
11
  "types": "./dist/index.d.ts",
12
12
  "files": [
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-codebuddy",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
7
7
  "dependencies": {
8
- "@mininglamp-oss/octo-runtime-protocol": "1.1.10",
9
- "@mininglamp-oss/octo-runtime-acp-client": "1.1.10",
10
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.10"
8
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.11",
9
+ "@mininglamp-oss/octo-runtime-acp-client": "1.1.11",
10
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.11"
11
11
  },
12
12
  "types": "./dist/index.d.ts",
13
13
  "files": [
@@ -1,3 +1,4 @@
1
+ import type { CodexTurnChannel } from "./service.js";
1
2
  /**
2
3
  * Codex app-server transport and event adaptation layer.
3
4
  *
@@ -6,7 +7,7 @@
6
7
  * initialize/thread/turn requests and must respond to approval/elicitation
7
8
  * requests that Codex sends back. That is why this does not reuse the generic
8
9
  * JSON CLI helper, but instead maintains a request pending map, notification
9
- * parser, cancellation and process-reaping state.
10
+ * parser and per-turn cancellation state. The service owns transport and process cleanup.
10
11
  *
11
12
  * This module upholds four key invariants:
12
13
  * - the provider session becomes visible to the Core only after turn/start
@@ -14,12 +15,11 @@
14
15
  * - each invocation publishes at most one run.* terminal;
15
16
  * - only notifications for the current active thread are consumed, avoiding
16
17
  * crosstalk;
17
- * - all pending RPCs and subprocess resources eventually converge via
18
- * close()/finally.
18
+ * - close()/finally releases only the current turn's RPCs and subscription.
19
19
  */
20
20
  import { type AdapterInvocationContext, type AdapterOutput, type CanonicalEvent, type InvokeRequest } from "@mininglamp-oss/octo-runtime-adapter-sdk";
21
21
  import { type InteractionResponse, type NativeInteractionResponse } from "@mininglamp-oss/octo-runtime-protocol";
22
- import { type ChildProcessWithoutNullStreams } from "node:child_process";
22
+ import type { ChildProcessWithoutNullStreams } from "node:child_process";
23
23
  type JsonRecord = Record<string, unknown>;
24
24
  export type CodexInteractionResponder = (response: InteractionResponse) => Promise<void>;
25
25
  interface ProcessExit {
@@ -67,10 +67,10 @@ export declare function buildCodexAppServerArgs(): string[];
67
67
  * advancement" and resume fallback; CodexAppServerClient owns wire I/O and
68
68
  * normalizeCodexEvent handles the pure per-notification conversion.
69
69
  */
70
- export declare function runCodexAppServerTurn({ request, spec, spawnFn, context, onInteractionResponder, onNativeResponder }: {
70
+ export declare function runCodexAppServerTurn({ request, spec, channel, context, onInteractionResponder, onNativeResponder }: {
71
71
  request: InvokeRequest;
72
72
  spec: CodexAppServerCommand;
73
- spawnFn?: CodexAppServerSpawn;
73
+ channel?: CodexTurnChannel;
74
74
  context?: AdapterInvocationContext;
75
75
  onInteractionResponder?: (responder: CodexInteractionResponder | undefined) => void;
76
76
  onNativeResponder?: (responder: ((response: NativeInteractionResponse) => Promise<void>) | undefined) => void;