@abot-ai/runtime 1.6.0 → 1.7.0

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 (380) hide show
  1. package/README.md +2 -0
  2. package/dist/src/bridge/request-steering.js +60 -15
  3. package/dist/src/capabilities/normal-invocation/contracts.d.ts +3 -0
  4. package/dist/src/capabilities/normal-invocation/output-channels.d.ts +10 -0
  5. package/dist/src/capabilities/normal-invocation/output-channels.js +29 -0
  6. package/dist/src/capabilities/normal-invocation/validator.js +4 -2
  7. package/dist/src/capabilities/tool-types.d.ts +1 -1
  8. package/dist/src/cli/host-companion-bundle.mjs +7570 -6781
  9. package/dist/src/cli/host-companion-entry.js +5 -22
  10. package/dist/src/cli/host-companion-input.d.ts +3 -0
  11. package/dist/src/cli/host-companion-input.js +21 -0
  12. package/dist/src/cli/host-companion-lifecycle.d.ts +11 -0
  13. package/dist/src/cli/host-companion-lifecycle.js +32 -0
  14. package/dist/src/cli/host-companion-setup-target.d.ts +4 -0
  15. package/dist/src/cli/host-companion-setup-target.js +17 -0
  16. package/dist/src/cli/host-companion-startup.d.ts +2 -0
  17. package/dist/src/cli/host-companion-startup.js +7 -2
  18. package/dist/src/cli/host-companion.d.ts +6 -0
  19. package/dist/src/cli/host-companion.js +30 -27
  20. package/dist/src/cli/windows-companion-store-entry.d.ts +9 -0
  21. package/dist/src/cli/windows-companion-store-entry.js +67 -0
  22. package/dist/src/computer-access/command-output-capture.d.ts +37 -0
  23. package/dist/src/computer-access/command-output-capture.js +136 -0
  24. package/dist/src/computer-access/command-output-retention.d.ts +5 -0
  25. package/dist/src/computer-access/command-output-retention.js +90 -0
  26. package/dist/src/computer-access/command-output.d.ts +7 -0
  27. package/dist/src/computer-access/command-output.js +1 -0
  28. package/dist/src/computer-access/commands.d.ts +1 -0
  29. package/dist/src/computer-access/commands.js +1 -1
  30. package/dist/src/computer-access/companion/command-output-protocol.d.ts +12 -0
  31. package/dist/src/computer-access/companion/command-output-protocol.js +28 -0
  32. package/dist/src/computer-access/companion/command-output.d.ts +13 -0
  33. package/dist/src/computer-access/companion/command-output.js +110 -0
  34. package/dist/src/computer-access/companion/install-link-macos.d.ts +7 -0
  35. package/dist/src/computer-access/companion/install-link-macos.js +48 -0
  36. package/dist/src/computer-access/companion/install-link-registration.d.ts +4 -0
  37. package/dist/src/computer-access/companion/install-link-registration.js +184 -0
  38. package/dist/src/computer-access/companion/install-link-windows.d.ts +4 -0
  39. package/dist/src/computer-access/companion/install-link-windows.js +65 -0
  40. package/dist/src/computer-access/companion/install-link.d.ts +9 -0
  41. package/dist/src/computer-access/companion/install-link.js +54 -0
  42. package/dist/src/computer-access/companion/native-messages.js +3 -0
  43. package/dist/src/computer-access/companion/native-session.d.ts +1 -0
  44. package/dist/src/computer-access/companion/native-session.js +14 -2
  45. package/dist/src/computer-access/companion/native-supervisor.js +1 -0
  46. package/dist/src/computer-access/companion/notification-windows.d.ts +1 -1
  47. package/dist/src/computer-access/companion/notification-windows.js +8 -3
  48. package/dist/src/computer-access/companion/protocol.d.ts +1 -1
  49. package/dist/src/computer-access/companion/protocol.js +6 -0
  50. package/dist/src/computer-access/companion/release-version.d.ts +1 -1
  51. package/dist/src/computer-access/companion/release-version.js +1 -1
  52. package/dist/src/computer-access/companion/windows-store/connection-error.d.ts +7 -0
  53. package/dist/src/computer-access/companion/windows-store/connection-error.js +19 -0
  54. package/dist/src/computer-access/companion/windows-store/connection-link.d.ts +13 -0
  55. package/dist/src/computer-access/companion/windows-store/connection-link.js +109 -0
  56. package/dist/src/computer-access/companion/windows-store/identity.d.ts +13 -0
  57. package/dist/src/computer-access/companion/windows-store/identity.js +13 -0
  58. package/dist/src/computer-access/companion/windows-store/lifecycle.d.ts +5 -0
  59. package/dist/src/computer-access/companion/windows-store/lifecycle.js +90 -0
  60. package/dist/src/computer-access/contracts.d.ts +1 -1
  61. package/dist/src/computer-access/handlers.d.ts +2 -1
  62. package/dist/src/computer-access/handlers.js +5 -1
  63. package/dist/src/computer-access/process-capture.d.ts +6 -0
  64. package/dist/src/computer-access/process-capture.js +1 -0
  65. package/dist/src/computer-access/process-result.d.ts +2 -0
  66. package/dist/src/computer-access/process-result.js +14 -6
  67. package/dist/src/computer-access/process-runner.d.ts +2 -1
  68. package/dist/src/computer-access/process-runner.js +21 -13
  69. package/dist/src/model-gateway/server/configuration.d.ts +2 -0
  70. package/dist/src/model-gateway/server/configuration.js +73 -21
  71. package/dist/src/plugin-contract/install-source.d.ts +13 -0
  72. package/dist/src/plugin-contract/install-source.js +99 -0
  73. package/dist/src/plugin-contract/manifest.d.ts +2 -1
  74. package/dist/src/plugin-sdk/computer-access.d.ts +8 -0
  75. package/dist/src/plugin-sdk/computer-access.js +5 -0
  76. package/dist/src/runtime/adapters/in-memory-session-store.js +6 -16
  77. package/dist/src/runtime/admin/config-control.js +2 -1
  78. package/dist/src/runtime/automations/catalog.d.ts +3 -0
  79. package/dist/src/runtime/automations/catalog.js +1 -0
  80. package/dist/src/runtime/automations/model-dependency-projection.d.ts +2 -0
  81. package/dist/src/runtime/automations/service.d.ts +2 -0
  82. package/dist/src/runtime/capabilities/automation-builder/authoring-reference.d.ts +10 -5
  83. package/dist/src/runtime/capabilities/automation-builder/authoring-reference.js +8 -7
  84. package/dist/src/runtime/capabilities/automation-builder/payload-instructions.d.ts +2 -2
  85. package/dist/src/runtime/capabilities/automation-builder/payload-instructions.js +2 -2
  86. package/dist/src/runtime/capabilities/automation-builder/tool-contract.d.ts +2 -2
  87. package/dist/src/runtime/capabilities/automations/authoring-catalog.js +1 -1
  88. package/dist/src/runtime/capabilities/automations/authoring-preparation.d.ts +11 -5
  89. package/dist/src/runtime/capabilities/automations/tool-module.js +1 -1
  90. package/dist/src/runtime/capabilities/request-permission-catalog.d.ts +3 -1
  91. package/dist/src/runtime/capabilities/request-permission-catalog.js +21 -2
  92. package/dist/src/runtime/capabilities/request-permission-tool-registry.d.ts +2 -1
  93. package/dist/src/runtime/capabilities/request-permission-tool-registry.js +18 -10
  94. package/dist/src/runtime/capabilities/request-runtime-tool-registry.d.ts +2 -0
  95. package/dist/src/runtime/capabilities/request-runtime-tool-registry.js +1 -1
  96. package/dist/src/runtime/capabilities/scheduling/create-operations.d.ts +6 -0
  97. package/dist/src/runtime/config/builders.js +6 -5
  98. package/dist/src/runtime/config/effective-model-config-validation.js +4 -35
  99. package/dist/src/runtime/config/fields.js +15 -0
  100. package/dist/src/runtime/config/model-context-capacity.d.ts +20 -0
  101. package/dist/src/runtime/config/model-context-capacity.js +55 -0
  102. package/dist/src/runtime/config/model-execution-policy.d.ts +5 -1
  103. package/dist/src/runtime/config/model-execution-policy.js +16 -0
  104. package/dist/src/runtime/config/model-plugin-config.d.ts +8 -0
  105. package/dist/src/runtime/config/model-plugin-config.js +40 -0
  106. package/dist/src/runtime/config/schema.js +5 -1
  107. package/dist/src/runtime/config/validation/model-profile-validation.js +2 -0
  108. package/dist/src/runtime/config/validation/runtime-config-validation-contract.d.ts +3 -1
  109. package/dist/src/runtime/config/validation/runtime-config-validation-contract.js +3 -1
  110. package/dist/src/runtime/config/validation/runtime-root-section-validation.js +11 -4
  111. package/dist/src/runtime/config/validation/web-ui-config-validation.js +3 -2
  112. package/dist/src/runtime/config/web-ui.d.ts +5 -0
  113. package/dist/src/runtime/config/web-ui.js +5 -0
  114. package/dist/src/runtime/config.js +2 -0
  115. package/dist/src/runtime/local-application.d.ts +2 -0
  116. package/dist/src/runtime/local-host/app-owner.js +50 -6
  117. package/dist/src/runtime/local-host/app-request-control.d.ts +3 -1
  118. package/dist/src/runtime/local-host/app-request-control.js +91 -11
  119. package/dist/src/runtime/local-host/client-requests.js +32 -5
  120. package/dist/src/runtime/local-host/client-services.d.ts +2 -0
  121. package/dist/src/runtime/local-host/local-request-diagnostics.d.ts +9 -0
  122. package/dist/src/runtime/local-host/local-request-diagnostics.js +47 -0
  123. package/dist/src/runtime/local-host/saved-approvals.js +23 -2
  124. package/dist/src/runtime/model/model-selection.js +4 -1
  125. package/dist/src/runtime/observability/request-control-diagnostics.d.ts +6 -0
  126. package/dist/src/runtime/observability/request-control-diagnostics.js +52 -0
  127. package/dist/src/runtime/plugins/configuration-context.d.ts +9 -0
  128. package/dist/src/runtime/plugins/configuration-context.js +42 -0
  129. package/dist/src/runtime/plugins/configuration-settings.d.ts +2 -0
  130. package/dist/src/runtime/plugins/configuration-settings.js +26 -0
  131. package/dist/src/runtime/plugins/configuration-store.d.ts +23 -0
  132. package/dist/src/runtime/plugins/configuration-store.js +100 -0
  133. package/dist/src/runtime/plugins/configuration-write.d.ts +5 -0
  134. package/dist/src/runtime/plugins/configuration-write.js +58 -0
  135. package/dist/src/runtime/plugins/installation/archive.d.ts +2 -0
  136. package/dist/src/runtime/plugins/installation/archive.js +107 -0
  137. package/dist/src/runtime/plugins/installation/github-download.d.ts +9 -0
  138. package/dist/src/runtime/plugins/installation/github-download.js +72 -0
  139. package/dist/src/runtime/plugins/installation/installed-package.d.ts +9 -0
  140. package/dist/src/runtime/plugins/installation/installed-package.js +66 -0
  141. package/dist/src/runtime/plugins/installation/package.d.ts +45 -0
  142. package/dist/src/runtime/plugins/installation/package.js +79 -0
  143. package/dist/src/runtime/plugins/installation/portable-path.d.ts +2 -0
  144. package/dist/src/runtime/plugins/installation/portable-path.js +10 -0
  145. package/dist/src/runtime/plugins/installation/publication.d.ts +10 -0
  146. package/dist/src/runtime/plugins/installation/publication.js +17 -0
  147. package/dist/src/runtime/plugins/installation/service.d.ts +41 -0
  148. package/dist/src/runtime/plugins/installation/service.js +80 -0
  149. package/dist/src/runtime/plugins/loader.js +15 -29
  150. package/dist/src/runtime/plugins/manifest-projection.js +1 -0
  151. package/dist/src/runtime/plugins/manifest-validator.js +3 -0
  152. package/dist/src/runtime/plugins/module-cache.d.ts +2 -0
  153. package/dist/src/runtime/plugins/module-cache.js +19 -0
  154. package/dist/src/runtime/plugins/selection.d.ts +2 -0
  155. package/dist/src/runtime/plugins/selection.js +16 -11
  156. package/dist/src/runtime/ports.d.ts +6 -4
  157. package/dist/src/runtime/request/dependencies.d.ts +2 -1
  158. package/dist/src/runtime/request/execution-payload-compacted-evidence.d.ts +1 -1
  159. package/dist/src/runtime/request/handler.js +8 -0
  160. package/dist/src/runtime/request/prepared-execution.js +6 -1
  161. package/dist/src/runtime/request/request-steering.d.ts +4 -0
  162. package/dist/src/runtime/request/request-steering.js +37 -12
  163. package/dist/src/runtime/request/worker-capability-composition.d.ts +2 -0
  164. package/dist/src/runtime/request/worker-capability-composition.js +4 -1
  165. package/dist/src/runtime/scheduler/journal-index-state.d.ts +1 -1
  166. package/dist/src/sessions/assistant-initiative-message.d.ts +3 -0
  167. package/dist/src/sessions/assistant-initiative-message.js +12 -0
  168. package/dist/src/sessions/assistant-initiative.d.ts +2 -2
  169. package/dist/src/sessions/assistant-initiative.js +1 -7
  170. package/dist/src/sessions/durable-session-commit.d.ts +2 -1
  171. package/dist/src/sessions/durable-session-commit.js +6 -1
  172. package/dist/src/sessions/metadata/projection.d.ts +15 -0
  173. package/dist/src/sessions/metadata/projection.js +55 -0
  174. package/dist/src/sessions/metadata/publication.d.ts +12 -0
  175. package/dist/src/sessions/metadata/publication.js +78 -0
  176. package/dist/src/sessions/metadata/source-receipt.d.ts +5 -0
  177. package/dist/src/sessions/metadata/source-receipt.js +42 -0
  178. package/dist/src/sessions/metadata/store.d.ts +7 -0
  179. package/dist/src/sessions/metadata/store.js +119 -0
  180. package/dist/src/sessions/record/projection.d.ts +3 -1
  181. package/dist/src/sessions/record/projection.js +26 -18
  182. package/dist/src/sessions/request-lifecycle/service.js +3 -3
  183. package/dist/src/sessions/session-service.d.ts +2 -4
  184. package/dist/src/sessions/session-service.js +4 -16
  185. package/dist/src/sessions/session-store.d.ts +2 -1
  186. package/dist/src/sessions/session-store.js +9 -3
  187. package/dist/src/sessions/snapshot.d.ts +17 -0
  188. package/dist/src/sessions/snapshot.js +105 -0
  189. package/dist/src/sessions/types.d.ts +2 -0
  190. package/dist/src/shared/tool-selection.d.ts +2 -0
  191. package/dist/src/shared/tool-selection.js +7 -0
  192. package/dist/src/web-ui/app/ARCHITECTURE.md +14 -0
  193. package/dist/src/web-ui/app/app.js +6 -3
  194. package/dist/src/web-ui/app/components/config-workspace/config-model.js +2 -0
  195. package/dist/src/web-ui/app/components/config-workspace/model-plugin-permissions.js +130 -0
  196. package/dist/src/web-ui/app/components/config-workspace/model-plugin-selection.js +180 -0
  197. package/dist/src/web-ui/app/components/config-workspace/model-plugin-view-state.js +114 -0
  198. package/dist/src/web-ui/app/components/config-workspace/model-rendering.js +3 -0
  199. package/dist/src/web-ui/app/components/config-workspace/model-summary.js +39 -0
  200. package/dist/src/web-ui/app/components/config-workspace/summary-rendering.js +30 -0
  201. package/dist/src/web-ui/app/components/config-workspace/workspace-events.js +37 -0
  202. package/dist/src/web-ui/app/components/config-workspace/workspace-mutations.js +2 -0
  203. package/dist/src/web-ui/app/components/config-workspace/workspace-persistence.js +9 -1
  204. package/dist/src/web-ui/app/components/config-workspace/workspace-view.js +23 -67
  205. package/dist/src/web-ui/app/components/config-workspace.js +11 -2
  206. package/dist/src/web-ui/app/components/conversation-view.js +36 -5
  207. package/dist/src/web-ui/app/components/dashboard/recent-conversations.js +2 -1
  208. package/dist/src/web-ui/app/components/dashboard/workspace.js +2 -1
  209. package/dist/src/web-ui/app/components/operations-summary.js +105 -0
  210. package/dist/src/web-ui/app/components/passive-learning/home.js +1 -9
  211. package/dist/src/web-ui/app/components/plugins/configuration-draft.js +34 -0
  212. package/dist/src/web-ui/app/components/plugins/configuration-editor.js +147 -0
  213. package/dist/src/web-ui/app/components/plugins/configuration-fields.js +103 -0
  214. package/dist/src/web-ui/app/components/plugins/configuration-retained-secrets.js +20 -0
  215. package/dist/src/web-ui/app/components/plugins/configuration-settings.js +108 -0
  216. package/dist/src/web-ui/app/components/plugins/discovery-rendering.js +37 -0
  217. package/dist/src/web-ui/app/components/plugins/installation.js +212 -0
  218. package/dist/src/web-ui/app/components/plugins/manager.js +160 -6
  219. package/dist/src/web-ui/app/components/plugins/removal.js +130 -0
  220. package/dist/src/web-ui/app/components/plugins/rendering.js +14 -2
  221. package/dist/src/web-ui/app/components/plugins/summary.js +54 -0
  222. package/dist/src/web-ui/app/components/plugins/tabs.js +31 -0
  223. package/dist/src/web-ui/app/components/plugins/view-state.js +3 -1
  224. package/dist/src/web-ui/app/components/runtime-setup/connection-form.js +5 -2
  225. package/dist/src/web-ui/app/components/runtime-setup/connection-state.js +9 -1
  226. package/dist/src/web-ui/app/components/runtime-setup/context-window-feedback.js +71 -0
  227. package/dist/src/web-ui/app/components/runtime-setup/optional-steps.js +2 -0
  228. package/dist/src/web-ui/app/components/runtime-setup-guide.js +15 -3
  229. package/dist/src/web-ui/app/components/spark-chat/empty-state.js +1 -0
  230. package/dist/src/web-ui/app/components/spark-chat/panel.js +1 -0
  231. package/dist/src/web-ui/app/components/system-host/connection-card.js +35 -0
  232. package/dist/src/web-ui/app/components/system-host/macos-setup.js +1 -1
  233. package/dist/src/web-ui/app/components/system-host/manager.js +45 -12
  234. package/dist/src/web-ui/app/components/system-host/rendering.js +111 -106
  235. package/dist/src/web-ui/app/components/system-host/windows-store-setup.js +293 -0
  236. package/dist/src/web-ui/app/components/workspace-shell.js +6 -0
  237. package/dist/src/web-ui/app/computer-access-feature.js +22 -5
  238. package/dist/src/web-ui/app/configuration-feature.js +35 -2
  239. package/dist/src/web-ui/app/controllers/app-event-bindings.js +4 -1
  240. package/dist/src/web-ui/app/controllers/conversation-read-state-controller.d.ts +1 -0
  241. package/dist/src/web-ui/app/controllers/conversation-read-state-controller.js +7 -3
  242. package/dist/src/web-ui/app/controllers/conversation-request-hydration.js +88 -0
  243. package/dist/src/web-ui/app/controllers/conversation-session-controller.d.ts +9 -3
  244. package/dist/src/web-ui/app/controllers/conversation-session-controller.js +52 -144
  245. package/dist/src/web-ui/app/controllers/history-pagination.js +111 -0
  246. package/dist/src/web-ui/app/controllers/operations-controller.d.ts +12 -0
  247. package/dist/src/web-ui/app/controllers/operations-controller.js +28 -21
  248. package/dist/src/web-ui/app/controllers/runtime-onboarding-controller.d.ts +1 -0
  249. package/dist/src/web-ui/app/controllers/runtime-onboarding-controller.js +11 -0
  250. package/dist/src/web-ui/app/controllers/session-controller.js +10 -2
  251. package/dist/src/web-ui/app/controllers/session-list-pagination.js +71 -0
  252. package/dist/src/web-ui/app/controllers/session-sidebar-controller.js +6 -4
  253. package/dist/src/web-ui/app/controllers/spark-chat-reading.js +1 -0
  254. package/dist/src/web-ui/app/controllers/spark-chat-sync.js +24 -5
  255. package/dist/src/web-ui/app/controllers/workspace-route-controller.js +21 -19
  256. package/dist/src/web-ui/app/dashboard-feature.js +2 -2
  257. package/dist/src/web-ui/app/index.html +6 -2
  258. package/dist/src/web-ui/app/lib/history-page-messages.js +49 -0
  259. package/dist/src/web-ui/app/lib/request-lifecycle-view.js +8 -0
  260. package/dist/src/web-ui/app/lib/workspace-route.d.ts +3 -0
  261. package/dist/src/web-ui/app/lib/workspace-route.js +4 -0
  262. package/dist/src/web-ui/app/passive-learning-feature.js +0 -1
  263. package/dist/src/web-ui/app/runtime-onboarding-feature.js +3 -0
  264. package/dist/src/web-ui/app/schedules-feature.js +1 -1
  265. package/dist/src/web-ui/app/services/runtime-web-client/configuration.js +20 -0
  266. package/dist/src/web-ui/app/services/runtime-web-client/plugin-configuration.js +19 -0
  267. package/dist/src/web-ui/app/services/runtime-web-client/spark-chat.js +4 -4
  268. package/dist/src/web-ui/app/services/runtime-web-client/system-host.js +2 -0
  269. package/dist/src/web-ui/app/services/runtime-web-client.d.ts +6 -1
  270. package/dist/src/web-ui/app/services/runtime-web-client.js +12 -3
  271. package/dist/src/web-ui/app/spark-chat-feature.js +76 -19
  272. package/dist/src/web-ui/app/styles/11-product-links.css +30 -0
  273. package/dist/src/web-ui/app/styles/41-plugin-configuration.css +79 -0
  274. package/dist/src/web-ui/app/styles/41-plugin-discovery.css +132 -0
  275. package/dist/src/web-ui/app/styles/41-plugin-management.css +6 -0
  276. package/dist/src/web-ui/app/styles/42-model-plugin-permissions.css +173 -0
  277. package/dist/src/web-ui/app/styles/46-system-host.css +61 -107
  278. package/dist/src/web-ui/app/styles/47-config-controls.css +13 -1
  279. package/dist/src/web-ui/app/styles/54-spark-chat.css +33 -1
  280. package/dist/src/web-ui/app/styles.css +4 -0
  281. package/dist/src/web-ui/local-runtime/api-router.js +11 -6
  282. package/dist/src/web-ui/local-runtime/approval-request-attachment.js +14 -5
  283. package/dist/src/web-ui/local-runtime/configuration-activation-source.d.ts +1 -1
  284. package/dist/src/web-ui/local-runtime/configuration-activation-source.js +9 -3
  285. package/dist/src/web-ui/local-runtime/contracts.d.ts +4 -3
  286. package/dist/src/web-ui/local-runtime/environment-registry.d.ts +5 -1
  287. package/dist/src/web-ui/local-runtime/environment-registry.js +53 -11
  288. package/dist/src/web-ui/local-runtime/history-pagination.d.ts +16 -0
  289. package/dist/src/web-ui/local-runtime/history-pagination.js +20 -0
  290. package/dist/src/web-ui/local-runtime/plugin-configuration-routes.d.ts +16 -0
  291. package/dist/src/web-ui/local-runtime/plugin-configuration-routes.js +68 -0
  292. package/dist/src/web-ui/local-runtime/plugin-installation-routes.d.ts +16 -0
  293. package/dist/src/web-ui/local-runtime/plugin-installation-routes.js +96 -0
  294. package/dist/src/web-ui/local-runtime/plugin-management-routes.d.ts +8 -1
  295. package/dist/src/web-ui/local-runtime/plugin-management-routes.js +17 -0
  296. package/dist/src/web-ui/local-runtime/plugin-mutation-admission.d.ts +7 -0
  297. package/dist/src/web-ui/local-runtime/plugin-mutation-admission.js +17 -0
  298. package/dist/src/web-ui/local-runtime/plugin-removal-routes.d.ts +18 -0
  299. package/dist/src/web-ui/local-runtime/plugin-removal-routes.js +60 -0
  300. package/dist/src/web-ui/local-runtime/realtime-controller.js +41 -2
  301. package/dist/src/web-ui/local-runtime/request-cancellation-route.js +28 -1
  302. package/dist/src/web-ui/local-runtime/request-control-observation.d.ts +19 -0
  303. package/dist/src/web-ui/local-runtime/request-control-observation.js +80 -0
  304. package/dist/src/web-ui/local-runtime/request-execution.js +69 -37
  305. package/dist/src/web-ui/local-runtime/runtime-setup-context-window.d.ts +20 -0
  306. package/dist/src/web-ui/local-runtime/runtime-setup-context-window.js +44 -0
  307. package/dist/src/web-ui/local-runtime/runtime-setup-routes.js +2 -0
  308. package/dist/src/web-ui/local-runtime/runtime-setup-validation.js +9 -2
  309. package/dist/src/web-ui/local-runtime/session-routes.d.ts +1 -0
  310. package/dist/src/web-ui/local-runtime/session-routes.js +16 -4
  311. package/dist/src/web-ui/local-runtime/spark-chat-routes.js +4 -3
  312. package/dist/src/web-ui/plugin-capability-selection.js +4 -1
  313. package/dist/src/web-ui/plugin-configuration-input.d.ts +12 -0
  314. package/dist/src/web-ui/plugin-configuration-input.js +68 -0
  315. package/dist/src/web-ui/plugin-configuration-retained-secrets.d.ts +9 -0
  316. package/dist/src/web-ui/plugin-configuration-retained-secrets.js +48 -0
  317. package/dist/src/web-ui/plugin-configuration-service.d.ts +52 -0
  318. package/dist/src/web-ui/plugin-configuration-service.js +66 -0
  319. package/dist/src/web-ui/plugin-configuration-view.d.ts +25 -0
  320. package/dist/src/web-ui/plugin-configuration-view.js +45 -0
  321. package/dist/src/web-ui/plugin-disabled-selection.d.ts +7 -0
  322. package/dist/src/web-ui/plugin-disabled-selection.js +17 -0
  323. package/dist/src/web-ui/plugin-management-catalog.d.ts +3 -1
  324. package/dist/src/web-ui/plugin-management-catalog.js +11 -1
  325. package/dist/src/web-ui/plugin-management-selection.js +22 -9
  326. package/dist/src/web-ui/plugin-management-service.d.ts +5 -1
  327. package/dist/src/web-ui/plugin-management-service.js +11 -7
  328. package/dist/src/web-ui/plugin-removal-error.d.ts +7 -0
  329. package/dist/src/web-ui/plugin-removal-error.js +16 -0
  330. package/dist/src/web-ui/plugin-removal-service.d.ts +30 -0
  331. package/dist/src/web-ui/plugin-removal-service.js +109 -0
  332. package/dist/src/web-ui/runtime-setup-gateway.d.ts +6 -2
  333. package/dist/src/web-ui/runtime-setup-gateway.js +30 -10
  334. package/dist/src/web-ui/server.js +6 -2
  335. package/dist/src/web-ui/session-read-state/overview.d.ts +42 -0
  336. package/dist/src/web-ui/session-read-state/overview.js +16 -0
  337. package/dist/src/web-ui/session-read-state/pagination.d.ts +15 -0
  338. package/dist/src/web-ui/session-read-state/pagination.js +42 -0
  339. package/dist/src/web-ui/session-read-state/projection.d.ts +4 -3
  340. package/dist/src/web-ui/session-read-state/service.d.ts +213 -20
  341. package/dist/src/web-ui/session-read-state/service.js +25 -23
  342. package/dist/src/web-ui/session-read-state/visible-messages.d.ts +3 -3
  343. package/dist/src/web-ui/system-host-setup/companion-linux.js +1 -1
  344. package/dist/src/web-ui/system-host-setup/installer-contract.d.ts +1 -1
  345. package/dist/src/web-ui/system-host-setup/installer-contract.js +2 -2
  346. package/dist/src/web-ui/system-host-setup/installers.js +0 -7
  347. package/dist/src/web-ui/system-host-setup/local-connection.d.ts +4 -1
  348. package/dist/src/web-ui/system-host-setup/local-connection.js +10 -17
  349. package/dist/src/web-ui/system-host-setup/routes.d.ts +2 -0
  350. package/dist/src/web-ui/system-host-setup/routes.js +32 -9
  351. package/dist/src/web-ui/system-host-setup/setup-mutation.d.ts +9 -0
  352. package/dist/src/web-ui/system-host-setup/setup-mutation.js +27 -0
  353. package/dist/src/web-ui/system-host-setup/windows-store-route.d.ts +13 -0
  354. package/dist/src/web-ui/system-host-setup/windows-store-route.js +68 -0
  355. package/docs/configuration.md +46 -0
  356. package/docs/installation.md +45 -24
  357. package/docs/plugins.md +165 -2
  358. package/docs/projects-and-full-plus.md +2 -6
  359. package/docs/runtime-library.md +0 -1
  360. package/docs/windows-companion-store.md +127 -0
  361. package/package.json +3 -3
  362. package/plugins/document-reader/plugin.json +1 -0
  363. package/plugins/exec/plugin.json +3 -0
  364. package/plugins/filesystem/plugin.json +2 -0
  365. package/plugins/local-search/plugin.json +1 -0
  366. package/plugins/system/README.md +43 -3
  367. package/plugins/system/plugin.json +5 -0
  368. package/plugins/system/source/companion-command-output.ts +82 -0
  369. package/plugins/system/source/host-dispatch.ts +4 -0
  370. package/plugins/system/source/index.ts +11 -5
  371. package/plugins/system/source/local-command-output.ts +61 -0
  372. package/plugins/system/source/request-system-modules.ts +2 -0
  373. package/plugins/system/src/index.cjs +474 -39
  374. package/plugins/web/README.md +2 -2
  375. package/plugins/web/plugin.json +4 -0
  376. package/runtime.config.schema.json +25 -1
  377. package/src/runtime/README.md +12 -2
  378. package/dist/src/web-ui/system-host-setup/companion-windows.d.ts +0 -2
  379. package/dist/src/web-ui/system-host-setup/companion-windows.js +0 -108
  380. package/docs/publishing.md +0 -167
@@ -3,31 +3,14 @@ import { fileURLToPath, pathToFileURL } from "node:url";
3
3
  import { isNativeCredential } from "../computer-access/companion/native-state.js";
4
4
  import { isHostIdentifier, isHostRecord, } from "../computer-access/companion/protocol.js";
5
5
  import { runHostCompanionCli } from "./host-companion.js";
6
- const SETUP_INPUT_LIMIT_BYTES = 16_384;
7
- const SETUP_INPUT_TIMEOUT_MS = 10_000;
6
+ import { readHostCompanionInput } from "./host-companion-input.js";
8
7
  async function readSetupInput(input) {
9
- const chunks = [];
10
- let length = 0;
11
- const deadline = setTimeout(() => {
12
- input.destroy(new Error("Host setup input timed out."));
13
- }, SETUP_INPUT_TIMEOUT_MS);
8
+ const text = await readHostCompanionInput(input);
14
9
  try {
15
- for await (const chunk of input) {
16
- const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
17
- length += bytes.length;
18
- if (length > SETUP_INPUT_LIMIT_BYTES)
19
- throw new Error("Host setup input exceeds the size limit.");
20
- chunks.push(bytes);
21
- }
22
- try {
23
- return JSON.parse(Buffer.concat(chunks).toString("utf8"));
24
- }
25
- catch {
26
- throw new Error("Host setup requires a JSON object on standard input.");
27
- }
10
+ return JSON.parse(text);
28
11
  }
29
- finally {
30
- clearTimeout(deadline);
12
+ catch {
13
+ throw new Error("Host setup requires a JSON object on standard input.");
31
14
  }
32
15
  }
33
16
  function readSetupRequest(value) {
@@ -0,0 +1,3 @@
1
+ import type { Readable } from "node:stream";
2
+ /** Native launchers send short-lived secrets through bounded stdin, never shell arguments. */
3
+ export declare function readHostCompanionInput(input: Readable, maxBytes?: number): Promise<string>;
@@ -0,0 +1,21 @@
1
+ /** Native launchers send short-lived secrets through bounded stdin, never shell arguments. */
2
+ export async function readHostCompanionInput(input, maxBytes = 16_384) {
3
+ const chunks = [];
4
+ let length = 0;
5
+ const deadline = setTimeout(() => {
6
+ input.destroy(new Error("Host setup input timed out."));
7
+ }, 10_000);
8
+ try {
9
+ for await (const chunk of input) {
10
+ const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
11
+ length += bytes.length;
12
+ if (length > maxBytes)
13
+ throw new Error("Host setup input exceeds the size limit.");
14
+ chunks.push(bytes);
15
+ }
16
+ return Buffer.concat(chunks).toString("utf8");
17
+ }
18
+ finally {
19
+ clearTimeout(deadline);
20
+ }
21
+ }
@@ -0,0 +1,11 @@
1
+ import { type NativeAutostartOptions } from "../computer-access/companion/autostart.js";
2
+ import type { NativeNotificationSession } from "../computer-access/companion/native-notifications.js";
3
+ import type { NativeHostState } from "../computer-access/companion/native-state.js";
4
+ /** Packaging owns OS registration; pairing, ownership and supervision stay shared. */
5
+ export type HostCompanionLifecycle = Readonly<{
6
+ assertStartupSupported(startup: NativeAutostartOptions): void | Promise<void>;
7
+ completeStartup(state: NativeHostState, startup: NativeAutostartOptions, hostId: string): Promise<void>;
8
+ uninstall(state: NativeHostState, startup: NativeAutostartOptions): Promise<void>;
9
+ createNotifications?(runtimeUrl: string, signal?: AbortSignal): Promise<NativeNotificationSession>;
10
+ }>;
11
+ export declare const defaultHostCompanionLifecycle: HostCompanionLifecycle;
@@ -0,0 +1,32 @@
1
+ import { join } from "node:path";
2
+ import { nativeAutostartFile, uninstallNativeAutostart, } from "../computer-access/companion/autostart.js";
3
+ import { uninstallCompanionInstallLinks } from "../computer-access/companion/install-link-registration.js";
4
+ import { uninstallDesktopNotificationIdentity } from "../computer-access/companion/notification-installation.js";
5
+ import { isProcessOwnerAlive, requireCurrentProcessOwnerIdentity, } from "../computer-access/companion/process-owner-identity.js";
6
+ import { acquireFileLock } from "../runtime/adapters/long-term-memory/file-lock/acquisition.js";
7
+ import { completeHostCompanionStartup } from "./host-companion-startup.js";
8
+ async function uninstallDefaultCompanion(state, startup) {
9
+ await state.remove();
10
+ await uninstallNativeAutostart(startup);
11
+ await uninstallDesktopNotificationIdentity(startup);
12
+ const ownerIdentity = await requireCurrentProcessOwnerIdentity();
13
+ const release = await acquireFileLock(join(state.directory, "agent"), {
14
+ waitMs: 5_000,
15
+ releaseMode: "synchronous",
16
+ ownerIdentity,
17
+ processIsAlive: isProcessOwnerAlive,
18
+ });
19
+ await release();
20
+ await uninstallCompanionInstallLinks(startup).catch((error) => {
21
+ console.warn("Plugin installation link cleanup needs attention: " +
22
+ (error instanceof Error ? error.message : String(error)));
23
+ });
24
+ console.log("Host companion stopped. Login startup and the saved credential were removed.");
25
+ }
26
+ export const defaultHostCompanionLifecycle = {
27
+ assertStartupSupported(startup) {
28
+ nativeAutostartFile(startup);
29
+ },
30
+ completeStartup: completeHostCompanionStartup,
31
+ uninstall: uninstallDefaultCompanion,
32
+ };
@@ -1,3 +1,7 @@
1
1
  import type { NativeHostConnection } from "../computer-access/companion/native-state.js";
2
2
  /** Upgrade identity selects existing private state, never a new credential destination. */
3
3
  export declare function resolveHostCompanionSetupUrl(saved: NativeHostConnection | undefined, requestedUrl: string, upgradeHostId?: string): string;
4
+ /** Explicit fresh Store consent bypasses resume; other callers keep their saved pairing. */
5
+ export declare function canResumeHostCompanionPairing(saved: NativeHostConnection | undefined, pairingMode?: "fresh-grant"): saved is NativeHostConnection;
6
+ export declare function assertFreshHostPairingGrant(pairingMode: "fresh-grant" | undefined, pairingCode: string | undefined, upgradeHostId: string | undefined): void;
7
+ export declare function requiresFreshHostPairing(pairingMode?: "fresh-grant"): boolean;
@@ -21,3 +21,20 @@ export function resolveHostCompanionSetupUrl(saved, requestedUrl, upgradeHostId)
21
21
  throw new Error("This upgrade belongs to a different paired computer connection.");
22
22
  return saved.url;
23
23
  }
24
+ /** Explicit fresh Store consent bypasses resume; other callers keep their saved pairing. */
25
+ export function canResumeHostCompanionPairing(saved, pairingMode) {
26
+ if (!saved)
27
+ return false;
28
+ return !requiresFreshHostPairing(pairingMode);
29
+ }
30
+ export function assertFreshHostPairingGrant(pairingMode, pairingCode, upgradeHostId) {
31
+ if (!requiresFreshHostPairing(pairingMode))
32
+ return;
33
+ if (!pairingCode)
34
+ throw new Error("A fresh connection requires a pairing grant.");
35
+ if (upgradeHostId !== undefined)
36
+ throw new Error("A fresh connection cannot carry an upgrade identity.");
37
+ }
38
+ export function requiresFreshHostPairing(pairingMode) {
39
+ return pairingMode === "fresh-grant";
40
+ }
@@ -1,4 +1,6 @@
1
1
  import { type NativeAutostartOptions } from "../computer-access/companion/autostart.js";
2
2
  import type { NativeHostState } from "../computer-access/companion/native-state.js";
3
+ export declare function startDetachedCompanion(options: NativeAutostartOptions): Promise<void>;
4
+ export declare function waitForNativeConnection(state: NativeHostState, hostId: string, buildId: string, connectedAfter: number): Promise<boolean>;
3
5
  /** Startup can be resumed without consuming another grant or changing the saved pairing. */
4
6
  export declare function completeHostCompanionStartup(state: NativeHostState, startup: NativeAutostartOptions, hostId: string): Promise<void>;
@@ -1,3 +1,4 @@
1
+ import { installCompanionInstallLinks } from "../computer-access/companion/install-link-registration.js";
1
2
  import { spawn } from "node:child_process";
2
3
  import { installDesktopNotificationIdentity } from "../computer-access/companion/notification-installation.js";
3
4
  import { setTimeout as delay } from "node:timers/promises";
@@ -5,7 +6,7 @@ import { installNativeAutostart, existingOwnedRegistration, nativeAutostartFile,
5
6
  import { readNativeCompanionBuildId } from "../computer-access/companion/native-build-identity.js";
6
7
  import { stopOwnedNativeCompanion } from "../computer-access/companion/native-replacement.js";
7
8
  import { prepareNativeCompanionRuntime } from "../computer-access/companion/native-runtime-installation.js";
8
- async function startDetachedCompanion(options) {
9
+ export async function startDetachedCompanion(options) {
9
10
  const child = spawn(options.nodePath, [options.cliPath, "host", "run"], {
10
11
  cwd: options.homeDir,
11
12
  detached: true,
@@ -18,7 +19,7 @@ async function startDetachedCompanion(options) {
18
19
  });
19
20
  child.unref();
20
21
  }
21
- async function waitForNativeConnection(state, hostId, buildId, connectedAfter) {
22
+ export async function waitForNativeConnection(state, hostId, buildId, connectedAfter) {
22
23
  const deadline = Date.now() + 10_000;
23
24
  do {
24
25
  if (await state.isConnected(hostId, buildId, connectedAfter))
@@ -39,6 +40,10 @@ export async function completeHostCompanionStartup(state, startup, hostId) {
39
40
  console.warn("Desktop notifications setup needs attention: " +
40
41
  (error instanceof Error ? error.message : String(error)));
41
42
  });
43
+ await installCompanionInstallLinks(managedStartup).catch((error) => {
44
+ console.warn("Plugin installation links need attention: " +
45
+ (error instanceof Error ? error.message : String(error)));
46
+ });
42
47
  const connectedAfter = Date.now();
43
48
  const installed = await installNativeAutostart(managedStartup);
44
49
  if (!installed.started)
@@ -1,6 +1,12 @@
1
+ import { type NativeHostState } from "../computer-access/companion/native-state.js";
2
+ import { type HostCompanionLifecycle } from "./host-companion-lifecycle.js";
3
+ export declare function createHostCompanionState(): NativeHostState;
1
4
  export type HostCompanionCliOptions = Readonly<{
2
5
  cliPath?: string;
3
6
  pairingCode?: string;
4
7
  upgradeHostId?: string;
8
+ /** Store fresh connection consent must consume its new grant even with stale state. */
9
+ pairingMode?: "fresh-grant";
10
+ lifecycle?: HostCompanionLifecycle;
5
11
  }>;
6
12
  export declare function runHostCompanionCli(args: string[], options?: HostCompanionCliOptions): Promise<void>;
@@ -1,10 +1,9 @@
1
1
  import { homedir } from "node:os";
2
- import { uninstallDesktopNotificationIdentity } from "../computer-access/companion/notification-installation.js";
2
+ import { openPluginInstallLink, parsePluginInstallArguments, } from "../computer-access/companion/install-link.js";
3
3
  import { join } from "node:path";
4
4
  import { createInterface } from "node:readline/promises";
5
5
  import { stdin, stdout } from "node:process";
6
6
  import { fileURLToPath } from "node:url";
7
- import { nativeAutostartFile, uninstallNativeAutostart, } from "../computer-access/companion/autostart.js";
8
7
  import { normalizeNativeRuntimeUrl, resolveNativeRuntimeAddress, } from "../computer-access/companion/native-address.js";
9
8
  import { readNativeHostIdentity } from "../computer-access/companion/native-identity.js";
10
9
  import { connectNativeHost } from "../computer-access/companion/native-session.js";
@@ -14,8 +13,9 @@ import { isProcessOwnerAlive, requireCurrentProcessOwnerIdentity, } from "../com
14
13
  import { acquireFileLock } from "../runtime/adapters/long-term-memory/file-lock/acquisition.js";
15
14
  import { ensurePrivateRuntimeDirectory } from "../runtime/local-host/private-directory.js";
16
15
  import { assertPrivateRuntimeAccess } from "../runtime/local-host/private-access.js";
17
- import { completeHostCompanionStartup } from "./host-companion-startup.js";
18
- import { resolveHostCompanionSetupUrl } from "./host-companion-setup-target.js";
16
+ import { defaultHostCompanionLifecycle, } from "./host-companion-lifecycle.js";
17
+ import { assertFreshHostPairingGrant, canResumeHostCompanionPairing, resolveHostCompanionSetupUrl, requiresFreshHostPairing, } from "./host-companion-setup-target.js";
18
+ import { stopOwnedNativeCompanion } from "../computer-access/companion/native-replacement.js";
19
19
  import { readNativeCompanionBuildId } from "../computer-access/companion/native-build-identity.js";
20
20
  import { runHostPermissionsCli } from "./host-permissions.js";
21
21
  function printHostHelp() {
@@ -27,6 +27,7 @@ function printHostHelp() {
27
27
  " abot host disconnect",
28
28
  " abot host uninstall",
29
29
  " abot host run",
30
+ " abot host open-link <abot://install link>",
30
31
  "",
31
32
  "Connect asks for a one-time code from ABot Settings, saves a private credential,",
32
33
  "and starts the companion now and at future Windows/macOS/Linux desktop logins.",
@@ -35,7 +36,7 @@ function printHostHelp() {
35
36
  "Revoke the host in ABot Settings to remove Runtime-side pairing too.",
36
37
  ].join("\n"));
37
38
  }
38
- function nativeState() {
39
+ export function createHostCompanionState() {
39
40
  return createNativeHostState(join(homedir(), ".abot", "host-companion"), {
40
41
  ensureDirectory: ensurePrivateRuntimeDirectory,
41
42
  assertFile: (path, stat) => assertPrivateRuntimeAccess(path, stat, "host_companion_state_not_private"),
@@ -79,14 +80,20 @@ async function connectHost(args, state, options) {
79
80
  if (args.length !== 2 || args[0] !== "--url")
80
81
  throw new Error("Usage: abot host connect --url http://localhost:5177");
81
82
  const startup = autostartOptions(state, options);
82
- nativeAutostartFile(startup);
83
+ const lifecycle = options.lifecycle ?? defaultHostCompanionLifecycle;
84
+ await lifecycle.assertStartupSupported(startup);
85
+ assertFreshHostPairingGrant(options.pairingMode, options.pairingCode, options.upgradeHostId);
83
86
  const saved = await state.read();
84
87
  const url = resolveHostCompanionSetupUrl(saved, normalizeNativeRuntimeUrl(args[1]), options.upgradeHostId);
85
88
  await resolveNativeRuntimeAddress(url);
86
- if (saved) {
87
- await completeHostCompanionStartup(state, startup, saved.hostId);
89
+ if (canResumeHostCompanionPairing(saved, options.pairingMode)) {
90
+ await lifecycle.completeStartup(state, startup, saved.hostId);
88
91
  return;
89
92
  }
93
+ // The old process must exit before its credential is replaced; its in-flight
94
+ // authorization failure must not race with the new saved connection.
95
+ if (requiresFreshHostPairing(options.pairingMode))
96
+ await stopOwnedNativeCompanion(state.directory);
90
97
  const code = options.pairingCode ?? (await readPairingCode());
91
98
  let pairedHostId;
92
99
  let interrupted = false;
@@ -120,10 +127,11 @@ async function connectHost(args, state, options) {
120
127
  throw new Error("Host setup was interrupted before startup installation.");
121
128
  if (!pairedHostId)
122
129
  throw new Error("Pairing did not complete. Check ABot Settings and use a fresh pairing code.");
123
- await completeHostCompanionStartup(state, startup, pairedHostId);
130
+ await lifecycle.completeStartup(state, startup, pairedHostId);
124
131
  }
125
132
  async function runHost(state, options) {
126
- if (!(await state.read()))
133
+ const saved = await state.read();
134
+ if (!saved)
127
135
  return;
128
136
  const buildId = await readNativeCompanionBuildId(autostartOptions(state, options).cliPath);
129
137
  const ownerIdentity = await requireCurrentProcessOwnerIdentity();
@@ -143,31 +151,22 @@ async function runHost(state, options) {
143
151
  throw error;
144
152
  }
145
153
  try {
146
- await withStopSignals((signal) => runNativeHostSupervisor({
154
+ await withStopSignals(async (signal) => runNativeHostSupervisor({
147
155
  state,
148
156
  identity: readNativeHostIdentity(),
149
157
  signal,
150
158
  buildId,
159
+ ...(options.lifecycle?.createNotifications
160
+ ? {
161
+ notifications: await options.lifecycle.createNotifications(saved.url, signal),
162
+ }
163
+ : {}),
151
164
  }));
152
165
  }
153
166
  finally {
154
167
  await release();
155
168
  }
156
169
  }
157
- async function disconnectHost(state) {
158
- await state.remove();
159
- await uninstallNativeAutostart(autostartOptions(state));
160
- await uninstallDesktopNotificationIdentity(autostartOptions(state));
161
- const ownerIdentity = await requireCurrentProcessOwnerIdentity();
162
- const release = await acquireFileLock(join(state.directory, "agent"), {
163
- waitMs: 5_000,
164
- releaseMode: "synchronous",
165
- ownerIdentity,
166
- processIsAlive: isProcessOwnerAlive,
167
- });
168
- await release();
169
- console.log("Host companion stopped. Login startup and the saved credential were removed.");
170
- }
171
170
  export async function runHostCompanionCli(args, options = {}) {
172
171
  const [command, ...rest] = args;
173
172
  if (!command || ["help", "--help", "-h"].includes(command)) {
@@ -178,11 +177,15 @@ export async function runHostCompanionCli(args, options = {}) {
178
177
  await runHostPermissionsCli(rest);
179
178
  return;
180
179
  }
181
- const state = nativeState();
180
+ const state = createHostCompanionState();
182
181
  if (command === "connect") {
183
182
  await connectHost(rest, state, options);
184
183
  return;
185
184
  }
185
+ if (command === "open-link") {
186
+ await openPluginInstallLink(state, parsePluginInstallArguments(rest));
187
+ return;
188
+ }
186
189
  if (rest.length > 0)
187
190
  throw new Error(`Unknown host argument: ${rest[0]}`);
188
191
  if (command === "run") {
@@ -190,7 +193,7 @@ export async function runHostCompanionCli(args, options = {}) {
190
193
  return;
191
194
  }
192
195
  if (command === "disconnect" || command === "uninstall") {
193
- await disconnectHost(state);
196
+ await (options.lifecycle ?? defaultHostCompanionLifecycle).uninstall(state, autostartOptions(state, options));
194
197
  return;
195
198
  }
196
199
  if (command === "status") {
@@ -0,0 +1,9 @@
1
+ import type { Readable } from "node:stream";
2
+ import { createHostCompanionState, runHostCompanionCli } from "./host-companion.js";
3
+ /** Store-specific activation; all pairing, state and tool execution remain in the shared CLI. */
4
+ export declare function runWindowsCompanionStoreEntry(args: string[], options?: Readonly<{
5
+ input?: Readable;
6
+ cliPath?: string;
7
+ runCli?: typeof runHostCompanionCli;
8
+ createState?: typeof createHostCompanionState;
9
+ }>): Promise<void>;
@@ -0,0 +1,67 @@
1
+ import { stdin } from "node:process";
2
+ import { fileURLToPath, pathToFileURL } from "node:url";
3
+ import { normalizeNativeRuntimeUrl, resolveNativeRuntimeAddress } from "../computer-access/companion/native-address.js";
4
+ import { parseStoreConnectionLink, STORE_CONNECTION_LINK_MAX_BYTES } from "../computer-access/companion/windows-store/connection-link.js";
5
+ import { WINDOWS_COMPANION_AUMID } from "../computer-access/companion/windows-store/identity.js";
6
+ import { createWindowsStoreLifecycle } from "../computer-access/companion/windows-store/lifecycle.js";
7
+ import { hasMissingStoreUpgradeConnection, MissingStoreConnectionError, serializeStoreConnectionError } from "../computer-access/companion/windows-store/connection-error.js";
8
+ import { createHostCompanionState, runHostCompanionCli } from "./host-companion.js";
9
+ import { readHostCompanionInput } from "./host-companion-input.js";
10
+ import { resolveHostCompanionSetupUrl } from "./host-companion-setup-target.js";
11
+ function browserOrigin(runtimeUrl) {
12
+ const url = new URL(runtimeUrl);
13
+ url.protocol = url.protocol === "wss:" ? "https:" : "http:";
14
+ return url.origin;
15
+ }
16
+ /** Store-specific activation; all pairing, state and tool execution remain in the shared CLI. */
17
+ export async function runWindowsCompanionStoreEntry(args, options = {}) {
18
+ const [command, ...rest] = args;
19
+ const cliPath = options.cliPath ?? fileURLToPath(import.meta.url);
20
+ const runCli = options.runCli ?? runHostCompanionCli;
21
+ const lifecycle = createWindowsStoreLifecycle({ appUserModelId: WINDOWS_COMPANION_AUMID });
22
+ if (command === "host") {
23
+ if (!['run', 'status', 'disconnect', 'uninstall', '--help'].includes(rest[0] ?? '') || rest.length !== 1)
24
+ throw new Error("Unsupported Companion command.");
25
+ await runCli(rest, { cliPath, lifecycle });
26
+ return;
27
+ }
28
+ if (rest.length !== 0)
29
+ throw new Error("Companion links must be sent on standard input.");
30
+ if (!["inspect-link", "setup-link", "open-plugin-link"].includes(command ?? ""))
31
+ throw new Error("Unsupported Companion command.");
32
+ const link = await readHostCompanionInput(options.input ?? stdin, STORE_CONNECTION_LINK_MAX_BYTES);
33
+ if (command === "open-plugin-link") {
34
+ await runCli(["open-link", link], { cliPath, lifecycle });
35
+ return;
36
+ }
37
+ const invitation = parseStoreConnectionLink(link);
38
+ const state = (options.createState ?? createHostCompanionState)();
39
+ const saved = await state.read();
40
+ if (hasMissingStoreUpgradeConnection(invitation.upgradeHostId, saved))
41
+ throw new MissingStoreConnectionError();
42
+ const target = resolveHostCompanionSetupUrl(saved, normalizeNativeRuntimeUrl(invitation.url), invitation.upgradeHostId);
43
+ await resolveNativeRuntimeAddress(target);
44
+ if (command === "inspect-link") {
45
+ console.log(JSON.stringify({
46
+ runtimeUrl: browserOrigin(target),
47
+ expiresAt: invitation.expiresAt,
48
+ paired: Boolean(saved),
49
+ ...(saved ? { existingRuntimeUrl: browserOrigin(saved.url) } : {}),
50
+ }));
51
+ return;
52
+ }
53
+ // Revalidated by the CLI immediately before pairing; inspection never grants consent itself.
54
+ await runCli(["connect", "--url", invitation.url], {
55
+ cliPath, lifecycle, pairingCode: invitation.code,
56
+ ...(invitation.upgradeHostId
57
+ ? { upgradeHostId: invitation.upgradeHostId }
58
+ : { pairingMode: "fresh-grant" }),
59
+ });
60
+ }
61
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
62
+ void runWindowsCompanionStoreEntry(process.argv.slice(2)).catch((error) => {
63
+ // Neither activation URI nor one-time authorization may appear in process output.
64
+ console.error(serializeStoreConnectionError(error));
65
+ process.exitCode = 1;
66
+ });
67
+ }
@@ -0,0 +1,37 @@
1
+ import type { Readable } from "node:stream";
2
+ import { type SystemProcessResult } from "./contracts.js";
3
+ export type SystemOutputReceipt = Readonly<{
4
+ id: string;
5
+ stdoutBytes: number;
6
+ stderrBytes: number;
7
+ completedAt: string;
8
+ retentionMs: number;
9
+ complete: boolean;
10
+ stdoutSha256?: string;
11
+ stderrSha256?: string;
12
+ }>;
13
+ /** One synchronous command capture; no resumable-process or cursor state. */
14
+ export declare function createSystemOutputCapture(root: string, retentionMs: number): Promise<{
15
+ capture: Readonly<{
16
+ attach(stdout: Readable, stderr: Readable, onFailure: () => void): void;
17
+ end(): void;
18
+ }>;
19
+ readonly receipt: Readonly<{
20
+ id: string;
21
+ stdoutBytes: number;
22
+ stderrBytes: number;
23
+ completedAt: string;
24
+ retentionMs: number;
25
+ complete: boolean;
26
+ stdoutSha256?: string;
27
+ stderrSha256?: string;
28
+ }> | undefined;
29
+ readonly failure: string | undefined;
30
+ retain(): void;
31
+ release(): void;
32
+ read(stream: "stdout" | "stderr", offset: number, length: number): Promise<Buffer>;
33
+ finish(result?: SystemProcessResult, materialize?: boolean): Promise<{
34
+ stdout: string;
35
+ stderr: string;
36
+ }>;
37
+ }>;
@@ -0,0 +1,136 @@
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { once } from "node:events";
3
+ import { createWriteStream } from "node:fs";
4
+ import { mkdir, open, readFile, rename, stat, writeFile } from "node:fs/promises";
5
+ import { join } from "node:path";
6
+ import { finished } from "node:stream/promises";
7
+ import { SystemOperationError } from "./contracts.js";
8
+ import { activeSystemCaptures, scheduleSystemOutputCleanup } from "./command-output-retention.js";
9
+ const OUTPUT_IO_CHUNK_BYTES = 64 * 1024;
10
+ /** One synchronous command capture; no resumable-process or cursor state. */
11
+ export async function createSystemOutputCapture(root, retentionMs) {
12
+ const id = randomUUID();
13
+ const directory = join(root, id);
14
+ activeSystemCaptures.add(directory);
15
+ try {
16
+ await mkdir(directory, { recursive: true, mode: 0o700 });
17
+ }
18
+ catch {
19
+ activeSystemCaptures.delete(directory);
20
+ throw new SystemOperationError("system_output_storage_failed", "Output storage could not be prepared. The command was not dispatched.");
21
+ }
22
+ let failure;
23
+ let stop;
24
+ let ended = false;
25
+ let retained = false;
26
+ const sources = [];
27
+ const streams = ["stdout", "stderr"].map((name) => {
28
+ const path = join(directory, name + ".bytes");
29
+ const sink = createWriteStream(path, { flags: "wx", mode: 0o600, highWaterMark: OUTPUT_IO_CHUNK_BYTES, flush: true });
30
+ const completion = finished(sink).catch(() => {
31
+ failure ??= "write_failed";
32
+ stop?.();
33
+ });
34
+ return { name, path, sink, completion, hash: createHash("sha256") };
35
+ });
36
+ try {
37
+ await Promise.all(streams.map(({ sink }) => once(sink, "open")));
38
+ }
39
+ catch {
40
+ for (const { sink } of streams)
41
+ sink.destroy();
42
+ await Promise.all(streams.map(({ completion }) => completion));
43
+ activeSystemCaptures.delete(directory);
44
+ scheduleSystemOutputCleanup(root, retentionMs);
45
+ throw new SystemOperationError("system_output_storage_failed", "Output files could not be opened. The command was not dispatched.");
46
+ }
47
+ scheduleSystemOutputCleanup(root, retentionMs);
48
+ const capture = {
49
+ attach(stdout, stderr, onFailure) {
50
+ stop = onFailure;
51
+ sources.push(stdout, stderr);
52
+ stdout.on("data", (bytes) => streams[0].hash.update(bytes));
53
+ stderr.on("data", (bytes) => streams[1].hash.update(bytes));
54
+ stdout.pipe(streams[0].sink);
55
+ stderr.pipe(streams[1].sink);
56
+ if (failure)
57
+ onFailure();
58
+ },
59
+ end() {
60
+ if (ended)
61
+ return;
62
+ ended = true;
63
+ for (const source of sources) {
64
+ source.unpipe();
65
+ source.destroy();
66
+ }
67
+ for (const { sink } of streams)
68
+ if (!sink.destroyed && !sink.writableEnded)
69
+ sink.end();
70
+ },
71
+ };
72
+ let receipt;
73
+ return {
74
+ capture,
75
+ get receipt() { return receipt; },
76
+ get failure() { return failure; },
77
+ retain() { retained = true; activeSystemCaptures.add(directory); },
78
+ release() { retained = false; activeSystemCaptures.delete(directory); },
79
+ async read(stream, offset, length) {
80
+ const path = streams.find((entry) => entry.name === stream).path;
81
+ const file = await open(path, "r");
82
+ try {
83
+ const bytes = Buffer.alloc(length);
84
+ const { bytesRead } = await file.read(bytes, 0, length, offset);
85
+ return bytes.subarray(0, bytesRead);
86
+ }
87
+ finally {
88
+ await file.close();
89
+ }
90
+ },
91
+ async finish(result, materialize = true) {
92
+ capture.end();
93
+ try {
94
+ await Promise.all(streams.map(({ completion }) => completion));
95
+ const sizes = await Promise.all(streams.map(async ({ path }) => {
96
+ try {
97
+ return (await stat(path)).size;
98
+ }
99
+ catch {
100
+ failure ??= "read_failed";
101
+ return 0;
102
+ }
103
+ }));
104
+ let stdout = "", stderr = "";
105
+ if (!failure && materialize) {
106
+ try {
107
+ [stdout, stderr] = await Promise.all(streams.map(({ path }) => readFile(path, "utf8")));
108
+ }
109
+ catch {
110
+ failure = "read_failed";
111
+ }
112
+ }
113
+ const completedAt = Date.now();
114
+ receipt = { id, stdoutBytes: sizes[0], stderrBytes: sizes[1],
115
+ completedAt: new Date(completedAt).toISOString(), retentionMs, complete: !failure,
116
+ ...(!materialize ? { stdoutSha256: streams[0].hash.digest("hex"), stderrSha256: streams[1].hash.digest("hex") } : {}) };
117
+ try {
118
+ const temporary = join(directory, "receipt.tmp");
119
+ await writeFile(temporary, JSON.stringify({ kind: "system_command_output_v1", ...receipt,
120
+ processStatus: result?.status, exitCode: result?.exitCode, spawnedProcess: result?.spawnedProcess,
121
+ ...(failure ? { storageFailure: failure } : {}) }), { flag: "wx", mode: 0o600, flush: true });
122
+ await rename(temporary, join(directory, "receipt.json"));
123
+ }
124
+ catch {
125
+ failure ??= "receipt_write_failed";
126
+ receipt = { ...receipt, complete: false };
127
+ }
128
+ return { stdout, stderr };
129
+ }
130
+ finally {
131
+ if (!retained)
132
+ activeSystemCaptures.delete(directory);
133
+ }
134
+ },
135
+ };
136
+ }
@@ -0,0 +1,5 @@
1
+ export declare const DEFAULT_SYSTEM_OUTPUT_RETENTION_MS: number;
2
+ export declare const activeSystemCaptures: Set<string>;
3
+ export declare function cleanupSystemOutput(root: string, retentionMs: number): Promise<number>;
4
+ /** One cleanup job per storage root; the supplied policy also covers incomplete captures. */
5
+ export declare function scheduleSystemOutputCleanup(root: string, retentionMs: number): void;