@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
@@ -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 {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-cli",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,28 +8,30 @@
8
8
  },
9
9
  "types": "./dist/index.d.ts",
10
10
  "dependencies": {
11
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.3",
11
+ "commander": "15.0.0",
12
+ "@mininglamp-oss/octo-runtime-adapter-dsh": "1.1.5",
13
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5",
12
14
  "json5": "2.2.3",
13
- "@mininglamp-oss/octo-runtime-extra-channel-gateway": "1.1.3",
14
- "@mininglamp-oss/octo-runtime-host-sdk": "1.1.3",
15
- "@mininglamp-oss/octo-runtime-adapter-openclaw": "1.1.3",
16
- "@mininglamp-oss/octo-runtime-cross-service": "1.1.3",
17
- "@mininglamp-oss/octo-runtime-protocol": "1.1.3",
18
- "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.3",
19
- "@mininglamp-oss/octo-runtime-executor-core": "1.1.3",
20
- "@mininglamp-oss/octo-runtime-adapter-antigravity": "1.1.3",
21
- "@mininglamp-oss/octo-runtime-adapter-claude-code": "1.1.3",
22
- "@mininglamp-oss/octo-runtime-adapter-codebuddy": "1.1.3",
23
- "@mininglamp-oss/octo-runtime-adapter-codex": "1.1.3",
24
- "@mininglamp-oss/octo-runtime-adapter-hermes": "1.1.3",
25
- "@mininglamp-oss/octo-runtime-adapter-grok-build": "1.1.3",
26
- "@mininglamp-oss/octo-runtime-adapter-kimi-code": "1.1.3",
27
- "@mininglamp-oss/octo-runtime-adapter-mcode": "1.1.3",
28
- "@mininglamp-oss/octo-runtime-adapter-opencode": "1.1.3",
29
- "@mininglamp-oss/octo-runtime-adapter-qodercli": "1.1.3",
30
- "@mininglamp-oss/octo-runtime-adapter-qoderclicn": "1.1.3",
31
- "@mininglamp-oss/octo-runtime-adapter-zcode-gui": "1.1.3",
32
- "@mininglamp-oss/octo-runtime-extra-channel-wecom": "1.1.3",
33
- "@mininglamp-oss/octo-runtime-extra-webui": "1.1.3"
15
+ "@mininglamp-oss/octo-runtime-extra-channel-gateway": "1.1.5",
16
+ "@mininglamp-oss/octo-runtime-host-sdk": "1.1.5",
17
+ "@mininglamp-oss/octo-runtime-adapter-openclaw": "1.1.5",
18
+ "@mininglamp-oss/octo-runtime-cross-service": "1.1.5",
19
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.5",
20
+ "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.5",
21
+ "@mininglamp-oss/octo-runtime-executor-core": "1.1.5",
22
+ "@mininglamp-oss/octo-runtime-adapter-antigravity": "1.1.5",
23
+ "@mininglamp-oss/octo-runtime-adapter-claude-code": "1.1.5",
24
+ "@mininglamp-oss/octo-runtime-adapter-codebuddy": "1.1.5",
25
+ "@mininglamp-oss/octo-runtime-adapter-codex": "1.1.5",
26
+ "@mininglamp-oss/octo-runtime-adapter-hermes": "1.1.5",
27
+ "@mininglamp-oss/octo-runtime-adapter-grok-build": "1.1.5",
28
+ "@mininglamp-oss/octo-runtime-adapter-kimi-code": "1.1.5",
29
+ "@mininglamp-oss/octo-runtime-adapter-mcode": "1.1.5",
30
+ "@mininglamp-oss/octo-runtime-adapter-opencode": "1.1.5",
31
+ "@mininglamp-oss/octo-runtime-adapter-qodercli": "1.1.5",
32
+ "@mininglamp-oss/octo-runtime-adapter-qoderclicn": "1.1.5",
33
+ "@mininglamp-oss/octo-runtime-adapter-zcode-gui": "1.1.5",
34
+ "@mininglamp-oss/octo-runtime-extra-channel-wecom": "1.1.5",
35
+ "@mininglamp-oss/octo-runtime-extra-webui": "1.1.5"
34
36
  }
35
37
  }
@@ -14,13 +14,13 @@ export declare function runCommand(runner: CommandRunner, backend: ServiceBacken
14
14
  }): Promise<CommandResult>;
15
15
  /** 平台仅在确认原生 not-found 后忽略失败,其他结果沿同一受控错误合同传播。 */
16
16
  export declare function assertCommandSucceeded(result: CommandResult, backend: ServiceBackendKind): void;
17
- /** Read a UTF-8 service definition; absence is represented as `undefined`. */
17
+ /** 读取服务定义;兼容 Windows UTF-16LE BOM 与既有 UTF-8,缺失返回 undefined。 */
18
18
  export declare function readDefinition(path: string): Promise<string | undefined>;
19
19
  /**
20
20
  * Atomically replace a service definition with mode 0600.
21
21
  * Returns `false` when the installed bytes already match the desired content.
22
22
  */
23
- export declare function writeDefinition(path: string, content: string): Promise<boolean>;
23
+ export declare function writeDefinition(path: string, content: string, encoding?: "utf8" | "utf16le"): Promise<boolean>;
24
24
  /** Remove a service definition if present. */
25
25
  export declare function removeDefinition(path: string): Promise<void>;
26
26
  /** Return stable drift identifiers for desired-versus-installed file content. */
@@ -107,10 +107,13 @@ export function assertCommandSucceeded(result, backend) {
107
107
  });
108
108
  }
109
109
  }
110
- /** Read a UTF-8 service definition; absence is represented as `undefined`. */
110
+ /** 读取服务定义;兼容 Windows UTF-16LE BOM 与既有 UTF-8,缺失返回 undefined。 */
111
111
  export async function readDefinition(path) {
112
112
  try {
113
- return await readFile(path, "utf8");
113
+ const bytes = await readFile(path);
114
+ return bytes[0] === 0xff && bytes[1] === 0xfe
115
+ ? bytes.subarray(2).toString("utf16le")
116
+ : bytes.toString("utf8");
114
117
  }
115
118
  catch (error) {
116
119
  if (isNodeError(error, "ENOENT"))
@@ -122,15 +125,22 @@ export async function readDefinition(path) {
122
125
  * Atomically replace a service definition with mode 0600.
123
126
  * Returns `false` when the installed bytes already match the desired content.
124
127
  */
125
- export async function writeDefinition(path, content) {
126
- if ((await readDefinition(path)) === content)
127
- return false;
128
+ export async function writeDefinition(path, content, encoding = "utf8") {
129
+ const bytes = Buffer.from(encoding === "utf16le" ? `\uFEFF${content}` : content, encoding);
130
+ try {
131
+ if ((await readFile(path)).equals(bytes))
132
+ return false;
133
+ }
134
+ catch (error) {
135
+ if (!isNodeError(error, "ENOENT"))
136
+ throw error;
137
+ }
128
138
  await mkdir(dirname(path), { recursive: true, mode: 0o700 });
129
139
  const temporary = `${path}.${process.pid}.${randomUUID()}.tmp`;
130
140
  try {
131
141
  const file = await open(temporary, "wx", 0o600);
132
142
  try {
133
- await file.writeFile(content, "utf8");
143
+ await file.writeFile(bytes);
134
144
  await file.sync();
135
145
  }
136
146
  finally {
@@ -248,12 +248,8 @@ function renderSystemdUnitNormalized(spec) {
248
248
  .sort(([left], [right]) => left.localeCompare(right))
249
249
  .map(([key, value]) => `Environment=${systemdQuote(`${key}=${value}`)}`)
250
250
  .join("\n");
251
- const output = spec.stdoutPath
252
- ? `StandardOutput=${systemdQuote(`append:${spec.stdoutPath}`)}\n`
253
- : "";
254
- const error = spec.stderrPath
255
- ? `StandardError=${systemdQuote(`append:${spec.stderrPath}`)}\n`
256
- : "";
251
+ const output = spec.stdoutPath ? `StandardOutput=append:${systemdPath(spec.stdoutPath)}\n` : "";
252
+ const error = spec.stderrPath ? `StandardError=append:${systemdPath(spec.stderrPath)}\n` : "";
257
253
  return `[Unit]
258
254
  Description=${escapeSystemdText(spec.description)}
259
255
  After=network-online.target
@@ -264,7 +260,7 @@ StartLimitBurst=${spec.restart.maxBurst}
264
260
  [Service]
265
261
  Type=simple
266
262
  ExecStart=:${[spec.command, ...spec.args].map(systemdQuote).join(" ")}
267
- WorkingDirectory=${systemdQuote(spec.workingDirectory)}
263
+ WorkingDirectory=${systemdPath(spec.workingDirectory)}
268
264
  ${environment ? `${environment}\n` : ""}Restart=${restart}
269
265
  RestartSec=${spec.restart.delaySeconds}s
270
266
  TimeoutStopSec=${spec.timeoutStopSeconds}s
@@ -283,6 +279,12 @@ function systemdUnit(spec) {
283
279
  function systemdQuote(value) {
284
280
  return `"${value.replaceAll("\\", "\\\\").replaceAll('"', '\\"').replaceAll("%", "%%")}"`;
285
281
  }
282
+ function systemdPath(value) {
283
+ const trailingBackslashes = value.match(/\\+$/)?.[0].length ?? 0;
284
+ if (/[ \t]$/.test(value))
285
+ throw new ServiceError("UNSUPPORTED_SPEC", "systemd path directives cannot preserve trailing spaces or tabs");
286
+ return `${value.replaceAll("%", "%%")}${trailingBackslashes % 2 === 0 ? "" : " "}`;
287
+ }
286
288
  function escapeSystemdText(value) {
287
289
  return value.replaceAll("%", "%%");
288
290
  }
@@ -35,7 +35,10 @@ export declare class WindowsUserTaskBackend implements ServiceBackend {
35
35
  /** 确认旧实例停止后再启动替换实例;IPC 就绪仍由宿主查询,注销后不承诺继续运行。 */
36
36
  restart(spec: ServiceSpec): Promise<void>;
37
37
  }
38
- /** Validate and render deterministic Task Scheduler XML for one Windows user. */
38
+ /**
39
+ * 为一个 Windows 用户校验并返回确定的 XML 文本;声明为 UTF-16。
40
+ * 调用者写文件时必须使用带 BOM 的 UTF-16LE,不能按默认 UTF-8 序列化。
41
+ */
39
42
  export declare function renderWindowsTaskXml(spec: ServiceSpec, userId: string): string;
40
43
  /**
41
44
  * Quote one argv element with the Windows `CommandLineToArgvW` escaping rules.
@@ -119,9 +119,11 @@ export class WindowsUserTaskBackend {
119
119
  detail: "PowerShell returned an invalid task status payload"
120
120
  };
121
121
  }
122
+ const identityUnknown = windowsAccountIdentity(task.principal_user_id, task.principal_user_matches, this.#windowsUserId) === undefined ||
123
+ windowsAccountIdentity(task.trigger_user_id, task.trigger_user_matches, this.#windowsUserId) === undefined;
122
124
  return {
123
125
  manager: this.kind,
124
- state: windowsTaskState(task.state),
126
+ state: identityUnknown ? "unknown" : windowsTaskState(task.state),
125
127
  enabled: task.enabled === true,
126
128
  lastExitCode: task.last_exit_code,
127
129
  definitionPath,
@@ -129,7 +131,11 @@ export class WindowsUserTaskBackend {
129
131
  ...definitionDrift(actual, desired),
130
132
  ...windowsManagerDrift(task, normalized, this.#windowsUserId)
131
133
  ],
132
- detail: task.state ? undefined : "Task Scheduler did not report a state"
134
+ detail: identityUnknown
135
+ ? "Task Scheduler account identity could not be resolved"
136
+ : task.state
137
+ ? undefined
138
+ : "Task Scheduler did not report a state"
133
139
  };
134
140
  }
135
141
  /**
@@ -146,7 +152,9 @@ export class WindowsUserTaskBackend {
146
152
  const previous = await this.inspect(spec);
147
153
  if (previous.state === "running" || previous.state === "starting")
148
154
  await this.stop(spec);
149
- await writeDefinition(definitionPath, renderWindowsTaskXmlNormalized(normalized, taskName, this.#windowsUserId));
155
+ await writeDefinition(definitionPath, renderWindowsTaskXmlNormalized(normalized, taskName, this.#windowsUserId),
156
+ // schtasks 的 XML 导入使用带 BOM 的 UTF-16LE,声明与字节编码必须一致。
157
+ "utf16le");
150
158
  await this.#schtasksCommand(["/Create", "/TN", taskName, "/XML", definitionPath, "/F"]);
151
159
  // Restore only a previously running enabled task. A stopped task remains
152
160
  // stopped, so setup controls the explicit first start and readiness wait.
@@ -265,7 +273,7 @@ export class WindowsUserTaskBackend {
265
273
  : join(this.#definitionDirectory, fileName);
266
274
  }
267
275
  #query(taskName) {
268
- const script = windowsTaskQueryScript(taskName);
276
+ const script = windowsTaskQueryScript(taskName, this.#windowsUserId);
269
277
  return runCommand(this.#runner, this.kind, this.#powershell, powershellArguments(script), {
270
278
  checked: false,
271
279
  env: this.#environment
@@ -299,7 +307,10 @@ export class WindowsUserTaskBackend {
299
307
  });
300
308
  }
301
309
  }
302
- /** Validate and render deterministic Task Scheduler XML for one Windows user. */
310
+ /**
311
+ * 为一个 Windows 用户校验并返回确定的 XML 文本;声明为 UTF-16。
312
+ * 调用者写文件时必须使用带 BOM 的 UTF-16LE,不能按默认 UTF-8 序列化。
313
+ */
303
314
  export function renderWindowsTaskXml(spec, userId) {
304
315
  assertSingleLine(userId, "Windows user id");
305
316
  const normalized = normalizeServiceSpec(spec, "win32");
@@ -335,7 +346,7 @@ function renderWindowsTaskXmlNormalized(spec, taskName, userId) {
335
346
  const restart = spec.restart.policy === "on-failure"
336
347
  ? ` <RestartOnFailure>\n <Interval>PT${Math.max(TASK_RESTART_MINIMUM_SECONDS, spec.restart.delaySeconds)}S</Interval>\n <Count>${spec.restart.maxBurst}</Count>\n </RestartOnFailure>\n`
337
348
  : "";
338
- return `<?xml version="1.0" encoding="UTF-8"?>
349
+ return `<?xml version="1.0" encoding="UTF-16"?>
339
350
  <Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
340
351
  <RegistrationInfo>
341
352
  <Description>${escapeXml(spec.description)}</Description>
@@ -403,13 +414,21 @@ function assertWindowsSupported(spec) {
403
414
  });
404
415
  }
405
416
  }
406
- function windowsTaskQueryScript(taskName) {
417
+ function windowsTaskQueryScript(taskName, userId) {
407
418
  const task = taskName.slice(1);
408
419
  const quotedTask = powershellSingleQuote(task);
409
- return `$ErrorActionPreference='Stop';$task=Get-ScheduledTask -TaskPath '\\' -TaskName '${quotedTask}';$info=Get-ScheduledTaskInfo -InputObject $task;$action=@($task.Actions)[0];$trigger=@($task.Triggers)[0];[ordered]@{state=[string]$task.State;enabled=([string]$task.State -ne 'Disabled');last_exit_code=[long]$info.LastTaskResult;execute=[string]$action.Execute;arguments=[string]$action.Arguments;working_directory=[string]$action.WorkingDirectory;principal_user_id=[string]$task.Principal.UserId;principal_logon_type=[string]$task.Principal.LogonType;trigger_user_id=[string]$trigger.UserId}|ConvertTo-Json -Compress`;
420
+ // Scheduler 可把 DOMAIN\\user 规范化为短账号或 SID;比较系统身份,不能把同一账号报成 drift。
421
+ const identity = `function Get-AccountSid([string]$value){if($value -match '^S-1-'){return $value};return ([System.Security.Principal.NTAccount]$value).Translate([System.Security.Principal.SecurityIdentifier]).Value};function Test-AccountIdentity([string]$value){try{return (Get-AccountSid $value) -eq (Get-AccountSid '${powershellSingleQuote(userId)}')}catch{return $null}};`;
422
+ return `$ErrorActionPreference='Stop';${identity}$task=Get-ScheduledTask -TaskPath '\\' -TaskName '${quotedTask}';$info=Get-ScheduledTaskInfo -InputObject $task;$action=@($task.Actions)[0];$trigger=@($task.Triggers)[0];[ordered]@{state=[string]$task.State;enabled=([string]$task.State -ne 'Disabled');last_exit_code=[long]$info.LastTaskResult;execute=[string]$action.Execute;arguments=[string]$action.Arguments;working_directory=[string]$action.WorkingDirectory;principal_user_id=[string]$task.Principal.UserId;principal_user_matches=(Test-AccountIdentity ([string]$task.Principal.UserId));principal_logon_type=[string]$task.Principal.LogonType;trigger_user_id=[string]$trigger.UserId;trigger_user_matches=(Test-AccountIdentity ([string]$trigger.UserId))}|ConvertTo-Json -Compress`;
410
423
  }
411
424
  function powershellArguments(script) {
412
- return ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", script];
425
+ return [
426
+ "-NoLogo",
427
+ "-NoProfile",
428
+ "-NonInteractive",
429
+ "-Command",
430
+ `[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new($false);${script}`
431
+ ];
413
432
  }
414
433
  function powershellSingleQuote(value) {
415
434
  return value.replaceAll("'", "''");
@@ -423,12 +442,12 @@ function windowsManagerDrift(task, spec, userId) {
423
442
  drift.push("manager.arguments");
424
443
  if (!equalWindowsPath(task.working_directory, spec.workingDirectory))
425
444
  drift.push("manager.working_directory");
426
- if (!equalWindowsIdentity(task.principal_user_id, userId))
445
+ if (windowsAccountIdentity(task.principal_user_id, task.principal_user_matches, userId) === false)
427
446
  drift.push("manager.principal_user");
428
447
  if (!["interactivetoken", "interactive", "3"].includes(task.principal_logon_type?.toLowerCase() ?? "")) {
429
448
  drift.push("manager.logon_type");
430
449
  }
431
- if (!equalWindowsIdentity(task.trigger_user_id, userId))
450
+ if (windowsAccountIdentity(task.trigger_user_id, task.trigger_user_matches, userId) === false)
432
451
  drift.push("manager.trigger_user");
433
452
  if (task.enabled !== spec.enabled)
434
453
  drift.push("manager.enabled");
@@ -440,6 +459,12 @@ function equalWindowsPath(actual, expected) {
440
459
  function equalWindowsIdentity(actual, expected) {
441
460
  return actual?.toLowerCase() === expected.toLowerCase();
442
461
  }
462
+ /** null 表示系统身份查询失败;相同原文可确认,否则保留未知,不能伪造匹配或漂移。 */
463
+ function windowsAccountIdentity(actual, matches, expected) {
464
+ if (matches === null)
465
+ return equalWindowsIdentity(actual, expected) ? true : undefined;
466
+ return matches ?? equalWindowsIdentity(actual, expected);
467
+ }
443
468
  function windowsTaskState(value) {
444
469
  switch (value?.toLowerCase()) {
445
470
  case "running":
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-cross-service",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "private": true,
5
5
  "description": "Native user-service lifecycle backends for Octo Runtime",
6
6
  "type": "module",
@@ -290,6 +290,7 @@ export class AgentExecutor {
290
290
  };
291
291
  let state;
292
292
  let failureCode;
293
+ let failureReasonCode;
293
294
  const pendingInteractions = new Set();
294
295
  const source = receipt.protocol_mode === "canonical"
295
296
  ? this.#invokeCanonical(adapterType, request, streamLimits, owner)
@@ -303,8 +304,10 @@ export class AgentExecutor {
303
304
  if (next.done)
304
305
  break;
305
306
  const output = next.value;
306
- if (!("kind" in output) && output.type === "run.failed")
307
+ if (!("kind" in output) && output.type === "run.failed") {
307
308
  failureCode = output.payload.failure?.code;
309
+ failureReasonCode = output.payload.failure?.reasonCode;
310
+ }
308
311
  if ("kind" in output && output.kind === "control" && output.control.type === "error")
309
312
  failureCode = output.control.code;
310
313
  if ("kind" in output &&
@@ -422,7 +425,8 @@ export class AgentExecutor {
422
425
  if (state?.state === "failed")
423
426
  this.#log("error", "invoke.failed", {
424
427
  ...identity,
425
- code: failureCode ?? "EXECUTION_FAILED"
428
+ code: failureCode ?? "EXECUTION_FAILED",
429
+ reason_code: failureReasonCode
426
430
  });
427
431
  this.#log(state?.state === "failed" ? "error" : "info", "invoke.finished", {
428
432
  ...identity,
@@ -556,6 +560,7 @@ export class AgentExecutor {
556
560
  const context = {
557
561
  protocolMode,
558
562
  streamLimits,
563
+ log: this.#log,
559
564
  reportConversion: () => {
560
565
  if (protocolMode === "native")
561
566
  throw protocolError("EXECUTION_PROTOCOL_MISMATCH", "Native execution invoked a canonical converter");
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-executor-core",
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-adapter-sdk": "1.1.3",
9
- "@mininglamp-oss/octo-runtime-protocol": "1.1.3"
8
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5",
9
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.5"
10
10
  },
11
11
  "types": "./dist/index.d.ts",
12
12
  "files": [
@@ -3,8 +3,9 @@ export { HostRunService } from "./host-run-service.js";
3
3
  export { createKernelService, type KernelService, type KernelServiceOptions, type KernelServiceStatus } from "./service.js";
4
4
  export * from "./lifecycle.js";
5
5
  export { attachKernel } from "./client.js";
6
+ export { isInvocationNotSubmitted } from "./submission-error.js";
6
7
  export * from "./types.js";
7
- export { InvocationManifest, processStartIdentity, reapOrphanedInvocationManifest } from "./invocation-manifest.js";
8
+ export { InvocationManifest, acknowledgeOrphanCleanup, inspectOrphanCleanup, processStartIdentity, reapOrphanedInvocationManifest } from "./invocation-manifest.js";
8
9
  export { readAdapterConfigurations } from "./runtime-configuration.js";
9
10
  export { spawnWorker } from "./process.js";
10
11
  export { serveWorker } from "./serve.js";
@@ -4,8 +4,9 @@ export { HostRunService } from "./host-run-service.js";
4
4
  export { createKernelService } from "./service.js";
5
5
  export * from "./lifecycle.js";
6
6
  export { attachKernel } from "./client.js";
7
+ export { isInvocationNotSubmitted } from "./submission-error.js";
7
8
  export * from "./types.js";
8
- export { InvocationManifest, processStartIdentity, reapOrphanedInvocationManifest } from "./invocation-manifest.js";
9
+ export { InvocationManifest, acknowledgeOrphanCleanup, inspectOrphanCleanup, processStartIdentity, reapOrphanedInvocationManifest } from "./invocation-manifest.js";
9
10
  export { readAdapterConfigurations } from "./runtime-configuration.js";
10
11
  export { spawnWorker } from "./process.js";
11
12
  export { serveWorker } from "./serve.js";
@@ -1,4 +1,5 @@
1
1
  import { setTimeout as delay } from "node:timers/promises";
2
+ import { admissionClosedError } from "./submission-error.js";
2
3
  import { isHostTerminal } from "@mininglamp-oss/octo-runtime-protocol";
3
4
  import { KernelError } from "./types.js";
4
5
  /**
@@ -42,7 +43,7 @@ export class InvocationRegistry {
42
43
  }
43
44
  assertSubmission() {
44
45
  if (this.#stopped)
45
- throw new KernelError("CLIENT_INVOCATION_ADMISSION_CLOSED");
46
+ throw admissionClosedError();
46
47
  }
47
48
  accepted(record, ref, terminal) {
48
49
  record.ref = ref;
@@ -8,7 +8,7 @@ export interface OrphanReapResult {
8
8
  found: boolean;
9
9
  reaped: boolean;
10
10
  pid?: number;
11
- reason?: "kernel_alive" | "host_missing" | "identity_mismatch" | "unsupported_identity";
11
+ reason?: "kernel_alive" | "host_missing" | "identity_mismatch" | "unsupported_identity" | "cleanup_incomplete" | "cleanup_acknowledged";
12
12
  }
13
13
  /**
14
14
  * 持久化 Kernel/worker 身份与在途执行事实,用于下次启动时识别遗留资源,不保存业务历史。
@@ -31,5 +31,20 @@ export declare class InvocationManifest {
31
31
  * 无法验证身份时保留清单并报告 unsupported_identity;worker 已消失不证明 Windows 后代已清空。
32
32
  */
33
33
  export declare function reapOrphanedInvocationManifest(path: string): Promise<OrphanReapResult>;
34
+ /** 只读恢复诊断,不回收进程、不改写清单;用于 doctor 及 SDK 运维界面。 */
35
+ export declare function inspectOrphanCleanup(path: string): Promise<{
36
+ manifestPath: string;
37
+ state: "missing" | "available" | "cleanup_incomplete" | "acknowledged" | "unreadable";
38
+ workerPid?: number;
39
+ }>;
40
+ /**
41
+ * 操作者已停止未知后代后显式确认当前失败记录;不终止进程、不声称整树回收已验证。
42
+ * 仍存活的原 Kernel/worker 或无法核验的 PID 不能放行。备份保留,确认仅匹配原文摘要,
43
+ * 所以并发启动、后续调用或另一份清单不会复用旧确认;下一次 open 才替换失败记录。
44
+ */
45
+ export declare function acknowledgeOrphanCleanup(path: string): Promise<{
46
+ manifestPath: string;
47
+ archivePath: string;
48
+ }>;
34
49
  /** 查询系统启动时间以区分 PID 复用;失败时不返回可用于回收的身份,绝不以 PID 本身兜底。 */
35
50
  export declare function processStartIdentity(pid: number): Promise<string | undefined>;