@mininglamp-oss/octo-runtime 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +4 -2
  2. package/apps/cli/README.md +3 -1
  3. package/apps/cli/dist/build-info.json +2 -2
  4. package/apps/cli/dist/extras.d.ts +4 -2
  5. package/apps/cli/dist/extras.js +20 -21
  6. package/apps/cli/dist/help.js +3 -0
  7. package/apps/cli/dist/logs.d.ts +10 -0
  8. package/apps/cli/dist/logs.js +186 -0
  9. package/apps/cli/dist/main.d.ts +1 -0
  10. package/apps/cli/dist/main.js +94 -19
  11. package/apps/cli/dist/{default_adapters.json → manifest.json} +5 -0
  12. package/apps/cli/dist/module-manifest.d.ts +3 -0
  13. package/apps/cli/dist/module-manifest.js +11 -0
  14. package/apps/cli/dist/openclaw.js +30 -6
  15. package/apps/cli/dist/output.js +3 -0
  16. package/apps/cli/dist/playboard.js +10 -8
  17. package/apps/cli/dist/status-output.d.ts +10 -0
  18. package/apps/cli/dist/status-output.js +65 -0
  19. package/apps/cli/dist/worker.d.ts +1 -0
  20. package/apps/cli/dist/worker.js +18 -0
  21. package/dist/public/host.d.ts +1 -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/package.json +4 -4
  24. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  25. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  26. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  27. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  28. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  29. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  30. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  31. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  32. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  33. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
  34. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
  35. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +1 -0
  36. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +1 -0
  37. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/module-manifest.d.ts +33 -0
  38. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/module-manifest.js +118 -0
  39. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log-worker.js +7 -5
  40. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log.d.ts +3 -0
  41. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log.js +45 -10
  42. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.d.ts +11 -0
  43. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.js +70 -0
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +5 -3
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
  46. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  47. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extras.d.ts +4 -2
  48. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extras.js +20 -21
  49. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/help.js +3 -0
  50. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/logs.d.ts +10 -0
  51. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/logs.js +186 -0
  52. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.d.ts +1 -0
  53. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +94 -19
  54. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/{default_adapters.json → manifest.json} +5 -0
  55. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.d.ts +3 -0
  56. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.js +11 -0
  57. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/openclaw.js +30 -6
  58. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +3 -0
  59. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +10 -8
  60. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/status-output.d.ts +10 -0
  61. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/status-output.js +65 -0
  62. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/worker.d.ts +1 -0
  63. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/worker.js +18 -0
  64. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +22 -9
  65. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +2 -2
  66. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-input.d.ts +1 -1
  67. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-input.js +5 -5
  68. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  69. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/heartbeat.d.ts +16 -0
  70. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/heartbeat.js +59 -0
  71. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.d.ts +1 -0
  72. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.js +4 -1
  73. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/manifest-adapters.d.ts +6 -0
  74. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/manifest-adapters.js +88 -0
  75. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/module-specifier.d.ts +1 -2
  76. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/module-specifier.js +2 -9
  77. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.d.ts +7 -2
  78. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.js +138 -9
  79. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runner.js +3 -92
  80. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/serve.js +36 -12
  81. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +4 -1
  82. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +14 -6
  83. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.js +2 -1
  84. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.d.ts +2 -2
  85. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.js +57 -34
  86. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +8 -16
  87. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/config-schema.json +2 -2
  88. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +16 -17
  89. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
  90. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/config-schema.json +2 -2
  91. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
  92. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/config-schema.json +2 -2
  93. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/index.js +1 -1
  94. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/store.d.ts +4 -1
  95. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/store.js +54 -4
  96. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
  97. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-config.d.ts +8 -1
  98. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-config.js +27 -12
  99. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-service.js +39 -2
  100. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.d.ts +1 -0
  101. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
  102. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  103. package/node_modules/import-meta-resolve/index.d.ts +19 -0
  104. package/node_modules/import-meta-resolve/index.d.ts.map +1 -0
  105. package/node_modules/import-meta-resolve/index.js +47 -0
  106. package/node_modules/import-meta-resolve/lib/errors.d.ts +24 -0
  107. package/node_modules/import-meta-resolve/lib/errors.d.ts.map +1 -0
  108. package/node_modules/import-meta-resolve/lib/errors.js +504 -0
  109. package/node_modules/import-meta-resolve/lib/get-format.d.ts +13 -0
  110. package/node_modules/import-meta-resolve/lib/get-format.d.ts.map +1 -0
  111. package/node_modules/import-meta-resolve/lib/get-format.js +159 -0
  112. package/node_modules/import-meta-resolve/lib/package-json-reader.d.ts +31 -0
  113. package/node_modules/import-meta-resolve/lib/package-json-reader.d.ts.map +1 -0
  114. package/node_modules/import-meta-resolve/lib/package-json-reader.js +177 -0
  115. package/node_modules/import-meta-resolve/lib/resolve.d.ts +29 -0
  116. package/node_modules/import-meta-resolve/lib/resolve.d.ts.map +1 -0
  117. package/node_modules/import-meta-resolve/lib/resolve.js +1301 -0
  118. package/node_modules/import-meta-resolve/lib/utils.d.ts +6 -0
  119. package/node_modules/import-meta-resolve/lib/utils.d.ts.map +1 -0
  120. package/node_modules/import-meta-resolve/lib/utils.js +47 -0
  121. package/node_modules/import-meta-resolve/license +74 -0
  122. package/node_modules/import-meta-resolve/package.json +78 -0
  123. package/node_modules/import-meta-resolve/readme.md +252 -0
  124. package/package.json +28 -26
  125. package/packages/octo-runtime-extra-channel-gateway/config-schema.json +2 -2
  126. package/packages/octo-runtime-extra-channel-wecom/config-schema.json +2 -2
  127. package/packages/octo-runtime-extra-webui/config-schema.json +2 -2
@@ -1,16 +1,20 @@
1
1
  import net from "node:net";
2
2
  import { randomUUID } from "node:crypto";
3
- import { access, mkdir } from "node:fs/promises";
3
+ import { once } from "node:events";
4
+ import { lstat, mkdir } from "node:fs/promises";
4
5
  import { join, resolve } from "node:path";
5
6
  import { fileURLToPath } from "node:url";
6
7
  import { attachKernel, createKernelService, readAdapterConfigurations } from "@mininglamp-oss/octo-runtime-executor-kernel";
7
- import { componentEndpoint, createExtraService, extraRegistration } from "@mininglamp-oss/octo-runtime-host-sdk";
8
+ import { componentEndpoint, createExtraService } from "@mininglamp-oss/octo-runtime-host-sdk";
8
9
  import { getExtra, readExtra, setExtra } from "./extras.js";
9
10
  import { cliVersionInfo, helpText } from "./help.js";
10
11
  import { runForegroundService } from "./foreground.js";
12
+ import { showExtraLogs } from "./logs.js";
13
+ import { StatusOutput } from "./status-output.js";
11
14
  import { defaultRuntimeHome, runtimePaths, withSetupLock, readJsonFile } from "./state.js";
12
15
  import { resolveServiceControl } from "./service-control.js";
13
- import { initializeCliOpenClaw, syncCliOpenClawToolEnvironment } from "./openclaw.js";
16
+ import { loadCliManifest } from "./module-manifest.js";
17
+ import { resolveAdapterModules } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
14
18
  import { readExtraDirectory } from "@mininglamp-oss/octo-runtime-host-sdk";
15
19
  import { describeError, formatStatus, recordStartupFailure, readStartupFailure } from "./output.js";
16
20
  const components = ["executor-kernel", "channel-gateway"];
@@ -20,8 +24,11 @@ export async function runCli(args, dependencies = {}) {
20
24
  let json = args.includes("--json");
21
25
  let context = {};
22
26
  let runningComponent;
27
+ let statusOutput;
23
28
  try {
24
29
  const { flags, positional } = parse(args);
30
+ if ((flags.lines !== undefined || flags.follow !== undefined) && positional[1] !== "logs")
31
+ throw new Error("INVALID_ARGUMENTS");
25
32
  json = Boolean(flags.json);
26
33
  if (flags.version || positional[0] === "version") {
27
34
  output(cliVersionInfo);
@@ -37,16 +44,65 @@ export async function runCli(args, dependencies = {}) {
37
44
  return 0;
38
45
  }
39
46
  const home = resolve(flags.home ?? defaultRuntimeHome(dependencies.env, dependencies.platform));
47
+ // Route logs before config/module/manager access so offline failures remain diagnosable.
48
+ if (positional[1] === "logs") {
49
+ const extra = positional[0];
50
+ context = { component: extra, action: "logs", logs: join(home, "logs", "extras") };
51
+ if (positional.length !== 2 ||
52
+ extra === "executor-kernel" ||
53
+ !/^[a-z][a-z0-9-]{0,63}$/.test(extra) ||
54
+ flags.autostart !== undefined)
55
+ throw new Error("INVALID_ARGUMENTS");
56
+ if (!builtinComponents.includes(extra)) {
57
+ const registration = await lstat(join(home, "extras", extra, "config.json")).catch((error) => {
58
+ if (error.code === "ENOENT")
59
+ return undefined;
60
+ throw error;
61
+ });
62
+ if (!registration?.isFile() || registration.isSymbolicLink())
63
+ throw new Error("EXTRA_NOT_FOUND");
64
+ }
65
+ if (flags.lines !== undefined && !/^[1-9][0-9]{0,4}$/.test(flags.lines))
66
+ throw new Error("INVALID_ARGUMENTS");
67
+ await showExtraLogs({
68
+ home,
69
+ extra,
70
+ lines: Number(flags.lines ?? 200),
71
+ follow: Boolean(flags.follow),
72
+ json,
73
+ output: dependencies.output ??
74
+ (async (line, signal) => {
75
+ if (!process.stdout.write(`${line}\n`))
76
+ await once(process.stdout, "drain", { signal });
77
+ }),
78
+ errorOutput: dependencies.errorOutput ??
79
+ ((line) => {
80
+ process.stderr.write(`${line}\n`);
81
+ }),
82
+ signal: dependencies.logsSignal
83
+ });
84
+ return 0;
85
+ }
40
86
  const root = await readJsonFile(runtimePaths(home, "default").rootConfig);
41
87
  const profile = flags.profile ?? root?.default_profile ?? "default";
42
88
  const paths = runtimePaths(home, profile, dependencies.platform);
43
89
  const endpoint = componentEndpoint(home, "executor-kernel", dependencies.platform);
44
90
  context = { component: positional[0], action: positional[1], logs: join(home, "logs") };
45
91
  const registrations = await readExtraDirectory(join(home, "extras"));
92
+ // 部署、停止及配置修复命令不启动模块,也不因尚未可读的启动清单而无法操作。
93
+ const needsManifest = positional[1] === "run" ||
94
+ (!builtinComponents.includes(positional[0]) &&
95
+ !registrations.some((entry) => entry.name === positional[0]) &&
96
+ ["install", "start", "restart", "stop", "uninstall", "status"].includes(positional[1]));
97
+ const manifest = needsManifest
98
+ ? await loadCliManifest(home, flags.manifest, dependencies.errorOutput ?? ((message) => process.stderr.write(`${message}\n`)))
99
+ : undefined;
46
100
  const componentNames = [
47
101
  ...new Set([...components, ...registrations.map((entry) => entry.name)])
48
102
  ];
49
- const isComponent = (name) => builtinComponents.includes(name) || registrations.some((entry) => entry.name === name);
103
+ const isComponent = (name) => builtinComponents.includes(name) ||
104
+ registrations.some((entry) => entry.name === name) ||
105
+ manifest?.extras.some((entry) => entry.name === name) === true;
50
106
  if (positional.length === 1 && isComponent(positional[0])) {
51
107
  output(helpText(positional[0]));
52
108
  return 0;
@@ -159,41 +215,45 @@ export async function runCli(args, dependencies = {}) {
159
215
  return 0;
160
216
  }
161
217
  if (action === "run") {
218
+ if (!manifest)
219
+ throw new Error("MANIFEST_INVALID");
162
220
  runningComponent = component;
163
221
  dependencies.onComponentRun?.();
164
222
  await mkdir(home, { recursive: true, mode: 0o700 });
165
223
  let handle;
166
224
  if (component === "executor-kernel") {
167
- // 显式清单不存在时在宿主边界保留 ENOENT,而非等待 worker 断开后丢失原因。
168
- if (flags.manifest)
169
- await access(resolve(flags.manifest));
170
- await initializeCliOpenClaw(paths.profileRoot, dependencies.env ?? process.env);
171
- await syncCliOpenClawToolEnvironment(paths.profileRoot, await readExtraDirectory(join(home, "extras")));
172
225
  const config = await readJsonFile(paths.profileConfig);
173
226
  handle = createKernelService({
174
227
  endpoint,
175
228
  stateDirectory: join(home, "run"),
176
- workerEntrypoint: fileURLToPath(import.meta.resolve("@mininglamp-oss/octo-runtime-executor-kernel/runner")),
177
- manifest: flags.manifest
178
- ? resolve(flags.manifest)
179
- : fileURLToPath(new URL("./default_adapters.json", import.meta.url)),
229
+ workerEntrypoint: fileURLToPath(new URL("./worker.js", import.meta.url)),
230
+ adapterModules: resolveAdapterModules(manifest),
180
231
  adapterConfigurations: readAdapterConfigurations(paths.profileRoot, config?.adapters),
181
232
  env: {
182
233
  ...(dependencies.env ?? process.env),
183
234
  OCTO_RUNTIME_HOME: home,
235
+ OCTO_RUNTIME_CLI_PROFILE_ROOT: paths.profileRoot,
236
+ OCTO_RUNTIME_CLI_SYNC_OPENCLAW_TOOLS: "1",
184
237
  OCTO_RUNTIME_LOGS_DIRECTORY: join(home, "logs")
185
238
  }
186
239
  });
187
240
  }
188
241
  else {
189
- const registration = extraRegistration(await readExtra(paths, component));
242
+ const registration = await readExtra(paths, component, manifest);
190
243
  const module = registration.enabled === false
191
244
  ? { name: registration.name, default: () => () => { } }
192
245
  : await registration.load();
193
246
  if (module.name !== registration.name)
194
247
  throw new Error("EXTRA_NAME_MISMATCH");
248
+ if (!dependencies.output)
249
+ statusOutput = new StatusOutput(process.stdout);
195
250
  handle = createExtraService({
196
- logging: { directory: join(home, "logs") },
251
+ logging: {
252
+ directory: join(home, "logs"),
253
+ statusOutput: dependencies.output
254
+ ? (record) => output(JSON.stringify(record))
255
+ : statusOutput.write
256
+ },
197
257
  module,
198
258
  config: registration.config,
199
259
  dependencies: {},
@@ -202,7 +262,7 @@ export async function runCli(args, dependencies = {}) {
202
262
  controlEndpoint: componentEndpoint(home, component, dependencies.platform)
203
263
  });
204
264
  }
205
- return runForegroundService(handle, () => publish({ component, state: "ready" }, `${component}: ready`), async (error) => {
265
+ return await runForegroundService(handle, () => publish({ component, state: "ready" }, `${component}: ready`), async (error) => {
206
266
  try {
207
267
  await recordStartupFailure(join(home, "logs"), component, error);
208
268
  }
@@ -292,7 +352,7 @@ export async function runCli(args, dependencies = {}) {
292
352
  const failure = { ...describeError(error), ...context };
293
353
  const code = failure.code;
294
354
  if (json)
295
- output(JSON.stringify({ error: failure }, null, 2));
355
+ output(JSON.stringify({ error: failure }, null, context.action === "logs" ? undefined : 2));
296
356
  else
297
357
  (dependencies.errorOutput ?? ((line) => process.stderr.write(`${line}\n`)))(`${[context.component, context.action].filter(Boolean).join(" ") || "octo-runtime"}: ${code}${failure.cause_code ? ` (${failure.cause_code})` : ""}\n${failure.message}${context.logs ? `\nLogs: ${context.logs}` : ""}`);
298
358
  return ["SERVICE_NOT_INSTALLED", "NOT_INSTALLED"].includes(code)
@@ -305,6 +365,9 @@ export async function runCli(args, dependencies = {}) {
305
365
  ? 4
306
366
  : 1;
307
367
  }
368
+ finally {
369
+ statusOutput?.close();
370
+ }
308
371
  }
309
372
  async function componentStatus(home, component, platform, requireReady = false) {
310
373
  const endpoint = componentEndpoint(home, component, platform);
@@ -372,11 +435,23 @@ function parse(args) {
372
435
  }
373
436
  const match = /^--([a-z-]+)(?:=(.*))?$/.exec(arg);
374
437
  if (!match ||
375
- !["home", "profile", "manifest", "json", "help", "version", "autostart"].includes(match[1]) ||
438
+ ![
439
+ "home",
440
+ "profile",
441
+ "manifest",
442
+ "json",
443
+ "help",
444
+ "version",
445
+ "autostart",
446
+ "lines",
447
+ "follow"
448
+ ].includes(match[1]) ||
376
449
  Object.hasOwn(flags, match[1]))
377
450
  throw new Error("INVALID_ARGUMENTS");
378
451
  const key = match[1];
379
- flags[key] = ["json", "help", "version"].includes(key) ? "true" : (match[2] ?? args[++i]);
452
+ flags[key] = ["json", "help", "version", "follow"].includes(key)
453
+ ? "true"
454
+ : (match[2] ?? args[++i]);
380
455
  if (!flags[key] ||
381
456
  flags[key].startsWith("--") ||
382
457
  (key === "autostart" && !["true", "false"].includes(flags[key])))
@@ -61,5 +61,10 @@
61
61
  "module": "@mininglamp-oss/octo-runtime-adapter-antigravity",
62
62
  "export": "antigravityAdapter"
63
63
  }
64
+ ],
65
+ "extras": [
66
+ { "name": "channel-gateway", "module": "@mininglamp-oss/octo-runtime-extra-channel-gateway" },
67
+ { "name": "channel-wecom", "module": "@mininglamp-oss/octo-runtime-extra-channel-wecom" },
68
+ { "name": "webui", "module": "@mininglamp-oss/octo-runtime-extra-webui" }
64
69
  ]
65
70
  }
@@ -0,0 +1,3 @@
1
+ import { type ModuleManifest } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
2
+ /** CLI 独占默认目录与 Home 扩展策略;SDK 原生装配不读取这两份文件。 */
3
+ export declare function loadCliManifest(home: string, override?: string, report?: (message: string) => void): Promise<ModuleManifest>;
@@ -0,0 +1,11 @@
1
+ import { join, resolve } from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { mergeModuleManifests, readModuleManifest } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
4
+ /** CLI 独占默认目录与 Home 扩展策略;SDK 原生装配不读取这两份文件。 */
5
+ export async function loadCliManifest(home, override, report = (message) => console.error(message)) {
6
+ if (override)
7
+ return readModuleManifest(resolve(override), { legacy: true });
8
+ const builtin = await readModuleManifest(fileURLToPath(new URL("./manifest.json", import.meta.url)));
9
+ const extension = await readModuleManifest(join(home, "manifest.json"), { optional: true });
10
+ return mergeModuleManifests(builtin, extension, report);
11
+ }
@@ -1,7 +1,6 @@
1
1
  import { readFile, mkdir, writeFile, rename, lstat, chmod, rm } from "node:fs/promises";
2
2
  import { parseEnv, promisify } from "node:util";
3
3
  import { execFile } from "node:child_process";
4
- import { configuredCredential, validateImBots, octoCliEnvironment } from "@mininglamp-oss/octo-runtime-extra-channel-gateway";
5
4
  import { randomUUID } from "node:crypto";
6
5
  import { isIP } from "node:net";
7
6
  import { homedir, networkInterfaces } from "node:os";
@@ -103,15 +102,40 @@ export async function syncCliOpenClawToolEnvironment(runtimeRoot, extras) {
103
102
  if (!channel || channel.config.bots === undefined)
104
103
  return { written: false, restartRequired: false };
105
104
  const bots = channel.config.bots;
106
- validateImBots(bots);
105
+ if (!Array.isArray(bots) || bots.length > 64)
106
+ throw new Error("IM_CONFIG_LIST_REQUIRED");
107
107
  let values;
108
- for (const bot of bots) {
109
- if (bot.enabled === false || bot.adapter.adapter_type !== "openclaw")
108
+ for (const value of bots) {
109
+ const bot = record(value);
110
+ if (!bot)
111
+ throw new Error("IM_CONFIG_INVALID");
112
+ if (bot.enabled === false || record(bot.adapter)?.adapter_type !== "openclaw")
110
113
  continue;
111
- const token = configuredCredential(bot);
114
+ const token = typeof bot.bf_token === "string" ? bot.bf_token.trim() : undefined;
112
115
  if (!token)
113
116
  throw new Error("IM_CREDENTIALS_REQUIRED");
114
- values = Object.fromEntries(octoCliEnvironment(bot.api_url, token).env_variables.map(({ key, value }) => [key, value]));
117
+ // CLI 仅校验自己要写入的工具身份;完整 Bot 配置由启动后的 Extra 校验。
118
+ // 不为 Kernel 的 dotenv 同步导入整个业务 Extra,否则未启动 Extra 缺包也会阻塞 Kernel。
119
+ if (!/^bf_[A-Za-z0-9_-]+$/.test(token))
120
+ throw new Error("IM_BOT_TOKEN_INVALID");
121
+ let url;
122
+ try {
123
+ if (typeof bot.api_url !== "string")
124
+ throw new Error();
125
+ url = new URL(bot.api_url);
126
+ }
127
+ catch {
128
+ throw new Error("IM_API_URL_INVALID");
129
+ }
130
+ if (url.username ||
131
+ url.password ||
132
+ url.search ||
133
+ url.hash ||
134
+ (url.protocol !== "https:" &&
135
+ !(url.protocol === "http:" && ["127.0.0.1", "localhost", "[::1]"].includes(url.hostname))))
136
+ throw new Error("IM_API_URL_INVALID");
137
+ url.pathname = url.pathname.replace(/\/+$/, "").replace(/\/api$/, "");
138
+ values = { OCTO_BOT_TOKEN: token, OCTO_API_BASE_URL: url.href.replace(/\/+$/, "") };
115
139
  }
116
140
  if (!values)
117
141
  return { written: false, restartRequired: false };
@@ -102,6 +102,9 @@ export function describeError(error, fallback = "COMMAND_FAILED") {
102
102
  SERVICE_NOT_INSTALLED: "Run this component's install command, then start it.",
103
103
  NOT_INSTALLED: "Run this component's install command, then start it.",
104
104
  EXTRA_NOT_REGISTERED: "Save this Extra's declaration with extraset before starting it.",
105
+ EXTRA_MANIFEST_DECLARATION_REQUIRED: "Add this Extra's name and module to the selected Home manifest.json (extras array), then retry.",
106
+ 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.",
107
+ MANIFEST_INVALID: "Check manifest.json: version must be 1 and adapters/extras must be valid arrays without duplicate keys.",
105
108
  MANAGER_UNAVAILABLE: "Run doctor and check the current user's native service manager.",
106
109
  COMPONENT_UNAVAILABLE: "Check component status and the service logs; the IPC or worker is not ready.",
107
110
  SERVICE_PROCESS_EXITED: "The service exited unexpectedly. Check its logs and configuration.",
@@ -1,7 +1,7 @@
1
1
  import { defaultRuntimeHome, runtimePaths, readJsonFile } from "./state.js";
2
- import { initializeCliOpenClaw } from "./openclaw.js";
2
+ import { loadCliManifest } from "./module-manifest.js";
3
+ import { resolveAdapterModules } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
3
4
  import { readAdapterConfigurations, createKernelService } from "@mininglamp-oss/octo-runtime-executor-kernel";
4
- import { resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { componentEndpoint } from "@mininglamp-oss/octo-runtime-host-sdk";
7
7
  import { mkdtemp, rm } from "node:fs/promises";
@@ -67,15 +67,17 @@ export async function runPlayboard(options) {
67
67
  const temporary = await mkdtemp(join(tmpdir(), "octo-playboard-"));
68
68
  try {
69
69
  const paths = runtimePaths(home, profile);
70
- await initializeCliOpenClaw(paths.profileRoot, options.env ?? process.env);
70
+ const manifest = await loadCliManifest(home, options.manifest);
71
71
  const configuration = await readJsonFile(paths.profileConfig);
72
72
  kernel = createKernelService({
73
73
  endpoint: process.platform === "win32" ? componentEndpoint(temporary) : join(temporary, "k.sock"),
74
- workerEntrypoint: fileURLToPath(import.meta.resolve("@mininglamp-oss/octo-runtime-executor-kernel/runner")),
75
- manifest: options.manifest
76
- ? resolve(options.manifest)
77
- : fileURLToPath(new URL("./default_adapters.json", import.meta.url)),
78
- env: options.env ?? process.env,
74
+ workerEntrypoint: fileURLToPath(new URL("./worker.js", import.meta.url)),
75
+ adapterModules: resolveAdapterModules(manifest),
76
+ env: {
77
+ ...(options.env ?? process.env),
78
+ OCTO_RUNTIME_CLI_PROFILE_ROOT: paths.profileRoot,
79
+ OCTO_RUNTIME_CLI_SYNC_OPENCLAW_TOOLS: "0"
80
+ },
79
81
  adapterConfigurations: readAdapterConfigurations(paths.profileRoot, configuration?.adapters)
80
82
  });
81
83
  await kernel.initialize({ signal: controller.signal });
@@ -0,0 +1,10 @@
1
+ import type { Writable } from "node:stream";
2
+ import { type ExtraStatusRecord } from "@mininglamp-oss/octo-runtime-adapter-sdk";
3
+ /** Bound stdout buffering without blocking Extras; report dropped records when the pipe drains. */
4
+ export declare class StatusOutput {
5
+ #private;
6
+ private readonly output;
7
+ constructor(output: Writable);
8
+ readonly write: (record: ExtraStatusRecord) => void;
9
+ readonly close: () => void;
10
+ }
@@ -0,0 +1,65 @@
1
+ import { extraStatusRecord } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
+ /** Bound stdout buffering without blocking Extras; report dropped records when the pipe drains. */
3
+ export class StatusOutput {
4
+ output;
5
+ #queue = [];
6
+ #bytes = 0;
7
+ #blocked = false;
8
+ #closed = false;
9
+ #dropped = 0;
10
+ #extra = "extra";
11
+ constructor(output) {
12
+ this.output = output;
13
+ output.on("error", this.close);
14
+ }
15
+ write = (record) => {
16
+ if (this.#closed)
17
+ return;
18
+ this.#extra = record.extra_type;
19
+ const line = `${JSON.stringify(record)}\n`;
20
+ if (this.#queue.length >= 128 || this.#bytes + Buffer.byteLength(line) > 1024 * 1024) {
21
+ this.#dropped = Math.min(Number.MAX_SAFE_INTEGER, this.#dropped + 1);
22
+ return;
23
+ }
24
+ this.#queue.push(line);
25
+ this.#bytes += Buffer.byteLength(line);
26
+ this.#flush();
27
+ };
28
+ #drain = () => {
29
+ this.#blocked = false;
30
+ this.#flush();
31
+ };
32
+ #flush() {
33
+ if (this.#closed || this.#blocked)
34
+ return;
35
+ while (this.#queue.length) {
36
+ const line = this.#queue.shift();
37
+ this.#bytes -= Buffer.byteLength(line);
38
+ try {
39
+ if (!this.output.write(line)) {
40
+ this.#blocked = true;
41
+ this.output.once("drain", this.#drain);
42
+ return;
43
+ }
44
+ }
45
+ catch {
46
+ this.close();
47
+ return;
48
+ }
49
+ }
50
+ if (this.#dropped) {
51
+ const record = extraStatusRecord(this.#extra, "warn", "service.output_dropped", {
52
+ dropped_count: this.#dropped
53
+ });
54
+ this.#dropped = 0;
55
+ this.write(record);
56
+ }
57
+ }
58
+ close = () => {
59
+ this.#closed = true;
60
+ this.#queue = [];
61
+ this.#bytes = 0;
62
+ this.output.off("drain", this.#drain);
63
+ this.output.off("error", this.close);
64
+ };
65
+ }
@@ -0,0 +1,18 @@
1
+ // CLI 自有执行 worker。顶层 Kernel 仍由 CLI 调用进程创建;SDK 原生入口不使用此装配。
2
+ import { loadManifestAdapters } from "@mininglamp-oss/octo-runtime-executor-kernel/manifest-adapters";
3
+ import { serveWorker } from "@mininglamp-oss/octo-runtime-executor-kernel";
4
+ import { readExtraDirectory } from "@mininglamp-oss/octo-runtime-host-sdk";
5
+ import { dirname, join } from "node:path";
6
+ const adapters = await loadManifestAdapters();
7
+ // 旧显式清单允许省略 type;以所选实例真实类型判断,不猜包名,也不在父进程重复实例化。
8
+ if (adapters.some((adapter) => adapter.metadata.type === "openclaw")) {
9
+ const profileRoot = process.env.OCTO_RUNTIME_CLI_PROFILE_ROOT;
10
+ if (!profileRoot)
11
+ throw new Error("CLI_PROFILE_ROOT_REQUIRED");
12
+ const { initializeCliOpenClaw, syncCliOpenClawToolEnvironment } = await import("./openclaw.js");
13
+ await initializeCliOpenClaw(profileRoot);
14
+ if (process.env.OCTO_RUNTIME_CLI_SYNC_OPENCLAW_TOOLS === "1")
15
+ await syncCliOpenClawToolEnvironment(profileRoot, await readExtraDirectory(join(dirname(profileRoot), "extras")));
16
+ }
17
+ // 产品连接准备完成后才建立既有 list/probe 握手;所有实例仅交给唯一 Core 注册一次。
18
+ serveWorker(adapters);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-cli",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,14 +8,27 @@
8
8
  },
9
9
  "types": "./dist/index.d.ts",
10
10
  "dependencies": {
11
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.0",
11
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.1",
12
12
  "json5": "2.2.3",
13
- "@mininglamp-oss/octo-runtime-extra-channel-gateway": "1.1.0",
14
- "@mininglamp-oss/octo-runtime-host-sdk": "1.1.0",
15
- "@mininglamp-oss/octo-runtime-adapter-openclaw": "1.1.0",
16
- "@mininglamp-oss/octo-runtime-cross-service": "1.1.0",
17
- "@mininglamp-oss/octo-runtime-protocol": "1.1.0",
18
- "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.0",
19
- "@mininglamp-oss/octo-runtime-executor-core": "1.1.0"
13
+ "@mininglamp-oss/octo-runtime-extra-channel-gateway": "1.1.1",
14
+ "@mininglamp-oss/octo-runtime-host-sdk": "1.1.1",
15
+ "@mininglamp-oss/octo-runtime-adapter-openclaw": "1.1.1",
16
+ "@mininglamp-oss/octo-runtime-cross-service": "1.1.1",
17
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.1",
18
+ "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.1",
19
+ "@mininglamp-oss/octo-runtime-executor-core": "1.1.1",
20
+ "@mininglamp-oss/octo-runtime-adapter-antigravity": "1.1.1",
21
+ "@mininglamp-oss/octo-runtime-adapter-claude-code": "1.1.1",
22
+ "@mininglamp-oss/octo-runtime-adapter-codebuddy": "1.1.1",
23
+ "@mininglamp-oss/octo-runtime-adapter-codex": "1.1.1",
24
+ "@mininglamp-oss/octo-runtime-adapter-hermes": "1.1.1",
25
+ "@mininglamp-oss/octo-runtime-adapter-kimi-code": "1.1.1",
26
+ "@mininglamp-oss/octo-runtime-adapter-mcode": "1.1.1",
27
+ "@mininglamp-oss/octo-runtime-adapter-opencode": "1.1.1",
28
+ "@mininglamp-oss/octo-runtime-adapter-qodercli": "1.1.1",
29
+ "@mininglamp-oss/octo-runtime-adapter-qoderclicn": "1.1.1",
30
+ "@mininglamp-oss/octo-runtime-adapter-zcode-gui": "1.1.1",
31
+ "@mininglamp-oss/octo-runtime-extra-channel-wecom": "1.1.1",
32
+ "@mininglamp-oss/octo-runtime-extra-webui": "1.1.1"
20
33
  }
21
34
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-cross-service",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "private": true,
5
5
  "description": "Native user-service lifecycle backends for Octo Runtime",
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  "README.md"
12
12
  ],
13
13
  "engines": {
14
- "node": ">=24 <25"
14
+ "node": "^24.0.0 || ^26.0.0"
15
15
  },
16
16
  "dependencies": {}
17
17
  }
@@ -1,5 +1,5 @@
1
1
  import type { ContextEnvelope, InvokeRequest } from "@mininglamp-oss/octo-runtime-protocol";
2
- /** 仅渲染允许进入模型的业务 Context,执行/安全配置不作为普通提示词;对象键排序使同一快照稳定。 */
2
+ /** 仅渲染允许进入模型的业务 Context;固定格式使用英文,业务内容保留原文,对象键排序使同一快照稳定。 */
3
3
  export declare function renderModelContexts(context: ContextEnvelope): string;
4
4
  /**
5
5
  * Core 冻结原请求后、派发 Adapter 前调用一次;接入方不应预先渲染而造成 Context 重复。
@@ -1,20 +1,20 @@
1
1
  const MODEL_CONTEXT_PATTERNS = [/^extra\.[^/]+\/[^/]+$/, /^octo\.content\/(inline|references)$/];
2
- /** 仅渲染允许进入模型的业务 Context,执行/安全配置不作为普通提示词;对象键排序使同一快照稳定。 */
2
+ /** 仅渲染允许进入模型的业务 Context;固定格式使用英文,业务内容保留原文,对象键排序使同一快照稳定。 */
3
3
  export function renderModelContexts(context) {
4
4
  const items = context.items.filter((item) => MODEL_CONTEXT_PATTERNS.some((pattern) => pattern.test(item.namespace + "/" + item.name)));
5
5
  if (!items.length)
6
6
  return "";
7
7
  return [
8
- "<--- 上下文信息开始:以下内容为当前上下文信息 --->",
8
+ "<--- Context information begins: the following is the current context --->",
9
9
  "<contexts>",
10
10
  ...items.map((item) => [
11
11
  ` <context-item namespace="${item.namespace}" name="${item.name}">`,
12
- ...(item.guidance ? [` 指引: ${item.guidance}`] : []),
13
- ` 数据: ${JSON.stringify(sorted(item.payload))}`,
12
+ ...(item.guidance ? [` Guidance: ${item.guidance}`] : []),
13
+ ` Data: ${JSON.stringify(sorted(item.payload))}`,
14
14
  " </context-item>"
15
15
  ].join("\n")),
16
16
  "</contexts>",
17
- "<--- 上下文信息结束 --->"
17
+ "<--- Context information ends --->"
18
18
  ].join("\n");
19
19
  }
20
20
  function sorted(value) {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-executor-core",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
7
7
  "dependencies": {
8
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.0",
9
- "@mininglamp-oss/octo-runtime-protocol": "1.1.0"
8
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.1",
9
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.1"
10
10
  },
11
11
  "types": "./dist/index.d.ts",
12
12
  "files": [
@@ -0,0 +1,16 @@
1
+ /** A paused supervisor cannot establish worker failure; require a fresh probe after a gap. */
2
+ export declare class WorkerHeartbeat {
3
+ #private;
4
+ private readonly wallNow;
5
+ private readonly monotonicNow;
6
+ activeMs: number;
7
+ healthyMs: number;
8
+ constructor(wallNow?: () => number, monotonicNow?: () => number);
9
+ tick(): {
10
+ type: "ping";
11
+ id: number;
12
+ } | {
13
+ type: "waiting" | "expired";
14
+ };
15
+ pong(id: unknown): void;
16
+ }
@@ -0,0 +1,59 @@
1
+ import { performance } from "node:perf_hooks";
2
+ /** A paused supervisor cannot establish worker failure; require a fresh probe after a gap. */
3
+ export class WorkerHeartbeat {
4
+ wallNow;
5
+ monotonicNow;
6
+ #wall;
7
+ #mono;
8
+ #sequence = 0;
9
+ #pending;
10
+ #answered = false;
11
+ activeMs = 0;
12
+ healthyMs = 0;
13
+ constructor(wallNow = Date.now, monotonicNow = () => performance.now()) {
14
+ this.wallNow = wallNow;
15
+ this.monotonicNow = monotonicNow;
16
+ this.#wall = wallNow();
17
+ this.#mono = monotonicNow();
18
+ }
19
+ #gap(wall, mono) {
20
+ return (wall < this.#wall ||
21
+ mono < this.#mono ||
22
+ wall - this.#wall >= 5000 ||
23
+ mono - this.#mono >= 5000);
24
+ }
25
+ tick() {
26
+ const wall = this.wallNow(), mono = this.monotonicNow();
27
+ // Either clock can reveal suspend or a blocked supervisor; discard pre-gap liveness evidence.
28
+ if (this.#gap(wall, mono)) {
29
+ this.#pending = undefined;
30
+ this.#answered = false;
31
+ this.healthyMs = 0;
32
+ }
33
+ else {
34
+ const elapsed = mono - this.#mono;
35
+ this.activeMs += elapsed;
36
+ if (this.#answered)
37
+ this.healthyMs += elapsed;
38
+ }
39
+ this.#wall = wall;
40
+ this.#mono = mono;
41
+ this.#answered = false;
42
+ // Ordinary timer ticks never renew an unanswered probe's fixed deadline.
43
+ if (this.#pending)
44
+ return { type: mono >= this.#pending.deadline ? "expired" : "waiting" };
45
+ this.#pending = { id: ++this.#sequence, deadline: mono + 5000 };
46
+ return { type: "ping", id: this.#sequence };
47
+ }
48
+ pong(id) {
49
+ const wall = this.wallNow(), mono = this.monotonicNow();
50
+ // A queued or stale pong cannot establish post-resume health or extend the new deadline.
51
+ if (this.#gap(wall, mono) ||
52
+ !this.#pending ||
53
+ id !== this.#pending.id ||
54
+ mono >= this.#pending.deadline)
55
+ return;
56
+ this.#pending = undefined;
57
+ this.#answered = true;
58
+ }
59
+ }
@@ -31,4 +31,5 @@ export declare class InvocationManifest {
31
31
  * 无法验证身份时保留清单并报告 unsupported_identity;worker 已消失不证明 Windows 后代已清空。
32
32
  */
33
33
  export declare function reapOrphanedInvocationManifest(path: string): Promise<OrphanReapResult>;
34
+ /** 查询系统启动时间以区分 PID 复用;失败时不返回可用于回收的身份,绝不以 PID 本身兜底。 */
34
35
  export declare function processStartIdentity(pid: number): Promise<string | undefined>;