@mininglamp-oss/octo-runtime 1.1.3 → 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 (214) hide show
  1. package/README.md +62 -38
  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 -75
  17. package/apps/cli/dist/main.d.ts +2 -0
  18. package/apps/cli/dist/main.js +53 -63
  19. package/apps/cli/dist/manifest.json +53 -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/openclaw.js +32 -8
  23. package/apps/cli/dist/output.js +16 -2
  24. package/apps/cli/dist/playboard.d.ts +5 -0
  25. package/apps/cli/dist/playboard.js +41 -13
  26. package/apps/cli/dist/service-control.js +2 -2
  27. package/apps/cli/dist/state.js +48 -19
  28. package/dist/public/channel-gateway-commands.d.ts +1 -0
  29. package/dist/public/channel-gateway-commands.js +1 -0
  30. package/dist/public/channel-wecom-commands.d.ts +1 -0
  31. package/dist/public/channel-wecom-commands.js +1 -0
  32. package/dist/public/dsh.d.ts +2 -0
  33. package/dist/public/dsh.js +1 -0
  34. package/dist/public/executor-kernel.d.ts +1 -1
  35. package/dist/public/executor-kernel.js +1 -1
  36. package/dist/public/extra.d.ts +1 -0
  37. package/dist/public/extra.js +1 -0
  38. package/dist/public/host.d.ts +2 -4
  39. package/dist/public/host.js +1 -2
  40. package/dist/public/webui-commands.d.ts +1 -0
  41. package/dist/public/webui-commands.js +1 -0
  42. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/dist/index.js +2 -2
  43. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +4 -0
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +26 -2
  46. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  47. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  48. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  49. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  50. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +3 -3
  51. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  52. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/chunk-DYOJCNWF.js +854 -0
  53. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/chunk-G5PWGRL5.js +209 -0
  54. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/chunk-UOQRXV3Q.js +340 -0
  55. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/desktop-entry.d.ts +1 -0
  56. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/desktop-entry.js +16 -0
  57. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/dsh-sdk-NOTICE.txt +6 -0
  58. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/dsh-sdk-client-LICENSE.txt +21 -0
  59. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/dsh-sdk-protocol-LICENSE.txt +21 -0
  60. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.d.ts +35 -0
  61. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +14 -0
  62. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +52 -0
  63. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +306 -0
  64. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.d.ts +11 -0
  65. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +13 -0
  66. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.d.ts +12 -0
  67. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +7 -0
  68. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +15 -0
  69. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/client.js +2 -1
  70. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
  71. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  72. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  73. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  74. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  75. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +10 -5
  76. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +214 -55
  77. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  78. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
  79. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
  80. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/activity.d.ts +3 -0
  81. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/environment.d.ts +4 -0
  82. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/environment.js +24 -2
  83. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/hourly-log.js +11 -3
  84. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +12 -3
  85. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +30 -8
  86. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/mcp.js +4 -3
  87. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/module-manifest.d.ts +6 -0
  88. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/module-manifest.js +16 -4
  89. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.js +15 -2
  90. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log.js +29 -1
  91. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
  92. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.js +5 -5
  93. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
  94. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  95. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/cli-entrypoint.d.ts +2 -0
  96. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/cli-entrypoint.js +16 -0
  97. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.d.ts +20 -0
  98. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +402 -0
  99. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-command-config.d.ts +4 -0
  100. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-command-config.js +50 -0
  101. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-commands.d.ts +15 -0
  102. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-commands.js +275 -0
  103. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extras.js +14 -2
  104. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/global-extras.d.ts +16 -0
  105. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/global-extras.js +201 -0
  106. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/help.d.ts +4 -1
  107. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/help.js +31 -75
  108. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.d.ts +2 -0
  109. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +53 -63
  110. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +53 -3
  111. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.d.ts +1 -1
  112. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.js +3 -2
  113. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/openclaw.js +32 -8
  114. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +16 -2
  115. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.d.ts +5 -0
  116. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +41 -13
  117. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/service-control.js +2 -2
  118. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.js +48 -19
  119. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +25 -23
  120. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/common.d.ts +2 -2
  121. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/common.js +16 -6
  122. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/systemd.js +9 -7
  123. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/windows-task.d.ts +4 -1
  124. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/windows-task.js +36 -11
  125. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
  126. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +7 -2
  127. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  128. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +2 -1
  129. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +2 -1
  130. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.js +2 -1
  131. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.d.ts +16 -1
  132. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.js +152 -21
  133. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/serve.js +9 -2
  134. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.d.ts +8 -0
  135. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.js +17 -0
  136. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -4
  137. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/config-schema.json +56 -0
  138. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +170 -28
  139. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/session-store.d.ts +3 -1
  140. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/commands.d.ts +4 -0
  141. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/commands.js +124 -0
  142. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +19 -1
  143. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifact-policy.d.ts +23 -0
  144. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifact-policy.js +43 -0
  145. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifacts.d.ts +15 -0
  146. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifacts.js +283 -0
  147. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.d.ts +2 -0
  148. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.js +15 -1
  149. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.d.ts +5 -1
  150. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.js +48 -13
  151. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/tool-environment.d.ts +1 -1
  152. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/tool-environment.js +5 -3
  153. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/lifecycle/configuration.js +26 -1
  154. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/cards.js +2 -1
  155. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/client.d.ts +1 -0
  156. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/client.js +3 -2
  157. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/conversations.js +3 -2
  158. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.d.ts +4 -0
  159. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.js +104 -3
  160. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/rules.js +4 -3
  161. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/url.d.ts +2 -0
  162. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/url.js +7 -0
  163. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/auth.d.ts +1 -1
  164. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/auth.js +4 -3
  165. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.d.ts +9 -0
  166. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js +44 -13
  167. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connection-error.d.ts +7 -0
  168. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connection-error.js +44 -3
  169. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/image-input.js +2 -1
  170. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.d.ts +7 -0
  171. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js +18 -12
  172. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +10 -6
  173. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/im-channel.js +141 -16
  174. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/session-store.d.ts +3 -1
  175. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/commands.d.ts +4 -0
  176. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/commands.js +128 -0
  177. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +9 -5
  178. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/commands.d.ts +3 -0
  179. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/commands.js +51 -0
  180. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/assets/index-CXTvRGim.js +74 -0
  181. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/index.html +1 -1
  182. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +7 -3
  183. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-commands.d.ts +70 -0
  184. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-commands.js +16 -0
  185. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-config.js +33 -9
  186. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/home.js +9 -4
  187. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.d.ts +1 -3
  188. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.js +1 -2
  189. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +8 -4
  190. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +5 -0
  191. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +39 -1
  192. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +76 -7
  193. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  194. package/node_modules/commander/LICENSE +22 -0
  195. package/node_modules/commander/Readme.md +1172 -0
  196. package/node_modules/commander/index.js +21 -0
  197. package/node_modules/commander/lib/argument.js +147 -0
  198. package/node_modules/commander/lib/command.js +2790 -0
  199. package/node_modules/commander/lib/error.js +36 -0
  200. package/node_modules/commander/lib/help.js +731 -0
  201. package/node_modules/commander/lib/option.js +377 -0
  202. package/node_modules/commander/lib/suggestSimilar.js +99 -0
  203. package/node_modules/commander/package-support.json +19 -0
  204. package/node_modules/commander/package.json +64 -0
  205. package/node_modules/commander/typings/index.d.ts +1113 -0
  206. package/package.json +49 -29
  207. package/packages/octo-runtime-extra-channel-gateway/config-schema.json +56 -0
  208. package/packages/octo-runtime-protocol/schema/kernel-ipc.schema.json +443 -56
  209. package/packages/octo-runtime-protocol/schema/protocol.schema.json +357 -37
  210. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/assets/index-DiPc-ipL.js +0 -74
  211. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/launch.d.ts +0 -15
  212. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/launch.js +0 -22
  213. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/native.d.ts +0 -16
  214. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/native.js +0 -160
@@ -32,7 +32,18 @@ export function parseModuleManifest(value, source, { legacy = false } = {}) {
32
32
  const name = text(entry.name, "extra.name");
33
33
  if (!/^[a-z][a-z0-9-]{0,63}$/.test(name))
34
34
  throw new TypeError("extra.name is invalid");
35
- return { name, module: text(entry.module, "extra.module"), sourceManifest };
35
+ return {
36
+ name,
37
+ ...(entry.description === undefined
38
+ ? {}
39
+ : { description: text(entry.description, "extra.description") }),
40
+ ...(entry.configExample === undefined
41
+ ? {}
42
+ : { configExample: record(entry.configExample, "extra.configExample") }),
43
+ module: text(entry.module, "extra.module"),
44
+ sourceManifest,
45
+ ...(entry.commands === undefined ? {} : { commands: text(entry.commands, "extra.commands") })
46
+ };
36
47
  });
37
48
  unique(adapters, (entry) => entry.type, "adapter.type");
38
49
  unique(extraEntries, (entry) => entry.name, "extra.name");
@@ -59,17 +70,18 @@ export async function readModuleManifest(file, { optional = false, legacy = fals
59
70
  /** 内置优先、用户追加;冲突项在解析/import 前剔除,诊断不得包含 options 或业务配置。 */
60
71
  export function mergeModuleManifests(builtin, extension, report = () => { }) {
61
72
  function merge(first, second, key) {
62
- const seen = new Set(first.map(key).filter((value) => value !== undefined));
73
+ const seen = new Map(first.map((entry) => [key(entry), entry]));
63
74
  return [
64
75
  ...first,
65
76
  ...second.filter((entry) => {
66
77
  const name = key(entry);
67
78
  if (name !== undefined && seen.has(name)) {
68
- report(`Ignoring extension module "${name}": built-in declaration takes precedence`);
79
+ const selected = seen.get(name);
80
+ report(`Ignoring extension module "${name}": built-in declaration takes precedence; selected ${JSON.stringify({ module: selected.module, source: selected.sourceManifest })}; ignored ${JSON.stringify({ module: entry.module, source: entry.sourceManifest })}`);
69
81
  return false;
70
82
  }
71
83
  if (name !== undefined)
72
- seen.add(name);
84
+ seen.set(name, entry);
73
85
  return true;
74
86
  })
75
87
  ];
@@ -18,8 +18,21 @@ export function sanitizePublicValue(value, key = "", depth = 0) {
18
18
  ]));
19
19
  }
20
20
  function redactCredentialText(value) {
21
- return value
22
- .replace(/-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*?-----END [^-]*PRIVATE KEY-----/gi, "[REDACTED]")
21
+ // 单向扫描 PEM,避免多个未闭合 BEGIN 反复扫描后缀;截断的私钥同样不能公开。
22
+ const begin = /-----BEGIN [^-]*PRIVATE KEY-----/gi;
23
+ const end = /-----END [^-]*PRIVATE KEY-----/gi;
24
+ const parts = [];
25
+ let offset = 0;
26
+ for (let match = begin.exec(value); match; match = begin.exec(value)) {
27
+ parts.push(value.slice(offset, match.index), "[REDACTED]");
28
+ end.lastIndex = begin.lastIndex;
29
+ const closing = end.exec(value);
30
+ offset = closing ? end.lastIndex : value.length;
31
+ begin.lastIndex = offset;
32
+ }
33
+ parts.push(value.slice(offset));
34
+ return parts
35
+ .join("")
23
36
  .replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/gi, "$1 [REDACTED]")
24
37
  .replace(/\b(api[_-]?key|(?:access[_-]?|refresh[_-]?|bf[_-]?)?token|password|passwd|secret)\s*["']?\s*[:=]\s*["']?[^\s,;&"'}]+/gi, "$1=[REDACTED]")
25
38
  .replace(/([?&](?:api[_-]?key|access[_-]?token|refresh[_-]?token|password|secret)=)[^&#\s]*/gi, "$1[REDACTED]")
@@ -11,12 +11,21 @@ const strings = new Set([
11
11
  "model",
12
12
  "status",
13
13
  "code",
14
+ "reason_code",
15
+ "native_code",
16
+ "primary_code",
17
+ "cleanup_code",
18
+ "signal",
14
19
  "endpoint_id",
15
20
  "state",
16
21
  "protocol_mode"
17
22
  ]);
18
23
  const numbers = new Set([
19
24
  "duration_ms",
25
+ "request_id",
26
+ "pid",
27
+ "exit_code",
28
+ "native_code",
20
29
  "input_count",
21
30
  "text_input_count",
22
31
  "image_input_count",
@@ -125,9 +134,28 @@ export class RuntimeLogging {
125
134
  }
126
135
  for (const key of numbers) {
127
136
  const value = data?.[key];
128
- if (typeof value === "number" && Number.isFinite(value) && value >= 0)
137
+ if (typeof value === "number" &&
138
+ Number.isFinite(value) &&
139
+ (value >= 0 || (key === "native_code" && Number.isSafeInteger(value))))
129
140
  safe[key] = value;
130
141
  }
142
+ // 任务诊断只进入普通日志;逐字段校验,保持组件状态输出的独立隐私边界。
143
+ const diagnosticId = data?.diagnostic_id;
144
+ if (typeof diagnosticId === "string" && /^diag_[0-9a-f]{32}$/.test(diagnosticId))
145
+ safe.diagnostic_id = diagnosticId;
146
+ const stage = data?.stage;
147
+ if (typeof stage === "string" &&
148
+ ["channel_session_read", "channel_presentation_initialize", "channel_admission"].includes(stage))
149
+ safe.stage = stage;
150
+ const component = data?.failure_component;
151
+ if (component === "octo-runtime" || component === "octo-agent-worker")
152
+ safe.failure_component = component;
153
+ const occurredAt = data?.occurred_at;
154
+ if (typeof occurredAt === "string" &&
155
+ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(occurredAt) &&
156
+ Number.isFinite(Date.parse(occurredAt)) &&
157
+ new Date(occurredAt).toISOString() === occurredAt)
158
+ safe.occurred_at = occurredAt;
131
159
  const record = {
132
160
  time: new Date().toISOString(),
133
161
  level,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-sdk",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -9,7 +9,7 @@
9
9
  "./module-manifest": "./dist/module-manifest.js"
10
10
  },
11
11
  "dependencies": {
12
- "@mininglamp-oss/octo-runtime-protocol": "1.1.3",
12
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.5",
13
13
  "import-meta-resolve": "4.2.0"
14
14
  },
15
15
  "types": "./dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import { hasImageInput, invocationEnvironment } from "@mininglamp-oss/octo-runtime-adapter-sdk";
1
+ import { hasImageInput, invocationEnvironment, processEnvironmentValue } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
2
  import { execFile } from "node:child_process";
3
3
  import { existsSync } from "node:fs";
4
4
  import { homedir } from "node:os";
@@ -15,7 +15,7 @@ const DEFAULT_APP_SERVER_ARGS = [
15
15
  ];
16
16
  /** Resolve the CLI embedded in ZCode Desktop when no PATH command is installed. */
17
17
  export function discoverZcodeBin(env = process.env) {
18
- const configured = nonEmptyString(env.ZCODE_BIN);
18
+ const configured = nonEmptyString(processEnvironmentValue(env, "ZCODE_BIN"));
19
19
  if (configured)
20
20
  return resolve(configured);
21
21
  const pathCommand = findOnPath("zcode", env);
@@ -24,7 +24,7 @@ export function discoverZcodeBin(env = process.env) {
24
24
  const home = homedir();
25
25
  const candidates = process.platform === "win32"
26
26
  ? [
27
- join(env.LOCALAPPDATA ?? join(home, "AppData", "Local"), "Programs", "ZCode", "resources", "glm", "zcode.cjs")
27
+ join(processEnvironmentValue(env, "LOCALAPPDATA") ?? join(home, "AppData", "Local"), "Programs", "ZCode", "resources", "glm", "zcode.cjs")
28
28
  ]
29
29
  : process.platform === "darwin"
30
30
  ? [
@@ -131,9 +131,9 @@ export function createZcodeGuiAdapter({ command, appServerArgs, spawnFn } = {})
131
131
  }
132
132
  function findOnPath(command, env) {
133
133
  const extensions = process.platform === "win32"
134
- ? ["", ...(env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";")]
134
+ ? ["", ...(processEnvironmentValue(env, "PATHEXT") ?? ".EXE;.CMD;.BAT;.COM").split(";")]
135
135
  : [""];
136
- for (const directory of (env.PATH ?? "").split(delimiter)) {
136
+ for (const directory of (processEnvironmentValue(env, "PATH") ?? "").split(delimiter)) {
137
137
  if (!directory)
138
138
  continue;
139
139
  for (const extension of extensions) {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-adapter-zcode-gui",
3
- "version": "1.1.3",
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.3",
9
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.3"
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,5 +1,5 @@
1
1
  {
2
- "commit": "fe19d350431534da4ed3a76f3466add4ced86d81",
2
+ "commit": "ae7835c168e1e138287c012a6c87517dd2874a5d",
3
3
  "dirty": false,
4
- "buildTime": "2026-10-22T15:06:34.025Z"
4
+ "buildTime": "2026-10-27T08:38:03.037Z"
5
5
  }
@@ -0,0 +1,2 @@
1
+ /** 保留包管理器入口中的安装组路径;只有指向本 CLI 的 argv 才能影响服务部署与发现。 */
2
+ export declare function cliEntrypoint(invocation?: string, installed?: string): string;
@@ -0,0 +1,16 @@
1
+ import { realpathSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ /** 保留包管理器入口中的安装组路径;只有指向本 CLI 的 argv 才能影响服务部署与发现。 */
5
+ export function cliEntrypoint(invocation = process.argv[1], installed = fileURLToPath(new URL("./index.js", import.meta.url))) {
6
+ if (invocation) {
7
+ try {
8
+ if (realpathSync(invocation) === realpathSync(installed))
9
+ return resolve(invocation);
10
+ }
11
+ catch {
12
+ // 库内调用、测试 runner 或已移除的入口不拥有本 CLI 的安装来源。
13
+ }
14
+ }
15
+ return installed;
16
+ }
@@ -0,0 +1,20 @@
1
+ import type { ExtraModuleEntry } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
2
+ import type { ExtraCommand, ExtraCommandInput } from "@mininglamp-oss/octo-runtime-host-sdk";
3
+ import type { CliDependencies } from "./main.js";
4
+ export interface ParsedCliCommand {
5
+ flags: Record<string, string>;
6
+ positional: string[];
7
+ help?: string;
8
+ extra?: {
9
+ entry: ExtraModuleEntry;
10
+ command: ExtraCommand;
11
+ input: ExtraCommandInput;
12
+ home: string;
13
+ };
14
+ }
15
+ /**
16
+ * 两阶段装配:先只解析宿主选择参数,再为有效目录挂载命令。
17
+ * 根帮助不 import Extra;离线服务动作不加载 /commands;所选业务树才递归适配。
18
+ * 本函数只返回调用描述或帮助文本,不运行 handler、不访问服务管理器、不写 Home。
19
+ */
20
+ export declare function parseCliCommand(raw: string[], dependencies: CliDependencies): Promise<ParsedCliCommand>;
@@ -0,0 +1,402 @@
1
+ import { Command, CommanderError, Option } from "commander";
2
+ import { resolve } from "node:path";
3
+ import { cliHelpHeader, lifecycleCommands, preferredRootCommands, rootCommands } from "./help.js";
4
+ import { loadCliManifest } from "./module-manifest.js";
5
+ import { loadExtraCommands, validateCommands } from "./extra-commands.js";
6
+ import { defaultRuntimeHome } from "./state.js";
7
+ const hostStrings = new Set(["home", "manifest", "profile"]);
8
+ const hostBooleans = new Set(["help", "json", "version", "follow"]);
9
+ const commandExamples = new WeakMap();
10
+ const nativeOptions = [
11
+ ["--autostart <boolean>", "Enable automatic startup: true or false (install default: true)"],
12
+ ["--lines <count>", "Number of lines, 1..10000 (default: 200)"],
13
+ ["--follow", "Follow new log entries"],
14
+ [
15
+ "--acknowledge-orphan-cleanup",
16
+ "Confirm manual cleanup; preserve evidence and reject a live owner"
17
+ ]
18
+ ];
19
+ /** 仅统一布局;列宽、换行、命令/参数可见性都使用 Commander 的 Help 实现。 */
20
+ function formatHelp(command, helper) {
21
+ const width = helper.padWidth(command, helper);
22
+ const children = helper.visibleCommands(command);
23
+ if (!command.parent) {
24
+ const rank = (cmd) => {
25
+ const index = preferredRootCommands.indexOf(cmd.name());
26
+ return index < 0 ? preferredRootCommands.length : index;
27
+ };
28
+ children.sort((left, right) => rank(left) - rank(right) || left.name().localeCompare(right.name()));
29
+ }
30
+ const examples = commandExamples.get(command) ??
31
+ (command.parent
32
+ ? children.map((child) => `${commandPath(child).join(" ")} --help`)
33
+ : [
34
+ ...children
35
+ .filter((child) => child.commands.some((action) => action.name() === "start"))
36
+ .slice(0, 4)
37
+ .map((child) => `${commandPath(child).join(" ")} ${child.name() === "executor-kernel" ? "start" : "--help"}`),
38
+ "octo-runtime status"
39
+ ]);
40
+ const section = (title, rows) => rows.length
41
+ ? [
42
+ title,
43
+ ...rows.map(([term, description]) => helper.formatItem(term, width, description, helper)),
44
+ ""
45
+ ]
46
+ : [];
47
+ return [
48
+ ...(!command.parent ? [cliHelpHeader, ""] : []),
49
+ helper.commandDescription(command),
50
+ "",
51
+ "Usage:",
52
+ ` ${helper.commandUsage(command)}`,
53
+ "",
54
+ ...(examples.length
55
+ ? [
56
+ "Examples:",
57
+ ...examples.flatMap((example) => example.split("\n").map((line) => ` ${line}`)),
58
+ ""
59
+ ]
60
+ : []),
61
+ ...section("Available Commands:", children.map((child) => [child.name(), helper.subcommandDescription(child)])),
62
+ ...section("Arguments:", helper
63
+ .visibleArguments(command)
64
+ .map((arg) => [helper.argumentTerm(arg), helper.argumentDescription(arg)])),
65
+ ...section("Flags:", helper
66
+ .visibleOptions(command)
67
+ .map((option) => [helper.optionTerm(option), helper.optionDescription(option)])),
68
+ ...section("Global Flags:", helper
69
+ .visibleGlobalOptions(command)
70
+ .map((option) => [helper.optionTerm(option), helper.optionDescription(option)])),
71
+ ...(command.commands.length
72
+ ? [
73
+ `Use "${commandPath(command).join(" ")} [command] --help" for more information about a command.`,
74
+ ""
75
+ ]
76
+ : [])
77
+ ].join("\n");
78
+ }
79
+ function commandPath(command) {
80
+ return command.parent ? [...commandPath(command.parent), command.name()] : [command.name()];
81
+ }
82
+ /** 示例配置归目录声明;单引号按 shell 规则转义,展示不导入业务模块、不读取已存凭据。 */
83
+ function extrasetExample(name, config = {}, module) {
84
+ // 旧配置外壳不接受相对模块路径;这类目录仍省略兼容字段,避免示例无法保存。
85
+ const declaration = {
86
+ ...(module && !module.startsWith(".") ? { module } : {}),
87
+ enabled: true,
88
+ config
89
+ };
90
+ const json = JSON.stringify(declaration, null, 2).replaceAll("'", "'\\''");
91
+ return `octo-runtime ${name} extraset <<< '${json}'`;
92
+ }
93
+ function command(name, description) {
94
+ return new Command(name)
95
+ .description(description)
96
+ .helpOption("-h, --help", `help for ${name}`)
97
+ .addHelpCommand(false)
98
+ .configureHelp({
99
+ showGlobalOptions: true,
100
+ sortSubcommands: false,
101
+ sortOptions: true,
102
+ subcommandTerm: (cmd) => cmd.name(),
103
+ formatHelp
104
+ })
105
+ .exitOverride()
106
+ .configureOutput({ writeOut() { }, writeErr() { } });
107
+ }
108
+ /** 参数重复及缺值仍按现有 CLI 合同拒绝,避免 Commander 的后值覆盖掩盖输入错误。 */
109
+ function option(cmd, syntax, description, raw, business = false) {
110
+ const value = new Option(syntax, description);
111
+ // Extra 的布尔名称是原样的业务键,no- 前缀不代表 Commander 的反向默认值。
112
+ if (business) {
113
+ value.negate = false;
114
+ value.attributeName = () => value.name();
115
+ // constructor 也是合法业务键;显式空值避免继承原型属性并误通过必填检查。
116
+ cmd.setOptionValue(value.name(), undefined);
117
+ }
118
+ let seen = false;
119
+ value.argParser((input) => {
120
+ // 仅在 Commander 实际消费本命令的选项时检查,兄弟命令可声明同名但不同类型的选项。
121
+ // 仍按原始边界拒绝缺值,避免祖先先取走 --home X 后将 --port 123 拼成合法输入。
122
+ const literalIndex = raw.indexOf("--");
123
+ const tokens = literalIndex < 0 ? raw : raw.slice(0, literalIndex);
124
+ if (business &&
125
+ value.required &&
126
+ tokens.some((token, index) => token === value.long && (!tokens[index + 1] || tokens[index + 1].startsWith("-"))))
127
+ throw new Error("INVALID_ARGUMENTS");
128
+ if (seen)
129
+ throw new Error("INVALID_ARGUMENTS");
130
+ seen = true;
131
+ if (value.required &&
132
+ (!input ||
133
+ (input.startsWith(business ? "-" : "--") && !raw.includes(`${value.long}=${input}`))))
134
+ throw new Error("INVALID_ARGUMENTS");
135
+ if (value.long === "--autostart" && !["true", "false"].includes(input))
136
+ throw new Error("INVALID_ARGUMENTS");
137
+ return value.required ? input : true;
138
+ });
139
+ cmd.addOption(value);
140
+ return value;
141
+ }
142
+ function addHostOptions(root, raw, profile = true) {
143
+ option(root, "--home <path>", "Runtime Home directory", raw);
144
+ option(root, "--manifest <path>", "Use an explicit module manifest", raw).hideHelp();
145
+ option(root, "--json", "Print machine-readable JSON", raw);
146
+ option(root, "--profile <name>", "Select a runtime profile", raw).hideHelp(!profile);
147
+ }
148
+ /** 保留既有宿主布尔等号形式;-- 后的位置参数及业务选项原样交给 Commander。 */
149
+ function normalize(args) {
150
+ let literal = false;
151
+ return args.map((arg) => {
152
+ if (arg === "--")
153
+ literal = true;
154
+ const match = !literal && /^--([^=]+)=/.exec(arg);
155
+ return match && hostBooleans.has(match[1]) ? `--${match[1]}` : arg;
156
+ });
157
+ }
158
+ /** help 路径只改写命令位置,不把 --home help 等参数值误当成帮助命令。 */
159
+ function helpAlias(args) {
160
+ for (let i = 0; i < args.length; i++) {
161
+ const arg = args[i];
162
+ if (arg === "--")
163
+ return args;
164
+ if (arg.startsWith("-")) {
165
+ if (hostStrings.has(arg.slice(2)))
166
+ i++;
167
+ continue;
168
+ }
169
+ return arg === "help" ? [...args.slice(0, i), ...args.slice(i + 1), "--help"] : args;
170
+ }
171
+ return args;
172
+ }
173
+ /**
174
+ * 两阶段装配:先只解析宿主选择参数,再为有效目录挂载命令。
175
+ * 根帮助不 import Extra;离线服务动作不加载 /commands;所选业务树才递归适配。
176
+ * 本函数只返回调用描述或帮助文本,不运行 handler、不访问服务管理器、不写 Home。
177
+ */
178
+ export async function parseCliCommand(raw, dependencies) {
179
+ const args = normalize(helpAlias(raw));
180
+ const selector = command("octo-runtime", "").helpOption(false);
181
+ addHostOptions(selector, args);
182
+ option(selector, "-h, --help", "Help", args);
183
+ option(selector, "-v, --version", "Version", args);
184
+ for (const [syntax, description] of nativeOptions)
185
+ option(selector, syntax, description, args);
186
+ let operands;
187
+ try {
188
+ operands = selector.parseOptions(args).operands;
189
+ }
190
+ catch (error) {
191
+ if (error instanceof CommanderError)
192
+ throw new Error("INVALID_ARGUMENTS", { cause: error });
193
+ throw error;
194
+ }
195
+ const selected = selector.opts();
196
+ // 版本属于全局元数据查询;不依赖后续命令、业务必填项或可用的模块目录。
197
+ if (selected.version)
198
+ return { flags: { version: "true" }, positional: [] };
199
+ const name = operands[0];
200
+ // 旧顶层写法继续执行;显式查看旧入口帮助时指向同一组件下的规范路径。
201
+ if (selected.help && ["extraset", "extraget"].includes(name)) {
202
+ const target = operands[1];
203
+ const globalArgs = [...hostStrings].flatMap((key) => selected[key] ? [`--${key}=${selected[key]}`] : []);
204
+ return parseCliCommand([...globalArgs, ...(target ? [target, name] : []), "--help"], dependencies);
205
+ }
206
+ const home = resolve(selected.home ?? defaultRuntimeHome(dependencies.env, dependencies.platform));
207
+ const isExtra = Boolean(name && !rootCommands.has(name));
208
+ const offline = isExtra && lifecycleCommands.has(operands[1]);
209
+ const needsDirectory = !selected.version && (!name || (isExtra && !offline));
210
+ const entries = needsDirectory
211
+ ? (await loadCliManifest(home, selected.manifest, dependencies.errorOutput)).extras
212
+ : [];
213
+ if (entries.some((entry) => rootCommands.has(entry.name)))
214
+ throw new Error("EXTRA_COMMAND_NAMESPACE_CONFLICT");
215
+ const entry = entries.find((entry) => entry.name === name);
216
+ const extension = entry ? await loadExtraCommands(entry) : undefined;
217
+ if (extension)
218
+ validateCommands(extension);
219
+ // 已登记服务必须在模块丢失时仍能停止/卸载;真实存在性由原生命周期入口核验。
220
+ if (offline) {
221
+ let metadata;
222
+ // 离线帮助尽量读取公开示例;损坏的目录不能阻断停止、卸载或完整配置修复。
223
+ if (selected.help && operands[1] === "extraset") {
224
+ try {
225
+ metadata = (await loadCliManifest(home, selected.manifest, () => { })).extras.find((item) => item.name === name);
226
+ }
227
+ catch {
228
+ // 元数据不可用时仍展示通用 JSON 外壳,实际动作保持既有离线路径。
229
+ }
230
+ }
231
+ entries.push(metadata ?? { name, module: "", sourceManifest: "" });
232
+ }
233
+ const root = command("octo-runtime", "Manage the local Octo Agent runtime and independent services.");
234
+ addHostOptions(root, args, !isExtra || (offline && !["extraset", "extraget"].includes(operands[1])));
235
+ option(root, "-v, --version", "Print version and build information", args);
236
+ // 旧服务参数可位于组件之前;根仅隐藏解析,所属动作仍在本层帮助展示。
237
+ // 业务树不开放这些选项,继续由 Extra 自己定义和校验输入。
238
+ if (!isExtra || offline)
239
+ for (const [syntax, description] of nativeOptions)
240
+ option(root, syntax, description, args).hideHelp();
241
+ let result = { flags: {}, positional: [] };
242
+ let help;
243
+ const configure = (cmd) => {
244
+ cmd.configureOutput({
245
+ writeOut: (text) => {
246
+ help = (help ?? "") + text;
247
+ },
248
+ writeErr() { }
249
+ });
250
+ cmd.exitOverride();
251
+ };
252
+ const capture = (cmd, definition) => {
253
+ configure(cmd);
254
+ cmd.action(() => {
255
+ if (cmd !== root && Object.keys(cmd.opts()).some((key) => Object.hasOwn(root.opts(), key)))
256
+ throw new Error("INVALID_ARGUMENTS");
257
+ const all = cmd.optsWithGlobals();
258
+ const flags = Object.fromEntries(Object.entries(root.opts()).map(([key, value]) => [key, String(value)]));
259
+ for (const key of ["autostart", "lines", "follow", "acknowledgeOrphanCleanup"])
260
+ if (all[key] !== undefined)
261
+ flags[key === "acknowledgeOrphanCleanup" ? "acknowledge-orphan-cleanup" : key] = String(all[key]);
262
+ const path = commandPath(cmd).slice(1);
263
+ // 新入口和隐藏旧入口共用完整声明的原子读写,保持完整声明语义,不生成额外的业务配置命令。
264
+ if (path.length === 2 && ["extraset", "extraget"].includes(path[1]))
265
+ path.reverse();
266
+ result = { flags, positional: [...path, ...cmd.args] };
267
+ if (definition && entry) {
268
+ if (all.profile !== undefined)
269
+ throw new Error("INVALID_ARGUMENTS");
270
+ const values = cmd.opts();
271
+ const options = Object.fromEntries((definition.options ?? [])
272
+ .filter((opt) => values[opt.name] !== undefined)
273
+ .map((opt) => [opt.name, values[opt.name]]));
274
+ result.extra = {
275
+ entry,
276
+ command: definition,
277
+ input: { options, arguments: cmd.args },
278
+ home
279
+ };
280
+ }
281
+ if (cmd.commands.length || cmd === root)
282
+ help = cmd.helpInformation().trimEnd();
283
+ });
284
+ };
285
+ const leaf = (parent, name, description, hidden = false) => {
286
+ const child = command(name, description);
287
+ parent.addCommand(child, { hidden });
288
+ capture(child);
289
+ return child;
290
+ };
291
+ const service = (name, description, configExample, module) => {
292
+ const parent = leaf(root, name, description);
293
+ const prefix = `octo-runtime ${name}`;
294
+ commandExamples.set(parent, [
295
+ `${prefix} start`,
296
+ `${prefix} status`,
297
+ ...(name === "executor-kernel" ? [] : [extrasetExample(name, configExample, module)])
298
+ ]);
299
+ for (const [action, summary] of lifecycleCommands) {
300
+ if (name === "executor-kernel" && ["logs", "extraset", "extraget"].includes(action))
301
+ continue;
302
+ const child = leaf(parent, action, summary);
303
+ const invocation = `${prefix} ${action}`;
304
+ commandExamples.set(child, [
305
+ action === "extraset" ? extrasetExample(name, configExample, module) : invocation,
306
+ ...(action === "install" ? [`${invocation} --autostart=false`] : []),
307
+ ...(action === "logs" ? [`${invocation} --lines 200 --follow`] : [])
308
+ ]);
309
+ if (action === "install")
310
+ option(child, "--autostart <boolean>", "Enable automatic startup: true or false (install default: true)", args);
311
+ if (action === "extraset")
312
+ child.addHelpText("after", "\nReads {config, enabled?, module?} from stdin. Replaces the whole declaration; restart to apply.");
313
+ if (action === "extraget")
314
+ child.addHelpText("after", "\nReturns the complete declaration, INCLUDING CREDENTIALS.");
315
+ if (action === "logs") {
316
+ option(child, "--lines <count>", "Number of lines, 1..10000 (default: 200)", args);
317
+ option(child, "--follow", "Follow new log entries", args);
318
+ }
319
+ }
320
+ return parent;
321
+ };
322
+ for (const [name, description] of rootCommands) {
323
+ if (name === "help")
324
+ continue;
325
+ const cmd = name === "executor-kernel"
326
+ ? service(name, description)
327
+ : leaf(root, name, description, ["extraset", "extraget"].includes(name));
328
+ if (name === "executor-kernel") {
329
+ const recover = leaf(cmd, "recover", "Acknowledge orphan cleanup after stopping all orphan tools");
330
+ commandExamples.set(recover, [
331
+ "octo-runtime executor-kernel recover --acknowledge-orphan-cleanup"
332
+ ]);
333
+ option(recover, "--acknowledge-orphan-cleanup", "Confirm manual cleanup; preserve evidence and reject a live owner", args);
334
+ }
335
+ if (name === "adapter") {
336
+ const list = leaf(cmd, "list", "List execution adapters");
337
+ commandExamples.set(list, ["octo-runtime adapter list"]);
338
+ const probe = leaf(cmd, "probe", "Probe one execution adapter").argument("<type>");
339
+ commandExamples.set(probe, ["octo-runtime adapter probe <type>"]);
340
+ }
341
+ if (["status", "doctor", "version"].includes(name))
342
+ commandExamples.set(cmd, [`octo-runtime ${name}`]);
343
+ if (name === "playboard")
344
+ commandExamples.set(cmd, ["octo-runtime playboard < request.json"]);
345
+ if (name === "extraset" || name === "extraget") {
346
+ cmd.argument("<name>");
347
+ cmd.addHelpText("after", name === "extraget"
348
+ ? "\nReturns the complete configuration, INCLUDING CREDENTIALS."
349
+ : "\nReads a complete configuration envelope from stdin JSON. Restart the service to apply.");
350
+ }
351
+ }
352
+ const addBusiness = (parent, definitions) => {
353
+ for (const definition of definitions) {
354
+ const child = command(definition.name, definition.description);
355
+ parent.addCommand(child);
356
+ for (const item of definition.options ?? []) {
357
+ const flag = option(child, `--${item.name}${item.type === "string" ? " <value>" : ""}`, `${item.description}${item.required ? " (required)" : ""}`, args, true);
358
+ flag.makeOptionMandatory(Boolean(item.required));
359
+ }
360
+ for (const item of definition.arguments ?? [])
361
+ child.argument(item.required ? `<${item.name}>` : `[${item.name}]`);
362
+ if (definition.examples?.length)
363
+ commandExamples.set(child, definition.examples);
364
+ capture(child, definition);
365
+ if (definition.commands)
366
+ addBusiness(child, definition.commands);
367
+ }
368
+ };
369
+ for (const extra of entries) {
370
+ const parent = service(extra.name, extra.description ?? `Manage the ${extra.name} service`, extra.configExample, extra.module);
371
+ if (extra === entry && extension) {
372
+ addBusiness(parent, extension.commands);
373
+ commandExamples.set(parent, [
374
+ ...commandExamples.get(parent),
375
+ `octo-runtime ${extra.name} ${extension.commands[0].name} --help`
376
+ ]);
377
+ }
378
+ }
379
+ // help 路径在装配前转换,目录中仍提供真实可用的帮助入口。
380
+ leaf(root, "help", "Help about any command").argument("[command...]");
381
+ capture(root);
382
+ try {
383
+ root.parse(args, { from: "user" });
384
+ }
385
+ catch (error) {
386
+ if (!(error instanceof CommanderError))
387
+ throw error;
388
+ if (error.code !== "commander.helpDisplayed")
389
+ throw new Error(isExtra && error.code === "commander.unknownCommand"
390
+ ? "EXTRA_COMMAND_NOT_FOUND"
391
+ : "INVALID_ARGUMENTS", { cause: error });
392
+ }
393
+ if (root.opts().version)
394
+ return { flags: { version: "true" }, positional: [] };
395
+ if (help !== undefined) {
396
+ // Extra 自有配置的 profile 禁令在帮助入口同样生效,服务动作保留原合同。
397
+ if (isExtra && !offline && selected.profile !== undefined)
398
+ throw new Error("INVALID_ARGUMENTS");
399
+ return { ...result, help: help.trimEnd() };
400
+ }
401
+ return result;
402
+ }
@@ -0,0 +1,4 @@
1
+ import { type ExtraCommandContext } from "@mininglamp-oss/octo-runtime-host-sdk";
2
+ import { type RuntimePaths } from "./state.js";
3
+ /** 与 extraset 共用 Home 锁和原子写入;网络/交互发生在调用方,不能占用写锁。 */
4
+ export declare function commandConfig(paths: RuntimePaths, name: string, module: string, signal: AbortSignal): Pick<ExtraCommandContext, "readConfig" | "saveConfig">;