@mininglamp-oss/octo-runtime 1.1.12 → 1.1.14

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 (195) hide show
  1. package/README.md +1 -1
  2. package/apps/cli/dist/adapters.d.ts +19 -1
  3. package/apps/cli/dist/adapters.js +154 -28
  4. package/apps/cli/dist/build-info.json +2 -2
  5. package/apps/cli/dist/codex.d.ts +5 -0
  6. package/apps/cli/dist/codex.js +36 -0
  7. package/apps/cli/dist/kernel.d.ts +4 -0
  8. package/apps/cli/dist/kernel.js +84 -0
  9. package/apps/cli/dist/main.js +8 -7
  10. package/apps/cli/dist/manifest.json +33 -22
  11. package/apps/cli/dist/output.d.ts +1 -0
  12. package/apps/cli/dist/output.js +8 -4
  13. package/apps/cli/dist/playboard.js +21 -12
  14. package/apps/cli/dist/provider-launch.d.ts +28 -0
  15. package/apps/cli/dist/provider-launch.js +52 -0
  16. package/apps/cli/dist/providers.d.ts +182 -0
  17. package/apps/cli/dist/providers.js +34 -0
  18. package/dist/public/adapter-sdk.d.ts +2 -0
  19. package/dist/public/adapter-sdk.js +2 -0
  20. package/dist/public/protocol.d.ts +2 -2
  21. package/dist/public/protocol.js +1 -1
  22. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/dist/index.js +4 -4
  23. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  24. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +26 -10
  25. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +44 -53
  26. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  27. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.d.ts +10 -35
  28. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.js +21 -29
  29. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  30. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/agent-env.d.ts +3 -0
  31. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/agent-env.js +10 -0
  32. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.d.ts +14 -68
  33. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.js +77 -61
  34. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  35. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.d.ts +19 -31
  36. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.js +28 -18
  37. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  38. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/agent-env.d.ts +3 -0
  39. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/agent-env.js +10 -0
  40. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.d.ts +6 -5
  41. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +55 -54
  42. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/engine.d.ts +54 -0
  43. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/engine.js +147 -0
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/environment.js +4 -8
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +20 -92
  46. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +103 -217
  47. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/mcp.d.ts +2 -2
  48. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/mcp.js +4 -11
  49. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.d.ts +9 -5
  50. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.js +77 -81
  51. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  52. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-SMTJTIN7.js → chunk-AE3OJBDS.js} +1 -1
  53. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-H3S6WM37.js → chunk-NGR74QLF.js} +0 -1
  54. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-RISQ6NGV.js → chunk-XIUZ6GXG.js} +1 -1
  55. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.d.ts +0 -1
  56. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +1 -1
  57. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +6 -8
  58. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +16 -21
  59. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +2 -2
  60. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +2 -2
  61. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
  62. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.d.ts +14 -16
  63. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.js +29 -46
  64. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/agent-env.d.ts +3 -0
  65. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/agent-env.js +10 -0
  66. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/client.js +4 -7
  67. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.d.ts +13 -21
  68. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.js +47 -36
  69. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
  70. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.d.ts +24 -8
  71. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.js +14 -7
  72. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  73. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.d.ts +24 -8
  74. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.js +13 -6
  75. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  76. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.d.ts +24 -8
  77. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.js +14 -7
  78. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  79. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +7 -7
  80. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +28 -31
  81. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  82. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +16 -25
  83. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +113 -179
  84. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  85. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.d.ts +24 -8
  86. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.js +14 -6
  87. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +3 -2
  88. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.d.ts +24 -8
  89. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.js +14 -6
  90. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +3 -2
  91. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/activity.d.ts +5 -1
  92. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.d.ts +48 -0
  93. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.js +234 -0
  94. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/approval.js +7 -2
  95. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/environment.js +1 -1
  96. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.d.ts +5 -1
  97. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +25 -14
  98. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +112 -59
  99. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/mcp.js +1 -1
  100. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.d.ts +11 -1
  101. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.js +89 -8
  102. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/provider-launch.d.ts +10 -0
  103. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/provider-launch.js +25 -0
  104. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.js +10 -3
  105. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
  106. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.d.ts +19 -1
  107. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +154 -28
  108. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  109. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/codex.d.ts +5 -0
  110. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/codex.js +36 -0
  111. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/kernel.d.ts +4 -0
  112. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/kernel.js +84 -0
  113. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +8 -7
  114. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +33 -22
  115. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.d.ts +1 -0
  116. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +8 -4
  117. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +21 -12
  118. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/provider-launch.d.ts +28 -0
  119. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/provider-launch.js +52 -0
  120. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/providers.d.ts +182 -0
  121. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/providers.js +34 -0
  122. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +20 -20
  123. package/node_modules/@mininglamp-oss/octo-runtime-client/build-info.json +2 -2
  124. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.js +2 -2
  125. package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +5 -5
  126. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc.schema.json +3 -104
  127. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +166 -1870
  128. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
  129. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +0 -2
  130. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +122 -65
  131. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.d.ts +2 -2
  132. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.js +13 -85
  133. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-output-silence.d.ts +21 -0
  134. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-output-silence.js +176 -0
  135. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.d.ts +3 -2
  136. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +8 -4
  137. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  138. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +1 -1
  139. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +1 -1
  140. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +5 -0
  141. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +17 -20
  142. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +5 -5
  143. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
  144. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.d.ts +1 -1
  145. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.d.ts +0 -2
  146. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.js +0 -2
  147. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.d.ts +0 -1
  148. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.js +3 -9
  149. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-configuration.js +1 -8
  150. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.d.ts +1 -5
  151. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +3 -292
  152. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/experience.js +7 -0
  153. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +2 -0
  154. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +18 -13
  155. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +90 -608
  156. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.js +32 -1
  157. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +7 -18
  158. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +34 -189
  159. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.d.ts +11 -22
  160. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +38 -78
  161. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/multimodal.js +6 -0
  162. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.d.ts +2 -1
  163. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +5 -40
  164. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.js +2 -1
  165. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  166. package/package.json +34 -37
  167. package/packages/octo-runtime-protocol/schema/kernel-ipc.schema.json +3 -104
  168. package/packages/octo-runtime-protocol/schema/protocol.schema.json +166 -1870
  169. package/dist/public/codex.d.ts +0 -1
  170. package/dist/public/codex.js +0 -1
  171. package/dist/public/dsh.d.ts +0 -2
  172. package/dist/public/dsh.js +0 -1
  173. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/actmode.d.ts +0 -5
  174. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/actmode.js +0 -8
  175. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-configuration-fixtures.json +0 -1219
  176. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-fixtures.json +0 -5988
  177. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-client.behavior.json +0 -56
  178. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/native-invoke-fixtures.json +0 -116
  179. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/run-protocol-fixtures.json +0 -761
  180. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/runtime-selection-fixtures.json +0 -663
  181. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/session-name-fixtures.json +0 -191
  182. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/context.d.ts +0 -12
  183. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/context.js +0 -89
  184. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/execution-preparation.d.ts +0 -33
  185. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/execution-preparation.js +0 -93
  186. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.d.ts +0 -4
  187. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.js +0 -36
  188. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.d.ts +0 -3
  189. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.js +0 -80
  190. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.d.ts +0 -3
  191. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.js +0 -9
  192. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.d.ts +0 -3
  193. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.js +0 -68
  194. /package/node_modules/@mininglamp-oss/octo-runtime-client/{schema → fixtures}/kernel-ipc-fixtures.json +0 -0
  195. /package/packages/octo-runtime-protocol/{schema → test/fixtures}/kernel-ipc-fixtures.json +0 -0
@@ -1,6 +1,7 @@
1
- import { readFileSync, statSync } from "node:fs";
2
- import { basename, delimiter, dirname, extname, join, resolve } from "node:path";
1
+ import { accessSync, closeSync, constants, lstatSync, openSync, readFileSync, readSync, realpathSync, statSync } from "node:fs";
2
+ import { basename, delimiter, dirname, extname, isAbsolute, join, resolve } from "node:path";
3
3
  import { processEnvironmentValue } from "./environment.js";
4
+ import { snapshotProviderLaunch } from "./provider-launch.js";
4
5
  function fileSize(file) {
5
6
  try {
6
7
  const info = statSync(file);
@@ -12,26 +13,57 @@ function fileSize(file) {
12
13
  throw error;
13
14
  }
14
15
  }
16
+ /** 有界读取 shebang;无扩展名的 Node 入口也必须在宿主固定运行器。 */
17
+ function isNodeScript(file) {
18
+ let descriptor;
19
+ try {
20
+ descriptor = openSync(file, "r");
21
+ }
22
+ catch (error) {
23
+ // 原生文件可以只有执行权限;读 shebang 不是原生 exec 的先决条件。
24
+ if (error.code === "EACCES")
25
+ return false;
26
+ throw error;
27
+ }
28
+ try {
29
+ const header = Buffer.alloc(256);
30
+ const length = readSync(descriptor, header, 0, header.length, 0);
31
+ const firstLine = header.toString("utf8", 0, length).split("\n", 1)[0];
32
+ if (!firstLine.startsWith("#!"))
33
+ return /\.[cm]?js$/i.test(file);
34
+ if (!/^#![^\r\n]*[/\s]node(?:\s|$)/.test(firstLine))
35
+ return false;
36
+ if (!/^#!\s*(?:\S*\/env\s+node|\S*\/node)\s*$/.test(firstLine))
37
+ throw new TypeError("PROVIDER_LAUNCH_INVALID: inject Node and shebang arguments explicitly");
38
+ return true;
39
+ }
40
+ finally {
41
+ closeSync(descriptor);
42
+ }
43
+ }
15
44
  function commandPath(command, env, cwd) {
16
45
  if (/[/\\]/.test(command) || /^[A-Za-z]:/.test(command))
17
46
  return resolve(cwd, command);
18
- const extensions = extname(command)
47
+ const extensions = process.platform !== "win32" || extname(command)
19
48
  ? [""]
20
49
  : (processEnvironmentValue(env, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD")
21
50
  .split(";")
22
51
  .filter((extension) => /^\.(exe|com|cmd|bat)$/i.test(extension));
23
- const path = processEnvironmentValue(env, "PATH") ?? processEnvironmentValue(process.env, "PATH") ?? "";
24
- for (const directory of [cwd, ...path.split(delimiter)]) {
52
+ const path = processEnvironmentValue(env, "PATH") ?? "";
53
+ const directories = process.platform === "win32" ? [cwd, ...path.split(delimiter)] : path.split(delimiter);
54
+ for (const directory of directories) {
25
55
  for (const extension of extensions) {
26
56
  const candidate = resolve(cwd, directory.replace(/^"(.*)"$/, "$1"), command + extension);
27
- if (fileSize(candidate) !== undefined)
57
+ if (fileSize(candidate) !== undefined) {
58
+ accessSync(candidate, process.platform === "win32" ? constants.F_OK : constants.X_OK);
28
59
  return candidate;
60
+ }
29
61
  }
30
62
  }
31
63
  return undefined;
32
64
  }
33
65
  /**
34
- * 在 Provider 启动和版本探测前同步解析 Windows npm 包装器,保持 spawn 的同步返回合同。
66
+ * 仅由宿主在装配时解析 Windows npm 包装器;Adapter 和 transport 不调用此函数。
35
67
  * JS 入口交给 Node,原生入口直接执行;argv 独立传递,未知 batch 沿原路径报错。
36
68
  * 返回启动命令和参数;ChildProcess、管道及清理仍由调用方负责。
37
69
  */
@@ -86,6 +118,55 @@ export function resolveProcessLaunch(command, args, { env = process.env, cwd = p
86
118
  ? pathNode
87
119
  : basename(process.execPath).toLowerCase() === "node.exe"
88
120
  ? process.execPath
89
- : "node";
121
+ : undefined;
122
+ if (!node)
123
+ throw Object.assign(new Error("Provider Node runtime not found"), { code: "ENOENT" });
90
124
  return { command: node, args: [entry, ...args] };
91
125
  }
126
+ /**
127
+ * 仅供宿主装配调用:选择一个安装并解析 npm/Node 启动链,返回可注入快照。
128
+ * 首个已有候选损坏时立即失败,不换安装;不校验协议版本、不安装或启动程序。
129
+ */
130
+ export function resolveHostProviderLaunch(command, { env, cwd, args = [] }) {
131
+ if (!command || command.includes("\0"))
132
+ throw new TypeError("PROVIDER_LAUNCH_INVALID");
133
+ const qualified = isAbsolute(command) || /[/\\]/.test(command) || /^[A-Za-z]:/.test(command);
134
+ const extensions = process.platform === "win32" && !extname(command)
135
+ ? (processEnvironmentValue(env, "PATHEXT") ?? ".EXE;.CMD;.BAT;.COM").split(";")
136
+ : [""];
137
+ const directories = qualified
138
+ ? [""]
139
+ : (processEnvironmentValue(env, "PATH") ?? "").split(delimiter);
140
+ let selected;
141
+ for (const directory of directories) {
142
+ for (const extension of extensions) {
143
+ const candidate = resolve(cwd, directory.replace(/^"(.*)"$/, "$1"), command + extension);
144
+ try {
145
+ lstatSync(candidate);
146
+ }
147
+ catch (error) {
148
+ if (["ENOENT", "ENOTDIR"].includes(error.code ?? ""))
149
+ continue;
150
+ throw error;
151
+ }
152
+ accessSync(candidate, process.platform === "win32" ? constants.F_OK : constants.X_OK);
153
+ if (!statSync(candidate).isFile())
154
+ throw new TypeError("PROVIDER_LAUNCH_INVALID");
155
+ selected = candidate;
156
+ break;
157
+ }
158
+ if (selected)
159
+ break;
160
+ }
161
+ if (!selected)
162
+ throw Object.assign(new Error("Provider command not found"), { code: "ENOENT" });
163
+ let launch = resolveProcessLaunch(selected, args, { env, cwd });
164
+ const physical = realpathSync(selected);
165
+ if (process.platform !== "win32" && isNodeScript(physical)) {
166
+ const node = process.versions.electron ? commandPath("node", env, cwd) : process.execPath;
167
+ if (!node)
168
+ throw Object.assign(new Error("Provider Node runtime not found"), { code: "ENOENT" });
169
+ launch = { command: node, args: [physical, ...args] };
170
+ }
171
+ return snapshotProviderLaunch({ ...launch, env });
172
+ }
@@ -0,0 +1,10 @@
1
+ /** 宿主已选定的本地启动目标;args 只含运行器/入口前缀,协议参数由 Adapter 追加。 */
2
+ export interface ProviderLaunch {
3
+ command: string;
4
+ args?: readonly string[];
5
+ env?: NodeJS.ProcessEnv;
6
+ }
7
+ /** 构造时复制宿主绑定,不发现安装、不启动程序;本轮环境不能重新选择 executable。 */
8
+ export declare function snapshotProviderLaunch(launch: ProviderLaunch): Required<ProviderLaunch>;
9
+ /** 纯执行层只接受已解析的绝对路径;不解析 PATH、cwd、shim 或备用安装。 */
10
+ export declare function assertProviderCommand(command: unknown): asserts command is string;
@@ -0,0 +1,25 @@
1
+ import { isAbsolute } from "node:path";
2
+ /** 构造时复制宿主绑定,不发现安装、不启动程序;本轮环境不能重新选择 executable。 */
3
+ export function snapshotProviderLaunch(launch) {
4
+ assertProviderCommand(launch?.command);
5
+ const args = launch.args ?? [];
6
+ if (!Array.isArray(args) ||
7
+ args.some((arg) => typeof arg !== "string" || arg.includes("\0")))
8
+ throw new TypeError("PROVIDER_LAUNCH_INVALID");
9
+ return Object.freeze({
10
+ command: launch.command,
11
+ args: Object.freeze(Array.from(args, (arg) => {
12
+ if (typeof arg !== "string")
13
+ throw new TypeError("PROVIDER_LAUNCH_INVALID");
14
+ return arg;
15
+ })),
16
+ env: Object.freeze({ ...(launch.env ?? {}) })
17
+ });
18
+ }
19
+ /** 纯执行层只接受已解析的绝对路径;不解析 PATH、cwd、shim 或备用安装。 */
20
+ export function assertProviderCommand(command) {
21
+ if (command === undefined)
22
+ throw new TypeError("PROVIDER_LAUNCH_REQUIRED");
23
+ if (typeof command !== "string" || !command || command.includes("\0") || !isAbsolute(command))
24
+ throw new TypeError("PROVIDER_LAUNCH_INVALID");
25
+ }
@@ -30,10 +30,17 @@ export function sanitizeDiagnosticBody(body) {
30
30
  safe = "[REDACTED]";
31
31
  // Headers can occur inside a JSON message too. Drop the entire suffix at the first
32
32
  // sensitive key instead of guessing where a spaced or truncated credential ends.
33
- const keys = /["']?([\w-]+)[\\"']*\s*[:=]/g;
33
+ // 先消费完整 key,再单向检查分隔符,避免无分隔符长输入反复回溯后缀。
34
+ const keys = /[\w-]+/g;
34
35
  for (const match of safe.matchAll(keys)) {
35
- if (SENSITIVE_OUTPUT_KEY.test(match[1])) {
36
- safe = `${safe.slice(0, match.index)}[REDACTED]`;
36
+ let end = match.index + match[0].length;
37
+ while (end < safe.length && /[\\"']/.test(safe[end]))
38
+ end += 1;
39
+ while (end < safe.length && /\s/.test(safe[end]))
40
+ end += 1;
41
+ if ((safe[end] === ":" || safe[end] === "=") && SENSITIVE_OUTPUT_KEY.test(match[0])) {
42
+ const start = match.index > 0 && /["']/.test(safe[match.index - 1]) ? match.index - 1 : match.index;
43
+ safe = `${safe.slice(0, start)}[REDACTED]`;
37
44
  break;
38
45
  }
39
46
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-sdk",
3
- "version": "1.1.12",
3
+ "version": "1.1.14",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -10,7 +10,7 @@
10
10
  "./module-manifest": "./dist/module-manifest.js"
11
11
  },
12
12
  "dependencies": {
13
- "@mininglamp-oss/octo-runtime-protocol": "1.1.12",
13
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.14",
14
14
  "import-meta-resolve": "4.2.0"
15
15
  },
16
16
  "types": "./dist/index.d.ts",
@@ -1,7 +1,25 @@
1
1
  import { type AdapterModuleEntry } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
2
2
  import type { HostedAdapter } from "@mininglamp-oss/octo-runtime-executor-kernel";
3
+ import { type ServiceCleanupResult } from "@mininglamp-oss/octo-runtime-executor-kernel";
4
+ import type { AdapterScopeCleanup, ServiceProcessSnapshot } from "@mininglamp-oss/octo-runtime-adapter-sdk";
5
+ /** CLI 默认每种 Harness 一个自有实例;工厂不按调用分池,SDK 自管装配不受此约定限制。 */
6
+ export interface CliAdapterResource {
7
+ adapter: HostedAdapter;
8
+ processes?(): readonly ServiceProcessSnapshot[];
9
+ beginShutdown?(): void;
10
+ close(deadline: number): Promise<AdapterScopeCleanup>;
11
+ }
12
+ export interface CliAdapters {
13
+ adapters: HostedAdapter[];
14
+ processes(): readonly ServiceProcessSnapshot[];
15
+ beginShutdown(): void;
16
+ close(deadline: number): Promise<AdapterScopeCleanup>;
17
+ }
3
18
  /** CLI 只加载所选模块并构造实例;Kernel 不接触清单、模块路径或产品准备。 */
4
19
  export declare function loadCliAdapters(entries: readonly AdapterModuleEntry[], options?: {
5
20
  profileRoot: string;
6
21
  syncOpenClawTools: boolean;
7
- }): Promise<HostedAdapter[]>;
22
+ env?: NodeJS.ProcessEnv;
23
+ }): Promise<CliAdapters>;
24
+ /** 将宿主资源清理事实投影到既有启动诊断;主失败与 pending/failed 资源分别保留。 */
25
+ export declare function cliCleanupResult(cleanup: AdapterScopeCleanup): ServiceCleanupResult;
@@ -1,41 +1,166 @@
1
1
  import { resolveModuleSpecifier } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
2
- import { withStartupContext } from "@mininglamp-oss/octo-runtime-executor-kernel";
2
+ import { withStartupContext, ServiceInitializationError } from "@mininglamp-oss/octo-runtime-executor-kernel";
3
3
  /** CLI 只加载所选模块并构造实例;Kernel 不接触清单、模块路径或产品准备。 */
4
4
  export async function loadCliAdapters(entries, options) {
5
5
  const adapters = [];
6
+ const resources = [];
7
+ const pending = new Map();
8
+ const completed = new Map();
9
+ const types = new Set();
10
+ const assembly = {
11
+ adapters,
12
+ processes: () => resources.flatMap((r) => [...(r.processes?.() ?? [])]),
13
+ beginShutdown() {
14
+ const errors = [];
15
+ for (const resource of resources) {
16
+ try {
17
+ resource.beginShutdown?.();
18
+ }
19
+ catch (error) {
20
+ errors.push(error);
21
+ }
22
+ }
23
+ if (errors.length)
24
+ throw new AggregateError(errors, "CLI_ENGINE_SHUTDOWN_FAILED");
25
+ },
26
+ async close(deadline) {
27
+ if (!Number.isFinite(deadline))
28
+ throw new TypeError("CLEANUP_DEADLINE_INVALID");
29
+ // 按构造逆序释放依赖;每个 disposer 只启动一次,到期仍尝试其余独立资源。
30
+ for (const [index, resource] of [...resources.entries()].reverse()) {
31
+ if (!pending.has(resource)) {
32
+ pending.set(resource, Promise.resolve()
33
+ .then(() => resource.close(deadline))
34
+ .then((result) => {
35
+ // JS 工厂可能违反类型合同;坏结果也必须成为清理失败,不能打断其他 disposer。
36
+ if (!isScopeCleanup(result))
37
+ throw new TypeError("CLI_RESOURCE_CLEANUP_INVALID");
38
+ completed.set(resource, !result.complete && !result.unresolvedServiceIds.length
39
+ ? { ...result, unresolvedServiceIds: [`cli-adapter-${index}`] }
40
+ : result);
41
+ })
42
+ .catch(() => {
43
+ completed.set(resource, {
44
+ complete: false,
45
+ unresolvedServiceIds: [`cli-adapter-${index}`],
46
+ failedCleanupServiceIds: [`cli-adapter-${index}`]
47
+ });
48
+ }));
49
+ }
50
+ let timer;
51
+ if (performance.now() >= deadline) {
52
+ await Promise.resolve();
53
+ continue;
54
+ }
55
+ try {
56
+ await Promise.race([
57
+ pending.get(resource),
58
+ new Promise((done) => {
59
+ timer = setTimeout(done, Math.max(0, deadline - performance.now()));
60
+ })
61
+ ]);
62
+ }
63
+ finally {
64
+ clearTimeout(timer);
65
+ }
66
+ }
67
+ const results = resources.map((resource, index) => completed.get(resource) ?? {
68
+ complete: false,
69
+ unresolvedServiceIds: [`cli-adapter-${index}`],
70
+ failedCleanupServiceIds: []
71
+ });
72
+ return {
73
+ complete: results.every((r) => r.complete && !r.unresolvedServiceIds.length && !r.failedCleanupServiceIds.length),
74
+ unresolvedServiceIds: results.flatMap((r) => [...r.unresolvedServiceIds]),
75
+ failedCleanupServiceIds: results.flatMap((r) => [...r.failedCleanupServiceIds])
76
+ };
77
+ }
78
+ };
6
79
  // 解析也在诊断边界内;仍先解析整个所选集合,再导入/构造,保持 CLI 原顺序。
80
+ const declaredTypes = new Set();
7
81
  const selected = entries.map((entry) => {
8
82
  try {
83
+ // 已声明类型在任何工厂运行前拒绝重复,避免先创建第二个受管 Harness。
84
+ if (entry.type) {
85
+ if (declaredTypes.has(entry.type))
86
+ throw new Error(`CLI_HARNESS_TYPE_DUPLICATE: ${entry.type}`);
87
+ declaredTypes.add(entry.type);
88
+ }
9
89
  return { entry, specifier: resolveModuleSpecifier(entry.module, entry.sourceManifest) };
10
90
  }
11
91
  catch (error) {
12
92
  throw adapterStartupFailure(error, entry);
13
93
  }
14
94
  });
15
- for (const { entry, specifier } of selected) {
16
- try {
17
- const loaded = await import(specifier);
18
- const exports = asRecord(loaded, `adapter module ${entry.module}`);
19
- const exported = exports[entry.export];
20
- if (exported === undefined)
21
- throw new Error(`missing export ${entry.export} from ${entry.module}`);
22
- // 动态模块先校验工厂与 Adapter 形状,再交给唯一 Core 注册;不提前探测未选模块。
23
- const instance = entry.factory ? callFactory(exported, entry) : exported;
24
- if (!isHostedAdapter(instance))
25
- throw new TypeError(`${entry.module}#${entry.export} is not an Octo Runtime adapter`);
26
- if (entry.type && instance.metadata.type !== entry.type)
27
- throw new Error(`manifest type ${entry.type} does not match adapter ${instance.metadata.type}`);
28
- adapters.push(instance);
95
+ try {
96
+ for (const { entry, specifier } of selected) {
97
+ try {
98
+ const loaded = await import(specifier);
99
+ const exports = asRecord(loaded, `adapter module ${entry.module}`);
100
+ const exported = exports[entry.export];
101
+ if (exported === undefined)
102
+ throw new Error(`missing export ${entry.export} from ${entry.module}`);
103
+ // 动态模块先校验工厂与 Adapter 形状,再交给唯一 Core 注册;不提前探测未选模块。
104
+ const constructed = entry.factory
105
+ ? await callFactory(exported, entry, options?.env ?? process.env)
106
+ : exported;
107
+ const resource = isRecord(constructed) &&
108
+ typeof constructed.close === "function" &&
109
+ "adapter" in constructed
110
+ ? constructed
111
+ : undefined;
112
+ if (resource)
113
+ resources.push(resource);
114
+ const instance = resource ? resource.adapter : constructed;
115
+ if (!isHostedAdapter(instance))
116
+ throw new TypeError(`${entry.module}#${entry.export} is not an Octo Runtime adapter`);
117
+ if (entry.type && instance.metadata.type !== entry.type)
118
+ throw new Error(`manifest type ${entry.type} does not match adapter ${instance.metadata.type}`);
119
+ if (types.has(instance.metadata.type))
120
+ throw new Error(`CLI_HARNESS_TYPE_DUPLICATE: ${instance.metadata.type}`);
121
+ types.add(instance.metadata.type);
122
+ adapters.push(instance);
123
+ }
124
+ catch (error) {
125
+ throw adapterStartupFailure(error, entry);
126
+ }
29
127
  }
30
- catch (error) {
31
- throw adapterStartupFailure(error, entry);
128
+ if (options && adapters.some((adapter) => adapter.metadata.type === "openclaw")) {
129
+ const { initializeCliOpenClaw } = await import("./openclaw.js");
130
+ await initializeCliOpenClaw(options.profileRoot);
32
131
  }
132
+ return assembly;
33
133
  }
34
- if (options && adapters.some((adapter) => adapter.metadata.type === "openclaw")) {
35
- const { initializeCliOpenClaw } = await import("./openclaw.js");
36
- await initializeCliOpenClaw(options.profileRoot);
134
+ catch (error) {
135
+ const cleanup = await assembly.close(performance.now() + 2500);
136
+ if (!cleanup.complete)
137
+ throw new ServiceInitializationError(error, cliCleanupResult(cleanup), {
138
+ component: "cli",
139
+ phase: "created"
140
+ });
141
+ throw error;
37
142
  }
38
- return adapters;
143
+ }
144
+ /** 将宿主资源清理事实投影到既有启动诊断;主失败与 pending/failed 资源分别保留。 */
145
+ export function cliCleanupResult(cleanup) {
146
+ const complete = cleanup.complete &&
147
+ !cleanup.unresolvedServiceIds.length &&
148
+ !cleanup.failedCleanupServiceIds.length;
149
+ return {
150
+ complete,
151
+ errors: complete
152
+ ? []
153
+ : [
154
+ { resource: "engines", code: "ENGINE_CLEANUP_INCOMPLETE" },
155
+ ...cleanup.failedCleanupServiceIds.map((resource) => ({
156
+ resource,
157
+ code: "ENGINE_CLEANUP_FAILED"
158
+ }))
159
+ ],
160
+ pendingResources: [
161
+ ...new Set([...cleanup.unresolvedServiceIds, ...cleanup.failedCleanupServiceIds])
162
+ ]
163
+ };
39
164
  }
40
165
  function adapterStartupFailure(error, entry) {
41
166
  return withStartupContext(error, {
@@ -49,19 +174,20 @@ function adapterStartupFailure(error, entry) {
49
174
  }
50
175
  });
51
176
  }
52
- function callFactory(value, entry) {
177
+ function callFactory(value, entry, env) {
53
178
  if (typeof value !== "function")
54
179
  throw new TypeError(`${entry.module}#${entry.export} is marked as a factory but is not callable`);
55
- return value(entry.options);
180
+ return value(entry.options, { env });
56
181
  }
57
182
  function isHostedAdapter(value) {
58
183
  if (!isRecord(value) || !isRecord(value.metadata))
59
184
  return false;
60
- return (typeof value.metadata.type === "string" &&
61
- Array.isArray(value.metadata.agentSources) &&
62
- value.metadata.agentSources.length > 0 &&
63
- value.metadata.agentSources.every((source) => source === "preset" || source === "provisioned") &&
64
- typeof value.invoke === "function");
185
+ return typeof value.metadata.type === "string" && typeof value.invoke === "function";
186
+ }
187
+ function isScopeCleanup(value) {
188
+ if (!isRecord(value) || typeof value.complete !== "boolean")
189
+ return false;
190
+ return [value.unresolvedServiceIds, value.failedCleanupServiceIds].every((ids) => Array.isArray(ids) && ids.every((id) => typeof id === "string"));
65
191
  }
66
192
  function asRecord(value, label) {
67
193
  if (!isRecord(value))
@@ -1,5 +1,5 @@
1
1
  {
2
- "commit": "4276f6d339461daa88c3215b8024d548eb313cb1",
2
+ "commit": "c9d3bb6a642abce3177ac28cf9f26993909c3d32",
3
3
  "dirty": false,
4
- "buildTime": "2026-11-09T03:16:42.298Z"
4
+ "buildTime": "2026-11-10T17:37:37.695Z"
5
5
  }
@@ -0,0 +1,5 @@
1
+ import type { CliAdapterResource } from "./adapters.js";
2
+ /** CLI 在实际服务进程选择默认 Home 并持有 owner;库和 Adapter 不决定目录生命周期。 */
3
+ export declare function createCliCodexAdapter(options: Record<string, unknown>, context: {
4
+ env: NodeJS.ProcessEnv;
5
+ }): CliAdapterResource;
@@ -0,0 +1,36 @@
1
+ import { homedir } from "node:os";
2
+ import { join } from "node:path";
3
+ import { createCodexAdapter, codexMetadata, createManagedCodexEngine } from "@mininglamp-oss/octo-runtime-adapter-codex";
4
+ import { processEnvironmentValue } from "@mininglamp-oss/octo-runtime-adapter-sdk";
5
+ import { cliProviderLaunch, unavailableCliAdapter } from "./provider-launch.js";
6
+ /** CLI 在实际服务进程选择默认 Home 并持有 owner;库和 Adapter 不决定目录生命周期。 */
7
+ export function createCliCodexAdapter(options, context) {
8
+ const codexHome = options.codexHome ??
9
+ processEnvironmentValue(context.env, "CODEX_HOME") ??
10
+ join(homedir(), ".codex");
11
+ if (typeof codexHome !== "string" ||
12
+ (options.command !== undefined && typeof options.command !== "string") ||
13
+ (options.appServerArgs !== undefined &&
14
+ (!Array.isArray(options.appServerArgs) ||
15
+ !options.appServerArgs.every((v) => typeof v === "string"))))
16
+ throw new TypeError("CODEX_CONFIGURATION_INVALID");
17
+ const selected = cliProviderLaunch(options, context.env, "codex");
18
+ if (!selected.launch)
19
+ return {
20
+ adapter: unavailableCliAdapter(codexMetadata, selected.reason, selected.command),
21
+ close: () => Promise.resolve({ complete: true, unresolvedServiceIds: [], failedCleanupServiceIds: [] })
22
+ };
23
+ const owner = createManagedCodexEngine({
24
+ codexHome,
25
+ env: selected.launch.env,
26
+ command: selected.launch.command,
27
+ commandArgsPrefix: selected.launch.args,
28
+ appServerArgs: options.appServerArgs
29
+ });
30
+ return {
31
+ adapter: createCodexAdapter({ engine: owner.provider }),
32
+ processes: () => owner.processes(),
33
+ beginShutdown: () => owner.beginShutdown(),
34
+ close: (deadline) => owner.close({ deadline })
35
+ };
36
+ }
@@ -0,0 +1,4 @@
1
+ import { type KernelService, type KernelServiceOptions } from "@mininglamp-oss/octo-runtime-executor-kernel";
2
+ import { type CliAdapters } from "./adapters.js";
3
+ /** CLI 显式拥有装配资源;Kernel 只关闭自身调用,最后由此宿主关闭 Engine owner。 */
4
+ export declare function createCliKernelService(options: Omit<KernelServiceOptions, "adapters">, assembly: CliAdapters): Promise<KernelService>;
@@ -0,0 +1,84 @@
1
+ import { createKernelService, ServiceInitializationError } from "@mininglamp-oss/octo-runtime-executor-kernel";
2
+ import { cliCleanupResult } from "./adapters.js";
3
+ /** CLI 显式拥有装配资源;Kernel 只关闭自身调用,最后由此宿主关闭 Engine owner。 */
4
+ export async function createCliKernelService(options, assembly) {
5
+ let kernel;
6
+ try {
7
+ kernel = createKernelService({
8
+ ...options,
9
+ adapters: assembly.adapters,
10
+ serviceProcesses: () => assembly.processes(),
11
+ async finalizeHostResources(deadline) {
12
+ const cleanup = await assembly.close(deadline);
13
+ if (!cleanup.complete)
14
+ throw new Error("ENGINE_CLEANUP_INCOMPLETE", { cause: cleanup });
15
+ }
16
+ });
17
+ }
18
+ catch (error) {
19
+ const result = await assembly.close(performance.now() + 2500);
20
+ if (!result.complete)
21
+ throw new ServiceInitializationError(error, cliCleanupResult(result), {
22
+ component: "cli",
23
+ phase: "created"
24
+ });
25
+ throw error;
26
+ }
27
+ let closing;
28
+ let finish;
29
+ const closed = new Promise((resolve) => {
30
+ finish = resolve;
31
+ });
32
+ const close = () => (closing ??= (async () => {
33
+ const deadline = performance.now() + 5000;
34
+ const errors = [];
35
+ const pendingResources = [];
36
+ let cleanupError;
37
+ try {
38
+ assembly.beginShutdown();
39
+ }
40
+ catch {
41
+ errors.push({ resource: "engines", code: "ENGINE_SHUTDOWN_FAILED" });
42
+ }
43
+ try {
44
+ const result = await kernel.close();
45
+ errors.push(...result.errors);
46
+ pendingResources.push(...result.pendingResources);
47
+ if (!result.complete && !result.errors.length)
48
+ errors.push({ resource: "kernel", code: "KERNEL_CLEANUP_INCOMPLETE" });
49
+ }
50
+ catch (error) {
51
+ cleanupError = error;
52
+ errors.push({ resource: "kernel", code: "KERNEL_CLEANUP_INCOMPLETE" });
53
+ }
54
+ const engines = await assembly.close(deadline);
55
+ const engineCleanup = cliCleanupResult(engines);
56
+ errors.push(...engineCleanup.errors);
57
+ pendingResources.push(...engineCleanup.pendingResources);
58
+ const result = { complete: !errors.length, errors, pendingResources };
59
+ finish(result);
60
+ if (cleanupError)
61
+ throw cleanupError instanceof Error
62
+ ? cleanupError
63
+ : new Error("KERNEL_CLEANUP_INCOMPLETE", { cause: cleanupError });
64
+ return result;
65
+ })());
66
+ void kernel.closed.then(() => close()).catch(() => { });
67
+ // initialize 自身失败也走统一 disposer;保留主原因和所有独立清理事实。
68
+ return {
69
+ get client() {
70
+ return kernel.client;
71
+ },
72
+ async initialize(options) {
73
+ try {
74
+ await kernel.initialize(options);
75
+ }
76
+ catch (error) {
77
+ throw new ServiceInitializationError(error, await close().catch(() => closed));
78
+ }
79
+ },
80
+ status: () => kernel.status(),
81
+ close,
82
+ closed
83
+ };
84
+ }
@@ -1,7 +1,8 @@
1
1
  import { loadCliAdapters } from "./adapters.js";
2
+ import { createCliKernelService } from "./kernel.js";
2
3
  import { once } from "node:events";
3
4
  import { join, resolve } from "node:path";
4
- import { attachKernel, acknowledgeOrphanCleanup, inspectOrphanCleanup, createKernelService, safeStartupValue } from "@mininglamp-oss/octo-runtime-executor-kernel";
5
+ import { attachKernel, acknowledgeOrphanCleanup, inspectOrphanCleanup, safeStartupValue } from "@mininglamp-oss/octo-runtime-executor-kernel";
5
6
  import { componentEndpoint, validateRuntimeHome, RuntimeHomeError } from "@mininglamp-oss/octo-runtime-host-sdk";
6
7
  import { cliVersionInfo, lifecycleCommands } from "./help.js";
7
8
  import { parseCliCommand } from "./command-tree.js";
@@ -230,17 +231,17 @@ export async function runCli(args, dependencies = {}) {
230
231
  let handle;
231
232
  {
232
233
  const config = await readJsonFile(paths.profileConfig);
233
- handle = createKernelService({
234
+ handle = await createCliKernelService({
234
235
  home,
235
236
  logging: { directory: join(home, "logs") },
236
237
  endpoint: kernelEndpoint(),
237
238
  stateDirectory: kernelStateDirectory,
238
- adapters: await loadCliAdapters(manifest.adapters, {
239
- profileRoot: paths.profileRoot,
240
- syncOpenClawTools: true
241
- }),
242
239
  adapterConfigurations: await readCliAdapterConfigurations(paths.profileRoot, config?.adapters, manifest, dependencies.env ?? process.env)
243
- });
240
+ }, await loadCliAdapters(manifest.adapters, {
241
+ profileRoot: paths.profileRoot,
242
+ syncOpenClawTools: true,
243
+ env: dependencies.env ?? process.env
244
+ }));
244
245
  }
245
246
  return await runForegroundService(handle, () => publish({ component, state: "ready" }, `${component}: ready`), async (error) => {
246
247
  try {