@mininglamp-oss/octo-runtime 1.1.4 → 1.1.5

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 (117) hide show
  1. package/README.md +61 -37
  2. package/apps/cli/README.md +58 -22
  3. package/apps/cli/dist/build-info.json +2 -2
  4. package/apps/cli/dist/cli-entrypoint.d.ts +2 -0
  5. package/apps/cli/dist/cli-entrypoint.js +16 -0
  6. package/apps/cli/dist/command-tree.d.ts +20 -0
  7. package/apps/cli/dist/command-tree.js +402 -0
  8. package/apps/cli/dist/extra-command-config.d.ts +4 -0
  9. package/apps/cli/dist/extra-command-config.js +50 -0
  10. package/apps/cli/dist/extra-commands.d.ts +15 -0
  11. package/apps/cli/dist/extra-commands.js +275 -0
  12. package/apps/cli/dist/extras.js +14 -2
  13. package/apps/cli/dist/global-extras.d.ts +16 -0
  14. package/apps/cli/dist/global-extras.js +201 -0
  15. package/apps/cli/dist/help.d.ts +4 -1
  16. package/apps/cli/dist/help.js +31 -79
  17. package/apps/cli/dist/main.d.ts +2 -0
  18. package/apps/cli/dist/main.js +27 -63
  19. package/apps/cli/dist/manifest.json +48 -3
  20. package/apps/cli/dist/module-manifest.d.ts +1 -1
  21. package/apps/cli/dist/module-manifest.js +3 -2
  22. package/apps/cli/dist/output.js +13 -2
  23. package/apps/cli/dist/service-control.js +2 -2
  24. package/apps/cli/dist/state.js +48 -19
  25. package/dist/public/channel-gateway-commands.d.ts +1 -0
  26. package/dist/public/channel-gateway-commands.js +1 -0
  27. package/dist/public/channel-wecom-commands.d.ts +1 -0
  28. package/dist/public/channel-wecom-commands.js +1 -0
  29. package/dist/public/extra.d.ts +1 -0
  30. package/dist/public/extra.js +1 -0
  31. package/dist/public/host.d.ts +2 -4
  32. package/dist/public/host.js +1 -2
  33. package/dist/public/webui-commands.d.ts +1 -0
  34. package/dist/public/webui-commands.js +1 -0
  35. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  36. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  37. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  38. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  39. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  40. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  41. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
  42. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
  43. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  46. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  47. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  48. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
  49. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
  50. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/module-manifest.d.ts +6 -0
  51. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/module-manifest.js +16 -4
  52. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
  53. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
  54. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  55. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/cli-entrypoint.d.ts +2 -0
  56. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/cli-entrypoint.js +16 -0
  57. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.d.ts +20 -0
  58. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +402 -0
  59. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-command-config.d.ts +4 -0
  60. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-command-config.js +50 -0
  61. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-commands.d.ts +15 -0
  62. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-commands.js +275 -0
  63. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extras.js +14 -2
  64. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/global-extras.d.ts +16 -0
  65. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/global-extras.js +201 -0
  66. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/help.d.ts +4 -1
  67. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/help.js +31 -79
  68. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.d.ts +2 -0
  69. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +27 -63
  70. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +48 -3
  71. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.d.ts +1 -1
  72. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.js +3 -2
  73. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +13 -2
  74. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/service-control.js +2 -2
  75. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.js +48 -19
  76. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +25 -24
  77. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
  78. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  79. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -4
  80. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +3 -3
  81. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/commands.d.ts +4 -0
  82. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/commands.js +124 -0
  83. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/auth.d.ts +1 -1
  84. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/auth.js +2 -2
  85. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connection-error.d.ts +7 -0
  86. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connection-error.js +44 -3
  87. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js +8 -5
  88. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +10 -6
  89. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/commands.d.ts +4 -0
  90. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/commands.js +128 -0
  91. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +9 -5
  92. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/commands.d.ts +3 -0
  93. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/commands.js +51 -0
  94. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +7 -3
  95. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-commands.d.ts +70 -0
  96. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-commands.js +16 -0
  97. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.d.ts +1 -3
  98. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.js +1 -2
  99. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +8 -4
  100. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  101. package/node_modules/commander/LICENSE +22 -0
  102. package/node_modules/commander/Readme.md +1172 -0
  103. package/node_modules/commander/index.js +21 -0
  104. package/node_modules/commander/lib/argument.js +147 -0
  105. package/node_modules/commander/lib/command.js +2790 -0
  106. package/node_modules/commander/lib/error.js +36 -0
  107. package/node_modules/commander/lib/help.js +731 -0
  108. package/node_modules/commander/lib/option.js +377 -0
  109. package/node_modules/commander/lib/suggestSimilar.js +99 -0
  110. package/node_modules/commander/package-support.json +19 -0
  111. package/node_modules/commander/package.json +64 -0
  112. package/node_modules/commander/typings/index.d.ts +1113 -0
  113. package/package.json +41 -27
  114. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/launch.d.ts +0 -15
  115. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/launch.js +0 -22
  116. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/native.d.ts +0 -16
  117. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/native.js +0 -160
@@ -1,3 +1,4 @@
1
+ import { runExtraCommand, commandError } from "./extra-commands.js";
1
2
  import net from "node:net";
2
3
  import { randomUUID } from "node:crypto";
3
4
  import { once } from "node:events";
@@ -7,7 +8,8 @@ import { fileURLToPath } from "node:url";
7
8
  import { attachKernel, acknowledgeOrphanCleanup, inspectOrphanCleanup, createKernelService, readAdapterConfigurations } from "@mininglamp-oss/octo-runtime-executor-kernel";
8
9
  import { componentEndpoint, createExtraService } from "@mininglamp-oss/octo-runtime-host-sdk";
9
10
  import { getExtra, readExtra, setExtra } from "./extras.js";
10
- import { cliVersionInfo, helpText } from "./help.js";
11
+ import { cliVersionInfo } from "./help.js";
12
+ import { parseCliCommand } from "./command-tree.js";
11
13
  import { runForegroundService } from "./foreground.js";
12
14
  import { showExtraLogs } from "./logs.js";
13
15
  import { StatusOutput } from "./status-output.js";
@@ -21,12 +23,22 @@ const components = ["executor-kernel", "channel-gateway"];
21
23
  const builtinComponents = [...components, "channel-wecom", "webui"];
22
24
  export async function runCli(args, dependencies = {}) {
23
25
  const output = dependencies.output ?? ((line) => process.stdout.write(`${line}\n`));
24
- let json = args.includes("--json");
26
+ // 参数解析失败也按宿主布尔标记输出 JSON;-- 后的字面位置参数不选择输出格式。
27
+ const literalIndex = args.indexOf("--");
28
+ let json = (literalIndex < 0 ? args : args.slice(0, literalIndex)).some((arg) => arg === "--json" || arg.startsWith("--json="));
25
29
  let context = {};
26
30
  let runningComponent;
27
31
  let statusOutput;
28
32
  try {
29
- const { flags, positional } = parse(args);
33
+ const parsed = await parseCliCommand(args, dependencies);
34
+ if (parsed.help !== undefined) {
35
+ output(parsed.help);
36
+ return 0;
37
+ }
38
+ const { flags, positional } = parsed;
39
+ json = Boolean(flags.json);
40
+ if (parsed.extra)
41
+ return await runExtraCommand(parsed, dependencies);
30
42
  if (flags["acknowledge-orphan-cleanup"] !== undefined &&
31
43
  !(positional[0] === "executor-kernel" && positional[1] === "recover"))
32
44
  throw new Error("INVALID_ARGUMENTS");
@@ -37,15 +49,6 @@ export async function runCli(args, dependencies = {}) {
37
49
  output(cliVersionInfo);
38
50
  return 0;
39
51
  }
40
- if (flags.help || !positional.length || positional[0] === "help") {
41
- output(helpText(builtinComponents.includes(positional[0]) ? positional[0] : undefined));
42
- return 0;
43
- }
44
- // 裸组件帮助仅做词法校验,不读取配置或创建服务管理器。
45
- if (positional.length === 1 && builtinComponents.includes(positional[0])) {
46
- output(helpText(positional[0]));
47
- return 0;
48
- }
49
52
  const home = resolve(flags.home ?? defaultRuntimeHome(dependencies.env, dependencies.platform));
50
53
  // 模块清单不决定运行状态位置;前台 Kernel、doctor 和恢复确认共用 Home 下的同一路径。
51
54
  const kernelStateDirectory = join(home, "run");
@@ -125,10 +128,6 @@ export async function runCli(args, dependencies = {}) {
125
128
  const isComponent = (name) => builtinComponents.includes(name) ||
126
129
  registrations.some((entry) => entry.name === name) ||
127
130
  manifest?.extras.some((entry) => entry.name === name) === true;
128
- if (positional.length === 1 && isComponent(positional[0])) {
129
- output(helpText(positional[0]));
130
- return 0;
131
- }
132
131
  const service = resolveServiceControl(dependencies);
133
132
  const input = dependencies.input ?? process.stdin;
134
133
  const publish = (value, human) => output(typeof value === "string" ? value : !json && human ? human : JSON.stringify(value, null, 2));
@@ -372,21 +371,23 @@ export async function runCli(args, dependencies = {}) {
372
371
  catch (error) {
373
372
  if (runningComponent && context.logs)
374
373
  await recordStartupFailure(context.logs, runningComponent, error);
375
- const failure = { ...describeError(error), ...context };
374
+ const failure = { ...(commandError(error) ?? describeError(error)), ...context };
376
375
  const code = failure.code;
377
376
  if (json)
378
377
  output(JSON.stringify({ error: failure }, null, context.action === "logs" ? undefined : 2));
379
378
  else
380
379
  (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}` : ""}`);
381
- return ["SERVICE_NOT_INSTALLED", "NOT_INSTALLED"].includes(code)
382
- ? 3
383
- : /INVALID|REQUIRED/.test(code)
384
- ? 2
385
- : /INCOMPLETE/.test(code)
386
- ? 5
387
- : /UNAVAILABLE|SERVICE_PROCESS_EXITED/.test(code)
388
- ? 4
389
- : 1;
380
+ return code === "EXTRA_COMMAND_CANCELLED"
381
+ ? 130
382
+ : ["SERVICE_NOT_INSTALLED", "NOT_INSTALLED"].includes(code)
383
+ ? 3
384
+ : /INVALID|REQUIRED|COMMAND_NOT_FOUND/.test(code)
385
+ ? 2
386
+ : /INCOMPLETE/.test(code)
387
+ ? 5
388
+ : /UNAVAILABLE|SERVICE_PROCESS_EXITED/.test(code)
389
+ ? 4
390
+ : 1;
390
391
  }
391
392
  finally {
392
393
  statusOutput?.close();
@@ -448,40 +449,3 @@ async function componentStatus(home, component, platform, requireReady = false)
448
449
  });
449
450
  }
450
451
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
451
- function parse(args) {
452
- const flags = {}, positional = [];
453
- for (let i = 0; i < args.length; i++) {
454
- const arg = args[i] === "-h" ? "--help" : args[i] === "-v" ? "--version" : args[i];
455
- if (!arg.startsWith("-")) {
456
- positional.push(arg);
457
- continue;
458
- }
459
- const match = /^--([a-z-]+)(?:=(.*))?$/.exec(arg);
460
- if (!match ||
461
- ![
462
- "home",
463
- "profile",
464
- "manifest",
465
- "json",
466
- "help",
467
- "version",
468
- "autostart",
469
- "lines",
470
- "follow",
471
- "acknowledge-orphan-cleanup"
472
- ].includes(match[1]) ||
473
- Object.hasOwn(flags, match[1]))
474
- throw new Error("INVALID_ARGUMENTS");
475
- const key = match[1];
476
- flags[key] = ["json", "help", "version", "follow", "acknowledge-orphan-cleanup"].includes(key)
477
- ? "true"
478
- : (match[2] ?? args[++i]);
479
- if (key === "acknowledge-orphan-cleanup" && match[2] !== undefined)
480
- throw new Error("INVALID_ARGUMENTS");
481
- if (!flags[key] ||
482
- flags[key].startsWith("--") ||
483
- (key === "autostart" && !["true", "false"].includes(flags[key])))
484
- throw new Error("INVALID_ARGUMENTS");
485
- }
486
- return { flags, positional };
487
- }
@@ -73,8 +73,53 @@
73
73
  }
74
74
  ],
75
75
  "extras": [
76
- { "name": "channel-gateway", "module": "@mininglamp-oss/octo-runtime-extra-channel-gateway" },
77
- { "name": "channel-wecom", "module": "@mininglamp-oss/octo-runtime-extra-channel-wecom" },
78
- { "name": "webui", "module": "@mininglamp-oss/octo-runtime-extra-webui" }
76
+ {
77
+ "name": "channel-gateway",
78
+ "description": "Connect Octo IM Bots to local Agent execution",
79
+ "configExample": {
80
+ "bots": [
81
+ {
82
+ "api_url": "https://im.example.com/api",
83
+ "bot_id": "<BOT_ID>",
84
+ "bf_token": "<BOT_TOKEN>",
85
+ "adapter": {
86
+ "adapter_type": "codex",
87
+ "workdir": "/absolute/workspace",
88
+ "model": "<MODEL_ID>",
89
+ "effort": "medium"
90
+ }
91
+ }
92
+ ]
93
+ },
94
+ "module": "@mininglamp-oss/octo-runtime-extra-channel-gateway"
95
+ },
96
+ {
97
+ "name": "channel-wecom",
98
+ "description": "Connect WeCom Bots to local Agent execution",
99
+ "configExample": {
100
+ "bots": [
101
+ {
102
+ "bot_id": "<BOT_ID>",
103
+ "app_secret": "<APP_SECRET>",
104
+ "adapter": {
105
+ "adapter_type": "codex",
106
+ "workdir": "/absolute/workspace",
107
+ "model": "<MODEL_ID>",
108
+ "effort": "medium"
109
+ }
110
+ }
111
+ ]
112
+ },
113
+ "module": "@mininglamp-oss/octo-runtime-extra-channel-wecom"
114
+ },
115
+ {
116
+ "name": "webui",
117
+ "description": "Open a local browser workspace for Agent conversations",
118
+ "configExample": {
119
+ "port": 13888,
120
+ "sessionStorePath": "/absolute/host-home/extras/webui/sessions.json"
121
+ },
122
+ "module": "@mininglamp-oss/octo-runtime-extra-webui"
123
+ }
79
124
  ]
80
125
  }
@@ -1,3 +1,3 @@
1
1
  import { type ModuleManifest } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
2
- /** CLI 独占默认目录与 Home 扩展策略;SDK 原生装配不读取这两份文件。 */
2
+ /** CLI 独占内置、Home 与全局 Extra 目录;SDK 不扫描,显式清单完全替换。 */
3
3
  export declare function loadCliManifest(home: string, override?: string, report?: (message: string) => void): Promise<ModuleManifest>;
@@ -1,11 +1,12 @@
1
1
  import { join, resolve } from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { mergeModuleManifests, readModuleManifest } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
4
- /** CLI 独占默认目录与 Home 扩展策略;SDK 原生装配不读取这两份文件。 */
4
+ import { discoverGlobalExtras, mergeGlobalExtras } from "./global-extras.js";
5
+ /** CLI 独占内置、Home 与全局 Extra 目录;SDK 不扫描,显式清单完全替换。 */
5
6
  export async function loadCliManifest(home, override, report = (message) => console.error(message)) {
6
7
  if (override)
7
8
  return readModuleManifest(resolve(override), { legacy: true });
8
9
  const builtin = await readModuleManifest(fileURLToPath(new URL("./manifest.json", import.meta.url)));
9
10
  const extension = await readModuleManifest(join(home, "manifest.json"), { optional: true });
10
- return mergeModuleManifests(builtin, extension, report);
11
+ return mergeGlobalExtras(mergeModuleManifests(builtin, extension, report), await discoverGlobalExtras(report), report);
11
12
  }
@@ -104,8 +104,19 @@ export function describeError(error, fallback = "COMMAND_FAILED") {
104
104
  ORPHAN_CLEANUP_NOT_PENDING: "There is no valid incomplete orphan cleanup to acknowledge. Run doctor with the same --home.",
105
105
  SERVICE_NOT_INSTALLED: "Run this component's install command, then start it.",
106
106
  NOT_INSTALLED: "Run this component's install command, then start it.",
107
- EXTRA_NOT_REGISTERED: "Save this Extra's declaration with extraset before starting it.",
108
- EXTRA_MANIFEST_DECLARATION_REQUIRED: "Add this Extra's name and module to the selected Home manifest.json (extras array), then retry.",
107
+ EXTRA_COMMAND_FAILED: "The Extra command failed. No private backend error is printed; check its input and configuration, then retry.",
108
+ EXTRA_CONFIG_CONFLICT: "Configuration changed after this command read it. Read the latest configuration and retry.",
109
+ EXTRA_COMMAND_LOAD_FAILED: "The selected Extra command module or one of its dependencies is broken. Check its package and commands export; lifecycle commands remain available.",
110
+ EXTRA_COMMAND_API_UNSUPPORTED: "This CLI supports Extra command apiVersion 1. Install a compatible command extension.",
111
+ EXTRA_COMMAND_DEFINITION_INVALID: "Command definitions must have unique names and valid options; lifecycle and host option names are reserved.",
112
+ EXTRA_COMMAND_NAMESPACE_CONFLICT: "An Extra name conflicts with a Runtime command. Rename its manifest entry.",
113
+ EXTRA_COMMAND_NOT_FOUND: "Unknown command. Use --help on the service command to see available subcommands.",
114
+ EXTRA_COMMAND_CANCELLED: "The command was cancelled. Any save that already completed remains persisted.",
115
+ EXTRA_COMMAND_STDIN_REQUIRED: "Pipe the required input through stdin; do not put credentials in command arguments.",
116
+ EXTRA_NOT_REGISTERED: "Save the service configuration using its configure or extraset subcommand before starting it.",
117
+ EXTRA_MANIFEST_DECLARATION_REQUIRED: "Install this Extra alongside the global Runtime, or add its name and module to the selected Home manifest.json (extras array), then retry.",
118
+ EXTRA_NAME_MISMATCH: "The selected Extra must export the same name as its catalog entry. Check the reported package origin.",
119
+ EXTRA_MODULE_LOAD_FAILED: "Check the selected catalog declaration, discovery diagnostics, installation and ESM exports; reinstall it or select a valid Home manifest entry, then retry.",
109
120
  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.",
110
121
  MANIFEST_INVALID: "Check manifest.json: version must be 1 and adapters/extras must be valid arrays without duplicate keys.",
111
122
  MANAGER_UNAVAILABLE: "Run doctor and check the current user's native service manager.",
@@ -1,6 +1,6 @@
1
1
  import { homedir } from "node:os";
2
2
  import { resolve } from "node:path";
3
- import { fileURLToPath } from "node:url";
3
+ import { cliEntrypoint } from "./cli-entrypoint.js";
4
4
  import { componentServiceId } from "@mininglamp-oss/octo-runtime-host-sdk";
5
5
  import { createServiceBackend } from "@mininglamp-oss/octo-runtime-cross-service";
6
6
  export function resolveServiceControl(options = {}) {
@@ -19,7 +19,7 @@ export function resolveServiceControl(options = {}) {
19
19
  description: `Octo Runtime ${component}`,
20
20
  command: resolve(options.nodeExecutable ?? process.execPath),
21
21
  args: [
22
- resolve(options.cliEntrypoint ?? fileURLToPath(new URL("./index.js", import.meta.url))),
22
+ resolve(options.cliEntrypoint ?? cliEntrypoint()),
23
23
  component,
24
24
  "run",
25
25
  "--home",
@@ -1,5 +1,5 @@
1
- import { randomUUID } from "node:crypto";
2
- import { access, chmod, mkdir, open, readFile, rename, rm, rmdir } from "node:fs/promises";
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { access, chmod, link, mkdir, open, readFile, rename, rm, rmdir } from "node:fs/promises";
3
3
  import { homedir } from "node:os";
4
4
  import { basename, dirname, join, resolve } from "node:path";
5
5
  import { componentEndpoint } from "@mininglamp-oss/octo-runtime-host-sdk";
@@ -235,35 +235,64 @@ async function writeFileAtomic(path, value) {
235
235
  throw error;
236
236
  }
237
237
  }
238
+ /**
239
+ * 主锁和回收锁使用同一协议:先完整写入独占临时文件,再用硬链接原子发布 PID/随机身份。
240
+ * 发布前退出只留下不参与互斥的临时文件;发布后退出可按 PID 回收,不存在无 owner 窗口。
241
+ * 回收前先持有该锁自己的回收锁,并再次核对原记录,防止删除后来取得的锁。
242
+ * 回收者也可能退出,因此回收锁递归遵循同一协议;固定长度哈希避免路径随层级增长。
243
+ */
238
244
  async function acquireProcessLock(path) {
239
- for (let attempt = 0; attempt < 2; attempt++) {
245
+ const record = `${JSON.stringify({ pid: process.pid, id: randomUUID() })}\n`;
246
+ const temporary = `${path}.${process.pid}.${randomUUID()}.tmp`;
247
+ const handle = await open(temporary, "wx", 0o600);
248
+ try {
240
249
  try {
241
- const handle = await open(path, "wx", 0o600);
242
- await handle.writeFile(`${JSON.stringify({ pid: process.pid, created_at: new Date().toISOString() })}\n`, "utf8");
250
+ await handle.writeFile(record, "utf8");
251
+ }
252
+ finally {
243
253
  await handle.close();
244
- return async () => {
254
+ }
255
+ for (let attempt = 0; attempt < 2; attempt++) {
256
+ try {
257
+ await link(temporary, path);
258
+ return async () => {
259
+ if ((await readLockOwner(path))?.record === record)
260
+ await rm(path, { force: true });
261
+ };
262
+ }
263
+ catch (error) {
264
+ if (!isNodeError(error, "EEXIST"))
265
+ throw error;
245
266
  const owner = await readLockOwner(path);
246
- if (owner === process.pid)
267
+ // 旧格式的不完整记录仍需保守拒绝;不能根据时间猜测它已失效。
268
+ if (!owner || processAlive(owner.pid))
269
+ throw new Error("SETUP_IN_PROGRESS", { cause: error });
270
+ // 只哈希文件名,使同一 Home 的不同符号链接路径仍争用同一个回收锁。
271
+ const reclaim = join(dirname(path), `.reclaim-${createHash("sha256").update(basename(path)).digest("hex")}`);
272
+ const release = await acquireProcessLock(reclaim);
273
+ try {
274
+ const current = await readLockOwner(path);
275
+ if (!current || current.record !== owner.record || processAlive(current.pid))
276
+ throw new Error("SETUP_IN_PROGRESS", { cause: error });
247
277
  await rm(path, { force: true });
248
- };
249
- }
250
- catch (error) {
251
- if (!isNodeError(error, "EEXIST"))
252
- throw error;
253
- const owner = await readLockOwner(path);
254
- if (owner !== undefined && processAlive(owner)) {
255
- throw new Error("SETUP_IN_PROGRESS", { cause: error });
278
+ }
279
+ finally {
280
+ await release();
281
+ }
256
282
  }
257
- await rm(path, { force: true });
258
283
  }
284
+ throw new Error("could not acquire setup lock");
285
+ }
286
+ finally {
287
+ await rm(temporary, { force: true });
259
288
  }
260
- throw new Error("could not acquire setup lock");
261
289
  }
262
290
  async function readLockOwner(path) {
263
291
  try {
264
- const value = JSON.parse(await readFile(path, "utf8"));
292
+ const record = await readFile(path, "utf8");
293
+ const value = JSON.parse(record);
265
294
  return typeof value.pid === "number" && Number.isSafeInteger(value.pid) && value.pid > 0
266
- ? value.pid
295
+ ? { pid: value.pid, record }
267
296
  : undefined;
268
297
  }
269
298
  catch {
@@ -0,0 +1 @@
1
+ export { default } from "@mininglamp-oss/octo-runtime-extra-channel-gateway/commands";
@@ -0,0 +1 @@
1
+ export { default } from "@mininglamp-oss/octo-runtime-extra-channel-gateway/commands";
@@ -0,0 +1 @@
1
+ export { default } from "@mininglamp-oss/octo-runtime-extra-channel-wecom/commands";
@@ -0,0 +1 @@
1
+ export { default } from "@mininglamp-oss/octo-runtime-extra-channel-wecom/commands";
@@ -2,3 +2,4 @@ export * from "./protocol.js";
2
2
  export type { ExtraContext, RuntimeLog, RuntimeLogLevel, ExtraDisposer, ExtraInitializer, ExtraPlugin, ExtraPluginModule, ExtraRegistration, ExtraStatus, ExtraStatusHandler, JsonObject, JsonValue } from "@mininglamp-oss/octo-runtime-host-sdk/extra";
3
3
  export { ExtraPlugins } from "@mininglamp-oss/octo-runtime-host-sdk/extra";
4
4
  export type { ExtraDescriptor, StoredExtra } from "@mininglamp-oss/octo-runtime-host-sdk/extra-config";
5
+ export * from "@mininglamp-oss/octo-runtime-host-sdk/extra-commands";
@@ -1,2 +1,3 @@
1
1
  export * from "./protocol.js";
2
2
  export { ExtraPlugins } from "@mininglamp-oss/octo-runtime-host-sdk/extra";
3
+ export * from "@mininglamp-oss/octo-runtime-host-sdk/extra-commands";
@@ -1,7 +1,5 @@
1
- export { createExtraService, ComponentStartError, componentEndpoint, componentServiceId, homeHash, normalizedHome } from "@mininglamp-oss/octo-runtime-host-sdk";
2
- export type { ExtraService, ExtraServiceOptions, ExtraServiceStatus, CleanupResult } from "@mininglamp-oss/octo-runtime-host-sdk";
3
- export { startNativeComponent } from "@mininglamp-oss/octo-runtime-host-sdk";
4
- export type { NativeComponentOptions } from "@mininglamp-oss/octo-runtime-host-sdk";
1
+ export { createExtraService, componentEndpoint, componentServiceId, homeHash, normalizedHome } from "@mininglamp-oss/octo-runtime-host-sdk";
2
+ export type { ExtraService, ExtraServiceOptions, ExtraServiceStatus } from "@mininglamp-oss/octo-runtime-host-sdk";
5
3
  export type { RuntimeLoggingOptions, ExtraStatusRecord } from "@mininglamp-oss/octo-runtime-host-sdk";
6
4
  export { createKernelService, ServiceInitializationError } from "./executor-kernel.js";
7
5
  export type { KernelService, KernelServiceOptions, KernelServiceStatus, ServiceCleanupResult, ServiceLifecycle, ServicePhase } from "./executor-kernel.js";
@@ -1,3 +1,2 @@
1
- export { createExtraService, ComponentStartError, componentEndpoint, componentServiceId, homeHash, normalizedHome } from "@mininglamp-oss/octo-runtime-host-sdk";
2
- export { startNativeComponent } from "@mininglamp-oss/octo-runtime-host-sdk";
1
+ export { createExtraService, componentEndpoint, componentServiceId, homeHash, normalizedHome } from "@mininglamp-oss/octo-runtime-host-sdk";
3
2
  export { createKernelService, ServiceInitializationError } from "./executor-kernel.js";
@@ -0,0 +1 @@
1
+ export { default } from "@mininglamp-oss/octo-runtime-extra-webui/commands";
@@ -0,0 +1 @@
1
+ export { default } from "@mininglamp-oss/octo-runtime-extra-webui/commands";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-acp-client",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
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.4",
13
- "@mininglamp-oss/octo-runtime-protocol": "1.1.4"
12
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5",
13
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.5"
14
14
  }
15
15
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-acp",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
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.4",
13
- "@mininglamp-oss/octo-runtime-acp-client": "1.1.4",
14
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.4"
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"
15
15
  }
16
16
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-antigravity",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
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.4",
14
- "@mininglamp-oss/octo-runtime-protocol": "1.1.4"
13
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5",
14
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.5"
15
15
  }
16
16
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-claude-code",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
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.4",
9
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.4"
8
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.5",
9
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5"
10
10
  },
11
11
  "types": "./dist/index.d.ts",
12
12
  "files": [
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-codebuddy",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
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.4",
9
- "@mininglamp-oss/octo-runtime-acp-client": "1.1.4",
10
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.4"
8
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.5",
9
+ "@mininglamp-oss/octo-runtime-acp-client": "1.1.5",
10
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5"
11
11
  },
12
12
  "types": "./dist/index.d.ts",
13
13
  "files": [
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-codex",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
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.4",
9
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.4"
8
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.5",
9
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5"
10
10
  },
11
11
  "types": "./dist/index.d.ts",
12
12
  "files": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-dsh",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
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.4",
13
- "@mininglamp-oss/octo-runtime-protocol": "1.1.4"
12
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5",
13
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.5"
14
14
  }
15
15
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-grok-build",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -9,9 +9,9 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@mininglamp-oss/octo-runtime-acp-client": "1.1.4",
13
- "@mininglamp-oss/octo-runtime-adapter-acp": "1.1.4",
14
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.4",
15
- "@mininglamp-oss/octo-runtime-protocol": "1.1.4"
12
+ "@mininglamp-oss/octo-runtime-acp-client": "1.1.5",
13
+ "@mininglamp-oss/octo-runtime-adapter-acp": "1.1.5",
14
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5",
15
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.5"
16
16
  }
17
17
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-hermes",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -9,6 +9,6 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@mininglamp-oss/octo-runtime-adapter-acp": "1.1.4"
12
+ "@mininglamp-oss/octo-runtime-adapter-acp": "1.1.5"
13
13
  }
14
14
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-kimi-code",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -9,6 +9,6 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@mininglamp-oss/octo-runtime-adapter-acp": "1.1.4"
12
+ "@mininglamp-oss/octo-runtime-adapter-acp": "1.1.5"
13
13
  }
14
14
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-mcode",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -9,6 +9,6 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@mininglamp-oss/octo-runtime-adapter-acp": "1.1.4"
12
+ "@mininglamp-oss/octo-runtime-adapter-acp": "1.1.5"
13
13
  }
14
14
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-openclaw",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
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.4",
9
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.4",
8
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.5",
9
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5",
10
10
  "ws": "8.22.0"
11
11
  },
12
12
  "types": "./dist/index.d.ts",