@draht/coding-agent 2026.7.13-1 → 2026.7.30
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 +87 -0
- package/README.md +1 -0
- package/dist/bun/cli.js +2 -0
- package/dist/bun/cli.js.map +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +12 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/credential-print.d.ts +23 -0
- package/dist/cli/credential-print.d.ts.map +1 -0
- package/dist/cli/credential-print.js +116 -0
- package/dist/cli/credential-print.js.map +1 -0
- package/dist/cli/list-models.d.ts +2 -2
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/startup-ui.js +1 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +3 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +3 -6
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +23 -9
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +52 -11
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +199 -101
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +15 -103
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +46 -259
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/cache-stats.d.ts +2 -2
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +1 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +8 -2
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +8 -11
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +19 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +71 -26
- package/dist/core/compaction/compaction.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 +6 -17
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/context-windows.d.ts +7 -0
- package/dist/core/context-windows.d.ts.map +1 -0
- package/dist/core/context-windows.js +35 -0
- package/dist/core/context-windows.js.map +1 -0
- package/dist/core/extensions/index.d.ts +1 -1
- 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.map +1 -1
- package/dist/core/extensions/loader.js +18 -3
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +6 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +80 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +48 -4
- 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 +22 -3
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +10 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +1 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/keybindings.d.ts +13 -3
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +11 -3
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-config.d.ts +542 -0
- package/dist/core/model-config.d.ts.map +1 -0
- package/dist/core/model-config.js +247 -0
- package/dist/core/model-config.js.map +1 -0
- package/dist/core/model-registry.d.ts +17 -123
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +59 -730
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +7 -6
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +41 -21
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +83 -0
- package/dist/core/model-runtime.d.ts.map +1 -0
- package/dist/core/model-runtime.js +431 -0
- package/dist/core/model-runtime.js.map +1 -0
- package/dist/core/models-store.d.ts +17 -0
- package/dist/core/models-store.d.ts.map +1 -0
- package/dist/core/models-store.js +46 -0
- package/dist/core/models-store.js.map +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +31 -12
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +4 -4
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-composer.d.ts +55 -0
- package/dist/core/provider-composer.d.ts.map +1 -0
- package/dist/core/provider-composer.js +375 -0
- package/dist/core/provider-composer.js.map +1 -0
- package/dist/core/radius.d.ts +2 -0
- package/dist/core/radius.d.ts.map +1 -0
- package/dist/core/radius.js +2 -0
- package/dist/core/radius.js.map +1 -0
- package/dist/core/remote-catalog-provider.d.ts +5 -0
- package/dist/core/remote-catalog-provider.d.ts.map +1 -0
- package/dist/core/remote-catalog-provider.js +115 -0
- package/dist/core/remote-catalog-provider.js.map +1 -0
- package/dist/core/resource-loader.d.ts +15 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +64 -9
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +15 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -0
- package/dist/core/runtime-credentials.js +35 -0
- package/dist/core/runtime-credentials.js.map +1 -0
- package/dist/core/sdk.d.ts +3 -6
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +22 -21
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +14 -6
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +116 -28
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +2 -12
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +34 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +3 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/usage-totals.d.ts +19 -0
- package/dist/core/usage-totals.d.ts.map +1 -0
- package/dist/core/usage-totals.js +52 -0
- package/dist/core/usage-totals.js.map +1 -0
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/index.js +3 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/llama/client.d.ts +61 -0
- package/dist/extensions/llama/client.d.ts.map +1 -0
- package/dist/extensions/llama/client.js +300 -0
- package/dist/extensions/llama/client.js.map +1 -0
- package/dist/extensions/llama/huggingface.d.ts +23 -0
- package/dist/extensions/llama/huggingface.d.ts.map +1 -0
- package/dist/extensions/llama/huggingface.js +139 -0
- package/dist/extensions/llama/huggingface.js.map +1 -0
- package/dist/extensions/llama/index.d.ts +3 -0
- package/dist/extensions/llama/index.d.ts.map +1 -0
- package/dist/extensions/llama/index.js +208 -0
- package/dist/extensions/llama/index.js.map +1 -0
- package/dist/extensions/llama/provider.d.ts +10 -0
- package/dist/extensions/llama/provider.d.ts.map +1 -0
- package/dist/extensions/llama/provider.js +107 -0
- package/dist/extensions/llama/provider.js.map +1 -0
- package/dist/extensions/llama/ui.d.ts +42 -0
- package/dist/extensions/llama/ui.d.ts.map +1 -0
- package/dist/extensions/llama/ui.js +400 -0
- package/dist/extensions/llama/ui.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +63 -16
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +22 -10
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +1 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +3 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +9 -2
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -2
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +16 -46
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +24 -23
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +5 -5
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +17 -8
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +11 -4
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +74 -41
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +4 -4
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +14 -25
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +22 -13
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +5 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +47 -12
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +12 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -0
- package/dist/modes/interactive/external-editor.js +37 -0
- package/dist/modes/interactive/external-editor.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +10 -7
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +369 -261
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +4 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +7 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +20 -2
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +11 -0
- 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.map +1 -1
- package/dist/package-manager-cli.js +67 -5
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +1 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +32 -8
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +3 -1
- package/dist/utils/version-check.js.map +1 -1
- package/docs/compaction.md +9 -4
- package/docs/custom-provider.md +50 -16
- package/docs/environment-variables.md +88 -0
- package/docs/extensions.md +228 -15
- package/docs/index.md +2 -0
- package/docs/json.md +5 -1
- package/docs/keybindings.md +2 -0
- package/docs/llama-cpp.md +99 -0
- package/docs/models.md +13 -2
- package/docs/packages.md +1 -0
- package/docs/prompt-templates.md +1 -0
- package/docs/providers.md +36 -2
- package/docs/quickstart.md +1 -1
- package/docs/rpc.md +107 -7
- package/docs/sdk.md +3 -0
- package/docs/session-format.md +19 -3
- package/docs/settings.md +1 -1
- package/docs/tui.md +41 -26
- package/docs/usage.md +4 -14
- package/examples/extensions/custom-compaction.ts +4 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +9 -3
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/custom-provider-qwen-cli/package.json +1 -1
- package/examples/extensions/gondolin/package.json +2 -2
- package/examples/extensions/handoff.ts +9 -1
- package/examples/extensions/kimi-deferred-tools.ts +61 -0
- package/examples/extensions/message-renderer.ts +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/summarize.ts +3 -0
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/02-custom-model.ts +5 -8
- package/examples/sdk/09-api-keys-and-oauth.ts +15 -31
- package/examples/sdk/12-full-control.ts +9 -12
- package/package.json +10 -8
- package/dist/core/provider-display-names.d.ts +0 -2
- package/dist/core/provider-display-names.d.ts.map +0 -1
- package/dist/core/provider-display-names.js +0 -36
- package/dist/core/provider-display-names.js.map +0 -1
package/docs/providers.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Providers
|
|
2
2
|
|
|
3
|
-
Pi supports subscription-based providers via OAuth and API key providers via environment variables or auth file.
|
|
3
|
+
Pi supports subscription-based providers via OAuth and API key providers via environment variables or auth file. Built-in catalogs ship with pi; configured providers may refresh newer catalogs and cache them in `~/.pi/agent/models-store.json` for offline use.
|
|
4
4
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
@@ -8,6 +8,7 @@ Pi supports subscription-based providers via OAuth and API key providers via env
|
|
|
8
8
|
- [API Keys](#api-keys)
|
|
9
9
|
- [Auth File](#auth-file)
|
|
10
10
|
- [Cloud Providers](#cloud-providers)
|
|
11
|
+
- [llama.cpp](#llamacpp)
|
|
11
12
|
- [Custom Providers](#custom-providers)
|
|
12
13
|
- [Resolution Order](#resolution-order)
|
|
13
14
|
|
|
@@ -18,8 +19,11 @@ Use `/login` in interactive mode, then select a provider:
|
|
|
18
19
|
- ChatGPT Plus/Pro (Codex)
|
|
19
20
|
- Claude Pro/Max
|
|
20
21
|
- GitHub Copilot
|
|
22
|
+
- xAI (Grok/X subscription)
|
|
23
|
+
- OpenRouter (OAuth-minted API key billed from OpenRouter credits)
|
|
24
|
+
- Radius
|
|
21
25
|
|
|
22
|
-
Use `/logout` to clear credentials. Tokens are stored in `~/.pi/agent/auth.json` and auto-refresh when expired.
|
|
26
|
+
Use `/logout` to clear credentials. Tokens are stored in `~/.pi/agent/auth.json` and auto-refresh when expired. OpenRouter instead mints a user-controlled API key that does not expire automatically.
|
|
23
27
|
|
|
24
28
|
### OpenAI Codex
|
|
25
29
|
|
|
@@ -35,6 +39,22 @@ Anthropic subscription auth is active for Claude Pro/Max accounts. Third-party h
|
|
|
35
39
|
- Press Enter for github.com, or enter your GitHub Enterprise Server domain
|
|
36
40
|
- If you get "model not supported", enable it in VS Code: Copilot Chat → model selector → select model → "Enable"
|
|
37
41
|
|
|
42
|
+
### xAI (Grok/X subscription)
|
|
43
|
+
|
|
44
|
+
- Run `/login xai`, then select **Use a subscription**
|
|
45
|
+
- `XAI_API_KEY` remains available through **Use an API key**
|
|
46
|
+
|
|
47
|
+
### OpenRouter
|
|
48
|
+
|
|
49
|
+
- Run `/login openrouter`, then select **Sign in with OpenRouter** to open the OpenRouter PKCE authorization flow
|
|
50
|
+
- The authorization creates a user-controlled OpenRouter API key billed from your OpenRouter credits
|
|
51
|
+
- On remote/headless machines (e.g. over SSH) the browser cannot reach the loopback callback; paste the final redirect URL (or the authorization code) into the login prompt instead
|
|
52
|
+
- `OPENROUTER_API_KEY` remains available through **Use an API key**
|
|
53
|
+
|
|
54
|
+
### Radius
|
|
55
|
+
|
|
56
|
+
Radius is a dynamic `pi-messages` gateway. `/login radius` stores OAuth tokens in `auth.json`; the gateway catalog is refreshed independently and cached in `models-store.json`. Custom Radius gateways can be declared in `models.json` with `"oauth": "radius"` and a gateway `baseUrl`.
|
|
57
|
+
|
|
38
58
|
## API Keys
|
|
39
59
|
|
|
40
60
|
### Environment Variables or Auth File
|
|
@@ -55,6 +75,7 @@ pi
|
|
|
55
75
|
| DeepSeek | `DEEPSEEK_API_KEY` | `deepseek` |
|
|
56
76
|
| NVIDIA NIM | `NVIDIA_API_KEY` | `nvidia` |
|
|
57
77
|
| Google Gemini | `GEMINI_API_KEY` | `google` |
|
|
78
|
+
| Amazon Bedrock | `AWS_BEARER_TOKEN_BEDROCK` | `amazon-bedrock` |
|
|
58
79
|
| Mistral | `MISTRAL_API_KEY` | `mistral` |
|
|
59
80
|
| Groq | `GROQ_API_KEY` | `groq` |
|
|
60
81
|
| Cerebras | `CEREBRAS_API_KEY` | `cerebras` |
|
|
@@ -67,12 +88,15 @@ pi
|
|
|
67
88
|
| ZAI Coding Plan (China) | `ZAI_CODING_CN_API_KEY` | `zai-coding-cn` |
|
|
68
89
|
| OpenCode Zen | `OPENCODE_API_KEY` | `opencode` |
|
|
69
90
|
| OpenCode Go | `OPENCODE_API_KEY` | `opencode-go` |
|
|
91
|
+
| Radius | `RADIUS_API_KEY` | `radius` |
|
|
70
92
|
| Hugging Face | `HF_TOKEN` | `huggingface` |
|
|
71
93
|
| Fireworks | `FIREWORKS_API_KEY` | `fireworks` |
|
|
72
94
|
| Together AI | `TOGETHER_API_KEY` | `together` |
|
|
73
95
|
| Kimi For Coding | `KIMI_API_KEY` | `kimi-coding` |
|
|
74
96
|
| MiniMax | `MINIMAX_API_KEY` | `minimax` |
|
|
75
97
|
| MiniMax (China) | `MINIMAX_CN_API_KEY` | `minimax-cn` |
|
|
98
|
+
| Qwen Token Plan | `QWEN_TOKEN_PLAN_API_KEY` | `qwen-token-plan` |
|
|
99
|
+
| Qwen Token Plan (China) | `QWEN_TOKEN_PLAN_CN_API_KEY` | `qwen-token-plan-cn` |
|
|
76
100
|
| Xiaomi MiMo | `XIAOMI_API_KEY` | `xiaomi` |
|
|
77
101
|
| Xiaomi MiMo Token Plan (China) | `XIAOMI_TOKEN_PLAN_CN_API_KEY` | `xiaomi-token-plan-cn` |
|
|
78
102
|
| Xiaomi MiMo Token Plan (Amsterdam) | `XIAOMI_TOKEN_PLAN_AMS_API_KEY` | `xiaomi-token-plan-ams` |
|
|
@@ -95,6 +119,8 @@ Store credentials in `~/.pi/agent/auth.json`:
|
|
|
95
119
|
"opencode": { "type": "api_key", "key": "..." },
|
|
96
120
|
"opencode-go": { "type": "api_key", "key": "..." },
|
|
97
121
|
"together": { "type": "api_key", "key": "..." },
|
|
122
|
+
"qwen-token-plan": { "type": "api_key", "key": "sk-sp-..." },
|
|
123
|
+
"qwen-token-plan-cn": { "type": "api_key", "key": "sk-sp-..." },
|
|
98
124
|
"xiaomi": { "type": "api_key", "key": "..." },
|
|
99
125
|
"xiaomi-token-plan-cn": { "type": "api_key", "key": "..." },
|
|
100
126
|
"xiaomi-token-plan-ams": { "type": "api_key", "key": "..." },
|
|
@@ -152,6 +178,8 @@ export AZURE_OPENAI_DEPLOYMENT_NAME_MAP=gpt-4=my-gpt4,gpt-4o=my-gpt4o
|
|
|
152
178
|
|
|
153
179
|
### Amazon Bedrock
|
|
154
180
|
|
|
181
|
+
Use `/login amazon-bedrock` to store a Bedrock API key, or configure one of the ambient AWS credential sources below:
|
|
182
|
+
|
|
155
183
|
```bash
|
|
156
184
|
# Option 1: AWS Profile
|
|
157
185
|
export AWS_PROFILE=your-profile
|
|
@@ -241,6 +269,12 @@ export GOOGLE_CLOUD_LOCATION=us-central1
|
|
|
241
269
|
|
|
242
270
|
Or set `GOOGLE_APPLICATION_CREDENTIALS` to a service account key file.
|
|
243
271
|
|
|
272
|
+
## llama.cpp
|
|
273
|
+
|
|
274
|
+
Pi supports the llama.cpp router server. Configure it with `/login llama.cpp`, manage loaded models with `/llama`, and select a loaded model with `/model`.
|
|
275
|
+
|
|
276
|
+
See [llama.cpp](llama-cpp.md) for server setup, model directory layout, environment variables, and command usage.
|
|
277
|
+
|
|
244
278
|
## Custom Providers
|
|
245
279
|
|
|
246
280
|
**Via models.json:** Add Ollama, LM Studio, vLLM, or any provider that speaks a supported API (OpenAI Completions, OpenAI Responses, Anthropic Messages, Google Generative AI). See [models.md](models.md).
|
package/docs/quickstart.md
CHANGED
|
@@ -113,7 +113,7 @@ pi @README.md "Summarize this"
|
|
|
113
113
|
pi @src/app.ts @src/app.test.ts "Review these together"
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
Images can be pasted with Ctrl+V (Alt+V on Windows)
|
|
116
|
+
Images or text can be pasted with Ctrl+V (Alt+V on Windows); images can also be dragged into supported terminals.
|
|
117
117
|
|
|
118
118
|
### Run shell commands
|
|
119
119
|
|
package/docs/rpc.md
CHANGED
|
@@ -23,7 +23,7 @@ Common options:
|
|
|
23
23
|
- **Responses**: JSON objects with `type: "response"` indicating command success/failure
|
|
24
24
|
- **Events**: Agent events streamed to stdout as JSON lines
|
|
25
25
|
|
|
26
|
-
All commands support an optional `id` field for request/response correlation. If provided, the corresponding response will include the same `id`.
|
|
26
|
+
All commands support an optional `id` field for request/response correlation. If provided, the corresponding response will include the same `id`. `bash_execution_update` events also include the `id` of their originating `bash` command.
|
|
27
27
|
|
|
28
28
|
### Framing
|
|
29
29
|
|
|
@@ -313,6 +313,26 @@ Response:
|
|
|
313
313
|
}
|
|
314
314
|
```
|
|
315
315
|
|
|
316
|
+
#### get_available_thinking_levels
|
|
317
|
+
|
|
318
|
+
List the thinking levels supported by the current model. Returns `["off"]` for a model without reasoning support.
|
|
319
|
+
|
|
320
|
+
```json
|
|
321
|
+
{"type": "get_available_thinking_levels"}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Response:
|
|
325
|
+
```json
|
|
326
|
+
{
|
|
327
|
+
"type": "response",
|
|
328
|
+
"command": "get_available_thinking_levels",
|
|
329
|
+
"success": true,
|
|
330
|
+
"data": {
|
|
331
|
+
"levels": ["off", "minimal", "low", "medium", "high"]
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
316
336
|
### Queue Modes
|
|
317
337
|
|
|
318
338
|
#### set_steering_mode
|
|
@@ -374,11 +394,22 @@ Response:
|
|
|
374
394
|
"summary": "Summary of conversation...",
|
|
375
395
|
"firstKeptEntryId": "abc123",
|
|
376
396
|
"tokensBefore": 150000,
|
|
397
|
+
"estimatedTokensAfter": 32000,
|
|
398
|
+
"usage": {
|
|
399
|
+
"input": 32000,
|
|
400
|
+
"output": 1200,
|
|
401
|
+
"cacheRead": 0,
|
|
402
|
+
"cacheWrite": 0,
|
|
403
|
+
"totalTokens": 33200,
|
|
404
|
+
"cost": {"input": 0.01, "output": 0.02, "cacheRead": 0, "cacheWrite": 0, "total": 0.03}
|
|
405
|
+
},
|
|
377
406
|
"details": {}
|
|
378
407
|
}
|
|
379
408
|
}
|
|
380
409
|
```
|
|
381
410
|
|
|
411
|
+
`estimatedTokensAfter` is a heuristic estimate over the rebuilt message context immediately after compaction, not a provider-exact token count. `usage` reports the LLM call or calls that generated the summary and may be omitted by custom compaction handlers.
|
|
412
|
+
|
|
382
413
|
#### set_auto_compaction
|
|
383
414
|
|
|
384
415
|
Enable or disable automatic compaction when context is nearly full.
|
|
@@ -424,15 +455,18 @@ Response:
|
|
|
424
455
|
|
|
425
456
|
#### bash
|
|
426
457
|
|
|
427
|
-
Execute a shell command and add output to conversation context.
|
|
458
|
+
Execute a shell command and add output to conversation context. Output streams as `bash_execution_update` events while the command runs; the response contains the final result.
|
|
428
459
|
|
|
429
460
|
```json
|
|
430
|
-
{"type": "bash", "command": "ls -la"}
|
|
461
|
+
{"id": "req-1", "type": "bash", "command": "ls -la"}
|
|
431
462
|
```
|
|
432
463
|
|
|
464
|
+
Include an `id` to associate streamed `bash_execution_update` events with this command.
|
|
465
|
+
|
|
433
466
|
Response:
|
|
434
467
|
```json
|
|
435
468
|
{
|
|
469
|
+
"id": "req-1",
|
|
436
470
|
"type": "response",
|
|
437
471
|
"command": "bash",
|
|
438
472
|
"success": true,
|
|
@@ -463,7 +497,7 @@ If output was truncated, includes `fullOutputPath`:
|
|
|
463
497
|
|
|
464
498
|
**How bash results reach the LLM:**
|
|
465
499
|
|
|
466
|
-
The `bash` command executes immediately and returns a `BashResult`. Internally, a `BashExecutionMessage` is created and stored in the agent's message state.
|
|
500
|
+
The `bash` command executes immediately and returns a `BashResult`. Internally, a `BashExecutionMessage` is created and stored in the agent's message state.
|
|
467
501
|
|
|
468
502
|
When the next `prompt` command is sent, all messages (including `BashExecutionMessage`) are transformed before being sent to the LLM. The `BashExecutionMessage` is converted to a `UserMessage` with this format:
|
|
469
503
|
|
|
@@ -478,7 +512,6 @@ drwxr-xr-x ...
|
|
|
478
512
|
This means:
|
|
479
513
|
1. Bash output is included in the LLM context on the **next prompt**, not immediately
|
|
480
514
|
2. Multiple bash commands can be executed before a prompt; all outputs will be included
|
|
481
|
-
3. No event is emitted for the `BashExecutionMessage` itself
|
|
482
515
|
|
|
483
516
|
#### abort_bash
|
|
484
517
|
|
|
@@ -534,7 +567,7 @@ Response:
|
|
|
534
567
|
}
|
|
535
568
|
```
|
|
536
569
|
|
|
537
|
-
`tokens`
|
|
570
|
+
`tokens` and `cost` include assistant messages, usage reported by tools, and compaction/branch-summary generation across the full session. `contextUsage` contains the actual current context-window estimate used for compaction and footer display.
|
|
538
571
|
|
|
539
572
|
`contextUsage` is omitted when no model or context window is available. `contextUsage.tokens` and `contextUsage.percent` are `null` immediately after compaction until a fresh post-compaction assistant response provides valid usage data.
|
|
540
573
|
|
|
@@ -798,7 +831,7 @@ Each command has:
|
|
|
798
831
|
|
|
799
832
|
## Events
|
|
800
833
|
|
|
801
|
-
Events are streamed to stdout as JSON lines during agent operation. Events do
|
|
834
|
+
Events are streamed to stdout as JSON lines during agent operation. Events do not generally include an `id` field; `bash_execution_update` includes the `id` of its originating `bash` command when one was provided.
|
|
802
835
|
|
|
803
836
|
### Event Types
|
|
804
837
|
|
|
@@ -812,6 +845,7 @@ Events are streamed to stdout as JSON lines during agent operation. Events do NO
|
|
|
812
845
|
| `message_start` | Message begins |
|
|
813
846
|
| `message_update` | Streaming update (text/thinking/toolcall deltas) |
|
|
814
847
|
| `message_end` | Message completes |
|
|
848
|
+
| `bash_execution_update` | Direct RPC bash command output chunk |
|
|
815
849
|
| `tool_execution_start` | Tool begins execution |
|
|
816
850
|
| `tool_execution_update` | Tool execution progress (streaming output) |
|
|
817
851
|
| `tool_execution_end` | Tool completes |
|
|
@@ -820,6 +854,9 @@ Events are streamed to stdout as JSON lines during agent operation. Events do NO
|
|
|
820
854
|
| `compaction_end` | Compaction completes |
|
|
821
855
|
| `auto_retry_start` | Auto-retry begins (after transient error) |
|
|
822
856
|
| `auto_retry_end` | Auto-retry completes (success or final failure) |
|
|
857
|
+
| `summarization_retry_scheduled` | Retry scheduled for a transient compaction or branch-summary summarization error |
|
|
858
|
+
| `summarization_retry_attempt_start` | Retried summarization request starts |
|
|
859
|
+
| `summarization_retry_finished` | Summarization retry loop completes |
|
|
823
860
|
| `extension_error` | Extension threw an error |
|
|
824
861
|
|
|
825
862
|
### agent_start
|
|
@@ -917,6 +954,20 @@ Example streaming a text response:
|
|
|
917
954
|
{"type":"message_update","message":{...},"assistantMessageEvent":{"type":"text_end","contentIndex":0,"content":"Hello world","partial":{...}}}
|
|
918
955
|
```
|
|
919
956
|
|
|
957
|
+
### bash_execution_update
|
|
958
|
+
|
|
959
|
+
Emitted once for each output chunk from a direct `bash` command. `id` matches the command's `id`, allowing clients to associate output with the correct command.
|
|
960
|
+
|
|
961
|
+
Events stream all output while the command runs, even if the final `bash` response's `output` is truncated.
|
|
962
|
+
|
|
963
|
+
```json
|
|
964
|
+
{
|
|
965
|
+
"type": "bash_execution_update",
|
|
966
|
+
"id": "req-1",
|
|
967
|
+
"delta": "total 48\n"
|
|
968
|
+
}
|
|
969
|
+
```
|
|
970
|
+
|
|
920
971
|
### tool_execution_start / tool_execution_update / tool_execution_end
|
|
921
972
|
|
|
922
973
|
Emitted when a tool begins, streams progress, and completes execution.
|
|
@@ -992,6 +1043,15 @@ The `reason` field is `"manual"`, `"threshold"`, or `"overflow"`.
|
|
|
992
1043
|
"summary": "Summary of conversation...",
|
|
993
1044
|
"firstKeptEntryId": "abc123",
|
|
994
1045
|
"tokensBefore": 150000,
|
|
1046
|
+
"estimatedTokensAfter": 32000,
|
|
1047
|
+
"usage": {
|
|
1048
|
+
"input": 32000,
|
|
1049
|
+
"output": 1200,
|
|
1050
|
+
"cacheRead": 0,
|
|
1051
|
+
"cacheWrite": 0,
|
|
1052
|
+
"totalTokens": 33200,
|
|
1053
|
+
"cost": {"input": 0.01, "output": 0.02, "cacheRead": 0, "cacheWrite": 0, "total": 0.03}
|
|
1054
|
+
},
|
|
995
1055
|
"details": {}
|
|
996
1056
|
},
|
|
997
1057
|
"aborted": false,
|
|
@@ -1037,6 +1097,36 @@ On final failure (max retries exceeded):
|
|
|
1037
1097
|
}
|
|
1038
1098
|
```
|
|
1039
1099
|
|
|
1100
|
+
### summarization_retry_scheduled / summarization_retry_attempt_start / summarization_retry_finished
|
|
1101
|
+
|
|
1102
|
+
Emitted when compaction or branch-summary summarization retries after a transient provider error. These events use the same retry settings as automatic assistant-turn retries.
|
|
1103
|
+
|
|
1104
|
+
```json
|
|
1105
|
+
{
|
|
1106
|
+
"type": "summarization_retry_scheduled",
|
|
1107
|
+
"attempt": 1,
|
|
1108
|
+
"maxAttempts": 3,
|
|
1109
|
+
"delayMs": 2000,
|
|
1110
|
+
"errorMessage": "terminated"
|
|
1111
|
+
}
|
|
1112
|
+
```
|
|
1113
|
+
|
|
1114
|
+
```json
|
|
1115
|
+
{
|
|
1116
|
+
"type": "summarization_retry_attempt_start",
|
|
1117
|
+
"source": "compaction",
|
|
1118
|
+
"reason": "threshold"
|
|
1119
|
+
}
|
|
1120
|
+
```
|
|
1121
|
+
|
|
1122
|
+
For branch summaries, `source` is `"branchSummary"` and no `reason` is present.
|
|
1123
|
+
|
|
1124
|
+
```json
|
|
1125
|
+
{
|
|
1126
|
+
"type": "summarization_retry_finished"
|
|
1127
|
+
}
|
|
1128
|
+
```
|
|
1129
|
+
|
|
1040
1130
|
### extension_error
|
|
1041
1131
|
|
|
1042
1132
|
Emitted when an extension throws an error.
|
|
@@ -1344,11 +1434,21 @@ Stop reasons: `"stop"`, `"length"`, `"toolUse"`, `"error"`, `"aborted"`
|
|
|
1344
1434
|
"toolCallId": "call_123",
|
|
1345
1435
|
"toolName": "bash",
|
|
1346
1436
|
"content": [{"type": "text", "text": "total 48\ndrwxr-xr-x ..."}],
|
|
1437
|
+
"usage": {
|
|
1438
|
+
"input": 100,
|
|
1439
|
+
"output": 50,
|
|
1440
|
+
"cacheRead": 0,
|
|
1441
|
+
"cacheWrite": 0,
|
|
1442
|
+
"totalTokens": 150,
|
|
1443
|
+
"cost": {"input": 0.0003, "output": 0.00075, "cacheRead": 0, "cacheWrite": 0, "total": 0.00105}
|
|
1444
|
+
},
|
|
1347
1445
|
"isError": false,
|
|
1348
1446
|
"timestamp": 1733234567890
|
|
1349
1447
|
}
|
|
1350
1448
|
```
|
|
1351
1449
|
|
|
1450
|
+
`usage` is optional and reports nested LLM work performed by the tool. When present, it contributes to session token and cost totals.
|
|
1451
|
+
|
|
1352
1452
|
### BashExecutionMessage
|
|
1353
1453
|
|
|
1354
1454
|
Created by the `bash` RPC command (not by LLM tool calls):
|
package/docs/sdk.md
CHANGED
|
@@ -323,6 +323,9 @@ session.subscribe((event) => {
|
|
|
323
323
|
case "compaction_end":
|
|
324
324
|
case "auto_retry_start":
|
|
325
325
|
case "auto_retry_end":
|
|
326
|
+
case "summarization_retry_scheduled":
|
|
327
|
+
case "summarization_retry_attempt_start":
|
|
328
|
+
case "summarization_retry_finished":
|
|
326
329
|
break;
|
|
327
330
|
}
|
|
328
331
|
});
|
package/docs/session-format.md
CHANGED
|
@@ -96,6 +96,7 @@ interface ToolResultMessage {
|
|
|
96
96
|
toolName: string;
|
|
97
97
|
content: (TextContent | ImageContent)[];
|
|
98
98
|
details?: any; // Tool-specific metadata
|
|
99
|
+
usage?: Usage; // Nested LLM work performed by the tool
|
|
99
100
|
isError: boolean;
|
|
100
101
|
timestamp: number;
|
|
101
102
|
}
|
|
@@ -116,6 +117,8 @@ interface Usage {
|
|
|
116
117
|
}
|
|
117
118
|
```
|
|
118
119
|
|
|
120
|
+
The exported pi-ai `StopReason` type also includes `"pending"`, but that value is reserved for partial messages in streaming events. Terminal `done`/`error` messages replace it with a completion reason before pi persists the assistant message, so `"pending"` should never appear in session JSONL.
|
|
121
|
+
|
|
119
122
|
### Extended Message Types (from pi-coding-agent)
|
|
120
123
|
|
|
121
124
|
```typescript
|
|
@@ -231,9 +234,18 @@ Created when context is compacted. Stores a summary of earlier messages.
|
|
|
231
234
|
{"type":"compaction","id":"f6g7h8i9","parentId":"e5f6g7h8","timestamp":"2024-12-03T14:10:00.000Z","summary":"User discussed X, Y, Z...","firstKeptEntryId":"c3d4e5f6","tokensBefore":50000}
|
|
232
235
|
```
|
|
233
236
|
|
|
237
|
+
Newer harness-generated compactions embed the retained post-compaction context directly on the entry, instead of `firstKeptEntryId`:
|
|
238
|
+
|
|
239
|
+
```json
|
|
240
|
+
{"type":"compaction","id":"f6g7h8i9","parentId":"e5f6g7h8","timestamp":"2024-12-03T14:10:00.000Z","summary":"User discussed X, Y, Z...","tokensBefore":50000,"retainedTail":[{"role":"user","content":"latest request"},{"role":"assistant","content":[{"type":"text","text":"latest reply"}],"provider":"anthropic","model":"claude-sonnet-4-5","usage":{...},"stopReason":"stop"}]}
|
|
241
|
+
```
|
|
242
|
+
|
|
234
243
|
Optional fields:
|
|
244
|
+
- `usage`: LLM usage from generating the summary; included in session token and cost totals
|
|
245
|
+
- `retainedTail`: Materialized `AgentMessage[]` kept after compaction. This is optional only for backward compatibility with older sessions. Newer harness-generated compactions include it so we can rebuild context from this checkpoint without walking older entries before the compaction entry.
|
|
235
246
|
- `details`: Implementation-specific data (e.g., `{ readFiles: string[], modifiedFiles: string[] }` for default, or custom data for extensions)
|
|
236
247
|
- `fromHook`: `true` if generated by an extension, `false`/`undefined` if pi-generated (legacy field name)
|
|
248
|
+
- `firstKeptEntryId`: for compatibility with old entry format.
|
|
237
249
|
|
|
238
250
|
### BranchSummaryEntry
|
|
239
251
|
|
|
@@ -244,6 +256,7 @@ Created when switching branches via `/tree` with an LLM generated summary of the
|
|
|
244
256
|
```
|
|
245
257
|
|
|
246
258
|
Optional fields:
|
|
259
|
+
- `usage`: LLM usage from generating the summary; included in session token and cost totals
|
|
247
260
|
- `details`: File tracking data (`{ readFiles: string[], modifiedFiles: string[] }`) for default, or custom data for extensions
|
|
248
261
|
- `fromHook`: `true` if generated by an extension, `false`/`undefined` if pi-generated (legacy field name)
|
|
249
262
|
|
|
@@ -311,8 +324,9 @@ Entries form a tree:
|
|
|
311
324
|
1. Collects all entries on the path
|
|
312
325
|
2. If a `CompactionEntry` is on the path:
|
|
313
326
|
- Includes the compaction entry first
|
|
314
|
-
-
|
|
315
|
-
-
|
|
327
|
+
- If `retainedTail` is present, it acts as a self-contained checkpoint and entries after the compaction are included
|
|
328
|
+
- Otherwise entries from `firstKeptEntryId` to the compaction are included
|
|
329
|
+
- Then entries after compaction are included
|
|
316
330
|
3. Preserves non-message entries in the selected range so interactive mode can render them
|
|
317
331
|
|
|
318
332
|
`buildSessionContext()` builds on that entry list to produce the message list for the LLM:
|
|
@@ -320,11 +334,13 @@ Entries form a tree:
|
|
|
320
334
|
1. Extracts current model and thinking level settings from the full path
|
|
321
335
|
2. Converts selected entries to messages:
|
|
322
336
|
- `message` -> stored `AgentMessage`
|
|
323
|
-
- `compaction` -> `compactionSummary`
|
|
337
|
+
- `compaction` -> `compactionSummary` plus `retainedTail` when present
|
|
324
338
|
- `branch_summary` -> `branchSummary`
|
|
325
339
|
- `custom_message` -> `CustomMessage`
|
|
326
340
|
- `custom` -> no context message
|
|
327
341
|
|
|
342
|
+
This makes newer compactions act like self-contained checkpoints. `retainedTail` is optional only so older sessions that only store `firstKeptEntryId` continue to load correctly.
|
|
343
|
+
|
|
328
344
|
## Parsing Example
|
|
329
345
|
|
|
330
346
|
```typescript
|
package/docs/settings.md
CHANGED
|
@@ -130,7 +130,7 @@ Set `PI_SKIP_VERSION_CHECK=1` to disable the Pi version update check. Use `--off
|
|
|
130
130
|
| `retry.provider.maxRetries` | number | `0` | Provider/SDK retry attempts |
|
|
131
131
|
| `retry.provider.maxRetryDelayMs` | number | `60000` | Max server-requested delay before failing (60s) |
|
|
132
132
|
|
|
133
|
-
When a provider requests a retry delay longer than `retry.provider.maxRetryDelayMs
|
|
133
|
+
When a provider requests a retry delay longer than `retry.provider.maxRetryDelayMs`, the request fails immediately with an informative error instead of waiting silently. Set it to `0` to disable the limit.
|
|
134
134
|
|
|
135
135
|
Keep `retry.provider.maxRetries` at `0` unless provider-level retries are explicitly needed. Setting it above `0` can make SDK/provider retries handle out-of-usage-limit errors before Pi sees them, which may block the agent until the provider quota resets in some circumstances.
|
|
136
136
|
|
package/docs/tui.md
CHANGED
|
@@ -90,19 +90,32 @@ Without this propagation, typing with an IME (Chinese, Japanese, Korean, etc.) w
|
|
|
90
90
|
|
|
91
91
|
```typescript
|
|
92
92
|
pi.on("session_start", async (_event, ctx) => {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
const result = await ctx.ui.custom<string | null>((tui, theme, keybindings, done) =>
|
|
94
|
+
new MyComponent({
|
|
95
|
+
theme,
|
|
96
|
+
keybindings,
|
|
97
|
+
onChange: () => tui.requestRender(),
|
|
98
|
+
onSelect: (value) => done(value),
|
|
99
|
+
onCancel: () => done(null),
|
|
100
|
+
})
|
|
101
|
+
);
|
|
96
102
|
});
|
|
97
103
|
```
|
|
98
104
|
|
|
99
|
-
**In custom tools** via `
|
|
105
|
+
**In custom tools** via `ctx.ui.custom()`:
|
|
100
106
|
|
|
101
107
|
```typescript
|
|
102
|
-
async execute(toolCallId, params, onUpdate, ctx
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
109
|
+
const result = await ctx.ui.custom<string | null>((tui, theme, keybindings, done) =>
|
|
110
|
+
new MyComponent({
|
|
111
|
+
theme,
|
|
112
|
+
keybindings,
|
|
113
|
+
onChange: () => tui.requestRender(),
|
|
114
|
+
onSelect: (value) => done(value),
|
|
115
|
+
onCancel: () => done(null),
|
|
116
|
+
})
|
|
117
|
+
);
|
|
118
|
+
// Use result...
|
|
106
119
|
}
|
|
107
120
|
```
|
|
108
121
|
|
|
@@ -374,24 +387,26 @@ Usage in an extension:
|
|
|
374
387
|
```typescript
|
|
375
388
|
pi.registerCommand("pick", {
|
|
376
389
|
description: "Pick an item",
|
|
377
|
-
handler: async (
|
|
390
|
+
handler: async (_args, ctx) => {
|
|
378
391
|
const items = ["Option A", "Option B", "Option C"];
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
resolve();
|
|
392
|
+
const selected = await ctx.ui.custom<string | null>((tui, _theme, _keybindings, done) => {
|
|
393
|
+
const selector = new MySelector(items);
|
|
394
|
+
selector.onSelect = done;
|
|
395
|
+
selector.onCancel = () => done(null);
|
|
396
|
+
|
|
397
|
+
return {
|
|
398
|
+
render: (width) => selector.render(width),
|
|
399
|
+
handleInput: (data) => {
|
|
400
|
+
selector.handleInput(data);
|
|
401
|
+
tui.requestRender();
|
|
402
|
+
},
|
|
403
|
+
invalidate: () => selector.invalidate(),
|
|
392
404
|
};
|
|
393
|
-
handle = ctx.ui.custom(selector);
|
|
394
405
|
});
|
|
406
|
+
|
|
407
|
+
if (selected !== null) {
|
|
408
|
+
ctx.ui.notify(`Selected: ${selected}`, "info");
|
|
409
|
+
}
|
|
395
410
|
}
|
|
396
411
|
});
|
|
397
412
|
```
|
|
@@ -486,7 +501,7 @@ class CachedComponent {
|
|
|
486
501
|
}
|
|
487
502
|
```
|
|
488
503
|
|
|
489
|
-
Call `invalidate()` when state changes, then `
|
|
504
|
+
Call `invalidate()` when state changes, then use the injected `tui.requestRender()` to trigger re-render.
|
|
490
505
|
|
|
491
506
|
## Invalidation and Theme Changes
|
|
492
507
|
|
|
@@ -885,9 +900,9 @@ class VimEditor extends CustomEditor {
|
|
|
885
900
|
|
|
886
901
|
export default function (pi: ExtensionAPI) {
|
|
887
902
|
pi.on("session_start", (_event, ctx) => {
|
|
888
|
-
// Factory receives theme and keybindings from the app
|
|
903
|
+
// Factory receives the TUI, theme, and keybindings from the app
|
|
889
904
|
ctx.ui.setEditorComponent((tui, theme, keybindings) =>
|
|
890
|
-
new VimEditor(theme, keybindings)
|
|
905
|
+
new VimEditor(tui, theme, keybindings)
|
|
891
906
|
);
|
|
892
907
|
});
|
|
893
908
|
}
|
package/docs/usage.md
CHANGED
|
@@ -11,7 +11,7 @@ The interface has four main areas:
|
|
|
11
11
|
- **Startup header** - shortcuts, loaded context files, prompt templates, skills, and extensions
|
|
12
12
|
- **Messages** - user messages, assistant responses, tool calls, tool results, notifications, errors, and extension UI
|
|
13
13
|
- **Editor** - where you type; border color indicates the current thinking level
|
|
14
|
-
- **Footer** - working directory, session name, token/cache usage, cost, context usage, and current model
|
|
14
|
+
- **Footer** - working directory, session name, token/cache usage, cost, context usage, and current model. Totals include assistant responses, usage reported by tools, and summary generation.
|
|
15
15
|
|
|
16
16
|
The editor can be replaced temporarily by built-in UI such as `/settings` or by custom extension UI.
|
|
17
17
|
|
|
@@ -22,6 +22,7 @@ The editor can be replaced temporarily by built-in UI such as `/settings` or by
|
|
|
22
22
|
| File reference | Type `@` to fuzzy-search project files |
|
|
23
23
|
| Path completion | Press Tab to complete paths |
|
|
24
24
|
| Multi-line input | Shift+Enter, or Ctrl+Enter on Windows Terminal |
|
|
25
|
+
| Copy response | Ctrl+X copies the last assistant message; in `/tree`, it copies the selected message |
|
|
25
26
|
| Images | Paste with Ctrl+V, Alt+V on Windows, or drag into the terminal |
|
|
26
27
|
| Shell command | `!command` runs and sends output to the model |
|
|
27
28
|
| Hidden shell command | `!!command` runs without sending output to the model |
|
|
@@ -36,6 +37,7 @@ Type `/` in the editor to open command completion. Extensions can register custo
|
|
|
36
37
|
| Command | Description |
|
|
37
38
|
|---------|-------------|
|
|
38
39
|
| `/login`, `/logout` | Manage OAuth or API-key credentials |
|
|
40
|
+
| [`/llama`](llama-cpp.md) | Download, load, and unload llama.cpp router models |
|
|
39
41
|
| `/model` | Switch models |
|
|
40
42
|
| `/scoped-models` | Enable/disable models for Ctrl+P cycling |
|
|
41
43
|
| `/settings` | Thinking level, theme, message delivery, transport |
|
|
@@ -147,6 +149,7 @@ pi remove <source> [-l] # Remove package
|
|
|
147
149
|
pi uninstall <source> [-l] # Alias for remove
|
|
148
150
|
pi update [source|self|pi] # Update pi and packages; reconcile pinned git refs
|
|
149
151
|
pi update --extensions # Update packages only; reconcile pinned git refs
|
|
152
|
+
pi update --models # Refresh model catalogs only
|
|
150
153
|
pi update --self # Update pi only
|
|
151
154
|
pi update --extension <src> # Update one package
|
|
152
155
|
pi list # List installed packages
|
|
@@ -283,19 +286,6 @@ pi --tools read,grep,find,ls -p "Review the code"
|
|
|
283
286
|
pi --exclude-tools ask_question
|
|
284
287
|
```
|
|
285
288
|
|
|
286
|
-
### Environment Variables
|
|
287
|
-
|
|
288
|
-
| Variable | Description |
|
|
289
|
-
|----------|-------------|
|
|
290
|
-
| `PI_CODING_AGENT_DIR` | Override config directory; default is `~/.pi/agent` |
|
|
291
|
-
| `PI_CODING_AGENT_SESSION_DIR` | Override session storage directory; overridden by `--session-dir` |
|
|
292
|
-
| `PI_PACKAGE_DIR` | Override package directory, useful for Nix/Guix store paths |
|
|
293
|
-
| `PI_OFFLINE` | Disable startup network operations, including update checks, package update checks, and install/update telemetry |
|
|
294
|
-
| `PI_SKIP_VERSION_CHECK` | Skip the Pi version update check at startup. This prevents the `pi.dev` latest-version request |
|
|
295
|
-
| `PI_TELEMETRY` | Override install/update telemetry and provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no`. This does not disable update checks |
|
|
296
|
-
| `PI_CACHE_RETENTION` | Set to `long` for extended prompt cache where supported |
|
|
297
|
-
| `VISUAL`, `EDITOR` | Fallback external editor for Ctrl+G when `externalEditor` is unset; defaults to Notepad on Windows and `nano` elsewhere |
|
|
298
|
-
|
|
299
289
|
## Design Principles
|
|
300
290
|
|
|
301
291
|
Pi keeps the core small and pushes workflow-specific behavior into extensions, skills, prompt templates, and packages.
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* pi --extension examples/extensions/custom-compaction.ts
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
import { uuidv7 } from "@draht/ai";
|
|
16
17
|
import { complete } from "@draht/ai/compat";
|
|
17
18
|
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
18
19
|
import { convertToLlm, serializeConversation } from "@draht/coding-agent";
|
|
@@ -96,6 +97,8 @@ ${conversationText}
|
|
|
96
97
|
env: auth.env,
|
|
97
98
|
maxTokens: 8192,
|
|
98
99
|
signal,
|
|
100
|
+
cacheRetention: "none",
|
|
101
|
+
sessionId: uuidv7(),
|
|
99
102
|
},
|
|
100
103
|
);
|
|
101
104
|
|
|
@@ -116,6 +119,7 @@ ${conversationText}
|
|
|
116
119
|
summary,
|
|
117
120
|
firstKeptEntryId,
|
|
118
121
|
tokensBefore,
|
|
122
|
+
usage: response.usage,
|
|
119
123
|
},
|
|
120
124
|
};
|
|
121
125
|
} catch (error) {
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
47
47
|
|
|
48
48
|
// =============================================================================
|
|
49
|
-
// OAuth
|
|
49
|
+
// OAuth implementation adapted for the legacy extension compatibility interface.
|
|
50
50
|
// =============================================================================
|
|
51
51
|
|
|
52
52
|
const decode = (s: string) => atob(s);
|
|
@@ -353,7 +353,7 @@ function streamCustomAnthropic(
|
|
|
353
353
|
totalTokens: 0,
|
|
354
354
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
355
355
|
},
|
|
356
|
-
stopReason: "
|
|
356
|
+
stopReason: "pending",
|
|
357
357
|
timestamp: Date.now(),
|
|
358
358
|
};
|
|
359
359
|
|
|
@@ -546,8 +546,14 @@ function streamCustomAnthropic(
|
|
|
546
546
|
if (options?.signal?.aborted) {
|
|
547
547
|
throw new Error("Request was aborted");
|
|
548
548
|
}
|
|
549
|
+
if (output.stopReason === "pending") {
|
|
550
|
+
throw new Error("Anthropic stream ended without a stop reason");
|
|
551
|
+
}
|
|
552
|
+
if (output.stopReason === "error" || output.stopReason === "aborted") {
|
|
553
|
+
throw new Error(output.errorMessage || "An unknown error occurred");
|
|
554
|
+
}
|
|
549
555
|
|
|
550
|
-
stream.push({ type: "done", reason: output.stopReason
|
|
556
|
+
stream.push({ type: "done", reason: output.stopReason, message: output });
|
|
551
557
|
stream.end();
|
|
552
558
|
} catch (error) {
|
|
553
559
|
for (const block of output.content) delete (block as any).index;
|