talos-code 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +111 -3
- package/THIRD_PARTY_NOTICES.md +40 -0
- package/dist/archive/zip.js +73 -0
- package/dist/args.js +97 -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 +185 -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 +43 -0
- package/dist/i18n/en/common.js +9 -0
- package/dist/i18n/en/credentials.js +82 -0
- package/dist/i18n/en/errors.js +246 -0
- package/dist/i18n/en/firstrun.js +89 -0
- package/dist/i18n/en/providers.js +37 -0
- package/dist/i18n/en/screen.js +736 -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 +330 -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/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-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 +262 -0
- package/dist/runtime/talos-composition.js +1006 -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/app.js +3761 -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 +559 -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 +32 -0
- package/dist/tui/components/terminal-shell.js +205 -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/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 +139 -0
- package/dist/tui/line-diff.js +57 -0
- package/dist/tui/live-activity.js +45 -0
- package/dist/tui/metrics.js +123 -0
- package/dist/tui/onboarding.js +36 -0
- package/dist/tui/overlays/agent-tree.js +39 -0
- package/dist/tui/overlays/approval-dialog.js +640 -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 +72 -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 +145 -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 +287 -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 +778 -0
- package/dist/tui/session-export.js +54 -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 +80 -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 +25 -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 +63 -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,248 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { assertNoUnknownOptions, takeOption, writeValue } from "./context.js";
|
|
4
|
+
import { importTalosModule } from "../runtime/repo.js";
|
|
5
|
+
import { createMemoryFacade } from "../services/memory-facade.js";
|
|
6
|
+
import { createNotesFacade } from "../services/notes-facade.js";
|
|
7
|
+
import { createTaskBoardFacade } from "../services/task-board-facade.js";
|
|
8
|
+
import { createLibraryFacade } from "../services/library-facade.js";
|
|
9
|
+
import { createForgeFacade } from "../services/forge-facade.js";
|
|
10
|
+
const clean = (v) => { if (Array.isArray(v))
|
|
11
|
+
return v.map(clean); if (v && typeof v === 'object') {
|
|
12
|
+
const o = {};
|
|
13
|
+
for (const [k, x] of Object.entries(v)) {
|
|
14
|
+
if (/percorso|path/iu.test(k))
|
|
15
|
+
continue;
|
|
16
|
+
o[k] = clean(x);
|
|
17
|
+
}
|
|
18
|
+
return o;
|
|
19
|
+
} return v; };
|
|
20
|
+
function req(args, what) { const v = args.shift(); if (!v)
|
|
21
|
+
throw new Error(`${what}_REQUIRED`); return v; }
|
|
22
|
+
export async function runNotesCommand(ctx, args0) { const a = [...args0], op = a.shift() ?? 'list'; const notes = createNotesFacade({ projectRoot: ctx.projectRoot, paths: ctx.paths, repoRoot: ctx.repoRoot }); let r; if (op === 'list') {
|
|
23
|
+
assertNoUnknownOptions(a);
|
|
24
|
+
const x = await notes.list();
|
|
25
|
+
r = x.state === 'ready' ? x.legacyRows : x;
|
|
26
|
+
}
|
|
27
|
+
else if (op === 'add') {
|
|
28
|
+
const title = req(a, 'TITLE'), body = req(a, 'BODY');
|
|
29
|
+
assertNoUnknownOptions(a);
|
|
30
|
+
r = (await notes.add({ title, content: body })).legacy;
|
|
31
|
+
}
|
|
32
|
+
else if (op === 'update') {
|
|
33
|
+
const id = req(a, 'ID');
|
|
34
|
+
const title = takeOption(a, '--title'), content = takeOption(a, '--body');
|
|
35
|
+
assertNoUnknownOptions(a);
|
|
36
|
+
r = (await notes.update(id, { ...(title !== undefined ? { title } : {}), ...(content !== undefined ? { content } : {}) })).legacy;
|
|
37
|
+
}
|
|
38
|
+
else if (op === 'delete') {
|
|
39
|
+
const id = req(a, 'ID');
|
|
40
|
+
assertNoUnknownOptions(a);
|
|
41
|
+
r = (await notes.delete(id)).legacy;
|
|
42
|
+
}
|
|
43
|
+
else if (op === 'link' || op === 'unlink') {
|
|
44
|
+
const noteId = req(a, 'NOTE_ID'), targetKind = req(a, 'TARGET_KIND'), targetId = req(a, 'TARGET_ID');
|
|
45
|
+
assertNoUnknownOptions(a);
|
|
46
|
+
r = op === 'link' ? await notes.link(noteId, targetKind, targetId) : await notes.unlink(noteId, targetKind, targetId);
|
|
47
|
+
}
|
|
48
|
+
else
|
|
49
|
+
throw new Error(`Unsupported notes operation: ${op}`); writeValue(ctx, clean(r)); return 0; }
|
|
50
|
+
export async function runTasksCommand(ctx, args0) { const a = [...args0], op = a.shift() ?? 'list'; const tasks = createTaskBoardFacade({ projectRoot: ctx.projectRoot, paths: ctx.paths, repoRoot: ctx.repoRoot }); let r; if (op === 'list') {
|
|
51
|
+
assertNoUnknownOptions(a);
|
|
52
|
+
const x = await tasks.list();
|
|
53
|
+
r = x.state === 'ready' ? x.legacyRows : x;
|
|
54
|
+
}
|
|
55
|
+
else if (op === 'add') {
|
|
56
|
+
const title = req(a, 'TITLE'), description = req(a, 'DESCRIPTION'), priority = (takeOption(a, '--priority') ?? 'normal');
|
|
57
|
+
assertNoUnknownOptions(a);
|
|
58
|
+
r = (await tasks.add({ title, description, priority })).legacy;
|
|
59
|
+
}
|
|
60
|
+
else if (op === 'update') {
|
|
61
|
+
const id = req(a, 'ID');
|
|
62
|
+
const title = takeOption(a, '--title'), description = takeOption(a, '--description'), priority = takeOption(a, '--priority');
|
|
63
|
+
assertNoUnknownOptions(a);
|
|
64
|
+
r = (await tasks.update(id, { ...(title !== undefined ? { title } : {}), ...(description !== undefined ? { description } : {}), ...(priority !== undefined ? { priority } : {}) })).legacy;
|
|
65
|
+
}
|
|
66
|
+
else if (op === 'complete') {
|
|
67
|
+
const id = req(a, 'ID'), status = (a.shift() ?? 'done');
|
|
68
|
+
assertNoUnknownOptions(a);
|
|
69
|
+
r = (await tasks.complete(id, status)).legacy;
|
|
70
|
+
}
|
|
71
|
+
else if (op === 'delete') {
|
|
72
|
+
const id = req(a, 'ID');
|
|
73
|
+
assertNoUnknownOptions(a);
|
|
74
|
+
r = (await tasks.delete(id)).legacy;
|
|
75
|
+
}
|
|
76
|
+
else if (op === 'depend' || op === 'undepend') {
|
|
77
|
+
const id = req(a, 'TASK_ID'), target = req(a, 'DEPENDENCY_TASK_ID');
|
|
78
|
+
assertNoUnknownOptions(a);
|
|
79
|
+
r = op === 'depend' ? await tasks.depend(id, target) : await tasks.undepend(id, target);
|
|
80
|
+
}
|
|
81
|
+
else if (op === 'evidence' || op === 'unevidence') {
|
|
82
|
+
const id = req(a, 'TASK_ID'), sessionId = req(a, 'SESSION_ID');
|
|
83
|
+
assertNoUnknownOptions(a);
|
|
84
|
+
r = op === 'evidence' ? await tasks.addEvidence(id, sessionId) : await tasks.removeEvidence(id, sessionId);
|
|
85
|
+
}
|
|
86
|
+
else if (op === 'assign' || op === 'unassign') {
|
|
87
|
+
const id = req(a, 'TASK_ID'), sessionId = req(a, 'AGENT_SESSION_ID');
|
|
88
|
+
assertNoUnknownOptions(a);
|
|
89
|
+
r = op === 'assign' ? await tasks.assignAgent(id, sessionId) : await tasks.unassignAgent(id, sessionId);
|
|
90
|
+
}
|
|
91
|
+
else if (op === 'schedule' || op === 'unschedule') {
|
|
92
|
+
const id = req(a, 'TASK_ID'), automationId = req(a, 'AUTOMATION_ID');
|
|
93
|
+
assertNoUnknownOptions(a);
|
|
94
|
+
r = op === 'schedule' ? await tasks.attachSchedule(id, automationId) : await tasks.detachSchedule(id, automationId);
|
|
95
|
+
}
|
|
96
|
+
else
|
|
97
|
+
throw new Error(`Unsupported tasks operation: ${op}`); writeValue(ctx, clean(r)); return 0; }
|
|
98
|
+
export async function runMemoryCommand(ctx, args0) { const a = [...args0], op = a.shift() ?? 'list'; const memory = createMemoryFacade({ projectRoot: ctx.projectRoot, paths: ctx.paths, repoRoot: ctx.repoRoot }); let r; if (op === 'list') {
|
|
99
|
+
assertNoUnknownOptions(a);
|
|
100
|
+
const x = await memory.list();
|
|
101
|
+
r = x.state === 'ready' ? x.legacyRows : x;
|
|
102
|
+
}
|
|
103
|
+
else if (op === 'search') {
|
|
104
|
+
const query = req(a, 'QUERY');
|
|
105
|
+
assertNoUnknownOptions(a);
|
|
106
|
+
const x = await memory.search(query);
|
|
107
|
+
r = x.state === 'ready' ? x.legacy : x;
|
|
108
|
+
}
|
|
109
|
+
else if (op === 'add') {
|
|
110
|
+
const title = req(a, 'TITLE'), content = req(a, 'CONTENT'), kind = (takeOption(a, '--kind') ?? 'preference');
|
|
111
|
+
assertNoUnknownOptions(a);
|
|
112
|
+
r = (await memory.add({ title, content, kind })).legacy;
|
|
113
|
+
}
|
|
114
|
+
else if (op === 'update') {
|
|
115
|
+
const id = req(a, 'ID'), title = takeOption(a, '--title'), content = takeOption(a, '--content'), kind = takeOption(a, '--kind');
|
|
116
|
+
assertNoUnknownOptions(a);
|
|
117
|
+
r = (await memory.update(id, { ...(title !== undefined ? { title } : {}), ...(content !== undefined ? { content } : {}), ...(kind !== undefined ? { kind } : {}) })).legacy;
|
|
118
|
+
}
|
|
119
|
+
else if (op === 'delete') {
|
|
120
|
+
const id = req(a, 'ID');
|
|
121
|
+
assertNoUnknownOptions(a);
|
|
122
|
+
r = (await memory.delete(id)).legacy;
|
|
123
|
+
}
|
|
124
|
+
else
|
|
125
|
+
throw new Error(`Unsupported memory operation: ${op}`); writeValue(ctx, clean(r)); return 0; }
|
|
126
|
+
export async function runLibraryCommand(ctx, args0) { const a = [...args0], op = a.shift() ?? 'list'; const library = createLibraryFacade({ projectRoot: ctx.projectRoot, paths: ctx.paths, repoRoot: ctx.repoRoot }); let r; if (op === 'list') {
|
|
127
|
+
assertNoUnknownOptions(a);
|
|
128
|
+
const x = await library.list();
|
|
129
|
+
r = x.state === 'ready' ? x.legacyRows : x;
|
|
130
|
+
}
|
|
131
|
+
else if (op === 'search') {
|
|
132
|
+
const query = req(a, 'QUERY');
|
|
133
|
+
assertNoUnknownOptions(a);
|
|
134
|
+
r = (await library.search(query)).legacy;
|
|
135
|
+
}
|
|
136
|
+
else if (op === 'read') {
|
|
137
|
+
const id = req(a, 'ID');
|
|
138
|
+
assertNoUnknownOptions(a);
|
|
139
|
+
r = (await library.read(id)).legacy;
|
|
140
|
+
}
|
|
141
|
+
else if (op === 'preview') {
|
|
142
|
+
const id = req(a, 'ID');
|
|
143
|
+
assertNoUnknownOptions(a);
|
|
144
|
+
r = await library.preview(id);
|
|
145
|
+
}
|
|
146
|
+
else if (op === 'duplicates') {
|
|
147
|
+
const id = req(a, 'ID');
|
|
148
|
+
assertNoUnknownOptions(a);
|
|
149
|
+
r = await library.duplicates(id);
|
|
150
|
+
}
|
|
151
|
+
else if (op === 'context-ref') {
|
|
152
|
+
const id = req(a, 'ID');
|
|
153
|
+
assertNoUnknownOptions(a);
|
|
154
|
+
r = await library.prepareContextReference(id);
|
|
155
|
+
}
|
|
156
|
+
else if (op === 'import') {
|
|
157
|
+
const file = req(a, 'FILE');
|
|
158
|
+
assertNoUnknownOptions(a);
|
|
159
|
+
r = await library.importFile(file);
|
|
160
|
+
}
|
|
161
|
+
else if (op === 'export') {
|
|
162
|
+
const id = req(a, 'ID'), out = takeOption(a, '--out');
|
|
163
|
+
assertNoUnknownOptions(a);
|
|
164
|
+
if (!out)
|
|
165
|
+
throw new Error('LIBRARY_EXPORT_OUT_REQUIRED');
|
|
166
|
+
r = (await library.exportFile(id, out)).legacy;
|
|
167
|
+
}
|
|
168
|
+
else if (op === 'rename') {
|
|
169
|
+
const id = req(a, 'ID'), name = req(a, 'NAME');
|
|
170
|
+
assertNoUnknownOptions(a);
|
|
171
|
+
r = (await library.rename(id, name)).legacy;
|
|
172
|
+
}
|
|
173
|
+
else if (op === 'delete') {
|
|
174
|
+
const id = req(a, 'ID');
|
|
175
|
+
assertNoUnknownOptions(a);
|
|
176
|
+
r = (await library.delete(id)).legacy;
|
|
177
|
+
}
|
|
178
|
+
else
|
|
179
|
+
throw new Error(`Unsupported library operation: ${op}`); writeValue(ctx, clean(r)); return 0; }
|
|
180
|
+
export async function runForgeCommand(ctx, args0) {
|
|
181
|
+
const a = [...args0], op = a.shift() ?? 'list', forgeRoot = join(ctx.paths.dataRoot, 'forge');
|
|
182
|
+
const base = createForgeFacade({ forgeRoot, repoRoot: ctx.repoRoot });
|
|
183
|
+
let r;
|
|
184
|
+
const packageFrom = async () => JSON.parse(await readFile(req(a, 'PACKAGE_FILE'), 'utf8'));
|
|
185
|
+
const owner = async (sessionId) => { const rc = await ctx.createRuntimeContext({ projectRoot: ctx.projectRoot, paths: ctx.paths, repoRoot: ctx.repoRoot, model: ctx.invocation.model ?? 'openai:gpt-5-mini', environmentKeys: 'consent' }); await rc.registry?.ripristina?.(); return createForgeFacade({ forgeRoot, repoRoot: ctx.repoRoot }, { registry: rc.registry }); };
|
|
186
|
+
if (op === 'list') {
|
|
187
|
+
assertNoUnknownOptions(a);
|
|
188
|
+
const x = await base.list();
|
|
189
|
+
r = x.state === 'ready' ? x.rows : x;
|
|
190
|
+
}
|
|
191
|
+
else if (op === 'inspect') {
|
|
192
|
+
const id = req(a, 'ID');
|
|
193
|
+
assertNoUnknownOptions(a);
|
|
194
|
+
r = await base.read(id);
|
|
195
|
+
}
|
|
196
|
+
else if (op === 'validate') {
|
|
197
|
+
const pkg = await packageFrom();
|
|
198
|
+
assertNoUnknownOptions(a);
|
|
199
|
+
r = base.validatePackage(pkg);
|
|
200
|
+
}
|
|
201
|
+
else if (op === 'scan') {
|
|
202
|
+
const pkg = await packageFrom();
|
|
203
|
+
assertNoUnknownOptions(a);
|
|
204
|
+
r = await base.scanPackage(pkg);
|
|
205
|
+
}
|
|
206
|
+
else if (op === 'simulate') {
|
|
207
|
+
const pkg = await packageFrom();
|
|
208
|
+
assertNoUnknownOptions(a);
|
|
209
|
+
r = await base.analyzePackage(pkg);
|
|
210
|
+
}
|
|
211
|
+
else if (op === 'install') {
|
|
212
|
+
const session = takeOption(a, '--session'), pkg = await packageFrom();
|
|
213
|
+
assertNoUnknownOptions(a);
|
|
214
|
+
if (!session)
|
|
215
|
+
throw new Error('FORGE_SESSION_REQUIRED');
|
|
216
|
+
r = await (await owner(session)).installPackage(session, pkg);
|
|
217
|
+
}
|
|
218
|
+
else if (op === 'versions') {
|
|
219
|
+
const id = req(a, 'ID'), session = takeOption(a, '--session');
|
|
220
|
+
assertNoUnknownOptions(a);
|
|
221
|
+
if (!session)
|
|
222
|
+
throw new Error('FORGE_SESSION_REQUIRED');
|
|
223
|
+
r = await (await owner(session)).versions(session, id);
|
|
224
|
+
}
|
|
225
|
+
else if (op === 'rollback') {
|
|
226
|
+
const id = req(a, 'ID'), revision = Number(req(a, 'REVISION')), session = takeOption(a, '--session');
|
|
227
|
+
assertNoUnknownOptions(a);
|
|
228
|
+
if (!Number.isSafeInteger(revision) || revision < 1)
|
|
229
|
+
throw new Error('FORGE_REVISION_INVALID');
|
|
230
|
+
if (!session)
|
|
231
|
+
throw new Error('FORGE_SESSION_REQUIRED');
|
|
232
|
+
r = await (await owner(session)).rollback(session, id, revision);
|
|
233
|
+
}
|
|
234
|
+
else if (op === 'enable' || op === 'disable') {
|
|
235
|
+
const id = req(a, 'ID'), session = takeOption(a, '--session');
|
|
236
|
+
assertNoUnknownOptions(a);
|
|
237
|
+
if (session)
|
|
238
|
+
r = await (await owner(session)).setEnabled(session, id, op === 'enable');
|
|
239
|
+
else {
|
|
240
|
+
const m = await importTalosModule(ctx.repoRoot, 'tool-forge-store.mjs');
|
|
241
|
+
r = await m.abilitaToolForgiato({ cartella: forgeRoot, id, abilitato: op === 'enable' });
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
else
|
|
245
|
+
throw new Error(`Unsupported forge operation: ${op}`);
|
|
246
|
+
writeValue(ctx, clean(r));
|
|
247
|
+
return 0;
|
|
248
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { chmod, mkdir, readFile, stat, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { deleteSessionToolOutput } from "../runtime/output-store.js";
|
|
4
|
+
import { exportMarkdown } from "../sessions/export-format.js";
|
|
5
|
+
import { t } from "../i18n/index.js";
|
|
6
|
+
import { secretValuesFromEnvironment } from "../diagnostics/redact.js";
|
|
7
|
+
import { assertNoUnknownOptions, takeOption, writeValue } from "./context.js";
|
|
8
|
+
import { importTalosModule } from "../runtime/repo.js";
|
|
9
|
+
import { keyOriginForEntry, stateKeyOrigin } from "../provider/environment-keys.js";
|
|
10
|
+
import { createSessionMetadataStore, sessionMetadataRoot } from "../sessions/metadata-store.js";
|
|
11
|
+
import { buildSafeSessionShare, writeSafeSessionShare } from "../sessions/share.js";
|
|
12
|
+
/* B1 slice 18: the entry decides. Resuming runs a model, so an environment key is used without asking and its origin is stated; reading sessions asks. */
|
|
13
|
+
async function rc(ctx, environmentKeys) { const c = await ctx.createRuntimeContext({ projectRoot: ctx.projectRoot, paths: ctx.paths, repoRoot: ctx.repoRoot, model: ctx.invocation.model ?? 'openai:gpt-5-mini', environmentKeys }); if (typeof c.runtime?.restore === 'function')
|
|
14
|
+
await c.runtime.restore();
|
|
15
|
+
else
|
|
16
|
+
await c.registry.ripristina?.(); return c; }
|
|
17
|
+
async function sessionSummaries(c) { if (typeof c.runtime?.listSessions === 'function')
|
|
18
|
+
return c.runtime.listSessions(); const { normalizeSessionSummaries } = await import("../runtime/session-summary.js"); return normalizeSessionSummaries(c.registry.elenca?.() ?? []); }
|
|
19
|
+
function metadataStore(ctx) { return createSessionMetadataStore({ rootDir: sessionMetadataRoot(ctx.paths.dataRoot) }); }
|
|
20
|
+
async function summariesWithMetadata(ctx, c) { const store = metadataStore(ctx); const rows = await sessionSummaries(c); return Promise.all(rows.map(async (row) => { const metadata = await store.get(row.id ?? row.sessionId); return { ...row, ...(metadata?.name ? { name: metadata.name } : {}), tags: metadata?.tags ?? [], pinned: metadata?.pinned ?? false }; })); }
|
|
21
|
+
function matchesSearch(row, query) { const q = query.trim().toLowerCase(); return [row.id, row.sessionId, row.name, row.project, ...(Array.isArray(row.tags) ? row.tags : [])].some(value => typeof value === 'string' && value.toLowerCase().includes(q)); }
|
|
22
|
+
async function requireSession(c, id) { const row = (await sessionSummaries(c)).find((x) => x.id === id || x.sessionId === id); if (!row)
|
|
23
|
+
throw new Error('SESSION_NOT_FOUND'); return row; }
|
|
24
|
+
/* R5b D1 (Q-R5-12): the Markdown export is sessions/export-format.ts, shared with the TUI's /export. */
|
|
25
|
+
async function writeExport(out, format, payload) { await mkdir(dirname(resolve(out)), { recursive: true }); let body; if (format === 'json')
|
|
26
|
+
body = `${JSON.stringify(payload, null, 2)}\n`;
|
|
27
|
+
else if (format === 'jsonl')
|
|
28
|
+
body = (payload.eventi ?? []).map((e) => JSON.stringify(e)).join('\n') + ((payload.eventi ?? []).length ? '\n' : '');
|
|
29
|
+
else if (format === 'md')
|
|
30
|
+
body = exportMarkdown(payload, { secrets: secretValuesFromEnvironment(process.env) });
|
|
31
|
+
else
|
|
32
|
+
throw new Error('SESSION_EXPORT_FORMAT_INVALID'); await writeFile(out, body, { encoding: 'utf8', mode: 0o600 }); try {
|
|
33
|
+
await chmod(resolve(out), 0o600);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (process.platform !== 'win32')
|
|
37
|
+
throw error;
|
|
38
|
+
} }
|
|
39
|
+
export async function runSessionCommand(ctx, args0) { const args = [...args0]; const op = args.shift() ?? 'list'; const c = await rc(ctx, op === 'resume' ? 'use' : 'consent'); const registry = c.registry; if (op === 'list') {
|
|
40
|
+
assertNoUnknownOptions(args);
|
|
41
|
+
writeValue(ctx, await summariesWithMetadata(ctx, c));
|
|
42
|
+
return 0;
|
|
43
|
+
} if (op === 'search') {
|
|
44
|
+
const query = args.join(' ').trim();
|
|
45
|
+
if (!query)
|
|
46
|
+
throw new Error('SESSION_SEARCH_QUERY_REQUIRED');
|
|
47
|
+
writeValue(ctx, (await summariesWithMetadata(ctx, c)).filter((row) => matchesSearch(row, query)));
|
|
48
|
+
return 0;
|
|
49
|
+
} const id = args.shift(); if (!id && op !== 'import')
|
|
50
|
+
throw new Error('SESSION_ID_REQUIRED'); if (op === 'tag' || op === 'untag' || op === 'pin' || op === 'unpin') {
|
|
51
|
+
await requireSession(c, id);
|
|
52
|
+
const store = metadataStore(ctx);
|
|
53
|
+
let metadata;
|
|
54
|
+
if (op === 'tag' || op === 'untag') {
|
|
55
|
+
const tag = args.join(' ');
|
|
56
|
+
if (!tag.trim())
|
|
57
|
+
throw new Error('SESSION_TAG_REQUIRED');
|
|
58
|
+
metadata = op === 'tag' ? await store.addTag(id, tag) : await store.removeTag(id, tag);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
assertNoUnknownOptions(args);
|
|
62
|
+
metadata = await store.setPinned(id, op === 'pin');
|
|
63
|
+
}
|
|
64
|
+
writeValue(ctx, { ok: true, sessionId: id, tags: metadata.tags, pinned: metadata.pinned });
|
|
65
|
+
return 0;
|
|
66
|
+
} /* R5b D2 (Q-R5-12): the same name as the TUI's /rename; no name clears it. */ /* R5b D2 (Q-R5-12): the same name as the TUI's /rename; no name clears it. */ if (op === 'rename') {
|
|
67
|
+
await requireSession(c, id);
|
|
68
|
+
const name = args.join(' ').trim();
|
|
69
|
+
const metadata = await metadataStore(ctx).setName(id, name ? name : null);
|
|
70
|
+
writeValue(ctx, { ok: true, sessionId: id, name: metadata.name ?? null }, `${metadata.name ? t('screen.session.renamedCli', { id: String(id), name: metadata.name }) : t('screen.session.nameClearedCli', { id: String(id) })}\n`);
|
|
71
|
+
return 0;
|
|
72
|
+
} if (op === 'context') {
|
|
73
|
+
assertNoUnknownOptions(args);
|
|
74
|
+
await requireSession(c, id);
|
|
75
|
+
if (typeof c.runtime?.contextStatus !== 'function')
|
|
76
|
+
throw new Error('SESSION_CONTEXT_UNAVAILABLE');
|
|
77
|
+
writeValue(ctx, await c.runtime.contextStatus(id));
|
|
78
|
+
return 0;
|
|
79
|
+
} if (op === 'show') {
|
|
80
|
+
assertNoUnknownOptions(args);
|
|
81
|
+
const row = (await summariesWithMetadata(ctx, c)).find((x) => x.id === id || x.sessionId === id);
|
|
82
|
+
if (!row)
|
|
83
|
+
throw new Error('SESSION_NOT_FOUND');
|
|
84
|
+
const payload = registry.esporta?.(id);
|
|
85
|
+
writeValue(ctx, { ...row, eventCount: payload?.eventi?.length ?? 0 });
|
|
86
|
+
return 0;
|
|
87
|
+
} if (op === 'fork') {
|
|
88
|
+
assertNoUnknownOptions(args);
|
|
89
|
+
const x = registry.forka(id);
|
|
90
|
+
if (x?.erroreAvvio)
|
|
91
|
+
throw Object.assign(new Error(x.erroreAvvio), { code: x.code });
|
|
92
|
+
writeValue(ctx, { sessionId: x.sessionId, forkedFrom: id }, `${x.sessionId}\n`);
|
|
93
|
+
return 0;
|
|
94
|
+
} if (op === 'resume') {
|
|
95
|
+
const prompt = args.length ? args.join(' ') : undefined;
|
|
96
|
+
const sessionModel = (await sessionSummaries(c)).find((x) => x.id === id || x.sessionId === id)?.model;
|
|
97
|
+
const origin = prompt?.trim() ? stateKeyOrigin(ctx.io, ctx.invocation.outputFormat, keyOriginForEntry(c.runtime, typeof sessionModel === 'string' && sessionModel ? sessionModel : ctx.invocation.model ?? 'openai:gpt-5-mini', { refuseMissing: true })) : {};
|
|
98
|
+
const sid = await c.runtime.resume(id, prompt);
|
|
99
|
+
writeValue(ctx, { sessionId: sid, resumed: true, ...origin }, `${sid}\n`);
|
|
100
|
+
return 0;
|
|
101
|
+
} if (op === 'share') {
|
|
102
|
+
const out = takeOption(args, '--out');
|
|
103
|
+
assertNoUnknownOptions(args);
|
|
104
|
+
if (!out)
|
|
105
|
+
throw new Error('SESSION_SHARE_OUT_REQUIRED');
|
|
106
|
+
const row = await requireSession(c, id);
|
|
107
|
+
const payload = registry.esporta?.(id);
|
|
108
|
+
if (!payload)
|
|
109
|
+
throw new Error('SESSION_NOT_FOUND');
|
|
110
|
+
const store = metadataStore(ctx);
|
|
111
|
+
const metadata = await store.get(id);
|
|
112
|
+
const share = buildSafeSessionShare({ summary: row, metadata, payload, secrets: secretValuesFromEnvironment(process.env) });
|
|
113
|
+
await writeSafeSessionShare(out, share);
|
|
114
|
+
writeValue(ctx, { ok: true, sessionId: id, schema: share.schema, redacted: true, out: resolve(out) }, `Shared redacted ${id} to ${out}\n`);
|
|
115
|
+
return 0;
|
|
116
|
+
} if (op === 'export') {
|
|
117
|
+
const format = takeOption(args, '--format') ?? 'json';
|
|
118
|
+
const out = takeOption(args, '--out');
|
|
119
|
+
assertNoUnknownOptions(args);
|
|
120
|
+
if (!out)
|
|
121
|
+
throw new Error('SESSION_EXPORT_OUT_REQUIRED');
|
|
122
|
+
const payload = registry.esporta?.(id);
|
|
123
|
+
if (!payload)
|
|
124
|
+
throw new Error('SESSION_NOT_FOUND');
|
|
125
|
+
await writeExport(out, format, payload);
|
|
126
|
+
writeValue(ctx, { ok: true, sessionId: id, format, out: resolve(out) }, `Exported ${id} to ${out}\n`);
|
|
127
|
+
return 0;
|
|
128
|
+
} if (op === 'delete') {
|
|
129
|
+
assertNoUnknownOptions(args);
|
|
130
|
+
const sm = await importTalosModule(ctx.repoRoot, 'session-store.mjs');
|
|
131
|
+
await sm.eliminaSessionePersistita({ cartellaStore: ctx.paths.sessionsRoot, sessionId: id }); /* R5a E6 (Q-R5-10): the session's kept command outputs go with it. */
|
|
132
|
+
await deleteSessionToolOutput(ctx.paths.dataRoot, String(id));
|
|
133
|
+
writeValue(ctx, { ok: true, sessionId: id }, `Deleted ${id}\n`);
|
|
134
|
+
return 0;
|
|
135
|
+
} if (op === 'import') {
|
|
136
|
+
const file = id ?? args.shift();
|
|
137
|
+
if (!file)
|
|
138
|
+
throw new Error('SESSION_IMPORT_FILE_REQUIRED');
|
|
139
|
+
assertNoUnknownOptions(args);
|
|
140
|
+
let info;
|
|
141
|
+
try {
|
|
142
|
+
info = await stat(file);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
throw new Error('SESSION_IMPORT_INVALID');
|
|
146
|
+
}
|
|
147
|
+
if (!info.isFile() || info.size > 256 * 1024 * 1024)
|
|
148
|
+
throw new Error('SESSION_IMPORT_INVALID');
|
|
149
|
+
let data;
|
|
150
|
+
try {
|
|
151
|
+
data = JSON.parse(await readFile(file, 'utf8'));
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
throw new Error('SESSION_IMPORT_INVALID');
|
|
155
|
+
}
|
|
156
|
+
const sourceSchema = data?.schema ?? data?.header?.schema;
|
|
157
|
+
if (sourceSchema !== 'talos.harness-ui.session-export.v1' && sourceSchema !== 'talos.cli.session.v1')
|
|
158
|
+
throw new Error('SESSION_SCHEMA_UNSUPPORTED');
|
|
159
|
+
const rawEvents = data.eventi ?? data.events ?? [];
|
|
160
|
+
if (!Array.isArray(rawEvents))
|
|
161
|
+
throw new Error('SESSION_IMPORT_INVALID');
|
|
162
|
+
const safeEvents = rawEvents.filter((e) => e && typeof e === 'object' && e.type !== 'ApprovalRequested');
|
|
163
|
+
const importId = String(data.sessionId ?? data.header?.sessionId ?? 'imported');
|
|
164
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u.test(importId) || importId.includes('..'))
|
|
165
|
+
throw new Error('SESSION_IMPORT_ID_INVALID');
|
|
166
|
+
const target = join(ctx.paths.dataRoot, 'imports', `${importId}.json`);
|
|
167
|
+
await mkdir(dirname(target), { recursive: true });
|
|
168
|
+
await writeFile(target, `${JSON.stringify({ ...data, eventi: safeEvents, events: undefined, sourceSchema, importedBy: 'talos-cli', importedAt: new Date().toISOString() }, null, 2)}\n`, { encoding: 'utf8', mode: 0o600 });
|
|
169
|
+
writeValue(ctx, { ok: true, sessionId: importId, file: target, pendingApprovalsDropped: rawEvents.length - safeEvents.length, runnable: false }, `Imported archive ${importId}\n`);
|
|
170
|
+
return 0;
|
|
171
|
+
} throw new Error(`Unsupported session operation: ${op}`); }
|