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.
- package/CHANGELOG.md +87 -0
- package/LICENSE +661 -0
- package/README.md +116 -3
- package/THIRD_PARTY_NOTICES.md +40 -0
- package/dist/archive/zip.js +73 -0
- package/dist/args.js +100 -0
- package/dist/automations/history-store.js +34 -0
- package/dist/automations/policy-store.js +43 -0
- package/dist/automations/runner.js +107 -0
- package/dist/automations/schedule.js +85 -0
- package/dist/automations/windows-task.js +53 -0
- package/dist/commands/advanced-cli.js +233 -0
- package/dist/commands/checkpoint-cli.js +45 -0
- package/dist/commands/config-cli.js +107 -0
- package/dist/commands/context.js +17 -0
- package/dist/commands/extensions-cli.js +207 -0
- package/dist/commands/project-cli.js +74 -0
- package/dist/commands/project-commands.js +143 -0
- package/dist/commands/provider-cli.js +244 -0
- package/dist/commands/services-cli.js +248 -0
- package/dist/commands/session-cli.js +171 -0
- package/dist/commands/system-cli.js +405 -0
- package/dist/config/commands.js +60 -0
- package/dist/config/load.js +382 -0
- package/dist/config/migrations.js +48 -0
- package/dist/config/types.js +11 -0
- package/dist/diagnostics/development-log.js +154 -0
- package/dist/diagnostics/doctor.js +104 -0
- package/dist/diagnostics/redact.js +80 -0
- package/dist/diagnostics/zip.js +52 -0
- package/dist/errors.js +156 -0
- package/dist/events/bridge.js +130 -0
- package/dist/extensions/installer.js +178 -0
- package/dist/extensions/package-schema.js +24 -0
- package/dist/headless/result.js +84 -0
- package/dist/headless/run.js +230 -0
- package/dist/i18n/en/approval.js +46 -0
- package/dist/i18n/en/common.js +9 -0
- package/dist/i18n/en/credentials.js +92 -0
- package/dist/i18n/en/errors.js +267 -0
- package/dist/i18n/en/firstrun.js +101 -0
- package/dist/i18n/en/providers.js +37 -0
- package/dist/i18n/en/screen.js +774 -0
- package/dist/i18n/en/tools.js +127 -0
- package/dist/i18n/en.js +14 -0
- package/dist/i18n/error-view.js +307 -0
- package/dist/i18n/index.js +19 -0
- package/dist/i18n/kernel-map.js +139 -0
- package/dist/io.js +45 -0
- package/dist/main.js +331 -0
- package/dist/paths.js +41 -0
- package/dist/protocol/v2/codec.js +9 -0
- package/dist/protocol/v2/events.js +555 -0
- package/dist/protocol/v2/index.js +4 -0
- package/dist/protocol/v2/replay.js +28 -0
- package/dist/protocol/v2/types.js +1 -0
- package/dist/provider/control-plane.js +135 -0
- package/dist/provider/environment-keys.js +275 -0
- package/dist/provider/health.js +110 -0
- package/dist/provider/missing-key.js +48 -0
- package/dist/provider/model-catalog.js +168 -0
- package/dist/provider/openrouter-login.js +172 -0
- package/dist/provider/provider-text.js +13 -0
- package/dist/provider/store.js +95 -0
- package/dist/provider/system-keyring.js +214 -0
- package/dist/runtime/active-run.js +63 -0
- package/dist/runtime/agent-tree.js +74 -0
- package/dist/runtime/attachments.js +84 -0
- package/dist/runtime/brokered-executor.js +395 -0
- package/dist/runtime/context-archive.js +69 -0
- package/dist/runtime/context-status.js +76 -0
- package/dist/runtime/create-runtime.js +111 -0
- package/dist/runtime/model-profile.js +361 -0
- package/dist/runtime/output-store.js +137 -0
- package/dist/runtime/provider-attempts.js +185 -0
- package/dist/runtime/replay-buffer.js +153 -0
- package/dist/runtime/repo.js +95 -0
- package/dist/runtime/session-facade.js +135 -0
- package/dist/runtime/session-summary.js +125 -0
- package/dist/runtime/supervisor.js +265 -0
- package/dist/runtime/talos-composition.js +1011 -0
- package/dist/runtime/types.js +5 -0
- package/dist/runtime/usage-snapshot.js +82 -0
- package/dist/security/auto-classifier.js +38 -0
- package/dist/security/credential-free-environment.js +54 -0
- package/dist/security/evaluate.js +243 -0
- package/dist/security/execution-backends.js +236 -0
- package/dist/security/execution-broker.js +102 -0
- package/dist/security/forge-scan.js +74 -0
- package/dist/security/from-approval.js +39 -0
- package/dist/security/mxc-execution-backend.js +281 -0
- package/dist/security/permission-engine.js +138 -0
- package/dist/security/permission-explanation.js +54 -0
- package/dist/security/persist.js +179 -0
- package/dist/security/plugin-guard.js +230 -0
- package/dist/security/process-tree-evidence-store.js +74 -0
- package/dist/security/process-tree-probe.js +554 -0
- package/dist/security/project-resource-inventory.js +186 -0
- package/dist/security/project-trust-gate.js +38 -0
- package/dist/security/project-trust.js +367 -0
- package/dist/security/rule-parser.js +201 -0
- package/dist/security/shell-segmentation.js +68 -0
- package/dist/security/trust-authority.js +324 -0
- package/dist/security/types.js +1 -0
- package/dist/security/workspace-identity.js +102 -0
- package/dist/services/automation-facade.js +59 -0
- package/dist/services/forge-facade.js +77 -0
- package/dist/services/hook-facade.js +240 -0
- package/dist/services/index.js +16 -0
- package/dist/services/library-facade.js +174 -0
- package/dist/services/mcp-facade.js +348 -0
- package/dist/services/memory-facade.js +126 -0
- package/dist/services/notes-facade.js +157 -0
- package/dist/services/plugin-facade.js +308 -0
- package/dist/services/research-facade.js +110 -0
- package/dist/services/task-board-facade.js +236 -0
- package/dist/services/workflow-catalog.js +246 -0
- package/dist/sessions/export-format.js +98 -0
- package/dist/sessions/metadata-store.js +160 -0
- package/dist/sessions/share.js +122 -0
- package/dist/sessions/transfer.js +16 -0
- package/dist/subcommands.js +62 -0
- package/dist/tui/agent-roster.js +36 -0
- package/dist/tui/agent-view.js +51 -0
- package/dist/tui/app.js +4098 -0
- package/dist/tui/approval.js +36 -0
- package/dist/tui/boot/boot-sequence.js +76 -0
- package/dist/tui/boot/cinematic.js +243 -0
- package/dist/tui/boot/desktop-logo.js +82 -0
- package/dist/tui/boot.js +3 -0
- package/dist/tui/busy-input.js +58 -0
- package/dist/tui/catalog-service.js +560 -0
- package/dist/tui/components/assistant-stream.js +1 -0
- package/dist/tui/components/command-menu.js +68 -0
- package/dist/tui/components/composer.js +219 -0
- package/dist/tui/components/diff.js +35 -0
- package/dist/tui/components/footer.js +48 -0
- package/dist/tui/components/header.js +6 -0
- package/dist/tui/components/markdown.js +305 -0
- package/dist/tui/components/status-indicator.js +38 -0
- package/dist/tui/components/terminal-shell.js +214 -0
- package/dist/tui/components/thinking-row.js +19 -0
- package/dist/tui/components/tool-row.js +97 -0
- package/dist/tui/components/transcript-virtualizer.js +165 -0
- package/dist/tui/components/transcript.js +43 -0
- package/dist/tui/descendant-approvals.js +104 -0
- package/dist/tui/diff-model.js +77 -0
- package/dist/tui/editor-history.js +21 -0
- package/dist/tui/editor.js +210 -0
- package/dist/tui/event-adapter.js +436 -0
- package/dist/tui/exit-output.js +58 -0
- package/dist/tui/external-editor.js +53 -0
- package/dist/tui/file-completion.js +89 -0
- package/dist/tui/focus-manager.js +5 -0
- package/dist/tui/highlight.js +30 -0
- package/dist/tui/input-router.js +18 -0
- package/dist/tui/interrupt.js +99 -0
- package/dist/tui/keybindings.js +194 -0
- package/dist/tui/keymap-resolver.js +91 -0
- package/dist/tui/launch-state.js +148 -0
- package/dist/tui/line-diff.js +57 -0
- package/dist/tui/live-activity.js +56 -0
- package/dist/tui/metrics.js +123 -0
- package/dist/tui/onboarding.js +36 -0
- package/dist/tui/overlays/agent-tree.js +43 -0
- package/dist/tui/overlays/approval-dialog.js +642 -0
- package/dist/tui/overlays/automation-center.js +51 -0
- package/dist/tui/overlays/checkpoint-picker.js +47 -0
- package/dist/tui/overlays/context-inspector.js +36 -0
- package/dist/tui/overlays/effort-line.js +110 -0
- package/dist/tui/overlays/forge-center.js +46 -0
- package/dist/tui/overlays/help-dialog.js +16 -0
- package/dist/tui/overlays/history-picker.js +37 -0
- package/dist/tui/overlays/hook-center.js +70 -0
- package/dist/tui/overlays/library-center.js +55 -0
- package/dist/tui/overlays/mcp-center.js +60 -0
- package/dist/tui/overlays/memory-center.js +63 -0
- package/dist/tui/overlays/model-picker.js +77 -0
- package/dist/tui/overlays/notes-center.js +53 -0
- package/dist/tui/overlays/overlay-host.js +8 -0
- package/dist/tui/overlays/plugin-center.js +76 -0
- package/dist/tui/overlays/provider-picker.js +171 -0
- package/dist/tui/overlays/queue-editor.js +32 -0
- package/dist/tui/overlays/research-center.js +59 -0
- package/dist/tui/overlays/scroll-window.js +234 -0
- package/dist/tui/overlays/session-picker.js +115 -0
- package/dist/tui/overlays/tasks-center.js +83 -0
- package/dist/tui/overlays/theme-picker.js +21 -0
- package/dist/tui/overlays/transcript-search.js +58 -0
- package/dist/tui/overlays/trust-center.js +29 -0
- package/dist/tui/overlays/workflow-center.js +46 -0
- package/dist/tui/project-file-index.js +214 -0
- package/dist/tui/project-references.js +85 -0
- package/dist/tui/project-trust-prompt.js +289 -0
- package/dist/tui/prompt-history-store.js +116 -0
- package/dist/tui/queue-store.js +110 -0
- package/dist/tui/regions/budget.js +59 -0
- package/dist/tui/regions/views.js +96 -0
- package/dist/tui/render-coordinator.js +148 -0
- package/dist/tui/render-scheduler.js +4 -0
- package/dist/tui/run.js +69 -0
- package/dist/tui/selection-list.js +29 -0
- package/dist/tui/session-controller.js +791 -0
- package/dist/tui/session-export.js +54 -0
- package/dist/tui/setup-wizard.js +46 -0
- package/dist/tui/shell-input.js +35 -0
- package/dist/tui/shell-layout.js +48 -0
- package/dist/tui/shell-model.js +98 -0
- package/dist/tui/slash-commands.js +82 -0
- package/dist/tui/state.js +151 -0
- package/dist/tui/status-bar.js +125 -0
- package/dist/tui/status-view.js +40 -0
- package/dist/tui/terminal-capabilities.js +9 -0
- package/dist/tui/terminal-session.js +11 -0
- package/dist/tui/text-width.js +66 -0
- package/dist/tui/theme-catalog.js +27 -0
- package/dist/tui/theme-store.js +23 -0
- package/dist/tui/theme.js +23 -0
- package/dist/tui/tool-display.js +135 -0
- package/dist/tui/tool-facts.js +1 -0
- package/dist/tui/tools/bash-renderer.js +32 -0
- package/dist/tui/tools/change.js +61 -0
- package/dist/tui/tools/edit-renderer.js +17 -0
- package/dist/tui/tools/generic-renderer.js +13 -0
- package/dist/tui/tools/list-renderer.js +14 -0
- package/dist/tui/tools/read-renderer.js +13 -0
- package/dist/tui/tools/registry.js +20 -0
- package/dist/tui/tools/row-format.js +187 -0
- package/dist/tui/tools/search-renderer.js +38 -0
- package/dist/tui/tools/shared.js +97 -0
- package/dist/tui/tools/write-renderer.js +15 -0
- package/dist/tui/transcript-model.js +441 -0
- package/dist/tui/ui-preferences.js +79 -0
- package/dist/tui/usage-view.js +77 -0
- package/dist/tui/vim-mode.js +99 -0
- package/dist/update/check.js +15 -0
- package/dist/update/npm.js +51 -0
- package/dist/update/run.js +129 -0
- package/dist/version.js +2 -0
- package/dist/workspace/checkpoint-store.js +210 -0
- package/dist/workspace/checkpoint.js +413 -0
- package/dist/workspace/restore.js +232 -0
- package/package.json +64 -5
- package/vendor/context-engine/package.json +11 -0
- package/vendor/context-engine/src/compaction-planner.mjs +57 -0
- package/vendor/context-engine/src/contracts.mjs +48 -0
- package/vendor/context-engine/src/engine.mjs +445 -0
- package/vendor/context-engine/src/node/context-export.mjs +164 -0
- package/vendor/context-engine/src/node/legacy-import.mjs +92 -0
- package/vendor/context-engine/src/node/migrations/001-context.sql +126 -0
- package/vendor/context-engine/src/node/sqlite-store.mjs +85 -0
- package/vendor/context-engine/src/node/sqlite-worker.mjs +559 -0
- package/vendor/context-engine/src/profiles.mjs +10 -0
- package/vendor/context-engine/src/retrieval.mjs +104 -0
- package/vendor/context-engine/src/summary.mjs +97 -0
- package/vendor/context-engine/src/usage.mjs +34 -0
- package/vendor/harness-ui/package.json +38 -0
- package/vendor/harness-ui/src/acp-agent.mjs +350 -0
- package/vendor/harness-ui/src/agent-service.mjs +2188 -0
- package/vendor/harness-ui/src/agui-events.mjs +452 -0
- package/vendor/harness-ui/src/ambiente-solo-server.mjs +121 -0
- package/vendor/harness-ui/src/artifact-store.mjs +39 -0
- package/vendor/harness-ui/src/assistenza.mjs +123 -0
- package/vendor/harness-ui/src/automation-scheduler.mjs +69 -0
- package/vendor/harness-ui/src/automation-store.mjs +145 -0
- package/vendor/harness-ui/src/browser-annota.mjs +639 -0
- package/vendor/harness-ui/src/browser-frame.mjs +211 -0
- package/vendor/harness-ui/src/browser-proxy-universale.mjs +519 -0
- package/vendor/harness-ui/src/browser-proxy.mjs +87 -0
- package/vendor/harness-ui/src/browser-sessione-viva.mjs +329 -0
- package/vendor/harness-ui/src/browser-stream.mjs +445 -0
- package/vendor/harness-ui/src/browser-vivo.mjs +694 -0
- package/vendor/harness-ui/src/chat-image-attachments.mjs +72 -0
- package/vendor/harness-ui/src/config.mjs +697 -0
- package/vendor/harness-ui/src/contesto-del-progetto.mjs +385 -0
- package/vendor/harness-ui/src/context-asset-adapter.mjs +72 -0
- package/vendor/harness-ui/src/context-desktop-service.mjs +253 -0
- package/vendor/harness-ui/src/context-embedding-runtime.mjs +252 -0
- package/vendor/harness-ui/src/context-inference-scheduler.mjs +81 -0
- package/vendor/harness-ui/src/context-native-compaction.mjs +75 -0
- package/vendor/harness-ui/src/context-provider-adapter.mjs +141 -0
- package/vendor/harness-ui/src/context-runtime.mjs +118 -0
- package/vendor/harness-ui/src/context-token-counters.mjs +184 -0
- package/vendor/harness-ui/src/context-tool-catalog.mjs +86 -0
- package/vendor/harness-ui/src/context-tool-output.mjs +72 -0
- package/vendor/harness-ui/src/costo-elenco.mjs +252 -0
- package/vendor/harness-ui/src/custom-task.mjs +171 -0
- package/vendor/harness-ui/src/doctor.mjs +142 -0
- package/vendor/harness-ui/src/document-filename.mjs +97 -0
- package/vendor/harness-ui/src/document-generator.mjs +493 -0
- package/vendor/harness-ui/src/document-report.mjs +331 -0
- package/vendor/harness-ui/src/duckduckgo-search.mjs +155 -0
- package/vendor/harness-ui/src/elenco-profondo.mjs +337 -0
- package/vendor/harness-ui/src/favicon-proxy.mjs +113 -0
- package/vendor/harness-ui/src/forge-contract.mjs +221 -0
- package/vendor/harness-ui/src/frequent-dirs.mjs +134 -0
- package/vendor/harness-ui/src/generated-image-store.mjs +147 -0
- package/vendor/harness-ui/src/generation-idle.mjs +332 -0
- package/vendor/harness-ui/src/gguf-header.mjs +207 -0
- package/vendor/harness-ui/src/git-service.mjs +626 -0
- package/vendor/harness-ui/src/gitignore-elenco.mjs +604 -0
- package/vendor/harness-ui/src/harness-receipt-keypair.mjs +207 -0
- package/vendor/harness-ui/src/hf-direct-transfer.mjs +170 -0
- package/vendor/harness-ui/src/hf-hub-client.mjs +106 -0
- package/vendor/harness-ui/src/hf-image-proxy.mjs +105 -0
- package/vendor/harness-ui/src/hf-model-transfer.mjs +245 -0
- package/vendor/harness-ui/src/hook-registry.mjs +186 -0
- package/vendor/harness-ui/src/http-app.mjs +6259 -0
- package/vendor/harness-ui/src/http-lifecycle.mjs +132 -0
- package/vendor/harness-ui/src/id-archivio.mjs +27 -0
- package/vendor/harness-ui/src/image-generator.mjs +143 -0
- package/vendor/harness-ui/src/istruzioni-di-progetto.mjs +234 -0
- package/vendor/harness-ui/src/kernel/dist/kernelPerIlBanco.js +518 -0
- package/vendor/harness-ui/src/kernel/talosHarness.mjs +10437 -0
- package/vendor/harness-ui/src/library-policy-store.mjs +175 -0
- package/vendor/harness-ui/src/library-store.mjs +652 -0
- package/vendor/harness-ui/src/llama-server-supervisor.mjs +629 -0
- package/vendor/harness-ui/src/local-model-store.mjs +339 -0
- package/vendor/harness-ui/src/local-runtime-contract.mjs +66 -0
- package/vendor/harness-ui/src/local-runtime-events.mjs +44 -0
- package/vendor/harness-ui/src/local-runtime-llama-server.mjs +244 -0
- package/vendor/harness-ui/src/local-runtime-probe.mjs +401 -0
- package/vendor/harness-ui/src/machine-capacity.mjs +66 -0
- package/vendor/harness-ui/src/mappa-cartelle.mjs +491 -0
- package/vendor/harness-ui/src/mcp-client.mjs +98 -0
- package/vendor/harness-ui/src/mcp-registry.mjs +157 -0
- package/vendor/harness-ui/src/mcp-session.mjs +177 -0
- package/vendor/harness-ui/src/memory-store.mjs +227 -0
- package/vendor/harness-ui/src/model-catalog-models-dev.mjs +276 -0
- package/vendor/harness-ui/src/model-catalog.mjs +129 -0
- package/vendor/harness-ui/src/model-destination.mjs +189 -0
- package/vendor/harness-ui/src/modifica-ancorata.mjs +177 -0
- package/vendor/harness-ui/src/native-provider-adapter.mjs +205 -0
- package/vendor/harness-ui/src/notes-store.mjs +250 -0
- package/vendor/harness-ui/src/openai-compatible-runtime.mjs +428 -0
- package/vendor/harness-ui/src/openrouter-oauth.mjs +339 -0
- package/vendor/harness-ui/src/path-policy.mjs +442 -0
- package/vendor/harness-ui/src/plugin-registry.mjs +780 -0
- package/vendor/harness-ui/src/plugin-session.mjs +180 -0
- package/vendor/harness-ui/src/process-policy.mjs +345 -0
- package/vendor/harness-ui/src/prompt-enhancer-provider.mjs +94 -0
- package/vendor/harness-ui/src/provider-auth-cloud.mjs +95 -0
- package/vendor/harness-ui/src/provider-credential-store.mjs +541 -0
- package/vendor/harness-ui/src/provider-probe.mjs +582 -0
- package/vendor/harness-ui/src/provider-registry.mjs +1633 -0
- package/vendor/harness-ui/src/pty-terminal.mjs +312 -0
- package/vendor/harness-ui/src/public-problem.mjs +109 -0
- package/vendor/harness-ui/src/research/card.mjs +235 -0
- package/vendor/harness-ui/src/research/citations.mjs +142 -0
- package/vendor/harness-ui/src/research/collector.mjs +275 -0
- package/vendor/harness-ui/src/research/deposito-a-pezzi.mjs +139 -0
- package/vendor/harness-ui/src/research/dossier.mjs +114 -0
- package/vendor/harness-ui/src/research/esportazioni.mjs +560 -0
- package/vendor/harness-ui/src/research/fetch-cache.mjs +465 -0
- package/vendor/harness-ui/src/research/fidelity.mjs +122 -0
- package/vendor/harness-ui/src/research/independence.mjs +159 -0
- package/vendor/harness-ui/src/research/ledger.mjs +166 -0
- package/vendor/harness-ui/src/research/markdown-server.mjs +565 -0
- package/vendor/harness-ui/src/research/narration.mjs +181 -0
- package/vendor/harness-ui/src/research/open-cards.mjs +131 -0
- package/vendor/harness-ui/src/research/opposing.mjs +305 -0
- package/vendor/harness-ui/src/research/outline.mjs +111 -0
- package/vendor/harness-ui/src/research/page-budget.mjs +209 -0
- package/vendor/harness-ui/src/research/pdf.mjs +291 -0
- package/vendor/harness-ui/src/research/plan.mjs +301 -0
- package/vendor/harness-ui/src/research/raccolta-viva.mjs +452 -0
- package/vendor/harness-ui/src/research/recheck-document.mjs +69 -0
- package/vendor/harness-ui/src/research/recheck-history.mjs +192 -0
- package/vendor/harness-ui/src/research/recheck.mjs +194 -0
- package/vendor/harness-ui/src/research/report.mjs +203 -0
- package/vendor/harness-ui/src/research/run.mjs +527 -0
- package/vendor/harness-ui/src/research/synthesis.mjs +318 -0
- package/vendor/harness-ui/src/research/verification.mjs +572 -0
- package/vendor/harness-ui/src/research-orchestrator.mjs +2679 -0
- package/vendor/harness-ui/src/research-store.mjs +1133 -0
- package/vendor/harness-ui/src/runtime-build-manifest.mjs +26 -0
- package/vendor/harness-ui/src/runtime-contract.mjs +59 -0
- package/vendor/harness-ui/src/runtime-owner-adapter.mjs +1348 -0
- package/vendor/harness-ui/src/runtime-owner-contract.mjs +32 -0
- package/vendor/harness-ui/src/scheda-di-lavoro.mjs +249 -0
- package/vendor/harness-ui/src/search-source-store.mjs +172 -0
- package/vendor/harness-ui/src/session-registry.mjs +6095 -0
- package/vendor/harness-ui/src/session-store.mjs +220 -0
- package/vendor/harness-ui/src/sessione-pronta.mjs +73 -0
- package/vendor/harness-ui/src/setup-stato.mjs +31 -0
- package/vendor/harness-ui/src/sezioni-istruzioni.mjs +204 -0
- package/vendor/harness-ui/src/skill-registry.mjs +120 -0
- package/vendor/harness-ui/src/sse-replay-coalescente.mjs +0 -0
- package/vendor/harness-ui/src/static-files.mjs +96 -0
- package/vendor/harness-ui/src/stream-partition.mjs +123 -0
- package/vendor/harness-ui/src/subagent-orchestrator.mjs +453 -0
- package/vendor/harness-ui/src/task-catalog.mjs +65 -0
- package/vendor/harness-ui/src/tasks-store.mjs +220 -0
- package/vendor/harness-ui/src/terminal-registry.mjs +312 -0
- package/vendor/harness-ui/src/terminal-ws.mjs +170 -0
- package/vendor/harness-ui/src/tool-forge-store.mjs +299 -0
- package/vendor/harness-ui/src/tool-schema-normalize.mjs +100 -0
- package/vendor/harness-ui/src/usage-cache.mjs +315 -0
- package/vendor/harness-ui/src/workspace-browser.mjs +213 -0
- package/vendor/harness-ui/src/workspace-context.mjs +124 -0
- package/vendor/harness-ui/src/workspace-disk.mjs +62 -0
- package/vendor/harness-ui/src/workspace-files.mjs +589 -0
- package/vendor/harness-ui/src/workspace-info.mjs +189 -0
- package/vendor/harness-ui/src/workspace-launch-store.mjs +150 -0
- package/vendor/harness-ui/src/workspace-tree.mjs +67 -0
- package/vendor/harness-ui/src/workspace-watcher.mjs +161 -0
- package/vendor/manifest.json +170 -0
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
import { createRedactor } from "../../diagnostics/redact.js";
|
|
2
|
+
import { safeTalosFailure } from "../../errors.js";
|
|
3
|
+
import { describeError } from "../../i18n/error-view.js";
|
|
4
|
+
import { parseToolOutputMarker, parseToolResultCut } from "../../runtime/output-store.js";
|
|
5
|
+
import { CLI_EVENT } from "../../runtime/provider-attempts.js";
|
|
6
|
+
import { toolDisplay } from "../../tui/tool-display.js";
|
|
7
|
+
// Gate E11 (2026-09-23): a key is secret by exact normalized name or by a whole secret word, never by
|
|
8
|
+
// substring, so usage counters such as prompt_tokens survive. Counters are allowed first; secret values
|
|
9
|
+
// are masked in place (the key stays, as in diagnostics/redact.ts), never dropped. v1 bridge.ts is frozen.
|
|
10
|
+
const USAGE_COUNTER_KEYS = new Set([
|
|
11
|
+
'prompt_tokens', 'completion_tokens', 'total_tokens', 'cached_tokens', 'reasoning_tokens', 'token_count',
|
|
12
|
+
'input_tokens', 'output_tokens', 'cache_read_input_tokens', 'cache_creation_input_tokens',
|
|
13
|
+
'promptTokens', 'completionTokens', 'totalTokens', 'inputTokens', 'outputTokens', 'reasoningTokens'
|
|
14
|
+
]);
|
|
15
|
+
const OTEL_USAGE_COUNTER = /^gen_ai\.usage\.[a-z0-9_.]+_tokens$/u;
|
|
16
|
+
const SECRET_KEYS = new Set([
|
|
17
|
+
'authorization', 'proxyauthorization', 'apikey', 'xapikey', 'accesstoken', 'refreshtoken', 'idtoken',
|
|
18
|
+
'clientsecret', 'password', 'passwd', 'secret', 'token'
|
|
19
|
+
]);
|
|
20
|
+
const SECRET_WORDS = new Set(['authorization', 'apikey', 'apikeys', 'password', 'passwords', 'passwd', 'secret', 'secrets', 'token']);
|
|
21
|
+
function usageCounter(key, value) {
|
|
22
|
+
return typeof value === 'number' && Number.isFinite(value) && (USAGE_COUNTER_KEYS.has(key) || OTEL_USAGE_COUNTER.test(key));
|
|
23
|
+
}
|
|
24
|
+
function secretKey(key) {
|
|
25
|
+
if (SECRET_KEYS.has(key.toLowerCase().replace(/[^a-z0-9]/gu, '')))
|
|
26
|
+
return true;
|
|
27
|
+
const words = key.replace(/([a-z0-9])([A-Z])/gu, '$1 $2').toLowerCase().split(/[^a-z0-9]+/u).filter(Boolean);
|
|
28
|
+
return words.some((word, index) => SECRET_WORDS.has(word) || (word === 'api' && (words[index + 1] === 'key' || words[index + 1] === 'keys')));
|
|
29
|
+
}
|
|
30
|
+
const MASK = /^\[REDACTED(?::\d+)?\]$/u;
|
|
31
|
+
function masked(value) {
|
|
32
|
+
if (typeof value === 'string' && MASK.test(value))
|
|
33
|
+
return value; // withoutMeta() cleans an already clean event
|
|
34
|
+
return typeof value === 'string' ? `[REDACTED:${Buffer.byteLength(value, 'utf8')}]` : '[REDACTED]';
|
|
35
|
+
}
|
|
36
|
+
const FAILED_RECEIPT_STATUSES = new Set(['denied', 'premise_absent', 'failed', 'refused_busy']);
|
|
37
|
+
const TOOL_RECEIPT_KEYS = new Set(['status', 'consentito', 'allowed', 'via', 'motivo', 'reason', 'risk', 'evidence']);
|
|
38
|
+
const ENFORCEMENT_KEYS = new Set([
|
|
39
|
+
'exitCode', 'requestedEnforcement', 'appliedEnforcement', 'sandboxEnforcement', 'backend', 'appContainer',
|
|
40
|
+
'filesystem', 'network', 'processTree', 'processTreeEvidence', 'sandboxSpecVersion'
|
|
41
|
+
]);
|
|
42
|
+
const TOOL_TOP_LEVEL_KEYS = new Set(['type', '_sequenza', 'toolCallId', 'content', 'receipt', 'outcome', 'isError']);
|
|
43
|
+
function objectValue(value) {
|
|
44
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : null;
|
|
45
|
+
}
|
|
46
|
+
function stringValue(value) { return typeof value === 'string' && value.length > 0 ? value : null; }
|
|
47
|
+
function numberValue(value) { return typeof value === 'number' && Number.isFinite(value) ? value : null; }
|
|
48
|
+
function booleanValue(value) { return typeof value === 'boolean' ? value : null; }
|
|
49
|
+
function detailsOutside(source, known) {
|
|
50
|
+
if (!source)
|
|
51
|
+
return undefined;
|
|
52
|
+
const details = Object.fromEntries(Object.entries(source).filter(([key]) => !known.has(key)));
|
|
53
|
+
return Object.keys(details).length ? details : undefined;
|
|
54
|
+
}
|
|
55
|
+
function clean(value, redactText) {
|
|
56
|
+
if (Array.isArray(value))
|
|
57
|
+
return value.map(item => clean(item, redactText));
|
|
58
|
+
if (value && typeof value === 'object') {
|
|
59
|
+
const out = {};
|
|
60
|
+
for (const [key, item] of Object.entries(value)) {
|
|
61
|
+
if (usageCounter(key, item))
|
|
62
|
+
out[key] = item;
|
|
63
|
+
else if (secretKey(key))
|
|
64
|
+
out[key] = masked(item);
|
|
65
|
+
else
|
|
66
|
+
out[key] = clean(item, redactText);
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
return typeof value === 'string' ? redactText(value) : value;
|
|
71
|
+
}
|
|
72
|
+
function nativeSequence(value) {
|
|
73
|
+
if (typeof value === 'number' && Number.isSafeInteger(value) && value >= 0)
|
|
74
|
+
return value;
|
|
75
|
+
if (typeof value === 'string' && /^\d+$/u.test(value)) {
|
|
76
|
+
const parsed = Number(value);
|
|
77
|
+
if (Number.isSafeInteger(parsed))
|
|
78
|
+
return parsed;
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
function cursorFor(sessionId, sequence) {
|
|
83
|
+
return sequence === null ? null : { sessionId, sequence };
|
|
84
|
+
}
|
|
85
|
+
function eventIdFor(sessionId, sequence, synthetic) {
|
|
86
|
+
const identity = encodeURIComponent(sessionId || 'none');
|
|
87
|
+
return sequence === null ? 'talos:' + identity + ':transient:' + synthetic : 'talos:' + identity + ':native:' + sequence;
|
|
88
|
+
}
|
|
89
|
+
function baseEvent(input) {
|
|
90
|
+
return {
|
|
91
|
+
schema: 'talos.cli.event.v2',
|
|
92
|
+
version: 2,
|
|
93
|
+
sessionId: input.sessionId,
|
|
94
|
+
eventId: eventIdFor(input.sessionId, input.sequence, input.synthetic),
|
|
95
|
+
cursor: cursorFor(input.sessionId, input.sequence),
|
|
96
|
+
ts: input.clock(),
|
|
97
|
+
durability: input.durability,
|
|
98
|
+
type: input.type,
|
|
99
|
+
data: input.data,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function toolStatus(raw, receiptStatus) {
|
|
103
|
+
if (raw.outcome === 'cancelled')
|
|
104
|
+
return 'cancelled';
|
|
105
|
+
if (receiptStatus === 'effect_unknown')
|
|
106
|
+
return 'unknown';
|
|
107
|
+
if (receiptStatus === 'succeeded')
|
|
108
|
+
return 'completed';
|
|
109
|
+
if (receiptStatus && FAILED_RECEIPT_STATUSES.has(receiptStatus))
|
|
110
|
+
return 'failed';
|
|
111
|
+
if (raw.isError === true)
|
|
112
|
+
return 'failed';
|
|
113
|
+
return 'completed';
|
|
114
|
+
}
|
|
115
|
+
function enforcementFrom(receipt) {
|
|
116
|
+
const evidence = objectValue(receipt?.evidence);
|
|
117
|
+
if (!evidence)
|
|
118
|
+
return null;
|
|
119
|
+
const extra = detailsOutside(evidence, ENFORCEMENT_KEYS);
|
|
120
|
+
return {
|
|
121
|
+
exitCode: numberValue(evidence.exitCode),
|
|
122
|
+
requested: stringValue(evidence.requestedEnforcement),
|
|
123
|
+
applied: stringValue(evidence.appliedEnforcement),
|
|
124
|
+
sandbox: stringValue(evidence.sandboxEnforcement),
|
|
125
|
+
backend: stringValue(evidence.backend),
|
|
126
|
+
appContainer: booleanValue(evidence.appContainer),
|
|
127
|
+
filesystem: stringValue(evidence.filesystem),
|
|
128
|
+
network: stringValue(evidence.network),
|
|
129
|
+
processTree: stringValue(evidence.processTree),
|
|
130
|
+
sandboxSpecVersion: stringValue(evidence.sandboxSpecVersion),
|
|
131
|
+
...(evidence.processTreeEvidence !== undefined ? { processTreeEvidence: evidence.processTreeEvidence } : {}),
|
|
132
|
+
...(extra ? { details: extra } : {}),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function toolResultFromNative(raw) {
|
|
136
|
+
const toolCallId = stringValue(raw.toolCallId);
|
|
137
|
+
if (!toolCallId)
|
|
138
|
+
return null;
|
|
139
|
+
const receipt = objectValue(raw.receipt);
|
|
140
|
+
const receiptStatus = stringValue(receipt?.status);
|
|
141
|
+
const receiptExtra = detailsOutside(receipt, TOOL_RECEIPT_KEYS);
|
|
142
|
+
const topExtra = detailsOutside(raw, TOOL_TOP_LEVEL_KEYS);
|
|
143
|
+
const normalizedReceipt = {
|
|
144
|
+
status: receiptStatus,
|
|
145
|
+
allowed: booleanValue(receipt?.consentito ?? receipt?.allowed),
|
|
146
|
+
via: stringValue(receipt?.via),
|
|
147
|
+
reason: stringValue(receipt?.motivo ?? receipt?.reason),
|
|
148
|
+
risk: stringValue(receipt?.risk),
|
|
149
|
+
...(receiptExtra ? { details: englishRecord(receiptExtra, RECEIPT_DETAILS_SHAPE) } : {}),
|
|
150
|
+
};
|
|
151
|
+
/* R5a lane R (Q-R5-10/11, additive): the two cut markers the model read, as facts. */
|
|
152
|
+
const content = String(raw.content ?? '');
|
|
153
|
+
const saved = parseToolOutputMarker(content);
|
|
154
|
+
const cut = parseToolResultCut(content);
|
|
155
|
+
return {
|
|
156
|
+
toolCallId,
|
|
157
|
+
status: toolStatus(raw, receiptStatus),
|
|
158
|
+
content,
|
|
159
|
+
receipt: normalizedReceipt,
|
|
160
|
+
enforcement: enforcementFrom(receipt),
|
|
161
|
+
...(topExtra ? { details: englishRecord(topExtra, TOOL_DETAILS_SHAPE) } : {}),
|
|
162
|
+
...(saved ? { outputSaved: { path: saved.path, keptChars: saved.keptChars, totalChars: saved.totalChars } } : {}),
|
|
163
|
+
...(cut ? { readCut: { shownLines: cut.shownLines, totalLines: cut.totalLines, limitChars: cut.limitChars, shownChars: cut.shownChars, totalChars: cut.totalChars } } : {}),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function withoutMeta(raw, redactText) {
|
|
167
|
+
const cleaned = clean(raw, redactText);
|
|
168
|
+
delete cleaned.type;
|
|
169
|
+
delete cleaned._sequenza;
|
|
170
|
+
return cleaned;
|
|
171
|
+
}
|
|
172
|
+
function english(value, shape) {
|
|
173
|
+
if (Array.isArray(value))
|
|
174
|
+
return value.map(item => english(item, shape));
|
|
175
|
+
const row = objectValue(value);
|
|
176
|
+
if (!row)
|
|
177
|
+
return value;
|
|
178
|
+
const out = {};
|
|
179
|
+
for (const [key, item] of Object.entries(row)) {
|
|
180
|
+
const rule = shape[key];
|
|
181
|
+
const name = rule === undefined ? key : typeof rule === 'string' ? rule : rule.as ?? key;
|
|
182
|
+
if (name !== key && Object.hasOwn(row, name))
|
|
183
|
+
continue;
|
|
184
|
+
const values = typeof rule === 'object' ? rule.values : undefined;
|
|
185
|
+
const mapped = typeof item === 'string' && values && Object.hasOwn(values, item) ? values[item] : item;
|
|
186
|
+
out[name] = typeof rule === 'object' && rule.shape ? english(mapped, rule.shape) : mapped;
|
|
187
|
+
}
|
|
188
|
+
return out;
|
|
189
|
+
}
|
|
190
|
+
const USAGE_SHAPE = { giri: 'turns' }; // E-03: the token counters stay (clean() allows them), the turn count reads `turns`
|
|
191
|
+
const RUN_STARTED_SHAPE = {
|
|
192
|
+
input: { shape: {
|
|
193
|
+
consegna: 'prompt', consegnaCorta: 'shortPrompt', progetto: 'project', seguito: 'followUp', reindirizzato: 'redirected',
|
|
194
|
+
immagini: { as: 'images', shape: { tipo: { as: 'type', values: { immagine: 'image' } }, nome: 'name', byte: 'bytes' } },
|
|
195
|
+
} },
|
|
196
|
+
contesto: { as: 'context', shape: { progetto: 'project', cartella: 'folder', repoAnnidati: 'nestedRepos', modello: 'model', permessi: 'permissions' } },
|
|
197
|
+
};
|
|
198
|
+
const APPROVAL_REQUIRED_SHAPE = { azione: { as: 'action', shape: {
|
|
199
|
+
tipo: 'tool', percorso: 'path', comando: 'command', formato: 'format',
|
|
200
|
+
segreto: { as: 'sensitive', shape: { classe: 'class', percorso: 'path', frase: 'sentence', nascosto: 'hidden' } },
|
|
201
|
+
} } };
|
|
202
|
+
const APPROVAL_RESOLVED_SHAPE = { approvato: 'approved' };
|
|
203
|
+
const RUN_COMPLETED_SHAPE = {
|
|
204
|
+
outcome: { values: { concluso: 'completed', fermato: 'stopped' } }, // session-registry.mjs:2677,2691
|
|
205
|
+
result: { shape: { detto: 'text', compattazioni: 'compactions', premesseNegate: 'deniedPremises', usage: { shape: USAGE_SHAPE } } },
|
|
206
|
+
};
|
|
207
|
+
const TOOL_DETAILS_SHAPE = { durataMs: 'durationMs', comando: 'command' };
|
|
208
|
+
const RECEIPT_DETAILS_SHAPE = { azione: 'tool', percorso: 'path', comando: 'command', hashContenuto: 'contentHash' };
|
|
209
|
+
function englishRecord(value, shape) { return english(value, shape); }
|
|
210
|
+
/** Gate §8: the approval names its tool twice — the kernel id (`tool`, a stable contract) and the English label. */
|
|
211
|
+
function approvalRequired(data) {
|
|
212
|
+
const out = englishRecord(data, APPROVAL_REQUIRED_SHAPE);
|
|
213
|
+
const action = objectValue(out.action);
|
|
214
|
+
const tool = stringValue(action?.tool);
|
|
215
|
+
if (action && tool && action.displayName === undefined)
|
|
216
|
+
out.action = { ...action, displayName: toolDisplay(tool).label };
|
|
217
|
+
return out;
|
|
218
|
+
}
|
|
219
|
+
/*
|
|
220
|
+
* Q-R2-4 (owner 2026-09-24): the v2 envelope carries what happened / what to do / where to look as fields, filled by lane E's
|
|
221
|
+
* `describeError` (the one error describer, gate E6); `code`, `message` and the rest of the envelope stay as they were. The
|
|
222
|
+
* words pass the same redactor as every v2 string. A describer that throws is reported as the failure message itself: an
|
|
223
|
+
* error about an error must never lose the original failure (a guard that explodes is absent).
|
|
224
|
+
*/
|
|
225
|
+
function v2Error(source, failure, redactText) {
|
|
226
|
+
let view = null;
|
|
227
|
+
try {
|
|
228
|
+
view = describeError(source);
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
view = null;
|
|
232
|
+
}
|
|
233
|
+
const text = (value) => typeof value === 'string' && value.length > 0 ? redactText(value) : null;
|
|
234
|
+
/* Owner decision 2026-09-24 (Q-R2-2 applied to JSON): `message` is the English headline, as on screen; the original
|
|
235
|
+
(already redacted) message moves to `raw`, for diagnosis, and only when it says something else. */
|
|
236
|
+
const what = text(view?.what) ?? failure.message;
|
|
237
|
+
/* R5a lane R (Q-R5-6, additive): the HTTP status and the provider's requested wait travel as fields, so a later
|
|
238
|
+
`describeError` of this v2 error (the TUI's) still tells 401 from 403 and names a known wait. */
|
|
239
|
+
const row = source && typeof source === 'object' ? source : null;
|
|
240
|
+
const status = numberValue(row?.stato) ?? numberValue(row?.status);
|
|
241
|
+
const retryAfterMs = numberValue(row?.retryAfterMs);
|
|
242
|
+
return { message: what, ...(failure.message && failure.message !== what ? { raw: failure.message } : {}), envelope: { ...failure.envelope, what, todo: text(view?.todo), where: text(view?.where) },
|
|
243
|
+
...(status !== null ? { status } : {}), ...(retryAfterMs !== null ? { retryAfterMs } : {}) };
|
|
244
|
+
}
|
|
245
|
+
function transient(type) {
|
|
246
|
+
return type === 'message.started' || type === 'message.delta' || type === 'message.completed'
|
|
247
|
+
|| type === 'reasoning.started' || type === 'reasoning.delta' || type === 'reasoning.completed'
|
|
248
|
+
|| type === 'tool.started' || type === 'tool.args' || type === 'tool.output'
|
|
249
|
+
|| type === 'usage.updated' || type === 'warning' || type === 'provider.attempt';
|
|
250
|
+
}
|
|
251
|
+
/*
|
|
252
|
+
* R5a lane R (Q-R5-4/5/6, gate E3/E9, additive): the CUSTOM rows v2 now reads. v1 maps no CUSTOM row, so it is unchanged.
|
|
253
|
+
* - `talos.cli.provider.attempt` / `talos.cli.context.compacted`: the CLI's own live facts (runtime/provider-attempts.ts);
|
|
254
|
+
* - `talos.context` of kind `context.version.committed`: the Context Engine committed a compacted version
|
|
255
|
+
* (context-engine/src/node/sqlite-worker.mjs `activate`), persisted by the kernel, so it replays;
|
|
256
|
+
* - `talos.cli.provider.failure`: folded into the next `run.failed` (status, requested wait), never an event of its own;
|
|
257
|
+
* - `consumo-fornitore`: one model request's own usage and declared cost (runtime-owner-adapter.mjs:978), folded into the
|
|
258
|
+
* next `usage.updated` as `lastRequest` and `declaredCostUsd` (measured order: the row precedes its /usage delta).
|
|
259
|
+
*/
|
|
260
|
+
function countOrNull(value) { return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? Math.round(value) : null; }
|
|
261
|
+
function compactionData(value, engine) {
|
|
262
|
+
const trigger = value?.trigger === 'manual' || value?.trigger === 'automatic' ? value.trigger : null;
|
|
263
|
+
return { engine, messagesSummarized: countOrNull(value?.messagesSummarized), tokensBefore: countOrNull(value?.tokensBefore), tokensAfter: countOrNull(value?.tokensAfter),
|
|
264
|
+
...(trigger ? { trigger } : {}), ...(typeof value?.versionId === 'string' ? { versionId: value.versionId } : {}) };
|
|
265
|
+
}
|
|
266
|
+
/*
|
|
267
|
+
* Desktop CE fix 5f78b1316+4ceb232a5 (aligned 2026-09-25): after a refused or failed automatic compaction the engine waits
|
|
268
|
+
* 60 s, then 300, then 900 before trying again, and says so ONCE per failed job (`context.compaction.cooling`, id
|
|
269
|
+
* `cooling-<jobId>`, payload {code, attempts, waitSeconds, retryAfter}). A row without a readable time or code says nothing.
|
|
270
|
+
*/
|
|
271
|
+
function pausedFields(value) {
|
|
272
|
+
const payload = objectValue(value?.payload);
|
|
273
|
+
const code = stringValue(payload?.code);
|
|
274
|
+
const retryAfter = stringValue(payload?.retryAfter);
|
|
275
|
+
if (!code || !retryAfter || !Number.isFinite(Date.parse(retryAfter)))
|
|
276
|
+
return null;
|
|
277
|
+
return { noticeId: stringValue(value?.id), code, attempts: countOrNull(payload?.attempts), waitSeconds: countOrNull(payload?.waitSeconds), retryAfter };
|
|
278
|
+
}
|
|
279
|
+
function requestUsage(value) {
|
|
280
|
+
const usage = objectValue(value?.usage);
|
|
281
|
+
if (!usage)
|
|
282
|
+
return null;
|
|
283
|
+
const details = objectValue(usage.prompt_tokens_details);
|
|
284
|
+
const inputTokens = countOrNull(usage.prompt_tokens ?? usage.input_tokens), outputTokens = countOrNull(usage.completion_tokens ?? usage.output_tokens);
|
|
285
|
+
if (inputTokens === null && outputTokens === null)
|
|
286
|
+
return null;
|
|
287
|
+
return { provider: stringValue(value?.provider), model: stringValue(value?.model), inputTokens, outputTokens, cachedTokens: countOrNull(details?.cached_tokens ?? usage.cache_read_input_tokens ?? usage.prompt_cache_hit_tokens) };
|
|
288
|
+
}
|
|
289
|
+
export function createV2EventBridge(sessionId, clock = () => new Date().toISOString(), secretValues = []) {
|
|
290
|
+
let synthetic = 0;
|
|
291
|
+
const redactor = createRedactor(secretValues);
|
|
292
|
+
const messageBuffers = new Map();
|
|
293
|
+
const reasoningBuffers = new Map();
|
|
294
|
+
/* R5a lane R: facts held for the next event of their run (see the CUSTOM rows above). */
|
|
295
|
+
let pendingFailure = null;
|
|
296
|
+
let lastRequest = null;
|
|
297
|
+
let declaredCost = null;
|
|
298
|
+
const resetRun = () => { pendingFailure = null; lastRequest = null; declaredCost = null; };
|
|
299
|
+
return {
|
|
300
|
+
translate(raw) {
|
|
301
|
+
if (!raw || typeof raw !== 'object')
|
|
302
|
+
return null;
|
|
303
|
+
const original = raw;
|
|
304
|
+
const r = clean(original, redactor.text);
|
|
305
|
+
const sequence = nativeSequence(original._sequenza);
|
|
306
|
+
const next = (type, data, durability = transient(type) ? 'transient' : 'durable') => baseEvent({ sessionId, sequence, synthetic: ++synthetic, clock, durability, type, data });
|
|
307
|
+
const pausedData = (value) => { const fields = pausedFields(value); return fields ? next('context.compaction.paused', fields, 'durable') : null; };
|
|
308
|
+
switch (String(r.type)) {
|
|
309
|
+
case 'RunStarted':
|
|
310
|
+
resetRun();
|
|
311
|
+
return next('run.started', englishRecord(withoutMeta(r, redactor.text), RUN_STARTED_SHAPE), 'durable');
|
|
312
|
+
case 'CUSTOM': {
|
|
313
|
+
const name = String(r.name ?? '');
|
|
314
|
+
const value = objectValue(r.value);
|
|
315
|
+
if (name === CLI_EVENT.attempt) {
|
|
316
|
+
const attempt = countOrNull(value?.attempt), maxAttempts = countOrNull(value?.maxAttempts);
|
|
317
|
+
return attempt === null || maxAttempts === null ? null : next('provider.attempt', { attempt, maxAttempts, status: countOrNull(value?.status), retryAfterMs: countOrNull(value?.retryAfterMs), waitMs: countOrNull(value?.waitMs) });
|
|
318
|
+
}
|
|
319
|
+
if (name === CLI_EVENT.compacted)
|
|
320
|
+
return next('context.compacted', compactionData(value, 'kernel'), 'transient');
|
|
321
|
+
if (name === CLI_EVENT.summaryRequested)
|
|
322
|
+
return next('context.summary.requested', {}, 'transient');
|
|
323
|
+
if (name === 'talos.context' && value?.kind === 'context.version.committed')
|
|
324
|
+
return next('context.compacted', compactionData({ versionId: value.versionId }, 'context-engine'), 'durable');
|
|
325
|
+
if (name === 'talos.context' && value?.kind === 'context.compaction.cooling')
|
|
326
|
+
return pausedData(value);
|
|
327
|
+
if (name === CLI_EVENT.failure) {
|
|
328
|
+
pendingFailure = { status: countOrNull(value?.status), retryAfterMs: countOrNull(value?.retryAfterMs) };
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
if (name === 'consumo-fornitore') {
|
|
332
|
+
const request = requestUsage(value);
|
|
333
|
+
if (request)
|
|
334
|
+
lastRequest = request;
|
|
335
|
+
const cost = numberValue(value?.costoDichiarato);
|
|
336
|
+
if (cost !== null && cost >= 0)
|
|
337
|
+
declaredCost = (declaredCost ?? 0) + cost;
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
case 'TextMessageStart': {
|
|
343
|
+
const messageId = String(r.messageId ?? 'assistant');
|
|
344
|
+
messageBuffers.set(messageId, '');
|
|
345
|
+
return next('message.started', { messageId, role: r.role === 'user' ? 'user' : 'assistant' });
|
|
346
|
+
}
|
|
347
|
+
case 'TextMessageContent': {
|
|
348
|
+
const messageId = String(r.messageId ?? 'assistant');
|
|
349
|
+
const delta = redactor.text(String(r.delta ?? ''));
|
|
350
|
+
messageBuffers.set(messageId, (messageBuffers.get(messageId) ?? '') + delta);
|
|
351
|
+
return next('message.delta', { messageId, delta });
|
|
352
|
+
}
|
|
353
|
+
case 'TextMessageEnd': {
|
|
354
|
+
const messageId = String(r.messageId ?? 'assistant');
|
|
355
|
+
const text = messageBuffers.get(messageId) ?? '';
|
|
356
|
+
messageBuffers.delete(messageId);
|
|
357
|
+
return next('message.completed', { messageId, text }, 'durable');
|
|
358
|
+
}
|
|
359
|
+
case 'ReasoningMessageStart': {
|
|
360
|
+
const messageId = String(r.messageId ?? 'reasoning');
|
|
361
|
+
reasoningBuffers.set(messageId, '');
|
|
362
|
+
return next('reasoning.started', { messageId });
|
|
363
|
+
}
|
|
364
|
+
case 'ReasoningMessageContent': {
|
|
365
|
+
const messageId = String(r.messageId ?? 'reasoning');
|
|
366
|
+
const delta = redactor.text(String(r.delta ?? ''));
|
|
367
|
+
reasoningBuffers.set(messageId, (reasoningBuffers.get(messageId) ?? '') + delta);
|
|
368
|
+
return next('reasoning.delta', { messageId, delta });
|
|
369
|
+
}
|
|
370
|
+
case 'ReasoningMessageEnd': {
|
|
371
|
+
const messageId = String(r.messageId ?? 'reasoning');
|
|
372
|
+
const text = reasoningBuffers.get(messageId) ?? '';
|
|
373
|
+
reasoningBuffers.delete(messageId);
|
|
374
|
+
return next('reasoning.completed', { messageId, text }, 'durable');
|
|
375
|
+
}
|
|
376
|
+
case 'ToolCallStart':
|
|
377
|
+
return next('tool.started', { toolCallId: String(r.toolCallId ?? ''), toolName: String(r.toolCallName ?? r.name ?? 'tool') });
|
|
378
|
+
case 'ToolCallArgs':
|
|
379
|
+
return next('tool.args', { toolCallId: String(r.toolCallId ?? ''), delta: redactor.text(String(r.delta ?? '')) });
|
|
380
|
+
case 'ToolCallOutput':
|
|
381
|
+
return next('tool.output', { toolCallId: String(r.toolCallId ?? ''), delta: redactor.text(String(r.delta ?? '')) });
|
|
382
|
+
case 'ToolCallResult': {
|
|
383
|
+
const result = toolResultFromNative(r);
|
|
384
|
+
return result ? next('tool.completed', result, 'durable') : null;
|
|
385
|
+
}
|
|
386
|
+
case 'FileChanged':
|
|
387
|
+
return next('file.changed', withoutMeta(r, redactor.text), 'durable');
|
|
388
|
+
case 'ApprovalRequested':
|
|
389
|
+
return next('approval.required', approvalRequired(withoutMeta(r, redactor.text)), 'durable');
|
|
390
|
+
case 'ApprovalResolved':
|
|
391
|
+
return next('approval.resolved', englishRecord(withoutMeta(r, redactor.text), APPROVAL_RESOLVED_SHAPE), 'durable');
|
|
392
|
+
case 'StateDelta': {
|
|
393
|
+
const rows = Array.isArray(r.delta) ? r.delta : [];
|
|
394
|
+
const usage = rows.find(row => row?.path === '/usage');
|
|
395
|
+
return usage ? next('usage.updated', { value: english(usage.value, USAGE_SHAPE), ...(lastRequest ? { lastRequest: { ...lastRequest } } : {}), ...(declaredCost !== null ? { declaredCostUsd: declaredCost } : {}) }) : null;
|
|
396
|
+
}
|
|
397
|
+
case 'RuntimeFallback':
|
|
398
|
+
return next('warning', { message: redactor.text(String(r.message ?? r.reason ?? 'runtime fallback')) });
|
|
399
|
+
case 'RunFinished':
|
|
400
|
+
resetRun();
|
|
401
|
+
return next('run.completed', englishRecord(withoutMeta(r, redactor.text), RUN_COMPLETED_SHAPE), 'durable');
|
|
402
|
+
case 'RunError': {
|
|
403
|
+
const failureFacts = pendingFailure;
|
|
404
|
+
pendingFailure = null;
|
|
405
|
+
const traceId = stringValue(r.traceId);
|
|
406
|
+
const failure = safeTalosFailure(r, {
|
|
407
|
+
component: stringValue(r.component) ?? 'runtime',
|
|
408
|
+
retryable: typeof r.retryable === 'boolean' ? r.retryable : false,
|
|
409
|
+
...(traceId ? { traceId } : {})
|
|
410
|
+
}, secretValues);
|
|
411
|
+
const runId = stringValue(r.runId);
|
|
412
|
+
const source = withoutMeta(r, redactor.text);
|
|
413
|
+
/* R5a lane R: the kernel's RunError has no status (agent-service.mjs:1991); the run's own failure facts, announced just
|
|
414
|
+
before it, are its status and requested wait. A field the kernel wrote is never replaced. */
|
|
415
|
+
const facts = failureFacts ? { ...(failureFacts.status !== null && source.stato === undefined ? { stato: failureFacts.status } : {}), ...(failureFacts.retryAfterMs !== null && source.retryAfterMs === undefined ? { retryAfterMs: failureFacts.retryAfterMs } : {}) } : {};
|
|
416
|
+
lastRequest = null;
|
|
417
|
+
declaredCost = null;
|
|
418
|
+
return next('run.failed', { error: v2Error({ ...source, ...facts }, failure, redactor.text), ...(runId ? { runId } : {}) }, 'durable');
|
|
419
|
+
}
|
|
420
|
+
case 'RunCancelled': {
|
|
421
|
+
const runId = stringValue(r.runId);
|
|
422
|
+
return next('run.cancelled', { reason: redactor.text(String(r.reason ?? r.message ?? 'cancelled')), ...(runId ? { runId } : {}) }, 'durable');
|
|
423
|
+
}
|
|
424
|
+
default:
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
export function createV2SyntheticEvent(input) {
|
|
431
|
+
return {
|
|
432
|
+
schema: 'talos.cli.event.v2',
|
|
433
|
+
version: 2,
|
|
434
|
+
sessionId: input.sessionId,
|
|
435
|
+
eventId: input.eventId,
|
|
436
|
+
cursor: null,
|
|
437
|
+
ts: (input.clock ?? (() => new Date().toISOString()))(),
|
|
438
|
+
durability: input.durability ?? 'transient',
|
|
439
|
+
type: input.type,
|
|
440
|
+
data: input.data ?? {},
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
export function createV2FailureEvent(input) {
|
|
444
|
+
const secrets = input.secretValues ?? [];
|
|
445
|
+
const redactor = createRedactor(secrets);
|
|
446
|
+
const safeDetails = input.details ? clean(input.details, redactor.text) : undefined;
|
|
447
|
+
const failure = safeTalosFailure(input.error, {
|
|
448
|
+
component: input.component ?? 'runtime',
|
|
449
|
+
retryable: input.retryable ?? false,
|
|
450
|
+
}, secrets);
|
|
451
|
+
return {
|
|
452
|
+
schema: 'talos.cli.event.v2',
|
|
453
|
+
version: 2,
|
|
454
|
+
sessionId: input.sessionId,
|
|
455
|
+
eventId: 'talos:' + encodeURIComponent(input.sessionId || 'none') + ':failure:' + failure.envelope.traceId,
|
|
456
|
+
cursor: null,
|
|
457
|
+
ts: (input.clock ?? (() => new Date().toISOString()))(),
|
|
458
|
+
durability: 'durable',
|
|
459
|
+
type: 'run.failed',
|
|
460
|
+
data: {
|
|
461
|
+
error: v2Error(input.error, failure, redactor.text),
|
|
462
|
+
...(safeDetails && Object.keys(safeDetails).length ? { details: safeDetails } : {}),
|
|
463
|
+
},
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
export function createV2SessionSnapshot(input) {
|
|
467
|
+
if (input.cursor.sessionId !== input.summary.sessionId)
|
|
468
|
+
throw Object.assign(new Error('Replay cursor is bound to a different session'), { code: 'PROTOCOL_CURSOR_SESSION_MISMATCH' });
|
|
469
|
+
return {
|
|
470
|
+
schema: 'talos.cli.event.v2',
|
|
471
|
+
version: 2,
|
|
472
|
+
sessionId: input.summary.sessionId,
|
|
473
|
+
eventId: eventIdFor(input.summary.sessionId, input.cursor.sequence, 0),
|
|
474
|
+
cursor: { ...input.cursor },
|
|
475
|
+
ts: (input.clock ?? (() => new Date().toISOString()))(),
|
|
476
|
+
durability: 'durable',
|
|
477
|
+
type: 'session.snapshot',
|
|
478
|
+
data: { summary: input.summary, ...(input.context !== undefined ? { context: input.context } : {}) },
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
function toolResultFromEvent(event) {
|
|
482
|
+
if (event.type !== 'tool.completed')
|
|
483
|
+
return null;
|
|
484
|
+
const data = event.data;
|
|
485
|
+
return typeof data.toolCallId === 'string' && typeof data.content === 'string' && typeof data.status === 'string' && data.receipt
|
|
486
|
+
? data
|
|
487
|
+
: null;
|
|
488
|
+
}
|
|
489
|
+
export function createV2RunResultAccumulator() {
|
|
490
|
+
let text = '';
|
|
491
|
+
const changed = new Set();
|
|
492
|
+
let usage = null;
|
|
493
|
+
const warnings = [];
|
|
494
|
+
const tools = new Map();
|
|
495
|
+
let sessionId = null;
|
|
496
|
+
let cursor = null;
|
|
497
|
+
let outcome = 'completed';
|
|
498
|
+
let error;
|
|
499
|
+
const redactText = createRedactor([]).text;
|
|
500
|
+
return {
|
|
501
|
+
add(event) {
|
|
502
|
+
sessionId = event.sessionId || sessionId;
|
|
503
|
+
if (event.cursor && (!cursor || event.cursor.sequence >= cursor.sequence))
|
|
504
|
+
cursor = { ...event.cursor };
|
|
505
|
+
if (event.type === 'message.delta')
|
|
506
|
+
text += String(event.data.delta ?? '');
|
|
507
|
+
if (event.type === 'file.changed' && typeof event.data.path === 'string')
|
|
508
|
+
changed.add(event.data.path);
|
|
509
|
+
if (event.type === 'usage.updated')
|
|
510
|
+
usage = event.data.value ?? event.data;
|
|
511
|
+
if (event.type === 'warning')
|
|
512
|
+
warnings.push(String(event.data.message ?? 'warning'));
|
|
513
|
+
const tool = toolResultFromEvent(event);
|
|
514
|
+
if (tool)
|
|
515
|
+
tools.set(tool.toolCallId, tool);
|
|
516
|
+
if (event.type === 'run.failed') {
|
|
517
|
+
outcome = 'failed';
|
|
518
|
+
const candidate = objectValue(event.data.error);
|
|
519
|
+
const envelope = objectValue(candidate?.envelope);
|
|
520
|
+
if (candidate && envelope && typeof candidate.message === 'string')
|
|
521
|
+
error = { message: candidate.message, ...(typeof candidate.raw === 'string' ? { raw: candidate.raw } : {}), envelope: envelope };
|
|
522
|
+
}
|
|
523
|
+
if (event.type === 'run.cancelled') {
|
|
524
|
+
outcome = 'cancelled';
|
|
525
|
+
const reason = String(event.data.reason ?? 'cancelled');
|
|
526
|
+
/* R3 Q-R3-8: a stop the person asked for is INTERRUPTED (exit 130), not a generic cancel. */
|
|
527
|
+
const source = { code: event.data.interrupted === true ? 'INTERRUPTED' : 'CANCELLED', message: reason, component: 'runtime', retryable: false };
|
|
528
|
+
error = v2Error(source, safeTalosFailure(source, { component: 'runtime' }), redactText);
|
|
529
|
+
}
|
|
530
|
+
if (event.type === 'run.completed')
|
|
531
|
+
outcome = 'completed';
|
|
532
|
+
},
|
|
533
|
+
result() {
|
|
534
|
+
if (outcome === 'failed' || outcome === 'cancelled') {
|
|
535
|
+
const fallback = error ?? (() => {
|
|
536
|
+
const code = outcome === 'cancelled' ? 'CANCELLED' : 'AGENT_FAILED';
|
|
537
|
+
const message = outcome === 'cancelled' ? 'cancelled' : 'Agent run failed';
|
|
538
|
+
const source = { code, message, component: 'runtime', retryable: false };
|
|
539
|
+
return v2Error(source, safeTalosFailure(source, { component: 'runtime' }), redactText);
|
|
540
|
+
})();
|
|
541
|
+
return {
|
|
542
|
+
schema: 'talos.cli.result.v2', version: 2, ok: false, sessionId, cursor, outcome, error: fallback,
|
|
543
|
+
warnings: [...warnings], toolResults: [...tools.values()]
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
return {
|
|
547
|
+
schema: 'talos.cli.result.v2', version: 2, ok: true, sessionId, cursor, outcome: 'completed',
|
|
548
|
+
result: { text, changedFiles: [...changed], usage }, warnings: [...warnings], toolResults: [...tools.values()]
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
export function withV2RunWarnings(result, warnings) {
|
|
554
|
+
return { ...result, warnings: [...warnings] };
|
|
555
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class TalosV2ReplayError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
details;
|
|
4
|
+
constructor(code, message, details = {}) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = 'TalosV2ReplayError';
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.details = details;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function replayDurableAfter(events, cursor) {
|
|
12
|
+
const replayable = events.filter(event => event.cursor !== null);
|
|
13
|
+
if (cursor === null)
|
|
14
|
+
return replayable.filter(event => event.durability === 'durable');
|
|
15
|
+
const wrongSession = events.find(event => event.sessionId !== cursor.sessionId);
|
|
16
|
+
if (wrongSession)
|
|
17
|
+
throw new TalosV2ReplayError('PROTOCOL_CURSOR_SESSION_MISMATCH', 'Replay cursor is bound to a different session', { cursorSessionId: cursor.sessionId, eventSessionId: wrongSession.sessionId });
|
|
18
|
+
if (replayable.length === 0)
|
|
19
|
+
throw new TalosV2ReplayError('PROTOCOL_CURSOR_UNAVAILABLE', 'No retained replay range is available for this cursor', { cursor });
|
|
20
|
+
const sequences = replayable.map(event => event.cursor.sequence);
|
|
21
|
+
const oldest = Math.min(...sequences);
|
|
22
|
+
const newest = Math.max(...sequences);
|
|
23
|
+
if (cursor.sequence < oldest - 1 || cursor.sequence > newest)
|
|
24
|
+
throw new TalosV2ReplayError('PROTOCOL_CURSOR_UNAVAILABLE', 'Requested replay cursor is outside the retained range', { cursor, oldestSequence: oldest, newestSequence: newest });
|
|
25
|
+
return replayable.filter(event => event.sessionId === cursor.sessionId
|
|
26
|
+
&& event.cursor.sequence > cursor.sequence
|
|
27
|
+
&& event.durability === 'durable');
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|