dal-code 1.0.49 → 1.0.51
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 +1043 -5
- package/dist/bundle/chunks/anthropic-messages-2P3UGLIO.js +5 -0
- package/dist/bundle/chunks/anthropic.js +74 -0
- package/dist/bundle/chunks/azure-openai-responses-S4GNH2XC.js +1 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +88 -0
- package/dist/bundle/chunks/chunk-2KOJ4RNS.js +43 -0
- package/dist/bundle/chunks/chunk-3YGHTGYM.js +7 -0
- package/dist/bundle/chunks/chunk-4LDEEFCY.js +1 -0
- package/dist/bundle/chunks/chunk-4UTLMBZZ.js +13 -0
- package/dist/bundle/chunks/chunk-567OJLS7.js +1 -0
- package/dist/bundle/chunks/chunk-5AGIVGSV.js +5 -0
- package/dist/bundle/chunks/chunk-6QGV3IWD.js +5 -0
- package/dist/bundle/chunks/chunk-723ZGEZ2.js +1 -0
- package/dist/bundle/chunks/chunk-7DDKXS2Q.js +1 -0
- package/dist/bundle/chunks/chunk-7ZC4UXSL.js +1 -0
- package/dist/bundle/chunks/chunk-AL7NZVPP.js +1 -0
- package/dist/bundle/chunks/chunk-ATQJO2OE.js +3 -0
- package/dist/bundle/chunks/chunk-B7NRFMLU.js +8 -0
- package/dist/bundle/chunks/chunk-BEDAM2M7.js +81 -0
- package/dist/bundle/chunks/chunk-CF5GWZHW.js +30 -0
- package/dist/bundle/chunks/chunk-CFPQOC7P.js +1 -0
- package/dist/bundle/chunks/chunk-D2WTLI2T.js +19 -0
- package/dist/bundle/chunks/chunk-EH7SFF47.js +129 -0
- package/dist/bundle/chunks/chunk-FCKLBLA4.js +1 -0
- package/dist/bundle/chunks/chunk-FFMDRXC4.js +9 -0
- package/dist/bundle/chunks/chunk-GSGE3ULF.js +15 -0
- package/dist/bundle/chunks/chunk-H5FHS6BV.js +1 -0
- package/dist/bundle/chunks/chunk-HXK5EFBE.js +1172 -0
- package/dist/bundle/chunks/chunk-IEBK4HQA.js +1 -0
- package/dist/bundle/chunks/chunk-JE6UXK35.js +30 -0
- package/dist/bundle/chunks/chunk-JXWJOIH4.js +1 -0
- package/dist/bundle/chunks/chunk-K7VBBYTT.js +1 -0
- package/dist/bundle/chunks/chunk-L2ZPNLYD.js +1 -0
- package/dist/bundle/chunks/chunk-LVVZS2NO.js +11 -0
- package/dist/bundle/chunks/chunk-ML5DIOWR.js +1 -0
- package/dist/bundle/chunks/chunk-NUIR7PPD.js +25 -0
- package/dist/bundle/chunks/chunk-P7FPUEYA.js +1 -0
- package/dist/bundle/chunks/chunk-PGXDEOVV.js +1 -0
- package/dist/bundle/chunks/chunk-PJACZCIR.js +1 -0
- package/dist/bundle/chunks/chunk-PRRNXB7S.js +1 -0
- package/dist/bundle/chunks/chunk-PWZRJWNP.js +17 -0
- package/dist/bundle/chunks/chunk-R44HF4S5.js +9 -0
- package/dist/bundle/chunks/chunk-R47JBGS3.js +1 -0
- package/dist/bundle/chunks/chunk-RCVVRHMF.js +9 -0
- package/dist/bundle/chunks/chunk-RDZVAGPR.js +1 -0
- package/dist/bundle/chunks/chunk-RR3ZP63P.js +56 -0
- package/dist/bundle/chunks/chunk-SE42OS3U.js +21 -0
- package/dist/bundle/chunks/chunk-TMTOQ7H7.js +1 -0
- package/dist/bundle/chunks/chunk-UTB4DTYQ.js +1 -0
- package/dist/bundle/chunks/chunk-VNHNHA4V.js +1 -0
- package/dist/bundle/chunks/chunk-XJFQKN3N.js +2 -0
- package/dist/bundle/chunks/chunk-ZG74NES2.js +1 -0
- package/dist/bundle/chunks/cli-FWMQKBFA.js +30 -0
- package/dist/bundle/chunks/cli-ZEDY5U67.js +52 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-E6TEENDO.js +1 -0
- package/dist/bundle/chunks/codemode-worker.js +480 -0
- package/dist/bundle/chunks/dist-D3WIBXB5.js +10 -0
- package/dist/bundle/chunks/easter-egg-3d-5TFBCTIS.js +1 -0
- package/dist/bundle/chunks/execute-62LDYHXA.js +506 -0
- package/dist/bundle/chunks/github-copilot.js +1 -0
- package/dist/bundle/chunks/google-generative-ai-V5DLXTF7.js +1 -0
- package/dist/bundle/chunks/google-vertex-K3KYGGLI.js +1 -0
- package/dist/bundle/chunks/http-proxy-KF35JLJN.js +1 -0
- package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +12 -0
- package/dist/bundle/chunks/image-resize-worker.js +1 -0
- package/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +20 -0
- package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +1 -0
- package/dist/bundle/chunks/kimi-coding.js +1 -0
- package/dist/bundle/chunks/lib-4AVRLBHM.js +8 -0
- package/dist/bundle/chunks/llama-cpp-classify-JCTIEHTL.js +21 -0
- package/dist/bundle/chunks/mcp-VF7EY5WC.js +10 -0
- package/dist/bundle/chunks/meta.js +1 -0
- package/dist/bundle/chunks/mistral-conversations-LVBXTF6R.js +4 -0
- package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +2 -0
- package/dist/bundle/chunks/node-AUOGOBCN.js +1 -0
- package/dist/bundle/chunks/node-ZTHARAQV.js +15 -0
- package/dist/bundle/chunks/office-PONBADQP.js +419 -0
- package/dist/bundle/chunks/openai-chatgpt.js +74 -0
- package/dist/bundle/chunks/openai-codex-responses-WBZKNYLX.js +9 -0
- package/dist/bundle/chunks/openai-codex.js +74 -0
- package/dist/bundle/chunks/openai-completions-HMHQRGX4.js +6 -0
- package/dist/bundle/chunks/openai-decisions-R7OFRKLL.js +4 -0
- package/dist/bundle/chunks/openai-responses-BHXRQFCI.js +3 -0
- package/dist/bundle/chunks/openrouter-images-BIMNIXQZ.js +1 -0
- package/dist/bundle/chunks/openrouter.js +74 -0
- package/dist/bundle/chunks/pi-messages-X5YTLXQJ.js +7 -0
- package/dist/bundle/chunks/radius.js +74 -0
- package/dist/bundle/chunks/review-WCGIBVLM.js +80 -0
- package/dist/bundle/chunks/rewind-2OYLDDHH.js +8 -0
- package/dist/bundle/chunks/router-7E5LU7US.js +3 -0
- package/dist/bundle/chunks/runtime-5PTUOEM2.js +1 -0
- package/dist/bundle/chunks/sdk-ZUFIGPSS.js +1 -0
- package/dist/bundle/chunks/src-QKGKDFSU.js +3 -0
- package/dist/bundle/chunks/sync-LOX6TIM6.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-KOIOG3HP.js +1 -0
- package/dist/bundle/chunks/usage-2EVEFGNI.js +1 -0
- package/dist/bundle/chunks/virtual-modules-MYMONT3Y.js +1 -0
- package/dist/bundle/chunks/xai.js +1 -0
- package/dist/bundle/cli-runtime.js +2 -0
- package/dist/bundle/cli.js +2 -0
- package/dist/bundle/index.js +1 -0
- package/dist/bundle/rpc-entry.js +2 -0
- package/dist/cli/args.js +1 -1
- package/dist/cli/auth-command.js +9 -6
- package/dist/cli/auth-login.js +2 -0
- package/dist/cli/auth-logout.js +1 -0
- package/dist/cli/auth-terminal.js +5 -0
- package/dist/cli/config-selector.js +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.js +1 -1
- package/dist/core/agent-session-runtime.js +1 -1
- package/dist/core/agent-session-services.js +1 -1
- package/dist/core/agent-session.d.ts +8 -1
- package/dist/core/agent-session.js +12 -9
- package/dist/core/auth-storage.js +1 -1
- package/dist/core/bash-executor.js +1 -1
- package/dist/core/bug-report.js +3 -3
- package/dist/core/cache-warmer.d.ts +3 -15
- package/dist/core/cache-warmer.js +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +3 -2
- package/dist/core/compaction/branch-summarization.js +5 -5
- package/dist/core/compaction/compaction.d.ts +1 -0
- package/dist/core/compaction/compaction.js +14 -14
- package/dist/core/compaction/tool-output-pruning.js +1 -1
- package/dist/core/compaction/utils.d.ts +0 -1
- package/dist/core/compaction/utils.js +8 -8
- package/dist/core/exec.d.ts +2 -0
- package/dist/core/exec.js +1 -1
- package/dist/core/export-html/template.css +9 -0
- package/dist/core/export-html/template.js +46 -39
- package/dist/core/export-html/tool-renderer.js +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/pi-ai-extension-view.js +1 -0
- package/dist/core/extensions/runner.js +1 -1
- package/dist/core/extensions/types.d.ts +25 -7
- package/dist/core/extensions/virtual-modules.js +1 -1
- package/dist/core/keybindings.d.ts +1 -1
- package/dist/core/keybindings.js +1 -1
- package/dist/core/mcp-servers.d.ts +6 -17
- package/dist/core/mcp-servers.js +1 -1
- package/dist/core/model-config.d.ts +1912 -2211
- package/dist/core/model-config.js +4 -4
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-runtime.d.ts +1 -0
- package/dist/core/model-runtime.js +1 -1
- package/dist/core/package-manager.d.ts +10 -1
- package/dist/core/package-manager.js +2 -2
- package/dist/core/pi-ai-schemas.js +1 -0
- package/dist/core/pi-manifest.js +1 -1
- package/dist/core/preferred-providers.js +1 -0
- package/dist/core/project-trust.js +2 -2
- package/dist/core/prompt-templates.js +2 -2
- package/dist/core/provider-composer.js +1 -1
- package/dist/core/provider-matching.js +1 -0
- package/dist/core/radius-mcp.js +1 -0
- package/dist/core/remote-catalog-provider.js +1 -1
- package/dist/core/resource-loader.d.ts +3 -1
- package/dist/core/resource-loader.js +1 -1
- package/dist/core/runtime-credentials.js +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/session-cwd.js +3 -7
- package/dist/core/session-manager.d.ts +1 -0
- package/dist/core/session-manager.js +12 -12
- package/dist/core/settings-defaults.js +1 -1
- package/dist/core/settings-manager.d.ts +4 -0
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/settings-schema.d.ts +4 -2
- package/dist/core/settings-schema.js +1 -1
- package/dist/core/skills.js +3 -3
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/source-info.d.ts +8 -0
- package/dist/core/source-info.js +1 -1
- package/dist/core/system-prompt.js +3 -3
- package/dist/core/tools/bash.d.ts +2 -2
- package/dist/core/tools/bash.js +15 -15
- package/dist/core/tools/edit-diff.d.ts +9 -4
- package/dist/core/tools/edit-diff.js +22 -15
- package/dist/core/tools/edit.d.ts +3 -3
- package/dist/core/tools/edit.js +3 -3
- package/dist/core/tools/find.d.ts +2 -2
- package/dist/core/tools/find.js +10 -11
- package/dist/core/tools/grep.d.ts +3 -3
- package/dist/core/tools/grep.js +8 -12
- package/dist/core/tools/ls.d.ts +2 -2
- package/dist/core/tools/ls.js +4 -4
- package/dist/core/tools/powershell.js +6 -2
- package/dist/core/tools/read.d.ts +5 -2
- package/dist/core/tools/read.js +20 -19
- package/dist/core/tools/render-utils.js +5 -5
- package/dist/core/tools/renderers/write.js +10 -10
- package/dist/core/tools/tool-definition-wrapper.d.ts +11 -0
- package/dist/core/tools/truncate.d.ts +2 -8
- package/dist/core/tools/truncate.js +10 -10
- package/dist/core/tools/write.d.ts +2 -2
- package/dist/core/trust-manager.js +2 -2
- package/dist/core/usage-totals.js +1 -1
- package/dist/extensions/codemode/execute.js +12 -12
- package/dist/extensions/codemode/renderer.js +6 -6
- package/dist/extensions/codemode/tool.d.ts +2 -1
- package/dist/extensions/codemode/tool.js +11 -10
- package/dist/extensions/llama/client.js +5 -5
- package/dist/extensions/llama/ui.js +2 -2
- package/dist/extensions/mcp/cli.js +21 -19
- package/dist/extensions/mcp/config.js +2 -2
- package/dist/extensions/mcp/index.js +7 -7
- package/dist/extensions/mcp/oauth.d.ts +3 -22
- package/dist/extensions/mcp/oauth.js +2 -2
- package/dist/extensions/mcp/resources.d.ts +1 -1
- package/dist/extensions/mcp/resources.js +1 -1
- package/dist/extensions/mcp/runtime.d.ts +2 -2
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/extensions/mcp/tools.d.ts +1 -8
- package/dist/extensions/mcp/tools.js +4 -9
- package/dist/extensions/mcp/ui.js +1 -1
- package/dist/extensions/tool-search/tool.js +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/main.js +4 -4
- package/dist/modes/interactive/components/assistant-message.d.ts +4 -1
- package/dist/modes/interactive/components/assistant-message.js +2 -2
- package/dist/modes/interactive/components/branch-summary-message.d.ts +5 -1
- package/dist/modes/interactive/components/branch-summary-message.js +2 -2
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +5 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +2 -2
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/custom-editor.js +1 -1
- package/dist/modes/interactive/components/custom-entry.js +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +5 -2
- package/dist/modes/interactive/components/custom-message.js +3 -3
- package/dist/modes/interactive/components/diff.js +3 -3
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -0
- package/dist/modes/interactive/components/extension-editor.js +1 -1
- package/dist/modes/interactive/components/extension-selector.js +2 -2
- package/dist/modes/interactive/components/login-dialog.d.ts +5 -0
- package/dist/modes/interactive/components/login-dialog.js +1 -1
- package/dist/modes/interactive/components/markdown-transform.js +1 -1
- package/dist/modes/interactive/components/mermaid.js +4 -4
- package/dist/modes/interactive/components/model-selector.d.ts +1 -0
- package/dist/modes/interactive/components/model-selector.js +2 -2
- package/dist/modes/interactive/components/oauth-selector.d.ts +2 -1
- package/dist/modes/interactive/components/oauth-selector.js +1 -1
- package/dist/modes/interactive/components/provider-brand.js +1 -0
- package/dist/modes/interactive/components/radius-login-selector.js +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
- package/dist/modes/interactive/components/session-selector-search.js +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +2 -1
- package/dist/modes/interactive/components/session-selector.js +2 -2
- package/dist/modes/interactive/components/settings-submenu.js +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +5 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +2 -2
- package/dist/modes/interactive/components/tool-execution.d.ts +1 -0
- package/dist/modes/interactive/components/tool-execution.js +3 -3
- package/dist/modes/interactive/components/tree-selector.d.ts +2 -0
- package/dist/modes/interactive/components/tree-selector.js +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +2 -1
- package/dist/modes/interactive/components/user-message.js +1 -1
- package/dist/modes/interactive/external-editor.js +3 -3
- package/dist/modes/interactive/interactive-mode.d.ts +10 -1
- package/dist/modes/interactive/interactive-mode.js +45 -40
- package/dist/modes/interactive/model-search.js +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +4 -0
- package/dist/modes/interactive/theme/theme.js +3 -6
- package/dist/modes/print-mode.js +7 -7
- package/dist/modes/rpc/rpc-mode.js +1 -1
- package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-codeindex/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-compat/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-learn/package.json +3 -2
- package/dist/node_modules/@dalcode/dal-learn/src/index.js +16 -16
- package/dist/node_modules/@dalcode/dal-learn/src/lesson-events.js +1 -0
- package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +4 -3
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +4 -3
- package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-router/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-sync/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
- 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/image-budget.js +1 -0
- package/dist/node_modules/@dalcode/dal-workflow/src/index.js +4 -4
- package/dist/node_modules/@dalcode/dal-workflow/src/todo-snapshot.js +2 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +3 -3
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-agent-core/README.md +8 -6
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +2 -2
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +8 -5
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/README.md +58 -39
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +4 -4
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +2 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +9 -9
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/strict-tool-limits.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/meta.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/trusted-url.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/cache-warming.d.ts +21 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/cache-warming.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/index.d.ts +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/lazy-bedrock-provider.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/lazy-oauth.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/all.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.d.ts +485 -498
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js +1 -1
- 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/amazon-bedrock.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/azure.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/meta.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.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/opencode.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/qwen-token-plan-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-individual-cn.json +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-individual.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.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/data/together.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.d.ts +65 -65
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.models.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.models.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/schema-builders.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/telemetry.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts +4 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/openrouter-cost.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/streaming-json.d.ts +26 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/streaming-json.js +4 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/{typebox-helpers.d.ts → string-enum.d.ts} +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/string-enum.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.js +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/validation.js +4 -4
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +12 -5
- package/dist/node_modules/@earendil-works/pi-codemode/README.md +2 -2
- package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.js +4 -4
- package/dist/node_modules/@earendil-works/pi-codemode/dist/index.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-codemode/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.js +2 -0
- package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/CHANGELOG.md +32 -0
- package/dist/node_modules/@earendil-works/pi-mcp/README.md +60 -5
- package/dist/node_modules/@earendil-works/pi-mcp/dist/config.d.ts +45 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/config.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/index.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/input-schema.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/input-schema.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/naming.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/naming.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/auth-provider.d.ts +18 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/auth-provider.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/callback.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/client-settings.d.ts +42 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/client-settings.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/index.d.ts +5 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/loopback.d.ts +22 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/loopback.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/sign-in.d.ts +28 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/sign-in.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/types.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/types.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/output-limit.d.ts +8 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/output-limit.js +11 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/lines.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/pipe.d.ts +34 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/pipe.js +2 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/stdio.d.ts +1 -4
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/stdio.js +2 -2
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.js +6 -4
- package/dist/node_modules/@earendil-works/pi-mcp/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-schema/CHANGELOG.md +37 -0
- package/dist/node_modules/@earendil-works/pi-schema/LICENSE +21 -0
- package/dist/node_modules/@earendil-works/pi-schema/README.md +319 -0
- package/dist/node_modules/@earendil-works/pi-schema/THIRD_PARTY_NOTICES/typebox-LICENSE +23 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/annotations.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/builders.d.ts +89 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/builders.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/checks.d.ts +51 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/checks.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/coerce.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/compiler.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/explain.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/index.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/date.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/date_time.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/duration.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/email.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idn_email.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idn_hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/format/bidi.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/format/puny.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/idn-hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/index.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/ascii.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/puny.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/unicode.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/pattern/pattern.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/ipv4.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/ipv6.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/iri.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/iri_reference.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/json_pointer.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/json_pointer_uri_fragment.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/regex.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/relative_json_pointer.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/time.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri_reference.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri_template.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/url.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uuid.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/index.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/index.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/resolver.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/shared.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/typebox-static.d.ts +54 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/typebox-static.js +0 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/types.d.ts +25 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/types.js +0 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/validator.d.ts +20 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/validator.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/package.json +43 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.js +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/render.js +2 -2
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +3 -1
- package/dist/node_modules/@earendil-works/pi-tui/README.md +2 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.js +3 -3
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +11 -10
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/text.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/index.d.ts +2 -2
- package/dist/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/keys.js +5 -5
- package/dist/node_modules/@earendil-works/pi-tui/dist/layout.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/program-status.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +4 -4
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js +13 -13
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui.js +2 -2
- package/dist/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/utils.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/dist/package-manager-cli.js +17 -16
- package/dist/utils/ansi.js +1 -1
- package/dist/utils/changelog.js +3 -3
- package/dist/utils/clipboard-command.js +1 -1
- package/dist/utils/image-resize-core.js +1 -1
- package/dist/utils/image-resize.js +1 -1
- package/dist/utils/open-browser.js +1 -1
- package/dist/utils/paths.js +1 -1
- package/dist/utils/shell.js +3 -3
- package/dist/utils/syntax-highlight.js +4 -4
- package/dist/utils/terminal-question.js +1 -0
- package/dist/utils/tools-manager.js +1 -1
- package/dist/utils/web-url.js +1 -0
- package/examples/extensions/README.md +2 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +14 -14
- package/examples/extensions/debug-provider.ts +2 -2
- package/examples/extensions/gondolin/package-lock.json +19 -29
- package/examples/extensions/gondolin/package.json +2 -2
- package/examples/extensions/plan-mode/index.ts +20 -9
- package/examples/extensions/plan-mode/utils.ts +42 -16
- package/examples/extensions/preset.ts +2 -0
- package/examples/extensions/reload-runtime.ts +17 -5
- package/examples/extensions/subagent/README.md +14 -11
- package/examples/extensions/subagent/index.ts +392 -171
- package/examples/extensions/todo.ts +7 -0
- package/examples/extensions/tools.ts +2 -0
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +20 -20
- package/examples/tsconfig.json +208 -0
- package/npm-shrinkwrap.json +407 -383
- package/package.json +6 -7
- package/examples/extensions/sandbox/index.ts +0 -327
- package/examples/extensions/sandbox/package-lock.json +0 -92
- package/examples/extensions/sandbox/package.json +0 -19
- /package/dist/node_modules/@earendil-works/pi-mcp/{LICENSES → THIRD_PARTY_NOTICES}/modelcontextprotocol-typescript-sdk.txt +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
var D=Object.defineProperty;var d=(r,e)=>D(r,"name",{value:e,configurable:!0});import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS as N}from"@earendil-works/pi-ai";import{randomUUID as R}from"crypto";import{existsSync as w,mkdirSync as W,readFileSync as _}from"fs";import{dirname as U,join as f}from"path";import $ from"proper-lockfile";import{CONFIG_DIR_NAME as C,getAgentDir as H}from"../config.js";import{normalizePath as x,resolvePath as p}from"../utils/paths.js";import{stripBom as T}from"../utils/text.js";import{DEFAULT_FIRST_TOKEN_TIMEOUT_MS as B,DEFAULT_HTTP_IDLE_TIMEOUT_MS as V,parseHttpIdleTimeoutMs as F}from"./http-dispatcher.js";import{SETTINGS_DEFAULTS as l}from"./settings-defaults.js";import{declaredDataFormat as S,reportNewerDataFormat as q,writeFileAtomicSync as G}from"./shared-data.js";import{DEFAULT_STALL_WATCHDOG_MS as K}from"./stall-watchdog.js";const X=8e4,z={reserveTokens:16384,keepRecentTokens:2e4,maxContextTokens:X},Q=32e3,J=5,Y=["off","streaming","idle"];function y(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}d(y,"isMergeableObject");function L(r,e){const t={...r};for(const s of Object.keys(e)){const i=e[s];if(i===void 0)continue;const o=r[s];t[s]=y(o)&&y(i)?L(o,i):i}return t}d(L,"deepMergeObjects");const Z=["read","bash","edit","write"];function b(r){return typeof r=="string"&&(r.startsWith("+")||r.startsWith("-"))}d(b,"isToolModifier");function ke(r){const e=r.filter(b);if(e.length===0)return;if(e.length<r.length)return"tool names cannot be mixed with +name or -name entries";const t=e.find(s=>s.includes("*"));if(t)return`+name and -name entries take exact tool names, not patterns: ${t}`}d(ke,"getToolListError");function ee(r,e){const t=[...r];for(const s of e){if(!b(s))continue;const i=s.slice(1),o=t.indexOf(i);s.startsWith("+")&&o===-1&&i?t.push(i):s.startsWith("-")&&o!==-1&&t.splice(o,1)}return t}d(ee,"applyToolModifiers");function te(r,e){return e===void 0?r:!Array.isArray(r)||!Array.isArray(e)||!e.every(b)?e:[...r,...e]}d(te,"mergeDefaultTools");function se(r){const e=r.filter(t=>!b(t));return ee(e.length>0||r.length===0?e:Z,r)}d(se,"resolveDefaultTools");function c(r,e){const t=L(r,e),s=te(r.defaultTools,e.defaultTools);return s===void 0?t:{...t,defaultTools:s}}d(c,"deepMergeSettings");function k(r,e){const t=F(r);if(t!==void 0)return t;if(r!==void 0)throw new Error(`Invalid ${e} setting: ${String(r)}`)}d(k,"parseTimeoutSetting");const M=1,v=["enableAnalytics","trackingId"];function ie(r){let e;try{e=JSON.parse(T(r))}catch{return}if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;if(!(S(t)>M)&&v.some(s=>s in t)){for(const s of v)delete t[s];return JSON.stringify(t,null,2)}}d(ie,"withoutRetiredKeys");function P(r,e,t){return{scope:r,...t?{path:t}:{},error:e instanceof Error?e:new Error(String(e))}}d(P,"toSettingsError");class re{static{d(this,"FileSettingsStorage")}globalSettingsPath;projectSettingsPath;constructor(e,t){const s=p(e),i=p(t);this.globalSettingsPath=f(i,"settings.json"),this.projectSettingsPath=f(s,C,"settings.json")}acquireLockSyncWithRetry(e){let i;for(let o=1;o<=100;o++)try{return $.lockSync(e,{realpath:!1})}catch(n){if((typeof n=="object"&&n!==null&&"code"in n?String(n.code):void 0)!=="ELOCKED"||o===100)throw n;i=n;const h=Date.now();for(;Date.now()-h<20;);}throw i??new Error("Failed to acquire settings lock")}withLock(e,t){const s=e==="global"?this.globalSettingsPath:this.projectSettingsPath,i=U(s);let o;try{const n=w(s);n&&(o=this.acquireLockSyncWithRetry(s));const a=n?_(s,"utf-8"):void 0,h=t(a);h!==void 0&&(w(i)||W(i,{recursive:!0}),o||(o=this.acquireLockSyncWithRetry(s)),G(s,h))}finally{o&&o()}}}class oe{static{d(this,"InMemorySettingsStorage")}global;project;withLock(e,t){const s=e==="global"?this.global:this.project,i=t(s);i!==void 0&&(e==="global"?this.global=i:this.project=i)}}class g{static{d(this,"SettingsManager")}storage;globalSettings;projectSettings;settings;projectTrusted;modifiedFields=new Set;modifiedNestedFields=new Map;modifiedProjectFields=new Set;modifiedProjectNestedFields=new Map;globalSettingsLoadError=null;projectSettingsLoadError=null;writeQueue=Promise.resolve();errors;settingsPaths;constructor(e,t,s,i=null,o=null,n=[],a=!0,h={}){this.storage=e,this.globalSettings=t,this.projectSettings=s,this.projectTrusted=a,this.globalSettingsLoadError=i,this.projectSettingsLoadError=o,this.errors=[...n],this.settingsPaths=h,this.settings=c(this.globalSettings,this.projectSettings),this.reportNewerFormatScopes()}static create(e,t=H(),s={}){const i=p(e),o=p(t),n=new re(i,o);return g.fromStorageWithPaths(n,s,{global:f(o,"settings.json"),project:f(i,C,"settings.json")})}static fromStorage(e,t={}){return g.fromStorageWithPaths(e,t)}static fromStorageWithPaths(e,t,s={}){const i=t.projectTrusted??!0,o=g.tryLoadFromStorage(e,"global"),n=g.tryLoadFromStorage(e,"project",i),a=[];return o.error&&a.push(P("global",o.error,s.global)),n.error&&a.push(P("project",n.error,s.project)),new g(e,o.settings,n.settings,o.error,n.error,a,i,s)}static inMemory(e={},t={}){const s=new oe,i=g.migrateSettings(structuredClone(e));return s.withLock("global",()=>JSON.stringify(i,null,2)),g.fromStorage(s,t)}static loadFromStorage(e,t,s=!0){if(t==="project"&&!s)return{};let i;if(e.withLock(t,n=>(i=n,t==="global"&&n?ie(n):void 0)),!i)return{};const o=JSON.parse(T(i));return g.migrateSettings(o)}static tryLoadFromStorage(e,t,s=!0){try{return{settings:g.loadFromStorage(e,t,s),error:null}}catch(i){return{settings:{},error:i}}}static migrateSettings(e){for(const t of v)delete e[t];if("queueMode"in e&&!("steeringMode"in e)&&(e.steeringMode=e.queueMode,delete e.queueMode),!("transport"in e)&&typeof e.websockets=="boolean"&&(e.transport=e.websockets?"websocket":"sse",delete e.websockets),"skills"in e&&typeof e.skills=="object"&&e.skills!==null&&!Array.isArray(e.skills)){const t=e.skills;t.enableSkillCommands!==void 0&&e.enableSkillCommands===void 0&&(e.enableSkillCommands=t.enableSkillCommands),Array.isArray(t.customDirectories)&&t.customDirectories.length>0?e.skills=t.customDirectories:delete e.skills}if("retry"in e&&typeof e.retry=="object"&&e.retry!==null&&!Array.isArray(e.retry)){const t=e.retry,s=typeof t.provider=="object"&&t.provider!==null?t.provider:void 0;typeof t.maxDelayMs=="number"&&(s?.maxRetryDelayMs===void 0||s?.maxRetryDelayMs===null)&&(t.provider={...s??{},maxRetryDelayMs:t.maxDelayMs}),delete t.maxDelayMs}return e}getSettings(){return structuredClone(this.settings)}getGlobalSettings(){return structuredClone(this.globalSettings)}getProjectSettings(){return structuredClone(this.projectSettings)}isProjectTrusted(){return this.projectTrusted}setProjectTrusted(e){if(this.projectTrusted===e)return;if(this.projectTrusted=e,this.modifiedProjectFields.clear(),this.modifiedProjectNestedFields.clear(),!e){this.projectSettings={},this.projectSettingsLoadError=null,this.settings=c(this.globalSettings,this.projectSettings);return}const t=g.tryLoadFromStorage(this.storage,"project",e);this.projectSettings=t.settings,this.projectSettingsLoadError=t.error,t.error&&this.recordError("project",t.error),this.settings=c(this.globalSettings,this.projectSettings)}async reload(){await this.writeQueue;const e=g.tryLoadFromStorage(this.storage,"global");e.error?(this.globalSettingsLoadError=e.error,this.recordError("global",e.error)):(this.globalSettings=e.settings,this.globalSettingsLoadError=null),this.modifiedFields.clear(),this.modifiedNestedFields.clear(),this.modifiedProjectFields.clear(),this.modifiedProjectNestedFields.clear();const t=g.tryLoadFromStorage(this.storage,"project",this.projectTrusted);t.error?(this.projectSettingsLoadError=t.error,this.recordError("project",t.error)):(this.projectSettings=t.settings,this.projectSettingsLoadError=null),this.settings=c(this.globalSettings,this.projectSettings),this.reportNewerFormatScopes()}applyOverrides(e){this.settings=c(this.settings,e)}markModified(e,t){this.modifiedFields.add(e),t&&(this.modifiedNestedFields.has(e)||this.modifiedNestedFields.set(e,new Set),this.modifiedNestedFields.get(e).add(t))}markProjectModified(e,t){this.modifiedProjectFields.add(e),t&&(this.modifiedProjectNestedFields.has(e)||this.modifiedProjectNestedFields.set(e,new Set),this.modifiedProjectNestedFields.get(e).add(t))}assertProjectTrustedForWrite(){if(!this.projectTrusted)throw new Error("Project is not trusted; refusing to write project settings")}reportNewerFormat(e){q(this.settingsPaths[e]??`${e} settings.json`)}reportNewerFormatScopes(){S(this.globalSettings)>M&&this.reportNewerFormat("global"),S(this.projectSettings)>M&&this.reportNewerFormat("project")}recordError(e,t){this.errors.push(P(e,t,this.settingsPaths[e]))}clearModifiedScope(e){if(e==="global"){this.modifiedFields.clear(),this.modifiedNestedFields.clear();return}this.modifiedProjectFields.clear(),this.modifiedProjectNestedFields.clear()}enqueueWrite(e,t){this.writeQueue=this.writeQueue.then(()=>{e==="project"&&this.assertProjectTrustedForWrite(),t(),this.clearModifiedScope(e)}).catch(s=>{this.recordError(e,s)})}cloneModifiedNestedFields(e){const t=new Map;for(const[s,i]of e.entries())t.set(s,new Set(i));return t}persistScopedSettings(e,t,s,i){this.storage.withLock(e,o=>{const n=o?JSON.parse(T(o)):{};if(S(n)>M){this.reportNewerFormat(e);return}const a=o?g.migrateSettings(n):{},h={...a};for(const u of s){const m=t[u];if(i.has(u)&&typeof m=="object"&&m!==null){const I=i.get(u),O=a[u]??{},A=m,j={...O};for(const E of I)j[E]=A[E];h[u]=j}else h[u]=m}return JSON.stringify(h,null,2)})}save(){if(this.settings=c(this.globalSettings,this.projectSettings),this.globalSettingsLoadError)return;const e=structuredClone(this.globalSettings),t=new Set(this.modifiedFields),s=this.cloneModifiedNestedFields(this.modifiedNestedFields);this.enqueueWrite("global",()=>{this.persistScopedSettings("global",e,t,s)})}saveProjectSettings(e){if(this.assertProjectTrustedForWrite(),this.projectSettings=structuredClone(e),this.settings=c(this.globalSettings,this.projectSettings),this.projectSettingsLoadError)return;const t=structuredClone(this.projectSettings),s=new Set(this.modifiedProjectFields),i=this.cloneModifiedNestedFields(this.modifiedProjectNestedFields);this.enqueueWrite("project",()=>{this.persistScopedSettings("project",t,s,i)})}updateProjectSettings(e,t){this.assertProjectTrustedForWrite();const s=structuredClone(this.projectSettings);t(s),this.markProjectModified(e),this.saveProjectSettings(s)}async flush(){await this.writeQueue}drainErrors(){const e=[...this.errors];return this.errors=[],e}getLastChangelogVersion(){return this.settings.lastChangelogVersion}setLastChangelogVersion(e){this.globalSettings.lastChangelogVersion=e,this.markModified("lastChangelogVersion"),this.save()}getSessionDir(){const e=this.settings.sessionDir;return e&&x(e)}getDefaultProvider(){return this.settings.defaultProvider}getDefaultModel(){return this.settings.defaultModel}setDefaultProvider(e){this.globalSettings.defaultProvider=e,this.markModified("defaultProvider"),this.save()}setDefaultModel(e){this.globalSettings.defaultModel=e,this.markModified("defaultModel"),this.save()}setDefaultModelAndProvider(e,t){this.globalSettings.defaultProvider=e,this.globalSettings.defaultModel=t,this.markModified("defaultProvider"),this.markModified("defaultModel"),this.save()}getSteeringMode(){return this.settings.steeringMode||l.steeringMode}setSteeringMode(e){this.globalSettings.steeringMode=e,this.markModified("steeringMode"),this.save()}getFollowUpMode(){return this.settings.followUpMode||l.followUpMode}setFollowUpMode(e){this.globalSettings.followUpMode=e,this.markModified("followUpMode"),this.save()}getThemeSetting(){const e=this.settings.theme;if(typeof e=="string")return e}getTheme(){const e=this.getThemeSetting();return e?.includes("/")?void 0:e}setTheme(e){this.globalSettings.theme=e,this.markModified("theme"),this.save()}getDefaultThinkingLevel(){return this.settings.defaultThinkingLevel}setDefaultThinkingLevel(e){this.globalSettings.defaultThinkingLevel=e,this.markModified("defaultThinkingLevel"),this.save()}getModelThinkingLevel(e,t){return this.settings.modelThinkingLevels?.[`${e}/${t}`]}getAllModelThinkingLevels(){return{...this.settings.modelThinkingLevels??{}}}setModelThinkingLevel(e,t,s){this.globalSettings.modelThinkingLevels||(this.globalSettings.modelThinkingLevels={}),this.globalSettings.modelThinkingLevels[`${e}/${t}`]=s,this.markModified("modelThinkingLevels"),this.save()}removeModelThinkingLevel(e,t){this.globalSettings.modelThinkingLevels&&(delete this.globalSettings.modelThinkingLevels[`${e}/${t}`],Object.keys(this.globalSettings.modelThinkingLevels).length===0&&delete this.globalSettings.modelThinkingLevels,this.markModified("modelThinkingLevels"),this.save())}getTransport(){return this.settings.transport??l.transport}setTransport(e){this.globalSettings.transport=e,this.markModified("transport"),this.save()}getSessionShareDestination(){const e=this.settings.sessionShareDestination;return e==="gist"||e==="radius"?e:l.sessionShareDestination}setSessionShareDestination(e){this.globalSettings.sessionShareDestination=e,this.markModified("sessionShareDestination"),this.save()}getCompactionEnabled(){return this.settings.compaction?.enabled??l.compaction.enabled}setCompactionEnabled(e){this.globalSettings.compaction||(this.globalSettings.compaction={}),this.globalSettings.compaction.enabled=e,this.markModified("compaction","enabled"),this.save()}getCompactionTokenSetting(e,t){const s=this.settings.compaction,i=s?.[e];if(i!==void 0&&(typeof i!="number"||!Number.isSafeInteger(i)||i<0))throw new Error(`Invalid compaction.${e} setting: ${String(i)}. Expected a non-negative safe integer.`);const o=t?`${t.provider}/${t.id}`:void 0,n=o!==void 0?s?.modelOverrides?.[o]:void 0;if(n!==void 0&&!y(n))throw new Error(`Invalid compaction.modelOverrides["${o}"] setting: ${String(n)}. Expected an object.`);const a=n?.[e];if(a!==void 0&&(typeof a!="number"||!Number.isSafeInteger(a)||a<0))throw new Error(`Invalid compaction.modelOverrides["${o}"].${e} setting: ${String(a)}. Expected a non-negative safe integer.`);return a??i??z[e]}getCompactionReserveTokens(e){return this.getCompactionTokenSetting("reserveTokens",e)}getCompactionKeepRecentTokens(e){return this.getCompactionTokenSetting("keepRecentTokens",e)}getCompactionSettings(e){return{enabled:this.getCompactionEnabled(),reserveTokens:this.getCompactionReserveTokens(e),keepRecentTokens:this.getCompactionKeepRecentTokens(e),maxContextTokens:this.getCompactionMaxContextTokens(e),pruneToolOutputs:this.getCompactionPruneToolOutputs()}}getCompactionMaxContextTokens(e){return this.getCompactionTokenSetting("maxContextTokens",e)}getCompactionPruneToolOutputs(){const e=this.settings.compaction?.pruneToolOutputs;if(e!==void 0&&typeof e!="boolean")throw new Error(`Invalid compaction.pruneToolOutputs setting: ${String(e)}. Expected a boolean.`);return e??!0}getCompactionSummaryModel(){const e=this.settings.compaction?.summaryModel;if(e===void 0||e==="")return;const t=typeof e=="string"?e.indexOf("/"):-1;if(typeof e!="string"||t<=0||t===e.length-1)throw new Error(`Invalid compaction.summaryModel setting: ${String(e)}. Expected "provider/modelId".`);return{provider:e.slice(0,t),modelId:e.slice(t+1)}}getBranchSummarySettings(){return{reserveTokens:this.settings.branchSummary?.reserveTokens??l.branchSummary.reserveTokens,skipPrompt:this.settings.branchSummary?.skipPrompt??l.branchSummary.skipPrompt}}getBranchSummarySkipPrompt(){return this.settings.branchSummary?.skipPrompt??l.branchSummary.skipPrompt}getRetryEnabled(){return this.settings.retry?.enabled??l.retry.enabled}setRetryEnabled(e){this.globalSettings.retry||(this.globalSettings.retry={}),this.globalSettings.retry.enabled=e,this.markModified("retry","enabled"),this.save()}getRetrySettings(){return{enabled:this.getRetryEnabled(),maxRetries:this.settings.retry?.maxRetries??J,baseDelayMs:this.settings.retry?.baseDelayMs??2e3,maxAgentDelayMs:this.settings.retry?.maxAgentDelayMs??N}}getMaxOutputTokens(){const e=this.settings.maxOutputTokens;if(e===void 0)return Q;if(typeof e!="number"||!Number.isSafeInteger(e)||e<0)throw new Error(`Invalid maxOutputTokens setting: ${String(e)}. Expected a non-negative safe integer.`);return e}getOutputTokenLimit(e){const t=this.getMaxOutputTokens();return t>0&&(e<=0||e>t)?t:e}getStallWatchdogMs(){const e=F(process.env.DAL_STALL_WATCHDOG_MS);return e!==void 0?e:k(this.settings.stallWatchdogMs,"stallWatchdogMs")??K}getHttpIdleTimeoutMs(){return k(this.settings.httpIdleTimeoutMs,"httpIdleTimeoutMs")??V}getFirstTokenTimeoutMs(){return k(this.settings.firstTokenTimeoutMs,"firstTokenTimeoutMs")??B}setHttpIdleTimeoutMs(e){if(!Number.isFinite(e)||e<0)throw new Error(`Invalid httpIdleTimeoutMs setting: ${String(e)}`);this.globalSettings.httpIdleTimeoutMs=Math.floor(e),this.markModified("httpIdleTimeoutMs"),this.save()}getCacheWarmingMode(){const e=this.globalSettings.cacheWarming;return e!==void 0&&Y.includes(e)?e:l.cacheWarming}setCacheWarmingMode(e){this.globalSettings.cacheWarming=e,this.markModified("cacheWarming"),this.save()}getProviderRetrySettings(){return{timeoutMs:this.settings.retry?.provider?.timeoutMs,maxRetries:this.settings.retry?.provider?.maxRetries,maxRetryDelayMs:this.settings.retry?.provider?.maxRetryDelayMs??l.retry.provider.maxRetryDelayMs}}getWebSocketConnectTimeoutMs(){return k(this.settings.websocketConnectTimeoutMs,"websocketConnectTimeoutMs")}getHideThinkingBlock(){return this.settings.hideThinkingBlock??!0}getShowCacheMissNotices(){return this.settings.showCacheMissNotices??l.showCacheMissNotices}getExternalEditorCommand(){const e=this.settings.externalEditor;if(typeof e=="string"&&e.trim()!=="")return e;const t=process.env.VISUAL||process.env.EDITOR;return t||(process.platform==="win32"?"notepad":"nano")}setHideThinkingBlock(e){this.globalSettings.hideThinkingBlock=e,this.markModified("hideThinkingBlock"),this.save()}setShowCacheMissNotices(e){this.globalSettings.showCacheMissNotices=e,this.markModified("showCacheMissNotices"),this.save()}getShellPath(){const e=this.settings.shellPath;return e&&x(e)}setShellPath(e){this.globalSettings.shellPath=e,this.markModified("shellPath"),this.save()}getQuietStartup(){const e=this.settings.quietStartup;return e===!1?!1:e==="header"?e:!0}setQuietStartup(e){this.globalSettings.quietStartup=e,this.markModified("quietStartup"),this.save()}getDefaultProjectTrust(){const e=this.globalSettings.defaultProjectTrust;return e==="always"||e==="never"?e:l.defaultProjectTrust}setDefaultProjectTrust(e){this.globalSettings.defaultProjectTrust=e,this.markModified("defaultProjectTrust"),this.save()}getShellCommandPrefix(){return this.settings.shellCommandPrefix}getShellEnvironmentPolicy(){const e=this.globalSettings.shellEnvironment??{},t=[...e.exclude??[],...this.projectSettings.shellEnvironment?.exclude??[]];return{...e.inherit!==void 0?{inherit:e.inherit}:{},...t.length>0?{exclude:t}:{},...e.include!==void 0?{include:[...e.include]}:{},...e.set!==void 0?{set:{...e.set}}:{}}}getPermissionRuleSources(){return{...this.globalSettings.permissions?{user:structuredClone(this.globalSettings.permissions)}:{},...this.projectSettings.permissions?{project:structuredClone(this.projectSettings.permissions)}:{}}}getSandboxSettingsSources(){return{...this.globalSettings.sandbox?{global:structuredClone(this.globalSettings.sandbox)}:{},...this.projectSettings.sandbox?{project:structuredClone(this.projectSettings.sandbox)}:{}}}setShellCommandPrefix(e){this.globalSettings.shellCommandPrefix=e,this.markModified("shellCommandPrefix"),this.save()}getNpmCommand(){return this.settings.npmCommand?[...this.settings.npmCommand]:void 0}setNpmCommand(e){this.globalSettings.npmCommand=e?[...e]:void 0,this.markModified("npmCommand"),this.save()}getCollapseChangelog(){return this.settings.collapseChangelog??!0}setCollapseChangelog(e){this.globalSettings.collapseChangelog=e,this.markModified("collapseChangelog"),this.save()}getEnableInstallTelemetry(){return this.settings.enableInstallTelemetry??l.enableInstallTelemetry}setEnableInstallTelemetry(e){this.globalSettings.enableInstallTelemetry=e,this.markModified("enableInstallTelemetry"),this.save()}getOrCreateDeviceId(){return this.globalSettings.deviceId||(this.globalSettings.deviceId=R(),this.markModified("deviceId"),this.save()),this.globalSettings.deviceId}getPackages(){return[...this.settings.packages??[]]}setPackages(e){this.globalSettings.packages=e,this.markModified("packages"),this.save()}setProjectPackages(e){this.updateProjectSettings("packages",t=>{t.packages=e})}getExtensionPaths(){return[...this.settings.extensions??[]]}setExtensionPaths(e){this.globalSettings.extensions=e,this.markModified("extensions"),this.save()}setProjectExtensionPaths(e){this.updateProjectSettings("extensions",t=>{t.extensions=e})}getSkillPaths(){return[...this.settings.skills??[]]}setSkillPaths(e){this.globalSettings.skills=e,this.markModified("skills"),this.save()}setProjectSkillPaths(e){this.updateProjectSettings("skills",t=>{t.skills=e})}getPromptTemplatePaths(){return[...this.settings.prompts??[]]}setPromptTemplatePaths(e){this.globalSettings.prompts=e,this.markModified("prompts"),this.save()}setProjectPromptTemplatePaths(e){this.updateProjectSettings("prompts",t=>{t.prompts=e})}getThemePaths(){return[...this.settings.themes??[]]}setThemePaths(e){this.globalSettings.themes=e,this.markModified("themes"),this.save()}setProjectThemePaths(e){this.updateProjectSettings("themes",t=>{t.themes=e})}getEnableSkillCommands(){return this.settings.enableSkillCommands??l.enableSkillCommands}setEnableSkillCommands(e){this.globalSettings.enableSkillCommands=e,this.markModified("enableSkillCommands"),this.save()}getFactoryEnabled(){return this.settings.factoryEnabled??!0}setFactoryEnabled(e){this.globalSettings.factoryEnabled=e,this.markModified("factoryEnabled"),this.save()}getThinkingBudgets(){return this.settings.thinkingBudgets}getTerminalCapabilityOverrides(){const e=this.settings.terminal,t=e?.images;return{...t==="kitty"||t==="iterm2"?{images:t}:t===!1?{images:null}:{},...typeof e?.trueColor=="boolean"?{trueColor:e.trueColor}:{},...typeof e?.hyperlinks=="boolean"?{hyperlinks:e.hyperlinks}:{}}}getShowImages(){return this.settings.terminal?.showImages??l.terminal.showImages}setShowImages(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.showImages=e,this.markModified("terminal","showImages"),this.save()}getImageWidthCells(){const e=this.settings.terminal?.imageWidthCells;return typeof e!="number"||!Number.isFinite(e)?l.terminal.imageWidthCells:Math.max(1,Math.floor(e))}setImageWidthCells(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.imageWidthCells=Math.max(1,Math.floor(e)),this.markModified("terminal","imageWidthCells"),this.save()}getClearOnShrink(){return this.settings.terminal?.clearOnShrink!==void 0?this.settings.terminal.clearOnShrink:process.env.PI_CLEAR_ON_SHRINK==="1"?!0:l.terminal.clearOnShrink}setClearOnShrink(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.clearOnShrink=e,this.markModified("terminal","clearOnShrink"),this.save()}getShowTerminalProgress(){return this.settings.terminal?.showTerminalProgress??l.terminal.showTerminalProgress}setShowTerminalProgress(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.showTerminalProgress=e,this.markModified("terminal","showTerminalProgress"),this.save()}getTuiMode(){return this.settings.tuiMode==="fullscreen"?"fullscreen":(this.settings.tuiMode==="regular"||this.settings.tuiMode,"regular")}setTuiMode(e){this.globalSettings.tuiMode=e,this.markModified("tuiMode"),this.save()}getFullscreenExitOutput(){return this.settings.fullscreenExitOutput==="resume-hint"?"resume-hint":l.fullscreenExitOutput}setFullscreenExitOutput(e){this.globalSettings.fullscreenExitOutput=e,this.markModified("fullscreenExitOutput"),this.save()}getFullscreenScrollbar(){const e=this.settings.fullscreenScrollbar;return e==="always"||e==="hidden"?e:l.fullscreenScrollbar}setFullscreenScrollbar(e){this.globalSettings.fullscreenScrollbar=e,this.markModified("fullscreenScrollbar"),this.save()}getFullscreenCopyOnSelect(){return this.settings.fullscreenCopyOnSelect??l.fullscreenCopyOnSelect}setFullscreenCopyOnSelect(e){this.globalSettings.fullscreenCopyOnSelect=e,this.markModified("fullscreenCopyOnSelect"),this.save()}getFullscreenWheelScrollLines(){const e=this.settings.fullscreenWheelScrollLines;return typeof e=="number"&&Number.isFinite(e)?Math.max(1,Math.min(100,Math.floor(e))):l.fullscreenWheelScrollLines}setFullscreenWheelScrollLines(e){this.globalSettings.fullscreenWheelScrollLines=e==="auto"?e:Math.max(1,Math.min(100,Math.floor(e))),this.markModified("fullscreenWheelScrollLines"),this.save()}getImageAutoResize(){return this.settings.images?.autoResize??l.images.autoResize}setImageAutoResize(e){this.globalSettings.images||(this.globalSettings.images={}),this.globalSettings.images.autoResize=e,this.markModified("images","autoResize"),this.save()}getBlockImages(){return this.settings.images?.blockImages??l.images.blockImages}setBlockImages(e){this.globalSettings.images||(this.globalSettings.images={}),this.globalSettings.images.blockImages=e,this.markModified("images","blockImages"),this.save()}getEnabledModels(){return this.settings.enabledModels}getDefaultTools(){const e=this.settings.defaultTools;if(e!==void 0)return se(Array.isArray(e)?e.filter(t=>typeof t=="string"):[])}setEnabledModels(e){this.globalSettings.enabledModels=e,this.markModified("enabledModels"),this.save()}getDoubleEscapeAction(){return this.settings.doubleEscapeAction??l.doubleEscapeAction}setDoubleEscapeAction(e){this.globalSettings.doubleEscapeAction=e,this.markModified("doubleEscapeAction"),this.save()}getTreeFilterMode(){const e=this.settings.treeFilterMode;return e&&["default","no-tools","user-only","labeled-only","all"].includes(e)?e:l.treeFilterMode}setTreeFilterMode(e){this.globalSettings.treeFilterMode=e,this.markModified("treeFilterMode"),this.save()}getShowHardwareCursor(){return this.settings.showHardwareCursor??process.env.PI_HARDWARE_CURSOR==="1"}setShowHardwareCursor(e){this.globalSettings.showHardwareCursor=e,this.markModified("showHardwareCursor"),this.save()}getEditorPaddingX(){return this.settings.editorPaddingX??1}setEditorPaddingX(e){this.globalSettings.editorPaddingX=Math.max(0,Math.min(3,Math.floor(e))),this.markModified("editorPaddingX"),this.save()}getOutputPad(){return this.settings.outputPad===1?1:0}setOutputPad(e){this.globalSettings.outputPad=e,this.markModified("outputPad"),this.save()}getAutocompleteMaxVisible(){return this.settings.autocompleteMaxVisible??l.autocompleteMaxVisible}setAutocompleteMaxVisible(e){this.globalSettings.autocompleteMaxVisible=Math.max(3,Math.min(20,Math.floor(e))),this.markModified("autocompleteMaxVisible"),this.save()}getCodeBlockIndent(){return this.settings.markdown?.codeBlockIndent??l.markdown.codeBlockIndent}getMermaidRenderingMode(){const e=this.settings.markdown?.mermaid;return e==="off"||e==="final"?e:l.markdown.mermaid}setMermaidRenderingMode(e){this.globalSettings.markdown??={},this.globalSettings.markdown.mermaid=e,this.markModified("markdown","mermaid"),this.save()}getWarnings(){return{...this.settings.warnings??{}}}setWarnings(e){this.globalSettings.warnings={...e},this.markModified("warnings"),this.save()}}export{Y as CACHE_WARMING_MODES,X as DEFAULT_COMPACTION_MAX_CONTEXT_TOKENS,Q as DEFAULT_MAX_OUTPUT_TOKENS,J as DEFAULT_MAX_RETRIES,Z as DEFAULT_TOOL_NAMES,re as FileSettingsStorage,oe as InMemorySettingsStorage,M as SETTINGS_FORMAT_VERSION,g as SettingsManager,ee as applyToolModifiers,ke as getToolListError,b as isToolModifier};
|
|
1
|
+
var D=Object.defineProperty;var d=(r,e)=>D(r,"name",{value:e,configurable:!0});import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS as N}from"@earendil-works/pi-ai";import{randomUUID as R}from"crypto";import{existsSync as C,mkdirSync as W,readFileSync as _}from"fs";import{dirname as U,join as f}from"path";import $ from"proper-lockfile";import{CONFIG_DIR_NAME as w,getAgentDir as V}from"../config.js";import{normalizePath as x,resolvePath as p}from"../utils/paths.js";import{stripBom as T}from"../utils/text.js";import{DEFAULT_FIRST_TOKEN_TIMEOUT_MS as H,DEFAULT_HTTP_IDLE_TIMEOUT_MS as B,parseHttpIdleTimeoutMs as F}from"./http-dispatcher.js";import{SETTINGS_DEFAULTS as l}from"./settings-defaults.js";import{declaredDataFormat as S,reportNewerDataFormat as q,writeFileAtomicSync as G}from"./shared-data.js";import{DEFAULT_STALL_WATCHDOG_MS as K}from"./stall-watchdog.js";const X=8e4,z={reserveTokens:16384,keepRecentTokens:2e4,maxContextTokens:X},Q=32e3,J=5,Y=["off","streaming","idle"];function y(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}d(y,"isMergeableObject");function L(r,e){const t={...r};for(const s of Object.keys(e)){const i=e[s];if(i===void 0)continue;const o=r[s];t[s]=y(o)&&y(i)?L(o,i):i}return t}d(L,"deepMergeObjects");const Z=["read","bash","edit","write"];function b(r){return typeof r=="string"&&(r.startsWith("+")||r.startsWith("-"))}d(b,"isToolModifier");function ke(r){const e=r.filter(b);if(e.length===0)return;if(e.length<r.length)return"tool names cannot be mixed with +name or -name entries";const t=e.find(s=>s.includes("*"));if(t)return`+name and -name entries take exact tool names, not patterns: ${t}`}d(ke,"getToolListError");function ee(r,e){const t=[...r];for(const s of e){if(!b(s))continue;const i=s.slice(1),o=t.indexOf(i);s.startsWith("+")&&o===-1&&i?t.push(i):s.startsWith("-")&&o!==-1&&t.splice(o,1)}return t}d(ee,"applyToolModifiers");function te(r,e){return e===void 0?r:!Array.isArray(r)||!Array.isArray(e)||!e.every(b)?e:[...r,...e]}d(te,"mergeDefaultTools");function se(r){const e=r.filter(t=>!b(t));return ee(e.length>0||r.length===0?e:Z,r)}d(se,"resolveDefaultTools");function c(r,e){const t=L(r,e),s=te(r.defaultTools,e.defaultTools);return s===void 0?t:{...t,defaultTools:s}}d(c,"deepMergeSettings");function k(r,e){const t=F(r);if(t!==void 0)return t;if(r!==void 0)throw new Error(`Invalid ${e} setting: ${String(r)}`)}d(k,"parseTimeoutSetting");const M=1,v=["enableAnalytics","trackingId"];function ie(r){let e;try{e=JSON.parse(T(r))}catch{return}if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;if(!(S(t)>M)&&v.some(s=>s in t)){for(const s of v)delete t[s];return JSON.stringify(t,null,2)}}d(ie,"withoutRetiredKeys");function P(r,e,t){return{scope:r,...t?{path:t}:{},error:e instanceof Error?e:new Error(String(e))}}d(P,"toSettingsError");class re{static{d(this,"FileSettingsStorage")}globalSettingsPath;projectSettingsPath;constructor(e,t){const s=p(e),i=p(t);this.globalSettingsPath=f(i,"settings.json"),this.projectSettingsPath=f(s,w,"settings.json")}acquireLockSyncWithRetry(e){let i;for(let o=1;o<=100;o++)try{return $.lockSync(e,{realpath:!1})}catch(n){if((typeof n=="object"&&n!==null&&"code"in n?String(n.code):void 0)!=="ELOCKED"||o===100)throw n;i=n;const h=Date.now();for(;Date.now()-h<20;);}throw i??new Error("Failed to acquire settings lock")}withLock(e,t){const s=e==="global"?this.globalSettingsPath:this.projectSettingsPath,i=U(s);let o;try{const n=C(s);n&&(o=this.acquireLockSyncWithRetry(s));const a=n?_(s,"utf-8"):void 0,h=t(a);h!==void 0&&(C(i)||W(i,{recursive:!0}),o||(o=this.acquireLockSyncWithRetry(s)),G(s,h))}finally{o&&o()}}}class oe{static{d(this,"InMemorySettingsStorage")}global;project;withLock(e,t){const s=e==="global"?this.global:this.project,i=t(s);i!==void 0&&(e==="global"?this.global=i:this.project=i)}}class g{static{d(this,"SettingsManager")}storage;globalSettings;projectSettings;settings;projectTrusted;modifiedFields=new Set;modifiedNestedFields=new Map;modifiedProjectFields=new Set;modifiedProjectNestedFields=new Map;globalSettingsLoadError=null;projectSettingsLoadError=null;writeQueue=Promise.resolve();errors;settingsPaths;constructor(e,t,s,i=null,o=null,n=[],a=!0,h={}){this.storage=e,this.globalSettings=t,this.projectSettings=s,this.projectTrusted=a,this.globalSettingsLoadError=i,this.projectSettingsLoadError=o,this.errors=[...n],this.settingsPaths=h,this.settings=c(this.globalSettings,this.projectSettings),this.reportNewerFormatScopes()}static create(e,t=V(),s={}){const i=p(e),o=p(t),n=new re(i,o);return g.fromStorageWithPaths(n,s,{global:f(o,"settings.json"),project:f(i,w,"settings.json")})}static fromStorage(e,t={}){return g.fromStorageWithPaths(e,t)}static fromStorageWithPaths(e,t,s={}){const i=t.projectTrusted??!0,o=g.tryLoadFromStorage(e,"global"),n=g.tryLoadFromStorage(e,"project",i),a=[];return o.error&&a.push(P("global",o.error,s.global)),n.error&&a.push(P("project",n.error,s.project)),new g(e,o.settings,n.settings,o.error,n.error,a,i,s)}static inMemory(e={},t={}){const s=new oe,i=g.migrateSettings(structuredClone(e));return s.withLock("global",()=>JSON.stringify(i,null,2)),g.fromStorage(s,t)}static loadFromStorage(e,t,s=!0){if(t==="project"&&!s)return{};let i;if(e.withLock(t,n=>(i=n,t==="global"&&n?ie(n):void 0)),!i)return{};const o=JSON.parse(T(i));return g.migrateSettings(o)}static tryLoadFromStorage(e,t,s=!0){try{return{settings:g.loadFromStorage(e,t,s),error:null}}catch(i){return{settings:{},error:i}}}static migrateSettings(e){for(const t of v)delete e[t];if("queueMode"in e&&!("steeringMode"in e)&&(e.steeringMode=e.queueMode,delete e.queueMode),!("transport"in e)&&typeof e.websockets=="boolean"&&(e.transport=e.websockets?"websocket":"sse",delete e.websockets),"skills"in e&&typeof e.skills=="object"&&e.skills!==null&&!Array.isArray(e.skills)){const t=e.skills;t.enableSkillCommands!==void 0&&e.enableSkillCommands===void 0&&(e.enableSkillCommands=t.enableSkillCommands),Array.isArray(t.customDirectories)&&t.customDirectories.length>0?e.skills=t.customDirectories:delete e.skills}if("retry"in e&&typeof e.retry=="object"&&e.retry!==null&&!Array.isArray(e.retry)){const t=e.retry,s=typeof t.provider=="object"&&t.provider!==null?t.provider:void 0;typeof t.maxDelayMs=="number"&&(s?.maxRetryDelayMs===void 0||s?.maxRetryDelayMs===null)&&(t.provider={...s??{},maxRetryDelayMs:t.maxDelayMs}),delete t.maxDelayMs}return e}getSettings(){return structuredClone(this.settings)}getGlobalSettings(){return structuredClone(this.globalSettings)}getProjectSettings(){return structuredClone(this.projectSettings)}isProjectTrusted(){return this.projectTrusted}setProjectTrusted(e){if(this.projectTrusted===e)return;if(this.projectTrusted=e,this.modifiedProjectFields.clear(),this.modifiedProjectNestedFields.clear(),!e){this.projectSettings={},this.projectSettingsLoadError=null,this.settings=c(this.globalSettings,this.projectSettings);return}const t=g.tryLoadFromStorage(this.storage,"project",e);this.projectSettings=t.settings,this.projectSettingsLoadError=t.error,t.error&&this.recordError("project",t.error),this.settings=c(this.globalSettings,this.projectSettings)}async reload(){await this.writeQueue;const e=g.tryLoadFromStorage(this.storage,"global");e.error?(this.globalSettingsLoadError=e.error,this.recordError("global",e.error)):(this.globalSettings=e.settings,this.globalSettingsLoadError=null),this.modifiedFields.clear(),this.modifiedNestedFields.clear(),this.modifiedProjectFields.clear(),this.modifiedProjectNestedFields.clear();const t=g.tryLoadFromStorage(this.storage,"project",this.projectTrusted);t.error?(this.projectSettingsLoadError=t.error,this.recordError("project",t.error)):(this.projectSettings=t.settings,this.projectSettingsLoadError=null),this.settings=c(this.globalSettings,this.projectSettings),this.reportNewerFormatScopes()}applyOverrides(e){this.settings=c(this.settings,e)}markModified(e,t){this.modifiedFields.add(e),t&&(this.modifiedNestedFields.has(e)||this.modifiedNestedFields.set(e,new Set),this.modifiedNestedFields.get(e).add(t))}markProjectModified(e,t){this.modifiedProjectFields.add(e),t&&(this.modifiedProjectNestedFields.has(e)||this.modifiedProjectNestedFields.set(e,new Set),this.modifiedProjectNestedFields.get(e).add(t))}assertProjectTrustedForWrite(){if(!this.projectTrusted)throw new Error("Project is not trusted; refusing to write project settings")}reportNewerFormat(e){q(this.settingsPaths[e]??`${e} settings.json`)}reportNewerFormatScopes(){S(this.globalSettings)>M&&this.reportNewerFormat("global"),S(this.projectSettings)>M&&this.reportNewerFormat("project")}recordError(e,t){this.errors.push(P(e,t,this.settingsPaths[e]))}clearModifiedScope(e){if(e==="global"){this.modifiedFields.clear(),this.modifiedNestedFields.clear();return}this.modifiedProjectFields.clear(),this.modifiedProjectNestedFields.clear()}enqueueWrite(e,t){this.writeQueue=this.writeQueue.then(()=>{e==="project"&&this.assertProjectTrustedForWrite(),t(),this.clearModifiedScope(e)}).catch(s=>{this.recordError(e,s)})}cloneModifiedNestedFields(e){const t=new Map;for(const[s,i]of e.entries())t.set(s,new Set(i));return t}persistScopedSettings(e,t,s,i){this.storage.withLock(e,o=>{const n=o?JSON.parse(T(o)):{};if(S(n)>M){this.reportNewerFormat(e);return}const a=o?g.migrateSettings(n):{},h={...a};for(const u of s){const m=t[u];if(i.has(u)&&typeof m=="object"&&m!==null){const I=i.get(u),O=a[u]??{},A=m,E={...O};for(const j of I)E[j]=A[j];h[u]=E}else h[u]=m}return JSON.stringify(h,null,2)})}save(){if(this.settings=c(this.globalSettings,this.projectSettings),this.globalSettingsLoadError)return;const e=structuredClone(this.globalSettings),t=new Set(this.modifiedFields),s=this.cloneModifiedNestedFields(this.modifiedNestedFields);this.enqueueWrite("global",()=>{this.persistScopedSettings("global",e,t,s)})}saveProjectSettings(e){if(this.assertProjectTrustedForWrite(),this.projectSettings=structuredClone(e),this.settings=c(this.globalSettings,this.projectSettings),this.projectSettingsLoadError)return;const t=structuredClone(this.projectSettings),s=new Set(this.modifiedProjectFields),i=this.cloneModifiedNestedFields(this.modifiedProjectNestedFields);this.enqueueWrite("project",()=>{this.persistScopedSettings("project",t,s,i)})}updateProjectSettings(e,t){this.assertProjectTrustedForWrite();const s=structuredClone(this.projectSettings);t(s),this.markProjectModified(e),this.saveProjectSettings(s)}async flush(){await this.writeQueue}drainErrors(){const e=[...this.errors];return this.errors=[],e}getLastChangelogVersion(){return this.settings.lastChangelogVersion}setLastChangelogVersion(e){this.globalSettings.lastChangelogVersion=e,this.markModified("lastChangelogVersion"),this.save()}getExtensionChangelogVersion(e){return this.settings.extensionChangelogVersions?.[e]}setExtensionChangelogVersion(e,t){this.globalSettings.extensionChangelogVersions={...this.globalSettings.extensionChangelogVersions??{},[e]:t},this.markModified("extensionChangelogVersions",e),this.save()}getSessionDir(){const e=this.settings.sessionDir;return e&&x(e)}getDefaultProvider(){return this.settings.defaultProvider}getDefaultModel(){return this.settings.defaultModel}setDefaultProvider(e){this.globalSettings.defaultProvider=e,this.markModified("defaultProvider"),this.save()}setDefaultModel(e){this.globalSettings.defaultModel=e,this.markModified("defaultModel"),this.save()}setDefaultModelAndProvider(e,t){this.globalSettings.defaultProvider=e,this.globalSettings.defaultModel=t,this.markModified("defaultProvider"),this.markModified("defaultModel"),this.save()}getSteeringMode(){return this.settings.steeringMode||l.steeringMode}setSteeringMode(e){this.globalSettings.steeringMode=e,this.markModified("steeringMode"),this.save()}getFollowUpMode(){return this.settings.followUpMode||l.followUpMode}setFollowUpMode(e){this.globalSettings.followUpMode=e,this.markModified("followUpMode"),this.save()}getThemeSetting(){const e=this.settings.theme;if(typeof e=="string")return e}getTheme(){const e=this.getThemeSetting();return e?.includes("/")?void 0:e}setTheme(e){this.globalSettings.theme=e,this.markModified("theme"),this.save()}getDefaultThinkingLevel(){return this.settings.defaultThinkingLevel}setDefaultThinkingLevel(e){this.globalSettings.defaultThinkingLevel=e,this.markModified("defaultThinkingLevel"),this.save()}getModelThinkingLevel(e,t){return this.settings.modelThinkingLevels?.[`${e}/${t}`]}getAllModelThinkingLevels(){return{...this.settings.modelThinkingLevels??{}}}setModelThinkingLevel(e,t,s){this.globalSettings.modelThinkingLevels||(this.globalSettings.modelThinkingLevels={}),this.globalSettings.modelThinkingLevels[`${e}/${t}`]=s,this.markModified("modelThinkingLevels"),this.save()}removeModelThinkingLevel(e,t){this.globalSettings.modelThinkingLevels&&(delete this.globalSettings.modelThinkingLevels[`${e}/${t}`],Object.keys(this.globalSettings.modelThinkingLevels).length===0&&delete this.globalSettings.modelThinkingLevels,this.markModified("modelThinkingLevels"),this.save())}getTransport(){return this.settings.transport??l.transport}setTransport(e){this.globalSettings.transport=e,this.markModified("transport"),this.save()}getSessionShareDestination(){const e=this.settings.sessionShareDestination;return e==="gist"||e==="radius"?e:l.sessionShareDestination}setSessionShareDestination(e){this.globalSettings.sessionShareDestination=e,this.markModified("sessionShareDestination"),this.save()}getCompactionEnabled(){return this.settings.compaction?.enabled??l.compaction.enabled}setCompactionEnabled(e){this.globalSettings.compaction||(this.globalSettings.compaction={}),this.globalSettings.compaction.enabled=e,this.markModified("compaction","enabled"),this.save()}getCompactionTokenSetting(e,t){const s=this.settings.compaction,i=s?.[e];if(i!==void 0&&(typeof i!="number"||!Number.isSafeInteger(i)||i<0))throw new Error(`Invalid compaction.${e} setting: ${String(i)}. Expected a non-negative safe integer.`);const o=t?`${t.provider}/${t.id}`:void 0,n=o!==void 0?s?.modelOverrides?.[o]:void 0;if(n!==void 0&&!y(n))throw new Error(`Invalid compaction.modelOverrides["${o}"] setting: ${String(n)}. Expected an object.`);const a=n?.[e];if(a!==void 0&&(typeof a!="number"||!Number.isSafeInteger(a)||a<0))throw new Error(`Invalid compaction.modelOverrides["${o}"].${e} setting: ${String(a)}. Expected a non-negative safe integer.`);return a??i??z[e]}getCompactionReserveTokens(e){return this.getCompactionTokenSetting("reserveTokens",e)}getCompactionKeepRecentTokens(e){return this.getCompactionTokenSetting("keepRecentTokens",e)}getCompactionSettings(e){return{enabled:this.getCompactionEnabled(),reserveTokens:this.getCompactionReserveTokens(e),keepRecentTokens:this.getCompactionKeepRecentTokens(e),maxContextTokens:this.getCompactionMaxContextTokens(e),pruneToolOutputs:this.getCompactionPruneToolOutputs()}}getCompactionMaxContextTokens(e){return this.getCompactionTokenSetting("maxContextTokens",e)}getCompactionPruneToolOutputs(){const e=this.settings.compaction?.pruneToolOutputs;if(e!==void 0&&typeof e!="boolean")throw new Error(`Invalid compaction.pruneToolOutputs setting: ${String(e)}. Expected a boolean.`);return e??!0}getCompactionSummaryModel(){const e=this.settings.compaction?.summaryModel;if(e===void 0||e==="")return;const t=typeof e=="string"?e.indexOf("/"):-1;if(typeof e!="string"||t<=0||t===e.length-1)throw new Error(`Invalid compaction.summaryModel setting: ${String(e)}. Expected "provider/modelId".`);return{provider:e.slice(0,t),modelId:e.slice(t+1)}}getBranchSummarySettings(){return{reserveTokens:this.settings.branchSummary?.reserveTokens??l.branchSummary.reserveTokens,skipPrompt:this.settings.branchSummary?.skipPrompt??l.branchSummary.skipPrompt}}getBranchSummarySkipPrompt(){return this.settings.branchSummary?.skipPrompt??l.branchSummary.skipPrompt}getRetryEnabled(){return this.settings.retry?.enabled??l.retry.enabled}setRetryEnabled(e){this.globalSettings.retry||(this.globalSettings.retry={}),this.globalSettings.retry.enabled=e,this.markModified("retry","enabled"),this.save()}getRetrySettings(){return{enabled:this.getRetryEnabled(),maxRetries:this.settings.retry?.maxRetries??J,baseDelayMs:this.settings.retry?.baseDelayMs??2e3,maxAgentDelayMs:this.settings.retry?.maxAgentDelayMs??N}}getMaxOutputTokens(){const e=this.settings.maxOutputTokens;if(e===void 0)return Q;if(typeof e!="number"||!Number.isSafeInteger(e)||e<0)throw new Error(`Invalid maxOutputTokens setting: ${String(e)}. Expected a non-negative safe integer.`);return e}getOutputTokenLimit(e){const t=this.getMaxOutputTokens();return t>0&&(e<=0||e>t)?t:e}getStallWatchdogMs(){const e=F(process.env.DAL_STALL_WATCHDOG_MS);return e!==void 0?e:k(this.settings.stallWatchdogMs,"stallWatchdogMs")??K}getHttpIdleTimeoutMs(){return k(this.settings.httpIdleTimeoutMs,"httpIdleTimeoutMs")??B}getFirstTokenTimeoutMs(){return k(this.settings.firstTokenTimeoutMs,"firstTokenTimeoutMs")??H}setHttpIdleTimeoutMs(e){if(!Number.isFinite(e)||e<0)throw new Error(`Invalid httpIdleTimeoutMs setting: ${String(e)}`);this.globalSettings.httpIdleTimeoutMs=Math.floor(e),this.markModified("httpIdleTimeoutMs"),this.save()}getCacheWarmingMode(){const e=this.globalSettings.cacheWarming;return e!==void 0&&Y.includes(e)?e:l.cacheWarming}setCacheWarmingMode(e){this.globalSettings.cacheWarming=e,this.markModified("cacheWarming"),this.save()}getProviderRetrySettings(){return{timeoutMs:this.settings.retry?.provider?.timeoutMs,maxRetries:this.settings.retry?.provider?.maxRetries,maxRetryDelayMs:this.settings.retry?.provider?.maxRetryDelayMs??l.retry.provider.maxRetryDelayMs}}getWebSocketConnectTimeoutMs(){return k(this.settings.websocketConnectTimeoutMs,"websocketConnectTimeoutMs")}getHideThinkingBlock(){return this.settings.hideThinkingBlock??!0}getShowCacheMissNotices(){return this.settings.showCacheMissNotices??l.showCacheMissNotices}getExternalEditorCommand(){const e=this.settings.externalEditor;if(typeof e=="string"&&e.trim()!=="")return e;const t=process.env.VISUAL||process.env.EDITOR;return t||(process.platform==="win32"?"notepad":"nano")}setHideThinkingBlock(e){this.globalSettings.hideThinkingBlock=e,this.markModified("hideThinkingBlock"),this.save()}setShowCacheMissNotices(e){this.globalSettings.showCacheMissNotices=e,this.markModified("showCacheMissNotices"),this.save()}getShellPath(){const e=this.settings.shellPath;return e&&x(e)}setShellPath(e){this.globalSettings.shellPath=e,this.markModified("shellPath"),this.save()}getQuietStartup(){const e=this.settings.quietStartup;return e===!1?!1:e==="header"?e:!0}setQuietStartup(e){this.globalSettings.quietStartup=e,this.markModified("quietStartup"),this.save()}getDefaultProjectTrust(){const e=this.globalSettings.defaultProjectTrust;return e==="always"||e==="never"?e:l.defaultProjectTrust}setDefaultProjectTrust(e){this.globalSettings.defaultProjectTrust=e,this.markModified("defaultProjectTrust"),this.save()}getShellCommandPrefix(){return this.settings.shellCommandPrefix}getShellEnvironmentPolicy(){const e=this.globalSettings.shellEnvironment??{},t=[...e.exclude??[],...this.projectSettings.shellEnvironment?.exclude??[]];return{...e.inherit!==void 0?{inherit:e.inherit}:{},...t.length>0?{exclude:t}:{},...e.include!==void 0?{include:[...e.include]}:{},...e.set!==void 0?{set:{...e.set}}:{}}}getPermissionRuleSources(){return{...this.globalSettings.permissions?{user:structuredClone(this.globalSettings.permissions)}:{},...this.projectSettings.permissions?{project:structuredClone(this.projectSettings.permissions)}:{}}}getSandboxSettingsSources(){return{...this.globalSettings.sandbox?{global:structuredClone(this.globalSettings.sandbox)}:{},...this.projectSettings.sandbox?{project:structuredClone(this.projectSettings.sandbox)}:{}}}setShellCommandPrefix(e){this.globalSettings.shellCommandPrefix=e,this.markModified("shellCommandPrefix"),this.save()}getNpmCommand(){return this.settings.npmCommand?[...this.settings.npmCommand]:void 0}setNpmCommand(e){this.globalSettings.npmCommand=e?[...e]:void 0,this.markModified("npmCommand"),this.save()}getCollapseChangelog(){return this.settings.collapseChangelog??!0}setCollapseChangelog(e){this.globalSettings.collapseChangelog=e,this.markModified("collapseChangelog"),this.save()}getEnableInstallTelemetry(){return this.settings.enableInstallTelemetry??l.enableInstallTelemetry}setEnableInstallTelemetry(e){this.globalSettings.enableInstallTelemetry=e,this.markModified("enableInstallTelemetry"),this.save()}getOrCreateDeviceId(){return this.globalSettings.deviceId||(this.globalSettings.deviceId=R(),this.markModified("deviceId"),this.save()),this.globalSettings.deviceId}getPackages(){return[...this.settings.packages??[]]}setPackages(e){this.globalSettings.packages=e,this.markModified("packages"),this.save()}setProjectPackages(e){this.updateProjectSettings("packages",t=>{t.packages=e})}getExtensionPaths(){return[...this.settings.extensions??[]]}setExtensionPaths(e){this.globalSettings.extensions=e,this.markModified("extensions"),this.save()}setProjectExtensionPaths(e){this.updateProjectSettings("extensions",t=>{t.extensions=e})}getSkillPaths(){return[...this.settings.skills??[]]}setSkillPaths(e){this.globalSettings.skills=e,this.markModified("skills"),this.save()}setProjectSkillPaths(e){this.updateProjectSettings("skills",t=>{t.skills=e})}getPromptTemplatePaths(){return[...this.settings.prompts??[]]}setPromptTemplatePaths(e){this.globalSettings.prompts=e,this.markModified("prompts"),this.save()}setProjectPromptTemplatePaths(e){this.updateProjectSettings("prompts",t=>{t.prompts=e})}getThemePaths(){return[...this.settings.themes??[]]}setThemePaths(e){this.globalSettings.themes=e,this.markModified("themes"),this.save()}setProjectThemePaths(e){this.updateProjectSettings("themes",t=>{t.themes=e})}getEnableSkillCommands(){return this.settings.enableSkillCommands??l.enableSkillCommands}setEnableSkillCommands(e){this.globalSettings.enableSkillCommands=e,this.markModified("enableSkillCommands"),this.save()}getFactoryEnabled(){return this.settings.factoryEnabled??!0}setFactoryEnabled(e){this.globalSettings.factoryEnabled=e,this.markModified("factoryEnabled"),this.save()}getThinkingBudgets(){return this.settings.thinkingBudgets}getTerminalCapabilityOverrides(){const e=this.settings.terminal,t=e?.images;return{...t==="kitty"||t==="iterm2"?{images:t}:t===!1?{images:null}:{},...typeof e?.trueColor=="boolean"?{trueColor:e.trueColor}:{},...typeof e?.hyperlinks=="boolean"?{hyperlinks:e.hyperlinks}:{}}}getShowImages(){return this.settings.terminal?.showImages??l.terminal.showImages}setShowImages(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.showImages=e,this.markModified("terminal","showImages"),this.save()}getImageWidthCells(){const e=this.settings.terminal?.imageWidthCells;return typeof e!="number"||!Number.isFinite(e)?l.terminal.imageWidthCells:Math.max(1,Math.floor(e))}setImageWidthCells(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.imageWidthCells=Math.max(1,Math.floor(e)),this.markModified("terminal","imageWidthCells"),this.save()}getClearOnShrink(){return this.settings.terminal?.clearOnShrink!==void 0?this.settings.terminal.clearOnShrink:process.env.PI_CLEAR_ON_SHRINK==="1"?!0:l.terminal.clearOnShrink}setClearOnShrink(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.clearOnShrink=e,this.markModified("terminal","clearOnShrink"),this.save()}getShowTerminalProgress(){return this.settings.terminal?.showTerminalProgress??l.terminal.showTerminalProgress}setShowTerminalProgress(e){this.globalSettings.terminal||(this.globalSettings.terminal={}),this.globalSettings.terminal.showTerminalProgress=e,this.markModified("terminal","showTerminalProgress"),this.save()}getTuiMode(){return this.settings.tuiMode==="fullscreen"?"fullscreen":(this.settings.tuiMode==="regular"||this.settings.tuiMode,"regular")}setTuiMode(e){this.globalSettings.tuiMode=e,this.markModified("tuiMode"),this.save()}getFullscreenExitOutput(){return this.settings.fullscreenExitOutput==="resume-hint"?"resume-hint":l.fullscreenExitOutput}setFullscreenExitOutput(e){this.globalSettings.fullscreenExitOutput=e,this.markModified("fullscreenExitOutput"),this.save()}getFullscreenScrollbar(){const e=this.settings.fullscreenScrollbar;return e==="always"||e==="hidden"?e:l.fullscreenScrollbar}setFullscreenScrollbar(e){this.globalSettings.fullscreenScrollbar=e,this.markModified("fullscreenScrollbar"),this.save()}getFullscreenCopyOnSelect(){return this.settings.fullscreenCopyOnSelect??l.fullscreenCopyOnSelect}setFullscreenCopyOnSelect(e){this.globalSettings.fullscreenCopyOnSelect=e,this.markModified("fullscreenCopyOnSelect"),this.save()}getFullscreenWheelScrollLines(){const e=this.settings.fullscreenWheelScrollLines;return typeof e=="number"&&Number.isFinite(e)?Math.max(1,Math.min(100,Math.floor(e))):l.fullscreenWheelScrollLines}setFullscreenWheelScrollLines(e){this.globalSettings.fullscreenWheelScrollLines=e==="auto"?e:Math.max(1,Math.min(100,Math.floor(e))),this.markModified("fullscreenWheelScrollLines"),this.save()}getImageAutoResize(){return this.settings.images?.autoResize??l.images.autoResize}setImageAutoResize(e){this.globalSettings.images||(this.globalSettings.images={}),this.globalSettings.images.autoResize=e,this.markModified("images","autoResize"),this.save()}getBlockImages(){return this.settings.images?.blockImages??l.images.blockImages}setBlockImages(e){this.globalSettings.images||(this.globalSettings.images={}),this.globalSettings.images.blockImages=e,this.markModified("images","blockImages"),this.save()}getEnabledModels(){return this.settings.enabledModels}getDefaultTools(){const e=this.settings.defaultTools;if(e!==void 0)return se(Array.isArray(e)?e.filter(t=>typeof t=="string"):[])}setEnabledModels(e){this.globalSettings.enabledModels=e,this.markModified("enabledModels"),this.save()}getDoubleEscapeAction(){return this.settings.doubleEscapeAction??l.doubleEscapeAction}setDoubleEscapeAction(e){this.globalSettings.doubleEscapeAction=e,this.markModified("doubleEscapeAction"),this.save()}getTreeFilterMode(){const e=this.settings.treeFilterMode;return e&&["default","no-tools","user-only","labeled-only","all"].includes(e)?e:l.treeFilterMode}setTreeFilterMode(e){this.globalSettings.treeFilterMode=e,this.markModified("treeFilterMode"),this.save()}getShowHardwareCursor(){return this.settings.showHardwareCursor??process.env.PI_HARDWARE_CURSOR==="1"}setShowHardwareCursor(e){this.globalSettings.showHardwareCursor=e,this.markModified("showHardwareCursor"),this.save()}getEditorPaddingX(){return this.settings.editorPaddingX??1}setEditorPaddingX(e){this.globalSettings.editorPaddingX=Math.max(0,Math.min(3,Math.floor(e))),this.markModified("editorPaddingX"),this.save()}getOutputPad(){return this.settings.outputPad===1?1:0}setOutputPad(e){this.globalSettings.outputPad=e,this.markModified("outputPad"),this.save()}getAutocompleteMaxVisible(){return this.settings.autocompleteMaxVisible??l.autocompleteMaxVisible}setAutocompleteMaxVisible(e){this.globalSettings.autocompleteMaxVisible=Math.max(3,Math.min(20,Math.floor(e))),this.markModified("autocompleteMaxVisible"),this.save()}getCodeBlockIndent(){return this.settings.markdown?.codeBlockIndent??l.markdown.codeBlockIndent}getMermaidRenderingMode(){const e=this.settings.markdown?.mermaid;return e==="off"||e==="final"?e:l.markdown.mermaid}setMermaidRenderingMode(e){this.globalSettings.markdown??={},this.globalSettings.markdown.mermaid=e,this.markModified("markdown","mermaid"),this.save()}getWarnings(){return{...this.settings.warnings??{}}}setWarnings(e){this.globalSettings.warnings={...e},this.markModified("warnings"),this.save()}}export{Y as CACHE_WARMING_MODES,X as DEFAULT_COMPACTION_MAX_CONTEXT_TOKENS,Q as DEFAULT_MAX_OUTPUT_TOKENS,J as DEFAULT_MAX_RETRIES,Z as DEFAULT_TOOL_NAMES,re as FileSettingsStorage,oe as InMemorySettingsStorage,M as SETTINGS_FORMAT_VERSION,g as SettingsManager,ee as applyToolModifiers,ke as getToolListError,b as isToolModifier};
|
|
@@ -75,10 +75,11 @@ declare const PackageSourceSchema: Type.TUnion<[Type.TString, Type.TObject<{
|
|
|
75
75
|
export declare const SettingsSchema: Type.TObject<{
|
|
76
76
|
$schema: Type.TOptional<Type.TString>;
|
|
77
77
|
lastChangelogVersion: Type.TOptional<Type.TString>;
|
|
78
|
+
extensionChangelogVersions: Type.TOptional<Type.TRecord<"^.*$", Type.TString>>;
|
|
78
79
|
defaultProvider: Type.TOptional<Type.TString>;
|
|
79
80
|
defaultModel: Type.TOptional<Type.TString>;
|
|
80
|
-
defaultThinkingLevel: Type.TOptional<Type.
|
|
81
|
-
modelThinkingLevels: Type.TOptional<Type.TRecord<"^.*$", Type.
|
|
81
|
+
defaultThinkingLevel: Type.TOptional<Type.TUnsafe<"off" | "high" | "low" | "max" | "medium" | "minimal" | "xhigh">>;
|
|
82
|
+
modelThinkingLevels: Type.TOptional<Type.TRecord<"^.*$", Type.TUnsafe<"off" | "high" | "low" | "max" | "medium" | "minimal" | "xhigh">>>;
|
|
82
83
|
transport: Type.TOptional<Type.TUnion<[Type.TLiteral<"auto">, Type.TLiteral<"sse">, Type.TLiteral<"websocket">, Type.TLiteral<"websocket-cached">]>>;
|
|
83
84
|
sessionShareDestination: Type.TOptional<Type.TUnion<[Type.TLiteral<"auto">, Type.TLiteral<"gist">, Type.TLiteral<"radius">]>>;
|
|
84
85
|
steeringMode: Type.TOptional<Type.TUnion<[Type.TLiteral<"all">, Type.TLiteral<"one-at-a-time">]>>;
|
|
@@ -117,6 +118,7 @@ export declare const SettingsSchema: Type.TObject<{
|
|
|
117
118
|
defaultProjectTrust: Type.TOptional<Type.TUnion<[Type.TLiteral<"ask">, Type.TLiteral<"always">, Type.TLiteral<"never">]>>;
|
|
118
119
|
shellCommandPrefix: Type.TOptional<Type.TString>;
|
|
119
120
|
npmCommand: Type.TOptional<Type.TArray<Type.TString>>;
|
|
121
|
+
selfUpdateCommand: Type.TOptional<Type.TArray<Type.TString>>;
|
|
120
122
|
collapseChangelog: Type.TOptional<Type.TBoolean>;
|
|
121
123
|
enableInstallTelemetry: Type.TOptional<Type.TBoolean>;
|
|
122
124
|
enableAnalytics: Type.TOptional<Type.TBoolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var p=Object.defineProperty;var o=(i,c)=>p(i,"name",{value:c,configurable:!0});import{ModelThinkingLevelSchema as r}from"@earendil-works/pi-ai/providers/model-schema";import{Type as e}from"typebox";import{SETTINGS_DEFAULTS as t}from"./settings-defaults.js";function n(i={}){return e.Integer({minimum:0,maximum:Number.MAX_SAFE_INTEGER,...i})}o(n,"nonNegativeSafeInteger");function a(i){return e.Union([e.Number({minimum:0}),e.Literal("disabled")],i)}o(a,"timeoutSetting");const m=e.Object({reserveTokens:e.Optional(n()),keepRecentTokens:e.Optional(n())}),u=e.Object({enabled:e.Optional(e.Boolean({default:t.compaction.enabled})),reserveTokens:e.Optional(n({default:t.compaction.reserveTokens})),keepRecentTokens:e.Optional(n({default:t.compaction.keepRecentTokens})),modelOverrides:e.Optional(e.Record(e.String(),m,{description:'Per-model overrides keyed by exact "provider/modelId" strings.'}))}),g=e.Object({reserveTokens:e.Optional(e.Number({description:"Tokens reserved for the prompt and LLM response.",default:t.branchSummary.reserveTokens})),skipPrompt:e.Optional(e.Boolean({description:'When true, skips the "Summarize branch?" prompt and defaults to no summary.',default:t.branchSummary.skipPrompt}))}),h=e.Object({timeoutMs:e.Optional(e.Number({description:"SDK or provider request timeout in milliseconds."})),maxRetries:e.Optional(e.Number({description:"SDK or provider retry attempts."})),maxRetryDelayMs:e.Optional(e.Number({description:"Maximum server-requested delay before failing.",default:t.retry.provider.maxRetryDelayMs}))}),f=e.Object({enabled:e.Optional(e.Boolean({default:t.retry.enabled})),maxRetries:e.Optional(e.Number({default:t.retry.maxRetries})),baseDelayMs:e.Optional(e.Number({description:"Exponential backoff base delay in milliseconds: 2s, 4s, 8s.",default:t.retry.baseDelayMs})),maxAgentDelayMs:e.Optional(e.Number({default:t.retry.maxAgentDelayMs})),provider:e.Optional(h),maxDelayMs:e.Optional(e.Number({description:"Legacy retry delay setting. Use provider.maxRetryDelayMs instead.",deprecated:!0}))}),O=e.Object({showImages:e.Optional(e.Boolean({description:"Show images when the terminal supports them.",default:t.terminal.showImages})),imageWidthCells:e.Optional(e.Number({description:"Preferred inline image width in terminal cells.",default:t.terminal.imageWidthCells})),clearOnShrink:e.Optional(e.Boolean({description:"Clear empty rows when content shrinks.",default:t.terminal.clearOnShrink})),showTerminalProgress:e.Optional(e.Boolean({description:"Show OSC 9;4 terminal progress indicators.",default:t.terminal.showTerminalProgress})),hyperlinks:e.Optional(e.Union([e.Boolean(),e.Literal("auto")])),images:e.Optional(e.Union([e.Literal("kitty"),e.Literal("iterm2"),e.Literal("auto"),e.Literal(!1)])),trueColor:e.Optional(e.Union([e.Boolean(),e.Literal("auto")]))}),b=e.Object({autoResize:e.Optional(e.Boolean({description:"Resize images to 2000x2000 maximum for better model compatibility.",default:t.images.autoResize})),blockImages:e.Optional(e.Boolean({description:"When true, prevents all images from being sent to LLM providers.",default:t.images.blockImages}))});function l(i){return e.Object({minimal:e.Optional(e.Number()),low:e.Optional(e.Number()),medium:e.Optional(e.Number()),high:e.Optional(e.Number())},i)}o(l,"thinkingBudgetsSettings");const U=l(),S=e.Object({codeBlockIndent:e.Optional(e.String({default:t.markdown.codeBlockIndent})),mermaid:e.Optional(e.Union([e.Literal("off"),e.Literal("final"),e.Literal("streaming")],{default:t.markdown.mermaid}))}),y=e.Object({anthropicExtraUsage:e.Optional(e.Boolean({default:t.warnings.anthropicExtraUsage}))});function s(i){return e.Union([e.Literal("on"),e.Literal("only")],i)}o(s,"codemodeMode");const B=s(),k=e.Object({mode:e.Optional(s({description:'How codemode presents tools. "on" keeps direct tools declared and annotates tools callable from scripts; codemode lists only tools without direct exposure. "only" lists every script-callable tool in codemode and does not declare active direct tools.',default:t.codemode.mode})),inlineBudget:e.Optional(e.Number({minimum:0,description:"Estimated tokens available for inline codemode tool declarations.",default:t.codemode.inlineBudget}))}),L=e.Union([e.String({description:"Load all resources from the package."}),e.Object({source:e.String(),autoload:e.Optional(e.Boolean({description:"When false, start empty and only apply explicit resource patterns."})),extensions:e.Optional(e.Array(e.String())),skills:e.Optional(e.Array(e.String())),prompts:e.Optional(e.Array(e.String())),themes:e.Optional(e.Array(e.String()))})],{description:"Package source for npm or git packages. Use the string form to load all resources or the object form to filter resources."}),d=e.Array(e.String()),w=e.Union([d,e.Object({enableSkillCommands:e.Optional(e.Boolean()),customDirectories:e.Optional(d)},{deprecated:!0})],{description:"Local skill file paths or directories."}),C=e.Object({$schema:e.Optional(e.String({description:"JSON Schema reference."})),lastChangelogVersion:e.Optional(e.String()),defaultProvider:e.Optional(e.String()),defaultModel:e.Optional(e.String()),defaultThinkingLevel:e.Optional(r),modelThinkingLevels:e.Optional(e.Record(e.String(),r,{description:'Per-model default thinking level overrides keyed by "provider/modelId".'})),transport:e.Optional(e.Union([e.Literal("auto"),e.Literal("sse"),e.Literal("websocket"),e.Literal("websocket-cached")],{default:t.transport})),sessionShareDestination:e.Optional(e.Union([e.Literal("auto"),e.Literal("gist"),e.Literal("radius")],{description:'Destination used by /share. "auto" uses Radius when authenticated and otherwise creates a GitHub gist.',default:t.sessionShareDestination})),steeringMode:e.Optional(e.Union([e.Literal("all"),e.Literal("one-at-a-time")],{default:t.steeringMode})),followUpMode:e.Optional(e.Union([e.Literal("all"),e.Literal("one-at-a-time")],{default:t.followUpMode})),theme:e.Optional(e.String()),compaction:e.Optional(u),branchSummary:e.Optional(g),retry:e.Optional(f),hideThinkingBlock:e.Optional(e.Boolean({default:t.hideThinkingBlock})),showCacheMissNotices:e.Optional(e.Boolean({description:"Show cache cost and provider recovery notices.",default:t.showCacheMissNotices})),externalEditor:e.Optional(e.String({description:"Command for Ctrl+G external editor; takes precedence over VISUAL and EDITOR."})),shellPath:e.Optional(e.String({description:"Custom shell path, for example for Cygwin on Windows, with support for leading ~ expansion."})),quietStartup:e.Optional(e.Union([e.Boolean(),e.Literal("header")],{description:'When true, hide all startup output. When "header", keep only the startup header.',default:t.quietStartup})),defaultProjectTrust:e.Optional(e.Union([e.Literal("ask"),e.Literal("always"),e.Literal("never")],{description:"Global setting only.",default:t.defaultProjectTrust})),shellCommandPrefix:e.Optional(e.String({description:"Prefix prepended to every bash command, for example to enable shell aliases."})),npmCommand:e.Optional(e.Array(e.String(),{description:'Command used for npm package lookup and installation, in argv form such as ["mise", "exec", "node@20", "--", "npm"].'})),collapseChangelog:e.Optional(e.Boolean({description:"Show the condensed changelog after update; use /changelog for the full changelog.",default:t.collapseChangelog})),enableInstallTelemetry:e.Optional(e.Boolean({description:"Send an anonymous version and update ping after changelog-detected updates.",default:t.enableInstallTelemetry})),enableAnalytics:e.Optional(e.Boolean({description:"Opt in to analytics data sharing.",default:t.enableAnalytics})),trackingId:e.Optional(e.String({description:"Analytics tracking identifier, generated when analytics is enabled."})),packages:e.Optional(e.Array(L,{description:"npm or git package sources, as strings or objects with resource filtering."})),extensions:e.Optional(e.Array(e.String(),{description:"Local extension file paths or directories."})),deviceId:e.Optional(e.String({description:"Stable installation UUID, generated when authentication first needs it. Global only."})),skills:e.Optional(w),prompts:e.Optional(e.Array(e.String(),{description:"Local prompt template file paths or directories."})),themes:e.Optional(e.Array(e.String(),{description:"Local theme file paths or directories."})),enableSkillCommands:e.Optional(e.Boolean({description:"Register skills as /skill:name commands.",default:t.enableSkillCommands})),terminal:e.Optional(O),images:e.Optional(b),enabledModels:e.Optional(e.Array(e.String(),{description:"Model patterns for cycling, in the same format as the --models CLI flag."})),defaultTools:e.Optional(e.Array(e.String(),{description:"Initial tool selection. Plain names replace the inherited selection; +name and -name entries add or remove tools."})),doubleEscapeAction:e.Optional(e.Union([e.Literal("fork"),e.Literal("tree"),e.Literal("none")],{description:"Action for double-escape with an empty editor.",default:t.doubleEscapeAction})),treeFilterMode:e.Optional(e.Union([e.Literal("default"),e.Literal("no-tools"),e.Literal("user-only"),e.Literal("labeled-only"),e.Literal("all")],{description:"Default filter when opening /tree.",default:t.treeFilterMode})),thinkingBudgets:e.Optional(l({description:"Custom token budgets for thinking levels."})),editorPaddingX:e.Optional(e.Number({description:"Horizontal padding for the input editor.",default:t.editorPaddingX})),outputPad:e.Optional(e.Union([e.Literal(0),e.Literal(1)],{description:"Horizontal padding for transcript content.",default:t.outputPad})),autocompleteMaxVisible:e.Optional(e.Number({description:"Maximum visible items in the autocomplete dropdown.",default:t.autocompleteMaxVisible})),showHardwareCursor:e.Optional(e.Boolean({description:"Show the terminal cursor while still positioning it for IME."})),markdown:e.Optional(S),warnings:e.Optional(y),codemode:e.Optional(k),sessionDir:e.Optional(e.String({description:"Custom session storage directory, in the same format as the --session-dir CLI flag."})),httpProxy:e.Optional(e.String({description:"Proxy URL applied as HTTP_PROXY and HTTPS_PROXY for Pi-managed HTTP clients."})),httpIdleTimeoutMs:e.Optional(a({description:'HTTP header or body idle timeout in milliseconds; 0 or "disabled" disables it.'})),stallWatchdogMs:e.Optional(a({description:'Milliseconds a run may go without model output, tool output or a heartbeat before it reports where it is waiting (default 60000); 0 or "disabled" turns the report off.'})),firstTokenTimeoutMs:e.Optional(a({description:'Model requests with no output within this many milliseconds are cancelled and retried; 0 or "disabled" disables it. Default 45000.'})),cacheWarming:e.Optional(e.Union([e.Literal("off"),e.Literal("streaming"),e.Literal("idle")],{description:'Cache-warming profile. "idle" also warms between agent runs. Global only because each refresh costs money.',default:t.cacheWarming})),websocketConnectTimeoutMs:e.Optional(a({description:'WebSocket connect or open handshake timeout in milliseconds; 0 or "disabled" disables it.'})),tuiMode:e.Optional(e.Union([e.Literal("regular"),e.Literal("fullscreen")],{default:t.tuiMode})),fullscreenExitOutput:e.Optional(e.Union([e.Literal("transcript"),e.Literal("resume-hint")],{description:"No effect in regular TUI mode.",default:t.fullscreenExitOutput})),fullscreenScrollbar:e.Optional(e.Union([e.Literal("auto"),e.Literal("always"),e.Literal("hidden")],{description:"No effect in regular TUI mode.",default:t.fullscreenScrollbar})),fullscreenCopyOnSelect:e.Optional(e.Boolean({description:"No effect in regular TUI mode.",default:t.fullscreenCopyOnSelect})),fullscreenWheelScrollLines:e.Optional(e.Union([e.Number(),e.Literal("auto")],{description:"Lines scrolled per wheel event in fullscreen mode; numeric values are clamped from 1 to 100.",default:t.fullscreenWheelScrollLines})),queueMode:e.Optional(e.Union([e.Literal("all"),e.Literal("one-at-a-time")],{description:"Legacy setting migrated to steeringMode.",deprecated:!0})),websockets:e.Optional(e.Boolean({description:"Legacy setting migrated to transport.",deprecated:!0}))},{additionalProperties:!0});export{C as SettingsSchema};
|
|
1
|
+
var p=Object.defineProperty;var o=(i,c)=>p(i,"name",{value:c,configurable:!0});import{Type as e}from"typebox";import{ModelThinkingLevelSchema as r}from"./pi-ai-schemas.js";import{SETTINGS_DEFAULTS as t}from"./settings-defaults.js";function n(i={}){return e.Integer({minimum:0,maximum:Number.MAX_SAFE_INTEGER,...i})}o(n,"nonNegativeSafeInteger");function a(i){return e.Union([e.Number({minimum:0}),e.Literal("disabled")],i)}o(a,"timeoutSetting");const m=e.Object({reserveTokens:e.Optional(n()),keepRecentTokens:e.Optional(n())}),u=e.Object({enabled:e.Optional(e.Boolean({default:t.compaction.enabled})),reserveTokens:e.Optional(n({default:t.compaction.reserveTokens})),keepRecentTokens:e.Optional(n({default:t.compaction.keepRecentTokens})),modelOverrides:e.Optional(e.Record(e.String(),m,{description:'Per-model overrides keyed by exact "provider/modelId" strings.'}))}),g=e.Object({reserveTokens:e.Optional(e.Number({description:"Tokens reserved for the prompt and LLM response.",default:t.branchSummary.reserveTokens})),skipPrompt:e.Optional(e.Boolean({description:'When true, skips the "Summarize branch?" prompt and defaults to no summary.',default:t.branchSummary.skipPrompt}))}),h=e.Object({timeoutMs:e.Optional(e.Number({description:"SDK or provider request timeout in milliseconds."})),maxRetries:e.Optional(e.Number({description:"SDK or provider retry attempts."})),maxRetryDelayMs:e.Optional(e.Number({description:"Maximum server-requested delay before failing.",default:t.retry.provider.maxRetryDelayMs}))}),f=e.Object({enabled:e.Optional(e.Boolean({default:t.retry.enabled})),maxRetries:e.Optional(e.Number({default:t.retry.maxRetries})),baseDelayMs:e.Optional(e.Number({description:"Exponential backoff base delay in milliseconds: 2s, 4s, 8s.",default:t.retry.baseDelayMs})),maxAgentDelayMs:e.Optional(e.Number({default:t.retry.maxAgentDelayMs})),provider:e.Optional(h),maxDelayMs:e.Optional(e.Number({description:"Legacy retry delay setting. Use provider.maxRetryDelayMs instead.",deprecated:!0}))}),O=e.Object({showImages:e.Optional(e.Boolean({description:"Show images when the terminal supports them.",default:t.terminal.showImages})),imageWidthCells:e.Optional(e.Number({description:"Preferred inline image width in terminal cells.",default:t.terminal.imageWidthCells})),clearOnShrink:e.Optional(e.Boolean({description:"Clear empty rows when content shrinks.",default:t.terminal.clearOnShrink})),showTerminalProgress:e.Optional(e.Boolean({description:"Show OSC 9;4 terminal progress indicators.",default:t.terminal.showTerminalProgress})),hyperlinks:e.Optional(e.Union([e.Boolean(),e.Literal("auto")])),images:e.Optional(e.Union([e.Literal("kitty"),e.Literal("iterm2"),e.Literal("auto"),e.Literal(!1)])),trueColor:e.Optional(e.Union([e.Boolean(),e.Literal("auto")]))}),S=e.Object({autoResize:e.Optional(e.Boolean({description:"Resize images to 2000x2000 maximum for better model compatibility.",default:t.images.autoResize})),blockImages:e.Optional(e.Boolean({description:"When true, prevents all images from being sent to LLM providers.",default:t.images.blockImages}))});function l(i){return e.Object({minimal:e.Optional(e.Number()),low:e.Optional(e.Number()),medium:e.Optional(e.Number()),high:e.Optional(e.Number())},i)}o(l,"thinkingBudgetsSettings");const U=l(),b=e.Object({codeBlockIndent:e.Optional(e.String({default:t.markdown.codeBlockIndent})),mermaid:e.Optional(e.Union([e.Literal("off"),e.Literal("final"),e.Literal("streaming")],{default:t.markdown.mermaid}))}),y=e.Object({anthropicExtraUsage:e.Optional(e.Boolean({default:t.warnings.anthropicExtraUsage}))});function s(i){return e.Union([e.Literal("on"),e.Literal("only")],i)}o(s,"codemodeMode");const C=s(),k=e.Object({mode:e.Optional(s({description:'How codemode presents tools. "on" keeps direct tools declared and annotates tools callable from scripts; codemode lists only tools without direct exposure. "only" lists every script-callable tool in codemode and does not declare active direct tools.',default:t.codemode.mode})),inlineBudget:e.Optional(e.Number({minimum:0,description:"Estimated tokens available for inline codemode tool declarations.",default:t.codemode.inlineBudget}))}),L=e.Union([e.String({description:"Load all resources from the package."}),e.Object({source:e.String(),autoload:e.Optional(e.Boolean({description:"When false, start empty and only apply explicit resource patterns."})),extensions:e.Optional(e.Array(e.String())),skills:e.Optional(e.Array(e.String())),prompts:e.Optional(e.Array(e.String())),themes:e.Optional(e.Array(e.String()))})],{description:"Package source for npm or git packages. Use the string form to load all resources or the object form to filter resources."}),d=e.Array(e.String()),w=e.Union([d,e.Object({enableSkillCommands:e.Optional(e.Boolean()),customDirectories:e.Optional(d)},{deprecated:!0})],{description:"Local skill file paths or directories."}),P=e.Object({$schema:e.Optional(e.String({description:"JSON Schema reference."})),lastChangelogVersion:e.Optional(e.String()),extensionChangelogVersions:e.Optional(e.Record(e.String(),e.String(),{description:"Last seen changelog version per extension package."})),defaultProvider:e.Optional(e.String()),defaultModel:e.Optional(e.String()),defaultThinkingLevel:e.Optional(r),modelThinkingLevels:e.Optional(e.Record(e.String(),r,{description:'Per-model default thinking level overrides keyed by "provider/modelId".'})),transport:e.Optional(e.Union([e.Literal("auto"),e.Literal("sse"),e.Literal("websocket"),e.Literal("websocket-cached")],{default:t.transport})),sessionShareDestination:e.Optional(e.Union([e.Literal("auto"),e.Literal("gist"),e.Literal("radius")],{description:'Destination used by /share. "auto" uses Radius when authenticated and otherwise creates a GitHub gist.',default:t.sessionShareDestination})),steeringMode:e.Optional(e.Union([e.Literal("all"),e.Literal("one-at-a-time")],{default:t.steeringMode})),followUpMode:e.Optional(e.Union([e.Literal("all"),e.Literal("one-at-a-time")],{default:t.followUpMode})),theme:e.Optional(e.String()),compaction:e.Optional(u),branchSummary:e.Optional(g),retry:e.Optional(f),hideThinkingBlock:e.Optional(e.Boolean({default:t.hideThinkingBlock})),showCacheMissNotices:e.Optional(e.Boolean({description:"Show cache cost and provider recovery notices.",default:t.showCacheMissNotices})),externalEditor:e.Optional(e.String({description:"Command for Ctrl+G external editor; takes precedence over VISUAL and EDITOR."})),shellPath:e.Optional(e.String({description:"Custom shell path, for example for Cygwin on Windows, with support for leading ~ expansion."})),quietStartup:e.Optional(e.Union([e.Boolean(),e.Literal("header")],{description:'When true, hide all startup output. When "header", keep only the startup header.',default:t.quietStartup})),defaultProjectTrust:e.Optional(e.Union([e.Literal("ask"),e.Literal("always"),e.Literal("never")],{description:"Global setting only.",default:t.defaultProjectTrust})),shellCommandPrefix:e.Optional(e.String({description:"Prefix prepended to every bash command, for example to enable shell aliases."})),npmCommand:e.Optional(e.Array(e.String(),{description:'Command used for npm package lookup and installation, in argv form such as ["mise", "exec", "node@20", "--", "npm"].'})),selfUpdateCommand:e.Optional(e.Array(e.String(),{minItems:1,description:'Command `pi update` runs to update Pi itself, in argv form such as ["mise", "use", "-g", "npm:{packageName}@{version}"]. Placeholders: {packageName}, {version}, {installSpec}. PI_SELF_UPDATE_COMMAND takes precedence. Global setting only.'})),collapseChangelog:e.Optional(e.Boolean({description:"Show the condensed changelog after update; use /changelog for the full changelog.",default:t.collapseChangelog})),enableInstallTelemetry:e.Optional(e.Boolean({description:"Send an anonymous version and update ping after changelog-detected updates.",default:t.enableInstallTelemetry})),enableAnalytics:e.Optional(e.Boolean({description:"Opt in to analytics data sharing.",default:t.enableAnalytics})),trackingId:e.Optional(e.String({description:"Analytics tracking identifier, generated when analytics is enabled."})),packages:e.Optional(e.Array(L,{description:"npm or git package sources, as strings or objects with resource filtering."})),extensions:e.Optional(e.Array(e.String(),{description:"Local extension file paths or directories."})),deviceId:e.Optional(e.String({description:"Stable installation UUID, generated when authentication first needs it. Global only."})),skills:e.Optional(w),prompts:e.Optional(e.Array(e.String(),{description:"Local prompt template file paths or directories."})),themes:e.Optional(e.Array(e.String(),{description:"Local theme file paths or directories."})),enableSkillCommands:e.Optional(e.Boolean({description:"Register skills as /skill:name commands.",default:t.enableSkillCommands})),terminal:e.Optional(O),images:e.Optional(S),enabledModels:e.Optional(e.Array(e.String(),{description:"Model patterns for cycling, in the same format as the --models CLI flag."})),defaultTools:e.Optional(e.Array(e.String(),{description:"Initial tool selection. Plain names replace the inherited selection; +name and -name entries add or remove tools."})),doubleEscapeAction:e.Optional(e.Union([e.Literal("fork"),e.Literal("tree"),e.Literal("none")],{description:"Action for double-escape with an empty editor.",default:t.doubleEscapeAction})),treeFilterMode:e.Optional(e.Union([e.Literal("default"),e.Literal("no-tools"),e.Literal("user-only"),e.Literal("labeled-only"),e.Literal("all")],{description:"Default filter when opening /tree.",default:t.treeFilterMode})),thinkingBudgets:e.Optional(l({description:"Custom token budgets for thinking levels."})),editorPaddingX:e.Optional(e.Number({description:"Horizontal padding for the input editor.",default:t.editorPaddingX})),outputPad:e.Optional(e.Union([e.Literal(0),e.Literal(1)],{description:"Horizontal padding for transcript content.",default:t.outputPad})),autocompleteMaxVisible:e.Optional(e.Number({description:"Maximum visible items in the autocomplete dropdown.",default:t.autocompleteMaxVisible})),showHardwareCursor:e.Optional(e.Boolean({description:"Show the terminal cursor while still positioning it for IME."})),markdown:e.Optional(b),warnings:e.Optional(y),codemode:e.Optional(k),sessionDir:e.Optional(e.String({description:"Custom session storage directory, in the same format as the --session-dir CLI flag."})),httpProxy:e.Optional(e.String({description:"Proxy URL applied as HTTP_PROXY and HTTPS_PROXY for Pi-managed HTTP clients."})),httpIdleTimeoutMs:e.Optional(a({description:'HTTP header or body idle timeout in milliseconds; 0 or "disabled" disables it.'})),stallWatchdogMs:e.Optional(a({description:'Milliseconds a run may go without model output, tool output or a heartbeat before it reports where it is waiting (default 60000); 0 or "disabled" turns the report off.'})),firstTokenTimeoutMs:e.Optional(a({description:'Model requests with no output within this many milliseconds are cancelled and retried; 0 or "disabled" disables it. Default 45000.'})),cacheWarming:e.Optional(e.Union([e.Literal("off"),e.Literal("streaming"),e.Literal("idle")],{description:'Cache-warming profile. "idle" also warms between agent runs. Global only because each refresh costs money.',default:t.cacheWarming})),websocketConnectTimeoutMs:e.Optional(a({description:'WebSocket connect or open handshake timeout in milliseconds; 0 or "disabled" disables it.'})),tuiMode:e.Optional(e.Union([e.Literal("regular"),e.Literal("fullscreen")],{default:t.tuiMode})),fullscreenExitOutput:e.Optional(e.Union([e.Literal("transcript"),e.Literal("resume-hint")],{description:"No effect in regular TUI mode.",default:t.fullscreenExitOutput})),fullscreenScrollbar:e.Optional(e.Union([e.Literal("auto"),e.Literal("always"),e.Literal("hidden")],{description:"No effect in regular TUI mode.",default:t.fullscreenScrollbar})),fullscreenCopyOnSelect:e.Optional(e.Boolean({description:"No effect in regular TUI mode.",default:t.fullscreenCopyOnSelect})),fullscreenWheelScrollLines:e.Optional(e.Union([e.Number(),e.Literal("auto")],{description:"Lines scrolled per wheel event in fullscreen mode; numeric values are clamped from 1 to 100.",default:t.fullscreenWheelScrollLines})),queueMode:e.Optional(e.Union([e.Literal("all"),e.Literal("one-at-a-time")],{description:"Legacy setting migrated to steeringMode.",deprecated:!0})),websockets:e.Optional(e.Boolean({description:"Legacy setting migrated to transport.",deprecated:!0}))},{additionalProperties:!0});export{P as SettingsSchema};
|
package/dist/core/skills.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var R=Object.defineProperty;var
|
|
1
|
+
var R=Object.defineProperty;var f=(t,s)=>R(t,"name",{value:s,configurable:!0});import{existsSync as F,readdirSync as T,readFileSync as N,statSync as I}from"fs";import C from"ignore";import{basename as x,dirname as G,join as S,relative as P,resolve as W,sep as K}from"path";import{CONFIG_DIR_NAME as _,getAgentDir as z}from"../config.js";import{parseFrontmatter as O}from"../utils/frontmatter.js";import{isPathWithin as M,resolvePath as $}from"../utils/paths.js";import{createSyntheticSourceInfo as D,getResourcePathKey as U}from"./source-info.js";const j=64,A=1024,X=[".gitignore",".ignore",".fdignore"];function E(t){return t.split(K).join("/")}f(E,"toPosixPath");function q(t,s){const n=t.trim();if(!n||n.startsWith("#")&&!n.startsWith("\\#"))return null;let e=t,l=!1;e.startsWith("!")?(l=!0,e=e.slice(1)):e.startsWith("\\!")&&(e=e.slice(1)),e.startsWith("/")&&(e=e.slice(1));const r=s?`${s}${e}`:e;return l?`!${r}`:r}f(q,"prefixIgnorePattern");function H(t,s,n){const e=P(n,s),l=e?`${E(e)}/`:"";for(const r of X){const c=S(s,r);if(F(c))try{const u=N(c,"utf-8").split(/\r?\n/).map(d=>q(d,l)).filter(d=>!!d);u.length>0&&t.add(u)}catch{}}}f(H,"addIgnoreRules");function B(t){const s=[];return t.length>j&&s.push(`name exceeds ${j} characters (${t.length})`),/^[a-z0-9-]+$/.test(t)||s.push("name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)"),(t.startsWith("-")||t.endsWith("-"))&&s.push("name must not start or end with a hyphen"),t.includes("--")&&s.push("name must not contain consecutive hyphens"),s}f(B,"validateName");function J(t){const s=[];return typeof t!="string"||t.trim()===""?s.push("description is required"):t.length>A&&s.push(`description exceeds ${A} characters (${t.length})`),s}f(J,"validateDescription");function Q(t,s,n){switch(n){case"user":return D(t,{source:"local",scope:"user",baseDir:s});case"project":return D(t,{source:"local",scope:"project",baseDir:s});case"path":return D(t,{source:"local",baseDir:s});default:return D(t,{source:n,baseDir:s})}}f(Q,"createSkillSourceInfo");function ot(t){const{dir:s,source:n}=t;return w(s,n,!0)}f(ot,"loadSkillsFromDir");function w(t,s,n,e,l){const r=[],c=[];if(!F(t))return{skills:r,diagnostics:c};const m=l??t,u=e??C();H(u,t,m);try{const d=T(t,{withFileTypes:!0});for(const a of d){if(a.name!=="SKILL.md")continue;const g=S(t,a.name);let k=a.isFile();if(a.isSymbolicLink())try{k=I(g).isFile()}catch{continue}const y=E(P(m,g));if(!k||u.ignores(y))continue;const i=b(g,s);return i.skill&&r.push(i.skill),c.push(...i.diagnostics),{skills:r,diagnostics:c}}for(const a of d){if(a.name.startsWith(".")||a.name==="node_modules")continue;const g=S(t,a.name);let k=a.isDirectory(),y=a.isFile();if(a.isSymbolicLink())try{const p=I(g);k=p.isDirectory(),y=p.isFile()}catch{continue}const i=E(P(m,g)),o=k?`${i}/`:i;if(u.ignores(o))continue;if(k){const p=w(g,s,!1,u,m);r.push(...p.skills),c.push(...p.diagnostics);continue}if(!y||!n||!a.name.endsWith(".md"))continue;const h=b(g,s);h.skill&&r.push(h.skill),c.push(...h.diagnostics)}}catch{}return{skills:r,diagnostics:c}}f(w,"loadSkillsFromDirInternal");function b(t,s){const n=[],e=x(t)==="SKILL.md";let l;try{l=N(t,"utf-8")}catch(i){const o=i instanceof Error?i.message:"failed to read skill file";return n.push({type:"warning",message:o,path:t}),{skill:null,diagnostics:n}}let r;try{({frontmatter:r}=O(l))}catch(i){if(e){const o=i instanceof Error?i.message:"failed to parse skill file";n.push({type:"warning",message:o,path:t})}return{skill:null,diagnostics:n}}const c=r.description,m=typeof c=="string"&&c.trim()!=="";if(!e&&!m)return{skill:null,diagnostics:n};const u=G(t),d=x(u),a=J(c);for(const i of a)n.push({type:"warning",message:i,path:t});const k=(typeof r.name=="string"?r.name:void 0)||d,y=B(k);for(const i of y)n.push({type:"warning",message:i,path:t});return m?{skill:{name:k,description:c,filePath:t,baseDir:u,sourceInfo:Q(t,u,s),disableModelInvocation:r["disable-model-invocation"]===!0},diagnostics:n}:{skill:null,diagnostics:n}}f(b,"loadSkillFromFile");function rt(t,s="read"){const n=t.filter(l=>!l.disableModelInvocation);if(n.length===0)return"";const e=[`
|
|
2
2
|
|
|
3
|
-
The following skills provide specialized instructions for specific tasks.`,
|
|
4
|
-
`)}
|
|
3
|
+
The following skills provide specialized instructions for specific tasks.`,s==="read"?"Use the read tool to load a skill's file when the task matches its description.":s==="bash"?"Use bash to load a skill's file when the task matches its description.":"Load a skill's file when the task matches its description.","Resolve relative paths against the skill's directory (parent of SKILL.md). Use absolute paths in tool calls.","","<available_skills>"];for(const l of n)e.push(" <skill>"),e.push(` <name>${L(l.name)}</name>`),e.push(` <description>${L(l.description)}</description>`),e.push(` <location>${L(l.filePath)}</location>`),e.push(" </skill>");return e.push("</available_skills>"),e.join(`
|
|
4
|
+
`)}f(rt,"formatSkillsForPrompt");function L(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}f(L,"escapeXml");function lt(t){const{agentDir:s,skillPaths:n,includeDefaults:e}=t,l=$(t.cwd),r=$(s??z()),c=new Map,m=new Set,u=[],d=[];function a(i){u.push(...i.diagnostics);for(const o of i.skills){const h=U(o.filePath);if(m.has(h))continue;const p=c.get(o.name);p?d.push({type:"collision",message:`name "${o.name}" collision`,path:o.filePath,collision:{resourceType:"skill",name:o.name,winnerPath:p.filePath,loserPath:o.filePath}}):(c.set(o.name,o),m.add(h))}}f(a,"addSkills"),e&&(a(w(S(r,"skills"),"user",!0)),a(w(W(l,_,"skills"),"project",!0)));const g=S(r,"skills"),k=W(l,_,"skills"),y=f(i=>{if(!e){if(M(g,i))return"user";if(M(k,i))return"project"}return"path"},"getSource");for(const i of n){const o=$(i,l,{trim:!0});if(!F(o)){u.push({type:"warning",message:"skill path does not exist",path:o});continue}try{const h=I(o),p=y(o);if(h.isDirectory())a(w(o,p,!0));else if(h.isFile()&&o.endsWith(".md")){const v=b(o,p);v.skill?a({skills:[v.skill],diagnostics:v.diagnostics}):u.push(...v.diagnostics)}else u.push({type:"warning",message:"skill path is not a markdown file",path:o})}catch(h){const p=h instanceof Error?h.message:"failed to read skill path";u.push({type:"warning",message:p,path:o})}}return{skills:Array.from(c.values()),diagnostics:[...u,...d]}}f(lt,"loadSkills");export{rt as formatSkillsForPrompt,lt as loadSkills,ot as loadSkillsFromDir};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var p=Object.defineProperty;var n=(t,r)=>p(t,"name",{value:r,configurable:!0});import{APP_NAME as s}from"../config.js";import{fill as l,t as o}from"../dal/i18n.js";function e(t,r,i){return{name:t,get description(){return r()},...i&&{argumentHint:i}}}n(e,"builtin");const u=[e("settings",()=>o("\u6253\u5F00\u8BBE\u7F6E\u83DC\u5355")),e("extensions",()=>o("\u542F\u7528\u6216\u505C\u7528\u5DF2\u52A0\u8F7D\u7684\u6269\u5C55")),e("model",()=>o("\u9009\u62E9\u6A21\u578B\uFF08\u6253\u5F00\u9009\u62E9\u754C\u9762\uFF09"),"<provider/model>"),e("tree",()=>o("\u6D4F\u89C8\u4F1A\u8BDD\u6811\uFF0C\u5207\u6362\u5206\u652F")),e("thinking",()=>o("\u8BBE\u7F6E\u601D\u8003\u6DF1\u5EA6"),"<level>"),e("scoped-models",()=>o("\u9009\u62E9\u54EA\u4E9B\u6A21\u578B\u53C2\u4E0E Ctrl+P \u8F6E\u6362")),e("export",()=>o("\u5BFC\u51FA\u4F1A\u8BDD\uFF08\u9ED8\u8BA4 HTML\uFF0C\u4E5F\u53EF\u6307\u5B9A\u8DEF\u5F84\uFF1A.html/.jsonl\uFF09")),e("import",()=>o("\
|
|
1
|
+
var p=Object.defineProperty;var n=(t,r)=>p(t,"name",{value:r,configurable:!0});import{APP_NAME as s}from"../config.js";import{fill as l,t as o}from"../dal/i18n.js";function e(t,r,i){return{name:t,get description(){return r()},...i&&{argumentHint:i}}}n(e,"builtin");const u=[e("settings",()=>o("\u6253\u5F00\u8BBE\u7F6E\u83DC\u5355")),e("extensions",()=>o("\u542F\u7528\u6216\u505C\u7528\u5DF2\u52A0\u8F7D\u7684\u6269\u5C55")),e("model",()=>o("\u9009\u62E9\u6A21\u578B\uFF08\u6253\u5F00\u9009\u62E9\u754C\u9762\uFF09"),"<provider/model>"),e("tree",()=>o("\u6D4F\u89C8\u4F1A\u8BDD\u6811\uFF0C\u5207\u6362\u5206\u652F")),e("thinking",()=>o("\u8BBE\u7F6E\u601D\u8003\u6DF1\u5EA6"),"<level>"),e("scoped-models",()=>o("\u9009\u62E9\u54EA\u4E9B\u6A21\u578B\u53C2\u4E0E Ctrl+P \u8F6E\u6362")),e("export",()=>o("\u5BFC\u51FA\u4F1A\u8BDD\uFF08\u9ED8\u8BA4 HTML\uFF0C\u4E5F\u53EF\u6307\u5B9A\u8DEF\u5F84\uFF1A.html/.jsonl\uFF09")),e("import",()=>o("\u5BFC\u5165 JSONL \u4F1A\u8BDD\uFF0C\u4FDD\u7559\u539F\u4F1A\u8BDD ID \u548C\u5DE5\u4F5C\u76EE\u5F55")),e("share",()=>o("\u628A\u4F1A\u8BDD\u5206\u4EAB\u4E3A\u79C1\u5BC6 GitHub gist")),e("bug",()=>o("\u5BFC\u51FA\u95EE\u9898\u62A5\u544A\uFF08\u672C\u5730 zip\uFF09\uFF0C\u53D1\u7ED9\u6280\u672F\u652F\u6301"),"<description>"),e("copy",()=>o("\u590D\u5236\u6700\u540E\u4E00\u6761\u56DE\u590D\u5230\u526A\u8D34\u677F")),e("name",()=>o("\u8BBE\u7F6E\u4F1A\u8BDD\u663E\u793A\u540D\u79F0")),e("session",()=>o("\u67E5\u770B\u4F1A\u8BDD\u4FE1\u606F\u548C\u7EDF\u8BA1")),e("map",()=>o("\u67E5\u770B\u7CBE\u7B80\u7684\u9879\u76EE\u7ED3\u6784\u56FE")),e("changelog",()=>o("\u67E5\u770B\u66F4\u65B0\u65E5\u5FD7")),e("hotkeys",()=>o("\u67E5\u770B\u5168\u90E8\u5FEB\u6377\u952E")),e("fork",()=>o("\u4ECE\u4E4B\u524D\u7684\u67D0\u6761\u6D88\u606F\u5206\u53C9\u51FA\u65B0\u4F1A\u8BDD")),e("clone",()=>o("\u5728\u5F53\u524D\u4F4D\u7F6E\u590D\u5236\u4E00\u4EFD\u4F1A\u8BDD")),e("trust",()=>o("\u4FDD\u5B58\u9879\u76EE\u4FE1\u4EFB\u8BBE\u7F6E\uFF0C\u4EE5\u540E\u7684\u4F1A\u8BDD\u6CBF\u7528")),e("login",()=>o("\u914D\u7F6E\u6A21\u578B\u63D0\u4F9B\u65B9\u7684\u767B\u5F55"),"<provider>"),e("logout",()=>o("\u79FB\u9664\u6A21\u578B\u63D0\u4F9B\u65B9\u7684\u767B\u5F55\u4FE1\u606F")),e("new",()=>o("\u5F00\u59CB\u65B0\u4F1A\u8BDD")),e("compact",()=>o("\u624B\u52A8\u538B\u7F29\u4F1A\u8BDD\u4E0A\u4E0B\u6587")),e("resume",()=>o("\u6062\u590D\u4E4B\u524D\u7684\u4F1A\u8BDD")),e("reload",()=>o("\u91CD\u65B0\u52A0\u8F7D\u5FEB\u6377\u952E\u3001\u6269\u5C55\u3001\u6280\u80FD\u3001\u63D0\u793A\u8BCD\u3001\u4E3B\u9898\u548C\u4E0A\u4E0B\u6587\u6587\u4EF6")),e("quit",()=>l(o("\u9000\u51FA {app}"),{app:s}))];export{u as BUILTIN_SLASH_COMMANDS};
|
|
@@ -8,14 +8,22 @@ export interface SourceInfo {
|
|
|
8
8
|
origin: SourceOrigin;
|
|
9
9
|
baseDir?: string;
|
|
10
10
|
packageName?: string;
|
|
11
|
+
changelogPath?: string;
|
|
11
12
|
}
|
|
13
|
+
export interface SourcePackageIdentity {
|
|
14
|
+
source: string;
|
|
15
|
+
scope: SourceScope;
|
|
16
|
+
}
|
|
17
|
+
export declare function getSourcePackageKey(identity: SourcePackageIdentity): string;
|
|
12
18
|
export declare const BUILTIN_PATH_PREFIX = "builtin:";
|
|
13
19
|
export declare function getSyntheticPathSource(path: string): string | undefined;
|
|
14
20
|
export declare function isSyntheticPath(path: string): boolean;
|
|
21
|
+
export declare function getResourcePathKey(path: string): string;
|
|
15
22
|
export declare function createSourceInfo(path: string, metadata: PathMetadata): SourceInfo;
|
|
16
23
|
export declare function createSyntheticSourceInfo(path: string, options: {
|
|
17
24
|
source: string;
|
|
18
25
|
scope?: SourceScope;
|
|
19
26
|
origin?: SourceOrigin;
|
|
20
27
|
baseDir?: string;
|
|
28
|
+
changelogPath?: string;
|
|
21
29
|
}): SourceInfo;
|
package/dist/core/source-info.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var i=Object.defineProperty;var n=(e,r)=>i(e,"name",{value:r,configurable:!0});import{readFileSync as s}from"node:fs";import{join as u}from"node:path";import{canonicalizePath as a,getPathComparisonKey as g}from"../utils/paths.js";function S(e){return JSON.stringify({source:e.source,scope:e.scope})}n(S,"getSourcePackageKey");const o="builtin:";function m(e){if(e.startsWith(o))return"builtin";if(e.startsWith("<")&&e.endsWith(">"))return e.slice(1,-1).split(":")[0]||"temporary"}n(m,"getSyntheticPathSource");function f(e){return e.startsWith(o)||e.startsWith("<")}n(f,"isSyntheticPath");const c=new Map;function h(e){if(!c.has(e)){let r;try{const t=JSON.parse(s(u(e,"package.json"),"utf8"));r=typeof t.name=="string"?t.name:void 0}catch{r=void 0}c.set(e,r)}return c.get(e)}n(h,"packageNameAt");function k(e){return f(e)?e:g(a(e))}n(k,"getResourcePathKey");function x(e,r){const t=r.packageRoot?h(r.packageRoot):void 0;return{path:e,source:r.source,scope:r.scope,origin:r.origin,baseDir:r.baseDir,...t?{packageName:t}:{},...r.changelogPath?{changelogPath:r.changelogPath}:{}}}n(x,"createSourceInfo");function b(e,r){return{path:e,source:r.source,scope:r.scope??"temporary",origin:r.origin??"top-level",baseDir:r.baseDir,...r.changelogPath?{changelogPath:r.changelogPath}:{}}}n(b,"createSyntheticSourceInfo");export{o as BUILTIN_PATH_PREFIX,x as createSourceInfo,b as createSyntheticSourceInfo,k as getResourcePathKey,S as getSourcePackageKey,m as getSyntheticPathSource,f as isSyntheticPath};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var x=Object.defineProperty;var c=(e,t)=>x(e,"name",{value:t,configurable:!0});import{join as $}from"node:path";import{getSystemMessageText as j}from"@earendil-works/pi-ai";import{APP_NAME as v,APP_TITLE as p,getDalDocsPath as E,getDocsPath as T,getExamplesPath as O,getReadmePath as _,IS_WHITE_LABEL_BUILD as I}from"../config.js";import{describeGitState as N}from"./git-state.js";import{INJECTED_CONTEXT_TAG as
|
|
1
|
+
var x=Object.defineProperty;var c=(e,t)=>x(e,"name",{value:t,configurable:!0});import{join as $}from"node:path";import{getSystemMessageText as j}from"@earendil-works/pi-ai";import{APP_NAME as v,APP_TITLE as p,getDalDocsPath as E,getDocsPath as T,getExamplesPath as O,getReadmePath as _,IS_WHITE_LABEL_BUILD as I}from"../config.js";import{describeGitState as N}from"./git-state.js";import{INJECTED_CONTEXT_TAG as A}from"./messages.js";import{describeProjectFacts as R}from"./project-facts.js";import{formatSkillsForPrompt as C}from"./skills.js";const F=/^[a-z][a-z0-9_-]*$/;function M(e){return{customPrompt:e.customPrompt,forceSystemPrompt:e.forceSystemPrompt,selectedTools:[...e.selectedTools??["read","bash","edit","write"]],hiddenTools:[...e.hiddenTools??[]],toolSnippets:{...e.toolSnippets??{}},toolGuidelines:Object.fromEntries(Object.entries(e.toolGuidelines??{}).map(([t,n])=>[t,[...n]])),promptGuidelines:[...e.promptGuidelines??[]],appendSystemPrompt:e.appendSystemPrompt??"",sections:{...e.sections??{}},cwd:e.cwd,gitState:e.gitState,projectFacts:e.projectFacts,contextFiles:(e.contextFiles??[]).map(t=>({...t})),skills:(e.skills??[]).map(t=>({...t}))}}c(M,"normalizeBuildSystemPromptOptions");function D(e){return["Project-specific instructions and guidelines:",...e.map(({path:t,content:n})=>`<project_instructions path="${t}">
|
|
2
2
|
${n}
|
|
3
3
|
</project_instructions>`)].join(`
|
|
4
4
|
|
|
5
|
-
`)}c(D,"renderProjectContext");function G(e,t,n){const i=[],d=new Set,o=c(l=>{const m=l.trim();!m||d.has(m)||(d.add(m),i.push(m))},"addRule"),h=e.includes("bash"),u=e.includes("powershell"),a=e.includes("grep"),f=e.includes("find"),y=e.includes("ls");(h||u)&&!a&&!f&&!y&&o(h&&u?"Use bash or PowerShell for file operations like listing, searching, and finding files":u?"Use PowerShell for file operations like listing, searching, and finding files":"Use bash for file operations like ls, rg, find");for(const l of e)for(const m of t[l]??[])o(m);for(const l of n)o(l);return e.length>0&&(o("Plan a step's lookups first, then make the independent calls (reads, searches, read-only commands) together in one response; they run in parallel"),o("Use paths relative to the working directory; do not begin commands with cd into it"),o("Finish the task in this turn; ask only to choose between approaches, or before push, deploy, delete, spend or send"),o("Reproduce a reported bug before changing code; if it does not reproduce, or the premise does not match what the code or tests show, say so plainly, give the evidence and change no product code, whatever a loaded skill assumes"),o("When a protection refuses a call, stop that step and say why; never reach the same data another way"),o(`You are ${p}: adapt instructions written for another agent, and sign commits "Co-Authored-By: ${p} <noreply@deepailab.ai>", never Claude, Codex or Copilot`)),o(`Text inside <${
|
|
5
|
+
`)}c(D,"renderProjectContext");function G(e,t,n){const i=[],d=new Set,o=c(l=>{const m=l.trim();!m||d.has(m)||(d.add(m),i.push(m))},"addRule"),h=e.includes("bash"),u=e.includes("powershell"),a=e.includes("grep"),f=e.includes("find"),y=e.includes("ls");(h||u)&&!a&&!f&&!y&&o(h&&u?"Use bash or PowerShell for file operations like listing, searching, and finding files":u?"Use PowerShell for file operations like listing, searching, and finding files":"Use bash for file operations like ls, rg, find");for(const l of e)for(const m of t[l]??[])o(m);for(const l of n)o(l);return e.length>0&&(o("Plan a step's lookups first, then make the independent calls (reads, searches, read-only commands) together in one response; they run in parallel"),o("Use paths relative to the working directory; do not begin commands with cd into it"),o("Finish the task in this turn; ask only to choose between approaches, or before push, deploy, delete, spend or send"),o("Reproduce a reported bug before changing code; if it does not reproduce, or the premise does not match what the code or tests show, say so plainly, give the evidence and change no product code, whatever a loaded skill assumes"),o("When a protection refuses a call, stop that step and say why; never reach the same data another way"),o(`You are ${p}: adapt instructions written for another agent, and sign commits "Co-Authored-By: ${p} <noreply@deepailab.ai>", never Claude, Codex or Copilot`)),o(`Text inside <${A} type="..."> tags comes from ${p}, not the user: follow it, but do not answer it as the user's words`),o("Reply in the language of the user's latest message, whatever language tool results, skills or injected notices use"),o("Be concise, and show file paths clearly"),i.map(l=>`- ${l}`).join(`
|
|
6
6
|
`)}c(G,"buildRules");function L(e){const t=M(e),{customPrompt:n,selectedTools:i,hiddenTools:d,toolSnippets:o,toolGuidelines:h,promptGuidelines:u,appendSystemPrompt:a,sections:f,cwd:y,contextFiles:l,skills:m}=t;for(const s of Object.keys(f))if(!F.test(s)||s==="preamble")throw new Error(`Invalid system prompt section name: ${s}`);const S=i.filter(s=>!d.includes(s)),r={};if(n)r.preamble=n;else{r.preamble=`You are an expert coding assistant operating inside ${p} (${v}). You help users by reading files, executing commands, editing code, and writing new files.`;const s=S.filter(b=>!!o[b]),g=s.length>0?s.map(b=>`- ${b}: ${o[b]}`).join(`
|
|
7
7
|
`):"(none)";r.tools=`${g}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Additional tools may be available.`,r.rules=G(S,h,u),r.docs=z()}a&&(r.addendum=a),l.length>0&&(r.project_context=D(l));const k=["read","bash"],w=k.find(s=>S.includes(s))??(k.some(s=>i.includes(s))?"indirect":void 0);if(f.skills)r.skills=f.skills;else if(w&&m.length>0){const s=C(m,w).trim();s&&(r.skills=s)}if(r.cwd=`Current working directory: ${y.replace(/\\/g,"/")}. Commands and relative paths start here; do not cd into it first.`,t.gitState&&!f.git_state&&(r.git=N(y)),t.projectFacts&&!f.project){const s=R(y);s&&(r.project=s)}for(const[s,g]of Object.entries(f))g&&(r[s]=g);const P={preamble:r.preamble};for(const[s,g]of Object.entries(r))s!=="preamble"&&(P[s]=`<${s}>
|
|
10
10
|
${g}
|
|
11
11
|
</${s}>`);return P}c(L,"buildSystemPromptSections");const U="cwd",B="Environment of this session, part of the system prompt. Later updates to these sections arrive as system prompt updates.";function Z(e){const t=e[0];if(!t||t.role!=="system"||!t.sections)return e;const n=Object.keys(t.sections),i=n.indexOf(U);if(i===-1)return e;const d=n.slice(i).map(a=>t.sections?.[a]).filter(a=>typeof a=="string"&&a.length>0),o=Object.fromEntries(n.slice(0,i).map(a=>[a,t.sections?.[a]??null])),h={...t,sections:o};if(d.length===0)return[h,...e.slice(1)];const u={role:"user",content:[{type:"text",text:`<session_environment>
|
|
12
12
|
${B}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
1
|
import { type ChildProcess } from "child_process";
|
|
3
2
|
import { type Static, Type } from "typebox";
|
|
4
3
|
import { type ShellConfig } from "../../utils/shell.ts";
|
|
5
4
|
import type { BackgroundProcessInfo, BackgroundProcessManager } from "../background-processes.ts";
|
|
6
5
|
import type { ToolDefinition } from "../extensions/types.ts";
|
|
7
6
|
import { type SandboxRunDetails, type ShellSandbox } from "../sandbox/shell-sandbox.ts";
|
|
7
|
+
import { type TypeBoxAgentTool } from "./tool-definition-wrapper.ts";
|
|
8
8
|
import { type TruncationResult } from "./truncate.ts";
|
|
9
9
|
declare const bashSchema: Type.TObject<{
|
|
10
10
|
command: Type.TString;
|
|
@@ -98,5 +98,5 @@ export interface ShellToolConfig {
|
|
|
98
98
|
}
|
|
99
99
|
export declare function createShellToolDefinition(cwd: string, config: ShellToolConfig, options?: BashToolOptions): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState>;
|
|
100
100
|
export declare function createBashToolDefinition(cwd: string, options?: BashToolOptions): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState>;
|
|
101
|
-
export declare function createBashTool(cwd: string, options?: BashToolOptions):
|
|
101
|
+
export declare function createBashTool(cwd: string, options?: BashToolOptions): TypeBoxAgentTool<typeof bashSchema>;
|
|
102
102
|
export {};
|
package/dist/core/tools/bash.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
Cannot execute ${t} commands.`)}const
|
|
3
|
-
${
|
|
1
|
+
var Le=Object.defineProperty;var s=(t,e)=>Le(t,"name",{value:e,configurable:!0});import{constants as Te}from"node:fs";import{access as Ce}from"node:fs/promises";import{constants as Pe}from"node:os";import{ToolExecutionError as ue}from"@earendil-works/pi-agent-core";import{Container as De,Text as Y,truncateToWidth as ve}from"@earendil-works/pi-tui";import{spawn as Ie}from"child_process";import{Type as u}from"typebox";import{fill as W,t as v}from"../../dal/i18n.js";import{keyHint as Ae}from"../../modes/interactive/components/keybinding-hints.js";import{truncateToVisualLines as ke}from"../../modes/interactive/components/visual-truncate.js";import{theme as E}from"../../modes/interactive/theme/theme.js";import{waitForChildProcess as Me}from"../../utils/child-process.js";import{writeOutputFile as Fe}from"../../utils/output-files.js";import{getShellConfig as ce,getShellEnv as me,killProcessTree as pe,trackDetachedChildPid as Ne,untrackDetachedChildPid as Be}from"../../utils/shell.js";import{missingManagedToolHint as Re}from"../../utils/tools-manager.js";import{describeDenialForModel as Ue}from"../sandbox/denial.js";import{getProcessShellSandbox as Ge}from"../sandbox/shell-sandbox.js";import{toolDenial as He,withToolDenial as je}from"../tool-denial.js";import{isReadOnlyBashCommand as We}from"./bash-read-only.js";import{OutputAccumulator as Ve}from"./output-accumulator.js";import{condenseShellOutput as Ye,outputCondenseDisabled as Xe}from"./output-condense.js";import{countOutputLines as Ke,formatCollapsedSummary as qe,getTextOutput as fe,invalidArgText as ze,str as he,truncateDisplay as Je}from"./render-utils.js";import{wrapToolDefinition as Qe}from"./tool-definition-wrapper.js";import{DEFAULT_MAX_BYTES as Ze,formatSize as et,SHELL_OUTPUT_MAX_CHARS as ee,truncateHeadTail as tt}from"./truncate.js";const we=2147483647,Se=1024*1024,nt=8*1024*1024,ot=we/1e3,te=12e4,ne=30;function it(t){if(t===void 0)return te;if(!Number.isFinite(t)||t<=0)throw new Error("Invalid timeout: must be a finite number of seconds");const e=t*1e3;if(e>we)throw new Error(`Invalid timeout: maximum is ${ot} seconds`);return e}s(it,"resolveTimeoutMs");const xe=u.Object({command:u.String({description:"Shell command to execute"}),description:u.String({description:`What it does and why, 3-10 words in the user's language, shown instead of the command: "Find hardcoded key names", not "run grep"`}),timeout:u.Optional(u.Number({description:"Seconds to wait for the command (default in the tool description). Raise it for long builds."}))}),st=u.Optional(u.Object({mode:u.Union([u.Literal("allow"),u.Literal("unsandboxed")],{description:'"allow": stay sandboxed with the domains/paths below; "unsandboxed": run outside the sandbox'}),justification:u.String({description:"Why, in one sentence for the user, who must approve it"}),allow_domains:u.Optional(u.Array(u.String(),{description:"e.g. registry.npmjs.org"})),allow_write:u.Optional(u.Array(u.String(),{description:"Paths to make writable"}))},{description:"Only after the sandbox blocked this command: the access it needs. Never pre-emptively."})),rt=u.Object({...xe.properties,sandbox_escalation:st}),be={snippet:"Execute bash commands (ls, grep, find, etc.)",guidelines:["You can inspect DAL_* environment variables for current model and session details."]},at=u.Object({output:u.String({description:"Combined stdout and stderr, possibly truncated"}),truncated:u.Boolean(),full_output_path:u.Optional(u.String({description:"Full output, when truncated"})),exit_code:u.Number({description:"-1 while the command runs in the background"}),background_id:u.Optional(u.String({description:"Background process id, when it is still running"})),wall_time_seconds:u.Number()});class Ee extends Error{static{s(this,"ShellTimeoutError")}shellExit;constructor(e,n){super(`timeout:${e}`),this.shellExit=n}}function dt(t,e){return{exec:s(async(n,o,{onData:c,signal:i,timeout:$,env:w,yieldTo:r})=>{const L=it($);if(i?.aborted)throw new Error("aborted");const S=e();try{await Ce(o,Te.F_OK)}catch{throw new Error(`Working directory does not exist: ${o}
|
|
2
|
+
Cannot execute ${t} commands.`)}const x=S.commandTransport==="stdin",a=Ie(S.shell,x?S.args:[...S.args,n],{cwd:o,detached:process.platform!=="win32",env:w??me(),stdio:[x?"pipe":"ignore","pipe","pipe"],windowsHide:!0});x&&(a.stdin?.on("error",()=>{}),a.stdin?.end(n)),a.pid&&Ne(a.pid);const d=performance.now();let p;a.once("exit",()=>{p=performance.now()-d});let h=!1,m=!1,f;const T=new Promise(U=>{f=s(()=>U("yielded"),"onYielded")});let R,D;const k=s(()=>{a.pid&&pe(a.pid)},"onAbort");try{L!==void 0&&(D=setTimeout(()=>{if(r&&a.exitCode===null&&a.signalCode===null&&r(a)){m=!0,f?.();return}h=!0,R=p,a.pid&&pe(a.pid)},L)),a.stdout?.on("data",c),a.stderr?.on("data",c),i&&(i.aborted?k():i.addEventListener("abort",k,{once:!0}));const U=Me(a),C=await Promise.race([U,T]);if(C==="yielded")return U.catch(()=>{}),{exitCode:null,yielded:!0};const O=C;if(i?.aborted)throw new Error("aborted");const g=a.signalCode,M=O??(g?128+(Pe.signals[g]??0):1);if(h)throw new Ee((L??te)/1e3,R!==void 0?{exitCode:M,afterSeconds:Math.round(R/100)/10}:void 0);return{exitCode:M}}finally{a.pid&&!m&&Be(a.pid),D&&clearTimeout(D),i&&i.removeEventListener("abort",k)}},"exec")}}s(dt,"createLocalShellOperations");function lt(t){return dt("bash",()=>ce(t?.shellPath))}s(lt,"createLocalBashOperations");const oe=Symbol.for("dal.shell.executionGuards"),ie=globalThis;ie[oe]instanceof Set||(ie[oe]=new Set);const se=ie[oe];function Kt(t){return se.add(t),()=>{se.delete(t)}}s(Kt,"registerShellExecutionGuard");async function ut(t){for(const e of se){let n;try{n=await e(t)}catch(o){return`Command refused: the safety check could not run (${o instanceof Error?o.message:String(o)}).`}if(n!==void 0)return n}}s(ut,"shellExecutionRefusal");const ct=["SESSION_ID","SESSION_FILE","PROVIDER","MODEL","REASONING_LEVEL"];function mt(t,e,n,o,c){const i={...me()};if(delete i.PI_SESSION_ID,delete i.PI_SESSION_FILE,delete i.PI_PROVIDER,delete i.PI_MODEL,delete i.PI_REASONING_LEVEL,o&&c){const w=c.model;i.PI_SESSION_ID=c.sessionManager.getSessionId();const r=c.sessionManager.getSessionFile();r&&(i.PI_SESSION_FILE=r),w&&(i.PI_PROVIDER=w.provider,i.PI_MODEL=w.id),c.thinkingLevel&&(i.PI_REASONING_LEVEL=c.thinkingLevel)}for(const w of ct){delete i[`DAL_${w}`];const r=i[`PI_${w}`];r!==void 0&&(i[`DAL_${w}`]=r)}const $={command:t,cwd:e,env:i};return n?n($):$}s(mt,"resolveSpawnContext");const pt=5,ft=100;class ht extends De{static{s(this,"BashResultRenderComponent")}state={cachedWidth:void 0,cachedLines:void 0,cachedSkipped:void 0}}function wt(t){const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e),o=Math.floor(n/60),c=n%60;return o<60?`${o}m ${c}s`:`${Math.floor(o/60)}h ${o%60}m ${c}s`}s(wt,"formatDuration");function St(t,e,n=!1){const o=he(t?.command),c=he(t?.description)?.trim(),i=t?.timeout,$=i?E.fg("muted",W(v(" (\u8D85\u65F6 {seconds} \u79D2)"),{seconds:i})):"";if(c){const r=E.fg("toolTitle",E.bold(c))+$;return!n||!o?r:`${r}
|
|
3
|
+
${E.fg("muted",` \u23BF ${e} ${o.trim()}`)}`}const w=o===null?ze(E):o?E.fg("dim",Je(o.replace(/\s+/g," ").trim(),42)):E.fg("dim","\u2026");return`${E.fg("toolTitle",E.bold(e))} ${w}${$}`}s(St,"formatShellCall");function xt(t,e,n,o,c,i,$,w){const r=t.state;t.clear();const L=bt(n,c,i,w);if(!n.expanded&&!$){const d=fe(e,o),p=Ke(d),h=[];p>0&&h.push(W(v("{count} \u884C"),{count:p})),L&&h.push(L);const m=qe(E,h);m&&t.addChild(new Y(m,0,0));return}let S=fe(e,o).trim();const x=e.details?.truncation,a=e.details?.fullOutputPath;if(!n.isPartial&&x?.truncated&&a&&S.endsWith("]")){const d=S.lastIndexOf(`
|
|
4
4
|
|
|
5
|
-
[`);
|
|
6
|
-
`).map(
|
|
7
|
-
`);n.expanded?t.addChild(new
|
|
8
|
-
${
|
|
9
|
-
${
|
|
10
|
-
${
|
|
11
|
-
${
|
|
5
|
+
[`);d!==-1&&S.slice(d).includes(a)&&(S=S.slice(0,d).trimEnd())}if(S){const d=S.split(`
|
|
6
|
+
`).map(p=>E.fg("toolOutput",p)).join(`
|
|
7
|
+
`);n.expanded?t.addChild(new Y(`
|
|
8
|
+
${d}`,0,0)):t.addChild({render:s(p=>{if(r.cachedLines===void 0||r.cachedWidth!==p){const h=ke(d,pt,p);r.cachedLines=h.visualLines,r.cachedSkipped=h.skippedCount,r.cachedWidth=p}if(r.cachedSkipped&&r.cachedSkipped>0){const h=E.fg("muted",W(v("... (\u524D\u9762\u8FD8\u6709 {count} \u884C\uFF0C"),{count:r.cachedSkipped}))+` ${Ae("app.tools.expand",v("\u5373\u53EF\u5C55\u5F00"))}${E.fg("muted",")")}`;return["",ve(h,p,"..."),...r.cachedLines??[]]}return["",...r.cachedLines??[]]},"render"),invalidate:s(()=>{r.cachedWidth=void 0,r.cachedLines=void 0,r.cachedSkipped=void 0},"invalidate")})}if(x?.truncated||a){const d=[];a&&d.push(W(v("\u5B8C\u6574\u8F93\u51FA\uFF1A{path}"),{path:a})),x?.truncated&&(x.truncatedBy==="lines"?d.push(W(v("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A {shown}/{total} \u884C"),{shown:x.outputLines,total:x.totalLines})):d.push(W(v("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A\u4E86 {shown} \u884C\uFF08\u4E0A\u9650 {limit}\uFF09"),{shown:x.outputLines,limit:et(x.maxBytes??Ze)}))),t.addChild(new Y(`
|
|
9
|
+
${E.fg("warning",`[${d.join(". ")}]`)}`,0,0))}L&&t.addChild(new Y(`
|
|
10
|
+
${E.fg("muted",L)}`,0,0))}s(xt,"rebuildBashResultRenderComponent");function bt(t,e,n,o){let c;if(!t.isPartial&&o!==void 0)c=o;else if(e!==void 0)c=(n??Date.now())-e;else return;if(!(!t.isPartial&&c<100))return`${t.isPartial?v("\u5DF2\u8FD0\u884C"):v("\u8017\u65F6")} ${wt(c)}`}s(bt,"bashTimingLabel");function Et(t,e,n){const o=n?.operations??e.defaultOperations?.()??lt({shellPath:n?.shellPath}),c=n?.commandPrefix,i=n?.exposeSessionEnvironment??!0,$=n?.spawnHook,w=n?.sandbox,r=n?.operations===void 0,L=w?.describeForModel(),S=n?.background;let x=!1;const a=s(d=>`Execute a ${e.shellName} command in the current working directory; returns stdout and stderr. Long output is cut to its start and end (error lines kept) and the full output saved to a file named in the result. ${d?`A command still running after \`timeout\` seconds (default ${ne}) keeps running in the background: you get its id and the output so far, then use the process tool to poll or kill it.`:`A command still running after \`timeout\` seconds (default ${te/1e3}) is killed.`}${L?` ${L}`:""}`,"describe");return{name:e.name,label:e.label,description:a(!1),prepareLoadout:S&&r?d=>(x=d.declared.some(p=>p.name==="process"),x?{descriptions:{[e.name]:a(!0)}}:void 0):void 0,promptSnippet:e.promptSnippet,promptGuidelines:i&&e.promptGuidelines?[...e.promptGuidelines]:void 0,executionMode:"sequential",executionModeFor:e.readOnlyCommand&&!c?d=>e.readOnlyCommand?.(d?.command)?"parallel":void 0:void 0,parameters:w?.active?rt:xe,outputSchema:at,constrainedSampling:{type:"json_schema",strict:"prefer"},async execute(d,p,h,m,f){const{command:T,timeout:R}=p;m&&m({content:[],details:void 0});const D=w??(r?Ge():void 0),k=await ut({toolName:e.name,command:T,cwd:f?.cwd||t,sessionFile:f?.sessionManager?.getSessionFile(),...D?.active?{tempDir:D.scratchDir()}:{}});if(k!==void 0)throw new ue(k,je(void 0,He("dangerous-command",k)));const U=c?`${c}
|
|
11
|
+
${T}`:T,C=mt(U,f?.cwd||t,$,i,f);let O;if(D?.active){if(!e.sandboxShell)throw new Error(`Command refused: ${e.shellName} commands cannot run inside the OS sandbox yet, and the sandbox level is "${D.level}". Use the bash tool, or the user can opt out with \`dal --sandbox off\`.`);O=await D.prepare({command:C.command,cwd:C.cwd,shell:e.sandboxShell(n?.shellPath),shellKind:e.sandboxShellKind??"bash",env:C.env,toolCallId:d,toolName:e.name,escalation:p.sandbox_escalation,ctx:f,signal:h})}const g=new Ve({tempFilePrefix:e.tempFilePrefix,maxBytes:ee});let M=!0,V,K=!1,re=0;const q=s(()=>{if(!m||!K)return;K=!1,re=Date.now();const l=g.snapshot({persistIfTruncated:!0});m({content:[{type:"text",text:l.content||""}],details:{truncation:l.truncation.truncated?l.truncation:void 0,fullOutputPath:l.fullOutputPath}})},"emitOutputUpdate"),z=s(()=>{V&&(clearTimeout(V),V=void 0)},"clearUpdateTimer"),_e=s(()=>{if(!m)return;K=!0;const l=ft-(Date.now()-re);if(l<=0){z(),q();return}V??=setTimeout(()=>{V=void 0,q()},l)},"scheduleOutputUpdate"),Oe=s(l=>{M&&(g.append(l),_e())},"handleData"),ge=s(async()=>{M=!1,g.finish(),z(),q();const l=g.snapshot({persistIfTruncated:!0});return await g.closeTempFile(),l},"finishOutput"),J=s(async(l="(no output)")=>{const y=await ge(),F=await g.readFullOutput(nt),P=Xe()?void 0:Ye(F.content),_=tt(P?.text??F.content,ee);let A=y.fullOutputPath;(_.truncated||P)&&!A&&(A=await Fe(e.tempFilePrefix,".log",F.content));let N=_.content||l,H;const j=y.truncation.totalLines;return _.truncated?(H={truncation:{content:_.content,truncated:!0,truncatedBy:"bytes",totalLines:j,totalBytes:y.truncation.totalBytes,outputLines:_.headLines+_.tailLines,outputBytes:Buffer.byteLength(_.content,"utf-8"),lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines:j,maxBytes:ee},fullOutputPath:A},N+=`
|
|
12
12
|
|
|
13
|
-
[Truncated: first ${
|
|
13
|
+
[Truncated: first ${_.headLines} and last ${_.tailLines} of ${_.totalLines} lines shown${P?`, after condensing ${j} lines (${P.summary})`:""}; read more with read (offset/limit) or grep. Full output: ${A}]`):P&&(H={fullOutputPath:A},N+=`
|
|
14
14
|
|
|
15
|
-
[Condensed: ${
|
|
15
|
+
[Condensed: ${P.summary}. Full output: ${A}]`),{text:N,details:H,snapshot:y}},"modelOutput"),G=s((l,y)=>`${l?`${l}
|
|
16
16
|
|
|
17
|
-
`:""}${
|
|
17
|
+
`:""}${y}`,"appendStatus"),ae=performance.now();let I;const Q=S&&r&&x?l=>{M=!1;try{return I=S.adopt({child:l,command:T,cwd:C.cwd,...O?{prepared:O}:{},...g.handOff()}),!0}catch{return M=!0,!1}}:void 0;try{let l;try{const b=await o.exec(O?.command??C.command,C.cwd,{onData:Oe,signal:h,timeout:R??(Q?ne:void 0),env:C.env,...Q?{yieldTo:Q}:{}});if(b.yielded&&I){const{text:B,details:de}=await J(""),X=R??ne,ye=I.urls.length>0?` It printed ${I.urls.join(" ")}.`:"",$e=`[Still running after ${X}s, now in the background as ${I.id}.${ye} For new output and the exit code call process with action "poll" and id "${I.id}"; "kill" stops it.]`,le=await g.readFullOutput(Se);return{content:[{type:"text",text:G(B,$e)}],details:{...de,background:I},structuredContent:{output:le.content,truncated:le.truncated,exit_code:-1,background_id:I.id,wall_time_seconds:Math.round((performance.now()-ae)/100)/10}}}l=b.exitCode}catch(b){const{text:B}=await J("");if(await O?.finish(null,""),b instanceof Error&&b.message==="aborted")throw new Error(G(B,"Command aborted"));if(b instanceof Error&&b.message.startsWith("timeout:")){let X=`Command timed out after ${b.message.split(":")[1]} seconds`;throw b instanceof Ee&&b.shellExit&&(X+=`. The shell exited with code ${b.shellExit.exitCode} after ${b.shellExit.afterSeconds} seconds, but background processes it started kept writing output until the timeout.`),new Error(G(B,X))}throw b}const{text:y,details:F,snapshot:P}=await J(),_=await O?.finish(l,P.content||"");if(_&&O)throw new ue(`${G(y,`Command exited with code ${l??"(none)"}`)}
|
|
18
18
|
|
|
19
|
-
${
|
|
20
|
-
${
|
|
19
|
+
${Ue(_)}`,{...F,sandbox:O.details});if(l===null)throw new Error(G(y,"Command terminated without an exit code"));const A=Math.round((performance.now()-ae)/100)/10,N=await g.readFullOutput(Se),H={output:N.content,truncated:N.truncated,...N.truncated&&P.fullOutputPath?{full_output_path:P.fullOutputPath}:{},exit_code:l,wall_time_seconds:A},j=O?.details.escalation?O.details:void 0,Z=j?{...F,sandbox:j}:F;if(l!==0){const b=l===127?await Re(y):void 0,B=G(y,`Command exited with code ${l}`);return{content:[{type:"text",text:b?`${B}
|
|
20
|
+
${b}`:B}],details:Z,structuredContent:H,isError:!0}}return{content:[{type:"text",text:y}],details:Z,structuredContent:H}}finally{z()}},renderCall(d,p,h){const m=h.state;h.executionStarted&&m.startedAt===void 0&&(m.startedAt=Date.now(),m.endedAt=void 0);const f=h.lastComponent??new Y("",0,0);return f.setText(St(d,e.prompt,h.expanded===!0)),f},renderResult(d,p,h,m){const f=m.state;f.startedAt!==void 0&&p.isPartial&&!f.interval&&(f.interval=setInterval(()=>m.invalidate(),1e3)),(!p.isPartial||m.isError)&&(f.endedAt??=Date.now(),f.interval&&(clearInterval(f.interval),f.interval=void 0));const T=m.lastComponent??new ht;return xt(T,d,p,m.showImages,f.startedAt,f.endedAt,m.isError,m.durationMs),T.invalidate(),T}}}s(Et,"createShellToolDefinition");const _t={name:"bash",label:"bash",shellName:"bash",prompt:"$",promptSnippet:be.snippet,promptGuidelines:be.guidelines,tempFilePrefix:"dal-bash",readOnlyCommand:We,sandboxShell:s(t=>ce(t).shell,"sandboxShell")};function Ot(t,e){return Et(t,_t,e)}s(Ot,"createBashToolDefinition");function qt(t,e){const n=Ot(t,e),o=Qe(n);return Object.assign(o,{promptSnippet:n.promptSnippet,promptGuidelines:n.promptGuidelines}),o}s(qt,"createBashTool");export{be as bashToolSystemPromptContribution,qt as createBashTool,Ot as createBashToolDefinition,lt as createLocalBashOperations,dt as createLocalShellOperations,Et as createShellToolDefinition,Kt as registerShellExecutionGuard,st as sandboxEscalationSchema,ut as shellExecutionRefusal};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export declare function detectLineEnding(content: string): "\r\n" | "\n";
|
|
2
1
|
export declare function normalizeToLF(text: string): string;
|
|
3
|
-
export declare function
|
|
2
|
+
export declare function applyReplacementsToOriginal(originalContent: string, replacements: TextReplacement[]): string;
|
|
4
3
|
export declare function normalizeForFuzzyMatch(text: string): string;
|
|
5
4
|
interface MatchedEdit {
|
|
6
5
|
editIndex: number;
|
|
@@ -8,8 +7,7 @@ interface MatchedEdit {
|
|
|
8
7
|
matchLength: number;
|
|
9
8
|
newText: string;
|
|
10
9
|
}
|
|
11
|
-
type TextReplacement = Pick<MatchedEdit, "matchIndex" | "matchLength" | "newText">;
|
|
12
|
-
export declare function applyReplacementsPreservingUnchangedLines(originalContent: string, baseContent: string, replacements: TextReplacement[]): string;
|
|
10
|
+
export type TextReplacement = Pick<MatchedEdit, "matchIndex" | "matchLength" | "newText">;
|
|
13
11
|
export interface FuzzyMatchResult {
|
|
14
12
|
found: boolean;
|
|
15
13
|
index: number;
|
|
@@ -24,6 +22,7 @@ export interface Edit {
|
|
|
24
22
|
export interface AppliedEditsResult {
|
|
25
23
|
baseContent: string;
|
|
26
24
|
newContent: string;
|
|
25
|
+
replacements: TextReplacement[];
|
|
27
26
|
}
|
|
28
27
|
export declare function fuzzyFindText(content: string, oldText: string): FuzzyMatchResult;
|
|
29
28
|
export declare function applyEditsToNormalizedContent(normalizedContent: string, edits: Edit[], path: string): AppliedEditsResult;
|
|
@@ -32,6 +31,12 @@ export declare function generateDiffString(oldContent: string, newContent: strin
|
|
|
32
31
|
diff: string;
|
|
33
32
|
firstChangedLine: number | undefined;
|
|
34
33
|
};
|
|
34
|
+
export interface EditDiff {
|
|
35
|
+
diff: string;
|
|
36
|
+
patch: string;
|
|
37
|
+
firstChangedLine: number | undefined;
|
|
38
|
+
}
|
|
39
|
+
export declare function generateEditDiff(path: string, baseContent: string, newContent: string, replacements: TextReplacement[], contextLines?: number): EditDiff;
|
|
35
40
|
export interface EditDiffResult {
|
|
36
41
|
diff: string;
|
|
37
42
|
firstChangedLine: number | undefined;
|