@abot-ai/runtime 1.3.0 → 1.4.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 (660) hide show
  1. package/dist/plugins/system/source/application-catalog.d.ts +14 -0
  2. package/dist/plugins/system/source/application-catalog.js +185 -0
  3. package/dist/plugins/system/source/application-launch.d.ts +10 -0
  4. package/dist/plugins/system/source/application-launch.js +80 -0
  5. package/dist/plugins/system/source/application-observation.d.ts +25 -0
  6. package/dist/plugins/system/source/application-observation.js +53 -0
  7. package/dist/plugins/system/source/commands.d.ts +7 -0
  8. package/dist/plugins/system/source/commands.js +71 -0
  9. package/dist/plugins/system/source/companion/autostart.d.ts +16 -0
  10. package/dist/plugins/system/source/companion/autostart.js +146 -0
  11. package/dist/plugins/system/source/companion/broker-location.d.ts +11 -0
  12. package/dist/plugins/system/source/companion/broker-location.js +76 -0
  13. package/dist/plugins/system/source/companion/broker-server.d.ts +4 -0
  14. package/dist/plugins/system/source/companion/broker-server.js +147 -0
  15. package/dist/plugins/system/source/companion/connection.d.ts +25 -0
  16. package/dist/plugins/system/source/companion/connection.js +182 -0
  17. package/dist/plugins/system/source/companion/liveness.d.ts +3 -0
  18. package/dist/plugins/system/source/companion/liveness.js +20 -0
  19. package/dist/plugins/system/source/companion/native-address.d.ts +12 -0
  20. package/dist/plugins/system/source/companion/native-address.js +41 -0
  21. package/dist/plugins/system/source/companion/native-identity.d.ts +2 -0
  22. package/dist/plugins/system/source/companion/native-identity.js +23 -0
  23. package/dist/plugins/system/source/companion/native-messages.d.ts +9 -0
  24. package/dist/plugins/system/source/companion/native-messages.js +77 -0
  25. package/dist/plugins/system/source/companion/native-session.d.ts +19 -0
  26. package/dist/plugins/system/source/companion/native-session.js +205 -0
  27. package/dist/plugins/system/source/companion/native-state.d.ts +22 -0
  28. package/dist/plugins/system/source/companion/native-state.js +126 -0
  29. package/dist/plugins/system/source/companion/native-supervisor.d.ts +10 -0
  30. package/dist/plugins/system/source/companion/native-supervisor.js +93 -0
  31. package/dist/plugins/system/source/companion/pairing-store.d.ts +22 -0
  32. package/dist/plugins/system/source/companion/pairing-store.js +102 -0
  33. package/dist/plugins/system/source/companion/private-store.d.ts +4 -0
  34. package/dist/plugins/system/source/companion/private-store.js +59 -0
  35. package/dist/plugins/system/source/companion/process-owner-identity.d.ts +22 -0
  36. package/dist/plugins/system/source/companion/process-owner-identity.js +144 -0
  37. package/dist/plugins/system/source/companion/protocol.d.ts +57 -0
  38. package/dist/plugins/system/source/companion/protocol.js +66 -0
  39. package/dist/plugins/system/source/contracts.d.ts +38 -0
  40. package/dist/plugins/system/source/contracts.js +7 -0
  41. package/dist/plugins/system/source/elevation.d.ts +8 -0
  42. package/dist/plugins/system/source/elevation.js +57 -0
  43. package/dist/plugins/system/source/handlers.d.ts +3 -0
  44. package/dist/plugins/system/source/handlers.js +90 -0
  45. package/dist/plugins/system/source/host-evidence.d.ts +4 -0
  46. package/dist/plugins/system/source/host-evidence.js +52 -0
  47. package/dist/plugins/system/source/host-observation.d.ts +25 -0
  48. package/dist/plugins/system/source/host-observation.js +59 -0
  49. package/dist/plugins/system/source/process-result.d.ts +4 -0
  50. package/dist/plugins/system/source/process-result.js +86 -0
  51. package/dist/plugins/system/source/process-runner.d.ts +3 -0
  52. package/dist/plugins/system/source/process-runner.js +103 -0
  53. package/dist/plugins/system/source/target-observation.d.ts +18 -0
  54. package/dist/plugins/system/source/target-observation.js +29 -0
  55. package/dist/plugins/system/source/targets.d.ts +8 -0
  56. package/dist/plugins/system/source/targets.js +101 -0
  57. package/dist/scripts/add-runtime-model.js +10 -53
  58. package/dist/scripts/init-runtime.js +4 -13
  59. package/dist/scripts/runtime-model-addition.d.ts +13 -0
  60. package/dist/scripts/runtime-model-addition.js +53 -0
  61. package/dist/scripts/runtime-setup-directories.d.ts +2 -0
  62. package/dist/scripts/runtime-setup-directories.js +38 -0
  63. package/dist/scripts/runtime-setup-files.d.ts +3 -1
  64. package/dist/scripts/runtime-setup-files.js +18 -1
  65. package/dist/src/capabilities/file-output-presentation.d.ts +43 -0
  66. package/dist/src/capabilities/file-output-presentation.js +133 -0
  67. package/dist/src/capabilities/tool-definition-validator/definition-parser.js +2 -0
  68. package/dist/src/capabilities/tool-definition-validator/event-input-text-options.d.ts +5 -0
  69. package/dist/src/capabilities/tool-definition-validator/event-input-text-options.js +37 -0
  70. package/dist/src/capabilities/tool-definition-validator/event-presentation.js +3 -0
  71. package/dist/src/capabilities/tool-definition-validator/module-registry.js +12 -0
  72. package/dist/src/capabilities/tool-event-input-text.d.ts +9 -0
  73. package/dist/src/capabilities/tool-event-input-text.js +64 -0
  74. package/dist/src/capabilities/tool-event-metadata.js +10 -0
  75. package/dist/src/capabilities/tool-executor.d.ts +1 -0
  76. package/dist/src/capabilities/tool-executor.js +1 -0
  77. package/dist/src/capabilities/tool-permission-mode.d.ts +7 -0
  78. package/dist/src/capabilities/tool-permission-mode.js +27 -0
  79. package/dist/src/capabilities/tool-types.d.ts +18 -2
  80. package/dist/src/cli/abot.js +18 -15
  81. package/dist/src/cli/host-companion-bundle.mjs +5201 -0
  82. package/dist/src/cli/host-companion-entry.d.ts +8 -0
  83. package/dist/src/cli/host-companion-entry.js +70 -0
  84. package/dist/src/cli/host-companion-startup.d.ts +4 -0
  85. package/dist/src/cli/host-companion-startup.js +35 -0
  86. package/dist/src/cli/host-companion.d.ts +5 -0
  87. package/dist/src/cli/host-companion.js +203 -0
  88. package/dist/src/model-gateway/server/configuration.js +4 -1
  89. package/dist/src/model-gateway/server/contracts.d.ts +2 -0
  90. package/dist/src/plugin-contract/entrypoint.d.ts +4 -2
  91. package/dist/src/plugin-contract/manifest.d.ts +1 -0
  92. package/dist/src/runtime/adapters/config-file-transaction.d.ts +46 -0
  93. package/dist/src/runtime/adapters/config-file-transaction.js +158 -0
  94. package/dist/src/runtime/adapters/configured-skill-provider.js +3 -3
  95. package/dist/src/runtime/adapters/in-memory-session-store.js +11 -1
  96. package/dist/src/runtime/adapters/long-term-memory/file-lock/acquisition.js +7 -3
  97. package/dist/src/runtime/adapters/long-term-memory/file-lock/contracts.d.ts +4 -1
  98. package/dist/src/runtime/adapters/long-term-memory/file-lock/install.d.ts +1 -1
  99. package/dist/src/runtime/adapters/long-term-memory/file-lock/install.js +5 -1
  100. package/dist/src/runtime/adapters/long-term-memory/file-lock/owner-identity.d.ts +3 -0
  101. package/dist/src/runtime/adapters/long-term-memory/file-lock/owner-identity.js +15 -0
  102. package/dist/src/runtime/adapters/long-term-memory/file-lock/owner-record.js +2 -0
  103. package/dist/src/runtime/adapters/long-term-memory/onboarding-config-repository.js +17 -43
  104. package/dist/src/runtime/adapters/registered-tool-normal-invocations/catalog/registrations.js +6 -2
  105. package/dist/src/runtime/adapters/registered-tool-normal-invocations/execution/approval.js +10 -1
  106. package/dist/src/runtime/adapters/registered-tool-normal-invocations/execution/execution-binding.d.ts +11 -0
  107. package/dist/src/runtime/adapters/registered-tool-normal-invocations/execution/execution-binding.js +37 -0
  108. package/dist/src/runtime/adapters/registered-tool-normal-invocations/execution/file-output-presentation.d.ts +7 -0
  109. package/dist/src/runtime/adapters/registered-tool-normal-invocations/execution/file-output-presentation.js +105 -0
  110. package/dist/src/runtime/adapters/registered-tool-normal-invocations/execution/run.js +29 -3
  111. package/dist/src/runtime/adapters/registered-tool-normal-invocations/shared/action-fingerprint.d.ts +1 -0
  112. package/dist/src/runtime/adapters/registered-tool-normal-invocations/shared/action-fingerprint.js +1 -0
  113. package/dist/src/runtime/capabilities/configured-tool-registry.js +9 -1
  114. package/dist/src/runtime/capabilities/file-output-root-identity.d.ts +5 -0
  115. package/dist/src/runtime/capabilities/file-output-root-identity.js +146 -0
  116. package/dist/src/runtime/capabilities/file-output-root-marker-creation.d.ts +5 -0
  117. package/dist/src/runtime/capabilities/file-output-root-marker-creation.js +63 -0
  118. package/dist/src/runtime/capabilities/request-bound-tool-registry.d.ts +1 -0
  119. package/dist/src/runtime/capabilities/request-bound-tool-registry.js +6 -1
  120. package/dist/src/runtime/capabilities/request-module-preparation.d.ts +3 -0
  121. package/dist/src/runtime/capabilities/request-module-preparation.js +102 -0
  122. package/dist/src/runtime/capabilities/request-permission-catalog.d.ts +10 -0
  123. package/dist/src/runtime/capabilities/request-permission-catalog.js +50 -0
  124. package/dist/src/runtime/capabilities/request-permission-tool-registry.d.ts +4 -0
  125. package/dist/src/runtime/capabilities/request-permission-tool-registry.js +61 -0
  126. package/dist/src/runtime/capabilities/request-runtime-tool-registry.d.ts +3 -0
  127. package/dist/src/runtime/capabilities/request-runtime-tool-registry.js +5 -2
  128. package/dist/src/runtime/capabilities/request-working-directory.d.ts +3 -0
  129. package/dist/src/runtime/capabilities/request-working-directory.js +12 -0
  130. package/dist/src/runtime/composition.d.ts +2 -0
  131. package/dist/src/runtime/config/runner/loader.d.ts +4 -0
  132. package/dist/src/runtime/config/runner/loader.js +23 -3
  133. package/dist/src/runtime/context/capability-brief-budget.d.ts +18 -0
  134. package/dist/src/runtime/context/capability-brief-budget.js +38 -0
  135. package/dist/src/runtime/context/capability-brief-readmission.d.ts +21 -0
  136. package/dist/src/runtime/context/capability-brief-readmission.js +47 -0
  137. package/dist/src/runtime/context/capability-brief.d.ts +9 -2
  138. package/dist/src/runtime/context/capability-brief.js +21 -39
  139. package/dist/src/runtime/context/capability-descriptions.d.ts +3 -0
  140. package/dist/src/runtime/context/capability-descriptions.js +23 -0
  141. package/dist/src/runtime/default-environment-adapters.js +3 -4
  142. package/dist/src/runtime/local-application.d.ts +18 -0
  143. package/dist/src/runtime/local-application.js +12 -0
  144. package/dist/src/runtime/local-host/app-service-dispatch.d.ts +1 -0
  145. package/dist/src/runtime/local-host/app-service-dispatch.js +9 -0
  146. package/dist/src/runtime/local-host/client-services.d.ts +16 -0
  147. package/dist/src/runtime/local-host/client-services.js +3 -2
  148. package/dist/src/runtime/local-host/contracts.d.ts +4 -0
  149. package/dist/src/runtime/local-host/startup-connection.js +22 -7
  150. package/dist/src/runtime/local-host/transport.js +14 -2
  151. package/dist/src/runtime/orchestration/role-calls/candidate-validation.js +5 -2
  152. package/dist/src/runtime/orchestration/role-calls/command-decoder.js +3 -0
  153. package/dist/src/runtime/orchestration/role-calls/command-dispatch/work-plan-transition.d.ts +3 -0
  154. package/dist/src/runtime/orchestration/role-calls/command-dispatch/work-plan-transition.js +46 -0
  155. package/dist/src/runtime/orchestration/role-calls/command-dispatch.js +3 -0
  156. package/dist/src/runtime/orchestration/role-calls/contracts.d.ts +8 -4
  157. package/dist/src/runtime/orchestration/role-calls/transactions.js +2 -0
  158. package/dist/src/runtime/orchestration/role-calls/work-plan-contracts.d.ts +48 -0
  159. package/dist/src/runtime/orchestration/role-calls/work-plan-contracts.js +9 -0
  160. package/dist/src/runtime/orchestration/role-calls/work-plan-source.d.ts +7 -0
  161. package/dist/src/runtime/orchestration/role-calls/work-plan-source.js +85 -0
  162. package/dist/src/runtime/orchestration/role-calls/work-plan-transactions.d.ts +3 -0
  163. package/dist/src/runtime/orchestration/role-calls/work-plan-transactions.js +17 -0
  164. package/dist/src/runtime/orchestration/role-calls/work-plan-validation.d.ts +10 -0
  165. package/dist/src/runtime/orchestration/role-calls/work-plan-validation.js +149 -0
  166. package/dist/src/runtime/orchestration/worker-capabilities/contracts.d.ts +1 -1
  167. package/dist/src/runtime/orchestration/worker-capabilities/contracts.js +1 -1
  168. package/dist/src/runtime/plugins/compiled-catalog.d.ts +2 -1
  169. package/dist/src/runtime/plugins/configured-manifests.d.ts +3 -0
  170. package/dist/src/runtime/plugins/configured-manifests.js +37 -0
  171. package/dist/src/runtime/plugins/entrypoint-validation.d.ts +6 -0
  172. package/dist/src/runtime/plugins/entrypoint-validation.js +74 -0
  173. package/dist/src/runtime/plugins/loader.js +11 -123
  174. package/dist/src/runtime/plugins/manifest-discovery.d.ts +4 -1
  175. package/dist/src/runtime/plugins/manifest-discovery.js +8 -1
  176. package/dist/src/runtime/plugins/manifest-projection.js +3 -0
  177. package/dist/src/runtime/plugins/manifest-validator.js +7 -1
  178. package/dist/src/runtime/plugins/runtime-capability-plugins.d.ts +4 -0
  179. package/dist/src/runtime/plugins/runtime-capability-plugins.js +7 -0
  180. package/dist/src/runtime/plugins/selection.d.ts +14 -0
  181. package/dist/src/runtime/plugins/selection.js +38 -0
  182. package/dist/src/runtime/ports.d.ts +8 -2
  183. package/dist/src/runtime/projects/contracts.d.ts +40 -0
  184. package/dist/src/runtime/projects/contracts.js +10 -0
  185. package/dist/src/runtime/projects/folders.d.ts +7 -0
  186. package/dist/src/runtime/projects/folders.js +110 -0
  187. package/dist/src/runtime/projects/repository.d.ts +10 -0
  188. package/dist/src/runtime/projects/repository.js +54 -0
  189. package/dist/src/runtime/projects/service.d.ts +3 -0
  190. package/dist/src/runtime/projects/service.js +34 -0
  191. package/dist/src/runtime/projects/session-paths.d.ts +5 -0
  192. package/dist/src/runtime/projects/session-paths.js +13 -0
  193. package/dist/src/runtime/request/execution-agent-plan-update.d.ts +4 -0
  194. package/dist/src/runtime/request/execution-agent-plan-update.js +13 -0
  195. package/dist/src/runtime/request/execution-agent-root-execution.js +9 -1
  196. package/dist/src/runtime/request/handler.js +9 -2
  197. package/dist/src/runtime/request/input.d.ts +2 -1
  198. package/dist/src/runtime/request/input.js +1 -6
  199. package/dist/src/runtime/request/role-call-planner-events.js +4 -0
  200. package/dist/src/runtime/request/role-executor-composition.js +9 -1
  201. package/dist/src/runtime/request/root-contract.d.ts +6 -1
  202. package/dist/src/runtime/request/root-execution-kernel.js +17 -0
  203. package/dist/src/runtime/request/root-plan-event-projection.d.ts +3 -0
  204. package/dist/src/runtime/request/root-plan-event-projection.js +32 -0
  205. package/dist/src/runtime/request/root-plan-update.d.ts +15 -0
  206. package/dist/src/runtime/request/root-plan-update.js +20 -0
  207. package/dist/src/runtime/request/worker-capability-composition.d.ts +1 -0
  208. package/dist/src/runtime/request/worker-capability-composition.js +2 -0
  209. package/dist/src/runtime/runtime-environment.d.ts +1 -0
  210. package/dist/src/runtime/runtime-environment.js +2 -0
  211. package/dist/src/runtime/steps/auditor-decision/advisory-receipt.d.ts +32 -0
  212. package/dist/src/runtime/steps/auditor-decision/advisory-receipt.js +106 -0
  213. package/dist/src/runtime/steps/auditor-decision/advisory-result-budget.d.ts +5 -0
  214. package/dist/src/runtime/steps/auditor-decision/advisory-result-budget.js +40 -0
  215. package/dist/src/runtime/steps/auditor-decision/audit-input-state.d.ts +12 -0
  216. package/dist/src/runtime/steps/auditor-decision/audit-input-state.js +101 -0
  217. package/dist/src/runtime/steps/auditor-decision/contracts.d.ts +31 -16
  218. package/dist/src/runtime/steps/auditor-decision/contracts.js +3 -3
  219. package/dist/src/runtime/steps/auditor-decision/evidence-binding.d.ts +5 -0
  220. package/dist/src/runtime/steps/auditor-decision/evidence-binding.js +43 -0
  221. package/dist/src/runtime/steps/auditor-decision/evidence-coverage.d.ts +2 -0
  222. package/dist/src/runtime/steps/auditor-decision/evidence-coverage.js +71 -0
  223. package/dist/src/runtime/steps/auditor-decision/evidence-inventory.d.ts +13 -0
  224. package/dist/src/runtime/steps/auditor-decision/evidence-inventory.js +89 -0
  225. package/dist/src/runtime/steps/auditor-decision/evidence-representation.d.ts +10 -0
  226. package/dist/src/runtime/steps/auditor-decision/evidence-representation.js +56 -0
  227. package/dist/src/runtime/steps/auditor-decision/evidence-selection.d.ts +9 -0
  228. package/dist/src/runtime/steps/auditor-decision/evidence-selection.js +71 -0
  229. package/dist/src/runtime/steps/auditor-decision/format.js +44 -2
  230. package/dist/src/runtime/steps/auditor-decision/index.d.ts +3 -0
  231. package/dist/src/runtime/steps/auditor-decision/index.js +3 -0
  232. package/dist/src/runtime/steps/auditor-decision/input.d.ts +2 -2
  233. package/dist/src/runtime/steps/auditor-decision/input.js +64 -20
  234. package/dist/src/runtime/steps/auditor-decision/parser.js +38 -23
  235. package/dist/src/runtime/steps/auditor-decision/projection.js +49 -99
  236. package/dist/src/runtime/steps/auditor-decision/prompt.d.ts +1 -1
  237. package/dist/src/runtime/steps/auditor-decision/prompt.js +9 -4
  238. package/dist/src/runtime/steps/auditor-decision/run.js +79 -47
  239. package/dist/src/runtime/steps/execution-agent/contracts.d.ts +8 -1
  240. package/dist/src/runtime/steps/execution-agent/contracts.js +2 -0
  241. package/dist/src/runtime/steps/execution-agent/decision-parsing.js +4 -0
  242. package/dist/src/runtime/steps/execution-agent/format.js +4 -3
  243. package/dist/src/runtime/steps/execution-agent/input.js +10 -11
  244. package/dist/src/runtime/steps/execution-agent/prompt.d.ts +1 -0
  245. package/dist/src/runtime/steps/execution-agent/prompt.js +11 -4
  246. package/dist/src/runtime/steps/execution-agent/state-context.js +10 -0
  247. package/dist/src/runtime/steps/execution-agent/work-plan-contract.d.ts +18 -0
  248. package/dist/src/runtime/steps/execution-agent/work-plan-contract.js +86 -0
  249. package/dist/src/runtime/steps/execution-agent/work-plan-decision-parsing.d.ts +2 -0
  250. package/dist/src/runtime/steps/execution-agent/work-plan-decision-parsing.js +38 -0
  251. package/dist/src/runtime/steps/execution-agent/work-plan-sources.d.ts +6 -0
  252. package/dist/src/runtime/steps/execution-agent/work-plan-sources.js +54 -0
  253. package/dist/src/runtime/steps/planner-decision/capability-brief.d.ts +40 -0
  254. package/dist/src/runtime/steps/planner-decision/capability-brief.js +47 -0
  255. package/dist/src/runtime/steps/planner-decision/input.d.ts +4 -2
  256. package/dist/src/runtime/steps/planner-decision/input.js +23 -13
  257. package/dist/src/runtime/steps/planner-decision/prompt.js +2 -2
  258. package/dist/src/runtime/steps/planner-decision/run.js +11 -7
  259. package/dist/src/runtime/steps/planner-graph/parser.js +0 -11
  260. package/dist/src/runtime/steps/planner-graph/prompt.js +2 -1
  261. package/dist/src/runtime/steps/supervisor-decision/capability-brief-readmission.d.ts +10 -0
  262. package/dist/src/runtime/steps/supervisor-decision/capability-brief-readmission.js +39 -0
  263. package/dist/src/runtime/steps/supervisor-decision/run.js +2 -1
  264. package/dist/src/runtime/steps/worker-decision/parser/accepted-decision.d.ts +3 -1
  265. package/dist/src/runtime/steps/worker-decision/parser/accepted-decision.js +20 -1
  266. package/dist/src/runtime/steps/worker-decision/parser/capability-batch-validation.d.ts +1 -1
  267. package/dist/src/runtime/steps/worker-decision/parser/capability-batch-validation.js +6 -6
  268. package/dist/src/runtime/steps/worker-decision/parser/capability-invocation-validation.js +2 -1
  269. package/dist/src/sessions/project-binding.d.ts +12 -0
  270. package/dist/src/sessions/project-binding.js +49 -0
  271. package/dist/src/sessions/record/projection.d.ts +6 -1
  272. package/dist/src/sessions/record/projection.js +1 -0
  273. package/dist/src/sessions/session-service.d.ts +2 -1
  274. package/dist/src/sessions/session-service.js +11 -1
  275. package/dist/src/sessions/types.d.ts +7 -0
  276. package/dist/src/shared/directory-authority/bootstrap.d.ts +1 -0
  277. package/dist/src/shared/directory-authority/bootstrap.js +118 -0
  278. package/dist/src/shared/directory-authority/command.d.ts +8 -0
  279. package/dist/src/shared/directory-authority/command.js +27 -0
  280. package/dist/src/shared/directory-authority/errors.d.ts +5 -0
  281. package/dist/src/shared/directory-authority/errors.js +10 -0
  282. package/dist/src/shared/directory-authority/index.d.ts +3 -0
  283. package/dist/src/shared/directory-authority/index.js +3 -0
  284. package/dist/src/shared/directory-authority/protocol.d.ts +11 -0
  285. package/dist/src/shared/directory-authority/protocol.js +62 -0
  286. package/dist/src/shared/directory-authority/task.d.ts +7 -0
  287. package/dist/src/shared/directory-authority/task.js +97 -0
  288. package/dist/src/web-ui/app/ARCHITECTURE.md +121 -1
  289. package/dist/src/web-ui/app/app-bootstrap.js +3 -0
  290. package/dist/src/web-ui/app/app-dom.js +3 -0
  291. package/dist/src/web-ui/app/app-state.js +38 -0
  292. package/dist/src/web-ui/app/app.js +76 -67
  293. package/dist/src/web-ui/app/components/config-workspace/config-model.js +23 -3
  294. package/dist/src/web-ui/app/components/config-workspace/dashboard-rendering.js +2 -0
  295. package/dist/src/web-ui/app/components/config-workspace/field-rendering.js +2 -0
  296. package/dist/src/web-ui/app/components/config-workspace/model-rendering.js +6 -0
  297. package/dist/src/web-ui/app/components/config-workspace/model-setup-entry.js +27 -0
  298. package/dist/src/web-ui/app/components/config-workspace/raw-config-repair.js +28 -0
  299. package/dist/src/web-ui/app/components/config-workspace/workspace-events.js +5 -0
  300. package/dist/src/web-ui/app/components/config-workspace/workspace-mutations.js +23 -3
  301. package/dist/src/web-ui/app/components/config-workspace/workspace-persistence.js +26 -8
  302. package/dist/src/web-ui/app/components/config-workspace/workspace-view.js +56 -0
  303. package/dist/src/web-ui/app/components/config-workspace.js +11 -0
  304. package/dist/src/web-ui/app/components/conversation-activity.d.ts +6 -0
  305. package/dist/src/web-ui/app/components/conversation-activity.js +10 -2
  306. package/dist/src/web-ui/app/components/conversation-file-action.js +33 -0
  307. package/dist/src/web-ui/app/components/conversation-file-focus.d.ts +12 -0
  308. package/dist/src/web-ui/app/components/conversation-file-focus.js +149 -0
  309. package/dist/src/web-ui/app/components/conversation-file-preview.d.ts +23 -0
  310. package/dist/src/web-ui/app/components/conversation-file-preview.js +247 -0
  311. package/dist/src/web-ui/app/components/conversation-role-cards.d.ts +6 -0
  312. package/dist/src/web-ui/app/components/conversation-role-cards.js +10 -2
  313. package/dist/src/web-ui/app/components/conversation-tool-evidence.d.ts +9 -0
  314. package/dist/src/web-ui/app/components/conversation-tool-evidence.js +129 -0
  315. package/dist/src/web-ui/app/components/conversation-tools.d.ts +6 -0
  316. package/dist/src/web-ui/app/components/conversation-tools.js +25 -105
  317. package/dist/src/web-ui/app/components/conversation-view.js +10 -1
  318. package/dist/src/web-ui/app/components/dashboard/workspace.js +19 -7
  319. package/dist/src/web-ui/app/components/model-setup/rendering.js +99 -0
  320. package/dist/src/web-ui/app/components/model-setup/save-flow.js +111 -0
  321. package/dist/src/web-ui/app/components/model-setup/save-outcome.js +16 -0
  322. package/dist/src/web-ui/app/components/model-setup/validation.js +125 -0
  323. package/dist/src/web-ui/app/components/model-setup/wizard.d.ts +44 -0
  324. package/dist/src/web-ui/app/components/model-setup/wizard.js +370 -0
  325. package/dist/src/web-ui/app/components/plugins/manager.js +200 -0
  326. package/dist/src/web-ui/app/components/plugins/rendering.js +124 -0
  327. package/dist/src/web-ui/app/components/plugins/view-state.js +123 -0
  328. package/dist/src/web-ui/app/components/project-creation.js +119 -0
  329. package/dist/src/web-ui/app/components/project-session-groups.js +95 -0
  330. package/dist/src/web-ui/app/components/runtime-config-activation.js +83 -0
  331. package/dist/src/web-ui/app/components/runtime-setup/bridge-guide.d.ts +9 -0
  332. package/dist/src/web-ui/app/components/runtime-setup/bridge-guide.js +198 -0
  333. package/dist/src/web-ui/app/components/runtime-setup/bridge-rendering.js +107 -0
  334. package/dist/src/web-ui/app/components/runtime-setup/commands.js +54 -0
  335. package/dist/src/web-ui/app/components/runtime-setup/configuration-recovery.js +25 -0
  336. package/dist/src/web-ui/app/components/runtime-setup/connection-form.js +154 -0
  337. package/dist/src/web-ui/app/components/runtime-setup/connection-state.js +71 -0
  338. package/dist/src/web-ui/app/components/runtime-setup/context-window.js +18 -0
  339. package/dist/src/web-ui/app/components/runtime-setup/embedding-credential-status.d.ts +15 -0
  340. package/dist/src/web-ui/app/components/runtime-setup/embedding-credential-status.js +87 -0
  341. package/dist/src/web-ui/app/components/runtime-setup/embedding-provider-receipt.js +30 -0
  342. package/dist/src/web-ui/app/components/runtime-setup/embedding-rendering.js +57 -0
  343. package/dist/src/web-ui/app/components/runtime-setup/embedding.js +284 -0
  344. package/dist/src/web-ui/app/components/runtime-setup/optional-steps.js +117 -0
  345. package/dist/src/web-ui/app/components/runtime-setup/plugins.js +173 -0
  346. package/dist/src/web-ui/app/components/runtime-setup/rendering.js +141 -0
  347. package/dist/src/web-ui/app/components/runtime-setup/validation.js +69 -0
  348. package/dist/src/web-ui/app/components/runtime-setup/view-state.js +58 -0
  349. package/dist/src/web-ui/app/components/runtime-setup/wizard-shell.js +27 -0
  350. package/dist/src/web-ui/app/components/runtime-setup-guide.d.ts +66 -5
  351. package/dist/src/web-ui/app/components/runtime-setup-guide.js +415 -461
  352. package/dist/src/web-ui/app/components/system-host/download.js +38 -0
  353. package/dist/src/web-ui/app/components/system-host/manager.js +249 -0
  354. package/dist/src/web-ui/app/components/system-host/rendering.js +88 -0
  355. package/dist/src/web-ui/app/components/system-host/setup-notice.js +87 -0
  356. package/dist/src/web-ui/app/components/system-host/visibility.js +35 -0
  357. package/dist/src/web-ui/app/components/tool-approval-card.d.ts +4 -0
  358. package/dist/src/web-ui/app/components/tool-approval-card.js +15 -0
  359. package/dist/src/web-ui/app/configuration-environment-refresh.js +118 -0
  360. package/dist/src/web-ui/app/configuration-feature.js +125 -4
  361. package/dist/src/web-ui/app/controllers/app-event-bindings.js +2 -0
  362. package/dist/src/web-ui/app/controllers/composer-workspace-controller.d.ts +1 -0
  363. package/dist/src/web-ui/app/controllers/composer-workspace-controller.js +4 -3
  364. package/dist/src/web-ui/app/controllers/conversation-file-preview-controller.d.ts +24 -0
  365. package/dist/src/web-ui/app/controllers/conversation-file-preview-controller.js +158 -0
  366. package/dist/src/web-ui/app/controllers/conversation-file-preview-feature.d.ts +19 -0
  367. package/dist/src/web-ui/app/controllers/conversation-file-preview-feature.js +63 -0
  368. package/dist/src/web-ui/app/controllers/conversation-session-controller.d.ts +1 -0
  369. package/dist/src/web-ui/app/controllers/conversation-session-controller.js +2 -0
  370. package/dist/src/web-ui/app/controllers/conversation-view-feature.js +28 -0
  371. package/dist/src/web-ui/app/controllers/dashboard-controller.js +17 -0
  372. package/dist/src/web-ui/app/controllers/projects-controller.d.ts +45 -0
  373. package/dist/src/web-ui/app/controllers/projects-controller.js +278 -0
  374. package/dist/src/web-ui/app/controllers/realtime-event-controller.js +3 -0
  375. package/dist/src/web-ui/app/controllers/runtime-onboarding-controller.js +13 -6
  376. package/dist/src/web-ui/app/controllers/runtime-selection-controller.d.ts +7 -1
  377. package/dist/src/web-ui/app/controllers/runtime-selection-controller.js +11 -95
  378. package/dist/src/web-ui/app/controllers/session-controller.js +64 -57
  379. package/dist/src/web-ui/app/controllers/tool-permission-mode-controller.d.ts +20 -0
  380. package/dist/src/web-ui/app/controllers/tool-permission-mode-controller.js +116 -0
  381. package/dist/src/web-ui/app/dashboard-feature.js +32 -10
  382. package/dist/src/web-ui/app/index.html +44 -7
  383. package/dist/src/web-ui/app/lib/conversation-file-preview.d.ts +12 -0
  384. package/dist/src/web-ui/app/lib/conversation-file-reference.d.ts +30 -0
  385. package/dist/src/web-ui/app/lib/conversation-file-reference.js +66 -0
  386. package/dist/src/web-ui/app/lib/tool-activity-event.d.ts +2 -0
  387. package/dist/src/web-ui/app/lib/tool-activity-event.js +18 -6
  388. package/dist/src/web-ui/app/lib/tool-activity-model.d.ts +2 -0
  389. package/dist/src/web-ui/app/lib/tool-activity-model.js +4 -2
  390. package/dist/src/web-ui/app/lib/tool-permission-mode.d.ts +16 -0
  391. package/dist/src/web-ui/app/lib/tool-permission-mode.js +60 -0
  392. package/dist/src/web-ui/app/lib/tool-process-activity-fields.js +102 -0
  393. package/dist/src/web-ui/app/projects-feature.js +134 -0
  394. package/dist/src/web-ui/app/runtime-onboarding-feature.d.ts +34 -0
  395. package/dist/src/web-ui/app/runtime-onboarding-feature.js +92 -0
  396. package/dist/src/web-ui/app/runtime-setup-page-lifecycle.d.ts +5 -0
  397. package/dist/src/web-ui/app/runtime-setup-page-lifecycle.js +13 -0
  398. package/dist/src/web-ui/app/services/client-preferences.d.ts +24 -0
  399. package/dist/src/web-ui/app/services/client-preferences.js +32 -19
  400. package/dist/src/web-ui/app/services/runtime-web-client/configuration.js +46 -0
  401. package/dist/src/web-ui/app/services/runtime-web-client/conversation-files.d.ts +28 -0
  402. package/dist/src/web-ui/app/services/runtime-web-client/conversation-files.js +75 -0
  403. package/dist/src/web-ui/app/services/runtime-web-client/projects.d.ts +19 -0
  404. package/dist/src/web-ui/app/services/runtime-web-client/projects.js +34 -0
  405. package/dist/src/web-ui/app/services/runtime-web-client/system-host.js +27 -0
  406. package/dist/src/web-ui/app/services/runtime-web-client.d.ts +52 -0
  407. package/dist/src/web-ui/app/services/runtime-web-client.js +35 -4
  408. package/dist/src/web-ui/app/styles/13-projects.css +272 -0
  409. package/dist/src/web-ui/app/styles/18-dashboard.css +0 -5
  410. package/dist/src/web-ui/app/styles/19-runtime-setup.css +411 -0
  411. package/dist/src/web-ui/app/styles/20-chat-composer.css +0 -384
  412. package/dist/src/web-ui/app/styles/29-conversation-file-preview.css +254 -0
  413. package/dist/src/web-ui/app/styles/37-runtime-activation.css +26 -0
  414. package/dist/src/web-ui/app/styles/38-schedule-workspace.css +1 -10
  415. package/dist/src/web-ui/app/styles/41-plugin-management.css +351 -0
  416. package/dist/src/web-ui/app/styles/42-runtime-setup-plugins.css +179 -0
  417. package/dist/src/web-ui/app/styles/43-model-setup.css +73 -0
  418. package/dist/src/web-ui/app/styles/44-model-provider-cards.css +63 -0
  419. package/dist/src/web-ui/app/styles/45-bridge-setup.css +44 -0
  420. package/dist/src/web-ui/app/styles/46-system-host.css +132 -0
  421. package/dist/src/web-ui/app/styles.css +10 -0
  422. package/dist/src/web-ui/config-dashboard-backend.d.ts +5 -0
  423. package/dist/src/web-ui/config-dashboard-backend.js +94 -114
  424. package/dist/src/web-ui/config-dashboard-model-identity.d.ts +7 -0
  425. package/dist/src/web-ui/config-dashboard-model-identity.js +45 -0
  426. package/dist/src/web-ui/config-dashboard-save-transaction.d.ts +5 -0
  427. package/dist/src/web-ui/config-dashboard-save-transaction.js +21 -0
  428. package/dist/src/web-ui/environment-config.d.ts +17 -0
  429. package/dist/src/web-ui/environment-config.js +60 -0
  430. package/dist/src/web-ui/forwarded-loopback-policy.d.ts +2 -0
  431. package/dist/src/web-ui/forwarded-loopback-policy.js +14 -0
  432. package/dist/src/web-ui/local-runtime/api-router.d.ts +7 -0
  433. package/dist/src/web-ui/local-runtime/api-router.js +136 -12
  434. package/dist/src/web-ui/local-runtime/config-mutation-request.d.ts +8 -0
  435. package/dist/src/web-ui/local-runtime/config-mutation-request.js +55 -0
  436. package/dist/src/web-ui/local-runtime/configuration-activation-environments.d.ts +22 -0
  437. package/dist/src/web-ui/local-runtime/configuration-activation-environments.js +106 -0
  438. package/dist/src/web-ui/local-runtime/configuration-activation-source.d.ts +7 -0
  439. package/dist/src/web-ui/local-runtime/configuration-activation-source.js +36 -0
  440. package/dist/src/web-ui/local-runtime/configuration-activation.d.ts +20 -0
  441. package/dist/src/web-ui/local-runtime/configuration-activation.js +107 -0
  442. package/dist/src/web-ui/local-runtime/contracts.d.ts +8 -0
  443. package/dist/src/web-ui/local-runtime/conversation-file-access.d.ts +30 -0
  444. package/dist/src/web-ui/local-runtime/conversation-file-access.js +131 -0
  445. package/dist/src/web-ui/local-runtime/conversation-file-content.d.ts +21 -0
  446. package/dist/src/web-ui/local-runtime/conversation-file-content.js +75 -0
  447. package/dist/src/web-ui/local-runtime/conversation-file-format.d.ts +12 -0
  448. package/dist/src/web-ui/local-runtime/conversation-file-format.js +87 -0
  449. package/dist/src/web-ui/local-runtime/conversation-file-native-open.d.ts +10 -0
  450. package/dist/src/web-ui/local-runtime/conversation-file-native-open.js +94 -0
  451. package/dist/src/web-ui/local-runtime/conversation-file-native-request.d.ts +4 -0
  452. package/dist/src/web-ui/local-runtime/conversation-file-native-request.js +72 -0
  453. package/dist/src/web-ui/local-runtime/conversation-file-routes.d.ts +11 -0
  454. package/dist/src/web-ui/local-runtime/conversation-file-routes.js +105 -0
  455. package/dist/src/web-ui/local-runtime/conversation-file-target.d.ts +14 -0
  456. package/dist/src/web-ui/local-runtime/conversation-file-target.js +158 -0
  457. package/dist/src/web-ui/local-runtime/environment-registry.d.ts +14 -0
  458. package/dist/src/web-ui/local-runtime/environment-registry.js +121 -6
  459. package/dist/src/web-ui/local-runtime/memory-onboarding-routes.d.ts +2 -1
  460. package/dist/src/web-ui/local-runtime/memory-onboarding-routes.js +15 -10
  461. package/dist/src/web-ui/local-runtime/model-setup-catalog.d.ts +17 -0
  462. package/dist/src/web-ui/local-runtime/model-setup-catalog.js +45 -0
  463. package/dist/src/web-ui/local-runtime/model-setup-identity.d.ts +16 -0
  464. package/dist/src/web-ui/local-runtime/model-setup-identity.js +20 -0
  465. package/dist/src/web-ui/local-runtime/model-setup-input.d.ts +24 -0
  466. package/dist/src/web-ui/local-runtime/model-setup-input.js +107 -0
  467. package/dist/src/web-ui/local-runtime/model-setup-provider.d.ts +17 -0
  468. package/dist/src/web-ui/local-runtime/model-setup-provider.js +68 -0
  469. package/dist/src/web-ui/local-runtime/model-setup-retry.d.ts +14 -0
  470. package/dist/src/web-ui/local-runtime/model-setup-retry.js +47 -0
  471. package/dist/src/web-ui/local-runtime/model-setup-routes.d.ts +12 -0
  472. package/dist/src/web-ui/local-runtime/model-setup-routes.js +50 -0
  473. package/dist/src/web-ui/local-runtime/model-setup-service.d.ts +30 -0
  474. package/dist/src/web-ui/local-runtime/model-setup-service.js +93 -0
  475. package/dist/src/web-ui/local-runtime/model-setup-validation.d.ts +5 -0
  476. package/dist/src/web-ui/local-runtime/model-setup-validation.js +33 -0
  477. package/dist/src/web-ui/local-runtime/plugin-management-routes.d.ts +14 -0
  478. package/dist/src/web-ui/local-runtime/plugin-management-routes.js +50 -0
  479. package/dist/src/web-ui/local-runtime/project-routes.d.ts +17 -0
  480. package/dist/src/web-ui/local-runtime/project-routes.js +93 -0
  481. package/dist/src/web-ui/local-runtime/provider-credential-identity.d.ts +3 -0
  482. package/dist/src/web-ui/local-runtime/provider-credential-identity.js +18 -0
  483. package/dist/src/web-ui/local-runtime/request-execution.d.ts +1 -0
  484. package/dist/src/web-ui/local-runtime/request-execution.js +8 -0
  485. package/dist/src/web-ui/local-runtime/runtime-availability.js +36 -7
  486. package/dist/src/web-ui/local-runtime/runtime-setup-completion.d.ts +13 -0
  487. package/dist/src/web-ui/local-runtime/runtime-setup-completion.js +28 -0
  488. package/dist/src/web-ui/local-runtime/runtime-setup-connection-edit.d.ts +13 -0
  489. package/dist/src/web-ui/local-runtime/runtime-setup-connection-edit.js +110 -0
  490. package/dist/src/web-ui/local-runtime/runtime-setup-credential-completion.d.ts +4 -0
  491. package/dist/src/web-ui/local-runtime/runtime-setup-credential-completion.js +21 -0
  492. package/dist/src/web-ui/local-runtime/runtime-setup-credentials.d.ts +14 -0
  493. package/dist/src/web-ui/local-runtime/runtime-setup-credentials.js +148 -0
  494. package/dist/src/web-ui/local-runtime/runtime-setup-draft-recovery.d.ts +7 -0
  495. package/dist/src/web-ui/local-runtime/runtime-setup-draft-recovery.js +18 -0
  496. package/dist/src/web-ui/local-runtime/runtime-setup-draft.d.ts +21 -0
  497. package/dist/src/web-ui/local-runtime/runtime-setup-draft.js +105 -0
  498. package/dist/src/web-ui/local-runtime/runtime-setup-embedding-invalidation.d.ts +8 -0
  499. package/dist/src/web-ui/local-runtime/runtime-setup-embedding-invalidation.js +40 -0
  500. package/dist/src/web-ui/local-runtime/runtime-setup-environment-assignment.d.ts +1 -0
  501. package/dist/src/web-ui/local-runtime/runtime-setup-environment-assignment.js +27 -0
  502. package/dist/src/web-ui/local-runtime/runtime-setup-input.d.ts +19 -0
  503. package/dist/src/web-ui/local-runtime/runtime-setup-input.js +82 -0
  504. package/dist/src/web-ui/local-runtime/runtime-setup-model-file.d.ts +7 -0
  505. package/dist/src/web-ui/local-runtime/runtime-setup-model-file.js +35 -0
  506. package/dist/src/web-ui/local-runtime/runtime-setup-provider-ownership-recovery.d.ts +4 -0
  507. package/dist/src/web-ui/local-runtime/runtime-setup-provider-ownership-recovery.js +23 -0
  508. package/dist/src/web-ui/local-runtime/runtime-setup-provider-retention.d.ts +11 -0
  509. package/dist/src/web-ui/local-runtime/runtime-setup-provider-retention.js +31 -0
  510. package/dist/src/web-ui/local-runtime/runtime-setup-provider.d.ts +11 -0
  511. package/dist/src/web-ui/local-runtime/runtime-setup-provider.js +60 -0
  512. package/dist/src/web-ui/local-runtime/runtime-setup-receipt-file.d.ts +8 -0
  513. package/dist/src/web-ui/local-runtime/runtime-setup-receipt-file.js +77 -0
  514. package/dist/src/web-ui/local-runtime/runtime-setup-routes.d.ts +35 -0
  515. package/dist/src/web-ui/local-runtime/runtime-setup-routes.js +56 -0
  516. package/dist/src/web-ui/local-runtime/runtime-setup-scaffold.d.ts +17 -0
  517. package/dist/src/web-ui/local-runtime/runtime-setup-scaffold.js +229 -0
  518. package/dist/src/web-ui/local-runtime/runtime-setup-service.d.ts +65 -0
  519. package/dist/src/web-ui/local-runtime/runtime-setup-service.js +195 -0
  520. package/dist/src/web-ui/local-runtime/runtime-setup-validation.d.ts +8 -0
  521. package/dist/src/web-ui/local-runtime/runtime-setup-validation.js +35 -0
  522. package/dist/src/web-ui/local-runtime/saved-model-catalog.d.ts +3 -0
  523. package/dist/src/web-ui/local-runtime/saved-model-catalog.js +20 -0
  524. package/dist/src/web-ui/local-runtime/setup-embedding-input.d.ts +8 -0
  525. package/dist/src/web-ui/local-runtime/setup-embedding-input.js +71 -0
  526. package/dist/src/web-ui/local-runtime/setup-embedding-provider.d.ts +13 -0
  527. package/dist/src/web-ui/local-runtime/setup-embedding-provider.js +114 -0
  528. package/dist/src/web-ui/local-runtime/setup-embedding-routes.d.ts +12 -0
  529. package/dist/src/web-ui/local-runtime/setup-embedding-routes.js +53 -0
  530. package/dist/src/web-ui/local-runtime/setup-embedding-service.d.ts +32 -0
  531. package/dist/src/web-ui/local-runtime/setup-embedding-service.js +59 -0
  532. package/dist/src/web-ui/local-runtime-backend.d.ts +1 -0
  533. package/dist/src/web-ui/local-runtime-backend.js +3 -0
  534. package/dist/src/web-ui/plugin-capability-selection.d.ts +14 -0
  535. package/dist/src/web-ui/plugin-capability-selection.js +48 -0
  536. package/dist/src/web-ui/plugin-management-catalog.d.ts +26 -0
  537. package/dist/src/web-ui/plugin-management-catalog.js +56 -0
  538. package/dist/src/web-ui/plugin-management-selection.d.ts +16 -0
  539. package/dist/src/web-ui/plugin-management-selection.js +71 -0
  540. package/dist/src/web-ui/plugin-management-service.d.ts +29 -0
  541. package/dist/src/web-ui/plugin-management-service.js +150 -0
  542. package/dist/src/web-ui/request-authority.d.ts +8 -0
  543. package/dist/src/web-ui/request-authority.js +129 -0
  544. package/dist/src/web-ui/runtime-setup-gateway-address.d.ts +3 -0
  545. package/dist/src/web-ui/runtime-setup-gateway-address.js +26 -0
  546. package/dist/src/web-ui/runtime-setup-gateway.d.ts +29 -0
  547. package/dist/src/web-ui/runtime-setup-gateway.js +177 -0
  548. package/dist/src/web-ui/runtime-setup-shutdown.d.ts +2 -0
  549. package/dist/src/web-ui/runtime-setup-shutdown.js +20 -0
  550. package/dist/src/web-ui/server.d.ts +7 -14
  551. package/dist/src/web-ui/server.js +53 -63
  552. package/dist/src/web-ui/session-read-state/service.d.ts +12 -2
  553. package/dist/src/web-ui/system-host-service.d.ts +19 -0
  554. package/dist/src/web-ui/system-host-service.js +159 -0
  555. package/dist/src/web-ui/system-host-setup/companion-bundle.d.ts +2 -0
  556. package/dist/src/web-ui/system-host-setup/companion-bundle.js +12 -0
  557. package/dist/src/web-ui/system-host-setup/companion-macos.d.ts +2 -0
  558. package/dist/src/web-ui/system-host-setup/companion-macos.js +74 -0
  559. package/dist/src/web-ui/system-host-setup/companion-windows.d.ts +2 -0
  560. package/dist/src/web-ui/system-host-setup/companion-windows.js +105 -0
  561. package/dist/src/web-ui/system-host-setup/installer-contract.d.ts +18 -0
  562. package/dist/src/web-ui/system-host-setup/installer-contract.js +51 -0
  563. package/dist/src/web-ui/system-host-setup/installers.d.ts +6 -0
  564. package/dist/src/web-ui/system-host-setup/installers.js +30 -0
  565. package/dist/src/web-ui/system-host-setup/native-authorization.d.ts +3 -0
  566. package/dist/src/web-ui/system-host-setup/native-authorization.js +11 -0
  567. package/dist/src/web-ui/system-host-setup/node-distribution.d.ts +19 -0
  568. package/dist/src/web-ui/system-host-setup/node-distribution.js +9 -0
  569. package/dist/src/web-ui/system-host-setup/readiness.d.ts +18 -0
  570. package/dist/src/web-ui/system-host-setup/readiness.js +70 -0
  571. package/dist/src/web-ui/system-host-setup/routes.d.ts +20 -0
  572. package/dist/src/web-ui/system-host-setup/routes.js +121 -0
  573. package/dist/src/web-ui/system-host-setup/windows-script-wrapper.d.ts +2 -0
  574. package/dist/src/web-ui/system-host-setup/windows-script-wrapper.js +17 -0
  575. package/dist/src/web-ui/system-host-setup/wsl-interop-config.d.ts +3 -0
  576. package/dist/src/web-ui/system-host-setup/wsl-interop-config.js +67 -0
  577. package/dist/src/web-ui/system-host-setup/wsl-interop-windows.d.ts +1 -0
  578. package/dist/src/web-ui/system-host-setup/wsl-interop-windows.js +49 -0
  579. package/dist/src/web-ui/system-host-upgrade-authority.d.ts +5 -0
  580. package/dist/src/web-ui/system-host-upgrade-authority.js +13 -0
  581. package/docs/architecture.md +6 -1
  582. package/docs/installation.md +53 -17
  583. package/docs/known-limitations.md +14 -0
  584. package/docs/plugins.md +137 -26
  585. package/docs/projects-and-full-plus.md +218 -0
  586. package/docs/runtime-invariant-coverage.md +6 -3
  587. package/docs/runtime-prompt-policy-contracts.md +37 -5
  588. package/docs/runtime-public-contracts.md +17 -0
  589. package/package.json +5 -2
  590. package/plugins/exec/plugin.json +30 -9
  591. package/plugins/exec/skills/exec_process_skill/SKILL.md +1 -0
  592. package/plugins/exec/skills/exec_skill/SKILL.md +9 -10
  593. package/plugins/exec/source/handlers.ts +4 -38
  594. package/plugins/exec/source/paths.ts +53 -49
  595. package/plugins/exec/source/process-manager.ts +1 -20
  596. package/plugins/exec/source/shell-platform.ts +29 -0
  597. package/plugins/exec/source/types.ts +6 -4
  598. package/plugins/exec/source/validation.ts +33 -198
  599. package/plugins/exec/src/index.cjs +87 -222
  600. package/plugins/filesystem/plugin.json +1 -1
  601. package/plugins/filesystem/skills/dev_view_skill/SKILL.md +7 -0
  602. package/plugins/filesystem/source/atomic-write.ts +15 -3
  603. package/plugins/filesystem/source/bounded-io.ts +5 -99
  604. package/plugins/filesystem/source/dev-view.ts +2 -1
  605. package/plugins/filesystem/source/directory-authority-write.ts +68 -0
  606. package/plugins/filesystem/source/directory-sample-task.ts +23 -0
  607. package/plugins/filesystem/source/directory-sample.ts +132 -0
  608. package/plugins/filesystem/source/directory-write-task.ts +160 -0
  609. package/plugins/filesystem/source/edit-file.ts +3 -0
  610. package/plugins/filesystem/source/file-output-presentation.ts +42 -0
  611. package/plugins/filesystem/source/mutation-parent.ts +29 -9
  612. package/plugins/filesystem/source/view-locator.ts +141 -0
  613. package/plugins/filesystem/source/view-window.ts +12 -25
  614. package/plugins/filesystem/source/write-file.ts +8 -0
  615. package/plugins/filesystem/src/index.cjs +855 -153
  616. package/plugins/local-search/source/index.ts +2 -0
  617. package/plugins/local-search/source/paths.ts +30 -7
  618. package/plugins/local-search/source/ripgrep-process.ts +69 -0
  619. package/plugins/local-search/source/ripgrep.ts +19 -23
  620. package/plugins/local-search/src/index.cjs +295 -32
  621. package/plugins/system/plugin.json +374 -0
  622. package/plugins/system/skills/system_actions/SKILL.md +31 -0
  623. package/plugins/system/source/application-catalog.ts +237 -0
  624. package/plugins/system/source/application-launch.ts +113 -0
  625. package/plugins/system/source/application-observation.ts +78 -0
  626. package/plugins/system/source/commands.ts +106 -0
  627. package/plugins/system/source/companion/autostart.ts +185 -0
  628. package/plugins/system/source/companion/broker-client.ts +183 -0
  629. package/plugins/system/source/companion/broker-location.ts +89 -0
  630. package/plugins/system/source/companion/broker-server.ts +169 -0
  631. package/plugins/system/source/companion/connection.ts +211 -0
  632. package/plugins/system/source/companion/liveness.ts +23 -0
  633. package/plugins/system/source/companion/native-address.ts +55 -0
  634. package/plugins/system/source/companion/native-identity.ts +26 -0
  635. package/plugins/system/source/companion/native-messages.ts +100 -0
  636. package/plugins/system/source/companion/native-session.ts +268 -0
  637. package/plugins/system/source/companion/native-state.ts +135 -0
  638. package/plugins/system/source/companion/native-supervisor.ts +98 -0
  639. package/plugins/system/source/companion/pairing-store.ts +110 -0
  640. package/plugins/system/source/companion/private-store.ts +58 -0
  641. package/plugins/system/source/companion/process-owner-identity.ts +190 -0
  642. package/plugins/system/source/companion/protocol.ts +108 -0
  643. package/plugins/system/source/contracts.ts +44 -0
  644. package/plugins/system/source/elevation.ts +88 -0
  645. package/plugins/system/source/handlers.ts +120 -0
  646. package/plugins/system/source/host-dispatch.ts +106 -0
  647. package/plugins/system/source/host-evidence.ts +72 -0
  648. package/plugins/system/source/host-observation.ts +66 -0
  649. package/plugins/system/source/index.ts +8 -0
  650. package/plugins/system/source/process-result.ts +111 -0
  651. package/plugins/system/source/process-runner.ts +104 -0
  652. package/plugins/system/source/request-system-modules.ts +117 -0
  653. package/plugins/system/source/request-target-snapshot.ts +163 -0
  654. package/plugins/system/source/target-observation.ts +43 -0
  655. package/plugins/system/source/targets.ts +147 -0
  656. package/plugins/system/src/index.cjs +1730 -0
  657. package/src/runtime/README.md +36 -8
  658. package/src/runtime/local-host/README.md +7 -0
  659. package/dist/src/runtime/steps/planner-decision/capability-catalog-context.d.ts +0 -14
  660. package/dist/src/runtime/steps/planner-decision/capability-catalog-context.js +0 -87
@@ -0,0 +1,1730 @@
1
+ // GENERATED FILE - DO NOT EDIT.
2
+ // Source: plugins/system/source/index.ts
3
+ // Run "npm run build:plugins" after editing plugin source.
4
+ "use strict";
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+
23
+ // plugins/system/source/index.ts
24
+ var index_exports = {};
25
+ __export(index_exports, {
26
+ default: () => index_default
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+
30
+ // src/plugin-sdk/parameters.ts
31
+ var PluginParameterError = class extends TypeError {
32
+ code;
33
+ parameter;
34
+ constructor(params) {
35
+ super(params.message ?? `${params.parameter}: ${params.code}`);
36
+ this.name = "PluginParameterError";
37
+ this.code = params.code;
38
+ this.parameter = params.parameter;
39
+ }
40
+ };
41
+ function isPluginParameterError(error) {
42
+ return error instanceof PluginParameterError;
43
+ }
44
+ function stringOptions(input) {
45
+ return typeof input === "string" ? { name: input } : input;
46
+ }
47
+ function parameterName(options) {
48
+ return options.name ?? options.parameter ?? "value";
49
+ }
50
+ function parseString(value, options) {
51
+ if (value === void 0 || value === null) return void 0;
52
+ const parameter = parameterName(options);
53
+ if (typeof value !== "string") {
54
+ throw new PluginParameterError({
55
+ code: "plugin_parameter_invalid",
56
+ parameter
57
+ });
58
+ }
59
+ const parsed = options.trim === false ? value : value.trim();
60
+ if (options.minLength !== void 0 && parsed.length < options.minLength || options.maxLength !== void 0 && parsed.length > options.maxLength) {
61
+ throw new PluginParameterError({
62
+ code: "plugin_parameter_invalid",
63
+ parameter
64
+ });
65
+ }
66
+ return parsed;
67
+ }
68
+ function readOptionalString(value, input = {}) {
69
+ return parseString(value, stringOptions(input));
70
+ }
71
+ function readRequiredString(value, input = {}) {
72
+ const options = stringOptions(input);
73
+ const parameter = parameterName(options);
74
+ const parsed = parseString(value, {
75
+ ...options,
76
+ minLength: Math.max(options.minLength ?? 1, 1)
77
+ });
78
+ if (parsed === void 0) {
79
+ throw new PluginParameterError({
80
+ code: "plugin_parameter_required",
81
+ parameter
82
+ });
83
+ }
84
+ return parsed;
85
+ }
86
+ function readBoundedInteger(value, options) {
87
+ const parameter = parameterName(options);
88
+ const candidate = value === void 0 ? options.defaultValue : value;
89
+ if (!Number.isSafeInteger(candidate) || candidate < options.minimum || candidate > options.maximum) {
90
+ throw new PluginParameterError({
91
+ code: candidate === void 0 ? "plugin_parameter_required" : "plugin_parameter_invalid",
92
+ parameter
93
+ });
94
+ }
95
+ return candidate;
96
+ }
97
+
98
+ // src/plugin-sdk/paths.ts
99
+ function runtimeToolPathErrorCode(error) {
100
+ if (!(error instanceof Error) || !("code" in error) || typeof error.code !== "string" || !error.code.startsWith("runtime_tool_path_")) {
101
+ return void 0;
102
+ }
103
+ return error.code;
104
+ }
105
+
106
+ // src/plugin-sdk/plugin.ts
107
+ function defineRuntimePlugin(definition) {
108
+ return definition;
109
+ }
110
+
111
+ // src/plugin-sdk/results.ts
112
+ var PLUGIN_RESULT_SERIALIZED_MAX_BYTES = 128 * 1024;
113
+ function resultBoundsFailure(code, message) {
114
+ return {
115
+ ok: false,
116
+ output: message,
117
+ producedNewInformation: false,
118
+ error: message,
119
+ errorCode: code
120
+ };
121
+ }
122
+ function enforcePluginResultByteBudget(result) {
123
+ let serialized;
124
+ try {
125
+ const candidate = JSON.stringify(result);
126
+ if (candidate === void 0) {
127
+ return resultBoundsFailure(
128
+ "plugin_result_not_json_safe",
129
+ "The plugin produced a result that is not JSON-safe."
130
+ );
131
+ }
132
+ serialized = candidate;
133
+ } catch {
134
+ return resultBoundsFailure(
135
+ "plugin_result_not_json_safe",
136
+ "The plugin produced a result that is not JSON-safe."
137
+ );
138
+ }
139
+ if (Buffer.byteLength(serialized, "utf8") > PLUGIN_RESULT_SERIALIZED_MAX_BYTES) {
140
+ return resultBoundsFailure(
141
+ "plugin_result_too_large",
142
+ `The plugin result exceeds the ${PLUGIN_RESULT_SERIALIZED_MAX_BYTES}-byte safety limit.`
143
+ );
144
+ }
145
+ return result;
146
+ }
147
+ function successResult(input) {
148
+ return enforcePluginResultByteBudget({
149
+ ok: true,
150
+ output: input.output,
151
+ producedNewInformation: input.producedNewInformation ?? true,
152
+ ...input.progress !== void 0 ? { progress: input.progress } : {},
153
+ ...input.actions !== void 0 ? { actions: input.actions } : {},
154
+ ...input.exitCode !== void 0 ? { exitCode: input.exitCode } : {},
155
+ ...input.stdout !== void 0 ? { stdout: input.stdout } : {},
156
+ ...input.stderr !== void 0 ? { stderr: input.stderr } : {},
157
+ ...input.data !== void 0 ? { data: input.data } : {}
158
+ });
159
+ }
160
+ function failureResult(input) {
161
+ return enforcePluginResultByteBudget({
162
+ ok: false,
163
+ output: input.output ?? input.message,
164
+ producedNewInformation: false,
165
+ ...input.progress !== void 0 ? { progress: input.progress } : {},
166
+ ...input.actions !== void 0 ? { actions: input.actions } : {},
167
+ ...input.exitCode !== void 0 ? { exitCode: input.exitCode } : {},
168
+ ...input.stdout !== void 0 ? { stdout: input.stdout } : {},
169
+ ...input.stderr !== void 0 ? { stderr: input.stderr } : {},
170
+ ...input.data !== void 0 ? { data: input.data } : {},
171
+ error: input.message,
172
+ errorCode: input.errorCode
173
+ });
174
+ }
175
+ function failureFromError(error, options) {
176
+ const pathCode = runtimeToolPathErrorCode(error);
177
+ const parameterCode = isPluginParameterError(error) ? error.code : void 0;
178
+ const errorCode = pathCode ?? parameterCode ?? options.fallbackCode;
179
+ const message = pathCode ?? parameterCode ?? options.fallbackMessage;
180
+ return failureResult({
181
+ errorCode,
182
+ message,
183
+ output: options.operation ? `${options.operation} failed: ${message}` : message
184
+ });
185
+ }
186
+
187
+ // plugins/system/source/application-catalog.ts
188
+ var import_promises2 = require("node:fs/promises");
189
+ var import_node_os2 = require("node:os");
190
+ var import_node_path2 = require("node:path");
191
+
192
+ // plugins/system/source/contracts.ts
193
+ var SystemOperationError = class extends Error {
194
+ constructor(code, message) {
195
+ super(message);
196
+ this.code = code;
197
+ }
198
+ code;
199
+ };
200
+
201
+ // plugins/system/source/targets.ts
202
+ var import_node_fs2 = require("node:fs");
203
+ var import_promises = require("node:fs/promises");
204
+ var import_node_path = require("node:path");
205
+
206
+ // plugins/system/source/process-runner.ts
207
+ var import_node_child_process = require("node:child_process");
208
+ var STREAM_MAX_CHARS = 16e3;
209
+ function runSystemProcess(input) {
210
+ if (input.abortSignal?.aborted)
211
+ return Promise.resolve({
212
+ exitCode: null,
213
+ stdout: "",
214
+ stderr: "",
215
+ status: "aborted",
216
+ outputTruncated: false
217
+ });
218
+ return new Promise((resolve) => {
219
+ const streamMaxChars = Math.min(
220
+ input.outputMaxChars ?? STREAM_MAX_CHARS,
221
+ 512e3
222
+ );
223
+ let stdout = "";
224
+ let stderr = "";
225
+ let truncated = false;
226
+ let settled = false;
227
+ let status = "completed";
228
+ let spawnedProcess;
229
+ let timeout;
230
+ let stopGrace;
231
+ const finish = (exitCode) => {
232
+ if (settled) return;
233
+ settled = true;
234
+ if (timeout) clearTimeout(timeout);
235
+ if (stopGrace) clearTimeout(stopGrace);
236
+ input.abortSignal?.removeEventListener("abort", abort);
237
+ resolve(
238
+ Object.freeze({
239
+ exitCode,
240
+ stdout,
241
+ stderr,
242
+ status,
243
+ outputTruncated: truncated,
244
+ ...spawnedProcess ? { spawnedProcess } : {}
245
+ })
246
+ );
247
+ };
248
+ const child = (0, import_node_child_process.spawn)(input.executable, [...input.args], {
249
+ ...input.cwd ? { cwd: input.cwd } : {},
250
+ stdio: ["ignore", "pipe", "pipe"],
251
+ windowsHide: true,
252
+ detached: process.platform !== "win32"
253
+ });
254
+ child.once("spawn", () => {
255
+ if (child.pid === void 0) return;
256
+ spawnedProcess = {
257
+ pid: child.pid,
258
+ pidNamespace: "runtime_os",
259
+ executable: input.executable,
260
+ identitySource: "spawn_arguments"
261
+ };
262
+ });
263
+ const stop = (reason) => {
264
+ if (settled) return;
265
+ status = reason;
266
+ const pid = child.pid;
267
+ if (pid && process.platform !== "win32") {
268
+ try {
269
+ process.kill(-pid, "SIGKILL");
270
+ } catch {
271
+ child.kill("SIGKILL");
272
+ }
273
+ } else {
274
+ child.kill("SIGKILL");
275
+ }
276
+ stopGrace = setTimeout(() => finish(null), 1e3);
277
+ stopGrace.unref();
278
+ };
279
+ const abort = () => stop("aborted");
280
+ child.stdout.setEncoding("utf8");
281
+ child.stderr.setEncoding("utf8");
282
+ child.stdout.on("data", (chunk) => {
283
+ const remaining = streamMaxChars - stdout.length;
284
+ truncated ||= chunk.length > remaining;
285
+ stdout += chunk.slice(0, remaining);
286
+ });
287
+ child.stderr.on("data", (chunk) => {
288
+ const remaining = streamMaxChars - stderr.length;
289
+ truncated ||= chunk.length > remaining;
290
+ stderr += chunk.slice(0, remaining);
291
+ });
292
+ child.once("error", (error) => {
293
+ status = "spawn_failed";
294
+ stderr = error.message.slice(0, STREAM_MAX_CHARS);
295
+ finish(null);
296
+ });
297
+ child.once("close", (code) => finish(code));
298
+ timeout = setTimeout(() => stop("timeout"), input.timeoutMs ?? 3e4);
299
+ timeout.unref();
300
+ input.abortSignal?.addEventListener("abort", abort, { once: true });
301
+ if (input.abortSignal?.aborted) abort();
302
+ });
303
+ }
304
+
305
+ // plugins/system/source/host-observation.ts
306
+ var import_node_fs = require("node:fs");
307
+ var import_node_os = require("node:os");
308
+ function readSystemHostFacts() {
309
+ return {
310
+ platform: process.platform,
311
+ kernelRelease: (0, import_node_os.release)(),
312
+ containerMarker: hasSystemContainerMarker()
313
+ };
314
+ }
315
+ function hasSystemContainerMarker() {
316
+ if ((0, import_node_fs.existsSync)("/.dockerenv")) return true;
317
+ return (0, import_node_fs.existsSync)("/run/.containerenv");
318
+ }
319
+ function isContainerHostRuntime(facts) {
320
+ if (facts.platform !== "linux") return false;
321
+ return facts.containerMarker === true;
322
+ }
323
+ function isWslHostRuntime(facts) {
324
+ if (facts.platform !== "linux") return false;
325
+ if (isContainerHostRuntime(facts)) return false;
326
+ return /microsoft/iu.test(facts.kernelRelease);
327
+ }
328
+ function runtimeOs(platform) {
329
+ if (platform === "win32") return "windows";
330
+ if (platform === "darwin") return "macos";
331
+ if (platform === "linux") return "linux";
332
+ return "unsupported";
333
+ }
334
+ function observeSystemHost(facts = readSystemHostFacts()) {
335
+ const runtime = runtimeOs(facts.platform);
336
+ if (isContainerHostRuntime(facts)) return {
337
+ runtimeOs: runtime,
338
+ kernelRelease: facts.kernelRelease,
339
+ environment: "container",
340
+ inferredHostOs: "unknown",
341
+ hostInferenceSource: "container_marker",
342
+ windowsExecutionRequiresProbe: false,
343
+ guiSessionStatus: "not_checked"
344
+ };
345
+ const wsl = isWslHostRuntime(facts);
346
+ const inferredHostOs = wsl ? "windows" : runtime;
347
+ return {
348
+ runtimeOs: runtime,
349
+ kernelRelease: facts.kernelRelease,
350
+ environment: wsl ? "wsl_guest" : "not_identified_as_wsl",
351
+ inferredHostOs,
352
+ hostInferenceSource: wsl ? "wsl_kernel_signature" : "runtime_platform_only",
353
+ windowsExecutionRequiresProbe: inferredHostOs === "windows",
354
+ guiSessionStatus: "not_checked"
355
+ };
356
+ }
357
+
358
+ // plugins/system/source/targets.ts
359
+ function powershellArguments(script) {
360
+ const preamble = "$ErrorActionPreference='Stop';[Console]::OutputEncoding=[Text.UTF8Encoding]::new();$global:LASTEXITCODE=0;";
361
+ return [
362
+ "-NoLogo",
363
+ "-NoProfile",
364
+ "-NonInteractive",
365
+ "-EncodedCommand",
366
+ Buffer.from(preamble + script, "utf16le").toString("base64")
367
+ ];
368
+ }
369
+ function powershellLiteral(value) {
370
+ return "'" + value.replaceAll("'", "''") + "'";
371
+ }
372
+ function shellLiteral(value) {
373
+ return "'" + value.replaceAll("'", `'"'"'`) + "'";
374
+ }
375
+ function windowsSystemCommandScript(command, cwd) {
376
+ return `Set-Location -LiteralPath ${powershellLiteral(cwd)};${command}
377
+ if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }`;
378
+ }
379
+ async function findExecutable(name, additional = []) {
380
+ const candidates = [
381
+ ...additional,
382
+ ...(process.env.PATH ?? "").split(import_node_path.delimiter).filter(Boolean).map((directory) => (0, import_node_path.join)(directory, name))
383
+ ];
384
+ for (const candidate of candidates) {
385
+ try {
386
+ await (0, import_promises.access)(candidate, import_node_fs2.constants.X_OK);
387
+ return candidate;
388
+ } catch {
389
+ }
390
+ }
391
+ return void 0;
392
+ }
393
+ async function resolveSystemTarget(id, run = runSystemProcess) {
394
+ if (isNativeUnixTarget(id)) return resolveNativeUnixTarget(id);
395
+ if (id !== "windows")
396
+ throw new SystemOperationError(
397
+ "system_target_unavailable",
398
+ `The runtime is not executing on ${id}.`
399
+ );
400
+ const nativeWindows = process.platform === "win32";
401
+ const wslWindows = isWslHostRuntime(readSystemHostFacts());
402
+ if (!hasWindowsExecutionTransport(nativeWindows, wslWindows))
403
+ throw new SystemOperationError(
404
+ "system_target_unavailable",
405
+ "No Windows execution transport is available on this host."
406
+ );
407
+ const canonicalShell = nativeWindows ? (0, import_node_path.join)(
408
+ process.env.SystemRoot ?? "C:\\Windows",
409
+ "System32",
410
+ "WindowsPowerShell",
411
+ "v1.0",
412
+ "powershell.exe"
413
+ ) : "/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe";
414
+ const shell = await findExecutable("powershell.exe", [canonicalShell]);
415
+ if (!shell)
416
+ throw new SystemOperationError(
417
+ "system_target_unavailable",
418
+ "A native Windows PowerShell executable was not found; Windows interop is unavailable."
419
+ );
420
+ const probe = await run({
421
+ executable: shell,
422
+ args: powershellArguments("[Environment]::OSVersion.Platform.ToString()"),
423
+ timeoutMs: 5e3
424
+ });
425
+ if (!hasObservedWindowsPlatform(probe))
426
+ throw new SystemOperationError(
427
+ "system_target_unavailable",
428
+ "Windows PowerShell could not execute. WSL executable interop may be disabled; enable a real Windows execution transport on the host."
429
+ );
430
+ return { id, transport: nativeWindows ? "native" : "wsl_interop", shell };
431
+ }
432
+ function readSystemTargetId(value) {
433
+ if (value === "linux" || value === "macos" || value === "windows")
434
+ return value;
435
+ throw new SystemOperationError(
436
+ "system_target_required",
437
+ "Select an explicit target returned by system_targets: linux, macos, or windows."
438
+ );
439
+ }
440
+ function isNativeUnixTarget(id) {
441
+ if (id === "linux") return process.platform === "linux";
442
+ if (id === "macos") return process.platform === "darwin";
443
+ return false;
444
+ }
445
+ async function resolveNativeUnixTarget(id) {
446
+ try {
447
+ await (0, import_promises.access)("/bin/bash", import_node_fs2.constants.X_OK);
448
+ } catch {
449
+ throw new SystemOperationError(
450
+ "system_target_unavailable",
451
+ "The native target has no executable /bin/bash."
452
+ );
453
+ }
454
+ return { id, transport: "native", shell: "/bin/bash" };
455
+ }
456
+ function hasWindowsExecutionTransport(nativeWindows, wslWindows) {
457
+ if (nativeWindows) return true;
458
+ return wslWindows;
459
+ }
460
+ function hasObservedWindowsPlatform(probe) {
461
+ if (probe.status !== "completed") return false;
462
+ if (probe.exitCode !== 0) return false;
463
+ return probe.stdout.trim() === "Win32NT";
464
+ }
465
+
466
+ // plugins/system/source/application-catalog.ts
467
+ var CATALOG_ENTRY_LIMIT = 2e3;
468
+ function isAbsentOptionalCatalogRoot(error, depth) {
469
+ if (depth !== 0 || !(error instanceof Error)) return false;
470
+ return "code" in error && error.code === "ENOENT";
471
+ }
472
+ async function readApplicationDirectory(path, depth) {
473
+ try {
474
+ return {
475
+ entries: await (0, import_promises2.readdir)(path, { withFileTypes: true }),
476
+ complete: true
477
+ };
478
+ } catch (error) {
479
+ return { entries: [], complete: isAbsentOptionalCatalogRoot(error, depth) };
480
+ }
481
+ }
482
+ async function collectApplicationPaths(roots, extension) {
483
+ const pending = roots.map((path) => ({ path, depth: 0 }));
484
+ const paths = [];
485
+ let scannedEntries = 0;
486
+ let complete = true;
487
+ while (pending.length > 0 && scannedEntries < 2e4 && paths.length < CATALOG_ENTRY_LIMIT) {
488
+ const current = pending.shift();
489
+ const directory = await readApplicationDirectory(
490
+ current.path,
491
+ current.depth
492
+ );
493
+ complete = complete && directory.complete;
494
+ for (const entry of directory.entries) {
495
+ scannedEntries += 1;
496
+ if (scannedEntries >= 2e4 || paths.length >= CATALOG_ENTRY_LIMIT) {
497
+ complete = false;
498
+ break;
499
+ }
500
+ const absolute = (0, import_node_path2.join)(current.path, entry.name);
501
+ if (entry.name.endsWith(extension)) {
502
+ paths.push(absolute);
503
+ continue;
504
+ }
505
+ if (!entry.isDirectory()) continue;
506
+ if (current.depth >= 4) {
507
+ complete = false;
508
+ continue;
509
+ }
510
+ pending.push({ path: absolute, depth: current.depth + 1 });
511
+ }
512
+ }
513
+ return {
514
+ paths: [...new Set(paths)].sort(),
515
+ complete: complete && pending.length === 0
516
+ };
517
+ }
518
+ function parseDesktopApplication(content, path) {
519
+ const section = content.split(/^\[Desktop Entry\]\s*$/mu)[1]?.split(/^\[/mu)[0];
520
+ if (!section) return void 0;
521
+ const fields = new Map(
522
+ section.split(/\r?\n/u).map((line) => {
523
+ const split = line.indexOf("=");
524
+ return [
525
+ line.slice(0, split).trim(),
526
+ line.slice(split + 1).trim()
527
+ ];
528
+ })
529
+ );
530
+ if (fields.get("Type") !== "Application") return void 0;
531
+ if (fields.get("Hidden") === "true") return void 0;
532
+ const name = fields.get("Name");
533
+ if (!name) return void 0;
534
+ return { id: path, name, target: "linux" };
535
+ }
536
+ async function windowsApplications(target, run) {
537
+ const result = await run({
538
+ executable: target.shell,
539
+ args: powershellArguments(
540
+ "@(Get-StartApps | Sort-Object AppID | Select-Object -First 2001 Name,AppID) | ConvertTo-Json -Compress"
541
+ ),
542
+ timeoutMs: 15e3,
543
+ outputMaxChars: 512e3
544
+ });
545
+ if (result.status !== "completed" || result.exitCode !== 0 || result.outputTruncated)
546
+ throw new SystemOperationError(
547
+ "system_application_catalog_unavailable",
548
+ "Windows Start application catalog could not be read completely within the observation budget."
549
+ );
550
+ let entries;
551
+ try {
552
+ entries = JSON.parse(result.stdout || "[]");
553
+ } catch {
554
+ throw new SystemOperationError(
555
+ "system_application_catalog_invalid",
556
+ "Windows returned an unreadable application catalog."
557
+ );
558
+ }
559
+ const rows = Array.isArray(entries) ? entries : [entries];
560
+ const applications = rows.slice(0, CATALOG_ENTRY_LIMIT).flatMap((entry) => {
561
+ if (!entry || typeof entry !== "object") return [];
562
+ if (!("Name" in entry) || !("AppID" in entry)) return [];
563
+ if (typeof entry.Name !== "string" || typeof entry.AppID !== "string")
564
+ return [];
565
+ return [
566
+ { id: entry.AppID, name: entry.Name, target: "windows" }
567
+ ];
568
+ });
569
+ return {
570
+ applications,
571
+ complete: rows.length <= CATALOG_ENTRY_LIMIT,
572
+ scope: {
573
+ source: "windows_start_apps",
574
+ roots: [],
575
+ includesExecutableSearch: false,
576
+ includesOtherTargets: false
577
+ }
578
+ };
579
+ }
580
+ async function readSystemApplications(target, run) {
581
+ if (target.id === "windows") return windowsApplications(target, run);
582
+ if (target.id === "macos") {
583
+ const roots2 = [
584
+ "/Applications",
585
+ "/System/Applications",
586
+ (0, import_node_path2.join)((0, import_node_os2.homedir)(), "Applications")
587
+ ];
588
+ const catalog2 = await collectApplicationPaths(roots2, ".app");
589
+ return {
590
+ applications: catalog2.paths.map((id) => ({
591
+ id,
592
+ name: (0, import_node_path2.basename)(id, ".app"),
593
+ target: "macos"
594
+ })),
595
+ complete: catalog2.complete,
596
+ scope: {
597
+ source: "macos_application_bundles",
598
+ roots: roots2,
599
+ includesExecutableSearch: false,
600
+ includesOtherTargets: false
601
+ }
602
+ };
603
+ }
604
+ const dataHome = process.env.XDG_DATA_HOME ?? (0, import_node_path2.join)((0, import_node_os2.homedir)(), ".local", "share");
605
+ const dataDirs = (process.env.XDG_DATA_DIRS ?? "/usr/local/share:/usr/share").split(":");
606
+ const roots = [dataHome, ...dataDirs].map(
607
+ (directory) => (0, import_node_path2.join)(directory, "applications")
608
+ );
609
+ const catalog = await collectApplicationPaths(roots, ".desktop");
610
+ const applications = [];
611
+ let complete = catalog.complete;
612
+ for (const path of catalog.paths) {
613
+ let content;
614
+ try {
615
+ content = await (0, import_promises2.readFile)(path, "utf8");
616
+ } catch {
617
+ complete = false;
618
+ continue;
619
+ }
620
+ if (isDesktopEntryOverBudget(content)) {
621
+ complete = false;
622
+ continue;
623
+ }
624
+ const application = parseDesktopApplication(content, path);
625
+ if (application) applications.push(application);
626
+ }
627
+ return {
628
+ applications,
629
+ complete,
630
+ scope: {
631
+ source: "linux_desktop_entries",
632
+ roots,
633
+ includesExecutableSearch: false,
634
+ includesOtherTargets: false
635
+ }
636
+ };
637
+ }
638
+ function isDesktopEntryOverBudget(content) {
639
+ return content.length > 128e3;
640
+ }
641
+
642
+ // plugins/system/source/application-observation.ts
643
+ var SUMMARY_MAX_CHARS = 7e3;
644
+ var SUMMARY_ROOT_LIMIT = 16;
645
+ var SUMMARY_ROOT_CHARS = 256;
646
+ function systemApplicationObservation(target, catalog, query, limit) {
647
+ const matches = catalog.applications.filter(
648
+ (application) => matchesApplicationQuery(application.name, application.id, query)
649
+ );
650
+ const data = {
651
+ target: target.id,
652
+ transport: target.transport,
653
+ absenceConclusionSupported: false,
654
+ completenessMeaning: "declared_catalog_sources_only",
655
+ catalogScope: catalog.scope,
656
+ catalogComplete: catalog.complete,
657
+ observedMatches: matches.length,
658
+ omittedMatches: Math.max(0, matches.length - limit),
659
+ applications: matches.slice(0, limit)
660
+ };
661
+ const summaryRoots = catalog.scope.roots.slice(0, SUMMARY_ROOT_LIMIT).map((root) => root.slice(0, SUMMARY_ROOT_CHARS));
662
+ const summary = {
663
+ ...data,
664
+ catalogScope: { ...catalog.scope, roots: summaryRoots },
665
+ summaryRootsOmitted: Math.max(
666
+ 0,
667
+ catalog.scope.roots.length - summaryRoots.length
668
+ ),
669
+ summaryRootCharactersOmitted: catalog.scope.roots.reduce(
670
+ (total, root, index) => total + root.length - (summaryRoots[index]?.length ?? 0),
671
+ 0
672
+ ),
673
+ applications: [...data.applications],
674
+ summaryApplicationsOmitted: 0
675
+ };
676
+ while (isApplicationSummaryOverBudget(summary)) {
677
+ summary.applications.pop();
678
+ summary.summaryApplicationsOmitted += 1;
679
+ }
680
+ while (isCatalogRootSummaryOverBudget(summary)) {
681
+ const removedRoot = summary.catalogScope.roots.pop();
682
+ summary.summaryRootsOmitted += 1;
683
+ summary.summaryRootCharactersOmitted += removedRoot.length;
684
+ }
685
+ return { output: JSON.stringify(summary), data };
686
+ }
687
+ function matchesApplicationQuery(name, id, query) {
688
+ if (name.toLowerCase().includes(query)) return true;
689
+ return id.toLowerCase().includes(query);
690
+ }
691
+ function isApplicationSummaryOverBudget(summary) {
692
+ if (summary.applications.length === 0) return false;
693
+ return JSON.stringify(summary).length > SUMMARY_MAX_CHARS;
694
+ }
695
+ function isCatalogRootSummaryOverBudget(summary) {
696
+ if (summary.catalogScope.roots.length === 0) return false;
697
+ return JSON.stringify(summary).length > SUMMARY_MAX_CHARS;
698
+ }
699
+
700
+ // plugins/system/source/target-observation.ts
701
+ async function observeSystemTargets(run = runSystemProcess) {
702
+ const observations = [];
703
+ for (const id of ["linux", "macos", "windows"]) {
704
+ try {
705
+ const target = await resolveSystemTarget(id, run);
706
+ observations.push({
707
+ ...target,
708
+ available: true,
709
+ commandExecutionAvailable: true,
710
+ guiSessionStatus: "not_checked"
711
+ });
712
+ } catch (error) {
713
+ observations.push({
714
+ id,
715
+ available: false,
716
+ reason: error instanceof Error ? error.message : String(error)
717
+ });
718
+ }
719
+ }
720
+ return {
721
+ host: observeSystemHost(),
722
+ availabilityScope: "command_execution_only",
723
+ targets: observations
724
+ };
725
+ }
726
+
727
+ // plugins/system/source/application-launch.ts
728
+ function readApplicationArguments(value) {
729
+ if (value === void 0) return [];
730
+ if (!hasBoundedArgumentArray(value))
731
+ throw new SystemOperationError(
732
+ "system_application_arguments_invalid",
733
+ "arguments must be an array of at most 32 strings."
734
+ );
735
+ for (const argument of value) {
736
+ if (!isSupportedApplicationArgument(argument))
737
+ throw new SystemOperationError(
738
+ "system_application_arguments_invalid",
739
+ "Each application argument must be a string without null bytes, at most 4096 characters."
740
+ );
741
+ }
742
+ return [...value];
743
+ }
744
+ async function launchSystemApplication(input) {
745
+ const { target, params, run } = input;
746
+ const id = readRequiredString(params.application_id, {
747
+ name: "application_id",
748
+ maxLength: 4096
749
+ });
750
+ const args = readApplicationArguments(params.arguments);
751
+ const catalog = await readSystemApplications(target, run);
752
+ const application = catalog.applications.find((entry) => entry.id === id);
753
+ if (!application)
754
+ throw new SystemOperationError(
755
+ "system_application_not_found",
756
+ "The identity is absent from the current target catalog; this does not establish that the application is uninstalled. Inspect the correct OS target and use system_command for bounded executable discovery when this catalog is insufficient."
757
+ );
758
+ const common = {
759
+ timeoutMs: 3e4,
760
+ ...input.abortSignal ? { abortSignal: input.abortSignal } : {}
761
+ };
762
+ if (target.id === "macos")
763
+ return {
764
+ application,
765
+ process: await run({
766
+ ...common,
767
+ executable: "/usr/bin/open",
768
+ args: ["-a", id, ...args.length ? ["--args", ...args] : []]
769
+ })
770
+ };
771
+ if (hasUnsupportedTargetArguments(target, args))
772
+ throw new SystemOperationError(
773
+ "system_application_arguments_unsupported",
774
+ "This target application catalog does not define generic raw arguments. Use system_command with the application's documented native invocation."
775
+ );
776
+ if (target.id === "windows") {
777
+ return {
778
+ application,
779
+ process: await run({
780
+ ...common,
781
+ executable: target.shell,
782
+ args: powershellArguments(
783
+ `$applicationPath=${powershellLiteral("shell:AppsFolder\\" + id)}; Start-Process -FilePath (Join-Path $env:SystemRoot 'explorer.exe') -ArgumentList ('"' + $applicationPath + '"'); Write-Output 'Launch request dispatched to Windows shell.'`
784
+ )
785
+ })
786
+ };
787
+ }
788
+ const launcher = await findExecutable("gio");
789
+ if (!launcher)
790
+ throw new SystemOperationError(
791
+ "system_application_launcher_unavailable",
792
+ "The installed desktop application catalog was read, but a native gio launcher is unavailable."
793
+ );
794
+ return {
795
+ application,
796
+ process: await run({
797
+ ...common,
798
+ executable: launcher,
799
+ args: ["launch", id]
800
+ })
801
+ };
802
+ }
803
+ function hasBoundedArgumentArray(value) {
804
+ if (!Array.isArray(value)) return false;
805
+ return value.length <= 32;
806
+ }
807
+ function isSupportedApplicationArgument(value) {
808
+ if (typeof value !== "string") return false;
809
+ if (value.length > 4096) return false;
810
+ return !value.includes("\0");
811
+ }
812
+ function hasUnsupportedTargetArguments(target, args) {
813
+ if (target.id === "macos") return false;
814
+ return args.length > 0;
815
+ }
816
+
817
+ // plugins/system/source/commands.ts
818
+ var import_promises3 = require("node:fs/promises");
819
+ var import_node_path3 = require("node:path");
820
+
821
+ // plugins/system/source/elevation.ts
822
+ var WINDOWS_ADMIN_PROBE = "([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)";
823
+ async function elevatedSystemCommand(input) {
824
+ const { target, command, cwd, run } = input;
825
+ if (target.id === "windows")
826
+ return windowsElevatedCommand(target, command, cwd, run);
827
+ if (process.getuid?.() === 0)
828
+ return { executable: target.shell, args: ["-lc", command], cwd };
829
+ if (target.id === "macos") {
830
+ const script = `cd ${shellLiteral(cwd)} && ${shellLiteral(target.shell)} -lc ${shellLiteral(command)}`;
831
+ const appleScriptString = JSON.stringify(script);
832
+ return {
833
+ executable: "/usr/bin/osascript",
834
+ args: [
835
+ "-e",
836
+ `do shell script ${appleScriptString} with administrator privileges`
837
+ ]
838
+ };
839
+ }
840
+ const probe = await run({
841
+ executable: "/usr/bin/sudo",
842
+ args: ["-n", "--", "/usr/bin/true"],
843
+ timeoutMs: 5e3
844
+ });
845
+ if (!hasSuccessfulPrivilegeProbe(probe))
846
+ throw new SystemOperationError(
847
+ "system_authorization_required",
848
+ "Linux sudo authorization requires a human or a configured native privilege policy. Authenticate in a native terminal or supply an authorized host; ABot does not request, invent or bypass passwords."
849
+ );
850
+ return {
851
+ executable: "/usr/bin/sudo",
852
+ args: ["-n", "--", target.shell, "-lc", command],
853
+ cwd
854
+ };
855
+ }
856
+ function hasSuccessfulPrivilegeProbe(probe) {
857
+ if (probe.status !== "completed") return false;
858
+ return probe.exitCode === 0;
859
+ }
860
+ function hasWindowsAdministratorAuthority(probe) {
861
+ if (!hasSuccessfulPrivilegeProbe(probe)) return false;
862
+ return probe.stdout.trim() === "True";
863
+ }
864
+ async function windowsElevatedCommand(target, command, cwd, run) {
865
+ const probe = await run({
866
+ executable: target.shell,
867
+ args: powershellArguments(WINDOWS_ADMIN_PROBE),
868
+ timeoutMs: 5e3
869
+ });
870
+ if (!hasWindowsAdministratorAuthority(probe))
871
+ throw new SystemOperationError(
872
+ "system_authorization_required",
873
+ "Windows Administrator authority is required. Approve UAC in a native Windows elevated host, then retry; this noninteractive transport cannot answer UAC or provide credentials."
874
+ );
875
+ return {
876
+ executable: target.shell,
877
+ args: powershellArguments(windowsSystemCommandScript(command, cwd))
878
+ };
879
+ }
880
+
881
+ // plugins/system/source/commands.ts
882
+ async function executeSystemCommand(input) {
883
+ const { target, params, run } = input;
884
+ const command = readRequiredString(params.command, {
885
+ name: "command",
886
+ trim: false,
887
+ maxLength: 4096
888
+ });
889
+ const cwd = readRequiredString(params.cwd, { name: "cwd", maxLength: 4096 });
890
+ const timeoutMs = params.timeout_ms === void 0 ? 6e4 : readBoundedInteger(params.timeout_ms, {
891
+ name: "timeout_ms",
892
+ minimum: 1e3,
893
+ maximum: 6e5
894
+ });
895
+ if (hasSystemCommandNullBytes(command, cwd))
896
+ throw new SystemOperationError(
897
+ "system_command_invalid",
898
+ "Commands and directories cannot contain null bytes."
899
+ );
900
+ if (hasInvalidElevationFlag(params.elevated))
901
+ throw new SystemOperationError(
902
+ "system_command_invalid",
903
+ "elevated must be a boolean."
904
+ );
905
+ const absoluteCwd = target.id === "windows" ? hasExplicitWindowsDirectory(cwd) : (0, import_node_path3.isAbsolute)(cwd);
906
+ if (!absoluteCwd)
907
+ throw new SystemOperationError(
908
+ "system_cwd_invalid",
909
+ "System commands require an explicit absolute directory in the selected OS namespace."
910
+ );
911
+ await requireNativeWorkingDirectory(target, cwd);
912
+ const plan = params.elevated === true ? await elevatedSystemCommand({ target, command, cwd, run }) : unprivilegedSystemCommand(target, command, cwd);
913
+ return run({
914
+ ...plan,
915
+ timeoutMs,
916
+ ...input.abortSignal ? { abortSignal: input.abortSignal } : {}
917
+ });
918
+ }
919
+ function unprivilegedSystemCommand(target, command, cwd) {
920
+ if (target.id === "windows")
921
+ return {
922
+ executable: target.shell,
923
+ args: powershellArguments(windowsSystemCommandScript(command, cwd))
924
+ };
925
+ return { executable: target.shell, args: ["-lc", command], cwd };
926
+ }
927
+ function hasExplicitWindowsDirectory(path) {
928
+ if (/^[a-z]:[\\/]/iu.test(path)) return true;
929
+ return /^\\\\[^\\/]+[\\/][^\\/]+(?:[\\/]|$)/u.test(path);
930
+ }
931
+ function hasSystemCommandNullBytes(command, cwd) {
932
+ if (command.includes("\0")) return true;
933
+ return cwd.includes("\0");
934
+ }
935
+ function hasInvalidElevationFlag(value) {
936
+ if (value === void 0) return false;
937
+ return typeof value !== "boolean";
938
+ }
939
+ async function requireNativeWorkingDirectory(target, cwd) {
940
+ if (target.id === "windows") return;
941
+ const directory = await (0, import_promises3.stat)(cwd).catch(() => void 0);
942
+ if (directory?.isDirectory()) return;
943
+ throw new SystemOperationError(
944
+ "system_cwd_unavailable",
945
+ "The selected target directory is unavailable or not a directory."
946
+ );
947
+ }
948
+
949
+ // plugins/system/source/process-result.ts
950
+ var STREAM_EXCERPT_CHARS = 2e3;
951
+ var IDENTITY_EXCERPT_CHARS = 512;
952
+ var LEGACY_EVIDENCE_LABELS = {
953
+ command_process_completion: "system command process completion",
954
+ launch_request_dispatch: "application launch request dispatch"
955
+ };
956
+ function systemProcessResult(target, result, evidenceScope, application) {
957
+ const stdoutOmittedChars = Math.max(
958
+ 0,
959
+ result.stdout.length - STREAM_EXCERPT_CHARS
960
+ );
961
+ const stderrOmittedChars = Math.max(
962
+ 0,
963
+ result.stderr.length - STREAM_EXCERPT_CHARS
964
+ );
965
+ const data = {
966
+ evidenceScope,
967
+ evidence: LEGACY_EVIDENCE_LABELS[evidenceScope],
968
+ independentOutcomeCheck: "not_performed",
969
+ target: target.id,
970
+ transport: target.transport,
971
+ processStatus: result.status,
972
+ spawnedProcess: result.spawnedProcess ?? null,
973
+ ...application ? { catalogApplication: application } : {},
974
+ outputTruncated: result.outputTruncated,
975
+ summaryOmittedChars: {
976
+ stdout: stdoutOmittedChars,
977
+ stderr: stderrOmittedChars
978
+ },
979
+ observationMeta: {
980
+ kind: "volatile_external",
981
+ carryPolicy: "never"
982
+ }
983
+ };
984
+ const output = [
985
+ `Adapter evidence: ${evidenceScope}. Independent outcome check: not performed. Completion/dispatch alone does not verify the requested application, window or system effect; evaluate command evidence separately.`,
986
+ `Target: ${target.id} (${target.transport})`,
987
+ `Process status: ${result.status}; exit code: ${result.exitCode ?? "unavailable"}`,
988
+ result.spawnedProcess ? `Spawned helper: ${identityExcerpt(result.spawnedProcess.executable)}; PID ${result.spawnedProcess.pid} in runtime OS namespace. Identity comes from spawn arguments, not application image inspection.` : "Spawned helper identity: not recorded.",
989
+ ...application ? [
990
+ `Revalidated catalog identity: ${identityExcerpt(application.id)} (identity only; no application process/window check).`
991
+ ] : [],
992
+ "STDOUT excerpt:",
993
+ result.stdout.slice(0, STREAM_EXCERPT_CHARS) || "(empty)",
994
+ "STDERR excerpt:",
995
+ result.stderr.slice(0, STREAM_EXCERPT_CHARS) || "(empty)",
996
+ `Summary omitted characters: stdout=${stdoutOmittedChars}, stderr=${stderrOmittedChars}. Raw stream capture truncated: ${result.outputTruncated}.`
997
+ ].join("\n");
998
+ if (hasSuccessfulSystemObservation(result)) {
999
+ return successResult({
1000
+ output,
1001
+ stdout: result.stdout,
1002
+ stderr: result.stderr,
1003
+ exitCode: 0,
1004
+ data
1005
+ });
1006
+ }
1007
+ const errorCode = result.status === "completed" ? "system_command_failed" : `system_${result.status}`;
1008
+ return failureResult({
1009
+ errorCode,
1010
+ message: hasUncertainDescendantState(result) ? "System command observation stopped. External or detached descendants may remain; inspect the target before retrying." : "The target did not report successful command completion.",
1011
+ output,
1012
+ stdout: result.stdout,
1013
+ stderr: result.stderr,
1014
+ ...result.exitCode !== null ? { exitCode: result.exitCode } : {},
1015
+ data
1016
+ });
1017
+ }
1018
+ function hasSuccessfulSystemObservation(result) {
1019
+ if (result.status !== "completed") return false;
1020
+ return result.exitCode === 0;
1021
+ }
1022
+ function hasUncertainDescendantState(result) {
1023
+ if (result.status === "timeout") return true;
1024
+ return result.status === "aborted";
1025
+ }
1026
+ function identityExcerpt(identity) {
1027
+ if (identity.length <= IDENTITY_EXCERPT_CHARS) return identity;
1028
+ return `${identity.slice(0, IDENTITY_EXCERPT_CHARS)} [${identity.length - IDENTITY_EXCERPT_CHARS} characters omitted; full identity in result data]`;
1029
+ }
1030
+
1031
+ // plugins/system/source/handlers.ts
1032
+ function withSystemOperationErrors(operation) {
1033
+ return async (params, context) => {
1034
+ try {
1035
+ return await operation(params, context);
1036
+ } catch (error) {
1037
+ if (error instanceof SystemOperationError)
1038
+ return failureResult({
1039
+ errorCode: error.code,
1040
+ message: error.message,
1041
+ data: {
1042
+ humanActionRequired: error.code === "system_authorization_required"
1043
+ }
1044
+ });
1045
+ return failureFromError(error, {
1046
+ fallbackCode: "system_operation_failed",
1047
+ fallbackMessage: "The native system operation failed.",
1048
+ operation: "system"
1049
+ });
1050
+ }
1051
+ };
1052
+ }
1053
+ function createSystemHandlers(run = runSystemProcess, resolveTarget = (id) => resolveSystemTarget(id, run)) {
1054
+ const targets = async () => {
1055
+ const observation = await observeSystemTargets(run);
1056
+ return successResult({
1057
+ output: JSON.stringify(observation),
1058
+ data: {
1059
+ ...observation,
1060
+ observationMeta: { kind: "volatile_external", carryPolicy: "never" }
1061
+ }
1062
+ });
1063
+ };
1064
+ const command = async (params, context) => {
1065
+ const target = await resolveTarget(readSystemTargetId(params.target));
1066
+ const result = await executeSystemCommand({
1067
+ target,
1068
+ params,
1069
+ run,
1070
+ ...context?.abortSignal ? { abortSignal: context.abortSignal } : {}
1071
+ });
1072
+ return systemProcessResult(target, result, "command_process_completion");
1073
+ };
1074
+ const applications = async (params) => {
1075
+ const target = await resolveTarget(readSystemTargetId(params.target));
1076
+ const query = (readOptionalString(params.query) ?? "").toLowerCase();
1077
+ const limit = params.limit === void 0 ? 50 : readBoundedInteger(params.limit, {
1078
+ name: "limit",
1079
+ minimum: 1,
1080
+ maximum: 100
1081
+ });
1082
+ const catalog = await readSystemApplications(target, run);
1083
+ const { output, data } = systemApplicationObservation(
1084
+ target,
1085
+ catalog,
1086
+ query,
1087
+ limit
1088
+ );
1089
+ return successResult({
1090
+ output,
1091
+ data: {
1092
+ ...data,
1093
+ observationMeta: { kind: "volatile_external", carryPolicy: "never" }
1094
+ }
1095
+ });
1096
+ };
1097
+ const launch = async (params, context) => {
1098
+ const target = await resolveTarget(readSystemTargetId(params.target));
1099
+ const result = await launchSystemApplication({
1100
+ target,
1101
+ params,
1102
+ run,
1103
+ ...context?.abortSignal ? { abortSignal: context.abortSignal } : {}
1104
+ });
1105
+ return systemProcessResult(
1106
+ target,
1107
+ result.process,
1108
+ "launch_request_dispatch",
1109
+ result.application
1110
+ );
1111
+ };
1112
+ return {
1113
+ system_targets: withSystemOperationErrors(targets),
1114
+ system_command: withSystemOperationErrors(command),
1115
+ system_applications: withSystemOperationErrors(applications),
1116
+ system_launch: withSystemOperationErrors(launch)
1117
+ };
1118
+ }
1119
+
1120
+ // plugins/system/source/companion/protocol.ts
1121
+ var HOST_WIRE_MAX_BYTES = 256 * 1024;
1122
+ var HOST_OPERATIONS = [
1123
+ "system_targets",
1124
+ "system_command",
1125
+ "system_applications",
1126
+ "system_launch"
1127
+ ];
1128
+ function isHostOperation(value) {
1129
+ return HOST_OPERATIONS.some((operation) => operation === value);
1130
+ }
1131
+ function isHostRecord(value) {
1132
+ if (value === null) return false;
1133
+ if (typeof value !== "object") return false;
1134
+ return !Array.isArray(value);
1135
+ }
1136
+ function isHostIdentifier(value) {
1137
+ if (typeof value !== "string") return false;
1138
+ return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u.test(
1139
+ value
1140
+ );
1141
+ }
1142
+ function isHostIdentityText(value, maximum) {
1143
+ if (typeof value !== "string") return false;
1144
+ if (value.length === 0) return false;
1145
+ if (value.length > maximum) return false;
1146
+ return !/[\x00-\x1f\x7f]/u.test(value);
1147
+ }
1148
+ function isHostIdentity(value) {
1149
+ if (!isHostRecord(value)) return false;
1150
+ if (Object.keys(value).some(
1151
+ (key) => !["name", "os", "user", "homeDir"].includes(key)
1152
+ ))
1153
+ return false;
1154
+ if (!["windows", "macos", "linux"].includes(String(value.os))) return false;
1155
+ if (!isHostIdentityText(value.name, 128)) return false;
1156
+ if (!isHostIdentityText(value.user, 128)) return false;
1157
+ return isHostIdentityText(value.homeDir, 4096);
1158
+ }
1159
+ function isHostToolResult(value) {
1160
+ if (!isHostRecord(value)) return false;
1161
+ if (typeof value.ok !== "boolean") return false;
1162
+ if (typeof value.producedNewInformation !== "boolean") return false;
1163
+ if (value.data !== void 0 && !isHostRecord(value.data)) return false;
1164
+ return typeof value.output === "string";
1165
+ }
1166
+
1167
+ // plugins/system/source/companion/broker-client.ts
1168
+ var import_node_net = require("node:net");
1169
+
1170
+ // plugins/system/source/companion/broker-location.ts
1171
+ var import_node_crypto2 = require("node:crypto");
1172
+ var import_node_fs4 = require("node:fs");
1173
+ var import_node_path5 = require("node:path");
1174
+ var import_node_os3 = require("node:os");
1175
+
1176
+ // plugins/system/source/companion/private-store.ts
1177
+ var import_node_crypto = require("node:crypto");
1178
+ var import_node_fs3 = require("node:fs");
1179
+ var import_node_path4 = require("node:path");
1180
+ function hostStateDirectory(rootDir) {
1181
+ return (0, import_node_path4.join)(rootDir, ".runtime", "system-host");
1182
+ }
1183
+ function ensureHostStateDirectory(directory) {
1184
+ (0, import_node_fs3.mkdirSync)(directory, { recursive: true, mode: 448 });
1185
+ const stat2 = (0, import_node_fs3.lstatSync)(directory);
1186
+ if (!stat2.isDirectory()) throw new Error("host_state_directory_invalid");
1187
+ if (process.platform === "win32") return;
1188
+ if (stat2.uid !== process.getuid?.())
1189
+ throw new Error("host_state_owner_invalid");
1190
+ if ((stat2.mode & 63) !== 0)
1191
+ throw new Error("host_state_directory_not_private");
1192
+ }
1193
+ function readHostPrivateJson(path) {
1194
+ try {
1195
+ const stat2 = (0, import_node_fs3.lstatSync)(path);
1196
+ if (!stat2.isFile()) throw new Error("host_state_file_invalid");
1197
+ if (process.platform !== "win32") {
1198
+ if (stat2.uid !== process.getuid?.())
1199
+ throw new Error("host_state_owner_invalid");
1200
+ if ((stat2.mode & 63) !== 0)
1201
+ throw new Error("host_state_file_not_private");
1202
+ }
1203
+ if (stat2.size > 16384) throw new Error("host_state_file_too_large");
1204
+ return JSON.parse((0, import_node_fs3.readFileSync)(path, "utf8"));
1205
+ } catch (error) {
1206
+ if (error.code === "ENOENT") return void 0;
1207
+ throw error;
1208
+ }
1209
+ }
1210
+ function writeHostPrivateJson(path, value) {
1211
+ ensureHostStateDirectory((0, import_node_path4.dirname)(path));
1212
+ const temporary = `${path}.${(0, import_node_crypto.randomUUID)()}.tmp`;
1213
+ try {
1214
+ (0, import_node_fs3.writeFileSync)(temporary, JSON.stringify(value), {
1215
+ flag: "wx",
1216
+ mode: 384
1217
+ });
1218
+ (0, import_node_fs3.renameSync)(temporary, path);
1219
+ } finally {
1220
+ try {
1221
+ (0, import_node_fs3.unlinkSync)(temporary);
1222
+ } catch (error) {
1223
+ if (error.code !== "ENOENT") throw error;
1224
+ }
1225
+ }
1226
+ }
1227
+
1228
+ // plugins/system/source/companion/broker-location.ts
1229
+ function brokerRecordPath(rootDir) {
1230
+ return (0, import_node_path5.join)(hostStateDirectory(rootDir), "broker.json");
1231
+ }
1232
+ function brokerSocketPath(rootDir) {
1233
+ if (process.platform !== "linux")
1234
+ throw new Error("host_broker_requires_linux_runtime");
1235
+ const key = (0, import_node_crypto2.createHash)("sha256").update((0, import_node_fs4.realpathSync)(rootDir)).digest("hex").slice(0, 20);
1236
+ return (0, import_node_path5.join)(
1237
+ (0, import_node_os3.tmpdir)(),
1238
+ `abot-host-${process.getuid?.()}-${key}`,
1239
+ "broker.sock"
1240
+ );
1241
+ }
1242
+ function isBrokerLocation(value) {
1243
+ if (!isHostRecord(value)) return false;
1244
+ if (!isHostIdentifier(value.ownerId)) return false;
1245
+ if (typeof value.token !== "string") return false;
1246
+ if (!/^[A-Za-z0-9_-]{43}$/u.test(value.token)) return false;
1247
+ return typeof value.socketPath === "string";
1248
+ }
1249
+ function readBrokerLocation(rootDir) {
1250
+ const record = readHostPrivateJson(brokerRecordPath(rootDir));
1251
+ if (record === void 0) return void 0;
1252
+ if (!isBrokerLocation(record)) throw new Error("host_broker_record_invalid");
1253
+ if (record.socketPath !== brokerSocketPath(rootDir))
1254
+ throw new Error("host_broker_path_invalid");
1255
+ return record;
1256
+ }
1257
+
1258
+ // plugins/system/source/companion/pairing-store.ts
1259
+ var import_node_crypto3 = require("node:crypto");
1260
+ var import_node_path6 = require("node:path");
1261
+ function tokenDigest(token) {
1262
+ return (0, import_node_crypto3.createHash)("sha256").update(token).digest("hex");
1263
+ }
1264
+ function matchesToken(token, digest) {
1265
+ if (!/^[a-f0-9]{64}$/u.test(digest)) return false;
1266
+ return (0, import_node_crypto3.timingSafeEqual)(
1267
+ Buffer.from(tokenDigest(token), "hex"),
1268
+ Buffer.from(digest, "hex")
1269
+ );
1270
+ }
1271
+ function isBoundedPairingLifetime(lifetimeMs) {
1272
+ if (!Number.isSafeInteger(lifetimeMs)) return false;
1273
+ if (lifetimeMs < 1) return false;
1274
+ return lifetimeMs <= 15 * 6e4;
1275
+ }
1276
+ function isStoredPairing(value) {
1277
+ if (!isHostRecord(value)) return false;
1278
+ if (value.version !== 1) return false;
1279
+ if (value.pending !== void 0) {
1280
+ if (!isHostRecord(value.pending)) return false;
1281
+ if (typeof value.pending.digest !== "string") return false;
1282
+ if (typeof value.pending.expiresAt !== "number") return false;
1283
+ }
1284
+ if (value.host === void 0) return true;
1285
+ if (!isHostRecord(value.host)) return false;
1286
+ if (!isHostIdentifier(value.host.hostId)) return false;
1287
+ if (!isHostIdentity(value.host.identity)) return false;
1288
+ return typeof value.host.credentialDigest === "string";
1289
+ }
1290
+ var HostPairingStore = class {
1291
+ constructor(rootDir, now = Date.now) {
1292
+ this.now = now;
1293
+ this.path = (0, import_node_path6.join)(hostStateDirectory(rootDir), "pairing.json");
1294
+ }
1295
+ now;
1296
+ path;
1297
+ read() {
1298
+ const value = readHostPrivateJson(this.path);
1299
+ if (value === void 0) return { version: 1 };
1300
+ if (!isStoredPairing(value)) throw new Error("host_pairing_state_invalid");
1301
+ return value;
1302
+ }
1303
+ host() {
1304
+ return this.read().host;
1305
+ }
1306
+ begin(lifetimeMs = 5 * 6e4) {
1307
+ if (!isBoundedPairingLifetime(lifetimeMs))
1308
+ throw new Error("host_pairing_lifetime_invalid");
1309
+ if (this.host()) throw new Error("host_already_paired");
1310
+ const code = (0, import_node_crypto3.randomBytes)(32).toString("base64url");
1311
+ const expiresAt = this.now() + lifetimeMs;
1312
+ writeHostPrivateJson(this.path, {
1313
+ version: 1,
1314
+ pending: { digest: tokenDigest(code), expiresAt }
1315
+ });
1316
+ return { code, expiresAt: new Date(expiresAt).toISOString() };
1317
+ }
1318
+ authenticate(token) {
1319
+ if (!/^[A-Za-z0-9_-]{43}$/u.test(token)) return void 0;
1320
+ const record = this.read();
1321
+ if (record.host && matchesToken(token, record.host.credentialDigest))
1322
+ return "credential";
1323
+ if (!record.pending) return void 0;
1324
+ if (record.pending.expiresAt <= this.now()) return void 0;
1325
+ if (matchesToken(token, record.pending.digest)) return "pairing";
1326
+ return void 0;
1327
+ }
1328
+ consume(code, identity) {
1329
+ if (this.authenticate(code) !== "pairing")
1330
+ throw new Error("host_pairing_expired");
1331
+ const hostId = (0, import_node_crypto3.randomUUID)();
1332
+ const credential = (0, import_node_crypto3.randomBytes)(32).toString("base64url");
1333
+ writeHostPrivateJson(this.path, {
1334
+ version: 1,
1335
+ host: { hostId, identity, credentialDigest: tokenDigest(credential) }
1336
+ });
1337
+ return { hostId, credential };
1338
+ }
1339
+ revoke() {
1340
+ writeHostPrivateJson(this.path, { version: 1 });
1341
+ }
1342
+ };
1343
+
1344
+ // plugins/system/source/companion/broker-client.ts
1345
+ async function callBroker(rootDir, request, signal) {
1346
+ const location = readBrokerLocation(rootDir);
1347
+ if (!location) throw new Error("host_broker_unavailable");
1348
+ if (signal?.aborted) throw new Error("host_request_cancelled");
1349
+ return new Promise((resolve, reject) => {
1350
+ const socket = (0, import_node_net.connect)(location.socketPath);
1351
+ let received = Buffer.alloc(0);
1352
+ let settled = false;
1353
+ let sent = false;
1354
+ const finish = (error, result) => {
1355
+ if (settled) return;
1356
+ settled = true;
1357
+ clearTimeout(deadline);
1358
+ signal?.removeEventListener("abort", abort);
1359
+ socket.destroy();
1360
+ if (error) {
1361
+ reject(
1362
+ sent && request.kind === "execute" ? new Error("host_outcome_unknown") : error
1363
+ );
1364
+ return;
1365
+ }
1366
+ resolve(result);
1367
+ };
1368
+ const abort = () => finish(
1369
+ new Error(sent ? "host_outcome_unknown" : "host_request_cancelled")
1370
+ );
1371
+ const deadline = setTimeout(
1372
+ abort,
1373
+ request.kind === "status" ? 3e3 : 615e3
1374
+ );
1375
+ signal?.addEventListener("abort", abort, { once: true });
1376
+ socket.once("connect", () => {
1377
+ const bytes = JSON.stringify({ ...request, version: 1, token: location.token }) + "\n";
1378
+ if (Buffer.byteLength(bytes) > HOST_WIRE_MAX_BYTES) {
1379
+ finish(new Error("host_request_too_large"));
1380
+ return;
1381
+ }
1382
+ sent = true;
1383
+ socket.write(bytes);
1384
+ });
1385
+ socket.on(
1386
+ "error",
1387
+ () => finish(
1388
+ new Error(sent ? "host_outcome_unknown" : "host_broker_unavailable")
1389
+ )
1390
+ );
1391
+ socket.on(
1392
+ "close",
1393
+ () => finish(
1394
+ new Error(sent ? "host_outcome_unknown" : "host_broker_unavailable")
1395
+ )
1396
+ );
1397
+ socket.on("data", (chunk) => {
1398
+ received = Buffer.concat([received, chunk]);
1399
+ if (received.length > HOST_WIRE_MAX_BYTES) {
1400
+ finish(new Error("host_response_too_large"));
1401
+ return;
1402
+ }
1403
+ const boundary = received.indexOf(10);
1404
+ if (boundary < 0) return;
1405
+ if (boundary !== received.length - 1) {
1406
+ finish(new Error("host_response_invalid"));
1407
+ return;
1408
+ }
1409
+ try {
1410
+ finish(
1411
+ void 0,
1412
+ JSON.parse(received.subarray(0, boundary).toString())
1413
+ );
1414
+ } catch {
1415
+ finish(new Error("host_response_invalid"));
1416
+ }
1417
+ });
1418
+ });
1419
+ }
1420
+ function isHostStatus(value) {
1421
+ if (!isHostRecord(value)) return false;
1422
+ if (typeof value.paired !== "boolean") return false;
1423
+ if (typeof value.connected !== "boolean") return false;
1424
+ if (!hasValidHostConnectionBinding(value)) return false;
1425
+ if (!value.paired) return value.connected === false;
1426
+ if (!isHostIdentifier(value.hostId)) return false;
1427
+ return isHostIdentity(value.identity);
1428
+ }
1429
+ function hasValidHostConnectionBinding(value) {
1430
+ if (value.connected === true) return isHostIdentifier(value.connectionId);
1431
+ return !Object.hasOwn(value, "connectionId");
1432
+ }
1433
+ async function readHostStatus(rootDir) {
1434
+ try {
1435
+ const response = await callBroker(rootDir, { kind: "status" });
1436
+ if (!isHostRecord(response)) throw new Error("host_response_invalid");
1437
+ if (!isHostStatus(response.status)) throw new Error("host_status_invalid");
1438
+ return response.status;
1439
+ } catch {
1440
+ const host = new HostPairingStore(rootDir).host();
1441
+ if (!host) return { paired: false, connected: false };
1442
+ return {
1443
+ paired: true,
1444
+ connected: false,
1445
+ hostId: host.hostId,
1446
+ identity: host.identity
1447
+ };
1448
+ }
1449
+ }
1450
+ async function executeHostOperation(rootDir, input) {
1451
+ if (!isHostIdentifier(input.connectionId))
1452
+ return failureResult({
1453
+ errorCode: "system_host_binding_invalid",
1454
+ message: "An observed host connection identity is required before dispatch.",
1455
+ data: { outcome: "not_dispatched", retrySafe: true }
1456
+ });
1457
+ try {
1458
+ const response = await callBroker(
1459
+ rootDir,
1460
+ {
1461
+ kind: "execute",
1462
+ hostId: input.hostId,
1463
+ connectionId: input.connectionId,
1464
+ operation: input.operation,
1465
+ params: input.params
1466
+ },
1467
+ input.abortSignal
1468
+ );
1469
+ if (!isHostRecord(response)) throw new Error("host_outcome_unknown");
1470
+ if (response.ok !== true) throw new Error("host_outcome_unknown");
1471
+ if (!isHostToolResult(response.result))
1472
+ throw new Error("host_outcome_unknown");
1473
+ return response.result;
1474
+ } catch (error) {
1475
+ const message = error instanceof Error ? error.message : "host_request_failed";
1476
+ const uncertain = message === "host_outcome_unknown";
1477
+ return failureResult({
1478
+ errorCode: uncertain ? "system_host_outcome_unknown" : "system_host_unavailable",
1479
+ message: uncertain ? "Host communication ended after dispatch. Effects may remain; inspect before retrying. The action was not replayed." : "The selected host connection is unavailable. No fallback target was used.",
1480
+ data: {
1481
+ outcome: uncertain ? "unknown" : "not_dispatched",
1482
+ retrySafe: !uncertain
1483
+ }
1484
+ });
1485
+ }
1486
+ }
1487
+
1488
+ // plugins/system/source/request-target-snapshot.ts
1489
+ async function captureSystemTargetSnapshot(input) {
1490
+ const [native, companion] = await Promise.allSettled([
1491
+ input.observeTargets(),
1492
+ input.readHostStatus()
1493
+ ]);
1494
+ const routes = capturedNativeRoutes(native);
1495
+ if (companion.status !== "fulfilled") return Object.freeze(routes);
1496
+ const remote = connectedCompanionRoute(companion.value);
1497
+ if (!remote) return Object.freeze(routes);
1498
+ if (routes.some((route) => routeTargetId(route) === remote.target))
1499
+ return Object.freeze(routes);
1500
+ return Object.freeze([...routes, remote]);
1501
+ }
1502
+ function capturedNativeRoutes(observation) {
1503
+ if (observation.status !== "fulfilled") return [];
1504
+ return observation.value.targets.flatMap((target) => {
1505
+ if (!target.available) return [];
1506
+ return [
1507
+ Object.freeze({
1508
+ kind: "native",
1509
+ target: Object.freeze({
1510
+ id: target.id,
1511
+ shell: target.shell,
1512
+ transport: target.transport
1513
+ })
1514
+ })
1515
+ ];
1516
+ });
1517
+ }
1518
+ function connectedCompanionRoute(status) {
1519
+ if (!status.paired) return void 0;
1520
+ if (!status.connected) return void 0;
1521
+ if (!isHostIdentifier(status.hostId)) return void 0;
1522
+ if (!isHostIdentifier(status.connectionId)) return void 0;
1523
+ if (!isHostIdentity(status.identity)) return void 0;
1524
+ return Object.freeze({
1525
+ kind: "companion",
1526
+ target: status.identity.os,
1527
+ hostId: status.hostId,
1528
+ connectionId: status.connectionId,
1529
+ identity: Object.freeze({ ...status.identity })
1530
+ });
1531
+ }
1532
+ function routeTargetId(route) {
1533
+ if (route.kind === "native") return route.target.id;
1534
+ return route.target;
1535
+ }
1536
+ function requireSystemRequestRoute(snapshot, target) {
1537
+ const route = snapshot.find(
1538
+ (candidate) => routeTargetId(candidate) === target
1539
+ );
1540
+ if (route) return route;
1541
+ throw new SystemOperationError(
1542
+ "system_target_unavailable",
1543
+ "The requested OS target is unavailable in this request."
1544
+ );
1545
+ }
1546
+ function resolveCapturedNativeTarget(snapshot, target) {
1547
+ const route = requireSystemRequestRoute(snapshot, target);
1548
+ if (route.kind === "native") return route.target;
1549
+ throw new SystemOperationError(
1550
+ "system_target_unavailable",
1551
+ "The request did not bind this target to native execution."
1552
+ );
1553
+ }
1554
+ function systemRouteBindingIdentity(route) {
1555
+ if (route.kind === "native")
1556
+ return JSON.stringify([route.kind, route.target]);
1557
+ return JSON.stringify([
1558
+ route.kind,
1559
+ route.target,
1560
+ route.hostId,
1561
+ route.connectionId
1562
+ ]);
1563
+ }
1564
+ function systemRouteMetadata(route) {
1565
+ if (route.kind === "native")
1566
+ return {
1567
+ displayTarget: route.target.id,
1568
+ transport: route.target.transport
1569
+ };
1570
+ return {
1571
+ displayTarget: route.target,
1572
+ transport: "host_companion",
1573
+ computerName: route.identity.name
1574
+ };
1575
+ }
1576
+ function observeCapturedSystemTargets(snapshot) {
1577
+ return {
1578
+ targets: snapshot.map((route) => ({
1579
+ id: routeTargetId(route),
1580
+ available: true,
1581
+ ...modelSafeRouteObservation(route),
1582
+ guiSessionStatus: "not_checked"
1583
+ })),
1584
+ availabilityScope: "request_execution_routes"
1585
+ };
1586
+ }
1587
+ function modelSafeRouteObservation(route) {
1588
+ if (route.kind === "native")
1589
+ return {
1590
+ transport: route.target.transport,
1591
+ commandExecutionStatus: "probed",
1592
+ availabilityScope: "command_execution_only"
1593
+ };
1594
+ return {
1595
+ transport: "host_companion",
1596
+ commandExecutionStatus: "not_probed",
1597
+ availabilityScope: "transport_connection_only"
1598
+ };
1599
+ }
1600
+
1601
+ // plugins/system/source/host-dispatch.ts
1602
+ var defaultSystemHostConnection = {
1603
+ readHostStatus,
1604
+ executeHostOperation
1605
+ };
1606
+ function createBoundSystemHandlers(input) {
1607
+ return Object.fromEntries(
1608
+ HOST_OPERATIONS.map((operation) => [
1609
+ operation,
1610
+ boundOperation(input, operation)
1611
+ ])
1612
+ );
1613
+ }
1614
+ function boundOperation(input, operation) {
1615
+ return async (params, context) => {
1616
+ if (hasConnectionControl(params))
1617
+ return failureResult({
1618
+ errorCode: "system_connection_control_forbidden",
1619
+ message: "Connection selection is managed internally and is not an operation input."
1620
+ });
1621
+ if (operation === "system_targets") {
1622
+ const observation = observeCapturedSystemTargets(input.snapshot);
1623
+ return successResult({
1624
+ output: JSON.stringify(observation),
1625
+ data: {
1626
+ ...observation,
1627
+ observationMeta: { kind: "volatile_external", carryPolicy: "never" }
1628
+ }
1629
+ });
1630
+ }
1631
+ try {
1632
+ const route = requireSystemRequestRoute(input.snapshot, params.target);
1633
+ if (route.kind === "native")
1634
+ return await input.nativeHandlers[operation](params, context);
1635
+ return await input.connection.executeHostOperation(input.rootDir, {
1636
+ hostId: route.hostId,
1637
+ connectionId: route.connectionId,
1638
+ operation,
1639
+ params,
1640
+ ...context?.abortSignal ? { abortSignal: context.abortSignal } : {}
1641
+ });
1642
+ } catch (error) {
1643
+ if (error instanceof SystemOperationError)
1644
+ return failureResult({ errorCode: error.code, message: error.message });
1645
+ return failureResult({
1646
+ errorCode: "system_execution_route_failed",
1647
+ message: "The bound execution route failed. No other destination was attempted; effects may be partial if dispatch began."
1648
+ });
1649
+ }
1650
+ };
1651
+ }
1652
+ function hasConnectionControl(params) {
1653
+ if (Object.hasOwn(params, "host_id")) return true;
1654
+ if (Object.hasOwn(params, "hostId")) return true;
1655
+ return Object.hasOwn(params, "connectionId");
1656
+ }
1657
+
1658
+ // plugins/system/source/request-system-modules.ts
1659
+ async function prepareSystemRequestModules(rootDir, modules, dependencies = {}) {
1660
+ if (modules.length === 0) return Object.freeze([]);
1661
+ if (modules.some((module2) => !isHostOperation(module2.definition.name)))
1662
+ throw new Error("system_request_module_unknown");
1663
+ const connection = dependencies.connection ?? defaultSystemHostConnection;
1664
+ const snapshot = await captureSystemTargetSnapshot({
1665
+ observeTargets: dependencies.observeTargets ?? observeSystemTargets,
1666
+ readHostStatus: () => connection.readHostStatus(rootDir)
1667
+ });
1668
+ if (snapshot.length === 0) return Object.freeze([]);
1669
+ const createNative = dependencies.createNativeHandlers ?? ((resolve) => createSystemHandlers(void 0, resolve));
1670
+ const nativeHandlers = createNative(
1671
+ async (target) => resolveCapturedNativeTarget(snapshot, target)
1672
+ );
1673
+ const handlers = createBoundSystemHandlers({
1674
+ rootDir,
1675
+ snapshot,
1676
+ connection,
1677
+ nativeHandlers
1678
+ });
1679
+ return Object.freeze(
1680
+ modules.map(
1681
+ (module2) => projectSystemRequestModule(module2, snapshot, handlers)
1682
+ )
1683
+ );
1684
+ }
1685
+ function projectSystemRequestModule(module2, snapshot, handlers) {
1686
+ const targets = Object.freeze(snapshot.map(routeTargetId));
1687
+ const availability = ` Available targets for this request: ${targets.join(", ")}.`;
1688
+ return Object.freeze({
1689
+ ...module2,
1690
+ normalInvocation: {
1691
+ ...module2.normalInvocation,
1692
+ operations: module2.normalInvocation.operations.map((operation) => ({
1693
+ ...operation,
1694
+ summary: operation.summary + availability,
1695
+ input: {
1696
+ ...operation.input,
1697
+ properties: {
1698
+ ...operation.input.properties,
1699
+ ...Object.hasOwn(operation.input.properties, "target") ? { target: { type: "string", enum: targets } } : {}
1700
+ }
1701
+ }
1702
+ }))
1703
+ },
1704
+ implementation: handlers[module2.definition.name],
1705
+ adapter: {
1706
+ ...module2.adapter,
1707
+ executionBinding: systemExecutionBinding(snapshot)
1708
+ }
1709
+ });
1710
+ }
1711
+ function systemExecutionBinding(snapshot) {
1712
+ return (call) => {
1713
+ if (call.tool === "system_targets")
1714
+ return {
1715
+ identity: JSON.stringify(snapshot.map(systemRouteBindingIdentity)),
1716
+ metadata: { displayTarget: snapshot.map(routeTargetId).join(", ") }
1717
+ };
1718
+ const route = requireSystemRequestRoute(snapshot, call.params.target);
1719
+ return {
1720
+ identity: systemRouteBindingIdentity(route),
1721
+ metadata: systemRouteMetadata(route)
1722
+ };
1723
+ };
1724
+ }
1725
+
1726
+ // plugins/system/source/index.ts
1727
+ var index_default = defineRuntimePlugin(({ rootDir }) => ({
1728
+ handlers: createSystemHandlers(),
1729
+ prepareRequest: (modules) => prepareSystemRequestModules(rootDir, modules)
1730
+ }));