@bastani/atomic 0.9.19 → 0.9.20-alpha.10
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 +313 -0
- package/README.md +52 -7
- package/dist/builtin/intercom/CHANGELOG.md +40 -0
- package/dist/builtin/intercom/README.md +2 -2
- package/dist/builtin/intercom/broker/broker.ts +110 -39
- package/dist/builtin/intercom/broker/client.ts +8 -1
- package/dist/builtin/intercom/broker/send-handler.ts +59 -2
- package/dist/builtin/intercom/index.bundle.mjs +177 -19
- package/dist/builtin/intercom/live-route-refusal.ts +69 -0
- package/dist/builtin/intercom/package.json +3 -5
- package/dist/builtin/intercom/recoverable-disconnect.ts +16 -4
- package/dist/builtin/intercom/session-target.ts +34 -9
- package/dist/builtin/intercom/skills/intercom/SKILL.md +47 -16
- package/dist/builtin/intercom/types.ts +3 -1
- package/dist/builtin/mcp/CHANGELOG.md +13 -0
- package/dist/builtin/mcp/OAUTH.md +1 -1
- package/dist/builtin/mcp/README.md +3 -1
- package/dist/builtin/mcp/index.bundle.mjs +412 -64
- package/dist/builtin/mcp/package.json +4 -4
- package/dist/builtin/subagents/CHANGELOG.md +63 -0
- package/dist/builtin/subagents/README.md +4 -2
- package/dist/builtin/subagents/agents/code-simplifier.md +3 -4
- package/dist/builtin/subagents/agents/codebase-analyzer.md +3 -4
- package/dist/builtin/subagents/agents/codebase-locator.md +2 -3
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +5 -6
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -3
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -3
- package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -3
- package/dist/builtin/subagents/agents/debugger.md +8 -7
- package/dist/builtin/subagents/agents/worker.md +5 -4
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/subagents/skills/agent-browser/SKILL.md +56 -0
- package/dist/builtin/subagents/skills/cua-driver/BROWSER.md +494 -0
- package/dist/builtin/subagents/skills/cua-driver/EMBEDDING.md +578 -0
- package/dist/builtin/subagents/skills/cua-driver/LINUX.md +364 -0
- package/dist/builtin/subagents/skills/cua-driver/MACOS.md +509 -0
- package/dist/builtin/subagents/skills/cua-driver/README.md +113 -0
- package/dist/builtin/subagents/skills/cua-driver/RECORDING.md +162 -0
- package/dist/builtin/subagents/skills/cua-driver/SKILL.md +1105 -0
- package/dist/builtin/subagents/skills/cua-driver/WINDOWS.md +866 -0
- package/dist/builtin/subagents/skills/feedback/SKILL.md +49 -0
- package/dist/builtin/subagents/skills/feedback/scripts/scrub.mjs +498 -0
- package/dist/builtin/subagents/skills/subagent/SKILL.md +45 -19
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +276 -68
- package/dist/builtin/web-access/CHANGELOG.md +18 -0
- package/dist/builtin/web-access/index.bundle.mjs +372 -300
- package/dist/builtin/web-access/package.json +3 -3
- package/dist/builtin/workflows/CHANGELOG.md +177 -0
- package/dist/builtin/workflows/README.md +20 -33
- package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
- package/dist/builtin/workflows/builtin/{chunk-g0csgs7w.js → chunk-18yz7r43.js} +8 -10
- package/dist/builtin/workflows/builtin/{chunk-31j2gs7h.js → chunk-1pd5zcfa.js} +4 -6
- package/dist/builtin/workflows/builtin/{chunk-xtxcq5tj.js → chunk-24c235x7.js} +17 -1
- package/dist/builtin/workflows/builtin/{chunk-6w6cvk6b.js → chunk-2jv44yz7.js} +4 -6
- package/dist/builtin/workflows/builtin/{chunk-yeee2jrc.js → chunk-2npg6daz.js} +76 -90
- package/dist/builtin/workflows/builtin/{chunk-z29qbehr.js → chunk-7ps7bnb4.js} +4 -6
- package/dist/builtin/workflows/builtin/{chunk-1jth021m.js → chunk-ad864596.js} +13 -218
- package/dist/builtin/workflows/builtin/{chunk-fg9esgkj.js → chunk-f8jjd90r.js} +4 -6
- package/dist/builtin/workflows/builtin/{chunk-a2kdsqn8.js → chunk-gxrhbnaj.js} +5 -3
- package/dist/builtin/workflows/builtin/chunk-twefqrv0.js +10666 -0
- package/dist/builtin/workflows/builtin/{chunk-nkrafh9s.js → chunk-ynded223.js} +40 -111
- package/dist/builtin/workflows/builtin/{chunk-wf741bv3.js → chunk-z5xdqrs6.js} +4 -6
- package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
- package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
- package/dist/builtin/workflows/builtin/goal.js +4 -4
- package/dist/builtin/workflows/builtin/index.d.ts +1 -1
- package/dist/builtin/workflows/builtin/index.js +12 -12
- package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
- package/dist/builtin/workflows/builtin/open-claude-design.d.ts +1 -1
- package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +4 -4
- package/dist/builtin/workflows/builtin/steering-context.js +1 -1
- package/dist/builtin/workflows/builtin/tournament.js +3 -3
- package/dist/builtin/workflows/package.json +4 -4
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +18 -11
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/animate.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +5 -5
- package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +6 -6
- package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/clarify.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/colorize.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +0 -6
- package/dist/builtin/workflows/skills/impeccable/reference/critique.md +19 -41
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +11 -65
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/delight.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/distill.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/extract.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/harden.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +21 -21
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +8 -8
- package/dist/builtin/workflows/skills/impeccable/reference/layout.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/live-setup.md +10 -8
- package/dist/builtin/workflows/skills/impeccable/reference/live.md +39 -38
- package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +48 -21
- package/dist/builtin/workflows/skills/impeccable/reference/onboard.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/overdrive.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/polish.md +11 -3
- package/dist/builtin/workflows/skills/impeccable/reference/quieter.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/routing.md +13 -7
- package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +13 -19
- package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index-failures.json +121 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index.json +1 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +212 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +218 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-dom.js +21 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +242 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +25 -4
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +666 -197
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +10 -9
- package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +4 -4
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +96 -23
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +75 -27
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +72 -26
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +58 -22
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5_5.md +118 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +70 -29
- package/dist/builtin/workflows/skills/prompt-engineer/references/core_prompting.md +1 -1
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +95 -32
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +79 -30
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +139 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +4 -4
- package/dist/builtin/workflows/skills/research-codebase/SKILL.md +1 -1
- package/dist/builtin/workflows/src/authoring.d.ts +6 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +26185 -21957
- package/dist/builtin/workflows/src/index.js +43264 -6482
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +11 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +17 -1
- package/dist/bun/split-loader.js +13 -0
- package/dist/bun/split-loader.js.map +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +17 -6
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/file-processor.d.ts +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-accessors.d.ts.map +1 -1
- package/dist/core/agent-session-accessors.js +2 -1
- package/dist/core/agent-session-accessors.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +49 -14
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts +3 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +27 -14
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-boundaries.d.ts +68 -0
- package/dist/core/agent-session-boundaries.d.ts.map +1 -0
- package/dist/core/agent-session-boundaries.js +339 -0
- package/dist/core/agent-session-boundaries.js.map +1 -0
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +38 -15
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts +6 -6
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +175 -74
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.d.ts +1 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +34 -39
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +3 -2
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +274 -70
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +36 -7
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +55 -15
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts +2 -2
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +38 -29
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +2 -1
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.js +18 -1
- package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +186 -36
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-queue-pause.d.ts +2 -0
- package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
- package/dist/core/agent-session-queue-pause.js +15 -3
- package/dist/core/agent-session-queue-pause.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +0 -3
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +28 -20
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime-auth.d.ts.map +1 -1
- package/dist/core/agent-session-runtime-auth.js +10 -0
- package/dist/core/agent-session-runtime-auth.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +21 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +434 -197
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +4 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +31 -2
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-state.d.ts +10 -2
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +32 -22
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-summary.d.ts.map +1 -1
- package/dist/core/agent-session-summary.js +9 -2
- package/dist/core/agent-session-summary.js.map +1 -1
- package/dist/core/agent-session-tasks.d.ts +10 -0
- package/dist/core/agent-session-tasks.d.ts.map +1 -1
- package/dist/core/agent-session-tasks.js +94 -21
- package/dist/core/agent-session-tasks.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +41 -8
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +13 -26
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-transfer.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +8 -3
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +13 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +36 -10
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +137 -68
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +5 -3
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +18 -5
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/builtin-diagnostics.d.ts +2 -0
- package/dist/core/builtin-diagnostics.d.ts.map +1 -0
- package/dist/core/builtin-diagnostics.js +14 -0
- package/dist/core/builtin-diagnostics.js.map +1 -0
- package/dist/core/builtin-packages.d.ts +5 -2
- package/dist/core/builtin-packages.d.ts.map +1 -1
- package/dist/core/builtin-packages.js +24 -3
- package/dist/core/builtin-packages.js.map +1 -1
- package/dist/core/builtin-resource-loader.d.ts +4 -0
- package/dist/core/builtin-resource-loader.d.ts.map +1 -0
- package/dist/core/builtin-resource-loader.js +239 -0
- package/dist/core/builtin-resource-loader.js.map +1 -0
- package/dist/core/cache-retention.d.ts +4 -0
- package/dist/core/cache-retention.d.ts.map +1 -0
- package/dist/core/cache-retention.js +58 -0
- package/dist/core/cache-retention.js.map +1 -0
- package/dist/core/cache-stats.d.ts +7 -1
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +34 -4
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/cache-warmer.d.ts +66 -0
- package/dist/core/cache-warmer.d.ts.map +1 -0
- package/dist/core/cache-warmer.js +313 -0
- package/dist/core/cache-warmer.js.map +1 -0
- package/dist/core/child-session-options.d.ts +5 -0
- package/dist/core/child-session-options.d.ts.map +1 -0
- package/dist/core/child-session-options.js +30 -0
- package/dist/core/child-session-options.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +3 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction-boundary.d.ts +29 -1
- package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
- package/dist/core/compaction/compaction-boundary.js +48 -10
- package/dist/core/compaction/compaction-boundary.js.map +1 -1
- package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/compaction-runner.js +18 -5
- package/dist/core/compaction/compaction-runner.js.map +1 -1
- package/dist/core/compaction/compaction-types.d.ts +7 -0
- package/dist/core/compaction/compaction-types.d.ts.map +1 -1
- package/dist/core/compaction/compaction-types.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +3 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +55 -0
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/fallback-planner.d.ts +1 -0
- package/dist/core/compaction/fallback-planner.d.ts.map +1 -1
- package/dist/core/compaction/fallback-planner.js +2 -0
- package/dist/core/compaction/fallback-planner.js.map +1 -1
- package/dist/core/compaction/index.d.ts +1 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +1 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/range-planner.d.ts.map +1 -1
- package/dist/core/compaction/range-planner.js +3 -3
- package/dist/core/compaction/range-planner.js.map +1 -1
- package/dist/core/compaction/session-summarization.d.ts.map +1 -1
- package/dist/core/compaction/session-summarization.js +2 -1
- package/dist/core/compaction/session-summarization.js.map +1 -1
- package/dist/core/compaction/whole-context-stats.d.ts +21 -0
- package/dist/core/compaction/whole-context-stats.d.ts.map +1 -0
- package/dist/core/compaction/whole-context-stats.js +32 -0
- package/dist/core/compaction/whole-context-stats.js.map +1 -0
- package/dist/core/crash-log.d.ts +6 -0
- package/dist/core/crash-log.d.ts.map +1 -0
- package/dist/core/crash-log.js +69 -0
- package/dist/core/crash-log.js.map +1 -0
- package/dist/core/credential-screening.d.ts +17 -0
- package/dist/core/credential-screening.d.ts.map +1 -0
- package/dist/core/credential-screening.js +30 -0
- package/dist/core/credential-screening.js.map +1 -0
- package/dist/core/execution-model-router.d.ts +45 -0
- package/dist/core/execution-model-router.d.ts.map +1 -0
- package/dist/core/execution-model-router.js +249 -0
- package/dist/core/execution-model-router.js.map +1 -0
- package/dist/core/export-html/template-js/tree-filter-render.js +6 -1
- package/dist/core/export-html/template.js +6 -1
- package/dist/core/extensions/agent-events.d.ts +82 -8
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +51 -42
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +7 -1
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/event-results.d.ts +10 -6
- package/dist/core/extensions/event-results.d.ts.map +1 -1
- package/dist/core/extensions/event-results.js.map +1 -1
- package/dist/core/extensions/event-types.d.ts +3 -2
- package/dist/core/extensions/event-types.d.ts.map +1 -1
- package/dist/core/extensions/event-types.js.map +1 -1
- package/dist/core/extensions/extension-work.d.ts +14 -0
- package/dist/core/extensions/extension-work.d.ts.map +1 -0
- package/dist/core/extensions/extension-work.js +73 -0
- package/dist/core/extensions/extension-work.js.map +1 -0
- package/dist/core/extensions/herdr-file-integration.d.ts +36 -0
- package/dist/core/extensions/herdr-file-integration.d.ts.map +1 -0
- package/dist/core/extensions/herdr-file-integration.js +60 -0
- package/dist/core/extensions/herdr-file-integration.js.map +1 -0
- package/dist/core/extensions/host-input.d.ts +51 -0
- package/dist/core/extensions/host-input.d.ts.map +1 -0
- package/dist/core/extensions/host-input.js +211 -0
- package/dist/core/extensions/host-input.js.map +1 -0
- package/dist/core/extensions/index.d.ts +4 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +0 -3
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/jiti-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-loader.js +3 -0
- package/dist/core/extensions/jiti-loader.js.map +1 -0
- package/dist/core/extensions/jiti-static-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-static-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-static-loader.js +3 -0
- package/dist/core/extensions/jiti-static-loader.js.map +1 -0
- package/dist/core/extensions/loader-api.d.ts +7 -0
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +154 -28
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-bindings.d.ts +24 -0
- package/dist/core/extensions/loader-bindings.d.ts.map +1 -0
- package/dist/core/extensions/loader-bindings.js +128 -0
- package/dist/core/extensions/loader-bindings.js.map +1 -0
- package/dist/core/extensions/loader-core.d.ts +2 -1
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +92 -14
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-host-modules.js +3 -1
- package/dist/core/extensions/loader-host-modules.js.map +1 -1
- package/dist/core/extensions/loader-rollback.d.ts +14 -0
- package/dist/core/extensions/loader-rollback.d.ts.map +1 -0
- package/dist/core/extensions/loader-rollback.js +95 -0
- package/dist/core/extensions/loader-rollback.js.map +1 -0
- package/dist/core/extensions/loader-runtime.d.ts +3 -1
- package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
- package/dist/core/extensions/loader-runtime.js +38 -14
- package/dist/core/extensions/loader-runtime.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +9 -2
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +34 -14
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/reactive-widget.d.ts +1 -1
- package/dist/core/extensions/reactive-widget.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +4 -0
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +25 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner-events.d.ts +24 -6
- package/dist/core/extensions/runner-events.d.ts.map +1 -1
- package/dist/core/extensions/runner-events.js +153 -58
- package/dist/core/extensions/runner-events.js.map +1 -1
- package/dist/core/extensions/runner-project-trust.d.ts.map +1 -1
- package/dist/core/extensions/runner-project-trust.js +2 -4
- package/dist/core/extensions/runner-project-trust.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +34 -6
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +223 -24
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +6 -0
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/tool-types.d.ts +9 -0
- package/dist/core/extensions/tool-types.d.ts.map +1 -1
- package/dist/core/extensions/tool-types.js.map +1 -1
- package/dist/core/extensions/types.d.ts +3 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +0 -12
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/workflow-activity-hub.d.ts +2 -0
- package/dist/core/extensions/workflow-activity-hub.d.ts.map +1 -1
- package/dist/core/extensions/workflow-activity-hub.js +5 -3
- package/dist/core/extensions/workflow-activity-hub.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +5 -3
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/fast-model-routing.d.ts +3 -3
- package/dist/core/fast-model-routing.d.ts.map +1 -1
- package/dist/core/fast-model-routing.js +4 -3
- package/dist/core/fast-model-routing.js.map +1 -1
- package/dist/core/fast-model-variants.d.ts +30 -0
- package/dist/core/fast-model-variants.d.ts.map +1 -1
- package/dist/core/fast-model-variants.js +43 -1
- package/dist/core/fast-model-variants.js.map +1 -1
- package/dist/core/index.d.ts +4 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/mandatory-resource-loader.d.ts +4 -0
- package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
- package/dist/core/mandatory-resource-loader.js +29 -1
- package/dist/core/mandatory-resource-loader.js.map +1 -1
- package/dist/core/mandatory-runtime-tools.d.ts +1 -4
- package/dist/core/mandatory-runtime-tools.d.ts.map +1 -1
- package/dist/core/mandatory-runtime-tools.js +1 -9
- package/dist/core/mandatory-runtime-tools.js.map +1 -1
- package/dist/core/messages.d.ts +10 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +76 -2
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +178 -10
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +48 -19
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +6 -2
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +12 -2
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-defaults.d.ts.map +1 -1
- package/dist/core/model-resolver-defaults.js +2 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/model-routing-constraints.d.ts +24 -0
- package/dist/core/model-routing-constraints.d.ts.map +1 -0
- package/dist/core/model-routing-constraints.js +46 -0
- package/dist/core/model-routing-constraints.js.map +1 -0
- package/dist/core/model-routing-task.d.ts +4 -0
- package/dist/core/model-routing-task.d.ts.map +1 -0
- package/dist/core/model-routing-task.js +77 -0
- package/dist/core/model-routing-task.js.map +1 -0
- package/dist/core/model-runtime-auth.d.ts +2 -2
- package/dist/core/model-runtime-auth.d.ts.map +1 -1
- package/dist/core/model-runtime-auth.js.map +1 -1
- package/dist/core/model-runtime-streaming.d.ts +13 -3
- package/dist/core/model-runtime-streaming.d.ts.map +1 -1
- package/dist/core/model-runtime-streaming.js +16 -5
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/model-runtime-types.d.ts +2 -2
- package/dist/core/model-runtime-types.d.ts.map +1 -1
- package/dist/core/model-runtime-types.js.map +1 -1
- package/dist/core/model-runtime.d.ts +29 -6
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +84 -7
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager-npm.d.ts.map +1 -1
- package/dist/core/package-manager-npm.js +32 -8
- package/dist/core/package-manager-npm.js.map +1 -1
- package/dist/core/package-manager-resolver.js +3 -1
- package/dist/core/package-manager-resolver.js.map +1 -1
- package/dist/core/package-manager-types.d.ts +1 -0
- package/dist/core/package-manager-types.d.ts.map +1 -1
- package/dist/core/package-manager-types.js.map +1 -1
- package/dist/core/prompt-templates-async.d.ts +2 -2
- package/dist/core/prompt-templates-async.d.ts.map +1 -1
- package/dist/core/prompt-templates-async.js +57 -29
- package/dist/core/prompt-templates-async.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +6 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +61 -35
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-composer-internal.d.ts +41 -20
- package/dist/core/provider-composer-internal.d.ts.map +1 -1
- package/dist/core/provider-composer-internal.js +43 -20
- package/dist/core/provider-composer-internal.js.map +1 -1
- package/dist/core/provider-composer.d.ts +3 -3
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +54 -10
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +8 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +46 -4
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts +2 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +23 -1
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader-assets.d.ts.map +1 -1
- package/dist/core/resource-loader-assets.js +6 -6
- package/dist/core/resource-loader-assets.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts +6 -0
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +41 -6
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-extension-warnings.d.ts +9 -0
- package/dist/core/resource-loader-extension-warnings.d.ts.map +1 -0
- package/dist/core/resource-loader-extension-warnings.js +54 -0
- package/dist/core/resource-loader-extension-warnings.js.map +1 -0
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.js +3 -0
- package/dist/core/resource-loader-extensions.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +13 -2
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader.d.ts +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +1 -1
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +2 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +18 -1
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk-types.d.ts +18 -5
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts +3 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +231 -42
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-lifecycle-scope.d.ts +15 -0
- package/dist/core/session-lifecycle-scope.d.ts.map +1 -0
- package/dist/core/session-lifecycle-scope.js +13 -0
- package/dist/core/session-lifecycle-scope.js.map +1 -0
- package/dist/core/session-lifecycle-work.d.ts +17 -0
- package/dist/core/session-lifecycle-work.d.ts.map +1 -0
- package/dist/core/session-lifecycle-work.js +144 -0
- package/dist/core/session-lifecycle-work.js.map +1 -0
- package/dist/core/session-manager-core.d.ts +19 -6
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +117 -12
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +4 -1
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +8 -0
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +16 -1
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +106 -40
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-list.d.ts +3 -3
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +89 -74
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +10 -7
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +41 -4
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager.d.ts +2 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-startup-rollback.d.ts +5 -0
- package/dist/core/session-startup-rollback.d.ts.map +1 -0
- package/dist/core/session-startup-rollback.js +16 -0
- package/dist/core/session-startup-rollback.js.map +1 -0
- package/dist/core/settings-manager-basic-accessors.d.ts +5 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +35 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +4 -0
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +1 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-types.d.ts +4 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/settings-write-ownership.d.ts +7 -0
- package/dist/core/settings-write-ownership.d.ts.map +1 -0
- package/dist/core/settings-write-ownership.js +24 -0
- package/dist/core/settings-write-ownership.js.map +1 -0
- package/dist/core/skill-catalog.d.ts.map +1 -1
- package/dist/core/skill-catalog.js +18 -6
- package/dist/core/skill-catalog.js.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/structured-output/choice-schema.d.ts +8 -0
- package/dist/core/structured-output/choice-schema.d.ts.map +1 -0
- package/dist/core/structured-output/choice-schema.js +79 -0
- package/dist/core/structured-output/choice-schema.js.map +1 -0
- package/dist/core/structured-output/index.d.ts +10 -0
- package/dist/core/structured-output/index.d.ts.map +1 -0
- package/dist/core/structured-output/index.js +424 -0
- package/dist/core/structured-output/index.js.map +1 -0
- package/dist/core/structured-output/invalid-output.d.ts +8 -0
- package/dist/core/structured-output/invalid-output.d.ts.map +1 -0
- package/dist/core/structured-output/invalid-output.js +4 -0
- package/dist/core/structured-output/invalid-output.js.map +1 -0
- package/dist/core/structured-output/resolver.d.ts +3 -0
- package/dist/core/structured-output/resolver.d.ts.map +1 -0
- package/dist/core/structured-output/resolver.js +26 -0
- package/dist/core/structured-output/resolver.js.map +1 -0
- package/dist/core/structured-output/types.d.ts +76 -0
- package/dist/core/structured-output/types.d.ts.map +1 -0
- package/dist/core/structured-output/types.js +2 -0
- package/dist/core/structured-output/types.js.map +1 -0
- package/dist/core/system-prompt.d.ts +48 -5
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +141 -100
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/child-command-owner.d.ts +34 -0
- package/dist/core/tasks/child-command-owner.d.ts.map +1 -0
- package/dist/core/tasks/child-command-owner.js +70 -0
- package/dist/core/tasks/child-command-owner.js.map +1 -0
- package/dist/core/tasks/contracts.d.ts +6 -0
- package/dist/core/tasks/contracts.d.ts.map +1 -1
- package/dist/core/tasks/contracts.js.map +1 -1
- package/dist/core/tasks/owner-store.d.ts +6 -0
- package/dist/core/tasks/owner-store.d.ts.map +1 -1
- package/dist/core/tasks/owner-store.js +16 -3
- package/dist/core/tasks/owner-store.js.map +1 -1
- package/dist/core/tasks/pause.js +1 -1
- package/dist/core/tasks/pause.js.map +1 -1
- package/dist/core/tasks/supervisor.d.ts +4 -2
- package/dist/core/tasks/supervisor.d.ts.map +1 -1
- package/dist/core/tasks/supervisor.js +16 -3
- package/dist/core/tasks/supervisor.js.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts +4 -1
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.js +32 -35
- package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
- package/dist/core/tools/ask-user-question/index.d.ts +1 -1
- package/dist/core/tools/ask-user-question/index.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/key-router.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/key-router.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/row-intent.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/row-intent.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/contract.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/contract.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/derivations.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/derivations.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/state-reducer.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/state.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/state.js.map +1 -1
- package/dist/core/tools/ask-user-question/tool/format-answer.d.ts +1 -1
- package/dist/core/tools/ask-user-question/tool/format-answer.js.map +1 -1
- package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts +1 -1
- package/dist/core/tools/ask-user-question/tool/response-envelope.js.map +1 -1
- package/dist/core/tools/ask-user-question/tool/validate-questionnaire.d.ts +1 -1
- package/dist/core/tools/ask-user-question/tool/validate-questionnaire.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/props-adapter.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/props-adapter.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
- package/dist/core/tools/bash-pty-native.d.ts +5 -1
- package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
- package/dist/core/tools/bash-pty-native.js +15 -7
- package/dist/core/tools/bash-pty-native.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +32 -24
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +1 -0
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-coordinator.d.ts +4 -3
- package/dist/core/tools/file-mutation-coordinator.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-coordinator.js +45 -38
- package/dist/core/tools/file-mutation-coordinator.js.map +1 -1
- package/dist/core/tools/find.d.ts +2 -2
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/kill.d.ts +2 -2
- package/dist/core/tools/kill.d.ts.map +1 -1
- package/dist/core/tools/kill.js +3 -4
- package/dist/core/tools/kill.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +16 -0
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/read.d.ts +4 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +5 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/structured-output.d.ts +9 -6
- package/dist/core/tools/structured-output.d.ts.map +1 -1
- package/dist/core/tools/structured-output.js +36 -8
- package/dist/core/tools/structured-output.js.map +1 -1
- package/dist/core/tools/todos.d.ts.map +1 -1
- package/dist/core/tools/todos.js +1 -0
- package/dist/core/tools/todos.js.map +1 -1
- package/dist/core/tools/tool-concurrency.d.ts +23 -0
- package/dist/core/tools/tool-concurrency.d.ts.map +1 -0
- package/dist/core/tools/tool-concurrency.js +58 -0
- package/dist/core/tools/tool-concurrency.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +4 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +2 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +1 -0
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +4 -0
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/extensions/herdr/index.d.ts.map +1 -1
- package/dist/extensions/herdr/index.js +0 -7
- package/dist/extensions/herdr/index.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +2 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +6 -2
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +18 -4
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +13 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/main-app-mode.d.ts +1 -1
- package/dist/main-app-mode.d.ts.map +1 -1
- package/dist/main-app-mode.js +3 -2
- package/dist/main-app-mode.js.map +1 -1
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +24 -16
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +9 -6
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.js +3 -2
- package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +12 -5
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +5 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +4 -0
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts +2 -2
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts +2 -0
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +30 -12
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +6 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +17 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form-mount.d.ts +1 -1
- package/dist/modes/interactive/components/host-input-form-mount.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form.d.ts +1 -1
- package/dist/modes/interactive/components/host-input-form.js.map +1 -1
- package/dist/modes/interactive/components/host-session-picker.d.ts +1 -1
- package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
- package/dist/modes/interactive/components/reserved-bottom-overlay.d.ts +1 -1
- package/dist/modes/interactive/components/reserved-bottom-overlay.js.map +1 -1
- package/dist/modes/interactive/components/scroll-widget.d.ts +1 -1
- package/dist/modes/interactive/components/scroll-widget.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
- package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +52 -1
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js +2 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +8 -2
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +11 -4
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/startup-identity.d.ts +3 -0
- package/dist/modes/interactive/components/startup-identity.d.ts.map +1 -1
- package/dist/modes/interactive/components/startup-identity.js +11 -2
- package/dist/modes/interactive/components/startup-identity.js.map +1 -1
- package/dist/modes/interactive/components/task-inspector.d.ts +1 -0
- package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-inspector.js +11 -11
- package/dist/modes/interactive/components/task-inspector.js.map +1 -1
- package/dist/modes/interactive/components/task-list.d.ts +9 -3
- package/dist/modes/interactive/components/task-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-list.js +26 -2
- package/dist/modes/interactive/components/task-list.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +14 -9
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +6 -0
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-model.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-model.js +1 -0
- package/dist/modes/interactive/components/tree-selector-model.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +20 -10
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +3 -5
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +2 -2
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +4 -0
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +13 -6
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +5 -0
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +2 -2
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +16 -0
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +2 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +13 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +30 -34
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +6 -9
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +11 -0
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +5 -1
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +2 -4
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +2 -2
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-tui.d.ts +3 -6
- package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-tui.js +15 -5
- package/dist/modes/interactive/interactive-tui.js.map +1 -1
- package/dist/modes/interactive/overlay-line-composite.d.ts +7 -0
- package/dist/modes/interactive/overlay-line-composite.d.ts.map +1 -0
- package/dist/modes/interactive/overlay-line-composite.js +24 -0
- package/dist/modes/interactive/overlay-line-composite.js.map +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +3 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/engine-input-form.d.ts +1 -1
- package/dist/modes/interactive-engine/engine-input-form.js.map +1 -1
- package/dist/modes/interactive-engine/engine-session-picker.d.ts +1 -1
- package/dist/modes/interactive-engine/engine-session-picker.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-auth.d.ts +16 -0
- package/dist/modes/interactive-engine/isolated-auth.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-auth.js +27 -0
- package/dist/modes/interactive-engine/isolated-auth.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +5 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +19 -2
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +1 -1
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +2 -1
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +7 -2
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +3 -1
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-keybindings-reload.d.ts +1 -1
- package/dist/modes/rpc/rpc-keybindings-reload.js.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.d.ts +3 -2
- package/dist/modes/rpc/rpc-provider-auth.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.js +2 -2
- package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/session-id-target.d.ts +31 -0
- package/dist/session-id-target.d.ts.map +1 -0
- package/dist/session-id-target.js +57 -0
- package/dist/session-id-target.js.map +1 -0
- package/dist/utils/abort.d.ts.map +1 -1
- package/dist/utils/abort.js +29 -4
- package/dist/utils/abort.js.map +1 -1
- package/dist/utils/child-process.d.ts +1 -0
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +7 -8
- 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 +15 -29
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +88 -12
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/mime.js +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +18 -1
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tool-result-images.d.ts +3 -1
- package/dist/utils/tool-result-images.d.ts.map +1 -1
- package/dist/utils/tool-result-images.js +4 -1
- package/dist/utils/tool-result-images.js.map +1 -1
- package/dist/utils/wsl.d.ts +3 -0
- package/dist/utils/wsl.d.ts.map +1 -0
- package/dist/utils/wsl.js +15 -0
- package/dist/utils/wsl.js.map +1 -0
- package/docs/background-tasks.md +38 -16
- package/docs/build.md +6 -16
- package/docs/compaction/reference.md +12 -12
- package/docs/compaction.md +33 -109
- package/docs/computer-use.md +124 -76
- package/docs/containerization.md +4 -5
- package/docs/custom-provider/api-reference.md +10 -1
- package/docs/custom-provider/oauth.md +4 -2
- package/docs/custom-provider/registration.md +1 -1
- package/docs/custom-provider/streaming.md +8 -3
- package/docs/custom-provider.md +44 -2
- package/docs/development.md +13 -138
- package/docs/docs.json +19 -4
- package/docs/environment-variables.md +21 -5
- package/docs/extensions/api-reference.md +6 -2
- package/docs/extensions/authoring.md +29 -7
- package/docs/extensions/events.md +107 -31
- package/docs/extensions/examples.md +1 -0
- package/docs/extensions/ui.md +3 -4
- package/docs/extensions.md +28 -20
- package/docs/getting-started/authentication.md +4 -1
- package/docs/getting-started/first-session.md +11 -8
- package/docs/getting-started/installation.md +14 -6
- package/docs/getting-started/project-instructions.md +5 -1
- package/docs/guides/configuration.md +10 -5
- package/docs/guides/non-interactive.md +2 -2
- package/docs/guides.md +8 -17
- package/docs/herdr.md +2 -1
- package/docs/index.md +2 -2
- package/docs/intercom/operations.md +25 -67
- package/docs/intercom/reference.md +15 -5
- package/docs/intercom.md +16 -7
- package/docs/json.md +12 -2
- package/docs/keybindings.md +15 -8
- package/docs/llama-cpp.md +6 -2
- package/docs/mcp-servers.md +93 -0
- package/docs/models/evals.md +75 -465
- package/docs/models/model-selection.md +35 -116
- package/docs/models/reference.md +70 -24
- package/docs/models.md +7 -4
- package/docs/packages/authoring.md +8 -2
- package/docs/packages/reference.md +5 -1
- package/docs/packages.md +7 -3
- package/docs/programmatic.md +3 -1
- package/docs/prompt-templates.md +3 -2
- package/docs/providers/reference.md +2 -2
- package/docs/providers.md +55 -18
- package/docs/quickstart.md +8 -4
- package/docs/reference/cli.md +21 -13
- package/docs/reference.md +3 -6
- package/docs/rpc/examples.md +2 -0
- package/docs/rpc/protocol.md +11 -13
- package/docs/rpc.md +5 -1
- package/docs/sdk/reference.md +62 -267
- package/docs/sdk/structured-decisions.md +94 -0
- package/docs/sdk.md +194 -19
- package/docs/security.md +7 -4
- package/docs/session-format.md +35 -7
- package/docs/sessions.md +12 -6
- package/docs/settings.md +68 -16
- package/docs/skills/authoring.md +7 -1
- package/docs/skills.md +33 -8
- package/docs/subagents/authoring.md +11 -1
- package/docs/subagents/reference.md +97 -10
- package/docs/subagents.md +52 -36
- package/docs/terminal-setup.md +4 -2
- package/docs/termux.md +3 -1
- package/docs/themes/reference.md +4 -1
- package/docs/themes.md +1 -1
- package/docs/tools.md +431 -20
- package/docs/tui/reference.md +13 -14
- package/docs/tui.md +10 -6
- package/docs/usage.md +34 -7
- package/docs/web-access.md +5 -1
- package/docs/windows.md +18 -11
- package/docs/workflows/api-reference.md +112 -27
- package/docs/workflows/authoring.md +345 -33
- package/docs/workflows/builtins.md +22 -28
- package/docs/workflows/operations.md +259 -138
- package/docs/workflows/reliable-design.md +59 -130
- package/docs/workflows/verification.md +40 -14
- package/docs/workflows.md +12 -17
- package/examples/extensions/README.md +1 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +15 -10
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
- package/examples/extensions/debug-provider.ts +90 -0
- package/examples/extensions/prompt-customizer.ts +17 -37
- package/examples/extensions/structured-output.ts +6 -0
- package/examples/rpc-client.ts +38 -0
- package/examples/rpc-extension-ui.ts +19 -5
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +506 -713
- package/package.json +13 -11
- package/dist/builtin/subagents/skills/playwright-cli/SKILL.md +0 -420
- package/dist/builtin/subagents/skills/playwright-cli/references/element-attributes.md +0 -23
- package/dist/builtin/subagents/skills/playwright-cli/references/playwright-tests.md +0 -39
- package/dist/builtin/subagents/skills/playwright-cli/references/request-mocking.md +0 -87
- package/dist/builtin/subagents/skills/playwright-cli/references/running-code.md +0 -241
- package/dist/builtin/subagents/skills/playwright-cli/references/session-management.md +0 -225
- package/dist/builtin/subagents/skills/playwright-cli/references/storage-state.md +0 -275
- package/dist/builtin/subagents/skills/playwright-cli/references/test-generation.md +0 -433
- package/dist/builtin/subagents/skills/playwright-cli/references/tracing.md +0 -139
- package/dist/builtin/subagents/skills/playwright-cli/references/video-recording.md +0 -143
- package/dist/builtin/workflows/builtin/chunk-ngkqkzej.js +0 -2813
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_asset_producer.toml +0 -94
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_documenter.toml +0 -27
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_finish_reviewer.toml +0 -41
- package/dist/builtin/workflows/skills/impeccable/agents/impeccable_manual_edit_applier.toml +0 -95
- package/dist/builtin/workflows/skills/impeccable/agents/openai.yaml +0 -4
- package/dist/builtin/workflows/skills/impeccable/scripts/concept-seed.mjs +0 -695
- package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +0 -325
- package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +0 -1503
- package/dist/builtin/workflows/skills/impeccable/scripts/critique-storage.mjs +0 -222
- package/dist/builtin/workflows/skills/impeccable/scripts/detect-csp.mjs +0 -198
- package/dist/builtin/workflows/skills/impeccable/scripts/detect.mjs +0 -21
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +0 -2073
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +0 -432
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +0 -1121
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +0 -8746
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns.mjs +0 -51
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +0 -376
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +0 -1168
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +0 -1192
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +0 -290
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +0 -189
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/findings.mjs +0 -18
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/node/file-system.mjs +0 -213
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/profile/profiler.mjs +0 -166
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +0 -617
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +0 -5534
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/color.mjs +0 -588
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/constants.mjs +0 -112
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +0 -30
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/inline-ignores.mjs +0 -148
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +0 -35
- package/dist/builtin/workflows/skills/impeccable/scripts/doctor.mjs +0 -338
- package/dist/builtin/workflows/skills/impeccable/scripts/embed-prompt.mjs +0 -270
- package/dist/builtin/workflows/skills/impeccable/scripts/generate-image.mjs +0 -277
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +0 -783
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +0 -2305
- package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +0 -78
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/artifact-schema.mjs +0 -93
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/composition-catalog.mjs +0 -200
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/concept-catalog.mjs +0 -395
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/design-parser.mjs +0 -925
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +0 -640
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-paths.mjs +0 -137
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +0 -72
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/open-system-browser.mjs +0 -57
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/provider.mjs +0 -5
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/roll-selection.mjs +0 -369
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-deep.mjs +0 -483
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-notice.mjs +0 -169
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness.mjs +0 -528
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/surface-briefs.mjs +0 -151
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-args.mjs +0 -42
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-slug.mjs +0 -33
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/template-extensions.mjs +0 -146
- package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-css.mjs +0 -617
- package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-verify.mjs +0 -71
- package/dist/builtin/workflows/skills/impeccable/scripts/live/browser-script-parts.mjs +0 -77
- package/dist/builtin/workflows/skills/impeccable/scripts/live/completion.mjs +0 -28
- package/dist/builtin/workflows/skills/impeccable/scripts/live/event-validation.mjs +0 -199
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/astro.mjs +0 -47
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/detect-utils.mjs +0 -157
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/index.mjs +0 -143
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/journal.mjs +0 -205
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nextjs.mjs +0 -49
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nuxt.mjs +0 -170
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/script-src.mjs +0 -26
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/static-html.mjs +0 -26
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/sveltekit.mjs +0 -71
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tag-strategy.mjs +0 -247
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tanstack-start.mjs +0 -70
- package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/vite-generic.mjs +0 -42
- package/dist/builtin/workflows/skills/impeccable/scripts/live/generation-preflight.mjs +0 -149
- package/dist/builtin/workflows/skills/impeccable/scripts/live/insert-ui.mjs +0 -458
- package/dist/builtin/workflows/skills/impeccable/scripts/live/instructions.mjs +0 -169
- package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-apply.mjs +0 -939
- package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edit-routes.mjs +0 -357
- package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edits-buffer.mjs +0 -152
- package/dist/builtin/workflows/skills/impeccable/scripts/live/poll-lanes.mjs +0 -14
- package/dist/builtin/workflows/skills/impeccable/scripts/live/roots.mjs +0 -670
- package/dist/builtin/workflows/skills/impeccable/scripts/live/session-store.mjs +0 -563
- package/dist/builtin/workflows/skills/impeccable/scripts/live/source-lock.mjs +0 -105
- package/dist/builtin/workflows/skills/impeccable/scripts/live/source-search.mjs +0 -105
- package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-ast.mjs +0 -969
- package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +0 -1401
- package/dist/builtin/workflows/skills/impeccable/scripts/live/sveltekit-adapter.mjs +0 -314
- package/dist/builtin/workflows/skills/impeccable/scripts/live/tanstack-adapter.mjs +0 -280
- package/dist/builtin/workflows/skills/impeccable/scripts/live/ui-surfaces.mjs +0 -75
- package/dist/builtin/workflows/skills/impeccable/scripts/live/vocabulary.mjs +0 -171
- package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +0 -961
- package/dist/builtin/workflows/skills/impeccable/scripts/live-commit-manual-edits.mjs +0 -1244
- package/dist/builtin/workflows/skills/impeccable/scripts/live-complete.mjs +0 -107
- package/dist/builtin/workflows/skills/impeccable/scripts/live-copy-edit-agent.mjs +0 -800
- package/dist/builtin/workflows/skills/impeccable/scripts/live-discard-manual-edits.mjs +0 -51
- package/dist/builtin/workflows/skills/impeccable/scripts/live-inject.mjs +0 -515
- package/dist/builtin/workflows/skills/impeccable/scripts/live-insert.mjs +0 -292
- package/dist/builtin/workflows/skills/impeccable/scripts/live-manual-edit-evidence.mjs +0 -371
- package/dist/builtin/workflows/skills/impeccable/scripts/live-poll.mjs +0 -427
- package/dist/builtin/workflows/skills/impeccable/scripts/live-resume.mjs +0 -123
- package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +0 -1675
- package/dist/builtin/workflows/skills/impeccable/scripts/live-status.mjs +0 -71
- package/dist/builtin/workflows/skills/impeccable/scripts/live-target.mjs +0 -30
- package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +0 -927
- package/dist/builtin/workflows/skills/impeccable/scripts/live.mjs +0 -365
- package/dist/builtin/workflows/skills/impeccable/scripts/palette.mjs +0 -628
- package/dist/builtin/workflows/skills/impeccable/scripts/pin.mjs +0 -224
- package/dist/builtin/workflows/skills/impeccable/scripts/serve-question.mjs +0 -1540
- package/dist/builtin/workflows/skills/impeccable/scripts/surface-brief.mjs +0 -74
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_astra.md +0 -58
- package/docs/models/artificial-analysis-index.md +0 -89
- package/docs/models/pareto-efficiency.md +0 -90
- package/docs/tools/edit.md +0 -378
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export function resolveToolConcurrency(concurrency, args) {
|
|
2
|
+
if (typeof concurrency !== "function")
|
|
3
|
+
return concurrency ?? "shared";
|
|
4
|
+
try {
|
|
5
|
+
return concurrency(args);
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
return "exclusive";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Orders tool executions in the order they start. The agent loop starts a batch's calls in
|
|
13
|
+
* assistant-message order, so an exclusive call observes every earlier call's effects and no
|
|
14
|
+
* later call observes the state from before it.
|
|
15
|
+
*/
|
|
16
|
+
export class ToolExecutionScheduler {
|
|
17
|
+
#lastExclusive;
|
|
18
|
+
#sharedSinceExclusive = new Set();
|
|
19
|
+
/** Runs `run` synchronously when nothing earlier blocks it, so its abort listeners attach immediately. */
|
|
20
|
+
schedule(mode, run) {
|
|
21
|
+
const blockers = mode === "exclusive"
|
|
22
|
+
? [...(this.#lastExclusive ? [this.#lastExclusive] : []), ...this.#sharedSinceExclusive]
|
|
23
|
+
: this.#lastExclusive
|
|
24
|
+
? [this.#lastExclusive]
|
|
25
|
+
: [];
|
|
26
|
+
const task = blockers.length === 0 ? invoke(run) : Promise.all(blockers).then(run);
|
|
27
|
+
const settled = task.then(() => undefined, () => undefined);
|
|
28
|
+
if (mode === "exclusive") {
|
|
29
|
+
this.#lastExclusive = settled;
|
|
30
|
+
this.#sharedSinceExclusive.clear();
|
|
31
|
+
void settled.then(() => {
|
|
32
|
+
if (this.#lastExclusive === settled)
|
|
33
|
+
this.#lastExclusive = undefined;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.#sharedSinceExclusive.add(settled);
|
|
38
|
+
void settled.then(() => this.#sharedSinceExclusive.delete(settled));
|
|
39
|
+
}
|
|
40
|
+
return task;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function invoke(run) {
|
|
44
|
+
try {
|
|
45
|
+
return run();
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
return Promise.reject(error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Route a tool's executions through a session scheduler according to its declared concurrency. */
|
|
52
|
+
export function scheduleToolExecution(tool, scheduler) {
|
|
53
|
+
return {
|
|
54
|
+
...tool,
|
|
55
|
+
execute: (...args) => scheduler.schedule(resolveToolConcurrency(tool.concurrency, args[1]), () => tool.execute(...args)),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=tool-concurrency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1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B,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;YACnC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;gBACtB,IAAI,IAAI,CAAC,cAAc,KAAK,OAAO;oBAAE,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;YACtE,CAAC,CAAC,CAAC;QACJ,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACxC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED,SAAS,MAAM,CAAI,GAAqB;IACvC,IAAI,CAAC;QACJ,OAAO,GAAG,EAAE,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACF,CAAC;AAED,mGAAmG;AACnG,MAAM,UAAU,qBAAqB,CAAC,IAAe,EAAE,SAAiC;IACvF,OAAO;QACN,GAAG,IAAI;QACP,OAAO,EAAE,CAAC,GAAG,IAAsC,EAAE,EAAE,CACtD,SAAS,CAAC,QAAQ,CAAC,sBAAsB,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAA4B,CAAC,EAAE,GAAG,EAAE,CACrG,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CACrB;KACF,CAAC;AACH,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\n\n/**\n * How a tool call is ordered against the other calls of the same assistant message.\n * - \"shared\": may overlap other shared calls; waits for the latest earlier exclusive call (default)\n * - \"exclusive\": waits for every earlier call; later calls wait for it\n * - function: resolved per call from its prepared arguments; a throwing resolver means \"exclusive\"\n */\nexport type ToolConcurrencyMode = \"shared\" | \"exclusive\";\nexport type ToolConcurrency<TArgs = Record<string, unknown>> =\n\t| ToolConcurrencyMode\n\t| ((args: Partial<TArgs>) => ToolConcurrencyMode);\n\nexport function resolveToolConcurrency<TArgs>(\n\tconcurrency: ToolConcurrency<TArgs> | undefined,\n\targs: Partial<TArgs>,\n): ToolConcurrencyMode {\n\tif (typeof concurrency !== \"function\") return concurrency ?? \"shared\";\n\ttry {\n\t\treturn concurrency(args);\n\t} catch {\n\t\treturn \"exclusive\";\n\t}\n}\n\n/**\n * Orders tool executions in the order they start. The agent loop starts a batch's calls in\n * assistant-message order, so an exclusive call observes every earlier call's effects and no\n * later call observes the state from before it.\n */\nexport class ToolExecutionScheduler {\n\t#lastExclusive: Promise<void> | undefined;\n\treadonly #sharedSinceExclusive = new Set<Promise<void>>();\n\n\t/** Runs `run` synchronously when nothing earlier blocks it, so its abort listeners attach immediately. */\n\tschedule<T>(mode: ToolConcurrencyMode, run: () => Promise<T>): Promise<T> {\n\t\tconst blockers =\n\t\t\tmode === \"exclusive\"\n\t\t\t\t? [...(this.#lastExclusive ? [this.#lastExclusive] : []), ...this.#sharedSinceExclusive]\n\t\t\t\t: this.#lastExclusive\n\t\t\t\t\t? [this.#lastExclusive]\n\t\t\t\t\t: [];\n\t\tconst task = blockers.length === 0 ? invoke(run) : Promise.all(blockers).then(run);\n\t\tconst settled = task.then(\n\t\t\t() => undefined,\n\t\t\t() => undefined,\n\t\t);\n\t\tif (mode === \"exclusive\") {\n\t\t\tthis.#lastExclusive = settled;\n\t\t\tthis.#sharedSinceExclusive.clear();\n\t\t\tvoid settled.then(() => {\n\t\t\t\tif (this.#lastExclusive === settled) this.#lastExclusive = undefined;\n\t\t\t});\n\t\t} else {\n\t\t\tthis.#sharedSinceExclusive.add(settled);\n\t\t\tvoid settled.then(() => this.#sharedSinceExclusive.delete(settled));\n\t\t}\n\t\treturn task;\n\t}\n}\n\nfunction invoke<T>(run: () => Promise<T>): Promise<T> {\n\ttry {\n\t\treturn run();\n\t} catch (error) {\n\t\treturn Promise.reject(error);\n\t}\n}\n\n/** Route a tool's executions through a session scheduler according to its declared concurrency. */\nexport function scheduleToolExecution(tool: AgentTool, scheduler: ToolExecutionScheduler): AgentTool {\n\treturn {\n\t\t...tool,\n\t\texecute: (...args: Parameters<AgentTool[\"execute\"]>) =>\n\t\t\tscheduler.schedule(resolveToolConcurrency(tool.concurrency, args[1] as Record<string, unknown>), () =>\n\t\t\t\ttool.execute(...args),\n\t\t\t),\n\t};\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import type { TSchema } from "typebox";
|
|
2
|
+
import type { Static, TSchema } from "typebox";
|
|
3
3
|
import type { ExtensionContext, ToolDefinition } from "../extensions/types.ts";
|
|
4
|
+
import type { ToolConcurrency } from "./tool-concurrency.ts";
|
|
4
5
|
declare module "@earendil-works/pi-agent-core" {
|
|
5
6
|
interface AgentTool<TParameters extends TSchema = TSchema, TDetails = any> {
|
|
6
7
|
/** Optional per-tool character cap for model-visible result persistence. Use Infinity to opt out. */
|
|
@@ -8,6 +9,8 @@ declare module "@earendil-works/pi-agent-core" {
|
|
|
8
9
|
/** Optional prompt metadata retained by factory-created tools registered as extensions. */
|
|
9
10
|
promptSnippet?: string;
|
|
10
11
|
promptGuidelines?: string[];
|
|
12
|
+
/** Ordering against the other calls of the same assistant message; see ToolDefinition.concurrency. */
|
|
13
|
+
concurrency?: ToolConcurrency<Static<TParameters>>;
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
16
|
/** Wrap a ToolDefinition into an AgentTool for the core runtime. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-definition-wrapper.d.ts","sourceRoot":"","sources":["../../../src/core/tools/tool-definition-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"tool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EAAE,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,GAChC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAsBnC"}
|
|
@@ -16,6 +16,7 @@ export function wrapToolDefinition(definition, ctxFactory) {
|
|
|
16
16
|
? (args) => runSynchronousCallback({ kind: "tool.prepare", name: definition.name }, () => definition.prepareArguments?.(args))
|
|
17
17
|
: undefined,
|
|
18
18
|
executionMode: definition.executionMode,
|
|
19
|
+
concurrency: definition.concurrency,
|
|
19
20
|
execute: (toolCallId, params, signal, onUpdate, context) => runCallback({ kind: "tool.execute", name: definition.name, toolCallId }, () => definition.execute(toolCallId, params, signal, onUpdate, context ?? ctxFactory?.())),
|
|
20
21
|
};
|
|
21
22
|
}
|
|
@@ -41,6 +42,7 @@ export function createToolDefinitionFromAgentTool(tool) {
|
|
|
41
42
|
maxResultSizeChars: tool.maxResultSizeChars,
|
|
42
43
|
prepareArguments: tool.prepareArguments ? (args) => tool.prepareArguments?.(args) : undefined,
|
|
43
44
|
executionMode: tool.executionMode,
|
|
45
|
+
concurrency: tool.concurrency,
|
|
44
46
|
execute: async (toolCallId, params, signal, onUpdate, context) => tool.execute(toolCallId, params, signal, onUpdate, context),
|
|
45
47
|
};
|
|
46
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-definition-wrapper.js","sourceRoot":"","sources":["../../../src/core/tools/tool-definition-wrapper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-definition-wrapper.js","sourceRoot":"","sources":["../../../src/core/tools/tool-definition-wrapper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AA0B9E,oEAAoE;AACpE,MAAM,UAAU,kBAAkB,CACjC,UAA6C,EAC7C,UAAmC;IAEnC,OAAO;QACN,IAAI,EAAE,UAAU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AC/C,UAAmC;IAEnC,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,kBAAkB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AACpF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAChD,IAAkC;IAElC,OAAO;QACN,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxG,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;QAC3C,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAoB,CAAC,CAAC,CAAC,SAAS;QAChH,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,CAC/D,IAAI,CAAC,OAAqD,CAC1D,UAAU,EACV,MAA+B,EAC/B,MAAM,EACN,QAAQ,EACR,OAAO,CACP;KACF,CAAC;AACH,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { Static, TSchema } from \"typebox\";\nimport { runCallback, runSynchronousCallback } from \"../callback-activity.ts\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport type { ToolConcurrency } from \"./tool-concurrency.ts\";\n\ndeclare module \"@earendil-works/pi-agent-core\" {\n\tinterface AgentTool<TParameters extends TSchema = TSchema, TDetails = any> {\n\t\t/** Optional per-tool character cap for model-visible result persistence. Use Infinity to opt out. */\n\t\tmaxResultSizeChars?: number;\n\t\t/** Optional prompt metadata retained by factory-created tools registered as extensions. */\n\t\tpromptSnippet?: string;\n\t\tpromptGuidelines?: string[];\n\t\t/** Ordering against the other calls of the same assistant message; see ToolDefinition.concurrency. */\n\t\tconcurrency?: ToolConcurrency<Static<TParameters>>;\n\t}\n}\n\ntype PiToolParams<TParams extends TSchema> = Parameters<AgentTool<TParams>[\"execute\"]>[1];\ntype PiPreparedParams<TParams extends TSchema> = ReturnType<NonNullable<AgentTool<TParams>[\"prepareArguments\"]>>;\ntype ContextualAgentExecute<TParams extends TSchema, TDetails> = (\n\ttoolCallId: string,\n\tparams: PiToolParams<TParams>,\n\tsignal?: AbortSignal,\n\tonUpdate?: Parameters<AgentTool<TParams, TDetails>[\"execute\"]>[3],\n\tcontext?: ExtensionContext,\n) => ReturnType<AgentTool<TParams, TDetails>[\"execute\"]>;\n\n/** Wrap a ToolDefinition into an AgentTool for the core runtime. */\nexport function wrapToolDefinition<TParams extends TSchema, TDetails = unknown>(\n\tdefinition: ToolDefinition<TParams, TDetails>,\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<TParams, TDetails> {\n\treturn {\n\t\tname: definition.name,\n\t\tlabel: definition.label,\n\t\tdescription: definition.description,\n\t\tparameters: definition.parameters,\n\t\t...(Object.hasOwn(definition, \"constrainedSampling\")\n\t\t\t? { constrainedSampling: definition.constrainedSampling }\n\t\t\t: {}),\n\t\tpromptSnippet: definition.promptSnippet,\n\t\tpromptGuidelines: definition.promptGuidelines ? [...definition.promptGuidelines] : undefined,\n\t\tmaxResultSizeChars: definition.maxResultSizeChars,\n\t\tprepareArguments: definition.prepareArguments\n\t\t\t? (args) =>\n\t\t\t\t\trunSynchronousCallback(\n\t\t\t\t\t\t{ kind: \"tool.prepare\", name: definition.name },\n\t\t\t\t\t\t() => definition.prepareArguments?.(args) as PiPreparedParams<TParams>,\n\t\t\t\t\t)\n\t\t\t: undefined,\n\t\texecutionMode: definition.executionMode,\n\t\tconcurrency: definition.concurrency,\n\t\texecute: (toolCallId, params, signal, onUpdate, context?: ExtensionContext) =>\n\t\t\trunCallback({ kind: \"tool.execute\", name: definition.name, toolCallId }, () =>\n\t\t\t\tdefinition.execute(\n\t\t\t\t\ttoolCallId,\n\t\t\t\t\tparams as Static<TParams>,\n\t\t\t\t\tsignal,\n\t\t\t\t\tonUpdate,\n\t\t\t\t\tcontext ?? (ctxFactory?.() as ExtensionContext),\n\t\t\t\t),\n\t\t\t),\n\t};\n}\n\n/** Wrap multiple ToolDefinitions into AgentTools for the core runtime. */\nexport function wrapToolDefinitions(\n\tdefinitions: ToolDefinition<TSchema, unknown>[],\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<TSchema, unknown>[] {\n\treturn definitions.map((definition) => wrapToolDefinition(definition, ctxFactory));\n}\n\n/**\n * Synthesize a minimal ToolDefinition from an AgentTool.\n *\n * This keeps AgentSession's internal registry definition-first even when a caller\n * provides plain AgentTool overrides that do not include prompt metadata or renderers.\n */\nexport function createToolDefinitionFromAgentTool<TParams extends TSchema = TSchema, TDetails = unknown>(\n\ttool: AgentTool<TParams, TDetails>,\n): ToolDefinition<TParams, TDetails> {\n\treturn {\n\t\tname: tool.name,\n\t\tlabel: tool.label,\n\t\tdescription: tool.description,\n\t\tparameters: tool.parameters,\n\t\t...(Object.hasOwn(tool, \"constrainedSampling\") ? { constrainedSampling: tool.constrainedSampling } : {}),\n\t\tpromptSnippet: tool.promptSnippet,\n\t\tpromptGuidelines: tool.promptGuidelines,\n\t\tmaxResultSizeChars: tool.maxResultSizeChars,\n\t\tprepareArguments: tool.prepareArguments ? (args) => tool.prepareArguments?.(args) as Static<TParams> : undefined,\n\t\texecutionMode: tool.executionMode,\n\t\tconcurrency: tool.concurrency,\n\t\texecute: async (toolCallId, params, signal, onUpdate, context) =>\n\t\t\t(tool.execute as ContextualAgentExecute<TParams, TDetails>)(\n\t\t\t\ttoolCallId,\n\t\t\t\tparams as PiToolParams<TParams>,\n\t\t\t\tsignal,\n\t\t\t\tonUpdate,\n\t\t\t\tcontext,\n\t\t\t),\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAW/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,KAAK,EAAoB,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AAExG,OAAO,EAQN,KAAK,yBAAyB,EAC9B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAGN,KAAK,qBAAqB,EAM1B,MAAM,eAAe,CAAC;AAiBvB,QAAA,MAAM,WAAW;;;EAYhB,CAAC;AAEF,eAAO,MAAM,iCAAiC;sBACpC,+CAA+C;;EAI9C,CAAC;AACZ,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AACxD,MAAM,WAAW,gBAAgB;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACtD,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,8DAA8D;AAC9D,MAAM,WAAW,gBAAgB;IAChC;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,8BAA8B;IAC9B,SAAS,EAAE,CAAC,YAAY,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AC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACtD,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,8DAA8D;AAC9D,MAAM,WAAW,gBAAgB;IAChC;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,8BAA8B;IAC9B,SAAS,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChG,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC;;;;;;;;;;;OAWG;IACH,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAChE;AAwGD,MAAM,WAAW,gBAAgB;IAChC,oEAAoE;IACpE,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,iFAAiF;IACjF,wBAAwB,CAAC,EAAE,yBAAyB,CAAC;CACrD;AA+ID,wBAAgB,yBAAyB,CACxC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,gBAAgB,GACxB,cAAc,CAAC,OAAO,WAAW,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAsRlE;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC,OAAO,WAAW,CAAC,CAEtG"}
|
package/dist/core/tools/write.js
CHANGED
|
@@ -255,6 +255,7 @@ export function createWriteToolDefinition(cwd, options) {
|
|
|
255
255
|
const resolveMutationRequester = options?.resolveMutationRequester;
|
|
256
256
|
return {
|
|
257
257
|
name: "write",
|
|
258
|
+
concurrency: "exclusive",
|
|
258
259
|
label: "write",
|
|
259
260
|
description: "Create or overwrite a file, writable internal resource, archive entry, SQLite row, or merge-conflict resolution.",
|
|
260
261
|
promptSnippet: writeToolSystemPromptContribution.snippet,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACN,KAAK,IAAI,OAAO,EAChB,KAAK,IAAI,OAAO,EAChB,OAAO,IAAI,SAAS,EACpB,QAAQ,IAAI,UAAU,EACtB,IAAI,IAAI,MAAM,EACd,SAAS,IAAI,WAAW,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAC9F,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAE5F,OAAO,EAAsB,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC9G,OAAO,EACN,6BAA6B,EAC7B,gBAAgB,EAChB,oBAAoB,EAEpB,mBAAmB,EACnB,0BAA0B,EAC1B,oBAAoB,GAEpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,2BAA2B,EAC3B,qBAAqB,EAErB,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,+BAA+B,EAC/B,uCAAuC,GACvC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE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,GAAW,EAAE,OAA0B;IACtE,OAAO,kBAAkB,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Container, Text } from \"@earendil-works/pi-tui\";\nimport {\n\tchmod as fsChmod,\n\tmkdir as fsMkdir,\n\treaddir as fsReaddir,\n\treadFile as fsReadFile,\n\tstat as fsStat,\n\twriteFile as fsWriteFile,\n} from \"fs/promises\";\nimport { dirname, join } from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { getLanguageFromPath, highlightCode } from \"../../modes/interactive/theme/theme.js\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { type ConflictBlock, getRegisteredConflictBlocks, parseConflictBlocks } from \"./conflict-registry.ts\";\nimport {\n\tassertPriorSessionObservation,\n\tcomputeLiveState,\n\tFileMutationConflict,\n\ttype FileMutationConflictDetails,\n\tfilesystemErrorCode,\n\tisExclusiveCreateCollision,\n\tisMissingTargetError,\n\ttype MutationRequesterResolver,\n} from \"./file-mutation-coordinator.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport {\n\tcreateHashlineSnapshotStore,\n\tformatHashlineContent,\n\ttype HashlineSnapshotStore,\n\thashlineStoreKey,\n\tnormalizeHashlineContent,\n\trecordHashlineSnapshot,\n\tstripKnownHashlineCopiedContent,\n\tstripKnownHashlineCopiedContentWithMeta,\n} from \"./hashline.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { invalidArgText, normalizeDisplayText, replaceTabs, shortenPath, str } from \"./render-utils.ts\";\nimport {\n\ttype InternalResourceContext,\n\tparseArchiveSelector,\n\tparseSqliteSelector,\n\tresolveArchiveSelector,\n\tresolveInternalSelector,\n\tsqliteSelectorForPath,\n\twriteArchiveSelector,\n\twriteInternalSelector,\n\twriteSqliteSelector,\n} from \"./resource-selectors.ts\";\nimport { invalidateNativeSearchCache } from \"./search-native.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst writeSchema = Type.Object(\n\t{\n\t\tpath: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"File path, writable internal resource, archive entry, SQLite row selector, or conflict resolution target.\",\n\t\t}),\n\t\tcontent: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"Full replacement content. SQLite non-delete writes parse as a JSON5 object; empty content deletes a SQLite row when a row key exists.\",\n\t\t}),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const writeToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Create or overwrite a writable path selector.\",\n\tguidelines: Object.freeze([\n\t\t\"Use write when replacing the full content of a target; use edit for source edits anchored to existing hashline snapshots.\",\n\t] as const),\n} as const);\nexport type WriteToolInput = Static<typeof writeSchema>;\nexport interface WriteToolDetails {\n\tresolvedPath?: string;\n\tmadeExecutable?: boolean;\n\tmeta?: { sourcePath?: string; diagnostics?: unknown };\n\tdiagnostics?: unknown;\n}\n\n/** Per-call options for {@link WriteOperations.writeFile}. */\nexport interface WriteFileOptions {\n\t/**\n\t * Create the file, failing with `EEXIST` if the path is already taken, rather than\n\t * truncating whatever is there. Requested only when the tool has just established that the\n\t * target was absent, so it closes the window between that check and the write.\n\t *\n\t * An implementation that cannot express exclusive create may ignore this and overwrite. It\n\t * then loses only the race against writers outside Atomic, since the mutation queue already\n\t * excludes writers inside it.\n\t */\n\texclusive?: boolean;\n}\n\n/**\n * Pluggable operations for the write tool.\n * Override these to delegate file writing to remote systems (for example SSH).\n */\nexport interface WriteOperations {\n\t/** Write content to a file */\n\twriteFile: (absolutePath: string, content: string, options?: WriteFileOptions) => Promise<void>;\n\tmkdir: (dir: string) => Promise<void>;\n\t/**\n\t * Current content of a path, or `undefined` when nothing is there.\n\t *\n\t * `write` reads before every write, to refuse generated files, to check that this session\n\t * has observed what it is replacing, and to decide between creating and overwriting. Those\n\t * checks have to see the same filesystem the write lands on, so this belongs here rather\n\t * than being read from local disk behind an implementation's back.\n\t *\n\t * Report absence as `undefined` and **reject** for anything else. A path that exists but\n\t * cannot be read is not the same as a free path: returning `undefined` for it would present\n\t * an unreadable file as a fresh create and truncate it.\n\t */\n\treadFile: (absolutePath: string) => Promise<string | undefined>;\n}\n\nasync function findConflictBlocks(root: string, limit = 100): Promise<ConflictBlock[]> {\n\tconst out: ConflictBlock[] = [];\n\tasync function walk(dir: string): Promise<void> {\n\t\tfor (const entry of await fsReaddir(dir, { withFileTypes: true }).catch(() => [])) {\n\t\t\tif (out.length >= limit || entry.name === \".git\" || entry.name === \"node_modules\") continue;\n\t\t\tconst full = join(dir, entry.name);\n\t\t\tif (entry.isDirectory()) await walk(full);\n\t\t\telse if (entry.isFile()) {\n\t\t\t\tconst text = await fsReadFile(full, \"utf8\").catch(() => \"\");\n\t\t\t\tif (text.includes(\"<<<<<<<\") && text.includes(\"=======\") && text.includes(\">>>>>>>\"))\n\t\t\t\t\tout.push(...parseConflictBlocks(full, text));\n\t\t\t}\n\t\t}\n\t}\n\tawait walk(root);\n\treturn out;\n}\n/**\n * Reconcile the read-time conflict view (registry, populated by `read\n * …:conflicts`) against the live tree-walk snapshot. A registered block is\n * only trustworthy when the markers still sit at its recorded file+offset —\n * otherwise the file drifted and the id→block mapping would be wrong. When\n * any registered block is still live, resolve ids against the registered\n * ordering (what the agent actually saw); otherwise fall back to the fresh\n * tree walk. This closes the divergent id-space where `conflict://2` could\n * resolve a different block than the read displayed.\n */\nfunction reconcileConflictBlocks(live: ConflictBlock[], cwd: string): ConflictBlock[] {\n\tconst registered = getRegisteredConflictBlocks(cwd);\n\tif (registered.length === 0) return live;\n\tconst liveKeys = new Set(live.map((block) => `${block.file}\\0${block.start}\\0${block.end}`));\n\tconst registeredLive = registered.filter((block) => liveKeys.has(`${block.file}\\0${block.start}\\0${block.end}`));\n\t// If the registered view no longer matches the live tree at all, the file\n\t// changed under us — trust the live walk rather than a stale id mapping.\n\treturn registeredLive.length > 0 ? registeredLive : live;\n}\nfunction conflictReplacement(content: string, block: ConflictBlock): string[] {\n\tconst token = content.trim();\n\tif (token === \"@ours\") return block.ours;\n\tif (token === \"@theirs\") return block.theirs;\n\tif (token === \"@base\") return block.base;\n\tconst normalized = content.endsWith(\"\\n\") ? content.slice(0, -1) : content;\n\treturn normalized === \"\" ? [] : normalized.split(\"\\n\");\n}\nasync function resolveConflictBlocks(blocks: ConflictBlock[], content: string): Promise<string[]> {\n\tconst byFile = new Map<string, ConflictBlock[]>();\n\tfor (const block of blocks) byFile.set(block.file, [...(byFile.get(block.file) ?? []), block]);\n\tconst written: string[] = [];\n\tfor (const [file, fileBlocks] of byFile) {\n\t\tconst text = await fsReadFile(file, \"utf8\"),\n\t\t\tlines = text.split(\"\\n\");\n\t\tfor (const block of fileBlocks.sort((a, b) => b.start - a.start))\n\t\t\tlines.splice(block.start, block.end - block.start + 1, ...conflictReplacement(content, block));\n\t\tawait fsWriteFile(file, lines.join(\"\\n\"), \"utf8\");\n\t\twritten.push(file);\n\t}\n\treturn written;\n}\nasync function conflictSnapshotHeaders(files: string[], cwd: string, store: HashlineSnapshotStore): Promise<string[]> {\n\tconst headers: string[] = [];\n\tfor (const file of [...new Set(files)]) {\n\t\tinvalidateNativeSearchCache(file);\n\t\tconst text = await fsReadFile(file, \"utf8\").catch(() => undefined);\n\t\tif (text !== undefined)\n\t\t\theaders.push(formatHashlineContent(recordHashlineSnapshot(file, cwd, text, store)).split(\"\\n\")[0]!);\n\t}\n\treturn headers;\n}\nconst GENERATED_MARKER_BYTES = 1024;\nconst GENERATED_MARKER_LINES = 40;\nfunction hasGeneratedMarker(text: string): boolean {\n\tconst header = text.slice(0, GENERATED_MARKER_BYTES).split(\"\\n\").slice(0, GENERATED_MARKER_LINES);\n\treturn header.some((line) => /@generated|auto-generated|DO NOT EDIT|GENERATED -- do not edit/i.test(line));\n}\nfunction strippedHashlineNote(stripped: boolean): string {\n\treturn stripped ? \"\\n\\nNote: stripped copied hashline headers and line prefixes before writing.\" : \"\";\n}\nfunction hashlineHeaderForWrite(path: string, cwd: string, content: string, store: HashlineSnapshotStore): string {\n\tconst snapshot = recordHashlineSnapshot(path, cwd, content, store);\n\treturn `[${snapshot.displayPath}#${snapshot.tag}]`;\n}\nconst defaultWriteOperations: WriteOperations = {\n\t// `wx` is `O_CREAT | O_EXCL`, so the kernel decides the create race rather than this\n\t// process. Without it the absence check above the write is advisory only.\n\twriteFile: (path, content, options) =>\n\t\toptions?.exclusive\n\t\t\t? fsWriteFile(path, content, { encoding: \"utf-8\", flag: \"wx\" })\n\t\t\t: fsWriteFile(path, content, \"utf-8\"),\n\tmkdir: (dir) => fsMkdir(dir, { recursive: true }).then(() => {}),\n\treadFile: async (path) => {\n\t\ttry {\n\t\t\treturn await fsReadFile(path, \"utf8\");\n\t\t} catch (error) {\n\t\t\t// Only a genuinely free path becomes `undefined`. A directory, a locked file, or a\n\t\t\t// permissions failure keeps throwing, so the caller reports it rather than treating\n\t\t\t// an occupied path as available and truncating it.\n\t\t\tif (isMissingTargetError(error)) return undefined;\n\t\t\tthrow error;\n\t\t}\n\t},\n};\n\nexport interface WriteToolOptions {\n\t/** Custom operations for file writing. Default: local filesystem */\n\toperations?: WriteOperations;\n\thashlineStore?: HashlineSnapshotStore;\n\t/** Resolves who is being rejected when a mutation conflicts. Diagnostic only. */\n\tresolveMutationRequester?: MutationRequesterResolver;\n}\n\ntype WriteHighlightCache = {\n\trawPath: string | null;\n\tlang: string;\n\trawContent: string;\n\tnormalizedLines: string[];\n\thighlightedLines: string[];\n};\n\nclass WriteCallRenderComponent extends Text {\n\tcache?: WriteHighlightCache;\n\n\tconstructor() {\n\t\tsuper(\"\", 0, 0);\n\t}\n}\n\nconst WRITE_PARTIAL_FULL_HIGHLIGHT_LINES = 50;\n\nfunction highlightSingleLine(line: string, lang: string): string {\n\tconst highlighted = highlightCode(line, lang);\n\treturn highlighted[0] ?? \"\";\n}\n\nfunction refreshWriteHighlightPrefix(cache: WriteHighlightCache): void {\n\tconst prefixCount = Math.min(WRITE_PARTIAL_FULL_HIGHLIGHT_LINES, cache.normalizedLines.length);\n\tif (prefixCount === 0) return;\n\tconst prefixSource = cache.normalizedLines.slice(0, prefixCount).join(\"\\n\");\n\tconst prefixHighlighted = highlightCode(prefixSource, cache.lang);\n\tfor (let i = 0; i < prefixCount; i++) {\n\t\tcache.highlightedLines[i] =\n\t\t\tprefixHighlighted[i] ?? highlightSingleLine(cache.normalizedLines[i] ?? \"\", cache.lang);\n\t}\n}\n\nfunction rebuildWriteHighlightCacheFull(rawPath: string | null, fileContent: string): WriteHighlightCache | undefined {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (!lang) return undefined;\n\tconst displayContent = normalizeDisplayText(fileContent);\n\tconst normalized = replaceTabs(displayContent);\n\treturn {\n\t\trawPath,\n\t\tlang,\n\t\trawContent: fileContent,\n\t\tnormalizedLines: normalized.split(\"\\n\"),\n\t\thighlightedLines: highlightCode(normalized, lang),\n\t};\n}\n\nfunction updateWriteHighlightCacheIncremental(\n\tcache: WriteHighlightCache | undefined,\n\trawPath: string | null,\n\tfileContent: string,\n): WriteHighlightCache | undefined {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (!lang) return undefined;\n\tif (!cache) return rebuildWriteHighlightCacheFull(rawPath, fileContent);\n\tif (cache.lang !== lang || cache.rawPath !== rawPath) return rebuildWriteHighlightCacheFull(rawPath, fileContent);\n\tif (!fileContent.startsWith(cache.rawContent)) return rebuildWriteHighlightCacheFull(rawPath, fileContent);\n\tif (fileContent.length === cache.rawContent.length) return cache;\n\n\tconst deltaRaw = fileContent.slice(cache.rawContent.length);\n\tconst deltaDisplay = normalizeDisplayText(deltaRaw);\n\tconst deltaNormalized = replaceTabs(deltaDisplay);\n\tcache.rawContent = fileContent;\n\tif (cache.normalizedLines.length === 0) {\n\t\tcache.normalizedLines.push(\"\");\n\t\tcache.highlightedLines.push(\"\");\n\t}\n\n\tconst segments = deltaNormalized.split(\"\\n\");\n\tconst lastIndex = cache.normalizedLines.length - 1;\n\tcache.normalizedLines[lastIndex] += segments[0];\n\tcache.highlightedLines[lastIndex] = highlightSingleLine(cache.normalizedLines[lastIndex], cache.lang);\n\tfor (let i = 1; i < segments.length; i++) {\n\t\tcache.normalizedLines.push(segments[i]);\n\t\tcache.highlightedLines.push(highlightSingleLine(segments[i], cache.lang));\n\t}\n\trefreshWriteHighlightPrefix(cache);\n\treturn cache;\n}\n\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\n\nfunction formatWriteCall(\n\targs: { path?: string; content?: string } | undefined,\n\toptions: ToolRenderResultOptions,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n\tcache: WriteHighlightCache | undefined,\n): string {\n\tconst rawPath = str(args?.path);\n\tconst fileContent = str(args?.content);\n\tconst path = rawPath !== null ? shortenPath(rawPath) : null;\n\tconst invalidArg = invalidArgText(theme);\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"write\"))} ${path === null ? invalidArg : path ? theme.fg(\"accent\", path) : theme.fg(\"toolOutput\", \"...\")}`;\n\n\tif (fileContent === null) {\n\t\ttext += `\\n\\n${theme.fg(\"error\", \"[invalid content arg - expected string]\")}`;\n\t} else if (fileContent) {\n\t\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\t\tconst renderedLines = lang\n\t\t\t? (cache?.highlightedLines ?? highlightCode(replaceTabs(normalizeDisplayText(fileContent)), lang))\n\t\t\t: normalizeDisplayText(fileContent).split(\"\\n\");\n\t\tconst lines = trimTrailingEmptyLines(renderedLines);\n\t\tconst totalLines = lines.length;\n\t\tconst maxLines = options.expanded ? lines.length : 10;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n\\n${displayLines.map((line) => (lang ? line : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext +=\n\t\t\t\ttheme.fg(\"muted\", \"\\n... \") +\n\t\t\t\tparenthesizedKeyHint(\"app.tools.expand\", \"Expand\", `${remaining} more lines, ${totalLines} total`);\n\t\t}\n\t}\n\n\treturn text;\n}\n\nfunction formatWriteResult(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }>; isError?: boolean },\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n): string | undefined {\n\tif (!result.isError) {\n\t\treturn undefined;\n\t}\n\tconst output = result.content\n\t\t.filter((c) => c.type === \"text\")\n\t\t.map((c) => c.text || \"\")\n\t\t.join(\"\\n\");\n\tif (!output) {\n\t\treturn undefined;\n\t}\n\treturn `\\n${theme.fg(\"error\", output)}`;\n}\n\nexport function createWriteToolDefinition(\n\tcwd: string,\n\toptions?: WriteToolOptions,\n): ToolDefinition<typeof writeSchema, WriteToolDetails | undefined> {\n\tconst ops = options?.operations ?? defaultWriteOperations;\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst resolveMutationRequester = options?.resolveMutationRequester;\n\treturn {\n\t\tname: \"write\",\n\t\tlabel: \"write\",\n\t\tdescription:\n\t\t\t\"Create or overwrite a file, writable internal resource, archive entry, SQLite row, or merge-conflict resolution.\",\n\t\tpromptSnippet: writeToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...writeToolSystemPromptContribution.guidelines],\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tparameters: writeSchema,\n\t\tasync execute(\n\t\t\ttoolCallId,\n\t\t\t{ path, content }: { path: string; content: string },\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\tctx?: ExtensionContext,\n\t\t) {\n\t\t\tconst resourceCtx = ctx as InternalResourceContext | undefined;\n\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\tconst archive = parseArchiveSelector(path);\n\t\t\tconst parsedSqlite = parseSqliteSelector(path);\n\t\t\tif (parsedSqlite?.table && path.includes(\"?\"))\n\t\t\t\tthrow new Error(\"SQLite write selectors must not include query parameters.\");\n\t\t\tif (\n\t\t\t\tparsedSqlite?.table &&\n\t\t\t\t(parsedSqlite.limit !== undefined ||\n\t\t\t\t\tparsedSqlite.offset !== undefined ||\n\t\t\t\t\tparsedSqlite.where ||\n\t\t\t\t\tparsedSqlite.order ||\n\t\t\t\t\tparsedSqlite.schema ||\n\t\t\t\t\tparsedSqlite.sampleRows !== undefined ||\n\t\t\t\t\tparsedSqlite.query)\n\t\t\t)\n\t\t\t\tthrow new Error(\"SQLite write selectors must not include query parameters.\");\n\t\t\tconst sqlite = sqliteSelectorForPath(path, executionCwd);\n\t\t\tif (!sqlite && parsedSqlite?.table) throw new Error(`SQLite database not found or is not SQLite: ${path}`);\n\t\t\tif (sqlite) {\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tconst message = writeSqliteSelector(sqlite, stripped.content);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `${message}${strippedHashlineNote(stripped.stripped)}` }],\n\t\t\t\t\tdetails: { meta: { sourcePath: sqlite.databasePath } },\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (archive) {\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tconst resolvedArchive = resolveArchiveSelector(archive, executionCwd);\n\t\t\t\twriteArchiveSelector(resolvedArchive, stripped.content);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Successfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { resolvedPath: resolvedArchive.archivePath },\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (path.startsWith(\"conflict://\")) {\n\t\t\t\tconst writeContent = stripKnownHashlineCopiedContent(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tconst target = decodeURIComponent(path.slice(\"conflict://\".length));\n\t\t\t\tif (!target) throw new Error(\"conflict:// target is required.\");\n\t\t\t\tif (target.includes(\"/\"))\n\t\t\t\t\tthrow new Error(\"Scoped conflict resources are read-only; write conflict://<id> or conflict://*.\");\n\t\t\t\tconst liveBlocks = await findConflictBlocks(executionCwd);\n\t\t\t\tif (liveBlocks.length === 0) throw new Error(\"No conflict markers found.\");\n\t\t\t\tconst blocks = reconcileConflictBlocks(liveBlocks, executionCwd);\n\t\t\t\tif (target === \"*\") {\n\t\t\t\t\tconst headers = await conflictSnapshotHeaders(\n\t\t\t\t\t\tawait resolveConflictBlocks(blocks, writeContent),\n\t\t\t\t\t\texecutionCwd,\n\t\t\t\t\t\thashlineStore,\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\ttext: `Resolved ${blocks.length} conflict${blocks.length === 1 ? \"\" : \"s\"}${headers.length > 0 ? `\\n\\nSnapshots:\\n${headers.join(\"\\n\")}` : \"\"}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (!/^\\d+$/.test(target)) throw new Error(\"Conflict writes must target conflict://<id> or conflict://*.\");\n\t\t\t\tconst id = Number.parseInt(target, 10);\n\t\t\t\tconst block = blocks[id - 1];\n\t\t\t\tif (!block) throw new Error(`Conflict id not found: ${target}`);\n\t\t\t\tconst headers = await conflictSnapshotHeaders(\n\t\t\t\t\tawait resolveConflictBlocks([block], writeContent),\n\t\t\t\t\texecutionCwd,\n\t\t\t\t\thashlineStore,\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Resolved conflict ${target}${headers[0] ? `\\n\\n${headers[0]}` : \"\"}` }],\n\t\t\t\t\tdetails: undefined,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (/^[a-z]+:\\/\\//i.test(path)) {\n\t\t\t\tconst sourcePath = path.startsWith(\"local://\") ? resolveInternalSelector(path, executionCwd) : undefined;\n\t\t\t\tif (sourcePath)\n\t\t\t\t\treturn createWriteToolDefinition(executionCwd, { ...options, hashlineStore }).execute(\n\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t{ path: sourcePath, content },\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t_onUpdate,\n\t\t\t\t\t\tctx as never,\n\t\t\t\t\t);\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tawait writeInternalSelector(path, executionCwd, stripped.content, resourceCtx);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Successfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {},\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst absolutePath = resolveToCwd(path, executionCwd);\n\t\t\tconst dir = dirname(absolutePath);\n\t\t\treturn withFileMutationQueue(absolutePath, async (canonicalKey) => {\n\t\t\t\t// Do not reject from an abort event listener here: that would release the\n\t\t\t\t// mutation queue while an in-flight filesystem operation may still finish.\n\t\t\t\t// Checking signal.aborted after each await observes the same aborts while\n\t\t\t\t// keeping the queue locked until the current operation has settled.\n\t\t\t\tconst throwIfAborted = (): void => {\n\t\t\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t};\n\n\t\t\t\tthrowIfAborted();\n\t\t\t\t// Create parent directories if needed.\n\t\t\t\tawait ops.mkdir(dir);\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\tconst requester = resolveMutationRequester?.(toolCallId);\n\t\t\t\tconst conflict = (details: Omit<FileMutationConflictDetails, \"path\" | \"canonicalKey\" | \"requester\">) =>\n\t\t\t\t\tnew FileMutationConflict({\n\t\t\t\t\t\t...details,\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\t// Registration resolved this already, so a conflict names the target\n\t\t\t\t\t\t// without paying for a second `realpath` while holding the lock.\n\t\t\t\t\t\tcanonicalKey,\n\t\t\t\t\t\t...(requester ? { requester } : {}),\n\t\t\t\t\t});\n\n\t\t\t\tlet existing: string | undefined;\n\t\t\t\ttry {\n\t\t\t\t\texisting = await ops.readFile(absolutePath);\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// The path is occupied by something this reader cannot open: a directory, a\n\t\t\t\t\t// locked file, a permissions failure. Treating that as absence would present it\n\t\t\t\t\t// as a fresh create and truncate it, so it is a conflict rather than a fallback.\n\t\t\t\t\tconst causeCode = filesystemErrorCode(error);\n\t\t\t\t\tthrow conflict({\n\t\t\t\t\t\treason: \"target_unreadable\",\n\t\t\t\t\t\t// Nothing about the target can be described once the read fails, and\n\t\t\t\t\t\t// inventing a size or a tag would be worse than omitting them.\n\t\t\t\t\t\t...(causeCode ? { causeCode } : {}),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (existing !== undefined && hasGeneratedMarker(existing))\n\t\t\t\t\tthrow new Error(`Refusing to overwrite generated file: ${path}`);\n\t\t\t\tif (existing !== undefined) {\n\t\t\t\t\t// `write` replaces a whole file rather than anchoring to a section, so nothing\n\t\t\t\t\t// in the call itself says what is being replaced. Having recorded that exact\n\t\t\t\t\t// content is the only evidence this session ever saw it, and the store answers\n\t\t\t\t\t// for this session alone, which is what makes another agent's file land here as\n\t\t\t\t\t// a conflict instead of silently losing.\n\t\t\t\t\t//\n\t\t\t\t\t// The read above is reused deliberately: it already happened under the queue,\n\t\t\t\t\t// so re-reading would only widen the window it closes.\n\t\t\t\t\tassertPriorSessionObservation({\n\t\t\t\t\t\tcanonicalKey,\n\t\t\t\t\t\tstoreKey: hashlineStoreKey(absolutePath),\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tstore: hashlineStore.snapshots,\n\t\t\t\t\t\t// Normalized because that is the form `record` stored. Comparing raw bytes\n\t\t\t\t\t\t// would reject every CRLF file the session had read perfectly well.\n\t\t\t\t\t\tlive: normalizeHashlineContent(existing),\n\t\t\t\t\t\t...(requester ? { requester } : {}),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(\n\t\t\t\t\tcontent,\n\t\t\t\t\tabsolutePath,\n\t\t\t\t\texecutionCwd,\n\t\t\t\t\thashlineStore,\n\t\t\t\t\tpath,\n\t\t\t\t);\n\t\t\t\tconst writeContent = stripped.content;\n\t\t\t\tif (existing === undefined) {\n\t\t\t\t\t// Nothing was there a moment ago, so this is a create and says so to the\n\t\t\t\t\t// filesystem. The mutation queue already excludes other Atomic writers; `O_EXCL`\n\t\t\t\t\t// covers the rest, and turns what would have been a silent clobber of a file\n\t\t\t\t\t// that appeared in between into a conflict that names it.\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait ops.writeFile(absolutePath, writeContent, { exclusive: true });\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!isExclusiveCreateCollision(error)) throw error;\n\t\t\t\t\t\tconst appeared = await ops.readFile(absolutePath).catch(() => undefined);\n\t\t\t\t\t\tthrow conflict({\n\t\t\t\t\t\t\treason: \"target_exists\",\n\t\t\t\t\t\t\t// Only describe the file when it can still be read. `computeLiveState`\n\t\t\t\t\t\t\t// renders absence for `undefined`, which would contradict the reason.\n\t\t\t\t\t\t\t...(appeared !== undefined ? { liveState: computeLiveState(appeared) } : {}),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else await ops.writeFile(absolutePath, writeContent);\n\t\t\t\tinvalidateNativeSearchCache(absolutePath);\n\t\t\t\t// Recorded as soon as the bytes land, ahead of the abort check below, because an\n\t\t\t\t// abort cancels reporting the result rather than undoing the write. Left until\n\t\t\t\t// after it, a cancelled-but-written file would come back as someone else's work on\n\t\t\t\t// the next overwrite. The hashline engine already records inside `commit` for the\n\t\t\t\t// same reason.\n\t\t\t\tconst header = hashlineHeaderForWrite(absolutePath, executionCwd, writeContent, hashlineStore);\n\t\t\t\tlet madeExecutable = false;\n\t\t\t\tif (writeContent.startsWith(\"#!\")) {\n\t\t\t\t\tconst mode = await fsStat(absolutePath)\n\t\t\t\t\t\t.then((stat) => stat.mode)\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tif (mode !== undefined) {\n\t\t\t\t\t\tawait fsChmod(absolutePath, mode | 0o111);\n\t\t\t\t\t\tmadeExecutable = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `${header}\\nSuccessfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { resolvedPath: absolutePath, ...(madeExecutable ? { madeExecutable } : {}) },\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst renderArgs = args as { path?: string; content?: string } | undefined;\n\t\t\tconst rawPath = str(renderArgs?.path);\n\t\t\tconst fileContent = str(renderArgs?.content);\n\t\t\tconst component =\n\t\t\t\t(context.lastComponent as WriteCallRenderComponent | undefined) ?? new WriteCallRenderComponent();\n\t\t\tif (fileContent !== null) {\n\t\t\t\tcomponent.cache = context.argsComplete\n\t\t\t\t\t? rebuildWriteHighlightCacheFull(rawPath, fileContent)\n\t\t\t\t\t: updateWriteHighlightCacheIncremental(component.cache, rawPath, fileContent);\n\t\t\t} else {\n\t\t\t\tcomponent.cache = undefined;\n\t\t\t}\n\t\t\tcomponent.setText(\n\t\t\t\tformatWriteCall(\n\t\t\t\t\trenderArgs,\n\t\t\t\t\t{ expanded: context.expanded, isPartial: context.isPartial },\n\t\t\t\t\ttheme,\n\t\t\t\t\tcomponent.cache,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn component;\n\t\t},\n\t\trenderResult(result, _options, theme, context) {\n\t\t\tconst output = formatWriteResult({ ...result, isError: context.isError }, theme);\n\t\t\tif (!output) {\n\t\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\t\tcomponent.clear();\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(output);\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createWriteTool(cwd: string, options?: WriteToolOptions): AgentTool<typeof writeSchema> {\n\treturn wrapToolDefinition(createWriteToolDefinition(cwd, options));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACN,KAAK,IAAI,OAAO,EAChB,KAAK,IAAI,OAAO,EAChB,OAAO,IAAI,SAAS,EACpB,QAAQ,IAAI,UAAU,EACtB,IAAI,IAAI,MAAM,EACd,SAAS,IAAI,WAAW,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAC9F,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAE5F,OAAO,EAAsB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C,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;YACjF,IAAI,CAAC,MAAM,EAAE,CAAC;gBACb,MAAM,SAAS,GAAI,OAAO,CAAC,aAAuC,IAAI,IAAI,SAAS,EAAE,CAAC;gBACtF,SAAS,CAAC,KAAK,EAAE,CAAC;gBAClB,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,OAA0B;IACtE,OAAO,kBAAkB,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Container, Text } from \"@earendil-works/pi-tui\";\nimport {\n\tchmod as fsChmod,\n\tmkdir as fsMkdir,\n\treaddir as fsReaddir,\n\treadFile as fsReadFile,\n\tstat as fsStat,\n\twriteFile as fsWriteFile,\n} from \"fs/promises\";\nimport { dirname, join } from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { getLanguageFromPath, highlightCode } from \"../../modes/interactive/theme/theme.js\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { type ConflictBlock, getRegisteredConflictBlocks, parseConflictBlocks } from \"./conflict-registry.ts\";\nimport {\n\tassertPriorSessionObservation,\n\tcomputeLiveState,\n\tFileMutationConflict,\n\ttype FileMutationConflictDetails,\n\tfilesystemErrorCode,\n\tisExclusiveCreateCollision,\n\tisMissingTargetError,\n\ttype MutationRequesterResolver,\n} from \"./file-mutation-coordinator.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport {\n\tcreateHashlineSnapshotStore,\n\tformatHashlineContent,\n\ttype HashlineSnapshotStore,\n\thashlineStoreKey,\n\tnormalizeHashlineContent,\n\trecordHashlineSnapshot,\n\tstripKnownHashlineCopiedContent,\n\tstripKnownHashlineCopiedContentWithMeta,\n} from \"./hashline.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { invalidArgText, normalizeDisplayText, replaceTabs, shortenPath, str } from \"./render-utils.ts\";\nimport {\n\ttype InternalResourceContext,\n\tparseArchiveSelector,\n\tparseSqliteSelector,\n\tresolveArchiveSelector,\n\tresolveInternalSelector,\n\tsqliteSelectorForPath,\n\twriteArchiveSelector,\n\twriteInternalSelector,\n\twriteSqliteSelector,\n} from \"./resource-selectors.ts\";\nimport { invalidateNativeSearchCache } from \"./search-native.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst writeSchema = Type.Object(\n\t{\n\t\tpath: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"File path, writable internal resource, archive entry, SQLite row selector, or conflict resolution target.\",\n\t\t}),\n\t\tcontent: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"Full replacement content. SQLite non-delete writes parse as a JSON5 object; empty content deletes a SQLite row when a row key exists.\",\n\t\t}),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const writeToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Create or overwrite a writable path selector.\",\n\tguidelines: Object.freeze([\n\t\t\"Use write when replacing the full content of a target; use edit for source edits anchored to existing hashline snapshots.\",\n\t] as const),\n} as const);\nexport type WriteToolInput = Static<typeof writeSchema>;\nexport interface WriteToolDetails {\n\tresolvedPath?: string;\n\tmadeExecutable?: boolean;\n\tmeta?: { sourcePath?: string; diagnostics?: unknown };\n\tdiagnostics?: unknown;\n}\n\n/** Per-call options for {@link WriteOperations.writeFile}. */\nexport interface WriteFileOptions {\n\t/**\n\t * Create the file, failing with `EEXIST` if the path is already taken, rather than\n\t * truncating whatever is there. Requested only when the tool has just established that the\n\t * target was absent, so it closes the window between that check and the write.\n\t *\n\t * An implementation that cannot express exclusive create may ignore this and overwrite. It\n\t * then loses only the race against writers outside Atomic, since the mutation queue already\n\t * excludes writers inside it.\n\t */\n\texclusive?: boolean;\n}\n\n/**\n * Pluggable operations for the write tool.\n * Override these to delegate file writing to remote systems (for example SSH).\n */\nexport interface WriteOperations {\n\t/** Write content to a file */\n\twriteFile: (absolutePath: string, content: string, options?: WriteFileOptions) => Promise<void>;\n\tmkdir: (dir: string) => Promise<void>;\n\t/**\n\t * Current content of a path, or `undefined` when nothing is there.\n\t *\n\t * `write` reads before every write, to refuse generated files, to check that this session\n\t * has observed what it is replacing, and to decide between creating and overwriting. Those\n\t * checks have to see the same filesystem the write lands on, so this belongs here rather\n\t * than being read from local disk behind an implementation's back.\n\t *\n\t * Report absence as `undefined` and **reject** for anything else. A path that exists but\n\t * cannot be read is not the same as a free path: returning `undefined` for it would present\n\t * an unreadable file as a fresh create and truncate it.\n\t */\n\treadFile: (absolutePath: string) => Promise<string | undefined>;\n}\n\nasync function findConflictBlocks(root: string, limit = 100): Promise<ConflictBlock[]> {\n\tconst out: ConflictBlock[] = [];\n\tasync function walk(dir: string): Promise<void> {\n\t\tfor (const entry of await fsReaddir(dir, { withFileTypes: true }).catch(() => [])) {\n\t\t\tif (out.length >= limit || entry.name === \".git\" || entry.name === \"node_modules\") continue;\n\t\t\tconst full = join(dir, entry.name);\n\t\t\tif (entry.isDirectory()) await walk(full);\n\t\t\telse if (entry.isFile()) {\n\t\t\t\tconst text = await fsReadFile(full, \"utf8\").catch(() => \"\");\n\t\t\t\tif (text.includes(\"<<<<<<<\") && text.includes(\"=======\") && text.includes(\">>>>>>>\"))\n\t\t\t\t\tout.push(...parseConflictBlocks(full, text));\n\t\t\t}\n\t\t}\n\t}\n\tawait walk(root);\n\treturn out;\n}\n/**\n * Reconcile the read-time conflict view (registry, populated by `read\n * …:conflicts`) against the live tree-walk snapshot. A registered block is\n * only trustworthy when the markers still sit at its recorded file+offset —\n * otherwise the file drifted and the id→block mapping would be wrong. When\n * any registered block is still live, resolve ids against the registered\n * ordering (what the agent actually saw); otherwise fall back to the fresh\n * tree walk. This closes the divergent id-space where `conflict://2` could\n * resolve a different block than the read displayed.\n */\nfunction reconcileConflictBlocks(live: ConflictBlock[], cwd: string): ConflictBlock[] {\n\tconst registered = getRegisteredConflictBlocks(cwd);\n\tif (registered.length === 0) return live;\n\tconst liveKeys = new Set(live.map((block) => `${block.file}\\0${block.start}\\0${block.end}`));\n\tconst registeredLive = registered.filter((block) => liveKeys.has(`${block.file}\\0${block.start}\\0${block.end}`));\n\t// If the registered view no longer matches the live tree at all, the file\n\t// changed under us — trust the live walk rather than a stale id mapping.\n\treturn registeredLive.length > 0 ? registeredLive : live;\n}\nfunction conflictReplacement(content: string, block: ConflictBlock): string[] {\n\tconst token = content.trim();\n\tif (token === \"@ours\") return block.ours;\n\tif (token === \"@theirs\") return block.theirs;\n\tif (token === \"@base\") return block.base;\n\tconst normalized = content.endsWith(\"\\n\") ? content.slice(0, -1) : content;\n\treturn normalized === \"\" ? [] : normalized.split(\"\\n\");\n}\nasync function resolveConflictBlocks(blocks: ConflictBlock[], content: string): Promise<string[]> {\n\tconst byFile = new Map<string, ConflictBlock[]>();\n\tfor (const block of blocks) byFile.set(block.file, [...(byFile.get(block.file) ?? []), block]);\n\tconst written: string[] = [];\n\tfor (const [file, fileBlocks] of byFile) {\n\t\tconst text = await fsReadFile(file, \"utf8\"),\n\t\t\tlines = text.split(\"\\n\");\n\t\tfor (const block of fileBlocks.sort((a, b) => b.start - a.start))\n\t\t\tlines.splice(block.start, block.end - block.start + 1, ...conflictReplacement(content, block));\n\t\tawait fsWriteFile(file, lines.join(\"\\n\"), \"utf8\");\n\t\twritten.push(file);\n\t}\n\treturn written;\n}\nasync function conflictSnapshotHeaders(files: string[], cwd: string, store: HashlineSnapshotStore): Promise<string[]> {\n\tconst headers: string[] = [];\n\tfor (const file of [...new Set(files)]) {\n\t\tinvalidateNativeSearchCache(file);\n\t\tconst text = await fsReadFile(file, \"utf8\").catch(() => undefined);\n\t\tif (text !== undefined)\n\t\t\theaders.push(formatHashlineContent(recordHashlineSnapshot(file, cwd, text, store)).split(\"\\n\")[0]!);\n\t}\n\treturn headers;\n}\nconst GENERATED_MARKER_BYTES = 1024;\nconst GENERATED_MARKER_LINES = 40;\nfunction hasGeneratedMarker(text: string): boolean {\n\tconst header = text.slice(0, GENERATED_MARKER_BYTES).split(\"\\n\").slice(0, GENERATED_MARKER_LINES);\n\treturn header.some((line) => /@generated|auto-generated|DO NOT EDIT|GENERATED -- do not edit/i.test(line));\n}\nfunction strippedHashlineNote(stripped: boolean): string {\n\treturn stripped ? \"\\n\\nNote: stripped copied hashline headers and line prefixes before writing.\" : \"\";\n}\nfunction hashlineHeaderForWrite(path: string, cwd: string, content: string, store: HashlineSnapshotStore): string {\n\tconst snapshot = recordHashlineSnapshot(path, cwd, content, store);\n\treturn `[${snapshot.displayPath}#${snapshot.tag}]`;\n}\nconst defaultWriteOperations: WriteOperations = {\n\t// `wx` is `O_CREAT | O_EXCL`, so the kernel decides the create race rather than this\n\t// process. Without it the absence check above the write is advisory only.\n\twriteFile: (path, content, options) =>\n\t\toptions?.exclusive\n\t\t\t? fsWriteFile(path, content, { encoding: \"utf-8\", flag: \"wx\" })\n\t\t\t: fsWriteFile(path, content, \"utf-8\"),\n\tmkdir: (dir) => fsMkdir(dir, { recursive: true }).then(() => {}),\n\treadFile: async (path) => {\n\t\ttry {\n\t\t\treturn await fsReadFile(path, \"utf8\");\n\t\t} catch (error) {\n\t\t\t// Only a genuinely free path becomes `undefined`. A directory, a locked file, or a\n\t\t\t// permissions failure keeps throwing, so the caller reports it rather than treating\n\t\t\t// an occupied path as available and truncating it.\n\t\t\tif (isMissingTargetError(error)) return undefined;\n\t\t\tthrow error;\n\t\t}\n\t},\n};\n\nexport interface WriteToolOptions {\n\t/** Custom operations for file writing. Default: local filesystem */\n\toperations?: WriteOperations;\n\thashlineStore?: HashlineSnapshotStore;\n\t/** Resolves who is being rejected when a mutation conflicts. Diagnostic only. */\n\tresolveMutationRequester?: MutationRequesterResolver;\n}\n\ntype WriteHighlightCache = {\n\trawPath: string | null;\n\tlang: string;\n\trawContent: string;\n\tnormalizedLines: string[];\n\thighlightedLines: string[];\n};\n\nclass WriteCallRenderComponent extends Text {\n\tcache?: WriteHighlightCache;\n\n\tconstructor() {\n\t\tsuper(\"\", 0, 0);\n\t}\n}\n\nconst WRITE_PARTIAL_FULL_HIGHLIGHT_LINES = 50;\n\nfunction highlightSingleLine(line: string, lang: string): string {\n\tconst highlighted = highlightCode(line, lang);\n\treturn highlighted[0] ?? \"\";\n}\n\nfunction refreshWriteHighlightPrefix(cache: WriteHighlightCache): void {\n\tconst prefixCount = Math.min(WRITE_PARTIAL_FULL_HIGHLIGHT_LINES, cache.normalizedLines.length);\n\tif (prefixCount === 0) return;\n\tconst prefixSource = cache.normalizedLines.slice(0, prefixCount).join(\"\\n\");\n\tconst prefixHighlighted = highlightCode(prefixSource, cache.lang);\n\tfor (let i = 0; i < prefixCount; i++) {\n\t\tcache.highlightedLines[i] =\n\t\t\tprefixHighlighted[i] ?? highlightSingleLine(cache.normalizedLines[i] ?? \"\", cache.lang);\n\t}\n}\n\nfunction rebuildWriteHighlightCacheFull(rawPath: string | null, fileContent: string): WriteHighlightCache | undefined {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (!lang) return undefined;\n\tconst displayContent = normalizeDisplayText(fileContent);\n\tconst normalized = replaceTabs(displayContent);\n\treturn {\n\t\trawPath,\n\t\tlang,\n\t\trawContent: fileContent,\n\t\tnormalizedLines: normalized.split(\"\\n\"),\n\t\thighlightedLines: highlightCode(normalized, lang),\n\t};\n}\n\nfunction updateWriteHighlightCacheIncremental(\n\tcache: WriteHighlightCache | undefined,\n\trawPath: string | null,\n\tfileContent: string,\n): WriteHighlightCache | undefined {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (!lang) return undefined;\n\tif (!cache) return rebuildWriteHighlightCacheFull(rawPath, fileContent);\n\tif (cache.lang !== lang || cache.rawPath !== rawPath) return rebuildWriteHighlightCacheFull(rawPath, fileContent);\n\tif (!fileContent.startsWith(cache.rawContent)) return rebuildWriteHighlightCacheFull(rawPath, fileContent);\n\tif (fileContent.length === cache.rawContent.length) return cache;\n\n\tconst deltaRaw = fileContent.slice(cache.rawContent.length);\n\tconst deltaDisplay = normalizeDisplayText(deltaRaw);\n\tconst deltaNormalized = replaceTabs(deltaDisplay);\n\tcache.rawContent = fileContent;\n\tif (cache.normalizedLines.length === 0) {\n\t\tcache.normalizedLines.push(\"\");\n\t\tcache.highlightedLines.push(\"\");\n\t}\n\n\tconst segments = deltaNormalized.split(\"\\n\");\n\tconst lastIndex = cache.normalizedLines.length - 1;\n\tcache.normalizedLines[lastIndex] += segments[0];\n\tcache.highlightedLines[lastIndex] = highlightSingleLine(cache.normalizedLines[lastIndex], cache.lang);\n\tfor (let i = 1; i < segments.length; i++) {\n\t\tcache.normalizedLines.push(segments[i]);\n\t\tcache.highlightedLines.push(highlightSingleLine(segments[i], cache.lang));\n\t}\n\trefreshWriteHighlightPrefix(cache);\n\treturn cache;\n}\n\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\n\nfunction formatWriteCall(\n\targs: { path?: string; content?: string } | undefined,\n\toptions: ToolRenderResultOptions,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n\tcache: WriteHighlightCache | undefined,\n): string {\n\tconst rawPath = str(args?.path);\n\tconst fileContent = str(args?.content);\n\tconst path = rawPath !== null ? shortenPath(rawPath) : null;\n\tconst invalidArg = invalidArgText(theme);\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"write\"))} ${path === null ? invalidArg : path ? theme.fg(\"accent\", path) : theme.fg(\"toolOutput\", \"...\")}`;\n\n\tif (fileContent === null) {\n\t\ttext += `\\n\\n${theme.fg(\"error\", \"[invalid content arg - expected string]\")}`;\n\t} else if (fileContent) {\n\t\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\t\tconst renderedLines = lang\n\t\t\t? (cache?.highlightedLines ?? highlightCode(replaceTabs(normalizeDisplayText(fileContent)), lang))\n\t\t\t: normalizeDisplayText(fileContent).split(\"\\n\");\n\t\tconst lines = trimTrailingEmptyLines(renderedLines);\n\t\tconst totalLines = lines.length;\n\t\tconst maxLines = options.expanded ? lines.length : 10;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n\\n${displayLines.map((line) => (lang ? line : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext +=\n\t\t\t\ttheme.fg(\"muted\", \"\\n... \") +\n\t\t\t\tparenthesizedKeyHint(\"app.tools.expand\", \"Expand\", `${remaining} more lines, ${totalLines} total`);\n\t\t}\n\t}\n\n\treturn text;\n}\n\nfunction formatWriteResult(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }>; isError?: boolean },\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n): string | undefined {\n\tif (!result.isError) {\n\t\treturn undefined;\n\t}\n\tconst output = result.content\n\t\t.filter((c) => c.type === \"text\")\n\t\t.map((c) => c.text || \"\")\n\t\t.join(\"\\n\");\n\tif (!output) {\n\t\treturn undefined;\n\t}\n\treturn `\\n${theme.fg(\"error\", output)}`;\n}\n\nexport function createWriteToolDefinition(\n\tcwd: string,\n\toptions?: WriteToolOptions,\n): ToolDefinition<typeof writeSchema, WriteToolDetails | undefined> {\n\tconst ops = options?.operations ?? defaultWriteOperations;\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst resolveMutationRequester = options?.resolveMutationRequester;\n\treturn {\n\t\tname: \"write\",\n\t\tconcurrency: \"exclusive\",\n\t\tlabel: \"write\",\n\t\tdescription:\n\t\t\t\"Create or overwrite a file, writable internal resource, archive entry, SQLite row, or merge-conflict resolution.\",\n\t\tpromptSnippet: writeToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...writeToolSystemPromptContribution.guidelines],\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tparameters: writeSchema,\n\t\tasync execute(\n\t\t\ttoolCallId,\n\t\t\t{ path, content }: { path: string; content: string },\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\tctx?: ExtensionContext,\n\t\t) {\n\t\t\tconst resourceCtx = ctx as InternalResourceContext | undefined;\n\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\tconst archive = parseArchiveSelector(path);\n\t\t\tconst parsedSqlite = parseSqliteSelector(path);\n\t\t\tif (parsedSqlite?.table && path.includes(\"?\"))\n\t\t\t\tthrow new Error(\"SQLite write selectors must not include query parameters.\");\n\t\t\tif (\n\t\t\t\tparsedSqlite?.table &&\n\t\t\t\t(parsedSqlite.limit !== undefined ||\n\t\t\t\t\tparsedSqlite.offset !== undefined ||\n\t\t\t\t\tparsedSqlite.where ||\n\t\t\t\t\tparsedSqlite.order ||\n\t\t\t\t\tparsedSqlite.schema ||\n\t\t\t\t\tparsedSqlite.sampleRows !== undefined ||\n\t\t\t\t\tparsedSqlite.query)\n\t\t\t)\n\t\t\t\tthrow new Error(\"SQLite write selectors must not include query parameters.\");\n\t\t\tconst sqlite = sqliteSelectorForPath(path, executionCwd);\n\t\t\tif (!sqlite && parsedSqlite?.table) throw new Error(`SQLite database not found or is not SQLite: ${path}`);\n\t\t\tif (sqlite) {\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tconst message = writeSqliteSelector(sqlite, stripped.content);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `${message}${strippedHashlineNote(stripped.stripped)}` }],\n\t\t\t\t\tdetails: { meta: { sourcePath: sqlite.databasePath } },\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (archive) {\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tconst resolvedArchive = resolveArchiveSelector(archive, executionCwd);\n\t\t\t\twriteArchiveSelector(resolvedArchive, stripped.content);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Successfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { resolvedPath: resolvedArchive.archivePath },\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (path.startsWith(\"conflict://\")) {\n\t\t\t\tconst writeContent = stripKnownHashlineCopiedContent(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tconst target = decodeURIComponent(path.slice(\"conflict://\".length));\n\t\t\t\tif (!target) throw new Error(\"conflict:// target is required.\");\n\t\t\t\tif (target.includes(\"/\"))\n\t\t\t\t\tthrow new Error(\"Scoped conflict resources are read-only; write conflict://<id> or conflict://*.\");\n\t\t\t\tconst liveBlocks = await findConflictBlocks(executionCwd);\n\t\t\t\tif (liveBlocks.length === 0) throw new Error(\"No conflict markers found.\");\n\t\t\t\tconst blocks = reconcileConflictBlocks(liveBlocks, executionCwd);\n\t\t\t\tif (target === \"*\") {\n\t\t\t\t\tconst headers = await conflictSnapshotHeaders(\n\t\t\t\t\t\tawait resolveConflictBlocks(blocks, writeContent),\n\t\t\t\t\t\texecutionCwd,\n\t\t\t\t\t\thashlineStore,\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\ttext: `Resolved ${blocks.length} conflict${blocks.length === 1 ? \"\" : \"s\"}${headers.length > 0 ? `\\n\\nSnapshots:\\n${headers.join(\"\\n\")}` : \"\"}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (!/^\\d+$/.test(target)) throw new Error(\"Conflict writes must target conflict://<id> or conflict://*.\");\n\t\t\t\tconst id = Number.parseInt(target, 10);\n\t\t\t\tconst block = blocks[id - 1];\n\t\t\t\tif (!block) throw new Error(`Conflict id not found: ${target}`);\n\t\t\t\tconst headers = await conflictSnapshotHeaders(\n\t\t\t\t\tawait resolveConflictBlocks([block], writeContent),\n\t\t\t\t\texecutionCwd,\n\t\t\t\t\thashlineStore,\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Resolved conflict ${target}${headers[0] ? `\\n\\n${headers[0]}` : \"\"}` }],\n\t\t\t\t\tdetails: undefined,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (/^[a-z]+:\\/\\//i.test(path)) {\n\t\t\t\tconst sourcePath = path.startsWith(\"local://\") ? resolveInternalSelector(path, executionCwd) : undefined;\n\t\t\t\tif (sourcePath)\n\t\t\t\t\treturn createWriteToolDefinition(executionCwd, { ...options, hashlineStore }).execute(\n\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t{ path: sourcePath, content },\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t_onUpdate,\n\t\t\t\t\t\tctx as never,\n\t\t\t\t\t);\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tawait writeInternalSelector(path, executionCwd, stripped.content, resourceCtx);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Successfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {},\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst absolutePath = resolveToCwd(path, executionCwd);\n\t\t\tconst dir = dirname(absolutePath);\n\t\t\treturn withFileMutationQueue(absolutePath, async (canonicalKey) => {\n\t\t\t\t// Do not reject from an abort event listener here: that would release the\n\t\t\t\t// mutation queue while an in-flight filesystem operation may still finish.\n\t\t\t\t// Checking signal.aborted after each await observes the same aborts while\n\t\t\t\t// keeping the queue locked until the current operation has settled.\n\t\t\t\tconst throwIfAborted = (): void => {\n\t\t\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t};\n\n\t\t\t\tthrowIfAborted();\n\t\t\t\t// Create parent directories if needed.\n\t\t\t\tawait ops.mkdir(dir);\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\tconst requester = resolveMutationRequester?.(toolCallId);\n\t\t\t\tconst conflict = (details: Omit<FileMutationConflictDetails, \"path\" | \"canonicalKey\" | \"requester\">) =>\n\t\t\t\t\tnew FileMutationConflict({\n\t\t\t\t\t\t...details,\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\t// Registration resolved this already, so a conflict names the target\n\t\t\t\t\t\t// without paying for a second `realpath` while holding the lock.\n\t\t\t\t\t\tcanonicalKey,\n\t\t\t\t\t\t...(requester ? { requester } : {}),\n\t\t\t\t\t});\n\n\t\t\t\tlet existing: string | undefined;\n\t\t\t\ttry {\n\t\t\t\t\texisting = await ops.readFile(absolutePath);\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// The path is occupied by something this reader cannot open: a directory, a\n\t\t\t\t\t// locked file, a permissions failure. Treating that as absence would present it\n\t\t\t\t\t// as a fresh create and truncate it, so it is a conflict rather than a fallback.\n\t\t\t\t\tconst causeCode = filesystemErrorCode(error);\n\t\t\t\t\tthrow conflict({\n\t\t\t\t\t\treason: \"target_unreadable\",\n\t\t\t\t\t\t// Nothing about the target can be described once the read fails, and\n\t\t\t\t\t\t// inventing a size or a tag would be worse than omitting them.\n\t\t\t\t\t\t...(causeCode ? { causeCode } : {}),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (existing !== undefined && hasGeneratedMarker(existing))\n\t\t\t\t\tthrow new Error(`Refusing to overwrite generated file: ${path}`);\n\t\t\t\tif (existing !== undefined) {\n\t\t\t\t\t// `write` replaces a whole file rather than anchoring to a section, so nothing\n\t\t\t\t\t// in the call itself says what is being replaced. Having recorded that exact\n\t\t\t\t\t// content is the only evidence this session ever saw it, and the store answers\n\t\t\t\t\t// for this session alone, which is what makes another agent's file land here as\n\t\t\t\t\t// a conflict instead of silently losing.\n\t\t\t\t\t//\n\t\t\t\t\t// The read above is reused deliberately: it already happened under the queue,\n\t\t\t\t\t// so re-reading would only widen the window it closes.\n\t\t\t\t\tassertPriorSessionObservation({\n\t\t\t\t\t\tcanonicalKey,\n\t\t\t\t\t\tstoreKey: hashlineStoreKey(absolutePath),\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tstore: hashlineStore.snapshots,\n\t\t\t\t\t\t// Normalized because that is the form `record` stored. Comparing raw bytes\n\t\t\t\t\t\t// would reject every CRLF file the session had read perfectly well.\n\t\t\t\t\t\tlive: normalizeHashlineContent(existing),\n\t\t\t\t\t\t...(requester ? { requester } : {}),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(\n\t\t\t\t\tcontent,\n\t\t\t\t\tabsolutePath,\n\t\t\t\t\texecutionCwd,\n\t\t\t\t\thashlineStore,\n\t\t\t\t\tpath,\n\t\t\t\t);\n\t\t\t\tconst writeContent = stripped.content;\n\t\t\t\tif (existing === undefined) {\n\t\t\t\t\t// Nothing was there a moment ago, so this is a create and says so to the\n\t\t\t\t\t// filesystem. The mutation queue already excludes other Atomic writers; `O_EXCL`\n\t\t\t\t\t// covers the rest, and turns what would have been a silent clobber of a file\n\t\t\t\t\t// that appeared in between into a conflict that names it.\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait ops.writeFile(absolutePath, writeContent, { exclusive: true });\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!isExclusiveCreateCollision(error)) throw error;\n\t\t\t\t\t\tconst appeared = await ops.readFile(absolutePath).catch(() => undefined);\n\t\t\t\t\t\tthrow conflict({\n\t\t\t\t\t\t\treason: \"target_exists\",\n\t\t\t\t\t\t\t// Only describe the file when it can still be read. `computeLiveState`\n\t\t\t\t\t\t\t// renders absence for `undefined`, which would contradict the reason.\n\t\t\t\t\t\t\t...(appeared !== undefined ? { liveState: computeLiveState(appeared) } : {}),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else await ops.writeFile(absolutePath, writeContent);\n\t\t\t\tinvalidateNativeSearchCache(absolutePath);\n\t\t\t\t// Recorded as soon as the bytes land, ahead of the abort check below, because an\n\t\t\t\t// abort cancels reporting the result rather than undoing the write. Left until\n\t\t\t\t// after it, a cancelled-but-written file would come back as someone else's work on\n\t\t\t\t// the next overwrite. The hashline engine already records inside `commit` for the\n\t\t\t\t// same reason.\n\t\t\t\tconst header = hashlineHeaderForWrite(absolutePath, executionCwd, writeContent, hashlineStore);\n\t\t\t\tlet madeExecutable = false;\n\t\t\t\tif (writeContent.startsWith(\"#!\")) {\n\t\t\t\t\tconst mode = await fsStat(absolutePath)\n\t\t\t\t\t\t.then((stat) => stat.mode)\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tif (mode !== undefined) {\n\t\t\t\t\t\tawait fsChmod(absolutePath, mode | 0o111);\n\t\t\t\t\t\tmadeExecutable = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `${header}\\nSuccessfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { resolvedPath: absolutePath, ...(madeExecutable ? { madeExecutable } : {}) },\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst renderArgs = args as { path?: string; content?: string } | undefined;\n\t\t\tconst rawPath = str(renderArgs?.path);\n\t\t\tconst fileContent = str(renderArgs?.content);\n\t\t\tconst component =\n\t\t\t\t(context.lastComponent as WriteCallRenderComponent | undefined) ?? new WriteCallRenderComponent();\n\t\t\tif (fileContent !== null) {\n\t\t\t\tcomponent.cache = context.argsComplete\n\t\t\t\t\t? rebuildWriteHighlightCacheFull(rawPath, fileContent)\n\t\t\t\t\t: updateWriteHighlightCacheIncremental(component.cache, rawPath, fileContent);\n\t\t\t} else {\n\t\t\t\tcomponent.cache = undefined;\n\t\t\t}\n\t\t\tcomponent.setText(\n\t\t\t\tformatWriteCall(\n\t\t\t\t\trenderArgs,\n\t\t\t\t\t{ expanded: context.expanded, isPartial: context.isPartial },\n\t\t\t\t\ttheme,\n\t\t\t\t\tcomponent.cache,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn component;\n\t\t},\n\t\trenderResult(result, _options, theme, context) {\n\t\t\tconst output = formatWriteResult({ ...result, isError: context.isError }, theme);\n\t\t\tif (!output) {\n\t\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\t\tcomponent.clear();\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(output);\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createWriteTool(cwd: string, options?: WriteToolOptions): AgentTool<typeof writeSchema> {\n\treturn wrapToolDefinition(createWriteToolDefinition(cwd, options));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-totals.d.ts","sourceRoot":"","sources":["../../src/core/usage-totals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,WAAW,WAAW;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,iBAAiB,IAAI,WAAW,CAE/C;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAMxE;AAED,MAAM,WAAW,uBAAuB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CACf;AAID,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,uBAAuB,EAAE,
|
|
1
|
+
{"version":3,"file":"usage-totals.d.ts","sourceRoot":"","sources":["../../src/core/usage-totals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,WAAW,WAAW;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,iBAAiB,IAAI,WAAW,CAE/C;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAMxE;AAED,MAAM,WAAW,uBAAuB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CACf;AAID,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,uBAAuB,EAAE,CAmCxF"}
|
|
@@ -13,6 +13,10 @@ export function getUsageCostBreakdown(entries) {
|
|
|
13
13
|
for (const entry of entries) {
|
|
14
14
|
let key;
|
|
15
15
|
let usage;
|
|
16
|
+
if (entry.type === "usage") {
|
|
17
|
+
key = `${entry.provider}/${entry.model}`;
|
|
18
|
+
usage = entry.usage;
|
|
19
|
+
}
|
|
16
20
|
if (entry.type === "message" && entry.message.role === "assistant") {
|
|
17
21
|
key = `${entry.message.provider}/${entry.message.responseModel ?? entry.message.model}`;
|
|
18
22
|
usage = entry.message.usage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-totals.js","sourceRoot":"","sources":["../../src/core/usage-totals.ts"],"names":[],"mappings":"AAWA,MAAM,UAAU,iBAAiB;IAChC,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAmB,EAAE,KAAY;IACjE,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC;IAC5B,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;IAC9B,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC;IACpC,MAAM,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC;IACtC,MAAM,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;AACjC,CAAC;AAUD,MAAM,UAAU,qBAAqB,CAAC,OAAuB;IAC5D,MAAM,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAC;IACnD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;Q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CAAC,CAAC;QACxB,GAAG;QACH,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,UAAU;KAC3E,CAAC,CAAC;SACF,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;SACrD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import type { Usage } from \"@bastani/pi-ai/compat\";\nimport type { SessionEntry } from \"./session-manager.ts\";\n\nexport interface UsageTotals {\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\tcost: number;\n}\n\nexport function createUsageTotals(): UsageTotals {\n\treturn { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0 };\n}\n\nexport function addUsageToTotals(totals: UsageTotals, usage: Usage): void {\n\ttotals.input += usage.input;\n\ttotals.output += usage.output;\n\ttotals.cacheRead += usage.cacheRead;\n\ttotals.cacheWrite += usage.cacheWrite;\n\ttotals.cost += usage.cost.total;\n}\n\nexport interface UsageCostBreakdownEntry {\n\tkey: string;\n\tcost: number;\n\ttokens: number;\n}\n\ntype MessageWithUsage = { role: \"toolResult\"; usage?: Usage };\n\nexport function getUsageCostBreakdown(entries: SessionEntry[]): UsageCostBreakdownEntry[] {\n\tconst totalsByKey = new Map<string, UsageTotals>();\n\tfor (const entry of entries) {\n\t\tlet key: string | undefined;\n\t\tlet usage: Usage | undefined;\n\t\tif (entry.type === \"message\" && entry.message.role === \"assistant\") {\n\t\t\tkey = `${entry.message.provider}/${entry.message.responseModel ?? entry.message.model}`;\n\t\t\tusage = entry.message.usage;\n\t\t} else if (entry.type === \"message\" && entry.message.role === \"toolResult\") {\n\t\t\tusage = (entry.message as MessageWithUsage).usage;\n\t\t\tkey = usage ? \"Tools/summaries\" : undefined;\n\t\t} else if (\n\t\t\t(entry.type === \"branch_summary\" || entry.type === \"session_summary\" || entry.type === \"compaction\") &&\n\t\t\tentry.usage\n\t\t) {\n\t\t\tkey = \"Tools/summaries\";\n\t\t\tusage = entry.usage;\n\t\t}\n\t\tif (!key || !usage) continue;\n\t\tconst totals = totalsByKey.get(key) ?? createUsageTotals();\n\t\taddUsageToTotals(totals, usage);\n\t\ttotalsByKey.set(key, totals);\n\t}\n\treturn [...totalsByKey]\n\t\t.map(([key, totals]) => ({\n\t\t\tkey,\n\t\t\tcost: totals.cost,\n\t\t\ttokens: totals.input + totals.output + totals.cacheRead + totals.cacheWrite,\n\t\t}))\n\t\t.filter((entry) => entry.cost > 0 || entry.tokens > 0)\n\t\t.sort((a, b) => b.cost - a.cost);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"usage-totals.js","sourceRoot":"","sources":["../../src/core/usage-totals.ts"],"names":[],"mappings":"AAWA,MAAM,UAAU,iBAAiB;IAChC,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAmB,EAAE,KAAY;IACjE,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC;IAC5B,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;IAC9B,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC;IACpC,MAAM,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC;IACtC,MAAM,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;AACjC,CAAC;AAUD,MAAM,UAAU,qBAAqB,CAAC,OAAuB;IA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W,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,iBAAiB,EAAE,CAAC;QAC3D,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAChC,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,CAAC,GAAG,WAAW,CAAC;SACrB,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;QACxB,GAAG;QACH,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,UAAU;KAC3E,CAAC,CAAC;SACF,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;SACrD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import type { Usage } from \"@bastani/pi-ai/compat\";\nimport type { SessionEntry } from \"./session-manager.ts\";\n\nexport interface UsageTotals {\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\tcost: number;\n}\n\nexport function createUsageTotals(): UsageTotals {\n\treturn { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0 };\n}\n\nexport function addUsageToTotals(totals: UsageTotals, usage: Usage): void {\n\ttotals.input += usage.input;\n\ttotals.output += usage.output;\n\ttotals.cacheRead += usage.cacheRead;\n\ttotals.cacheWrite += usage.cacheWrite;\n\ttotals.cost += usage.cost.total;\n}\n\nexport interface UsageCostBreakdownEntry {\n\tkey: string;\n\tcost: number;\n\ttokens: number;\n}\n\ntype MessageWithUsage = { role: \"toolResult\"; usage?: Usage };\n\nexport function getUsageCostBreakdown(entries: SessionEntry[]): UsageCostBreakdownEntry[] {\n\tconst totalsByKey = new Map<string, UsageTotals>();\n\tfor (const entry of entries) {\n\t\tlet key: string | undefined;\n\t\tlet usage: Usage | undefined;\n\t\tif (entry.type === \"usage\") {\n\t\t\tkey = `${entry.provider}/${entry.model}`;\n\t\t\tusage = entry.usage;\n\t\t}\n\t\tif (entry.type === \"message\" && entry.message.role === \"assistant\") {\n\t\t\tkey = `${entry.message.provider}/${entry.message.responseModel ?? entry.message.model}`;\n\t\t\tusage = entry.message.usage;\n\t\t} else if (entry.type === \"message\" && entry.message.role === \"toolResult\") {\n\t\t\tusage = (entry.message as MessageWithUsage).usage;\n\t\t\tkey = usage ? \"Tools/summaries\" : undefined;\n\t\t} else if (\n\t\t\t(entry.type === \"branch_summary\" || entry.type === \"session_summary\" || entry.type === \"compaction\") &&\n\t\t\tentry.usage\n\t\t) {\n\t\t\tkey = \"Tools/summaries\";\n\t\t\tusage = entry.usage;\n\t\t}\n\t\tif (!key || !usage) continue;\n\t\tconst totals = totalsByKey.get(key) ?? createUsageTotals();\n\t\taddUsageToTotals(totals, usage);\n\t\ttotalsByKey.set(key, totals);\n\t}\n\treturn [...totalsByKey]\n\t\t.map(([key, totals]) => ({\n\t\t\tkey,\n\t\t\tcost: totals.cost,\n\t\t\ttokens: totals.input + totals.output + totals.cacheRead + totals.cacheWrite,\n\t\t}))\n\t\t.filter((entry) => entry.cost > 0 || entry.tokens > 0)\n\t\t.sort((a, b) => b.cost - a.cost);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/herdr/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAMvG,OAAO,EAGN,KAAK,oBAAoB,EAIzB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IAClE,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,OAAO,CAAC;CAC7C;AAOD,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/herdr/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAMvG,OAAO,EAGN,KAAK,oBAAoB,EAIzB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IAClE,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,OAAO,CAAC;CAC7C;AAOD,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,gBAAgB,CAoL1F;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAE7D"}
|
|
@@ -74,13 +74,6 @@ export function createHerdrExtension(options = {}) {
|
|
|
74
74
|
return;
|
|
75
75
|
if (!(options.enabled ?? enabled)(ctx))
|
|
76
76
|
return;
|
|
77
|
-
const conflict = ctx
|
|
78
|
-
.getExtensionPaths?.()
|
|
79
|
-
.find((path) => /herdr-atomic-reporter|herdr-agent-state/.test(path));
|
|
80
|
-
if (conflict) {
|
|
81
|
-
diagnostic({ kind: "unsupported", owner: conflict });
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
77
|
if (boundRunner && boundRunner !== runner)
|
|
85
78
|
retiredRunners.add(boundRunner);
|
|
86
79
|
boundRunner = runner;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/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ACH,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAgB;IACtD,oBAAoB,EAAE,CAAC,EAAE,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import { getExtensionContextOwner, publishExtensionContextEffect } from \"../../core/extensions/runner-context.ts\";\nimport type { ExtensionAPI, ExtensionContext, ExtensionFactory } from \"../../core/extensions/types.ts\";\nimport type { WorkflowRootActivity } from \"../../core/extensions/workflow-events.js\";\nimport { SettingsManager } from \"../../core/settings-manager.ts\";\nimport { OwnerTaskStore } from \"../../core/tasks/owner-store.js\";\nimport { deriveSessionActivity } from \"./activity.js\";\nimport { captureHerdrEnvironment } from \"./environment.js\";\nimport {\n\tclaimPaneReporting,\n\ttype PaneOwner,\n\ttype PaneReportingOptions,\n\treleasePaneReporting,\n\treportPaneActivity,\n\tretirePaneReporting,\n} from \"./pane-owner.js\";\nimport type { HerdrDiagnostic } from \"./transport.js\";\n\nexport interface HerdrExtensionOptions extends PaneReportingOptions {\n\tenv?: NodeJS.ProcessEnv;\n\tenabled?: (ctx: ExtensionContext) => boolean;\n}\n\nfunction enabled(ctx: ExtensionContext): boolean {\n\tconst settings = SettingsManager.create(ctx.cwd, undefined, { projectTrusted: ctx.isProjectTrusted() });\n\treturn (settings.getProjectSettings().herdr?.enabled ?? settings.getGlobalSettings().herdr?.enabled) !== false;\n}\n\nexport function createHerdrExtension(options: HerdrExtensionOptions = {}): ExtensionFactory {\n\treturn (pi) => {\n\t\tif (!captureHerdrEnvironment(options.env ?? process.env)) return;\n\t\tlet owner: PaneOwner | undefined;\n\t\t// Supplied loaders can share closures across sessions and overlapping reload runners.\n\t\tlet boundSessionManager: ExtensionContext[\"sessionManager\"] | undefined;\n\t\tlet boundRunner: object | undefined;\n\t\tconst retiredRunners = new WeakSet<object>();\n\t\tconst ownsBinding = (ctx: ExtensionContext) =>\n\t\t\tboundSessionManager !== undefined && getExtensionContextOwner(ctx) === boundRunner;\n\t\tlet lease: { dispose(): void } | undefined;\n\t\tlet taskStore: OwnerTaskStore | undefined;\n\t\tlet unsubscribeTasks: (() => void) | undefined;\n\t\tlet agentRunning = false;\n\t\tlet openPromptCount = 0;\n\t\tlet availability: \"ready\" | \"unavailable\" | \"recovering\" = \"unavailable\";\n\t\tconst roots = new Map<string, WorkflowRootActivity>();\n\t\tconst acknowledgedBlocks = new Map<string, WorkflowRootActivity>();\n\t\tconst updateRoot = (root: WorkflowRootActivity) => {\n\t\t\tconst acknowledged = acknowledgedBlocks.get(root.rootRunId);\n\t\t\tif (\n\t\t\t\tacknowledged &&\n\t\t\t\t(root.state !== acknowledged.state ||\n\t\t\t\t\troot.reason !== acknowledged.reason ||\n\t\t\t\t\troot.actionableBlockCount !== acknowledged.actionableBlockCount ||\n\t\t\t\t\troot.activeExecutionCount !== acknowledged.activeExecutionCount ||\n\t\t\t\t\troot.needsAttention !== acknowledged.needsAttention)\n\t\t\t)\n\t\t\t\tacknowledgedBlocks.delete(root.rootRunId);\n\t\t\troots.set(root.rootRunId, root);\n\t\t};\n\t\tconst seenDiagnostics = new Set<string>();\n\t\tlet generation = 0;\n\t\tconst diagnostic = (value: HerdrDiagnostic) => {\n\t\t\tconst key = `${value.kind}:${value.owner ?? \"\"}`;\n\t\t\tif (seenDiagnostics.has(key)) return;\n\t\t\tseenDiagnostics.add(key);\n\t\t\tif (options.diagnostic) options.diagnostic(value);\n\t\t\telse console.error(`[Herdr] ${value.kind}${value.owner ? `: deferring to ${value.owner}` : \"\"}`);\n\t\t};\n\t\tconst tasksRunning = () => taskStore?.tasks.some((task) => task.execution.kind !== \"settled\") ?? false;\n\t\tconst report = () => {\n\t\t\tif (!owner) return;\n\t\t\tconst activity = deriveSessionActivity({\n\t\t\t\tagentRunning,\n\t\t\t\ttasksRunning: tasksRunning(),\n\t\t\t\topenPromptCount,\n\t\t\t\troots: [...roots.values()].filter((root) => !acknowledgedBlocks.has(root.rootRunId)),\n\t\t\t\tavailability,\n\t\t\t});\n\t\t\tif (activity) reportPaneActivity(owner, activity);\n\t\t};\n\t\tconst start = async (ctx: ExtensionContext) => {\n\t\t\tconst runner = getExtensionContextOwner(ctx);\n\t\t\tif (retiredRunners.has(runner)) return;\n\t\t\tif (boundSessionManager && ctx.sessionManager !== boundSessionManager) return;\n\t\t\tconst environment = captureHerdrEnvironment(options.env ?? process.env);\n\t\t\tif (!environment || ctx.mode !== \"tui\" || !ctx.hasUI || ctx.subagentPolicy || ctx.orchestrationContext) return;\n\t\t\tif (!(options.enabled ?? enabled)(ctx)) return;\n\t\t\tconst conflict = ctx\n\t\t\t\t.getExtensionPaths?.()\n\t\t\t\t.find((path) => /herdr-atomic-reporter|herdr-agent-state/.test(path));\n\t\t\tif (conflict) {\n\t\t\t\tdiagnostic({ kind: \"unsupported\", owner: conflict });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (boundRunner && boundRunner !== runner) retiredRunners.add(boundRunner);\n\t\t\tboundRunner = runner;\n\t\t\tboundSessionManager = ctx.sessionManager;\n\t\t\tconst current = ++generation;\n\t\t\tlease?.dispose();\n\t\t\tlease = undefined;\n\t\t\tunsubscribeTasks?.();\n\t\t\ttaskStore?.dispose();\n\t\t\tunsubscribeTasks = undefined;\n\t\t\ttaskStore = undefined;\n\t\t\topenPromptCount = 0;\n\t\t\troots.clear();\n\t\t\tacknowledgedBlocks.clear();\n\t\t\tavailability = \"unavailable\";\n\t\t\tconst claimed = await claimPaneReporting(\n\t\t\t\tenvironment,\n\t\t\t\t{ id: ctx.sessionManager.getSessionId(), path: ctx.sessionManager.getSessionFile() },\n\t\t\t\t{ ...options, diagnostic },\n\t\t\t);\n\t\t\tif (current !== generation) {\n\t\t\t\tawait releasePaneReporting(claimed);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\towner = claimed;\n\t\t\tagentRunning = !ctx.isIdle();\n\t\t\tconst taskHost = ctx.getAgentTaskHost?.();\n\t\t\tif (taskHost) {\n\t\t\t\tconst { supervisor, owner: taskOwner } = taskHost.ownerBinding;\n\t\t\t\ttaskStore = new OwnerTaskStore(supervisor, taskOwner);\n\t\t\t\ttaskStore.connect();\n\t\t\t\tlet running = tasksRunning();\n\t\t\t\tunsubscribeTasks = taskStore.subscribe(() => {\n\t\t\t\t\tif (current !== generation) return;\n\t\t\t\t\tconst next = tasksRunning();\n\t\t\t\t\tif (next === running) return;\n\t\t\t\t\trunning = next;\n\t\t\t\t\treport();\n\t\t\t\t});\n\t\t\t}\n\t\t\tlease = ctx.observeWorkflowActivity((frame) => {\n\t\t\t\tif (current !== generation) return;\n\t\t\t\tif (frame.kind === \"snapshot\") {\n\t\t\t\t\tavailability = frame.availability;\n\t\t\t\t\troots.clear();\n\t\t\t\t\tif (frame.availability === \"ready\") {\n\t\t\t\t\t\tfor (const root of frame.roots) updateRoot(root);\n\t\t\t\t\t\tfor (const id of acknowledgedBlocks.keys()) if (!roots.has(id)) acknowledgedBlocks.delete(id);\n\t\t\t\t\t}\n\t\t\t\t} else if (frame.kind === \"changed\") updateRoot(frame.root);\n\t\t\t\telse {\n\t\t\t\t\troots.delete(frame.rootRunId);\n\t\t\t\t\tacknowledgedBlocks.delete(frame.rootRunId);\n\t\t\t\t}\n\t\t\t\treport();\n\t\t\t});\n\t\t};\n\t\tpi.on(\"session_start\", (_event, ctx) => publishExtensionContextEffect(ctx, () => start(ctx)));\n\t\tpi.on(\"input\", (event, ctx) => {\n\t\t\tif (!ownsBinding(ctx) || event.source !== \"interactive\") return;\n\t\t\tlet changed = false;\n\t\t\tfor (const root of roots.values()) {\n\t\t\t\tif (root.state === \"blocked\" && !acknowledgedBlocks.has(root.rootRunId)) {\n\t\t\t\t\tacknowledgedBlocks.set(root.rootRunId, { ...root });\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (changed) report();\n\t\t});\n\t\tpi.on(\"workflow_lifecycle\", (event, ctx) => {\n\t\t\tif (!ownsBinding(ctx) || event.delivery !== \"live\") return;\n\t\t\tconst target = event.target;\n\t\t\tconst newBlock =\n\t\t\t\ttarget.kind === \"prompt\"\n\t\t\t\t\t? target.status === \"opened\"\n\t\t\t\t\t: (target.kind === \"run\" || target.kind === \"stage\") &&\n\t\t\t\t\t\t(target.status === \"blocked\" || target.status === \"awaiting_input\") &&\n\t\t\t\t\t\ttarget.previousStatus !== target.status;\n\t\t\tif (newBlock && acknowledgedBlocks.delete(event.rootRunId)) report();\n\t\t});\n\t\tpi.on(\"agent_start\", (_event, ctx) => {\n\t\t\tif (!ownsBinding(ctx)) return;\n\t\t\tagentRunning = true;\n\t\t\treport();\n\t\t});\n\t\tpi.on(\"agent_settled\", (_event, ctx) => {\n\t\t\tif (!ownsBinding(ctx)) return;\n\t\t\tagentRunning = false;\n\t\t\treport();\n\t\t});\n\t\tpi.on(\"ui_prompt_start\", (_event, ctx) => {\n\t\t\tif (!ownsBinding(ctx)) return;\n\t\t\topenPromptCount++;\n\t\t\treport();\n\t\t});\n\t\tpi.on(\"ui_prompt_end\", (_event, ctx) => {\n\t\t\tif (!ownsBinding(ctx)) return;\n\t\t\topenPromptCount = Math.max(0, openPromptCount - 1);\n\t\t\treport();\n\t\t});\n\t\tpi.on(\"session_shutdown\", async (event, ctx) => {\n\t\t\tif (!ownsBinding(ctx)) return;\n\t\t\t// A non-quit stop may restart this runner, unless a successor supersedes it first.\n\t\t\tif (event.reason === \"quit\") retiredRunners.add(boundRunner!);\n\t\t\tgeneration++;\n\t\t\tlease?.dispose();\n\t\t\tlease = undefined;\n\t\t\tunsubscribeTasks?.();\n\t\t\ttaskStore?.dispose();\n\t\t\tunsubscribeTasks = undefined;\n\t\t\ttaskStore = undefined;\n\t\t\tconst previous = owner;\n\t\t\towner = undefined;\n\t\t\t// Clear before awaiting transport: a successor can bind while retirement drains,\n\t\t\t// and this shutdown's completion must never clear that newer binding.\n\t\t\tboundSessionManager = undefined;\n\t\t\tif (previous) {\n\t\t\t\tif (event.reason === \"quit\") await releasePaneReporting(previous);\n\t\t\t\telse await retirePaneReporting(previous);\n\t\t\t}\n\t\t});\n\t};\n}\n\nexport default function herdrExtension(pi: ExtensionAPI): void {\n\tcreateHerdrExtension()(pi);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/herdr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AAGlH,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EACN,kBAAkB,EAGlB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,iBAAiB,CAAC;AAQzB,SAAS,OAAO,CAAC,GAAqB;IACrC,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,cAAc,EAAE,GAAG,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACxG,OAAO,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC,KAAK,EAAE,OAAO,IAAI,QAAQ,CAAC,iBAAiB,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,KAAK,CAAC;AAChH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAO,GAA0B,EAAE;IACvE,OAAO,CAAC,EAAE,EAAE,EAAE;QACb,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;YAAE,OAAO;QACjE,IAAI,KAA4B,CAAC;QACjC,sFAAsF;QACtF,IAAI,mBAAmE,CAAC;QACxE,IAAI,WAA+B,CAAC;QACpC,MAAM,cAAc,GAAG,IAAI,OAAO,EAAU,CAAC;QAC7C,MAAM,WAAW,GAAG,CAAC,GAAqB,EAAE,EAA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context.ts\";\nimport type { ExtensionAPI, ExtensionContext, ExtensionFactory } from \"../../core/extensions/types.ts\";\nimport type { WorkflowRootActivity } from \"../../core/extensions/workflow-events.js\";\nimport { SettingsManager } from \"../../core/settings-manager.ts\";\nimport { OwnerTaskStore } from \"../../core/tasks/owner-store.js\";\nimport { deriveSessionActivity } from \"./activity.js\";\nimport { captureHerdrEnvironment } from \"./environment.js\";\nimport {\n\tclaimPaneReporting,\n\ttype PaneOwner,\n\ttype PaneReportingOptions,\n\treleasePaneReporting,\n\treportPaneActivity,\n\tretirePaneReporting,\n} from \"./pane-owner.js\";\nimport type { HerdrDiagnostic } from \"./transport.js\";\n\nexport interface HerdrExtensionOptions extends PaneReportingOptions {\n\tenv?: NodeJS.ProcessEnv;\n\tenabled?: (ctx: ExtensionContext) => boolean;\n}\n\nfunction enabled(ctx: ExtensionContext): boolean {\n\tconst settings = SettingsManager.create(ctx.cwd, undefined, { projectTrusted: ctx.isProjectTrusted() });\n\treturn (settings.getProjectSettings().herdr?.enabled ?? settings.getGlobalSettings().herdr?.enabled) !== false;\n}\n\nexport function createHerdrExtension(options: HerdrExtensionOptions = {}): ExtensionFactory {\n\treturn (pi) => {\n\t\tif (!captureHerdrEnvironment(options.env ?? process.env)) return;\n\t\tlet owner: PaneOwner | undefined;\n\t\t// Supplied loaders can share closures across sessions and overlapping reload runners.\n\t\tlet boundSessionManager: ExtensionContext[\"sessionManager\"] | undefined;\n\t\tlet boundRunner: object | undefined;\n\t\tconst retiredRunners = new WeakSet<object>();\n\t\tconst ownsBinding = (ctx: ExtensionContext) =>\n\t\t\tboundSessionManager !== undefined && getExtensionContextOwner(ctx) === boundRunner;\n\t\tlet lease: { dispose(): void } | undefined;\n\t\tlet taskStore: OwnerTaskStore | undefined;\n\t\tlet unsubscribeTasks: (() => void) | undefined;\n\t\tlet agentRunning = false;\n\t\tlet openPromptCount = 0;\n\t\tlet availability: \"ready\" | \"unavailable\" | \"recovering\" = \"unavailable\";\n\t\tconst roots = new Map<string, WorkflowRootActivity>();\n\t\tconst acknowledgedBlocks = new Map<string, WorkflowRootActivity>();\n\t\tconst updateRoot = (root: WorkflowRootActivity) => {\n\t\t\tconst acknowledged = acknowledgedBlocks.get(root.rootRunId);\n\t\t\tif (\n\t\t\t\tacknowledged &&\n\t\t\t\t(root.state !== acknowledged.state ||\n\t\t\t\t\troot.reason !== acknowledged.reason ||\n\t\t\t\t\troot.actionableBlockCount !== acknowledged.actionableBlockCount ||\n\t\t\t\t\troot.activeExecutionCount !== acknowledged.activeExecutionCount ||\n\t\t\t\t\troot.needsAttention !== acknowledged.needsAttention)\n\t\t\t)\n\t\t\t\tacknowledgedBlocks.delete(root.rootRunId);\n\t\t\troots.set(root.rootRunId, root);\n\t\t};\n\t\tconst seenDiagnostics = new Set<string>();\n\t\tlet generation = 0;\n\t\tconst diagnostic = (value: HerdrDiagnostic) => {\n\t\t\tconst key = `${value.kind}:${value.owner ?? \"\"}`;\n\t\t\tif (seenDiagnostics.has(key)) return;\n\t\t\tseenDiagnostics.add(key);\n\t\t\tif (options.diagnostic) options.diagnostic(value);\n\t\t\telse console.error(`[Herdr] ${value.kind}${value.owner ? `: deferring to ${value.owner}` : \"\"}`);\n\t\t};\n\t\tconst tasksRunning = () => taskStore?.tasks.some((task) => task.execution.kind !== \"settled\") ?? false;\n\t\tconst report = () => {\n\t\t\tif (!owner) return;\n\t\t\tconst activity = deriveSessionActivity({\n\t\t\t\tagentRunning,\n\t\t\t\ttasksRunning: tasksRunning(),\n\t\t\t\topenPromptCount,\n\t\t\t\troots: [...roots.values()].filter((root) => !acknowledgedBlocks.has(root.rootRunId)),\n\t\t\t\tavailability,\n\t\t\t});\n\t\t\tif (activity) reportPaneActivity(owner, activity);\n\t\t};\n\t\tconst start = async (ctx: ExtensionContext) => {\n\t\t\tconst runner = getExtensionContextOwner(ctx);\n\t\t\tif (retiredRunners.has(runner)) return;\n\t\t\tif (boundSessionManager && ctx.sessionManager !== boundSessionManager) return;\n\t\t\tconst environment = captureHerdrEnvironment(options.env ?? process.env);\n\t\t\tif (!environment || ctx.mode !== \"tui\" || !ctx.hasUI || ctx.subagentPolicy || ctx.orchestrationContext) return;\n\t\t\tif (!(options.enabled ?? enabled)(ctx)) return;\n\t\t\tif (boundRunner && boundRunner !== runner) retiredRunners.add(boundRunner);\n\t\t\tboundRunner = runner;\n\t\t\tboundSessionManager = ctx.sessionManager;\n\t\t\tconst current = ++generation;\n\t\t\tlease?.dispose();\n\t\t\tlease = undefined;\n\t\t\tunsubscribeTasks?.();\n\t\t\ttaskStore?.dispose();\n\t\t\tunsubscribeTasks = undefined;\n\t\t\ttaskStore = undefined;\n\t\t\topenPromptCount = 0;\n\t\t\troots.clear();\n\t\t\tacknowledgedBlocks.clear();\n\t\t\tavailability = \"unavailable\";\n\t\t\tconst claimed = await claimPaneReporting(\n\t\t\t\tenvironment,\n\t\t\t\t{ id: ctx.sessionManager.getSessionId(), path: ctx.sessionManager.getSessionFile() },\n\t\t\t\t{ ...options, diagnostic },\n\t\t\t);\n\t\t\tif (current !== generation) {\n\t\t\t\tawait releasePaneReporting(claimed);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\towner = claimed;\n\t\t\tagentRunning = !ctx.isIdle();\n\t\t\tconst taskHost = ctx.getAgentTaskHost?.();\n\t\t\tif (taskHost) {\n\t\t\t\tconst { supervisor, owner: taskOwner } = taskHost.ownerBinding;\n\t\t\t\ttaskStore = new OwnerTaskStore(supervisor, taskOwner);\n\t\t\t\ttaskStore.connect();\n\t\t\t\tlet running = tasksRunning();\n\t\t\t\tunsubscribeTasks = taskStore.subscribe(() => {\n\t\t\t\t\tif (current !== generation) return;\n\t\t\t\t\tconst next = tasksRunning();\n\t\t\t\t\tif (next === running) return;\n\t\t\t\t\trunning = next;\n\t\t\t\t\treport();\n\t\t\t\t});\n\t\t\t}\n\t\t\tlease = ctx.observeWorkflowActivity((frame) => {\n\t\t\t\tif (current !== generation) return;\n\t\t\t\tif (frame.kind === \"snapshot\") {\n\t\t\t\t\tavailability = frame.availability;\n\t\t\t\t\troots.clear();\n\t\t\t\t\tif (frame.availability === \"ready\") {\n\t\t\t\t\t\tfor (const root of frame.roots) updateRoot(root);\n\t\t\t\t\t\tfor (const id of acknowledgedBlocks.keys()) if (!roots.has(id)) acknowledgedBlocks.delete(id);\n\t\t\t\t\t}\n\t\t\t\t} else if (frame.kind === \"changed\") updateRoot(frame.root);\n\t\t\t\telse {\n\t\t\t\t\troots.delete(frame.rootRunId);\n\t\t\t\t\tacknowledgedBlocks.delete(frame.rootRunId);\n\t\t\t\t}\n\t\t\t\treport();\n\t\t\t});\n\t\t};\n\t\tpi.on(\"session_start\", (_event, ctx) => publishExtensionContextEffect(ctx, () => start(ctx)));\n\t\tpi.on(\"input\", (event, ctx) => {\n\t\t\tif (!ownsBinding(ctx) || event.source !== \"interactive\") return;\n\t\t\tlet changed = false;\n\t\t\tfor (const root of roots.values()) {\n\t\t\t\tif (root.state === \"blocked\" && !acknowledgedBlocks.has(root.rootRunId)) {\n\t\t\t\t\tacknowledgedBlocks.set(root.rootRunId, { ...root });\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (changed) report();\n\t\t});\n\t\tpi.on(\"workflow_lifecycle\", (event, ctx) => {\n\t\t\tif (!ownsBinding(ctx) || event.delivery !== \"live\") return;\n\t\t\tconst target = event.target;\n\t\t\tconst newBlock =\n\t\t\t\ttarget.kind === \"prompt\"\n\t\t\t\t\t? target.status === \"opened\"\n\t\t\t\t\t: (target.kind === \"run\" || target.kind === \"stage\") &&\n\t\t\t\t\t\t(target.status === \"blocked\" || target.status === \"awaiting_input\") &&\n\t\t\t\t\t\ttarget.previousStatus !== target.status;\n\t\t\tif (newBlock && acknowledgedBlocks.delete(event.rootRunId)) report();\n\t\t});\n\t\tpi.on(\"agent_start\", (_event, ctx) => {\n\t\t\tif (!ownsBinding(ctx)) return;\n\t\t\tagentRunning = true;\n\t\t\treport();\n\t\t});\n\t\tpi.on(\"agent_settled\", (_event, ctx) => {\n\t\t\tif (!ownsBinding(ctx)) return;\n\t\t\tagentRunning = false;\n\t\t\treport();\n\t\t});\n\t\tpi.on(\"ui_prompt_start\", (_event, ctx) => {\n\t\t\tif (!ownsBinding(ctx)) return;\n\t\t\topenPromptCount++;\n\t\t\treport();\n\t\t});\n\t\tpi.on(\"ui_prompt_end\", (_event, ctx) => {\n\t\t\tif (!ownsBinding(ctx)) return;\n\t\t\topenPromptCount = Math.max(0, openPromptCount - 1);\n\t\t\treport();\n\t\t});\n\t\tpi.on(\"session_shutdown\", async (event, ctx) => {\n\t\t\tif (!ownsBinding(ctx)) return;\n\t\t\t// A non-quit stop may restart this runner, unless a successor supersedes it first.\n\t\t\tif (event.reason === \"quit\") retiredRunners.add(boundRunner!);\n\t\t\tgeneration++;\n\t\t\tlease?.dispose();\n\t\t\tlease = undefined;\n\t\t\tunsubscribeTasks?.();\n\t\t\ttaskStore?.dispose();\n\t\t\tunsubscribeTasks = undefined;\n\t\t\ttaskStore = undefined;\n\t\t\tconst previous = owner;\n\t\t\towner = undefined;\n\t\t\t// Clear before awaiting transport: a successor can bind while retirement drains,\n\t\t\t// and this shutdown's completion must never clear that newer binding.\n\t\t\tboundSessionManager = undefined;\n\t\t\tif (previous) {\n\t\t\t\tif (event.reason === \"quit\") await releasePaneReporting(previous);\n\t\t\t\telse await retirePaneReporting(previous);\n\t\t\t}\n\t\t});\n\t};\n}\n\nexport default function herdrExtension(pi: ExtensionAPI): void {\n\tcreateHerdrExtension()(pi);\n}\n"]}
|
|
@@ -30,6 +30,7 @@ export interface LlamaModelsResponse {
|
|
|
30
30
|
}
|
|
31
31
|
export interface LlamaServerProps {
|
|
32
32
|
models_autoload?: boolean;
|
|
33
|
+
chat_template?: string;
|
|
33
34
|
}
|
|
34
35
|
export interface LlamaModelEvent {
|
|
35
36
|
model: string;
|
|
@@ -54,6 +55,7 @@ export declare class LlamaClient {
|
|
|
54
55
|
signal?: AbortSignal;
|
|
55
56
|
}): Promise<LlamaModelInfo[]>;
|
|
56
57
|
props(options?: {
|
|
58
|
+
model?: string;
|
|
57
59
|
signal?: AbortSignal;
|
|
58
60
|
}): Promise<LlamaServerProps>;
|
|
59
61
|
load(model: string, signal?: AbortSignal): Promise<void>;
|