@mininglamp-oss/octo-runtime 1.1.5 → 1.1.6

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 (96) hide show
  1. package/apps/cli/dist/adapter-configurations.d.ts +4 -0
  2. package/apps/cli/dist/adapter-configurations.js +102 -0
  3. package/apps/cli/dist/build-info.json +2 -2
  4. package/apps/cli/dist/command-tree.js +1 -1
  5. package/apps/cli/dist/logs.js +8 -4
  6. package/apps/cli/dist/main.js +11 -5
  7. package/apps/cli/dist/output.js +5 -0
  8. package/apps/cli/dist/playboard.js +3 -2
  9. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/dist/index.js +5 -2
  10. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  11. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  12. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  13. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  14. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.d.ts +3 -4
  15. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.js +161 -26
  16. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  17. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +3 -1
  18. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  19. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-G5PWGRL5.js → chunk-3GXX5VD5.js} +24 -90
  20. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-UOQRXV3Q.js → chunk-FWAPYRV2.js} +1 -1
  21. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-DYOJCNWF.js → chunk-IW62UM3C.js} +1 -1
  22. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.d.ts +1 -1
  23. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +1 -1
  24. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +3 -3
  25. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.d.ts +1 -1
  26. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +2 -2
  27. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +2 -2
  28. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
  29. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/client.js +8 -2
  30. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
  31. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  32. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  33. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  34. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  35. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  36. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
  37. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
  38. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +1 -1
  39. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +8 -4
  40. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.d.ts +12 -0
  41. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.js +91 -0
  42. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log-worker.js +2 -2
  43. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log.js +13 -1
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.d.ts +9 -0
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.js +40 -0
  46. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +3 -2
  47. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
  48. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.d.ts +4 -0
  49. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.js +102 -0
  50. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  51. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +1 -1
  52. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/logs.js +8 -4
  53. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +11 -5
  54. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +5 -0
  55. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +3 -2
  56. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +24 -24
  57. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
  58. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +8 -3
  59. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +47 -4
  60. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  61. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.js +2 -0
  62. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.js +4 -1
  63. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.d.ts +7 -0
  64. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.js +79 -5
  65. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +3 -1
  66. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +22 -6
  67. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.js +2 -1
  68. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.d.ts +5 -3
  69. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.js +12 -6
  70. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.d.ts +4 -2
  71. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.js +131 -43
  72. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -4
  73. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/context-gap.js +2 -2
  74. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +33 -17
  75. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.js +3 -0
  76. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/model-wait.d.ts +29 -0
  77. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/model-wait.js +171 -0
  78. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.d.ts +4 -1
  79. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.js +48 -6
  80. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/run-projector.d.ts +2 -0
  81. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.js +1 -1
  82. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/reasoning-frame.js +37 -0
  83. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
  84. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
  85. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
  86. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.d.ts +2 -0
  87. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.js +5 -3
  88. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
  89. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +2 -1
  90. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +9 -1
  91. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +9 -0
  92. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  93. package/package.json +27 -27
  94. package/packages/octo-runtime-protocol/schema/protocol.schema.json +14 -0
  95. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/desktop-entry.d.ts +0 -1
  96. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/desktop-entry.js +0 -16
@@ -0,0 +1,4 @@
1
+ import type { ModuleManifest } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
2
+ import { readAdapterConfigurations } from "@mininglamp-oss/octo-runtime-executor-kernel";
3
+ /** CLI 宿主在创建 Kernel 前补齐 npm DSH 入口;探测与调用共享快照,显式配置始终优先。 */
4
+ export declare function readCliAdapterConfigurations(profileRoot: string, adapters: unknown, manifest: ModuleManifest, env?: NodeJS.ProcessEnv): Promise<ReturnType<typeof readAdapterConfigurations>>;
@@ -0,0 +1,102 @@
1
+ import { constants } from "node:fs";
2
+ import { access, lstat, readFile, realpath, stat } from "node:fs/promises";
3
+ import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
4
+ import { processEnvironmentValue } from "@mininglamp-oss/octo-runtime-adapter-sdk";
5
+ import { readAdapterConfigurations } from "@mininglamp-oss/octo-runtime-executor-kernel";
6
+ /** CLI 宿主在创建 Kernel 前补齐 npm DSH 入口;探测与调用共享快照,显式配置始终优先。 */
7
+ export async function readCliAdapterConfigurations(profileRoot, adapters, manifest, env = process.env) {
8
+ const configurations = readAdapterConfigurations(profileRoot, adapters);
9
+ if (configurations.dsh?.providerOptions?.dshBin !== undefined ||
10
+ !manifest.adapters.some((entry) => entry.type === "dsh" || entry.type === undefined))
11
+ return configurations;
12
+ const dshBin = await discoverDshEntry(env);
13
+ if (dshBin)
14
+ configurations.dsh = {
15
+ ...configurations.dsh,
16
+ providerOptions: { ...configurations.dsh?.providerOptions, dshBin }
17
+ };
18
+ return configurations;
19
+ }
20
+ async function discoverDshEntry(env) {
21
+ const extensions = process.platform === "win32"
22
+ ? (processEnvironmentValue(env, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";")
23
+ : [""];
24
+ for (const directory of (processEnvironmentValue(env, "PATH") ?? "").split(delimiter)) {
25
+ if (!directory)
26
+ continue;
27
+ for (const extension of extensions) {
28
+ const command = resolve(directory, `dsh${extension}`);
29
+ // 只有路径不存在才能继续;lstat 保留损坏链接,首个已存在候选不可因不可用而换安装。
30
+ try {
31
+ await lstat(command);
32
+ }
33
+ catch (error) {
34
+ const code = error.code;
35
+ if (code === "ENOENT" || code === "ENOTDIR")
36
+ continue;
37
+ return;
38
+ }
39
+ try {
40
+ await access(command, process.platform === "win32" ? constants.F_OK : constants.X_OK);
41
+ if (!(await stat(command)).isFile())
42
+ return;
43
+ }
44
+ catch {
45
+ return;
46
+ }
47
+ // 先固定 PATH 中的命令,再读取安装元数据;不执行 shim,也不因版本不兼容换另一安装。
48
+ return packageEntryForCommand(command);
49
+ }
50
+ }
51
+ }
52
+ async function packageEntryForCommand(command) {
53
+ let target;
54
+ try {
55
+ target = await realpath(command);
56
+ }
57
+ catch {
58
+ return;
59
+ }
60
+ // npm 在 Unix 上使用符号链接;从链接目标向上确认包名,兼容自定义 prefix。
61
+ for (let directory = dirname(target);; directory = dirname(directory)) {
62
+ const entry = await packageEntry(directory);
63
+ if (entry)
64
+ return entry;
65
+ if (directory === dirname(directory))
66
+ break;
67
+ }
68
+ const binDirectory = dirname(command);
69
+ // Windows npm shim、Unix 全局 prefix/bin、以及项目 node_modules/.bin 均只读相邻安装。
70
+ for (const directory of [
71
+ join(binDirectory, "node_modules", "@deepseek-ai", "dsh"),
72
+ join(binDirectory, "..", "lib", "node_modules", "@deepseek-ai", "dsh"),
73
+ join(binDirectory, "..", "@deepseek-ai", "dsh")
74
+ ]) {
75
+ const entry = await packageEntry(directory);
76
+ if (entry)
77
+ return entry;
78
+ }
79
+ }
80
+ async function packageEntry(directory) {
81
+ try {
82
+ const metadata = JSON.parse(await readFile(join(directory, "package.json"), "utf8"));
83
+ if (metadata?.name !== "@deepseek-ai/dsh")
84
+ return;
85
+ const bin = typeof metadata.bin === "string"
86
+ ? metadata.bin
87
+ : metadata.bin && typeof metadata.bin === "object"
88
+ ? metadata.bin.dsh
89
+ : undefined;
90
+ if (typeof bin !== "string" || !bin.trim() || isAbsolute(bin))
91
+ return;
92
+ const entry = resolve(directory, bin);
93
+ const location = relative(directory, entry);
94
+ if (location === ".." || location.startsWith(`..${sep}`) || isAbsolute(location))
95
+ return;
96
+ // 文件与版本由 Adapter 校验;即使入口缺失,也不能改选 PATH 中的另一安装。
97
+ return entry;
98
+ }
99
+ catch {
100
+ return;
101
+ }
102
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
- "commit": "ae7835c168e1e138287c012a6c87517dd2874a5d",
2
+ "commit": "064f56a25ff431f5fc1c001b2830ba79d45ec951",
3
3
  "dirty": false,
4
- "buildTime": "2026-10-27T08:38:03.037Z"
4
+ "buildTime": "2026-10-28T08:41:32.948Z"
5
5
  }
@@ -297,7 +297,7 @@ export async function parseCliCommand(raw, dependencies) {
297
297
  ...(name === "executor-kernel" ? [] : [extrasetExample(name, configExample, module)])
298
298
  ]);
299
299
  for (const [action, summary] of lifecycleCommands) {
300
- if (name === "executor-kernel" && ["logs", "extraset", "extraget"].includes(action))
300
+ if (name === "executor-kernel" && ["extraset", "extraget"].includes(action))
301
301
  continue;
302
302
  const child = leaf(parent, action, summary);
303
303
  const invocation = `${prefix} ${action}`;
@@ -2,7 +2,7 @@ import { constants } from "node:fs";
2
2
  import { lstat, open, opendir } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
4
  import { setTimeout as delay } from "node:timers/promises";
5
- import { extraStatusRecord } from "@mininglamp-oss/octo-runtime-adapter-sdk";
5
+ import { extraStatusRecord, kernelStatusRecord } from "@mininglamp-oss/octo-runtime-adapter-sdk";
6
6
  const MAX_READ = 4 * 1024 * 1024;
7
7
  const MAX_LINE = 4096;
8
8
  function record(line, extra) {
@@ -10,6 +10,10 @@ function record(line, extra) {
10
10
  return;
11
11
  try {
12
12
  const value = JSON.parse(line);
13
+ if (extra === "executor-kernel")
14
+ return value.source === "kernel" && typeof value.time === "string"
15
+ ? kernelStatusRecord(value.level, value.event, value.data, value.time)
16
+ : undefined;
13
17
  if (value.source !== "extra" || value.extra_type !== extra || typeof value.time !== "string")
14
18
  return;
15
19
  return extraStatusRecord(extra, value.level, value.event, value.data, value.time);
@@ -19,7 +23,7 @@ function record(line, extra) {
19
23
  }
20
24
  }
21
25
  async function files(home, extra) {
22
- const directory = join(home, "logs", "extras");
26
+ const directory = extra === "executor-kernel" ? join(home, "logs") : join(home, "logs", "extras");
23
27
  for (const path of [join(home, "logs"), directory]) {
24
28
  try {
25
29
  const stat = await lstat(path);
@@ -32,7 +36,7 @@ async function files(home, extra) {
32
36
  throw error;
33
37
  }
34
38
  }
35
- const pattern = new RegExp(`^${extra}-status-\\d{8}T\\d{2}\\.log$`);
39
+ const pattern = new RegExp(`^${extra === "executor-kernel" ? "kernel" : extra}-status-\\d{8}T\\d{2}\\.log$`);
36
40
  // Keep only three candidates while scanning, without loading an unbounded directory listing.
37
41
  const selected = [];
38
42
  let count = 0;
@@ -88,7 +92,7 @@ export async function showExtraLogs(options) {
88
92
  const emit = async (value) => {
89
93
  const text = options.json
90
94
  ? JSON.stringify(value)
91
- : `${value.time} ${value.level.toUpperCase()} ${value.extra_type} ${value.event}${Object.keys(value.data).length ? ` ${JSON.stringify(value.data)}` : ""}`;
95
+ : `${value.time} ${value.level.toUpperCase()} ${value.source === "extra" ? value.extra_type : "executor-kernel"} ${value.event}${Object.keys(value.data).length ? ` ${JSON.stringify(value.data)}` : ""}`;
92
96
  await options.output(text, controller.signal);
93
97
  };
94
98
  try {
@@ -5,7 +5,7 @@ import { once } from "node:events";
5
5
  import { lstat, mkdir } from "node:fs/promises";
6
6
  import { join, resolve } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
- import { attachKernel, acknowledgeOrphanCleanup, inspectOrphanCleanup, createKernelService, readAdapterConfigurations } from "@mininglamp-oss/octo-runtime-executor-kernel";
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";
11
11
  import { cliVersionInfo } from "./help.js";
@@ -16,6 +16,7 @@ import { StatusOutput } from "./status-output.js";
16
16
  import { defaultRuntimeHome, runtimePaths, withSetupLock, readJsonFile } from "./state.js";
17
17
  import { resolveServiceControl } from "./service-control.js";
18
18
  import { loadCliManifest } from "./module-manifest.js";
19
+ import { readCliAdapterConfigurations } from "./adapter-configurations.js";
19
20
  import { resolveAdapterModules } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
20
21
  import { readExtraDirectory } from "@mininglamp-oss/octo-runtime-host-sdk";
21
22
  import { describeError, formatStatus, recordStartupFailure, readStartupFailure } from "./output.js";
@@ -72,9 +73,12 @@ export async function runCli(args, dependencies = {}) {
72
73
  // Route logs before config/module/manager access so offline failures remain diagnosable.
73
74
  if (positional[1] === "logs") {
74
75
  const extra = positional[0];
75
- context = { component: extra, action: "logs", logs: join(home, "logs", "extras") };
76
+ context = {
77
+ component: extra,
78
+ action: "logs",
79
+ logs: extra === "executor-kernel" ? join(home, "logs") : join(home, "logs", "extras")
80
+ };
76
81
  if (positional.length !== 2 ||
77
- extra === "executor-kernel" ||
78
82
  !/^[a-z][a-z0-9-]{0,63}$/.test(extra) ||
79
83
  flags.autostart !== undefined)
80
84
  throw new Error("INVALID_ARGUMENTS");
@@ -181,7 +185,8 @@ export async function runCli(args, dependencies = {}) {
181
185
  profile,
182
186
  manifest: flags.manifest,
183
187
  input,
184
- output: dependencies.output
188
+ output: dependencies.output,
189
+ env: dependencies.env
185
190
  });
186
191
  }
187
192
  if (positional[0] === "adapter" && positional[1] === "list" && positional.length === 2) {
@@ -246,11 +251,12 @@ export async function runCli(args, dependencies = {}) {
246
251
  if (component === "executor-kernel") {
247
252
  const config = await readJsonFile(paths.profileConfig);
248
253
  handle = createKernelService({
254
+ logging: { directory: join(home, "logs") },
249
255
  endpoint,
250
256
  stateDirectory: kernelStateDirectory,
251
257
  workerEntrypoint: fileURLToPath(new URL("./worker.js", import.meta.url)),
252
258
  adapterModules: resolveAdapterModules(manifest),
253
- adapterConfigurations: readAdapterConfigurations(paths.profileRoot, config?.adapters),
259
+ adapterConfigurations: await readCliAdapterConfigurations(paths.profileRoot, config?.adapters, manifest, dependencies.env ?? process.env),
254
260
  env: {
255
261
  ...(dependencies.env ?? process.env),
256
262
  OCTO_RUNTIME_HOME: home,
@@ -20,6 +20,11 @@ export function formatStatus(name, snapshot) {
20
20
  ];
21
21
  if (runtime.execution_ready !== undefined)
22
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
+ }
23
28
  if (runtime.available === false)
24
29
  lines.push(` Reason: ${text(record(runtime.error).code ?? "COMPONENT_UNAVAILABLE")}`);
25
30
  if (service.lastExitCode !== undefined && service.lastExitCode !== 0)
@@ -1,7 +1,8 @@
1
1
  import { defaultRuntimeHome, runtimePaths, readJsonFile } from "./state.js";
2
2
  import { loadCliManifest } from "./module-manifest.js";
3
+ import { readCliAdapterConfigurations } from "./adapter-configurations.js";
3
4
  import { resolveAdapterModules } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
4
- import { readAdapterConfigurations, createKernelService } from "@mininglamp-oss/octo-runtime-executor-kernel";
5
+ import { createKernelService } from "@mininglamp-oss/octo-runtime-executor-kernel";
5
6
  import { fileURLToPath } from "node:url";
6
7
  import { componentEndpoint } from "@mininglamp-oss/octo-runtime-host-sdk";
7
8
  import { mkdtemp, rm } from "node:fs/promises";
@@ -88,7 +89,7 @@ export async function runPlayboard(options) {
88
89
  OCTO_RUNTIME_CLI_PROFILE_ROOT: paths.profileRoot,
89
90
  OCTO_RUNTIME_CLI_SYNC_OPENCLAW_TOOLS: "0"
90
91
  },
91
- adapterConfigurations: readAdapterConfigurations(paths.profileRoot, configuration?.adapters)
92
+ adapterConfigurations: await readCliAdapterConfigurations(paths.profileRoot, configuration?.adapters, manifest, options.env ?? process.env)
92
93
  });
93
94
  await kernel.initialize({ signal: controller.signal });
94
95
  let exitCode = 1;
@@ -1,6 +1,7 @@
1
1
  import { DriverQueue, watchLineLimit, mergeProcessEnvironment } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
2
  import { INVOKE_REQUEST_MAX_BYTES, resolveStreamLimitPolicy } from "@mininglamp-oss/octo-runtime-protocol";
3
3
  import { createProcessCleanup } from "@mininglamp-oss/octo-runtime-adapter-sdk/process-cleanup";
4
+ import { resolveProcessLaunch } from "@mininglamp-oss/octo-runtime-adapter-sdk/process-launch";
4
5
  import { spawn } from "node:child_process";
5
6
  import { createInterface } from "node:readline";
6
7
  /** Build the exact params serialized by `session/new`. */
@@ -324,9 +325,11 @@ export class AcpClient {
324
325
  */
325
326
  export function spawnAcpClient(options) {
326
327
  const { command, args = [], cwd, env, signal, permissionHandler, onPermissionResponseWritten, onPermissionResponseFailed, streamLimits } = options;
327
- const child = spawn(command, args, {
328
+ const processEnv = mergeProcessEnvironment(process.env, env ?? {});
329
+ const launch = resolveProcessLaunch(command, args, { cwd, env: processEnv });
330
+ const child = spawn(launch.command, launch.args, {
328
331
  cwd,
329
- env: mergeProcessEnvironment(process.env, env ?? {}),
332
+ env: processEnv,
330
333
  stdio: ["pipe", "pipe", "pipe"],
331
334
  detached: process.platform !== "win32"
332
335
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-acp-client",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
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.5",
13
- "@mininglamp-oss/octo-runtime-protocol": "1.1.5"
12
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.6",
13
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.6"
14
14
  }
15
15
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-acp",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
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.5",
13
- "@mininglamp-oss/octo-runtime-acp-client": "1.1.5",
14
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5"
12
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.6",
13
+ "@mininglamp-oss/octo-runtime-acp-client": "1.1.6",
14
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.6"
15
15
  }
16
16
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-antigravity",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
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.5",
14
- "@mininglamp-oss/octo-runtime-protocol": "1.1.5"
13
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.6",
14
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.6"
15
15
  }
16
16
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-claude-code",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
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.5",
9
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5"
8
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.6",
9
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.6"
10
10
  },
11
11
  "types": "./dist/index.d.ts",
12
12
  "files": [
@@ -23,10 +23,9 @@ interface CodeBuddyUpdate extends AcpUpdate {
23
23
  /** Translate one ACP update into canonical events; unrecognized update kinds yield nothing. */
24
24
  export declare function normalizeCodeBuddyUpdate(update: CodeBuddyUpdate): CanonicalEvent[];
25
25
  /**
26
- * Create a CodeBuddy adapter. Each invocation spawns an ACP client, initializes
27
- * the connection, then either loads the stored provider session or creates a
28
- * new one. The final message/run terminals are synthesized here because ACP
29
- * prompt streams end silently rather than with a terminal.
26
+ * 创建 CodeBuddy adapter;每轮拥有独立 ACP client,先握手并创建或恢复显式会话,再发送 prompt。
27
+ * adapter 将 Provider 结果映射为唯一终态并负责关闭 client;Core 独立确认清理完成。
28
+ * 显式模型在 prompt 前按本次原生目录设置并确认;回执只取确认值,Provider 失败优先于部分输出及空输出检查。
30
29
  */
31
30
  export declare function createCodeBuddyAdapter({ acpClientFactory, command }?: {
32
31
  acpClientFactory?: typeof spawnAcpClient;
@@ -1,5 +1,5 @@
1
1
  import { initialControlInstructions, invocationEnvironment } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
- import { canonicalTerminalStatus, hasImageInput } from "@mininglamp-oss/octo-runtime-protocol";
2
+ import { canonicalTerminalStatus, failureMessage, hasImageInput } from "@mininglamp-oss/octo-runtime-protocol";
3
3
  import { acpLoadSessionParams, acpNewSessionParams, acpPromptParams, spawnAcpClient } from "@mininglamp-oss/octo-runtime-acp-client";
4
4
  import { AcpApprovalBridge, AcpTurnNormalizer, acpToolTerminalStatus, defineAdapter, normalizeAcpToolUpdate, probeCommand, providerInputText } from "@mininglamp-oss/octo-runtime-adapter-sdk";
5
5
  /** Translate one ACP update into canonical events; unrecognized update kinds yield nothing. */
@@ -55,7 +55,7 @@ export function normalizeCodeBuddyUpdate(update) {
55
55
  {
56
56
  protocolVersion: 2,
57
57
  type: "usage.update",
58
- payload: { ...update.usage, model: update.model }
58
+ payload: { ...update.usage, ...(update.model ? { model: update.model } : {}) }
59
59
  }
60
60
  ];
61
61
  return [];
@@ -68,11 +68,101 @@ function isCancelledStopReason(reason) {
68
68
  return (typeof reason === "string" &&
69
69
  ["cancelled", "canceled", "interrupted", "aborted"].includes(reason.toLowerCase()));
70
70
  }
71
+ /** 只回报本次原生响应确认的模型;请求值及旧 binding 都不代表恢复后的实际模型。 */
72
+ function confirmedSessionModel(result) {
73
+ if (!isRecord(result))
74
+ return undefined;
75
+ const option = Array.isArray(result.configOptions)
76
+ ? result.configOptions.find((value) => isRecord(value) && (value.id === "model" || value.category === "model"))
77
+ : undefined;
78
+ for (const value of [
79
+ isRecord(option) ? option.currentValue : undefined,
80
+ isRecord(result.models) ? result.models.currentModelId : undefined,
81
+ result.model
82
+ ]) {
83
+ if (typeof value === "string" && value.trim())
84
+ return value;
85
+ }
86
+ return undefined;
87
+ }
88
+ /** 只使用本次会话广告的目录与原生 setter,不把 session/new.model 当作选模确认。 */
89
+ function modelSelection(session, sessionId, model) {
90
+ const result = isRecord(session) ? session : {};
91
+ const option = Array.isArray(result.configOptions)
92
+ ? result.configOptions.find((value) => isRecord(value) && (value.id === "model" || value.category === "model"))
93
+ : undefined;
94
+ const config = isRecord(option) ? option : undefined;
95
+ const models = isRecord(result.models) ? result.models : {};
96
+ const entries = config
97
+ ? Array.isArray(config.options)
98
+ ? config.options.flatMap((value) => isRecord(value) && Array.isArray(value.options) ? value.options : [value])
99
+ : []
100
+ : Array.isArray(models.availableModels)
101
+ ? models.availableModels
102
+ : [];
103
+ const available = entries
104
+ .filter(isRecord)
105
+ .map((entry) => (config ? entry.value : entry.modelId))
106
+ .filter((value) => typeof value === "string" && value.length > 0);
107
+ if (!available.includes(model)) {
108
+ throw new Error(`MODEL_NOT_FOUND: CodeBuddy does not offer model ${model}. Select a model from its advertised catalog.`);
109
+ }
110
+ if (confirmedSessionModel(result) === model)
111
+ return undefined;
112
+ if (config && (typeof config.id !== "string" || !config.id.trim())) {
113
+ throw new Error(`CodeBuddy cannot select model ${model}: the model config option has no id`);
114
+ }
115
+ return config
116
+ ? {
117
+ method: "session/set_config_option",
118
+ params: { sessionId, configId: config.id, value: model }
119
+ }
120
+ : { method: "session/set_model", params: { sessionId, modelId: model } };
121
+ }
122
+ /** ACP 失败详情按宿主要求原样序列化,不解析或筛选 Provider 的私有错误字段。 */
123
+ function promptFailure(update) {
124
+ const meta = isRecord(update._meta) ? update._meta : {};
125
+ const outcome = meta["codebuddy.ai/outcome"];
126
+ const raw = meta["codebuddy.ai/errorMessage"];
127
+ const hasError = typeof raw === "string" ? raw.trim().length > 0 : raw != null;
128
+ if (!(typeof update.stopReason === "string" && update.stopReason.toLowerCase() === "refusal") &&
129
+ !(typeof outcome === "string" && outcome.startsWith("FAILED")) &&
130
+ !hasError)
131
+ return undefined;
132
+ return {
133
+ code: "ACP_MODEL_REQUEST_FAILED",
134
+ message: `${failureMessage("OH-PRV-4010")}\n${JSON.stringify(update._meta)}`,
135
+ adapterType: "codebuddy"
136
+ };
137
+ }
138
+ /** 与通用 ACP 一致,仅在无流式 final 且未失败时使用已支持的结果正文载体。 */
139
+ function promptResultText(update) {
140
+ for (const value of [
141
+ update.text,
142
+ update.content,
143
+ update.output,
144
+ update.response,
145
+ update.message
146
+ ]) {
147
+ if (typeof value === "string" && value.trim())
148
+ return value;
149
+ if (isRecord(value) && typeof value.text === "string" && value.text.trim())
150
+ return value.text;
151
+ if (Array.isArray(value)) {
152
+ const text = value
153
+ .filter(isRecord)
154
+ .map((item) => (typeof item.text === "string" ? item.text : ""))
155
+ .join("");
156
+ if (text.trim())
157
+ return text;
158
+ }
159
+ }
160
+ return undefined;
161
+ }
71
162
  /**
72
- * Create a CodeBuddy adapter. Each invocation spawns an ACP client, initializes
73
- * the connection, then either loads the stored provider session or creates a
74
- * new one. The final message/run terminals are synthesized here because ACP
75
- * prompt streams end silently rather than with a terminal.
163
+ * 创建 CodeBuddy adapter;每轮拥有独立 ACP client,先握手并创建或恢复显式会话,再发送 prompt。
164
+ * adapter 将 Provider 结果映射为唯一终态并负责关闭 client;Core 独立确认清理完成。
165
+ * 显式模型在 prompt 前按本次原生目录设置并确认;回执只取确认值,Provider 失败优先于部分输出及空输出检查。
76
166
  */
77
167
  export function createCodeBuddyAdapter({ acpClientFactory = spawnAcpClient, command = "codebuddy" } = {}) {
78
168
  const responders = new Map();
@@ -114,7 +204,7 @@ export function createCodeBuddyAdapter({ acpClientFactory = spawnAcpClient, comm
114
204
  const sessionMethod = requestedSessionId ? "session/load" : "session/new";
115
205
  const sessionParams = requestedSessionId
116
206
  ? acpLoadSessionParams(requestedSessionId, { cwd: req.workdir })
117
- : acpNewSessionParams({ cwd: req.workdir, model: req.agentConfig?.model });
207
+ : acpNewSessionParams({ cwd: req.workdir });
118
208
  const sessionRequestId = client.reserveRequestId();
119
209
  let session;
120
210
  const requestOptions = {
@@ -133,8 +223,21 @@ export function createCodeBuddyAdapter({ acpClientFactory = spawnAcpClient, comm
133
223
  throw new Error("ACP session/new returned no sessionId");
134
224
  session = { id: sessionId };
135
225
  }
136
- // The AgentSession stores only the provider sessionId; both the
137
- // new and resume paths converge on the same ACP prompt stream.
226
+ let model = confirmedSessionModel(sessionResult);
227
+ const requestedModel = req.agentConfig?.model;
228
+ if (requestedModel) {
229
+ const selection = modelSelection(sessionResult, session.id, requestedModel);
230
+ if (selection) {
231
+ const selected = await client.request(selection.method, selection.params, {
232
+ requestId: client.reserveRequestId()
233
+ });
234
+ // 空 ACK 或旧模型都不能证明切换生效;失败时不发送下一轮 prompt。
235
+ model = confirmedSessionModel(selected);
236
+ if (model !== requestedModel) {
237
+ throw new Error(`CodeBuddy did not confirm model ${requestedModel} after selection (confirmed: ${model ?? "unknown"}). Select a supported model and retry.`);
238
+ }
239
+ }
240
+ }
138
241
  yield {
139
242
  protocolVersion: 2,
140
243
  type: "session.update",
@@ -142,7 +245,7 @@ export function createCodeBuddyAdapter({ acpClientFactory = spawnAcpClient, comm
142
245
  providerSession: {
143
246
  sessionId: session.id,
144
247
  resumable: true,
145
- model: req.agentConfig?.model
248
+ ...(model ? { model } : {})
146
249
  }
147
250
  }
148
251
  };
@@ -151,6 +254,9 @@ export function createCodeBuddyAdapter({ acpClientFactory = spawnAcpClient, comm
151
254
  const promptRequestId = client.reserveRequestId();
152
255
  let promptStopReason;
153
256
  let promptFinishReason;
257
+ let failure;
258
+ let resultText;
259
+ let producedFinalOutput = false;
154
260
  const activeToolIds = new Set();
155
261
  const turn = new AcpTurnNormalizer("codebuddy");
156
262
  for await (const update of client.prompt(session.id, prompt, {
@@ -158,12 +264,21 @@ export function createCodeBuddyAdapter({ acpClientFactory = spawnAcpClient, comm
158
264
  params: promptParams
159
265
  })) {
160
266
  if (update.type === "prompt_result") {
161
- promptStopReason = update.stopReason;
162
- promptFinishReason = update.finishReason;
267
+ promptStopReason =
268
+ typeof update.stopReason === "string" ? update.stopReason : undefined;
269
+ promptFinishReason =
270
+ typeof update.finishReason === "string" ? update.finishReason : undefined;
271
+ failure ??= promptFailure(update);
272
+ resultText = promptResultText(update);
163
273
  continue;
164
274
  }
165
275
  const events = turn.normalize(update.sessionUpdate ?? update.type, normalizeCodeBuddyUpdate(update));
166
276
  for (const event of events) {
277
+ if (event.type === "message.delta" &&
278
+ event.payload.channel !== "analysis" &&
279
+ typeof event.payload.text === "string" &&
280
+ event.payload.text.trim())
281
+ producedFinalOutput = true;
167
282
  const toolID = typeof event.payload.id === "string" ? event.payload.id : undefined;
168
283
  if (event.type === "tool_call.create" && toolID)
169
284
  activeToolIds.add(toolID);
@@ -174,34 +289,54 @@ export function createCodeBuddyAdapter({ acpClientFactory = spawnAcpClient, comm
174
289
  yield event;
175
290
  }
176
291
  }
177
- const cancelled = isCancelledStopReason(promptStopReason);
178
- if (cancelled) {
292
+ const cancelled = !failure && (req.signal?.aborted || isCancelledStopReason(promptStopReason));
293
+ if (!cancelled && !failure && !producedFinalOutput && resultText) {
294
+ yield* turn.normalize("agent_message_chunk", normalizeCodeBuddyUpdate({
295
+ sessionUpdate: "agent_message_chunk",
296
+ content: { text: resultText }
297
+ }));
298
+ producedFinalOutput = true;
299
+ }
300
+ if (!cancelled && !failure && !producedFinalOutput) {
301
+ failure = {
302
+ code: "ACP_NO_FINAL_OUTPUT",
303
+ message: "CodeBuddy completed without assistant output",
304
+ adapterType: "codebuddy"
305
+ };
306
+ }
307
+ const status = failure ? "failed" : cancelled ? "cancelled" : "completed";
308
+ if (cancelled || failure) {
179
309
  for (const id of activeToolIds) {
180
310
  yield {
181
311
  protocolVersion: 2,
182
312
  type: "tool_call.update",
183
- payload: { id, status: canonicalTerminalStatus("cancelled") }
313
+ payload: { id, status: canonicalTerminalStatus(status) }
184
314
  };
185
315
  }
186
316
  }
187
- for (const event of turn.finish(promptFinishReason ?? promptStopReason, cancelled ? "cancelled" : "completed"))
317
+ for (const event of turn.finish(promptFinishReason ?? promptStopReason, status))
188
318
  yield event;
189
319
  const terminalMessage = {
190
320
  protocolVersion: 2,
191
321
  type: "message.update",
192
- payload: { role: "assistant", status: cancelled ? "stopped" : "completed" }
322
+ payload: {
323
+ role: "assistant",
324
+ status: failure ? "failed" : cancelled ? "stopped" : "completed"
325
+ }
193
326
  };
194
327
  yield terminalMessage;
195
- yield cancelled
196
- ? {
197
- protocolVersion: 2,
198
- type: "run.cancelled",
199
- payload: {
200
- reason: promptStopReason ?? "cancelled",
201
- ...(promptFinishReason ? { finishReason: promptFinishReason } : {})
328
+ yield failure
329
+ ? { protocolVersion: 2, type: "run.failed", payload: failure }
330
+ : cancelled
331
+ ? {
332
+ protocolVersion: 2,
333
+ type: "run.cancelled",
334
+ payload: {
335
+ reason: promptStopReason ?? "cancelled",
336
+ ...(promptFinishReason ? { finishReason: promptFinishReason } : {})
337
+ }
202
338
  }
203
- }
204
- : { protocolVersion: 2, type: "run.completed", payload: {} };
339
+ : { protocolVersion: 2, type: "run.completed", payload: {} };
205
340
  }
206
341
  finally {
207
342
  await client.close?.();