talos-code 0.0.1 → 0.1.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 (401) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +111 -3
  3. package/THIRD_PARTY_NOTICES.md +40 -0
  4. package/dist/archive/zip.js +73 -0
  5. package/dist/args.js +97 -0
  6. package/dist/automations/history-store.js +34 -0
  7. package/dist/automations/policy-store.js +43 -0
  8. package/dist/automations/runner.js +107 -0
  9. package/dist/automations/schedule.js +85 -0
  10. package/dist/automations/windows-task.js +53 -0
  11. package/dist/commands/advanced-cli.js +233 -0
  12. package/dist/commands/checkpoint-cli.js +45 -0
  13. package/dist/commands/config-cli.js +107 -0
  14. package/dist/commands/context.js +17 -0
  15. package/dist/commands/extensions-cli.js +207 -0
  16. package/dist/commands/project-cli.js +74 -0
  17. package/dist/commands/project-commands.js +143 -0
  18. package/dist/commands/provider-cli.js +185 -0
  19. package/dist/commands/services-cli.js +248 -0
  20. package/dist/commands/session-cli.js +171 -0
  21. package/dist/commands/system-cli.js +405 -0
  22. package/dist/config/commands.js +60 -0
  23. package/dist/config/load.js +382 -0
  24. package/dist/config/migrations.js +48 -0
  25. package/dist/config/types.js +11 -0
  26. package/dist/diagnostics/development-log.js +154 -0
  27. package/dist/diagnostics/doctor.js +104 -0
  28. package/dist/diagnostics/redact.js +80 -0
  29. package/dist/diagnostics/zip.js +52 -0
  30. package/dist/errors.js +156 -0
  31. package/dist/events/bridge.js +130 -0
  32. package/dist/extensions/installer.js +178 -0
  33. package/dist/extensions/package-schema.js +24 -0
  34. package/dist/headless/result.js +84 -0
  35. package/dist/headless/run.js +230 -0
  36. package/dist/i18n/en/approval.js +43 -0
  37. package/dist/i18n/en/common.js +9 -0
  38. package/dist/i18n/en/credentials.js +82 -0
  39. package/dist/i18n/en/errors.js +246 -0
  40. package/dist/i18n/en/firstrun.js +89 -0
  41. package/dist/i18n/en/providers.js +37 -0
  42. package/dist/i18n/en/screen.js +736 -0
  43. package/dist/i18n/en/tools.js +127 -0
  44. package/dist/i18n/en.js +14 -0
  45. package/dist/i18n/error-view.js +307 -0
  46. package/dist/i18n/index.js +19 -0
  47. package/dist/i18n/kernel-map.js +139 -0
  48. package/dist/io.js +45 -0
  49. package/dist/main.js +330 -0
  50. package/dist/paths.js +41 -0
  51. package/dist/protocol/v2/codec.js +9 -0
  52. package/dist/protocol/v2/events.js +555 -0
  53. package/dist/protocol/v2/index.js +4 -0
  54. package/dist/protocol/v2/replay.js +28 -0
  55. package/dist/protocol/v2/types.js +1 -0
  56. package/dist/provider/control-plane.js +135 -0
  57. package/dist/provider/environment-keys.js +275 -0
  58. package/dist/provider/health.js +110 -0
  59. package/dist/provider/missing-key.js +48 -0
  60. package/dist/provider/model-catalog.js +168 -0
  61. package/dist/provider/provider-text.js +13 -0
  62. package/dist/provider/store.js +95 -0
  63. package/dist/provider/system-keyring.js +214 -0
  64. package/dist/runtime/active-run.js +63 -0
  65. package/dist/runtime/agent-tree.js +74 -0
  66. package/dist/runtime/attachments.js +84 -0
  67. package/dist/runtime/brokered-executor.js +395 -0
  68. package/dist/runtime/context-status.js +76 -0
  69. package/dist/runtime/create-runtime.js +111 -0
  70. package/dist/runtime/model-profile.js +361 -0
  71. package/dist/runtime/output-store.js +137 -0
  72. package/dist/runtime/provider-attempts.js +185 -0
  73. package/dist/runtime/replay-buffer.js +153 -0
  74. package/dist/runtime/repo.js +95 -0
  75. package/dist/runtime/session-facade.js +135 -0
  76. package/dist/runtime/session-summary.js +125 -0
  77. package/dist/runtime/supervisor.js +262 -0
  78. package/dist/runtime/talos-composition.js +1006 -0
  79. package/dist/runtime/types.js +5 -0
  80. package/dist/runtime/usage-snapshot.js +82 -0
  81. package/dist/security/auto-classifier.js +38 -0
  82. package/dist/security/credential-free-environment.js +54 -0
  83. package/dist/security/evaluate.js +243 -0
  84. package/dist/security/execution-backends.js +236 -0
  85. package/dist/security/execution-broker.js +102 -0
  86. package/dist/security/forge-scan.js +74 -0
  87. package/dist/security/from-approval.js +39 -0
  88. package/dist/security/mxc-execution-backend.js +281 -0
  89. package/dist/security/permission-engine.js +138 -0
  90. package/dist/security/permission-explanation.js +54 -0
  91. package/dist/security/persist.js +179 -0
  92. package/dist/security/plugin-guard.js +230 -0
  93. package/dist/security/process-tree-evidence-store.js +74 -0
  94. package/dist/security/process-tree-probe.js +554 -0
  95. package/dist/security/project-resource-inventory.js +186 -0
  96. package/dist/security/project-trust-gate.js +38 -0
  97. package/dist/security/project-trust.js +367 -0
  98. package/dist/security/rule-parser.js +201 -0
  99. package/dist/security/shell-segmentation.js +68 -0
  100. package/dist/security/trust-authority.js +324 -0
  101. package/dist/security/types.js +1 -0
  102. package/dist/security/workspace-identity.js +102 -0
  103. package/dist/services/automation-facade.js +59 -0
  104. package/dist/services/forge-facade.js +77 -0
  105. package/dist/services/hook-facade.js +240 -0
  106. package/dist/services/index.js +16 -0
  107. package/dist/services/library-facade.js +174 -0
  108. package/dist/services/mcp-facade.js +348 -0
  109. package/dist/services/memory-facade.js +126 -0
  110. package/dist/services/notes-facade.js +157 -0
  111. package/dist/services/plugin-facade.js +308 -0
  112. package/dist/services/research-facade.js +110 -0
  113. package/dist/services/task-board-facade.js +236 -0
  114. package/dist/services/workflow-catalog.js +246 -0
  115. package/dist/sessions/export-format.js +98 -0
  116. package/dist/sessions/metadata-store.js +160 -0
  117. package/dist/sessions/share.js +122 -0
  118. package/dist/sessions/transfer.js +16 -0
  119. package/dist/subcommands.js +62 -0
  120. package/dist/tui/agent-roster.js +36 -0
  121. package/dist/tui/app.js +3761 -0
  122. package/dist/tui/approval.js +36 -0
  123. package/dist/tui/boot/boot-sequence.js +76 -0
  124. package/dist/tui/boot/cinematic.js +243 -0
  125. package/dist/tui/boot/desktop-logo.js +82 -0
  126. package/dist/tui/boot.js +3 -0
  127. package/dist/tui/busy-input.js +58 -0
  128. package/dist/tui/catalog-service.js +559 -0
  129. package/dist/tui/components/assistant-stream.js +1 -0
  130. package/dist/tui/components/command-menu.js +68 -0
  131. package/dist/tui/components/composer.js +219 -0
  132. package/dist/tui/components/diff.js +35 -0
  133. package/dist/tui/components/footer.js +48 -0
  134. package/dist/tui/components/header.js +6 -0
  135. package/dist/tui/components/markdown.js +305 -0
  136. package/dist/tui/components/status-indicator.js +32 -0
  137. package/dist/tui/components/terminal-shell.js +205 -0
  138. package/dist/tui/components/thinking-row.js +19 -0
  139. package/dist/tui/components/tool-row.js +97 -0
  140. package/dist/tui/components/transcript-virtualizer.js +165 -0
  141. package/dist/tui/components/transcript.js +43 -0
  142. package/dist/tui/diff-model.js +77 -0
  143. package/dist/tui/editor-history.js +21 -0
  144. package/dist/tui/editor.js +210 -0
  145. package/dist/tui/event-adapter.js +436 -0
  146. package/dist/tui/exit-output.js +58 -0
  147. package/dist/tui/external-editor.js +53 -0
  148. package/dist/tui/file-completion.js +89 -0
  149. package/dist/tui/focus-manager.js +5 -0
  150. package/dist/tui/highlight.js +30 -0
  151. package/dist/tui/input-router.js +18 -0
  152. package/dist/tui/interrupt.js +99 -0
  153. package/dist/tui/keybindings.js +194 -0
  154. package/dist/tui/keymap-resolver.js +91 -0
  155. package/dist/tui/launch-state.js +139 -0
  156. package/dist/tui/line-diff.js +57 -0
  157. package/dist/tui/live-activity.js +45 -0
  158. package/dist/tui/metrics.js +123 -0
  159. package/dist/tui/onboarding.js +36 -0
  160. package/dist/tui/overlays/agent-tree.js +39 -0
  161. package/dist/tui/overlays/approval-dialog.js +640 -0
  162. package/dist/tui/overlays/automation-center.js +51 -0
  163. package/dist/tui/overlays/checkpoint-picker.js +47 -0
  164. package/dist/tui/overlays/context-inspector.js +36 -0
  165. package/dist/tui/overlays/effort-line.js +110 -0
  166. package/dist/tui/overlays/forge-center.js +46 -0
  167. package/dist/tui/overlays/help-dialog.js +16 -0
  168. package/dist/tui/overlays/history-picker.js +37 -0
  169. package/dist/tui/overlays/hook-center.js +70 -0
  170. package/dist/tui/overlays/library-center.js +55 -0
  171. package/dist/tui/overlays/mcp-center.js +60 -0
  172. package/dist/tui/overlays/memory-center.js +63 -0
  173. package/dist/tui/overlays/model-picker.js +72 -0
  174. package/dist/tui/overlays/notes-center.js +53 -0
  175. package/dist/tui/overlays/overlay-host.js +8 -0
  176. package/dist/tui/overlays/plugin-center.js +76 -0
  177. package/dist/tui/overlays/provider-picker.js +145 -0
  178. package/dist/tui/overlays/queue-editor.js +32 -0
  179. package/dist/tui/overlays/research-center.js +59 -0
  180. package/dist/tui/overlays/scroll-window.js +234 -0
  181. package/dist/tui/overlays/session-picker.js +115 -0
  182. package/dist/tui/overlays/tasks-center.js +83 -0
  183. package/dist/tui/overlays/theme-picker.js +21 -0
  184. package/dist/tui/overlays/transcript-search.js +58 -0
  185. package/dist/tui/overlays/trust-center.js +29 -0
  186. package/dist/tui/overlays/workflow-center.js +46 -0
  187. package/dist/tui/project-file-index.js +214 -0
  188. package/dist/tui/project-references.js +85 -0
  189. package/dist/tui/project-trust-prompt.js +287 -0
  190. package/dist/tui/prompt-history-store.js +116 -0
  191. package/dist/tui/queue-store.js +110 -0
  192. package/dist/tui/regions/budget.js +59 -0
  193. package/dist/tui/regions/views.js +96 -0
  194. package/dist/tui/render-coordinator.js +148 -0
  195. package/dist/tui/render-scheduler.js +4 -0
  196. package/dist/tui/run.js +69 -0
  197. package/dist/tui/selection-list.js +29 -0
  198. package/dist/tui/session-controller.js +778 -0
  199. package/dist/tui/session-export.js +54 -0
  200. package/dist/tui/shell-input.js +35 -0
  201. package/dist/tui/shell-layout.js +48 -0
  202. package/dist/tui/shell-model.js +98 -0
  203. package/dist/tui/slash-commands.js +80 -0
  204. package/dist/tui/state.js +151 -0
  205. package/dist/tui/status-bar.js +125 -0
  206. package/dist/tui/status-view.js +40 -0
  207. package/dist/tui/terminal-capabilities.js +9 -0
  208. package/dist/tui/terminal-session.js +11 -0
  209. package/dist/tui/text-width.js +66 -0
  210. package/dist/tui/theme-catalog.js +25 -0
  211. package/dist/tui/theme-store.js +23 -0
  212. package/dist/tui/theme.js +23 -0
  213. package/dist/tui/tool-display.js +135 -0
  214. package/dist/tui/tool-facts.js +1 -0
  215. package/dist/tui/tools/bash-renderer.js +32 -0
  216. package/dist/tui/tools/change.js +61 -0
  217. package/dist/tui/tools/edit-renderer.js +17 -0
  218. package/dist/tui/tools/generic-renderer.js +13 -0
  219. package/dist/tui/tools/list-renderer.js +14 -0
  220. package/dist/tui/tools/read-renderer.js +13 -0
  221. package/dist/tui/tools/registry.js +20 -0
  222. package/dist/tui/tools/row-format.js +187 -0
  223. package/dist/tui/tools/search-renderer.js +38 -0
  224. package/dist/tui/tools/shared.js +97 -0
  225. package/dist/tui/tools/write-renderer.js +15 -0
  226. package/dist/tui/transcript-model.js +441 -0
  227. package/dist/tui/ui-preferences.js +79 -0
  228. package/dist/tui/usage-view.js +77 -0
  229. package/dist/tui/vim-mode.js +99 -0
  230. package/dist/update/check.js +15 -0
  231. package/dist/update/npm.js +51 -0
  232. package/dist/update/run.js +129 -0
  233. package/dist/version.js +2 -0
  234. package/dist/workspace/checkpoint-store.js +210 -0
  235. package/dist/workspace/checkpoint.js +413 -0
  236. package/dist/workspace/restore.js +232 -0
  237. package/package.json +63 -5
  238. package/vendor/context-engine/package.json +11 -0
  239. package/vendor/context-engine/src/compaction-planner.mjs +57 -0
  240. package/vendor/context-engine/src/contracts.mjs +48 -0
  241. package/vendor/context-engine/src/engine.mjs +445 -0
  242. package/vendor/context-engine/src/node/context-export.mjs +164 -0
  243. package/vendor/context-engine/src/node/legacy-import.mjs +92 -0
  244. package/vendor/context-engine/src/node/migrations/001-context.sql +126 -0
  245. package/vendor/context-engine/src/node/sqlite-store.mjs +85 -0
  246. package/vendor/context-engine/src/node/sqlite-worker.mjs +559 -0
  247. package/vendor/context-engine/src/profiles.mjs +10 -0
  248. package/vendor/context-engine/src/retrieval.mjs +104 -0
  249. package/vendor/context-engine/src/summary.mjs +97 -0
  250. package/vendor/context-engine/src/usage.mjs +34 -0
  251. package/vendor/harness-ui/package.json +38 -0
  252. package/vendor/harness-ui/src/acp-agent.mjs +350 -0
  253. package/vendor/harness-ui/src/agent-service.mjs +2188 -0
  254. package/vendor/harness-ui/src/agui-events.mjs +452 -0
  255. package/vendor/harness-ui/src/ambiente-solo-server.mjs +121 -0
  256. package/vendor/harness-ui/src/artifact-store.mjs +39 -0
  257. package/vendor/harness-ui/src/assistenza.mjs +123 -0
  258. package/vendor/harness-ui/src/automation-scheduler.mjs +69 -0
  259. package/vendor/harness-ui/src/automation-store.mjs +145 -0
  260. package/vendor/harness-ui/src/browser-annota.mjs +639 -0
  261. package/vendor/harness-ui/src/browser-frame.mjs +211 -0
  262. package/vendor/harness-ui/src/browser-proxy-universale.mjs +519 -0
  263. package/vendor/harness-ui/src/browser-proxy.mjs +87 -0
  264. package/vendor/harness-ui/src/browser-sessione-viva.mjs +329 -0
  265. package/vendor/harness-ui/src/browser-stream.mjs +445 -0
  266. package/vendor/harness-ui/src/browser-vivo.mjs +694 -0
  267. package/vendor/harness-ui/src/chat-image-attachments.mjs +72 -0
  268. package/vendor/harness-ui/src/config.mjs +697 -0
  269. package/vendor/harness-ui/src/contesto-del-progetto.mjs +385 -0
  270. package/vendor/harness-ui/src/context-asset-adapter.mjs +72 -0
  271. package/vendor/harness-ui/src/context-desktop-service.mjs +253 -0
  272. package/vendor/harness-ui/src/context-embedding-runtime.mjs +252 -0
  273. package/vendor/harness-ui/src/context-inference-scheduler.mjs +81 -0
  274. package/vendor/harness-ui/src/context-native-compaction.mjs +75 -0
  275. package/vendor/harness-ui/src/context-provider-adapter.mjs +141 -0
  276. package/vendor/harness-ui/src/context-runtime.mjs +118 -0
  277. package/vendor/harness-ui/src/context-token-counters.mjs +184 -0
  278. package/vendor/harness-ui/src/context-tool-catalog.mjs +86 -0
  279. package/vendor/harness-ui/src/context-tool-output.mjs +72 -0
  280. package/vendor/harness-ui/src/costo-elenco.mjs +252 -0
  281. package/vendor/harness-ui/src/custom-task.mjs +171 -0
  282. package/vendor/harness-ui/src/doctor.mjs +142 -0
  283. package/vendor/harness-ui/src/document-filename.mjs +97 -0
  284. package/vendor/harness-ui/src/document-generator.mjs +493 -0
  285. package/vendor/harness-ui/src/document-report.mjs +331 -0
  286. package/vendor/harness-ui/src/duckduckgo-search.mjs +155 -0
  287. package/vendor/harness-ui/src/elenco-profondo.mjs +337 -0
  288. package/vendor/harness-ui/src/favicon-proxy.mjs +113 -0
  289. package/vendor/harness-ui/src/forge-contract.mjs +221 -0
  290. package/vendor/harness-ui/src/frequent-dirs.mjs +134 -0
  291. package/vendor/harness-ui/src/generated-image-store.mjs +147 -0
  292. package/vendor/harness-ui/src/generation-idle.mjs +332 -0
  293. package/vendor/harness-ui/src/gguf-header.mjs +207 -0
  294. package/vendor/harness-ui/src/git-service.mjs +626 -0
  295. package/vendor/harness-ui/src/gitignore-elenco.mjs +604 -0
  296. package/vendor/harness-ui/src/harness-receipt-keypair.mjs +207 -0
  297. package/vendor/harness-ui/src/hf-direct-transfer.mjs +170 -0
  298. package/vendor/harness-ui/src/hf-hub-client.mjs +106 -0
  299. package/vendor/harness-ui/src/hf-image-proxy.mjs +105 -0
  300. package/vendor/harness-ui/src/hf-model-transfer.mjs +245 -0
  301. package/vendor/harness-ui/src/hook-registry.mjs +186 -0
  302. package/vendor/harness-ui/src/http-app.mjs +6259 -0
  303. package/vendor/harness-ui/src/http-lifecycle.mjs +132 -0
  304. package/vendor/harness-ui/src/id-archivio.mjs +27 -0
  305. package/vendor/harness-ui/src/image-generator.mjs +143 -0
  306. package/vendor/harness-ui/src/istruzioni-di-progetto.mjs +234 -0
  307. package/vendor/harness-ui/src/kernel/dist/kernelPerIlBanco.js +518 -0
  308. package/vendor/harness-ui/src/kernel/talosHarness.mjs +10437 -0
  309. package/vendor/harness-ui/src/library-policy-store.mjs +175 -0
  310. package/vendor/harness-ui/src/library-store.mjs +652 -0
  311. package/vendor/harness-ui/src/llama-server-supervisor.mjs +629 -0
  312. package/vendor/harness-ui/src/local-model-store.mjs +339 -0
  313. package/vendor/harness-ui/src/local-runtime-contract.mjs +66 -0
  314. package/vendor/harness-ui/src/local-runtime-events.mjs +44 -0
  315. package/vendor/harness-ui/src/local-runtime-llama-server.mjs +244 -0
  316. package/vendor/harness-ui/src/local-runtime-probe.mjs +401 -0
  317. package/vendor/harness-ui/src/machine-capacity.mjs +66 -0
  318. package/vendor/harness-ui/src/mappa-cartelle.mjs +491 -0
  319. package/vendor/harness-ui/src/mcp-client.mjs +98 -0
  320. package/vendor/harness-ui/src/mcp-registry.mjs +157 -0
  321. package/vendor/harness-ui/src/mcp-session.mjs +177 -0
  322. package/vendor/harness-ui/src/memory-store.mjs +227 -0
  323. package/vendor/harness-ui/src/model-catalog-models-dev.mjs +276 -0
  324. package/vendor/harness-ui/src/model-catalog.mjs +129 -0
  325. package/vendor/harness-ui/src/model-destination.mjs +189 -0
  326. package/vendor/harness-ui/src/modifica-ancorata.mjs +177 -0
  327. package/vendor/harness-ui/src/native-provider-adapter.mjs +205 -0
  328. package/vendor/harness-ui/src/notes-store.mjs +250 -0
  329. package/vendor/harness-ui/src/openai-compatible-runtime.mjs +428 -0
  330. package/vendor/harness-ui/src/openrouter-oauth.mjs +339 -0
  331. package/vendor/harness-ui/src/path-policy.mjs +442 -0
  332. package/vendor/harness-ui/src/plugin-registry.mjs +780 -0
  333. package/vendor/harness-ui/src/plugin-session.mjs +180 -0
  334. package/vendor/harness-ui/src/process-policy.mjs +345 -0
  335. package/vendor/harness-ui/src/prompt-enhancer-provider.mjs +94 -0
  336. package/vendor/harness-ui/src/provider-auth-cloud.mjs +95 -0
  337. package/vendor/harness-ui/src/provider-credential-store.mjs +541 -0
  338. package/vendor/harness-ui/src/provider-probe.mjs +582 -0
  339. package/vendor/harness-ui/src/provider-registry.mjs +1633 -0
  340. package/vendor/harness-ui/src/pty-terminal.mjs +312 -0
  341. package/vendor/harness-ui/src/public-problem.mjs +109 -0
  342. package/vendor/harness-ui/src/research/card.mjs +235 -0
  343. package/vendor/harness-ui/src/research/citations.mjs +142 -0
  344. package/vendor/harness-ui/src/research/collector.mjs +275 -0
  345. package/vendor/harness-ui/src/research/deposito-a-pezzi.mjs +139 -0
  346. package/vendor/harness-ui/src/research/dossier.mjs +114 -0
  347. package/vendor/harness-ui/src/research/esportazioni.mjs +560 -0
  348. package/vendor/harness-ui/src/research/fetch-cache.mjs +465 -0
  349. package/vendor/harness-ui/src/research/fidelity.mjs +122 -0
  350. package/vendor/harness-ui/src/research/independence.mjs +159 -0
  351. package/vendor/harness-ui/src/research/ledger.mjs +166 -0
  352. package/vendor/harness-ui/src/research/markdown-server.mjs +565 -0
  353. package/vendor/harness-ui/src/research/narration.mjs +181 -0
  354. package/vendor/harness-ui/src/research/open-cards.mjs +131 -0
  355. package/vendor/harness-ui/src/research/opposing.mjs +305 -0
  356. package/vendor/harness-ui/src/research/outline.mjs +111 -0
  357. package/vendor/harness-ui/src/research/page-budget.mjs +209 -0
  358. package/vendor/harness-ui/src/research/pdf.mjs +291 -0
  359. package/vendor/harness-ui/src/research/plan.mjs +301 -0
  360. package/vendor/harness-ui/src/research/raccolta-viva.mjs +452 -0
  361. package/vendor/harness-ui/src/research/recheck-document.mjs +69 -0
  362. package/vendor/harness-ui/src/research/recheck-history.mjs +192 -0
  363. package/vendor/harness-ui/src/research/recheck.mjs +194 -0
  364. package/vendor/harness-ui/src/research/report.mjs +203 -0
  365. package/vendor/harness-ui/src/research/run.mjs +527 -0
  366. package/vendor/harness-ui/src/research/synthesis.mjs +318 -0
  367. package/vendor/harness-ui/src/research/verification.mjs +572 -0
  368. package/vendor/harness-ui/src/research-orchestrator.mjs +2679 -0
  369. package/vendor/harness-ui/src/research-store.mjs +1133 -0
  370. package/vendor/harness-ui/src/runtime-build-manifest.mjs +26 -0
  371. package/vendor/harness-ui/src/runtime-contract.mjs +59 -0
  372. package/vendor/harness-ui/src/runtime-owner-adapter.mjs +1348 -0
  373. package/vendor/harness-ui/src/runtime-owner-contract.mjs +32 -0
  374. package/vendor/harness-ui/src/scheda-di-lavoro.mjs +249 -0
  375. package/vendor/harness-ui/src/search-source-store.mjs +172 -0
  376. package/vendor/harness-ui/src/session-registry.mjs +6095 -0
  377. package/vendor/harness-ui/src/session-store.mjs +220 -0
  378. package/vendor/harness-ui/src/sessione-pronta.mjs +73 -0
  379. package/vendor/harness-ui/src/setup-stato.mjs +31 -0
  380. package/vendor/harness-ui/src/sezioni-istruzioni.mjs +204 -0
  381. package/vendor/harness-ui/src/skill-registry.mjs +120 -0
  382. package/vendor/harness-ui/src/sse-replay-coalescente.mjs +0 -0
  383. package/vendor/harness-ui/src/static-files.mjs +96 -0
  384. package/vendor/harness-ui/src/stream-partition.mjs +123 -0
  385. package/vendor/harness-ui/src/subagent-orchestrator.mjs +453 -0
  386. package/vendor/harness-ui/src/task-catalog.mjs +65 -0
  387. package/vendor/harness-ui/src/tasks-store.mjs +220 -0
  388. package/vendor/harness-ui/src/terminal-registry.mjs +312 -0
  389. package/vendor/harness-ui/src/terminal-ws.mjs +170 -0
  390. package/vendor/harness-ui/src/tool-forge-store.mjs +299 -0
  391. package/vendor/harness-ui/src/tool-schema-normalize.mjs +100 -0
  392. package/vendor/harness-ui/src/usage-cache.mjs +315 -0
  393. package/vendor/harness-ui/src/workspace-browser.mjs +213 -0
  394. package/vendor/harness-ui/src/workspace-context.mjs +124 -0
  395. package/vendor/harness-ui/src/workspace-disk.mjs +62 -0
  396. package/vendor/harness-ui/src/workspace-files.mjs +589 -0
  397. package/vendor/harness-ui/src/workspace-info.mjs +189 -0
  398. package/vendor/harness-ui/src/workspace-launch-store.mjs +150 -0
  399. package/vendor/harness-ui/src/workspace-tree.mjs +67 -0
  400. package/vendor/harness-ui/src/workspace-watcher.mjs +161 -0
  401. package/vendor/manifest.json +170 -0
@@ -0,0 +1,236 @@
1
+ import { createHash } from 'node:crypto';
2
+ import path from 'node:path';
3
+ import { createExecutionBroker } from "./execution-broker.js";
4
+ import { MXC_CHILD_ENVIRONMENT_NAMES, MXC_UI_POLICY, createMxcExecutionBackend, loadMxcSdk, mxcChildEnvironment, windowsCommandLine } from "./mxc-execution-backend.js";
5
+ import { createProcessTreeEvidenceStore } from "./process-tree-evidence-store.js";
6
+ import { createHostProcessTreeProbe, createSandboxWorkloadProbe, isolationCheckAborted } from "./process-tree-probe.js";
7
+ /*
8
+ * ⭐⭐⭐ B1 slice 19 — THE PROBE'S ENVIRONMENT IS AN ALLOWLIST, BECAUSE IT GOES ON A COMMAND LINE.
9
+ *
10
+ * SDK 0.8.0 copies the environment it is given into the configuration it passes as `--config-base64` on
11
+ * the `wxc-exec.exe` command line (`dist/sandbox.js`, `injectEnvIntoConfig`; `dist/helper.js`,
12
+ * `resolveBinaryAndCommonArgs`), and a command line is what process auditing records.
13
+ * · Round 1 passed `process.env` filtered by the kernel's name-shape denylist. Adversarial review
14
+ * measured 24 of 29 realistic secret-bearing names with no credential shape (DATABASE_URL, SENTRY_DSN,
15
+ * GH_PAT, MYSQL_PWD, HTTPS_PROXY with credentials, GIT_CONFIG_PARAMETERS carrying an authorization
16
+ * header…) decoded out of that argument, and one 15,000-character variable was enough to approach
17
+ * ENAMETOOLONG. A denylist cannot know what a value holds.
18
+ * · The probe executor runs a fixed script that reads nothing from its environment (the folder arrives
19
+ * in argv, the binary is `process.execPath`: `process-tree-probe.ts`, EXECUTOR_SOURCE and
20
+ * DESCENDANT_SOURCE). It gets the system variables below and nothing else, as decided by the
21
+ * coordinator. ⛔ A name is added only when a measurement shows the executor needs it.
22
+ * · ⛔⛔ R0 lane S (2026-09-23): that list had no LOCALAPPDATA, and with it every sandboxed process died before
23
+ * its first instruction (`WIN32_ERROR(203)`, measured; microsoft/mxc#1130). The probe now gets EXACTLY the
24
+ * environment every brokered command gets — `MXC_CHILD_ENVIRONMENT_NAMES` in `mxc-execution-backend.ts`, where
25
+ * each name carries its measurement — so "verified" is a statement about the container commands really run in.
26
+ */
27
+ export const PROBE_ENVIRONMENT_NAMES = MXC_CHILD_ENVIRONMENT_NAMES;
28
+ /** Only the allowlisted names this host defines, PATH System32-first. On Windows `process.env` lookups ignore case. */
29
+ export function probeEnvironment(source = process.env) {
30
+ return mxcChildEnvironment(source);
31
+ }
32
+ /*
33
+ * ⭐ R3 (owner, 2026-09-24): the sandbox check starts at startup and is INTERRUPTIBLE. Measured before: a check still running
34
+ * when TALOS quit (the MXC workloads take seconds on a fresh profile, up to 30 s each) kept the process alive after its
35
+ * exit, and the next Ctrl+C reached a process whose raw mode was off and killed it with code 1 (acceptance s09).
36
+ * · Every check runs under one process-wide AbortSignal and is tracked while it runs. Quitting calls
37
+ * `abortIsolationChecks()`: the probes end every process they started (process-tree-probe.ts, `stopAll`) and the
38
+ * call waits for them, bounded, so nothing a check started outlives TALOS.
39
+ * · An aborted check is NO verdict: the availability question answers "not available", nothing is written to the
40
+ * evidence store (a verdict landing after the abort is thrown away), and the next start checks again. The
41
+ * three-signal unanimity rule of the probe is untouched.
42
+ */
43
+ let checks = new AbortController();
44
+ const runningChecks = new Set();
45
+ /*
46
+ * ⛔ R3 (never a kill on trust): the pids a stopped check could not prove to be its own and therefore left running. The
47
+ * probe states them on its error (`leftover`); quitting hands them to the caller, so they are never silently ignored.
48
+ */
49
+ const leftBehind = [];
50
+ function noteLeftover(error) {
51
+ const pids = error?.leftover;
52
+ if (Array.isArray(pids))
53
+ for (const pid of pids)
54
+ if (typeof pid === 'number' && !leftBehind.includes(pid))
55
+ leftBehind.push(pid);
56
+ }
57
+ export function isolationCheckSignal() { return checks.signal; }
58
+ function track(task) {
59
+ const settled = task.then(() => undefined, error => { noteLeftover(error); }).finally(() => { runningChecks.delete(settled); });
60
+ runningChecks.add(settled);
61
+ return task;
62
+ }
63
+ /** Runs one check under the process-wide abort, tracked until it settles. */
64
+ export function runIsolationCheck(run) {
65
+ const signal = checks.signal;
66
+ if (signal.aborted)
67
+ return Promise.reject(isolationCheckAborted());
68
+ return track(run(signal));
69
+ }
70
+ /**
71
+ * TALOS is quitting: abort every running check and wait (at most `graceMs`) for them to end what they started. Answers
72
+ * the pids a check could not prove to be its own and so left running (R3: never a kill on trust), for the caller to state.
73
+ */
74
+ export async function abortIsolationChecks(graceMs = 2_000) {
75
+ const previous = checks;
76
+ checks = new AbortController();
77
+ sharedBackends.clear();
78
+ previous.abort();
79
+ const pending = [...runningChecks];
80
+ if (pending.length > 0) {
81
+ let timer;
82
+ await Promise.race([Promise.allSettled(pending), new Promise(resolve => { timer = setTimeout(resolve, graceMs); timer.unref?.(); })]);
83
+ if (timer)
84
+ clearTimeout(timer);
85
+ }
86
+ return leftBehind.splice(0);
87
+ }
88
+ /** A result the caller waits for, or an AbortError the moment the signal fires, whatever the task does after. */
89
+ function untilAborted(task, signal) {
90
+ if (signal.aborted)
91
+ return Promise.reject(isolationCheckAborted());
92
+ return new Promise((resolve, reject) => {
93
+ const onAbort = () => reject(isolationCheckAborted());
94
+ signal.addEventListener('abort', onAbort, { once: true });
95
+ task.then(value => { signal.removeEventListener('abort', onAbort); resolve(value); }, error => { signal.removeEventListener('abort', onAbort); reject(error); });
96
+ });
97
+ }
98
+ /**
99
+ * Runs the probe's executor inside the same MXC containment the broker would use for a command,
100
+ * so the measurement is of the sandbox and not of a bare `child_process` tree.
101
+ *
102
+ * The volume root is granted read-only on purpose. Upstream microsoft/mxc#1109 records that a
103
+ * read-write grant on a user-profile directory is unusable on a BaseContainer host unless the
104
+ * volume root is also in the read-only grants, and that adding `C:\\Users` or the profile
105
+ * directory alone does not fix it. Without this the probe would answer "not verified" forever for
106
+ * a reason that has nothing to do with process trees.
107
+ */
108
+ export function mxcSandboxedSpawn(getSdk) {
109
+ return async (request) => {
110
+ const sdk = await getSdk();
111
+ const volumeRoot = path.parse(request.probeDirectory).root;
112
+ const policy = {
113
+ version: '0.8.0-alpha',
114
+ filesystem: { readwritePaths: [request.probeDirectory], readonlyPaths: [volumeRoot], clearPolicyOnExit: true },
115
+ network: { egress: { default: 'deny' }, ingress: { default: 'deny', hostLoopback: 'deny' } },
116
+ /* R0 lane S, owner decision 4: the same UI policy as a brokered command (node.exe dies 0xC0000142 without Win32k). */
117
+ ui: { ...MXC_UI_POLICY }
118
+ };
119
+ const identity = `TALOS_CLI_PROBE_${createHash('sha256').update(request.probeDirectory).digest('hex').slice(0, 24)}`;
120
+ const config = sdk.createConfigFromPolicy(policy, 'process', identity);
121
+ config.process = { ...(config.process ?? { commandLine: '' }), commandLine: windowsCommandLine([request.executable, ...request.args]), cwd: request.cwd };
122
+ /* ⛔ B1 slice 19: never `process.env`, and never a denylist of it — see PROBE_ENVIRONMENT_NAMES above. */
123
+ const child = sdk.spawnSandboxFromConfig(config, { usePty: false, experimental: true }, request.cwd, probeEnvironment());
124
+ /*
125
+ * B1 slice 12, round 3: `exited` carries HOW the executor ended, so the probe's reason can say it.
126
+ * Measured on this host with the real SDK and this policy: node.exe exits 3221225794 (0xC0000142,
127
+ * STATUS_DLL_INIT_FAILED) within 73-139 ms, and before this the reason could only read «exit status
128
+ * not reported by the sandbox spawner».
129
+ * The promise settles once. `exit` is listened to first and Node emits it before `close`, so the
130
+ * status comes from `exit`; a `close` that arrives without a prior `exit` still settles the wait,
131
+ * with the status it carries or with nothing — never an invented one. A spawn `error` has no status.
132
+ */
133
+ let done = () => { };
134
+ const exited = new Promise(resolve => { done = resolve; });
135
+ child.once('exit', (code, signal) => done({ exitCode: code, signal }));
136
+ child.once('close', (code, signal) => done(code === undefined ? undefined : { exitCode: code, signal: signal ?? null }));
137
+ child.once('error', () => done());
138
+ return { pid: child.pid ?? undefined, kill: () => { try {
139
+ child.kill();
140
+ }
141
+ catch { } }, exited };
142
+ };
143
+ }
144
+ /**
145
+ * The process-tree measurement first (its reason is the one a person has read until now), then the real workloads
146
+ * (gate E3). Verified only when both are; the workload evidence rides on the process-tree evidence either way.
147
+ */
148
+ export function withWorkloads(tree, workloads) {
149
+ return async () => {
150
+ const measured = await tree();
151
+ if (!measured.verified)
152
+ return measured;
153
+ const ran = await workloads();
154
+ const evidence = { ...measured.evidence, workloads: ran.workloads };
155
+ return ran.ok ? { verified: true, evidence } : { verified: false, reason: ran.reason ?? 'PROCESS_TREE_PROBE_WORKLOAD_FAILED', evidence };
156
+ };
157
+ }
158
+ export function createVerifiedMxcBackend(options) {
159
+ const platform = options.platform ?? process.platform;
160
+ const signal = options.signal ?? isolationCheckSignal();
161
+ const store = options.store ?? createProcessTreeEvidenceStore({ cacheRoot: options.paths.cacheRoot });
162
+ let sdkPromise;
163
+ const getSdk = () => sdkPromise ??= options.sdk !== undefined
164
+ ? Promise.resolve(options.sdk)
165
+ : options.sdkLoader !== undefined ? options.sdkLoader() : loadMxcSdk();
166
+ const probe = options.probe ?? withWorkloads(createHostProcessTreeProbe({ platform, spawn: mxcSandboxedSpawn(getSdk), signal }), createSandboxWorkloadProbe({ platform, spawn: mxcSandboxedSpawn(getSdk), signal }));
167
+ /*
168
+ * ⛔ R0 lane S: a record written by the default probe before it ran the workloads says nothing about them (a
169
+ * positive one lives 24 h). Only a record that carries the workload evidence answers for the default probe; an
170
+ * injected probe owns its own records.
171
+ */
172
+ const answersForThisProbe = (record) => options.probe !== undefined || record.evidence?.workloads !== undefined;
173
+ // One measurement per backend instance: the cache lookup and the probe tree both happen at most once.
174
+ let pending;
175
+ const verify = () => pending ??= track((async () => {
176
+ if (signal.aborted)
177
+ throw isolationCheckAborted();
178
+ const cached = await store.read();
179
+ if (cached && answersForThisProbe(cached))
180
+ return cached;
181
+ /* The probe is tracked too, so quitting waits (bounded) for it to end the processes it started. */
182
+ const measured = await untilAborted(track(probe()), signal);
183
+ /* ⛔ An aborted check is no verdict: a result that lands after the abort is never trusted nor cached. */
184
+ if (signal.aborted)
185
+ throw isolationCheckAborted();
186
+ /* ⛔ R3: a check that left running a process it could not prove its own is stated, never cached — the next start checks again. */
187
+ if ((measured.evidence?.cleanup?.leftover?.length ?? 0) > 0)
188
+ return measured;
189
+ // The cache is an optimisation, never a gate: an unwritable cache must not make a verified host unavailable.
190
+ try {
191
+ await store.write(measured);
192
+ }
193
+ catch { }
194
+ return measured;
195
+ })());
196
+ return createMxcExecutionBackend({ platform, sdkLoader: getSdk, verifyProcessTreeKillOnClose: verify });
197
+ }
198
+ /*
199
+ * R0 (2026-09-23, owner: wire the real sandbox state into auto mode). One verified backend per cache root and process,
200
+ * shared by the broker and by the auto classifier's isolation source, so the host is probed once and both answer from
201
+ * the same measurement. Injected SDKs, stores or probes (tests) always get their own backend.
202
+ */
203
+ const sharedBackends = new Map();
204
+ function sharedVerifiedBackend(options) {
205
+ if (options.sdk !== undefined || options.sdkLoader !== undefined || options.store !== undefined || options.probe !== undefined)
206
+ return createVerifiedMxcBackend(options);
207
+ const key = `${options.platform ?? process.platform}${options.paths.cacheRoot}`;
208
+ let backend = sharedBackends.get(key);
209
+ if (!backend) {
210
+ backend = createVerifiedMxcBackend(options);
211
+ sharedBackends.set(key, backend);
212
+ }
213
+ return backend;
214
+ }
215
+ export function createCliExecutionBroker(options) {
216
+ return createExecutionBroker({ platform: options.platform ?? process.platform, windowsSandbox: sharedVerifiedBackend(options) });
217
+ }
218
+ /** Isolation state for the auto classifier: verified only when the same backend the broker uses is available. */
219
+ export function cliShellIsolation(options) {
220
+ return async () => {
221
+ const platform = options.platform ?? process.platform;
222
+ if (platform !== 'win32')
223
+ return { verified: false, reason: `no verified sandbox backend on ${platform}` };
224
+ /* R3: a check stopped because TALOS is quitting answers nothing (`aborted`), never a verdict. */
225
+ const signal = options.signal ?? isolationCheckSignal();
226
+ try {
227
+ const state = await sharedVerifiedBackend(options).available();
228
+ if (signal.aborted)
229
+ return { verified: false, aborted: true, reason: 'the check was stopped before it finished' };
230
+ return { verified: state.available === true, ...(state.reason ? { reason: state.reason } : {}) };
231
+ }
232
+ catch (error) {
233
+ return signal.aborted ? { verified: false, aborted: true, reason: 'the check was stopped before it finished' } : { verified: false, reason: error instanceof Error ? error.message : String(error) };
234
+ }
235
+ };
236
+ }
@@ -0,0 +1,102 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { realpath, stat } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { TalosError } from "../errors.js";
5
+ function error(code, request, cause, hint) { return new TalosError({ code, component: 'execution-broker', retryable: false, ...(hint ? { hint } : {}), docs: 'https://learn.microsoft.com/windows/win32/secauthz/createprocessinsandbox', traceId: request.id }, cause); }
6
+ async function canonicalDirectory(value, cwd, request) {
7
+ try {
8
+ const canonical = await realpath(path.resolve(cwd, value));
9
+ if (!(await stat(canonical)).isDirectory())
10
+ throw new Error('path is not a directory');
11
+ return canonical;
12
+ }
13
+ catch (cause) {
14
+ throw error('SANDBOX_PATH_INVALID', request, cause, `Create the sandbox path before execution: ${value}`);
15
+ }
16
+ }
17
+ function contains(root, candidate) { const relative = path.relative(root, candidate); return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative)); }
18
+ /**
19
+ * Upstream microsoft/mxc#1109 forces the volume root into the read-only grants before a
20
+ * read-write grant on a user-profile directory is usable on a BaseContainer host. That grant makes
21
+ * the containment check below trivially true for every request, so a volume root never satisfies
22
+ * it on its own: the working directory must be covered by a grant that is narrower than the whole
23
+ * volume. The volume root is still forwarded to the backend as a read-only grant.
24
+ */
25
+ function isVolumeRoot(candidate) { return path.parse(candidate).root === candidate; }
26
+ async function normalizeRequest(request) {
27
+ const cwd = await canonicalDirectory(request.cwd, process.cwd(), request);
28
+ const readWritePaths = [...new Set(await Promise.all(request.readWritePaths.map(value => canonicalDirectory(value, cwd, request))))].sort();
29
+ const readOnlyPaths = [...new Set(await Promise.all(request.readOnlyPaths.map(value => canonicalDirectory(value, cwd, request))))].filter(value => !readWritePaths.some(root => contains(root, value))).sort();
30
+ if (![...readWritePaths, ...readOnlyPaths].filter(root => !isVolumeRoot(root)).some(root => contains(root, cwd)))
31
+ throw error('SANDBOX_CWD_NOT_GRANTED', request, undefined, 'Add cwd to readWritePaths or readOnlyPaths: a granted volume root does not cover it');
32
+ return { ...request, cwd, readWritePaths, readOnlyPaths };
33
+ }
34
+ export async function createWindowsSandboxPolicy(request) {
35
+ const normalized = await normalizeRequest(request);
36
+ const suffix = createHash('sha256').update(`${normalized.id}\0${normalized.cwd}`).digest('hex').slice(0, 24);
37
+ return { version: '0.1.0', identity: `TALOS_CLI_${suffix}`, appContainer: true, disallowWin32kSystemCalls: false, fsReadWrite: normalized.readWritePaths, fsReadOnly: normalized.readOnlyPaths, capabilities: normalized.network === 'internet-client' ? ['internetClient'] : [] };
38
+ }
39
+ function verifyEvidence(backend, request, applied) {
40
+ const mismatch = () => { throw error('SANDBOX_EVIDENCE_MISMATCH', request, undefined, `Backend ${backend.name} did not apply its declared enforcement`); };
41
+ if (applied.enforcement !== backend.level || applied.processTree !== 'job-object-kill-on-close')
42
+ mismatch();
43
+ if (backend.level === 'windows-sandbox') {
44
+ if (!applied.appContainer || applied.filesystem !== 'bfs' || applied.network !== request.network || applied.sandboxSpecVersion !== '0.1.0')
45
+ mismatch();
46
+ }
47
+ else if (applied.appContainer || applied.filesystem !== 'restricted-token' || applied.network !== 'not-enforced' || applied.sandboxSpecVersion !== undefined)
48
+ mismatch();
49
+ }
50
+ export function createExecutionBroker({ platform = process.platform, windowsSandbox, restrictedProcess }) {
51
+ return { async execute(input) {
52
+ const request = await normalizeRequest(input);
53
+ const windowsAvailability = platform === 'win32' && windowsSandbox?.level === 'windows-sandbox' ? await windowsSandbox.available() : { available: false, reason: 'Windows sandbox backend is unavailable' };
54
+ let backend;
55
+ if (windowsAvailability.available)
56
+ backend = windowsSandbox;
57
+ else if (request.requiredEnforcement === 'windows-sandbox')
58
+ throw error('SANDBOX_REQUIRED_UNAVAILABLE', request, new Error(windowsAvailability.reason ?? 'Windows sandbox backend is unavailable'), 'Install a verified Windows sandbox backend or change the explicit policy');
59
+ /*
60
+ * ⛔ B1 slice 12, round 2 — the hint below is what a person reads in the enforcement line
61
+ * («no isolation backend on this host: <hint>»). It used to be one fixed sentence, discarding
62
+ * the reason each backend had just given; on this host that hid
63
+ * `PROCESS_TREE_PROBE_EXECUTOR_EXITED` behind «No execution backend satisfies the requested
64
+ * enforcement». Every CONFIGURED backend is now named with its own reason. A backend that is
65
+ * not configured is not a fact about the host, so it is not listed.
66
+ */
67
+ const declined = [];
68
+ if (!backend && windowsSandbox) {
69
+ if (platform !== 'win32')
70
+ declined.push(`${windowsSandbox.name}: requires win32, this host is ${platform}`);
71
+ else if (windowsSandbox.level !== 'windows-sandbox')
72
+ declined.push(`${windowsSandbox.name}: declares level ${windowsSandbox.level}, not windows-sandbox`);
73
+ else
74
+ declined.push(`${windowsSandbox.name}: ${windowsAvailability.reason ?? 'unavailable, and it gave no reason'}`);
75
+ }
76
+ if (!backend && restrictedProcess) {
77
+ if (restrictedProcess.level !== 'restricted-process')
78
+ declined.push(`${restrictedProcess.name}: declares level ${restrictedProcess.level}, not restricted-process`);
79
+ else {
80
+ const restrictedAvailability = await restrictedProcess.available();
81
+ if (restrictedAvailability.available)
82
+ backend = restrictedProcess;
83
+ else
84
+ declined.push(`${restrictedProcess.name}: ${restrictedAvailability.reason ?? 'unavailable, and it gave no reason'}`);
85
+ }
86
+ }
87
+ if (!backend)
88
+ throw error('EXECUTION_BACKEND_UNAVAILABLE', request, undefined, declined.length > 0 ? declined.join('; ') : 'no execution backend is configured');
89
+ try {
90
+ const windowsSandboxPolicy = backend.level === 'windows-sandbox' ? await createWindowsSandboxPolicy(request) : undefined;
91
+ const result = await backend.execute(windowsSandboxPolicy ? { request, windowsSandboxPolicy } : { request });
92
+ verifyEvidence(backend, request, result.applied);
93
+ const evidence = { requestedEnforcement: request.requiredEnforcement, appliedEnforcement: result.applied.enforcement, backend: backend.name, appContainer: result.applied.appContainer, filesystem: result.applied.filesystem, network: result.applied.network, processTree: result.applied.processTree, ...(result.applied.processTreeEvidence ? { processTreeEvidence: result.applied.processTreeEvidence } : {}), ...(result.applied.sandboxSpecVersion ? { sandboxSpecVersion: result.applied.sandboxSpecVersion } : {}) };
94
+ return { exitCode: result.exitCode, stdout: result.stdout, stderr: result.stderr, evidence };
95
+ }
96
+ catch (cause) {
97
+ if (cause instanceof TalosError)
98
+ throw cause;
99
+ throw error('EXECUTION_BACKEND_FAILED', request, cause, 'Inspect the backend health and enforcement evidence');
100
+ }
101
+ } };
102
+ }
@@ -0,0 +1,74 @@
1
+ const OWNER_PACKAGE_KEYS = new Set(['schemaVersion', 'revision', 'manifest', 'simulation']);
2
+ const SIMULATION_KEYS = new Set(['input', 'capabilityResults']);
3
+ const MANIFEST_ID = /^[a-z0-9][a-z0-9_-]{2,63}$/u;
4
+ const MANIFEST_FIELDS = new Set(['id', 'title', 'description', 'inputSchema', 'flow']);
5
+ const FLOW_FIELDS = new Set(['entry', 'maxTransitions', 'nodes']);
6
+ const NODE_FIELDS = {
7
+ capability: new Set(['id', 'type', 'capability', 'input', 'target', 'next']),
8
+ if: new Set(['id', 'type', 'condition', 'then', 'else']),
9
+ return: new Set(['id', 'type', 'value']),
10
+ fail: new Set(['id', 'type', 'code', 'message']),
11
+ };
12
+ /* R2 (gate E6): the code lives on `error.code` only; a `CODE: ` prefix made the failure line print it twice (D-06). */
13
+ function fail(message) { throw Object.assign(new Error(message), { code: 'FORGE_PACKAGE_SCHEMA_INVALID' }); }
14
+ function object(value) { return Boolean(value) && typeof value === 'object' && !Array.isArray(value); }
15
+ export function validateForgeOwnerPackage(value) {
16
+ if (!object(value))
17
+ fail('package must be an object');
18
+ for (const key of Object.keys(value))
19
+ if (!OWNER_PACKAGE_KEYS.has(key))
20
+ fail('unknown package field ' + key);
21
+ if (value.schemaVersion !== 1)
22
+ fail('schemaVersion must be 1');
23
+ if (!Number.isSafeInteger(value.revision) || value.revision < 1)
24
+ fail('revision must be a positive integer');
25
+ if (!object(value.manifest))
26
+ fail('manifest must be an object');
27
+ if (typeof value.manifest.id !== 'string' || !MANIFEST_ID.test(value.manifest.id))
28
+ fail('manifest.id must be a safe lowercase slug');
29
+ if (Object.prototype.hasOwnProperty.call(value.manifest, 'version') || Object.prototype.hasOwnProperty.call(value.manifest, 'parentVersion'))
30
+ fail('owner revision must stay outside the executable manifest');
31
+ const simulation = value.simulation === undefined ? {} : value.simulation;
32
+ if (!object(simulation))
33
+ fail('simulation must be an object');
34
+ for (const key of Object.keys(simulation))
35
+ if (!SIMULATION_KEYS.has(key))
36
+ fail('unknown simulation field ' + key);
37
+ if (simulation.capabilityResults !== undefined && !object(simulation.capabilityResults))
38
+ fail('simulation.capabilityResults must be an object');
39
+ return { schemaVersion: 1, revision: Number(value.revision), manifest: value.manifest, simulation: { input: simulation.input ?? {}, capabilityResults: simulation.capabilityResults ?? {} } };
40
+ }
41
+ export function scanForgeManifest(manifest, canonical) {
42
+ const findings = [];
43
+ const add = (code, path, message, blocking = true) => findings.push({ code, path, message, blocking });
44
+ if (!canonical?.ok)
45
+ for (const message of Array.isArray(canonical?.diagnostica) ? canonical.diagnostica : ['canonical validation failed'])
46
+ add('FORGE_CANONICAL_VALIDATION', 'manifest', String(message), true);
47
+ if (object(manifest))
48
+ for (const key of Object.keys(manifest))
49
+ if (!MANIFEST_FIELDS.has(key))
50
+ add('FORGE_UNKNOWN_MANIFEST_FIELD', 'manifest.' + key, 'unknown manifest field ' + key, true);
51
+ const flow = object(manifest?.flow) ? manifest.flow : null;
52
+ if (flow)
53
+ for (const key of Object.keys(flow))
54
+ if (!FLOW_FIELDS.has(key))
55
+ add('FORGE_UNKNOWN_FLOW_FIELD', 'flow.' + key, 'unknown flow field ' + key, true);
56
+ if (flow && Array.isArray(flow.nodes)) {
57
+ flow.nodes.forEach((node, index) => {
58
+ if (!object(node))
59
+ return;
60
+ const allowed = NODE_FIELDS[String(node.type)] ?? new Set(['id', 'type']);
61
+ for (const key of Object.keys(node))
62
+ if (!allowed.has(key))
63
+ add('FORGE_UNKNOWN_NODE_FIELD', `flow.nodes[${index}].${key}`, `unknown field "${key}" is not part of the declarative Forge DSL`, true);
64
+ });
65
+ }
66
+ return {
67
+ ok: Boolean(canonical?.ok) && !findings.some(f => f.blocking),
68
+ declarativeOnly: !findings.some(f => f.code.startsWith('FORGE_UNKNOWN_')),
69
+ capabilities: Array.isArray(canonical?.capacita) ? [...canonical.capacita] : [],
70
+ actions: Array.isArray(canonical?.azioni) ? [...canonical.azioni] : [],
71
+ risk: typeof canonical?.rischio === 'string' ? canonical.rischio : 'R1',
72
+ findings,
73
+ };
74
+ }
@@ -0,0 +1,39 @@
1
+ import { externalToolParts, isKernelTool, permissionToolFor } from "../tui/tool-display.js";
2
+ /*
3
+ * R2 lane T (gate E3/E4): the approval payload `{tipo:<kernel tool name>, percorso|comando, toolCallId}`
4
+ * (talosHarness.mjs:8166-9714, reaching the CLI as `ApprovalRequested.azione`, agui-events.mjs:279) is mapped by the
5
+ * kernel NAME through the one tool table, never by matching Italian substrings. The old `raw.includes('scritt')` missed
6
+ * the kernel's own `scrivi`, which carried `percorso` and was therefore judged as a Read, and a read inside the project is
7
+ * allowed without asking (evaluate.ts:130): the default mode wrote files without asking (review E-07).
8
+ *
9
+ * Fields decide only where the name cannot, and always toward the stricter reading:
10
+ * - a payload carrying a command is judged as that shell command, whatever tool it names (the command is what runs);
11
+ * - a name that is not a kernel tool and names a path is a Write, never a Read (a Read would pass without asking);
12
+ * - `serverId` makes it an MCP call; TALOS's own services carry the tool name as operation, so "always" writes a rule
13
+ * for that one operation (`TalosService(:notes_create)`) instead of `TalosService(:*)`, which matched every service.
14
+ */
15
+ function text(value) { return typeof value === 'string' ? value : undefined; }
16
+ export function permissionActionFromApproval(data) {
17
+ const a = (data.azione ?? data.action ?? data);
18
+ const command = text(a.comando) ?? text(a.command);
19
+ const name = text(a.tipo) ?? text(a.tool) ?? '';
20
+ const external = isKernelTool(name) ? null : externalToolParts(name);
21
+ let serverId = text(a.serverId), operation = text(a.operation);
22
+ if (external?.kind === 'mcp') {
23
+ serverId ??= external.owner;
24
+ operation ??= external.tool;
25
+ }
26
+ let tool;
27
+ if (command)
28
+ tool = 'Bash';
29
+ else if (isKernelTool(name) || external)
30
+ tool = permissionToolFor(name);
31
+ else if (serverId)
32
+ tool = 'Mcp';
33
+ else
34
+ tool = text(a.percorso) ?? text(a.path) ?? text(a.resource) ? 'Write' : 'TalosService';
35
+ const resource = text(a.percorso) ?? text(a.path) ?? text(a.resource) ?? (tool === 'WebFetch' ? text(a.url) : undefined);
36
+ if (!operation && name && (tool === 'TalosService' || tool === 'Plugin'))
37
+ operation = name;
38
+ return { tool, ...(command ? { command } : {}), ...(resource ? { resource } : {}), ...(serverId ? { serverId } : {}), ...(operation ? { operation } : {}) };
39
+ }