@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,27 +1,77 @@
1
1
  import net from "node:net";
2
+ import { AgentExecutor } from "@mininglamp-oss/octo-runtime-executor-core";
2
3
  import { performance } from "node:perf_hooks";
3
- import { chmod, mkdir, rm } from "node:fs/promises";
4
+ import { chmod, rm } from "node:fs/promises";
4
5
  import { dirname, resolve } from "node:path";
5
- import { RuntimeLogging, assertRuntimeLogging, readBoundedLines } from "@mininglamp-oss/octo-runtime-adapter-sdk";
6
- import { acquireEndpoint, attachKernel, ServiceInitializationError } from "@mininglamp-oss/octo-runtime-executor-kernel";
6
+ import { RuntimeLogging, readBoundedLines } from "@mininglamp-oss/octo-runtime-adapter-sdk";
7
+ import { assertStartupLogging, acquireEndpoint, assertIpcEndpoint, assertRuntimePath, validateRuntimeHome, prepareHomeDirectory, runtimePathFailure, attachKernel, ServiceInitializationError, withStartupContext } from "@mininglamp-oss/octo-runtime-executor-kernel";
7
8
  import { assertExtraName, ExtraPlugins } from "./extras.js";
8
9
  import { shutdownDeadline, withShutdownDeadline, withinShutdown } from "./shutdown.js";
9
10
  import { snapshotExtraDependencies } from "./extra-dependencies.js";
11
+ import { createDirectExecutionScope, createIpcExecutionScope } from "./execution.js";
10
12
  // 未确认清理的实例仍占有名称;不同 Kernel/Home 的同名 Extra 相互独立。
11
13
  const owners = new Map();
12
- /** 装配插件和同进程业务函数;只借用指定 Kernel,不启动或关闭它。 */
14
+ const directOwners = new WeakMap();
15
+ let ownerCount = 0;
16
+ /** 装配插件与独立调用 scope;只借用宿主的 Core 或既有 Kernel,关闭不接管执行服务。 */
13
17
  export function createExtraService(options) {
18
+ try {
19
+ return constructExtraService(options);
20
+ }
21
+ catch (error) {
22
+ throw withStartupContext(error, {
23
+ component: "extra",
24
+ phase: "created",
25
+ context: { operation: "validate-options", resource: "extra" }
26
+ });
27
+ }
28
+ }
29
+ function constructExtraService(options) {
30
+ // 以字段存在性拒绝混用,显式 undefined 不能绕过互斥;保存 executor 原对象身份。
31
+ let execution;
32
+ if ("execution" in options) {
33
+ if ("endpoint" in options)
34
+ throw new TypeError("EXTRA_EXECUTION_MIXED");
35
+ const value = options.execution;
36
+ if (!value || typeof value !== "object" || Array.isArray(value))
37
+ throw new TypeError("EXTRA_EXECUTION_INVALID");
38
+ if (value.kind === "direct") {
39
+ if ("endpoint" in value || !(value.executor instanceof AgentExecutor))
40
+ throw new TypeError("EXTRA_EXECUTOR_INVALID: use the AgentExecutor exported by the same Runtime installation");
41
+ execution = { kind: "direct", executor: value.executor };
42
+ }
43
+ else if (value.kind === "ipc") {
44
+ if ("executor" in value || typeof value.endpoint !== "string" || !value.endpoint)
45
+ throw new TypeError("EXTRA_EXECUTION_INVALID");
46
+ execution = { kind: "ipc", endpoint: value.endpoint };
47
+ }
48
+ else
49
+ throw new TypeError("EXTRA_EXECUTION_INVALID");
50
+ }
51
+ else {
52
+ if (typeof options.endpoint !== "string" || !options.endpoint)
53
+ throw new TypeError("EXTRA_EXECUTION_REQUIRED");
54
+ execution = { kind: "ipc", endpoint: options.endpoint };
55
+ }
14
56
  assertExtraName(options.module.name);
15
- assertRuntimeLogging(options.logging);
57
+ assertStartupLogging(options.logging, { component: options.module.name, phase: "created" });
16
58
  const name = options.module.name;
17
59
  const config = structuredClone(options.config);
18
60
  const module = { ...options.module };
19
61
  const pendingDependencies = new Set();
20
- const endpoint = options.endpoint;
62
+ const endpoint = execution.kind === "ipc" ? execution.endpoint : undefined;
63
+ const home = options.home;
21
64
  const controlEndpoint = options.controlEndpoint;
22
65
  const enabled = options.enabled !== false;
23
66
  const logging = options.logging && { ...options.logging };
24
- const key = `${process.platform === "win32" ? endpoint.toLowerCase() : resolve(endpoint)}\0${name}`;
67
+ let ownerships = owners;
68
+ if (execution.kind === "direct") {
69
+ ownerships = directOwners.get(execution.executor) ?? new Map();
70
+ directOwners.set(execution.executor, ownerships);
71
+ }
72
+ const key = endpoint === undefined
73
+ ? name
74
+ : `${process.platform === "win32" ? endpoint.toLowerCase() : resolve(endpoint)}\0${name}`;
25
75
  const owner = new AbortController();
26
76
  let dependenciesOpen = true;
27
77
  let shutdownUntil;
@@ -44,6 +94,7 @@ export function createExtraService(options) {
44
94
  let acquired = false;
45
95
  let phase = "created";
46
96
  let client;
97
+ let scope;
47
98
  let logs;
48
99
  let plugins;
49
100
  let starting;
@@ -61,11 +112,11 @@ export function createExtraService(options) {
61
112
  const kernelAvailable = () => {
62
113
  if (healthCheck)
63
114
  return healthCheck;
64
- healthCheck = (client?.status().then((value) => value.execution_ready, () => false) ?? Promise.resolve(false))
115
+ healthCheck = (scope?.available() ?? Promise.resolve(false))
65
116
  .then((available) => {
66
117
  if (!owner.signal.aborted && available !== lastAvailable) {
67
118
  lastAvailable = available;
68
- logState(available ? "kernel.available" : "kernel.unavailable", available ? "available" : "unavailable");
119
+ logState(`${execution.kind === "ipc" ? "kernel" : "execution"}.${available ? "available" : "unavailable"}`, available ? "available" : "unavailable");
69
120
  }
70
121
  return available;
71
122
  })
@@ -92,7 +143,8 @@ export function createExtraService(options) {
92
143
  phase,
93
144
  name,
94
145
  pid: process.pid,
95
- kernel_available: await kernelAvailable(),
146
+ execution: { kind: execution.kind, available: await kernelAvailable() },
147
+ ...(execution.kind === "ipc" ? { kernel_available: await kernelAvailable() } : {}),
96
148
  plugin: !enabled
97
149
  ? { phase: "disabled" }
98
150
  : phase === "ready" && plugins
@@ -100,9 +152,9 @@ export function createExtraService(options) {
100
152
  : { phase }
101
153
  });
102
154
  const drainRuns = async () => {
103
- if (!client)
155
+ if (!scope)
104
156
  return;
105
- const result = await client.invocations.drain({
157
+ const result = await scope.drain({
106
158
  deadline: (cleanupDeadline ??= Date.now() + 5000),
107
159
  reason: "extra_shutdown"
108
160
  });
@@ -112,7 +164,7 @@ export function createExtraService(options) {
112
164
  const beginDrain = (signal) => {
113
165
  shutdownUntil ??= shutdownDeadline(signal);
114
166
  cleanupDeadline ??= Date.now() + Math.max(0, Math.floor(shutdownUntil - performance.now()));
115
- client?.invocations.stopAdmission();
167
+ scope?.stopAdmission();
116
168
  // 回滚通知先于加载器等待 disposer;立即取消源调用,避免消费者与清理互相等待。
117
169
  if (!draining) {
118
170
  draining = drainRuns();
@@ -169,7 +221,7 @@ export function createExtraService(options) {
169
221
  server.close((error) => (error ? reject(error) : resolve()));
170
222
  });
171
223
  });
172
- client?.close();
224
+ await attempt("execution", () => scope?.release());
173
225
  if (!errors.length)
174
226
  await attempt("control-endpoint", async () => {
175
227
  if (!release)
@@ -183,8 +235,10 @@ export function createExtraService(options) {
183
235
  if (acquired) {
184
236
  if (errors.length)
185
237
  ownership.failed = true;
186
- else
187
- owners.delete(key);
238
+ else {
239
+ ownerships.delete(key);
240
+ ownerCount--;
241
+ }
188
242
  }
189
243
  phase = errors.length ? "failed" : "closed";
190
244
  const result = {
@@ -223,21 +277,59 @@ export function createExtraService(options) {
223
277
  signal?.addEventListener("abort", abort, { once: true });
224
278
  if (signal?.aborted)
225
279
  abort();
280
+ let startupContext = { resource: "extra", operation: "initialize" };
226
281
  starting = (async () => {
227
282
  owner.signal.throwIfAborted();
228
- const previous = owners.get(key);
283
+ const paths = [
284
+ ...(controlEndpoint && process.platform !== "win32"
285
+ ? [{ path: `${controlEndpoint}.owner.recovery`, resource: "endpoint-ownership" }]
286
+ : []),
287
+ ...(logging
288
+ ? [
289
+ {
290
+ path: resolve(logging.directory, "extras", `${name}-status-20000101T00.log.lock`),
291
+ resource: "extra-log",
292
+ optional: true
293
+ }
294
+ ]
295
+ : [])
296
+ ];
297
+ if (execution.kind === "ipc" || home !== undefined)
298
+ validateRuntimeHome(home, paths);
299
+ else {
300
+ // 没有隐式 Home;控制目录必须已由宿主准备,日志继续沿可选 best-effort 合同。
301
+ if (controlEndpoint && process.platform !== "win32")
302
+ validateRuntimeHome(dirname(controlEndpoint), paths);
303
+ else
304
+ for (const path of paths)
305
+ assertRuntimePath(path.path, path.resource);
306
+ }
307
+ if (endpoint !== undefined)
308
+ assertIpcEndpoint(endpoint);
309
+ if (controlEndpoint)
310
+ assertIpcEndpoint(controlEndpoint);
311
+ const previous = ownerships.get(key);
229
312
  if (previous)
230
313
  throw new Error(previous.failed ? "EXTRA_DISPOSE_FAILED" : "EXTRA_ALREADY_LOADED");
231
- if (owners.size >= 64)
314
+ if (ownerCount >= 64)
232
315
  throw new Error("EXTRA_CAPACITY_EXHAUSTED");
233
- owners.set(key, ownership);
316
+ ownerships.set(key, ownership);
317
+ ownerCount++;
234
318
  acquired = true;
235
- client = attachKernel({ endpoint });
319
+ if (execution.kind === "ipc") {
320
+ client = attachKernel({ endpoint: execution.endpoint });
321
+ scope = createIpcExecutionScope(client);
322
+ }
323
+ else {
324
+ if (!execution.executor.status().available)
325
+ throw new Error("EXECUTOR_CLOSED");
326
+ scope = createDirectExecutionScope(execution.executor);
327
+ }
236
328
  logs = new RuntimeLogging(logging);
237
329
  logState("service.initializing", phase);
238
330
  if (logging)
239
331
  watchKernel();
240
- plugins = new ExtraPlugins([], client, () => logs.extra(name));
332
+ plugins = new ExtraPlugins([], { execution: scope.context, ...(client ? { kernel: client } : {}) }, () => logs.extra(name));
241
333
  if (enabled)
242
334
  await plugins.load({
243
335
  ...module,
@@ -251,8 +343,13 @@ export function createExtraService(options) {
251
343
  }, config, dependencies);
252
344
  owner.signal.throwIfAborted();
253
345
  if (controlEndpoint) {
254
- if (process.platform !== "win32")
255
- await mkdir(dirname(controlEndpoint), { recursive: true, mode: 0o700 });
346
+ startupContext = {
347
+ resource: "extra-control",
348
+ endpoint: controlEndpoint,
349
+ operation: "listen"
350
+ };
351
+ if (process.platform !== "win32" && home !== undefined)
352
+ prepareHomeDirectory(home, dirname(controlEndpoint));
256
353
  owner.signal.throwIfAborted();
257
354
  release = await acquireEndpoint(controlEndpoint);
258
355
  owner.signal.throwIfAborted();
@@ -275,7 +372,7 @@ export function createExtraService(options) {
275
372
  const request = JSON.parse(line);
276
373
  if (request.method !== "status")
277
374
  throw new Error("METHOD_NOT_FOUND");
278
- void status().then((value) => socket.end(`${JSON.stringify({ jsonrpc: "2.0", id: request.id, result: { name, pid: process.pid, status: { ...value.plugin, kernel_available: value.kernel_available } } })}\n`), () => socket.destroy());
375
+ void status().then((value) => socket.end(`${JSON.stringify({ jsonrpc: "2.0", id: request.id, result: { name, pid: process.pid, status: { ...value.plugin, execution: value.execution, ...(value.kernel_available === undefined ? {} : { kernel_available: value.kernel_available }) } } })}\n`), () => socket.destroy());
279
376
  }
280
377
  catch {
281
378
  socket.destroy();
@@ -296,8 +393,19 @@ export function createExtraService(options) {
296
393
  })();
297
394
  initialized = Promise.race([starting, cancelled])
298
395
  .catch(async (error) => {
396
+ const io = error;
397
+ if (startupContext.resource === "extra-control" &&
398
+ ["ENOENT", "ENOTDIR", "EACCES", "EPERM", "EROFS", "ENAMETOOLONG"].includes(io?.code ?? ""))
399
+ error = runtimePathFailure(error, typeof io.path === "string" ? io.path : (controlEndpoint ?? home ?? ""), "extra-control", typeof io.syscall === "string" ? io.syscall : "listen");
299
400
  logState("service.failed", "failed", "SERVICE_INITIALIZATION_FAILED");
300
- throw new ServiceInitializationError(error, await close());
401
+ throw new ServiceInitializationError(error, await close(), {
402
+ component: name,
403
+ phase: "initializing",
404
+ context: {
405
+ endpoint: controlEndpoint ?? endpoint,
406
+ ...startupContext
407
+ }
408
+ });
301
409
  })
302
410
  .finally(() => {
303
411
  signal?.removeEventListener("abort", abort);
@@ -1,5 +1,7 @@
1
1
  import type { KernelClient } from "@mininglamp-oss/octo-runtime-executor-kernel";
2
2
  import { type RuntimeLog } from "@mininglamp-oss/octo-runtime-adapter-sdk";
3
+ import { type ExtraExecutionContext } from "./execution.js";
4
+ export type { ExtraExecution, ExtraExecutionContext } from "./execution.js";
3
5
  export type { ChannelDependencies, LoadContexts } from "./context-loader.js";
4
6
  export type { RuntimeLog, RuntimeLogLevel } from "@mininglamp-oss/octo-runtime-adapter-sdk";
5
7
  export type JsonValue = null | boolean | number | string | JsonValue[] | JsonObject;
@@ -12,7 +14,9 @@ export type ExtraStatusHandler = () => JsonObject;
12
14
  export interface ExtraContext {
13
15
  /** F31:.octospec/tasks/gateway-august-feature-assessment/assessment.md;无日志宿主也提供 no-op。 */
14
16
  readonly log: RuntimeLog;
15
- readonly kernel: KernelClient;
17
+ readonly execution: ExtraExecutionContext;
18
+ /** 仅 IPC 装配提供真实 client;旧插件使用前必须检查存在性。 */
19
+ readonly kernel?: KernelClient;
16
20
  readonly signal: AbortSignal;
17
21
  onDispose(dispose: ExtraDisposer): void;
18
22
  onStatus(handler: ExtraStatusHandler): void;
@@ -40,10 +44,13 @@ export declare function assertExtraName(name: unknown): asserts name is string;
40
44
  /** 每个声明名最多一个实例;只加载宿主选定的插件,并统一管理取消、状态和清理。 */
41
45
  export declare class ExtraPlugins {
42
46
  #private;
43
- private readonly kernel;
47
+ private readonly binding;
44
48
  private readonly logForExtra;
45
49
  static validate(registrations: readonly ExtraRegistration[]): void;
46
- constructor(registrations: readonly ExtraRegistration[], kernel: KernelClient, logForExtra?: (name: string) => RuntimeLog);
50
+ constructor(registrations: readonly ExtraRegistration[], binding: KernelClient | {
51
+ execution: ExtraExecutionContext;
52
+ kernel?: KernelClient;
53
+ }, logForExtra?: (name: string) => RuntimeLog);
47
54
  get status(): Record<string, ExtraStatus>;
48
55
  loadConfigured(): Promise<void>;
49
56
  inspect(name: string): Promise<JsonObject>;
@@ -1,13 +1,14 @@
1
1
  import { noopRuntimeLog } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
2
  import { abortForShutdown, shutdownDeadline, withinShutdown } from "./shutdown.js";
3
3
  import { snapshotExtraDependencies } from "./extra-dependencies.js";
4
+ import { ipcExecutionContext } from "./execution.js";
4
5
  export function assertExtraName(name) {
5
6
  if (typeof name !== "string" || !/^[a-z][a-z0-9-]{0,63}$/.test(name))
6
7
  throw new Error("EXTRA_NAME_INVALID");
7
8
  }
8
9
  /** 每个声明名最多一个实例;只加载宿主选定的插件,并统一管理取消、状态和清理。 */
9
10
  export class ExtraPlugins {
10
- kernel;
11
+ binding;
11
12
  logForExtra;
12
13
  #registrations = new Map();
13
14
  #instances = new Map();
@@ -31,8 +32,8 @@ export class ExtraPlugins {
31
32
  names.add(entry.name);
32
33
  }
33
34
  }
34
- constructor(registrations, kernel, logForExtra = () => noopRuntimeLog) {
35
- this.kernel = kernel;
35
+ constructor(registrations, binding, logForExtra = () => noopRuntimeLog) {
36
+ this.binding = binding;
36
37
  this.logForExtra = logForExtra;
37
38
  ExtraPlugins.validate(registrations);
38
39
  for (const registration of registrations) {
@@ -172,7 +173,9 @@ export class ExtraPlugins {
172
173
  assertStatusObject(registration.config);
173
174
  instance.controller.signal.throwIfAborted();
174
175
  const initialize = plugin.default({
175
- kernel: this.kernel,
176
+ ...("execution" in this.binding
177
+ ? this.binding
178
+ : { kernel: this.binding, execution: ipcExecutionContext(this.binding) }),
176
179
  log: (level, event, data) => {
177
180
  try {
178
181
  this.logForExtra(name)(level, event, data);
@@ -226,6 +229,17 @@ export class ExtraPlugins {
226
229
  });
227
230
  if (!instance.disposing && !instance.disposalError)
228
231
  this.#instances.delete(name);
232
+ if (cleanupFailed && instance.disposalError) {
233
+ // 回滚失败不能只留在加载器内部;聚合保留主失败与真实 disposer 链。
234
+ // 外层服务继续使用原 ServiceInitializationError/cleanup,主 message/code 保持兼容。
235
+ const failure = new AggregateError([error, instance.disposalError], error instanceof Error ? error.message : code, { cause: error });
236
+ const primaryCode = error instanceof Error
237
+ ? Object.getOwnPropertyDescriptor(error, "code")?.value
238
+ : undefined;
239
+ if (typeof primaryCode === "string")
240
+ Object.defineProperty(failure, "code", { value: primaryCode });
241
+ throw failure;
242
+ }
229
243
  throw error;
230
244
  }
231
245
  });
@@ -10,28 +10,27 @@ export interface HostHomePaths {
10
10
  pidFile: string;
11
11
  }
12
12
  export interface HostAccountPaths {
13
+ home: string;
13
14
  accountKey: string;
14
15
  root: string;
15
16
  configFile: string;
16
17
  logs: string;
17
18
  }
18
19
  export interface HostProfilePaths {
20
+ home: string;
19
21
  name: string;
20
22
  root: string;
21
23
  configFile: string;
22
24
  identityFile: string;
23
25
  credentialFile: string;
24
26
  }
25
- export declare function resolveHostHome(appId: string, options?: {
26
- platform?: NodeJS.Platform;
27
- env?: NodeJS.ProcessEnv;
28
- userHome?: string;
29
- }): string;
30
- export declare function hostHomePaths(homeInput: string, platform?: NodeJS.Platform): HostHomePaths;
27
+ /** 宿主先准备根;返回经过实际存在/权限与当前 endpoint 预算校验的 Home 路径,不创建身份。 */
28
+ export declare function hostHomePaths(homeInput: string): HostHomePaths;
31
29
  export declare function accountKeyFor(subjectType: string, subjectId: string): string;
32
30
  export declare function profileNameFor(appId: string, tenantId: string): string;
33
31
  export declare function accountPaths(paths: HostHomePaths, accountKey: string): HostAccountPaths;
34
32
  export declare function profilePaths(account: HostAccountPaths, name: string): HostProfilePaths;
33
+ /** 仅在宿主已存在的 Home 中创建 Runtime 子目录/身份;根不可用时失败,不自动修复根。 */
35
34
  export declare function ensureHostHome(paths: HostHomePaths): MachineIdentity;
36
35
  export declare function ensureAccount(account: HostAccountPaths, profiles: readonly string[]): void;
37
36
  export declare function readJson<T>(path: string): T;
@@ -1,31 +1,23 @@
1
1
  import { createHash, randomUUID } from "node:crypto";
2
2
  import { chmodSync, closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
3
- import { homedir } from "node:os";
4
- import { basename, dirname, isAbsolute, join, parse, resolve, win32 } from "node:path";
3
+ import { basename, dirname, join } from "node:path";
4
+ import { normalizeRuntimeHome, validateRuntimeHome, assertRuntimePath, prepareHomeDirectory } from "@mininglamp-oss/octo-runtime-executor-kernel";
5
5
  import { HostRuntimeError } from "./errors.js";
6
6
  import { componentEndpoint } from "./endpoint.js";
7
7
  const PROFILE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
8
8
  const MACHINE_PATTERN = /^machine_[0-9a-f-]{36}$/;
9
- export function resolveHostHome(appId, options = {}) {
10
- const slug = appSlug(appId);
11
- const platform = options.platform ?? process.platform;
12
- const env = options.env ?? process.env;
13
- const userHome = options.userHome ?? homedir();
14
- if (platform === "win32") {
15
- const localAppData = env.LOCALAPPDATA?.trim();
16
- if (!localAppData) {
17
- throw new HostRuntimeError("HOME_UNAVAILABLE", "home", false, "LOCALAPPDATA is required on Windows");
18
- }
19
- return win32.join(localAppData, slug, "OctoRuntime");
20
- }
21
- if (platform === "darwin")
22
- return join(userHome, "Library", "Application Support", slug, "octo-runtime");
23
- return join(env.XDG_STATE_HOME?.trim() || join(userHome, ".local", "state"), slug, "octo-runtime");
24
- }
25
- export function hostHomePaths(homeInput, platform = process.platform) {
26
- const home = validateHome(homeInput, platform);
9
+ /** 宿主先准备根;返回经过实际存在/权限与当前 endpoint 预算校验的 Home 路径,不创建身份。 */
10
+ export function hostHomePaths(homeInput) {
11
+ const home = normalizeRuntimeHome(homeInput);
27
12
  const run = join(home, "run");
28
- const socket = componentEndpoint(home, "executor-kernel", platform);
13
+ const socket = componentEndpoint(home, "executor-kernel");
14
+ validateRuntimeHome(home, [
15
+ { path: join(home, "octo-runtime-executor-kernel.pid"), resource: "kernel-pid" },
16
+ {
17
+ path: join(home, `.machine.json.${"0".repeat(10)}.${"0".repeat(36)}.tmp`),
18
+ resource: "machine-identity"
19
+ }
20
+ ]);
29
21
  return {
30
22
  home,
31
23
  machineFile: join(home, "machine.json"),
@@ -52,6 +44,7 @@ export function profileNameFor(appId, tenantId) {
52
44
  export function accountPaths(paths, accountKey) {
53
45
  const root = join(paths.home, "accounts", accountKey);
54
46
  return {
47
+ home: paths.home,
55
48
  accountKey,
56
49
  root,
57
50
  configFile: join(root, "config.json"),
@@ -62,7 +55,9 @@ export function profilePaths(account, name) {
62
55
  if (!PROFILE_PATTERN.test(name))
63
56
  throw new HostRuntimeError("PROFILE_INVALID", "home", false, `invalid profile: ${name}`);
64
57
  const root = join(account.root, name);
58
+ assertRuntimePath(join(root, "credentials", `.runtime-token.json.${"0".repeat(10)}.${"0".repeat(36)}.tmp`), "profile-credential");
65
59
  return {
60
+ home: account.home,
66
61
  name,
67
62
  root,
68
63
  configFile: join(root, "config.json"),
@@ -70,11 +65,16 @@ export function profilePaths(account, name) {
70
65
  credentialFile: join(root, "credentials", "runtime-token.json")
71
66
  };
72
67
  }
68
+ /** 仅在宿主已存在的 Home 中创建 Runtime 子目录/身份;根不可用时失败,不自动修复根。 */
73
69
  export function ensureHostHome(paths) {
74
- for (const directory of [paths.home, paths.run, join(paths.home, "accounts")])
75
- mkdirSync(directory, { recursive: true });
70
+ validateRuntimeHome(paths.home, [
71
+ { path: paths.machineFile, resource: "machine-identity" },
72
+ { path: paths.run, resource: "runtime-state" }
73
+ ]);
74
+ for (const directory of [paths.run, join(paths.home, "accounts")])
75
+ prepareHomeDirectory(paths.home, directory);
76
76
  if (process.platform !== "win32")
77
- mkdirSync(dirname(paths.socket), { recursive: true });
77
+ prepareHomeDirectory(paths.home, dirname(paths.socket));
78
78
  if (existsSync(paths.machineFile)) {
79
79
  const machine = readJson(paths.machineFile);
80
80
  if (machine.schema_version !== 1 || !MACHINE_PATTERN.test(machine.machine_id)) {
@@ -87,12 +87,15 @@ export function ensureHostHome(paths) {
87
87
  return machine;
88
88
  }
89
89
  export function ensureAccount(account, profiles) {
90
+ validateRuntimeHome(account.home, [
91
+ { path: account.configFile, resource: "account-configuration" }
92
+ ]);
90
93
  if (profiles.length === 0)
91
94
  throw new HostRuntimeError("TENANTS_EMPTY", "home", false, "at least one authorized tenant is required");
92
95
  for (const profile of profiles) {
93
96
  const paths = profilePaths(account, profile);
94
- mkdirSync(dirname(paths.identityFile), { recursive: true });
95
- mkdirSync(dirname(paths.credentialFile), { recursive: true });
97
+ prepareHomeDirectory(account.home, dirname(paths.identityFile));
98
+ prepareHomeDirectory(account.home, dirname(paths.credentialFile));
96
99
  }
97
100
  const existing = existsSync(account.configFile)
98
101
  ? readJson(account.configFile)
@@ -112,7 +115,8 @@ export function readJson(path) {
112
115
  }
113
116
  catch (error) {
114
117
  throw new HostRuntimeError("LOCAL_STATE_INVALID", "home", false, `cannot read ${path}`, {
115
- cause: error
118
+ cause: error,
119
+ context: { path, resource: "local-state", operation: "read" }
116
120
  });
117
121
  }
118
122
  }
@@ -122,8 +126,9 @@ export function readJsonOptional(path) {
122
126
  return readJson(path);
123
127
  }
124
128
  export function writeJsonAtomic(path, value, secret = false) {
125
- mkdirSync(dirname(path), { recursive: true });
126
129
  const temporary = join(dirname(path), `.${basename(path)}.${process.pid}.${randomUUID()}.tmp`);
130
+ assertRuntimePath(temporary, "runtime-state");
131
+ mkdirSync(dirname(path), { recursive: true });
127
132
  const fd = openSync(temporary, "wx", secret ? 0o600 : 0o644);
128
133
  try {
129
134
  writeFileSync(fd, `${JSON.stringify(value, null, 2)}\n`, "utf8");
@@ -141,23 +146,6 @@ export function writeJsonAtomic(path, value, secret = false) {
141
146
  export function removeFile(path) {
142
147
  rmSync(path, { force: true });
143
148
  }
144
- function validateHome(homeInput, platform) {
145
- const pathApi = platform === "win32" ? win32 : { isAbsolute, resolve, parse };
146
- if (!homeInput.trim() || !pathApi.isAbsolute(homeInput)) {
147
- throw new HostRuntimeError("HOME_INVALID", "home", false, "Embedded Runtime Home must be an absolute path");
148
- }
149
- const home = pathApi.resolve(homeInput);
150
- const root = pathApi.parse(home).root;
151
- if (home === root)
152
- throw new HostRuntimeError("HOME_INVALID", "home", false, "filesystem root cannot be used as Embedded Runtime Home");
153
- if (platform === "win32") {
154
- const input = homeInput.replaceAll("/", "\\");
155
- if (input.startsWith("\\\\") || input.startsWith("\\\\?\\") || /^[A-Za-z]:[^\\]/.test(input)) {
156
- throw new HostRuntimeError("HOME_UNSUPPORTED", "home", false, "Windows Embedded Runtime Home must be a local absolute path");
157
- }
158
- }
159
- return home;
160
- }
161
149
  function appSlug(appId) {
162
150
  const normalized = appId
163
151
  .trim()
@@ -1,6 +1,12 @@
1
1
  import { randomUUID } from "node:crypto";
2
+ import { validateRuntimeHome } from "@mininglamp-oss/octo-runtime-executor-kernel";
2
3
  import { readJsonOptional, writeJsonAtomic } from "./home.js";
3
4
  export function ensureLocalRuntime(profile, tenant) {
5
+ // 路径对象可能来自先前读取;写身份前重新确认根,不能递归补建已经消失的 Home。
6
+ validateRuntimeHome(profile.home, [
7
+ { path: profile.identityFile, resource: "runtime-identity" },
8
+ { path: profile.configFile, resource: "profile-configuration" }
9
+ ]);
4
10
  const saved = readJsonOptional(profile.identityFile);
5
11
  if (saved &&
6
12
  (saved.schema_version !== 1 ||
@@ -4,7 +4,11 @@ export * from "./extras.js";
4
4
  export * from "./extra-config.js";
5
5
  export * from "./context-loader.js";
6
6
  export * from "./extra-service.js";
7
+ export type { ExtraExecution, ExtraExecutionContext } from "./execution.js";
7
8
  export * from "./endpoint.js";
8
9
  export * from "./home.js";
9
10
  export * from "./identity.js";
10
11
  export * from "./extra-commands.js";
12
+ export { RuntimeHomeError, normalizeRuntimeHome, validateRuntimeHome, assertRuntimePath, assertIpcEndpoint, runtimePathFailure, type StartupPathDiagnostic } from "@mininglamp-oss/octo-runtime-executor-kernel";
13
+ export { HostRuntimeError } from "./errors.js";
14
+ export { STARTUP_CATALOG, describeStartupError, formatStartupDiagnostic, StartupError, type StartupDiagnostic, type StartupContext, type StartupLocation, type StartupCause } from "@mininglamp-oss/octo-runtime-executor-kernel";
@@ -7,3 +7,6 @@ export * from "./endpoint.js";
7
7
  export * from "./home.js";
8
8
  export * from "./identity.js";
9
9
  export * from "./extra-commands.js";
10
+ export { RuntimeHomeError, normalizeRuntimeHome, validateRuntimeHome, assertRuntimePath, assertIpcEndpoint, runtimePathFailure } from "@mininglamp-oss/octo-runtime-executor-kernel";
11
+ export { HostRuntimeError } from "./errors.js";
12
+ export { STARTUP_CATALOG, describeStartupError, formatStartupDiagnostic, StartupError } from "@mininglamp-oss/octo-runtime-executor-kernel";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-host-sdk",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -23,9 +23,10 @@
23
23
  }
24
24
  },
25
25
  "dependencies": {
26
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.9",
27
- "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.9",
28
- "@mininglamp-oss/octo-runtime-protocol": "1.1.9"
26
+ "@mininglamp-oss/octo-runtime-executor-core": "1.1.11",
27
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.11",
28
+ "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.11",
29
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.11"
29
30
  },
30
31
  "types": "./dist/index.d.ts",
31
32
  "files": [
@@ -0,0 +1,7 @@
1
+ import type { AdapterProtocolSupport } from "./run-protocol.js";
2
+ import type { HostedAdapterMetadataWire } from "./generated/protocol-types.js";
3
+ /** 宿主注册及执行时使用的完整元数据;编写时的可选默认值须由 Adapter 工厂先补齐。 */
4
+ export type HostedAdapterMetadata = Pick<HostedAdapterMetadataWire, "workspace" | "type" | "agentSources" | "processModel" | "transport" | "providerVersion" | "providerPath" | "available" | "unavailableReason"> & {
5
+ /** wire 可省略的编写输入不能放宽 Core 注册合同。 */
6
+ protocolSupport: AdapterProtocolSupport;
7
+ };
@@ -595,6 +595,21 @@ export interface ExecutionEvidence {
595
595
  reason?: "provider_unsupported" | "adapter_unmapped" | "provider_unconfirmed";
596
596
  };
597
597
  }
598
+ /**
599
+ * This interface was referenced by `OctoRuntimeProtocolSchema`'s JSON-Schema
600
+ * via the `definition` "ServiceProcessSnapshot".
601
+ */
602
+ export interface ServiceProcessSnapshot {
603
+ scope_id: string;
604
+ service_id: string;
605
+ incarnation: number;
606
+ provider: string;
607
+ owner_pid: number;
608
+ pid?: number;
609
+ state: "not_started" | "starting" | "ready" | "recovering" | "degraded" | "closing" | "closed" | "cleanup_incomplete";
610
+ observation: "alive" | "exited" | "unknown";
611
+ ownership: "owned";
612
+ }
598
613
  /**
599
614
  * This interface was referenced by `OctoRuntimeProtocolSchema`'s JSON-Schema
600
615
  * via the `definition` "KernelStatus".
@@ -604,21 +619,10 @@ export interface KernelStatus {
604
619
  kernel_instance_id: string;
605
620
  pid: number;
606
621
  execution_ready: boolean;
607
- worker: {
608
- pid?: number;
609
- generation: number;
610
- restart_attempt: number;
611
- recovery?: {
612
- trigger: "exit" | "error" | "heartbeat" | "ipc";
613
- stage: "cleanup" | "manifest" | "starting" | "backoff";
614
- code: string;
615
- occurred_at: string;
616
- retry_at?: string;
617
- exit_code?: number;
618
- signal?: string;
619
- };
620
- state: "starting" | "ready" | "recovering" | "stopped" | "exhausted";
621
- };
622
+ /**
623
+ * @maxItems 256
624
+ */
625
+ service_processes?: ServiceProcessSnapshot[];
622
626
  }
623
627
  /**
624
628
  * This interface was referenced by `OctoRuntimeProtocolSchema`'s JSON-Schema