@caupulican/pi-adaptative 0.81.42 → 0.84.1
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 +57 -0
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/register-bedrock.d.ts.map +1 -1
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
- package/dist/bun/restore-sandbox-env.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +52 -49
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +62 -57
- package/dist/bundled-resources/prompts/skillify.md +1 -1
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +16 -19
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +12 -26
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +15 -121
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +52 -79
- package/dist/bundled-resources/runtimes/pi-shell-engine/escapes.py +70 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +110 -61
- package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +106 -23
- package/dist/bundled-resources/runtimes/pi-shell-engine/paths.py +10 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +12 -4
- package/dist/bundled-resources/runtimes/pi-shell-engine/shell_args.py +22 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +9 -2
- package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +129 -259
- package/dist/bundled-resources/skills/authorized-web-security-audit/SKILL.md +187 -0
- package/dist/bundled-resources/skills/authorized-web-security-audit/references/assessment-contract.md +92 -0
- package/dist/bundled-resources/skills/deduplicate-by-evidence/SKILL.md +134 -0
- package/dist/bundled-resources/skills/evidence-gated-tdd/SKILL.md +93 -0
- package/dist/bundled-resources/skills/evidence-gated-tdd/references/evidence-model.md +27 -0
- package/dist/bundled-resources/skills/evidence-gated-tdd/references/security-scanners.md +24 -0
- package/dist/bundled-resources/skills/harness-self-adaptation/SKILL.md +4 -2
- package/dist/bundled-resources/skills/secure-agent-tool-surfaces/SKILL.md +217 -0
- package/dist/bundled-resources/skills/secure-agent-tool-surfaces/references/defensive-exploit-catalogue.md +175 -0
- package/dist/bundled-resources/skills/secure-agent-tool-surfaces/references/tool-boundary-checklist.md +87 -0
- package/dist/bundled-resources/skills/skill-architect/SKILL.md +2 -2
- package/dist/bundled-resources/skills/skill-creator/SKILL.md +188 -0
- package/dist/bundled-resources/skills/skill-creator/references/pi-skill-contract.md +73 -0
- package/dist/bundled-resources/skills/skill-creator/scripts/init-skill.mjs +142 -0
- package/dist/bundled-resources/skills/skill-creator/scripts/validate-skill.mjs +122 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +8 -8
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/initial-message.d.ts +1 -1
- package/dist/cli/initial-message.d.ts.map +1 -1
- package/dist/cli/initial-message.js.map +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/piped-stdin.d.ts +4 -0
- package/dist/cli/piped-stdin.d.ts.map +1 -0
- package/dist/cli/piped-stdin.js +13 -0
- package/dist/cli/piped-stdin.js.map +1 -0
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +10 -15
- package/dist/config.js.map +1 -1
- package/dist/core/agent-directory-layout.d.ts.map +1 -1
- package/dist/core/agent-directory-layout.js.map +1 -1
- package/dist/core/agent-paths.d.ts +1 -1
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +1 -1
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session-contracts.d.ts +5 -9
- package/dist/core/agent-session-contracts.d.ts.map +1 -1
- package/dist/core/agent-session-contracts.js +1 -12
- package/dist/core/agent-session-contracts.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +10 -25
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +24 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +210 -237
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-guidance.d.ts.map +1 -1
- package/dist/core/auth-guidance.js.map +1 -1
- package/dist/core/auth-storage.d.ts +4 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +13 -39
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
- package/dist/core/autonomy/approval-gate.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
- package/dist/core/autonomy/evidence-finding-projection.d.ts +11 -0
- package/dist/core/autonomy/evidence-finding-projection.d.ts.map +1 -0
- package/dist/core/autonomy/evidence-finding-projection.js +37 -0
- package/dist/core/autonomy/evidence-finding-projection.js.map +1 -0
- package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
- package/dist/core/autonomy/foreground-envelope.js.map +1 -1
- package/dist/core/autonomy/gates.d.ts.map +1 -1
- package/dist/core/autonomy/gates.js.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
- package/dist/core/autonomy/lane-private-paths.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +2 -3
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/autonomy/path-scope.d.ts.map +1 -1
- package/dist/core/autonomy/path-scope.js.map +1 -1
- package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.js.map +1 -1
- package/dist/core/autonomy/status.d.ts.map +1 -1
- package/dist/core/autonomy/status.js.map +1 -1
- package/dist/core/autonomy/subagent-prompt.d.ts.map +1 -1
- package/dist/core/autonomy/subagent-prompt.js.map +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
- package/dist/core/autonomy/telemetry-events.js.map +1 -1
- package/dist/core/autonomy-telemetry.d.ts.map +1 -1
- package/dist/core/autonomy-telemetry.js +2 -4
- package/dist/core/autonomy-telemetry.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +2 -15
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/background-tool-task-controller.d.ts +88 -0
- package/dist/core/background-tool-task-controller.d.ts.map +1 -0
- package/dist/core/background-tool-task-controller.js +470 -0
- package/dist/core/background-tool-task-controller.js.map +1 -0
- package/dist/core/bash-execution-controller.d.ts +1 -0
- package/dist/core/bash-execution-controller.d.ts.map +1 -1
- package/dist/core/bash-execution-controller.js +5 -4
- package/dist/core/bash-execution-controller.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/bedrock-sso-login.d.ts.map +1 -1
- package/dist/core/bedrock-sso-login.js.map +1 -1
- package/dist/core/billing-failover-controller.d.ts.map +1 -1
- package/dist/core/billing-failover-controller.js +3 -3
- package/dist/core/billing-failover-controller.js.map +1 -1
- package/dist/core/billing-failover.d.ts.map +1 -1
- package/dist/core/billing-failover.js.map +1 -1
- package/dist/core/capability-contract.d.ts.map +1 -1
- package/dist/core/catalog-manager.d.ts.map +1 -1
- package/dist/core/catalog-manager.js +0 -0
- package/dist/core/catalog-manager.js.map +1 -1
- package/dist/core/compaction-controller.d.ts +2 -0
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +21 -8
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/compaction-support.d.ts +8 -0
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +0 -2
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/artifact-retrieval.d.ts.map +1 -1
- package/dist/core/context/artifact-retrieval.js.map +1 -1
- package/dist/core/context/brain-curator.d.ts.map +1 -1
- package/dist/core/context/brain-curator.js +14 -33
- package/dist/core/context/brain-curator.js.map +1 -1
- package/dist/core/context/context-artifacts.d.ts.map +1 -1
- package/dist/core/context/context-artifacts.js +16 -24
- package/dist/core/context/context-artifacts.js.map +1 -1
- package/dist/core/context/context-audit.d.ts.map +1 -1
- package/dist/core/context/context-audit.js +3 -17
- package/dist/core/context/context-audit.js.map +1 -1
- package/dist/core/context/context-composition.d.ts.map +1 -1
- package/dist/core/context/context-composition.js.map +1 -1
- package/dist/core/context/context-item.d.ts.map +1 -1
- package/dist/core/context/context-item.js.map +1 -1
- package/dist/core/context/context-prompt-enforcement.d.ts.map +1 -1
- package/dist/core/context/context-prompt-enforcement.js +3 -16
- package/dist/core/context/context-prompt-enforcement.js.map +1 -1
- package/dist/core/context/context-prompt-policy.d.ts.map +1 -1
- package/dist/core/context/context-prompt-policy.js.map +1 -1
- package/dist/core/context/context-retention.d.ts.map +1 -1
- package/dist/core/context/context-retention.js.map +1 -1
- package/dist/core/context/context-store-retention.d.ts.map +1 -1
- package/dist/core/context/context-store-retention.js.map +1 -1
- package/dist/core/context/context-store.d.ts.map +1 -1
- package/dist/core/context/context-store.js.map +1 -1
- package/dist/core/context/context-tool-result.d.ts +4 -0
- package/dist/core/context/context-tool-result.d.ts.map +1 -0
- package/dist/core/context/context-tool-result.js +15 -0
- package/dist/core/context/context-tool-result.js.map +1 -0
- package/dist/core/context/current-work-memory.d.ts.map +1 -1
- package/dist/core/context/current-work-memory.js.map +1 -1
- package/dist/core/context/file-store-memory-provider.d.ts.map +1 -1
- package/dist/core/context/file-store-memory-provider.js +7 -28
- package/dist/core/context/file-store-memory-provider.js.map +1 -1
- package/dist/core/context/local-memory-search.d.ts +11 -0
- package/dist/core/context/local-memory-search.d.ts.map +1 -0
- package/dist/core/context/local-memory-search.js +37 -0
- package/dist/core/context/local-memory-search.js.map +1 -0
- package/dist/core/context/long-term-memory-trigger.d.ts.map +1 -1
- package/dist/core/context/long-term-memory-trigger.js.map +1 -1
- package/dist/core/context/memory-diagnostics.d.ts.map +1 -1
- package/dist/core/context/memory-diagnostics.js.map +1 -1
- package/dist/core/context/memory-index-store.d.ts.map +1 -1
- package/dist/core/context/memory-index-store.js.map +1 -1
- package/dist/core/context/memory-prompt-block.d.ts.map +1 -1
- package/dist/core/context/memory-prompt-block.js.map +1 -1
- package/dist/core/context/memory-prompt-budget.d.ts.map +1 -1
- package/dist/core/context/memory-prompt-budget.js.map +1 -1
- package/dist/core/context/memory-provider-contract.d.ts.map +1 -1
- package/dist/core/context/memory-provider-contract.js.map +1 -1
- package/dist/core/context/memory-retrieval.d.ts.map +1 -1
- package/dist/core/context/memory-retrieval.js.map +1 -1
- package/dist/core/context/memory-tier-composer.d.ts.map +1 -1
- package/dist/core/context/memory-tier-composer.js.map +1 -1
- package/dist/core/context/message-text.d.ts +7 -0
- package/dist/core/context/message-text.d.ts.map +1 -0
- package/dist/core/context/message-text.js +68 -0
- package/dist/core/context/message-text.js.map +1 -0
- package/dist/core/context/okf-memory-provider.d.ts.map +1 -1
- package/dist/core/context/okf-memory-provider.js +4 -30
- package/dist/core/context/okf-memory-provider.js.map +1 -1
- package/dist/core/context/okf-memory.d.ts.map +1 -1
- package/dist/core/context/okf-memory.js.map +1 -1
- package/dist/core/context/policy-engine.d.ts.map +1 -1
- package/dist/core/context/policy-engine.js.map +1 -1
- package/dist/core/context/policy-types.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.js.map +1 -1
- package/dist/core/context/storage-authority.d.ts.map +1 -1
- package/dist/core/context/tool-output-packer.d.ts.map +1 -1
- package/dist/core/context/tool-output-packer.js.map +1 -1
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +14 -21
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +1 -3
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +64 -145
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost/cost-summary.d.ts.map +1 -1
- package/dist/core/cost/cost-summary.js.map +1 -1
- package/dist/core/cost/daily-usage.d.ts.map +1 -1
- package/dist/core/cost/daily-usage.js.map +1 -1
- package/dist/core/cost/session-usage.d.ts.map +1 -1
- package/dist/core/cost/session-usage.js.map +1 -1
- package/dist/core/cost-guard.d.ts.map +1 -1
- package/dist/core/cost-guard.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +1 -0
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -1
- package/dist/core/delegation/managed-lane-controller.js +2 -6
- package/dist/core/delegation/managed-lane-controller.js.map +1 -1
- package/dist/core/delegation/session-worker-claim.d.ts.map +1 -1
- package/dist/core/delegation/session-worker-claim.js.map +1 -1
- package/dist/core/delegation/worker-action-journal.d.ts.map +1 -1
- package/dist/core/delegation/worker-action-journal.js +0 -4
- package/dist/core/delegation/worker-action-journal.js.map +1 -1
- package/dist/core/delegation/worker-actions.d.ts.map +1 -1
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts +1 -0
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js +13 -15
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control.js +1 -4
- package/dist/core/delegation/worker-agent-control.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-claim.d.ts.map +1 -1
- package/dist/core/delegation/worker-claim.js.map +1 -1
- package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -1
- package/dist/core/delegation/worker-conversation-store.js +0 -2
- package/dist/core/delegation/worker-conversation-store.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +5 -14
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -1
- package/dist/core/delegation/worker-dispatch-scheduler.js +5 -6
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -1
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
- package/dist/core/delegation/worker-execution-policy.js.map +1 -1
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
- package/dist/core/delegation/worker-lane-projection.js.map +1 -1
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
- package/dist/core/delegation/worker-lifecycle.js +0 -3
- package/dist/core/delegation/worker-lifecycle.js.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.js +4 -5
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-process-owner.d.ts.map +1 -1
- package/dist/core/delegation/worker-process-owner.js.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.js +1 -2
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.js +3 -4
- package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-resource-catalog.d.ts.map +1 -1
- package/dist/core/delegation/worker-resource-catalog.js.map +1 -1
- package/dist/core/delegation/worker-resource-materializer.d.ts.map +1 -1
- package/dist/core/delegation/worker-resource-materializer.js +1 -4
- package/dist/core/delegation/worker-resource-materializer.js.map +1 -1
- package/dist/core/delegation/worker-runner.d.ts +2 -4
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +6 -18
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-task-label.d.ts.map +1 -1
- package/dist/core/delegation/worker-task-label.js.map +1 -1
- package/dist/core/delegation/worker-terminal-finalizer.d.ts.map +1 -1
- package/dist/core/delegation/worker-terminal-finalizer.js.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.js +1 -4
- package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-write-reservation.d.ts.map +1 -1
- package/dist/core/delegation/worker-write-reservation.js +0 -2
- package/dist/core/delegation/worker-write-reservation.js.map +1 -1
- package/dist/core/diagnostics.d.ts.map +1 -1
- package/dist/core/doctor.d.ts +5 -5
- package/dist/core/doctor.d.ts.map +1 -1
- package/dist/core/doctor.js +16 -20
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/event-bus.js.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +26 -7
- package/dist/core/exec.js.map +1 -1
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/dist/core/export-html/ansi-to-html.js +21 -74
- package/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +4 -0
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/session-tree-foundations.d.mts +67 -0
- package/dist/core/export-html/session-tree-foundations.mjs +313 -0
- package/dist/core/export-html/template.css +14 -41
- package/dist/core/export-html/template.html +3 -1
- package/dist/core/export-html/template.js +26 -435
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extension-import-authority.d.ts.map +1 -1
- package/dist/core/extension-import-authority.js.map +1 -1
- package/dist/core/extension-metadata.d.ts.map +1 -1
- package/dist/core/extension-metadata.js.map +1 -1
- package/dist/core/extensions/builtin.d.ts +17 -0
- package/dist/core/extensions/builtin.d.ts.map +1 -1
- package/dist/core/extensions/builtin.js +18 -54
- package/dist/core/extensions/builtin.js.map +1 -1
- package/dist/core/extensions/entry-resolution.d.ts +3 -0
- package/dist/core/extensions/entry-resolution.d.ts.map +1 -0
- package/dist/core/extensions/entry-resolution.js +17 -0
- package/dist/core/extensions/entry-resolution.js.map +1 -0
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +76 -21
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +2 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +41 -112
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/stale-context.d.ts.map +1 -1
- package/dist/core/extensions/storage.d.ts.map +1 -1
- package/dist/core/extensions/storage.js.map +1 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +2 -5
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +27 -33
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
- package/dist/core/foreground-recovery-controller.js +0 -4
- package/dist/core/foreground-recovery-controller.js.map +1 -1
- package/dist/core/gateways/channel-provider.d.ts.map +1 -1
- package/dist/core/gateways/channel-provider.js +7 -5
- package/dist/core/gateways/channel-provider.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +0 -1
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
- package/dist/core/goals/compact-goal-context.js +2 -4
- package/dist/core/goals/compact-goal-context.js.map +1 -1
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -1
- package/dist/core/goals/goal-acceptance.js.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.js +1 -3
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -1
- package/dist/core/goals/goal-lifecycle.js.map +1 -1
- package/dist/core/goals/goal-record.d.ts.map +1 -1
- package/dist/core/goals/goal-record.js.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +15 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-session-controller.js +27 -3
- package/dist/core/goals/goal-session-controller.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +35 -51
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/natural-language-goal.d.ts +9 -0
- package/dist/core/goals/natural-language-goal.d.ts.map +1 -0
- package/dist/core/goals/natural-language-goal.js +23 -0
- package/dist/core/goals/natural-language-goal.js.map +1 -0
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/human-input-controller.d.ts.map +1 -1
- package/dist/core/human-input-controller.js +2 -3
- package/dist/core/human-input-controller.js.map +1 -1
- package/dist/core/human-input.d.ts.map +1 -1
- package/dist/core/human-input.js.map +1 -1
- package/dist/core/improvement-loop.d.ts.map +1 -1
- package/dist/core/improvement-loop.js +11 -11
- package/dist/core/improvement-loop.js.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/install-telemetry.d.ts.map +1 -1
- package/dist/core/install-telemetry.js.map +1 -1
- package/dist/core/isolated-text-completion.d.ts +17 -0
- package/dist/core/isolated-text-completion.d.ts.map +1 -0
- package/dist/core/isolated-text-completion.js +15 -0
- package/dist/core/isolated-text-completion.js.map +1 -0
- package/dist/core/keybindings.d.ts +47 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +12 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/learning-audit.d.ts.map +1 -1
- package/dist/core/learning/learning-audit.js.map +1 -1
- package/dist/core/learning/learning-gate.d.ts.map +1 -1
- package/dist/core/learning/learning-gate.js.map +1 -1
- package/dist/core/learning/observation-store.d.ts.map +1 -1
- package/dist/core/learning/observation-store.js +0 -2
- package/dist/core/learning/observation-store.js.map +1 -1
- package/dist/core/learning/reflection-engine.d.ts +1 -1
- package/dist/core/learning/reflection-engine.d.ts.map +1 -1
- package/dist/core/learning/reflection-engine.js +3 -0
- package/dist/core/learning/reflection-engine.js.map +1 -1
- package/dist/core/learning/reflection-turn-analysis.d.ts +20 -0
- package/dist/core/learning/reflection-turn-analysis.d.ts.map +1 -0
- package/dist/core/learning/reflection-turn-analysis.js +136 -0
- package/dist/core/learning/reflection-turn-analysis.js.map +1 -0
- package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
- package/dist/core/learning/session-learning-decision.js.map +1 -1
- package/dist/core/learning/skill-curator.d.ts.map +1 -1
- package/dist/core/learning/skill-curator.js +0 -3
- package/dist/core/learning/skill-curator.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +39 -0
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js +41 -62
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory/effectiveness-tracker.d.ts.map +1 -1
- package/dist/core/memory/effectiveness-tracker.js +4 -2
- package/dist/core/memory/effectiveness-tracker.js.map +1 -1
- package/dist/core/memory/memory-manager.d.ts.map +1 -1
- package/dist/core/memory/memory-manager.js +7 -7
- package/dist/core/memory/memory-manager.js.map +1 -1
- package/dist/core/memory/memory-provider.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.d.ts +7 -0
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +48 -13
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/memory/providers/transcript-recall-worker-protocol.d.ts +47 -0
- package/dist/core/memory/providers/transcript-recall-worker-protocol.d.ts.map +1 -0
- package/dist/core/memory/providers/transcript-recall-worker-protocol.js +50 -0
- package/dist/core/memory/providers/transcript-recall-worker-protocol.js.map +1 -0
- package/dist/core/memory/providers/transcript-recall-worker.d.ts +2 -0
- package/dist/core/memory/providers/transcript-recall-worker.d.ts.map +1 -0
- package/dist/core/memory/providers/transcript-recall-worker.js +143 -0
- package/dist/core/memory/providers/transcript-recall-worker.js.map +1 -0
- package/dist/core/memory/providers/transcript-recall.d.ts +24 -13
- package/dist/core/memory/providers/transcript-recall.d.ts.map +1 -1
- package/dist/core/memory/providers/transcript-recall.js +143 -141
- package/dist/core/memory/providers/transcript-recall.js.map +1 -1
- package/dist/core/memory/providers/user-memory-archive.d.ts +39 -0
- package/dist/core/memory/providers/user-memory-archive.d.ts.map +1 -0
- package/dist/core/memory/providers/user-memory-archive.js +258 -0
- package/dist/core/memory/providers/user-memory-archive.js.map +1 -0
- package/dist/core/memory/transcript-index.d.ts.map +1 -1
- package/dist/core/memory/transcript-index.js +1 -1
- package/dist/core/memory/transcript-index.js.map +1 -1
- package/dist/core/memory-controller.d.ts +9 -0
- package/dist/core/memory-controller.d.ts.map +1 -1
- package/dist/core/memory-controller.js +57 -16
- package/dist/core/memory-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-output-json.d.ts +10 -0
- package/dist/core/model-output-json.d.ts.map +1 -0
- package/dist/core/model-output-json.js +43 -0
- package/dist/core/model-output-json.js.map +1 -0
- package/dist/core/model-registry.d.ts +8 -8
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +29 -52
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router/config-diagnostics.d.ts.map +1 -1
- package/dist/core/model-router/config-diagnostics.js.map +1 -1
- package/dist/core/model-router/executor-route.d.ts.map +1 -1
- package/dist/core/model-router/executor-route.js.map +1 -1
- package/dist/core/model-router/fitness-gate.d.ts.map +1 -1
- package/dist/core/model-router/fitness-gate.js.map +1 -1
- package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
- package/dist/core/model-router/route-judge.d.ts.map +1 -1
- package/dist/core/model-router/route-judge.js +18 -36
- package/dist/core/model-router/route-judge.js.map +1 -1
- package/dist/core/model-router/session-buffer.d.ts.map +1 -1
- package/dist/core/model-router/session-buffer.js.map +1 -1
- package/dist/core/model-router/status.d.ts.map +1 -1
- package/dist/core/model-router/status.js.map +1 -1
- package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
- package/dist/core/model-router/tool-escalation.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +1 -0
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +25 -56
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +10 -0
- package/dist/core/model-selection-controller.d.ts.map +1 -1
- package/dist/core/model-selection-controller.js +0 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts.map +1 -1
- package/dist/core/model-tool-protocol.js.map +1 -1
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +0 -1
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/context-sizing.d.ts.map +1 -1
- package/dist/core/models/context-sizing.js.map +1 -1
- package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
- package/dist/core/models/default-model-suggestions.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +0 -1
- package/dist/core/models/fitness-store.js.map +1 -1
- package/dist/core/models/host-state-store.d.ts.map +1 -1
- package/dist/core/models/host-state-store.js +1 -6
- package/dist/core/models/host-state-store.js.map +1 -1
- package/dist/core/models/llamacpp-runtime.d.ts +4 -19
- package/dist/core/models/llamacpp-runtime.d.ts.map +1 -1
- package/dist/core/models/llamacpp-runtime.js +32 -136
- package/dist/core/models/llamacpp-runtime.js.map +1 -1
- package/dist/core/models/local-registration.d.ts.map +1 -1
- package/dist/core/models/local-registration.js +82 -115
- package/dist/core/models/local-registration.js.map +1 -1
- package/dist/core/models/local-runtime.d.ts +12 -18
- package/dist/core/models/local-runtime.d.ts.map +1 -1
- package/dist/core/models/local-runtime.js +60 -204
- package/dist/core/models/local-runtime.js.map +1 -1
- package/dist/core/models/model-endpoint.d.ts.map +1 -1
- package/dist/core/models/model-endpoint.js.map +1 -1
- package/dist/core/models/model-ref.d.ts.map +1 -1
- package/dist/core/models/model-ref.js.map +1 -1
- package/dist/core/models/needle-runtime.d.ts +7 -3
- package/dist/core/models/needle-runtime.d.ts.map +1 -1
- package/dist/core/models/needle-runtime.js +16 -92
- package/dist/core/models/needle-runtime.js.map +1 -1
- package/dist/core/models/perf-profile.d.ts +1 -1
- package/dist/core/models/perf-profile.d.ts.map +1 -1
- package/dist/core/models/perf-profile.js +6 -13
- package/dist/core/models/perf-profile.js.map +1 -1
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -1
- package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -1
- package/dist/core/models/runtime-arbiter.d.ts.map +1 -1
- package/dist/core/models/runtime-arbiter.js +3 -15
- package/dist/core/models/runtime-arbiter.js.map +1 -1
- package/dist/core/models/runtime-process.d.ts +100 -0
- package/dist/core/models/runtime-process.d.ts.map +1 -0
- package/dist/core/models/runtime-process.js +183 -0
- package/dist/core/models/runtime-process.js.map +1 -0
- package/dist/core/orchestration/agent-resume.d.ts.map +1 -1
- package/dist/core/orchestration/agent-resume.js.map +1 -1
- package/dist/core/orchestration/attempt-usage.d.ts.map +1 -1
- package/dist/core/orchestration/attempt-usage.js.map +1 -1
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
- package/dist/core/orchestration/capability-gateway.js +0 -14
- package/dist/core/orchestration/capability-gateway.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js.map +1 -1
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
- package/dist/core/orchestration/delegation-ledger.js +0 -2
- package/dist/core/orchestration/delegation-ledger.js.map +1 -1
- package/dist/core/orchestration/event-store.d.ts.map +1 -1
- package/dist/core/orchestration/event-store.js +1 -14
- package/dist/core/orchestration/event-store.js.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
- package/dist/core/orchestration/model-binding.d.ts.map +1 -1
- package/dist/core/orchestration/model-binding.js.map +1 -1
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -1
- package/dist/core/orchestration/policy-compiler.js +0 -3
- package/dist/core/orchestration/policy-compiler.js.map +1 -1
- package/dist/core/orchestration/policy-gate.d.ts.map +1 -1
- package/dist/core/orchestration/policy-gate.js +0 -2
- package/dist/core/orchestration/policy-gate.js.map +1 -1
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
- package/dist/core/orchestration/profile-registry.js +1 -1
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/orchestration/profile-store.d.ts.map +1 -1
- package/dist/core/orchestration/profile-store.js +0 -3
- package/dist/core/orchestration/profile-store.js.map +1 -1
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -1
- package/dist/core/orchestration/risk-budget.js.map +1 -1
- package/dist/core/orchestration/task-runtime.d.ts +1 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
- package/dist/core/orchestration/task-runtime.js +27 -42
- package/dist/core/orchestration/task-runtime.js.map +1 -1
- package/dist/core/orchestration/work-state-projection.d.ts.map +1 -1
- package/dist/core/orchestration/work-state-projection.js.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
- package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -1
- package/dist/core/orchestration/worker-result-adapter.js.map +1 -1
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/package-manager.d.ts +3 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +88 -353
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/process-identity.d.ts.map +1 -1
- package/dist/core/process-identity.js.map +1 -1
- package/dist/core/process-liveness.d.ts +3 -0
- package/dist/core/process-liveness.d.ts.map +1 -0
- package/dist/core/process-liveness.js +17 -0
- package/dist/core/process-liveness.js.map +1 -0
- package/dist/core/process-matrix/codes.d.ts.map +1 -1
- package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -1
- package/dist/core/process-matrix/resume-launcher.js.map +1 -1
- package/dist/core/process-matrix/runtime.d.ts.map +1 -1
- package/dist/core/process-matrix/runtime.js.map +1 -1
- package/dist/core/process-matrix/store.d.ts.map +1 -1
- package/dist/core/process-matrix/store.js.map +1 -1
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
- package/dist/core/process-matrix/supervisor.js.map +1 -1
- package/dist/core/profile-filter-controller.d.ts.map +1 -1
- package/dist/core/profile-filter-controller.js +7 -8
- package/dist/core/profile-filter-controller.js.map +1 -1
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +1 -2
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/profile-resource-selection.d.ts.map +1 -1
- package/dist/core/profile-resource-selection.js +18 -59
- package/dist/core/profile-resource-selection.js.map +1 -1
- package/dist/core/prompt-markup.d.ts +3 -0
- package/dist/core/prompt-markup.d.ts.map +1 -0
- package/dist/core/prompt-markup.js +7 -0
- package/dist/core/prompt-markup.js.map +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +13 -39
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/python-runtime.d.ts.map +1 -1
- package/dist/core/python-runtime.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +22 -1
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +143 -25
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts +2 -1
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +4 -14
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/request-auth.d.ts.map +1 -1
- package/dist/core/request-auth.js.map +1 -1
- package/dist/core/research/automata-provider.d.ts.map +1 -1
- package/dist/core/research/automata-provider.js.map +1 -1
- package/dist/core/research/evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/evidence-bundle.js.map +1 -1
- package/dist/core/research/lane-model-resolver.d.ts.map +1 -1
- package/dist/core/research/lane-model-resolver.js +0 -1
- package/dist/core/research/lane-model-resolver.js.map +1 -1
- package/dist/core/research/model-fitness-controller.d.ts.map +1 -1
- package/dist/core/research/model-fitness-controller.js +17 -33
- package/dist/core/research/model-fitness-controller.js.map +1 -1
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +4 -25
- package/dist/core/research/model-fitness.js.map +1 -1
- package/dist/core/research/research-gate.d.ts.map +1 -1
- package/dist/core/research/research-gate.js.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts.map +1 -1
- package/dist/core/research/research-lane-controller.js +5 -10
- package/dist/core/research/research-lane-controller.js.map +1 -1
- package/dist/core/research/research-runner.d.ts +2 -4
- package/dist/core/research/research-runner.d.ts.map +1 -1
- package/dist/core/research/research-runner.js +17 -48
- package/dist/core/research/research-runner.js.map +1 -1
- package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/session-evidence-bundle.js.map +1 -1
- package/dist/core/research/workspace-collector.d.ts.map +1 -1
- package/dist/core/research/workspace-collector.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-ignore.d.ts +6 -0
- package/dist/core/resource-ignore.d.ts.map +1 -0
- package/dist/core/resource-ignore.js +44 -0
- package/dist/core/resource-ignore.js.map +1 -0
- package/dist/core/resource-loader.d.ts +0 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +52 -187
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/resource-profile-blocks.d.ts +3 -1
- package/dist/core/resource-profile-blocks.d.ts.map +1 -1
- package/dist/core/resource-profile-blocks.js +8 -5
- package/dist/core/resource-profile-blocks.js.map +1 -1
- package/dist/core/resource-profile-equality.d.ts.map +1 -1
- package/dist/core/resource-profile-equality.js.map +1 -1
- package/dist/core/resource-traversal.d.ts +43 -0
- package/dist/core/resource-traversal.d.ts.map +1 -0
- package/dist/core/resource-traversal.js +84 -0
- package/dist/core/resource-traversal.js.map +1 -0
- package/dist/core/risk-classifier.d.ts.map +1 -1
- package/dist/core/risk-classifier.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +4 -1
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +25 -50
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +0 -1
- package/dist/core/scout-controller.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.js +101 -43
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
- package/dist/core/secrets/secret-dotenv.d.ts.map +1 -1
- package/dist/core/secrets/secret-dotenv.js +0 -1
- package/dist/core/secrets/secret-dotenv.js.map +1 -1
- package/dist/core/secrets/secret-vault-format.d.ts.map +1 -1
- package/dist/core/secrets/secret-vault-format.js +0 -1
- package/dist/core/secrets/secret-vault-format.js.map +1 -1
- package/dist/core/secrets/secret-vault.d.ts.map +1 -1
- package/dist/core/secrets/secret-vault.js +2 -10
- package/dist/core/secrets/secret-vault.js.map +1 -1
- package/dist/core/security/secret-text.d.ts.map +1 -1
- package/dist/core/security/secret-text.js.map +1 -1
- package/dist/core/security/untrusted-boundary.d.ts.map +1 -1
- package/dist/core/security/untrusted-boundary.js.map +1 -1
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +18 -50
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/session-artifact-bundle.d.ts.map +1 -1
- package/dist/core/session-artifact-bundle.js.map +1 -1
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-cwd.js +0 -1
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-entry-index.d.ts +8 -0
- package/dist/core/session-entry-index.d.ts.map +1 -0
- package/dist/core/session-entry-index.js +16 -0
- package/dist/core/session-entry-index.js.map +1 -0
- package/dist/core/session-image-store.d.ts.map +1 -1
- package/dist/core/session-image-store.js +0 -3
- package/dist/core/session-image-store.js.map +1 -1
- package/dist/core/session-jsonl-writer.d.ts +3 -0
- package/dist/core/session-jsonl-writer.d.ts.map +1 -0
- package/dist/core/session-jsonl-writer.js +38 -0
- package/dist/core/session-jsonl-writer.js.map +1 -0
- package/dist/core/session-manager-factory.d.ts.map +1 -1
- package/dist/core/session-manager-factory.js.map +1 -1
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/session-snapshot.d.ts.map +1 -1
- package/dist/core/session-snapshot.js.map +1 -1
- package/dist/core/session-supervision-runtime.d.ts.map +1 -1
- package/dist/core/session-supervision-runtime.js +1 -4
- package/dist/core/session-supervision-runtime.js.map +1 -1
- package/dist/core/session-tree-navigator.d.ts.map +1 -1
- package/dist/core/session-tree-navigator.js +0 -1
- package/dist/core/session-tree-navigator.js.map +1 -1
- package/dist/core/settings-manager.d.ts +2 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +64 -162
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skill-block.d.mts +8 -0
- package/dist/core/skill-block.mjs +52 -0
- package/dist/core/skill-discovery.d.ts +5 -0
- package/dist/core/skill-discovery.d.ts.map +1 -0
- package/dist/core/skill-discovery.js +34 -0
- package/dist/core/skill-discovery.js.map +1 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +23 -159
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/spawned-usage.d.ts +21 -0
- package/dist/core/spawned-usage.d.ts.map +1 -0
- package/dist/core/spawned-usage.js +29 -0
- package/dist/core/spawned-usage.js.map +1 -0
- package/dist/core/system-prompt-builder.d.ts +4 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +15 -8
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +53 -35
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-command.d.ts.map +1 -1
- package/dist/core/tasks/task-command.js.map +1 -1
- package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -1
- package/dist/core/tasks/task-contract-monitor.js.map +1 -1
- package/dist/core/tasks/task-projection.d.ts.map +1 -1
- package/dist/core/tasks/task-projection.js.map +1 -1
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/text-preview.d.ts +4 -0
- package/dist/core/text-preview.d.ts.map +1 -0
- package/dist/core/text-preview.js +33 -0
- package/dist/core/text-preview.js.map +1 -0
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts.map +1 -1
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +86 -87
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +4 -1
- package/dist/core/tool-protocol-controller.d.ts.map +1 -1
- package/dist/core/tool-protocol-controller.js +19 -23
- package/dist/core/tool-protocol-controller.js.map +1 -1
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-recovery-log-worker.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-worker.js.map +1 -1
- package/dist/core/tool-recovery-logger.d.ts.map +1 -1
- package/dist/core/tool-recovery-logger.js +12 -24
- package/dist/core/tool-recovery-logger.js.map +1 -1
- package/dist/core/tool-recovery-stats.d.ts.map +1 -1
- package/dist/core/tool-recovery-stats.js +16 -22
- package/dist/core/tool-recovery-stats.js.map +1 -1
- package/dist/core/tool-repair-health.d.ts.map +1 -1
- package/dist/core/tool-repair-health.js.map +1 -1
- package/dist/core/tool-repair-settings.d.ts.map +1 -1
- package/dist/core/tool-repair-settings.js.map +1 -1
- package/dist/core/tool-selection/expected-utility.d.ts.map +1 -1
- package/dist/core/tool-selection/expected-utility.js.map +1 -1
- package/dist/core/tool-selection/promotion.d.ts.map +1 -1
- package/dist/core/tool-selection/promotion.js.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.d.ts +2 -0
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +49 -7
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tool-selection/tool-phase-timing.d.ts +19 -0
- package/dist/core/tool-selection/tool-phase-timing.d.ts.map +1 -0
- package/dist/core/tool-selection/tool-phase-timing.js +63 -0
- package/dist/core/tool-selection/tool-phase-timing.js.map +1 -0
- package/dist/core/tool-selection/tool-selection-controller.d.ts +2 -5
- package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.js +50 -30
- package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
- package/dist/core/toolkit/reflex-interpreter.d.ts +16 -0
- package/dist/core/toolkit/reflex-interpreter.d.ts.map +1 -1
- package/dist/core/toolkit/reflex-interpreter.js +21 -0
- package/dist/core/toolkit/reflex-interpreter.js.map +1 -1
- package/dist/core/toolkit/script-registry.d.ts.map +1 -1
- package/dist/core/toolkit/script-registry.js.map +1 -1
- package/dist/core/toolkit/script-runner.d.ts.map +1 -1
- package/dist/core/toolkit/script-runner.js.map +1 -1
- package/dist/core/tools/artifact-retrieve.d.ts.map +1 -1
- package/dist/core/tools/artifact-retrieve.js.map +1 -1
- package/dist/core/tools/ask-question.d.ts +2 -3
- package/dist/core/tools/ask-question.d.ts.map +1 -1
- package/dist/core/tools/ask-question.js +14 -40
- package/dist/core/tools/ask-question.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +83 -30
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/context-scout.d.ts.map +1 -1
- package/dist/core/tools/context-scout.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +9 -7
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +6 -6
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/extensionify.d.ts.map +1 -1
- package/dist/core/tools/extensionify.js.map +1 -1
- package/dist/core/tools/fff-search-backend.d.ts +19 -0
- package/dist/core/tools/fff-search-backend.d.ts.map +1 -1
- package/dist/core/tools/fff-search-backend.js +28 -2
- package/dist/core/tools/fff-search-backend.js.map +1 -1
- package/dist/core/tools/file-encoding-policy.d.ts.map +1 -1
- package/dist/core/tools/file-encoding-policy.js.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/find.d.ts +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +44 -108
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +7 -7
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/grep.d.ts +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +42 -102
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +20 -36
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +5 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
- package/dist/core/tools/orchestration-panel.js +5 -5
- package/dist/core/tools/orchestration-panel.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +2 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +24 -36
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/persistent-process-coordinator.d.ts +31 -0
- package/dist/core/tools/persistent-process-coordinator.d.ts.map +1 -0
- package/dist/core/tools/persistent-process-coordinator.js +123 -0
- package/dist/core/tools/persistent-process-coordinator.js.map +1 -0
- package/dist/core/tools/python.d.ts.map +1 -1
- package/dist/core/tools/python.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +14 -13
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +29 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +31 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/run-process.d.ts.map +1 -1
- package/dist/core/tools/run-process.js.map +1 -1
- package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
- package/dist/core/tools/run-toolkit-script.js.map +1 -1
- package/dist/core/tools/search-command-guard.d.ts +10 -0
- package/dist/core/tools/search-command-guard.d.ts.map +1 -1
- package/dist/core/tools/search-command-guard.js +118 -31
- package/dist/core/tools/search-command-guard.js.map +1 -1
- package/dist/core/tools/search-router.d.ts.map +1 -1
- package/dist/core/tools/search-router.js.map +1 -1
- package/dist/core/tools/search-tool-runtime.d.ts +19 -0
- package/dist/core/tools/search-tool-runtime.d.ts.map +1 -0
- package/dist/core/tools/search-tool-runtime.js +12 -0
- package/dist/core/tools/search-tool-runtime.js.map +1 -0
- package/dist/core/tools/secret-store.d.ts.map +1 -1
- package/dist/core/tools/secret-store.js.map +1 -1
- package/dist/core/tools/shell-command-parser.d.ts.map +1 -1
- package/dist/core/tools/shell-command-parser.js.map +1 -1
- package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
- package/dist/core/tools/shell-contract-router.js +4 -1
- package/dist/core/tools/shell-contract-router.js.map +1 -1
- package/dist/core/tools/shell-execution-session.d.ts +4 -0
- package/dist/core/tools/shell-execution-session.d.ts.map +1 -0
- package/dist/core/tools/shell-execution-session.js +11 -0
- package/dist/core/tools/shell-execution-session.js.map +1 -0
- package/dist/core/tools/shell-output-projection.d.ts +49 -0
- package/dist/core/tools/shell-output-projection.d.ts.map +1 -0
- package/dist/core/tools/shell-output-projection.js +381 -0
- package/dist/core/tools/shell-output-projection.js.map +1 -0
- package/dist/core/tools/shell-session.d.ts +2 -13
- package/dist/core/tools/shell-session.d.ts.map +1 -1
- package/dist/core/tools/shell-session.js +36 -136
- package/dist/core/tools/shell-session.js.map +1 -1
- package/dist/core/tools/skill-audit.d.ts.map +1 -1
- package/dist/core/tools/skill-audit.js.map +1 -1
- package/dist/core/tools/skillify.d.ts.map +1 -1
- package/dist/core/tools/skillify.js.map +1 -1
- package/dist/core/tools/task-steps.d.ts +8 -8
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +17 -18
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
- package/dist/core/tools/tmux-dispatch.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/tool-task.d.ts +23 -0
- package/dist/core/tools/tool-task.d.ts.map +1 -0
- package/dist/core/tools/tool-task.js +93 -0
- package/dist/core/tools/tool-task.js.map +1 -0
- package/dist/core/tools/windows-shell-engine.d.ts +17 -11
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-engine.js +339 -117
- package/dist/core/tools/windows-shell-engine.js.map +1 -1
- package/dist/core/tools/windows-shell-state.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-state.js.map +1 -1
- package/dist/core/tools/worktree-sync.d.ts.map +1 -1
- package/dist/core/tools/worktree-sync.js +8 -12
- package/dist/core/tools/worktree-sync.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +0 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +7 -40
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +19 -0
- package/dist/core/util/atomic-file.d.ts.map +1 -1
- package/dist/core/util/atomic-file.js +50 -15
- package/dist/core/util/atomic-file.js.map +1 -1
- package/dist/core/util/bounded-file.d.ts.map +1 -1
- package/dist/core/util/bounded-file.js.map +1 -1
- package/dist/core/util/bounded-jsonl.d.ts.map +1 -1
- package/dist/core/util/bounded-jsonl.js +2 -9
- package/dist/core/util/bounded-jsonl.js.map +1 -1
- package/dist/core/util/bounded-value.d.ts.map +1 -1
- package/dist/core/util/bounded-value.js.map +1 -1
- package/dist/core/util/json-size.d.ts +3 -0
- package/dist/core/util/json-size.d.ts.map +1 -0
- package/dist/core/util/json-size.js +95 -0
- package/dist/core/util/json-size.js.map +1 -0
- package/dist/core/util/minimatch-cache.d.ts.map +1 -1
- package/dist/core/util/minimatch-cache.js.map +1 -1
- package/dist/core/util/value-guards.d.ts.map +1 -1
- package/dist/core/util/value-guards.js.map +1 -1
- package/dist/core/worktree-sync/codes.d.ts.map +1 -1
- package/dist/core/worktree-sync/git-engine.d.ts.map +1 -1
- package/dist/core/worktree-sync/git-engine.js +20 -36
- package/dist/core/worktree-sync/git-engine.js.map +1 -1
- package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
- package/dist/core/worktree-sync/lane-gate.js +1 -4
- package/dist/core/worktree-sync/lane-gate.js.map +1 -1
- package/dist/core/worktree-sync/runtime.d.ts.map +1 -1
- package/dist/core/worktree-sync/runtime.js.map +1 -1
- package/dist/core/worktree-sync/store.d.ts.map +1 -1
- package/dist/core/worktree-sync/store.js.map +1 -1
- package/dist/core/worktree-sync/watcher.d.ts.map +1 -1
- package/dist/core/worktree-sync/watcher.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +10 -32
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +6 -19
- package/dist/migrations.js.map +1 -1
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.d.ts +3 -0
- package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.js +96 -132
- package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts +1 -31
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +86 -307
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/autocomplete-provider.d.ts.map +1 -1
- package/dist/modes/interactive/autocomplete-provider.js.map +1 -1
- package/dist/modes/interactive/autonomy-commands.d.ts.map +1 -1
- package/dist/modes/interactive/autonomy-commands.js +2 -8
- package/dist/modes/interactive/autonomy-commands.js.map +1 -1
- package/dist/modes/interactive/clipboard-input.d.ts +5 -1
- package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
- package/dist/modes/interactive/clipboard-input.js +17 -0
- package/dist/modes/interactive/clipboard-input.js.map +1 -1
- package/dist/modes/interactive/compaction-queue.d.ts.map +1 -1
- package/dist/modes/interactive/compaction-queue.js +13 -18
- package/dist/modes/interactive/compaction-queue.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
- package/dist/modes/interactive/components/activity-lane.js +6 -10
- package/dist/modes/interactive/components/activity-lane.js.map +1 -1
- package/dist/modes/interactive/components/armin.d.ts +1 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -1
- package/dist/modes/interactive/components/armin.js +10 -21
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +1 -6
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +4 -9
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +0 -3
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +3 -8
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +13 -35
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +3 -8
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +14 -36
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +20 -43
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +0 -5
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +2 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +4 -8
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -6
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js +6 -8
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +0 -1
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
- package/dist/modes/interactive/components/expandable-markdown-message.d.ts +21 -0
- package/dist/modes/interactive/components/expandable-markdown-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/expandable-markdown-message.js +48 -0
- package/dist/modes/interactive/components/expandable-markdown-message.js.map +1 -0
- package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -1
- package/dist/modes/interactive/components/expandable-text.js +0 -2
- package/dist/modes/interactive/components/expandable-text.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +1 -9
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +2 -8
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +5 -20
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/fitness-role-selector.js +0 -1
- package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -5
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +4 -10
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -2
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +21 -44
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/model-suggestion-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-suggestion-selector.js +0 -1
- package/dist/modes/interactive/components/model-suggestion-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +16 -32
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.d.ts +3 -4
- package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.js +34 -93
- package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
- package/dist/modes/interactive/components/profile-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/profile-selector.js +0 -1
- package/dist/modes/interactive/components/profile-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +3 -4
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +34 -79
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/selector-list.d.ts +63 -0
- package/dist/modes/interactive/components/selector-list.d.ts.map +1 -0
- package/dist/modes/interactive/components/selector-list.js +186 -0
- package/dist/modes/interactive/components/selector-list.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +34 -59
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +40 -138
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts +2 -4
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js +9 -28
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +3 -8
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +12 -40
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts +2 -5
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +11 -37
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts +2 -4
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +9 -31
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +9 -28
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-group.js +2 -3
- package/dist/modes/interactive/components/tool-group.js.map +1 -1
- package/dist/modes/interactive/components/tool-panel-registry.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-panel-registry.js +5 -3
- package/dist/modes/interactive/components/tool-panel-registry.js.map +1 -1
- package/dist/modes/interactive/components/tool-title.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-title.js +0 -4
- package/dist/modes/interactive/components/tool-title.js.map +1 -1
- package/dist/modes/interactive/components/transcript-pager.d.ts +26 -0
- package/dist/modes/interactive/components/transcript-pager.d.ts.map +1 -0
- package/dist/modes/interactive/components/transcript-pager.js +81 -0
- package/dist/modes/interactive/components/transcript-pager.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -12
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +42 -402
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +4 -16
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.js +2 -10
- package/dist/modes/interactive/components/usage-action-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +3 -6
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +0 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/config-backup.d.ts.map +1 -1
- package/dist/modes/interactive/config-backup.js.map +1 -1
- package/dist/modes/interactive/editor-overlay-host.d.ts.map +1 -1
- package/dist/modes/interactive/editor-overlay-host.js +0 -3
- package/dist/modes/interactive/editor-overlay-host.js.map +1 -1
- package/dist/modes/interactive/extension-ui-host.d.ts +2 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
- package/dist/modes/interactive/extension-ui-host.js +51 -72
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -15
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
- package/dist/modes/interactive/history-reload-math.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.js +23 -16
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +13 -4
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +126 -207
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-selection-prompts.d.ts +20 -0
- package/dist/modes/interactive/interactive-selection-prompts.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-selection-prompts.js +43 -0
- package/dist/modes/interactive/interactive-selection-prompts.js.map +1 -0
- package/dist/modes/interactive/key-handlers.d.ts +2 -1
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/key-handlers.js +4 -2
- package/dist/modes/interactive/key-handlers.js.map +1 -1
- package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -1
- package/dist/modes/interactive/loaded-resources-view.js.map +1 -1
- package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
- package/dist/modes/interactive/local-model-commands.js +4 -9
- package/dist/modes/interactive/local-model-commands.js.map +1 -1
- package/dist/modes/interactive/model-fitness-presentation.d.ts +21 -0
- package/dist/modes/interactive/model-fitness-presentation.d.ts.map +1 -0
- package/dist/modes/interactive/model-fitness-presentation.js +13 -0
- package/dist/modes/interactive/model-fitness-presentation.js.map +1 -0
- package/dist/modes/interactive/profile-menu-controller.d.ts +2 -0
- package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.js +79 -171
- package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts +2 -0
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +12 -6
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/resource-display.d.ts.map +1 -1
- package/dist/modes/interactive/resource-display.js.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.js +6 -23
- package/dist/modes/interactive/resource-shell-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +21 -25
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-io-commands.js.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.js.map +1 -1
- package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
- package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
- package/dist/modes/interactive/signal-lifecycle.d.ts.map +1 -1
- package/dist/modes/interactive/signal-lifecycle.js.map +1 -1
- package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
- package/dist/modes/interactive/startup-checks.js +12 -8
- package/dist/modes/interactive/startup-checks.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +10 -76
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/usage-commands.d.ts.map +1 -1
- package/dist/modes/interactive/usage-commands.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +5 -22
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/jsonl.d.ts.map +1 -1
- package/dist/modes/rpc/jsonl.js +1 -1
- package/dist/modes/rpc/jsonl.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +7 -8
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +5 -20
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/modes/termination-signals.d.ts +4 -0
- package/dist/modes/termination-signals.d.ts.map +1 -0
- package/dist/modes/termination-signals.js +21 -0
- package/dist/modes/termination-signals.js.map +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/ansi-colors.d.ts +5 -0
- package/dist/utils/ansi-colors.d.ts.map +1 -0
- package/dist/utils/ansi-colors.js +38 -0
- package/dist/utils/ansi-colors.js.map +1 -0
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/deprecation.d.ts.map +1 -1
- package/dist/utils/deprecation.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/external-editor-command.d.ts.map +1 -1
- package/dist/utils/external-editor-command.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js.map +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +20 -28
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/highlight-js-languages.d.ts.map +1 -1
- package/dist/utils/html.d.ts.map +1 -1
- package/dist/utils/html.js.map +1 -1
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/image-resize-worker.d.ts.map +1 -1
- package/dist/utils/image-resize-worker.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/json.d.ts.map +1 -1
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/open-browser.d.ts.map +1 -1
- package/dist/utils/open-browser.js.map +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/pi-user-agent.d.ts.map +1 -1
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/dist/utils/platform.d.ts.map +1 -1
- package/dist/utils/platform.js.map +1 -1
- package/dist/utils/process-memory.d.ts.map +1 -1
- package/dist/utils/process-memory.js.map +1 -1
- package/dist/utils/safe-write-stream.d.ts.map +1 -1
- package/dist/utils/safe-write-stream.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/sleep.d.ts.map +1 -1
- package/dist/utils/sleep.js +2 -15
- package/dist/utils/sleep.js.map +1 -1
- package/dist/utils/stdin-events.d.ts +8 -0
- package/dist/utils/stdin-events.d.ts.map +1 -0
- package/dist/utils/stdin-events.js +19 -0
- package/dist/utils/stdin-events.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +20 -13
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +6 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +59 -2
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/windows-self-update.d.ts.map +1 -1
- package/dist/utils/windows-self-update.js.map +1 -1
- package/dist/utils/work-directory.d.ts.map +1 -1
- package/dist/utils/work-directory.js.map +1 -1
- package/docs/compaction.md +11 -3
- package/docs/development.md +1 -1
- package/docs/sessions.md +6 -0
- package/docs/settings.md +1 -1
- package/docs/windows.md +28 -3
- package/docs/work-directory.md +10 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +27 -27
- package/package.json +11 -11
- package/dist/utils/streaming-lines.d.ts +0 -20
- package/dist/utils/streaming-lines.d.ts.map +0 -1
- package/dist/utils/streaming-lines.js +0 -79
- package/dist/utils/streaming-lines.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-write-reservation.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-write-reservation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAkB,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACN,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA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AG,KAAK,CAAC,YAAY;iBACjC,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,iBAAiB,KAAK,SAAS,CAAC,iBAAiB,CAAC;iBACtF,GAAG,CAAC,CAAC,WAAW,EAAyC,EAAE,CAAC;gBAC5D,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;gBACtD,OAAO;oBACN,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,qBAAqB;oBAC1F,aAAa,EAAE,WAAW,CAAC,aAAa;oBACxC,KAAK,EAAE,eAAe,CAAC,QAAQ,EAAE,WAAW,CAAC;iBAC7C,CAAC;YAAA,CACF,CAAC,CAAC;YACJ,OAAO,EAAE,QAAQ,EAAE,CAAC;QAAA,CACpB,CAAC,CAAC;IAAA,CACH;IAEO,UAAU,CAAC,QAAgB,EAAE,cAAsB,EAA6B;QACvF,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;QACtG,OAAO,UAAU,CAChB,uBAAuB,CAAC,QAAQ,EAAE,cAAc,EAAE,gCAAgC,CAAC,EACnF,cAAc,CACd,CAAC;IAAA,CACF;CACD","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport { existsSync, type FSWatcher, mkdirSync, unlinkSync, watch } from \"node:fs\";\nimport { basename, dirname } from \"node:path\";\nimport { stateFile } from \"../agent-paths.ts\";\nimport {\n\tcanonicalPathScopeIdentity,\n\tisPathWithinScope,\n\tpathScopesOverlap,\n\tsafeRealpathSync,\n} from \"../autonomy/path-scope.ts\";\nimport { withFileLockSync, writeFileAtomicSync } from \"../util/atomic-file.ts\";\nimport { readBoundedTextFileSync } from \"../util/bounded-file.ts\";\nimport { requireBoundedTrimmedText } from \"../util/bounded-value.ts\";\nimport { parseLocalWorkerProcessOwnerId } from \"./worker-process-owner.ts\";\n\nconst SCHEMA_VERSION = 1;\nconst MAX_IDENTIFIER_CHARS = 256;\nconst MAX_PATH_CHARS = 4096;\nconst MAX_SCOPES = 32;\nconst MAX_RESERVATIONS = 64;\nconst MAX_FILE_BYTES = 128 * 1024;\nconst availabilityListeners = new Map<string, Set<() => void>>();\n\ntype WatchDirectory = (\n\tdirectory: string,\n\toptions: { persistent: boolean },\n\tlistener: (eventType: string, fileName: string | Buffer | null) => void,\n) => FSWatcher;\n\nexport interface WorkerWriteReservationWorkspace {\n\t/** Canonical repository/workspace root shared by primary and isolated worktrees. */\n\trepositoryRoot: string;\n\t/** Actual checkout used by this attempt. A non-primary checkout requires an isolation identity. */\n\texecutionRoot: string;\n\t/** Durable worktree identity supplied by the worktree owner, never a model-provided label. */\n\tisolatedWorktreeId?: string;\n}\n\nexport interface WorkerWriteReservationRequest {\n\tparentSessionId: string;\n\t/** Exact pi-owned process instance that acquired this reservation. */\n\townerId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tfencingToken: number;\n\taccess: \"read\" | \"write\";\n\tworkspace: WorkerWriteReservationWorkspace;\n\t/** Absolute authorized write roots. They are resolved before persistence. */\n\twriteScopes: readonly string[];\n}\n\nexport interface WorkerWriteReservationLease {\n\tfilePath: string;\n\treservationId: string;\n\tparentSessionId: string;\n\townerId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tfencingToken: number;\n\trepositoryRoot: string;\n\texecutionRoot: string;\n\texecutionIdentity: string;\n\tisolatedWorktreeId?: string;\n\twriteScopes: readonly string[];\n}\n\nexport type WorkerWriteReservationAcquireResult =\n\t| { kind: \"granted\"; lease?: WorkerWriteReservationLease }\n\t| {\n\t\t\tkind: \"blocked\";\n\t\t\treasonCode: \"overlapping_write_scope\" | \"attempt_reservation_conflict\" | \"reservation_capacity_reached\";\n\t\t\tconflictingReservationIds?: readonly string[];\n\t };\n\nexport type WorkerWriteReservationReleaseResult =\n\t| { kind: \"released\" }\n\t| { kind: \"stale_fence\" }\n\t| { kind: \"not_found\" };\n\nexport type WorkerWriteReservationEvidenceState = \"live\" | \"not_live\" | \"unknown\";\n\nexport interface WorkerWriteReservationRecoveryEvidence {\n\treservationId: string;\n\tstate: WorkerWriteReservationEvidenceState;\n}\n\nexport interface WorkerWriteReservationRecoveryRequest {\n\tworkspace: WorkerWriteReservationWorkspace;\n\t/** Caller-owned lease observations. This store never polls process state or worker output. */\n\tevidence: readonly WorkerWriteReservationRecoveryEvidence[];\n}\n\nexport interface WorkerWriteReservationRecoveryOutcome {\n\tkind: \"active\" | \"stale\" | \"inspection_required\";\n\treservationId: string;\n\tlease: WorkerWriteReservationLease;\n}\n\ninterface PersistedReservation {\n\treservationId: string;\n\tparentSessionId: string;\n\townerId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tfencingToken: number;\n\trepositoryRoot: string;\n\texecutionRoot: string;\n\texecutionIdentity: string;\n\tisolatedWorktreeId?: string;\n\twriteScopes: string[];\n\tcreatedAt: string;\n}\n\ninterface PersistedReservationStore {\n\tschemaVersion: number;\n\trepositoryRoot: string;\n\treservations: PersistedReservation[];\n}\n\ninterface CanonicalWorkspace {\n\trepositoryRoot: string;\n\texecutionRoot: string;\n\texecutionIdentity: string;\n\tisolatedWorktreeId?: string;\n}\n\nfunction positiveFencingToken(value: number): number {\n\tif (!Number.isSafeInteger(value) || value < 1) throw new TypeError(\"Fencing token must be a positive safe integer.\");\n\treturn value;\n}\n\n/**\n * Prefer a real path for filesystem-backed scopes, but preserve a foreign lexical path family\n * (for example a Windows drive path inspected from WSL) so shared path-scope helpers retain\n * their documented Windows drive/UNC comparison semantics.\n */\nfunction canonicalRealOrLexicalPath(value: string, label: string): string {\n\tconst lexical = canonicalPathScopeIdentity(requireBoundedTrimmedText(value, MAX_PATH_CHARS, label));\n\tconst resolved = safeRealpathSync(lexical);\n\treturn pathScopesOverlap(lexical, resolved) ? canonicalPathScopeIdentity(resolved) : lexical;\n}\n\nfunction canonicalWorkspace(workspace: WorkerWriteReservationWorkspace): CanonicalWorkspace {\n\tconst repositoryRoot = canonicalRealOrLexicalPath(workspace.repositoryRoot, \"Repository root\");\n\tconst executionRoot = canonicalRealOrLexicalPath(workspace.executionRoot, \"Execution root\");\n\tconst isolatedWorktreeId = workspace.isolatedWorktreeId\n\t\t? requireBoundedTrimmedText(workspace.isolatedWorktreeId, MAX_IDENTIFIER_CHARS, \"Isolated worktree id\")\n\t\t: undefined;\n\tconst isPrimaryExecutionRoot =\n\t\tisPathWithinScope(executionRoot, repositoryRoot) && isPathWithinScope(repositoryRoot, executionRoot);\n\tif (isPrimaryExecutionRoot && isolatedWorktreeId) {\n\t\tthrow new TypeError(\"An isolated worktree execution root must differ from the shared repository root.\");\n\t}\n\tif (!isPrimaryExecutionRoot && !isolatedWorktreeId) {\n\t\tthrow new TypeError(\"A non-primary execution root requires an explicit isolated worktree identity.\");\n\t}\n\treturn {\n\t\trepositoryRoot,\n\t\texecutionRoot,\n\t\texecutionIdentity: isolatedWorktreeId ? `isolated:${executionRoot}` : `shared:${repositoryRoot}`,\n\t\t...(isolatedWorktreeId ? { isolatedWorktreeId } : {}),\n\t};\n}\n\nfunction reservationFile(agentDir: string, repositoryRoot: string): string {\n\tconst digest = createHash(\"sha256\")\n\t\t.update(\"pi-worker-write-reservations-v1\")\n\t\t.update(\"\\0\")\n\t\t.update(repositoryRoot)\n\t\t.digest(\"hex\");\n\treturn stateFile(agentDir, \"orchestration\", \"worker-write-reservations\", `${digest}.json`);\n}\n\nfunction notifyAvailability(filePath: string): void {\n\tfor (const listener of availabilityListeners.get(filePath) ?? []) queueMicrotask(listener);\n}\n\nfunction leaseFromRecord(filePath: string, record: PersistedReservation): WorkerWriteReservationLease {\n\treturn {\n\t\tfilePath,\n\t\treservationId: record.reservationId,\n\t\tparentSessionId: record.parentSessionId,\n\t\townerId: record.ownerId,\n\t\ttaskId: record.taskId,\n\t\tattemptId: record.attemptId,\n\t\tfencingToken: record.fencingToken,\n\t\trepositoryRoot: record.repositoryRoot,\n\t\texecutionRoot: record.executionRoot,\n\t\texecutionIdentity: record.executionIdentity,\n\t\t...(record.isolatedWorktreeId ? { isolatedWorktreeId: record.isolatedWorktreeId } : {}),\n\t\twriteScopes: [...record.writeScopes],\n\t};\n}\n\nfunction stringField(value: unknown, label: string, maximum: number): string {\n\tif (typeof value !== \"string\") throw new Error(`Worker write reservation ${label} is invalid.`);\n\treturn requireBoundedTrimmedText(value, maximum, `Worker write reservation ${label}`);\n}\n\nfunction localOwnerId(value: unknown): string {\n\tconst ownerId = stringField(value, \"owner id\", MAX_IDENTIFIER_CHARS);\n\tif (!parseLocalWorkerProcessOwnerId(ownerId)) throw new Error(\"Worker write reservation owner id is invalid.\");\n\treturn ownerId;\n}\n\nfunction parseReservation(value: unknown, repositoryRoot: string): PersistedReservation {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value))\n\t\tthrow new Error(\"Worker write reservation entry is invalid.\");\n\tconst entry = value as Record<string, unknown>;\n\tconst fencingToken = entry.fencingToken;\n\tif (typeof fencingToken !== \"number\") throw new Error(\"Worker write reservation fencing token is invalid.\");\n\tconst parsedRepositoryRoot = stringField(entry.repositoryRoot, \"repository root\", MAX_PATH_CHARS);\n\tif (parsedRepositoryRoot !== repositoryRoot)\n\t\tthrow new Error(\"Worker write reservation repository root conflicts with its store.\");\n\tif (!Array.isArray(entry.writeScopes) || entry.writeScopes.length === 0 || entry.writeScopes.length > MAX_SCOPES) {\n\t\tthrow new Error(\"Worker write reservation scopes are invalid.\");\n\t}\n\tconst writeScopes = entry.writeScopes.map((scope) => stringField(scope, \"write scope\", MAX_PATH_CHARS));\n\tconst isolatedWorktreeId =\n\t\tentry.isolatedWorktreeId === undefined\n\t\t\t? undefined\n\t\t\t: stringField(entry.isolatedWorktreeId, \"isolated worktree id\", MAX_IDENTIFIER_CHARS);\n\treturn {\n\t\treservationId: stringField(entry.reservationId, \"id\", MAX_IDENTIFIER_CHARS),\n\t\tparentSessionId: stringField(entry.parentSessionId, \"parent session\", MAX_IDENTIFIER_CHARS),\n\t\townerId: localOwnerId(entry.ownerId),\n\t\ttaskId: stringField(entry.taskId, \"task\", MAX_IDENTIFIER_CHARS),\n\t\tattemptId: stringField(entry.attemptId, \"attempt\", MAX_IDENTIFIER_CHARS),\n\t\tfencingToken: positiveFencingToken(fencingToken),\n\t\trepositoryRoot: parsedRepositoryRoot,\n\t\texecutionRoot: stringField(entry.executionRoot, \"execution root\", MAX_PATH_CHARS),\n\t\texecutionIdentity: stringField(entry.executionIdentity, \"execution identity\", MAX_PATH_CHARS),\n\t\t...(isolatedWorktreeId ? { isolatedWorktreeId } : {}),\n\t\twriteScopes,\n\t\tcreatedAt: stringField(entry.createdAt, \"created time\", MAX_IDENTIFIER_CHARS),\n\t};\n}\n\nfunction parseStore(raw: string, repositoryRoot: string): PersistedReservationStore {\n\tif (Buffer.byteLength(raw, \"utf-8\") > MAX_FILE_BYTES)\n\t\tthrow new Error(\"Worker write reservation store exceeds its byte limit.\");\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(raw);\n\t} catch {\n\t\tthrow new Error(\"Worker write reservation store is unreadable; refusing concurrent write admission.\");\n\t}\n\tif (!value || typeof value !== \"object\" || Array.isArray(value))\n\t\tthrow new Error(\"Worker write reservation store is invalid.\");\n\tconst store = value as Record<string, unknown>;\n\tif (store.schemaVersion !== SCHEMA_VERSION) throw new Error(\"Worker write reservation store schema is unsupported.\");\n\tif (stringField(store.repositoryRoot, \"store repository root\", MAX_PATH_CHARS) !== repositoryRoot) {\n\t\tthrow new Error(\"Worker write reservation store root conflicts with the requested workspace.\");\n\t}\n\tif (!Array.isArray(store.reservations) || store.reservations.length > MAX_RESERVATIONS) {\n\t\tthrow new Error(\"Worker write reservation store entries are invalid.\");\n\t}\n\tconst reservations = store.reservations.map((entry) => parseReservation(entry, repositoryRoot));\n\tif (new Set(reservations.map((entry) => entry.reservationId)).size !== reservations.length) {\n\t\tthrow new Error(\"Worker write reservation store contains duplicate reservation identities.\");\n\t}\n\treturn { schemaVersion: SCHEMA_VERSION, repositoryRoot, reservations };\n}\n\nfunction writeStore(filePath: string, store: PersistedReservationStore): void {\n\tconst serialized = `${JSON.stringify(store)}\\n`;\n\tif (Buffer.byteLength(serialized, \"utf-8\") > MAX_FILE_BYTES) {\n\t\tthrow new Error(\"Worker write reservation store would exceed its byte limit.\");\n\t}\n\twriteFileAtomicSync(filePath, serialized, { mode: 0o600 });\n}\n\nfunction overlappingReservationIds(\n\treservations: readonly PersistedReservation[],\n\texecutionIdentity: string,\n\twriteScopes: readonly string[],\n): string[] {\n\tconst matches: string[] = [];\n\tfor (const reservation of reservations) {\n\t\tif (reservation.executionIdentity !== executionIdentity) continue;\n\t\tif (\n\t\t\treservation.writeScopes.some((reservedScope) =>\n\t\t\t\twriteScopes.some((requestedScope) => pathScopesOverlap(reservedScope, requestedScope)),\n\t\t\t)\n\t\t) {\n\t\t\tmatches.push(reservation.reservationId);\n\t\t}\n\t}\n\treturn matches;\n}\n\n/**\n * Cross-process, agent-owned admission seam for concurrent worker mutations. It owns only\n * reservations; lifecycle, process liveness, and terminal status remain controller concerns.\n */\nexport class WorkerWriteReservationStore {\n\tprivate readonly agentDir: string;\n\tprivate readonly watchDirectory: WatchDirectory;\n\n\tconstructor(options: { agentDir: string; watchDirectory?: WatchDirectory }) {\n\t\tthis.agentDir = requireBoundedTrimmedText(options.agentDir, MAX_PATH_CHARS, \"Agent directory\");\n\t\tthis.watchDirectory = options.watchDirectory ?? watch;\n\t}\n\n\tacquire(request: WorkerWriteReservationRequest): WorkerWriteReservationAcquireResult {\n\t\tif (request.access === \"read\") return { kind: \"granted\" };\n\t\tif (request.access !== \"write\") throw new TypeError(\"Worker write reservation access must be read or write.\");\n\t\tif (request.writeScopes.length === 0 || request.writeScopes.length > MAX_SCOPES) {\n\t\t\tthrow new TypeError(`Write reservations require from 1 through ${MAX_SCOPES} write scopes.`);\n\t\t}\n\t\tconst workspace = canonicalWorkspace(request.workspace);\n\t\tconst writeScopes = [\n\t\t\t...new Set(request.writeScopes.map((scope) => canonicalRealOrLexicalPath(scope, \"Write scope\"))),\n\t\t].sort();\n\t\tif (writeScopes.some((scope) => !isPathWithinScope(scope, workspace.executionRoot))) {\n\t\t\tthrow new TypeError(\"Write reservation scopes must be within the execution root.\");\n\t\t}\n\t\tconst parentSessionId = requireBoundedTrimmedText(\n\t\t\trequest.parentSessionId,\n\t\t\tMAX_IDENTIFIER_CHARS,\n\t\t\t\"Parent session id\",\n\t\t);\n\t\tconst ownerId = localOwnerId(request.ownerId);\n\t\tconst taskId = requireBoundedTrimmedText(request.taskId, MAX_IDENTIFIER_CHARS, \"Task id\");\n\t\tconst attemptId = requireBoundedTrimmedText(request.attemptId, MAX_IDENTIFIER_CHARS, \"Attempt id\");\n\t\tconst fencingToken = positiveFencingToken(request.fencingToken);\n\t\tconst filePath = reservationFile(this.agentDir, workspace.repositoryRoot);\n\n\t\treturn withFileLockSync(filePath, () => {\n\t\t\tconst store = this.readLocked(filePath, workspace.repositoryRoot);\n\t\t\tconst matchingAttempt = store.reservations.find(\n\t\t\t\t(reservation) =>\n\t\t\t\t\treservation.parentSessionId === parentSessionId &&\n\t\t\t\t\treservation.ownerId === ownerId &&\n\t\t\t\t\treservation.taskId === taskId &&\n\t\t\t\t\treservation.attemptId === attemptId &&\n\t\t\t\t\treservation.fencingToken === fencingToken,\n\t\t\t);\n\t\t\tif (matchingAttempt) {\n\t\t\t\tif (\n\t\t\t\t\tmatchingAttempt.executionIdentity !== workspace.executionIdentity ||\n\t\t\t\t\tmatchingAttempt.isolatedWorktreeId !== workspace.isolatedWorktreeId ||\n\t\t\t\t\tmatchingAttempt.writeScopes.length !== writeScopes.length ||\n\t\t\t\t\tmatchingAttempt.writeScopes.some((scope, index) => scope !== writeScopes[index])\n\t\t\t\t) {\n\t\t\t\t\treturn { kind: \"blocked\", reasonCode: \"attempt_reservation_conflict\" };\n\t\t\t\t}\n\t\t\t\treturn { kind: \"granted\", lease: leaseFromRecord(filePath, matchingAttempt) };\n\t\t\t}\n\t\t\tconst conflicts = overlappingReservationIds(store.reservations, workspace.executionIdentity, writeScopes);\n\t\t\tif (conflicts.length > 0) {\n\t\t\t\treturn { kind: \"blocked\", reasonCode: \"overlapping_write_scope\", conflictingReservationIds: conflicts };\n\t\t\t}\n\t\t\tif (store.reservations.length >= MAX_RESERVATIONS)\n\t\t\t\treturn { kind: \"blocked\", reasonCode: \"reservation_capacity_reached\" };\n\t\t\tconst record: PersistedReservation = {\n\t\t\t\treservationId: randomUUID(),\n\t\t\t\tparentSessionId,\n\t\t\t\townerId,\n\t\t\t\ttaskId,\n\t\t\t\tattemptId,\n\t\t\t\tfencingToken,\n\t\t\t\trepositoryRoot: workspace.repositoryRoot,\n\t\t\t\texecutionRoot: workspace.executionRoot,\n\t\t\t\texecutionIdentity: workspace.executionIdentity,\n\t\t\t\t...(workspace.isolatedWorktreeId ? { isolatedWorktreeId: workspace.isolatedWorktreeId } : {}),\n\t\t\t\twriteScopes,\n\t\t\t\tcreatedAt: new Date().toISOString(),\n\t\t\t};\n\t\t\tstore.reservations.push(record);\n\t\t\twriteStore(filePath, store);\n\t\t\treturn { kind: \"granted\", lease: leaseFromRecord(filePath, record) };\n\t\t});\n\t}\n\n\trelease(lease: WorkerWriteReservationLease): WorkerWriteReservationReleaseResult {\n\t\tconst repositoryRoot = requireBoundedTrimmedText(lease.repositoryRoot, MAX_PATH_CHARS, \"Lease repository root\");\n\t\tconst ownerId = localOwnerId(lease.ownerId);\n\t\tconst expectedFilePath = reservationFile(this.agentDir, repositoryRoot);\n\t\tif (lease.filePath !== expectedFilePath)\n\t\t\tthrow new TypeError(\"Worker write reservation lease does not belong to this agent state.\");\n\t\treturn withFileLockSync(expectedFilePath, () => {\n\t\t\tconst store = this.readLocked(expectedFilePath, repositoryRoot);\n\t\t\tconst index = store.reservations.findIndex((reservation) => reservation.reservationId === lease.reservationId);\n\t\t\tif (index < 0) {\n\t\t\t\tconst supersedingReservation = store.reservations.some(\n\t\t\t\t\t(reservation) =>\n\t\t\t\t\t\treservation.parentSessionId === lease.parentSessionId &&\n\t\t\t\t\t\treservation.ownerId === ownerId &&\n\t\t\t\t\t\treservation.taskId === lease.taskId &&\n\t\t\t\t\t\treservation.fencingToken > lease.fencingToken,\n\t\t\t\t);\n\t\t\t\treturn { kind: supersedingReservation ? \"stale_fence\" : \"not_found\" };\n\t\t\t}\n\t\t\tconst record = store.reservations[index];\n\t\t\tif (\n\t\t\t\trecord.parentSessionId !== lease.parentSessionId ||\n\t\t\t\trecord.ownerId !== ownerId ||\n\t\t\t\trecord.taskId !== lease.taskId ||\n\t\t\t\trecord.attemptId !== lease.attemptId ||\n\t\t\t\trecord.fencingToken !== lease.fencingToken ||\n\t\t\t\trecord.executionIdentity !== lease.executionIdentity ||\n\t\t\t\trecord.isolatedWorktreeId !== lease.isolatedWorktreeId\n\t\t\t) {\n\t\t\t\treturn { kind: \"stale_fence\" };\n\t\t\t}\n\t\t\tstore.reservations.splice(index, 1);\n\t\t\tif (store.reservations.length === 0) unlinkSync(expectedFilePath);\n\t\t\telse writeStore(expectedFilePath, store);\n\t\t\tnotifyAvailability(expectedFilePath);\n\t\t\treturn { kind: \"released\" };\n\t\t});\n\t}\n\n\t/** Event-driven cross-process wakeup for queued write admission; caller owns disposal. */\n\twatchAvailability(workspace: WorkerWriteReservationWorkspace, listener: () => void): () => void {\n\t\tconst canonical = canonicalWorkspace(workspace);\n\t\tconst filePath = reservationFile(this.agentDir, canonical.repositoryRoot);\n\t\tconst listeners = availabilityListeners.get(filePath) ?? new Set<() => void>();\n\t\tavailabilityListeners.set(filePath, listeners);\n\t\tlisteners.add(listener);\n\t\tconst directory = dirname(filePath);\n\t\tmkdirSync(directory, { recursive: true });\n\t\tlet scheduled = false;\n\t\tconst schedule = () => {\n\t\t\tif (scheduled) return;\n\t\t\tscheduled = true;\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tscheduled = false;\n\t\t\t\tlistener();\n\t\t\t});\n\t\t};\n\t\tconst watcher = this.watchDirectory(directory, { persistent: false }, (_eventType, fileName) => {\n\t\t\t// Node may omit a filename (notably on Windows), or provide a Buffer when the watcher is\n\t\t\t// configured that way. An unknown filename is conservatively treated as a wake signal: the\n\t\t\t// scheduler re-evaluates durable admission, so this cannot grant access by itself.\n\t\t\tif (fileName === null) {\n\t\t\t\tschedule();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst normalizedName = Buffer.isBuffer(fileName) ? fileName.toString(\"utf-8\") : fileName;\n\t\t\tif (normalizedName === basename(filePath)) schedule();\n\t\t});\n\t\treturn () => {\n\t\t\tlisteners.delete(listener);\n\t\t\tif (listeners.size === 0) availabilityListeners.delete(filePath);\n\t\t\twatcher.close();\n\t\t};\n\t}\n\n\trecover(request: WorkerWriteReservationRecoveryRequest): { outcomes: WorkerWriteReservationRecoveryOutcome[] } {\n\t\tconst workspace = canonicalWorkspace(request.workspace);\n\t\tconst filePath = reservationFile(this.agentDir, workspace.repositoryRoot);\n\t\tconst evidence = new Map<string, WorkerWriteReservationEvidenceState>();\n\t\tfor (const observation of request.evidence) {\n\t\t\tconst reservationId = requireBoundedTrimmedText(\n\t\t\t\tobservation.reservationId,\n\t\t\t\tMAX_IDENTIFIER_CHARS,\n\t\t\t\t\"Reservation evidence id\",\n\t\t\t);\n\t\t\tif (observation.state !== \"live\" && observation.state !== \"not_live\" && observation.state !== \"unknown\") {\n\t\t\t\tthrow new TypeError(\"Reservation evidence state must be live, not_live, or unknown.\");\n\t\t\t}\n\t\t\tif (evidence.has(reservationId)) throw new TypeError(\"Reservation evidence must not repeat an identity.\");\n\t\t\tevidence.set(reservationId, observation.state);\n\t\t}\n\t\treturn withFileLockSync(filePath, () => {\n\t\t\tconst store = this.readLocked(filePath, workspace.repositoryRoot);\n\t\t\tconst outcomes = store.reservations\n\t\t\t\t.filter((reservation) => reservation.executionIdentity === workspace.executionIdentity)\n\t\t\t\t.map((reservation): WorkerWriteReservationRecoveryOutcome => {\n\t\t\t\t\tconst state = evidence.get(reservation.reservationId);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkind: state === \"live\" ? \"active\" : state === \"not_live\" ? \"stale\" : \"inspection_required\",\n\t\t\t\t\t\treservationId: reservation.reservationId,\n\t\t\t\t\t\tlease: leaseFromRecord(filePath, reservation),\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\treturn { outcomes };\n\t\t});\n\t}\n\n\tprivate readLocked(filePath: string, repositoryRoot: string): PersistedReservationStore {\n\t\tif (!existsSync(filePath)) return { schemaVersion: SCHEMA_VERSION, repositoryRoot, reservations: [] };\n\t\treturn parseStore(\n\t\t\treadBoundedTextFileSync(filePath, MAX_FILE_BYTES, \"Worker write reservation store\"),\n\t\t\trepositoryRoot,\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"worker-write-reservation.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-write-reservation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAkB,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACN,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAE3E,M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,GAAG,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;gBACtD,OAAO;oBACN,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,qBAAqB;oBAC1F,aAAa,EAAE,WAAW,CAAC,aAAa;oBACxC,KAAK,EAAE,eAAe,CAAC,QAAQ,EAAE,WAAW,CAAC;iBAC7C,CAAC;YACH,CAAC,CAAC,CAAC;YACJ,OAAO,EAAE,QAAQ,EAAE,CAAC;QACrB,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,UAAU,CAAC,QAAgB,EAAE,cAAsB;QAC1D,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;QACtG,OAAO,UAAU,CAChB,uBAAuB,CAAC,QAAQ,EAAE,cAAc,EAAE,gCAAgC,CAAC,EACnF,cAAc,CACd,CAAC;IACH,CAAC;CACD","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport { existsSync, type FSWatcher, mkdirSync, unlinkSync, watch } from \"node:fs\";\nimport { basename, dirname } from \"node:path\";\nimport { stateFile } from \"../agent-paths.ts\";\nimport {\n\tcanonicalPathScopeIdentity,\n\tisPathWithinScope,\n\tpathScopesOverlap,\n\tsafeRealpathSync,\n} from \"../autonomy/path-scope.ts\";\nimport { withFileLockSync, writeFileAtomicSync } from \"../util/atomic-file.ts\";\nimport { readBoundedTextFileSync } from \"../util/bounded-file.ts\";\nimport { requireBoundedTrimmedText } from \"../util/bounded-value.ts\";\nimport { parseLocalWorkerProcessOwnerId } from \"./worker-process-owner.ts\";\n\nconst SCHEMA_VERSION = 1;\nconst MAX_IDENTIFIER_CHARS = 256;\nconst MAX_PATH_CHARS = 4096;\nconst MAX_SCOPES = 32;\nconst MAX_RESERVATIONS = 64;\nconst MAX_FILE_BYTES = 128 * 1024;\nconst availabilityListeners = new Map<string, Set<() => void>>();\n\ntype WatchDirectory = (\n\tdirectory: string,\n\toptions: { persistent: boolean },\n\tlistener: (eventType: string, fileName: string | Buffer | null) => void,\n) => FSWatcher;\n\nexport interface WorkerWriteReservationWorkspace {\n\t/** Canonical repository/workspace root shared by primary and isolated worktrees. */\n\trepositoryRoot: string;\n\t/** Actual checkout used by this attempt. A non-primary checkout requires an isolation identity. */\n\texecutionRoot: string;\n\t/** Durable worktree identity supplied by the worktree owner, never a model-provided label. */\n\tisolatedWorktreeId?: string;\n}\n\nexport interface WorkerWriteReservationRequest {\n\tparentSessionId: string;\n\t/** Exact pi-owned process instance that acquired this reservation. */\n\townerId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tfencingToken: number;\n\taccess: \"read\" | \"write\";\n\tworkspace: WorkerWriteReservationWorkspace;\n\t/** Absolute authorized write roots. They are resolved before persistence. */\n\twriteScopes: readonly string[];\n}\n\nexport interface WorkerWriteReservationLease {\n\tfilePath: string;\n\treservationId: string;\n\tparentSessionId: string;\n\townerId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tfencingToken: number;\n\trepositoryRoot: string;\n\texecutionRoot: string;\n\texecutionIdentity: string;\n\tisolatedWorktreeId?: string;\n\twriteScopes: readonly string[];\n}\n\nexport type WorkerWriteReservationAcquireResult =\n\t| { kind: \"granted\"; lease?: WorkerWriteReservationLease }\n\t| {\n\t\t\tkind: \"blocked\";\n\t\t\treasonCode: \"overlapping_write_scope\" | \"attempt_reservation_conflict\" | \"reservation_capacity_reached\";\n\t\t\tconflictingReservationIds?: readonly string[];\n\t };\n\nexport type WorkerWriteReservationReleaseResult =\n\t| { kind: \"released\" }\n\t| { kind: \"stale_fence\" }\n\t| { kind: \"not_found\" };\n\nexport type WorkerWriteReservationEvidenceState = \"live\" | \"not_live\" | \"unknown\";\n\nexport interface WorkerWriteReservationRecoveryEvidence {\n\treservationId: string;\n\tstate: WorkerWriteReservationEvidenceState;\n}\n\nexport interface WorkerWriteReservationRecoveryRequest {\n\tworkspace: WorkerWriteReservationWorkspace;\n\t/** Caller-owned lease observations. This store never polls process state or worker output. */\n\tevidence: readonly WorkerWriteReservationRecoveryEvidence[];\n}\n\nexport interface WorkerWriteReservationRecoveryOutcome {\n\tkind: \"active\" | \"stale\" | \"inspection_required\";\n\treservationId: string;\n\tlease: WorkerWriteReservationLease;\n}\n\ninterface PersistedReservation {\n\treservationId: string;\n\tparentSessionId: string;\n\townerId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tfencingToken: number;\n\trepositoryRoot: string;\n\texecutionRoot: string;\n\texecutionIdentity: string;\n\tisolatedWorktreeId?: string;\n\twriteScopes: string[];\n\tcreatedAt: string;\n}\n\ninterface PersistedReservationStore {\n\tschemaVersion: number;\n\trepositoryRoot: string;\n\treservations: PersistedReservation[];\n}\n\ninterface CanonicalWorkspace {\n\trepositoryRoot: string;\n\texecutionRoot: string;\n\texecutionIdentity: string;\n\tisolatedWorktreeId?: string;\n}\n\nfunction positiveFencingToken(value: number): number {\n\tif (!Number.isSafeInteger(value) || value < 1) throw new TypeError(\"Fencing token must be a positive safe integer.\");\n\treturn value;\n}\n\n/**\n * Prefer a real path for filesystem-backed scopes, but preserve a foreign lexical path family\n * (for example a Windows drive path inspected from WSL) so shared path-scope helpers retain\n * their documented Windows drive/UNC comparison semantics.\n */\nfunction canonicalRealOrLexicalPath(value: string, label: string): string {\n\tconst lexical = canonicalPathScopeIdentity(requireBoundedTrimmedText(value, MAX_PATH_CHARS, label));\n\tconst resolved = safeRealpathSync(lexical);\n\treturn pathScopesOverlap(lexical, resolved) ? canonicalPathScopeIdentity(resolved) : lexical;\n}\n\nfunction canonicalWorkspace(workspace: WorkerWriteReservationWorkspace): CanonicalWorkspace {\n\tconst repositoryRoot = canonicalRealOrLexicalPath(workspace.repositoryRoot, \"Repository root\");\n\tconst executionRoot = canonicalRealOrLexicalPath(workspace.executionRoot, \"Execution root\");\n\tconst isolatedWorktreeId = workspace.isolatedWorktreeId\n\t\t? requireBoundedTrimmedText(workspace.isolatedWorktreeId, MAX_IDENTIFIER_CHARS, \"Isolated worktree id\")\n\t\t: undefined;\n\tconst isPrimaryExecutionRoot =\n\t\tisPathWithinScope(executionRoot, repositoryRoot) && isPathWithinScope(repositoryRoot, executionRoot);\n\tif (isPrimaryExecutionRoot && isolatedWorktreeId) {\n\t\tthrow new TypeError(\"An isolated worktree execution root must differ from the shared repository root.\");\n\t}\n\tif (!isPrimaryExecutionRoot && !isolatedWorktreeId) {\n\t\tthrow new TypeError(\"A non-primary execution root requires an explicit isolated worktree identity.\");\n\t}\n\treturn {\n\t\trepositoryRoot,\n\t\texecutionRoot,\n\t\texecutionIdentity: isolatedWorktreeId ? `isolated:${executionRoot}` : `shared:${repositoryRoot}`,\n\t\t...(isolatedWorktreeId ? { isolatedWorktreeId } : {}),\n\t};\n}\n\nfunction reservationFile(agentDir: string, repositoryRoot: string): string {\n\tconst digest = createHash(\"sha256\")\n\t\t.update(\"pi-worker-write-reservations-v1\")\n\t\t.update(\"\\0\")\n\t\t.update(repositoryRoot)\n\t\t.digest(\"hex\");\n\treturn stateFile(agentDir, \"orchestration\", \"worker-write-reservations\", `${digest}.json`);\n}\n\nfunction notifyAvailability(filePath: string): void {\n\tfor (const listener of availabilityListeners.get(filePath) ?? []) queueMicrotask(listener);\n}\n\nfunction leaseFromRecord(filePath: string, record: PersistedReservation): WorkerWriteReservationLease {\n\treturn {\n\t\tfilePath,\n\t\treservationId: record.reservationId,\n\t\tparentSessionId: record.parentSessionId,\n\t\townerId: record.ownerId,\n\t\ttaskId: record.taskId,\n\t\tattemptId: record.attemptId,\n\t\tfencingToken: record.fencingToken,\n\t\trepositoryRoot: record.repositoryRoot,\n\t\texecutionRoot: record.executionRoot,\n\t\texecutionIdentity: record.executionIdentity,\n\t\t...(record.isolatedWorktreeId ? { isolatedWorktreeId: record.isolatedWorktreeId } : {}),\n\t\twriteScopes: [...record.writeScopes],\n\t};\n}\n\nfunction stringField(value: unknown, label: string, maximum: number): string {\n\tif (typeof value !== \"string\") throw new Error(`Worker write reservation ${label} is invalid.`);\n\treturn requireBoundedTrimmedText(value, maximum, `Worker write reservation ${label}`);\n}\n\nfunction localOwnerId(value: unknown): string {\n\tconst ownerId = stringField(value, \"owner id\", MAX_IDENTIFIER_CHARS);\n\tif (!parseLocalWorkerProcessOwnerId(ownerId)) throw new Error(\"Worker write reservation owner id is invalid.\");\n\treturn ownerId;\n}\n\nfunction parseReservation(value: unknown, repositoryRoot: string): PersistedReservation {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value))\n\t\tthrow new Error(\"Worker write reservation entry is invalid.\");\n\tconst entry = value as Record<string, unknown>;\n\tconst fencingToken = entry.fencingToken;\n\tif (typeof fencingToken !== \"number\") throw new Error(\"Worker write reservation fencing token is invalid.\");\n\tconst parsedRepositoryRoot = stringField(entry.repositoryRoot, \"repository root\", MAX_PATH_CHARS);\n\tif (parsedRepositoryRoot !== repositoryRoot)\n\t\tthrow new Error(\"Worker write reservation repository root conflicts with its store.\");\n\tif (!Array.isArray(entry.writeScopes) || entry.writeScopes.length === 0 || entry.writeScopes.length > MAX_SCOPES) {\n\t\tthrow new Error(\"Worker write reservation scopes are invalid.\");\n\t}\n\tconst writeScopes = entry.writeScopes.map((scope) => stringField(scope, \"write scope\", MAX_PATH_CHARS));\n\tconst isolatedWorktreeId =\n\t\tentry.isolatedWorktreeId === undefined\n\t\t\t? undefined\n\t\t\t: stringField(entry.isolatedWorktreeId, \"isolated worktree id\", MAX_IDENTIFIER_CHARS);\n\treturn {\n\t\treservationId: stringField(entry.reservationId, \"id\", MAX_IDENTIFIER_CHARS),\n\t\tparentSessionId: stringField(entry.parentSessionId, \"parent session\", MAX_IDENTIFIER_CHARS),\n\t\townerId: localOwnerId(entry.ownerId),\n\t\ttaskId: stringField(entry.taskId, \"task\", MAX_IDENTIFIER_CHARS),\n\t\tattemptId: stringField(entry.attemptId, \"attempt\", MAX_IDENTIFIER_CHARS),\n\t\tfencingToken: positiveFencingToken(fencingToken),\n\t\trepositoryRoot: parsedRepositoryRoot,\n\t\texecutionRoot: stringField(entry.executionRoot, \"execution root\", MAX_PATH_CHARS),\n\t\texecutionIdentity: stringField(entry.executionIdentity, \"execution identity\", MAX_PATH_CHARS),\n\t\t...(isolatedWorktreeId ? { isolatedWorktreeId } : {}),\n\t\twriteScopes,\n\t\tcreatedAt: stringField(entry.createdAt, \"created time\", MAX_IDENTIFIER_CHARS),\n\t};\n}\n\nfunction parseStore(raw: string, repositoryRoot: string): PersistedReservationStore {\n\tif (Buffer.byteLength(raw, \"utf-8\") > MAX_FILE_BYTES)\n\t\tthrow new Error(\"Worker write reservation store exceeds its byte limit.\");\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(raw);\n\t} catch {\n\t\tthrow new Error(\"Worker write reservation store is unreadable; refusing concurrent write admission.\");\n\t}\n\tif (!value || typeof value !== \"object\" || Array.isArray(value))\n\t\tthrow new Error(\"Worker write reservation store is invalid.\");\n\tconst store = value as Record<string, unknown>;\n\tif (store.schemaVersion !== SCHEMA_VERSION) throw new Error(\"Worker write reservation store schema is unsupported.\");\n\tif (stringField(store.repositoryRoot, \"store repository root\", MAX_PATH_CHARS) !== repositoryRoot) {\n\t\tthrow new Error(\"Worker write reservation store root conflicts with the requested workspace.\");\n\t}\n\tif (!Array.isArray(store.reservations) || store.reservations.length > MAX_RESERVATIONS) {\n\t\tthrow new Error(\"Worker write reservation store entries are invalid.\");\n\t}\n\tconst reservations = store.reservations.map((entry) => parseReservation(entry, repositoryRoot));\n\tif (new Set(reservations.map((entry) => entry.reservationId)).size !== reservations.length) {\n\t\tthrow new Error(\"Worker write reservation store contains duplicate reservation identities.\");\n\t}\n\treturn { schemaVersion: SCHEMA_VERSION, repositoryRoot, reservations };\n}\n\nfunction writeStore(filePath: string, store: PersistedReservationStore): void {\n\tconst serialized = `${JSON.stringify(store)}\\n`;\n\tif (Buffer.byteLength(serialized, \"utf-8\") > MAX_FILE_BYTES) {\n\t\tthrow new Error(\"Worker write reservation store would exceed its byte limit.\");\n\t}\n\twriteFileAtomicSync(filePath, serialized, { mode: 0o600 });\n}\n\nfunction overlappingReservationIds(\n\treservations: readonly PersistedReservation[],\n\texecutionIdentity: string,\n\twriteScopes: readonly string[],\n): string[] {\n\tconst matches: string[] = [];\n\tfor (const reservation of reservations) {\n\t\tif (reservation.executionIdentity !== executionIdentity) continue;\n\t\tif (\n\t\t\treservation.writeScopes.some((reservedScope) =>\n\t\t\t\twriteScopes.some((requestedScope) => pathScopesOverlap(reservedScope, requestedScope)),\n\t\t\t)\n\t\t) {\n\t\t\tmatches.push(reservation.reservationId);\n\t\t}\n\t}\n\treturn matches;\n}\n\n/**\n * Cross-process, agent-owned admission seam for concurrent worker mutations. It owns only\n * reservations; lifecycle, process liveness, and terminal status remain controller concerns.\n */\nexport class WorkerWriteReservationStore {\n\tprivate readonly agentDir: string;\n\tprivate readonly watchDirectory: WatchDirectory;\n\n\tconstructor(options: { agentDir: string; watchDirectory?: WatchDirectory }) {\n\t\tthis.agentDir = requireBoundedTrimmedText(options.agentDir, MAX_PATH_CHARS, \"Agent directory\");\n\t\tthis.watchDirectory = options.watchDirectory ?? watch;\n\t}\n\n\tacquire(request: WorkerWriteReservationRequest): WorkerWriteReservationAcquireResult {\n\t\tif (request.access === \"read\") return { kind: \"granted\" };\n\t\tif (request.access !== \"write\") throw new TypeError(\"Worker write reservation access must be read or write.\");\n\t\tif (request.writeScopes.length === 0 || request.writeScopes.length > MAX_SCOPES) {\n\t\t\tthrow new TypeError(`Write reservations require from 1 through ${MAX_SCOPES} write scopes.`);\n\t\t}\n\t\tconst workspace = canonicalWorkspace(request.workspace);\n\t\tconst writeScopes = [\n\t\t\t...new Set(request.writeScopes.map((scope) => canonicalRealOrLexicalPath(scope, \"Write scope\"))),\n\t\t].sort();\n\t\tif (writeScopes.some((scope) => !isPathWithinScope(scope, workspace.executionRoot))) {\n\t\t\tthrow new TypeError(\"Write reservation scopes must be within the execution root.\");\n\t\t}\n\t\tconst parentSessionId = requireBoundedTrimmedText(\n\t\t\trequest.parentSessionId,\n\t\t\tMAX_IDENTIFIER_CHARS,\n\t\t\t\"Parent session id\",\n\t\t);\n\t\tconst ownerId = localOwnerId(request.ownerId);\n\t\tconst taskId = requireBoundedTrimmedText(request.taskId, MAX_IDENTIFIER_CHARS, \"Task id\");\n\t\tconst attemptId = requireBoundedTrimmedText(request.attemptId, MAX_IDENTIFIER_CHARS, \"Attempt id\");\n\t\tconst fencingToken = positiveFencingToken(request.fencingToken);\n\t\tconst filePath = reservationFile(this.agentDir, workspace.repositoryRoot);\n\n\t\treturn withFileLockSync(filePath, () => {\n\t\t\tconst store = this.readLocked(filePath, workspace.repositoryRoot);\n\t\t\tconst matchingAttempt = store.reservations.find(\n\t\t\t\t(reservation) =>\n\t\t\t\t\treservation.parentSessionId === parentSessionId &&\n\t\t\t\t\treservation.ownerId === ownerId &&\n\t\t\t\t\treservation.taskId === taskId &&\n\t\t\t\t\treservation.attemptId === attemptId &&\n\t\t\t\t\treservation.fencingToken === fencingToken,\n\t\t\t);\n\t\t\tif (matchingAttempt) {\n\t\t\t\tif (\n\t\t\t\t\tmatchingAttempt.executionIdentity !== workspace.executionIdentity ||\n\t\t\t\t\tmatchingAttempt.isolatedWorktreeId !== workspace.isolatedWorktreeId ||\n\t\t\t\t\tmatchingAttempt.writeScopes.length !== writeScopes.length ||\n\t\t\t\t\tmatchingAttempt.writeScopes.some((scope, index) => scope !== writeScopes[index])\n\t\t\t\t) {\n\t\t\t\t\treturn { kind: \"blocked\", reasonCode: \"attempt_reservation_conflict\" };\n\t\t\t\t}\n\t\t\t\treturn { kind: \"granted\", lease: leaseFromRecord(filePath, matchingAttempt) };\n\t\t\t}\n\t\t\tconst conflicts = overlappingReservationIds(store.reservations, workspace.executionIdentity, writeScopes);\n\t\t\tif (conflicts.length > 0) {\n\t\t\t\treturn { kind: \"blocked\", reasonCode: \"overlapping_write_scope\", conflictingReservationIds: conflicts };\n\t\t\t}\n\t\t\tif (store.reservations.length >= MAX_RESERVATIONS)\n\t\t\t\treturn { kind: \"blocked\", reasonCode: \"reservation_capacity_reached\" };\n\t\t\tconst record: PersistedReservation = {\n\t\t\t\treservationId: randomUUID(),\n\t\t\t\tparentSessionId,\n\t\t\t\townerId,\n\t\t\t\ttaskId,\n\t\t\t\tattemptId,\n\t\t\t\tfencingToken,\n\t\t\t\trepositoryRoot: workspace.repositoryRoot,\n\t\t\t\texecutionRoot: workspace.executionRoot,\n\t\t\t\texecutionIdentity: workspace.executionIdentity,\n\t\t\t\t...(workspace.isolatedWorktreeId ? { isolatedWorktreeId: workspace.isolatedWorktreeId } : {}),\n\t\t\t\twriteScopes,\n\t\t\t\tcreatedAt: new Date().toISOString(),\n\t\t\t};\n\t\t\tstore.reservations.push(record);\n\t\t\twriteStore(filePath, store);\n\t\t\treturn { kind: \"granted\", lease: leaseFromRecord(filePath, record) };\n\t\t});\n\t}\n\n\trelease(lease: WorkerWriteReservationLease): WorkerWriteReservationReleaseResult {\n\t\tconst repositoryRoot = requireBoundedTrimmedText(lease.repositoryRoot, MAX_PATH_CHARS, \"Lease repository root\");\n\t\tconst ownerId = localOwnerId(lease.ownerId);\n\t\tconst expectedFilePath = reservationFile(this.agentDir, repositoryRoot);\n\t\tif (lease.filePath !== expectedFilePath)\n\t\t\tthrow new TypeError(\"Worker write reservation lease does not belong to this agent state.\");\n\t\treturn withFileLockSync(expectedFilePath, () => {\n\t\t\tconst store = this.readLocked(expectedFilePath, repositoryRoot);\n\t\t\tconst index = store.reservations.findIndex((reservation) => reservation.reservationId === lease.reservationId);\n\t\t\tif (index < 0) {\n\t\t\t\tconst supersedingReservation = store.reservations.some(\n\t\t\t\t\t(reservation) =>\n\t\t\t\t\t\treservation.parentSessionId === lease.parentSessionId &&\n\t\t\t\t\t\treservation.ownerId === ownerId &&\n\t\t\t\t\t\treservation.taskId === lease.taskId &&\n\t\t\t\t\t\treservation.fencingToken > lease.fencingToken,\n\t\t\t\t);\n\t\t\t\treturn { kind: supersedingReservation ? \"stale_fence\" : \"not_found\" };\n\t\t\t}\n\t\t\tconst record = store.reservations[index];\n\t\t\tif (\n\t\t\t\trecord.parentSessionId !== lease.parentSessionId ||\n\t\t\t\trecord.ownerId !== ownerId ||\n\t\t\t\trecord.taskId !== lease.taskId ||\n\t\t\t\trecord.attemptId !== lease.attemptId ||\n\t\t\t\trecord.fencingToken !== lease.fencingToken ||\n\t\t\t\trecord.executionIdentity !== lease.executionIdentity ||\n\t\t\t\trecord.isolatedWorktreeId !== lease.isolatedWorktreeId\n\t\t\t) {\n\t\t\t\treturn { kind: \"stale_fence\" };\n\t\t\t}\n\t\t\tstore.reservations.splice(index, 1);\n\t\t\tif (store.reservations.length === 0) unlinkSync(expectedFilePath);\n\t\t\telse writeStore(expectedFilePath, store);\n\t\t\tnotifyAvailability(expectedFilePath);\n\t\t\treturn { kind: \"released\" };\n\t\t});\n\t}\n\n\t/** Event-driven cross-process wakeup for queued write admission; caller owns disposal. */\n\twatchAvailability(workspace: WorkerWriteReservationWorkspace, listener: () => void): () => void {\n\t\tconst canonical = canonicalWorkspace(workspace);\n\t\tconst filePath = reservationFile(this.agentDir, canonical.repositoryRoot);\n\t\tconst listeners = availabilityListeners.get(filePath) ?? new Set<() => void>();\n\t\tavailabilityListeners.set(filePath, listeners);\n\t\tlisteners.add(listener);\n\t\tconst directory = dirname(filePath);\n\t\tmkdirSync(directory, { recursive: true });\n\t\tlet scheduled = false;\n\t\tconst schedule = () => {\n\t\t\tif (scheduled) return;\n\t\t\tscheduled = true;\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tscheduled = false;\n\t\t\t\tlistener();\n\t\t\t});\n\t\t};\n\t\tconst watcher = this.watchDirectory(directory, { persistent: false }, (_eventType, fileName) => {\n\t\t\t// Node may omit a filename (notably on Windows), or provide a Buffer when the watcher is\n\t\t\t// configured that way. An unknown filename is conservatively treated as a wake signal: the\n\t\t\t// scheduler re-evaluates durable admission, so this cannot grant access by itself.\n\t\t\tif (fileName === null) {\n\t\t\t\tschedule();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst normalizedName = Buffer.isBuffer(fileName) ? fileName.toString(\"utf-8\") : fileName;\n\t\t\tif (normalizedName === basename(filePath)) schedule();\n\t\t});\n\t\treturn () => {\n\t\t\tlisteners.delete(listener);\n\t\t\tif (listeners.size === 0) availabilityListeners.delete(filePath);\n\t\t\twatcher.close();\n\t\t};\n\t}\n\n\trecover(request: WorkerWriteReservationRecoveryRequest): { outcomes: WorkerWriteReservationRecoveryOutcome[] } {\n\t\tconst workspace = canonicalWorkspace(request.workspace);\n\t\tconst filePath = reservationFile(this.agentDir, workspace.repositoryRoot);\n\t\tconst evidence = new Map<string, WorkerWriteReservationEvidenceState>();\n\t\tfor (const observation of request.evidence) {\n\t\t\tconst reservationId = requireBoundedTrimmedText(\n\t\t\t\tobservation.reservationId,\n\t\t\t\tMAX_IDENTIFIER_CHARS,\n\t\t\t\t\"Reservation evidence id\",\n\t\t\t);\n\t\t\tif (observation.state !== \"live\" && observation.state !== \"not_live\" && observation.state !== \"unknown\") {\n\t\t\t\tthrow new TypeError(\"Reservation evidence state must be live, not_live, or unknown.\");\n\t\t\t}\n\t\t\tif (evidence.has(reservationId)) throw new TypeError(\"Reservation evidence must not repeat an identity.\");\n\t\t\tevidence.set(reservationId, observation.state);\n\t\t}\n\t\treturn withFileLockSync(filePath, () => {\n\t\t\tconst store = this.readLocked(filePath, workspace.repositoryRoot);\n\t\t\tconst outcomes = store.reservations\n\t\t\t\t.filter((reservation) => reservation.executionIdentity === workspace.executionIdentity)\n\t\t\t\t.map((reservation): WorkerWriteReservationRecoveryOutcome => {\n\t\t\t\t\tconst state = evidence.get(reservation.reservationId);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkind: state === \"live\" ? \"active\" : state === \"not_live\" ? \"stale\" : \"inspection_required\",\n\t\t\t\t\t\treservationId: reservation.reservationId,\n\t\t\t\t\t\tlease: leaseFromRecord(filePath, reservation),\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\treturn { outcomes };\n\t\t});\n\t}\n\n\tprivate readLocked(filePath: string, repositoryRoot: string): PersistedReservationStore {\n\t\tif (!existsSync(filePath)) return { schemaVersion: SCHEMA_VERSION, repositoryRoot, reservations: [] };\n\t\treturn parseStore(\n\t\t\treadBoundedTextFileSync(filePath, MAX_FILE_BYTES, \"Worker write reservation store\"),\n\t\t\trepositoryRoot,\n\t\t);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/core/diagnostics.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IACjC,YAAY,EAAE,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,WAAW,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC9B"
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/core/diagnostics.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IACjC,YAAY,EAAE,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,WAAW,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC9B"}
|
package/dist/core/doctor.d.ts
CHANGED
|
@@ -11,13 +11,13 @@ import { type PythonRuntimeOutcome } from "./python-runtime.ts";
|
|
|
11
11
|
*
|
|
12
12
|
* Two tool kinds, two different postures:
|
|
13
13
|
* - "managed": pi owns provisioning and attempts it when absent (fff-node,
|
|
14
|
-
*
|
|
15
|
-
* - "system": pi does not own the install (
|
|
16
|
-
*
|
|
14
|
+
* pinned rg/jq/uv, and the Python interpreter resolved through uv).
|
|
15
|
+
* - "system": pi does not own the install (Ollama). GUIDE MODE only -- exact
|
|
16
|
+
* manual steps are reported, never executed.
|
|
17
17
|
*/
|
|
18
18
|
export type DoctorToolKind = "managed" | "system";
|
|
19
19
|
export interface DoctorCheck {
|
|
20
|
-
/** Stable identifier, e.g. "fff-node", "ripgrep", "ollama", "python". */
|
|
20
|
+
/** Stable identifier, e.g. "fff-node", "ripgrep", "jq", "ollama", "python". */
|
|
21
21
|
id: string;
|
|
22
22
|
/** Human-readable label for the report. */
|
|
23
23
|
label: string;
|
|
@@ -45,7 +45,7 @@ export interface DoctorDeps {
|
|
|
45
45
|
loadAvailableFffNodePackage: () => unknown | undefined;
|
|
46
46
|
ensureFffNodePackage: (silent?: boolean) => Promise<unknown | undefined>;
|
|
47
47
|
getLastFffInstallOutcome: () => FffInstallOutcome | undefined;
|
|
48
|
-
|
|
48
|
+
ensureTool: (tool: "jq" | "rg", silent: boolean) => Promise<string | undefined>;
|
|
49
49
|
ensurePythonRuntime: (options: {
|
|
50
50
|
silent: boolean;
|
|
51
51
|
}) => Promise<PythonRuntimeOutcome>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","s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SAAS,CAAC;IAC9D,SAAS,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAC/B,mBAAmB,EAAE,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACrF,8IAA8I;IAC9I,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,KAAK,MAAM,GAAG,SAAS,CAAC;IACvF,aAAa,EAAE,mBAAmB,CAAC;IACnC,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;CAC9D;AAED,MAAM,WAAW,gBAAgB;IAChC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAyJD,wBAAsB,SAAS,CAC9B,IAAI,GAAE,UAA2B,EACjC,OAAO,GAAE,gBAAqB,GAC5B,OAAO,CAAC,YAAY,CAAC,CAQvB;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAc/D;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,GAAE,UAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAOzF","sourcesContent":["import chalk from \"chalk\";\nimport { getAgentDir } from \"../config.ts\";\nimport {\n\tensureFffNodePackage,\n\ttype FffInstallOutcome,\n\tgetLastFffInstallOutcome,\n\tgetToolPath,\n\tloadAvailableFffNodePackage,\n\tprobeVersion,\n} from \"../utils/tools-manager.ts\";\nimport { type AgentDirectoryLayoutReport, inspectAgentDirectoryLayout } from \"./agent-directory-layout.ts\";\nimport { OllamaRuntime } from \"./models/local-runtime.ts\";\nimport { ensurePythonRuntime, type PythonRuntimeOutcome } from \"./python-runtime.ts\";\n\n/**\n * Environment doctor: verifies required tooling and installs what it safely\n * can, instead of leaving provisioning entirely to lazy first-use (the exact\n * gap behind \"ran `pi-adaptative update` on another machine and fff-node\n * never got installed\" -- see fff-lazy-install.test.ts/fff-search-tools.test.ts\n * for the underlying lazy-install fix; this module is the proactive half).\n *\n * Two tool kinds, two different postures:\n * - \"managed\": pi owns provisioning and attempts it when absent (fff-node,\n * plus pinned uv and the Python interpreter resolved through it).\n * - \"system\": pi does not own the install (ripgrep and ollama). GUIDE MODE\n * only -- exact manual steps are reported, never executed.\n */\n\nexport type DoctorToolKind = \"managed\" | \"system\";\n\nexport interface DoctorCheck {\n\t/** Stable identifier, e.g. \"fff-node\", \"ripgrep\", \"ollama\", \"python\". */\n\tid: string;\n\t/** Human-readable label for the report. */\n\tlabel: string;\n\tkind: DoctorToolKind;\n\tpresent: boolean;\n\t/** Version/path/status summary, present or not. */\n\tdetail?: string;\n\t/** Only set for a \"managed\" tool: whether an install was just attempted. */\n\tinstallAttempted?: boolean;\n\t/** Only set for a \"system\" tool that's missing: exact manual steps, never executed. */\n\tguide?: string[];\n}\n\nexport interface DoctorReport {\n\tchecks: DoctorCheck[];\n\tnotices?: DoctorNotice[];\n}\n\nexport interface DoctorNotice {\n\tid: string;\n\tlabel: string;\n\tdetail: string;\n}\n\n/** Minimal slice of OllamaRuntime the doctor needs -- lets tests inject a fake without touching the real runtime. */\nexport type DoctorOllamaRuntime = Pick<OllamaRuntime, \"detect\" | \"installGuide\">;\n\nexport interface DoctorDeps {\n\tloadAvailableFffNodePackage: () => unknown | undefined;\n\tensureFffNodePackage: (silent?: boolean) => Promise<unknown | undefined>;\n\tgetLastFffInstallOutcome: () => FffInstallOutcome | undefined;\n\tgetRgPath: () => string | null;\n\tensurePythonRuntime: (options: { silent: boolean }) => Promise<PythonRuntimeOutcome>;\n\t/** Best-effort `<command> --version` probe; undefined if it can't be run. Used only to enrich a status line, never for presence detection. */\n\tprobeVersion: (command: string, versionArgs?: readonly string[]) => string | undefined;\n\tollamaRuntime: DoctorOllamaRuntime;\n\tinspectAgentDirectoryLayout: () => AgentDirectoryLayoutReport;\n}\n\nexport interface RunDoctorOptions {\n\t/**\n\t * Whether the fff-node managed install (if one is attempted) stays quiet.\n\t * Default true, matching runUpdatePreflight's existing background\n\t * behavior. The interactive `doctor` command passes `false` so a\n\t * multi-second install doesn't read as a silent hang.\n\t */\n\tsilent?: boolean;\n}\n\nconst realDoctorDeps: DoctorDeps = {\n\tloadAvailableFffNodePackage,\n\tensureFffNodePackage,\n\tgetLastFffInstallOutcome,\n\tgetRgPath: () => getToolPath(\"rg\"),\n\tensurePythonRuntime,\n\tprobeVersion,\n\tollamaRuntime: new OllamaRuntime({ agentDir: getAgentDir() }),\n\tinspectAgentDirectoryLayout: () => inspectAgentDirectoryLayout(getAgentDir()),\n};\n\nconst RIPGREP_GUIDE = [\n\t\"ripgrep (rg) was not found. Pi never runs installers itself -- manual steps (user-level, no sudo):\",\n\t\" - macOS (Homebrew): brew install ripgrep\",\n\t\" - Debian/Ubuntu: apt install ripgrep\",\n\t\" - Arch: pacman -S ripgrep\",\n\t\" - Or download a release: https://github.com/BurntSushi/ripgrep/releases\",\n];\n\nfunction describeFffOutcome(outcome: FffInstallOutcome | undefined): string {\n\tswitch (outcome?.status) {\n\t\tcase \"already-available\":\n\t\t\treturn \"already available\";\n\t\tcase \"installed\":\n\t\t\treturn \"installed just now\";\n\t\tcase \"offline\":\n\t\t\treturn \"offline mode enabled, skipped\";\n\t\tcase \"unsupported-platform\":\n\t\t\treturn \"no native build for this platform\";\n\t\tcase \"install-failed\":\n\t\t\treturn `install failed: ${outcome.reason}`;\n\t\tdefault:\n\t\t\treturn \"unavailable\";\n\t}\n}\n\n/** First line only -- a compiled-features/build-flags tail (e.g. rg --version) is noise in a one-line status report. */\nfunction firstLine(text: string | undefined): string | undefined {\n\treturn text?.split(\"\\n\")[0];\n}\n\n/** MANAGED tool: pi owns this install path, so the doctor actually attempts it when missing. */\nasync function checkFffNode(deps: DoctorDeps, silent: boolean): Promise<DoctorCheck> {\n\t// Delegate entirely to ensureFffNodePackage rather than re-deriving \"is it\n\t// already there\" here: that function (and its offline/unsupported-platform/\n\t// cooldown handling, see tools-manager.ts) is the single source of truth for\n\t// whether an install should even be attempted -- the doctor must not\n\t// duplicate or second-guess that logic, only report its outcome honestly.\n\tconst installed = await deps.ensureFffNodePackage(silent);\n\tconst outcome = deps.getLastFffInstallOutcome();\n\treturn {\n\t\tid: \"fff-node\",\n\t\tlabel: \"FFF native search (@ff-labs/fff-node)\",\n\t\tkind: \"managed\",\n\t\tpresent: Boolean(installed),\n\t\tinstallAttempted: outcome !== undefined && outcome.status !== \"already-available\",\n\t\tdetail: describeFffOutcome(outcome),\n\t};\n}\n\n/** SYSTEM tool: guide mode only, never installed by the doctor. */\nfunction checkRipgrep(deps: DoctorDeps): DoctorCheck {\n\tconst path = deps.getRgPath();\n\tif (!path) {\n\t\treturn { id: \"ripgrep\", label: \"ripgrep (rg)\", kind: \"system\", present: false, guide: RIPGREP_GUIDE };\n\t}\n\tconst version = firstLine(deps.probeVersion(path));\n\treturn {\n\t\tid: \"ripgrep\",\n\t\tlabel: \"ripgrep (rg)\",\n\t\tkind: \"system\",\n\t\tpresent: true,\n\t\tdetail: version ? `${path} (${version})` : path,\n\t};\n}\n\n/** SYSTEM tool: guide mode only, never installed by the doctor (OllamaRuntime.installGuide() is itself already guide-mode-only). */\nasync function checkOllama(deps: DoctorDeps): Promise<DoctorCheck> {\n\tconst status = await deps.ollamaRuntime.detect();\n\tif (!status.binaryPath) {\n\t\treturn {\n\t\t\tid: \"ollama\",\n\t\t\tlabel: \"Ollama (local model runtime)\",\n\t\t\tkind: \"system\",\n\t\t\tpresent: false,\n\t\t\tguide: deps.ollamaRuntime.installGuide(),\n\t\t};\n\t}\n\tconst version = firstLine(deps.probeVersion(status.binaryPath));\n\tconst versionSuffix = version ? `, ${version}` : \"\";\n\tconst activeStore = status.activeStore\n\t\t? `${status.activeStore.path} [${status.activeStore.kind}, ${status.activeStore.modelCount} model(s)]`\n\t\t: `none; pi-owned store ${status.ownedModelsDir} has ${status.ownedStore.modelCount} model(s)`;\n\treturn {\n\t\tid: \"ollama\",\n\t\tlabel: \"Ollama (local model runtime)\",\n\t\tkind: \"system\",\n\t\tpresent: true,\n\t\tdetail: `binary: ${status.binaryPath} [${status.binarySource}]${versionSuffix}; server: ${status.serverUp ? \"up\" : \"down\"} at ${status.serverUrl}; active store: ${activeStore}`,\n\t};\n}\n\n/** MANAGED tool: uv and Python share one deduplicated runtime manager with bounded provisioning. */\nasync function checkPython(deps: DoctorDeps, silent: boolean): Promise<DoctorCheck> {\n\tconst outcome = await deps.ensurePythonRuntime({ silent });\n\tif (outcome.status !== \"ready\") {\n\t\treturn {\n\t\t\tid: \"python\",\n\t\t\tlabel: \"Python (uv-managed)\",\n\t\t\tkind: \"managed\",\n\t\t\tpresent: false,\n\t\t\tdetail: outcome.reason,\n\t\t};\n\t}\n\treturn {\n\t\tid: \"python\",\n\t\tlabel: \"Python (uv-managed)\",\n\t\tkind: \"managed\",\n\t\tpresent: true,\n\t\tinstallAttempted: outcome.pythonInstalled,\n\t\tdetail: `uv: ${outcome.uvPath}; python: ${outcome.pythonPath}${outcome.pythonInstalled ? \" (installed just now)\" : \"\"}`,\n\t};\n}\n\nfunction checkAgentDirectoryLayout(deps: DoctorDeps): DoctorNotice[] {\n\tconst report = deps.inspectAgentDirectoryLayout();\n\tif (report.error) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tid: \"agent-directory-layout\",\n\t\t\t\tlabel: \"Agent directory layout\",\n\t\t\t\tdetail: `could not inspect ${report.agentDir}: ${report.error}`,\n\t\t\t},\n\t\t];\n\t}\n\tif (report.unexpectedEntryCount === 0 && !report.truncated) return [];\n\n\tconst listed = report.unexpectedEntries.join(\", \");\n\tconst omitted = report.unexpectedEntryCount - report.unexpectedEntries.length;\n\tconst count = report.truncated ? `at least ${report.unexpectedEntryCount}` : String(report.unexpectedEntryCount);\n\tconst listing = listed ? `: ${listed}${omitted > 0 ? ` (+${omitted} more)` : \"\"}` : \"\";\n\tconst truncation = report.truncated ? `; scan stopped after ${report.scannedEntries} entries` : \"\";\n\treturn [\n\t\t{\n\t\t\tid: \"agent-directory-layout\",\n\t\t\tlabel: \"Agent directory layout\",\n\t\t\tdetail: `${count} unexpected root entr${report.unexpectedEntryCount === 1 ? \"y\" : \"ies\"}${listing}${truncation}. Extension data belongs under state/extensions, cache/extensions, or leased work/extensions`,\n\t\t},\n\t];\n}\n\nexport async function runDoctor(\n\tdeps: DoctorDeps = realDoctorDeps,\n\toptions: RunDoctorOptions = {},\n): Promise<DoctorReport> {\n\tconst silent = options.silent ?? true;\n\tconst [fffNode, ollama, python] = await Promise.all([\n\t\tcheckFffNode(deps, silent),\n\t\tcheckOllama(deps),\n\t\tcheckPython(deps, silent),\n\t]);\n\treturn { checks: [fffNode, checkRipgrep(deps), ollama, python], notices: checkAgentDirectoryLayout(deps) };\n}\n\nexport function formatDoctorReport(report: DoctorReport): string {\n\tconst lines: string[] = [];\n\tfor (const check of report.checks) {\n\t\tconst status = check.present ? chalk.green(\"[OK]\") : chalk.yellow(\"[MISSING]\");\n\t\tconst detail = check.detail ? ` -- ${check.detail}` : \"\";\n\t\tlines.push(`${status} ${check.label}${detail}`);\n\t\tif (!check.present && check.guide) {\n\t\t\tfor (const guideLine of check.guide) lines.push(` ${guideLine}`);\n\t\t}\n\t}\n\tfor (const notice of report.notices ?? []) {\n\t\tlines.push(`${chalk.yellow(\"[WARN]\")} ${notice.label} -- ${notice.detail}`);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Best-effort preflight meant to be called right after `pi-adaptative update`\n * succeeds. Must never fail the update itself: any error here is swallowed\n * and reported as a skipped check, not surfaced as an update failure.\n */\nexport async function runUpdatePreflight(deps: DoctorDeps = realDoctorDeps): Promise<void> {\n\ttry {\n\t\tconst report = await runDoctor(deps);\n\t\tconsole.log(`\\n${formatDoctorReport(report)}\\n`);\n\t} catch (error) {\n\t\tconsole.log(chalk.dim(`(environment check skipped: ${error instanceof Error ? error.message : String(error)})`));\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/core/doct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AC9D,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAChF,mBAAmB,EAAE,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACrF,8IAA8I;IAC9I,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,KAAK,MAAM,GAAG,SAAS,CAAC;IACvF,aAAa,EAAE,mBAAmB,CAAC;IACnC,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;CAC9D;AAED,MAAM,WAAW,gBAAgB;IAChC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAiJD,wBAAsB,SAAS,CAC9B,IAAI,GAAE,UAA2B,EACjC,OAAO,GAAE,gBAAqB,GAC5B,OAAO,CAAC,YAAY,CAAC,CAUvB;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAc/D;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,GAAE,UAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAOzF"}
|
package/dist/core/doctor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { getAgentDir } from "../config.js";
|
|
3
|
-
import { ensureFffNodePackage,
|
|
3
|
+
import { ensureFffNodePackage, ensureTool, getLastFffInstallOutcome, loadAvailableFffNodePackage, probeVersion, } from "../utils/tools-manager.js";
|
|
4
4
|
import { inspectAgentDirectoryLayout } from "./agent-directory-layout.js";
|
|
5
5
|
import { OllamaRuntime } from "./models/local-runtime.js";
|
|
6
6
|
import { ensurePythonRuntime } from "./python-runtime.js";
|
|
@@ -8,19 +8,12 @@ const realDoctorDeps = {
|
|
|
8
8
|
loadAvailableFffNodePackage,
|
|
9
9
|
ensureFffNodePackage,
|
|
10
10
|
getLastFffInstallOutcome,
|
|
11
|
-
|
|
11
|
+
ensureTool,
|
|
12
12
|
ensurePythonRuntime,
|
|
13
13
|
probeVersion,
|
|
14
14
|
ollamaRuntime: new OllamaRuntime({ agentDir: getAgentDir() }),
|
|
15
15
|
inspectAgentDirectoryLayout: () => inspectAgentDirectoryLayout(getAgentDir()),
|
|
16
16
|
};
|
|
17
|
-
const RIPGREP_GUIDE = [
|
|
18
|
-
"ripgrep (rg) was not found. Pi never runs installers itself -- manual steps (user-level, no sudo):",
|
|
19
|
-
" - macOS (Homebrew): brew install ripgrep",
|
|
20
|
-
" - Debian/Ubuntu: apt install ripgrep",
|
|
21
|
-
" - Arch: pacman -S ripgrep",
|
|
22
|
-
" - Or download a release: https://github.com/BurntSushi/ripgrep/releases",
|
|
23
|
-
];
|
|
24
17
|
function describeFffOutcome(outcome) {
|
|
25
18
|
switch (outcome?.status) {
|
|
26
19
|
case "already-available":
|
|
@@ -59,17 +52,18 @@ async function checkFffNode(deps, silent) {
|
|
|
59
52
|
detail: describeFffOutcome(outcome),
|
|
60
53
|
};
|
|
61
54
|
}
|
|
62
|
-
/**
|
|
63
|
-
function
|
|
64
|
-
const path = deps.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
/** MANAGED tools: exact releases and checksums are owned by tools-manager. */
|
|
56
|
+
async function checkManagedDataTool(deps, tool, silent) {
|
|
57
|
+
const path = await deps.ensureTool(tool, silent);
|
|
58
|
+
const id = tool === "rg" ? "ripgrep" : "jq";
|
|
59
|
+
const label = tool === "rg" ? "ripgrep (rg)" : "jq (JSON projection)";
|
|
60
|
+
if (!path)
|
|
61
|
+
return { id, label, kind: "managed", present: false, detail: "managed install unavailable" };
|
|
68
62
|
const version = firstLine(deps.probeVersion(path));
|
|
69
63
|
return {
|
|
70
|
-
id
|
|
71
|
-
label
|
|
72
|
-
kind: "
|
|
64
|
+
id,
|
|
65
|
+
label,
|
|
66
|
+
kind: "managed",
|
|
73
67
|
present: true,
|
|
74
68
|
detail: version ? `${path} (${version})` : path,
|
|
75
69
|
};
|
|
@@ -148,12 +142,14 @@ function checkAgentDirectoryLayout(deps) {
|
|
|
148
142
|
}
|
|
149
143
|
export async function runDoctor(deps = realDoctorDeps, options = {}) {
|
|
150
144
|
const silent = options.silent ?? true;
|
|
151
|
-
const [fffNode, ollama, python] = await Promise.all([
|
|
145
|
+
const [fffNode, ripgrep, jq, ollama, python] = await Promise.all([
|
|
152
146
|
checkFffNode(deps, silent),
|
|
147
|
+
checkManagedDataTool(deps, "rg", silent),
|
|
148
|
+
checkManagedDataTool(deps, "jq", silent),
|
|
153
149
|
checkOllama(deps),
|
|
154
150
|
checkPython(deps, silent),
|
|
155
151
|
]);
|
|
156
|
-
return { checks: [fffNode,
|
|
152
|
+
return { checks: [fffNode, ripgrep, jq, ollama, python], notices: checkAgentDirectoryLayout(deps) };
|
|
157
153
|
}
|
|
158
154
|
export function formatDoctorReport(report) {
|
|
159
155
|
const lines = [];
|
package/dist/core/doctor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/core/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EACN,oBAAoB,EAEpB,wBAAwB,EACxB,WAAW,EACX,2BAA2B,EAC3B,YAAY,GACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAmC,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC3G,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAA6B,MAAM,qBAAqB,CAAC;AAqErF,MAAM,cAAc,GAAe;IAClC,2BAA2B;IAC3B,oBAAoB;IACpB,wBAAwB;IACxB,SAAS,EAAE,GAAG,EA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,CAAC,GAAG,MAAM,IAAI,KAAK,CAAC,KAAK,GAAG,MAAM,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YACnC,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,KAAK;gBAAE,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC,CAAC;QACnE,CAAC;IACF,CAAC;IACD,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;QAC3C,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,KAAK,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CACxB;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAI,GAAe,cAAc,EAAiB;IAC1F,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,KAAK,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,+BAA+B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAClH,CAAC;AAAA,CACD","sourcesContent":["import chalk from \"chalk\";\nimport { getAgentDir } from \"../config.ts\";\nimport {\n\tensureFffNodePackage,\n\ttype FffInstallOutcome,\n\tgetLastFffInstallOutcome,\n\tgetToolPath,\n\tloadAvailableFffNodePackage,\n\tprobeVersion,\n} from \"../utils/tools-manager.ts\";\nimport { type AgentDirectoryLayoutReport, inspectAgentDirectoryLayout } from \"./agent-directory-layout.ts\";\nimport { OllamaRuntime } from \"./models/local-runtime.ts\";\nimport { ensurePythonRuntime, type PythonRuntimeOutcome } from \"./python-runtime.ts\";\n\n/**\n * Environment doctor: verifies required tooling and installs what it safely\n * can, instead of leaving provisioning entirely to lazy first-use (the exact\n * gap behind \"ran `pi-adaptative update` on another machine and fff-node\n * never got installed\" -- see fff-lazy-install.test.ts/fff-search-tools.test.ts\n * for the underlying lazy-install fix; this module is the proactive half).\n *\n * Two tool kinds, two different postures:\n * - \"managed\": pi owns provisioning and attempts it when absent (fff-node,\n * plus pinned uv and the Python interpreter resolved through it).\n * - \"system\": pi does not own the install (ripgrep and ollama). GUIDE MODE\n * only -- exact manual steps are reported, never executed.\n */\n\nexport type DoctorToolKind = \"managed\" | \"system\";\n\nexport interface DoctorCheck {\n\t/** Stable identifier, e.g. \"fff-node\", \"ripgrep\", \"ollama\", \"python\". */\n\tid: string;\n\t/** Human-readable label for the report. */\n\tlabel: string;\n\tkind: DoctorToolKind;\n\tpresent: boolean;\n\t/** Version/path/status summary, present or not. */\n\tdetail?: string;\n\t/** Only set for a \"managed\" tool: whether an install was just attempted. */\n\tinstallAttempted?: boolean;\n\t/** Only set for a \"system\" tool that's missing: exact manual steps, never executed. */\n\tguide?: string[];\n}\n\nexport interface DoctorReport {\n\tchecks: DoctorCheck[];\n\tnotices?: DoctorNotice[];\n}\n\nexport interface DoctorNotice {\n\tid: string;\n\tlabel: string;\n\tdetail: string;\n}\n\n/** Minimal slice of OllamaRuntime the doctor needs -- lets tests inject a fake without touching the real runtime. */\nexport type DoctorOllamaRuntime = Pick<OllamaRuntime, \"detect\" | \"installGuide\">;\n\nexport interface DoctorDeps {\n\tloadAvailableFffNodePackage: () => unknown | undefined;\n\tensureFffNodePackage: (silent?: boolean) => Promise<unknown | undefined>;\n\tgetLastFffInstallOutcome: () => FffInstallOutcome | undefined;\n\tgetRgPath: () => string | null;\n\tensurePythonRuntime: (options: { silent: boolean }) => Promise<PythonRuntimeOutcome>;\n\t/** Best-effort `<command> --version` probe; undefined if it can't be run. Used only to enrich a status line, never for presence detection. */\n\tprobeVersion: (command: string, versionArgs?: readonly string[]) => string | undefined;\n\tollamaRuntime: DoctorOllamaRuntime;\n\tinspectAgentDirectoryLayout: () => AgentDirectoryLayoutReport;\n}\n\nexport interface RunDoctorOptions {\n\t/**\n\t * Whether the fff-node managed install (if one is attempted) stays quiet.\n\t * Default true, matching runUpdatePreflight's existing background\n\t * behavior. The interactive `doctor` command passes `false` so a\n\t * multi-second install doesn't read as a silent hang.\n\t */\n\tsilent?: boolean;\n}\n\nconst realDoctorDeps: DoctorDeps = {\n\tloadAvailableFffNodePackage,\n\tensureFffNodePackage,\n\tgetLastFffInstallOutcome,\n\tgetRgPath: () => getToolPath(\"rg\"),\n\tensurePythonRuntime,\n\tprobeVersion,\n\tollamaRuntime: new OllamaRuntime({ agentDir: getAgentDir() }),\n\tinspectAgentDirectoryLayout: () => inspectAgentDirectoryLayout(getAgentDir()),\n};\n\nconst RIPGREP_GUIDE = [\n\t\"ripgrep (rg) was not found. Pi never runs installers itself -- manual steps (user-level, no sudo):\",\n\t\" - macOS (Homebrew): brew install ripgrep\",\n\t\" - Debian/Ubuntu: apt install ripgrep\",\n\t\" - Arch: pacman -S ripgrep\",\n\t\" - Or download a release: https://github.com/BurntSushi/ripgrep/releases\",\n];\n\nfunction describeFffOutcome(outcome: FffInstallOutcome | undefined): string {\n\tswitch (outcome?.status) {\n\t\tcase \"already-available\":\n\t\t\treturn \"already available\";\n\t\tcase \"installed\":\n\t\t\treturn \"installed just now\";\n\t\tcase \"offline\":\n\t\t\treturn \"offline mode enabled, skipped\";\n\t\tcase \"unsupported-platform\":\n\t\t\treturn \"no native build for this platform\";\n\t\tcase \"install-failed\":\n\t\t\treturn `install failed: ${outcome.reason}`;\n\t\tdefault:\n\t\t\treturn \"unavailable\";\n\t}\n}\n\n/** First line only -- a compiled-features/build-flags tail (e.g. rg --version) is noise in a one-line status report. */\nfunction firstLine(text: string | undefined): string | undefined {\n\treturn text?.split(\"\\n\")[0];\n}\n\n/** MANAGED tool: pi owns this install path, so the doctor actually attempts it when missing. */\nasync function checkFffNode(deps: DoctorDeps, silent: boolean): Promise<DoctorCheck> {\n\t// Delegate entirely to ensureFffNodePackage rather than re-deriving \"is it\n\t// already there\" here: that function (and its offline/unsupported-platform/\n\t// cooldown handling, see tools-manager.ts) is the single source of truth for\n\t// whether an install should even be attempted -- the doctor must not\n\t// duplicate or second-guess that logic, only report its outcome honestly.\n\tconst installed = await deps.ensureFffNodePackage(silent);\n\tconst outcome = deps.getLastFffInstallOutcome();\n\treturn {\n\t\tid: \"fff-node\",\n\t\tlabel: \"FFF native search (@ff-labs/fff-node)\",\n\t\tkind: \"managed\",\n\t\tpresent: Boolean(installed),\n\t\tinstallAttempted: outcome !== undefined && outcome.status !== \"already-available\",\n\t\tdetail: describeFffOutcome(outcome),\n\t};\n}\n\n/** SYSTEM tool: guide mode only, never installed by the doctor. */\nfunction checkRipgrep(deps: DoctorDeps): DoctorCheck {\n\tconst path = deps.getRgPath();\n\tif (!path) {\n\t\treturn { id: \"ripgrep\", label: \"ripgrep (rg)\", kind: \"system\", present: false, guide: RIPGREP_GUIDE };\n\t}\n\tconst version = firstLine(deps.probeVersion(path));\n\treturn {\n\t\tid: \"ripgrep\",\n\t\tlabel: \"ripgrep (rg)\",\n\t\tkind: \"system\",\n\t\tpresent: true,\n\t\tdetail: version ? `${path} (${version})` : path,\n\t};\n}\n\n/** SYSTEM tool: guide mode only, never installed by the doctor (OllamaRuntime.installGuide() is itself already guide-mode-only). */\nasync function checkOllama(deps: DoctorDeps): Promise<DoctorCheck> {\n\tconst status = await deps.ollamaRuntime.detect();\n\tif (!status.binaryPath) {\n\t\treturn {\n\t\t\tid: \"ollama\",\n\t\t\tlabel: \"Ollama (local model runtime)\",\n\t\t\tkind: \"system\",\n\t\t\tpresent: false,\n\t\t\tguide: deps.ollamaRuntime.installGuide(),\n\t\t};\n\t}\n\tconst version = firstLine(deps.probeVersion(status.binaryPath));\n\tconst versionSuffix = version ? `, ${version}` : \"\";\n\tconst activeStore = status.activeStore\n\t\t? `${status.activeStore.path} [${status.activeStore.kind}, ${status.activeStore.modelCount} model(s)]`\n\t\t: `none; pi-owned store ${status.ownedModelsDir} has ${status.ownedStore.modelCount} model(s)`;\n\treturn {\n\t\tid: \"ollama\",\n\t\tlabel: \"Ollama (local model runtime)\",\n\t\tkind: \"system\",\n\t\tpresent: true,\n\t\tdetail: `binary: ${status.binaryPath} [${status.binarySource}]${versionSuffix}; server: ${status.serverUp ? \"up\" : \"down\"} at ${status.serverUrl}; active store: ${activeStore}`,\n\t};\n}\n\n/** MANAGED tool: uv and Python share one deduplicated runtime manager with bounded provisioning. */\nasync function checkPython(deps: DoctorDeps, silent: boolean): Promise<DoctorCheck> {\n\tconst outcome = await deps.ensurePythonRuntime({ silent });\n\tif (outcome.status !== \"ready\") {\n\t\treturn {\n\t\t\tid: \"python\",\n\t\t\tlabel: \"Python (uv-managed)\",\n\t\t\tkind: \"managed\",\n\t\t\tpresent: false,\n\t\t\tdetail: outcome.reason,\n\t\t};\n\t}\n\treturn {\n\t\tid: \"python\",\n\t\tlabel: \"Python (uv-managed)\",\n\t\tkind: \"managed\",\n\t\tpresent: true,\n\t\tinstallAttempted: outcome.pythonInstalled,\n\t\tdetail: `uv: ${outcome.uvPath}; python: ${outcome.pythonPath}${outcome.pythonInstalled ? \" (installed just now)\" : \"\"}`,\n\t};\n}\n\nfunction checkAgentDirectoryLayout(deps: DoctorDeps): DoctorNotice[] {\n\tconst report = deps.inspectAgentDirectoryLayout();\n\tif (report.error) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tid: \"agent-directory-layout\",\n\t\t\t\tlabel: \"Agent directory layout\",\n\t\t\t\tdetail: `could not inspect ${report.agentDir}: ${report.error}`,\n\t\t\t},\n\t\t];\n\t}\n\tif (report.unexpectedEntryCount === 0 && !report.truncated) return [];\n\n\tconst listed = report.unexpectedEntries.join(\", \");\n\tconst omitted = report.unexpectedEntryCount - report.unexpectedEntries.length;\n\tconst count = report.truncated ? `at least ${report.unexpectedEntryCount}` : String(report.unexpectedEntryCount);\n\tconst listing = listed ? `: ${listed}${omitted > 0 ? ` (+${omitted} more)` : \"\"}` : \"\";\n\tconst truncation = report.truncated ? `; scan stopped after ${report.scannedEntries} entries` : \"\";\n\treturn [\n\t\t{\n\t\t\tid: \"agent-directory-layout\",\n\t\t\tlabel: \"Agent directory layout\",\n\t\t\tdetail: `${count} unexpected root entr${report.unexpectedEntryCount === 1 ? \"y\" : \"ies\"}${listing}${truncation}. Extension data belongs under state/extensions, cache/extensions, or leased work/extensions`,\n\t\t},\n\t];\n}\n\nexport async function runDoctor(\n\tdeps: DoctorDeps = realDoctorDeps,\n\toptions: RunDoctorOptions = {},\n): Promise<DoctorReport> {\n\tconst silent = options.silent ?? true;\n\tconst [fffNode, ollama, python] = await Promise.all([\n\t\tcheckFffNode(deps, silent),\n\t\tcheckOllama(deps),\n\t\tcheckPython(deps, silent),\n\t]);\n\treturn { checks: [fffNode, checkRipgrep(deps), ollama, python], notices: checkAgentDirectoryLayout(deps) };\n}\n\nexport function formatDoctorReport(report: DoctorReport): string {\n\tconst lines: string[] = [];\n\tfor (const check of report.checks) {\n\t\tconst status = check.present ? chalk.green(\"[OK]\") : chalk.yellow(\"[MISSING]\");\n\t\tconst detail = check.detail ? ` -- ${check.detail}` : \"\";\n\t\tlines.push(`${status} ${check.label}${detail}`);\n\t\tif (!check.present && check.guide) {\n\t\t\tfor (const guideLine of check.guide) lines.push(` ${guideLine}`);\n\t\t}\n\t}\n\tfor (const notice of report.notices ?? []) {\n\t\tlines.push(`${chalk.yellow(\"[WARN]\")} ${notice.label} -- ${notice.detail}`);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Best-effort preflight meant to be called right after `pi-adaptative update`\n * succeeds. Must never fail the update itself: any error here is swallowed\n * and reported as a skipped check, not surfaced as an update failure.\n */\nexport async function runUpdatePreflight(deps: DoctorDeps = realDoctorDeps): Promise<void> {\n\ttry {\n\t\tconst report = await runDoctor(deps);\n\t\tconsole.log(`\\n${formatDoctorReport(report)}\\n`);\n\t} catch (error) {\n\t\tconsole.log(chalk.dim(`(environment check skipped: ${error instanceof Error ? error.message : String(error)})`));\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/core/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EACN,oBAAoB,EACpB,UAAU,EAEV,wBAAwB,EACxB,2BAA2B,EAC3B,YAAY,GACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAmC,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC3G,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAA6B,MAAM,qBAAqB,CAAC;AAqErF,MAAM,cAAc,GAAe;IAClC,2BAA2B;IAC3B,oBAAoB;IACpB,wBAAwB;IACxB,UAAU;IACV,mBAAmB;IACnB,YAAY;IACZ,aAAa,EAAE,IAAI,aAAa,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC;IAC7D,2BAA2B,EAAE,GAAG,EAAE,CAAC,2BAA2B,CAAC,WAAW,EAAE,CAAC;CAC7E,CAAC;AAEF,SAAS,kBAAkB,CAAC,OAAsC;IACjE,QAAQ,OAAO,EAAE,MAAM,EAAE,CAAC;QACzB,KAAK,mBAAmB;YACvB,OAAO,mBAAmB,CAAC;QAC5B,KAAK,WAAW;YACf,OAAO,oBAAoB,CAAC;QAC7B,KAAK,SAAS;YACb,OAAO,+BAA+B,CAAC;QACxC,KAAK,sBAAsB;YAC1B,OAAO,mCAAmC,CAAC;QAC5C,KAAK,gB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QAC3C,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,KAAK,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAI,GAAe,cAAc;IACzE,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,KAAK,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,+BAA+B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAClH,CAAC;AACF,CAAC","sourcesContent":["import chalk from \"chalk\";\nimport { getAgentDir } from \"../config.ts\";\nimport {\n\tensureFffNodePackage,\n\tensureTool,\n\ttype FffInstallOutcome,\n\tgetLastFffInstallOutcome,\n\tloadAvailableFffNodePackage,\n\tprobeVersion,\n} from \"../utils/tools-manager.ts\";\nimport { type AgentDirectoryLayoutReport, inspectAgentDirectoryLayout } from \"./agent-directory-layout.ts\";\nimport { OllamaRuntime } from \"./models/local-runtime.ts\";\nimport { ensurePythonRuntime, type PythonRuntimeOutcome } from \"./python-runtime.ts\";\n\n/**\n * Environment doctor: verifies required tooling and installs what it safely\n * can, instead of leaving provisioning entirely to lazy first-use (the exact\n * gap behind \"ran `pi-adaptative update` on another machine and fff-node\n * never got installed\" -- see fff-lazy-install.test.ts/fff-search-tools.test.ts\n * for the underlying lazy-install fix; this module is the proactive half).\n *\n * Two tool kinds, two different postures:\n * - \"managed\": pi owns provisioning and attempts it when absent (fff-node,\n * pinned rg/jq/uv, and the Python interpreter resolved through uv).\n * - \"system\": pi does not own the install (Ollama). GUIDE MODE only -- exact\n * manual steps are reported, never executed.\n */\n\nexport type DoctorToolKind = \"managed\" | \"system\";\n\nexport interface DoctorCheck {\n\t/** Stable identifier, e.g. \"fff-node\", \"ripgrep\", \"jq\", \"ollama\", \"python\". */\n\tid: string;\n\t/** Human-readable label for the report. */\n\tlabel: string;\n\tkind: DoctorToolKind;\n\tpresent: boolean;\n\t/** Version/path/status summary, present or not. */\n\tdetail?: string;\n\t/** Only set for a \"managed\" tool: whether an install was just attempted. */\n\tinstallAttempted?: boolean;\n\t/** Only set for a \"system\" tool that's missing: exact manual steps, never executed. */\n\tguide?: string[];\n}\n\nexport interface DoctorReport {\n\tchecks: DoctorCheck[];\n\tnotices?: DoctorNotice[];\n}\n\nexport interface DoctorNotice {\n\tid: string;\n\tlabel: string;\n\tdetail: string;\n}\n\n/** Minimal slice of OllamaRuntime the doctor needs -- lets tests inject a fake without touching the real runtime. */\nexport type DoctorOllamaRuntime = Pick<OllamaRuntime, \"detect\" | \"installGuide\">;\n\nexport interface DoctorDeps {\n\tloadAvailableFffNodePackage: () => unknown | undefined;\n\tensureFffNodePackage: (silent?: boolean) => Promise<unknown | undefined>;\n\tgetLastFffInstallOutcome: () => FffInstallOutcome | undefined;\n\tensureTool: (tool: \"jq\" | \"rg\", silent: boolean) => Promise<string | undefined>;\n\tensurePythonRuntime: (options: { silent: boolean }) => Promise<PythonRuntimeOutcome>;\n\t/** Best-effort `<command> --version` probe; undefined if it can't be run. Used only to enrich a status line, never for presence detection. */\n\tprobeVersion: (command: string, versionArgs?: readonly string[]) => string | undefined;\n\tollamaRuntime: DoctorOllamaRuntime;\n\tinspectAgentDirectoryLayout: () => AgentDirectoryLayoutReport;\n}\n\nexport interface RunDoctorOptions {\n\t/**\n\t * Whether the fff-node managed install (if one is attempted) stays quiet.\n\t * Default true, matching runUpdatePreflight's existing background\n\t * behavior. The interactive `doctor` command passes `false` so a\n\t * multi-second install doesn't read as a silent hang.\n\t */\n\tsilent?: boolean;\n}\n\nconst realDoctorDeps: DoctorDeps = {\n\tloadAvailableFffNodePackage,\n\tensureFffNodePackage,\n\tgetLastFffInstallOutcome,\n\tensureTool,\n\tensurePythonRuntime,\n\tprobeVersion,\n\tollamaRuntime: new OllamaRuntime({ agentDir: getAgentDir() }),\n\tinspectAgentDirectoryLayout: () => inspectAgentDirectoryLayout(getAgentDir()),\n};\n\nfunction describeFffOutcome(outcome: FffInstallOutcome | undefined): string {\n\tswitch (outcome?.status) {\n\t\tcase \"already-available\":\n\t\t\treturn \"already available\";\n\t\tcase \"installed\":\n\t\t\treturn \"installed just now\";\n\t\tcase \"offline\":\n\t\t\treturn \"offline mode enabled, skipped\";\n\t\tcase \"unsupported-platform\":\n\t\t\treturn \"no native build for this platform\";\n\t\tcase \"install-failed\":\n\t\t\treturn `install failed: ${outcome.reason}`;\n\t\tdefault:\n\t\t\treturn \"unavailable\";\n\t}\n}\n\n/** First line only -- a compiled-features/build-flags tail (e.g. rg --version) is noise in a one-line status report. */\nfunction firstLine(text: string | undefined): string | undefined {\n\treturn text?.split(\"\\n\")[0];\n}\n\n/** MANAGED tool: pi owns this install path, so the doctor actually attempts it when missing. */\nasync function checkFffNode(deps: DoctorDeps, silent: boolean): Promise<DoctorCheck> {\n\t// Delegate entirely to ensureFffNodePackage rather than re-deriving \"is it\n\t// already there\" here: that function (and its offline/unsupported-platform/\n\t// cooldown handling, see tools-manager.ts) is the single source of truth for\n\t// whether an install should even be attempted -- the doctor must not\n\t// duplicate or second-guess that logic, only report its outcome honestly.\n\tconst installed = await deps.ensureFffNodePackage(silent);\n\tconst outcome = deps.getLastFffInstallOutcome();\n\treturn {\n\t\tid: \"fff-node\",\n\t\tlabel: \"FFF native search (@ff-labs/fff-node)\",\n\t\tkind: \"managed\",\n\t\tpresent: Boolean(installed),\n\t\tinstallAttempted: outcome !== undefined && outcome.status !== \"already-available\",\n\t\tdetail: describeFffOutcome(outcome),\n\t};\n}\n\n/** MANAGED tools: exact releases and checksums are owned by tools-manager. */\nasync function checkManagedDataTool(deps: DoctorDeps, tool: \"jq\" | \"rg\", silent: boolean): Promise<DoctorCheck> {\n\tconst path = await deps.ensureTool(tool, silent);\n\tconst id = tool === \"rg\" ? \"ripgrep\" : \"jq\";\n\tconst label = tool === \"rg\" ? \"ripgrep (rg)\" : \"jq (JSON projection)\";\n\tif (!path) return { id, label, kind: \"managed\", present: false, detail: \"managed install unavailable\" };\n\tconst version = firstLine(deps.probeVersion(path));\n\treturn {\n\t\tid,\n\t\tlabel,\n\t\tkind: \"managed\",\n\t\tpresent: true,\n\t\tdetail: version ? `${path} (${version})` : path,\n\t};\n}\n\n/** SYSTEM tool: guide mode only, never installed by the doctor (OllamaRuntime.installGuide() is itself already guide-mode-only). */\nasync function checkOllama(deps: DoctorDeps): Promise<DoctorCheck> {\n\tconst status = await deps.ollamaRuntime.detect();\n\tif (!status.binaryPath) {\n\t\treturn {\n\t\t\tid: \"ollama\",\n\t\t\tlabel: \"Ollama (local model runtime)\",\n\t\t\tkind: \"system\",\n\t\t\tpresent: false,\n\t\t\tguide: deps.ollamaRuntime.installGuide(),\n\t\t};\n\t}\n\tconst version = firstLine(deps.probeVersion(status.binaryPath));\n\tconst versionSuffix = version ? `, ${version}` : \"\";\n\tconst activeStore = status.activeStore\n\t\t? `${status.activeStore.path} [${status.activeStore.kind}, ${status.activeStore.modelCount} model(s)]`\n\t\t: `none; pi-owned store ${status.ownedModelsDir} has ${status.ownedStore.modelCount} model(s)`;\n\treturn {\n\t\tid: \"ollama\",\n\t\tlabel: \"Ollama (local model runtime)\",\n\t\tkind: \"system\",\n\t\tpresent: true,\n\t\tdetail: `binary: ${status.binaryPath} [${status.binarySource}]${versionSuffix}; server: ${status.serverUp ? \"up\" : \"down\"} at ${status.serverUrl}; active store: ${activeStore}`,\n\t};\n}\n\n/** MANAGED tool: uv and Python share one deduplicated runtime manager with bounded provisioning. */\nasync function checkPython(deps: DoctorDeps, silent: boolean): Promise<DoctorCheck> {\n\tconst outcome = await deps.ensurePythonRuntime({ silent });\n\tif (outcome.status !== \"ready\") {\n\t\treturn {\n\t\t\tid: \"python\",\n\t\t\tlabel: \"Python (uv-managed)\",\n\t\t\tkind: \"managed\",\n\t\t\tpresent: false,\n\t\t\tdetail: outcome.reason,\n\t\t};\n\t}\n\treturn {\n\t\tid: \"python\",\n\t\tlabel: \"Python (uv-managed)\",\n\t\tkind: \"managed\",\n\t\tpresent: true,\n\t\tinstallAttempted: outcome.pythonInstalled,\n\t\tdetail: `uv: ${outcome.uvPath}; python: ${outcome.pythonPath}${outcome.pythonInstalled ? \" (installed just now)\" : \"\"}`,\n\t};\n}\n\nfunction checkAgentDirectoryLayout(deps: DoctorDeps): DoctorNotice[] {\n\tconst report = deps.inspectAgentDirectoryLayout();\n\tif (report.error) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tid: \"agent-directory-layout\",\n\t\t\t\tlabel: \"Agent directory layout\",\n\t\t\t\tdetail: `could not inspect ${report.agentDir}: ${report.error}`,\n\t\t\t},\n\t\t];\n\t}\n\tif (report.unexpectedEntryCount === 0 && !report.truncated) return [];\n\n\tconst listed = report.unexpectedEntries.join(\", \");\n\tconst omitted = report.unexpectedEntryCount - report.unexpectedEntries.length;\n\tconst count = report.truncated ? `at least ${report.unexpectedEntryCount}` : String(report.unexpectedEntryCount);\n\tconst listing = listed ? `: ${listed}${omitted > 0 ? ` (+${omitted} more)` : \"\"}` : \"\";\n\tconst truncation = report.truncated ? `; scan stopped after ${report.scannedEntries} entries` : \"\";\n\treturn [\n\t\t{\n\t\t\tid: \"agent-directory-layout\",\n\t\t\tlabel: \"Agent directory layout\",\n\t\t\tdetail: `${count} unexpected root entr${report.unexpectedEntryCount === 1 ? \"y\" : \"ies\"}${listing}${truncation}. Extension data belongs under state/extensions, cache/extensions, or leased work/extensions`,\n\t\t},\n\t];\n}\n\nexport async function runDoctor(\n\tdeps: DoctorDeps = realDoctorDeps,\n\toptions: RunDoctorOptions = {},\n): Promise<DoctorReport> {\n\tconst silent = options.silent ?? true;\n\tconst [fffNode, ripgrep, jq, ollama, python] = await Promise.all([\n\t\tcheckFffNode(deps, silent),\n\t\tcheckManagedDataTool(deps, \"rg\", silent),\n\t\tcheckManagedDataTool(deps, \"jq\", silent),\n\t\tcheckOllama(deps),\n\t\tcheckPython(deps, silent),\n\t]);\n\treturn { checks: [fffNode, ripgrep, jq, ollama, python], notices: checkAgentDirectoryLayout(deps) };\n}\n\nexport function formatDoctorReport(report: DoctorReport): string {\n\tconst lines: string[] = [];\n\tfor (const check of report.checks) {\n\t\tconst status = check.present ? chalk.green(\"[OK]\") : chalk.yellow(\"[MISSING]\");\n\t\tconst detail = check.detail ? ` -- ${check.detail}` : \"\";\n\t\tlines.push(`${status} ${check.label}${detail}`);\n\t\tif (!check.present && check.guide) {\n\t\t\tfor (const guideLine of check.guide) lines.push(` ${guideLine}`);\n\t\t}\n\t}\n\tfor (const notice of report.notices ?? []) {\n\t\tlines.push(`${chalk.yellow(\"[WARN]\")} ${notice.label} -- ${notice.detail}`);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Best-effort preflight meant to be called right after `pi-adaptative update`\n * succeeds. Must never fail the update itself: any error here is swallowed\n * and reported as a skipped check, not surfaced as an update failure.\n */\nexport async function runUpdatePreflight(deps: DoctorDeps = realDoctorDeps): Promise<void> {\n\ttry {\n\t\tconst report = await runDoctor(deps);\n\t\tconsole.log(`\\n${formatDoctorReport(report)}\\n`);\n\t} catch (error) {\n\t\tconsole.log(chalk.dim(`(environment check skipped: ${error instanceof Error ? error.message : String(error)})`));\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus.d.ts","sourceRoot":"","sources":["../../src/core/event-bus.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACxB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3C,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAClE;AAED,MAAM,WAAW,kBAAmB,SAAQ,QAAQ;IACnD,KAAK,IAAI,IAAI,CAAC;CACd;AAED,wBAAgB,cAAc,IAAI,kBAAkB,CAqBnD"
|
|
1
|
+
{"version":3,"file":"event-bus.d.ts","sourceRoot":"","sources":["../../src/core/event-bus.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACxB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3C,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAClE;AAED,MAAM,WAAW,kBAAmB,SAAQ,QAAQ;IACnD,KAAK,IAAI,IAAI,CAAC;CACd;AAED,wBAAgB,cAAc,IAAI,kBAAkB,CAqBnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../src/core/event-bus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAW3C,MAAM,UAAU,cAAc
|
|
1
|
+
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../src/core/event-bus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAW3C,MAAM,UAAU,cAAc;IAC7B,MAAM,OAAO,GAAG,IAAI,YAAY,EAAE,CAAC;IACnC,OAAO;QACN,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;YACvB,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC;QACD,EAAE,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;YACxB,MAAM,WAAW,GAAG,KAAK,EAAE,IAAa,EAAE,EAAE;gBAC3C,IAAI,CAAC;oBACJ,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;gBACrB,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACd,OAAO,CAAC,KAAK,CAAC,wBAAwB,OAAO,IAAI,EAAE,GAAG,CAAC,CAAC;gBACzD,CAAC;YACF,CAAC,CAAC;YACF,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YACjC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAChD,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACX,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC9B,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { EventEmitter } from \"node:events\";\n\nexport interface EventBus {\n\temit(channel: string, data: unknown): void;\n\ton(channel: string, handler: (data: unknown) => void): () => void;\n}\n\nexport interface EventBusController extends EventBus {\n\tclear(): void;\n}\n\nexport function createEventBus(): EventBusController {\n\tconst emitter = new EventEmitter();\n\treturn {\n\t\temit: (channel, data) => {\n\t\t\temitter.emit(channel, data);\n\t\t},\n\t\ton: (channel, handler) => {\n\t\t\tconst safeHandler = async (data: unknown) => {\n\t\t\t\ttry {\n\t\t\t\t\tawait handler(data);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(`Event handler error (${channel}):`, err);\n\t\t\t\t}\n\t\t\t};\n\t\t\temitter.on(channel, safeHandler);\n\t\t\treturn () => emitter.off(channel, safeHandler);\n\t\t},\n\t\tclear: () => {\n\t\t\temitter.removeAllListeners();\n\t\t},\n\t};\n}\n"]}
|
package/dist/core/exec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/core/exec.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,wCAAwC;IACxC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,0EAA0E;IAC1E,eAAe,EAAE,OAAO,CAAC;IACzB,0EAA0E;IAC1E,eAAe,EAAE,OAAO,CAAC;IACzB,sFAAsF;IACtF,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IACnC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,IAAI,MAAM,CAAC;IACf,SAAS,IAAI,OAAO,CAAC;CACrB;AAED,uGAAuG;AACvG,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/core/exec.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,wCAAwC;IACxC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,0EAA0E;IAC1E,eAAe,EAAE,OAAO,CAAC;IACzB,0EAA0E;IAC1E,eAAe,EAAE,OAAO,CAAC;IACzB,sFAAsF;IACtF,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IACnC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,IAAI,MAAM,CAAC;IACf,SAAS,IAAI,OAAO,CAAC;CACrB;AAED,uGAAuG;AACvG,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,CAwC/E;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAChC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CAmErB"}
|
package/dist/core/exec.js
CHANGED
|
@@ -10,25 +10,44 @@ const DEFAULT_EXEC_TIMEOUT_MS = 10 * 60_000;
|
|
|
10
10
|
const EXEC_KILL_GRACE_MS = 5_000;
|
|
11
11
|
/** Bounded child-process output accumulator: keeps a rolling tail of at most maxUnits UTF-16 units. */
|
|
12
12
|
export function createRollingOutputBuffer(maxUnits) {
|
|
13
|
+
const maximum = Number.isFinite(maxUnits) && maxUnits > 0 ? Math.floor(maxUnits) : 1;
|
|
13
14
|
const chunks = [];
|
|
15
|
+
let head = 0;
|
|
16
|
+
let headOffset = 0;
|
|
14
17
|
let units = 0;
|
|
15
18
|
let truncated = false;
|
|
16
19
|
return {
|
|
17
20
|
push(chunk) {
|
|
21
|
+
if (chunk.length === 0)
|
|
22
|
+
return;
|
|
18
23
|
chunks.push(chunk);
|
|
19
24
|
units += chunk.length;
|
|
20
|
-
while (units >
|
|
21
|
-
|
|
25
|
+
while (units > maximum) {
|
|
26
|
+
const excess = units - maximum;
|
|
27
|
+
const available = (chunks[head]?.length ?? 0) - headOffset;
|
|
28
|
+
if (excess < available) {
|
|
29
|
+
headOffset += excess;
|
|
30
|
+
units -= excess;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
units -= available;
|
|
34
|
+
head++;
|
|
35
|
+
headOffset = 0;
|
|
36
|
+
}
|
|
22
37
|
truncated = true;
|
|
23
38
|
}
|
|
24
|
-
if (
|
|
25
|
-
chunks
|
|
26
|
-
|
|
27
|
-
truncated = true;
|
|
39
|
+
if (head >= 1024 && head * 2 >= chunks.length) {
|
|
40
|
+
chunks.splice(0, head);
|
|
41
|
+
head = 0;
|
|
28
42
|
}
|
|
29
43
|
},
|
|
30
44
|
text() {
|
|
31
|
-
|
|
45
|
+
if (head >= chunks.length)
|
|
46
|
+
return "";
|
|
47
|
+
const retained = chunks.slice(head);
|
|
48
|
+
if (headOffset > 0)
|
|
49
|
+
retained[0] = retained[0].slice(headOffset);
|
|
50
|
+
return retained.join("");
|
|
32
51
|
},
|
|
33
52
|
truncated() {
|
|
34
53
|
return truncated;
|
package/dist/core/exec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/core/exec.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAE/E,gGAAgG;AAChG,MAAM,uBAAuB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AACjD,MAAM,uBAAuB,GAAG,EAAE,GAAG,MAAM,CAAC;AAC5C,M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,EAAE,KAAK;gBACb,eAAe,EAAE,MAAM,CAAC,SAAS,EAAE;gBACnC,eAAe,EAAE,MAAM,CAAC,SAAS,EAAE;gBACnC,YAAY,EAAE,UAAU;aACxB,CAAC,CAAC;QAAA,CACH,CAAC,CAAC;IAAA,CACJ,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * Shared command execution utilities for extensions and custom tools.\n */\n\nimport { spawn } from \"node:child_process\";\nimport { StringDecoder } from \"node:string_decoder\";\nimport { waitForChildProcessWithTermination } from \"../utils/child-process.ts\";\n\n/** Default per-stream retention for command output, in UTF-16 code units (~bytes for ASCII). */\nconst DEFAULT_EXEC_MAX_BUFFER = 16 * 1024 * 1024;\nconst DEFAULT_EXEC_TIMEOUT_MS = 10 * 60_000;\nconst EXEC_KILL_GRACE_MS = 5_000;\n\n/**\n * Options for executing shell commands.\n */\nexport interface ExecOptions {\n\t/** AbortSignal to cancel the command */\n\tsignal?: AbortSignal;\n\t/** Timeout in milliseconds */\n\ttimeout?: number;\n\t/** Working directory */\n\tcwd?: string;\n\t/** Environment for the child process. Defaults to process.env. */\n\tenv?: NodeJS.ProcessEnv;\n\t/**\n\t * Maximum output retained per stream, in UTF-16 code units (~bytes for ASCII).\n\t * Output is kept as a rolling tail; when exceeded, the oldest output is dropped\n\t * and the matching truncation flag is set on the result. Defaults to 16 MiB.\n\t */\n\tmaxBuffer?: number;\n}\n\n/**\n * Result of executing a shell command.\n */\nexport interface ExecResult {\n\tstdout: string;\n\tstderr: string;\n\tcode: number;\n\tkilled: boolean;\n\t/** True when stdout exceeded maxBuffer and only its tail was retained. */\n\tstdoutTruncated: boolean;\n\t/** True when stderr exceeded maxBuffer and only its tail was retained. */\n\tstderrTruncated: boolean;\n\t/** Present when the process failed to spawn (e.g. ENOENT); code is 1 in that case. */\n\terrorMessage?: string;\n}\n\nexport interface RollingOutputBuffer {\n\tpush(chunk: string): void;\n\ttext(): string;\n\ttruncated(): boolean;\n}\n\n/** Bounded child-process output accumulator: keeps a rolling tail of at most maxUnits UTF-16 units. */\nexport function createRollingOutputBuffer(maxUnits: number): RollingOutputBuffer {\n\tconst chunks: string[] = [];\n\tlet units = 0;\n\tlet truncated = false;\n\treturn {\n\t\tpush(chunk: string): void {\n\t\t\tchunks.push(chunk);\n\t\t\tunits += chunk.length;\n\t\t\twhile (units > maxUnits && chunks.length > 1) {\n\t\t\t\tunits -= chunks.shift()?.length ?? 0;\n\t\t\t\ttruncated = true;\n\t\t\t}\n\t\t\tif (units > maxUnits) {\n\t\t\t\tchunks[0] = chunks[0].slice(-maxUnits);\n\t\t\t\tunits = chunks[0].length;\n\t\t\t\ttruncated = true;\n\t\t\t}\n\t\t},\n\t\ttext(): string {\n\t\t\treturn chunks.join(\"\");\n\t\t},\n\t\ttruncated(): boolean {\n\t\t\treturn truncated;\n\t\t},\n\t};\n}\n\n/**\n * Execute a shell command and return stdout/stderr/code.\n * Supports timeout and abort signal. Output retention per stream is bounded\n * (rolling tail, see ExecOptions.maxBuffer) so a chatty child process cannot\n * grow the host heap without bound.\n */\nexport async function execCommand(\n\tcommand: string,\n\targs: string[],\n\tcwd: string,\n\toptions?: ExecOptions,\n): Promise<ExecResult> {\n\treturn new Promise((resolve) => {\n\t\tconst proc = spawn(command, args, {\n\t\t\tcwd,\n\t\t\tenv: options?.env,\n\t\t\tshell: false,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\tdetached: process.platform !== \"win32\",\n\t\t});\n\n\t\tlet spawnError: string | undefined;\n\t\tproc.once(\"error\", (err) => {\n\t\t\tspawnError = err.message;\n\t\t});\n\n\t\tconst maxBuffer =\n\t\t\toptions?.maxBuffer !== undefined && options.maxBuffer > 0 ? options.maxBuffer : DEFAULT_EXEC_MAX_BUFFER;\n\t\tconst stdout = createRollingOutputBuffer(maxBuffer);\n\t\tconst stderr = createRollingOutputBuffer(maxBuffer);\n\t\tconst stdoutDecoder = new StringDecoder(\"utf8\");\n\t\tconst stderrDecoder = new StringDecoder(\"utf8\");\n\n\t\tproc.stdout?.on(\"data\", (data: Buffer) => {\n\t\t\tstdout.push(stdoutDecoder.write(data));\n\t\t});\n\n\t\tproc.stderr?.on(\"data\", (data: Buffer) => {\n\t\t\tstderr.push(stderrDecoder.write(data));\n\t\t});\n\n\t\t// Settle from the child's terminal event or a bounded abort/timeout escalation.\n\t\t// This never waits for a second close event after termination has been acknowledged.\n\t\twaitForChildProcessWithTermination(proc, {\n\t\t\tsignal: options?.signal,\n\t\t\ttimeoutMs: options?.timeout && options.timeout > 0 ? options.timeout : DEFAULT_EXEC_TIMEOUT_MS,\n\t\t\tkillGraceMs: EXEC_KILL_GRACE_MS,\n\t\t})\n\t\t\t.then((terminal) => {\n\t\t\t\tstdout.push(stdoutDecoder.end());\n\t\t\t\tstderr.push(stderrDecoder.end());\n\t\t\t\tresolve({\n\t\t\t\t\tstdout: stdout.text(),\n\t\t\t\t\tstderr: stderr.text(),\n\t\t\t\t\tcode: terminal.code ?? 1,\n\t\t\t\t\tkilled: terminal.reason !== \"exited\",\n\t\t\t\t\tstdoutTruncated: stdout.truncated(),\n\t\t\t\t\tstderrTruncated: stderr.truncated(),\n\t\t\t\t\t...(spawnError !== undefined ? { errorMessage: spawnError } : {}),\n\t\t\t\t});\n\t\t\t})\n\t\t\t.catch((err) => {\n\t\t\t\tstdout.push(stdoutDecoder.end());\n\t\t\t\tstderr.push(stderrDecoder.end());\n\t\t\t\tif (spawnError === undefined) {\n\t\t\t\t\tspawnError = err instanceof Error ? err.message : String(err);\n\t\t\t\t}\n\t\t\t\tresolve({\n\t\t\t\t\tstdout: stdout.text(),\n\t\t\t\t\tstderr: stderr.text(),\n\t\t\t\t\tcode: 1,\n\t\t\t\t\tkilled: false,\n\t\t\t\t\tstdoutTruncated: stdout.truncated(),\n\t\t\t\t\tstderrTruncated: stderr.truncated(),\n\t\t\t\t\terrorMessage: spawnError,\n\t\t\t\t});\n\t\t\t});\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"exec.js","sour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ACL,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Shared command execution utilities for extensions and custom tools.\n */\n\nimport { spawn } from \"node:child_process\";\nimport { StringDecoder } from \"node:string_decoder\";\nimport { waitForChildProcessWithTermination } from \"../utils/child-process.ts\";\n\n/** Default per-stream retention for command output, in UTF-16 code units (~bytes for ASCII). */\nconst DEFAULT_EXEC_MAX_BUFFER = 16 * 1024 * 1024;\nconst DEFAULT_EXEC_TIMEOUT_MS = 10 * 60_000;\nconst EXEC_KILL_GRACE_MS = 5_000;\n\n/**\n * Options for executing shell commands.\n */\nexport interface ExecOptions {\n\t/** AbortSignal to cancel the command */\n\tsignal?: AbortSignal;\n\t/** Timeout in milliseconds */\n\ttimeout?: number;\n\t/** Working directory */\n\tcwd?: string;\n\t/** Environment for the child process. Defaults to process.env. */\n\tenv?: NodeJS.ProcessEnv;\n\t/**\n\t * Maximum output retained per stream, in UTF-16 code units (~bytes for ASCII).\n\t * Output is kept as a rolling tail; when exceeded, the oldest output is dropped\n\t * and the matching truncation flag is set on the result. Defaults to 16 MiB.\n\t */\n\tmaxBuffer?: number;\n}\n\n/**\n * Result of executing a shell command.\n */\nexport interface ExecResult {\n\tstdout: string;\n\tstderr: string;\n\tcode: number;\n\tkilled: boolean;\n\t/** True when stdout exceeded maxBuffer and only its tail was retained. */\n\tstdoutTruncated: boolean;\n\t/** True when stderr exceeded maxBuffer and only its tail was retained. */\n\tstderrTruncated: boolean;\n\t/** Present when the process failed to spawn (e.g. ENOENT); code is 1 in that case. */\n\terrorMessage?: string;\n}\n\nexport interface RollingOutputBuffer {\n\tpush(chunk: string): void;\n\ttext(): string;\n\ttruncated(): boolean;\n}\n\n/** Bounded child-process output accumulator: keeps a rolling tail of at most maxUnits UTF-16 units. */\nexport function createRollingOutputBuffer(maxUnits: number): RollingOutputBuffer {\n\tconst maximum = Number.isFinite(maxUnits) && maxUnits > 0 ? Math.floor(maxUnits) : 1;\n\tconst chunks: string[] = [];\n\tlet head = 0;\n\tlet headOffset = 0;\n\tlet units = 0;\n\tlet truncated = false;\n\treturn {\n\t\tpush(chunk: string): void {\n\t\t\tif (chunk.length === 0) return;\n\t\t\tchunks.push(chunk);\n\t\t\tunits += chunk.length;\n\t\t\twhile (units > maximum) {\n\t\t\t\tconst excess = units - maximum;\n\t\t\t\tconst available = (chunks[head]?.length ?? 0) - headOffset;\n\t\t\t\tif (excess < available) {\n\t\t\t\t\theadOffset += excess;\n\t\t\t\t\tunits -= excess;\n\t\t\t\t} else {\n\t\t\t\t\tunits -= available;\n\t\t\t\t\thead++;\n\t\t\t\t\theadOffset = 0;\n\t\t\t\t}\n\t\t\t\ttruncated = true;\n\t\t\t}\n\t\t\tif (head >= 1024 && head * 2 >= chunks.length) {\n\t\t\t\tchunks.splice(0, head);\n\t\t\t\thead = 0;\n\t\t\t}\n\t\t},\n\t\ttext(): string {\n\t\t\tif (head >= chunks.length) return \"\";\n\t\t\tconst retained = chunks.slice(head);\n\t\t\tif (headOffset > 0) retained[0] = retained[0].slice(headOffset);\n\t\t\treturn retained.join(\"\");\n\t\t},\n\t\ttruncated(): boolean {\n\t\t\treturn truncated;\n\t\t},\n\t};\n}\n\n/**\n * Execute a shell command and return stdout/stderr/code.\n * Supports timeout and abort signal. Output retention per stream is bounded\n * (rolling tail, see ExecOptions.maxBuffer) so a chatty child process cannot\n * grow the host heap without bound.\n */\nexport async function execCommand(\n\tcommand: string,\n\targs: string[],\n\tcwd: string,\n\toptions?: ExecOptions,\n): Promise<ExecResult> {\n\treturn new Promise((resolve) => {\n\t\tconst proc = spawn(command, args, {\n\t\t\tcwd,\n\t\t\tenv: options?.env,\n\t\t\tshell: false,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\tdetached: process.platform !== \"win32\",\n\t\t});\n\n\t\tlet spawnError: string | undefined;\n\t\tproc.once(\"error\", (err) => {\n\t\t\tspawnError = err.message;\n\t\t});\n\n\t\tconst maxBuffer =\n\t\t\toptions?.maxBuffer !== undefined && options.maxBuffer > 0 ? options.maxBuffer : DEFAULT_EXEC_MAX_BUFFER;\n\t\tconst stdout = createRollingOutputBuffer(maxBuffer);\n\t\tconst stderr = createRollingOutputBuffer(maxBuffer);\n\t\tconst stdoutDecoder = new StringDecoder(\"utf8\");\n\t\tconst stderrDecoder = new StringDecoder(\"utf8\");\n\n\t\tproc.stdout?.on(\"data\", (data: Buffer) => {\n\t\t\tstdout.push(stdoutDecoder.write(data));\n\t\t});\n\n\t\tproc.stderr?.on(\"data\", (data: Buffer) => {\n\t\t\tstderr.push(stderrDecoder.write(data));\n\t\t});\n\n\t\t// Settle from the child's terminal event or a bounded abort/timeout escalation.\n\t\t// This never waits for a second close event after termination has been acknowledged.\n\t\twaitForChildProcessWithTermination(proc, {\n\t\t\tsignal: options?.signal,\n\t\t\ttimeoutMs: options?.timeout && options.timeout > 0 ? options.timeout : DEFAULT_EXEC_TIMEOUT_MS,\n\t\t\tkillGraceMs: EXEC_KILL_GRACE_MS,\n\t\t})\n\t\t\t.then((terminal) => {\n\t\t\t\tstdout.push(stdoutDecoder.end());\n\t\t\t\tstderr.push(stderrDecoder.end());\n\t\t\t\tresolve({\n\t\t\t\t\tstdout: stdout.text(),\n\t\t\t\t\tstderr: stderr.text(),\n\t\t\t\t\tcode: terminal.code ?? 1,\n\t\t\t\t\tkilled: terminal.reason !== \"exited\",\n\t\t\t\t\tstdoutTruncated: stdout.truncated(),\n\t\t\t\t\tstderrTruncated: stderr.truncated(),\n\t\t\t\t\t...(spawnError !== undefined ? { errorMessage: spawnError } : {}),\n\t\t\t\t});\n\t\t\t})\n\t\t\t.catch((err) => {\n\t\t\t\tstdout.push(stdoutDecoder.end());\n\t\t\t\tstderr.push(stderrDecoder.end());\n\t\t\t\tif (spawnError === undefined) {\n\t\t\t\t\tspawnError = err instanceof Error ? err.message : String(err);\n\t\t\t\t}\n\t\t\t\tresolve({\n\t\t\t\t\tstdout: stdout.text(),\n\t\t\t\t\tstderr: stderr.text(),\n\t\t\t\t\tcode: 1,\n\t\t\t\t\tkilled: false,\n\t\t\t\t\tstdoutTruncated: stdout.truncated(),\n\t\t\t\t\tstderrTruncated: stderr.truncated(),\n\t\t\t\t\terrorMessage: spawnError,\n\t\t\t\t});\n\t\t\t});\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ansi-to-html.d.ts","sourceRoot":"","sources":["../../../src/core/export-html/ansi-to-html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"ansi-to-html.d.ts","sourceRoot":"","sources":["../../../src/core/export-html/ansi-to-html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAkIH;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAoD/C;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAEvD"}
|