@draht/coding-agent 2026.5.12 → 2026.7.7
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 +41 -0
- package/README.md +1 -4
- package/bin/draht-tools.cjs +3756 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +4 -2
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/register-bedrock.d.ts.map +1 -1
- package/dist/bun/register-bedrock.js +1 -1
- package/dist/bun/register-bedrock.js.map +1 -1
- package/dist/bun/restore-sandbox-env.d.ts +17 -0
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
- package/dist/bun/restore-sandbox-env.js +36 -0
- package/dist/bun/restore-sandbox-env.js.map +1 -0
- package/dist/cli/args.d.ts +9 -4
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +91 -38
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts +5 -3
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +13 -26
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/initial-message.d.ts +1 -1
- package/dist/cli/initial-message.d.ts.map +1 -1
- package/dist/cli/initial-message.js.map +1 -1
- package/dist/cli/list-models.d.ts +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +7 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/project-trust.d.ts +10 -0
- package/dist/cli/project-trust.d.ts.map +1 -0
- package/dist/cli/project-trust.js +48 -0
- package/dist/cli/project-trust.js.map +1 -0
- package/dist/cli/session-picker.d.ts +3 -2
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +5 -4
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/startup-ui.d.ts +20 -0
- package/dist/cli/startup-ui.d.ts.map +1 -0
- package/dist/cli/startup-ui.js +184 -0
- package/dist/cli/startup-ui.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +7 -4
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +27 -13
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +284 -63
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +45 -9
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +100 -33
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +6 -4
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +7 -4
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +55 -33
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +560 -492
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-guidance.d.ts +5 -0
- package/dist/core/auth-guidance.d.ts.map +1 -0
- package/dist/core/auth-guidance.js +21 -0
- package/dist/core/auth-guidance.js.map +1 -0
- package/dist/core/auth-storage.d.ts +21 -13
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +48 -28
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts +1 -15
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +10 -24
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/builtins/subagent.d.ts.map +1 -1
- package/dist/core/builtins/subagent.js +1 -2
- package/dist/core/builtins/subagent.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +9 -5
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +10 -4
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +8 -7
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +56 -47
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/index.d.ts +3 -3
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +1 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +1 -1
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js.map +1 -1
- package/dist/core/experimental.d.ts +2 -0
- package/dist/core/experimental.d.ts.map +1 -0
- package/dist/core/experimental.js +4 -0
- package/dist/core/experimental.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/dist/core/export-html/ansi-to-html.js +1 -1
- package/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/dist/core/export-html/index.d.ts +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +13 -11
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.css +69 -4
- package/dist/core/export-html/template.js +231 -57
- package/dist/core/export-html/tool-renderer.d.ts +0 -6
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +15 -2
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/export-html/vendor/marked.min.js +75 -3
- package/dist/core/extensions/index.d.ts +8 -8
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +5 -6
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +98 -43
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +31 -12
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +248 -33
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +191 -36
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +2 -2
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +7 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +78 -54
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts +22 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -0
- package/dist/core/http-dispatcher.js +91 -0
- package/dist/core/http-dispatcher.js.map +1 -0
- package/dist/core/index.d.ts +9 -8
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +67 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +59 -7
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts +24 -5
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +188 -51
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +12 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +84 -39
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/output-guard.d.ts +1 -0
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js +52 -22
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/package-manager.d.ts +22 -4
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +455 -157
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/project-trust.d.ts +15 -0
- package/dist/core/project-trust.d.ts.map +1 -0
- package/dist/core/project-trust.js +59 -0
- package/dist/core/project-trust.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +13 -11
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +67 -76
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-attribution.d.ts +4 -0
- package/dist/core/provider-attribution.d.ts.map +1 -0
- package/dist/core/provider-attribution.js +72 -0
- package/dist/core/provider-attribution.js.map +1 -0
- package/dist/core/provider-display-names.d.ts +2 -0
- package/dist/core/provider-display-names.d.ts.map +1 -0
- package/dist/core/provider-display-names.js +36 -0
- package/dist/core/provider-display-names.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +13 -6
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +143 -22
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader.d.ts +36 -15
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +178 -79
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +34 -18
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +47 -16
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +32 -14
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +366 -209
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +62 -6
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +230 -40
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +10 -10
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +13 -35
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +7 -4
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/source-info.d.ts +1 -1
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/system-prompt.d.ts +4 -4
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +20 -16
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/telemetry.d.ts +3 -0
- package/dist/core/telemetry.d.ts.map +1 -0
- package/dist/core/telemetry.js +9 -0
- package/dist/core/telemetry.js.map +1 -0
- package/dist/core/timings.d.ts +4 -2
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +24 -14
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/bash.d.ts +11 -16
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +187 -178
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +26 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +110 -23
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +22 -24
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +201 -113
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js +27 -12
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/find.d.ts +7 -18
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +148 -101
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +11 -30
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +23 -12
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +26 -101
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +78 -52
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +6 -15
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +12 -17
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -0
- package/dist/core/tools/output-accumulator.js +184 -0
- package/dist/core/tools/output-accumulator.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +2 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js +40 -22
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/read.d.ts +7 -18
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +103 -52
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +5 -2
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +18 -2
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +2 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +12 -2
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/write.d.ts +5 -14
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +27 -46
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts +36 -0
- package/dist/core/trust-manager.d.ts.map +1 -0
- package/dist/core/trust-manager.js +202 -0
- package/dist/core/trust-manager.js.map +1 -0
- package/dist/index.d.ts +33 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +5 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +208 -93
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +2 -2
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +4 -4
- package/dist/migrations.js.map +1 -1
- package/dist/modes/index.d.ts +5 -5
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +5 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +37 -15
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +3 -3
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +3 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +36 -5
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +318 -36
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts +2 -2
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +2 -2
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-entry.js +52 -0
- package/dist/modes/interactive/components/custom-entry.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +2 -2
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +3 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +26 -9
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +2 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +8 -3
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -0
- package/dist/modes/interactive/components/first-time-setup.js +103 -0
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +4 -3
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +27 -7
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +33 -31
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +2 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +5 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +19 -5
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +12 -2
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +45 -11
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -2
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +10 -6
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +18 -6
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +93 -25
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +5 -12
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +49 -31
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +2 -2
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +33 -14
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +17 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +301 -20
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -0
- package/dist/modes/interactive/components/status-indicator.js +60 -0
- package/dist/modes/interactive/components/status-indicator.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +1 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +6 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +57 -14
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +137 -13
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/trust-selector.js +91 -0
- package/dist/modes/interactive/components/trust-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +2 -2
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +8 -7
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +6 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +22 -8
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +76 -19
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1294 -494
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/modes/interactive/model-search.d.ts.map +1 -0
- package/dist/modes/interactive/model-search.js +15 -0
- package/dist/modes/interactive/model-search.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +5 -4
- package/dist/modes/interactive/theme/light.json +5 -4
- package/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.js +102 -0
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +2 -1
- package/dist/modes/interactive/theme/theme.d.ts +41 -3
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +183 -106
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +40 -20
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +30 -5
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +87 -8
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +2 -2
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +113 -31
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +42 -4
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +6 -2
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +504 -25
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/brainstorm.md +148 -0
- package/dist/prompts/commands/map-codebase.md +14 -0
- package/dist/rpc-entry.d.ts +3 -0
- package/dist/rpc-entry.d.ts.map +1 -0
- package/dist/rpc-entry.js +10 -0
- package/dist/rpc-entry.js.map +1 -0
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +52 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/changelog.d.ts +2 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +78 -0
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts +12 -5
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +33 -5
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +2 -2
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +3 -1
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js +14 -8
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +84 -45
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/deprecation.d.ts +4 -0
- package/dist/utils/deprecation.d.ts.map +1 -0
- package/dist/utils/deprecation.js +13 -0
- package/dist/utils/deprecation.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/fs-watch.d.ts +5 -0
- package/dist/utils/fs-watch.d.ts.map +1 -0
- package/dist/utils/fs-watch.js +25 -0
- package/dist/utils/fs-watch.js.map +1 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +54 -22
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/html.d.ts +7 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +40 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/image-convert.d.ts +1 -0
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js +21 -15
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-process.d.ts +18 -0
- package/dist/utils/image-process.d.ts.map +1 -0
- package/dist/utils/image-process.js +83 -0
- package/dist/utils/image-process.js.map +1 -0
- package/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -0
- package/dist/utils/image-resize-core.js +124 -0
- package/dist/utils/image-resize-core.js.map +1 -0
- package/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/utils/image-resize-worker.d.ts.map +1 -0
- package/dist/utils/image-resize-worker.js +31 -0
- package/dist/utils/image-resize-worker.js.map +1 -0
- package/dist/utils/image-resize.d.ts +7 -27
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +75 -115
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +7 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/mime.d.ts +1 -0
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js +100 -16
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/open-browser.d.ts +9 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +22 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/dist/utils/paths.d.ts +25 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +75 -2
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/utils/pi-user-agent.d.ts.map +1 -0
- package/dist/utils/pi-user-agent.js +5 -0
- package/dist/utils/pi-user-agent.js.map +1 -0
- package/dist/utils/shell.d.ts +11 -6
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +42 -26
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -0
- package/dist/utils/syntax-highlight.js +118 -0
- package/dist/utils/syntax-highlight.js.map +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +86 -10
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts +15 -0
- package/dist/utils/version-check.d.ts.map +1 -0
- package/dist/utils/version-check.js +59 -0
- package/dist/utils/version-check.js.map +1 -0
- package/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/utils/windows-self-update.d.ts.map +1 -0
- package/dist/utils/windows-self-update.js +77 -0
- package/dist/utils/windows-self-update.js.map +1 -0
- package/docs/compaction.md +12 -12
- package/docs/containerization.md +111 -0
- package/docs/custom-provider.md +187 -47
- package/docs/development.md +5 -5
- package/docs/docs.json +156 -0
- package/docs/extensions.md +520 -79
- package/docs/index.md +82 -0
- package/docs/json.md +4 -4
- package/docs/keybindings.md +24 -2
- package/docs/models.md +119 -17
- package/docs/packages.md +19 -11
- package/docs/prompt-templates.md +30 -2
- package/docs/providers.md +85 -23
- package/docs/quickstart.md +165 -0
- package/docs/rpc.md +99 -10
- package/docs/sdk.md +118 -50
- package/docs/security.md +55 -0
- package/docs/{session.md → session-format.md} +29 -19
- package/docs/sessions.md +145 -0
- package/docs/settings.md +71 -11
- package/docs/skills.md +16 -17
- package/docs/terminal-setup.md +44 -2
- package/docs/termux.md +4 -4
- package/docs/themes.md +3 -3
- package/docs/tmux.md +4 -2
- package/docs/tui.md +44 -4
- package/docs/usage.md +305 -0
- package/examples/extensions/README.md +1 -0
- package/examples/extensions/border-status-editor.ts +145 -0
- package/examples/extensions/built-in-tool-renderer.ts +3 -0
- package/examples/extensions/custom-compaction.ts +2 -1
- package/examples/extensions/custom-header.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +2 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +63 -8
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +2 -2
- package/examples/extensions/doom-overlay/doom-component.ts +2 -2
- package/examples/extensions/doom-overlay/index.ts +1 -1
- package/examples/extensions/dynamic-resources/dynamic.json +1 -1
- package/examples/extensions/dynamic-tools.ts +2 -2
- package/examples/extensions/entry-renderer.ts +41 -0
- package/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/examples/extensions/gondolin/index.ts +531 -0
- package/examples/extensions/gondolin/package-lock.json +185 -0
- package/examples/extensions/gondolin/package.json +19 -0
- package/examples/extensions/handoff.ts +52 -14
- package/examples/extensions/input-transform-streaming.ts +39 -0
- package/examples/extensions/interactive-shell.ts +1 -1
- package/examples/extensions/notify.ts +2 -9
- package/examples/extensions/overlay-qa-tests.ts +240 -138
- package/examples/extensions/overlay-test.ts +7 -4
- package/examples/extensions/plan-mode/index.ts +87 -37
- package/examples/extensions/plan-mode/utils.ts +1 -1
- package/examples/extensions/preset.ts +46 -7
- package/examples/extensions/project-trust.ts +64 -0
- package/examples/extensions/prompt-customizer.ts +97 -0
- package/examples/extensions/provider-payload.ts +8 -4
- package/examples/extensions/qna.ts +3 -3
- package/examples/extensions/question.ts +34 -20
- package/examples/extensions/questionnaire.ts +43 -30
- package/examples/extensions/reload-runtime.ts +1 -1
- package/examples/extensions/sandbox/index.ts +6 -6
- package/examples/extensions/sandbox/package-lock.json +5 -5
- package/examples/extensions/sandbox/package.json +2 -2
- package/examples/extensions/shutdown-command.ts +1 -1
- package/examples/extensions/snake.ts +1 -1
- package/examples/extensions/space-invaders.ts +1 -1
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/agents.ts +2 -2
- package/examples/extensions/subagent/index.ts +58 -29
- package/examples/extensions/summarize.ts +3 -2
- package/examples/extensions/tic-tac-toe.ts +1008 -0
- package/examples/extensions/titlebar-spinner.ts +2 -2
- package/examples/extensions/todo.ts +2 -2
- package/examples/extensions/tool-override.ts +1 -1
- package/examples/extensions/tools.ts +5 -0
- package/examples/extensions/truncated-tool.ts +1 -1
- package/examples/extensions/with-deps/index.ts +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +3 -3
- package/examples/extensions/working-indicator.ts +123 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/sdk/01-minimal.ts +14 -10
- package/examples/sdk/02-custom-model.ts +13 -9
- package/examples/sdk/03-custom-prompt.ts +32 -17
- package/examples/sdk/04-skills.ts +5 -2
- package/examples/sdk/05-tools.ts +23 -31
- package/examples/sdk/06-extensions.ts +14 -8
- package/examples/sdk/07-context-files.ts +5 -3
- package/examples/sdk/08-prompt-templates.ts +5 -2
- package/examples/sdk/09-api-keys-and-oauth.ts +8 -4
- package/examples/sdk/10-settings.ts +8 -6
- package/examples/sdk/11-sessions.ts +4 -0
- package/examples/sdk/12-full-control.ts +15 -19
- package/package.json +22 -16
- package/prompts/commands/brainstorm.md +148 -0
- package/prompts/commands/map-codebase.md +14 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Containerization
|
|
2
|
+
|
|
3
|
+
Pi runs with all permissions by default, but in some cases, you will want to have more control over what directories Pi can write to and which accesses it has.
|
|
4
|
+
|
|
5
|
+
There are two general options. You can either
|
|
6
|
+
1. run the whole `pi` process inside an isolated environment, or
|
|
7
|
+
2. run `pi` on the host and route tool execution into an isolated environment.
|
|
8
|
+
|
|
9
|
+
## Choose a pattern
|
|
10
|
+
|
|
11
|
+
| Pattern | What is isolated | Best for | Notes |
|
|
12
|
+
| --- | --- | --- | --- |
|
|
13
|
+
| OpenShell | Whole `pi` process in a policy-controlled sandbox | Local or remote managed sandbox | Requires an OpenShell gateway |
|
|
14
|
+
| Gondolin extension | Built-in tools and `!` commands | Local micro-VM isolation while keeping auth on host | See [`examples/extensions/gondolin/`](../examples/extensions/gondolin/). |
|
|
15
|
+
| Plain Docker | Whole `pi` process in a local container | Simple local isolation | Provider API keys enter the container. |
|
|
16
|
+
|
|
17
|
+
Extensions run wherever the `pi` process runs. If you run host `pi` with a tool-routing extension, other custom extension tools still run on the host unless they also delegate their operations.
|
|
18
|
+
|
|
19
|
+
## OpenShell
|
|
20
|
+
|
|
21
|
+
Use [NVIDIA OpenShell](https://docs.nvidia.com/openshell/about/overview) when you want a policy-controlled sandbox with filesystem, process, network, credential, and inference controls.
|
|
22
|
+
OpenShell can run sandboxes through a local gateway backed by Docker, Podman, or a VM runtime, or through a remote Kubernetes gateway.
|
|
23
|
+
|
|
24
|
+
Every sandbox requires an active gateway.
|
|
25
|
+
Register and select one before creating a sandbox:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
openshell gateway add <gateway-url> --name <name>
|
|
29
|
+
openshell gateway select <name>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Launch `pi` inside an OpenShell sandbox:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
openshell sandbox create --name pi-sandbox --from pi -- pi
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
In this pattern, the whole `pi` process runs inside the sandbox.
|
|
39
|
+
Built-in tools, `!` commands, and extension tools execute inside the OpenShell boundary.
|
|
40
|
+
|
|
41
|
+
If the gateway is remote, project files are not bind-mounted from the host, meaning writes in the sandbox are not reflected on your machine.
|
|
42
|
+
Clone the repository inside the sandbox or use OpenShell file transfer commands:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
openshell sandbox upload pi-sandbox ./repo /workspace
|
|
46
|
+
openshell sandbox download pi-sandbox /workspace/repo ./repo-out
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
OpenShell providers can keep raw model API keys outside the sandbox.
|
|
50
|
+
When inference routing is configured, code inside the sandbox can call `https://inference.local`, and the gateway injects the configured provider credentials upstream.
|
|
51
|
+
Configure Pi to use the corresponding OpenAI-compatible or Anthropic-compatible endpoint if you want model traffic to use this route.
|
|
52
|
+
|
|
53
|
+
## Gondolin
|
|
54
|
+
|
|
55
|
+
[Gondolin](https://github.com/earendil-works/gondolin) is a local Linux micro-VM.
|
|
56
|
+
Use the [example extension](../examples/extensions/gondolin) when you want `pi` on the host but all built-in tools routed into the VM.
|
|
57
|
+
|
|
58
|
+
Setup:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
cp -R packages/coding-agent/examples/extensions/gondolin ~/.pi/agent/extensions/gondolin
|
|
62
|
+
cd ~/.pi/agent/extensions/gondolin
|
|
63
|
+
npm install --ignore-scripts
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Run from the project you want mounted:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cd /path/to/project
|
|
70
|
+
pi -e ~/.pi/agent/extensions/gondolin
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The extension mounts the host cwd at `/workspace` in the VM and overrides `read`, `write`, `edit`, `bash`, `grep`, `find`, and `ls`.
|
|
74
|
+
User `!` commands are routed into the VM, as well.
|
|
75
|
+
File changes under `/workspace` write through to the host.
|
|
76
|
+
|
|
77
|
+
Requirements: Node.js >= 23.6.0 for `@earendil-works/gondolin`, plus QEMU (requires installation through your package manager).
|
|
78
|
+
|
|
79
|
+
## Plain Docker
|
|
80
|
+
|
|
81
|
+
Run the whole `pi` process in Docker when you want the simplest local container boundary.
|
|
82
|
+
|
|
83
|
+
`Dockerfile.pi`:
|
|
84
|
+
|
|
85
|
+
```dockerfile
|
|
86
|
+
FROM node:24-bookworm-slim
|
|
87
|
+
|
|
88
|
+
RUN apt-get update \
|
|
89
|
+
&& apt-get install -y --no-install-recommends bash ca-certificates git ripgrep \
|
|
90
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
91
|
+
RUN npm install -g --ignore-scripts @draht/coding-agent
|
|
92
|
+
|
|
93
|
+
WORKDIR /workspace
|
|
94
|
+
ENTRYPOINT ["pi"]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Build and run:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
docker build -t pi-sandbox -f Dockerfile.pi .
|
|
101
|
+
|
|
102
|
+
docker run --rm -it \
|
|
103
|
+
-e ANTHROPIC_API_KEY \
|
|
104
|
+
-v "$PWD:/workspace" \
|
|
105
|
+
-v pi-agent-home:/root/.pi/agent \
|
|
106
|
+
pi-sandbox
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The `-v "$PWD:/workspace"` mounts your current directory into the container at /workspace such that reads and writes in `/workspace` inside Docker directly affect your host files, like in the Gondolin example.
|
|
110
|
+
|
|
111
|
+
Use a named volume for `/root/.pi/agent` if you want container-local settings and sessions. Mounting your host `~/.pi/agent` exposes host auth and session files to the container.
|
package/docs/custom-provider.md
CHANGED
|
@@ -13,7 +13,6 @@ See these complete provider examples:
|
|
|
13
13
|
|
|
14
14
|
- [`examples/extensions/custom-provider-anthropic/`](../examples/extensions/custom-provider-anthropic/)
|
|
15
15
|
- [`examples/extensions/custom-provider-gitlab-duo/`](../examples/extensions/custom-provider-gitlab-duo/)
|
|
16
|
-
- [`examples/extensions/custom-provider-qwen-cli/`](../examples/extensions/custom-provider-qwen-cli/)
|
|
17
16
|
|
|
18
17
|
## Table of Contents
|
|
19
18
|
|
|
@@ -24,6 +23,7 @@ See these complete provider examples:
|
|
|
24
23
|
- [Unregister Provider](#unregister-provider)
|
|
25
24
|
- [OAuth Support](#oauth-support)
|
|
26
25
|
- [Custom Streaming API](#custom-streaming-api)
|
|
26
|
+
- [Context Overflow Errors](#context-overflow-errors)
|
|
27
27
|
- [Testing Your Implementation](#testing-your-implementation)
|
|
28
28
|
- [Config Reference](#config-reference)
|
|
29
29
|
- [Model Definition Reference](#model-definition-reference)
|
|
@@ -41,8 +41,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
41
41
|
|
|
42
42
|
// Register new provider with models
|
|
43
43
|
pi.registerProvider("my-provider", {
|
|
44
|
+
name: "My Provider",
|
|
44
45
|
baseUrl: "https://api.example.com",
|
|
45
|
-
apiKey: "MY_API_KEY",
|
|
46
|
+
apiKey: "$MY_API_KEY",
|
|
46
47
|
api: "openai-completions",
|
|
47
48
|
models: [
|
|
48
49
|
{
|
|
@@ -59,6 +60,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
59
60
|
}
|
|
60
61
|
```
|
|
61
62
|
|
|
63
|
+
The extension factory can also be `async`. For dynamic model discovery, fetch and register models in the factory instead of `session_start`. pi waits for the factory before startup continues, so the provider is available during interactive startup and to `pi --list-models`.
|
|
64
|
+
|
|
62
65
|
## Override Existing Provider
|
|
63
66
|
|
|
64
67
|
The simplest use case: redirect an existing provider through a proxy.
|
|
@@ -80,7 +83,7 @@ pi.registerProvider("openai", {
|
|
|
80
83
|
pi.registerProvider("google", {
|
|
81
84
|
baseUrl: "https://ai-gateway.corp.com/google",
|
|
82
85
|
headers: {
|
|
83
|
-
"X-Corp-Auth": "CORP_AUTH_TOKEN" // env var or literal
|
|
86
|
+
"X-Corp-Auth": "$CORP_AUTH_TOKEN" // env var or literal
|
|
84
87
|
}
|
|
85
88
|
});
|
|
86
89
|
```
|
|
@@ -91,10 +94,45 @@ When only `baseUrl` and/or `headers` are provided (no `models`), all existing mo
|
|
|
91
94
|
|
|
92
95
|
To add a completely new provider, specify `models` along with the required configuration.
|
|
93
96
|
|
|
97
|
+
If the model list comes from a remote endpoint, use an async extension factory:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
101
|
+
|
|
102
|
+
export default async function (pi: ExtensionAPI) {
|
|
103
|
+
const response = await fetch("http://localhost:1234/v1/models");
|
|
104
|
+
const payload = (await response.json()) as {
|
|
105
|
+
data: Array<{
|
|
106
|
+
id: string;
|
|
107
|
+
name?: string;
|
|
108
|
+
context_window?: number;
|
|
109
|
+
max_tokens?: number;
|
|
110
|
+
}>;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
pi.registerProvider("local-openai", {
|
|
114
|
+
baseUrl: "http://localhost:1234/v1",
|
|
115
|
+
apiKey: "$LOCAL_OPENAI_API_KEY",
|
|
116
|
+
api: "openai-completions",
|
|
117
|
+
models: payload.data.map((model) => ({
|
|
118
|
+
id: model.id,
|
|
119
|
+
name: model.name ?? model.id,
|
|
120
|
+
reasoning: false,
|
|
121
|
+
input: ["text"],
|
|
122
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
123
|
+
contextWindow: model.context_window ?? 128000,
|
|
124
|
+
maxTokens: model.max_tokens ?? 4096,
|
|
125
|
+
})),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
This registers the fetched models before startup finishes.
|
|
131
|
+
|
|
94
132
|
```typescript
|
|
95
133
|
pi.registerProvider("my-llm", {
|
|
96
134
|
baseUrl: "https://api.my-llm.com/v1",
|
|
97
|
-
apiKey: "MY_LLM_API_KEY", // env var
|
|
135
|
+
apiKey: "$MY_LLM_API_KEY", // env var reference
|
|
98
136
|
api: "openai-completions", // which streaming API to use
|
|
99
137
|
models: [
|
|
100
138
|
{
|
|
@@ -117,6 +155,8 @@ pi.registerProvider("my-llm", {
|
|
|
117
155
|
|
|
118
156
|
When `models` is provided, it **replaces** all existing models for that provider.
|
|
119
157
|
|
|
158
|
+
`apiKey` and custom header values use the same config value syntax as `models.json`: `!command` at the start executes a command for the whole value, `$ENV_VAR` and `${ENV_VAR}` interpolate environment variables, `$$` emits a literal `$`, and `$!` emits a literal `!`.
|
|
159
|
+
|
|
120
160
|
## Unregister Provider
|
|
121
161
|
|
|
122
162
|
Use `pi.unregisterProvider(name)` to remove a provider that was previously registered via `pi.registerProvider(name, ...)`:
|
|
@@ -125,7 +165,7 @@ Use `pi.unregisterProvider(name)` to remove a provider that was previously regis
|
|
|
125
165
|
// Register
|
|
126
166
|
pi.registerProvider("my-llm", {
|
|
127
167
|
baseUrl: "https://api.my-llm.com/v1",
|
|
128
|
-
apiKey: "MY_LLM_API_KEY",
|
|
168
|
+
apiKey: "$MY_LLM_API_KEY",
|
|
129
169
|
api: "openai-completions",
|
|
130
170
|
models: [
|
|
131
171
|
{
|
|
@@ -161,34 +201,38 @@ The `api` field determines which streaming implementation is used:
|
|
|
161
201
|
| `openai-codex-responses` | OpenAI Codex Responses API |
|
|
162
202
|
| `mistral-conversations` | Mistral SDK Conversations/Chat streaming |
|
|
163
203
|
| `google-generative-ai` | Google Generative AI API |
|
|
164
|
-
| `google-gemini-cli` | Google Cloud Code Assist API |
|
|
165
204
|
| `google-vertex` | Google Vertex AI API |
|
|
166
205
|
| `bedrock-converse-stream` | Amazon Bedrock Converse API |
|
|
167
206
|
|
|
168
|
-
Most OpenAI-compatible providers work with `openai-completions`. Use `compat` for quirks:
|
|
207
|
+
Most OpenAI-compatible providers work with `openai-completions`. Use model-level `thinkingLevelMap` for model-specific thinking levels, and `compat` for provider quirks:
|
|
169
208
|
|
|
170
209
|
```typescript
|
|
171
210
|
models: [{
|
|
172
211
|
id: "custom-model",
|
|
173
212
|
// ...
|
|
213
|
+
reasoning: true,
|
|
214
|
+
thinkingLevelMap: { // map pi levels to provider values; null hides unsupported levels
|
|
215
|
+
minimal: null,
|
|
216
|
+
low: null,
|
|
217
|
+
medium: null,
|
|
218
|
+
high: "default",
|
|
219
|
+
xhigh: "max"
|
|
220
|
+
},
|
|
174
221
|
compat: {
|
|
175
|
-
supportsDeveloperRole: false,
|
|
222
|
+
supportsDeveloperRole: false, // use "system" instead of "developer"
|
|
176
223
|
supportsReasoningEffort: true,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
},
|
|
184
|
-
maxTokensField: "max_tokens", // instead of "max_completion_tokens"
|
|
185
|
-
requiresToolResultName: true, // tool results need name field
|
|
186
|
-
thinkingFormat: "qwen" // top-level enable_thinking: true
|
|
187
|
-
}
|
|
188
|
-
}]
|
|
224
|
+
maxTokensField: "max_tokens", // instead of "max_completion_tokens"
|
|
225
|
+
requiresToolResultName: true, // tool results need name field
|
|
226
|
+
thinkingFormat: "qwen", // top-level enable_thinking: true
|
|
227
|
+
cacheControlFormat: "anthropic" // Anthropic-style cache_control markers
|
|
228
|
+
}
|
|
229
|
+
}]
|
|
189
230
|
```
|
|
190
231
|
|
|
191
|
-
Use `qwen-chat-template` instead for local Qwen-compatible servers that read `chat_template_kwargs.enable_thinking`.
|
|
232
|
+
Use `openrouter` for OpenRouter-style `reasoning: { effort }` controls. Use `together` for Together-style `reasoning: { enabled }` controls; with `supportsReasoningEffort`, it also sends `reasoning_effort`. Use `qwen-chat-template` instead for local Qwen-compatible servers that read `chat_template_kwargs.enable_thinking`.
|
|
233
|
+
Use `cacheControlFormat: "anthropic"` for OpenAI-compatible providers that expose Anthropic-style prompt caching via `cache_control` on the system prompt, last tool definition, and last user/assistant text content.
|
|
234
|
+
|
|
235
|
+
For Anthropic-compatible providers using `api: "anthropic-messages"`, set `compat.forceAdaptiveThinking: true` on models or providers whose upstream model requires adaptive thinking (`thinking.type: "adaptive"` plus `output_config.effort`). Built-in adaptive Claude models set this automatically. Set `compat.allowEmptySignature: true` only for providers that emit empty thinking signatures and expect `signature: ""` on replay.
|
|
192
236
|
|
|
193
237
|
> Migration note: Mistral moved from `openai-completions` to `mistral-conversations`.
|
|
194
238
|
> Use `mistral-conversations` for native Mistral models.
|
|
@@ -201,7 +245,7 @@ If your provider expects `Authorization: Bearer <key>` but doesn't use a standar
|
|
|
201
245
|
```typescript
|
|
202
246
|
pi.registerProvider("custom-api", {
|
|
203
247
|
baseUrl: "https://api.example.com",
|
|
204
|
-
apiKey: "MY_API_KEY",
|
|
248
|
+
apiKey: "$MY_API_KEY",
|
|
205
249
|
authHeader: true, // adds Authorization: Bearer header
|
|
206
250
|
api: "openai-completions",
|
|
207
251
|
models: [...]
|
|
@@ -223,17 +267,28 @@ pi.registerProvider("corporate-ai", {
|
|
|
223
267
|
name: "Corporate AI (SSO)",
|
|
224
268
|
|
|
225
269
|
async login(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials> {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
verificationUri: "https://sso.corp.com/device"
|
|
270
|
+
const method = await callbacks.onSelect({
|
|
271
|
+
message: "Select login method:",
|
|
272
|
+
options: [
|
|
273
|
+
{ id: "browser", label: "Browser OAuth" },
|
|
274
|
+
{ id: "device", label: "Device code" }
|
|
275
|
+
]
|
|
233
276
|
});
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
277
|
+
if (!method) throw new Error("Login cancelled");
|
|
278
|
+
|
|
279
|
+
let code: string;
|
|
280
|
+
if (method === "device") {
|
|
281
|
+
callbacks.onDeviceCode({
|
|
282
|
+
userCode: "ABCD-1234",
|
|
283
|
+
verificationUri: "https://sso.corp.com/device",
|
|
284
|
+
intervalSeconds: 5,
|
|
285
|
+
expiresInSeconds: 900
|
|
286
|
+
});
|
|
287
|
+
code = await pollDeviceCodeUntilComplete();
|
|
288
|
+
} else {
|
|
289
|
+
callbacks.onAuth({ url: "https://sso.corp.com/authorize?..." });
|
|
290
|
+
code = await callbacks.onPrompt({ message: "Enter SSO code:" });
|
|
291
|
+
}
|
|
237
292
|
|
|
238
293
|
// Exchange for tokens (your implementation)
|
|
239
294
|
const tokens = await exchangeCodeForTokens(code);
|
|
@@ -282,10 +337,21 @@ interface OAuthLoginCallbacks {
|
|
|
282
337
|
onAuth(params: { url: string }): void;
|
|
283
338
|
|
|
284
339
|
// Show device code (for device authorization flow)
|
|
285
|
-
onDeviceCode(params: {
|
|
340
|
+
onDeviceCode(params: {
|
|
341
|
+
userCode: string;
|
|
342
|
+
verificationUri: string;
|
|
343
|
+
intervalSeconds?: number;
|
|
344
|
+
expiresInSeconds?: number;
|
|
345
|
+
}): void;
|
|
286
346
|
|
|
287
347
|
// Prompt user for input (for manual token entry)
|
|
288
348
|
onPrompt(params: { message: string }): Promise<string>;
|
|
349
|
+
|
|
350
|
+
// Show an interactive selector, e.g. to choose browser OAuth vs device code
|
|
351
|
+
onSelect(params: {
|
|
352
|
+
message: string;
|
|
353
|
+
options: { id: string; label: string }[];
|
|
354
|
+
}): Promise<string | undefined>;
|
|
289
355
|
}
|
|
290
356
|
```
|
|
291
357
|
|
|
@@ -306,12 +372,12 @@ interface OAuthCredentials {
|
|
|
306
372
|
For providers with non-standard APIs, implement `streamSimple`. Study the existing provider implementations before writing your own:
|
|
307
373
|
|
|
308
374
|
**Reference implementations:**
|
|
309
|
-
- [anthropic.ts](https://github.com/
|
|
310
|
-
- [mistral.ts](https://github.com/
|
|
311
|
-
- [openai-completions.ts](https://github.com/
|
|
312
|
-
- [openai-responses.ts](https://github.com/
|
|
313
|
-
- [google.ts](https://github.com/
|
|
314
|
-
- [amazon-bedrock.ts](https://github.com/
|
|
375
|
+
- [anthropic.ts](https://github.com/earendil-works/pi-mono/blob/main/packages/ai/src/providers/anthropic.ts) - Anthropic Messages API
|
|
376
|
+
- [mistral.ts](https://github.com/earendil-works/pi-mono/blob/main/packages/ai/src/providers/mistral.ts) - Mistral Conversations API
|
|
377
|
+
- [openai-completions.ts](https://github.com/earendil-works/pi-mono/blob/main/packages/ai/src/providers/openai-completions.ts) - OpenAI Chat Completions
|
|
378
|
+
- [openai-responses.ts](https://github.com/earendil-works/pi-mono/blob/main/packages/ai/src/providers/openai-responses.ts) - OpenAI Responses API
|
|
379
|
+
- [google.ts](https://github.com/earendil-works/pi-mono/blob/main/packages/ai/src/providers/google.ts) - Google Generative AI
|
|
380
|
+
- [amazon-bedrock.ts](https://github.com/earendil-works/pi-mono/blob/main/packages/ai/src/providers/amazon-bedrock.ts) - AWS Bedrock
|
|
315
381
|
|
|
316
382
|
### Stream Pattern
|
|
317
383
|
|
|
@@ -467,6 +533,60 @@ output.usage.totalTokens = output.usage.input + output.usage.output +
|
|
|
467
533
|
calculateCost(model, output.usage);
|
|
468
534
|
```
|
|
469
535
|
|
|
536
|
+
### Context Overflow Errors
|
|
537
|
+
|
|
538
|
+
When a request exceeds the model's context window, pi can recover automatically by compacting the conversation and retrying. This recovery only kicks in if pi recognizes the failure as an overflow.
|
|
539
|
+
|
|
540
|
+
Detection runs on the finalized assistant message:
|
|
541
|
+
|
|
542
|
+
- `stopReason === "error"`
|
|
543
|
+
- `errorMessage` matches one of pi's known overflow patterns (see [`packages/ai/src/utils/overflow.ts`](https://github.com/earendil-works/pi-mono/blob/main/packages/ai/src/utils/overflow.ts))
|
|
544
|
+
|
|
545
|
+
If your provider returns overflow errors with a message pi does not recognize, normalize the error from the same extension that registers the provider. Use a `message_end` handler to rewrite the assistant message so its `errorMessage` starts with a phrase pi recognizes. The generic fallback `context_length_exceeded` is the safest choice.
|
|
546
|
+
|
|
547
|
+
```typescript
|
|
548
|
+
const MY_PROVIDER_OVERFLOW_PATTERN = /your provider's overflow phrase/i;
|
|
549
|
+
|
|
550
|
+
export default function (pi: ExtensionAPI) {
|
|
551
|
+
pi.registerProvider("my-provider", { /* ... */ });
|
|
552
|
+
|
|
553
|
+
pi.on("message_end", (event, ctx) => {
|
|
554
|
+
const message = event.message;
|
|
555
|
+
if (message.role !== "assistant") return;
|
|
556
|
+
if (message.stopReason !== "error") return;
|
|
557
|
+
if (
|
|
558
|
+
message.provider !== "my-provider" &&
|
|
559
|
+
ctx.model?.provider !== "my-provider"
|
|
560
|
+
)
|
|
561
|
+
return;
|
|
562
|
+
|
|
563
|
+
const errorMessage = message.errorMessage ?? "";
|
|
564
|
+
if (errorMessage.includes("context_length_exceeded")) return;
|
|
565
|
+
if (!MY_PROVIDER_OVERFLOW_PATTERN.test(errorMessage)) return;
|
|
566
|
+
|
|
567
|
+
return {
|
|
568
|
+
message: {
|
|
569
|
+
...message,
|
|
570
|
+
errorMessage: `context_length_exceeded: ${errorMessage}`,
|
|
571
|
+
},
|
|
572
|
+
};
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
`message_end` runs before pi tracks the assistant message for auto-compaction, so the rewritten `errorMessage` is what pi checks. With this in place, pi will:
|
|
578
|
+
|
|
579
|
+
1. Detect the overflow from `errorMessage`.
|
|
580
|
+
2. Drop the failed assistant message from live context.
|
|
581
|
+
3. Run compaction.
|
|
582
|
+
4. Retry the request once.
|
|
583
|
+
|
|
584
|
+
Guard the rewrite carefully:
|
|
585
|
+
|
|
586
|
+
- Scope it to your provider (`message.provider` and `ctx.model?.provider`) so unrelated errors from other providers are untouched.
|
|
587
|
+
- Match a provider-specific pattern, not pi's generic overflow patterns. Rewriting rate-limit or throttling errors (`rate limit`, `too many requests`) would falsely trigger compaction instead of pi's normal retry-with-backoff path.
|
|
588
|
+
- Skip when `errorMessage` already includes `context_length_exceeded` so the handler is idempotent.
|
|
589
|
+
|
|
470
590
|
### Registration
|
|
471
591
|
|
|
472
592
|
Register your stream function:
|
|
@@ -474,7 +594,7 @@ Register your stream function:
|
|
|
474
594
|
```typescript
|
|
475
595
|
pi.registerProvider("my-provider", {
|
|
476
596
|
baseUrl: "https://api.example.com",
|
|
477
|
-
apiKey: "MY_API_KEY",
|
|
597
|
+
apiKey: "$MY_API_KEY",
|
|
478
598
|
api: "my-custom-api",
|
|
479
599
|
models: [...],
|
|
480
600
|
streamSimple: streamMyProvider
|
|
@@ -483,7 +603,7 @@ pi.registerProvider("my-provider", {
|
|
|
483
603
|
|
|
484
604
|
## Testing Your Implementation
|
|
485
605
|
|
|
486
|
-
Test your provider against the same test suites used by built-in providers. Copy and adapt these test files from [packages/ai/test/](https://github.com/
|
|
606
|
+
Test your provider against the same test suites used by built-in providers. Copy and adapt these test files from [packages/ai/test/](https://github.com/earendil-works/pi-mono/tree/main/packages/ai/test):
|
|
487
607
|
|
|
488
608
|
| Test | Purpose |
|
|
489
609
|
|------|---------|
|
|
@@ -505,10 +625,13 @@ Run tests with your provider/model pairs to verify compatibility.
|
|
|
505
625
|
|
|
506
626
|
```typescript
|
|
507
627
|
interface ProviderConfig {
|
|
628
|
+
/** Display name for the provider in UI such as /login. */
|
|
629
|
+
name?: string;
|
|
630
|
+
|
|
508
631
|
/** API endpoint URL. Required when defining models. */
|
|
509
632
|
baseUrl?: string;
|
|
510
633
|
|
|
511
|
-
/** API key or
|
|
634
|
+
/** API key literal, env interpolation ($ENV_VAR or ${ENV_VAR}), or !command. Required when defining models (unless oauth). */
|
|
512
635
|
apiKey?: string;
|
|
513
636
|
|
|
514
637
|
/** API type for streaming. Required at provider or model level when defining models. */
|
|
@@ -521,7 +644,7 @@ interface ProviderConfig {
|
|
|
521
644
|
options?: SimpleStreamOptions
|
|
522
645
|
) => AssistantMessageEventStream;
|
|
523
646
|
|
|
524
|
-
/** Custom headers to include in requests. Values
|
|
647
|
+
/** Custom headers to include in requests. Values use the same resolution syntax as apiKey. */
|
|
525
648
|
headers?: Record<string, string>;
|
|
526
649
|
|
|
527
650
|
/** If true, adds Authorization: Bearer header with the resolved API key. */
|
|
@@ -554,9 +677,15 @@ interface ProviderModelConfig {
|
|
|
554
677
|
/** API type override for this specific model. */
|
|
555
678
|
api?: Api;
|
|
556
679
|
|
|
680
|
+
/** API endpoint URL override for this specific model. */
|
|
681
|
+
baseUrl?: string;
|
|
682
|
+
|
|
557
683
|
/** Whether the model supports extended thinking. */
|
|
558
684
|
reasoning: boolean;
|
|
559
685
|
|
|
686
|
+
/** Maps pi thinking levels to provider/model-specific values; null marks a level unsupported. */
|
|
687
|
+
thinkingLevelMap?: Partial<Record<"off" | "minimal" | "low" | "medium" | "high" | "xhigh", string | null>>;
|
|
688
|
+
|
|
560
689
|
/** Supported input types. */
|
|
561
690
|
input: ("text" | "image")[];
|
|
562
691
|
|
|
@@ -577,20 +706,31 @@ interface ProviderModelConfig {
|
|
|
577
706
|
/** Custom headers for this specific model. */
|
|
578
707
|
headers?: Record<string, string>;
|
|
579
708
|
|
|
580
|
-
/**
|
|
709
|
+
/** Compatibility settings for the selected API. */
|
|
581
710
|
compat?: {
|
|
711
|
+
// openai-completions
|
|
582
712
|
supportsStore?: boolean;
|
|
583
713
|
supportsDeveloperRole?: boolean;
|
|
584
714
|
supportsReasoningEffort?: boolean;
|
|
585
|
-
reasoningEffortMap?: Partial<Record<"minimal" | "low" | "medium" | "high" | "xhigh", string>>;
|
|
586
715
|
supportsUsageInStreaming?: boolean;
|
|
587
716
|
maxTokensField?: "max_completion_tokens" | "max_tokens";
|
|
588
717
|
requiresToolResultName?: boolean;
|
|
589
718
|
requiresAssistantAfterToolResult?: boolean;
|
|
590
719
|
requiresThinkingAsText?: boolean;
|
|
591
|
-
|
|
720
|
+
requiresReasoningContentOnAssistantMessages?: boolean;
|
|
721
|
+
thinkingFormat?: "openai" | "openrouter" | "deepseek" | "together" | "zai" | "qwen" | "qwen-chat-template";
|
|
722
|
+
cacheControlFormat?: "anthropic";
|
|
723
|
+
|
|
724
|
+
// anthropic-messages
|
|
725
|
+
supportsEagerToolInputStreaming?: boolean;
|
|
726
|
+
supportsLongCacheRetention?: boolean;
|
|
727
|
+
sendSessionAffinityHeaders?: boolean;
|
|
728
|
+
supportsCacheControlOnTools?: boolean;
|
|
729
|
+
forceAdaptiveThinking?: boolean;
|
|
730
|
+
allowEmptySignature?: boolean;
|
|
592
731
|
};
|
|
593
732
|
}
|
|
594
733
|
```
|
|
595
734
|
|
|
596
|
-
`qwen` is for DashScope-style top-level `enable_thinking`. Use `qwen-chat-template` for local Qwen-compatible servers that read `chat_template_kwargs.enable_thinking`.
|
|
735
|
+
`openrouter` sends `reasoning: { effort }`. `deepseek` sends `thinking: { type: "enabled" | "disabled" }` and `reasoning_effort` when enabled. `together` sends `reasoning: { enabled }` and also `reasoning_effort` when `supportsReasoningEffort` is enabled. `qwen` is for DashScope-style top-level `enable_thinking`. Use `qwen-chat-template` for local Qwen-compatible servers that read `chat_template_kwargs.enable_thinking`.
|
|
736
|
+
`cacheControlFormat: "anthropic"` applies Anthropic-style `cache_control` markers to the system prompt, last tool definition, and last user/assistant text content.
|
package/docs/development.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Development
|
|
2
2
|
|
|
3
|
-
See [AGENTS.md](
|
|
3
|
+
See [AGENTS.md](https://github.com/earendil-works/pi-mono/blob/main/AGENTS.md) for additional guidelines.
|
|
4
4
|
|
|
5
5
|
## Setup
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
git clone https://github.com/
|
|
9
|
-
cd
|
|
8
|
+
git clone https://github.com/earendil-works/pi-mono
|
|
9
|
+
cd pi-mono
|
|
10
10
|
npm install
|
|
11
11
|
npm run build
|
|
12
12
|
```
|
|
@@ -14,7 +14,7 @@ npm run build
|
|
|
14
14
|
Run from source:
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
/path/to/
|
|
17
|
+
/path/to/pi-mono/pi-test.sh
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
The script can be run from any directory. Pi keeps the caller's current working directory.
|
|
@@ -26,7 +26,7 @@ Configure via `package.json`:
|
|
|
26
26
|
```json
|
|
27
27
|
{
|
|
28
28
|
"piConfig": {
|
|
29
|
-
"name": "
|
|
29
|
+
"name": "pi",
|
|
30
30
|
"configDir": ".pi"
|
|
31
31
|
}
|
|
32
32
|
}
|