talos-code 0.0.1 → 0.2.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 (407) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/LICENSE +661 -0
  3. package/README.md +116 -3
  4. package/THIRD_PARTY_NOTICES.md +40 -0
  5. package/dist/archive/zip.js +73 -0
  6. package/dist/args.js +100 -0
  7. package/dist/automations/history-store.js +34 -0
  8. package/dist/automations/policy-store.js +43 -0
  9. package/dist/automations/runner.js +107 -0
  10. package/dist/automations/schedule.js +85 -0
  11. package/dist/automations/windows-task.js +53 -0
  12. package/dist/commands/advanced-cli.js +233 -0
  13. package/dist/commands/checkpoint-cli.js +45 -0
  14. package/dist/commands/config-cli.js +107 -0
  15. package/dist/commands/context.js +17 -0
  16. package/dist/commands/extensions-cli.js +207 -0
  17. package/dist/commands/project-cli.js +74 -0
  18. package/dist/commands/project-commands.js +143 -0
  19. package/dist/commands/provider-cli.js +244 -0
  20. package/dist/commands/services-cli.js +248 -0
  21. package/dist/commands/session-cli.js +171 -0
  22. package/dist/commands/system-cli.js +405 -0
  23. package/dist/config/commands.js +60 -0
  24. package/dist/config/load.js +382 -0
  25. package/dist/config/migrations.js +48 -0
  26. package/dist/config/types.js +11 -0
  27. package/dist/diagnostics/development-log.js +154 -0
  28. package/dist/diagnostics/doctor.js +104 -0
  29. package/dist/diagnostics/redact.js +80 -0
  30. package/dist/diagnostics/zip.js +52 -0
  31. package/dist/errors.js +156 -0
  32. package/dist/events/bridge.js +130 -0
  33. package/dist/extensions/installer.js +178 -0
  34. package/dist/extensions/package-schema.js +24 -0
  35. package/dist/headless/result.js +84 -0
  36. package/dist/headless/run.js +230 -0
  37. package/dist/i18n/en/approval.js +46 -0
  38. package/dist/i18n/en/common.js +9 -0
  39. package/dist/i18n/en/credentials.js +92 -0
  40. package/dist/i18n/en/errors.js +267 -0
  41. package/dist/i18n/en/firstrun.js +101 -0
  42. package/dist/i18n/en/providers.js +37 -0
  43. package/dist/i18n/en/screen.js +774 -0
  44. package/dist/i18n/en/tools.js +127 -0
  45. package/dist/i18n/en.js +14 -0
  46. package/dist/i18n/error-view.js +307 -0
  47. package/dist/i18n/index.js +19 -0
  48. package/dist/i18n/kernel-map.js +139 -0
  49. package/dist/io.js +45 -0
  50. package/dist/main.js +331 -0
  51. package/dist/paths.js +41 -0
  52. package/dist/protocol/v2/codec.js +9 -0
  53. package/dist/protocol/v2/events.js +555 -0
  54. package/dist/protocol/v2/index.js +4 -0
  55. package/dist/protocol/v2/replay.js +28 -0
  56. package/dist/protocol/v2/types.js +1 -0
  57. package/dist/provider/control-plane.js +135 -0
  58. package/dist/provider/environment-keys.js +275 -0
  59. package/dist/provider/health.js +110 -0
  60. package/dist/provider/missing-key.js +48 -0
  61. package/dist/provider/model-catalog.js +168 -0
  62. package/dist/provider/openrouter-login.js +172 -0
  63. package/dist/provider/provider-text.js +13 -0
  64. package/dist/provider/store.js +95 -0
  65. package/dist/provider/system-keyring.js +214 -0
  66. package/dist/runtime/active-run.js +63 -0
  67. package/dist/runtime/agent-tree.js +74 -0
  68. package/dist/runtime/attachments.js +84 -0
  69. package/dist/runtime/brokered-executor.js +395 -0
  70. package/dist/runtime/context-archive.js +69 -0
  71. package/dist/runtime/context-status.js +76 -0
  72. package/dist/runtime/create-runtime.js +111 -0
  73. package/dist/runtime/model-profile.js +361 -0
  74. package/dist/runtime/output-store.js +137 -0
  75. package/dist/runtime/provider-attempts.js +185 -0
  76. package/dist/runtime/replay-buffer.js +153 -0
  77. package/dist/runtime/repo.js +95 -0
  78. package/dist/runtime/session-facade.js +135 -0
  79. package/dist/runtime/session-summary.js +125 -0
  80. package/dist/runtime/supervisor.js +265 -0
  81. package/dist/runtime/talos-composition.js +1011 -0
  82. package/dist/runtime/types.js +5 -0
  83. package/dist/runtime/usage-snapshot.js +82 -0
  84. package/dist/security/auto-classifier.js +38 -0
  85. package/dist/security/credential-free-environment.js +54 -0
  86. package/dist/security/evaluate.js +243 -0
  87. package/dist/security/execution-backends.js +236 -0
  88. package/dist/security/execution-broker.js +102 -0
  89. package/dist/security/forge-scan.js +74 -0
  90. package/dist/security/from-approval.js +39 -0
  91. package/dist/security/mxc-execution-backend.js +281 -0
  92. package/dist/security/permission-engine.js +138 -0
  93. package/dist/security/permission-explanation.js +54 -0
  94. package/dist/security/persist.js +179 -0
  95. package/dist/security/plugin-guard.js +230 -0
  96. package/dist/security/process-tree-evidence-store.js +74 -0
  97. package/dist/security/process-tree-probe.js +554 -0
  98. package/dist/security/project-resource-inventory.js +186 -0
  99. package/dist/security/project-trust-gate.js +38 -0
  100. package/dist/security/project-trust.js +367 -0
  101. package/dist/security/rule-parser.js +201 -0
  102. package/dist/security/shell-segmentation.js +68 -0
  103. package/dist/security/trust-authority.js +324 -0
  104. package/dist/security/types.js +1 -0
  105. package/dist/security/workspace-identity.js +102 -0
  106. package/dist/services/automation-facade.js +59 -0
  107. package/dist/services/forge-facade.js +77 -0
  108. package/dist/services/hook-facade.js +240 -0
  109. package/dist/services/index.js +16 -0
  110. package/dist/services/library-facade.js +174 -0
  111. package/dist/services/mcp-facade.js +348 -0
  112. package/dist/services/memory-facade.js +126 -0
  113. package/dist/services/notes-facade.js +157 -0
  114. package/dist/services/plugin-facade.js +308 -0
  115. package/dist/services/research-facade.js +110 -0
  116. package/dist/services/task-board-facade.js +236 -0
  117. package/dist/services/workflow-catalog.js +246 -0
  118. package/dist/sessions/export-format.js +98 -0
  119. package/dist/sessions/metadata-store.js +160 -0
  120. package/dist/sessions/share.js +122 -0
  121. package/dist/sessions/transfer.js +16 -0
  122. package/dist/subcommands.js +62 -0
  123. package/dist/tui/agent-roster.js +36 -0
  124. package/dist/tui/agent-view.js +51 -0
  125. package/dist/tui/app.js +4098 -0
  126. package/dist/tui/approval.js +36 -0
  127. package/dist/tui/boot/boot-sequence.js +76 -0
  128. package/dist/tui/boot/cinematic.js +243 -0
  129. package/dist/tui/boot/desktop-logo.js +82 -0
  130. package/dist/tui/boot.js +3 -0
  131. package/dist/tui/busy-input.js +58 -0
  132. package/dist/tui/catalog-service.js +560 -0
  133. package/dist/tui/components/assistant-stream.js +1 -0
  134. package/dist/tui/components/command-menu.js +68 -0
  135. package/dist/tui/components/composer.js +219 -0
  136. package/dist/tui/components/diff.js +35 -0
  137. package/dist/tui/components/footer.js +48 -0
  138. package/dist/tui/components/header.js +6 -0
  139. package/dist/tui/components/markdown.js +305 -0
  140. package/dist/tui/components/status-indicator.js +38 -0
  141. package/dist/tui/components/terminal-shell.js +214 -0
  142. package/dist/tui/components/thinking-row.js +19 -0
  143. package/dist/tui/components/tool-row.js +97 -0
  144. package/dist/tui/components/transcript-virtualizer.js +165 -0
  145. package/dist/tui/components/transcript.js +43 -0
  146. package/dist/tui/descendant-approvals.js +104 -0
  147. package/dist/tui/diff-model.js +77 -0
  148. package/dist/tui/editor-history.js +21 -0
  149. package/dist/tui/editor.js +210 -0
  150. package/dist/tui/event-adapter.js +436 -0
  151. package/dist/tui/exit-output.js +58 -0
  152. package/dist/tui/external-editor.js +53 -0
  153. package/dist/tui/file-completion.js +89 -0
  154. package/dist/tui/focus-manager.js +5 -0
  155. package/dist/tui/highlight.js +30 -0
  156. package/dist/tui/input-router.js +18 -0
  157. package/dist/tui/interrupt.js +99 -0
  158. package/dist/tui/keybindings.js +194 -0
  159. package/dist/tui/keymap-resolver.js +91 -0
  160. package/dist/tui/launch-state.js +148 -0
  161. package/dist/tui/line-diff.js +57 -0
  162. package/dist/tui/live-activity.js +56 -0
  163. package/dist/tui/metrics.js +123 -0
  164. package/dist/tui/onboarding.js +36 -0
  165. package/dist/tui/overlays/agent-tree.js +43 -0
  166. package/dist/tui/overlays/approval-dialog.js +642 -0
  167. package/dist/tui/overlays/automation-center.js +51 -0
  168. package/dist/tui/overlays/checkpoint-picker.js +47 -0
  169. package/dist/tui/overlays/context-inspector.js +36 -0
  170. package/dist/tui/overlays/effort-line.js +110 -0
  171. package/dist/tui/overlays/forge-center.js +46 -0
  172. package/dist/tui/overlays/help-dialog.js +16 -0
  173. package/dist/tui/overlays/history-picker.js +37 -0
  174. package/dist/tui/overlays/hook-center.js +70 -0
  175. package/dist/tui/overlays/library-center.js +55 -0
  176. package/dist/tui/overlays/mcp-center.js +60 -0
  177. package/dist/tui/overlays/memory-center.js +63 -0
  178. package/dist/tui/overlays/model-picker.js +77 -0
  179. package/dist/tui/overlays/notes-center.js +53 -0
  180. package/dist/tui/overlays/overlay-host.js +8 -0
  181. package/dist/tui/overlays/plugin-center.js +76 -0
  182. package/dist/tui/overlays/provider-picker.js +171 -0
  183. package/dist/tui/overlays/queue-editor.js +32 -0
  184. package/dist/tui/overlays/research-center.js +59 -0
  185. package/dist/tui/overlays/scroll-window.js +234 -0
  186. package/dist/tui/overlays/session-picker.js +115 -0
  187. package/dist/tui/overlays/tasks-center.js +83 -0
  188. package/dist/tui/overlays/theme-picker.js +21 -0
  189. package/dist/tui/overlays/transcript-search.js +58 -0
  190. package/dist/tui/overlays/trust-center.js +29 -0
  191. package/dist/tui/overlays/workflow-center.js +46 -0
  192. package/dist/tui/project-file-index.js +214 -0
  193. package/dist/tui/project-references.js +85 -0
  194. package/dist/tui/project-trust-prompt.js +289 -0
  195. package/dist/tui/prompt-history-store.js +116 -0
  196. package/dist/tui/queue-store.js +110 -0
  197. package/dist/tui/regions/budget.js +59 -0
  198. package/dist/tui/regions/views.js +96 -0
  199. package/dist/tui/render-coordinator.js +148 -0
  200. package/dist/tui/render-scheduler.js +4 -0
  201. package/dist/tui/run.js +69 -0
  202. package/dist/tui/selection-list.js +29 -0
  203. package/dist/tui/session-controller.js +791 -0
  204. package/dist/tui/session-export.js +54 -0
  205. package/dist/tui/setup-wizard.js +46 -0
  206. package/dist/tui/shell-input.js +35 -0
  207. package/dist/tui/shell-layout.js +48 -0
  208. package/dist/tui/shell-model.js +98 -0
  209. package/dist/tui/slash-commands.js +82 -0
  210. package/dist/tui/state.js +151 -0
  211. package/dist/tui/status-bar.js +125 -0
  212. package/dist/tui/status-view.js +40 -0
  213. package/dist/tui/terminal-capabilities.js +9 -0
  214. package/dist/tui/terminal-session.js +11 -0
  215. package/dist/tui/text-width.js +66 -0
  216. package/dist/tui/theme-catalog.js +27 -0
  217. package/dist/tui/theme-store.js +23 -0
  218. package/dist/tui/theme.js +23 -0
  219. package/dist/tui/tool-display.js +135 -0
  220. package/dist/tui/tool-facts.js +1 -0
  221. package/dist/tui/tools/bash-renderer.js +32 -0
  222. package/dist/tui/tools/change.js +61 -0
  223. package/dist/tui/tools/edit-renderer.js +17 -0
  224. package/dist/tui/tools/generic-renderer.js +13 -0
  225. package/dist/tui/tools/list-renderer.js +14 -0
  226. package/dist/tui/tools/read-renderer.js +13 -0
  227. package/dist/tui/tools/registry.js +20 -0
  228. package/dist/tui/tools/row-format.js +187 -0
  229. package/dist/tui/tools/search-renderer.js +38 -0
  230. package/dist/tui/tools/shared.js +97 -0
  231. package/dist/tui/tools/write-renderer.js +15 -0
  232. package/dist/tui/transcript-model.js +441 -0
  233. package/dist/tui/ui-preferences.js +79 -0
  234. package/dist/tui/usage-view.js +77 -0
  235. package/dist/tui/vim-mode.js +99 -0
  236. package/dist/update/check.js +15 -0
  237. package/dist/update/npm.js +51 -0
  238. package/dist/update/run.js +129 -0
  239. package/dist/version.js +2 -0
  240. package/dist/workspace/checkpoint-store.js +210 -0
  241. package/dist/workspace/checkpoint.js +413 -0
  242. package/dist/workspace/restore.js +232 -0
  243. package/package.json +64 -5
  244. package/vendor/context-engine/package.json +11 -0
  245. package/vendor/context-engine/src/compaction-planner.mjs +57 -0
  246. package/vendor/context-engine/src/contracts.mjs +48 -0
  247. package/vendor/context-engine/src/engine.mjs +445 -0
  248. package/vendor/context-engine/src/node/context-export.mjs +164 -0
  249. package/vendor/context-engine/src/node/legacy-import.mjs +92 -0
  250. package/vendor/context-engine/src/node/migrations/001-context.sql +126 -0
  251. package/vendor/context-engine/src/node/sqlite-store.mjs +85 -0
  252. package/vendor/context-engine/src/node/sqlite-worker.mjs +559 -0
  253. package/vendor/context-engine/src/profiles.mjs +10 -0
  254. package/vendor/context-engine/src/retrieval.mjs +104 -0
  255. package/vendor/context-engine/src/summary.mjs +97 -0
  256. package/vendor/context-engine/src/usage.mjs +34 -0
  257. package/vendor/harness-ui/package.json +38 -0
  258. package/vendor/harness-ui/src/acp-agent.mjs +350 -0
  259. package/vendor/harness-ui/src/agent-service.mjs +2188 -0
  260. package/vendor/harness-ui/src/agui-events.mjs +452 -0
  261. package/vendor/harness-ui/src/ambiente-solo-server.mjs +121 -0
  262. package/vendor/harness-ui/src/artifact-store.mjs +39 -0
  263. package/vendor/harness-ui/src/assistenza.mjs +123 -0
  264. package/vendor/harness-ui/src/automation-scheduler.mjs +69 -0
  265. package/vendor/harness-ui/src/automation-store.mjs +145 -0
  266. package/vendor/harness-ui/src/browser-annota.mjs +639 -0
  267. package/vendor/harness-ui/src/browser-frame.mjs +211 -0
  268. package/vendor/harness-ui/src/browser-proxy-universale.mjs +519 -0
  269. package/vendor/harness-ui/src/browser-proxy.mjs +87 -0
  270. package/vendor/harness-ui/src/browser-sessione-viva.mjs +329 -0
  271. package/vendor/harness-ui/src/browser-stream.mjs +445 -0
  272. package/vendor/harness-ui/src/browser-vivo.mjs +694 -0
  273. package/vendor/harness-ui/src/chat-image-attachments.mjs +72 -0
  274. package/vendor/harness-ui/src/config.mjs +697 -0
  275. package/vendor/harness-ui/src/contesto-del-progetto.mjs +385 -0
  276. package/vendor/harness-ui/src/context-asset-adapter.mjs +72 -0
  277. package/vendor/harness-ui/src/context-desktop-service.mjs +253 -0
  278. package/vendor/harness-ui/src/context-embedding-runtime.mjs +252 -0
  279. package/vendor/harness-ui/src/context-inference-scheduler.mjs +81 -0
  280. package/vendor/harness-ui/src/context-native-compaction.mjs +75 -0
  281. package/vendor/harness-ui/src/context-provider-adapter.mjs +141 -0
  282. package/vendor/harness-ui/src/context-runtime.mjs +118 -0
  283. package/vendor/harness-ui/src/context-token-counters.mjs +184 -0
  284. package/vendor/harness-ui/src/context-tool-catalog.mjs +86 -0
  285. package/vendor/harness-ui/src/context-tool-output.mjs +72 -0
  286. package/vendor/harness-ui/src/costo-elenco.mjs +252 -0
  287. package/vendor/harness-ui/src/custom-task.mjs +171 -0
  288. package/vendor/harness-ui/src/doctor.mjs +142 -0
  289. package/vendor/harness-ui/src/document-filename.mjs +97 -0
  290. package/vendor/harness-ui/src/document-generator.mjs +493 -0
  291. package/vendor/harness-ui/src/document-report.mjs +331 -0
  292. package/vendor/harness-ui/src/duckduckgo-search.mjs +155 -0
  293. package/vendor/harness-ui/src/elenco-profondo.mjs +337 -0
  294. package/vendor/harness-ui/src/favicon-proxy.mjs +113 -0
  295. package/vendor/harness-ui/src/forge-contract.mjs +221 -0
  296. package/vendor/harness-ui/src/frequent-dirs.mjs +134 -0
  297. package/vendor/harness-ui/src/generated-image-store.mjs +147 -0
  298. package/vendor/harness-ui/src/generation-idle.mjs +332 -0
  299. package/vendor/harness-ui/src/gguf-header.mjs +207 -0
  300. package/vendor/harness-ui/src/git-service.mjs +626 -0
  301. package/vendor/harness-ui/src/gitignore-elenco.mjs +604 -0
  302. package/vendor/harness-ui/src/harness-receipt-keypair.mjs +207 -0
  303. package/vendor/harness-ui/src/hf-direct-transfer.mjs +170 -0
  304. package/vendor/harness-ui/src/hf-hub-client.mjs +106 -0
  305. package/vendor/harness-ui/src/hf-image-proxy.mjs +105 -0
  306. package/vendor/harness-ui/src/hf-model-transfer.mjs +245 -0
  307. package/vendor/harness-ui/src/hook-registry.mjs +186 -0
  308. package/vendor/harness-ui/src/http-app.mjs +6259 -0
  309. package/vendor/harness-ui/src/http-lifecycle.mjs +132 -0
  310. package/vendor/harness-ui/src/id-archivio.mjs +27 -0
  311. package/vendor/harness-ui/src/image-generator.mjs +143 -0
  312. package/vendor/harness-ui/src/istruzioni-di-progetto.mjs +234 -0
  313. package/vendor/harness-ui/src/kernel/dist/kernelPerIlBanco.js +518 -0
  314. package/vendor/harness-ui/src/kernel/talosHarness.mjs +10437 -0
  315. package/vendor/harness-ui/src/library-policy-store.mjs +175 -0
  316. package/vendor/harness-ui/src/library-store.mjs +652 -0
  317. package/vendor/harness-ui/src/llama-server-supervisor.mjs +629 -0
  318. package/vendor/harness-ui/src/local-model-store.mjs +339 -0
  319. package/vendor/harness-ui/src/local-runtime-contract.mjs +66 -0
  320. package/vendor/harness-ui/src/local-runtime-events.mjs +44 -0
  321. package/vendor/harness-ui/src/local-runtime-llama-server.mjs +244 -0
  322. package/vendor/harness-ui/src/local-runtime-probe.mjs +401 -0
  323. package/vendor/harness-ui/src/machine-capacity.mjs +66 -0
  324. package/vendor/harness-ui/src/mappa-cartelle.mjs +491 -0
  325. package/vendor/harness-ui/src/mcp-client.mjs +98 -0
  326. package/vendor/harness-ui/src/mcp-registry.mjs +157 -0
  327. package/vendor/harness-ui/src/mcp-session.mjs +177 -0
  328. package/vendor/harness-ui/src/memory-store.mjs +227 -0
  329. package/vendor/harness-ui/src/model-catalog-models-dev.mjs +276 -0
  330. package/vendor/harness-ui/src/model-catalog.mjs +129 -0
  331. package/vendor/harness-ui/src/model-destination.mjs +189 -0
  332. package/vendor/harness-ui/src/modifica-ancorata.mjs +177 -0
  333. package/vendor/harness-ui/src/native-provider-adapter.mjs +205 -0
  334. package/vendor/harness-ui/src/notes-store.mjs +250 -0
  335. package/vendor/harness-ui/src/openai-compatible-runtime.mjs +428 -0
  336. package/vendor/harness-ui/src/openrouter-oauth.mjs +339 -0
  337. package/vendor/harness-ui/src/path-policy.mjs +442 -0
  338. package/vendor/harness-ui/src/plugin-registry.mjs +780 -0
  339. package/vendor/harness-ui/src/plugin-session.mjs +180 -0
  340. package/vendor/harness-ui/src/process-policy.mjs +345 -0
  341. package/vendor/harness-ui/src/prompt-enhancer-provider.mjs +94 -0
  342. package/vendor/harness-ui/src/provider-auth-cloud.mjs +95 -0
  343. package/vendor/harness-ui/src/provider-credential-store.mjs +541 -0
  344. package/vendor/harness-ui/src/provider-probe.mjs +582 -0
  345. package/vendor/harness-ui/src/provider-registry.mjs +1633 -0
  346. package/vendor/harness-ui/src/pty-terminal.mjs +312 -0
  347. package/vendor/harness-ui/src/public-problem.mjs +109 -0
  348. package/vendor/harness-ui/src/research/card.mjs +235 -0
  349. package/vendor/harness-ui/src/research/citations.mjs +142 -0
  350. package/vendor/harness-ui/src/research/collector.mjs +275 -0
  351. package/vendor/harness-ui/src/research/deposito-a-pezzi.mjs +139 -0
  352. package/vendor/harness-ui/src/research/dossier.mjs +114 -0
  353. package/vendor/harness-ui/src/research/esportazioni.mjs +560 -0
  354. package/vendor/harness-ui/src/research/fetch-cache.mjs +465 -0
  355. package/vendor/harness-ui/src/research/fidelity.mjs +122 -0
  356. package/vendor/harness-ui/src/research/independence.mjs +159 -0
  357. package/vendor/harness-ui/src/research/ledger.mjs +166 -0
  358. package/vendor/harness-ui/src/research/markdown-server.mjs +565 -0
  359. package/vendor/harness-ui/src/research/narration.mjs +181 -0
  360. package/vendor/harness-ui/src/research/open-cards.mjs +131 -0
  361. package/vendor/harness-ui/src/research/opposing.mjs +305 -0
  362. package/vendor/harness-ui/src/research/outline.mjs +111 -0
  363. package/vendor/harness-ui/src/research/page-budget.mjs +209 -0
  364. package/vendor/harness-ui/src/research/pdf.mjs +291 -0
  365. package/vendor/harness-ui/src/research/plan.mjs +301 -0
  366. package/vendor/harness-ui/src/research/raccolta-viva.mjs +452 -0
  367. package/vendor/harness-ui/src/research/recheck-document.mjs +69 -0
  368. package/vendor/harness-ui/src/research/recheck-history.mjs +192 -0
  369. package/vendor/harness-ui/src/research/recheck.mjs +194 -0
  370. package/vendor/harness-ui/src/research/report.mjs +203 -0
  371. package/vendor/harness-ui/src/research/run.mjs +527 -0
  372. package/vendor/harness-ui/src/research/synthesis.mjs +318 -0
  373. package/vendor/harness-ui/src/research/verification.mjs +572 -0
  374. package/vendor/harness-ui/src/research-orchestrator.mjs +2679 -0
  375. package/vendor/harness-ui/src/research-store.mjs +1133 -0
  376. package/vendor/harness-ui/src/runtime-build-manifest.mjs +26 -0
  377. package/vendor/harness-ui/src/runtime-contract.mjs +59 -0
  378. package/vendor/harness-ui/src/runtime-owner-adapter.mjs +1348 -0
  379. package/vendor/harness-ui/src/runtime-owner-contract.mjs +32 -0
  380. package/vendor/harness-ui/src/scheda-di-lavoro.mjs +249 -0
  381. package/vendor/harness-ui/src/search-source-store.mjs +172 -0
  382. package/vendor/harness-ui/src/session-registry.mjs +6095 -0
  383. package/vendor/harness-ui/src/session-store.mjs +220 -0
  384. package/vendor/harness-ui/src/sessione-pronta.mjs +73 -0
  385. package/vendor/harness-ui/src/setup-stato.mjs +31 -0
  386. package/vendor/harness-ui/src/sezioni-istruzioni.mjs +204 -0
  387. package/vendor/harness-ui/src/skill-registry.mjs +120 -0
  388. package/vendor/harness-ui/src/sse-replay-coalescente.mjs +0 -0
  389. package/vendor/harness-ui/src/static-files.mjs +96 -0
  390. package/vendor/harness-ui/src/stream-partition.mjs +123 -0
  391. package/vendor/harness-ui/src/subagent-orchestrator.mjs +453 -0
  392. package/vendor/harness-ui/src/task-catalog.mjs +65 -0
  393. package/vendor/harness-ui/src/tasks-store.mjs +220 -0
  394. package/vendor/harness-ui/src/terminal-registry.mjs +312 -0
  395. package/vendor/harness-ui/src/terminal-ws.mjs +170 -0
  396. package/vendor/harness-ui/src/tool-forge-store.mjs +299 -0
  397. package/vendor/harness-ui/src/tool-schema-normalize.mjs +100 -0
  398. package/vendor/harness-ui/src/usage-cache.mjs +315 -0
  399. package/vendor/harness-ui/src/workspace-browser.mjs +213 -0
  400. package/vendor/harness-ui/src/workspace-context.mjs +124 -0
  401. package/vendor/harness-ui/src/workspace-disk.mjs +62 -0
  402. package/vendor/harness-ui/src/workspace-files.mjs +589 -0
  403. package/vendor/harness-ui/src/workspace-info.mjs +189 -0
  404. package/vendor/harness-ui/src/workspace-launch-store.mjs +150 -0
  405. package/vendor/harness-ui/src/workspace-tree.mjs +67 -0
  406. package/vendor/harness-ui/src/workspace-watcher.mjs +161 -0
  407. package/vendor/manifest.json +170 -0
@@ -0,0 +1,178 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { cp, mkdir, readFile, readdir, rm, writeFile } from 'node:fs/promises';
3
+ import { basename, dirname, join, resolve } from 'node:path';
4
+ import { validateArchiveEntries, validateExtensionManifest } from "./package-schema.js";
5
+ import { readZipEntries } from "../archive/zip.js";
6
+ import { CLI_VERSION } from "../version.js";
7
+ const hash = (v) => createHash('sha256').update(JSON.stringify(v)).digest('hex');
8
+ async function json(file, fallback) { try {
9
+ return JSON.parse(await readFile(file, 'utf8'));
10
+ }
11
+ catch (e) {
12
+ if (e?.code === 'ENOENT')
13
+ return fallback;
14
+ throw e;
15
+ } }
16
+ async function atomicJson(file, value) { await mkdir(dirname(file), { recursive: true }); const t = `${file}.tmp-${process.pid}`; await writeFile(t, `${JSON.stringify(value, null, 2)}\n`, 'utf8'); await rm(file, { force: true }); await import('node:fs/promises').then(m => m.rename(t, file)); }
17
+ function safeId(id) { if (!/^[a-z0-9][a-z0-9._-]{1,79}$/u.test(id))
18
+ throw new Error('EXTENSION_ID_INVALID'); return id; }
19
+ async function readExtensionManifest(sourceDir) { for (const name of ['extension.json', 'talos-extension.json']) {
20
+ try {
21
+ return JSON.parse(await readFile(join(sourceDir, name), 'utf8'));
22
+ }
23
+ catch (error) {
24
+ if (error?.code !== 'ENOENT')
25
+ throw error;
26
+ }
27
+ } throw Object.assign(new Error('EXTENSION_MANIFEST_MISSING'), { code: 'EXTENSION_MANIFEST_MISSING' }); }
28
+ export async function installExtensionDirectory({ sourceDir, projectRoot, currentVersion = CLI_VERSION }) {
29
+ const manifest = validateExtensionManifest(await readExtensionManifest(sourceDir), currentVersion);
30
+ safeId(manifest.id);
31
+ const stateDir = join(projectRoot, '.talos-cli', 'extensions', manifest.id);
32
+ const installedFile = join(stateDir, 'installed.json');
33
+ try {
34
+ await readFile(installedFile, 'utf8');
35
+ throw new Error('EXTENSION_ALREADY_INSTALLED');
36
+ }
37
+ catch (e) {
38
+ if (e?.message === 'EXTENSION_ALREADY_INSTALLED')
39
+ throw e;
40
+ if (e?.code !== 'ENOENT')
41
+ throw e;
42
+ }
43
+ const record = { id: manifest.id, name: manifest.name, version: manifest.version, source: resolve(sourceDir), components: {} };
44
+ await mkdir(stateDir, { recursive: true });
45
+ await cp(sourceDir, join(stateDir, 'package'), { recursive: true });
46
+ if (manifest.components.plugin) {
47
+ const src = join(sourceDir, manifest.components.plugin);
48
+ const text = await readFile(src, 'utf8');
49
+ const parsed = JSON.parse(text);
50
+ const dest = join(projectRoot, '.harness-ui-plugins', manifest.id, 'plugin.json');
51
+ await mkdir(dirname(dest), { recursive: true });
52
+ await writeFile(dest, text, 'utf8');
53
+ record.components.plugin = { id: manifest.id, hash: hash(parsed) };
54
+ }
55
+ if (manifest.components.mcp) {
56
+ const src = JSON.parse(await readFile(join(sourceDir, manifest.components.mcp), 'utf8'));
57
+ if (!Array.isArray(src?.server))
58
+ throw new Error('EXTENSION_MCP_INVALID');
59
+ const file = join(projectRoot, '.harness-ui-mcp.json');
60
+ const cur = await json(file, { server: [] });
61
+ if (!Array.isArray(cur.server))
62
+ throw new Error('MCP_CONFIG_MALFORMED');
63
+ const ids = new Set(cur.server.map((x) => x.id));
64
+ for (const row of src.server) {
65
+ if (!row?.id || ids.has(row.id))
66
+ throw new Error('EXTENSION_COMPONENT_COLLISION');
67
+ ids.add(row.id);
68
+ }
69
+ cur.server.push(...src.server);
70
+ await atomicJson(file, cur);
71
+ record.components.mcp = src.server.map((x) => ({ id: x.id, hash: hash(x) }));
72
+ }
73
+ if (manifest.components.hooks) {
74
+ const src = JSON.parse(await readFile(join(sourceDir, manifest.components.hooks), 'utf8'));
75
+ if (!Array.isArray(src?.hooks))
76
+ throw new Error('EXTENSION_HOOKS_INVALID');
77
+ const file = join(projectRoot, '.harness-ui-hooks.json');
78
+ const cur = await json(file, { hooks: [] });
79
+ if (!Array.isArray(cur.hooks))
80
+ throw new Error('HOOK_CONFIG_MALFORMED');
81
+ const ids = new Set(cur.hooks.map((x) => x.id));
82
+ for (const row of src.hooks) {
83
+ if (!row?.id || ids.has(row.id))
84
+ throw new Error('EXTENSION_COMPONENT_COLLISION');
85
+ ids.add(row.id);
86
+ }
87
+ cur.hooks.push(...src.hooks);
88
+ await atomicJson(file, cur);
89
+ record.components.hooks = src.hooks.map((x) => ({ id: x.id, hash: hash(x) }));
90
+ }
91
+ if (manifest.components.commands) {
92
+ const src = join(sourceDir, manifest.components.commands);
93
+ const dest = join(projectRoot, '.talos-cli', 'commands', manifest.id);
94
+ await cp(src, dest, { recursive: true });
95
+ const files = (await readdir(dest, { recursive: true })).filter((x) => String(x).endsWith('.md')).map(String);
96
+ record.components.commands = files;
97
+ }
98
+ await atomicJson(installedFile, record);
99
+ return record;
100
+ }
101
+ export async function listInstalledExtensions(projectRoot) { const root = join(projectRoot, '.talos-cli', 'extensions'); let ids; try {
102
+ ids = await readdir(root);
103
+ }
104
+ catch {
105
+ return [];
106
+ } const rows = []; for (const id of ids) {
107
+ try {
108
+ rows.push(JSON.parse(await readFile(join(root, id, 'installed.json'), 'utf8')));
109
+ }
110
+ catch { }
111
+ } return rows.sort((a, b) => a.id.localeCompare(b.id)); }
112
+ export async function removeInstalledExtension({ projectRoot, id }) {
113
+ safeId(id);
114
+ const stateDir = join(projectRoot, '.talos-cli', 'extensions', id);
115
+ const record = JSON.parse(await readFile(join(stateDir, 'installed.json'), 'utf8'));
116
+ if (record.components.mcp) {
117
+ const file = join(projectRoot, '.harness-ui-mcp.json');
118
+ const cur = await json(file, { server: [] });
119
+ for (const owned of record.components.mcp) {
120
+ const row = cur.server.find((x) => x.id === owned.id);
121
+ if (row && hash(row) !== owned.hash)
122
+ throw new Error(`EXTENSION_COMPONENT_MODIFIED:mcp:${owned.id}`);
123
+ }
124
+ cur.server = cur.server.filter((x) => !record.components.mcp.some(o => o.id === x.id));
125
+ await atomicJson(file, cur);
126
+ }
127
+ if (record.components.hooks) {
128
+ const file = join(projectRoot, '.harness-ui-hooks.json');
129
+ const cur = await json(file, { hooks: [] });
130
+ for (const owned of record.components.hooks) {
131
+ const row = cur.hooks.find((x) => x.id === owned.id);
132
+ if (row && hash(row) !== owned.hash)
133
+ throw new Error(`EXTENSION_COMPONENT_MODIFIED:hook:${owned.id}`);
134
+ }
135
+ cur.hooks = cur.hooks.filter((x) => !record.components.hooks.some(o => o.id === x.id));
136
+ await atomicJson(file, cur);
137
+ }
138
+ if (record.components.plugin) {
139
+ const file = join(projectRoot, '.harness-ui-plugins', id, 'plugin.json');
140
+ try {
141
+ const current = JSON.parse(await readFile(file, 'utf8'));
142
+ if (hash(current) !== record.components.plugin.hash)
143
+ throw new Error(`EXTENSION_COMPONENT_MODIFIED:plugin:${id}`);
144
+ }
145
+ catch (e) {
146
+ if (e?.code !== 'ENOENT')
147
+ throw e;
148
+ }
149
+ await rm(join(projectRoot, '.harness-ui-plugins', id), { recursive: true, force: true });
150
+ }
151
+ if (record.components.commands)
152
+ await rm(join(projectRoot, '.talos-cli', 'commands', id), { recursive: true, force: true });
153
+ await rm(stateDir, { recursive: true, force: true });
154
+ return { ok: true, id };
155
+ }
156
+ export async function installExtension({ source, projectRoot, currentVersion = CLI_VERSION }) { if (source.toLowerCase().endsWith('.zip')) {
157
+ const entries = readZipEntries(await readFile(source));
158
+ const names = [...entries.keys()];
159
+ validateArchiveEntries(names, process.platform === 'win32');
160
+ const os = await import('node:os');
161
+ const fs = await import('node:fs/promises');
162
+ const temp = await fs.mkdtemp(join(os.tmpdir(), 'talos-ext-'));
163
+ try {
164
+ for (const [name, data] of entries) {
165
+ if (name.endsWith('/')) {
166
+ await mkdir(join(temp, name), { recursive: true });
167
+ continue;
168
+ }
169
+ const dest = join(temp, name);
170
+ await mkdir(dirname(dest), { recursive: true });
171
+ await writeFile(dest, data);
172
+ }
173
+ return await installExtensionDirectory({ sourceDir: temp, projectRoot, currentVersion });
174
+ }
175
+ finally {
176
+ await rm(temp, { recursive: true, force: true });
177
+ }
178
+ } return installExtensionDirectory({ sourceDir: source, projectRoot, currentVersion }); }
@@ -0,0 +1,24 @@
1
+ const ID = /^[a-z0-9][a-z0-9._-]{1,79}$/u, VER = /^(\d+)\.(\d+)\.(\d+)(?:-[0-9A-Za-z.-]+)?$/u;
2
+ function compatible(range, current) { const cm = VER.exec(current); if (!cm)
3
+ return false; const major = Number(cm[1]); const ge = />=\s*(\d+)/u.exec(range), lt = /<\s*(\d+)/u.exec(range); if (ge && major < Number(ge[1]))
4
+ return false; if (lt && major >= Number(lt[1]))
5
+ return false; return true; }
6
+ export function validateExtensionManifest(x, currentVersion) { if (!x || typeof x !== 'object' || Array.isArray(x))
7
+ throw new Error('EXTENSION_MANIFEST_INVALID'); const o = x; const allowed = ['schema', 'id', 'name', 'version', 'talosCli', 'components']; if (Object.keys(o).some(k => !allowed.includes(k)) || o.schema !== 'talos.cli.extension.v1' || !ID.test(o.id ?? '') || typeof o.name !== 'string' || !VER.test(o.version ?? '') || typeof o.talosCli !== 'string' || !o.components || typeof o.components !== 'object')
8
+ throw new Error('EXTENSION_MANIFEST_INVALID'); if (!compatible(o.talosCli, currentVersion))
9
+ throw new Error('EXTENSION_INCOMPATIBLE'); for (const [k, v] of Object.entries(o.components)) {
10
+ if (!['plugin', 'commands', 'mcp', 'hooks'].includes(k) || typeof v !== 'string')
11
+ throw new Error('EXTENSION_MANIFEST_INVALID');
12
+ validateArchiveEntries([v]);
13
+ } return structuredClone(o); }
14
+ export function validateArchiveEntries(entries, windows = false) { const seen = new Set(); for (const p of entries) {
15
+ if (!p || p.startsWith('/') || /^[A-Za-z]:[\\/]/u.test(p))
16
+ throw new Error('EXTENSION_PATH_ABSOLUTE');
17
+ const parts = p.replace(/\\/gu, '/').split('/');
18
+ if (parts.some(x => x === '..'))
19
+ throw new Error('EXTENSION_PATH_TRAVERSAL');
20
+ const key = windows ? p.toLowerCase() : p;
21
+ if (seen.has(key))
22
+ throw new Error('EXTENSION_PATH_COLLISION');
23
+ seen.add(key);
24
+ } return true; }
@@ -0,0 +1,84 @@
1
+ import { hasToolOutcomeCarrier, toolOutcomesFromCliEvent } from "../events/bridge.js";
2
+ import { renderTalosFailureLine, safeTalosFailure } from "../errors.js";
3
+ function hiddenFailure(value, failure) { Object.defineProperty(value, 'failure', { value: failure, enumerable: false, configurable: false, writable: false }); return value; }
4
+ function hiddenToolOutcomes(value, outcomes) { if (outcomes.length === 0)
5
+ return value; Object.defineProperty(value, 'toolOutcomes', { value: [...outcomes], enumerable: false, configurable: false, writable: false }); return value; }
6
+ function resultToolOutcomes(value) { const outcomes = value.toolOutcomes; return Array.isArray(outcomes) ? outcomes : []; }
7
+ function eventFailure(e, component = 'runtime') {
8
+ const attached = e.failure;
9
+ if (attached)
10
+ return attached;
11
+ return safeTalosFailure({ ...e.data, code: String(e.data.code ?? e.data.sourceCode ?? 'AGENT_FAILED'), message: String(e.data.message ?? e.data.detto ?? 'Agent run failed') }, { component }, []);
12
+ }
13
+ export function canonicalizeFailureEvent(e, component = 'runtime') {
14
+ if (e.type !== 'run.failed')
15
+ return e;
16
+ const failure = eventFailure(e, component);
17
+ const outcomes = toolOutcomesFromCliEvent(e);
18
+ const normalized = { ...e, data: { ...e.data, code: failure.envelope.code, message: failure.message } };
19
+ return hiddenToolOutcomes(hiddenFailure(normalized, failure), outcomes);
20
+ }
21
+ export function createFailedRunResult(input) {
22
+ const details = input.details ?? {};
23
+ const failure = safeTalosFailure({ ...details, code: input.code, message: input.message }, { component: input.component ?? 'runtime', retryable: input.retryable ?? false });
24
+ const value = { schema: 'talos.cli.result.v1', ok: false, sessionId: input.sessionId, error: { code: failure.envelope.code, message: failure.message, details }, warnings: [...(input.warnings ?? [])] };
25
+ return hiddenFailure(value, failure);
26
+ }
27
+ export function withRunWarnings(r, warnings) {
28
+ const next = { ...r, warnings: [...warnings] };
29
+ const failure = r.failure;
30
+ const withFailure = failure ? hiddenFailure(next, failure) : next;
31
+ return hiddenToolOutcomes(withFailure, resultToolOutcomes(r));
32
+ }
33
+ function ensuredFailure(r) {
34
+ const attached = r.failure;
35
+ if (attached)
36
+ return attached;
37
+ const error = r.error ?? { code: 'INTERNAL_ERROR', message: 'Unknown error', details: {} };
38
+ return safeTalosFailure({ ...error.details, code: error.code, message: error.message }, { component: 'runtime' }, []);
39
+ }
40
+ export function createRunResultAccumulator() {
41
+ let text = '';
42
+ const changed = new Set();
43
+ let usage = null;
44
+ const warnings = [];
45
+ let failed;
46
+ let failure;
47
+ let sid = null;
48
+ let toolOutcomeSource = null;
49
+ return {
50
+ add(input) {
51
+ const e = canonicalizeFailureEvent(input);
52
+ sid = e.sessionId || sid;
53
+ if (hasToolOutcomeCarrier(e))
54
+ toolOutcomeSource = e;
55
+ if (e.type === 'message.delta')
56
+ text += String(e.data.delta ?? e.data.text ?? '');
57
+ if (e.type === 'file.changed' && typeof e.data.path === 'string')
58
+ changed.add(e.data.path);
59
+ if (e.type === 'usage.updated')
60
+ usage = e.data.value ?? e.data;
61
+ if (e.type === 'warning')
62
+ warnings.push(String(e.data.message ?? e.data.code ?? 'warning'));
63
+ if (e.type === 'run.failed') {
64
+ failure = eventFailure(e);
65
+ failed = { code: String(e.data.code ?? 'AGENT_FAILED'), message: String(e.data.message ?? 'Agent run failed'), details: e.data };
66
+ }
67
+ },
68
+ result() {
69
+ const toolOutcomes = toolOutcomeSource ? toolOutcomesFromCliEvent(toolOutcomeSource) : [];
70
+ if (failed) {
71
+ const value = { schema: 'talos.cli.result.v1', ok: false, sessionId: sid, error: failed, warnings: [...warnings] };
72
+ return hiddenToolOutcomes(hiddenFailure(value, failure ?? safeTalosFailure(failed, { component: 'runtime' })), toolOutcomes);
73
+ }
74
+ const value = { schema: 'talos.cli.result.v1', ok: true, sessionId: sid, result: { text, outcome: 'success', changedFiles: [...changed], usage }, warnings: [...warnings] };
75
+ return hiddenToolOutcomes(value, toolOutcomes);
76
+ }
77
+ };
78
+ }
79
+ export function reduceRunResult(events) { const acc = createRunResultAccumulator(); for (const e of events)
80
+ acc.add(e); return acc.result(); }
81
+ export function renderJson(r) { return `${JSON.stringify(r)}\n`; }
82
+ export function renderStreamJson(events) { return events.map(e => JSON.stringify(canonicalizeFailureEvent(e))).join('\n') + (events.length ? '\n' : ''); }
83
+ export function renderText(r) { return r.ok ? `${r.result?.text ?? ''}${r.result?.text ? '\n' : ''}` : renderTalosFailureLine(ensuredFailure(r)); }
84
+ export function exitCodeForResult(r) { return r.ok ? 0 : ensuredFailure(r).exitCode; }
@@ -0,0 +1,230 @@
1
+ import { createEventBridge } from "../events/bridge.js";
2
+ import { canonicalizeFailureEvent, createFailedRunResult, createRunResultAccumulator } from "./result.js";
3
+ import { createPermissionEngine } from "../security/permission-engine.js";
4
+ import { permissionActionFromApproval } from "../security/from-approval.js";
5
+ import { secretValuesFromEnvironment } from "../diagnostics/redact.js";
6
+ import { keyOriginForRun, keyOriginNotice } from "../provider/environment-keys.js";
7
+ /* R2 (E8 / Q-R2-7): the one missing-key sentence, also the JSON `message` of v1 and v2; the code stays PROVIDER_KEY_MISSING. */
8
+ import { missingKeyText } from "../provider/missing-key.js";
9
+ import { checkpointMutationAllowed } from "../workspace/checkpoint.js";
10
+ import { createCheckpointStore } from "../workspace/checkpoint-store.js";
11
+ import { createV2EventBridge, createV2FailureEvent, createV2RunResultAccumulator, createV2SyntheticEvent } from "../protocol/v2/events.js";
12
+ import { t } from "../i18n/index.js";
13
+ const INTERRUPT_GRACE_MS = 5_000;
14
+ /*
15
+ * R3 Q-R3-8b, gate E8. Ctrl+C on `talos -p` asks the runtime to stop the run and waits for its terminal event (at most
16
+ * `interruptGraceMs`), then ends the output with an interrupted run: v1 a failure with code INTERRUPTED, v2 a
17
+ * `run.cancelled` (outcome `cancelled`, envelope INTERRUPTED); both exit 130 (`exitCodeForEnvelope`, errors.ts). A run that
18
+ * completed before the stop took effect stays completed; any other failure stays that failure. Precedents in the window:
19
+ * Hermes `-q` exit 130 (`cli_single_query.py:148-167`), Gemini/Qwen `FatalCancellationError` exit 130 (gate §6.2).
20
+ */
21
+ function watchInterrupt(input, onStop, onGiveUp) {
22
+ let timer;
23
+ let stopped = false;
24
+ const stop = () => { if (stopped)
25
+ return; stopped = true; onStop(); timer = setTimeout(onGiveUp, input.interruptGraceMs ?? INTERRUPT_GRACE_MS); };
26
+ input.signal?.addEventListener('abort', stop, { once: true });
27
+ return { start() { if (input.signal?.aborted)
28
+ stop(); }, get stopped() { return stopped; }, dispose() { if (timer)
29
+ clearTimeout(timer); input.signal?.removeEventListener('abort', stop); } };
30
+ }
31
+ const isKernelStop = (code) => code === 'fermato' || code === 'INTERRUPTED' || code === 'CANCELLED';
32
+ function noticeEvent(sessionId, seq, message) { return { schema: 'talos.cli.event.v1', seq, ts: new Date().toISOString(), sessionId, type: 'warning', data: { code: 'PROVIDER_KEY_ORIGIN', message } }; }
33
+ async function beginTurnCheckpoint(runtime, input, operation, sessionId) {
34
+ if (!input.checkpointsRoot)
35
+ return null;
36
+ if (operation === 'start' && !checkpointMutationAllowed(input.permissionMode))
37
+ return null;
38
+ const store = createCheckpointStore({ rootDir: input.checkpointsRoot, projectRoot: input.projectRoot });
39
+ return store.begin({ operation, ...(sessionId ? { sessionId } : {}) });
40
+ }
41
+ function collectV1(runtime, id, input, onEvent, notices = [], checkpoint = null) {
42
+ const engine = createPermissionEngine({ projectRoot: input.projectRoot, rules: input.permissionRules ?? { allow: [], ask: [], deny: [] }, mode: input.permissionMode, ...(input.autoClassifier ? { classifier: input.autoClassifier } : {}) });
43
+ const bridge = createEventBridge(id, undefined, secretValuesFromEnvironment(process.env));
44
+ const events = [];
45
+ const accumulator = createRunResultAccumulator();
46
+ const offset = notices.length;
47
+ for (const [index, message] of notices.entries()) {
48
+ const event = noticeEvent(id, index + 1, message);
49
+ if (!onEvent)
50
+ events.push(event);
51
+ accumulator.add(event);
52
+ onEvent?.(event);
53
+ }
54
+ return new Promise((resolve) => {
55
+ let done = false;
56
+ let settling = false;
57
+ let timer;
58
+ let unsub = () => { };
59
+ let lastSeq = offset;
60
+ const finish = (result) => { if (done)
61
+ return; done = true; if (timer)
62
+ clearTimeout(timer); interrupt.dispose(); unsub(); resolve({ events, result }); };
63
+ const emit = (event) => { lastSeq = Math.max(lastSeq, event.seq); if (!onEvent)
64
+ events.push(event); accumulator.add(event); onEvent?.(event); };
65
+ const fail = (code, message, details = {}, component = 'runtime') => { if (done)
66
+ return; const event = canonicalizeFailureEvent({ schema: 'talos.cli.event.v1', seq: lastSeq + 1, ts: new Date().toISOString(), sessionId: id, type: 'run.failed', data: { ...details, code, message } }, component); emit(event); finish(accumulator.result()); };
67
+ const interrupted = () => fail('INTERRUPTED', t('error.run.interrupted.what'), {}, 'runtime');
68
+ const interrupt = watchInterrupt(input, () => { void runtime.cancel(id).catch(() => { }); }, interrupted);
69
+ unsub = runtime.subscribe(id, (raw) => {
70
+ if (done || settling)
71
+ return;
72
+ checkpoint?.observe(raw);
73
+ const translated = bridge.translate(raw);
74
+ if (!translated)
75
+ return;
76
+ const shifted = offset ? { ...translated, seq: translated.seq + offset } : translated;
77
+ const event = canonicalizeFailureEvent(shifted);
78
+ if (interrupt.stopped && event.type === 'run.failed' && isKernelStop(translated.data?.code)) {
79
+ if (!checkpoint) {
80
+ interrupted();
81
+ return;
82
+ }
83
+ settling = true;
84
+ void checkpoint.finalize().then(interrupted, interrupted);
85
+ return;
86
+ }
87
+ if (event.type === 'approval.required') {
88
+ emit(event);
89
+ void (async () => { const decision = await engine.decide(permissionActionFromApproval(event.data), { interactive: false, mode: input.permissionMode }); if (decision.kind === 'allow') {
90
+ await runtime.answerApproval(id, String(event.data.requestId), true);
91
+ return;
92
+ } fail(decision.kind === 'deny' ? decision.code : 'PERMISSION_REQUIRED', decision.kind === 'deny' ? decision.message : 'Operation requires approval in non-interactive mode', event.data, 'permission-engine'); void runtime.answerApproval(id, String(event.data.requestId), false).finally(() => runtime.cancel(id)).catch(() => { }); })().catch(error => { fail('PERMISSION_ENGINE_ERROR', error instanceof Error ? error.message : String(error), {}, 'permission-engine'); void runtime.cancel(id).catch(() => { }); });
93
+ return;
94
+ }
95
+ if (event.type === 'run.completed' || event.type === 'run.failed') {
96
+ if (!checkpoint) {
97
+ emit(event);
98
+ finish(accumulator.result());
99
+ return;
100
+ }
101
+ settling = true;
102
+ void checkpoint.finalize().then(() => { if (done)
103
+ return; emit(event); finish(accumulator.result()); }).catch(error => { settling = false; fail('CHECKPOINT_FINALIZE_FAILED', error instanceof Error ? error.message : String(error), {}, 'checkpoint'); });
104
+ return;
105
+ }
106
+ emit(event);
107
+ }, input.from ?? 0);
108
+ interrupt.start();
109
+ const ms = (input.timeoutSeconds ?? 180) * 1000;
110
+ timer = setTimeout(() => { fail('RUN_TIMEOUT', 'Run timed out after ' + ms + ' ms', {}, 'runtime'); void runtime.cancel(id).catch(() => { }); }, ms);
111
+ });
112
+ }
113
+ function collectV2(runtime, id, input, onEvent, notices = [], checkpoint = null) {
114
+ const engine = createPermissionEngine({ projectRoot: input.projectRoot, rules: input.permissionRules ?? { allow: [], ask: [], deny: [] }, mode: input.permissionMode, ...(input.autoClassifier ? { classifier: input.autoClassifier } : {}) });
115
+ const secrets = secretValuesFromEnvironment(process.env);
116
+ const bridge = createV2EventBridge(id, undefined, secrets);
117
+ const events = [];
118
+ const accumulator = createV2RunResultAccumulator();
119
+ for (const [index, message] of notices.entries()) {
120
+ const event = createV2SyntheticEvent({ sessionId: id, eventId: 'talos:' + encodeURIComponent(id) + ':provider-notice:' + (index + 1), type: 'warning', data: { code: 'PROVIDER_KEY_ORIGIN', message } });
121
+ if (!onEvent)
122
+ events.push(event);
123
+ accumulator.add(event);
124
+ onEvent?.(event);
125
+ }
126
+ return new Promise((resolve) => {
127
+ let done = false;
128
+ let settling = false;
129
+ let timer;
130
+ let unsub = () => { };
131
+ const finish = () => { if (done)
132
+ return; done = true; if (timer)
133
+ clearTimeout(timer); interrupt.dispose(); unsub(); resolve({ events, result: accumulator.result() }); };
134
+ const emit = (event) => { if (!onEvent)
135
+ events.push(event); accumulator.add(event); onEvent?.(event); };
136
+ const fail = (code, message, details = {}, component = 'runtime') => { if (done)
137
+ return; emit(createV2FailureEvent({ sessionId: id, error: { code, message, component, retryable: false }, component, details, secretValues: secrets })); finish(); };
138
+ const interrupted = () => { if (done)
139
+ return; emit(createV2SyntheticEvent({ sessionId: id, eventId: 'talos:' + encodeURIComponent(id) + ':interrupted', type: 'run.cancelled', data: { reason: t('error.run.interrupted.what'), interrupted: true }, durability: 'durable' })); finish(); };
140
+ const interrupt = watchInterrupt(input, () => { void runtime.cancel(id).catch(() => { }); }, interrupted);
141
+ unsub = runtime.subscribe(id, (raw) => {
142
+ if (done || settling)
143
+ return;
144
+ checkpoint?.observe(raw);
145
+ const event = bridge.translate(raw);
146
+ if (!event)
147
+ return;
148
+ if (interrupt.stopped && (event.type === 'run.failed' || event.type === 'run.cancelled') && (event.type === 'run.cancelled' || isKernelStop(event.data?.error?.envelope?.code))) {
149
+ if (!checkpoint) {
150
+ interrupted();
151
+ return;
152
+ }
153
+ settling = true;
154
+ void checkpoint.finalize().then(interrupted, interrupted);
155
+ return;
156
+ }
157
+ if (event.type === 'approval.required') {
158
+ emit(event);
159
+ void (async () => { const decision = await engine.decide(permissionActionFromApproval(event.data), { interactive: false, mode: input.permissionMode }); if (decision.kind === 'allow') {
160
+ await runtime.answerApproval(id, String(event.data.requestId ?? ''), true);
161
+ return;
162
+ } fail(decision.kind === 'deny' ? decision.code : 'PERMISSION_REQUIRED', decision.kind === 'deny' ? decision.message : 'Operation requires approval in non-interactive mode', event.data, 'permission-engine'); void runtime.answerApproval(id, String(event.data.requestId ?? ''), false).finally(() => runtime.cancel(id)).catch(() => { }); })().catch(error => { fail('PERMISSION_ENGINE_ERROR', error instanceof Error ? error.message : String(error), {}, 'permission-engine'); void runtime.cancel(id).catch(() => { }); });
163
+ return;
164
+ }
165
+ if (event.type === 'run.completed' || event.type === 'run.failed' || event.type === 'run.cancelled') {
166
+ if (!checkpoint) {
167
+ emit(event);
168
+ finish();
169
+ return;
170
+ }
171
+ settling = true;
172
+ void checkpoint.finalize().then(() => { if (done)
173
+ return; emit(event); finish(); }).catch(error => { settling = false; fail('CHECKPOINT_FINALIZE_FAILED', error instanceof Error ? error.message : String(error), {}, 'checkpoint'); });
174
+ return;
175
+ }
176
+ emit(event);
177
+ }, input.from ?? 0);
178
+ interrupt.start();
179
+ const ms = (input.timeoutSeconds ?? 180) * 1000;
180
+ timer = setTimeout(() => { fail('RUN_TIMEOUT', 'Run timed out after ' + ms + ' ms', {}, 'runtime'); void runtime.cancel(id).catch(() => { }); }, ms);
181
+ });
182
+ }
183
+ async function collectHeadlessRunV1(runtime, input, onEvent) {
184
+ const origin = keyOriginForRun(runtime, input.model);
185
+ if (origin?.required && origin.origin === 'none') {
186
+ const message = missingKeyText(origin.provider);
187
+ const failed = canonicalizeFailureEvent({ schema: 'talos.cli.event.v1', seq: 1, ts: new Date().toISOString(), sessionId: '', type: 'run.failed', data: { code: 'PROVIDER_KEY_MISSING', message, provider: origin.provider } }, 'provider');
188
+ onEvent?.(failed);
189
+ return { events: onEvent ? [] : [failed], result: createFailedRunResult({ sessionId: null, code: String(failed.data.code), message: String(failed.data.message), details: { provider: origin.provider }, component: 'provider' }) };
190
+ }
191
+ const notice = origin ? keyOriginNotice(origin) : null;
192
+ const checkpoint = await beginTurnCheckpoint(runtime, input, 'start');
193
+ const id = await runtime.start(input);
194
+ checkpoint?.bindSession(id);
195
+ return collectV1(runtime, id, input, onEvent, notice ? [notice] : [], checkpoint);
196
+ }
197
+ async function collectHeadlessRunV2(runtime, input, onEvent) {
198
+ const origin = keyOriginForRun(runtime, input.model);
199
+ if (origin?.required && origin.origin === 'none') {
200
+ const message = missingKeyText(origin.provider);
201
+ const event = createV2FailureEvent({ sessionId: '', error: { code: 'PROVIDER_KEY_MISSING', message, component: 'provider', retryable: false, provider: origin.provider }, component: 'provider', details: { provider: origin.provider }, secretValues: secretValuesFromEnvironment(process.env) });
202
+ const accumulator = createV2RunResultAccumulator();
203
+ accumulator.add(event);
204
+ onEvent?.(event);
205
+ return { events: onEvent ? [] : [event], result: accumulator.result() };
206
+ }
207
+ const notice = origin ? keyOriginNotice(origin) : null;
208
+ const checkpoint = await beginTurnCheckpoint(runtime, input, 'start');
209
+ const id = await runtime.start(input);
210
+ checkpoint?.bindSession(id);
211
+ return collectV2(runtime, id, input, onEvent, notice ? [notice] : [], checkpoint);
212
+ }
213
+ export async function collectHeadlessRun(runtime, input, onEvent) {
214
+ return input.protocolVersion === 'v2' ? collectHeadlessRunV2(runtime, input, onEvent) : collectHeadlessRunV1(runtime, input, onEvent);
215
+ }
216
+ export async function collectHeadlessResume(runtime, sessionId, prompt, input, onEvent) {
217
+ const checkpoint = await beginTurnCheckpoint(runtime, input, 'resume', sessionId);
218
+ const id = await runtime.resume(sessionId, prompt);
219
+ checkpoint?.bindSession(id);
220
+ return input.protocolVersion === 'v2' ? collectV2(runtime, id, input, onEvent, [], checkpoint) : collectV1(runtime, id, input, onEvent, [], checkpoint);
221
+ }
222
+ export async function collectHeadlessFork(runtime, sessionId, prompt, input, onEvent) {
223
+ const checkpoint = await beginTurnCheckpoint(runtime, input, 'fork', sessionId);
224
+ const id = await runtime.fork(sessionId, prompt);
225
+ checkpoint?.bindSession(id);
226
+ return input.protocolVersion === 'v2' ? collectV2(runtime, id, input, onEvent, [], checkpoint) : collectV1(runtime, id, input, onEvent, [], checkpoint);
227
+ }
228
+ export async function collectHeadlessSession(runtime, sessionId, input, onEvent) {
229
+ return input.protocolVersion === 'v2' ? collectV2(runtime, sessionId, input, onEvent) : collectV1(runtime, sessionId, input, onEvent);
230
+ }
@@ -0,0 +1,46 @@
1
+ /* R3 lane S+P: the approval dialog's question, choices and hints (gate E11, Q-R3-5/6/13/14). */
2
+ export const approval = {
3
+ 'approval.question': 'Allow this?',
4
+ /* One question per permission tool (gate E11: "a question sentence"). */
5
+ 'approval.question.Bash': 'Run this command?',
6
+ 'approval.question.Write': 'Write this file?',
7
+ 'approval.question.Edit': 'Make this edit?',
8
+ 'approval.question.Read': 'Read this file?',
9
+ 'approval.question.WebFetch': 'Open this address?',
10
+ 'approval.question.Mcp': 'Call this tool?',
11
+ 'approval.question.Hook': 'Run this hook?',
12
+ 'approval.question.Plugin': 'Run this plugin tool?',
13
+ 'approval.question.TalosService': 'Allow this?',
14
+ /* Q-R3-13 (R0 decision 4): the title of a command approval on a host with no verified sandbox. */
15
+ 'approval.unsandboxed': '(unsandboxed)',
16
+ /* P13 (owner decision 8): who asks, when a sub-agent does. */
17
+ 'approval.origin.agent': '· from agent · {task}',
18
+ 'approval.origin.agentUnnamed': '· from an agent',
19
+ /* Q-R3-6: four choices, Deny highlighted; "deny always" only in the full review (or /permissions). */
20
+ 'approval.choice.once': 'Allow once',
21
+ 'approval.choice.session': 'Allow for this session',
22
+ 'approval.choice.always': 'Always allow',
23
+ 'approval.choice.deny': 'Deny',
24
+ 'approval.choice.denyAlways': 'Deny always',
25
+ /* Q-R3-5 / Q-R3-14: Esc denies and stops the turn from the summary, and goes back from the full review. */
26
+ 'approval.hint.summary': '↑↓ Enter · v full review · Esc deny and stop',
27
+ 'approval.hint.review': 'Enter choose · [5] deny always · v/Esc back',
28
+ 'approval.hint.compact': 'Esc deny and stop',
29
+ /* The full review, for a person (gate E11, §0.10: no raw JSON, no kernel keys). */
30
+ 'approval.review.tool': 'Tool',
31
+ 'approval.review.path': 'Path',
32
+ 'approval.review.command': 'Command',
33
+ 'approval.review.format': 'Format',
34
+ 'approval.review.address': 'Address',
35
+ 'approval.review.server': 'Server',
36
+ 'approval.review.operation': 'Operation',
37
+ 'approval.review.sensitive': 'It touches a file that may hold keys or passwords: {path}',
38
+ 'approval.review.sensitiveHidden': 'It touches a file that may hold keys or passwords.',
39
+ 'approval.review.trifecta': 'This conversation now holds private data, untrusted content and a way to send data out, so TALOS asks again.',
40
+ 'approval.review.other': 'Other details',
41
+ /* Q-R3-4: a write or an edit shows its change in the approval, before it happens. */
42
+ 'approval.change.newFile': 'new file · {lines} lines',
43
+ 'approval.change.counts': '+{added} −{removed}',
44
+ 'approval.change.none': 'no change to the file',
45
+ 'approval.change.more': '… {count} more diff lines — press v to review in full',
46
+ };
@@ -0,0 +1,9 @@
1
+ /* R2 common words shared by every area (owner: coordinator). */
2
+ export const common = {
3
+ 'common.details': 'Details',
4
+ /* R7 (owner 2026-09-25): `talos update` of an npm install. */
5
+ 'common.update.npmAvailable': 'TALOS CLI {version} is available (this is {current}). Update with: {command}',
6
+ 'common.update.upToDate': 'TALOS CLI is up to date',
7
+ 'common.item.one': '{count} item',
8
+ 'common.item.other': '{count} items',
9
+ };