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,99 @@
1
+ import { deleteForward, moveCursor, moveVertical, nextGraphemeBoundary, previousGraphemeBoundary, redoEditor, undoEditor } from "./editor.js";
2
+ export function createVimState() { return { enabled: false, mode: 'insert' }; }
3
+ export function toggleVim(state) { return state.enabled ? { enabled: false, mode: 'insert' } : { enabled: true, mode: 'insert' }; }
4
+ export function vimModeHint(state) {
5
+ if (!state.enabled)
6
+ return '';
7
+ return state.mode === 'insert'
8
+ ? 'VIM INSERT · Esc normal · Alt+V off'
9
+ : 'VIM NORMAL · h/j/k/l · b/w · 0/$ · x · u/Ctrl+R · i/a/I/A · Alt+V off';
10
+ }
11
+ function setCursor(state, cursor) {
12
+ const { selectionAnchor: _, preferredColumn: __, ...rest } = state;
13
+ return { ...rest, cursor: Math.max(0, Math.min(state.text.length, cursor)) };
14
+ }
15
+ function isWordAt(state, cursor) {
16
+ if (cursor < 0 || cursor >= state.text.length)
17
+ return false;
18
+ const end = nextGraphemeBoundary(state.text, cursor);
19
+ return /[\p{L}\p{N}_]/u.test(state.text.slice(cursor, end));
20
+ }
21
+ function vimWordForward(state) {
22
+ let cursor = state.cursor;
23
+ if (cursor >= state.text.length)
24
+ return setCursor(state, cursor);
25
+ if (isWordAt(state, cursor))
26
+ while (cursor < state.text.length && isWordAt(state, cursor))
27
+ cursor = nextGraphemeBoundary(state.text, cursor);
28
+ while (cursor < state.text.length && !isWordAt(state, cursor))
29
+ cursor = nextGraphemeBoundary(state.text, cursor);
30
+ return setCursor(state, cursor);
31
+ }
32
+ function vimWordBackward(state) {
33
+ let cursor = state.cursor;
34
+ if (cursor <= 0)
35
+ return setCursor(state, 0);
36
+ cursor = previousGraphemeBoundary(state.text, cursor);
37
+ while (cursor > 0 && !isWordAt(state, cursor))
38
+ cursor = previousGraphemeBoundary(state.text, cursor);
39
+ while (cursor > 0) {
40
+ const previous = previousGraphemeBoundary(state.text, cursor);
41
+ if (!isWordAt(state, previous))
42
+ break;
43
+ cursor = previous;
44
+ }
45
+ return setCursor(state, cursor);
46
+ }
47
+ function result(state, editor, handled) { return { handled, state: { enabled: state.enabled, mode: state.mode }, editor }; }
48
+ function insertMode(state) { return { enabled: state.enabled, mode: 'insert' }; }
49
+ export function handleVimInput(input) {
50
+ const { state, editor, ch, key } = input;
51
+ if (!state.enabled)
52
+ return result(state, editor, false);
53
+ if (state.mode === 'insert') {
54
+ if (key.escape)
55
+ return { handled: true, state: { enabled: true, mode: 'normal' }, editor };
56
+ return result(state, editor, false);
57
+ }
58
+ if (key.escape)
59
+ return result(state, editor, false);
60
+ if (key.ctrl && ch.toLowerCase() === 'c')
61
+ return result(state, editor, false);
62
+ if (key.ctrl && ch.toLowerCase() === 'r')
63
+ return { handled: true, state: { enabled: true, mode: 'normal' }, editor: redoEditor(editor) };
64
+ if (key.ctrl || key.meta)
65
+ return result(state, editor, false);
66
+ if ((ch === '?' || ch === '/') && editor.text.trim().length === 0)
67
+ return result(state, editor, false);
68
+ if (ch === 'i')
69
+ return { handled: true, state: insertMode(state), editor };
70
+ if (ch === 'a')
71
+ return { handled: true, state: insertMode(state), editor: moveCursor(editor, 'right') };
72
+ if (ch === 'I')
73
+ return { handled: true, state: insertMode(state), editor: moveCursor(editor, 'home') };
74
+ if (ch === 'A')
75
+ return { handled: true, state: insertMode(state), editor: moveCursor(editor, 'end') };
76
+ if (ch === 'h')
77
+ return { handled: true, state: { enabled: true, mode: 'normal' }, editor: moveCursor(editor, 'left') };
78
+ if (ch === 'l')
79
+ return { handled: true, state: { enabled: true, mode: 'normal' }, editor: moveCursor(editor, 'right') };
80
+ if (ch === 'j')
81
+ return { handled: true, state: { enabled: true, mode: 'normal' }, editor: moveVertical(editor, 1) };
82
+ if (ch === 'k')
83
+ return { handled: true, state: { enabled: true, mode: 'normal' }, editor: moveVertical(editor, -1) };
84
+ if (ch === 'w')
85
+ return { handled: true, state: { enabled: true, mode: 'normal' }, editor: vimWordForward(editor) };
86
+ if (ch === 'b')
87
+ return { handled: true, state: { enabled: true, mode: 'normal' }, editor: vimWordBackward(editor) };
88
+ if (ch === '0')
89
+ return { handled: true, state: { enabled: true, mode: 'normal' }, editor: moveCursor(editor, 'home') };
90
+ if (ch === '$')
91
+ return { handled: true, state: { enabled: true, mode: 'normal' }, editor: moveCursor(editor, 'end') };
92
+ if (ch === 'x')
93
+ return { handled: true, state: { enabled: true, mode: 'normal' }, editor: deleteForward(editor) };
94
+ if (ch === 'u')
95
+ return { handled: true, state: { enabled: true, mode: 'normal' }, editor: undoEditor(editor) };
96
+ if (ch)
97
+ return result(state, editor, true);
98
+ return result(state, editor, false);
99
+ }
@@ -0,0 +1,15 @@
1
+ import { createHash } from 'node:crypto';
2
+ const V = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/u;
3
+ function cmp(a, b) { const x = V.exec(a), y = V.exec(b); if (!x || !y)
4
+ throw new Error('UPDATE_VERSION_INVALID'); for (let i = 1; i <= 3; i++) {
5
+ const d = Number(x[i]) - Number(y[i]);
6
+ if (d)
7
+ return Math.sign(d);
8
+ } return (x[4] ? 0 : 1) - (y[4] ? 0 : 1); }
9
+ /** The release order the installer check uses, shared with the npm check (update/npm.ts). */
10
+ export function compareReleaseVersions(a, b) { return cmp(a, b); }
11
+ export async function checkRelease({ currentVersion, channel, platform, fetchManifest }) { const m = await fetchManifest(); if (m.schema !== 'talos.cli.release.v1' || m.channel !== channel || !V.test(m.version))
12
+ throw new Error('UPDATE_MANIFEST_INVALID'); const asset = m.assets.find(a => a.platform === platform); return { available: cmp(m.version, currentVersion) > 0, version: m.version, asset: asset ?? null, manifest: m }; }
13
+ export async function verifyDownloadedAsset(bytes, asset) { if (bytes.byteLength !== asset.size)
14
+ throw new Error('UPDATE_SIZE_MISMATCH'); const h = createHash('sha256').update(bytes).digest('hex'); if (h.toLowerCase() !== asset.sha256.toLowerCase())
15
+ throw new Error('UPDATE_CHECKSUM_MISMATCH'); return h; }
@@ -0,0 +1,51 @@
1
+ import { basename, dirname } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { compareReleaseVersions } from "./check.js";
4
+ /*
5
+ * R7 (owner, 2026-09-25): an install made with `npm i -g talos-code` updates with npm. `talos update` asks the npm registry
6
+ * which version is current and says the command to run; it downloads nothing and changes nothing. The Windows installer
7
+ * keeps its own path (GitHub release manifest, verified download).
8
+ *
9
+ * How an npm install is recognised: npm puts the package at `<prefix>/node_modules/talos-code` (global) or
10
+ * `<project>/node_modules/talos-code`, so the folder above the package is `node_modules`. The Windows installer puts it in
11
+ * its own `app` folder, and a checkout runs from `cli/`.
12
+ */
13
+ export const NPM_PACKAGE = 'talos-code';
14
+ export const NPM_DIST_TAGS_URL = `https://registry.npmjs.org/-/package/${NPM_PACKAGE}/dist-tags`;
15
+ const TAG = { stable: 'latest', preview: 'next' };
16
+ /** The package folder of this build: `dist/update/npm.js` or `src/update/npm.ts`, two levels down. */
17
+ export function packageRootOf(moduleUrl = import.meta.url) { return fileURLToPath(new URL('../../', moduleUrl)); }
18
+ export function installedWithNpm(packageRoot = packageRootOf()) {
19
+ const root = packageRoot.replace(/[\\/]+$/u, '');
20
+ return basename(dirname(root)).toLowerCase() === 'node_modules' && basename(root) === NPM_PACKAGE;
21
+ }
22
+ export function npmUpdateCommand(channel) { return `npm i -g ${NPM_PACKAGE}@${TAG[channel]}`; }
23
+ export async function checkNpmRegistry({ currentVersion, channel, fetchFn = fetch, url = NPM_DIST_TAGS_URL, timeoutMs = 15_000 }) {
24
+ const controller = new AbortController();
25
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
26
+ let response;
27
+ try {
28
+ response = await fetchFn(url, { headers: { Accept: 'application/json' }, signal: controller.signal });
29
+ }
30
+ catch (error) {
31
+ if (controller.signal.aborted)
32
+ throw Object.assign(new Error('UPDATE_TIMEOUT'), { code: 'UPDATE_TIMEOUT' });
33
+ throw error;
34
+ }
35
+ finally {
36
+ clearTimeout(timer);
37
+ }
38
+ if (!response.ok)
39
+ throw Object.assign(new Error(`UPDATE_HTTP_${response.status}`), { code: 'UPDATE_HTTP_ERROR', status: response.status });
40
+ let tags;
41
+ try {
42
+ tags = await response.json();
43
+ }
44
+ catch {
45
+ throw Object.assign(new Error('UPDATE_RELEASE_METADATA_INVALID'), { code: 'UPDATE_RELEASE_METADATA_INVALID' });
46
+ }
47
+ const version = tags && typeof tags === 'object' ? tags[TAG[channel]] : undefined;
48
+ if (typeof version !== 'string')
49
+ throw Object.assign(new Error('UPDATE_RELEASE_NOT_FOUND'), { code: 'UPDATE_RELEASE_NOT_FOUND' });
50
+ return { source: 'npm', available: compareReleaseVersions(version, currentVersion) > 0, version, currentVersion, channel, command: npmUpdateCommand(channel) };
51
+ }
@@ -0,0 +1,129 @@
1
+ import { mkdir, rename, writeFile } from 'node:fs/promises';
2
+ import { basename, join } from 'node:path';
3
+ import { checkRelease, verifyDownloadedAsset } from "./check.js";
4
+ const DEFAULT_TIMEOUT_MS = 15_000;
5
+ const DEFAULT_ATTEMPTS = 2;
6
+ const DEFAULT_RETRY_DELAY_MS = 250;
7
+ function httpError(status) {
8
+ return Object.assign(new Error(`UPDATE_HTTP_${status}`), { code: 'UPDATE_HTTP_ERROR', status });
9
+ }
10
+ function timeoutError() {
11
+ return Object.assign(new Error('UPDATE_TIMEOUT'), { code: 'UPDATE_TIMEOUT' });
12
+ }
13
+ function sleep(ms) { return ms > 0 ? new Promise(resolve => setTimeout(resolve, ms)) : Promise.resolve(); }
14
+ function transient(error) {
15
+ if (error?.code === 'UPDATE_TIMEOUT')
16
+ return true;
17
+ if (error?.code === 'UPDATE_HTTP_ERROR')
18
+ return Number(error.status) >= 500;
19
+ return error instanceof TypeError || (typeof error?.code === 'string' && /^(?:EAI_AGAIN|ECONNRESET|ECONNREFUSED|ENETUNREACH|ETIMEDOUT)$/u.test(error.code));
20
+ }
21
+ async function fetchOnce(fetchFn, url, timeoutMs) {
22
+ const controller = new AbortController();
23
+ const timer = setTimeout(() => controller.abort(timeoutError()), timeoutMs);
24
+ try {
25
+ let response;
26
+ try {
27
+ response = await fetchFn(url, { headers: { Accept: 'application/json, application/octet-stream' }, signal: controller.signal });
28
+ }
29
+ catch (error) {
30
+ if (controller.signal.aborted)
31
+ throw timeoutError();
32
+ throw error;
33
+ }
34
+ if (!response.ok)
35
+ throw httpError(response.status);
36
+ return response;
37
+ }
38
+ finally {
39
+ clearTimeout(timer);
40
+ }
41
+ }
42
+ async function checkedResponse(fetchFn, url, { timeoutMs = DEFAULT_TIMEOUT_MS, attempts = DEFAULT_ATTEMPTS, retryDelayMs = DEFAULT_RETRY_DELAY_MS } = {}) {
43
+ if (!Number.isInteger(timeoutMs) || timeoutMs <= 0)
44
+ throw new Error('UPDATE_TIMEOUT_INVALID');
45
+ if (!Number.isInteger(attempts) || attempts <= 0 || attempts > 2)
46
+ throw new Error('UPDATE_ATTEMPTS_INVALID');
47
+ if (!Number.isInteger(retryDelayMs) || retryDelayMs < 0)
48
+ throw new Error('UPDATE_RETRY_DELAY_INVALID');
49
+ let last;
50
+ for (let attempt = 1; attempt <= attempts; attempt++) {
51
+ try {
52
+ return await fetchOnce(fetchFn, url, timeoutMs);
53
+ }
54
+ catch (error) {
55
+ last = error;
56
+ if (attempt >= attempts || !transient(error))
57
+ throw error;
58
+ await sleep(retryDelayMs);
59
+ }
60
+ }
61
+ throw last;
62
+ }
63
+ export async function discoverGitHubReleaseManifest({ channel, fetchFn = fetch, releasesUrl = 'https://api.github.com/repos/Ninozzz95/talos/releases?per_page=30', timeoutMs, retryDelayMs }) {
64
+ const policy = {};
65
+ if (timeoutMs !== undefined)
66
+ policy.timeoutMs = timeoutMs;
67
+ if (retryDelayMs !== undefined)
68
+ policy.retryDelayMs = retryDelayMs;
69
+ const response = await checkedResponse(fetchFn, releasesUrl, policy);
70
+ let releases;
71
+ try {
72
+ releases = await response.json();
73
+ }
74
+ catch {
75
+ throw new Error('UPDATE_RELEASE_METADATA_INVALID');
76
+ }
77
+ if (!Array.isArray(releases))
78
+ throw new Error('UPDATE_RELEASE_METADATA_INVALID');
79
+ const release = releases.find(r => r && r.draft !== true && typeof r.tag_name === 'string' && r.tag_name.startsWith('talos-cli-v') && (channel === 'preview' ? r.prerelease === true : r.prerelease !== true));
80
+ if (!release)
81
+ throw Object.assign(new Error('UPDATE_RELEASE_NOT_FOUND'), { code: 'UPDATE_RELEASE_NOT_FOUND' });
82
+ const asset = release.assets?.find(a => a?.name === 'talos-cli-release.json' && typeof a.browser_download_url === 'string');
83
+ if (!asset?.browser_download_url)
84
+ throw Object.assign(new Error('UPDATE_MANIFEST_ASSET_NOT_FOUND'), { code: 'UPDATE_MANIFEST_ASSET_NOT_FOUND' });
85
+ let url;
86
+ try {
87
+ url = new URL(asset.browser_download_url);
88
+ }
89
+ catch {
90
+ throw new Error('UPDATE_RELEASE_METADATA_INVALID');
91
+ }
92
+ if (url.protocol !== 'https:')
93
+ throw new Error('UPDATE_RELEASE_METADATA_INVALID');
94
+ return url.toString();
95
+ }
96
+ export async function performUpdateCheck({ currentVersion, channel, platform, manifestUrl, fetchFn = fetch, timeoutMs, retryDelayMs }) {
97
+ const policy = {};
98
+ if (timeoutMs !== undefined)
99
+ policy.timeoutMs = timeoutMs;
100
+ if (retryDelayMs !== undefined)
101
+ policy.retryDelayMs = retryDelayMs;
102
+ const response = await checkedResponse(fetchFn, manifestUrl, policy);
103
+ let manifest;
104
+ try {
105
+ manifest = await response.json();
106
+ }
107
+ catch {
108
+ throw new Error('UPDATE_MANIFEST_INVALID');
109
+ }
110
+ return checkRelease({ currentVersion, channel, platform, fetchManifest: async () => manifest });
111
+ }
112
+ export async function downloadVerifiedUpdate({ asset, cacheDir, fetchFn = fetch, timeoutMs, retryDelayMs }) {
113
+ await mkdir(cacheDir, { recursive: true, mode: 0o700 });
114
+ const policy = {};
115
+ if (timeoutMs !== undefined)
116
+ policy.timeoutMs = timeoutMs;
117
+ if (retryDelayMs !== undefined)
118
+ policy.retryDelayMs = retryDelayMs;
119
+ const response = await checkedResponse(fetchFn, asset.url, policy);
120
+ const bytes = Buffer.from(await response.arrayBuffer());
121
+ await verifyDownloadedAsset(bytes, asset);
122
+ const raw = basename(new URL(asset.url).pathname) || 'talos-update.bin';
123
+ const name = raw.replace(/[^A-Za-z0-9._-]/gu, '_');
124
+ const target = join(cacheDir, name);
125
+ const tmp = `${target}.tmp-${process.pid}`;
126
+ await writeFile(tmp, bytes, { mode: 0o600 });
127
+ await rename(tmp, target);
128
+ return target;
129
+ }
@@ -0,0 +1,2 @@
1
+ export const CLI_VERSION = '0.2.0';
2
+ export const TALOS_BASE_COMMIT = '0c432153a288f64237e98403869d02d20d8fabc7';
@@ -0,0 +1,210 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { chmod, mkdir, open, readdir, readFile, realpath, rename, rm } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { resolveWorkspaceIdentity } from "../security/workspace-identity.js";
5
+ import { CHECKPOINT_LIMITS, captureWorkspaceSnapshot, extractWorkspaceWriteEvidence, sameGitSnapshot, sameSnapshotEntry } from "./checkpoint.js";
6
+ function coded(code, message = code) { return Object.assign(new Error(message === code ? code : `${code}: ${message}`), { code }); }
7
+ function validId(id) { if (!/^[0-9]+-[0-9a-f-]{36}$/iu.test(id))
8
+ throw coded('CHECKPOINT_ID_INVALID'); return id; }
9
+ async function durableDir(dirname) { try {
10
+ const h = await open(dirname, 'r');
11
+ try {
12
+ await h.sync();
13
+ }
14
+ finally {
15
+ await h.close();
16
+ }
17
+ }
18
+ catch (error) {
19
+ if (process.platform !== 'win32')
20
+ throw error;
21
+ } }
22
+ async function ensurePrivateDir(dirname) { await mkdir(dirname, { recursive: true, mode: 0o700 }); try {
23
+ await chmod(dirname, 0o700);
24
+ }
25
+ catch (error) {
26
+ if (process.platform !== 'win32')
27
+ throw error;
28
+ } }
29
+ async function atomicWrite(pathname, text) {
30
+ const dirname = path.dirname(pathname);
31
+ await ensurePrivateDir(dirname);
32
+ const temp = path.join(dirname, `.${path.basename(pathname)}.${process.pid}.${randomUUID()}.tmp`);
33
+ try {
34
+ const handle = await open(temp, 'wx', 0o600);
35
+ try {
36
+ await handle.writeFile(text, 'utf8');
37
+ await handle.sync();
38
+ }
39
+ finally {
40
+ await handle.close();
41
+ }
42
+ await rename(temp, pathname);
43
+ try {
44
+ await chmod(pathname, 0o600);
45
+ }
46
+ catch (error) {
47
+ if (process.platform !== 'win32')
48
+ throw error;
49
+ }
50
+ await durableDir(dirname);
51
+ }
52
+ catch (error) {
53
+ await rm(temp, { force: true }).catch(() => { });
54
+ throw error;
55
+ }
56
+ }
57
+ function parseRecord(text, expectedRoot) {
58
+ const value = JSON.parse(text);
59
+ if (value?.schema !== 'talos.cli.checkpoint.v1' || typeof value.id !== 'string' || value.canonicalRoot !== expectedRoot || !['open', 'complete', 'undone'].includes(value.state) || !value.pre)
60
+ throw coded('CHECKPOINT_STORE_INVALID');
61
+ return value;
62
+ }
63
+ function dedupeEvidence(rows) { const byKey = new Map(); for (const row of rows)
64
+ byKey.set(`${row.path}\0${row.beforeHash ?? ''}\0${row.afterHash ?? ''}`, row); return [...byKey.values()]; }
65
+ export function createCheckpointStore({ rootDir, projectRoot, limits = CHECKPOINT_LIMITS }) {
66
+ const absoluteProject = path.resolve(projectRoot);
67
+ const absoluteRoot = path.resolve(rootDir);
68
+ const blobRoot = path.join(absoluteRoot, 'blobs');
69
+ let initialized = null;
70
+ async function init() {
71
+ if (!initialized)
72
+ initialized = (async () => { const workspace = await resolveWorkspaceIdentity({ projectRoot: absoluteProject }); const relation = path.relative(workspace.canonicalRoot, absoluteRoot); if (relation === '' || (!relation.startsWith(`..${path.sep}`) && relation !== '..' && !path.isAbsolute(relation)))
73
+ throw coded('CHECKPOINT_STORE_INSIDE_WORKSPACE'); await ensurePrivateDir(absoluteRoot); const canonicalState = await realpath(absoluteRoot); const stateRelation = path.relative(workspace.canonicalRoot, canonicalState); if (stateRelation === '' || (!stateRelation.startsWith(`..${path.sep}`) && stateRelation !== '..' && !path.isAbsolute(stateRelation)))
74
+ throw coded('CHECKPOINT_STORE_INSIDE_WORKSPACE'); const workspaceDir = path.join(canonicalState, 'workspaces', workspace.identityHash), recordsDir = path.join(workspaceDir, 'records'); await Promise.all([ensurePrivateDir(blobRoot), ensurePrivateDir(workspaceDir), ensurePrivateDir(recordsDir)]); return { workspaceDir, recordsDir, canonicalRoot: workspace.canonicalRoot }; })();
75
+ return initialized;
76
+ }
77
+ async function recordPath(id) { const x = await init(); return path.join(x.recordsDir, `${validId(id)}.json`); }
78
+ async function read(id) { const x = await init(); try {
79
+ return parseRecord(await readFile(await recordPath(id), 'utf8'), x.canonicalRoot);
80
+ }
81
+ catch (error) {
82
+ if (error?.code === 'ENOENT')
83
+ throw coded('CHECKPOINT_NOT_FOUND');
84
+ throw error;
85
+ } }
86
+ async function replace(record) { const x = await init(); if (record.canonicalRoot !== x.canonicalRoot)
87
+ throw coded('CHECKPOINT_WORKSPACE_MISMATCH'); await atomicWrite(await recordPath(record.id), `${JSON.stringify(record)}\n`); }
88
+ async function capture() { const x = await init(); return captureWorkspaceSnapshot({ projectRoot: x.canonicalRoot, blobRoot, limits }); }
89
+ async function list() { const x = await init(); let names = []; try {
90
+ names = await readdir(x.recordsDir);
91
+ }
92
+ catch (error) {
93
+ if (error?.code === 'ENOENT')
94
+ return [];
95
+ throw error;
96
+ } const rows = []; for (const name of names.filter(name => name.endsWith('.json')).sort()) {
97
+ try {
98
+ rows.push(parseRecord(await readFile(path.join(x.recordsDir, name), 'utf8'), x.canonicalRoot));
99
+ }
100
+ catch (error) {
101
+ if (error?.code === 'ENOENT')
102
+ continue;
103
+ throw error;
104
+ }
105
+ } return rows.sort((a, b) => b.createdAt.localeCompare(a.createdAt) || b.id.localeCompare(a.id)); }
106
+ async function begin(input) {
107
+ const pre = await capture();
108
+ const now = new Date().toISOString();
109
+ const record = { schema: 'talos.cli.checkpoint.v1', id: `${Date.now()}-${randomUUID()}`, operation: input.operation, sessionId: input.sessionId ?? null, commandId: null, state: 'open', createdAt: now, finalizedAt: null, workspaceIdentityHash: pre.workspace.identityHash, canonicalRoot: pre.workspace.canonicalRoot, pre, post: null, writeEvidence: [], reversible: true, nonReversibleReason: null, finalizationError: null, transitions: [{ kind: 'created', at: now }] };
110
+ await replace(record);
111
+ let finalized = null;
112
+ return { id: record.id, bindSession(sessionId) { record.sessionId = sessionId; }, bindCommand(commandId) { record.commandId = commandId; }, observe(raw) { record.writeEvidence.push(...extractWorkspaceWriteEvidence(raw)); }, finalize() {
113
+ if (finalized)
114
+ return finalized;
115
+ finalized = (async () => { try {
116
+ const post = await capture();
117
+ const at = new Date().toISOString();
118
+ record.post = post;
119
+ record.state = 'complete';
120
+ record.finalizedAt = at;
121
+ record.writeEvidence = dedupeEvidence(record.writeEvidence);
122
+ record.transitions.push({ kind: 'finalized', at });
123
+ if (!sameGitSnapshot(record.pre.git, post.git)) {
124
+ record.reversible = false;
125
+ record.nonReversibleReason = 'CHECKPOINT_GIT_METADATA_CHANGED';
126
+ }
127
+ await replace(record);
128
+ return record;
129
+ }
130
+ catch (error) {
131
+ record.finalizationError = error instanceof Error ? error.message : String(error);
132
+ await replace(record).catch(() => { });
133
+ throw error;
134
+ } })();
135
+ return finalized;
136
+ } };
137
+ }
138
+ async function latest(state) { return (await list()).find(row => row.state === state) ?? null; }
139
+ async function withRestoreLock(fn) {
140
+ const x = await init();
141
+ const lockPath = path.join(x.workspaceDir, 'restore.lock');
142
+ let handle;
143
+ for (let attempt = 0; attempt < 2; attempt += 1) {
144
+ try {
145
+ handle = await open(lockPath, 'wx', 0o600);
146
+ break;
147
+ }
148
+ catch (error) {
149
+ if (error?.code !== 'EEXIST')
150
+ throw error;
151
+ let stale = false;
152
+ try {
153
+ const owner = Number((await readFile(lockPath, 'utf8')).trim());
154
+ if (Number.isInteger(owner) && owner > 0 && owner !== process.pid) {
155
+ try {
156
+ process.kill(owner, 0);
157
+ }
158
+ catch (probe) {
159
+ if (probe?.code === 'ESRCH')
160
+ stale = true;
161
+ }
162
+ }
163
+ }
164
+ catch { }
165
+ if (stale) {
166
+ await rm(lockPath, { force: true });
167
+ continue;
168
+ }
169
+ throw coded('CHECKPOINT_RESTORE_BUSY');
170
+ }
171
+ }
172
+ if (!handle)
173
+ throw coded('CHECKPOINT_RESTORE_BUSY');
174
+ try {
175
+ await handle.writeFile(`${process.pid}\n`);
176
+ await handle.sync();
177
+ return await fn();
178
+ }
179
+ finally {
180
+ await handle.close().catch(() => { });
181
+ await rm(lockPath, { force: true }).catch(() => { });
182
+ }
183
+ }
184
+ async function transactionPath() { const x = await init(); return path.join(x.workspaceDir, 'restore-transaction.json'); }
185
+ async function readRestoreTransaction() { try {
186
+ const value = JSON.parse(await readFile(await transactionPath(), 'utf8'));
187
+ if (value?.schema !== 'talos.cli.checkpoint-restore.v1')
188
+ throw coded('CHECKPOINT_STORE_INVALID');
189
+ return value;
190
+ }
191
+ catch (error) {
192
+ if (error?.code === 'ENOENT')
193
+ return null;
194
+ throw error;
195
+ } }
196
+ async function writeRestoreTransaction(tx) { await atomicWrite(await transactionPath(), `${JSON.stringify(tx)}\n`); }
197
+ async function clearRestoreTransaction() { await rm(await transactionPath(), { force: true }); }
198
+ return { projectRoot: absoluteProject, rootDir: absoluteRoot, blobRoot, limits, begin, list, show: read, latest, capture, replace, withRestoreLock, readRestoreTransaction, writeRestoreTransaction, clearRestoreTransaction };
199
+ }
200
+ export function checkpointChanges(record) {
201
+ if (!record.post)
202
+ return [];
203
+ const pre = record.pre.entries, post = record.post.entries;
204
+ return [...new Set([...Object.keys(pre), ...Object.keys(post)])].sort()
205
+ .filter(relative => !sameSnapshotEntry(pre[relative], post[relative]))
206
+ .map(relative => ({ path: relative, change: !pre[relative] ? 'added' : !post[relative] ? 'deleted' : 'modified' }));
207
+ }
208
+ export async function sessionCheckpoints(store, sessionId) {
209
+ return (await store.list()).filter(row => row.sessionId === sessionId);
210
+ }