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,185 @@
1
+ /*
2
+ * R5a lane R, S3/S4 — owner decisions Q-R5-4 and Q-R5-6 (2026-09-24): the facts the kernel does not publish, observed by the
3
+ * CLI around each model run and handed to the screen and to protocol v2 as transient CLI events.
4
+ *
5
+ * A CLI event is an AG-UI `CUSTOM` row named `talos.cli.*` (the kernel's own CUSTOM rows are `talos.context`,
6
+ * `consumo-fornitore`, `cambio-fornitore`): protocol v1 maps no CUSTOM row (events/bridge.ts MAP), so v1 stays byte-frozen
7
+ * (gate E3); the v2 bridge turns them into `provider.attempt` / `context.compacted` and folds `provider.failure` into the
8
+ * next `run.failed`. They carry no `_sequenza`: they are live facts, never replayed, never persisted.
9
+ *
10
+ * What is observed, and where:
11
+ * - each retry WAIT, from the kernel's own callback (`onRetryWait`, the owner's amendment to talosHarness.mjs): attempt,
12
+ * status, the wait the provider asked for and the wait actually taken, so the screen can count down a known wait;
13
+ * - the failure that ends a run: the HTTP status the kernel keeps on the thrown error (`stato`, talosHarness.mjs
14
+ * `chiamaConRitentaBase`, and `erroreFornitorePubblico` in runtime-owner-adapter.mjs), which agent-service.mjs:1991 drops
15
+ * when it writes `RunError{message, code}`; and the provider's requested wait, read by this module's fetch observer,
16
+ * because the multi-provider wrapper rebuilds the error without it. With the status, 401 and 403 get their own words;
17
+ * - the kernel's own compaction (every 8 model calls once the estimate passes 2,000 tokens, talosHarness.mjs:195-222),
18
+ * which emits no event and was NOT approved as a kernel change: it is recognised at the network boundary the CLI already
19
+ * owns, by the kernel's two fixed texts — the English summary request it appends (`RICHIESTA_DI_RIASSUNTO`, first line)
20
+ * and the marker it puts in place of the history (`[conversazione compattata al giro …`). Both are pinned against the
21
+ * kernel source by r5a-r-provider-attempts.test.ts, so a reworded kernel turns a test red instead of going silent.
22
+ */
23
+ export const CLI_EVENT = Object.freeze({
24
+ attempt: 'talos.cli.provider.attempt',
25
+ failure: 'talos.cli.provider.failure',
26
+ compacted: 'talos.cli.context.compacted',
27
+ /* R5b (R5a open 2): one Context Engine summary requested; whether it was accepted is the engine's committed version. */
28
+ summaryRequested: 'talos.cli.context.summary-requested',
29
+ });
30
+ /** The owner's cap (Q-R5-6): a provider's requested wait is honoured up to 60 s; a longer one ends the retries. */
31
+ export const RETRY_AFTER_MAX_MS = 60_000;
32
+ /** The kernel's summary request (talosHarness.mjs `RICHIESTA_DI_RIASSUNTO`), its first words; pinned by test. */
33
+ export const KERNEL_SUMMARY_REQUEST_START = 'Before continuing, summarize your progress on this task so far';
34
+ /** The kernel's replacement for a compacted history (talosHarness.mjs `compattaConversazione`); pinned by test. */
35
+ export const KERNEL_COMPACTED_MARKER_START = '[conversazione compattata al giro ';
36
+ function finiteOrNull(value) { return typeof value === 'number' && Number.isFinite(value) ? value : null; }
37
+ function nonNegativeInteger(value) { const n = finiteOrNull(value); return n !== null && n >= 0 ? Math.round(n) : null; }
38
+ /** The wait a provider asks for, in ms, or null: `retry-after-ms`, then `Retry-After` seconds or HTTP date (as the kernel). */
39
+ export function retryAfterMs(headers, now = Date.now()) {
40
+ const read = (name) => { try {
41
+ return typeof headers?.get === 'function' ? headers.get(name) : null;
42
+ }
43
+ catch {
44
+ return null;
45
+ } };
46
+ const ms = read('retry-after-ms');
47
+ if (ms !== null && ms.trim() !== '' && Number.isFinite(Number(ms)))
48
+ return Math.max(0, Math.round(Number(ms)));
49
+ const value = read('retry-after');
50
+ if (value === null || value.trim() === '')
51
+ return null;
52
+ if (/^\d+(?:\.\d+)?$/u.test(value.trim()))
53
+ return Math.round(Number(value.trim()) * 1000);
54
+ const date = Date.parse(value);
55
+ return Number.isNaN(date) ? null : Math.max(0, date - now);
56
+ }
57
+ export function attemptEvent(info) {
58
+ const row = info && typeof info === 'object' ? info : null;
59
+ const attempt = nonNegativeInteger(row?.attempt), maxAttempts = nonNegativeInteger(row?.maxAttempts);
60
+ if (attempt === null || maxAttempts === null)
61
+ return null;
62
+ const value = { attempt, maxAttempts, status: nonNegativeInteger(row?.status), retryAfterMs: nonNegativeInteger(row?.retryAfterMs), waitMs: nonNegativeInteger(row?.waitMs) };
63
+ return { type: 'CUSTOM', name: CLI_EVENT.attempt, value };
64
+ }
65
+ export function compactionEvent(fact) { return { type: 'CUSTOM', name: CLI_EVENT.compacted, value: { ...fact } }; }
66
+ export function summaryRequestedEvent() { return { type: 'CUSTOM', name: CLI_EVENT.summaryRequested, value: {} }; }
67
+ export function failureEvent(fact) { return { type: 'CUSTOM', name: CLI_EVENT.failure, value: { ...fact } }; }
68
+ /** Per-session listeners for the CLI's transient events; the composition merges them into `subscribe`. */
69
+ export function createCliEventHub() {
70
+ const listeners = new Map();
71
+ return {
72
+ emit(sessionId, event) {
73
+ for (const listener of [...(listeners.get(sessionId) ?? [])]) {
74
+ try {
75
+ listener(event);
76
+ }
77
+ catch { /* a listener's failure is its own */ }
78
+ }
79
+ },
80
+ subscribe(sessionId, listener) {
81
+ let set = listeners.get(sessionId);
82
+ if (!set) {
83
+ set = new Set();
84
+ listeners.set(sessionId, set);
85
+ }
86
+ set.add(listener);
87
+ return () => { const current = listeners.get(sessionId); current?.delete(listener); if (current && current.size === 0)
88
+ listeners.delete(sessionId); };
89
+ },
90
+ size(sessionId) { return listeners.get(sessionId)?.size ?? 0; },
91
+ };
92
+ }
93
+ function textOf(content) {
94
+ if (typeof content === 'string')
95
+ return content;
96
+ if (Array.isArray(content))
97
+ return content.map(part => part && typeof part === 'object' && typeof part.text === 'string' ? part.text : '').join('');
98
+ return '';
99
+ }
100
+ function requestBody(init) {
101
+ if (typeof init?.body !== 'string')
102
+ return null;
103
+ try {
104
+ return JSON.parse(init.body);
105
+ }
106
+ catch {
107
+ return null;
108
+ }
109
+ }
110
+ function conversationOf(body) { return Array.isArray(body?.messages) ? body.messages : null; }
111
+ function isSummaryRequest(messages) {
112
+ const last = messages.at(-1);
113
+ return last?.role === 'user' && textOf(last.content).startsWith(KERNEL_SUMMARY_REQUEST_START);
114
+ }
115
+ function carriesCompactedMarker(messages) {
116
+ return messages.some(message => message?.role === 'user' && textOf(message.content).startsWith(KERNEL_COMPACTED_MARKER_START));
117
+ }
118
+ const SYSTEM_ROLES = new Set(['system', 'developer']);
119
+ /**
120
+ * One model run's observer. `fetchDiRete` wraps the innermost transport the owner adapter uses (talosLavora's
121
+ * `input.fetchDiRete`, runtime-owner-adapter.mjs:1193): every real HTTP request of the run passes through it, retries and
122
+ * fallback providers included. It never changes a request or a response.
123
+ */
124
+ export function createRunObserver({ sessionId, hub, baseFetch = (input, init) => fetch(input, init), now = () => Date.now() }) {
125
+ let lastResponse = null;
126
+ /* The requested wait of the latest real failed response, until the kernel reads it (`retryAfterMsFn`). */
127
+ let unreadWait = null;
128
+ let pending = null;
129
+ const emit = (event) => { if (event)
130
+ hub.emit(sessionId, event); };
131
+ async function fetchDiRete(input, init) {
132
+ const messages = conversationOf(requestBody(init));
133
+ let summary = null;
134
+ if (messages) {
135
+ if (isSummaryRequest(messages)) {
136
+ /* Summarised: everything but the system prompt, the task (kept word for word) and the summary request itself. */
137
+ const conversation = messages.filter(message => !SYSTEM_ROLES.has(String(message?.role)));
138
+ summary = { messagesSummarized: Math.max(0, conversation.length - 2), tokensBefore: null };
139
+ }
140
+ else if (pending) {
141
+ const done = pending;
142
+ pending = null;
143
+ if (carriesCompactedMarker(messages))
144
+ emit(compactionEvent({ engine: 'kernel', messagesSummarized: done.messagesSummarized, tokensBefore: done.tokensBefore, tokensAfter: null, trigger: 'automatic' }));
145
+ }
146
+ }
147
+ const response = await baseFetch(input, init);
148
+ if (messages) {
149
+ lastResponse = { status: response.status, retryAfterMs: response.ok ? null : retryAfterMs(response.headers, now()) };
150
+ unreadWait = lastResponse.retryAfterMs;
151
+ if (summary) {
152
+ pending = summary;
153
+ /* The summary call is not streamed (talosHarness.mjs `compattaConversazione` passes no onDelta): its reported input
154
+ tokens are read from a copy, off the kernel's path. */
155
+ if (response.ok && typeof response.clone === 'function') {
156
+ const holder = summary;
157
+ void response.clone().json().then((body) => { const tokens = nonNegativeInteger(body?.usage?.prompt_tokens ?? body?.usage?.input_tokens); if (tokens !== null)
158
+ holder.tokensBefore = tokens; }).catch(() => { });
159
+ }
160
+ }
161
+ }
162
+ return response;
163
+ }
164
+ return {
165
+ fetchDiRete,
166
+ /** The kernel's `onRetryWait` for this run. */
167
+ onRetryWait(info) { emit(attemptEvent(info)); },
168
+ /**
169
+ * The kernel's `retryAfterMsFn`: the provider's requested wait for the attempt that just failed, read here because the
170
+ * multi-provider layer hands the kernel a rebuilt response without the provider's headers (runtime-owner-adapter.mjs
171
+ * `rete`). Read once: an attempt the store answered itself, with no request (a key benched until the wait is over),
172
+ * finds nothing and the kernel's own backoff applies.
173
+ */
174
+ retryAfterMsFn(_info) { const wait = unreadWait; unreadWait = null; return wait; },
175
+ /** The facts of the error that ended the run, announced BEFORE the kernel's RunError reaches the stream. */
176
+ announceFailure(error) {
177
+ const row = error && typeof error === 'object' ? error : null;
178
+ const status = nonNegativeInteger(row?.stato) ?? nonNegativeInteger(row?.status) ?? (lastResponse && lastResponse.status >= 400 ? lastResponse.status : null);
179
+ const wait = nonNegativeInteger(row?.retryAfterMs) ?? (lastResponse && lastResponse.status === status ? lastResponse.retryAfterMs : null);
180
+ if (status === null && wait === null)
181
+ return;
182
+ emit(failureEvent({ status, retryAfterMs: wait }));
183
+ },
184
+ };
185
+ }
@@ -0,0 +1,153 @@
1
+ import { createHash, randomUUID } from 'node:crypto';
2
+ import { mkdir, readdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ function canonical(value) {
5
+ if (Array.isArray(value))
6
+ return value.map(canonical);
7
+ if (value && typeof value === 'object') {
8
+ const source = value;
9
+ return Object.fromEntries(Object.keys(source).sort().filter(key => source[key] !== undefined).map(key => [key, canonical(source[key])]));
10
+ }
11
+ return value === undefined ? null : value;
12
+ }
13
+ function identity(value) { return JSON.stringify(canonical(value)); }
14
+ export function startOperationFingerprint(input) {
15
+ const { operationId: _operationId, ...material } = input;
16
+ return createHash('sha256').update(identity(material)).digest('hex');
17
+ }
18
+ export function createRuntimeReplayBuffer() {
19
+ const sessions = new Map();
20
+ return {
21
+ push(sessionId, event) {
22
+ const raw = event?._sequenza;
23
+ const sequence = typeof raw === 'number' && Number.isSafeInteger(raw) && raw >= 0 ? raw : null;
24
+ if (sequence === null)
25
+ return false;
26
+ let rows = sessions.get(sessionId);
27
+ if (!rows) {
28
+ rows = new Map();
29
+ sessions.set(sessionId, rows);
30
+ }
31
+ const eventIdentity = identity(event);
32
+ const existing = rows.get(sequence);
33
+ if (existing) {
34
+ if (existing.identity === eventIdentity)
35
+ return false;
36
+ throw Object.assign(new Error('REPLAY_EVENT_CONFLICT'), { code: 'REPLAY_EVENT_CONFLICT', sessionId, sequence });
37
+ }
38
+ rows.set(sequence, { identity: eventIdentity, event: structuredClone(event) });
39
+ return true;
40
+ },
41
+ after(sessionId, sequence = 0) {
42
+ return [...(sessions.get(sessionId)?.entries() ?? [])]
43
+ .filter(([candidate]) => candidate > sequence)
44
+ .sort(([a], [b]) => a - b)
45
+ .map(([, row]) => structuredClone(row.event));
46
+ },
47
+ latest(sessionId) {
48
+ const keys = [...(sessions.get(sessionId)?.keys() ?? [])];
49
+ return keys.length ? Math.max(...keys) : 0;
50
+ },
51
+ clear(sessionId) { if (sessionId)
52
+ sessions.delete(sessionId);
53
+ else
54
+ sessions.clear(); },
55
+ };
56
+ }
57
+ function processAlive(pid) {
58
+ try {
59
+ process.kill(pid, 0);
60
+ return true;
61
+ }
62
+ catch (error) {
63
+ return error?.code === 'EPERM';
64
+ }
65
+ }
66
+ function ownerPid(name) {
67
+ const match = /\.(\d+)\.json$/u.exec(name);
68
+ if (!match)
69
+ return null;
70
+ const value = Number(match[1]);
71
+ return Number.isSafeInteger(value) && value > 0 ? value : null;
72
+ }
73
+ function operationPath(root, operationId, pid) {
74
+ return join(root, `${encodeURIComponent(operationId)}.${pid}.json`);
75
+ }
76
+ async function readRecord(path) {
77
+ try {
78
+ const value = JSON.parse(await readFile(path, 'utf8'));
79
+ if (value?.schema !== 'talos.cli.runtime-start-operation.v1' || typeof value.operationId !== 'string' || typeof value.fingerprint !== 'string')
80
+ return null;
81
+ return value;
82
+ }
83
+ catch {
84
+ return null;
85
+ }
86
+ }
87
+ export function createStartOperationJournal(options) {
88
+ const pid = options.pid ?? process.pid;
89
+ const isProcessAlive = options.isProcessAlive ?? processAlive;
90
+ const nextOperationId = options.operationId ?? randomUUID;
91
+ const now = options.now ?? (() => new Date().toISOString());
92
+ const root = options.rootDir;
93
+ async function ensure() { await mkdir(root, { recursive: true, mode: 0o700 }); }
94
+ return {
95
+ async claim(fingerprint) {
96
+ await ensure();
97
+ let names = [];
98
+ try {
99
+ names = await readdir(root);
100
+ }
101
+ catch { }
102
+ for (const name of names.sort()) {
103
+ if (!name.endsWith('.json'))
104
+ continue;
105
+ const oldPid = ownerPid(name);
106
+ if (oldPid === null || oldPid === pid || isProcessAlive(oldPid))
107
+ continue;
108
+ const source = join(root, name);
109
+ const record = await readRecord(source);
110
+ if (!record || record.fingerprint !== fingerprint)
111
+ continue;
112
+ const target = operationPath(root, record.operationId, pid);
113
+ try {
114
+ await rename(source, target);
115
+ }
116
+ catch (error) {
117
+ if (error?.code === 'ENOENT' || error?.code === 'EEXIST')
118
+ continue;
119
+ throw error;
120
+ }
121
+ const claimed = { ...record, pid };
122
+ await writeFile(target, `${JSON.stringify(claimed)}\n`, { encoding: 'utf8', mode: 0o600 });
123
+ return { operationId: record.operationId, recovered: true };
124
+ }
125
+ for (let attempt = 0; attempt < 16; attempt++) {
126
+ const id = nextOperationId();
127
+ const file = operationPath(root, id, pid);
128
+ const record = { schema: 'talos.cli.runtime-start-operation.v1', operationId: id, fingerprint, pid, createdAt: now() };
129
+ try {
130
+ await writeFile(file, `${JSON.stringify(record)}\n`, { encoding: 'utf8', mode: 0o600, flag: 'wx' });
131
+ return { operationId: id, recovered: false };
132
+ }
133
+ catch (error) {
134
+ if (error?.code === 'EEXIST')
135
+ continue;
136
+ throw error;
137
+ }
138
+ }
139
+ throw Object.assign(new Error('RUNTIME_OPERATION_ID_UNAVAILABLE'), { code: 'RUNTIME_OPERATION_ID_UNAVAILABLE' });
140
+ },
141
+ async releaseOwned() {
142
+ await ensure();
143
+ let names = [];
144
+ try {
145
+ names = await readdir(root);
146
+ }
147
+ catch {
148
+ return;
149
+ }
150
+ await Promise.all(names.filter(name => ownerPid(name) === pid).map(name => rm(join(root, name), { force: true })));
151
+ },
152
+ };
153
+ }
@@ -0,0 +1,95 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ import { existsSync } from 'node:fs';
10
+ import { dirname, join, resolve } from 'node:path';
11
+ import { fileURLToPath, pathToFileURL } from 'node:url';
12
+ function isTalosRuntimeRoot(root, exists) {
13
+ return exists(join(root, 'harness-ui', 'src', 'session-registry.mjs'));
14
+ }
15
+ function firstRuntimeRoot(candidates, exists) {
16
+ for (const candidate of candidates) {
17
+ const root = resolve(candidate);
18
+ if (isTalosRuntimeRoot(root, exists))
19
+ return root;
20
+ }
21
+ return null;
22
+ }
23
+ function findAncestorRuntimeRoot(start, exists) {
24
+ let current = resolve(start);
25
+ for (let i = 0; i < 16; i++) {
26
+ if (isTalosRuntimeRoot(current, exists))
27
+ return current;
28
+ const parent = dirname(current);
29
+ if (parent === current)
30
+ break;
31
+ current = parent;
32
+ }
33
+ return null;
34
+ }
35
+ function moduleDirectory(moduleUrl) {
36
+ try {
37
+ return dirname(fileURLToPath(moduleUrl));
38
+ }
39
+ catch {
40
+ return null;
41
+ }
42
+ }
43
+ function installedAppCandidates(appRoot) {
44
+ return [resolve(appRoot, 'vendor'), resolve(appRoot)];
45
+ }
46
+ export function findTalosRepoRoot(start = process.cwd(), deps = {}) {
47
+ const exists = deps.exists ?? existsSync;
48
+ const env = deps.env ?? process.env;
49
+ // The running CLI module is the strongest anchor. In the packaged tree this file is
50
+ // app/dist/runtime/repo.js, so ../.. is app and app/vendor is the shipped backend.
51
+ // In a source/build checkout the ancestor walk from the module finds the repository
52
+ // without consulting whatever project directory the user happens to be in.
53
+ const moduleDir = moduleDirectory(deps.moduleUrl ?? import.meta.url);
54
+ if (moduleDir) {
55
+ const appRoot = resolve(moduleDir, '..', '..');
56
+ const installed = firstRuntimeRoot(installedAppCandidates(appRoot), exists);
57
+ if (installed)
58
+ return installed;
59
+ const source = findAncestorRuntimeRoot(moduleDir, exists);
60
+ if (source)
61
+ return source;
62
+ }
63
+ // The Windows launcher already sets this to the staged/installed root. It is an
64
+ // internal launch contract, not a variable users must configure.
65
+ const launcherRoot = env.TALOS_CLI_ROOT?.trim();
66
+ if (launcherRoot) {
67
+ const installed = firstRuntimeRoot(installedAppCandidates(resolve(launcherRoot, 'app')), exists);
68
+ if (installed)
69
+ return installed;
70
+ }
71
+ // Compatibility with the bundled Node layout: <root>/runtime/node.exe beside <root>/app.
72
+ const app = resolve(dirname(deps.execPath ?? process.execPath), '..', 'app');
73
+ const bundled = firstRuntimeRoot(installedAppCandidates(app), exists);
74
+ if (bundled)
75
+ return bundled;
76
+ // Advanced developer override. A bad explicit override is an error; it never falls
77
+ // through to an unrelated working-directory runtime.
78
+ const configured = env.TALOS_CLI_RUNTIME_ROOT?.trim();
79
+ if (configured) {
80
+ const root = resolve(configured);
81
+ if (isTalosRuntimeRoot(root, exists))
82
+ return root;
83
+ throw new Error('TALOS_RUNTIME_ROOT_INVALID');
84
+ }
85
+ // Last-resort source/developer compatibility only. Installed launches have already
86
+ // resolved above, so an arbitrary CWD cannot shadow the shipped runtime.
87
+ const cwd = findAncestorRuntimeRoot(start, exists);
88
+ if (cwd)
89
+ return cwd;
90
+ throw new Error('TALOS_RUNTIME_NOT_FOUND');
91
+ }
92
+ export async function importTalosModule(repoRoot, relativeFromHarnessSrc) {
93
+ const file = join(repoRoot, 'harness-ui', 'src', relativeFromHarnessSrc);
94
+ return import(__rewriteRelativeImportExtension(pathToFileURL(file).href));
95
+ }
@@ -0,0 +1,135 @@
1
+ import { renderPromptWithAttachments, validateCliAttachments } from "./attachments.js";
2
+ import { CliRuntimeError } from "./types.js";
3
+ import { normalizeSessionSummaries } from "./session-summary.js";
4
+ import { buildContextStatus, unavailableContextStatus } from "./context-status.js";
5
+ function registryPermission(mode) { if (mode === 'plan')
6
+ return 'Read only'; if (mode === 'acceptEdits' || mode === 'bypassPermissions')
7
+ return 'Workspace write'; return 'On request'; }
8
+ export function createSessionFacade(registry, { model, origin = 'talos-cli', modelImageCapability, materializeImage }) {
9
+ const cancelled = new Set();
10
+ let restored = false;
11
+ let defaultReasoningEffort = null;
12
+ async function restore() { const x = typeof registry.ripristina === 'function' ? await registry.ripristina() : {}; restored = true; return { restored: Number(x?.ripristinate ?? x?.restored ?? 0), total: Number(x?.totali ?? x?.total ?? 0) }; }
13
+ async function ensure() { if (!restored)
14
+ await restore(); }
15
+ function sessionModel(sessionId) { let rows = []; try {
16
+ rows = typeof registry.elenca === 'function' ? registry.elenca() : [];
17
+ }
18
+ catch {
19
+ rows = [];
20
+ } const row = rows.find(candidate => candidate?.sessionId === sessionId); return typeof row?.modello === 'string' && row.modello.trim() ? row.modello.trim() : null; }
21
+ async function prepare(prompt, runModel, attachments) {
22
+ const rows = validateCliAttachments(attachments);
23
+ if (rows.length && !String(prompt ?? '').trim())
24
+ throw new CliRuntimeError('ATTACHMENT_PROMPT_REQUIRED', 'Attachments require a prompt.');
25
+ const images = rows.filter((row) => row.kind === 'image');
26
+ const stored = [];
27
+ if (images.length) {
28
+ let capability = null;
29
+ try {
30
+ capability = runModel && modelImageCapability ? await modelImageCapability(runModel) : null;
31
+ }
32
+ catch {
33
+ capability = null;
34
+ }
35
+ if (capability !== true)
36
+ throw new CliRuntimeError('MODEL_IMAGE_UNSUPPORTED', 'The selected model does not affirm image input support.', { model: runModel });
37
+ if (!materializeImage)
38
+ throw new CliRuntimeError('IMAGE_ATTACHMENT_UNAVAILABLE', 'Image attachment storage is unavailable.');
39
+ for (const image of images) {
40
+ try {
41
+ stored.push(await materializeImage(image));
42
+ }
43
+ catch (error) {
44
+ if (typeof error?.code === 'string')
45
+ throw error;
46
+ throw new CliRuntimeError('IMAGE_ATTACHMENT_MATERIALIZE_FAILED', 'The image could not be stored safely.');
47
+ }
48
+ }
49
+ }
50
+ return { prompt: renderPromptWithAttachments(String(prompt ?? ''), rows), images: stored };
51
+ }
52
+ async function contextStatus(sessionId) {
53
+ await ensure();
54
+ if (typeof registry.statoContesto !== 'function')
55
+ return unavailableContextStatus(sessionId, 'runtime-unavailable');
56
+ const raw = await registry.statoContesto(sessionId);
57
+ if (raw?.unavailableReason)
58
+ return unavailableContextStatus(sessionId, String(raw.unavailableReason));
59
+ const rows = typeof registry.elenca === 'function' ? [...registry.elenca()] : [];
60
+ const usage = normalizeSessionSummaries(rows).find(row => row.id === sessionId || row.sessionId === sessionId)?.usage ?? null;
61
+ return buildContextStatus({ sessionId, snapshot: raw, sessionUsage: usage });
62
+ }
63
+ async function start(input) { await ensure(); const prepared = await prepare(input.prompt, input.model || model, input.attachments); const reasoningEffort = input.reasoningEffort ?? defaultReasoningEffort; const x = registry.avviaLibero({ cartellaLibera: input.projectRoot, consegna: prepared.prompt, modello: input.model || model, permessi: registryPermission(input.permissionMode), ...(reasoningEffort ? { reasoning: { effort: reasoningEffort } } : {}), ...(prepared.images.length ? { immagini: prepared.images } : {}), ...(input.operationId ? { operationId: input.operationId } : {}) }, { kind: origin }); if (x?.erroreAvvio)
64
+ throw new CliRuntimeError(x.code ?? 'RUNTIME_START_FAILED', x.erroreAvvio); if (typeof x?.sessionId !== 'string')
65
+ throw new CliRuntimeError('RUNTIME_START_FAILED'); cancelled.delete(x.sessionId); return x.sessionId; }
66
+ return { restore, start, setDefaultReasoningEffort(effort) { defaultReasoningEffort = effort; }, async setReasoningEffort(sessionId, effort) { await ensure(); if (typeof registry.aggiornaImpostazioni !== 'function')
67
+ throw new CliRuntimeError('SESSION_SETTINGS_UNAVAILABLE'); const x = await registry.aggiornaImpostazioni(sessionId, { reasoning: { effort } }); if (x?.erroreAvvio)
68
+ throw new CliRuntimeError(x.code ?? 'SESSION_SETTINGS_FAILED', x.erroreAvvio); if (x?.ok !== true)
69
+ throw new CliRuntimeError('SESSION_SETTINGS_FAILED'); }, async resume(sessionId, prompt, attachments) { await ensure(); if (typeof registry.resume !== 'function')
70
+ throw new CliRuntimeError('SESSION_RESUME_UNAVAILABLE'); const prepared = await prepare(prompt, sessionModel(sessionId), attachments); const x = registry.resume(sessionId, prepared.prompt.trim() || null, prepared.images); if (x?.erroreAvvio)
71
+ throw new CliRuntimeError(x.code ?? 'SESSION_RESUME_FAILED', x.erroreAvvio); if (typeof x?.sessionId !== 'string')
72
+ throw new CliRuntimeError('SESSION_RESUME_FAILED'); cancelled.delete(x.sessionId); return x.sessionId; }, async fork(sessionId, prompt, attachments) { await ensure(); if (typeof registry.forka !== 'function')
73
+ throw new CliRuntimeError('SESSION_FORK_UNAVAILABLE'); const prepared = await prepare(prompt, sessionModel(sessionId), attachments); const x = registry.forka(sessionId); if (x?.erroreAvvio)
74
+ throw new CliRuntimeError(x.code ?? 'SESSION_FORK_FAILED', x.erroreAvvio); if (typeof x?.sessionId !== 'string')
75
+ throw new CliRuntimeError('SESSION_FORK_FAILED'); if (prepared.prompt.trim()) {
76
+ if (typeof registry.accodaMessaggio !== 'function')
77
+ throw new CliRuntimeError('SESSION_QUEUE_UNAVAILABLE');
78
+ const q = registry.accodaMessaggio(x.sessionId, prepared.prompt.trim(), prepared.images);
79
+ if (q?.erroreAvvio)
80
+ throw new CliRuntimeError(q.code ?? 'SESSION_QUEUE_FAILED', q.erroreAvvio);
81
+ } return x.sessionId; }, async steer(sessionId, prompt, attachments) { await ensure(); if (typeof registry.reindirizza !== 'function')
82
+ throw new CliRuntimeError('SESSION_STEER_UNAVAILABLE', 'Steering is unavailable for this runtime.'); const text = String(prompt ?? '').trim(); if (!text)
83
+ throw new CliRuntimeError('STEER_TEXT_REQUIRED', 'Steering text is required.'); const prepared = await prepare(text, sessionModel(sessionId), attachments); const x = registry.reindirizza(sessionId, prepared.prompt.trim(), prepared.images.length ? { immagini: prepared.images } : {}); if (x?.erroreAvvio)
84
+ throw new CliRuntimeError(x.code ?? 'SESSION_STEER_REJECTED', x.erroreAvvio); if (x?.ok !== true || typeof x?.redirectId !== 'string' || !x.redirectId)
85
+ throw new CliRuntimeError('SESSION_STEER_REJECTED', 'The runtime did not accept the steering request.'); return { redirectId: x.redirectId }; }, async compact(sessionId) { await ensure(); if (typeof registry.compatta !== 'function')
86
+ throw new CliRuntimeError('SESSION_COMPACT_UNAVAILABLE'); const x = await registry.compatta(sessionId); if (x?.erroreAvvio)
87
+ throw new CliRuntimeError(x.code ?? 'SESSION_COMPACT_FAILED', x.erroreAvvio); return x; }, contextStatus, async listSessions() {
88
+ await ensure();
89
+ const rows = typeof registry.elenca === 'function' ? [...registry.elenca()] : [];
90
+ const evidence = new Map();
91
+ if (typeof registry.elencaFigli === 'function') {
92
+ const parentIds = [...new Set(rows.map((row) => typeof row?.padreId === 'string' && row.padreId.trim() ? row.padreId : null).filter((value) => value !== null))];
93
+ for (const parentId of parentIds) {
94
+ let result = null;
95
+ try {
96
+ result = registry.elencaFigli(parentId);
97
+ }
98
+ catch {
99
+ result = null;
100
+ }
101
+ for (const child of Array.isArray(result?.figli) ? result.figli : []) {
102
+ const childId = typeof child?.sessionId === 'string' ? child.sessionId : null;
103
+ if (!childId)
104
+ continue;
105
+ evidence.set(childId, { ...(evidence.get(childId) ?? {}), child });
106
+ }
107
+ }
108
+ }
109
+ if (typeof registry.elencaProcessi === 'function') {
110
+ for (const row of rows) {
111
+ if (row?.inAttesaApprovazione !== true || typeof row?.sessionId !== 'string')
112
+ continue;
113
+ let result = null;
114
+ try {
115
+ result = registry.elencaProcessi(row.sessionId);
116
+ }
117
+ catch {
118
+ result = null;
119
+ }
120
+ const signal = Array.isArray(result?.guardia?.segnalazioni) ? result.guardia.segnalazioni.find((entry) => entry?.soggetto === 'approvazione') : null;
121
+ const approval = signal ? { requestId: signal.requestId, waitingMs: signal.fermoDaMs } : null;
122
+ if (approval)
123
+ evidence.set(row.sessionId, { ...(evidence.get(row.sessionId) ?? {}), approval });
124
+ }
125
+ }
126
+ return normalizeSessionSummaries(rows, evidence);
127
+ }, subscribe: (id, sink, from = 0) => registry.iscriviti(id, sink, from), async answerApproval(id, rid, approved) { const x = await registry.rispondiApprovazione(id, rid, approved); if (x?.erroreAvvio)
128
+ throw new CliRuntimeError(x.code ?? 'APPROVAL_FAILED', x.erroreAvvio); }, async cancel(id) { if (cancelled.has(id))
129
+ return; cancelled.add(id); const ok = await registry.ferma(id); if (ok === false)
130
+ throw new CliRuntimeError('SESSION_NOT_FOUND'); }, async shell(sessionId, command) { await ensure(); const text = String(command ?? '').trim(); if (!text)
131
+ throw new CliRuntimeError('SHELL_COMMAND_REQUIRED', 'A command is required'); if (typeof registry.shell !== 'function')
132
+ throw new CliRuntimeError('SESSION_SHELL_UNAVAILABLE'); const x = await registry.shell(sessionId, text); if (x?.erroreAvvio)
133
+ throw new CliRuntimeError(x.code ?? 'SESSION_SHELL_FAILED', x.erroreAvvio); if (x?.ok !== true)
134
+ throw new CliRuntimeError('SESSION_SHELL_FAILED'); }, export: (id) => registry.esporta?.(id) ?? null, async close() { await registry.chiudiContesto?.(); } };
135
+ }