@mininglamp-oss/octo-runtime 1.1.9 → 1.1.11

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 (225) hide show
  1. package/README.md +2 -2
  2. package/apps/cli/README.md +1 -1
  3. package/{node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-configuration.d.ts → apps/cli/dist/adapter-configuration.d.ts} +1 -0
  4. package/{node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-configuration.js → apps/cli/dist/adapter-configuration.js} +1 -0
  5. package/apps/cli/dist/adapter-configurations.d.ts +1 -1
  6. package/apps/cli/dist/adapter-configurations.js +1 -1
  7. package/apps/cli/dist/adapters.d.ts +7 -0
  8. package/apps/cli/dist/adapters.js +77 -0
  9. package/apps/cli/dist/build-info.json +2 -2
  10. package/apps/cli/dist/command-tree.js +2 -3
  11. package/apps/cli/dist/extras.js +11 -1
  12. package/apps/cli/dist/help.js +1 -1
  13. package/apps/cli/dist/index.js +18 -1
  14. package/apps/cli/dist/main.d.ts +2 -0
  15. package/apps/cli/dist/main.js +67 -34
  16. package/apps/cli/dist/manifest.json +0 -5
  17. package/apps/cli/dist/module-manifest.js +21 -3
  18. package/apps/cli/dist/output.d.ts +19 -1
  19. package/apps/cli/dist/output.js +180 -33
  20. package/apps/cli/dist/playboard-interrupt.d.ts +6 -0
  21. package/apps/cli/dist/playboard-interrupt.js +86 -0
  22. package/apps/cli/dist/playboard.d.ts +2 -0
  23. package/apps/cli/dist/playboard.js +10 -11
  24. package/apps/cli/dist/state.d.ts +5 -2
  25. package/apps/cli/dist/state.js +48 -13
  26. package/dist/public/codex.d.ts +1 -0
  27. package/dist/public/codex.js +1 -0
  28. package/dist/public/executor-kernel.d.ts +4 -1
  29. package/dist/public/executor-kernel.js +2 -1
  30. package/dist/public/extra.d.ts +1 -1
  31. package/dist/public/host.d.ts +5 -0
  32. package/dist/public/host.js +2 -0
  33. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  34. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +20 -0
  35. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  36. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  37. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  38. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  39. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.d.ts +6 -6
  40. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +68 -253
  41. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +11 -6
  42. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +198 -52
  43. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.d.ts +58 -0
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.js +650 -0
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.d.ts +3 -0
  46. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.js +15 -0
  47. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  48. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
  49. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
  50. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  51. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  52. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  53. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  54. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +2 -0
  55. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  56. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
  57. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
  58. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/activity.d.ts +5 -0
  59. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.d.ts +25 -0
  60. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +3 -0
  61. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/reasoning.js +1 -2
  62. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.d.ts +1 -1
  63. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.js +12 -30
  64. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
  65. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configuration.d.ts +3 -0
  66. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configuration.js +125 -0
  67. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.d.ts +1 -1
  68. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.js +1 -1
  69. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.d.ts +7 -0
  70. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +77 -0
  71. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  72. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +2 -3
  73. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extras.js +11 -1
  74. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/help.js +1 -1
  75. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/index.js +18 -1
  76. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.d.ts +2 -0
  77. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +67 -34
  78. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +0 -5
  79. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.js +21 -3
  80. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.d.ts +19 -1
  81. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +180 -33
  82. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard-interrupt.d.ts +6 -0
  83. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard-interrupt.js +86 -0
  84. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.d.ts +2 -0
  85. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +10 -11
  86. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.d.ts +5 -2
  87. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.js +48 -13
  88. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +23 -24
  89. package/node_modules/@mininglamp-oss/octo-runtime-client/build-info.json +5 -0
  90. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/async-question-reply.d.ts +30 -0
  91. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/async-question-reply.js +199 -0
  92. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/browser.d.ts +1 -0
  93. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/browser.js +1 -0
  94. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.d.ts +10 -0
  95. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.js +465 -0
  96. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/index.d.ts +6 -0
  97. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/index.js +6 -0
  98. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/internal.d.ts +4 -0
  99. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/internal.js +5 -0
  100. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/invocation-lifecycle.d.ts +59 -0
  101. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/invocation-lifecycle.js +287 -0
  102. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/notification.d.ts +1 -0
  103. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/notification.js +1 -0
  104. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/protocol.d.ts +1 -0
  105. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/protocol.js +1 -0
  106. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/runtime-path.d.ts +21 -0
  107. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/runtime-path.js +138 -0
  108. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-catalog.d.ts +8 -0
  109. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-catalog.js +65 -0
  110. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-diagnostics.d.ts +82 -0
  111. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-diagnostics.js +371 -0
  112. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/submission-error.d.ts +10 -0
  113. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/submission-error.js +23 -0
  114. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/types.d.ts +72 -0
  115. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/types.js +10 -0
  116. package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +54 -0
  117. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-configuration-fixtures.json +1219 -0
  118. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-fixtures.json +5988 -0
  119. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-client.behavior.json +56 -0
  120. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc-fixtures.json +53 -0
  121. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc.schema.json +538 -0
  122. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/native-invoke-fixtures.json +116 -0
  123. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +4525 -0
  124. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/run-protocol-fixtures.json +761 -0
  125. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/runtime-selection-fixtures.json +663 -0
  126. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/session-name-fixtures.json +191 -0
  127. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
  128. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +29 -21
  129. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +173 -14
  130. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  131. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.d.ts +1 -30
  132. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.js +2 -199
  133. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.d.ts +1 -8
  134. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.js +2 -444
  135. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/endpoint.js +2 -0
  136. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/execution-source.d.ts +17 -0
  137. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/execution-source.js +21 -0
  138. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.d.ts +11 -9
  139. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.js +14 -3
  140. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +5 -7
  141. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +6 -7
  142. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.d.ts +1 -53
  143. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.js +2 -280
  144. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.d.ts +14 -13
  145. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.js +84 -187
  146. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/lifecycle.d.ts +5 -10
  147. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/lifecycle.js +4 -1
  148. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-home.d.ts +20 -0
  149. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-home.js +180 -0
  150. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +5 -8
  151. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +75 -45
  152. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.d.ts +9 -2
  153. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.js +60 -5
  154. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-catalog.d.ts +1 -0
  155. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-catalog.js +1 -0
  156. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-diagnostics.d.ts +1 -0
  157. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-diagnostics.js +1 -0
  158. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-logging.d.ts +4 -0
  159. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-logging.js +18 -0
  160. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.d.ts +1 -10
  161. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.js +2 -23
  162. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/types.d.ts +2 -72
  163. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/types.js +2 -10
  164. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +5 -12
  165. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/extra.js +1 -1
  166. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/ports.d.ts +2 -2
  167. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
  168. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/extra.js +1 -1
  169. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/ports.d.ts +2 -2
  170. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
  171. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/index.js +4 -4
  172. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/assets/{index-BVxePruX.js → index-BLMf2Etg.js} +1 -3
  173. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/index.html +1 -1
  174. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
  175. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.d.ts +1 -1
  176. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.js +12 -5
  177. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/errors.d.ts +5 -1
  178. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/errors.js +9 -0
  179. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/execution.d.ts +44 -0
  180. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/execution.js +207 -0
  181. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-config.js +23 -3
  182. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-service.d.ts +27 -4
  183. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-service.js +133 -25
  184. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extras.d.ts +10 -3
  185. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extras.js +18 -4
  186. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/home.d.ts +5 -6
  187. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/home.js +33 -45
  188. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/identity.js +6 -0
  189. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.d.ts +4 -0
  190. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.js +3 -0
  191. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +5 -4
  192. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.d.ts +7 -0
  193. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +19 -15
  194. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +3 -1
  195. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +1 -0
  196. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.d.ts +5 -0
  197. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.js +65 -0
  198. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  199. package/package.json +33 -29
  200. package/packages/octo-runtime-protocol/schema/protocol.schema.json +42 -36
  201. package/apps/cli/dist/worker.js +0 -18
  202. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/app-server.d.ts +0 -63
  203. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/app-server.js +0 -846
  204. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.d.ts +0 -54
  205. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.js +0 -154
  206. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +0 -15
  207. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/worker.js +0 -18
  208. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/heartbeat.d.ts +0 -16
  209. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/heartbeat.js +0 -59
  210. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/manifest-adapters.d.ts +0 -6
  211. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/manifest-adapters.js +0 -88
  212. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/module-specifier.d.ts +0 -1
  213. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/module-specifier.js +0 -2
  214. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.d.ts +0 -42
  215. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.js +0 -292
  216. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/rpc.d.ts +0 -64
  217. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/rpc.js +0 -674
  218. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runner.d.ts +0 -2
  219. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runner.js +0 -5
  220. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/serve.d.ts +0 -10
  221. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/serve.js +0 -96
  222. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.d.ts +0 -15
  223. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.js +0 -279
  224. /package/{apps/cli/dist/worker.d.ts → node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.js} +0 -0
  225. /package/node_modules/@mininglamp-oss/{octo-runtime-cli/dist/worker.d.ts → octo-runtime-protocol/dist/adapter-metadata.js} +0 -0
@@ -1,15 +1,15 @@
1
- import { execFile } from "node:child_process";
2
1
  import { createHash, randomUUID } from "node:crypto";
3
2
  import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
4
3
  import { dirname } from "node:path";
5
4
  /**
6
- * 持久化 Kernel/worker 身份与在途执行事实,用于下次启动时识别遗留资源,不保存业务历史。
7
- * 写入串行化并通过 rename 替换;只有 owner 确认 worker 回收后才能 close 删除清单。
5
+ * 持久化原生 Kernel 所有权与在途执行事实,不保存业务历史,不迁移旧执行架构。
6
+ * 这是资源恢复记录,不是模块 manifest。写入串行化并通过 rename 替换;
7
+ * 只有 owner 确认 Core/Adapter 资源回收后才能 close 删除记录。
8
8
  */
9
9
  export class InvocationManifest {
10
10
  #path;
11
11
  #invocations = new Map();
12
- #worker;
12
+ #cleanupFailed = false;
13
13
  #writes = Promise.resolve();
14
14
  constructor(path) {
15
15
  this.#path = path;
@@ -19,29 +19,21 @@ export class InvocationManifest {
19
19
  if (reap.reason === "cleanup_incomplete") {
20
20
  throw Object.assign(new Error(`Orphan cleanup is unconfirmed: ${path}. After stopping all orphan tools, use acknowledgeOrphanCleanup(path), then retry startup.`), { code: "ORPHAN_CLEANUP_INCOMPLETE" });
21
21
  }
22
- if (reap.reason === "kernel_alive" || reap.reason === "unsupported_identity") {
23
- throw new Error(`cannot replace live or unverifiable invocation manifest (${reap.reason})`);
22
+ if (reap.reason === "kernel_alive") {
23
+ throw new Error(`cannot replace live invocation manifest (${reap.reason})`);
24
24
  }
25
25
  const manifest = new InvocationManifest(path);
26
26
  await manifest.#persist();
27
27
  await removeAcknowledgement(path);
28
28
  return { manifest, reap };
29
29
  }
30
- async setWorker(pid, entrypoint) {
31
- if (pid === undefined) {
32
- this.#worker = undefined;
33
- }
34
- else {
35
- try {
36
- const started = await queryProcessStartIdentity(pid);
37
- if (!started)
38
- throw new Error("system process start identity unavailable");
39
- this.#worker = { pid, started, entrypoint };
40
- }
41
- catch (cause) {
42
- throw new Error(`cannot identify worker process ${pid}`, { cause });
43
- }
44
- }
30
+ /** 原生服务异常退出无法证明 Adapter 资源已清空;正常 close 才删除所有权证据。 */
31
+ async markNativeOwner() {
32
+ await this.#persist();
33
+ }
34
+ /** owner 关闭未完成时登记实际失败;宿主继续存活也不能将诊断恢复为 available。 */
35
+ async markCleanupIncomplete() {
36
+ this.#cleanupFailed = true;
45
37
  await this.#persist();
46
38
  }
47
39
  async begin(entry) {
@@ -63,7 +55,9 @@ export class InvocationManifest {
63
55
  schemaVersion: 1,
64
56
  kernelPid: process.pid,
65
57
  updatedAt: new Date().toISOString(),
66
- ...(this.#worker ? { worker: { ...this.#worker } } : {}),
58
+ nativeOwner: true,
59
+ cleanupIncomplete: true,
60
+ ...(this.#cleanupFailed ? { cleanupFailed: true } : {}),
67
61
  invocations: [...this.#invocations.values()].map((entry) => ({ ...entry }))
68
62
  };
69
63
  // 当前调用仍收到自己的 IO 失败;后续完整快照可重试,不能让一次失败毒化整个串行队列。
@@ -76,74 +70,30 @@ export class InvocationManifest {
76
70
  }
77
71
  }
78
72
  /**
79
- * 仅在原 Kernel 已退出且 worker 的 PID/启动身份仍匹配时尝试回收,防止 PID 复用误杀。
80
- * 无法验证身份时保留清单并报告 unsupported_identity;worker 已消失不证明 Windows 后代已清空。
73
+ * 检查原生 owner 的遗留记录,不终止宿主或 Provider 进程。
74
+ * 仅文件不存在或该原文已获人工确认才允许 open;损坏及旧 worker 记录保留并明确拒绝。
81
75
  */
82
76
  export async function reapOrphanedInvocationManifest(path) {
83
- let parsed;
84
77
  let source;
85
78
  try {
86
79
  source = await readFile(path, "utf8");
87
- parsed = JSON.parse(source);
88
80
  }
89
81
  catch (error) {
90
- if (error.code === "ENOENT") {
91
- await removeAcknowledgement(path);
92
- return { found: false, reaped: false };
93
- }
94
- await rm(path, { force: true });
82
+ if (error.code !== "ENOENT")
83
+ throw error;
95
84
  await removeAcknowledgement(path);
96
- return { found: true, reaped: false, reason: "host_missing" };
85
+ return { found: false, reaped: false };
97
86
  }
98
- if (Number.isSafeInteger(parsed.kernelPid) &&
99
- parsed.kernelPid > 0 &&
100
- processAlive(parsed.kernelPid)) {
87
+ const parsed = parseManifest(source);
88
+ if (processAlive(parsed.kernelPid))
101
89
  return { found: true, reaped: false, reason: "kernel_alive" };
102
- }
103
- const host = parsed.worker;
104
- if (!host || !Number.isSafeInteger(host.pid) || host.pid < 1 || !processAlive(host.pid)) {
105
- if (parsed.cleanupIncomplete && process.platform === "win32") {
106
- return {
107
- found: true,
108
- reaped: false,
109
- pid: host?.pid,
110
- reason: (await cleanupWasAcknowledged(path, source))
111
- ? "cleanup_acknowledged"
112
- : "cleanup_incomplete"
113
- };
114
- }
115
- await rm(path, { force: true });
116
- await removeAcknowledgement(path);
117
- return { found: true, reaped: false, reason: "host_missing" };
118
- }
119
- const currentIdentity = await processStartIdentity(host.pid);
120
- if (!currentIdentity) {
121
- return { found: true, reaped: false, pid: host.pid, reason: "unsupported_identity" };
122
- }
123
- if (currentIdentity !== host.started) {
124
- if (parsed.cleanupIncomplete && process.platform === "win32") {
125
- return {
126
- found: true,
127
- reaped: false,
128
- pid: host.pid,
129
- reason: (await cleanupWasAcknowledged(path, source))
130
- ? "cleanup_acknowledged"
131
- : "cleanup_incomplete"
132
- };
133
- }
134
- await rm(path, { force: true });
135
- await removeAcknowledgement(path);
136
- return { found: true, reaped: false, pid: host.pid, reason: "identity_mismatch" };
137
- }
138
- // 必须在 leader 仍可识别时回收 Windows 树;失败保留证据,禁止覆盖清单并启动替代 worker。
139
- if (!(await terminateProcessGroup(host.pid)) && process.platform === "win32") {
140
- // 失败事实必须跨重启保留;leader 后来消失或 PID 复用不能抹去未确认的后代归属。
141
- await writeManifest(path, { ...parsed, cleanupIncomplete: true });
142
- return { found: true, reaped: false, pid: host.pid, reason: "cleanup_incomplete" };
143
- }
144
- await rm(path, { force: true });
145
- await removeAcknowledgement(path);
146
- return { found: true, reaped: true, pid: host.pid };
90
+ return {
91
+ found: true,
92
+ reaped: false,
93
+ reason: (await cleanupWasAcknowledged(path, source))
94
+ ? "cleanup_acknowledged"
95
+ : "cleanup_incomplete"
96
+ };
147
97
  }
148
98
  async function removeAcknowledgement(path) {
149
99
  try {
@@ -157,48 +107,38 @@ async function removeAcknowledgement(path) {
157
107
  export async function inspectOrphanCleanup(path) {
158
108
  try {
159
109
  const source = await readFile(path, "utf8");
160
- const parsed = JSON.parse(source);
110
+ const parsed = parseManifest(source);
161
111
  return {
162
112
  manifestPath: path,
163
- state: parsed.cleanupIncomplete
113
+ // 运行中的保守标记不表示实际失败;关闭已失败时,宿主继续存活也不能隐藏 incomplete。
114
+ state: parsed.cleanupFailed || !processAlive(parsed.kernelPid)
164
115
  ? (await cleanupWasAcknowledged(path, source))
165
116
  ? "acknowledged"
166
117
  : "cleanup_incomplete"
167
- : "available",
168
- workerPid: parsed.worker?.pid
118
+ : "available"
169
119
  };
170
120
  }
171
121
  catch (error) {
172
122
  return {
173
123
  manifestPath: path,
174
- state: error.code === "ENOENT" ? "missing" : "unreadable"
124
+ state: error.code === "ENOENT"
125
+ ? "missing"
126
+ : error.code === "ORPHAN_RECORD_UNSUPPORTED"
127
+ ? "unsupported"
128
+ : "unreadable"
175
129
  };
176
130
  }
177
131
  }
178
132
  /**
179
133
  * 操作者已停止未知后代后显式确认当前失败记录;不终止进程、不声称整树回收已验证。
180
- * 仍存活的原 Kernel/worker 或无法核验的 PID 不能放行。备份保留,确认仅匹配原文摘要,
134
+ * 仅接受有效原生记录,仍存活的原 Kernel 不能放行。备份保留,确认仅匹配原文摘要,
181
135
  * 所以并发启动、后续调用或另一份清单不会复用旧确认;下一次 open 才替换失败记录。
182
136
  */
183
137
  export async function acknowledgeOrphanCleanup(path) {
184
138
  const source = await readFile(path, "utf8");
185
- const parsed = JSON.parse(source);
186
- if (parsed.schemaVersion !== 1 ||
187
- !Number.isSafeInteger(parsed.kernelPid) ||
188
- parsed.kernelPid < 1 ||
189
- parsed.cleanupIncomplete !== true ||
190
- !parsed.worker ||
191
- !Number.isSafeInteger(parsed.worker.pid) ||
192
- parsed.worker.pid < 1) {
193
- throw new Error("ORPHAN_CLEANUP_NOT_PENDING");
194
- }
139
+ const parsed = parseManifest(source);
195
140
  if (processAlive(parsed.kernelPid))
196
141
  throw new Error("ORPHAN_CLEANUP_OWNER_ALIVE");
197
- if (processAlive(parsed.worker.pid)) {
198
- const identity = await processStartIdentity(parsed.worker.pid);
199
- if (!identity || identity === parsed.worker.started)
200
- throw new Error("ORPHAN_CLEANUP_OWNER_ALIVE");
201
- }
202
142
  const archivePath = `${path}.acknowledged.${randomUUID()}.json`;
203
143
  await writeFile(archivePath, source, { encoding: "utf8", flag: "wx", mode: 0o600 });
204
144
  const temporary = `${path}.${randomUUID()}.ack.tmp`;
@@ -242,96 +182,48 @@ async function writeManifest(path, snapshot) {
242
182
  await rm(temporary, { force: true });
243
183
  }
244
184
  }
245
- /** 查询系统启动时间以区分 PID 复用;失败时不返回可用于回收的身份,绝不以 PID 本身兜底。 */
246
- export async function processStartIdentity(pid) {
185
+ /** 旧格式、未知字段及损坏内容均不能当作空记录覆盖;读取与人工确认共用同一校验。 */
186
+ function parseManifest(source) {
247
187
  try {
248
- return await queryProcessStartIdentity(pid);
249
- }
250
- catch {
251
- return undefined;
252
- }
253
- }
254
- // 登记失败保留系统查询原因;公开探测与孤儿回收仍以 undefined 表示身份未知。
255
- async function queryProcessStartIdentity(pid) {
256
- if (!Number.isSafeInteger(pid) || pid < 1)
257
- return undefined;
258
- if (process.platform === "linux") {
259
- try {
260
- const stat = await readFile(`/proc/${pid}/stat`, "utf8");
261
- const fields = stat
262
- .slice(stat.lastIndexOf(")") + 2)
263
- .trim()
264
- .split(/\s+/);
265
- return fields[19] ? `linux:${fields[19]}` : undefined;
266
- }
267
- catch {
268
- return undefined;
269
- }
270
- }
271
- if (process.platform === "darwin" || process.platform === "freebsd") {
272
- return new Promise((resolve) => {
273
- execFile("/bin/ps", ["-o", "lstart=", "-p", String(pid)], { timeout: 2_000 }, (error, stdout) => {
274
- const value = stdout.trim();
275
- resolve(error || !value ? undefined : `ps:${value}`);
276
- });
277
- });
278
- }
279
- if (process.platform === "win32") {
280
- return new Promise((resolve, reject) => {
281
- execFile("powershell.exe", [
282
- "-NoLogo",
283
- "-NoProfile",
284
- "-NonInteractive",
285
- "-Command",
286
- // 直接调用系统进程对象,避免 Get-Process 的命令发现/模块自动加载占用身份查询预算。
287
- // 保持 UTC ticks 身份格式,不缓存可能已经复用的 PID。
288
- `$PSModuleAutoLoadingPreference='None'; $target=[System.Diagnostics.Process]::GetProcessById(${pid}); try { [Console]::Out.Write($target.StartTime.ToUniversalTime().Ticks.ToString([Globalization.CultureInfo]::InvariantCulture)) } finally { $target.Dispose() }`
289
- ],
290
- // PowerShell 冷启动与查询共用 40 秒;Windows CI 曾在 30 秒期限被系统命令超时终止。
291
- // 身份登记独立于后续 RPC 就绪与关闭预算,失败仍禁止使用未知 PID。
292
- { encoding: "utf8", timeout: 40_000, windowsHide: true }, (error, stdout) => {
293
- if (error) {
294
- reject(error instanceof Error
295
- ? error
296
- : new Error("Windows process identity query failed", { cause: error }));
297
- return;
298
- }
299
- const value = stdout.trim();
300
- resolve(!/^\d+$/.test(value) ? undefined : `windows:${value}`);
301
- });
302
- });
303
- }
304
- return undefined;
305
- }
306
- async function terminateProcessGroup(pid) {
307
- if (process.platform === "win32") {
308
- const terminated = await new Promise((resolve) => {
309
- execFile("taskkill.exe", ["/PID", String(pid), "/T", "/F"], { windowsHide: true, timeout: 5_000 }, (error) => resolve(!error));
188
+ const value = JSON.parse(source);
189
+ const fields = new Set([
190
+ "schemaVersion",
191
+ "kernelPid",
192
+ "updatedAt",
193
+ "nativeOwner",
194
+ "cleanupIncomplete",
195
+ "cleanupFailed",
196
+ "invocations"
197
+ ]);
198
+ if (!record(value) ||
199
+ Object.keys(value).some((key) => !fields.has(key)) ||
200
+ value.schemaVersion !== 1 ||
201
+ value.nativeOwner !== true ||
202
+ value.cleanupIncomplete !== true ||
203
+ !Number.isSafeInteger(value.kernelPid) ||
204
+ Number(value.kernelPid) < 1 ||
205
+ Number(value.kernelPid) > 2147483647 ||
206
+ !timestamp(value.updatedAt) ||
207
+ (value.cleanupFailed !== undefined && value.cleanupFailed !== true) ||
208
+ !Array.isArray(value.invocations) ||
209
+ !value.invocations.every((entry) => record(entry) &&
210
+ Object.keys(entry).length === 4 &&
211
+ ["invocationId", "runId", "adapterType"].every((key) => typeof entry[key] === "string" && entry[key] !== "") &&
212
+ timestamp(entry.startedAt)))
213
+ throw new Error("Invalid native ownership record");
214
+ return value;
215
+ }
216
+ catch (cause) {
217
+ throw Object.assign(new Error("ORPHAN_RECORD_UNSUPPORTED", { cause }), {
218
+ code: "ORPHAN_RECORD_UNSUPPORTED"
310
219
  });
311
- // taskkill 失败即使 leader 随后消失,也不能证明后代已回收。
312
- return terminated && (await waitForExit(pid, 1_000));
313
220
  }
314
- signalProcessGroup(pid, "SIGTERM");
315
- if (await waitForExit(pid, 1_000))
316
- return true;
317
- signalProcessGroup(pid, "SIGKILL");
318
- return waitForExit(pid, 1_000);
319
221
  }
320
- function signalProcessGroup(pid, signal) {
321
- try {
322
- process.kill(-pid, signal);
323
- }
324
- catch (error) {
325
- if (error.code !== "ESRCH")
326
- throw error;
327
- }
222
+ function record(value) {
223
+ return value !== null && typeof value === "object" && !Array.isArray(value);
328
224
  }
329
- async function waitForExit(pid, timeoutMs) {
330
- const deadline = Date.now() + timeoutMs;
331
- while (processAlive(pid) && Date.now() < deadline) {
332
- await new Promise((resolve) => setTimeout(resolve, 25));
333
- }
334
- return !processAlive(pid);
225
+ function timestamp(value) {
226
+ return typeof value === "string" && value.length > 0 && Number.isFinite(Date.parse(value));
335
227
  }
336
228
  function processAlive(pid) {
337
229
  try {
@@ -339,6 +231,11 @@ function processAlive(pid) {
339
231
  return true;
340
232
  }
341
233
  catch (error) {
342
- return error.code === "EPERM";
234
+ const code = error.code;
235
+ if (code === "ESRCH")
236
+ return false;
237
+ if (code === "EPERM")
238
+ return true;
239
+ throw error;
343
240
  }
344
241
  }
@@ -1,12 +1,6 @@
1
- export type ServicePhase = "created" | "initializing" | "ready" | "closing" | "closed" | "failed";
2
- export interface ServiceCleanupResult {
3
- readonly complete: boolean;
4
- readonly errors: readonly {
5
- resource: string;
6
- code: string;
7
- }[];
8
- readonly pendingResources: readonly string[];
9
- }
1
+ import { type StartupDiagnostic, type StartupLocation } from "./startup-diagnostics.js";
2
+ import type { ServiceCleanupResult } from "@mininglamp-oss/octo-runtime-client/internal";
3
+ export type { ServiceCleanupResult, ServicePhase } from "@mininglamp-oss/octo-runtime-client/internal";
10
4
  export interface ServiceLifecycle<S> {
11
5
  initialize(options?: {
12
6
  signal?: AbortSignal;
@@ -17,7 +11,8 @@ export interface ServiceLifecycle<S> {
17
11
  }
18
12
  export declare class ServiceInitializationError extends Error {
19
13
  readonly cleanup: ServiceCleanupResult;
20
- constructor(cause: unknown, cleanup: ServiceCleanupResult);
14
+ readonly diagnostic: StartupDiagnostic;
15
+ constructor(cause: unknown, cleanup: ServiceCleanupResult, location?: StartupLocation);
21
16
  }
22
17
  /** 所有阶段共用停止起点,超时只结束等待,不代表底层资源已释放。 */
23
18
  export declare function beforeDeadline<T>(operation: Promise<T>, until: number): Promise<T>;
@@ -1,9 +1,12 @@
1
+ import { describeStartupError } from "./startup-diagnostics.js";
1
2
  export class ServiceInitializationError extends Error {
2
3
  cleanup;
3
- constructor(cause, cleanup) {
4
+ diagnostic;
5
+ constructor(cause, cleanup, location = { component: "host", phase: "initializing" }) {
4
6
  super("SERVICE_INITIALIZATION_FAILED", { cause });
5
7
  this.cleanup = cleanup;
6
8
  this.name = "ServiceInitializationError";
9
+ this.diagnostic = describeStartupError(this, location);
7
10
  }
8
11
  }
9
12
  /** 所有阶段共用停止起点,超时只结束等待,不代表底层资源已释放。 */
@@ -0,0 +1,20 @@
1
+ import { RuntimeHomeError } from "@mininglamp-oss/octo-runtime-client/internal";
2
+ export { RuntimeHomeError, normalizeRuntimeHome, assertRuntimePath, assertIpcEndpoint, type StartupPathDiagnostic } from "@mininglamp-oss/octo-runtime-client/internal";
3
+ export interface RuntimePath {
4
+ path: string;
5
+ resource: string;
6
+ /** 可选日志只校验名称预算,IO 可用性由既有 best-effort 日志层处理。 */
7
+ optional?: boolean;
8
+ }
9
+ /**
10
+ * 宿主先准备根目录;SDK 在资源启动前只验证,不 mkdir 根或选择替代目录。
11
+ * access 后用独占短探针确认真实读写权限(Windows access 不能完整判断 ACL),不改变身份/配置。
12
+ * 这是同账号信任边界内的启动检查,不承诺对同账号并发替换目录提供文件系统沙箱。
13
+ */
14
+ export declare function validateRuntimeHome(input: string, paths?: readonly RuntimePath[]): string;
15
+ /** 只创建已验证 Home 内的子目录,逐级 mkdir;根消失时失败,绝不递归补建根。 */
16
+ export declare function prepareHomeDirectory(home: string, directory: string): void;
17
+ /** 将实际系统 IO 失败投影为启动诊断,保留必要 errno 但不公开系统错误正文。 */
18
+ export declare function runtimePathFailure(error: unknown, path: string, resource: string, operation: string): RuntimeHomeError;
19
+ /** 所有启动资源先列出完整最终文件名,覆盖原子写、恢复归档与轮转锁的额外后缀。 */
20
+ export declare function kernelStartupPaths(endpoint: string, stateDirectory?: string, logDirectory?: string): RuntimePath[];
@@ -0,0 +1,180 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { randomUUID } from "node:crypto";
3
+ import { accessSync, closeSync, constants, mkdirSync, opendirSync, openSync, statSync, unlinkSync } from "node:fs";
4
+ import { posix, win32 } from "node:path";
5
+ import { RuntimeHomeError, normalizeRuntimeHome, assertRuntimePath, platformLimits } from "@mininglamp-oss/octo-runtime-client/internal";
6
+ export { RuntimeHomeError, normalizeRuntimeHome, assertRuntimePath, assertIpcEndpoint } from "@mininglamp-oss/octo-runtime-client/internal";
7
+ /**
8
+ * 宿主先准备根目录;SDK 在资源启动前只验证,不 mkdir 根或选择替代目录。
9
+ * access 后用独占短探针确认真实读写权限(Windows access 不能完整判断 ACL),不改变身份/配置。
10
+ * 这是同账号信任边界内的启动检查,不承诺对同账号并发替换目录提供文件系统沙箱。
11
+ */
12
+ export function validateRuntimeHome(input, paths = []) {
13
+ const home = normalizeRuntimeHome(input);
14
+ let operation = "stat";
15
+ let affected = home;
16
+ let resource = "home";
17
+ try {
18
+ assertRuntimePath(home, "home");
19
+ if (!statSync(home).isDirectory())
20
+ throw new RuntimeHomeError({
21
+ code: "HOME_NOT_DIRECTORY",
22
+ path: home,
23
+ resource: "home",
24
+ operation
25
+ });
26
+ operation = "filesystem-limits";
27
+ const cache = new Map();
28
+ const filesystemLimits = (path) => {
29
+ if (process.platform === "win32")
30
+ return platformLimits(process.platform);
31
+ // 日志/状态可由高级宿主选择在另一文件系统;不能把 Home 所在卷的预算套给它。
32
+ let directory = path;
33
+ for (;;) {
34
+ try {
35
+ if (statSync(directory).isDirectory())
36
+ break;
37
+ }
38
+ catch (error) {
39
+ const code = error.code;
40
+ // 子路径缺失/被普通文件阻断时仍可查询最近目录;其他 IO 失败由调用方按资源必要性处理。
41
+ if (!["ENOENT", "ENOTDIR"].includes(code ?? ""))
42
+ throw error;
43
+ }
44
+ const parent = posix.dirname(directory);
45
+ if (parent === directory)
46
+ throw new Error("PATH_LIMIT_UNAVAILABLE");
47
+ directory = parent;
48
+ }
49
+ const cached = cache.get(directory);
50
+ if (cached)
51
+ return cached;
52
+ const query = (name) => {
53
+ operation = "getconf";
54
+ const value = Number(
55
+ // 使用 OS 工具的固定位置;宿主可能为 Provider 注入受限 PATH,不能据此选择查询程序。
56
+ execFileSync("/usr/bin/getconf", [name, directory], {
57
+ encoding: "utf8",
58
+ timeout: 1000,
59
+ stdio: ["ignore", "pipe", "ignore"]
60
+ }).trim());
61
+ if (!Number.isSafeInteger(value) || value < 1)
62
+ throw new Error("PATH_LIMIT_UNAVAILABLE");
63
+ return value;
64
+ };
65
+ const limits = { path: query("PATH_MAX") - 1, name: query("NAME_MAX") };
66
+ cache.set(directory, limits);
67
+ return limits;
68
+ };
69
+ const limits = filesystemLimits(home);
70
+ for (const entry of [{ path: home, resource: "home", optional: false }, ...paths]) {
71
+ affected = entry.path;
72
+ resource = entry.resource;
73
+ normalizeRuntimeHome(entry.path, process.platform, entry.resource);
74
+ assertRuntimePath(entry.path, entry.resource);
75
+ operation = "filesystem-limits";
76
+ let observed;
77
+ try {
78
+ observed = filesystemLimits(entry.path);
79
+ }
80
+ catch (error) {
81
+ // 可选日志的 stat/getconf 失败(循环链接、坏盘等)仍归日志层 best-effort 隔离,不能枚举少数 errno。
82
+ // 前面的输入/静态长度检查不在此隔离范围;Home 和状态等必需资源仍传播原始 IO 失败。
83
+ if (!entry.optional)
84
+ throw error;
85
+ }
86
+ if (observed)
87
+ assertRuntimePath(entry.path, entry.resource, process.platform, observed);
88
+ }
89
+ affected = home;
90
+ resource = "home";
91
+ operation = "access";
92
+ accessSync(home, constants.R_OK | constants.W_OK | constants.X_OK);
93
+ operation = "read-directory";
94
+ opendirSync(home).closeSync();
95
+ operation = "write-probe";
96
+ const probe = (process.platform === "win32" ? win32 : posix).join(home, `.octo-home-${randomUUID()}`);
97
+ assertRuntimePath(probe, "home-probe", process.platform, limits);
98
+ affected = probe;
99
+ const fd = openSync(probe, "wx", 0o600);
100
+ try {
101
+ closeSync(fd);
102
+ }
103
+ finally {
104
+ unlinkSync(probe);
105
+ }
106
+ return home;
107
+ }
108
+ catch (error) {
109
+ if (error instanceof RuntimeHomeError)
110
+ throw error;
111
+ throw runtimePathFailure(error, affected, resource, operation);
112
+ }
113
+ }
114
+ /** 只创建已验证 Home 内的子目录,逐级 mkdir;根消失时失败,绝不递归补建根。 */
115
+ export function prepareHomeDirectory(home, directory) {
116
+ const api = process.platform === "win32" ? win32 : posix;
117
+ const child = api.relative(home, directory);
118
+ if (!child || child.startsWith(`..${api.sep}`) || child === ".." || api.isAbsolute(child))
119
+ return;
120
+ let current = home;
121
+ for (const part of child.split(api.sep)) {
122
+ current = api.join(current, part);
123
+ try {
124
+ mkdirSync(current, { mode: 0o700 });
125
+ }
126
+ catch (error) {
127
+ if (error.code === "EEXIST" && statSync(current).isDirectory())
128
+ continue;
129
+ throw runtimePathFailure(error, current, "runtime-directory", "mkdir");
130
+ }
131
+ }
132
+ }
133
+ /** 将实际系统 IO 失败投影为启动诊断,保留必要 errno 但不公开系统错误正文。 */
134
+ export function runtimePathFailure(error, path, resource, operation) {
135
+ const raw = error instanceof Error && "code" in error ? error.code : undefined;
136
+ const systemCode = typeof raw === "string" && /^[A-Z][A-Z0-9_]+$/.test(raw) ? raw : undefined;
137
+ const code = operation === "getconf"
138
+ ? "HOME_LIMIT_UNAVAILABLE"
139
+ : systemCode === "ENOENT"
140
+ ? "HOME_NOT_FOUND"
141
+ : systemCode === "ENOTDIR"
142
+ ? "HOME_NOT_DIRECTORY"
143
+ : ["EACCES", "EPERM", "EROFS"].includes(systemCode ?? "")
144
+ ? "HOME_PERMISSION_DENIED"
145
+ : systemCode === "ENAMETOOLONG"
146
+ ? "HOME_PATH_TOO_LONG"
147
+ : operation === "filesystem-limits"
148
+ ? "HOME_LIMIT_UNAVAILABLE"
149
+ : "HOME_UNUSABLE";
150
+ return new RuntimeHomeError({
151
+ code,
152
+ path,
153
+ resource,
154
+ operation,
155
+ ...(systemCode ? { systemCode } : {})
156
+ }, error);
157
+ }
158
+ /** 所有启动资源先列出完整最终文件名,覆盖原子写、恢复归档与轮转锁的额外后缀。 */
159
+ export function kernelStartupPaths(endpoint, stateDirectory, logDirectory) {
160
+ const paths = [];
161
+ if (process.platform !== "win32")
162
+ paths.push({ path: `${endpoint}.owner.recovery`, resource: "endpoint-ownership" });
163
+ const statePath = stateDirectory
164
+ ? (process.platform === "win32" ? win32 : posix).join(stateDirectory, "kernel-invocations.json")
165
+ : process.platform !== "win32"
166
+ ? `${endpoint}.runs`
167
+ : undefined;
168
+ if (statePath)
169
+ paths.push({
170
+ path: `${statePath}.acknowledged.${"0".repeat(36)}.json`,
171
+ resource: "kernel-state"
172
+ });
173
+ if (logDirectory)
174
+ paths.push({
175
+ path: (process.platform === "win32" ? win32 : posix).join(logDirectory, "kernel-status-20000101T00.log.lock"),
176
+ resource: "kernel-log",
177
+ optional: true
178
+ });
179
+ return paths;
180
+ }
@@ -1,21 +1,18 @@
1
1
  import { type RuntimeLoggingOptions, type AdapterProbeOptions } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
- import { type AdapterModuleEntry } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
2
+ import { type HostedAdapter } from "@mininglamp-oss/octo-runtime-executor-core";
3
3
  import { type KernelStatus } from "./types.js";
4
4
  export interface KernelServerOptions {
5
5
  endpoint: string;
6
- workerEntrypoint: string;
7
- manifest?: string;
8
- /** CLI 装配快照;SDK 原生 worker 无需清单或此字段。 */
9
- adapterModules?: AdapterModuleEntry[];
10
- env?: NodeJS.ProcessEnv;
6
+ /** 宿主已 import/构造的实例;保留对象身份,不跨进程序列化。 */
7
+ adapters: readonly HostedAdapter[];
11
8
  adapterConfigurations?: Record<string, AdapterProbeOptions>;
12
9
  stateDirectory?: string;
13
- /** 父进程独立记录 worker 监督状态;不依赖 worker 的执行日志,调用方选择日志目录。 */
10
+ /** 记录 Kernel/Core 的生命周期;调用方选择日志目录。 */
14
11
  logging?: RuntimeLoggingOptions;
15
12
  configurations?: (runtimeId?: string) => Record<string, AdapterProbeOptions>;
16
13
  }
17
14
  /**
18
- * 创建独立 Kernel 的本地 RPC 端点,独占端点租约、Run 事件源与 worker 监督器。
15
+ * 在宿主进程创建本地 RPC 端点,独占端点租约、Run 事件源和 AgentExecutor。
19
16
  * 启动失败也执行回收;close 失败会保留所有权证据,客户端断开不等同于 owner 关闭。
20
17
  */
21
18
  export declare function startKernelServer(options: KernelServerOptions, signal?: AbortSignal): Promise<{