dal-code 1.0.24 → 1.0.25
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 +18 -0
- package/dal-docs/README.md +96 -0
- package/dal-docs/extensions.md +98 -0
- package/dal-docs/keybindings.md +40 -0
- package/dal-docs/packages.md +62 -0
- package/dal-docs/prompt-templates.md +42 -0
- package/dal-docs/settings.md +86 -0
- package/dal-docs/skills.md +65 -0
- package/dal-docs/themes.md +44 -0
- package/dist/cli/args.d.ts +56 -0
- package/dist/config.d.ts +63 -0
- package/dist/config.js +1 -1
- package/dist/core/agent-session-runtime.d.ts +74 -0
- package/dist/core/agent-session-services.d.ts +48 -0
- package/dist/core/agent-session.d.ts +409 -0
- package/dist/core/agent-session.js +5 -5
- package/dist/core/auth-storage.d.ts +56 -0
- package/dist/core/bash-executor.d.ts +13 -0
- package/dist/core/cache-warmer.d.ts +60 -0
- package/dist/core/compaction/branch-summarization.d.ts +43 -0
- package/dist/core/compaction/compaction.d.ts +62 -0
- package/dist/core/compaction/index.d.ts +3 -0
- package/dist/core/compaction/utils.d.ts +16 -0
- package/dist/core/diagnostics.d.ts +14 -0
- package/dist/core/event-bus.d.ts +8 -0
- package/dist/core/exec.d.ts +12 -0
- package/dist/core/extensions/index.d.ts +8 -0
- package/dist/core/extensions/loader.d.ts +13 -0
- package/dist/core/extensions/runner.d.ts +165 -0
- package/dist/core/extensions/types.d.ts +1000 -0
- package/dist/core/extensions/wrapper.d.ts +5 -0
- package/dist/core/footer-data-provider.d.ts +46 -0
- package/dist/core/keybindings.d.ts +525 -0
- package/dist/core/messages.d.ts +50 -0
- package/dist/core/model-config.d.ts +1212 -0
- package/dist/core/model-registry.d.ts +41 -0
- package/dist/core/model-resolver.d.ts +67 -0
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-runtime.d.ts +101 -0
- package/dist/core/model-runtime.js +2 -2
- package/dist/core/package-manager.d.ts +213 -0
- package/dist/core/package-manager.js +2 -2
- package/dist/core/project-map.d.ts +18 -0
- package/dist/core/prompt-templates.d.ts +24 -0
- package/dist/core/provider-composer.d.ts +55 -0
- package/dist/core/remote-catalog-provider.js +1 -1
- package/dist/core/resolve-config-value.d.ts +11 -0
- package/dist/core/resource-loader.d.ts +220 -0
- package/dist/core/resource-loader.js +1 -1
- package/dist/core/sdk.d.ts +40 -0
- package/dist/core/session-manager.d.ts +208 -0
- package/dist/core/settings-manager.d.ts +348 -0
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/skills.d.ts +33 -0
- package/dist/core/slash-commands.d.ts +14 -0
- package/dist/core/source-info.d.ts +17 -0
- package/dist/core/system-prompt.d.ts +39 -0
- package/dist/core/system-prompt.js +15 -11
- package/dist/core/tools/bash.d.ts +75 -0
- package/dist/core/tools/bash.js +14 -14
- package/dist/core/tools/edit-diff.d.ts +44 -0
- package/dist/core/tools/edit.d.ts +48 -0
- package/dist/core/tools/file-mutation-queue.d.ts +1 -0
- package/dist/core/tools/find.d.ts +34 -0
- package/dist/core/tools/grep.d.ts +34 -0
- package/dist/core/tools/index.d.ts +42 -0
- package/dist/core/tools/index.js +1 -1
- package/dist/core/tools/ls.d.ts +33 -0
- package/dist/core/tools/powershell.d.ts +17 -0
- package/dist/core/tools/read.d.ts +33 -0
- package/dist/core/tools/read.js +2 -2
- package/dist/core/tools/renderers/bash.d.ts +3 -0
- package/dist/core/tools/renderers/edit.d.ts +15 -0
- package/dist/core/tools/renderers/find.d.ts +2 -0
- package/dist/core/tools/renderers/grep.d.ts +2 -0
- package/dist/core/tools/renderers/index.d.ts +13 -0
- package/dist/core/tools/renderers/ls.d.ts +2 -0
- package/dist/core/tools/renderers/read.d.ts +3 -0
- package/dist/core/tools/renderers/read.js +8 -8
- package/dist/core/tools/renderers/write.d.ts +2 -0
- package/dist/core/tools/truncate.d.ts +27 -0
- package/dist/core/tools/write.d.ts +24 -0
- package/dist/core/trust-manager.d.ts +28 -0
- package/dist/core/trust-manager.js +2 -2
- package/dist/dal/child-env.d.ts +12 -0
- package/dist/dal/child-env.js +1 -0
- package/dist/dal/hooks/activity.d.ts +17 -0
- package/dist/dal/hooks/activity.js +1 -0
- package/dist/dal/hooks/config.d.ts +47 -0
- package/dist/dal/hooks/config.js +1 -0
- package/dist/dal/hooks/events.d.ts +43 -0
- package/dist/dal/hooks/events.js +4 -0
- package/dist/dal/hooks/extension.d.ts +3 -0
- package/dist/dal/hooks/extension.js +4 -0
- package/dist/dal/hooks/index.d.ts +5 -0
- package/dist/dal/hooks/index.js +1 -0
- package/dist/dal/hooks/runner.d.ts +57 -0
- package/dist/dal/hooks/runner.js +1 -0
- package/dist/dal/safety-net.js +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +1 -1
- package/dist/main.d.ts +9 -0
- package/dist/main.js +2 -2
- package/dist/modes/acp/acp-mode.d.ts +2 -0
- package/dist/modes/index.d.ts +7 -0
- package/dist/modes/interactive/components/armin.d.ts +30 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +26 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +22 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +14 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +11 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +11 -0
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/modes/interactive/components/custom-message.d.ts +17 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +17 -0
- package/dist/modes/interactive/components/diff.d.ts +4 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +12 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +19 -0
- package/dist/modes/interactive/components/extension-input.d.ts +21 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +22 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts +23 -0
- package/dist/modes/interactive/components/footer.d.ts +18 -0
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/index.d.ts +33 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +9 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +27 -0
- package/dist/modes/interactive/components/model-selector.d.ts +81 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +29 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +39 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +20 -0
- package/dist/modes/interactive/components/session-selector.d.ts +88 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +92 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +6 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +11 -0
- package/dist/modes/interactive/components/status-indicator.d.ts +44 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +7 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +19 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +76 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +65 -0
- package/dist/modes/interactive/components/trust-selector.d.ts +22 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +23 -0
- package/dist/modes/interactive/components/user-message.d.ts +14 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +5 -0
- package/dist/modes/interactive/interactive-mode.d.ts +326 -0
- package/dist/modes/interactive/theme/theme-json.d.ts +257 -0
- package/dist/modes/interactive/theme/theme.d.ts +106 -0
- package/dist/modes/interactive/tui-renderer.d.ts +18 -0
- package/dist/modes/json-event.d.ts +26 -0
- package/dist/modes/print-mode.d.ts +9 -0
- package/dist/modes/rpc/rpc-client.d.ts +119 -0
- package/dist/modes/rpc/rpc-client.js +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +3 -0
- package/dist/modes/rpc/rpc-types.d.ts +483 -0
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/src/ask-user.js +12 -0
- package/dist/node_modules/@dalcode/dal-bridge/src/client.js +1 -1
- package/dist/node_modules/@dalcode/dal-bridge/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-guard/package.json +5 -4
- package/dist/node_modules/@dalcode/dal-guard/src/hooks.js +1 -0
- package/dist/node_modules/@dalcode/dal-guard/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-lsp/src/client.js +3 -3
- package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-mcp/src/command-parser.d.ts +19 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/config-edit.d.ts +19 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/config.d.ts +9 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/http-client.d.ts +16 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.d.ts +22 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.js +2 -2
- package/dist/node_modules/@dalcode/dal-mcp/src/types.d.ts +30 -0
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-office/src/extract/csv.d.ts +3 -0
- package/dist/node_modules/@dalcode/dal-office/src/extract/csv.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/extract/ooxml.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/index.d.ts +11 -0
- package/dist/node_modules/@dalcode/dal-office/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/paths.d.ts +3 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/chart.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/render/docx.d.ts +19 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/pptx.d.ts +40 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/pptx.js +2 -2
- package/dist/node_modules/@dalcode/dal-office/src/render/thumbnails.d.ts +19 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/thumbnails.js +1 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/xlsx.d.ts +14 -0
- package/dist/node_modules/@dalcode/dal-office/src/scratchpad.d.ts +16 -0
- package/dist/node_modules/@dalcode/dal-office/src/themes.d.ts +13 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/docx-edit.js +10 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/edit-shared.js +1 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/pptx-edit.js +9 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/read-file.js +4 -2
- package/dist/node_modules/@dalcode/dal-office/src/tools/xlsx-edit.js +5 -0
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +2 -2
- package/dist/node_modules/@dalcode/dal-plugins/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-rewind/src/core.d.ts +61 -0
- package/dist/node_modules/@dalcode/dal-router/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-router/src/config.d.ts +50 -0
- package/dist/node_modules/@dalcode/dal-router/src/jev.d.ts +51 -0
- package/dist/node_modules/@dalcode/dal-router/src/pool.d.ts +6 -0
- package/dist/node_modules/@dalcode/dal-router/src/router.d.ts +32 -0
- package/dist/node_modules/@dalcode/dal-router/src/runtime.d.ts +37 -0
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-skills/src/discover.js +4 -4
- package/dist/node_modules/@dalcode/dal-skills/src/index.js +9 -9
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-subagent/src/index.js +10 -10
- package/dist/node_modules/@dalcode/dal-subagent/src/process-runner.js +3 -3
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/src/groups.js +1 -1
- package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/plan-mode.js +1 -1
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@dalcode/deepailab/src/index.js +3 -3
- package/dist/node_modules/@dalcode/deepailab/src/model-defaults.js +1 -1
- package/dist/node_modules/@earendil-works/chord/dist/api.d.ts +21 -0
- package/dist/node_modules/@earendil-works/chord/dist/context/index.d.ts +12 -0
- package/dist/node_modules/@earendil-works/chord/dist/delta/index.d.ts +127 -0
- package/dist/node_modules/@earendil-works/chord/dist/index.d.ts +8 -0
- package/dist/node_modules/@earendil-works/chord/dist/json.d.ts +2 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/errors.d.ts +16 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/provider.d.ts +32 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/state-codec.d.ts +12 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/wire.d.ts +59 -0
- package/dist/node_modules/@earendil-works/chord/dist/state/draft.d.ts +13 -0
- package/dist/node_modules/@earendil-works/chord/dist/types.d.ts +188 -0
- package/dist/node_modules/@earendil-works/chord/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts +7 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +80 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts +711 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts +44 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts +80 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts +15 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/context.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/events.d.ts +22 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/effect-gate.d.ts +17 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/hooks.d.ts +34 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts +50 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.d.ts +28 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/result.d.ts +132 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/harness.d.ts +56 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/lane.d.ts +94 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/reducer.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/types.d.ts +99 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/commit.d.ts +52 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork-policy.d.ts +19 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.d.ts +13 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/index.d.ts +10 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/index.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.d.ts +33 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.d.ts +37 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/types.d.ts +36 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.d.ts +46 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/mutation-line.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts +75 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.d.ts +473 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/values.d.ts +94 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.d.ts +26 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/telemetry.d.ts +1495 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.d.ts +26 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.d.ts +18 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.d.ts +32 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.d.ts +10 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +185 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/output-capture.d.ts +22 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts +22 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.d.ts +28 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +27 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +61 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/search/index.d.ts +28 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +150 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts +18 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts +13 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts +18 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts +12 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts +24 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts +14 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts +8 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts +15 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts +30 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +24 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts +10 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts +85 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/context.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.d.ts +10 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/helpers.d.ts +8 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts +20 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +127 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +0 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.d.ts +34 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/compat.d.ts +47 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts +9 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/image-models.d.ts +9 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +829 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts +13 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/images-models.d.ts +37 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/images.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/index.d.ts +38 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/legacy-api-aliases.d.ts +25 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/model-catalog.d.ts +16 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts +21 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.d.ts +97 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +84 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts +18 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/baseten.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts +100 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/meta.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/radius.d.ts +7 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/radius.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/session-resources.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts +502 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/assistant-message-frame.d.ts +63 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.d.ts +19 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts +19 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts +16 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/transcript.d.ts +29 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/uuid.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/validation.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-coding-agent/LICENSE +21 -0
- package/dist/node_modules/@earendil-works/pi-coding-agent/index.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-coding-agent/index.js +1 -0
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +15 -0
- package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-server/package.json +5 -5
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.d.ts +200 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.d.ts +20 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/noop.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +55 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts +20 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts +9 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +151 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/h-stack.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts +25 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts +43 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts +28 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +61 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/mouse-region.d.ts +10 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts +61 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +52 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +50 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts +8 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/stack.d.ts +35 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts +15 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts +9 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/v-stack.d.ts +7 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts +17 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/index.d.ts +32 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +329 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/keys.d.ts +101 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/latex.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/layout-node.d.ts +41 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/native-platform.d.ts +13 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +30 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-colors.d.ts +9 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +82 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +76 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +138 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.d.ts +32 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +252 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +38 -0
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/dist/package-manager-cli.js +32 -32
- package/dist/sdk/index.d.ts +14 -0
- package/dist/sdk/index.js +1 -0
- package/dist/sdk/mcp.d.ts +8 -0
- package/dist/sdk/mcp.js +1 -0
- package/dist/sdk/office.d.ts +1 -0
- package/dist/sdk/office.js +1 -0
- package/dist/sdk/rewind.d.ts +1 -0
- package/dist/sdk/rewind.js +1 -0
- package/dist/sdk/router.d.ts +6 -0
- package/dist/sdk/router.js +1 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/frontmatter.d.ts +7 -0
- package/dist/utils/image-convert.d.ts +5 -0
- package/dist/utils/image-resize-core.d.ts +16 -0
- package/dist/utils/image-resize.d.ts +4 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/shell.d.ts +20 -0
- package/dist/utils/shell.js +3 -3
- package/dist/utils/version-check.d.ts +20 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +22 -1
- package/dist/bun/register-bedrock.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/reducer.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +0 -5
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js +0 -1
- package/dist/node_modules/@earendil-works/pi-client/dist/session-handle.js +0 -1
- package/dist/node_modules/@earendil-works/pi-client/dist/state.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/cli.js +0 -16
- package/dist/node_modules/@earendil-works/pi-server/dist/config.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/handler.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/client.js +0 -2
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/protocol.js +0 -2
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/server.js +0 -3
- package/dist/node_modules/@earendil-works/pi-server/dist/protocol.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/radius.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/rpc-process.js +0 -4
- package/dist/node_modules/@earendil-works/pi-server/dist/serve.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/sessions.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/snapshots.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/storage.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/supervisor.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/service.js +0 -1
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/branch-cache.js +0 -7
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/search-backend.js +0 -36
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/branch-entries.js +0 -25
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/branch-tips.js +0 -2
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/entries.js +0 -7
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/facts.js +0 -20
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/lanes.js +0 -26
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/records.js +0 -9
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/session-sequences.js +0 -1
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/session-stats.js +0 -10
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/sessions.js +0 -29
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/writer-leases.js +0 -14
- package/dist/server/create-harness.js +0 -1
- package/dist/utils/clipboard-native.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var Z=Object.defineProperty;var P=(p,t)=>Z(p,"name",{value:t,configurable:!0});import{existsSync as u,readdirSync as tt,readFileSync as _,statSync as w}from"node:fs";import{basename as et,dirname as K,join as m,resolve as y,sep as D}from"node:path";import q from"chalk";import{CONFIG_DIR_NAME as x,getExamplesPath as st}from"../config.js";import{fill as H,t as M}from"../dal/i18n.js";import{loadThemeFromPath as ot}from"../modes/interactive/theme/theme.js";import{canonicalizePath as k,isLocalPath as b,resolvePath as g}from"../utils/paths.js";import{stripBom as J}from"../utils/text.js";import{createEventBus as it}from"./event-bus.js";import{clearExtensionCache as nt,createExtensionRuntime as rt,loadExtensionFromFactory as at,loadExtensionsCached as R}from"./extensions/loader.js";import{findGitPaths as ht}from"./footer-data-provider.js";import{DefaultPackageManager as lt}from"./package-manager.js";import{loadPromptTemplates as ct}from"./prompt-templates.js";import{SettingsManager as mt}from"./settings-manager.js";import{loadSkills as dt}from"./skills.js";import{createSourceInfo as E}from"./source-info.js";import{resetTimings as pt}from"./timings.js";function Q(p,t){if(p){if(u(p))try{return J(_(p,"utf-8"))}catch(o){return console.error(q.yellow(H(M("\u8B66\u544A\uFF1A\u65E0\u6CD5\u8BFB\u53D6{what}\u6587\u4EF6 {path}\uFF1A{error}"),{what:t,path:p,error:String(o)}))),p}return p}}P(Q,"resolvePromptInput");function C(p){const t=["AGENTS.override.md","AGENTS.md","AGENTS.MD","CLAUDE.md","CLAUDE.MD"];for(const o of t){const s=m(p,o);if(u(s))try{if(!w(s).isFile())continue;return{path:s,content:J(_(s,"utf-8"))}}catch(i){console.error(q.yellow(H(M("\u8B66\u544A\uFF1A\u65E0\u6CD5\u8BFB\u53D6 {path}\uFF1A{error}"),{path:s,error:String(i)})))}}return null}P(C,"loadContextFileFromDir");function ut(p){const t=ht(p);if(!t)return;const o=k(t.commonGitDir),s=k(t.repoDir),i=K(o);if(!s.startsWith(`${i}${D}`)||k(m(i,".git"))!==o)return;const e=C(s);return e?m(i,et(e.path)):void 0}P(ut,"findShadowedContextFile");function ft(p){const t=g(p.cwd),o=g(p.agentDir),s=[],i=new Set,e=C(o);e&&(s.push(e),i.add(e.path));const n=[],r=ut(t);let d=t;for(;;){const l=C(d),f=r!==void 0&&k(l?.path??"")===r;l&&!f&&!i.has(l.path)&&(n.unshift(l),i.add(l.path));const h=K(d);if(h===d)break;d=h}return s.push(...n),s}P(ft,"loadProjectContextFiles");class At{static{P(this,"DefaultResourceLoader")}cwd;agentDir;settingsManager;eventBus;packageManager;additionalExtensionPaths;additionalSkillPaths;additionalPromptTemplatePaths;additionalThemePaths;extensionFactories;noExtensions;noSkills;noPromptTemplates;noThemes;noContextFiles;systemPromptSource;appendSystemPromptSource;extensionsOverride;skillsOverride;promptsOverride;themesOverride;agentsFilesOverride;systemPromptOverride;appendSystemPromptOverride;extensionsResult;skills;skillDiagnostics;prompts;promptDiagnostics;themes;themeDiagnostics;agentsFiles;systemPrompt;systemPromptSourcePath;appendSystemPrompt;appendSystemPromptSourcePaths;lastSkillPaths;extensionSkillSourceInfos;extensionPromptSourceInfos;extensionThemeSourceInfos;resourceMetadataByPath;lastPromptPaths;lastThemePaths;loaded;constructor(t){this.cwd=g(t.cwd),this.agentDir=g(t.agentDir),this.settingsManager=t.settingsManager??mt.create(this.cwd,this.agentDir),this.eventBus=t.eventBus??it(),this.packageManager=new lt({cwd:this.cwd,agentDir:this.agentDir,settingsManager:this.settingsManager}),this.additionalExtensionPaths=t.additionalExtensionPaths??[],this.additionalSkillPaths=t.additionalSkillPaths??[],this.additionalPromptTemplatePaths=t.additionalPromptTemplatePaths??[],this.additionalThemePaths=t.additionalThemePaths??[],this.extensionFactories=t.extensionFactories??[],this.noExtensions=t.noExtensions??!1,this.noSkills=t.noSkills??!1,this.noPromptTemplates=t.noPromptTemplates??!1,this.noThemes=t.noThemes??!1,this.noContextFiles=t.noContextFiles??!1,this.systemPromptSource=t.systemPrompt,this.appendSystemPromptSource=t.appendSystemPrompt,this.extensionsOverride=t.extensionsOverride,this.skillsOverride=t.skillsOverride,this.promptsOverride=t.promptsOverride,this.themesOverride=t.themesOverride,this.agentsFilesOverride=t.agentsFilesOverride,this.systemPromptOverride=t.systemPromptOverride,this.appendSystemPromptOverride=t.appendSystemPromptOverride,this.extensionsResult={extensions:[],errors:[],runtime:rt()},this.skills=[],this.skillDiagnostics=[],this.prompts=[],this.promptDiagnostics=[],this.themes=[],this.themeDiagnostics=[],this.agentsFiles=[],this.appendSystemPrompt=[],this.appendSystemPromptSourcePaths=[],this.lastSkillPaths=[],this.extensionSkillSourceInfos=new Map,this.extensionPromptSourceInfos=new Map,this.extensionThemeSourceInfos=new Map,this.resourceMetadataByPath=new Map,this.lastPromptPaths=[],this.lastThemePaths=[],this.loaded=!1}getExtensions(){return this.extensionsResult}getSkills(){return{skills:this.skills,diagnostics:this.skillDiagnostics}}getPrompts(){return{prompts:this.prompts,diagnostics:this.promptDiagnostics}}getThemes(){return{themes:this.themes,diagnostics:this.themeDiagnostics}}getAgentsFiles(){return{agentsFiles:this.agentsFiles}}getSystemPrompt(){return this.systemPrompt}getSystemPromptSource(){return this.systemPromptSourcePath?{path:this.systemPromptSourcePath}:void 0}getAppendSystemPrompt(){return this.appendSystemPrompt}getAppendSystemPromptSources(){return this.appendSystemPromptSourcePaths.map(t=>({path:t}))}extendResources(t){const o=this.normalizeExtensionPaths(t.skillPaths??[]),s=this.normalizeExtensionPaths(t.promptPaths??[]),i=this.normalizeExtensionPaths(t.themePaths??[]);for(const e of o)this.extensionSkillSourceInfos.set(e.path,E(e.path,e.metadata));for(const e of s)this.extensionPromptSourceInfos.set(e.path,E(e.path,e.metadata));for(const e of i)this.extensionThemeSourceInfos.set(e.path,E(e.path,e.metadata));o.length>0&&(this.lastSkillPaths=this.mergePaths(this.lastSkillPaths,o.map(e=>e.path)),this.updateSkillsFromPaths(this.lastSkillPaths,this.resourceMetadataByPath)),s.length>0&&(this.lastPromptPaths=this.mergePaths(this.lastPromptPaths,s.map(e=>e.path)),this.updatePromptsFromPaths(this.lastPromptPaths,this.resourceMetadataByPath)),i.length>0&&(this.lastThemePaths=this.mergePaths(this.lastThemePaths,i.map(e=>e.path)),this.updateThemesFromPaths(this.lastThemePaths,this.resourceMetadataByPath))}async loadProjectTrustExtensions(){return this.settingsManager.setProjectTrusted(!1),await this.settingsManager.reload(),this.loadCurrentExtensionSet({includeInlineFactories:!0})}async reload(t){pt("extensions"),this.loaded&&nt();let o;if(t?.resolveProjectTrust){o=await this.loadProjectTrustExtensions();const a=await t.resolveProjectTrust({extensionsResult:o});this.settingsManager.setProjectTrusted(a)}await this.settingsManager.reload();const s=await this.packageManager.resolve(),i=await this.packageManager.resolveExtensionSources(this.additionalExtensionPaths,{temporary:!0});this.resourceMetadataByPath=new Map;const e=this.resourceMetadataByPath;this.extensionSkillSourceInfos=new Map,this.extensionPromptSourceInfos=new Map,this.extensionThemeSourceInfos=new Map;const n=P(a=>{for(const c of a)e.has(c.path)||e.set(c.path,c.metadata);return a.filter(c=>c.enabled)},"getEnabledResources"),r=P(a=>n(a).map(c=>c.path),"getEnabledPaths"),d=r(s.extensions),l=n(s.skills),f=r(s.prompts),h=r(s.themes),S=l.map(a=>this.mapSkillPath(a,e));for(const a of i.extensions)e.has(a.path)||e.set(a.path,{source:"cli",scope:"temporary",origin:"top-level"});for(const a of i.skills)e.has(a.path)||e.set(a.path,{source:"cli",scope:"temporary",origin:"top-level"});const A=r(i.extensions),j=r(i.skills),$=r(i.prompts),B=r(i.themes),V=this.noExtensions?A:this.mergePaths(A,d),O=await this.loadFinalExtensionSet(V,o);for(const a of this.additionalExtensionPaths)if(b(a)){const c=this.resolveResourcePath(a);u(c)||O.errors.push({path:c,error:`Extension path does not exist: ${c}`})}this.extensionsResult=this.extensionsOverride?this.extensionsOverride(O):O,this.applyExtensionSourceInfo(this.extensionsResult.extensions,e);const v=m(st(),"skills"),W=!this.noSkills&&u(v)?[v]:[];W.length>0&&!e.has(v)&&e.set(v,{source:"auto",scope:"user",origin:"top-level",baseDir:v});const z=this.noSkills?this.mergePaths(j,this.additionalSkillPaths):this.mergePaths([...W,...j,...S],this.additionalSkillPaths);this.lastSkillPaths=z,this.updateSkillsFromPaths(z,e);for(const a of this.additionalSkillPaths)if(b(a)){const c=this.resolveResourcePath(a);!u(c)&&!this.skillDiagnostics.some(F=>F.path===c)&&this.skillDiagnostics.push({type:"error",message:"Skill path does not exist",path:c})}const L=this.noPromptTemplates?this.mergePaths($,this.additionalPromptTemplatePaths):this.mergePaths([...$,...f],this.additionalPromptTemplatePaths);this.lastPromptPaths=L,this.updatePromptsFromPaths(L,e);for(const a of this.additionalPromptTemplatePaths)if(b(a)){const c=this.resolveResourcePath(a);!u(c)&&!this.promptDiagnostics.some(F=>F.path===c)&&this.promptDiagnostics.push({type:"error",message:"Prompt template path does not exist",path:c})}const N=this.noThemes?this.mergePaths(B,this.additionalThemePaths):this.mergePaths([...B,...h],this.additionalThemePaths);this.lastThemePaths=N,this.updateThemesFromPaths(N,e);for(const a of this.additionalThemePaths){const c=this.resolveResourcePath(a);!u(c)&&!this.themeDiagnostics.some(F=>F.path===c)&&this.themeDiagnostics.push({type:"error",message:"Theme path does not exist",path:c})}const G={agentsFiles:this.noContextFiles?[]:ft({cwd:this.cwd,agentDir:this.agentDir})},X=this.agentsFilesOverride?this.agentsFilesOverride(G):G;this.agentsFiles=X.agentsFiles;const T=this.systemPromptSource??this.discoverSystemPromptFile(),U=Q(T,M("\u7CFB\u7EDF\u63D0\u793A\u8BCD"));this.systemPrompt=this.systemPromptOverride?this.systemPromptOverride(U):U,this.systemPromptSourcePath=T&&u(T)?g(T):void 0;let I=this.appendSystemPromptSource;if(!I){const a=this.discoverAppendSystemPromptFile();I=a?[a]:[]}const Y=I.map(a=>Q(a,M("\u8FFD\u52A0\u7684\u7CFB\u7EDF\u63D0\u793A\u8BCD"))).filter(a=>a!==void 0);this.appendSystemPrompt=this.appendSystemPromptOverride?this.appendSystemPromptOverride(Y):Y,this.appendSystemPromptSourcePaths=I.filter(a=>u(a)).map(a=>g(a)),this.loaded=!0}async loadCurrentExtensionSet(t){const o=await this.packageManager.resolve(),s=await this.packageManager.resolveExtensionSources(this.additionalExtensionPaths,{temporary:!0}),i=o.extensions.filter(l=>l.enabled).map(l=>l.path),e=s.extensions.filter(l=>l.enabled).map(l=>l.path),n=this.noExtensions?e:this.mergePaths(e,i),r=await R(n,this.cwd,this.eventBus);if(!t.includeInlineFactories)return r;const d=await this.loadExtensionFactories(r.runtime);return r.extensions.push(...d.extensions),r.errors.push(...d.errors),r}resolveExtensionLoadPath(t){return g(t,this.cwd,{normalizeUnicodeSpaces:!0})}async loadFinalExtensionSet(t,o){if(!o){const h=await R(t,this.cwd,this.eventBus),S=await this.loadExtensionFactories(h.runtime);return h.extensions.push(...S.extensions),h.errors.push(...S.errors),this.addExtensionConflictDiagnostics(h),h}const s=new Map(o.extensions.filter(h=>!h.path.startsWith("<inline:")).map(h=>[h.resolvedPath,h])),i=new Set(o.errors.map(h=>this.resolveExtensionLoadPath(h.path))),e=t.filter(h=>{const S=this.resolveExtensionLoadPath(h);return!s.has(S)&&!i.has(S)}),n=await R(e,this.cwd,this.eventBus,o.runtime),r=new Map(s);for(const h of n.extensions)r.set(h.resolvedPath,h);const d=o.extensions.filter(h=>h.path.startsWith("<inline:")),l=t.map(h=>r.get(this.resolveExtensionLoadPath(h))).filter(h=>h!==void 0);l.push(...d);const f={extensions:l,errors:[...o.errors,...n.errors],runtime:o.runtime};return this.addExtensionConflictDiagnostics(f),f}addExtensionConflictDiagnostics(t){const o=this.detectExtensionConflicts(t.extensions);for(const s of o)t.errors.push({path:s.path,error:s.message})}mapSkillPath(t,o){if(t.metadata.source!=="auto"&&t.metadata.origin!=="package")return t.path;try{if(!w(t.path).isDirectory())return t.path}catch{return t.path}const s=m(t.path,"SKILL.md");return u(s)?(o.has(s)||o.set(s,t.metadata),s):t.path}normalizeExtensionPaths(t){return t.map(o=>{const s=o.metadata.baseDir?{...o.metadata,baseDir:this.resolveResourcePath(o.metadata.baseDir)}:o.metadata;return{path:this.resolveResourcePath(o.path),metadata:s}})}updateSkillsFromPaths(t,o){let s;this.noSkills&&t.length===0?s={skills:[],diagnostics:[]}:s=dt({cwd:this.cwd,agentDir:this.agentDir,skillPaths:t,includeDefaults:!1});const i=this.skillsOverride?this.skillsOverride(s):s;this.skills=i.skills.map(e=>({...e,sourceInfo:this.findSourceInfoForPath(e.filePath,this.extensionSkillSourceInfos,o)??e.sourceInfo??this.getDefaultSourceInfoForPath(e.filePath)})),this.skillDiagnostics=i.diagnostics}updatePromptsFromPaths(t,o){let s;if(this.noPromptTemplates&&t.length===0)s={prompts:[],diagnostics:[]};else{const e=ct({cwd:this.cwd,agentDir:this.agentDir,promptPaths:t,includeDefaults:!1}),n=this.dedupePrompts(e.templates);s={prompts:n.prompts,diagnostics:[...e.diagnostics,...n.diagnostics]}}const i=this.promptsOverride?this.promptsOverride(s):s;this.prompts=i.prompts.map(e=>({...e,sourceInfo:this.findSourceInfoForPath(e.filePath,this.extensionPromptSourceInfos,o)??e.sourceInfo??this.getDefaultSourceInfoForPath(e.filePath)})),this.promptDiagnostics=i.diagnostics}updateThemesFromPaths(t,o){let s;if(this.noThemes&&t.length===0)s={themes:[],diagnostics:[]};else{const e=this.loadThemes(t,!1),n=this.dedupeThemes(e.themes);s={themes:n.themes,diagnostics:[...e.diagnostics,...n.diagnostics]}}const i=this.themesOverride?this.themesOverride(s):s;this.themes=i.themes.map(e=>{const n=e.sourcePath;return e.sourceInfo=n?this.findSourceInfoForPath(n,this.extensionThemeSourceInfos,o)??e.sourceInfo??this.getDefaultSourceInfoForPath(n):e.sourceInfo,e}),this.themeDiagnostics=i.diagnostics}applyExtensionSourceInfo(t,o){for(const s of t){s.sourceInfo=this.findSourceInfoForPath(s.path,void 0,o)??this.getDefaultSourceInfoForPath(s.path);for(const i of s.commands.values())i.sourceInfo=s.sourceInfo;for(const i of s.tools.values())i.sourceInfo=s.sourceInfo}}findSourceInfoForPath(t,o,s){if(!t)return;if(t.startsWith("<"))return this.getDefaultSourceInfoForPath(t);const i=y(t);if(o)for(const[e,n]of o.entries()){const r=y(e);if(i===r||i.startsWith(`${r}${D}`))return{...n,path:t}}if(s){const e=s.get(i)??s.get(t);if(e)return E(t,e);for(const[n,r]of s.entries()){const d=y(n);if(i===d||i.startsWith(`${d}${D}`))return E(t,r)}}}getDefaultSourceInfoForPath(t){if(t.startsWith("<")&&t.endsWith(">"))return{path:t,source:t.slice(1,-1).split(":")[0]||"temporary",scope:"temporary",origin:"top-level"};const o=y(t),s=[m(this.agentDir,"skills"),m(this.agentDir,"prompts"),m(this.agentDir,"themes"),m(this.agentDir,"extensions")],i=[m(this.cwd,x,"skills"),m(this.cwd,x,"prompts"),m(this.cwd,x,"themes"),m(this.cwd,x,"extensions")];for(const e of s)if(this.isUnderPath(o,e))return{path:t,source:"local",scope:"user",origin:"top-level",baseDir:e};for(const e of i)if(this.isUnderPath(o,e))return{path:t,source:"local",scope:"project",origin:"top-level",baseDir:e};return{path:t,source:"local",scope:"temporary",origin:"top-level",baseDir:w(o).isDirectory()?o:y(o,"..")}}mergePaths(t,o){const s=[],i=new Set;for(const e of[...t,...o]){const n=this.resolveResourcePath(e),r=k(n);i.has(r)||(i.add(r),s.push(n))}return s}resolveResourcePath(t){return g(t,this.cwd,{trim:!0})}loadThemes(t,o=!0){const s=[],i=[];if(o){const e=[m(this.agentDir,"themes"),m(this.cwd,x,"themes")];for(const n of e)this.loadThemesFromDir(n,s,i)}for(const e of t){const n=this.resolveResourcePath(e);if(!u(n)){i.push({type:"warning",message:"theme path does not exist",path:n});continue}try{const r=w(n);r.isDirectory()?this.loadThemesFromDir(n,s,i):r.isFile()&&n.endsWith(".json")?this.loadThemeFromFile(n,s,i):i.push({type:"warning",message:"theme path is not a json file",path:n})}catch(r){const d=r instanceof Error?r.message:"failed to read theme path";i.push({type:"warning",message:d,path:n})}}return{themes:s,diagnostics:i}}loadThemesFromDir(t,o,s){if(u(t))try{const i=tt(t,{withFileTypes:!0});for(const e of i){let n=e.isFile();if(e.isSymbolicLink())try{n=w(m(t,e.name)).isFile()}catch{continue}n&&e.name.endsWith(".json")&&this.loadThemeFromFile(m(t,e.name),o,s)}}catch(i){const e=i instanceof Error?i.message:"failed to read theme directory";s.push({type:"warning",message:e,path:t})}}loadThemeFromFile(t,o,s){try{o.push(ot(t))}catch(i){const e=i instanceof Error?i.message:"failed to load theme";s.push({type:"warning",message:e,path:t})}}async loadExtensionFactories(t){const o=[],s=[];for(const[i,e]of this.extensionFactories.entries()){const n=typeof e!="function",r=n?e.factory:e,d=`<inline:${n?e.name:i+1}>`;try{const l=await at(r,this.cwd,this.eventBus,t,d);l.hidden=n&&e.hidden,o.push(l)}catch(l){const f=l instanceof Error?l.message:"failed to load extension";s.push({path:d,error:f})}}return{extensions:o,errors:s}}dedupePrompts(t){const o=new Map,s=[];for(const i of t){const e=o.get(i.name);e?s.push({type:"collision",message:`name "/${i.name}" collision`,path:i.filePath,collision:{resourceType:"prompt",name:i.name,winnerPath:e.filePath,loserPath:i.filePath}}):o.set(i.name,i)}return{prompts:Array.from(o.values()),diagnostics:s}}dedupeThemes(t){const o=new Map,s=[];for(const i of t){const e=i.name??"unnamed",n=o.get(e);n?s.push({type:"collision",message:`name "${e}" collision`,path:i.sourcePath,collision:{resourceType:"theme",name:e,winnerPath:n.sourcePath??"<builtin>",loserPath:i.sourcePath??"<builtin>"}}):o.set(e,i)}return{themes:Array.from(o.values()),diagnostics:s}}discoverSystemPromptFile(){const t=m(this.cwd,x,"SYSTEM.md");if(this.settingsManager.isProjectTrusted()&&u(t))return t;const o=m(this.agentDir,"SYSTEM.md");if(u(o))return o}discoverAppendSystemPromptFile(){const t=m(this.cwd,x,"APPEND_SYSTEM.md");if(this.settingsManager.isProjectTrusted()&&u(t))return t;const o=m(this.agentDir,"APPEND_SYSTEM.md");if(u(o))return o}isUnderPath(t,o){const s=y(o);if(t===s)return!0;const i=s.endsWith(D)?s:`${s}${D}`;return t.startsWith(i)}detectExtensionConflicts(t){const o=[],s=new Map,i=new Map;for(const e of t){for(const n of e.tools.keys()){const r=s.get(n);r&&r!==e.path?o.push({path:e.path,message:`Tool "${n}" conflicts with ${r}`}):s.set(n,e.path)}for(const n of e.flags.keys()){const r=i.get(n);r&&r!==e.path?o.push({path:e.path,message:`Flag "--${n}" conflicts with ${r}`}):i.set(n,e.path)}}return o}}export{At as DefaultResourceLoader,ft as loadProjectContextFiles};
|
|
1
|
+
var Z=Object.defineProperty;var P=(p,t)=>Z(p,"name",{value:t,configurable:!0});import{existsSync as u,readdirSync as tt,readFileSync as _,statSync as w}from"node:fs";import{basename as et,dirname as K,join as m,resolve as y,sep as D}from"node:path";import q from"chalk";import{CONFIG_DIR_NAME as x,getExamplesPath as st}from"../config.js";import{fill as H,t as M}from"../dal/i18n.js";import{loadThemeFromPath as ot}from"../modes/interactive/theme/theme.js";import{canonicalizePath as k,isLocalPath as b,resolvePath as g}from"../utils/paths.js";import{stripBom as J}from"../utils/text.js";import{createEventBus as it}from"./event-bus.js";import{clearExtensionCache as nt,createExtensionRuntime as rt,loadExtensionFromFactory as at,loadExtensionsCached as R}from"./extensions/loader.js";import{findGitPaths as ht}from"./footer-data-provider.js";import{DefaultPackageManager as lt}from"./package-manager.js";import{loadPromptTemplates as ct}from"./prompt-templates.js";import{SettingsManager as mt}from"./settings-manager.js";import{loadSkills as dt}from"./skills.js";import{createSourceInfo as E}from"./source-info.js";import{resetTimings as pt}from"./timings.js";function Q(p,t){if(p){if(u(p))try{return J(_(p,"utf-8"))}catch(o){return console.error(q.yellow(H(M("\u8B66\u544A\uFF1A\u65E0\u6CD5\u8BFB\u53D6{what}\u6587\u4EF6 {path}\uFF1A{error}"),{what:t,path:p,error:String(o)}))),p}return p}}P(Q,"resolvePromptInput");function C(p){const t=["AGENTS.override.md","AGENTS.md","AGENTS.MD","CLAUDE.md","CLAUDE.MD"];for(const o of t){const s=m(p,o);if(u(s))try{if(!w(s).isFile())continue;return{path:s,content:J(_(s,"utf-8"))}}catch(i){console.error(q.yellow(H(M("\u8B66\u544A\uFF1A\u65E0\u6CD5\u8BFB\u53D6 {path}\uFF1A{error}"),{path:s,error:String(i)})))}}return null}P(C,"loadContextFileFromDir");function ut(p){const t=ht(p);if(!t)return;const o=k(t.commonGitDir),s=k(t.repoDir),i=K(o);if(!s.startsWith(`${i}${D}`)||k(m(i,".git"))!==o)return;const e=C(s);return e?m(i,et(e.path)):void 0}P(ut,"findShadowedContextFile");function ft(p){const t=g(p.cwd),o=g(p.agentDir),s=[],i=new Set,e=C(o);e&&(s.push(e),i.add(e.path));const n=[],r=ut(t);let d=t;for(;;){const l=C(d),f=r!==void 0&&k(l?.path??"")===r;l&&!f&&!i.has(l.path)&&(n.unshift(l),i.add(l.path));const h=K(d);if(h===d)break;d=h}return s.push(...n),s}P(ft,"loadProjectContextFiles");class At{static{P(this,"DefaultResourceLoader")}cwd;agentDir;settingsManager;eventBus;packageManager;additionalExtensionPaths;additionalSkillPaths;additionalPromptTemplatePaths;additionalThemePaths;extensionFactories;noExtensions;noSkills;noPromptTemplates;noThemes;noContextFiles;systemPromptSource;appendSystemPromptSource;extensionsOverride;skillsOverride;promptsOverride;themesOverride;agentsFilesOverride;systemPromptOverride;appendSystemPromptOverride;extensionsResult;skills;skillDiagnostics;prompts;promptDiagnostics;themes;themeDiagnostics;agentsFiles;systemPrompt;systemPromptSourcePath;appendSystemPrompt;appendSystemPromptSourcePaths;lastSkillPaths;extensionSkillSourceInfos;extensionPromptSourceInfos;extensionThemeSourceInfos;resourceMetadataByPath;lastPromptPaths;lastThemePaths;loaded;constructor(t){this.cwd=g(t.cwd),this.agentDir=g(t.agentDir),this.settingsManager=t.settingsManager??mt.create(this.cwd,this.agentDir),this.eventBus=t.eventBus??it(),this.packageManager=new lt({cwd:this.cwd,agentDir:this.agentDir,settingsManager:this.settingsManager}),this.additionalExtensionPaths=t.additionalExtensionPaths??[],this.additionalSkillPaths=t.additionalSkillPaths??[],this.additionalPromptTemplatePaths=t.additionalPromptTemplatePaths??[],this.additionalThemePaths=t.additionalThemePaths??[],this.extensionFactories=t.extensionFactories??[],this.noExtensions=t.noExtensions??!1,this.noSkills=t.noSkills??!1,this.noPromptTemplates=t.noPromptTemplates??!1,this.noThemes=t.noThemes??!1,this.noContextFiles=t.noContextFiles??!1,this.systemPromptSource=t.systemPrompt,this.appendSystemPromptSource=t.appendSystemPrompt,this.extensionsOverride=t.extensionsOverride,this.skillsOverride=t.skillsOverride,this.promptsOverride=t.promptsOverride,this.themesOverride=t.themesOverride,this.agentsFilesOverride=t.agentsFilesOverride,this.systemPromptOverride=t.systemPromptOverride,this.appendSystemPromptOverride=t.appendSystemPromptOverride,this.extensionsResult={extensions:[],errors:[],runtime:rt()},this.skills=[],this.skillDiagnostics=[],this.prompts=[],this.promptDiagnostics=[],this.themes=[],this.themeDiagnostics=[],this.agentsFiles=[],this.appendSystemPrompt=[],this.appendSystemPromptSourcePaths=[],this.lastSkillPaths=[],this.extensionSkillSourceInfos=new Map,this.extensionPromptSourceInfos=new Map,this.extensionThemeSourceInfos=new Map,this.resourceMetadataByPath=new Map,this.lastPromptPaths=[],this.lastThemePaths=[],this.loaded=!1}getExtensions(){return this.extensionsResult}getSkills(){return{skills:this.skills,diagnostics:this.skillDiagnostics}}getPrompts(){return{prompts:this.prompts,diagnostics:this.promptDiagnostics}}getThemes(){return{themes:this.themes,diagnostics:this.themeDiagnostics}}getAgentsFiles(){return{agentsFiles:this.agentsFiles}}getSystemPrompt(){return this.systemPrompt}getSystemPromptSource(){return this.systemPromptSourcePath?{path:this.systemPromptSourcePath}:void 0}getAppendSystemPrompt(){return this.appendSystemPrompt}getAppendSystemPromptSources(){return this.appendSystemPromptSourcePaths.map(t=>({path:t}))}extendResources(t){const o=this.normalizeExtensionPaths(t.skillPaths??[]),s=this.normalizeExtensionPaths(t.promptPaths??[]),i=this.normalizeExtensionPaths(t.themePaths??[]);for(const e of o)this.extensionSkillSourceInfos.set(e.path,E(e.path,e.metadata));for(const e of s)this.extensionPromptSourceInfos.set(e.path,E(e.path,e.metadata));for(const e of i)this.extensionThemeSourceInfos.set(e.path,E(e.path,e.metadata));o.length>0&&(this.lastSkillPaths=this.mergePaths(this.lastSkillPaths,o.map(e=>e.path)),this.updateSkillsFromPaths(this.lastSkillPaths,this.resourceMetadataByPath)),s.length>0&&(this.lastPromptPaths=this.mergePaths(this.lastPromptPaths,s.map(e=>e.path)),this.updatePromptsFromPaths(this.lastPromptPaths,this.resourceMetadataByPath)),i.length>0&&(this.lastThemePaths=this.mergePaths(this.lastThemePaths,i.map(e=>e.path)),this.updateThemesFromPaths(this.lastThemePaths,this.resourceMetadataByPath))}async loadProjectTrustExtensions(){return this.settingsManager.setProjectTrusted(!1),await this.settingsManager.reload(),this.loadCurrentExtensionSet({includeInlineFactories:!0})}async reload(t){pt("extensions"),this.loaded&&nt();let o;if(t?.resolveProjectTrust){o=await this.loadProjectTrustExtensions();const a=await t.resolveProjectTrust({extensionsResult:o});this.settingsManager.setProjectTrusted(a)}await this.settingsManager.reload();const s=await this.packageManager.resolve(),i=await this.packageManager.resolveExtensionSources(this.additionalExtensionPaths,{temporary:!0});this.resourceMetadataByPath=new Map;const e=this.resourceMetadataByPath;this.extensionSkillSourceInfos=new Map,this.extensionPromptSourceInfos=new Map,this.extensionThemeSourceInfos=new Map;const n=P(a=>{for(const c of a)e.has(c.path)||e.set(c.path,c.metadata);return a.filter(c=>c.enabled)},"getEnabledResources"),r=P(a=>n(a).map(c=>c.path),"getEnabledPaths"),d=r(s.extensions),l=n(s.skills),f=r(s.prompts),h=r(s.themes),S=l.map(a=>this.mapSkillPath(a,e));for(const a of i.extensions)e.has(a.path)||e.set(a.path,{source:"cli",scope:"temporary",origin:"top-level"});for(const a of i.skills)e.has(a.path)||e.set(a.path,{source:"cli",scope:"temporary",origin:"top-level"});const A=r(i.extensions),j=r(i.skills),$=r(i.prompts),B=r(i.themes),V=this.noExtensions?A:this.mergePaths(A,d),O=await this.loadFinalExtensionSet(V,o);for(const a of this.additionalExtensionPaths)if(b(a)){const c=this.resolveResourcePath(a);u(c)||O.errors.push({path:c,error:`Extension path does not exist: ${c}`})}this.extensionsResult=this.extensionsOverride?this.extensionsOverride(O):O,this.applyExtensionSourceInfo(this.extensionsResult.extensions,e);const v=m(st(),"skills"),W=!this.noSkills&&u(v)?[v]:[];W.length>0&&!e.has(v)&&e.set(v,{source:"auto",scope:"user",origin:"top-level",baseDir:v});const z=this.noSkills?this.mergePaths(j,this.additionalSkillPaths):this.mergePaths([...j,...S,...W],this.additionalSkillPaths);this.lastSkillPaths=z,this.updateSkillsFromPaths(z,e);for(const a of this.additionalSkillPaths)if(b(a)){const c=this.resolveResourcePath(a);!u(c)&&!this.skillDiagnostics.some(F=>F.path===c)&&this.skillDiagnostics.push({type:"error",message:"Skill path does not exist",path:c})}const L=this.noPromptTemplates?this.mergePaths($,this.additionalPromptTemplatePaths):this.mergePaths([...$,...f],this.additionalPromptTemplatePaths);this.lastPromptPaths=L,this.updatePromptsFromPaths(L,e);for(const a of this.additionalPromptTemplatePaths)if(b(a)){const c=this.resolveResourcePath(a);!u(c)&&!this.promptDiagnostics.some(F=>F.path===c)&&this.promptDiagnostics.push({type:"error",message:"Prompt template path does not exist",path:c})}const N=this.noThemes?this.mergePaths(B,this.additionalThemePaths):this.mergePaths([...B,...h],this.additionalThemePaths);this.lastThemePaths=N,this.updateThemesFromPaths(N,e);for(const a of this.additionalThemePaths){const c=this.resolveResourcePath(a);!u(c)&&!this.themeDiagnostics.some(F=>F.path===c)&&this.themeDiagnostics.push({type:"error",message:"Theme path does not exist",path:c})}const G={agentsFiles:this.noContextFiles?[]:ft({cwd:this.cwd,agentDir:this.agentDir})},X=this.agentsFilesOverride?this.agentsFilesOverride(G):G;this.agentsFiles=X.agentsFiles;const T=this.systemPromptSource??this.discoverSystemPromptFile(),U=Q(T,M("\u7CFB\u7EDF\u63D0\u793A\u8BCD"));this.systemPrompt=this.systemPromptOverride?this.systemPromptOverride(U):U,this.systemPromptSourcePath=T&&u(T)?g(T):void 0;let I=this.appendSystemPromptSource;if(!I){const a=this.discoverAppendSystemPromptFile();I=a?[a]:[]}const Y=I.map(a=>Q(a,M("\u8FFD\u52A0\u7684\u7CFB\u7EDF\u63D0\u793A\u8BCD"))).filter(a=>a!==void 0);this.appendSystemPrompt=this.appendSystemPromptOverride?this.appendSystemPromptOverride(Y):Y,this.appendSystemPromptSourcePaths=I.filter(a=>u(a)).map(a=>g(a)),this.loaded=!0}async loadCurrentExtensionSet(t){const o=await this.packageManager.resolve(),s=await this.packageManager.resolveExtensionSources(this.additionalExtensionPaths,{temporary:!0}),i=o.extensions.filter(l=>l.enabled).map(l=>l.path),e=s.extensions.filter(l=>l.enabled).map(l=>l.path),n=this.noExtensions?e:this.mergePaths(e,i),r=await R(n,this.cwd,this.eventBus);if(!t.includeInlineFactories)return r;const d=await this.loadExtensionFactories(r.runtime);return r.extensions.push(...d.extensions),r.errors.push(...d.errors),r}resolveExtensionLoadPath(t){return g(t,this.cwd,{normalizeUnicodeSpaces:!0})}async loadFinalExtensionSet(t,o){if(!o){const h=await R(t,this.cwd,this.eventBus),S=await this.loadExtensionFactories(h.runtime);return h.extensions.push(...S.extensions),h.errors.push(...S.errors),this.addExtensionConflictDiagnostics(h),h}const s=new Map(o.extensions.filter(h=>!h.path.startsWith("<inline:")).map(h=>[h.resolvedPath,h])),i=new Set(o.errors.map(h=>this.resolveExtensionLoadPath(h.path))),e=t.filter(h=>{const S=this.resolveExtensionLoadPath(h);return!s.has(S)&&!i.has(S)}),n=await R(e,this.cwd,this.eventBus,o.runtime),r=new Map(s);for(const h of n.extensions)r.set(h.resolvedPath,h);const d=o.extensions.filter(h=>h.path.startsWith("<inline:")),l=t.map(h=>r.get(this.resolveExtensionLoadPath(h))).filter(h=>h!==void 0);l.push(...d);const f={extensions:l,errors:[...o.errors,...n.errors],runtime:o.runtime};return this.addExtensionConflictDiagnostics(f),f}addExtensionConflictDiagnostics(t){const o=this.detectExtensionConflicts(t.extensions);for(const s of o)t.errors.push({path:s.path,error:s.message})}mapSkillPath(t,o){if(t.metadata.source!=="auto"&&t.metadata.origin!=="package")return t.path;try{if(!w(t.path).isDirectory())return t.path}catch{return t.path}const s=m(t.path,"SKILL.md");return u(s)?(o.has(s)||o.set(s,t.metadata),s):t.path}normalizeExtensionPaths(t){return t.map(o=>{const s=o.metadata.baseDir?{...o.metadata,baseDir:this.resolveResourcePath(o.metadata.baseDir)}:o.metadata;return{path:this.resolveResourcePath(o.path),metadata:s}})}updateSkillsFromPaths(t,o){let s;this.noSkills&&t.length===0?s={skills:[],diagnostics:[]}:s=dt({cwd:this.cwd,agentDir:this.agentDir,skillPaths:t,includeDefaults:!1});const i=this.skillsOverride?this.skillsOverride(s):s;this.skills=i.skills.map(e=>({...e,sourceInfo:this.findSourceInfoForPath(e.filePath,this.extensionSkillSourceInfos,o)??e.sourceInfo??this.getDefaultSourceInfoForPath(e.filePath)})),this.skillDiagnostics=i.diagnostics}updatePromptsFromPaths(t,o){let s;if(this.noPromptTemplates&&t.length===0)s={prompts:[],diagnostics:[]};else{const e=ct({cwd:this.cwd,agentDir:this.agentDir,promptPaths:t,includeDefaults:!1}),n=this.dedupePrompts(e.templates);s={prompts:n.prompts,diagnostics:[...e.diagnostics,...n.diagnostics]}}const i=this.promptsOverride?this.promptsOverride(s):s;this.prompts=i.prompts.map(e=>({...e,sourceInfo:this.findSourceInfoForPath(e.filePath,this.extensionPromptSourceInfos,o)??e.sourceInfo??this.getDefaultSourceInfoForPath(e.filePath)})),this.promptDiagnostics=i.diagnostics}updateThemesFromPaths(t,o){let s;if(this.noThemes&&t.length===0)s={themes:[],diagnostics:[]};else{const e=this.loadThemes(t,!1),n=this.dedupeThemes(e.themes);s={themes:n.themes,diagnostics:[...e.diagnostics,...n.diagnostics]}}const i=this.themesOverride?this.themesOverride(s):s;this.themes=i.themes.map(e=>{const n=e.sourcePath;return e.sourceInfo=n?this.findSourceInfoForPath(n,this.extensionThemeSourceInfos,o)??e.sourceInfo??this.getDefaultSourceInfoForPath(n):e.sourceInfo,e}),this.themeDiagnostics=i.diagnostics}applyExtensionSourceInfo(t,o){for(const s of t){s.sourceInfo=this.findSourceInfoForPath(s.path,void 0,o)??this.getDefaultSourceInfoForPath(s.path);for(const i of s.commands.values())i.sourceInfo=s.sourceInfo;for(const i of s.tools.values())i.sourceInfo=s.sourceInfo}}findSourceInfoForPath(t,o,s){if(!t)return;if(t.startsWith("<"))return this.getDefaultSourceInfoForPath(t);const i=y(t);if(o)for(const[e,n]of o.entries()){const r=y(e);if(i===r||i.startsWith(`${r}${D}`))return{...n,path:t}}if(s){const e=s.get(i)??s.get(t);if(e)return E(t,e);for(const[n,r]of s.entries()){const d=y(n);if(i===d||i.startsWith(`${d}${D}`))return E(t,r)}}}getDefaultSourceInfoForPath(t){if(t.startsWith("<")&&t.endsWith(">"))return{path:t,source:t.slice(1,-1).split(":")[0]||"temporary",scope:"temporary",origin:"top-level"};const o=y(t),s=[m(this.agentDir,"skills"),m(this.agentDir,"prompts"),m(this.agentDir,"themes"),m(this.agentDir,"extensions")],i=[m(this.cwd,x,"skills"),m(this.cwd,x,"prompts"),m(this.cwd,x,"themes"),m(this.cwd,x,"extensions")];for(const e of s)if(this.isUnderPath(o,e))return{path:t,source:"local",scope:"user",origin:"top-level",baseDir:e};for(const e of i)if(this.isUnderPath(o,e))return{path:t,source:"local",scope:"project",origin:"top-level",baseDir:e};return{path:t,source:"local",scope:"temporary",origin:"top-level",baseDir:w(o).isDirectory()?o:y(o,"..")}}mergePaths(t,o){const s=[],i=new Set;for(const e of[...t,...o]){const n=this.resolveResourcePath(e),r=k(n);i.has(r)||(i.add(r),s.push(n))}return s}resolveResourcePath(t){return g(t,this.cwd,{trim:!0})}loadThemes(t,o=!0){const s=[],i=[];if(o){const e=[m(this.agentDir,"themes"),m(this.cwd,x,"themes")];for(const n of e)this.loadThemesFromDir(n,s,i)}for(const e of t){const n=this.resolveResourcePath(e);if(!u(n)){i.push({type:"warning",message:"theme path does not exist",path:n});continue}try{const r=w(n);r.isDirectory()?this.loadThemesFromDir(n,s,i):r.isFile()&&n.endsWith(".json")?this.loadThemeFromFile(n,s,i):i.push({type:"warning",message:"theme path is not a json file",path:n})}catch(r){const d=r instanceof Error?r.message:"failed to read theme path";i.push({type:"warning",message:d,path:n})}}return{themes:s,diagnostics:i}}loadThemesFromDir(t,o,s){if(u(t))try{const i=tt(t,{withFileTypes:!0});for(const e of i){let n=e.isFile();if(e.isSymbolicLink())try{n=w(m(t,e.name)).isFile()}catch{continue}n&&e.name.endsWith(".json")&&this.loadThemeFromFile(m(t,e.name),o,s)}}catch(i){const e=i instanceof Error?i.message:"failed to read theme directory";s.push({type:"warning",message:e,path:t})}}loadThemeFromFile(t,o,s){try{o.push(ot(t))}catch(i){const e=i instanceof Error?i.message:"failed to load theme";s.push({type:"warning",message:e,path:t})}}async loadExtensionFactories(t){const o=[],s=[];for(const[i,e]of this.extensionFactories.entries()){const n=typeof e!="function",r=n?e.factory:e,d=`<inline:${n?e.name:i+1}>`;try{const l=await at(r,this.cwd,this.eventBus,t,d);l.hidden=n&&e.hidden,o.push(l)}catch(l){const f=l instanceof Error?l.message:"failed to load extension";s.push({path:d,error:f})}}return{extensions:o,errors:s}}dedupePrompts(t){const o=new Map,s=[];for(const i of t){const e=o.get(i.name);e?s.push({type:"collision",message:`name "/${i.name}" collision`,path:i.filePath,collision:{resourceType:"prompt",name:i.name,winnerPath:e.filePath,loserPath:i.filePath}}):o.set(i.name,i)}return{prompts:Array.from(o.values()),diagnostics:s}}dedupeThemes(t){const o=new Map,s=[];for(const i of t){const e=i.name??"unnamed",n=o.get(e);n?s.push({type:"collision",message:`name "${e}" collision`,path:i.sourcePath,collision:{resourceType:"theme",name:e,winnerPath:n.sourcePath??"<builtin>",loserPath:i.sourcePath??"<builtin>"}}):o.set(e,i)}return{themes:Array.from(o.values()),diagnostics:s}}discoverSystemPromptFile(){const t=m(this.cwd,x,"SYSTEM.md");if(this.settingsManager.isProjectTrusted()&&u(t))return t;const o=m(this.agentDir,"SYSTEM.md");if(u(o))return o}discoverAppendSystemPromptFile(){const t=m(this.cwd,x,"APPEND_SYSTEM.md");if(this.settingsManager.isProjectTrusted()&&u(t))return t;const o=m(this.agentDir,"APPEND_SYSTEM.md");if(u(o))return o}isUnderPath(t,o){const s=y(o);if(t===s)return!0;const i=s.endsWith(D)?s:`${s}${D}`;return t.startsWith(i)}detectExtensionConflicts(t){const o=[],s=new Map,i=new Map;for(const e of t){for(const n of e.tools.keys()){const r=s.get(n);r&&r!==e.path?o.push({path:e.path,message:`Tool "${n}" conflicts with ${r}`}):s.set(n,e.path)}for(const n of e.flags.keys()){const r=i.get(n);r&&r!==e.path?o.push({path:e.path,message:`Flag "--${n}" conflicts with ${r}`}):i.set(n,e.path)}}return o}}export{At as DefaultResourceLoader,ft as loadProjectContextFiles};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import { type Model } from "@earendil-works/pi-ai/compat";
|
|
3
|
+
import { AgentSession } from "./agent-session.ts";
|
|
4
|
+
import type { LoadExtensionsResult, SessionStartEvent, ToolDefinition } from "./extensions/index.ts";
|
|
5
|
+
import { ModelRuntime } from "./model-runtime.ts";
|
|
6
|
+
import type { ResourceLoader } from "./resource-loader.ts";
|
|
7
|
+
import { SessionManager } from "./session-manager.ts";
|
|
8
|
+
import { SettingsManager } from "./settings-manager.ts";
|
|
9
|
+
import { createBashTool, createCodingTools, createEditTool, createFindTool, createGrepTool, createLsTool, createPowerShellTool, createReadOnlyTools, createReadTool, createWriteTool, withFileMutationQueue } from "./tools/index.ts";
|
|
10
|
+
export interface CreateAgentSessionOptions {
|
|
11
|
+
cwd?: string;
|
|
12
|
+
agentDir?: string;
|
|
13
|
+
modelRuntime?: ModelRuntime;
|
|
14
|
+
model?: Model<any>;
|
|
15
|
+
thinkingLevel?: ThinkingLevel;
|
|
16
|
+
scopedModels?: Array<{
|
|
17
|
+
model: Model<any>;
|
|
18
|
+
thinkingLevel?: ThinkingLevel;
|
|
19
|
+
}>;
|
|
20
|
+
noTools?: "all" | "builtin";
|
|
21
|
+
tools?: string[];
|
|
22
|
+
excludeTools?: string[];
|
|
23
|
+
customTools?: ToolDefinition[];
|
|
24
|
+
resourceLoader?: ResourceLoader;
|
|
25
|
+
sessionManager?: SessionManager;
|
|
26
|
+
settingsManager?: SettingsManager;
|
|
27
|
+
sessionStartEvent?: SessionStartEvent;
|
|
28
|
+
}
|
|
29
|
+
export interface CreateAgentSessionResult {
|
|
30
|
+
session: AgentSession;
|
|
31
|
+
extensionsResult: LoadExtensionsResult;
|
|
32
|
+
modelFallbackMessage?: string;
|
|
33
|
+
}
|
|
34
|
+
export * from "./agent-session-runtime.ts";
|
|
35
|
+
export type { ExtensionAPI, ExtensionCommandContext, ExtensionContext, ExtensionFactory, InlineExtension, SlashCommandInfo, SlashCommandSource, ToolDefinition, } from "./extensions/index.ts";
|
|
36
|
+
export type { PromptTemplate } from "./prompt-templates.ts";
|
|
37
|
+
export type { Skill } from "./skills.ts";
|
|
38
|
+
export type { Tool } from "./tools/index.ts";
|
|
39
|
+
export { withFileMutationQueue, createCodingTools, createReadOnlyTools, createReadTool, createBashTool, createEditTool, createWriteTool, createGrepTool, createFindTool, createLsTool, createPowerShellTool, };
|
|
40
|
+
export declare function createAgentSession(options?: CreateAgentSessionOptions): Promise<CreateAgentSessionResult>;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import type { AgentMessage } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import { type AssistantMessage, type ImageContent, type Message, type SystemMessage, type TextContent, type ToolResultMessage, type Usage, type UserMessage } from "@earendil-works/pi-ai";
|
|
3
|
+
import { type BashExecutionMessage, type CustomMessage } from "./messages.ts";
|
|
4
|
+
export declare const CURRENT_SESSION_VERSION = 3;
|
|
5
|
+
export interface SessionHeader {
|
|
6
|
+
type: "session";
|
|
7
|
+
version?: number;
|
|
8
|
+
id: string;
|
|
9
|
+
timestamp: string;
|
|
10
|
+
cwd: string;
|
|
11
|
+
parentSession?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface NewSessionOptions {
|
|
14
|
+
id?: string;
|
|
15
|
+
parentSession?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface SessionEntryBase {
|
|
18
|
+
type: string;
|
|
19
|
+
id: string;
|
|
20
|
+
parentId: string | null;
|
|
21
|
+
timestamp: string;
|
|
22
|
+
}
|
|
23
|
+
export interface SessionMessageEntry extends SessionEntryBase {
|
|
24
|
+
type: "message";
|
|
25
|
+
message: AgentMessage;
|
|
26
|
+
}
|
|
27
|
+
export interface ThinkingLevelChangeEntry extends SessionEntryBase {
|
|
28
|
+
type: "thinking_level_change";
|
|
29
|
+
thinkingLevel: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ModelChangeEntry extends SessionEntryBase {
|
|
32
|
+
type: "model_change";
|
|
33
|
+
provider: string;
|
|
34
|
+
modelId: string;
|
|
35
|
+
}
|
|
36
|
+
export interface UsageEntry extends SessionEntryBase {
|
|
37
|
+
type: "usage";
|
|
38
|
+
kind: string;
|
|
39
|
+
provider: string;
|
|
40
|
+
model: string;
|
|
41
|
+
usage: Usage;
|
|
42
|
+
note?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface CompactionEntry<T = unknown> extends SessionEntryBase {
|
|
45
|
+
type: "compaction";
|
|
46
|
+
summary: string;
|
|
47
|
+
firstKeptEntryId: string;
|
|
48
|
+
tokensBefore: number;
|
|
49
|
+
details?: T;
|
|
50
|
+
usage?: Usage;
|
|
51
|
+
fromHook?: boolean;
|
|
52
|
+
systemMessage?: SystemMessage;
|
|
53
|
+
}
|
|
54
|
+
export interface BranchSummaryEntry<T = unknown> extends SessionEntryBase {
|
|
55
|
+
type: "branch_summary";
|
|
56
|
+
fromId: string;
|
|
57
|
+
summary: string;
|
|
58
|
+
details?: T;
|
|
59
|
+
usage?: Usage;
|
|
60
|
+
fromHook?: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface CustomEntry<T = unknown> extends SessionEntryBase {
|
|
63
|
+
type: "custom";
|
|
64
|
+
customType: string;
|
|
65
|
+
data?: T;
|
|
66
|
+
}
|
|
67
|
+
export interface LabelEntry extends SessionEntryBase {
|
|
68
|
+
type: "label";
|
|
69
|
+
targetId: string;
|
|
70
|
+
label: string | undefined;
|
|
71
|
+
}
|
|
72
|
+
export interface SessionInfoEntry extends SessionEntryBase {
|
|
73
|
+
type: "session_info";
|
|
74
|
+
name?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface CustomMessageEntry<T = unknown> extends SessionEntryBase {
|
|
77
|
+
type: "custom_message";
|
|
78
|
+
customType: string;
|
|
79
|
+
content: string | (TextContent | ImageContent)[];
|
|
80
|
+
details?: T;
|
|
81
|
+
display: boolean;
|
|
82
|
+
}
|
|
83
|
+
export type ContextEditableContent = UserMessage["content"] | AssistantMessage["content"] | ToolResultMessage["content"] | CustomMessage["content"];
|
|
84
|
+
export interface ContextEditEntry extends SessionEntryBase {
|
|
85
|
+
type: "context_edit";
|
|
86
|
+
targetId: string;
|
|
87
|
+
replacement: {
|
|
88
|
+
content: ContextEditableContent;
|
|
89
|
+
} | null;
|
|
90
|
+
}
|
|
91
|
+
export type SessionEntry = SessionMessageEntry | ThinkingLevelChangeEntry | ModelChangeEntry | UsageEntry | CompactionEntry | BranchSummaryEntry | CustomEntry | CustomMessageEntry | ContextEditEntry | LabelEntry | SessionInfoEntry;
|
|
92
|
+
export type FileEntry = SessionHeader | SessionEntry;
|
|
93
|
+
export interface SessionTreeNode {
|
|
94
|
+
entry: SessionEntry;
|
|
95
|
+
children: SessionTreeNode[];
|
|
96
|
+
label?: string;
|
|
97
|
+
labelTimestamp?: string;
|
|
98
|
+
}
|
|
99
|
+
export interface ProjectedSessionEntry {
|
|
100
|
+
sourceEntry: SessionEntry;
|
|
101
|
+
messages: AgentMessage[];
|
|
102
|
+
}
|
|
103
|
+
export interface SessionProjection {
|
|
104
|
+
entries: ProjectedSessionEntry[];
|
|
105
|
+
messages: AgentMessage[];
|
|
106
|
+
thinkingLevel: string;
|
|
107
|
+
model: {
|
|
108
|
+
provider: string;
|
|
109
|
+
modelId: string;
|
|
110
|
+
} | null;
|
|
111
|
+
}
|
|
112
|
+
export interface SessionContext {
|
|
113
|
+
messages: AgentMessage[];
|
|
114
|
+
thinkingLevel: string;
|
|
115
|
+
model: {
|
|
116
|
+
provider: string;
|
|
117
|
+
modelId: string;
|
|
118
|
+
} | null;
|
|
119
|
+
}
|
|
120
|
+
export interface SessionInfo {
|
|
121
|
+
path: string;
|
|
122
|
+
id: string;
|
|
123
|
+
cwd: string;
|
|
124
|
+
name?: string;
|
|
125
|
+
parentSessionPath?: string;
|
|
126
|
+
created: Date;
|
|
127
|
+
modified: Date;
|
|
128
|
+
messageCount: number;
|
|
129
|
+
firstMessage: string;
|
|
130
|
+
allMessagesText: string;
|
|
131
|
+
}
|
|
132
|
+
export type ReadonlySessionManager = Pick<SessionManager, "getCwd" | "getSessionDir" | "getSessionId" | "getSessionFile" | "getLeafId" | "getLeafEntry" | "getEntry" | "getLabel" | "getBranch" | "buildContextEntries" | "buildSessionProjection" | "getHeader" | "getEntries" | "getTree" | "getSessionName">;
|
|
133
|
+
export declare function assertValidSessionId(id: string): void;
|
|
134
|
+
export declare function migrateSessionEntries(entries: FileEntry[]): void;
|
|
135
|
+
export declare function parseSessionEntries(content: string): FileEntry[];
|
|
136
|
+
export declare function getLatestCompactionEntry(entries: SessionEntry[]): CompactionEntry | null;
|
|
137
|
+
export declare function sessionEntryToContextMessages(entry: SessionEntry): AgentMessage[];
|
|
138
|
+
export declare function buildContextEntries(entries: SessionEntry[], leafId?: string | null, byId?: Map<string, SessionEntry>): SessionEntry[];
|
|
139
|
+
export declare function buildSessionProjection(entries: SessionEntry[], leafId?: string | null, byId?: Map<string, SessionEntry>): SessionProjection;
|
|
140
|
+
export declare function buildSessionContext(entries: SessionEntry[], leafId?: string | null, byId?: Map<string, SessionEntry>): SessionContext;
|
|
141
|
+
export declare function getDefaultSessionDir(cwd: string, agentDir?: string): string;
|
|
142
|
+
export declare function loadEntriesFromFile(filePath: string): FileEntry[];
|
|
143
|
+
export declare function findMostRecentSession(sessionDir: string, cwd?: string): string | null;
|
|
144
|
+
export type SessionListProgress = (loaded: number, total: number, partialSessions?: readonly SessionInfo[]) => void;
|
|
145
|
+
export declare class SessionManager {
|
|
146
|
+
private sessionId;
|
|
147
|
+
private sessionFile;
|
|
148
|
+
private sessionDir;
|
|
149
|
+
private cwd;
|
|
150
|
+
private persist;
|
|
151
|
+
private flushed;
|
|
152
|
+
private fileEntries;
|
|
153
|
+
private byId;
|
|
154
|
+
private labelsById;
|
|
155
|
+
private labelTimestampsById;
|
|
156
|
+
private leafId;
|
|
157
|
+
private constructor();
|
|
158
|
+
setSessionFile(sessionFile: string): void;
|
|
159
|
+
private _setSessionFile;
|
|
160
|
+
newSession(options?: NewSessionOptions): string | undefined;
|
|
161
|
+
private _loadEntries;
|
|
162
|
+
private _buildIndex;
|
|
163
|
+
private _rewriteFile;
|
|
164
|
+
isPersisted(): boolean;
|
|
165
|
+
getCwd(): string;
|
|
166
|
+
getSessionDir(): string;
|
|
167
|
+
usesDefaultSessionDir(): boolean;
|
|
168
|
+
getSessionId(): string;
|
|
169
|
+
getSessionFile(): string | undefined;
|
|
170
|
+
_persist(entry: SessionEntry): void;
|
|
171
|
+
private _appendEntry;
|
|
172
|
+
appendMessage(message: Message | CustomMessage | BashExecutionMessage): string;
|
|
173
|
+
appendThinkingLevelChange(thinkingLevel: string): string;
|
|
174
|
+
appendModelChange(provider: string, modelId: string): string;
|
|
175
|
+
appendUsage(kind: string, provider: string, model: string, usage: Usage, note?: string): UsageEntry;
|
|
176
|
+
appendCompaction<T = unknown>(summary: string, firstKeptEntryId: string | null, tokensBefore: number, details?: T, fromHook?: boolean, usage?: Usage): string;
|
|
177
|
+
appendCustomEntry(customType: string, data?: unknown): string;
|
|
178
|
+
appendSessionInfo(name: string): string;
|
|
179
|
+
getSessionName(): string | undefined;
|
|
180
|
+
appendCustomMessageEntry<T = unknown>(customType: string, content: string | (TextContent | ImageContent)[], display: boolean, details?: T): string;
|
|
181
|
+
appendContextEdit(targetId: string, replacement: ContextEditEntry["replacement"]): string;
|
|
182
|
+
getLeafId(): string | null;
|
|
183
|
+
getLeafEntry(): SessionEntry | undefined;
|
|
184
|
+
getEntry(id: string): SessionEntry | undefined;
|
|
185
|
+
getChildren(parentId: string): SessionEntry[];
|
|
186
|
+
getLabel(id: string): string | undefined;
|
|
187
|
+
appendLabelChange(targetId: string, label: string | undefined): string;
|
|
188
|
+
getBranch(fromId?: string): SessionEntry[];
|
|
189
|
+
buildContextEntries(): SessionEntry[];
|
|
190
|
+
buildSessionProjection(): SessionProjection;
|
|
191
|
+
buildSessionContext(): SessionContext;
|
|
192
|
+
getHeader(): SessionHeader | null;
|
|
193
|
+
getEntries(): SessionEntry[];
|
|
194
|
+
getTree(): SessionTreeNode[];
|
|
195
|
+
branch(branchFromId: string): void;
|
|
196
|
+
resetLeaf(): void;
|
|
197
|
+
branchWithSummary(branchFromId: string | null, summary: string, details?: unknown, fromHook?: boolean, usage?: Usage): string;
|
|
198
|
+
createBranchedSession(leafId: string): string | undefined;
|
|
199
|
+
static create(cwd: string, sessionDir?: string, options?: NewSessionOptions): SessionManager;
|
|
200
|
+
static open(path: string, sessionDir?: string, cwdOverride?: string): SessionManager;
|
|
201
|
+
static continueRecent(cwd: string, sessionDir?: string): SessionManager;
|
|
202
|
+
static inMemory(cwd?: string, options?: NewSessionOptions, entries?: FileEntry[]): SessionManager;
|
|
203
|
+
static forkFrom(sourcePath: string, targetCwd: string, sessionDir?: string, options?: NewSessionOptions): SessionManager;
|
|
204
|
+
static findById(cwd: string, id: string, sessionDir?: string): string | undefined;
|
|
205
|
+
static list(cwd: string, sessionDir?: string, onProgress?: SessionListProgress, signal?: AbortSignal): Promise<SessionInfo[]>;
|
|
206
|
+
static listAll(onProgress?: SessionListProgress, signal?: AbortSignal): Promise<SessionInfo[]>;
|
|
207
|
+
static listAll(sessionDir?: string, onProgress?: SessionListProgress, signal?: AbortSignal): Promise<SessionInfo[]>;
|
|
208
|
+
}
|