@bastani/atomic 0.7.17 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4200 -0
- package/README.md +655 -0
- package/dist/builtin/intercom/CHANGELOG.md +195 -0
- package/dist/builtin/intercom/LICENSE +21 -0
- package/dist/builtin/intercom/README.md +484 -0
- package/dist/builtin/intercom/broker/broker.ts +346 -0
- package/dist/builtin/intercom/broker/client.ts +535 -0
- package/dist/builtin/intercom/broker/framing.ts +57 -0
- package/dist/builtin/intercom/broker/paths.ts +21 -0
- package/dist/builtin/intercom/broker/spawn.ts +308 -0
- package/dist/builtin/intercom/config.ts +109 -0
- package/dist/builtin/intercom/index.ts +1780 -0
- package/dist/builtin/intercom/package.json +59 -0
- package/dist/builtin/intercom/reply-tracker.ts +102 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +513 -0
- package/dist/builtin/intercom/types.ts +46 -0
- package/dist/builtin/intercom/ui/compose.ts +139 -0
- package/dist/builtin/intercom/ui/inline-message.ts +76 -0
- package/dist/builtin/intercom/ui/session-list.ts +162 -0
- package/dist/builtin/mcp/CHANGELOG.md +346 -0
- package/dist/builtin/mcp/LICENSE +21 -0
- package/dist/builtin/mcp/OAUTH.md +324 -0
- package/dist/builtin/mcp/README.md +373 -0
- package/dist/builtin/mcp/agent-dir.ts +21 -0
- package/dist/builtin/mcp/app-bridge.bundle.js +67 -0
- package/dist/builtin/mcp/cli.js +186 -0
- package/dist/builtin/mcp/commands.ts +420 -0
- package/dist/builtin/mcp/config.ts +667 -0
- package/dist/builtin/mcp/consent-manager.ts +64 -0
- package/dist/builtin/mcp/direct-tools.ts +427 -0
- package/dist/builtin/mcp/errors.ts +219 -0
- package/dist/builtin/mcp/glimpse-ui.ts +80 -0
- package/dist/builtin/mcp/host-html-template.ts +427 -0
- package/dist/builtin/mcp/index.ts +334 -0
- package/dist/builtin/mcp/init.ts +336 -0
- package/dist/builtin/mcp/lifecycle.ts +93 -0
- package/dist/builtin/mcp/logger.ts +169 -0
- package/dist/builtin/mcp/mcp-auth-flow.ts +362 -0
- package/dist/builtin/mcp/mcp-auth.ts +297 -0
- package/dist/builtin/mcp/mcp-callback-server.ts +284 -0
- package/dist/builtin/mcp/mcp-oauth-provider.ts +302 -0
- package/dist/builtin/mcp/mcp-panel.ts +826 -0
- package/dist/builtin/mcp/mcp-setup-panel.ts +577 -0
- package/dist/builtin/mcp/metadata-cache.ts +201 -0
- package/dist/builtin/mcp/npx-resolver.ts +424 -0
- package/dist/builtin/mcp/oauth-handler.ts +60 -0
- package/dist/builtin/mcp/onboarding-state.ts +68 -0
- package/dist/builtin/mcp/package.json +61 -0
- package/dist/builtin/mcp/proxy-modes.ts +803 -0
- package/dist/builtin/mcp/resource-tools.ts +17 -0
- package/dist/builtin/mcp/sampling-handler.ts +268 -0
- package/dist/builtin/mcp/server-manager.ts +375 -0
- package/dist/builtin/mcp/state.ts +41 -0
- package/dist/builtin/mcp/tool-metadata.ts +152 -0
- package/dist/builtin/mcp/tool-registrar.ts +46 -0
- package/dist/builtin/mcp/tool-result-renderer.ts +65 -0
- package/dist/builtin/mcp/types.ts +441 -0
- package/dist/builtin/mcp/ui-resource-handler.ts +145 -0
- package/dist/builtin/mcp/ui-server.ts +623 -0
- package/dist/builtin/mcp/ui-session.ts +384 -0
- package/dist/builtin/mcp/ui-stream-types.ts +89 -0
- package/dist/builtin/mcp/utils.ts +129 -0
- package/dist/builtin/subagents/CHANGELOG.md +1019 -0
- package/dist/builtin/subagents/README.md +991 -0
- package/dist/builtin/subagents/agents/code-simplifier.md +84 -0
- package/dist/builtin/subagents/agents/codebase-analyzer.md +158 -0
- package/dist/builtin/subagents/agents/codebase-locator.md +113 -0
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +317 -0
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +236 -0
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +181 -0
- package/dist/builtin/subagents/agents/codebase-research-locator.md +146 -0
- package/dist/builtin/subagents/agents/debugger.md +92 -0
- package/dist/builtin/subagents/package.json +67 -0
- package/dist/builtin/subagents/prompts/gather-context-and-clarify.md +20 -0
- package/dist/builtin/subagents/prompts/parallel-cleanup.md +60 -0
- package/dist/builtin/subagents/prompts/parallel-context-build.md +55 -0
- package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +77 -0
- package/dist/builtin/subagents/prompts/parallel-research.md +58 -0
- package/dist/builtin/subagents/prompts/parallel-review.md +52 -0
- package/dist/builtin/subagents/prompts/review-loop.md +48 -0
- package/dist/builtin/subagents/skills/subagent/SKILL.md +734 -0
- package/dist/builtin/subagents/src/agents/agent-management.ts +644 -0
- package/dist/builtin/subagents/src/agents/agent-scope.ts +6 -0
- package/dist/builtin/subagents/src/agents/agent-selection.ts +23 -0
- package/dist/builtin/subagents/src/agents/agent-serializer.ts +84 -0
- package/dist/builtin/subagents/src/agents/agents.ts +809 -0
- package/dist/builtin/subagents/src/agents/chain-serializer.ts +137 -0
- package/dist/builtin/subagents/src/agents/frontmatter.ts +29 -0
- package/dist/builtin/subagents/src/agents/identity.ts +30 -0
- package/dist/builtin/subagents/src/agents/skills.ts +630 -0
- package/dist/builtin/subagents/src/extension/control-notices.ts +92 -0
- package/dist/builtin/subagents/src/extension/doctor.ts +199 -0
- package/dist/builtin/subagents/src/extension/index.ts +586 -0
- package/dist/builtin/subagents/src/extension/schemas.ts +168 -0
- package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +378 -0
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +269 -0
- package/dist/builtin/subagents/src/runs/background/async-execution.ts +612 -0
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +267 -0
- package/dist/builtin/subagents/src/runs/background/async-resume.ts +332 -0
- package/dist/builtin/subagents/src/runs/background/async-status.ts +295 -0
- package/dist/builtin/subagents/src/runs/background/completion-dedupe.ts +63 -0
- package/dist/builtin/subagents/src/runs/background/notify.ts +108 -0
- package/dist/builtin/subagents/src/runs/background/parallel-groups.ts +45 -0
- package/dist/builtin/subagents/src/runs/background/result-watcher.ts +250 -0
- package/dist/builtin/subagents/src/runs/background/run-status.ts +193 -0
- package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +291 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +1760 -0
- package/dist/builtin/subagents/src/runs/background/top-level-async.ts +13 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify.ts +1333 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +932 -0
- package/dist/builtin/subagents/src/runs/foreground/execution.ts +902 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +2231 -0
- package/dist/builtin/subagents/src/runs/shared/completion-guard.ts +125 -0
- package/dist/builtin/subagents/src/runs/shared/long-running-guard.ts +175 -0
- package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +103 -0
- package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +108 -0
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +163 -0
- package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +115 -0
- package/dist/builtin/subagents/src/runs/shared/run-history.ts +56 -0
- package/dist/builtin/subagents/src/runs/shared/single-output.ts +154 -0
- package/dist/builtin/subagents/src/runs/shared/subagent-control.ts +226 -0
- package/dist/builtin/subagents/src/runs/shared/subagent-prompt-runtime.ts +152 -0
- package/dist/builtin/subagents/src/runs/shared/worktree.ts +577 -0
- package/dist/builtin/subagents/src/shared/artifacts.ts +99 -0
- package/dist/builtin/subagents/src/shared/atomic-json.ts +16 -0
- package/dist/builtin/subagents/src/shared/file-coalescer.ts +40 -0
- package/dist/builtin/subagents/src/shared/fork-context.ts +76 -0
- package/dist/builtin/subagents/src/shared/formatters.ts +133 -0
- package/dist/builtin/subagents/src/shared/jsonl-writer.ts +81 -0
- package/dist/builtin/subagents/src/shared/model-info.ts +78 -0
- package/dist/builtin/subagents/src/shared/post-exit-stdio-guard.ts +85 -0
- package/dist/builtin/subagents/src/shared/session-identity.ts +10 -0
- package/dist/builtin/subagents/src/shared/session-tokens.ts +44 -0
- package/dist/builtin/subagents/src/shared/settings.ts +397 -0
- package/dist/builtin/subagents/src/shared/status-format.ts +49 -0
- package/dist/builtin/subagents/src/shared/types.ts +732 -0
- package/dist/builtin/subagents/src/shared/utils.ts +440 -0
- package/dist/builtin/subagents/src/slash/prompt-template-bridge.ts +397 -0
- package/dist/builtin/subagents/src/slash/slash-bridge.ts +174 -0
- package/dist/builtin/subagents/src/slash/slash-commands.ts +528 -0
- package/dist/builtin/subagents/src/slash/slash-live-state.ts +292 -0
- package/dist/builtin/subagents/src/tui/render-helpers.ts +80 -0
- package/dist/builtin/subagents/src/tui/render.ts +1257 -0
- package/dist/builtin/web-access/CHANGELOG.md +387 -0
- package/dist/builtin/web-access/LICENSE +21 -0
- package/dist/builtin/web-access/README.md +346 -0
- package/dist/builtin/web-access/activity.ts +101 -0
- package/dist/builtin/web-access/chrome-cookies.ts +322 -0
- package/dist/builtin/web-access/code-search.ts +107 -0
- package/dist/builtin/web-access/curator-page.ts +3359 -0
- package/dist/builtin/web-access/curator-server.ts +605 -0
- package/dist/builtin/web-access/exa.ts +521 -0
- package/dist/builtin/web-access/extract.ts +701 -0
- package/dist/builtin/web-access/gemini-api.ts +113 -0
- package/dist/builtin/web-access/gemini-search.ts +362 -0
- package/dist/builtin/web-access/gemini-url-context.ts +126 -0
- package/dist/builtin/web-access/gemini-web-config.ts +54 -0
- package/dist/builtin/web-access/gemini-web.ts +396 -0
- package/dist/builtin/web-access/github-api.ts +196 -0
- package/dist/builtin/web-access/github-extract.ts +635 -0
- package/dist/builtin/web-access/index.ts +2347 -0
- package/dist/builtin/web-access/package.json +54 -0
- package/dist/builtin/web-access/pdf-extract.ts +192 -0
- package/dist/builtin/web-access/perplexity.ts +196 -0
- package/dist/builtin/web-access/rsc-extract.ts +338 -0
- package/dist/builtin/web-access/storage.ts +72 -0
- package/dist/builtin/web-access/summary-review.ts +276 -0
- package/dist/builtin/web-access/utils.ts +44 -0
- package/dist/builtin/web-access/video-extract.ts +379 -0
- package/dist/builtin/web-access/youtube-extract.ts +311 -0
- package/dist/builtin/workflows/CHANGELOG.md +20 -0
- package/dist/builtin/workflows/README.md +323 -0
- package/dist/builtin/workflows/builtin/deep-research-codebase.ts +567 -0
- package/dist/builtin/workflows/builtin/index.ts +10 -0
- package/dist/builtin/workflows/builtin/open-claude-design.ts +985 -0
- package/dist/builtin/workflows/builtin/ralph.ts +613 -0
- package/dist/builtin/workflows/package.json +89 -0
- package/dist/builtin/workflows/skills/create-spec/SKILL.md +247 -0
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +173 -0
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +190 -0
- package/dist/builtin/workflows/skills/impeccable/reference/animate.md +175 -0
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +133 -0
- package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +113 -0
- package/dist/builtin/workflows/skills/impeccable/reference/brand.md +118 -0
- package/dist/builtin/workflows/skills/impeccable/reference/clarify.md +174 -0
- package/dist/builtin/workflows/skills/impeccable/reference/codex.md +105 -0
- package/dist/builtin/workflows/skills/impeccable/reference/cognitive-load.md +106 -0
- package/dist/builtin/workflows/skills/impeccable/reference/color-and-contrast.md +105 -0
- package/dist/builtin/workflows/skills/impeccable/reference/colorize.md +154 -0
- package/dist/builtin/workflows/skills/impeccable/reference/craft.md +123 -0
- package/dist/builtin/workflows/skills/impeccable/reference/critique.md +261 -0
- package/dist/builtin/workflows/skills/impeccable/reference/delight.md +302 -0
- package/dist/builtin/workflows/skills/impeccable/reference/distill.md +111 -0
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +427 -0
- package/dist/builtin/workflows/skills/impeccable/reference/extract.md +69 -0
- package/dist/builtin/workflows/skills/impeccable/reference/harden.md +347 -0
- package/dist/builtin/workflows/skills/impeccable/reference/heuristics-scoring.md +234 -0
- package/dist/builtin/workflows/skills/impeccable/reference/interaction-design.md +195 -0
- package/dist/builtin/workflows/skills/impeccable/reference/layout.md +141 -0
- package/dist/builtin/workflows/skills/impeccable/reference/live.md +622 -0
- package/dist/builtin/workflows/skills/impeccable/reference/motion-design.md +109 -0
- package/dist/builtin/workflows/skills/impeccable/reference/onboard.md +234 -0
- package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +258 -0
- package/dist/builtin/workflows/skills/impeccable/reference/overdrive.md +130 -0
- package/dist/builtin/workflows/skills/impeccable/reference/personas.md +179 -0
- package/dist/builtin/workflows/skills/impeccable/reference/polish.md +242 -0
- package/dist/builtin/workflows/skills/impeccable/reference/product.md +62 -0
- package/dist/builtin/workflows/skills/impeccable/reference/quieter.md +99 -0
- package/dist/builtin/workflows/skills/impeccable/reference/responsive-design.md +114 -0
- package/dist/builtin/workflows/skills/impeccable/reference/shape.md +165 -0
- package/dist/builtin/workflows/skills/impeccable/reference/spatial-design.md +100 -0
- package/dist/builtin/workflows/skills/impeccable/reference/teach.md +156 -0
- package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +124 -0
- package/dist/builtin/workflows/skills/impeccable/reference/typography.md +159 -0
- package/dist/builtin/workflows/skills/impeccable/reference/ux-writing.md +107 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/cleanup-deprecated.mjs +284 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/command-metadata.json +94 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/critique-storage.mjs +226 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/design-parser.mjs +820 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detect-csp.mjs +198 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable-paths.mjs +110 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/is-generated.mjs +69 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +646 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +123 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +4865 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-complete.mjs +75 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-completion.mjs +18 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-inject.mjs +446 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-poll.mjs +200 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-resume.mjs +48 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +847 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-session-store.mjs +254 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-status.mjs +47 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +632 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/live.mjs +247 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/load-context.mjs +141 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/pin.mjs +214 -0
- package/dist/builtin/workflows/skills/playwright-cli/SKILL.md +392 -0
- package/dist/builtin/workflows/skills/playwright-cli/references/element-attributes.md +23 -0
- package/dist/builtin/workflows/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/dist/builtin/workflows/skills/playwright-cli/references/request-mocking.md +87 -0
- package/dist/builtin/workflows/skills/playwright-cli/references/running-code.md +241 -0
- package/dist/builtin/workflows/skills/playwright-cli/references/session-management.md +225 -0
- package/dist/builtin/workflows/skills/playwright-cli/references/spec-driven-testing.md +305 -0
- package/dist/builtin/workflows/skills/playwright-cli/references/storage-state.md +275 -0
- package/dist/builtin/workflows/skills/playwright-cli/references/test-generation.md +134 -0
- package/dist/builtin/workflows/skills/playwright-cli/references/tracing.md +139 -0
- package/dist/builtin/workflows/skills/playwright-cli/references/video-recording.md +143 -0
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +263 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +271 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/core_prompting.md +137 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +193 -0
- package/dist/builtin/workflows/skills/research-codebase/SKILL.md +226 -0
- package/dist/builtin/workflows/skills/tdd/SKILL.md +109 -0
- package/dist/builtin/workflows/skills/tdd/deep-modules.md +33 -0
- package/dist/builtin/workflows/skills/tdd/interface-design.md +31 -0
- package/dist/builtin/workflows/skills/tdd/mocking.md +59 -0
- package/dist/builtin/workflows/skills/tdd/refactoring.md +10 -0
- package/dist/builtin/workflows/skills/tdd/tests.md +61 -0
- package/dist/builtin/workflows/skills/workflow/SKILL.md +255 -0
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/advanced-evaluation.md +404 -0
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/bdi-mental-states.md +313 -0
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/context-compression.md +274 -0
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/context-degradation.md +208 -0
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/context-fundamentals.md +203 -0
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/context-optimization.md +197 -0
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/evaluation.md +253 -0
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/filesystem-context.md +289 -0
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/hosted-agents.md +262 -0
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/memory-systems.md +221 -0
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/multi-agent-patterns.md +259 -0
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/project-development.md +293 -0
- package/dist/builtin/workflows/skills/workflow/references/context-engineering/tool-design.md +273 -0
- package/dist/builtin/workflows/skills/workflow/references/context-engineering.md +23 -0
- package/dist/builtin/workflows/skills/workflow/references/design-checklist.md +79 -0
- package/dist/builtin/workflows/skills/workflow/references/running-workflows.md +107 -0
- package/dist/builtin/workflows/skills/workflow/references/sdk-authoring.md +140 -0
- package/dist/builtin/workflows/src/extension/background-ui-adapter.ts +168 -0
- package/dist/builtin/workflows/src/extension/companions.ts +210 -0
- package/dist/builtin/workflows/src/extension/config-loader.ts +493 -0
- package/dist/builtin/workflows/src/extension/discovery.ts +501 -0
- package/dist/builtin/workflows/src/extension/dispatcher.ts +173 -0
- package/dist/builtin/workflows/src/extension/index.ts +2143 -0
- package/dist/builtin/workflows/src/extension/mcp.ts +110 -0
- package/dist/builtin/workflows/src/extension/render-call.ts +39 -0
- package/dist/builtin/workflows/src/extension/render-result.ts +214 -0
- package/dist/builtin/workflows/src/extension/renderers.ts +87 -0
- package/dist/builtin/workflows/src/extension/runtime.ts +360 -0
- package/dist/builtin/workflows/src/extension/status-writer.ts +167 -0
- package/dist/builtin/workflows/src/extension/wiring.ts +555 -0
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +102 -0
- package/dist/builtin/workflows/src/index.ts +25 -0
- package/dist/builtin/workflows/src/intercom/intercom-bridge.ts +93 -0
- package/dist/builtin/workflows/src/intercom/intercom-routing.ts +125 -0
- package/dist/builtin/workflows/src/intercom/result-intercom.ts +240 -0
- package/dist/builtin/workflows/src/runs/background/cancellation-registry.ts +113 -0
- package/dist/builtin/workflows/src/runs/background/job-tracker.ts +81 -0
- package/dist/builtin/workflows/src/runs/background/runner.ts +152 -0
- package/dist/builtin/workflows/src/runs/background/status.ts +354 -0
- package/dist/builtin/workflows/src/runs/foreground/executor.ts +1522 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +233 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +712 -0
- package/dist/builtin/workflows/src/runs/shared/concurrency.ts +76 -0
- package/dist/builtin/workflows/src/runs/shared/graph-inference.ts +69 -0
- package/dist/builtin/workflows/src/runs/shared/model-fallback.ts +293 -0
- package/dist/builtin/workflows/src/runs/shared/validate-inputs.ts +83 -0
- package/dist/builtin/workflows/src/runs/shared/workflow-runner.ts +170 -0
- package/dist/builtin/workflows/src/runs/shared/worktree.ts +577 -0
- package/dist/builtin/workflows/src/shared/persistence-compaction-policy.ts +72 -0
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +257 -0
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +145 -0
- package/dist/builtin/workflows/src/shared/render-inputs-schema.ts +196 -0
- package/dist/builtin/workflows/src/shared/store-types.ts +160 -0
- package/dist/builtin/workflows/src/shared/store.ts +579 -0
- package/dist/builtin/workflows/src/shared/types.ts +566 -0
- package/dist/builtin/workflows/src/tui/chat-surface-message.ts +224 -0
- package/dist/builtin/workflows/src/tui/chat-surface.ts +511 -0
- package/dist/builtin/workflows/src/tui/color-utils.ts +64 -0
- package/dist/builtin/workflows/src/tui/connectors.ts +88 -0
- package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +307 -0
- package/dist/builtin/workflows/src/tui/edge.ts +24 -0
- package/dist/builtin/workflows/src/tui/graph-canvas.ts +108 -0
- package/dist/builtin/workflows/src/tui/graph-theme.ts +283 -0
- package/dist/builtin/workflows/src/tui/graph-view.ts +1217 -0
- package/dist/builtin/workflows/src/tui/header.ts +172 -0
- package/dist/builtin/workflows/src/tui/inline-form-card.ts +421 -0
- package/dist/builtin/workflows/src/tui/inline-form-editor.ts +638 -0
- package/dist/builtin/workflows/src/tui/inline-form-overlay.ts +326 -0
- package/dist/builtin/workflows/src/tui/inline-form-store.ts +78 -0
- package/dist/builtin/workflows/src/tui/inputs-overlay.ts +163 -0
- package/dist/builtin/workflows/src/tui/inputs-picker.ts +888 -0
- package/dist/builtin/workflows/src/tui/keybindings-adapter.ts +154 -0
- package/dist/builtin/workflows/src/tui/layout.ts +153 -0
- package/dist/builtin/workflows/src/tui/node-card.ts +274 -0
- package/dist/builtin/workflows/src/tui/overlay-adapter.ts +277 -0
- package/dist/builtin/workflows/src/tui/prompt-card.ts +501 -0
- package/dist/builtin/workflows/src/tui/renderers.ts +15 -0
- package/dist/builtin/workflows/src/tui/run-detail.ts +339 -0
- package/dist/builtin/workflows/src/tui/session-confirm.ts +202 -0
- package/dist/builtin/workflows/src/tui/session-list.ts +32 -0
- package/dist/builtin/workflows/src/tui/session-overlays.ts +239 -0
- package/dist/builtin/workflows/src/tui/session-picker.ts +399 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +1873 -0
- package/dist/builtin/workflows/src/tui/status-helpers.ts +73 -0
- package/dist/builtin/workflows/src/tui/status-list.ts +361 -0
- package/dist/builtin/workflows/src/tui/store-widget-installer.ts +206 -0
- package/dist/builtin/workflows/src/tui/switcher.ts +121 -0
- package/dist/builtin/workflows/src/tui/text-helpers.ts +31 -0
- package/dist/builtin/workflows/src/tui/toast.ts +106 -0
- package/dist/builtin/workflows/src/tui/widget.ts +348 -0
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +285 -0
- package/dist/builtin/workflows/src/tui/workflow-list.ts +224 -0
- package/dist/builtin/workflows/src/workflows/define-workflow.ts +150 -0
- package/dist/builtin/workflows/src/workflows/identity.ts +39 -0
- package/dist/builtin/workflows/src/workflows/registry.ts +113 -0
- package/dist/bun/cli.d.ts +3 -0
- package/dist/bun/cli.d.ts.map +1 -0
- package/dist/bun/cli.js +9 -0
- package/dist/bun/cli.js.map +1 -0
- package/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/bun/register-bedrock.d.ts.map +1 -0
- package/dist/bun/register-bedrock.js +4 -0
- package/dist/bun/register-bedrock.js.map +1 -0
- package/dist/bun/restore-sandbox-env.d.ts +13 -0
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
- package/dist/bun/restore-sandbox-env.js +32 -0
- package/dist/bun/restore-sandbox-env.js.map +1 -0
- package/dist/cli/args.d.ts +53 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +341 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +83 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/initial-message.d.ts +18 -0
- package/dist/cli/initial-message.d.ts.map +1 -0
- package/dist/cli/initial-message.js +22 -0
- package/dist/cli/initial-message.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +98 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +35 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +20 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +102 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +411 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +117 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -0
- package/dist/core/agent-session-runtime.js +292 -0
- package/dist/core/agent-session-runtime.js.map +1 -0
- package/dist/core/agent-session-services.d.ts +86 -0
- package/dist/core/agent-session-services.d.ts.map +1 -0
- package/dist/core/agent-session-services.js +117 -0
- package/dist/core/agent-session-services.js.map +1 -0
- package/dist/core/agent-session.d.ts +595 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +2518 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-guidance.d.ts +5 -0
- package/dist/core/auth-guidance.d.ts.map +1 -0
- package/dist/core/auth-guidance.js +21 -0
- package/dist/core/auth-guidance.js.map +1 -0
- package/dist/core/auth-storage.d.ts +141 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +437 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +32 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +111 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/builtin-packages.d.ts +14 -0
- package/dist/core/builtin-packages.d.ts.map +1 -0
- package/dist/core/builtin-packages.js +113 -0
- package/dist/core/builtin-packages.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +88 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +243 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +121 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +615 -0
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/dist/core/compaction/index.d.ts.map +1 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/index.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +38 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +153 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +75 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +37 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +224 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +1066 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +1834 -0
- package/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +108 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +6 -0
- package/dist/core/extensions/index.d.ts +12 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/index.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +24 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +501 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +159 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +817 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1173 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +45 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +22 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +52 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +309 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/index.d.ts +12 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +12 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/keybindings.d.ts +353 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +294 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/messages.d.ts +77 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +123 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +150 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +726 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +110 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +493 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/output-guard.d.ts +6 -0
- package/dist/core/output-guard.d.ts.map +1 -0
- package/dist/core/output-guard.js +59 -0
- package/dist/core/output-guard.js.map +1 -0
- package/dist/core/package-manager.d.ts +198 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +1970 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +52 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +250 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/provider-display-names.d.ts +2 -0
- package/dist/core/provider-display-names.d.ts.map +1 -0
- package/dist/core/provider-display-names.js +33 -0
- package/dist/core/provider-display-names.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +23 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +126 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +196 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +698 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/sdk.d.ts +107 -0
- package/dist/core/sdk.d.ts.map +1 -0
- package/dist/core/sdk.js +291 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/session-cwd.d.ts +19 -0
- package/dist/core/session-cwd.d.ts.map +1 -0
- package/dist/core/session-cwd.js +37 -0
- package/dist/core/session-cwd.js.map +1 -0
- package/dist/core/session-manager.d.ts +333 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +1118 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +261 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +773 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +60 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +404 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +14 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +25 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/source-info.d.ts +18 -0
- package/dist/core/source-info.d.ts.map +1 -0
- package/dist/core/source-info.js +19 -0
- package/dist/core/source-info.js.map +1 -0
- package/dist/core/system-prompt.d.ts +28 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +120 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/telemetry.d.ts +3 -0
- package/dist/core/telemetry.d.ts.map +1 -0
- package/dist/core/telemetry.js +10 -0
- package/dist/core/telemetry.js.map +1 -0
- package/dist/core/timings.d.ts +8 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +32 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts +10 -0
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/ask-user-question.js +82 -0
- package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -0
- package/dist/core/tools/ask-user-question/config.d.ts +11 -0
- package/dist/core/tools/ask-user-question/config.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/config.js +34 -0
- package/dist/core/tools/ask-user-question/config.js.map +1 -0
- package/dist/core/tools/ask-user-question/index.d.ts +19 -0
- package/dist/core/tools/ask-user-question/index.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/index.js +19 -0
- package/dist/core/tools/ask-user-question/index.js.map +1 -0
- package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts +36 -0
- package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js +213 -0
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -0
- package/dist/core/tools/ask-user-question/state/key-router.d.ts +53 -0
- package/dist/core/tools/ask-user-question/state/key-router.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/state/key-router.js +240 -0
- package/dist/core/tools/ask-user-question/state/key-router.js.map +1 -0
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts +61 -0
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js +147 -0
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -0
- package/dist/core/tools/ask-user-question/state/row-intent.d.ts +91 -0
- package/dist/core/tools/ask-user-question/state/row-intent.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/state/row-intent.js +91 -0
- package/dist/core/tools/ask-user-question/state/row-intent.js.map +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/contract.d.ts +21 -0
- package/dist/core/tools/ask-user-question/state/selectors/contract.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/contract.js +2 -0
- package/dist/core/tools/ask-user-question/state/selectors/contract.js.map +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/derivations.d.ts +44 -0
- package/dist/core/tools/ask-user-question/state/selectors/derivations.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/derivations.js +76 -0
- package/dist/core/tools/ask-user-question/state/selectors/derivations.js.map +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/focus.d.ts +15 -0
- package/dist/core/tools/ask-user-question/state/selectors/focus.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/focus.js +18 -0
- package/dist/core/tools/ask-user-question/state/selectors/focus.js.map +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts +16 -0
- package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/projections.js +71 -0
- package/dist/core/tools/ask-user-question/state/selectors/projections.js.map +1 -0
- package/dist/core/tools/ask-user-question/state/state-reducer.d.ts +44 -0
- package/dist/core/tools/ask-user-question/state/state-reducer.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/state/state-reducer.js +239 -0
- package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -0
- package/dist/core/tools/ask-user-question/state/state.d.ts +42 -0
- package/dist/core/tools/ask-user-question/state/state.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/state/state.js +2 -0
- package/dist/core/tools/ask-user-question/state/state.js.map +1 -0
- package/dist/core/tools/ask-user-question/tool/format-answer.d.ts +30 -0
- package/dist/core/tools/ask-user-question/tool/format-answer.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/tool/format-answer.js +39 -0
- package/dist/core/tools/ask-user-question/tool/format-answer.js.map +1 -0
- package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts +29 -0
- package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/tool/response-envelope.js +46 -0
- package/dist/core/tools/ask-user-question/tool/response-envelope.js.map +1 -0
- package/dist/core/tools/ask-user-question/tool/types.d.ts +113 -0
- package/dist/core/tools/ask-user-question/tool/types.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/tool/types.js +81 -0
- package/dist/core/tools/ask-user-question/tool/types.js.map +1 -0
- package/dist/core/tools/ask-user-question/tool/validate-questionnaire.d.ts +21 -0
- package/dist/core/tools/ask-user-question/tool/validate-questionnaire.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/tool/validate-questionnaire.js +49 -0
- package/dist/core/tools/ask-user-question/tool/validate-questionnaire.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/body-residual-spacer.d.ts +18 -0
- package/dist/core/tools/ask-user-question/view/body-residual-spacer.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/body-residual-spacer.js +21 -0
- package/dist/core/tools/ask-user-question/view/body-residual-spacer.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/component-binding.d.ts +23 -0
- package/dist/core/tools/ask-user-question/view/component-binding.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/component-binding.js +16 -0
- package/dist/core/tools/ask-user-question/view/component-binding.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/chat-row-view.d.ts +40 -0
- package/dist/core/tools/ask-user-question/view/components/chat-row-view.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/chat-row-view.js +31 -0
- package/dist/core/tools/ask-user-question/view/components/chat-row-view.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts +35 -0
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js +91 -0
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/option-list-view.d.ts +43 -0
- package/dist/core/tools/ask-user-question/view/components/option-list-view.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/option-list-view.js +37 -0
- package/dist/core/tools/ask-user-question/view/components/option-list-view.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts +36 -0
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js +66 -0
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +46 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js +69 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-box-renderer.d.ts +39 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-box-renderer.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-box-renderer.js +76 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-box-renderer.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.d.ts +116 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.js +173 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-layout-decider.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts +66 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js +124 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/submit-picker.d.ts +37 -0
- package/dist/core/tools/ask-user-question/view/components/submit-picker.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/submit-picker.js +44 -0
- package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/tab-bar.d.ts +32 -0
- package/dist/core/tools/ask-user-question/view/components/tab-bar.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/tab-bar.js +33 -0
- package/dist/core/tools/ask-user-question/view/components/tab-bar.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts +122 -0
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js +161 -0
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts +66 -0
- package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/dialog-builder.js +85 -0
- package/dist/core/tools/ask-user-question/view/dialog-builder.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/props-adapter.d.ts +58 -0
- package/dist/core/tools/ask-user-question/view/props-adapter.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/props-adapter.js +67 -0
- package/dist/core/tools/ask-user-question/view/props-adapter.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/stateful-view.d.ts +24 -0
- package/dist/core/tools/ask-user-question/view/stateful-view.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/stateful-view.js +2 -0
- package/dist/core/tools/ask-user-question/view/stateful-view.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/tab-components.d.ts +15 -0
- package/dist/core/tools/ask-user-question/view/tab-components.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/tab-components.js +2 -0
- package/dist/core/tools/ask-user-question/view/tab-components.js.map +1 -0
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts +71 -0
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js +129 -0
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -0
- package/dist/core/tools/bash.d.ts +68 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +338 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +85 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +338 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +49 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +324 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-queue.js +37 -0
- package/dist/core/tools/file-mutation-queue.js.map +1 -0
- package/dist/core/tools/find.d.ts +35 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +298 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +37 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +304 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/index.d.ts +42 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +139 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +37 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +169 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/output-accumulator.d.ts +50 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -0
- package/dist/core/tools/output-accumulator.js +172 -0
- package/dist/core/tools/output-accumulator.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +8 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +81 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +35 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +289 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/render-utils.d.ts +21 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -0
- package/dist/core/tools/render-utils.js +49 -0
- package/dist/core/tools/render-utils.js.map +1 -0
- package/dist/core/tools/todos.d.ts +35 -0
- package/dist/core/tools/todos.d.ts.map +1 -0
- package/dist/core/tools/todos.js +906 -0
- package/dist/core/tools/todos.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.js +34 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +70 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +205 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/write.d.ts +26 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +212 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +13 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +586 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +33 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +281 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/index.d.ts +9 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/interactive/assets/clankolas.png +3 -0
- package/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -0
- package/dist/modes/interactive/components/armin.js +329 -0
- package/dist/modes/interactive/components/armin.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +20 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +116 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +34 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +170 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +51 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +42 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +43 -0
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +496 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +28 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +29 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +113 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +74 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
- package/dist/modes/interactive/components/daxnuts.js +138 -0
- package/dist/modes/interactive/components/daxnuts.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +151 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +20 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
- package/dist/modes/interactive/components/earendil-announcement.js +40 -0
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +20 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +106 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +55 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +26 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +75 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +27 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +199 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +32 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +33 -0
- package/dist/modes/interactive/components/index.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +36 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +46 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +158 -0
- package/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +47 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +266 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +31 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +156 -0
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +286 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +96 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +836 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +67 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +371 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +38 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +45 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +48 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +50 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +63 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +280 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +89 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +1079 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +111 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +10 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +28 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +369 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +4709 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/theme/catppuccin-frappe.json +90 -0
- package/dist/modes/interactive/theme/catppuccin-latte.json +90 -0
- package/dist/modes/interactive/theme/catppuccin-macchiato.json +90 -0
- package/dist/modes/interactive/theme/catppuccin-mocha.json +90 -0
- package/dist/modes/interactive/theme/dark.json +85 -0
- package/dist/modes/interactive/theme/light.json +84 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.d.ts +81 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +970 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/interactive/whimsical-messages.d.ts +5 -0
- package/dist/modes/interactive/whimsical-messages.d.ts.map +1 -0
- package/dist/modes/interactive/whimsical-messages.js +464 -0
- package/dist/modes/interactive/whimsical-messages.js.map +1 -0
- package/dist/modes/print-mode.d.ts +28 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +131 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/modes/rpc/jsonl.d.ts.map +1 -0
- package/dist/modes/rpc/jsonl.js +49 -0
- package/dist/modes/rpc/jsonl.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +224 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +409 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +601 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +419 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/package-manager-cli.d.ts +4 -0
- package/dist/package-manager-cli.d.ts.map +1 -0
- package/dist/package-manager-cli.js +460 -0
- package/dist/package-manager-cli.js.map +1 -0
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +52 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/changelog.d.ts +21 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +87 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/child-process.d.ts +12 -0
- package/dist/utils/child-process.d.ts.map +1 -0
- package/dist/utils/child-process.js +86 -0
- package/dist/utils/child-process.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +245 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +8 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +14 -0
- package/dist/utils/clipboard-native.js.map +1 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +117 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +5 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -0
- package/dist/utils/exif-orientation.js +158 -0
- package/dist/utils/exif-orientation.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/fs-watch.d.ts +5 -0
- package/dist/utils/fs-watch.d.ts.map +1 -0
- package/dist/utils/fs-watch.js +25 -0
- package/dist/utils/fs-watch.js.map +1 -0
- package/dist/utils/git.d.ts +26 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +163 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/html.d.ts +7 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +40 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/image-convert.d.ts +9 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +39 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-resize.d.ts +36 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +137 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/mime.d.ts +3 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +69 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/paths.d.ts +16 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +50 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/photon.d.ts +21 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/utils/pi-user-agent.d.ts.map +1 -0
- package/dist/utils/pi-user-agent.js +5 -0
- package/dist/utils/pi-user-agent.js.map +1 -0
- package/dist/utils/shell.d.ts +30 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +190 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -0
- package/dist/utils/syntax-highlight.js +118 -0
- package/dist/utils/syntax-highlight.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +325 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/dist/utils/version-check.d.ts +14 -0
- package/dist/utils/version-check.d.ts.map +1 -0
- package/dist/utils/version-check.js +76 -0
- package/dist/utils/version-check.js.map +1 -0
- package/docs/compaction.md +394 -0
- package/docs/custom-provider.md +646 -0
- package/docs/development.md +71 -0
- package/docs/docs.json +148 -0
- package/docs/extensions.md +2596 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +3 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/index.md +70 -0
- package/docs/json.md +82 -0
- package/docs/keybindings.md +197 -0
- package/docs/models.md +474 -0
- package/docs/packages.md +223 -0
- package/docs/prompt-templates.md +88 -0
- package/docs/providers.md +243 -0
- package/docs/quickstart.md +142 -0
- package/docs/rpc.md +1407 -0
- package/docs/sdk.md +1129 -0
- package/docs/session-format.md +412 -0
- package/docs/sessions.md +137 -0
- package/docs/settings.md +279 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +232 -0
- package/docs/terminal-setup.md +106 -0
- package/docs/termux.md +127 -0
- package/docs/themes.md +299 -0
- package/docs/tmux.md +61 -0
- package/docs/tui.md +918 -0
- package/docs/usage.md +277 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +25 -0
- package/examples/extensions/README.md +208 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/border-status-editor.ts +150 -0
- package/examples/extensions/built-in-tool-renderer.ts +249 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +127 -0
- package/examples/extensions/custom-footer.ts +64 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +349 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/examples/extensions/handoff.ts +191 -0
- package/examples/extensions/hello.ts +26 -0
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +426 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +1348 -0
- package/examples/extensions/overlay-test.ts +150 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +65 -0
- package/examples/extensions/plan-mode/index.ts +340 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +430 -0
- package/examples/extensions/prompt-customizer.ts +97 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/provider-payload.ts +18 -0
- package/examples/extensions/qna.ts +122 -0
- package/examples/extensions/question.ts +264 -0
- package/examples/extensions/questionnaire.ts +427 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +118 -0
- package/examples/extensions/sandbox/index.ts +321 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +32 -0
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/README.md +172 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +126 -0
- package/examples/extensions/subagent/index.ts +987 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +206 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/tic-tac-toe.ts +1008 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +297 -0
- package/examples/extensions/tool-override.ts +144 -0
- package/examples/extensions/tools.ts +141 -0
- package/examples/extensions/trigger-compact.ts +50 -0
- package/examples/extensions/truncated-tool.ts +195 -0
- package/examples/extensions/widget-placement.ts +9 -0
- package/examples/extensions/with-deps/index.ts +32 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/extensions/working-indicator.ts +123 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/rpc-extension-ui.ts +632 -0
- package/examples/sdk/01-minimal.ts +26 -0
- package/examples/sdk/02-custom-model.ts +53 -0
- package/examples/sdk/03-custom-prompt.ts +75 -0
- package/examples/sdk/04-skills.ts +55 -0
- package/examples/sdk/05-tools.ts +48 -0
- package/examples/sdk/06-extensions.ts +99 -0
- package/examples/sdk/07-context-files.ts +47 -0
- package/examples/sdk/08-prompt-templates.ts +51 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +52 -0
- package/examples/sdk/10-settings.ts +53 -0
- package/examples/sdk/11-sessions.ts +52 -0
- package/examples/sdk/12-full-control.ts +77 -0
- package/examples/sdk/13-session-runtime.ts +67 -0
- package/examples/sdk/README.md +144 -0
- package/package.json +94 -19
- package/bin/atomic +0 -82
- /package/{LICENSE → dist/builtin/workflows/LICENSE} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todos.js","sourceRoot":"","sources":["../../../src/core/tools/todos.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;A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AC,CAAC,OAAO,CAAC,MAAM,KAAK,QAAQ;oBAC5B,CAAC,CAAC,SAAS;oBACX,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,QAAQ;wBAC5B,CAAC,CAAC,aAAa;wBACf,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,QAAQ;4BAC5B,CAAC,CAAC,SAAS;4BACX,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,OAAO;gCAC3B,CAAC,CAAC,SAAS;gCACX,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS;oCAC7B,CAAC,CAAC,UAAU;oCACZ,CAAC,CAAC,IAAI,CAAC;YACd,IAAI,WAAW,EAAE,CAAC;gBACjB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC/B,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,WAAW,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACvF,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;YACD,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACf,IAAI,GAAG,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACtC,CAAC;YACD,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7B,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/**\n * This tool stores todo items as files under <todo-dir> (defaults to\n * <CONFIG_DIR_NAME>/todos, or the path in <APP_NAME>_TODO_PATH). Each todo is\n * a standalone markdown file named <id>.md and an optional <id>.lock file is\n * used while a session is editing it.\n *\n * File format in <CONFIG_DIR_NAME>/todos:\n * - The file starts with a JSON object (not YAML) containing the front matter:\n * { id, title, tags, status, created_at, assigned_to_session }\n * - After the JSON block comes optional markdown body text separated by a blank line.\n * - Example:\n * {\n * \"id\": \"deadbeef\",\n * \"title\": \"Add tests\",\n * \"tags\": [\"qa\"],\n * \"status\": \"open\",\n * \"created_at\": \"2026-01-25T17:00:00.000Z\",\n * \"assigned_to_session\": \"session.json\"\n * }\n *\n * Notes about the work go here.\n */\nimport { StringEnum } from \"@earendil-works/pi-ai\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport crypto from \"node:crypto\";\nimport { existsSync } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { Type } from \"typebox\";\nimport { APP_NAME, CONFIG_DIR_NAME } from \"../../config.js\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.js\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.js\";\n\nconst TODO_DIR_NAME = `${CONFIG_DIR_NAME}/todos`;\nconst TODO_PATH_ENV = `${APP_NAME.toUpperCase()}_TODO_PATH`;\nconst TODO_ID_PREFIX = \"TODO-\";\nconst TODO_ID_PATTERN = /^[a-f0-9]{8}$/i;\nconst LOCK_TTL_MS = 30 * 60 * 1000;\n\ninterface TodoFrontMatter {\n\tid: string;\n\ttitle: string;\n\ttags: string[];\n\tstatus: string;\n\tcreated_at: string;\n\tassigned_to_session?: string;\n}\n\ninterface TodoRecord extends TodoFrontMatter {\n\tbody: string;\n}\n\ninterface LockInfo {\n\tid: string;\n\tpid: number;\n\tsession?: string | null;\n\tcreated_at: string;\n}\n\nconst TodoParams = Type.Object({\n\taction: StringEnum([\n\t\t\"list\",\n\t\t\"list-all\",\n\t\t\"get\",\n\t\t\"create\",\n\t\t\"update\",\n\t\t\"append\",\n\t\t\"delete\",\n\t\t\"claim\",\n\t\t\"release\",\n\t] as const),\n\tid: Type.Optional(Type.String({ description: \"Todo id (TODO-<hex> or raw hex filename)\" })),\n\ttitle: Type.Optional(Type.String({ description: \"Short summary shown in lists\" })),\n\tstatus: Type.Optional(Type.String({ description: \"Todo status\" })),\n\ttags: Type.Optional(Type.Array(Type.String({ description: \"Todo tag\" }))),\n\tbody: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Long-form details (markdown). Update replaces; append adds.\",\n\t\t}),\n\t),\n\tforce: Type.Optional(Type.Boolean({ description: \"Override another session's assignment\" })),\n});\n\ntype TodoAction =\n\t| \"list\"\n\t| \"list-all\"\n\t| \"get\"\n\t| \"create\"\n\t| \"update\"\n\t| \"append\"\n\t| \"delete\"\n\t| \"claim\"\n\t| \"release\";\n\ntype TodoToolDetails =\n\t| {\n\t\t\taction: \"list\" | \"list-all\";\n\t\t\ttodos: TodoFrontMatter[];\n\t\t\tcurrentSessionId?: string;\n\t\t\terror?: string;\n\t }\n\t| {\n\t\t\taction: \"get\" | \"create\" | \"update\" | \"append\" | \"delete\" | \"claim\" | \"release\";\n\t\t\ttodo?: TodoRecord;\n\t\t\terror?: string;\n\t };\n\nfunction formatTodoId(id: string): string {\n\treturn `${TODO_ID_PREFIX}${id}`;\n}\n\nfunction normalizeTodoId(id: string): string {\n\tlet trimmed = id.trim();\n\tif (trimmed.startsWith(\"#\")) {\n\t\ttrimmed = trimmed.slice(1);\n\t}\n\tif (trimmed.toUpperCase().startsWith(TODO_ID_PREFIX)) {\n\t\ttrimmed = trimmed.slice(TODO_ID_PREFIX.length);\n\t}\n\treturn trimmed;\n}\n\nfunction validateTodoId(id: string): { id: string } | { error: string } {\n\tconst normalized = normalizeTodoId(id);\n\tif (!normalized || !TODO_ID_PATTERN.test(normalized)) {\n\t\treturn { error: \"Invalid todo id. Expected TODO-<hex>.\" };\n\t}\n\treturn { id: normalized.toLowerCase() };\n}\n\nfunction displayTodoId(id: string): string {\n\treturn formatTodoId(normalizeTodoId(id));\n}\n\nfunction isTodoClosed(status: string): boolean {\n\treturn [\"closed\", \"done\"].includes(status.toLowerCase());\n}\n\nfunction clearAssignmentIfClosed(todo: TodoFrontMatter): void {\n\tif (isTodoClosed(getTodoStatus(todo))) {\n\t\ttodo.assigned_to_session = undefined;\n\t}\n}\n\nfunction sortTodos(todos: TodoFrontMatter[]): TodoFrontMatter[] {\n\treturn [...todos].sort((a, b) => {\n\t\tconst aClosed = isTodoClosed(a.status);\n\t\tconst bClosed = isTodoClosed(b.status);\n\t\tif (aClosed !== bClosed) return aClosed ? 1 : -1;\n\t\tconst aAssigned = !aClosed && Boolean(a.assigned_to_session);\n\t\tconst bAssigned = !bClosed && Boolean(b.assigned_to_session);\n\t\tif (aAssigned !== bAssigned) return aAssigned ? -1 : 1;\n\t\treturn (a.created_at || \"\").localeCompare(b.created_at || \"\");\n\t});\n}\n\nfunction getTodosDir(cwd: string): string {\n\tconst overridePath = process.env[TODO_PATH_ENV];\n\tif (overridePath && overridePath.trim()) {\n\t\treturn path.resolve(cwd, overridePath.trim());\n\t}\n\treturn path.resolve(cwd, TODO_DIR_NAME);\n}\n\nfunction getTodosDirLabel(cwd: string): string {\n\tconst overridePath = process.env[TODO_PATH_ENV];\n\tif (overridePath && overridePath.trim()) {\n\t\treturn path.resolve(cwd, overridePath.trim());\n\t}\n\treturn TODO_DIR_NAME;\n}\n\nfunction getTodoPath(todosDir: string, id: string): string {\n\treturn path.join(todosDir, `${id}.md`);\n}\n\nfunction getLockPath(todosDir: string, id: string): string {\n\treturn path.join(todosDir, `${id}.lock`);\n}\n\nfunction parseFrontMatter(text: string, idFallback: string): TodoFrontMatter {\n\tconst data: TodoFrontMatter = {\n\t\tid: idFallback,\n\t\ttitle: \"\",\n\t\ttags: [],\n\t\tstatus: \"open\",\n\t\tcreated_at: \"\",\n\t\tassigned_to_session: undefined,\n\t};\n\n\tconst trimmed = text.trim();\n\tif (!trimmed) return data;\n\n\ttry {\n\t\tconst parsed = JSON.parse(trimmed) as Partial<TodoFrontMatter> | null;\n\t\tif (!parsed || typeof parsed !== \"object\") return data;\n\t\tif (typeof parsed.id === \"string\" && parsed.id) data.id = parsed.id;\n\t\tif (typeof parsed.title === \"string\") data.title = parsed.title;\n\t\tif (typeof parsed.status === \"string\" && parsed.status) data.status = parsed.status;\n\t\tif (typeof parsed.created_at === \"string\") data.created_at = parsed.created_at;\n\t\tif (\n\t\t\ttypeof parsed.assigned_to_session === \"string\" &&\n\t\t\tparsed.assigned_to_session.trim()\n\t\t) {\n\t\t\tdata.assigned_to_session = parsed.assigned_to_session;\n\t\t}\n\t\tif (Array.isArray(parsed.tags)) {\n\t\t\tdata.tags = parsed.tags.filter((tag): tag is string => typeof tag === \"string\");\n\t\t}\n\t} catch {\n\t\treturn data;\n\t}\n\n\treturn data;\n}\n\nfunction findJsonObjectEnd(content: string): number {\n\tlet depth = 0;\n\tlet inString = false;\n\tlet escaped = false;\n\n\tfor (let i = 0; i < content.length; i += 1) {\n\t\tconst char = content[i];\n\n\t\tif (inString) {\n\t\t\tif (escaped) {\n\t\t\t\tescaped = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (char === \"\\\\\") {\n\t\t\t\tescaped = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (char === '\"') {\n\t\t\t\tinString = false;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '\"') {\n\t\t\tinString = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tdepth += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"}\") {\n\t\t\tdepth -= 1;\n\t\t\tif (depth === 0) return i;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nfunction splitFrontMatter(content: string): { frontMatter: string; body: string } {\n\tif (!content.startsWith(\"{\")) {\n\t\treturn { frontMatter: \"\", body: content };\n\t}\n\n\tconst endIndex = findJsonObjectEnd(content);\n\tif (endIndex === -1) {\n\t\treturn { frontMatter: \"\", body: content };\n\t}\n\n\tconst frontMatter = content.slice(0, endIndex + 1);\n\tconst body = content.slice(endIndex + 1).replace(/^\\r?\\n+/, \"\");\n\treturn { frontMatter, body };\n}\n\nfunction parseTodoContent(content: string, idFallback: string): TodoRecord {\n\tconst { frontMatter, body } = splitFrontMatter(content);\n\tconst parsed = parseFrontMatter(frontMatter, idFallback);\n\treturn {\n\t\tid: idFallback,\n\t\ttitle: parsed.title,\n\t\ttags: parsed.tags ?? [],\n\t\tstatus: parsed.status,\n\t\tcreated_at: parsed.created_at,\n\t\tassigned_to_session: parsed.assigned_to_session,\n\t\tbody: body ?? \"\",\n\t};\n}\n\nfunction serializeTodo(todo: TodoRecord): string {\n\tconst frontMatter = JSON.stringify(\n\t\t{\n\t\t\tid: todo.id,\n\t\t\ttitle: todo.title,\n\t\t\ttags: todo.tags ?? [],\n\t\t\tstatus: todo.status,\n\t\t\tcreated_at: todo.created_at,\n\t\t\tassigned_to_session: todo.assigned_to_session || undefined,\n\t\t},\n\t\tnull,\n\t\t2,\n\t);\n\n\tconst body = todo.body ?? \"\";\n\tconst trimmedBody = body.replace(/^\\n+/, \"\").replace(/\\s+$/, \"\");\n\tif (!trimmedBody) return `${frontMatter}\\n`;\n\treturn `${frontMatter}\\n\\n${trimmedBody}\\n`;\n}\n\nasync function ensureTodosDir(todosDir: string) {\n\tawait fs.mkdir(todosDir, { recursive: true });\n}\n\nasync function readTodoFile(filePath: string, idFallback: string): Promise<TodoRecord> {\n\tconst content = await fs.readFile(filePath, \"utf8\");\n\treturn parseTodoContent(content, idFallback);\n}\n\nasync function writeTodoFile(filePath: string, todo: TodoRecord) {\n\tawait fs.writeFile(filePath, serializeTodo(todo), \"utf8\");\n}\n\nasync function generateTodoId(todosDir: string): Promise<string> {\n\tfor (let attempt = 0; attempt < 10; attempt += 1) {\n\t\tconst id = crypto.randomBytes(4).toString(\"hex\");\n\t\tconst todoPath = getTodoPath(todosDir, id);\n\t\tif (!existsSync(todoPath)) return id;\n\t}\n\tthrow new Error(\"Failed to generate unique todo id\");\n}\n\nasync function readLockInfo(lockPath: string): Promise<LockInfo | null> {\n\ttry {\n\t\tconst raw = await fs.readFile(lockPath, \"utf8\");\n\t\treturn JSON.parse(raw) as LockInfo;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nasync function acquireLock(\n\ttodosDir: string,\n\tid: string,\n\tctx: ExtensionContext,\n): Promise<(() => Promise<void>) | { error: string }> {\n\tconst lockPath = getLockPath(todosDir, id);\n\tconst now = Date.now();\n\tconst session = ctx.sessionManager.getSessionFile();\n\n\tfor (let attempt = 0; attempt < 2; attempt += 1) {\n\t\ttry {\n\t\t\tconst handle = await fs.open(lockPath, \"wx\");\n\t\t\tconst info: LockInfo = {\n\t\t\t\tid,\n\t\t\t\tpid: process.pid,\n\t\t\t\tsession,\n\t\t\t\tcreated_at: new Date(now).toISOString(),\n\t\t\t};\n\t\t\tawait handle.writeFile(JSON.stringify(info, null, 2), \"utf8\");\n\t\t\tawait handle.close();\n\t\t\treturn async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.unlink(lockPath);\n\t\t\t\t} catch {\n\t\t\t\t\t// ignore\n\t\t\t\t}\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconst fsError = error as { code?: string; message?: string };\n\t\t\tif (fsError.code !== \"EEXIST\") {\n\t\t\t\treturn {\n\t\t\t\t\terror: `Failed to acquire lock: ${fsError.message ?? \"unknown error\"}`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst stats = await fs.stat(lockPath).catch(() => null);\n\t\t\tconst lockAge = stats ? now - stats.mtimeMs : LOCK_TTL_MS + 1;\n\t\t\tif (lockAge <= LOCK_TTL_MS) {\n\t\t\t\tconst info = await readLockInfo(lockPath);\n\t\t\t\tconst owner = info?.session ? ` (session ${info.session})` : \"\";\n\t\t\t\treturn {\n\t\t\t\t\terror: `Todo ${displayTodoId(id)} is locked${owner}. Try again later.`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\treturn {\n\t\t\t\t\terror: `Todo ${displayTodoId(id)} lock is stale; rerun in interactive mode to steal it.`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst ok = await ctx.ui.confirm(\n\t\t\t\t\"Todo locked\",\n\t\t\t\t`Todo ${displayTodoId(id)} appears locked. Steal the lock?`,\n\t\t\t);\n\t\t\tif (!ok) {\n\t\t\t\treturn { error: `Todo ${displayTodoId(id)} remains locked.` };\n\t\t\t}\n\t\t\tawait fs.unlink(lockPath).catch(() => undefined);\n\t\t}\n\t}\n\n\treturn { error: `Failed to acquire lock for todo ${displayTodoId(id)}.` };\n}\n\nasync function withTodoLock<T>(\n\ttodosDir: string,\n\tid: string,\n\tctx: ExtensionContext,\n\tfn: () => Promise<T>,\n): Promise<T | { error: string }> {\n\tconst lock = await acquireLock(todosDir, id, ctx);\n\tif (typeof lock === \"object\" && \"error\" in lock) return lock;\n\ttry {\n\t\treturn await fn();\n\t} finally {\n\t\tawait lock();\n\t}\n}\n\nasync function listTodos(todosDir: string): Promise<TodoFrontMatter[]> {\n\tlet entries: string[] = [];\n\ttry {\n\t\tentries = await fs.readdir(todosDir);\n\t} catch {\n\t\treturn [];\n\t}\n\n\tconst todos: TodoFrontMatter[] = [];\n\tfor (const entry of entries) {\n\t\tif (!entry.endsWith(\".md\")) continue;\n\t\tconst id = entry.slice(0, -3);\n\t\tconst filePath = path.join(todosDir, entry);\n\t\ttry {\n\t\t\tconst content = await fs.readFile(filePath, \"utf8\");\n\t\t\tconst { frontMatter } = splitFrontMatter(content);\n\t\t\tconst parsed = parseFrontMatter(frontMatter, id);\n\t\t\ttodos.push({\n\t\t\t\tid,\n\t\t\t\ttitle: parsed.title,\n\t\t\t\ttags: parsed.tags ?? [],\n\t\t\t\tstatus: parsed.status,\n\t\t\t\tcreated_at: parsed.created_at,\n\t\t\t\tassigned_to_session: parsed.assigned_to_session,\n\t\t\t});\n\t\t} catch {\n\t\t\t// ignore unreadable todo\n\t\t}\n\t}\n\n\treturn sortTodos(todos);\n}\n\nfunction getTodoTitle(todo: TodoFrontMatter): string {\n\treturn todo.title || \"(untitled)\";\n}\n\nfunction getTodoStatus(todo: TodoFrontMatter): string {\n\treturn todo.status || \"open\";\n}\n\nfunction renderAssignmentSuffix(\n\ttheme: Theme,\n\ttodo: TodoFrontMatter,\n\tcurrentSessionId?: string,\n): string {\n\tif (!todo.assigned_to_session) return \"\";\n\tconst isCurrent = todo.assigned_to_session === currentSessionId;\n\tconst color = isCurrent ? \"success\" : \"dim\";\n\tconst suffix = isCurrent ? \", current\" : \"\";\n\treturn theme.fg(color, ` (assigned: ${todo.assigned_to_session}${suffix})`);\n}\n\nfunction splitTodosByAssignment(todos: TodoFrontMatter[]): {\n\tassignedTodos: TodoFrontMatter[];\n\topenTodos: TodoFrontMatter[];\n\tclosedTodos: TodoFrontMatter[];\n} {\n\tconst assignedTodos: TodoFrontMatter[] = [];\n\tconst openTodos: TodoFrontMatter[] = [];\n\tconst closedTodos: TodoFrontMatter[] = [];\n\tfor (const todo of todos) {\n\t\tif (isTodoClosed(getTodoStatus(todo))) {\n\t\t\tclosedTodos.push(todo);\n\t\t\tcontinue;\n\t\t}\n\t\tif (todo.assigned_to_session) {\n\t\t\tassignedTodos.push(todo);\n\t\t} else {\n\t\t\topenTodos.push(todo);\n\t\t}\n\t}\n\treturn { assignedTodos, openTodos, closedTodos };\n}\n\nfunction serializeTodoForAgent(todo: TodoRecord): string {\n\tconst payload = { ...todo, id: formatTodoId(todo.id) };\n\treturn JSON.stringify(payload, null, 2);\n}\n\nfunction serializeTodoListForAgent(todos: TodoFrontMatter[]): string {\n\tconst { assignedTodos, openTodos, closedTodos } = splitTodosByAssignment(todos);\n\tconst mapTodo = (todo: TodoFrontMatter) => ({\n\t\t...todo,\n\t\tid: formatTodoId(todo.id),\n\t});\n\treturn JSON.stringify(\n\t\t{\n\t\t\tassigned: assignedTodos.map(mapTodo),\n\t\t\topen: openTodos.map(mapTodo),\n\t\t\tclosed: closedTodos.map(mapTodo),\n\t\t},\n\t\tnull,\n\t\t2,\n\t);\n}\n\nfunction renderTodoHeading(\n\ttheme: Theme,\n\ttodo: TodoFrontMatter,\n\tcurrentSessionId?: string,\n): string {\n\tconst closed = isTodoClosed(getTodoStatus(todo));\n\tconst titleColor = closed ? \"dim\" : \"text\";\n\tconst tagText = todo.tags.length ? theme.fg(\"dim\", ` [${todo.tags.join(\", \")}]`) : \"\";\n\tconst assignmentText = renderAssignmentSuffix(theme, todo, currentSessionId);\n\treturn (\n\t\ttheme.fg(\"accent\", formatTodoId(todo.id)) +\n\t\t\" \" +\n\t\ttheme.fg(titleColor, getTodoTitle(todo)) +\n\t\ttagText +\n\t\tassignmentText\n\t);\n}\n\nfunction renderTodoList(\n\ttheme: Theme,\n\ttodos: TodoFrontMatter[],\n\texpanded: boolean,\n\tcurrentSessionId?: string,\n): string {\n\tif (!todos.length) return theme.fg(\"dim\", \"No todos\");\n\n\tconst { assignedTodos, openTodos, closedTodos } = splitTodosByAssignment(todos);\n\tconst lines: string[] = [];\n\tconst pushSection = (label: string, sectionTodos: TodoFrontMatter[]) => {\n\t\tlines.push(theme.fg(\"muted\", `${label} (${sectionTodos.length})`));\n\t\tif (!sectionTodos.length) {\n\t\t\tlines.push(theme.fg(\"dim\", \" none\"));\n\t\t\treturn;\n\t\t}\n\t\tconst maxItems = expanded ? sectionTodos.length : Math.min(sectionTodos.length, 3);\n\t\tfor (let i = 0; i < maxItems; i++) {\n\t\t\tlines.push(` ${renderTodoHeading(theme, sectionTodos[i], currentSessionId)}`);\n\t\t}\n\t\tif (!expanded && sectionTodos.length > maxItems) {\n\t\t\tlines.push(theme.fg(\"dim\", ` ... ${sectionTodos.length - maxItems} more`));\n\t\t}\n\t};\n\n\tconst sections: Array<{ label: string; todos: TodoFrontMatter[] }> = [\n\t\t{ label: \"Assigned todos\", todos: assignedTodos },\n\t\t{ label: \"Open todos\", todos: openTodos },\n\t\t{ label: \"Closed todos\", todos: closedTodos },\n\t];\n\n\tsections.forEach((section, index) => {\n\t\tif (index > 0) lines.push(\"\");\n\t\tpushSection(section.label, section.todos);\n\t});\n\n\treturn lines.join(\"\\n\");\n}\n\nfunction renderTodoDetail(theme: Theme, todo: TodoRecord, expanded: boolean): string {\n\tconst summary = renderTodoHeading(theme, todo);\n\tif (!expanded) return summary;\n\n\tconst tags = todo.tags.length ? todo.tags.join(\", \") : \"none\";\n\tconst createdAt = todo.created_at || \"unknown\";\n\tconst bodyText = todo.body?.trim() ? todo.body.trim() : \"No details yet.\";\n\tconst bodyLines = bodyText.split(\"\\n\");\n\n\tconst lines = [\n\t\tsummary,\n\t\ttheme.fg(\"muted\", `Status: ${getTodoStatus(todo)}`),\n\t\ttheme.fg(\"muted\", `Tags: ${tags}`),\n\t\ttheme.fg(\"muted\", `Created: ${createdAt}`),\n\t\t\"\",\n\t\ttheme.fg(\"muted\", \"Body:\"),\n\t\t...bodyLines.map((line) => theme.fg(\"text\", ` ${line}`)),\n\t];\n\n\treturn lines.join(\"\\n\");\n}\n\nfunction appendExpandHint(theme: Theme, text: string): string {\n\treturn `${text}\\n${theme.fg(\"dim\", `(${keyHint(\"app.tools.expand\", \"to expand\")})`)}`;\n}\n\nasync function ensureTodoExists(filePath: string, id: string): Promise<TodoRecord | null> {\n\tif (!existsSync(filePath)) return null;\n\treturn readTodoFile(filePath, id);\n}\n\nasync function appendTodoBody(\n\tfilePath: string,\n\ttodo: TodoRecord,\n\ttext: string,\n): Promise<TodoRecord> {\n\tconst spacer = todo.body.trim().length ? \"\\n\\n\" : \"\";\n\ttodo.body = `${todo.body.replace(/\\s+$/, \"\")}${spacer}${text.trim()}\\n`;\n\tawait writeTodoFile(filePath, todo);\n\treturn todo;\n}\n\nasync function claimTodoAssignment(\n\ttodosDir: string,\n\tid: string,\n\tctx: ExtensionContext,\n\tforce = false,\n): Promise<TodoRecord | { error: string }> {\n\tconst validated = validateTodoId(id);\n\tif (\"error\" in validated) {\n\t\treturn { error: validated.error };\n\t}\n\tconst normalizedId = validated.id;\n\tconst filePath = getTodoPath(todosDir, normalizedId);\n\tif (!existsSync(filePath)) {\n\t\treturn { error: `Todo ${displayTodoId(id)} not found` };\n\t}\n\tconst sessionId = ctx.sessionManager.getSessionId();\n\tconst result = await withTodoLock(todosDir, normalizedId, ctx, async () => {\n\t\tconst existing = await ensureTodoExists(filePath, normalizedId);\n\t\tif (!existing) return { error: `Todo ${displayTodoId(id)} not found` } as const;\n\t\tif (isTodoClosed(existing.status)) {\n\t\t\treturn { error: `Todo ${displayTodoId(id)} is closed` } as const;\n\t\t}\n\t\tconst assigned = existing.assigned_to_session;\n\t\tif (assigned && assigned !== sessionId && !force) {\n\t\t\treturn {\n\t\t\t\terror: `Todo ${displayTodoId(id)} is already assigned to session ${assigned}. Use force to override.`,\n\t\t\t} as const;\n\t\t}\n\t\tif (assigned !== sessionId) {\n\t\t\texisting.assigned_to_session = sessionId;\n\t\t\tawait writeTodoFile(filePath, existing);\n\t\t}\n\t\treturn existing;\n\t});\n\n\tif (typeof result === \"object\" && \"error\" in result) {\n\t\treturn { error: result.error };\n\t}\n\n\treturn result;\n}\n\nasync function releaseTodoAssignment(\n\ttodosDir: string,\n\tid: string,\n\tctx: ExtensionContext,\n\tforce = false,\n): Promise<TodoRecord | { error: string }> {\n\tconst validated = validateTodoId(id);\n\tif (\"error\" in validated) {\n\t\treturn { error: validated.error };\n\t}\n\tconst normalizedId = validated.id;\n\tconst filePath = getTodoPath(todosDir, normalizedId);\n\tif (!existsSync(filePath)) {\n\t\treturn { error: `Todo ${displayTodoId(id)} not found` };\n\t}\n\tconst sessionId = ctx.sessionManager.getSessionId();\n\tconst result = await withTodoLock(todosDir, normalizedId, ctx, async () => {\n\t\tconst existing = await ensureTodoExists(filePath, normalizedId);\n\t\tif (!existing) return { error: `Todo ${displayTodoId(id)} not found` } as const;\n\t\tconst assigned = existing.assigned_to_session;\n\t\tif (!assigned) {\n\t\t\treturn existing;\n\t\t}\n\t\tif (assigned !== sessionId && !force) {\n\t\t\treturn {\n\t\t\t\terror: `Todo ${displayTodoId(id)} is assigned to session ${assigned}. Use force to release.`,\n\t\t\t} as const;\n\t\t}\n\t\texisting.assigned_to_session = undefined;\n\t\tawait writeTodoFile(filePath, existing);\n\t\treturn existing;\n\t});\n\n\tif (typeof result === \"object\" && \"error\" in result) {\n\t\treturn { error: result.error };\n\t}\n\n\treturn result;\n}\n\nasync function deleteTodo(\n\ttodosDir: string,\n\tid: string,\n\tctx: ExtensionContext,\n): Promise<TodoRecord | { error: string }> {\n\tconst validated = validateTodoId(id);\n\tif (\"error\" in validated) {\n\t\treturn { error: validated.error };\n\t}\n\tconst normalizedId = validated.id;\n\tconst filePath = getTodoPath(todosDir, normalizedId);\n\tif (!existsSync(filePath)) {\n\t\treturn { error: `Todo ${displayTodoId(id)} not found` };\n\t}\n\n\tconst result = await withTodoLock(todosDir, normalizedId, ctx, async () => {\n\t\tconst existing = await ensureTodoExists(filePath, normalizedId);\n\t\tif (!existing) return { error: `Todo ${displayTodoId(id)} not found` } as const;\n\t\tawait fs.unlink(filePath);\n\t\treturn existing;\n\t});\n\n\tif (typeof result === \"object\" && \"error\" in result) {\n\t\treturn { error: result.error };\n\t}\n\n\treturn result;\n}\n\nexport function createTodoToolDefinition(\n\tcwd: string = process.cwd(),\n): ToolDefinition<typeof TodoParams, TodoToolDetails> {\n\tconst todosDirLabel = getTodosDirLabel(cwd);\n\n\treturn {\n\t\tname: \"todo\",\n\t\tlabel: \"Todo\",\n\t\tdescription:\n\t\t\t`Manage file-based todos in ${todosDirLabel} (list, list-all, get, create, update, append, delete, claim, release). ` +\n\t\t\t\"Title is the short summary; body is long-form markdown notes (update replaces, append adds). \" +\n\t\t\t\"Todo ids are shown as TODO-<hex>; id parameters accept TODO-<hex> or the raw hex filename. \" +\n\t\t\t\"Claim tasks before working on them to avoid conflicts, and close them when complete.\",\n\t\tparameters: TodoParams,\n\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\tconst todosDir = getTodosDir(ctx.cwd);\n\t\t\tconst action: TodoAction = params.action;\n\n\t\t\tswitch (action) {\n\t\t\t\tcase \"list\": {\n\t\t\t\t\tconst todos = await listTodos(todosDir);\n\t\t\t\t\tconst { assignedTodos, openTodos } = splitTodosByAssignment(todos);\n\t\t\t\t\tconst listedTodos = [...assignedTodos, ...openTodos];\n\t\t\t\t\tconst currentSessionId = ctx.sessionManager.getSessionId();\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: serializeTodoListForAgent(listedTodos) }],\n\t\t\t\t\t\tdetails: { action: \"list\", todos: listedTodos, currentSessionId },\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tcase \"list-all\": {\n\t\t\t\t\tconst todos = await listTodos(todosDir);\n\t\t\t\t\tconst currentSessionId = ctx.sessionManager.getSessionId();\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: serializeTodoListForAgent(todos) }],\n\t\t\t\t\t\tdetails: { action: \"list-all\", todos, currentSessionId },\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tcase \"get\": {\n\t\t\t\t\tif (!params.id) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"Error: id required\" }],\n\t\t\t\t\t\t\tdetails: { action: \"get\", error: \"id required\" },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst validated = validateTodoId(params.id);\n\t\t\t\t\tif (\"error\" in validated) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: validated.error }],\n\t\t\t\t\t\t\tdetails: { action: \"get\", error: validated.error },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst normalizedId = validated.id;\n\t\t\t\t\tconst displayId = formatTodoId(normalizedId);\n\t\t\t\t\tconst filePath = getTodoPath(todosDir, normalizedId);\n\t\t\t\t\tconst todo = await ensureTodoExists(filePath, normalizedId);\n\t\t\t\t\tif (!todo) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: `Todo ${displayId} not found` }],\n\t\t\t\t\t\t\tdetails: { action: \"get\", error: \"not found\" },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: serializeTodoForAgent(todo) }],\n\t\t\t\t\t\tdetails: { action: \"get\", todo },\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tcase \"create\": {\n\t\t\t\t\tif (!params.title) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"Error: title required\" }],\n\t\t\t\t\t\t\tdetails: { action: \"create\", error: \"title required\" },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tawait ensureTodosDir(todosDir);\n\t\t\t\t\tconst id = await generateTodoId(todosDir);\n\t\t\t\t\tconst filePath = getTodoPath(todosDir, id);\n\t\t\t\t\tconst todo: TodoRecord = {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttitle: params.title,\n\t\t\t\t\t\ttags: params.tags ?? [],\n\t\t\t\t\t\tstatus: params.status ?? \"open\",\n\t\t\t\t\t\tcreated_at: new Date().toISOString(),\n\t\t\t\t\t\tbody: params.body ?? \"\",\n\t\t\t\t\t};\n\n\t\t\t\t\tconst result = await withTodoLock(todosDir, id, ctx, async () => {\n\t\t\t\t\t\tawait writeTodoFile(filePath, todo);\n\t\t\t\t\t\treturn todo;\n\t\t\t\t\t});\n\n\t\t\t\t\tif (typeof result === \"object\" && \"error\" in result) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: result.error }],\n\t\t\t\t\t\t\tdetails: { action: \"create\", error: result.error },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: serializeTodoForAgent(todo) }],\n\t\t\t\t\t\tdetails: { action: \"create\", todo },\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tcase \"update\": {\n\t\t\t\t\tif (!params.id) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"Error: id required\" }],\n\t\t\t\t\t\t\tdetails: { action: \"update\", error: \"id required\" },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst validated = validateTodoId(params.id);\n\t\t\t\t\tif (\"error\" in validated) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: validated.error }],\n\t\t\t\t\t\t\tdetails: { action: \"update\", error: validated.error },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst normalizedId = validated.id;\n\t\t\t\t\tconst displayId = formatTodoId(normalizedId);\n\t\t\t\t\tconst filePath = getTodoPath(todosDir, normalizedId);\n\t\t\t\t\tif (!existsSync(filePath)) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: `Todo ${displayId} not found` }],\n\t\t\t\t\t\t\tdetails: { action: \"update\", error: \"not found\" },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst result = await withTodoLock(todosDir, normalizedId, ctx, async () => {\n\t\t\t\t\t\tconst existing = await ensureTodoExists(filePath, normalizedId);\n\t\t\t\t\t\tif (!existing) return { error: `Todo ${displayId} not found` } as const;\n\n\t\t\t\t\t\texisting.id = normalizedId;\n\t\t\t\t\t\tif (params.title !== undefined) existing.title = params.title;\n\t\t\t\t\t\tif (params.status !== undefined) existing.status = params.status;\n\t\t\t\t\t\tif (params.tags !== undefined) existing.tags = params.tags;\n\t\t\t\t\t\tif (params.body !== undefined) existing.body = params.body;\n\t\t\t\t\t\tif (!existing.created_at) existing.created_at = new Date().toISOString();\n\t\t\t\t\t\tclearAssignmentIfClosed(existing);\n\n\t\t\t\t\t\tawait writeTodoFile(filePath, existing);\n\t\t\t\t\t\treturn existing;\n\t\t\t\t\t});\n\n\t\t\t\t\tif (typeof result === \"object\" && \"error\" in result) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: result.error }],\n\t\t\t\t\t\t\tdetails: { action: \"update\", error: result.error },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst updatedTodo = result as TodoRecord;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: serializeTodoForAgent(updatedTodo) }],\n\t\t\t\t\t\tdetails: { action: \"update\", todo: updatedTodo },\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tcase \"append\": {\n\t\t\t\t\tif (!params.id) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"Error: id required\" }],\n\t\t\t\t\t\t\tdetails: { action: \"append\", error: \"id required\" },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst validated = validateTodoId(params.id);\n\t\t\t\t\tif (\"error\" in validated) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: validated.error }],\n\t\t\t\t\t\t\tdetails: { action: \"append\", error: validated.error },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst normalizedId = validated.id;\n\t\t\t\t\tconst displayId = formatTodoId(normalizedId);\n\t\t\t\t\tconst filePath = getTodoPath(todosDir, normalizedId);\n\t\t\t\t\tif (!existsSync(filePath)) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: `Todo ${displayId} not found` }],\n\t\t\t\t\t\t\tdetails: { action: \"append\", error: \"not found\" },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst result = await withTodoLock(todosDir, normalizedId, ctx, async () => {\n\t\t\t\t\t\tconst existing = await ensureTodoExists(filePath, normalizedId);\n\t\t\t\t\t\tif (!existing) return { error: `Todo ${displayId} not found` } as const;\n\t\t\t\t\t\tif (!params.body || !params.body.trim()) {\n\t\t\t\t\t\t\treturn existing;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst updated = await appendTodoBody(filePath, existing, params.body);\n\t\t\t\t\t\treturn updated;\n\t\t\t\t\t});\n\n\t\t\t\t\tif (typeof result === \"object\" && \"error\" in result) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: result.error }],\n\t\t\t\t\t\t\tdetails: { action: \"append\", error: result.error },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst updatedTodo = result as TodoRecord;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: serializeTodoForAgent(updatedTodo) }],\n\t\t\t\t\t\tdetails: { action: \"append\", todo: updatedTodo },\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tcase \"claim\": {\n\t\t\t\t\tif (!params.id) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"Error: id required\" }],\n\t\t\t\t\t\t\tdetails: { action: \"claim\", error: \"id required\" },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst result = await claimTodoAssignment(\n\t\t\t\t\t\ttodosDir,\n\t\t\t\t\t\tparams.id,\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tBoolean(params.force),\n\t\t\t\t\t);\n\t\t\t\t\tif (typeof result === \"object\" && \"error\" in result) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: result.error }],\n\t\t\t\t\t\t\tdetails: { action: \"claim\", error: result.error },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst updatedTodo = result as TodoRecord;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: serializeTodoForAgent(updatedTodo) }],\n\t\t\t\t\t\tdetails: { action: \"claim\", todo: updatedTodo },\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tcase \"release\": {\n\t\t\t\t\tif (!params.id) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"Error: id required\" }],\n\t\t\t\t\t\t\tdetails: { action: \"release\", error: \"id required\" },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst result = await releaseTodoAssignment(\n\t\t\t\t\t\ttodosDir,\n\t\t\t\t\t\tparams.id,\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tBoolean(params.force),\n\t\t\t\t\t);\n\t\t\t\t\tif (typeof result === \"object\" && \"error\" in result) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: result.error }],\n\t\t\t\t\t\t\tdetails: { action: \"release\", error: result.error },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst updatedTodo = result as TodoRecord;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: serializeTodoForAgent(updatedTodo) }],\n\t\t\t\t\t\tdetails: { action: \"release\", todo: updatedTodo },\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tcase \"delete\": {\n\t\t\t\t\tif (!params.id) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"Error: id required\" }],\n\t\t\t\t\t\t\tdetails: { action: \"delete\", error: \"id required\" },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst validated = validateTodoId(params.id);\n\t\t\t\t\tif (\"error\" in validated) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: validated.error }],\n\t\t\t\t\t\t\tdetails: { action: \"delete\", error: validated.error },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst result = await deleteTodo(todosDir, validated.id, ctx);\n\t\t\t\t\tif (typeof result === \"object\" && \"error\" in result) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: result.error }],\n\t\t\t\t\t\t\tdetails: { action: \"delete\", error: result.error },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\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: serializeTodoForAgent(result as TodoRecord),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: { action: \"delete\", todo: result as TodoRecord },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\trenderCall(args, theme) {\n\t\t\tconst action = typeof args.action === \"string\" ? args.action : \"\";\n\t\t\tconst id = typeof args.id === \"string\" ? args.id : \"\";\n\t\t\tconst normalizedId = id ? normalizeTodoId(id) : \"\";\n\t\t\tconst title = typeof args.title === \"string\" ? args.title : \"\";\n\t\t\tlet text = theme.fg(\"toolTitle\", theme.bold(\"todo \")) + theme.fg(\"muted\", action);\n\t\t\tif (normalizedId) {\n\t\t\t\ttext += \" \" + theme.fg(\"accent\", formatTodoId(normalizedId));\n\t\t\t}\n\t\t\tif (title) {\n\t\t\t\ttext += \" \" + theme.fg(\"dim\", `\"${title}\"`);\n\t\t\t}\n\t\t\treturn new Text(text, 0, 0);\n\t\t},\n\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tconst details = result.details as TodoToolDetails | undefined;\n\t\t\tif (isPartial) {\n\t\t\t\treturn new Text(theme.fg(\"warning\", \"Processing...\"), 0, 0);\n\t\t\t}\n\t\t\tif (!details) {\n\t\t\t\tconst text = result.content[0];\n\t\t\t\treturn new Text(text?.type === \"text\" ? text.text : \"\", 0, 0);\n\t\t\t}\n\n\t\t\tif (details.error) {\n\t\t\t\treturn new Text(theme.fg(\"error\", `Error: ${details.error}`), 0, 0);\n\t\t\t}\n\n\t\t\tif (details.action === \"list\" || details.action === \"list-all\") {\n\t\t\t\tlet text = renderTodoList(theme, details.todos, expanded, details.currentSessionId);\n\t\t\t\tif (!expanded) {\n\t\t\t\t\tconst { closedTodos } = splitTodosByAssignment(details.todos);\n\t\t\t\t\tif (closedTodos.length) {\n\t\t\t\t\t\ttext = appendExpandHint(theme, text);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn new Text(text, 0, 0);\n\t\t\t}\n\n\t\t\tif (!(\"todo\" in details) || !details.todo) {\n\t\t\t\tconst text = result.content[0];\n\t\t\t\treturn new Text(text?.type === \"text\" ? text.text : \"\", 0, 0);\n\t\t\t}\n\n\t\t\tlet text = renderTodoDetail(theme, details.todo, expanded);\n\t\t\tconst actionLabel =\n\t\t\t\tdetails.action === \"create\"\n\t\t\t\t\t? \"Created\"\n\t\t\t\t\t: details.action === \"update\"\n\t\t\t\t\t\t? \"Updated\"\n\t\t\t\t\t\t: details.action === \"append\"\n\t\t\t\t\t\t\t? \"Appended to\"\n\t\t\t\t\t\t\t: details.action === \"delete\"\n\t\t\t\t\t\t\t\t? \"Deleted\"\n\t\t\t\t\t\t\t\t: details.action === \"claim\"\n\t\t\t\t\t\t\t\t\t? \"Claimed\"\n\t\t\t\t\t\t\t\t\t: details.action === \"release\"\n\t\t\t\t\t\t\t\t\t\t? \"Released\"\n\t\t\t\t\t\t\t\t\t\t: null;\n\t\t\tif (actionLabel) {\n\t\t\t\tconst lines = text.split(\"\\n\");\n\t\t\t\tlines[0] = theme.fg(\"success\", \"✓ \") + theme.fg(\"muted\", `${actionLabel} `) + lines[0];\n\t\t\t\ttext = lines.join(\"\\n\");\n\t\t\t}\n\t\t\tif (!expanded) {\n\t\t\t\ttext = appendExpandHint(theme, text);\n\t\t\t}\n\t\t\treturn new Text(text, 0, 0);\n\t\t},\n\t};\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import type { ExtensionContext, ToolDefinition } from "../extensions/types.js";
|
|
3
|
+
/** Wrap a ToolDefinition into an AgentTool for the core runtime. */
|
|
4
|
+
export declare function wrapToolDefinition<TDetails = unknown>(definition: ToolDefinition<any, TDetails>, ctxFactory?: () => ExtensionContext): AgentTool<any, TDetails>;
|
|
5
|
+
/** Wrap multiple ToolDefinitions into AgentTools for the core runtime. */
|
|
6
|
+
export declare function wrapToolDefinitions(definitions: ToolDefinition<any, any>[], ctxFactory?: () => ExtensionContext): AgentTool<any>[];
|
|
7
|
+
/**
|
|
8
|
+
* Synthesize a minimal ToolDefinition from an AgentTool.
|
|
9
|
+
*
|
|
10
|
+
* This keeps AgentSession's internal registry definition-first even when a caller
|
|
11
|
+
* provides plain AgentTool overrides that do not include prompt metadata or renderers.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createToolDefinitionFromAgentTool(tool: AgentTool<any>): ToolDefinition<any, unknown>;
|
|
14
|
+
//# sourceMappingURL=tool-definition-wrapper.d.ts.map
|
|
@@ -0,0 +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,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE/E,oEAAoE;AACpE,wBAAgB,kBAAkB,CAAC,QAAQ,GAAG,OAAO,EACpD,UAAU,EAAE,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC,EACzC,UAAU,CAAC,EAAE,MAAM,gBAAgB,GACjC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,CAW1B;AAED,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAClC,WAAW,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EACvC,UAAU,CAAC,EAAE,MAAM,gBAAgB,GACjC,SAAS,CAAC,GAAG,CAAC,EAAE,CAElB;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAUpG","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.js\";\n\n/** Wrap a ToolDefinition into an AgentTool for the core runtime. */\nexport function wrapToolDefinition<TDetails = unknown>(\n\tdefinition: ToolDefinition<any, TDetails>,\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<any, 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\tprepareArguments: definition.prepareArguments,\n\t\texecutionMode: definition.executionMode,\n\t\texecute: (toolCallId, params, signal, onUpdate) =>\n\t\t\tdefinition.execute(toolCallId, params, signal, onUpdate, ctxFactory?.() as ExtensionContext),\n\t};\n}\n\n/** Wrap multiple ToolDefinitions into AgentTools for the core runtime. */\nexport function wrapToolDefinitions(\n\tdefinitions: ToolDefinition<any, any>[],\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<any>[] {\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(tool: AgentTool<any>): ToolDefinition<any, unknown> {\n\treturn {\n\t\tname: tool.name,\n\t\tlabel: tool.label,\n\t\tdescription: tool.description,\n\t\tparameters: tool.parameters as any,\n\t\tprepareArguments: tool.prepareArguments,\n\t\texecutionMode: tool.executionMode,\n\t\texecute: async (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params, signal, onUpdate),\n\t};\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Wrap a ToolDefinition into an AgentTool for the core runtime. */
|
|
2
|
+
export function wrapToolDefinition(definition, ctxFactory) {
|
|
3
|
+
return {
|
|
4
|
+
name: definition.name,
|
|
5
|
+
label: definition.label,
|
|
6
|
+
description: definition.description,
|
|
7
|
+
parameters: definition.parameters,
|
|
8
|
+
prepareArguments: definition.prepareArguments,
|
|
9
|
+
executionMode: definition.executionMode,
|
|
10
|
+
execute: (toolCallId, params, signal, onUpdate) => definition.execute(toolCallId, params, signal, onUpdate, ctxFactory?.()),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Wrap multiple ToolDefinitions into AgentTools for the core runtime. */
|
|
14
|
+
export function wrapToolDefinitions(definitions, ctxFactory) {
|
|
15
|
+
return definitions.map((definition) => wrapToolDefinition(definition, ctxFactory));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Synthesize a minimal ToolDefinition from an AgentTool.
|
|
19
|
+
*
|
|
20
|
+
* This keeps AgentSession's internal registry definition-first even when a caller
|
|
21
|
+
* provides plain AgentTool overrides that do not include prompt metadata or renderers.
|
|
22
|
+
*/
|
|
23
|
+
export function createToolDefinitionFromAgentTool(tool) {
|
|
24
|
+
return {
|
|
25
|
+
name: tool.name,
|
|
26
|
+
label: tool.label,
|
|
27
|
+
description: tool.description,
|
|
28
|
+
parameters: tool.parameters,
|
|
29
|
+
prepareArguments: tool.prepareArguments,
|
|
30
|
+
executionMode: tool.executionMode,
|
|
31
|
+
execute: async (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params, signal, onUpdate),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=tool-definition-wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-definition-wrapper.js","sourceRoot":"","sources":["../../../src/core/tools/tool-definition-wrapper.ts"],"names":[],"mappings":"AAGA,oEAAoE;AACpE,MAAM,UAAU,kBAAkB,CACjC,UAAyC,EACzC,UAAmC;IAEnC,OAAO;QACN,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;QAC7C,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CACjD,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAsB,CAAC;KAC7F,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB,CAClC,WAAuC,EACvC,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,CAAC,IAAoB;IACrE,OAAO;QACN,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,UAAU,EAAE,IAAI,CAAC,UAAiB;QAClC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;KAC3G,CAAC;AACH,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.js\";\n\n/** Wrap a ToolDefinition into an AgentTool for the core runtime. */\nexport function wrapToolDefinition<TDetails = unknown>(\n\tdefinition: ToolDefinition<any, TDetails>,\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<any, 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\tprepareArguments: definition.prepareArguments,\n\t\texecutionMode: definition.executionMode,\n\t\texecute: (toolCallId, params, signal, onUpdate) =>\n\t\t\tdefinition.execute(toolCallId, params, signal, onUpdate, ctxFactory?.() as ExtensionContext),\n\t};\n}\n\n/** Wrap multiple ToolDefinitions into AgentTools for the core runtime. */\nexport function wrapToolDefinitions(\n\tdefinitions: ToolDefinition<any, any>[],\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<any>[] {\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(tool: AgentTool<any>): ToolDefinition<any, unknown> {\n\treturn {\n\t\tname: tool.name,\n\t\tlabel: tool.label,\n\t\tdescription: tool.description,\n\t\tparameters: tool.parameters as any,\n\t\tprepareArguments: tool.prepareArguments,\n\t\texecutionMode: tool.executionMode,\n\t\texecute: async (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params, signal, onUpdate),\n\t};\n}\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared truncation utilities for tool outputs.
|
|
3
|
+
*
|
|
4
|
+
* Truncation is based on two independent limits - whichever is hit first wins:
|
|
5
|
+
* - Line limit (default: 2000 lines)
|
|
6
|
+
* - Byte limit (default: 50KB)
|
|
7
|
+
*
|
|
8
|
+
* Never returns partial lines (except bash tail truncation edge case).
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_MAX_LINES = 2000;
|
|
11
|
+
export declare const DEFAULT_MAX_BYTES: number;
|
|
12
|
+
export declare const GREP_MAX_LINE_LENGTH = 500;
|
|
13
|
+
export interface TruncationResult {
|
|
14
|
+
/** The truncated content */
|
|
15
|
+
content: string;
|
|
16
|
+
/** Whether truncation occurred */
|
|
17
|
+
truncated: boolean;
|
|
18
|
+
/** Which limit was hit: "lines", "bytes", or null if not truncated */
|
|
19
|
+
truncatedBy: "lines" | "bytes" | null;
|
|
20
|
+
/** Total number of lines in the original content */
|
|
21
|
+
totalLines: number;
|
|
22
|
+
/** Total number of bytes in the original content */
|
|
23
|
+
totalBytes: number;
|
|
24
|
+
/** Number of complete lines in the truncated output */
|
|
25
|
+
outputLines: number;
|
|
26
|
+
/** Number of bytes in the truncated output */
|
|
27
|
+
outputBytes: number;
|
|
28
|
+
/** Whether the last line was partially truncated (only for tail truncation edge case) */
|
|
29
|
+
lastLinePartial: boolean;
|
|
30
|
+
/** Whether the first line exceeded the byte limit (for head truncation) */
|
|
31
|
+
firstLineExceedsLimit: boolean;
|
|
32
|
+
/** The max lines limit that was applied */
|
|
33
|
+
maxLines: number;
|
|
34
|
+
/** The max bytes limit that was applied */
|
|
35
|
+
maxBytes: number;
|
|
36
|
+
}
|
|
37
|
+
export interface TruncationOptions {
|
|
38
|
+
/** Maximum number of lines (default: 2000) */
|
|
39
|
+
maxLines?: number;
|
|
40
|
+
/** Maximum number of bytes (default: 50KB) */
|
|
41
|
+
maxBytes?: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Format bytes as human-readable size.
|
|
45
|
+
*/
|
|
46
|
+
export declare function formatSize(bytes: number): string;
|
|
47
|
+
/**
|
|
48
|
+
* Truncate content from the head (keep first N lines/bytes).
|
|
49
|
+
* Suitable for file reads where you want to see the beginning.
|
|
50
|
+
*
|
|
51
|
+
* Never returns partial lines. If first line exceeds byte limit,
|
|
52
|
+
* returns empty content with firstLineExceedsLimit=true.
|
|
53
|
+
*/
|
|
54
|
+
export declare function truncateHead(content: string, options?: TruncationOptions): TruncationResult;
|
|
55
|
+
/**
|
|
56
|
+
* Truncate content from the tail (keep last N lines/bytes).
|
|
57
|
+
* Suitable for bash output where you want to see the end (errors, final results).
|
|
58
|
+
*
|
|
59
|
+
* May return partial first line if the last line of original content exceeds byte limit.
|
|
60
|
+
*/
|
|
61
|
+
export declare function truncateTail(content: string, options?: TruncationOptions): TruncationResult;
|
|
62
|
+
/**
|
|
63
|
+
* Truncate a single line to max characters, adding [truncated] suffix.
|
|
64
|
+
* Used for grep match lines.
|
|
65
|
+
*/
|
|
66
|
+
export declare function truncateLine(line: string, maxChars?: number): {
|
|
67
|
+
text: string;
|
|
68
|
+
wasTruncated: boolean;
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=truncate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truncate.d.ts","sourceRoot":"","sources":["../../../src/core/tools/truncate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,iBAAiB,QAAY,CAAC;AAC3C,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,MAAM,WAAW,gBAAgB;IAChC,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,WAAW,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;IACtC,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,eAAe,EAAE,OAAO,CAAC;IACzB,2EAA2E;IAC3E,qBAAqB,EAAE,OAAO,CAAC;IAC/B,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IACjC,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQhD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,gBAAgB,CAkF/F;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,gBAAgB,CAyE/F;AAuBD;;;GAGG;AACH,wBAAgB,YAAY,CAC3B,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAA6B,GACrC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAA;CAAE,CAKzC","sourcesContent":["/**\n * Shared truncation utilities for tool outputs.\n *\n * Truncation is based on two independent limits - whichever is hit first wins:\n * - Line limit (default: 2000 lines)\n * - Byte limit (default: 50KB)\n *\n * Never returns partial lines (except bash tail truncation edge case).\n */\n\nexport const DEFAULT_MAX_LINES = 2000;\nexport const DEFAULT_MAX_BYTES = 50 * 1024; // 50KB\nexport const GREP_MAX_LINE_LENGTH = 500; // Max chars per grep match line\n\nexport interface TruncationResult {\n\t/** The truncated content */\n\tcontent: string;\n\t/** Whether truncation occurred */\n\ttruncated: boolean;\n\t/** Which limit was hit: \"lines\", \"bytes\", or null if not truncated */\n\ttruncatedBy: \"lines\" | \"bytes\" | null;\n\t/** Total number of lines in the original content */\n\ttotalLines: number;\n\t/** Total number of bytes in the original content */\n\ttotalBytes: number;\n\t/** Number of complete lines in the truncated output */\n\toutputLines: number;\n\t/** Number of bytes in the truncated output */\n\toutputBytes: number;\n\t/** Whether the last line was partially truncated (only for tail truncation edge case) */\n\tlastLinePartial: boolean;\n\t/** Whether the first line exceeded the byte limit (for head truncation) */\n\tfirstLineExceedsLimit: boolean;\n\t/** The max lines limit that was applied */\n\tmaxLines: number;\n\t/** The max bytes limit that was applied */\n\tmaxBytes: number;\n}\n\nexport interface TruncationOptions {\n\t/** Maximum number of lines (default: 2000) */\n\tmaxLines?: number;\n\t/** Maximum number of bytes (default: 50KB) */\n\tmaxBytes?: number;\n}\n\n/**\n * Format bytes as human-readable size.\n */\nexport function formatSize(bytes: number): string {\n\tif (bytes < 1024) {\n\t\treturn `${bytes}B`;\n\t} else if (bytes < 1024 * 1024) {\n\t\treturn `${(bytes / 1024).toFixed(1)}KB`;\n\t} else {\n\t\treturn `${(bytes / (1024 * 1024)).toFixed(1)}MB`;\n\t}\n}\n\n/**\n * Truncate content from the head (keep first N lines/bytes).\n * Suitable for file reads where you want to see the beginning.\n *\n * Never returns partial lines. If first line exceeds byte limit,\n * returns empty content with firstLineExceedsLimit=true.\n */\nexport function truncateHead(content: string, options: TruncationOptions = {}): TruncationResult {\n\tconst maxLines = options.maxLines ?? DEFAULT_MAX_LINES;\n\tconst maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n\n\tconst totalBytes = Buffer.byteLength(content, \"utf-8\");\n\tconst lines = content.split(\"\\n\");\n\tconst totalLines = lines.length;\n\n\t// Check if no truncation needed\n\tif (totalLines <= maxLines && totalBytes <= maxBytes) {\n\t\treturn {\n\t\t\tcontent,\n\t\t\ttruncated: false,\n\t\t\ttruncatedBy: null,\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: totalLines,\n\t\t\toutputBytes: totalBytes,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: false,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Check if first line alone exceeds byte limit\n\tconst firstLineBytes = Buffer.byteLength(lines[0], \"utf-8\");\n\tif (firstLineBytes > maxBytes) {\n\t\treturn {\n\t\t\tcontent: \"\",\n\t\t\ttruncated: true,\n\t\t\ttruncatedBy: \"bytes\",\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: 0,\n\t\t\toutputBytes: 0,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: true,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Collect complete lines that fit\n\tconst outputLinesArr: string[] = [];\n\tlet outputBytesCount = 0;\n\tlet truncatedBy: \"lines\" | \"bytes\" = \"lines\";\n\n\tfor (let i = 0; i < lines.length && i < maxLines; i++) {\n\t\tconst line = lines[i];\n\t\tconst lineBytes = Buffer.byteLength(line, \"utf-8\") + (i > 0 ? 1 : 0); // +1 for newline\n\n\t\tif (outputBytesCount + lineBytes > maxBytes) {\n\t\t\ttruncatedBy = \"bytes\";\n\t\t\tbreak;\n\t\t}\n\n\t\toutputLinesArr.push(line);\n\t\toutputBytesCount += lineBytes;\n\t}\n\n\t// If we exited due to line limit\n\tif (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {\n\t\ttruncatedBy = \"lines\";\n\t}\n\n\tconst outputContent = outputLinesArr.join(\"\\n\");\n\tconst finalOutputBytes = Buffer.byteLength(outputContent, \"utf-8\");\n\n\treturn {\n\t\tcontent: outputContent,\n\t\ttruncated: true,\n\t\ttruncatedBy,\n\t\ttotalLines,\n\t\ttotalBytes,\n\t\toutputLines: outputLinesArr.length,\n\t\toutputBytes: finalOutputBytes,\n\t\tlastLinePartial: false,\n\t\tfirstLineExceedsLimit: false,\n\t\tmaxLines,\n\t\tmaxBytes,\n\t};\n}\n\n/**\n * Truncate content from the tail (keep last N lines/bytes).\n * Suitable for bash output where you want to see the end (errors, final results).\n *\n * May return partial first line if the last line of original content exceeds byte limit.\n */\nexport function truncateTail(content: string, options: TruncationOptions = {}): TruncationResult {\n\tconst maxLines = options.maxLines ?? DEFAULT_MAX_LINES;\n\tconst maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n\n\tconst totalBytes = Buffer.byteLength(content, \"utf-8\");\n\tconst lines = content.split(\"\\n\");\n\tconst totalLines = lines.length;\n\n\t// Check if no truncation needed\n\tif (totalLines <= maxLines && totalBytes <= maxBytes) {\n\t\treturn {\n\t\t\tcontent,\n\t\t\ttruncated: false,\n\t\t\ttruncatedBy: null,\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: totalLines,\n\t\t\toutputBytes: totalBytes,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: false,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Work backwards from the end\n\tconst outputLinesArr: string[] = [];\n\tlet outputBytesCount = 0;\n\tlet truncatedBy: \"lines\" | \"bytes\" = \"lines\";\n\tlet lastLinePartial = false;\n\n\tfor (let i = lines.length - 1; i >= 0 && outputLinesArr.length < maxLines; i--) {\n\t\tconst line = lines[i];\n\t\tconst lineBytes = Buffer.byteLength(line, \"utf-8\") + (outputLinesArr.length > 0 ? 1 : 0); // +1 for newline\n\n\t\tif (outputBytesCount + lineBytes > maxBytes) {\n\t\t\ttruncatedBy = \"bytes\";\n\t\t\t// Edge case: if we haven't added ANY lines yet and this line exceeds maxBytes,\n\t\t\t// take the end of the line (partial)\n\t\t\tif (outputLinesArr.length === 0) {\n\t\t\t\tconst truncatedLine = truncateStringToBytesFromEnd(line, maxBytes);\n\t\t\t\toutputLinesArr.unshift(truncatedLine);\n\t\t\t\toutputBytesCount = Buffer.byteLength(truncatedLine, \"utf-8\");\n\t\t\t\tlastLinePartial = true;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\toutputLinesArr.unshift(line);\n\t\toutputBytesCount += lineBytes;\n\t}\n\n\t// If we exited due to line limit\n\tif (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {\n\t\ttruncatedBy = \"lines\";\n\t}\n\n\tconst outputContent = outputLinesArr.join(\"\\n\");\n\tconst finalOutputBytes = Buffer.byteLength(outputContent, \"utf-8\");\n\n\treturn {\n\t\tcontent: outputContent,\n\t\ttruncated: true,\n\t\ttruncatedBy,\n\t\ttotalLines,\n\t\ttotalBytes,\n\t\toutputLines: outputLinesArr.length,\n\t\toutputBytes: finalOutputBytes,\n\t\tlastLinePartial,\n\t\tfirstLineExceedsLimit: false,\n\t\tmaxLines,\n\t\tmaxBytes,\n\t};\n}\n\n/**\n * Truncate a string to fit within a byte limit (from the end).\n * Handles multi-byte UTF-8 characters correctly.\n */\nfunction truncateStringToBytesFromEnd(str: string, maxBytes: number): string {\n\tconst buf = Buffer.from(str, \"utf-8\");\n\tif (buf.length <= maxBytes) {\n\t\treturn str;\n\t}\n\n\t// Start from the end, skip maxBytes back\n\tlet start = buf.length - maxBytes;\n\n\t// Find a valid UTF-8 boundary (start of a character)\n\twhile (start < buf.length && (buf[start] & 0xc0) === 0x80) {\n\t\tstart++;\n\t}\n\n\treturn buf.slice(start).toString(\"utf-8\");\n}\n\n/**\n * Truncate a single line to max characters, adding [truncated] suffix.\n * Used for grep match lines.\n */\nexport function truncateLine(\n\tline: string,\n\tmaxChars: number = GREP_MAX_LINE_LENGTH,\n): { text: string; wasTruncated: boolean } {\n\tif (line.length <= maxChars) {\n\t\treturn { text: line, wasTruncated: false };\n\t}\n\treturn { text: `${line.slice(0, maxChars)}... [truncated]`, wasTruncated: true };\n}\n"]}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared truncation utilities for tool outputs.
|
|
3
|
+
*
|
|
4
|
+
* Truncation is based on two independent limits - whichever is hit first wins:
|
|
5
|
+
* - Line limit (default: 2000 lines)
|
|
6
|
+
* - Byte limit (default: 50KB)
|
|
7
|
+
*
|
|
8
|
+
* Never returns partial lines (except bash tail truncation edge case).
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_MAX_LINES = 2000;
|
|
11
|
+
export const DEFAULT_MAX_BYTES = 50 * 1024; // 50KB
|
|
12
|
+
export const GREP_MAX_LINE_LENGTH = 500; // Max chars per grep match line
|
|
13
|
+
/**
|
|
14
|
+
* Format bytes as human-readable size.
|
|
15
|
+
*/
|
|
16
|
+
export function formatSize(bytes) {
|
|
17
|
+
if (bytes < 1024) {
|
|
18
|
+
return `${bytes}B`;
|
|
19
|
+
}
|
|
20
|
+
else if (bytes < 1024 * 1024) {
|
|
21
|
+
return `${(bytes / 1024).toFixed(1)}KB`;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Truncate content from the head (keep first N lines/bytes).
|
|
29
|
+
* Suitable for file reads where you want to see the beginning.
|
|
30
|
+
*
|
|
31
|
+
* Never returns partial lines. If first line exceeds byte limit,
|
|
32
|
+
* returns empty content with firstLineExceedsLimit=true.
|
|
33
|
+
*/
|
|
34
|
+
export function truncateHead(content, options = {}) {
|
|
35
|
+
const maxLines = options.maxLines ?? DEFAULT_MAX_LINES;
|
|
36
|
+
const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
37
|
+
const totalBytes = Buffer.byteLength(content, "utf-8");
|
|
38
|
+
const lines = content.split("\n");
|
|
39
|
+
const totalLines = lines.length;
|
|
40
|
+
// Check if no truncation needed
|
|
41
|
+
if (totalLines <= maxLines && totalBytes <= maxBytes) {
|
|
42
|
+
return {
|
|
43
|
+
content,
|
|
44
|
+
truncated: false,
|
|
45
|
+
truncatedBy: null,
|
|
46
|
+
totalLines,
|
|
47
|
+
totalBytes,
|
|
48
|
+
outputLines: totalLines,
|
|
49
|
+
outputBytes: totalBytes,
|
|
50
|
+
lastLinePartial: false,
|
|
51
|
+
firstLineExceedsLimit: false,
|
|
52
|
+
maxLines,
|
|
53
|
+
maxBytes,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// Check if first line alone exceeds byte limit
|
|
57
|
+
const firstLineBytes = Buffer.byteLength(lines[0], "utf-8");
|
|
58
|
+
if (firstLineBytes > maxBytes) {
|
|
59
|
+
return {
|
|
60
|
+
content: "",
|
|
61
|
+
truncated: true,
|
|
62
|
+
truncatedBy: "bytes",
|
|
63
|
+
totalLines,
|
|
64
|
+
totalBytes,
|
|
65
|
+
outputLines: 0,
|
|
66
|
+
outputBytes: 0,
|
|
67
|
+
lastLinePartial: false,
|
|
68
|
+
firstLineExceedsLimit: true,
|
|
69
|
+
maxLines,
|
|
70
|
+
maxBytes,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// Collect complete lines that fit
|
|
74
|
+
const outputLinesArr = [];
|
|
75
|
+
let outputBytesCount = 0;
|
|
76
|
+
let truncatedBy = "lines";
|
|
77
|
+
for (let i = 0; i < lines.length && i < maxLines; i++) {
|
|
78
|
+
const line = lines[i];
|
|
79
|
+
const lineBytes = Buffer.byteLength(line, "utf-8") + (i > 0 ? 1 : 0); // +1 for newline
|
|
80
|
+
if (outputBytesCount + lineBytes > maxBytes) {
|
|
81
|
+
truncatedBy = "bytes";
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
outputLinesArr.push(line);
|
|
85
|
+
outputBytesCount += lineBytes;
|
|
86
|
+
}
|
|
87
|
+
// If we exited due to line limit
|
|
88
|
+
if (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {
|
|
89
|
+
truncatedBy = "lines";
|
|
90
|
+
}
|
|
91
|
+
const outputContent = outputLinesArr.join("\n");
|
|
92
|
+
const finalOutputBytes = Buffer.byteLength(outputContent, "utf-8");
|
|
93
|
+
return {
|
|
94
|
+
content: outputContent,
|
|
95
|
+
truncated: true,
|
|
96
|
+
truncatedBy,
|
|
97
|
+
totalLines,
|
|
98
|
+
totalBytes,
|
|
99
|
+
outputLines: outputLinesArr.length,
|
|
100
|
+
outputBytes: finalOutputBytes,
|
|
101
|
+
lastLinePartial: false,
|
|
102
|
+
firstLineExceedsLimit: false,
|
|
103
|
+
maxLines,
|
|
104
|
+
maxBytes,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Truncate content from the tail (keep last N lines/bytes).
|
|
109
|
+
* Suitable for bash output where you want to see the end (errors, final results).
|
|
110
|
+
*
|
|
111
|
+
* May return partial first line if the last line of original content exceeds byte limit.
|
|
112
|
+
*/
|
|
113
|
+
export function truncateTail(content, options = {}) {
|
|
114
|
+
const maxLines = options.maxLines ?? DEFAULT_MAX_LINES;
|
|
115
|
+
const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
116
|
+
const totalBytes = Buffer.byteLength(content, "utf-8");
|
|
117
|
+
const lines = content.split("\n");
|
|
118
|
+
const totalLines = lines.length;
|
|
119
|
+
// Check if no truncation needed
|
|
120
|
+
if (totalLines <= maxLines && totalBytes <= maxBytes) {
|
|
121
|
+
return {
|
|
122
|
+
content,
|
|
123
|
+
truncated: false,
|
|
124
|
+
truncatedBy: null,
|
|
125
|
+
totalLines,
|
|
126
|
+
totalBytes,
|
|
127
|
+
outputLines: totalLines,
|
|
128
|
+
outputBytes: totalBytes,
|
|
129
|
+
lastLinePartial: false,
|
|
130
|
+
firstLineExceedsLimit: false,
|
|
131
|
+
maxLines,
|
|
132
|
+
maxBytes,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
// Work backwards from the end
|
|
136
|
+
const outputLinesArr = [];
|
|
137
|
+
let outputBytesCount = 0;
|
|
138
|
+
let truncatedBy = "lines";
|
|
139
|
+
let lastLinePartial = false;
|
|
140
|
+
for (let i = lines.length - 1; i >= 0 && outputLinesArr.length < maxLines; i--) {
|
|
141
|
+
const line = lines[i];
|
|
142
|
+
const lineBytes = Buffer.byteLength(line, "utf-8") + (outputLinesArr.length > 0 ? 1 : 0); // +1 for newline
|
|
143
|
+
if (outputBytesCount + lineBytes > maxBytes) {
|
|
144
|
+
truncatedBy = "bytes";
|
|
145
|
+
// Edge case: if we haven't added ANY lines yet and this line exceeds maxBytes,
|
|
146
|
+
// take the end of the line (partial)
|
|
147
|
+
if (outputLinesArr.length === 0) {
|
|
148
|
+
const truncatedLine = truncateStringToBytesFromEnd(line, maxBytes);
|
|
149
|
+
outputLinesArr.unshift(truncatedLine);
|
|
150
|
+
outputBytesCount = Buffer.byteLength(truncatedLine, "utf-8");
|
|
151
|
+
lastLinePartial = true;
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
outputLinesArr.unshift(line);
|
|
156
|
+
outputBytesCount += lineBytes;
|
|
157
|
+
}
|
|
158
|
+
// If we exited due to line limit
|
|
159
|
+
if (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {
|
|
160
|
+
truncatedBy = "lines";
|
|
161
|
+
}
|
|
162
|
+
const outputContent = outputLinesArr.join("\n");
|
|
163
|
+
const finalOutputBytes = Buffer.byteLength(outputContent, "utf-8");
|
|
164
|
+
return {
|
|
165
|
+
content: outputContent,
|
|
166
|
+
truncated: true,
|
|
167
|
+
truncatedBy,
|
|
168
|
+
totalLines,
|
|
169
|
+
totalBytes,
|
|
170
|
+
outputLines: outputLinesArr.length,
|
|
171
|
+
outputBytes: finalOutputBytes,
|
|
172
|
+
lastLinePartial,
|
|
173
|
+
firstLineExceedsLimit: false,
|
|
174
|
+
maxLines,
|
|
175
|
+
maxBytes,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Truncate a string to fit within a byte limit (from the end).
|
|
180
|
+
* Handles multi-byte UTF-8 characters correctly.
|
|
181
|
+
*/
|
|
182
|
+
function truncateStringToBytesFromEnd(str, maxBytes) {
|
|
183
|
+
const buf = Buffer.from(str, "utf-8");
|
|
184
|
+
if (buf.length <= maxBytes) {
|
|
185
|
+
return str;
|
|
186
|
+
}
|
|
187
|
+
// Start from the end, skip maxBytes back
|
|
188
|
+
let start = buf.length - maxBytes;
|
|
189
|
+
// Find a valid UTF-8 boundary (start of a character)
|
|
190
|
+
while (start < buf.length && (buf[start] & 0xc0) === 0x80) {
|
|
191
|
+
start++;
|
|
192
|
+
}
|
|
193
|
+
return buf.slice(start).toString("utf-8");
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Truncate a single line to max characters, adding [truncated] suffix.
|
|
197
|
+
* Used for grep match lines.
|
|
198
|
+
*/
|
|
199
|
+
export function truncateLine(line, maxChars = GREP_MAX_LINE_LENGTH) {
|
|
200
|
+
if (line.length <= maxChars) {
|
|
201
|
+
return { text: line, wasTruncated: false };
|
|
202
|
+
}
|
|
203
|
+
return { text: `${line.slice(0, maxChars)}... [truncated]`, wasTruncated: true };
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=truncate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truncate.js","sourceRoot":"","sources":["../../../src/core/tools/truncate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AACtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO;AACnD,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC,CAAC,gCAAgC;AAkCzE;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACvC,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC;QAClB,OAAO,GAAG,KAAK,GAAG,CAAC;IACpB,CAAC;SAAM,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;QAChC,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACzC,CAAC;SAAM,CAAC;QACP,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IAClD,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,OAAO,GAAsB,EAAE;IAC5E,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,iBAAiB,CAAC;IACvD,MAAM,QAAQ,GAAG,OAAO,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CAAC,KAAK,IAAI,EAAE,CAAC;QAC3D,KAAK,EAAE,CAAC;IACT,CAAC;IAED,OAAO,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC3B,IAAY,EACZ,QAAQ,GAAW,oBAAoB;IAEvC,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC7B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IAC5C,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,iBAAiB,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AAClF,CAAC","sourcesContent":["/**\n * Shared truncation utilities for tool outputs.\n *\n * Truncation is based on two independent limits - whichever is hit first wins:\n * - Line limit (default: 2000 lines)\n * - Byte limit (default: 50KB)\n *\n * Never returns partial lines (except bash tail truncation edge case).\n */\n\nexport const DEFAULT_MAX_LINES = 2000;\nexport const DEFAULT_MAX_BYTES = 50 * 1024; // 50KB\nexport const GREP_MAX_LINE_LENGTH = 500; // Max chars per grep match line\n\nexport interface TruncationResult {\n\t/** The truncated content */\n\tcontent: string;\n\t/** Whether truncation occurred */\n\ttruncated: boolean;\n\t/** Which limit was hit: \"lines\", \"bytes\", or null if not truncated */\n\ttruncatedBy: \"lines\" | \"bytes\" | null;\n\t/** Total number of lines in the original content */\n\ttotalLines: number;\n\t/** Total number of bytes in the original content */\n\ttotalBytes: number;\n\t/** Number of complete lines in the truncated output */\n\toutputLines: number;\n\t/** Number of bytes in the truncated output */\n\toutputBytes: number;\n\t/** Whether the last line was partially truncated (only for tail truncation edge case) */\n\tlastLinePartial: boolean;\n\t/** Whether the first line exceeded the byte limit (for head truncation) */\n\tfirstLineExceedsLimit: boolean;\n\t/** The max lines limit that was applied */\n\tmaxLines: number;\n\t/** The max bytes limit that was applied */\n\tmaxBytes: number;\n}\n\nexport interface TruncationOptions {\n\t/** Maximum number of lines (default: 2000) */\n\tmaxLines?: number;\n\t/** Maximum number of bytes (default: 50KB) */\n\tmaxBytes?: number;\n}\n\n/**\n * Format bytes as human-readable size.\n */\nexport function formatSize(bytes: number): string {\n\tif (bytes < 1024) {\n\t\treturn `${bytes}B`;\n\t} else if (bytes < 1024 * 1024) {\n\t\treturn `${(bytes / 1024).toFixed(1)}KB`;\n\t} else {\n\t\treturn `${(bytes / (1024 * 1024)).toFixed(1)}MB`;\n\t}\n}\n\n/**\n * Truncate content from the head (keep first N lines/bytes).\n * Suitable for file reads where you want to see the beginning.\n *\n * Never returns partial lines. If first line exceeds byte limit,\n * returns empty content with firstLineExceedsLimit=true.\n */\nexport function truncateHead(content: string, options: TruncationOptions = {}): TruncationResult {\n\tconst maxLines = options.maxLines ?? DEFAULT_MAX_LINES;\n\tconst maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n\n\tconst totalBytes = Buffer.byteLength(content, \"utf-8\");\n\tconst lines = content.split(\"\\n\");\n\tconst totalLines = lines.length;\n\n\t// Check if no truncation needed\n\tif (totalLines <= maxLines && totalBytes <= maxBytes) {\n\t\treturn {\n\t\t\tcontent,\n\t\t\ttruncated: false,\n\t\t\ttruncatedBy: null,\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: totalLines,\n\t\t\toutputBytes: totalBytes,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: false,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Check if first line alone exceeds byte limit\n\tconst firstLineBytes = Buffer.byteLength(lines[0], \"utf-8\");\n\tif (firstLineBytes > maxBytes) {\n\t\treturn {\n\t\t\tcontent: \"\",\n\t\t\ttruncated: true,\n\t\t\ttruncatedBy: \"bytes\",\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: 0,\n\t\t\toutputBytes: 0,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: true,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Collect complete lines that fit\n\tconst outputLinesArr: string[] = [];\n\tlet outputBytesCount = 0;\n\tlet truncatedBy: \"lines\" | \"bytes\" = \"lines\";\n\n\tfor (let i = 0; i < lines.length && i < maxLines; i++) {\n\t\tconst line = lines[i];\n\t\tconst lineBytes = Buffer.byteLength(line, \"utf-8\") + (i > 0 ? 1 : 0); // +1 for newline\n\n\t\tif (outputBytesCount + lineBytes > maxBytes) {\n\t\t\ttruncatedBy = \"bytes\";\n\t\t\tbreak;\n\t\t}\n\n\t\toutputLinesArr.push(line);\n\t\toutputBytesCount += lineBytes;\n\t}\n\n\t// If we exited due to line limit\n\tif (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {\n\t\ttruncatedBy = \"lines\";\n\t}\n\n\tconst outputContent = outputLinesArr.join(\"\\n\");\n\tconst finalOutputBytes = Buffer.byteLength(outputContent, \"utf-8\");\n\n\treturn {\n\t\tcontent: outputContent,\n\t\ttruncated: true,\n\t\ttruncatedBy,\n\t\ttotalLines,\n\t\ttotalBytes,\n\t\toutputLines: outputLinesArr.length,\n\t\toutputBytes: finalOutputBytes,\n\t\tlastLinePartial: false,\n\t\tfirstLineExceedsLimit: false,\n\t\tmaxLines,\n\t\tmaxBytes,\n\t};\n}\n\n/**\n * Truncate content from the tail (keep last N lines/bytes).\n * Suitable for bash output where you want to see the end (errors, final results).\n *\n * May return partial first line if the last line of original content exceeds byte limit.\n */\nexport function truncateTail(content: string, options: TruncationOptions = {}): TruncationResult {\n\tconst maxLines = options.maxLines ?? DEFAULT_MAX_LINES;\n\tconst maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n\n\tconst totalBytes = Buffer.byteLength(content, \"utf-8\");\n\tconst lines = content.split(\"\\n\");\n\tconst totalLines = lines.length;\n\n\t// Check if no truncation needed\n\tif (totalLines <= maxLines && totalBytes <= maxBytes) {\n\t\treturn {\n\t\t\tcontent,\n\t\t\ttruncated: false,\n\t\t\ttruncatedBy: null,\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: totalLines,\n\t\t\toutputBytes: totalBytes,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: false,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Work backwards from the end\n\tconst outputLinesArr: string[] = [];\n\tlet outputBytesCount = 0;\n\tlet truncatedBy: \"lines\" | \"bytes\" = \"lines\";\n\tlet lastLinePartial = false;\n\n\tfor (let i = lines.length - 1; i >= 0 && outputLinesArr.length < maxLines; i--) {\n\t\tconst line = lines[i];\n\t\tconst lineBytes = Buffer.byteLength(line, \"utf-8\") + (outputLinesArr.length > 0 ? 1 : 0); // +1 for newline\n\n\t\tif (outputBytesCount + lineBytes > maxBytes) {\n\t\t\ttruncatedBy = \"bytes\";\n\t\t\t// Edge case: if we haven't added ANY lines yet and this line exceeds maxBytes,\n\t\t\t// take the end of the line (partial)\n\t\t\tif (outputLinesArr.length === 0) {\n\t\t\t\tconst truncatedLine = truncateStringToBytesFromEnd(line, maxBytes);\n\t\t\t\toutputLinesArr.unshift(truncatedLine);\n\t\t\t\toutputBytesCount = Buffer.byteLength(truncatedLine, \"utf-8\");\n\t\t\t\tlastLinePartial = true;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\toutputLinesArr.unshift(line);\n\t\toutputBytesCount += lineBytes;\n\t}\n\n\t// If we exited due to line limit\n\tif (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {\n\t\ttruncatedBy = \"lines\";\n\t}\n\n\tconst outputContent = outputLinesArr.join(\"\\n\");\n\tconst finalOutputBytes = Buffer.byteLength(outputContent, \"utf-8\");\n\n\treturn {\n\t\tcontent: outputContent,\n\t\ttruncated: true,\n\t\ttruncatedBy,\n\t\ttotalLines,\n\t\ttotalBytes,\n\t\toutputLines: outputLinesArr.length,\n\t\toutputBytes: finalOutputBytes,\n\t\tlastLinePartial,\n\t\tfirstLineExceedsLimit: false,\n\t\tmaxLines,\n\t\tmaxBytes,\n\t};\n}\n\n/**\n * Truncate a string to fit within a byte limit (from the end).\n * Handles multi-byte UTF-8 characters correctly.\n */\nfunction truncateStringToBytesFromEnd(str: string, maxBytes: number): string {\n\tconst buf = Buffer.from(str, \"utf-8\");\n\tif (buf.length <= maxBytes) {\n\t\treturn str;\n\t}\n\n\t// Start from the end, skip maxBytes back\n\tlet start = buf.length - maxBytes;\n\n\t// Find a valid UTF-8 boundary (start of a character)\n\twhile (start < buf.length && (buf[start] & 0xc0) === 0x80) {\n\t\tstart++;\n\t}\n\n\treturn buf.slice(start).toString(\"utf-8\");\n}\n\n/**\n * Truncate a single line to max characters, adding [truncated] suffix.\n * Used for grep match lines.\n */\nexport function truncateLine(\n\tline: string,\n\tmaxChars: number = GREP_MAX_LINE_LENGTH,\n): { text: string; wasTruncated: boolean } {\n\tif (line.length <= maxChars) {\n\t\treturn { text: line, wasTruncated: false };\n\t}\n\treturn { text: `${line.slice(0, maxChars)}... [truncated]`, wasTruncated: true };\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import { type Static, Type } from "typebox";
|
|
3
|
+
import type { ToolDefinition } from "../extensions/types.js";
|
|
4
|
+
declare const writeSchema: Type.TObject<{
|
|
5
|
+
path: Type.TString;
|
|
6
|
+
content: Type.TString;
|
|
7
|
+
}>;
|
|
8
|
+
export type WriteToolInput = Static<typeof writeSchema>;
|
|
9
|
+
/**
|
|
10
|
+
* Pluggable operations for the write tool.
|
|
11
|
+
* Override these to delegate file writing to remote systems (for example SSH).
|
|
12
|
+
*/
|
|
13
|
+
export interface WriteOperations {
|
|
14
|
+
/** Write content to a file */
|
|
15
|
+
writeFile: (absolutePath: string, content: string) => Promise<void>;
|
|
16
|
+
/** Create directory recursively */
|
|
17
|
+
mkdir: (dir: string) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface WriteToolOptions {
|
|
20
|
+
/** Custom operations for file writing. Default: local filesystem */
|
|
21
|
+
operations?: WriteOperations;
|
|
22
|
+
}
|
|
23
|
+
export declare function createWriteToolDefinition(cwd: string, options?: WriteToolOptions): ToolDefinition<typeof writeSchema, undefined>;
|
|
24
|
+
export declare function createWriteTool(cwd: string, options?: WriteToolOptions): AgentTool<typeof writeSchema>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=write.d.ts.map
|
|
@@ -0,0 +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;AAI/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AAMtF,QAAA,MAAM,WAAW;;;EAGf,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,8BAA8B;IAC9B,SAAS,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,mCAAmC;IACnC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAOD,MAAM,WAAW,gBAAgB;IAChC,oEAAoE;IACpE,UAAU,CAAC,EAAE,eAAe,CAAC;CAC7B;AA6ID,wBAAgB,yBAAyB,CACxC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,gBAAgB,GACxB,cAAc,CAAC,OAAO,WAAW,EAAE,SAAS,CAAC,CA6F/C;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC,OAAO,WAAW,CAAC,CAEtG","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Container, Text } from \"@earendil-works/pi-tui\";\nimport { mkdir as fsMkdir, writeFile as fsWriteFile } from \"fs/promises\";\nimport { dirname } from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { getLanguageFromPath, highlightCode } from \"../../modes/interactive/theme/theme.js\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.js\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.js\";\nimport { resolveToCwd } from \"./path-utils.js\";\nimport { invalidArgText, normalizeDisplayText, replaceTabs, shortenPath, str } from \"./render-utils.js\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.js\";\n\nconst writeSchema = Type.Object({\n\tpath: Type.String({ description: \"Path to the file to write (relative or absolute)\" }),\n\tcontent: Type.String({ description: \"Content to write to the file\" }),\n});\n\nexport type WriteToolInput = Static<typeof writeSchema>;\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) => Promise<void>;\n\t/** Create directory recursively */\n\tmkdir: (dir: string) => Promise<void>;\n}\n\nconst defaultWriteOperations: WriteOperations = {\n\twriteFile: (path, content) => fsWriteFile(path, content, \"utf-8\"),\n\tmkdir: (dir) => fsMkdir(dir, { recursive: true }).then(() => {}),\n};\n\nexport interface WriteToolOptions {\n\t/** Custom operations for file writing. Default: local filesystem */\n\toperations?: WriteOperations;\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; file_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?.file_path ?? 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 += `${theme.fg(\"muted\", `\\n... (${remaining} more lines, ${totalLines} total,`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\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, undefined> {\n\tconst ops = options?.operations ?? defaultWriteOperations;\n\treturn {\n\t\tname: \"write\",\n\t\tlabel: \"write\",\n\t\tdescription:\n\t\t\t\"Write content to a file. Creates the file if it doesn't exist, overwrites if it does. Automatically creates parent directories.\",\n\t\tpromptSnippet: \"Create or overwrite files\",\n\t\tpromptGuidelines: [\"Use write only for new files or complete rewrites.\"],\n\t\tparameters: writeSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ path, content }: { path: string; content: string },\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\t_ctx?,\n\t\t) {\n\t\t\tconst absolutePath = resolveToCwd(path, cwd);\n\t\t\tconst dir = dirname(absolutePath);\n\t\t\treturn withFileMutationQueue(\n\t\t\t\tabsolutePath,\n\t\t\t\t() =>\n\t\t\t\t\tnew Promise<{ content: Array<{ type: \"text\"; text: string }>; details: undefined }>(\n\t\t\t\t\t\t(resolve, reject) => {\n\t\t\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlet aborted = false;\n\t\t\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t\t\t(async () => {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t// Create parent directories if needed.\n\t\t\t\t\t\t\t\t\tawait ops.mkdir(dir);\n\t\t\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\t\t\t// Write the file contents.\n\t\t\t\t\t\t\t\t\tawait ops.writeFile(absolutePath, content);\n\t\t\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t\t\t\t\t{ type: \"text\", text: `Successfully wrote ${content.length} bytes to ${path}` },\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t\t\tif (!aborted) reject(error);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})();\n\t\t\t\t\t\t},\n\t\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; file_path?: string; content?: string } | undefined;\n\t\t\tconst rawPath = str(renderArgs?.file_path ?? 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"]}
|