@bastani/atomic 0.9.2-alpha.1 → 0.9.3-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/README.md +2 -2
- package/dist/builtin/cursor/CHANGELOG.md +6 -0
- package/dist/builtin/cursor/package.json +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/CHANGELOG.md +12 -0
- package/dist/builtin/mcp/direct-tools.ts +4 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/mcp/proxy-call.ts +3 -1
- package/dist/builtin/mcp/utils.ts +18 -7
- package/dist/builtin/subagents/CHANGELOG.md +17 -0
- package/dist/builtin/subagents/README.md +6 -6
- package/dist/builtin/subagents/agents/code-simplifier.md +7 -6
- package/dist/builtin/subagents/agents/codebase-analyzer.md +5 -4
- package/dist/builtin/subagents/agents/codebase-locator.md +3 -3
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +10 -10
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +4 -4
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +3 -3
- package/dist/builtin/subagents/agents/codebase-research-locator.md +4 -4
- package/dist/builtin/subagents/agents/debugger.md +5 -5
- package/dist/builtin/subagents/agents/worker.md +56 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +11 -11
- package/dist/builtin/subagents/src/agents/agent-loaders.ts +3 -5
- package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +3 -3
- package/dist/builtin/subagents/src/extension/schemas.ts +2 -2
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -3
- package/dist/builtin/subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +1 -1
- package/dist/builtin/subagents/src/runs/shared/nested-render.ts +2 -2
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +2 -1
- package/dist/builtin/subagents/src/shared/types-depth.ts +5 -5
- package/dist/builtin/subagents/src/shared/types-runtime.ts +2 -1
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +2 -2
- package/dist/builtin/web-access/CHANGELOG.md +6 -0
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +21 -0
- package/dist/builtin/workflows/README.md +2 -2
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +11 -6
- package/dist/builtin/workflows/builtin/goal-ledger.ts +33 -1
- package/dist/builtin/workflows/builtin/goal-prompts.ts +23 -28
- package/dist/builtin/workflows/builtin/goal-reducer.ts +2 -2
- package/dist/builtin/workflows/builtin/goal-reports.ts +2 -5
- package/dist/builtin/workflows/builtin/goal-review.ts +1 -1
- package/dist/builtin/workflows/builtin/goal-runner.ts +10 -17
- package/dist/builtin/workflows/builtin/open-claude-design-feedback.ts +3 -3
- package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +1 -3
- package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +1 -1
- package/dist/builtin/workflows/builtin/ralph-core.ts +7 -17
- package/dist/builtin/workflows/builtin/ralph-runner.ts +11 -18
- package/dist/builtin/workflows/builtin/shared-prompts.ts +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/config-loader.ts +35 -15
- package/dist/builtin/workflows/src/extension/discovery.ts +20 -8
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +1 -2
- package/dist/builtin/workflows/src/extension/wiring.ts +1 -1
- package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +11 -10
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +9 -9
- package/dist/cli/args.js.map +1 -1
- package/dist/config-self-update.d.ts.map +1 -1
- package/dist/config-self-update.js +3 -4
- package/dist/config-self-update.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -5
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts +1 -0
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +1 -0
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +23 -0
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/bash-executor.d.ts +2 -0
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +1 -0
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +29 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +36 -1
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/context-compaction-metrics.d.ts +14 -2
- package/dist/core/compaction/context-compaction-metrics.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-metrics.js +50 -1
- package/dist/core/compaction/context-compaction-metrics.js.map +1 -1
- package/dist/core/compaction/context-compaction-prompt.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-prompt.js +2 -0
- package/dist/core/compaction/context-compaction-prompt.js.map +1 -1
- package/dist/core/compaction/context-compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-runner.js +1 -1
- package/dist/core/compaction/context-compaction-runner.js.map +1 -1
- package/dist/core/compaction/context-deletion-application.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-application.js +5 -5
- package/dist/core/compaction/context-deletion-application.js.map +1 -1
- package/dist/core/compaction/context-deletion-targets.d.ts +2 -0
- package/dist/core/compaction/context-deletion-targets.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-targets.js +23 -3
- package/dist/core/compaction/context-deletion-targets.js.map +1 -1
- package/dist/core/compaction/context-deletion-tool-definitions.d.ts +6 -0
- package/dist/core/compaction/context-deletion-tool-definitions.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-tool-definitions.js.map +1 -1
- package/dist/core/compaction/context-deletion-tools.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-tools.js +18 -10
- package/dist/core/compaction/context-deletion-tools.js.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.js +2 -4
- package/dist/core/compaction/context-transcript-analysis.js.map +1 -1
- package/dist/core/copilot-gemini-tool-arguments.d.ts.map +1 -1
- package/dist/core/copilot-gemini-tool-arguments.js +2 -60
- package/dist/core/copilot-gemini-tool-arguments.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +2 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +11 -3
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +11 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/tool-events.d.ts +13 -13
- package/dist/core/extensions/tool-events.d.ts.map +1 -1
- package/dist/core/extensions/tool-events.js +3 -3
- package/dist/core/extensions/tool-events.js.map +1 -1
- package/dist/core/extensions/types.d.ts +1 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/flattened-tool-arguments.d.ts +18 -0
- package/dist/core/flattened-tool-arguments.d.ts.map +1 -1
- package/dist/core/flattened-tool-arguments.js +104 -0
- package/dist/core/flattened-tool-arguments.js.map +1 -1
- package/dist/core/sdk-exports.d.ts +1 -1
- package/dist/core/sdk-exports.d.ts.map +1 -1
- package/dist/core/sdk-exports.js +1 -1
- package/dist/core/sdk-exports.js.map +1 -1
- package/dist/core/sdk-types.d.ts +2 -2
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +4 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +18 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-resource-accessors.d.ts +4 -0
- package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-resource-accessors.js +15 -0
- package/dist/core/settings-manager-resource-accessors.js.map +1 -1
- package/dist/core/settings-types.d.ts +11 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/system-prompt.d.ts +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +3 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/artifact-protocol.d.ts +11 -0
- package/dist/core/tools/artifact-protocol.d.ts.map +1 -0
- package/dist/core/tools/artifact-protocol.js +76 -0
- package/dist/core/tools/artifact-protocol.js.map +1 -0
- package/dist/core/tools/artifacts.d.ts +18 -0
- package/dist/core/tools/artifacts.d.ts.map +1 -0
- package/dist/core/tools/artifacts.js +90 -0
- package/dist/core/tools/artifacts.js.map +1 -0
- package/dist/core/tools/bash-async-jobs.d.ts +20 -0
- package/dist/core/tools/bash-async-jobs.d.ts.map +1 -0
- package/dist/core/tools/bash-async-jobs.js +59 -0
- package/dist/core/tools/bash-async-jobs.js.map +1 -0
- package/dist/core/tools/bash-async-output.d.ts +10 -0
- package/dist/core/tools/bash-async-output.d.ts.map +1 -0
- package/dist/core/tools/bash-async-output.js +80 -0
- package/dist/core/tools/bash-async-output.js.map +1 -0
- package/dist/core/tools/bash-interceptor.d.ts +10 -0
- package/dist/core/tools/bash-interceptor.d.ts.map +1 -0
- package/dist/core/tools/bash-interceptor.js +39 -0
- package/dist/core/tools/bash-interceptor.js.map +1 -0
- package/dist/core/tools/bash-leading-cd.d.ts +7 -0
- package/dist/core/tools/bash-leading-cd.d.ts.map +1 -0
- package/dist/core/tools/bash-leading-cd.js +59 -0
- package/dist/core/tools/bash-leading-cd.js.map +1 -0
- package/dist/core/tools/bash-pty-native.d.ts +14 -0
- package/dist/core/tools/bash-pty-native.d.ts.map +1 -0
- package/dist/core/tools/bash-pty-native.js +71 -0
- package/dist/core/tools/bash-pty-native.js.map +1 -0
- package/dist/core/tools/bash.d.ts +28 -17
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +152 -35
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/block-resolver.d.ts +16 -0
- package/dist/core/tools/block-resolver.d.ts.map +1 -0
- package/dist/core/tools/block-resolver.js +74 -0
- package/dist/core/tools/block-resolver.js.map +1 -0
- package/dist/core/tools/conflict-registry.d.ts +16 -0
- package/dist/core/tools/conflict-registry.d.ts.map +1 -0
- package/dist/core/tools/conflict-registry.js +44 -0
- package/dist/core/tools/conflict-registry.js.map +1 -0
- package/dist/core/tools/directory-tree.d.ts +13 -0
- package/dist/core/tools/directory-tree.d.ts.map +1 -0
- package/dist/core/tools/directory-tree.js +81 -0
- package/dist/core/tools/directory-tree.js.map +1 -0
- package/dist/core/tools/edit.d.ts +4 -29
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +136 -228
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/fetch-url.d.ts +74 -0
- package/dist/core/tools/fetch-url.d.ts.map +1 -0
- package/dist/core/tools/fetch-url.js +518 -0
- package/dist/core/tools/fetch-url.js.map +1 -0
- package/dist/core/tools/find.d.ts +27 -9
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +400 -176
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/glob-path-utils.d.ts +8 -0
- package/dist/core/tools/glob-path-utils.d.ts.map +1 -0
- package/dist/core/tools/glob-path-utils.js +26 -0
- package/dist/core/tools/glob-path-utils.js.map +1 -0
- package/dist/core/tools/grep.d.ts +12 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +141 -17
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/hashline-engine/apply.d.ts +11 -0
- package/dist/core/tools/hashline-engine/apply.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/apply.js +752 -0
- package/dist/core/tools/hashline-engine/apply.js.map +1 -0
- package/dist/core/tools/hashline-engine/block.d.ts +40 -0
- package/dist/core/tools/hashline-engine/block.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/block.js +117 -0
- package/dist/core/tools/hashline-engine/block.js.map +1 -0
- package/dist/core/tools/hashline-engine/diff-preview.d.ts +15 -0
- package/dist/core/tools/hashline-engine/diff-preview.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/diff-preview.js +98 -0
- package/dist/core/tools/hashline-engine/diff-preview.js.map +1 -0
- package/dist/core/tools/hashline-engine/format.d.ts +71 -0
- package/dist/core/tools/hashline-engine/format.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/format.js +178 -0
- package/dist/core/tools/hashline-engine/format.js.map +1 -0
- package/dist/core/tools/hashline-engine/fs.d.ts +81 -0
- package/dist/core/tools/hashline-engine/fs.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/fs.js +143 -0
- package/dist/core/tools/hashline-engine/fs.js.map +1 -0
- package/dist/core/tools/hashline-engine/index.d.ts +18 -0
- package/dist/core/tools/hashline-engine/index.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/index.js +20 -0
- package/dist/core/tools/hashline-engine/index.js.map +1 -0
- package/dist/core/tools/hashline-engine/input.d.ts +101 -0
- package/dist/core/tools/hashline-engine/input.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/input.js +398 -0
- package/dist/core/tools/hashline-engine/input.js.map +1 -0
- package/dist/core/tools/hashline-engine/messages.d.ts +99 -0
- package/dist/core/tools/hashline-engine/messages.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/messages.js +144 -0
- package/dist/core/tools/hashline-engine/messages.js.map +1 -0
- package/dist/core/tools/hashline-engine/mismatch.d.ts +45 -0
- package/dist/core/tools/hashline-engine/mismatch.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/mismatch.js +90 -0
- package/dist/core/tools/hashline-engine/mismatch.js.map +1 -0
- package/dist/core/tools/hashline-engine/normalize.d.ts +21 -0
- package/dist/core/tools/hashline-engine/normalize.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/normalize.js +33 -0
- package/dist/core/tools/hashline-engine/normalize.js.map +1 -0
- package/dist/core/tools/hashline-engine/parser.d.ts +24 -0
- package/dist/core/tools/hashline-engine/parser.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/parser.js +381 -0
- package/dist/core/tools/hashline-engine/parser.js.map +1 -0
- package/dist/core/tools/hashline-engine/patcher.d.ts +118 -0
- package/dist/core/tools/hashline-engine/patcher.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/patcher.js +341 -0
- package/dist/core/tools/hashline-engine/patcher.js.map +1 -0
- package/dist/core/tools/hashline-engine/prefixes.d.ts +43 -0
- package/dist/core/tools/hashline-engine/prefixes.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/prefixes.js +135 -0
- package/dist/core/tools/hashline-engine/prefixes.js.map +1 -0
- package/dist/core/tools/hashline-engine/recovery.d.ts +41 -0
- package/dist/core/tools/hashline-engine/recovery.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/recovery.js +168 -0
- package/dist/core/tools/hashline-engine/recovery.js.map +1 -0
- package/dist/core/tools/hashline-engine/snapshots.d.ts +65 -0
- package/dist/core/tools/hashline-engine/snapshots.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/snapshots.js +108 -0
- package/dist/core/tools/hashline-engine/snapshots.js.map +1 -0
- package/dist/core/tools/hashline-engine/stream.d.ts +3 -0
- package/dist/core/tools/hashline-engine/stream.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/stream.js +111 -0
- package/dist/core/tools/hashline-engine/stream.js.map +1 -0
- package/dist/core/tools/hashline-engine/tokenizer.d.ts +69 -0
- package/dist/core/tools/hashline-engine/tokenizer.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/tokenizer.js +430 -0
- package/dist/core/tools/hashline-engine/tokenizer.js.map +1 -0
- package/dist/core/tools/hashline-engine/types.d.ts +166 -0
- package/dist/core/tools/hashline-engine/types.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/types.js +9 -0
- package/dist/core/tools/hashline-engine/types.js.map +1 -0
- package/dist/core/tools/hashline.d.ts +29 -0
- package/dist/core/tools/hashline.d.ts.map +1 -0
- package/dist/core/tools/hashline.js +110 -0
- package/dist/core/tools/hashline.js.map +1 -0
- package/dist/core/tools/index.d.ts +6 -4
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +52 -35
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/notebook.d.ts +38 -0
- package/dist/core/tools/notebook.d.ts.map +1 -0
- package/dist/core/tools/notebook.js +125 -0
- package/dist/core/tools/notebook.js.map +1 -0
- package/dist/core/tools/read-document-extract.d.ts +9 -0
- package/dist/core/tools/read-document-extract.d.ts.map +1 -0
- package/dist/core/tools/read-document-extract.js +212 -0
- package/dist/core/tools/read-document-extract.js.map +1 -0
- package/dist/core/tools/read-selectors.d.ts +24 -0
- package/dist/core/tools/read-selectors.d.ts.map +1 -0
- package/dist/core/tools/read-selectors.js +277 -0
- package/dist/core/tools/read-selectors.js.map +1 -0
- package/dist/core/tools/read-url.d.ts +37 -0
- package/dist/core/tools/read-url.d.ts.map +1 -0
- package/dist/core/tools/read-url.js +39 -0
- package/dist/core/tools/read-url.js.map +1 -0
- package/dist/core/tools/read.d.ts +11 -11
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +224 -94
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/resource-selectors.d.ts +44 -0
- package/dist/core/tools/resource-selectors.d.ts.map +1 -0
- package/dist/core/tools/resource-selectors.js +808 -0
- package/dist/core/tools/resource-selectors.js.map +1 -0
- package/dist/core/tools/search-details.d.ts +26 -0
- package/dist/core/tools/search-details.d.ts.map +1 -0
- package/dist/core/tools/search-details.js +24 -0
- package/dist/core/tools/search-details.js.map +1 -0
- package/dist/core/tools/search-line-ranges.d.ts +11 -0
- package/dist/core/tools/search-line-ranges.d.ts.map +1 -0
- package/dist/core/tools/search-line-ranges.js +65 -0
- package/dist/core/tools/search-line-ranges.js.map +1 -0
- package/dist/core/tools/search-native.d.ts +97 -0
- package/dist/core/tools/search-native.d.ts.map +1 -0
- package/dist/core/tools/search-native.js +27 -0
- package/dist/core/tools/search-native.js.map +1 -0
- package/dist/core/tools/search.d.ts +24 -0
- package/dist/core/tools/search.d.ts.map +1 -0
- package/dist/core/tools/search.js +573 -0
- package/dist/core/tools/search.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +4 -4
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +3 -3
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/url-ip-guards.d.ts +4 -0
- package/dist/core/tools/url-ip-guards.d.ts.map +1 -0
- package/dist/core/tools/url-ip-guards.js +126 -0
- package/dist/core/tools/url-ip-guards.js.map +1 -0
- package/dist/core/tools/write.d.ts +12 -2
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +166 -14
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +2 -3
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/index-extensions.d.ts +2 -2
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +9 -2
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
- package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +7 -0
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +2 -0
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +0 -5
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +1 -0
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +80 -2
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.js +3 -0
- package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +51 -0
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +5 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +5 -0
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +12 -0
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +4 -1
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-onboarding.d.ts +11 -0
- package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-onboarding.js +220 -0
- package/dist/modes/interactive/interactive-onboarding.js.map +1 -0
- package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +4 -0
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +6 -0
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +9 -4
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +28 -0
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +21 -1
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/markit.d.ts +8 -0
- package/dist/utils/markit.d.ts.map +1 -0
- package/dist/utils/markit.js +53 -0
- package/dist/utils/markit.js.map +1 -0
- package/dist/utils/paths.d.ts +2 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +14 -1
- package/dist/utils/paths.js.map +1 -1
- package/docs/compaction.md +16 -1
- package/docs/containerization.md +1 -1
- package/docs/docs.json +1 -0
- package/docs/extensions.md +25 -36
- package/docs/quickstart.md +11 -6
- package/docs/sdk.md +5 -5
- package/docs/settings.md +7 -0
- package/docs/subagents.md +3 -2
- package/docs/tools.md +49 -0
- package/docs/usage.md +3 -3
- package/docs/workflows.md +7 -5
- package/examples/extensions/subagent/README.md +5 -5
- package/examples/extensions/subagent/agents/planner.md +1 -1
- package/examples/extensions/subagent/agents/reviewer.md +1 -1
- package/examples/extensions/subagent/agents/scout.md +2 -2
- package/examples/extensions/subagent/display.ts +3 -3
- package/examples/sdk/05-tools.ts +3 -3
- package/examples/sdk/README.md +1 -1
- package/package.json +3 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ImageContent, TextContent } from "@earendil-works/pi-ai";
|
|
2
2
|
import type { EditToolDetails } from "../tools/edit.ts";
|
|
3
|
-
import type { BashToolDetails, BashToolInput, EditToolInput, FindToolDetails, FindToolInput,
|
|
3
|
+
import type { BashToolDetails, BashToolInput, EditToolInput, FindToolDetails, FindToolInput, LsToolDetails, LsToolInput, ReadToolDetails, ReadToolInput, SearchToolDetails, SearchToolInput, WriteToolInput } from "../tools/index.ts";
|
|
4
4
|
interface ToolCallEventBase {
|
|
5
5
|
type: "tool_call";
|
|
6
6
|
toolCallId: string;
|
|
@@ -21,14 +21,14 @@ export interface WriteToolCallEvent extends ToolCallEventBase {
|
|
|
21
21
|
toolName: "write";
|
|
22
22
|
input: WriteToolInput;
|
|
23
23
|
}
|
|
24
|
-
export interface GrepToolCallEvent extends ToolCallEventBase {
|
|
25
|
-
toolName: "grep";
|
|
26
|
-
input: GrepToolInput;
|
|
27
|
-
}
|
|
28
24
|
export interface FindToolCallEvent extends ToolCallEventBase {
|
|
29
25
|
toolName: "find";
|
|
30
26
|
input: FindToolInput;
|
|
31
27
|
}
|
|
28
|
+
export interface SearchToolCallEvent extends ToolCallEventBase {
|
|
29
|
+
toolName: "search";
|
|
30
|
+
input: SearchToolInput;
|
|
31
|
+
}
|
|
32
32
|
export interface LsToolCallEvent extends ToolCallEventBase {
|
|
33
33
|
toolName: "ls";
|
|
34
34
|
input: LsToolInput;
|
|
@@ -43,7 +43,7 @@ export interface CustomToolCallEvent extends ToolCallEventBase {
|
|
|
43
43
|
* `event.input` is mutable. Mutate it in place to patch tool arguments before execution.
|
|
44
44
|
* Later `tool_call` handlers see earlier mutations. No re-validation is performed after mutation.
|
|
45
45
|
*/
|
|
46
|
-
export type ToolCallEvent = BashToolCallEvent | ReadToolCallEvent | EditToolCallEvent | WriteToolCallEvent |
|
|
46
|
+
export type ToolCallEvent = BashToolCallEvent | ReadToolCallEvent | EditToolCallEvent | WriteToolCallEvent | FindToolCallEvent | SearchToolCallEvent | LsToolCallEvent | CustomToolCallEvent;
|
|
47
47
|
interface ToolResultEventBase {
|
|
48
48
|
type: "tool_result";
|
|
49
49
|
toolCallId: string;
|
|
@@ -67,14 +67,14 @@ export interface WriteToolResultEvent extends ToolResultEventBase {
|
|
|
67
67
|
toolName: "write";
|
|
68
68
|
details: undefined;
|
|
69
69
|
}
|
|
70
|
-
export interface GrepToolResultEvent extends ToolResultEventBase {
|
|
71
|
-
toolName: "grep";
|
|
72
|
-
details: GrepToolDetails | undefined;
|
|
73
|
-
}
|
|
74
70
|
export interface FindToolResultEvent extends ToolResultEventBase {
|
|
75
71
|
toolName: "find";
|
|
76
72
|
details: FindToolDetails | undefined;
|
|
77
73
|
}
|
|
74
|
+
export interface SearchToolResultEvent extends ToolResultEventBase {
|
|
75
|
+
toolName: "search";
|
|
76
|
+
details: SearchToolDetails | undefined;
|
|
77
|
+
}
|
|
78
78
|
export interface LsToolResultEvent extends ToolResultEventBase {
|
|
79
79
|
toolName: "ls";
|
|
80
80
|
details: LsToolDetails | undefined;
|
|
@@ -84,13 +84,13 @@ export interface CustomToolResultEvent extends ToolResultEventBase {
|
|
|
84
84
|
details: unknown;
|
|
85
85
|
}
|
|
86
86
|
/** Fired after a tool executes. Can modify result. */
|
|
87
|
-
export type ToolResultEvent = BashToolResultEvent | ReadToolResultEvent | EditToolResultEvent | WriteToolResultEvent |
|
|
87
|
+
export type ToolResultEvent = BashToolResultEvent | ReadToolResultEvent | EditToolResultEvent | WriteToolResultEvent | FindToolResultEvent | SearchToolResultEvent | LsToolResultEvent | CustomToolResultEvent;
|
|
88
88
|
export declare function isBashToolResult(e: ToolResultEvent): e is BashToolResultEvent;
|
|
89
89
|
export declare function isReadToolResult(e: ToolResultEvent): e is ReadToolResultEvent;
|
|
90
90
|
export declare function isEditToolResult(e: ToolResultEvent): e is EditToolResultEvent;
|
|
91
91
|
export declare function isWriteToolResult(e: ToolResultEvent): e is WriteToolResultEvent;
|
|
92
|
-
export declare function isGrepToolResult(e: ToolResultEvent): e is GrepToolResultEvent;
|
|
93
92
|
export declare function isFindToolResult(e: ToolResultEvent): e is FindToolResultEvent;
|
|
93
|
+
export declare function isSearchToolResult(e: ToolResultEvent): e is SearchToolResultEvent;
|
|
94
94
|
export declare function isLsToolResult(e: ToolResultEvent): e is LsToolResultEvent;
|
|
95
95
|
/**
|
|
96
96
|
* Type guard for narrowing ToolCallEvent by tool name.
|
|
@@ -116,8 +116,8 @@ export declare function isToolCallEventType(toolName: "bash", event: ToolCallEve
|
|
|
116
116
|
export declare function isToolCallEventType(toolName: "read", event: ToolCallEvent): event is ReadToolCallEvent;
|
|
117
117
|
export declare function isToolCallEventType(toolName: "edit", event: ToolCallEvent): event is EditToolCallEvent;
|
|
118
118
|
export declare function isToolCallEventType(toolName: "write", event: ToolCallEvent): event is WriteToolCallEvent;
|
|
119
|
-
export declare function isToolCallEventType(toolName: "grep", event: ToolCallEvent): event is GrepToolCallEvent;
|
|
120
119
|
export declare function isToolCallEventType(toolName: "find", event: ToolCallEvent): event is FindToolCallEvent;
|
|
120
|
+
export declare function isToolCallEventType(toolName: "search", event: ToolCallEvent): event is SearchToolCallEvent;
|
|
121
121
|
export declare function isToolCallEventType(toolName: "ls", event: ToolCallEvent): event is LsToolCallEvent;
|
|
122
122
|
export declare function isToolCallEventType<TName extends string, TInput extends Record<string, unknown>>(toolName: TName, event: ToolCallEvent): event is ToolCallEvent & {
|
|
123
123
|
toolName: TName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-events.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/tool-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EACX,eAAe,EACf,aAAa,EACb,aAAa,EACb,eAAe,EACf,aAAa,EACb,eAAe,EACf,aAAa,EACb,aAAa,EACb,WAAW,EACX,eAAe,EACf,aAAa,EACb,cAAc,EACd,MAAM,mBAAmB,CAAC;AAM3B,UAAU,iBAAiB;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC5D,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,cAAc,CAAC;CACtB;AAED,MAAM,WAAW,iBAAkB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GAAG,CAAC,IAAI,iBAAiB,CAEzE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,iBAAiB,CAAC;AACxG,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,iBAAiB,CAAC;AACxG,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,iBAAiB,CAAC;AACxG,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,kBAAkB,CAAC;AAC1G,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,iBAAiB,CAAC;AACxG,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,iBAAiB,CAAC;AACxG,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,eAAe,CAAC;AACpG,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/F,QAAQ,EAAE,KAAK,EACf,KAAK,EAAE,aAAa,GAClB,KAAK,IAAI,aAAa,GAAG;IAAE,QAAQ,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC","sourcesContent":["import type { ImageContent, TextContent } from \"@earendil-works/pi-ai\";\nimport type { EditToolDetails } from \"../tools/edit.ts\";\nimport type {\n\tBashToolDetails,\n\tBashToolInput,\n\tEditToolInput,\n\tFindToolDetails,\n\tFindToolInput,\n\tGrepToolDetails,\n\tGrepToolInput,\n\tLsToolDetails,\n\tLsToolInput,\n\tReadToolDetails,\n\tReadToolInput,\n\tWriteToolInput,\n} from \"../tools/index.ts\";\n\n// ============================================================================\n// Tool Events\n// ============================================================================\n\ninterface ToolCallEventBase {\n\ttype: \"tool_call\";\n\ttoolCallId: string;\n}\n\nexport interface BashToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"bash\";\n\tinput: BashToolInput;\n}\n\nexport interface ReadToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"read\";\n\tinput: ReadToolInput;\n}\n\nexport interface EditToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"edit\";\n\tinput: EditToolInput;\n}\n\nexport interface WriteToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"write\";\n\tinput: WriteToolInput;\n}\n\nexport interface GrepToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"grep\";\n\tinput: GrepToolInput;\n}\n\nexport interface FindToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"find\";\n\tinput: FindToolInput;\n}\n\nexport interface LsToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"ls\";\n\tinput: LsToolInput;\n}\n\nexport interface CustomToolCallEvent extends ToolCallEventBase {\n\ttoolName: string;\n\tinput: Record<string, unknown>;\n}\n\n/**\n * Fired before a tool executes. Can block.\n *\n * `event.input` is mutable. Mutate it in place to patch tool arguments before execution.\n * Later `tool_call` handlers see earlier mutations. No re-validation is performed after mutation.\n */\nexport type ToolCallEvent =\n\t| BashToolCallEvent\n\t| ReadToolCallEvent\n\t| EditToolCallEvent\n\t| WriteToolCallEvent\n\t| GrepToolCallEvent\n\t| FindToolCallEvent\n\t| LsToolCallEvent\n\t| CustomToolCallEvent;\n\ninterface ToolResultEventBase {\n\ttype: \"tool_result\";\n\ttoolCallId: string;\n\tinput: Record<string, unknown>;\n\tcontent: (TextContent | ImageContent)[];\n\tisError: boolean;\n}\n\nexport interface BashToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"bash\";\n\tdetails: BashToolDetails | undefined;\n}\n\nexport interface ReadToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"read\";\n\tdetails: ReadToolDetails | undefined;\n}\n\nexport interface EditToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"edit\";\n\tdetails: EditToolDetails | undefined;\n}\n\nexport interface WriteToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"write\";\n\tdetails: undefined;\n}\n\nexport interface GrepToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"grep\";\n\tdetails: GrepToolDetails | undefined;\n}\n\nexport interface FindToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"find\";\n\tdetails: FindToolDetails | undefined;\n}\n\nexport interface LsToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"ls\";\n\tdetails: LsToolDetails | undefined;\n}\n\nexport interface CustomToolResultEvent extends ToolResultEventBase {\n\ttoolName: string;\n\tdetails: unknown;\n}\n\n/** Fired after a tool executes. Can modify result. */\nexport type ToolResultEvent =\n\t| BashToolResultEvent\n\t| ReadToolResultEvent\n\t| EditToolResultEvent\n\t| WriteToolResultEvent\n\t| GrepToolResultEvent\n\t| FindToolResultEvent\n\t| LsToolResultEvent\n\t| CustomToolResultEvent;\n\n// Type guards for ToolResultEvent\nexport function isBashToolResult(e: ToolResultEvent): e is BashToolResultEvent {\n\treturn e.toolName === \"bash\";\n}\nexport function isReadToolResult(e: ToolResultEvent): e is ReadToolResultEvent {\n\treturn e.toolName === \"read\";\n}\nexport function isEditToolResult(e: ToolResultEvent): e is EditToolResultEvent {\n\treturn e.toolName === \"edit\";\n}\nexport function isWriteToolResult(e: ToolResultEvent): e is WriteToolResultEvent {\n\treturn e.toolName === \"write\";\n}\nexport function isGrepToolResult(e: ToolResultEvent): e is GrepToolResultEvent {\n\treturn e.toolName === \"grep\";\n}\nexport function isFindToolResult(e: ToolResultEvent): e is FindToolResultEvent {\n\treturn e.toolName === \"find\";\n}\nexport function isLsToolResult(e: ToolResultEvent): e is LsToolResultEvent {\n\treturn e.toolName === \"ls\";\n}\n\n/**\n * Type guard for narrowing ToolCallEvent by tool name.\n *\n * Built-in tools narrow automatically (no type params needed):\n * ```ts\n * if (isToolCallEventType(\"bash\", event)) {\n * event.input.command; // string\n * }\n * ```\n *\n * Custom tools require explicit type parameters:\n * ```ts\n * if (isToolCallEventType<\"my_tool\", MyToolInput>(\"my_tool\", event)) {\n * event.input.action; // typed\n * }\n * ```\n *\n * Note: Direct narrowing via `event.toolName === \"bash\"` doesn't work because\n * CustomToolCallEvent.toolName is `string` which overlaps with all literals.\n */\nexport function isToolCallEventType(toolName: \"bash\", event: ToolCallEvent): event is BashToolCallEvent;\nexport function isToolCallEventType(toolName: \"read\", event: ToolCallEvent): event is ReadToolCallEvent;\nexport function isToolCallEventType(toolName: \"edit\", event: ToolCallEvent): event is EditToolCallEvent;\nexport function isToolCallEventType(toolName: \"write\", event: ToolCallEvent): event is WriteToolCallEvent;\nexport function isToolCallEventType(toolName: \"grep\", event: ToolCallEvent): event is GrepToolCallEvent;\nexport function isToolCallEventType(toolName: \"find\", event: ToolCallEvent): event is FindToolCallEvent;\nexport function isToolCallEventType(toolName: \"ls\", event: ToolCallEvent): event is LsToolCallEvent;\nexport function isToolCallEventType<TName extends string, TInput extends Record<string, unknown>>(\n\ttoolName: TName,\n\tevent: ToolCallEvent,\n): event is ToolCallEvent & { toolName: TName; input: TInput };\nexport function isToolCallEventType(toolName: string, event: ToolCallEvent): boolean {\n\treturn event.toolName === toolName;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tool-events.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/tool-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EACX,eAAe,EACf,aAAa,EACb,aAAa,EACb,eAAe,EACf,aAAa,EACb,aAAa,EACb,WAAW,EACX,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AAgB,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,mBAAmB,CAAC;AAC5G,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,eAAe,CAAC;AACpG,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/F,QAAQ,EAAE,KAAK,EACf,KAAK,EAAE,aAAa,GAClB,KAAK,IAAI,aAAa,GAAG;IAAE,QAAQ,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC","sourcesContent":["import type { ImageContent, TextContent } from \"@earendil-works/pi-ai\";\nimport type { EditToolDetails } from \"../tools/edit.ts\";\nimport type {\n\tBashToolDetails,\n\tBashToolInput,\n\tEditToolInput,\n\tFindToolDetails,\n\tFindToolInput,\n\tLsToolDetails,\n\tLsToolInput,\n\tReadToolDetails,\n\tReadToolInput,\n\tSearchToolDetails,\n\tSearchToolInput,\n\tWriteToolInput,\n} from \"../tools/index.ts\";\n\n// ============================================================================\n// Tool Events\n// ============================================================================\n\ninterface ToolCallEventBase {\n\ttype: \"tool_call\";\n\ttoolCallId: string;\n}\n\nexport interface BashToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"bash\";\n\tinput: BashToolInput;\n}\n\nexport interface ReadToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"read\";\n\tinput: ReadToolInput;\n}\n\nexport interface EditToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"edit\";\n\tinput: EditToolInput;\n}\n\nexport interface WriteToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"write\";\n\tinput: WriteToolInput;\n}\n\nexport interface FindToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"find\";\n\tinput: FindToolInput;\n}\n\nexport interface SearchToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"search\";\n\tinput: SearchToolInput;\n}\n\nexport interface LsToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"ls\";\n\tinput: LsToolInput;\n}\n\nexport interface CustomToolCallEvent extends ToolCallEventBase {\n\ttoolName: string;\n\tinput: Record<string, unknown>;\n}\n\n/**\n * Fired before a tool executes. Can block.\n *\n * `event.input` is mutable. Mutate it in place to patch tool arguments before execution.\n * Later `tool_call` handlers see earlier mutations. No re-validation is performed after mutation.\n */\nexport type ToolCallEvent =\n\t| BashToolCallEvent\n\t| ReadToolCallEvent\n\t| EditToolCallEvent\n\t| WriteToolCallEvent\n\t| FindToolCallEvent\n\t| SearchToolCallEvent\n\t| LsToolCallEvent\n\t| CustomToolCallEvent;\n\ninterface ToolResultEventBase {\n\ttype: \"tool_result\";\n\ttoolCallId: string;\n\tinput: Record<string, unknown>;\n\tcontent: (TextContent | ImageContent)[];\n\tisError: boolean;\n}\n\nexport interface BashToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"bash\";\n\tdetails: BashToolDetails | undefined;\n}\n\nexport interface ReadToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"read\";\n\tdetails: ReadToolDetails | undefined;\n}\n\nexport interface EditToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"edit\";\n\tdetails: EditToolDetails | undefined;\n}\n\nexport interface WriteToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"write\";\n\tdetails: undefined;\n}\n\nexport interface FindToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"find\";\n\tdetails: FindToolDetails | undefined;\n}\n\nexport interface SearchToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"search\";\n\tdetails: SearchToolDetails | undefined;\n}\n\nexport interface LsToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"ls\";\n\tdetails: LsToolDetails | undefined;\n}\n\nexport interface CustomToolResultEvent extends ToolResultEventBase {\n\ttoolName: string;\n\tdetails: unknown;\n}\n\n/** Fired after a tool executes. Can modify result. */\nexport type ToolResultEvent =\n\t| BashToolResultEvent\n\t| ReadToolResultEvent\n\t| EditToolResultEvent\n\t| WriteToolResultEvent\n\t| FindToolResultEvent\n\t| SearchToolResultEvent\n\t| LsToolResultEvent\n\t| CustomToolResultEvent;\n\n// Type guards for ToolResultEvent\nexport function isBashToolResult(e: ToolResultEvent): e is BashToolResultEvent {\n\treturn e.toolName === \"bash\";\n}\nexport function isReadToolResult(e: ToolResultEvent): e is ReadToolResultEvent {\n\treturn e.toolName === \"read\";\n}\nexport function isEditToolResult(e: ToolResultEvent): e is EditToolResultEvent {\n\treturn e.toolName === \"edit\";\n}\nexport function isWriteToolResult(e: ToolResultEvent): e is WriteToolResultEvent {\n\treturn e.toolName === \"write\";\n}\nexport function isFindToolResult(e: ToolResultEvent): e is FindToolResultEvent {\n\treturn e.toolName === \"find\";\n}\nexport function isSearchToolResult(e: ToolResultEvent): e is SearchToolResultEvent {\n\treturn e.toolName === \"search\";\n}\nexport function isLsToolResult(e: ToolResultEvent): e is LsToolResultEvent {\n\treturn e.toolName === \"ls\";\n}\n\n/**\n * Type guard for narrowing ToolCallEvent by tool name.\n *\n * Built-in tools narrow automatically (no type params needed):\n * ```ts\n * if (isToolCallEventType(\"bash\", event)) {\n * event.input.command; // string\n * }\n * ```\n *\n * Custom tools require explicit type parameters:\n * ```ts\n * if (isToolCallEventType<\"my_tool\", MyToolInput>(\"my_tool\", event)) {\n * event.input.action; // typed\n * }\n * ```\n *\n * Note: Direct narrowing via `event.toolName === \"bash\"` doesn't work because\n * CustomToolCallEvent.toolName is `string` which overlaps with all literals.\n */\nexport function isToolCallEventType(toolName: \"bash\", event: ToolCallEvent): event is BashToolCallEvent;\nexport function isToolCallEventType(toolName: \"read\", event: ToolCallEvent): event is ReadToolCallEvent;\nexport function isToolCallEventType(toolName: \"edit\", event: ToolCallEvent): event is EditToolCallEvent;\nexport function isToolCallEventType(toolName: \"write\", event: ToolCallEvent): event is WriteToolCallEvent;\nexport function isToolCallEventType(toolName: \"find\", event: ToolCallEvent): event is FindToolCallEvent;\nexport function isToolCallEventType(toolName: \"search\", event: ToolCallEvent): event is SearchToolCallEvent;\nexport function isToolCallEventType(toolName: \"ls\", event: ToolCallEvent): event is LsToolCallEvent;\nexport function isToolCallEventType<TName extends string, TInput extends Record<string, unknown>>(\n\ttoolName: TName,\n\tevent: ToolCallEvent,\n): event is ToolCallEvent & { toolName: TName; input: TInput };\nexport function isToolCallEventType(toolName: string, event: ToolCallEvent): boolean {\n\treturn event.toolName === toolName;\n}\n"]}
|
|
@@ -11,12 +11,12 @@ export function isEditToolResult(e) {
|
|
|
11
11
|
export function isWriteToolResult(e) {
|
|
12
12
|
return e.toolName === "write";
|
|
13
13
|
}
|
|
14
|
-
export function isGrepToolResult(e) {
|
|
15
|
-
return e.toolName === "grep";
|
|
16
|
-
}
|
|
17
14
|
export function isFindToolResult(e) {
|
|
18
15
|
return e.toolName === "find";
|
|
19
16
|
}
|
|
17
|
+
export function isSearchToolResult(e) {
|
|
18
|
+
return e.toolName === "search";
|
|
19
|
+
}
|
|
20
20
|
export function isLsToolResult(e) {
|
|
21
21
|
return e.toolName === "ls";
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-events.js","sourceRoot":"","sources":["../../../src/core/extensions/tool-events.ts"],"names":[],"mappings":"AA6IA,kCAAkC;AAClC,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,iBAAiB,CAAC,CAAkB;IACnD,OAAO,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC;AAC/B,CAAC;AACD,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"tool-events.js","sourceRoot":"","sources":["../../../src/core/extensions/tool-events.ts"],"names":[],"mappings":"AA6IA,kCAAkC;AAClC,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,iBAAiB,CAAC,CAAkB;IACnD,OAAO,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC;AAC/B,CAAC;AACD,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,kBAAkB,CAAC,CAAkB;IACpD,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC;AAChC,CAAC;AACD,MAAM,UAAU,cAAc,CAAC,CAAkB;IAChD,OAAO,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC;AAC5B,CAAC;AAiCD,MAAM,UAAU,mBAAmB,CAAC,QAAgB,EAAE,KAAoB;IACzE,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACpC,CAAC","sourcesContent":["import type { ImageContent, TextContent } from \"@earendil-works/pi-ai\";\nimport type { EditToolDetails } from \"../tools/edit.ts\";\nimport type {\n\tBashToolDetails,\n\tBashToolInput,\n\tEditToolInput,\n\tFindToolDetails,\n\tFindToolInput,\n\tLsToolDetails,\n\tLsToolInput,\n\tReadToolDetails,\n\tReadToolInput,\n\tSearchToolDetails,\n\tSearchToolInput,\n\tWriteToolInput,\n} from \"../tools/index.ts\";\n\n// ============================================================================\n// Tool Events\n// ============================================================================\n\ninterface ToolCallEventBase {\n\ttype: \"tool_call\";\n\ttoolCallId: string;\n}\n\nexport interface BashToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"bash\";\n\tinput: BashToolInput;\n}\n\nexport interface ReadToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"read\";\n\tinput: ReadToolInput;\n}\n\nexport interface EditToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"edit\";\n\tinput: EditToolInput;\n}\n\nexport interface WriteToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"write\";\n\tinput: WriteToolInput;\n}\n\nexport interface FindToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"find\";\n\tinput: FindToolInput;\n}\n\nexport interface SearchToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"search\";\n\tinput: SearchToolInput;\n}\n\nexport interface LsToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"ls\";\n\tinput: LsToolInput;\n}\n\nexport interface CustomToolCallEvent extends ToolCallEventBase {\n\ttoolName: string;\n\tinput: Record<string, unknown>;\n}\n\n/**\n * Fired before a tool executes. Can block.\n *\n * `event.input` is mutable. Mutate it in place to patch tool arguments before execution.\n * Later `tool_call` handlers see earlier mutations. No re-validation is performed after mutation.\n */\nexport type ToolCallEvent =\n\t| BashToolCallEvent\n\t| ReadToolCallEvent\n\t| EditToolCallEvent\n\t| WriteToolCallEvent\n\t| FindToolCallEvent\n\t| SearchToolCallEvent\n\t| LsToolCallEvent\n\t| CustomToolCallEvent;\n\ninterface ToolResultEventBase {\n\ttype: \"tool_result\";\n\ttoolCallId: string;\n\tinput: Record<string, unknown>;\n\tcontent: (TextContent | ImageContent)[];\n\tisError: boolean;\n}\n\nexport interface BashToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"bash\";\n\tdetails: BashToolDetails | undefined;\n}\n\nexport interface ReadToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"read\";\n\tdetails: ReadToolDetails | undefined;\n}\n\nexport interface EditToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"edit\";\n\tdetails: EditToolDetails | undefined;\n}\n\nexport interface WriteToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"write\";\n\tdetails: undefined;\n}\n\nexport interface FindToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"find\";\n\tdetails: FindToolDetails | undefined;\n}\n\nexport interface SearchToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"search\";\n\tdetails: SearchToolDetails | undefined;\n}\n\nexport interface LsToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"ls\";\n\tdetails: LsToolDetails | undefined;\n}\n\nexport interface CustomToolResultEvent extends ToolResultEventBase {\n\ttoolName: string;\n\tdetails: unknown;\n}\n\n/** Fired after a tool executes. Can modify result. */\nexport type ToolResultEvent =\n\t| BashToolResultEvent\n\t| ReadToolResultEvent\n\t| EditToolResultEvent\n\t| WriteToolResultEvent\n\t| FindToolResultEvent\n\t| SearchToolResultEvent\n\t| LsToolResultEvent\n\t| CustomToolResultEvent;\n\n// Type guards for ToolResultEvent\nexport function isBashToolResult(e: ToolResultEvent): e is BashToolResultEvent {\n\treturn e.toolName === \"bash\";\n}\nexport function isReadToolResult(e: ToolResultEvent): e is ReadToolResultEvent {\n\treturn e.toolName === \"read\";\n}\nexport function isEditToolResult(e: ToolResultEvent): e is EditToolResultEvent {\n\treturn e.toolName === \"edit\";\n}\nexport function isWriteToolResult(e: ToolResultEvent): e is WriteToolResultEvent {\n\treturn e.toolName === \"write\";\n}\nexport function isFindToolResult(e: ToolResultEvent): e is FindToolResultEvent {\n\treturn e.toolName === \"find\";\n}\nexport function isSearchToolResult(e: ToolResultEvent): e is SearchToolResultEvent {\n\treturn e.toolName === \"search\";\n}\nexport function isLsToolResult(e: ToolResultEvent): e is LsToolResultEvent {\n\treturn e.toolName === \"ls\";\n}\n\n/**\n * Type guard for narrowing ToolCallEvent by tool name.\n *\n * Built-in tools narrow automatically (no type params needed):\n * ```ts\n * if (isToolCallEventType(\"bash\", event)) {\n * event.input.command; // string\n * }\n * ```\n *\n * Custom tools require explicit type parameters:\n * ```ts\n * if (isToolCallEventType<\"my_tool\", MyToolInput>(\"my_tool\", event)) {\n * event.input.action; // typed\n * }\n * ```\n *\n * Note: Direct narrowing via `event.toolName === \"bash\"` doesn't work because\n * CustomToolCallEvent.toolName is `string` which overlaps with all literals.\n */\nexport function isToolCallEventType(toolName: \"bash\", event: ToolCallEvent): event is BashToolCallEvent;\nexport function isToolCallEventType(toolName: \"read\", event: ToolCallEvent): event is ReadToolCallEvent;\nexport function isToolCallEventType(toolName: \"edit\", event: ToolCallEvent): event is EditToolCallEvent;\nexport function isToolCallEventType(toolName: \"write\", event: ToolCallEvent): event is WriteToolCallEvent;\nexport function isToolCallEventType(toolName: \"find\", event: ToolCallEvent): event is FindToolCallEvent;\nexport function isToolCallEventType(toolName: \"search\", event: ToolCallEvent): event is SearchToolCallEvent;\nexport function isToolCallEventType(toolName: \"ls\", event: ToolCallEvent): event is LsToolCallEvent;\nexport function isToolCallEventType<TName extends string, TInput extends Record<string, unknown>>(\n\ttoolName: TName,\n\tevent: ToolCallEvent,\n): event is ToolCallEvent & { toolName: TName; input: TInput };\nexport function isToolCallEventType(toolName: string, event: ToolCallEvent): boolean {\n\treturn event.toolName === toolName;\n}\n"]}
|
|
@@ -28,5 +28,5 @@ export type * from "./tool-events.ts";
|
|
|
28
28
|
export type * from "./tool-types.ts";
|
|
29
29
|
export type * from "./ui-types.ts";
|
|
30
30
|
export { defineTool } from "./tool-types.ts";
|
|
31
|
-
export { isBashToolResult, isEditToolResult, isFindToolResult,
|
|
31
|
+
export { isBashToolResult, isEditToolResult, isFindToolResult, isLsToolResult, isSearchToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, } from "./tool-events.ts";
|
|
32
32
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EAAE,eAAe,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACjH,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC1D,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,YAAY,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AACpE,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,eAAe,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EAAE,eAAe,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACjH,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC1D,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,YAAY,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AACpE,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,qBAAqB,CAAC;AACzC,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,eAAe,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,GACjB,MAAM,kBAAkB,CAAC","sourcesContent":["/**\n * Extension system types.\n *\n * Extensions are TypeScript modules that can:\n * - Subscribe to agent lifecycle events\n * - Register LLM-callable tools\n * - Register commands, keyboard shortcuts, and CLI flags\n * - Interact with the user via UI primitives\n *\n * This file preserves the public import path for extension authors while the\n * declarations live in responsibility-focused sibling modules.\n */\n\nexport type { AgentToolResult, AgentToolUpdateCallback, ToolExecutionMode } from \"@earendil-works/pi-agent-core\";\nexport type { ExecOptions, ExecResult } from \"../exec.ts\";\nexport type { AppKeybinding, KeybindingsManager } from \"../keybindings.ts\";\nexport type { BuildSystemPromptOptions } from \"../system-prompt.ts\";\nexport type * from \"./agent-events.ts\";\nexport type * from \"./api-types.ts\";\nexport type * from \"./command-types.ts\";\nexport type * from \"./context-types.ts\";\nexport type * from \"./event-results.ts\";\nexport type * from \"./event-types.ts\";\nexport type * from \"./message-types.ts\";\nexport type * from \"./provider-types.ts\";\nexport type * from \"./runtime-types.ts\";\nexport type * from \"./session-events.ts\";\nexport type * from \"./tool-events.ts\";\nexport type * from \"./tool-types.ts\";\nexport type * from \"./ui-types.ts\";\n\nexport { defineTool } from \"./tool-types.ts\";\nexport {\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisLsToolResult,\n\tisSearchToolResult,\n\tisReadToolResult,\n\tisToolCallEventType,\n\tisWriteToolResult,\n} from \"./tool-events.ts\";\n"]}
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
* declarations live in responsibility-focused sibling modules.
|
|
12
12
|
*/
|
|
13
13
|
export { defineTool } from "./tool-types.js";
|
|
14
|
-
export { isBashToolResult, isEditToolResult, isFindToolResult,
|
|
14
|
+
export { isBashToolResult, isEditToolResult, isFindToolResult, isLsToolResult, isSearchToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, } from "./tool-events.js";
|
|
15
15
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/extensions/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAoBH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/extensions/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAoBH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,GACjB,MAAM,kBAAkB,CAAC","sourcesContent":["/**\n * Extension system types.\n *\n * Extensions are TypeScript modules that can:\n * - Subscribe to agent lifecycle events\n * - Register LLM-callable tools\n * - Register commands, keyboard shortcuts, and CLI flags\n * - Interact with the user via UI primitives\n *\n * This file preserves the public import path for extension authors while the\n * declarations live in responsibility-focused sibling modules.\n */\n\nexport type { AgentToolResult, AgentToolUpdateCallback, ToolExecutionMode } from \"@earendil-works/pi-agent-core\";\nexport type { ExecOptions, ExecResult } from \"../exec.ts\";\nexport type { AppKeybinding, KeybindingsManager } from \"../keybindings.ts\";\nexport type { BuildSystemPromptOptions } from \"../system-prompt.ts\";\nexport type * from \"./agent-events.ts\";\nexport type * from \"./api-types.ts\";\nexport type * from \"./command-types.ts\";\nexport type * from \"./context-types.ts\";\nexport type * from \"./event-results.ts\";\nexport type * from \"./event-types.ts\";\nexport type * from \"./message-types.ts\";\nexport type * from \"./provider-types.ts\";\nexport type * from \"./runtime-types.ts\";\nexport type * from \"./session-events.ts\";\nexport type * from \"./tool-events.ts\";\nexport type * from \"./tool-types.ts\";\nexport type * from \"./ui-types.ts\";\n\nexport { defineTool } from \"./tool-types.ts\";\nexport {\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisLsToolResult,\n\tisSearchToolResult,\n\tisReadToolResult,\n\tisToolCallEventType,\n\tisWriteToolResult,\n} from \"./tool-events.ts\";\n"]}
|
|
@@ -38,4 +38,22 @@ export declare function parseFlattenedKeyPath(key: string): Array<string | numbe
|
|
|
38
38
|
* plain key equal to one of those names.
|
|
39
39
|
*/
|
|
40
40
|
export declare function reconstructFlattenedKeys(args: Record<string, unknown>, shouldSplit: (key: string) => boolean): Record<string, unknown>;
|
|
41
|
+
/**
|
|
42
|
+
* Reconstruct flattened tool-call arguments into nested arrays/objects using
|
|
43
|
+
* schema-aware disambiguation for dotted keys.
|
|
44
|
+
*
|
|
45
|
+
* - Bracket-indexed keys (`ids[0]`, `files[0].path`) are always reconstructed.
|
|
46
|
+
* - Purely dotted keys (`parent.child`) are reconstructed only when the optional
|
|
47
|
+
* `schema` marks their head segment as an object/array container property.
|
|
48
|
+
* The presence of a bracket-indexed sibling does NOT force a pure dotted key
|
|
49
|
+
* to split, so a literal property name such as `filter.name` survives intact
|
|
50
|
+
* even when a sibling like `ids[0]` is present (issue #1496).
|
|
51
|
+
* - Otherwise dotted keys are preserved verbatim — fixing the regression where a
|
|
52
|
+
* literal property name like `filter.name` was silently corrupted.
|
|
53
|
+
*
|
|
54
|
+
* Returns the original reference unchanged when there is nothing to
|
|
55
|
+
* reconstruct. Prototype-pollution safety is delegated to
|
|
56
|
+
* {@link reconstructFlattenedKeys}.
|
|
57
|
+
*/
|
|
58
|
+
export declare function unflattenArgumentsWithSchema(args: Record<string, unknown>, schema?: unknown): Record<string, unknown>;
|
|
41
59
|
//# sourceMappingURL=flattened-tool-arguments.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattened-tool-arguments.d.ts","sourceRoot":"","sources":["../../src/core/flattened-tool-arguments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AASH;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,CAmCrF;AA0CD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GACpC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazB","sourcesContent":["/**\n * Canonical reconstruction of flattened tool-call arguments.\n *\n * Some upstream providers — notably GitHub Copilot Gemini models proxied through\n * Google's GenAI API — serialize array/object function-call arguments as\n * flattened, indexed keys on the wire. For example a tool called with\n * `{ keywords: [\"a\", \"b\"] }` arrives as `{ \"keywords[0]\": \"a\", \"keywords[1]\": \"b\" }`,\n * and `{ files: [{ path }] }` as `{ \"files[0].path\": \"...\" }`.\n *\n * This module is the single source of truth for turning those flattened keys\n * back into nested arrays/objects. Both the host runtime's per-tool\n * normalization (gated to Copilot Gemini, schema-aware) and the MCP `callTool`\n * boundary (provider-agnostic, bracket self-gating) delegate here so the two\n * paths cannot drift — in particular so the prototype-pollution guard lives in\n * exactly one place.\n *\n * Security: argument keys cross a trust boundary (model/provider wire → tool /\n * MCP server validation). A key path that walks through `__proto__`,\n * `constructor`, or `prototype` could otherwise reach `Object.prototype` and\n * mutate it process-wide. Any key whose path contains such a segment — at any\n * position, including the final segment and a literal plain key — is dropped.\n */\n\n/** Key segments that must never be written or traversed (prototype pollution). */\nconst UNSAFE_KEY_SEGMENTS: ReadonlySet<string> = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\nfunction isUnsafeSegment(segment: string | number): boolean {\n return typeof segment === \"string\" && UNSAFE_KEY_SEGMENTS.has(segment);\n}\n\n/**\n * Parse a flattened key such as `a.b[0].c` into path segments\n * `[\"a\", \"b\", 0, \"c\"]`. Returns `undefined` for a plain key with no `.`/`[`, or\n * for a malformed bracket expression (left untouched by the caller).\n */\nexport function parseFlattenedKeyPath(key: string): Array<string | number> | undefined {\n if (!/[.[]/.test(key)) return undefined;\n const segments: Array<string | number> = [];\n let current = \"\";\n let index = 0;\n const flush = () => {\n if (current !== \"\") {\n segments.push(current);\n current = \"\";\n }\n };\n while (index < key.length) {\n const char = key[index];\n if (char === \".\") {\n flush();\n index += 1;\n } else if (char === \"[\") {\n flush();\n const end = key.indexOf(\"]\", index);\n if (end === -1) return undefined; // malformed — leave key untouched\n const inner = key.slice(index + 1, end);\n const numeric = Number(inner);\n if (inner.trim() !== \"\" && Number.isInteger(numeric) && numeric >= 0) {\n segments.push(numeric);\n } else {\n segments.push(inner.replace(/^[\"']|[\"']$/g, \"\"));\n }\n index = end + 1;\n } else {\n current += char;\n index += 1;\n }\n }\n flush();\n return segments.length > 0 ? segments : undefined;\n}\n\n/** Assign `value` at the given path inside `root`, creating arrays/objects as needed. */\nfunction assignFlattenedKeyPath(\n root: Record<string | number, unknown>,\n segments: Array<string | number>,\n value: unknown,\n): void {\n let node: Record<string | number, unknown> = root;\n for (let i = 0; i < segments.length - 1; i += 1) {\n const segment = segments[i];\n const nextIsIndex = typeof segments[i + 1] === \"number\";\n const existing = node[segment];\n if (existing === null || existing === undefined || typeof existing !== \"object\") {\n node[segment] = nextIsIndex ? [] : {};\n }\n node = node[segment] as Record<string | number, unknown>;\n }\n node[segments[segments.length - 1]] = value;\n}\n\n/**\n * Remove empty holes from sparse arrays produced by out-of-order indices.\n *\n * Note: this collapses holes rather than preserving them — `name[0]` + `name[2]`\n * (no index 1) becomes a dense 2-element array `[a, c]`, not `[a, <hole>, c]`.\n * That is the intended healing for Gemini's flattened output (which emits\n * contiguous indices in practice); it would, however, silently misalign two\n * arrays that were meant to be index-paired.\n */\nfunction compactSparseArrays(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.filter((entry) => entry !== undefined).map((entry) => compactSparseArrays(entry));\n }\n if (value !== null && typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) out[key] = compactSparseArrays(entry);\n return out;\n }\n return value;\n}\n\n/**\n * Reconstruct (unflatten) flattened keys into nested arrays/objects — for\n * example `\"items[0]\"` -> `{ items: [...] }` and `\"parent.child\"` ->\n * `{ parent: { child: ... } }`. `shouldSplit` decides, per key, whether it is a\n * flattened path (true) or an opaque literal key to be preserved (false);\n * callers apply their own gating/schema logic there.\n *\n * Prototype-pollution safe: a key whose parsed path contains `__proto__`,\n * `constructor`, or `prototype` (at any position) is dropped, as is a literal\n * plain key equal to one of those names.\n */\nexport function reconstructFlattenedKeys(\n args: Record<string, unknown>,\n shouldSplit: (key: string) => boolean,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(args)) {\n const segments = shouldSplit(key) ? parseFlattenedKeyPath(key) : undefined;\n if (!segments) {\n // Plain passthrough — but never assign a literal prototype-polluting key.\n if (!UNSAFE_KEY_SEGMENTS.has(key)) result[key] = value;\n continue;\n }\n if (segments.some(isUnsafeSegment)) continue; // drop a polluting path entirely\n assignFlattenedKeyPath(result, segments, value);\n }\n return compactSparseArrays(result) as Record<string, unknown>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"flattened-tool-arguments.d.ts","sourceRoot":"","sources":["../../src/core/flattened-tool-arguments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AASH;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,CAmCrF;AA0CD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GACpC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazB;AAyFD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,CAAC,EAAE,OAAO,GACf,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYzB","sourcesContent":["/**\n * Canonical reconstruction of flattened tool-call arguments.\n *\n * Some upstream providers — notably GitHub Copilot Gemini models proxied through\n * Google's GenAI API — serialize array/object function-call arguments as\n * flattened, indexed keys on the wire. For example a tool called with\n * `{ keywords: [\"a\", \"b\"] }` arrives as `{ \"keywords[0]\": \"a\", \"keywords[1]\": \"b\" }`,\n * and `{ files: [{ path }] }` as `{ \"files[0].path\": \"...\" }`.\n *\n * This module is the single source of truth for turning those flattened keys\n * back into nested arrays/objects. Both the host runtime's per-tool\n * normalization (gated to Copilot Gemini, schema-aware) and the MCP `callTool`\n * boundary (provider-agnostic, bracket self-gating) delegate here so the two\n * paths cannot drift — in particular so the prototype-pollution guard lives in\n * exactly one place.\n *\n * Security: argument keys cross a trust boundary (model/provider wire → tool /\n * MCP server validation). A key path that walks through `__proto__`,\n * `constructor`, or `prototype` could otherwise reach `Object.prototype` and\n * mutate it process-wide. Any key whose path contains such a segment — at any\n * position, including the final segment and a literal plain key — is dropped.\n */\n\n/** Key segments that must never be written or traversed (prototype pollution). */\nconst UNSAFE_KEY_SEGMENTS: ReadonlySet<string> = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\nfunction isUnsafeSegment(segment: string | number): boolean {\n return typeof segment === \"string\" && UNSAFE_KEY_SEGMENTS.has(segment);\n}\n\n/**\n * Parse a flattened key such as `a.b[0].c` into path segments\n * `[\"a\", \"b\", 0, \"c\"]`. Returns `undefined` for a plain key with no `.`/`[`, or\n * for a malformed bracket expression (left untouched by the caller).\n */\nexport function parseFlattenedKeyPath(key: string): Array<string | number> | undefined {\n if (!/[.[]/.test(key)) return undefined;\n const segments: Array<string | number> = [];\n let current = \"\";\n let index = 0;\n const flush = () => {\n if (current !== \"\") {\n segments.push(current);\n current = \"\";\n }\n };\n while (index < key.length) {\n const char = key[index];\n if (char === \".\") {\n flush();\n index += 1;\n } else if (char === \"[\") {\n flush();\n const end = key.indexOf(\"]\", index);\n if (end === -1) return undefined; // malformed — leave key untouched\n const inner = key.slice(index + 1, end);\n const numeric = Number(inner);\n if (inner.trim() !== \"\" && Number.isInteger(numeric) && numeric >= 0) {\n segments.push(numeric);\n } else {\n segments.push(inner.replace(/^[\"']|[\"']$/g, \"\"));\n }\n index = end + 1;\n } else {\n current += char;\n index += 1;\n }\n }\n flush();\n return segments.length > 0 ? segments : undefined;\n}\n\n/** Assign `value` at the given path inside `root`, creating arrays/objects as needed. */\nfunction assignFlattenedKeyPath(\n root: Record<string | number, unknown>,\n segments: Array<string | number>,\n value: unknown,\n): void {\n let node: Record<string | number, unknown> = root;\n for (let i = 0; i < segments.length - 1; i += 1) {\n const segment = segments[i];\n const nextIsIndex = typeof segments[i + 1] === \"number\";\n const existing = node[segment];\n if (existing === null || existing === undefined || typeof existing !== \"object\") {\n node[segment] = nextIsIndex ? [] : {};\n }\n node = node[segment] as Record<string | number, unknown>;\n }\n node[segments[segments.length - 1]] = value;\n}\n\n/**\n * Remove empty holes from sparse arrays produced by out-of-order indices.\n *\n * Note: this collapses holes rather than preserving them — `name[0]` + `name[2]`\n * (no index 1) becomes a dense 2-element array `[a, c]`, not `[a, <hole>, c]`.\n * That is the intended healing for Gemini's flattened output (which emits\n * contiguous indices in practice); it would, however, silently misalign two\n * arrays that were meant to be index-paired.\n */\nfunction compactSparseArrays(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.filter((entry) => entry !== undefined).map((entry) => compactSparseArrays(entry));\n }\n if (value !== null && typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) out[key] = compactSparseArrays(entry);\n return out;\n }\n return value;\n}\n\n/**\n * Reconstruct (unflatten) flattened keys into nested arrays/objects — for\n * example `\"items[0]\"` -> `{ items: [...] }` and `\"parent.child\"` ->\n * `{ parent: { child: ... } }`. `shouldSplit` decides, per key, whether it is a\n * flattened path (true) or an opaque literal key to be preserved (false);\n * callers apply their own gating/schema logic there.\n *\n * Prototype-pollution safe: a key whose parsed path contains `__proto__`,\n * `constructor`, or `prototype` (at any position) is dropped, as is a literal\n * plain key equal to one of those names.\n */\nexport function reconstructFlattenedKeys(\n args: Record<string, unknown>,\n shouldSplit: (key: string) => boolean,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(args)) {\n const segments = shouldSplit(key) ? parseFlattenedKeyPath(key) : undefined;\n if (!segments) {\n // Plain passthrough — but never assign a literal prototype-polluting key.\n if (!UNSAFE_KEY_SEGMENTS.has(key)) result[key] = value;\n continue;\n }\n if (segments.some(isUnsafeSegment)) continue; // drop a polluting path entirely\n assignFlattenedKeyPath(result, segments, value);\n }\n return compactSparseArrays(result) as Record<string, unknown>;\n}\n\n// ---------------------------------------------------------------------------\n// Schema-aware unflattening\n// ---------------------------------------------------------------------------\n//\n// A flattened key with a bracket index (`foo[0]`) is unambiguous and is always\n// reconstructed. A purely dotted key (`parent.child`) is ambiguous: it could be\n// a real nested path *or* a legitimate argument whose name literally contains\n// a dot (for example an MCP tool whose JSON Schema declares a property named\n// `filter.name`). To avoid corrupting such literal dotted keys, a dotted key is\n// only split when the tool's `inputSchema` proves its head segment is an\n// object/array container property. The presence of a bracket-indexed sibling\n// does NOT force a pure dotted key to split — the two are decided per key, so\n// a literal property such as `filter.name` survives intact even when a bracket\n// sibling like `ids[0]` is present (issue #1496). Callers that only want the\n// unambiguous bracket case can omit the schema.\n\ntype JsonRecord = Record<string, unknown>;\n\nfunction isPlainObject(value: unknown): value is JsonRecord {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** A flattened key contains a bracket index like `foo[0]`. */\nfunction hasBracketIndex(key: string): boolean {\n return /\\[\\d+\\]/.test(key);\n}\n\n/** A schema node that holds a nested object/array (so dotted keys are real paths). */\nfunction isContainerSchema(schema: unknown): boolean {\n if (!isPlainObject(schema)) return false;\n if (schema.type === \"object\" || schema.type === \"array\") return true;\n if (\"properties\" in schema || \"items\" in schema) return true;\n const union = schema.anyOf ?? schema.oneOf;\n if (Array.isArray(union)) return union.some((branch) => isContainerSchema(branch));\n return false;\n}\n\n/** Exact top-level `schema.properties` names (literal property keys). */\nfunction literalPropertyNames(schema: unknown): Set<string> {\n const names = new Set<string>();\n if (!isPlainObject(schema)) return names;\n const properties = schema.properties;\n if (!isPlainObject(properties)) return names;\n for (const name of Object.keys(properties)) names.add(name);\n return names;\n}\n\n/** Top-level property names whose schema is an object/array container. */\nfunction containerPropertyNames(schema: unknown): Set<string> {\n const names = new Set<string>();\n if (!isPlainObject(schema)) return names;\n const properties = schema.properties;\n if (!isPlainObject(properties)) return names;\n for (const [name, sub] of Object.entries(properties)) {\n if (isContainerSchema(sub)) names.add(name);\n }\n return names;\n}\n\n/** Whether `key` is a pure dotted path (`parent.child`) headed by a container prop. */\nfunction isDottedContainerKey(key: string, containers: Set<string>): boolean {\n const dot = key.indexOf(\".\");\n if (dot <= 0) return false;\n return containers.has(key.slice(0, dot));\n}\n\n/**\n * Decide whether a flattened key should be split into nested path segments.\n *\n * - Bracket-indexed keys (`foo[0]`, `foo[0].bar`) always split: they are\n * unambiguous evidence of provider flattening.\n * - Purely dotted keys (`parent.child`) split only when the schema marks their\n * head segment as an object/array container property AND the schema does not\n * declare the full key as a literal top-level property. The latter guard\n * protects a schema that intentionally defines both a literal dotted property\n * (e.g. `filter.name`) and a same-head container (e.g. `filter`): the literal\n * property wins and is preserved verbatim (reviewer-b P2, issue #1496). The\n * presence of a bracket-indexed sibling does NOT force a pure dotted key to\n * split, so a literal property name such as `filter.name` is preserved\n * verbatim even when a sibling like `ids[0]` is reconstructed.\n */\nfunction shouldSplitKey(key: string, containers: Set<string>, literals: Set<string>): boolean {\n if (hasBracketIndex(key)) return true;\n if (literals.has(key)) return false; // explicit literal property wins\n return isDottedContainerKey(key, containers);\n}\n\n/**\n * Reconstruct flattened tool-call arguments into nested arrays/objects using\n * schema-aware disambiguation for dotted keys.\n *\n * - Bracket-indexed keys (`ids[0]`, `files[0].path`) are always reconstructed.\n * - Purely dotted keys (`parent.child`) are reconstructed only when the optional\n * `schema` marks their head segment as an object/array container property.\n * The presence of a bracket-indexed sibling does NOT force a pure dotted key\n * to split, so a literal property name such as `filter.name` survives intact\n * even when a sibling like `ids[0]` is present (issue #1496).\n * - Otherwise dotted keys are preserved verbatim — fixing the regression where a\n * literal property name like `filter.name` was silently corrupted.\n *\n * Returns the original reference unchanged when there is nothing to\n * reconstruct. Prototype-pollution safety is delegated to\n * {@link reconstructFlattenedKeys}.\n */\nexport function unflattenArgumentsWithSchema(\n args: Record<string, unknown>,\n schema?: unknown,\n): Record<string, unknown> {\n const keys = Object.keys(args);\n const literals = literalPropertyNames(schema);\n const containers = containerPropertyNames(schema);\n const hasBracket = keys.some((key) => hasBracketIndex(key));\n // A dotted key needs splitting only if it is not a literal property AND its\n // head is a schema container. Literal dotted properties are always preserved.\n const hasSplittableDotted = keys.some(\n (key) => !literals.has(key) && isDottedContainerKey(key, containers),\n );\n if (!hasBracket && !hasSplittableDotted) return args;\n return reconstructFlattenedKeys(args, (key) => shouldSplitKey(key, containers, literals));\n}\n"]}
|
|
@@ -133,4 +133,108 @@ export function reconstructFlattenedKeys(args, shouldSplit) {
|
|
|
133
133
|
}
|
|
134
134
|
return compactSparseArrays(result);
|
|
135
135
|
}
|
|
136
|
+
function isPlainObject(value) {
|
|
137
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
138
|
+
}
|
|
139
|
+
/** A flattened key contains a bracket index like `foo[0]`. */
|
|
140
|
+
function hasBracketIndex(key) {
|
|
141
|
+
return /\[\d+\]/.test(key);
|
|
142
|
+
}
|
|
143
|
+
/** A schema node that holds a nested object/array (so dotted keys are real paths). */
|
|
144
|
+
function isContainerSchema(schema) {
|
|
145
|
+
if (!isPlainObject(schema))
|
|
146
|
+
return false;
|
|
147
|
+
if (schema.type === "object" || schema.type === "array")
|
|
148
|
+
return true;
|
|
149
|
+
if ("properties" in schema || "items" in schema)
|
|
150
|
+
return true;
|
|
151
|
+
const union = schema.anyOf ?? schema.oneOf;
|
|
152
|
+
if (Array.isArray(union))
|
|
153
|
+
return union.some((branch) => isContainerSchema(branch));
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
/** Exact top-level `schema.properties` names (literal property keys). */
|
|
157
|
+
function literalPropertyNames(schema) {
|
|
158
|
+
const names = new Set();
|
|
159
|
+
if (!isPlainObject(schema))
|
|
160
|
+
return names;
|
|
161
|
+
const properties = schema.properties;
|
|
162
|
+
if (!isPlainObject(properties))
|
|
163
|
+
return names;
|
|
164
|
+
for (const name of Object.keys(properties))
|
|
165
|
+
names.add(name);
|
|
166
|
+
return names;
|
|
167
|
+
}
|
|
168
|
+
/** Top-level property names whose schema is an object/array container. */
|
|
169
|
+
function containerPropertyNames(schema) {
|
|
170
|
+
const names = new Set();
|
|
171
|
+
if (!isPlainObject(schema))
|
|
172
|
+
return names;
|
|
173
|
+
const properties = schema.properties;
|
|
174
|
+
if (!isPlainObject(properties))
|
|
175
|
+
return names;
|
|
176
|
+
for (const [name, sub] of Object.entries(properties)) {
|
|
177
|
+
if (isContainerSchema(sub))
|
|
178
|
+
names.add(name);
|
|
179
|
+
}
|
|
180
|
+
return names;
|
|
181
|
+
}
|
|
182
|
+
/** Whether `key` is a pure dotted path (`parent.child`) headed by a container prop. */
|
|
183
|
+
function isDottedContainerKey(key, containers) {
|
|
184
|
+
const dot = key.indexOf(".");
|
|
185
|
+
if (dot <= 0)
|
|
186
|
+
return false;
|
|
187
|
+
return containers.has(key.slice(0, dot));
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Decide whether a flattened key should be split into nested path segments.
|
|
191
|
+
*
|
|
192
|
+
* - Bracket-indexed keys (`foo[0]`, `foo[0].bar`) always split: they are
|
|
193
|
+
* unambiguous evidence of provider flattening.
|
|
194
|
+
* - Purely dotted keys (`parent.child`) split only when the schema marks their
|
|
195
|
+
* head segment as an object/array container property AND the schema does not
|
|
196
|
+
* declare the full key as a literal top-level property. The latter guard
|
|
197
|
+
* protects a schema that intentionally defines both a literal dotted property
|
|
198
|
+
* (e.g. `filter.name`) and a same-head container (e.g. `filter`): the literal
|
|
199
|
+
* property wins and is preserved verbatim (reviewer-b P2, issue #1496). The
|
|
200
|
+
* presence of a bracket-indexed sibling does NOT force a pure dotted key to
|
|
201
|
+
* split, so a literal property name such as `filter.name` is preserved
|
|
202
|
+
* verbatim even when a sibling like `ids[0]` is reconstructed.
|
|
203
|
+
*/
|
|
204
|
+
function shouldSplitKey(key, containers, literals) {
|
|
205
|
+
if (hasBracketIndex(key))
|
|
206
|
+
return true;
|
|
207
|
+
if (literals.has(key))
|
|
208
|
+
return false; // explicit literal property wins
|
|
209
|
+
return isDottedContainerKey(key, containers);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Reconstruct flattened tool-call arguments into nested arrays/objects using
|
|
213
|
+
* schema-aware disambiguation for dotted keys.
|
|
214
|
+
*
|
|
215
|
+
* - Bracket-indexed keys (`ids[0]`, `files[0].path`) are always reconstructed.
|
|
216
|
+
* - Purely dotted keys (`parent.child`) are reconstructed only when the optional
|
|
217
|
+
* `schema` marks their head segment as an object/array container property.
|
|
218
|
+
* The presence of a bracket-indexed sibling does NOT force a pure dotted key
|
|
219
|
+
* to split, so a literal property name such as `filter.name` survives intact
|
|
220
|
+
* even when a sibling like `ids[0]` is present (issue #1496).
|
|
221
|
+
* - Otherwise dotted keys are preserved verbatim — fixing the regression where a
|
|
222
|
+
* literal property name like `filter.name` was silently corrupted.
|
|
223
|
+
*
|
|
224
|
+
* Returns the original reference unchanged when there is nothing to
|
|
225
|
+
* reconstruct. Prototype-pollution safety is delegated to
|
|
226
|
+
* {@link reconstructFlattenedKeys}.
|
|
227
|
+
*/
|
|
228
|
+
export function unflattenArgumentsWithSchema(args, schema) {
|
|
229
|
+
const keys = Object.keys(args);
|
|
230
|
+
const literals = literalPropertyNames(schema);
|
|
231
|
+
const containers = containerPropertyNames(schema);
|
|
232
|
+
const hasBracket = keys.some((key) => hasBracketIndex(key));
|
|
233
|
+
// A dotted key needs splitting only if it is not a literal property AND its
|
|
234
|
+
// head is a schema container. Literal dotted properties are always preserved.
|
|
235
|
+
const hasSplittableDotted = keys.some((key) => !literals.has(key) && isDottedContainerKey(key, containers));
|
|
236
|
+
if (!hasBracket && !hasSplittableDotted)
|
|
237
|
+
return args;
|
|
238
|
+
return reconstructFlattenedKeys(args, (key) => shouldSplitKey(key, containers, literals));
|
|
239
|
+
}
|
|
136
240
|
//# sourceMappingURL=flattened-tool-arguments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattened-tool-arguments.js","sourceRoot":"","sources":["../../src/core/flattened-tool-arguments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,kFAAkF;AAClF,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;AA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QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC;YAAE,SAAS,CAAC,iCAAiC;QAC/E,sBAAsB,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,mBAAmB,CAAC,MAAM,CAA4B,CAAC;AAChE,CAAC","sourcesContent":["/**\n * Canonical reconstruction of flattened tool-call arguments.\n *\n * Some upstream providers — notably GitHub Copilot Gemini models proxied through\n * Google's GenAI API — serialize array/object function-call arguments as\n * flattened, indexed keys on the wire. For example a tool called with\n * `{ keywords: [\"a\", \"b\"] }` arrives as `{ \"keywords[0]\": \"a\", \"keywords[1]\": \"b\" }`,\n * and `{ files: [{ path }] }` as `{ \"files[0].path\": \"...\" }`.\n *\n * This module is the single source of truth for turning those flattened keys\n * back into nested arrays/objects. Both the host runtime's per-tool\n * normalization (gated to Copilot Gemini, schema-aware) and the MCP `callTool`\n * boundary (provider-agnostic, bracket self-gating) delegate here so the two\n * paths cannot drift — in particular so the prototype-pollution guard lives in\n * exactly one place.\n *\n * Security: argument keys cross a trust boundary (model/provider wire → tool /\n * MCP server validation). A key path that walks through `__proto__`,\n * `constructor`, or `prototype` could otherwise reach `Object.prototype` and\n * mutate it process-wide. Any key whose path contains such a segment — at any\n * position, including the final segment and a literal plain key — is dropped.\n */\n\n/** Key segments that must never be written or traversed (prototype pollution). */\nconst UNSAFE_KEY_SEGMENTS: ReadonlySet<string> = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\nfunction isUnsafeSegment(segment: string | number): boolean {\n return typeof segment === \"string\" && UNSAFE_KEY_SEGMENTS.has(segment);\n}\n\n/**\n * Parse a flattened key such as `a.b[0].c` into path segments\n * `[\"a\", \"b\", 0, \"c\"]`. Returns `undefined` for a plain key with no `.`/`[`, or\n * for a malformed bracket expression (left untouched by the caller).\n */\nexport function parseFlattenedKeyPath(key: string): Array<string | number> | undefined {\n if (!/[.[]/.test(key)) return undefined;\n const segments: Array<string | number> = [];\n let current = \"\";\n let index = 0;\n const flush = () => {\n if (current !== \"\") {\n segments.push(current);\n current = \"\";\n }\n };\n while (index < key.length) {\n const char = key[index];\n if (char === \".\") {\n flush();\n index += 1;\n } else if (char === \"[\") {\n flush();\n const end = key.indexOf(\"]\", index);\n if (end === -1) return undefined; // malformed — leave key untouched\n const inner = key.slice(index + 1, end);\n const numeric = Number(inner);\n if (inner.trim() !== \"\" && Number.isInteger(numeric) && numeric >= 0) {\n segments.push(numeric);\n } else {\n segments.push(inner.replace(/^[\"']|[\"']$/g, \"\"));\n }\n index = end + 1;\n } else {\n current += char;\n index += 1;\n }\n }\n flush();\n return segments.length > 0 ? segments : undefined;\n}\n\n/** Assign `value` at the given path inside `root`, creating arrays/objects as needed. */\nfunction assignFlattenedKeyPath(\n root: Record<string | number, unknown>,\n segments: Array<string | number>,\n value: unknown,\n): void {\n let node: Record<string | number, unknown> = root;\n for (let i = 0; i < segments.length - 1; i += 1) {\n const segment = segments[i];\n const nextIsIndex = typeof segments[i + 1] === \"number\";\n const existing = node[segment];\n if (existing === null || existing === undefined || typeof existing !== \"object\") {\n node[segment] = nextIsIndex ? [] : {};\n }\n node = node[segment] as Record<string | number, unknown>;\n }\n node[segments[segments.length - 1]] = value;\n}\n\n/**\n * Remove empty holes from sparse arrays produced by out-of-order indices.\n *\n * Note: this collapses holes rather than preserving them — `name[0]` + `name[2]`\n * (no index 1) becomes a dense 2-element array `[a, c]`, not `[a, <hole>, c]`.\n * That is the intended healing for Gemini's flattened output (which emits\n * contiguous indices in practice); it would, however, silently misalign two\n * arrays that were meant to be index-paired.\n */\nfunction compactSparseArrays(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.filter((entry) => entry !== undefined).map((entry) => compactSparseArrays(entry));\n }\n if (value !== null && typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) out[key] = compactSparseArrays(entry);\n return out;\n }\n return value;\n}\n\n/**\n * Reconstruct (unflatten) flattened keys into nested arrays/objects — for\n * example `\"items[0]\"` -> `{ items: [...] }` and `\"parent.child\"` ->\n * `{ parent: { child: ... } }`. `shouldSplit` decides, per key, whether it is a\n * flattened path (true) or an opaque literal key to be preserved (false);\n * callers apply their own gating/schema logic there.\n *\n * Prototype-pollution safe: a key whose parsed path contains `__proto__`,\n * `constructor`, or `prototype` (at any position) is dropped, as is a literal\n * plain key equal to one of those names.\n */\nexport function reconstructFlattenedKeys(\n args: Record<string, unknown>,\n shouldSplit: (key: string) => boolean,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(args)) {\n const segments = shouldSplit(key) ? parseFlattenedKeyPath(key) : undefined;\n if (!segments) {\n // Plain passthrough — but never assign a literal prototype-polluting key.\n if (!UNSAFE_KEY_SEGMENTS.has(key)) result[key] = value;\n continue;\n }\n if (segments.some(isUnsafeSegment)) continue; // drop a polluting path entirely\n assignFlattenedKeyPath(result, segments, value);\n }\n return compactSparseArrays(result) as Record<string, unknown>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"flattened-tool-arguments.js","sourceRoot":"","sources":["../../src/core/flattened-tool-arguments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,kFAAkF;AAClF,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;AAEpG,SAAS,eAAe,CAAC,OAAwB;IAC/C,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACzE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAW;IAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,IAAI,KAAK,GAAG,CAAC,CAAC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UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,4EAA4E;IAC5E,8EAA8E;IAC9E,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CACnC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,oBAAoB,CAAC,GAAG,EAAE,UAAU,CAAC,CACrE,CAAC;IACF,IAAI,CAAC,UAAU,IAAI,CAAC,mBAAmB;QAAE,OAAO,IAAI,CAAC;IACrD,OAAO,wBAAwB,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["/**\n * Canonical reconstruction of flattened tool-call arguments.\n *\n * Some upstream providers — notably GitHub Copilot Gemini models proxied through\n * Google's GenAI API — serialize array/object function-call arguments as\n * flattened, indexed keys on the wire. For example a tool called with\n * `{ keywords: [\"a\", \"b\"] }` arrives as `{ \"keywords[0]\": \"a\", \"keywords[1]\": \"b\" }`,\n * and `{ files: [{ path }] }` as `{ \"files[0].path\": \"...\" }`.\n *\n * This module is the single source of truth for turning those flattened keys\n * back into nested arrays/objects. Both the host runtime's per-tool\n * normalization (gated to Copilot Gemini, schema-aware) and the MCP `callTool`\n * boundary (provider-agnostic, bracket self-gating) delegate here so the two\n * paths cannot drift — in particular so the prototype-pollution guard lives in\n * exactly one place.\n *\n * Security: argument keys cross a trust boundary (model/provider wire → tool /\n * MCP server validation). A key path that walks through `__proto__`,\n * `constructor`, or `prototype` could otherwise reach `Object.prototype` and\n * mutate it process-wide. Any key whose path contains such a segment — at any\n * position, including the final segment and a literal plain key — is dropped.\n */\n\n/** Key segments that must never be written or traversed (prototype pollution). */\nconst UNSAFE_KEY_SEGMENTS: ReadonlySet<string> = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\nfunction isUnsafeSegment(segment: string | number): boolean {\n return typeof segment === \"string\" && UNSAFE_KEY_SEGMENTS.has(segment);\n}\n\n/**\n * Parse a flattened key such as `a.b[0].c` into path segments\n * `[\"a\", \"b\", 0, \"c\"]`. Returns `undefined` for a plain key with no `.`/`[`, or\n * for a malformed bracket expression (left untouched by the caller).\n */\nexport function parseFlattenedKeyPath(key: string): Array<string | number> | undefined {\n if (!/[.[]/.test(key)) return undefined;\n const segments: Array<string | number> = [];\n let current = \"\";\n let index = 0;\n const flush = () => {\n if (current !== \"\") {\n segments.push(current);\n current = \"\";\n }\n };\n while (index < key.length) {\n const char = key[index];\n if (char === \".\") {\n flush();\n index += 1;\n } else if (char === \"[\") {\n flush();\n const end = key.indexOf(\"]\", index);\n if (end === -1) return undefined; // malformed — leave key untouched\n const inner = key.slice(index + 1, end);\n const numeric = Number(inner);\n if (inner.trim() !== \"\" && Number.isInteger(numeric) && numeric >= 0) {\n segments.push(numeric);\n } else {\n segments.push(inner.replace(/^[\"']|[\"']$/g, \"\"));\n }\n index = end + 1;\n } else {\n current += char;\n index += 1;\n }\n }\n flush();\n return segments.length > 0 ? segments : undefined;\n}\n\n/** Assign `value` at the given path inside `root`, creating arrays/objects as needed. */\nfunction assignFlattenedKeyPath(\n root: Record<string | number, unknown>,\n segments: Array<string | number>,\n value: unknown,\n): void {\n let node: Record<string | number, unknown> = root;\n for (let i = 0; i < segments.length - 1; i += 1) {\n const segment = segments[i];\n const nextIsIndex = typeof segments[i + 1] === \"number\";\n const existing = node[segment];\n if (existing === null || existing === undefined || typeof existing !== \"object\") {\n node[segment] = nextIsIndex ? [] : {};\n }\n node = node[segment] as Record<string | number, unknown>;\n }\n node[segments[segments.length - 1]] = value;\n}\n\n/**\n * Remove empty holes from sparse arrays produced by out-of-order indices.\n *\n * Note: this collapses holes rather than preserving them — `name[0]` + `name[2]`\n * (no index 1) becomes a dense 2-element array `[a, c]`, not `[a, <hole>, c]`.\n * That is the intended healing for Gemini's flattened output (which emits\n * contiguous indices in practice); it would, however, silently misalign two\n * arrays that were meant to be index-paired.\n */\nfunction compactSparseArrays(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.filter((entry) => entry !== undefined).map((entry) => compactSparseArrays(entry));\n }\n if (value !== null && typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) out[key] = compactSparseArrays(entry);\n return out;\n }\n return value;\n}\n\n/**\n * Reconstruct (unflatten) flattened keys into nested arrays/objects — for\n * example `\"items[0]\"` -> `{ items: [...] }` and `\"parent.child\"` ->\n * `{ parent: { child: ... } }`. `shouldSplit` decides, per key, whether it is a\n * flattened path (true) or an opaque literal key to be preserved (false);\n * callers apply their own gating/schema logic there.\n *\n * Prototype-pollution safe: a key whose parsed path contains `__proto__`,\n * `constructor`, or `prototype` (at any position) is dropped, as is a literal\n * plain key equal to one of those names.\n */\nexport function reconstructFlattenedKeys(\n args: Record<string, unknown>,\n shouldSplit: (key: string) => boolean,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(args)) {\n const segments = shouldSplit(key) ? parseFlattenedKeyPath(key) : undefined;\n if (!segments) {\n // Plain passthrough — but never assign a literal prototype-polluting key.\n if (!UNSAFE_KEY_SEGMENTS.has(key)) result[key] = value;\n continue;\n }\n if (segments.some(isUnsafeSegment)) continue; // drop a polluting path entirely\n assignFlattenedKeyPath(result, segments, value);\n }\n return compactSparseArrays(result) as Record<string, unknown>;\n}\n\n// ---------------------------------------------------------------------------\n// Schema-aware unflattening\n// ---------------------------------------------------------------------------\n//\n// A flattened key with a bracket index (`foo[0]`) is unambiguous and is always\n// reconstructed. A purely dotted key (`parent.child`) is ambiguous: it could be\n// a real nested path *or* a legitimate argument whose name literally contains\n// a dot (for example an MCP tool whose JSON Schema declares a property named\n// `filter.name`). To avoid corrupting such literal dotted keys, a dotted key is\n// only split when the tool's `inputSchema` proves its head segment is an\n// object/array container property. The presence of a bracket-indexed sibling\n// does NOT force a pure dotted key to split — the two are decided per key, so\n// a literal property such as `filter.name` survives intact even when a bracket\n// sibling like `ids[0]` is present (issue #1496). Callers that only want the\n// unambiguous bracket case can omit the schema.\n\ntype JsonRecord = Record<string, unknown>;\n\nfunction isPlainObject(value: unknown): value is JsonRecord {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** A flattened key contains a bracket index like `foo[0]`. */\nfunction hasBracketIndex(key: string): boolean {\n return /\\[\\d+\\]/.test(key);\n}\n\n/** A schema node that holds a nested object/array (so dotted keys are real paths). */\nfunction isContainerSchema(schema: unknown): boolean {\n if (!isPlainObject(schema)) return false;\n if (schema.type === \"object\" || schema.type === \"array\") return true;\n if (\"properties\" in schema || \"items\" in schema) return true;\n const union = schema.anyOf ?? schema.oneOf;\n if (Array.isArray(union)) return union.some((branch) => isContainerSchema(branch));\n return false;\n}\n\n/** Exact top-level `schema.properties` names (literal property keys). */\nfunction literalPropertyNames(schema: unknown): Set<string> {\n const names = new Set<string>();\n if (!isPlainObject(schema)) return names;\n const properties = schema.properties;\n if (!isPlainObject(properties)) return names;\n for (const name of Object.keys(properties)) names.add(name);\n return names;\n}\n\n/** Top-level property names whose schema is an object/array container. */\nfunction containerPropertyNames(schema: unknown): Set<string> {\n const names = new Set<string>();\n if (!isPlainObject(schema)) return names;\n const properties = schema.properties;\n if (!isPlainObject(properties)) return names;\n for (const [name, sub] of Object.entries(properties)) {\n if (isContainerSchema(sub)) names.add(name);\n }\n return names;\n}\n\n/** Whether `key` is a pure dotted path (`parent.child`) headed by a container prop. */\nfunction isDottedContainerKey(key: string, containers: Set<string>): boolean {\n const dot = key.indexOf(\".\");\n if (dot <= 0) return false;\n return containers.has(key.slice(0, dot));\n}\n\n/**\n * Decide whether a flattened key should be split into nested path segments.\n *\n * - Bracket-indexed keys (`foo[0]`, `foo[0].bar`) always split: they are\n * unambiguous evidence of provider flattening.\n * - Purely dotted keys (`parent.child`) split only when the schema marks their\n * head segment as an object/array container property AND the schema does not\n * declare the full key as a literal top-level property. The latter guard\n * protects a schema that intentionally defines both a literal dotted property\n * (e.g. `filter.name`) and a same-head container (e.g. `filter`): the literal\n * property wins and is preserved verbatim (reviewer-b P2, issue #1496). The\n * presence of a bracket-indexed sibling does NOT force a pure dotted key to\n * split, so a literal property name such as `filter.name` is preserved\n * verbatim even when a sibling like `ids[0]` is reconstructed.\n */\nfunction shouldSplitKey(key: string, containers: Set<string>, literals: Set<string>): boolean {\n if (hasBracketIndex(key)) return true;\n if (literals.has(key)) return false; // explicit literal property wins\n return isDottedContainerKey(key, containers);\n}\n\n/**\n * Reconstruct flattened tool-call arguments into nested arrays/objects using\n * schema-aware disambiguation for dotted keys.\n *\n * - Bracket-indexed keys (`ids[0]`, `files[0].path`) are always reconstructed.\n * - Purely dotted keys (`parent.child`) are reconstructed only when the optional\n * `schema` marks their head segment as an object/array container property.\n * The presence of a bracket-indexed sibling does NOT force a pure dotted key\n * to split, so a literal property name such as `filter.name` survives intact\n * even when a sibling like `ids[0]` is present (issue #1496).\n * - Otherwise dotted keys are preserved verbatim — fixing the regression where a\n * literal property name like `filter.name` was silently corrupted.\n *\n * Returns the original reference unchanged when there is nothing to\n * reconstruct. Prototype-pollution safety is delegated to\n * {@link reconstructFlattenedKeys}.\n */\nexport function unflattenArgumentsWithSchema(\n args: Record<string, unknown>,\n schema?: unknown,\n): Record<string, unknown> {\n const keys = Object.keys(args);\n const literals = literalPropertyNames(schema);\n const containers = containerPropertyNames(schema);\n const hasBracket = keys.some((key) => hasBracketIndex(key));\n // A dotted key needs splitting only if it is not a literal property AND its\n // head is a schema container. Literal dotted properties are always preserved.\n const hasSplittableDotted = keys.some(\n (key) => !literals.has(key) && isDottedContainerKey(key, containers),\n );\n if (!hasBracket && !hasSplittableDotted) return args;\n return reconstructFlattenedKeys(args, (key) => shouldSplitKey(key, containers, literals));\n}\n"]}
|
|
@@ -3,5 +3,5 @@ export type { ExtensionAPI, ExtensionCommandContext, ExtensionContext, Extension
|
|
|
3
3
|
export type { PromptTemplate } from "./prompt-templates.ts";
|
|
4
4
|
export type { Skill } from "./skills.ts";
|
|
5
5
|
export type { JsonObject, JsonPrimitive, JsonValue, StructuredOutputCapture, StructuredOutputFileCapture, StructuredOutputToolOptions, Tool, } from "./tools/index.ts";
|
|
6
|
-
export { withFileMutationQueue, STRUCTURED_OUTPUT_TOOL_NAME, createCodingTools, createReadOnlyTools, createReadTool, createBashTool, createEditTool, createWriteTool,
|
|
6
|
+
export { withFileMutationQueue, STRUCTURED_OUTPUT_TOOL_NAME, createCodingTools, createReadOnlyTools, createReadTool, createBashTool, createEditTool, createWriteTool, createFindTool, createSearchTool, createLsTool, createStructuredOutputCapture, createStructuredOutputTool, } from "./tools/index.ts";
|
|
7
7
|
//# sourceMappingURL=sdk-exports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-exports.d.ts","sourceRoot":"","sources":["../../src/core/sdk-exports.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,YAAY,EACV,YAAY,EACZ,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EACV,UAAU,EACV,aAAa,EACb,SAAS,EACT,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,IAAI,GACL,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAE3B,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"sdk-exports.d.ts","sourceRoot":"","sources":["../../src/core/sdk-exports.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,YAAY,EACV,YAAY,EACZ,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EACV,UAAU,EACV,aAAa,EACb,SAAS,EACT,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,IAAI,GACL,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAE3B,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC","sourcesContent":["export * from \"./agent-session-runtime.ts\";\nexport type {\n ExtensionAPI,\n ExtensionCommandContext,\n ExtensionContext,\n ExtensionFactory,\n SlashCommandInfo,\n SlashCommandSource,\n ToolDefinition,\n} from \"./extensions/index.ts\";\nexport type { PromptTemplate } from \"./prompt-templates.ts\";\nexport type { Skill } from \"./skills.ts\";\nexport type {\n JsonObject,\n JsonPrimitive,\n JsonValue,\n StructuredOutputCapture,\n StructuredOutputFileCapture,\n StructuredOutputToolOptions,\n Tool,\n} from \"./tools/index.ts\";\n\nexport {\n withFileMutationQueue,\n STRUCTURED_OUTPUT_TOOL_NAME,\n // Tool factories (for custom cwd)\n createCodingTools,\n createReadOnlyTools,\n createReadTool,\n createBashTool,\n createEditTool,\n createWriteTool,\n createFindTool,\n createSearchTool,\n createLsTool,\n createStructuredOutputCapture,\n createStructuredOutputTool,\n} from \"./tools/index.ts\";\n\n"]}
|
package/dist/core/sdk-exports.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./agent-session-runtime.js";
|
|
2
2
|
export { withFileMutationQueue, STRUCTURED_OUTPUT_TOOL_NAME,
|
|
3
3
|
// Tool factories (for custom cwd)
|
|
4
|
-
createCodingTools, createReadOnlyTools, createReadTool, createBashTool, createEditTool, createWriteTool,
|
|
4
|
+
createCodingTools, createReadOnlyTools, createReadTool, createBashTool, createEditTool, createWriteTool, createFindTool, createSearchTool, createLsTool, createStructuredOutputCapture, createStructuredOutputTool, } from "./tools/index.js";
|
|
5
5
|
//# sourceMappingURL=sdk-exports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-exports.js","sourceRoot":"","sources":["../../src/core/sdk-exports.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAsB3C,OAAO,EACL,qBAAqB,EACrB,2BAA2B;AAC3B,kCAAkC;AAClC,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"sdk-exports.js","sourceRoot":"","sources":["../../src/core/sdk-exports.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAsB3C,OAAO,EACL,qBAAqB,EACrB,2BAA2B;AAC3B,kCAAkC;AAClC,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC","sourcesContent":["export * from \"./agent-session-runtime.ts\";\nexport type {\n ExtensionAPI,\n ExtensionCommandContext,\n ExtensionContext,\n ExtensionFactory,\n SlashCommandInfo,\n SlashCommandSource,\n ToolDefinition,\n} from \"./extensions/index.ts\";\nexport type { PromptTemplate } from \"./prompt-templates.ts\";\nexport type { Skill } from \"./skills.ts\";\nexport type {\n JsonObject,\n JsonPrimitive,\n JsonValue,\n StructuredOutputCapture,\n StructuredOutputFileCapture,\n StructuredOutputToolOptions,\n Tool,\n} from \"./tools/index.ts\";\n\nexport {\n withFileMutationQueue,\n STRUCTURED_OUTPUT_TOOL_NAME,\n // Tool factories (for custom cwd)\n createCodingTools,\n createReadOnlyTools,\n createReadTool,\n createBashTool,\n createEditTool,\n createWriteTool,\n createFindTool,\n createSearchTool,\n createLsTool,\n createStructuredOutputCapture,\n createStructuredOutputTool,\n} from \"./tools/index.ts\";\n\n"]}
|
package/dist/core/sdk-types.d.ts
CHANGED
|
@@ -34,14 +34,14 @@ export interface CreateAgentSessionOptions {
|
|
|
34
34
|
*
|
|
35
35
|
* - "all": start with no tools enabled
|
|
36
36
|
* - "builtin": disable the default built-in tools (read, bash, edit, write,
|
|
37
|
-
* ask_user_question, todo) but keep extension/custom tools enabled
|
|
37
|
+
* find, search, ask_user_question, todo) but keep extension/custom tools enabled
|
|
38
38
|
*/
|
|
39
39
|
noTools?: "all" | "builtin";
|
|
40
40
|
/**
|
|
41
41
|
* Optional allowlist of tool names.
|
|
42
42
|
*
|
|
43
43
|
* When omitted, pi enables the default built-in tools (read, bash, edit, write,
|
|
44
|
-
* ask_user_question, todo) and leaves extension/custom tools enabled unless
|
|
44
|
+
* find, search, ask_user_question, todo) and leaves extension/custom tools enabled unless
|
|
45
45
|
* `noTools` changes that default.
|
|
46
46
|
* When provided, only the listed tool names are enabled, minus any names in
|
|
47
47
|
* `excludedTools`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-types.d.ts","sourceRoot":"","sources":["../../src/core/sdk-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAA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CAAC,EAAE,cAAc,CAAC;IAEhC,uEAAuE;IACvE,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,8EAA8E;IAC9E,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED,qCAAqC;AACrC,MAAM,WAAW,wBAAwB;IACvC,0BAA0B;IAC1B,OAAO,EAAE,YAAY,CAAC;IACtB,mEAAmE;IACnE,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,wEAAwE;IACxE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,4FAA4F;IAC5F,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,2EAA2E;IAC3E,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, Model } from \"@earendil-works/pi-ai\";\nimport type { AuthStorage } from \"./auth-storage.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { AgentSession } from \"./agent-session.ts\";\nimport type { LoadExtensionsResult, OrchestrationContext, SessionStartEvent, ToolDefinition } from \"./extensions/index.ts\";\n\nexport interface CreateAgentSessionOptions {\n /** Working directory for project-local discovery. Default: process.cwd() */\n cwd?: string;\n /** Global config directory. Default: ~/.atomic/agent */\n agentDir?: string;\n\n /** Auth storage for credentials. Default: AuthStorage.create(agentDir/auth.json) */\n authStorage?: AuthStorage;\n /** Model registry. Default: ModelRegistry.create(authStorage, agentDir/models.json) */\n modelRegistry?: ModelRegistry;\n\n /** Model to use. Default: from settings, else first available */\n model?: Model<Api>;\n /** Thinking level. Default: from settings, else 'medium' (clamped to model capabilities) */\n thinkingLevel?: ThinkingLevel;\n /** Context window token count. Default: model scalar contextWindow, or settings/session override when supported. */\n contextWindow?: number;\n /** Treat unsupported contextWindow as an error instead of a warning/fallback. */\n contextWindowStrict?: boolean;\n /** Models available for cycling (Ctrl+P in interactive mode) */\n scopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\n /**\n * Optional default tool suppression mode when no explicit allowlist is provided.\n *\n * - \"all\": start with no tools enabled\n * - \"builtin\": disable the default built-in tools (read, bash, edit, write,\n * ask_user_question, todo) but keep extension/custom tools enabled\n */\n noTools?: \"all\" | \"builtin\";\n /**\n * Optional allowlist of tool names.\n *\n * When omitted, pi enables the default built-in tools (read, bash, edit, write,\n * ask_user_question, todo) and leaves extension/custom tools enabled unless\n * `noTools` changes that default.\n * When provided, only the listed tool names are enabled, minus any names in\n * `excludedTools`.\n */\n tools?: string[];\n /**\n * Optional blocklist of tool names.\n *\n * Matching built-in, extension, and SDK custom tools are omitted from the\n * final session tool registry and active tool set. Unknown names are ignored.\n */\n excludedTools?: string[];\n /** Custom tools to register (in addition to built-in tools). */\n customTools?: ToolDefinition[];\n\n /** Resource loader. When omitted, DefaultResourceLoader is used. */\n resourceLoader?: ResourceLoader;\n\n /** Session manager. Default: SessionManager.create(cwd) */\n sessionManager?: SessionManager;\n\n /** Settings manager. Default: SettingsManager.create(cwd, agentDir) */\n settingsManager?: SettingsManager;\n /** Session start event metadata for extension runtime startup. */\n sessionStartEvent?: SessionStartEvent;\n /** Session-scoped orchestration policy exposed to extension/tool handlers. */\n orchestrationContext?: OrchestrationContext;\n}\n\n/** Result from createAgentSession */\nexport interface CreateAgentSessionResult {\n /** The created session */\n session: AgentSession;\n /** Extensions result (for UI context setup in interactive mode) */\n extensionsResult: LoadExtensionsResult;\n /** Warning if session was restored with a different model than saved */\n modelFallbackMessage?: string;\n /** Warning if a saved/default context window could not be applied to the selected model. */\n contextWindowWarning?: string;\n /** Error if an explicit strict context-window selection is unsupported. */\n contextWindowError?: string;\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"sdk-types.d.ts","sourceRoot":"","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AMG;IACH,OAAO,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IAC5B;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,gEAAgE;IAChE,WAAW,CAAC,EAAE,cAAc,EAAE,CAAC;IAE/B,oEAAoE;IACpE,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,uEAAuE;IACvE,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,8EAA8E;IAC9E,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED,qCAAqC;AACrC,MAAM,WAAW,wBAAwB;IACvC,0BAA0B;IAC1B,OAAO,EAAE,YAAY,CAAC;IACtB,mEAAmE;IACnE,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,wEAAwE;IACxE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,4FAA4F;IAC5F,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,2EAA2E;IAC3E,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, Model } from \"@earendil-works/pi-ai\";\nimport type { AuthStorage } from \"./auth-storage.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { AgentSession } from \"./agent-session.ts\";\nimport type { LoadExtensionsResult, OrchestrationContext, SessionStartEvent, ToolDefinition } from \"./extensions/index.ts\";\n\nexport interface CreateAgentSessionOptions {\n /** Working directory for project-local discovery. Default: process.cwd() */\n cwd?: string;\n /** Global config directory. Default: ~/.atomic/agent */\n agentDir?: string;\n\n /** Auth storage for credentials. Default: AuthStorage.create(agentDir/auth.json) */\n authStorage?: AuthStorage;\n /** Model registry. Default: ModelRegistry.create(authStorage, agentDir/models.json) */\n modelRegistry?: ModelRegistry;\n\n /** Model to use. Default: from settings, else first available */\n model?: Model<Api>;\n /** Thinking level. Default: from settings, else 'medium' (clamped to model capabilities) */\n thinkingLevel?: ThinkingLevel;\n /** Context window token count. Default: model scalar contextWindow, or settings/session override when supported. */\n contextWindow?: number;\n /** Treat unsupported contextWindow as an error instead of a warning/fallback. */\n contextWindowStrict?: boolean;\n /** Models available for cycling (Ctrl+P in interactive mode) */\n scopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\n /**\n * Optional default tool suppression mode when no explicit allowlist is provided.\n *\n * - \"all\": start with no tools enabled\n * - \"builtin\": disable the default built-in tools (read, bash, edit, write,\n * find, search, ask_user_question, todo) but keep extension/custom tools enabled\n */\n noTools?: \"all\" | \"builtin\";\n /**\n * Optional allowlist of tool names.\n *\n * When omitted, pi enables the default built-in tools (read, bash, edit, write,\n * find, search, ask_user_question, todo) and leaves extension/custom tools enabled unless\n * `noTools` changes that default.\n * When provided, only the listed tool names are enabled, minus any names in\n * `excludedTools`.\n */\n tools?: string[];\n /**\n * Optional blocklist of tool names.\n *\n * Matching built-in, extension, and SDK custom tools are omitted from the\n * final session tool registry and active tool set. Unknown names are ignored.\n */\n excludedTools?: string[];\n /** Custom tools to register (in addition to built-in tools). */\n customTools?: ToolDefinition[];\n\n /** Resource loader. When omitted, DefaultResourceLoader is used. */\n resourceLoader?: ResourceLoader;\n\n /** Session manager. Default: SessionManager.create(cwd) */\n sessionManager?: SessionManager;\n\n /** Settings manager. Default: SettingsManager.create(cwd, agentDir) */\n settingsManager?: SettingsManager;\n /** Session start event metadata for extension runtime startup. */\n sessionStartEvent?: SessionStartEvent;\n /** Session-scoped orchestration policy exposed to extension/tool handlers. */\n orchestrationContext?: OrchestrationContext;\n}\n\n/** Result from createAgentSession */\nexport interface CreateAgentSessionResult {\n /** The created session */\n session: AgentSession;\n /** Extensions result (for UI context setup in interactive mode) */\n extensionsResult: LoadExtensionsResult;\n /** Warning if session was restored with a different model than saved */\n modelFallbackMessage?: string;\n /** Warning if a saved/default context window could not be applied to the selected model. */\n contextWindowWarning?: string;\n /** Error if an explicit strict context-window selection is unsupported. */\n contextWindowError?: string;\n}\n\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-types.js","sourceRoot":"","sources":["../../src/core/sdk-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, Model } from \"@earendil-works/pi-ai\";\nimport type { AuthStorage } from \"./auth-storage.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { AgentSession } from \"./agent-session.ts\";\nimport type { LoadExtensionsResult, OrchestrationContext, SessionStartEvent, ToolDefinition } from \"./extensions/index.ts\";\n\nexport interface CreateAgentSessionOptions {\n /** Working directory for project-local discovery. Default: process.cwd() */\n cwd?: string;\n /** Global config directory. Default: ~/.atomic/agent */\n agentDir?: string;\n\n /** Auth storage for credentials. Default: AuthStorage.create(agentDir/auth.json) */\n authStorage?: AuthStorage;\n /** Model registry. Default: ModelRegistry.create(authStorage, agentDir/models.json) */\n modelRegistry?: ModelRegistry;\n\n /** Model to use. Default: from settings, else first available */\n model?: Model<Api>;\n /** Thinking level. Default: from settings, else 'medium' (clamped to model capabilities) */\n thinkingLevel?: ThinkingLevel;\n /** Context window token count. Default: model scalar contextWindow, or settings/session override when supported. */\n contextWindow?: number;\n /** Treat unsupported contextWindow as an error instead of a warning/fallback. */\n contextWindowStrict?: boolean;\n /** Models available for cycling (Ctrl+P in interactive mode) */\n scopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\n /**\n * Optional default tool suppression mode when no explicit allowlist is provided.\n *\n * - \"all\": start with no tools enabled\n * - \"builtin\": disable the default built-in tools (read, bash, edit, write,\n * ask_user_question, todo) but keep extension/custom tools enabled\n */\n noTools?: \"all\" | \"builtin\";\n /**\n * Optional allowlist of tool names.\n *\n * When omitted, pi enables the default built-in tools (read, bash, edit, write,\n * ask_user_question, todo) and leaves extension/custom tools enabled unless\n * `noTools` changes that default.\n * When provided, only the listed tool names are enabled, minus any names in\n * `excludedTools`.\n */\n tools?: string[];\n /**\n * Optional blocklist of tool names.\n *\n * Matching built-in, extension, and SDK custom tools are omitted from the\n * final session tool registry and active tool set. Unknown names are ignored.\n */\n excludedTools?: string[];\n /** Custom tools to register (in addition to built-in tools). */\n customTools?: ToolDefinition[];\n\n /** Resource loader. When omitted, DefaultResourceLoader is used. */\n resourceLoader?: ResourceLoader;\n\n /** Session manager. Default: SessionManager.create(cwd) */\n sessionManager?: SessionManager;\n\n /** Settings manager. Default: SettingsManager.create(cwd, agentDir) */\n settingsManager?: SettingsManager;\n /** Session start event metadata for extension runtime startup. */\n sessionStartEvent?: SessionStartEvent;\n /** Session-scoped orchestration policy exposed to extension/tool handlers. */\n orchestrationContext?: OrchestrationContext;\n}\n\n/** Result from createAgentSession */\nexport interface CreateAgentSessionResult {\n /** The created session */\n session: AgentSession;\n /** Extensions result (for UI context setup in interactive mode) */\n extensionsResult: LoadExtensionsResult;\n /** Warning if session was restored with a different model than saved */\n modelFallbackMessage?: string;\n /** Warning if a saved/default context window could not be applied to the selected model. */\n contextWindowWarning?: string;\n /** Error if an explicit strict context-window selection is unsupported. */\n contextWindowError?: string;\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"sdk-types.js","sourceRoot":"","sources":["../../src/core/sdk-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, Model } from \"@earendil-works/pi-ai\";\nimport type { AuthStorage } from \"./auth-storage.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { AgentSession } from \"./agent-session.ts\";\nimport type { LoadExtensionsResult, OrchestrationContext, SessionStartEvent, ToolDefinition } from \"./extensions/index.ts\";\n\nexport interface CreateAgentSessionOptions {\n /** Working directory for project-local discovery. Default: process.cwd() */\n cwd?: string;\n /** Global config directory. Default: ~/.atomic/agent */\n agentDir?: string;\n\n /** Auth storage for credentials. Default: AuthStorage.create(agentDir/auth.json) */\n authStorage?: AuthStorage;\n /** Model registry. Default: ModelRegistry.create(authStorage, agentDir/models.json) */\n modelRegistry?: ModelRegistry;\n\n /** Model to use. Default: from settings, else first available */\n model?: Model<Api>;\n /** Thinking level. Default: from settings, else 'medium' (clamped to model capabilities) */\n thinkingLevel?: ThinkingLevel;\n /** Context window token count. Default: model scalar contextWindow, or settings/session override when supported. */\n contextWindow?: number;\n /** Treat unsupported contextWindow as an error instead of a warning/fallback. */\n contextWindowStrict?: boolean;\n /** Models available for cycling (Ctrl+P in interactive mode) */\n scopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\n /**\n * Optional default tool suppression mode when no explicit allowlist is provided.\n *\n * - \"all\": start with no tools enabled\n * - \"builtin\": disable the default built-in tools (read, bash, edit, write,\n * find, search, ask_user_question, todo) but keep extension/custom tools enabled\n */\n noTools?: \"all\" | \"builtin\";\n /**\n * Optional allowlist of tool names.\n *\n * When omitted, pi enables the default built-in tools (read, bash, edit, write,\n * find, search, ask_user_question, todo) and leaves extension/custom tools enabled unless\n * `noTools` changes that default.\n * When provided, only the listed tool names are enabled, minus any names in\n * `excludedTools`.\n */\n tools?: string[];\n /**\n * Optional blocklist of tool names.\n *\n * Matching built-in, extension, and SDK custom tools are omitted from the\n * final session tool registry and active tool set. Unknown names are ignored.\n */\n excludedTools?: string[];\n /** Custom tools to register (in addition to built-in tools). */\n customTools?: ToolDefinition[];\n\n /** Resource loader. When omitted, DefaultResourceLoader is used. */\n resourceLoader?: ResourceLoader;\n\n /** Session manager. Default: SessionManager.create(cwd) */\n sessionManager?: SessionManager;\n\n /** Settings manager. Default: SettingsManager.create(cwd, agentDir) */\n settingsManager?: SettingsManager;\n /** Session start event metadata for extension runtime startup. */\n sessionStartEvent?: SessionStartEvent;\n /** Session-scoped orchestration policy exposed to extension/tool handlers. */\n orchestrationContext?: OrchestrationContext;\n}\n\n/** Result from createAgentSession */\nexport interface CreateAgentSessionResult {\n /** The created session */\n session: AgentSession;\n /** Extensions result (for UI context setup in interactive mode) */\n extensionsResult: LoadExtensionsResult;\n /** Warning if session was restored with a different model than saved */\n modelFallbackMessage?: string;\n /** Warning if a saved/default context window could not be applied to the selected model. */\n contextWindowWarning?: string;\n /** Error if an explicit strict context-window selection is unsupported. */\n contextWindowError?: string;\n}\n\n"]}
|