pi-namespace-patch 0.85.1 → 0.86.1-namespace.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +110 -0
- package/README.md +26 -705
- package/dist/bundle/chunks/anthropic-messages-MYU5ZMRF.js +6 -0
- package/dist/bundle/chunks/azure-openai-responses-HUSQ3GP2.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +47 -38
- package/dist/bundle/chunks/chunk-4YJERF5N.js +2 -0
- package/dist/bundle/chunks/chunk-A3JYRWB6.js +2 -0
- package/dist/bundle/chunks/chunk-CVPNLAPW.js +1562 -0
- package/dist/bundle/chunks/chunk-DTD7JQ7Y.js +42 -0
- package/dist/bundle/chunks/chunk-FUXEF6JQ.js +44 -0
- package/dist/bundle/chunks/{chunk-IDDQWTHI.js → chunk-RCZIEVGO.js} +10 -1
- package/dist/bundle/chunks/chunk-S7SZN6Z3.js +2 -0
- package/dist/bundle/chunks/chunk-WIUZI2CJ.js +11 -0
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/google-generative-ai-IMS5EK2Y.js +2 -0
- package/dist/bundle/chunks/google-vertex-O4YJEQUW.js +2 -0
- package/dist/bundle/chunks/jiti-loader-C3NU2SDH.js +21 -0
- package/dist/bundle/chunks/jiti-static-loader-E6ANQD5T.js +2 -0
- package/dist/bundle/chunks/meta.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-NOSQHBEY.js +5 -0
- package/dist/bundle/chunks/{node-KG362ECQ.js → node-O3RIBJRH.js} +1 -1
- package/dist/bundle/chunks/openai-codex-responses-QDSOTBBO.js +10 -0
- package/dist/bundle/chunks/openai-completions-CYGM3XXP.js +7 -0
- package/dist/bundle/chunks/openai-responses-HWEUZ6WZ.js +2 -0
- package/dist/bundle/chunks/{pi-messages-PML4SPVJ.js → pi-messages-GFKBWJHZ.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-R7YYFUSE.js +2 -0
- package/dist/bundle/cli-runtime.js +3 -0
- package/dist/bundle/cli.js +4 -2
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +56 -6
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +294 -157
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bug-report-upload.d.ts +12 -0
- package/dist/core/bug-report-upload.d.ts.map +1 -0
- package/dist/core/bug-report-upload.js +22 -0
- package/dist/core/bug-report-upload.js.map +1 -0
- package/dist/core/bug-report.d.ts +176 -0
- package/dist/core/bug-report.d.ts.map +1 -0
- package/dist/core/bug-report.js +292 -0
- package/dist/core/bug-report.js.map +1 -0
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +12 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/cache-warmer.d.ts +102 -0
- package/dist/core/cache-warmer.d.ts.map +1 -0
- package/dist/core/cache-warmer.js +342 -0
- package/dist/core/cache-warmer.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +2 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +11 -12
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/crash-log.d.ts +22 -0
- package/dist/core/crash-log.d.ts.map +1 -0
- package/dist/core/crash-log.js +71 -0
- package/dist/core/crash-log.js.map +1 -0
- package/dist/core/experimental.d.ts +0 -4
- package/dist/core/experimental.d.ts.map +1 -1
- package/dist/core/experimental.js +0 -4
- package/dist/core/experimental.js.map +1 -1
- 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/jiti-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-loader.js +4 -0
- package/dist/core/extensions/jiti-loader.js.map +1 -0
- package/dist/core/extensions/jiti-static-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-static-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-static-loader.js +4 -0
- package/dist/core/extensions/jiti-static-loader.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +38 -51
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +10 -7
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +85 -67
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +60 -50
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts +3 -0
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/virtual-modules.js +38 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +1 -20
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +1 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +1 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +101 -20
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +25 -18
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +5 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +8 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +2 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +5 -3
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer.d.ts +3 -2
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +2 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/radius.d.ts +3 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +6 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +60 -38
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-export.d.ts +6 -2
- package/dist/core/session-export.d.ts.map +1 -1
- package/dist/core/session-export.js +14 -13
- package/dist/core/session-export.js.map +1 -1
- package/dist/core/session-manager.d.ts +29 -6
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +159 -96
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +20 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +43 -7
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts +49 -6
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +121 -92
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +10 -4
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +1 -2
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js +9 -1
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +1 -2
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/usage-totals.d.ts +1 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +5 -1
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +2 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +7 -3
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +20 -5
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +13 -9
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +2 -2
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/bug-report.d.ts +16 -0
- package/dist/modes/interactive/bug-report.d.ts.map +1 -0
- package/dist/modes/interactive/bug-report.js +206 -0
- package/dist/modes/interactive/bug-report.js.map +1 -0
- package/dist/modes/interactive/chat-viewport.d.ts.map +1 -1
- package/dist/modes/interactive/chat-viewport.js +1 -1
- package/dist/modes/interactive/chat-viewport.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +12 -5
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +12 -5
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +3 -3
- 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/extension-editor.d.ts +4 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +7 -2
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +2 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +6 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +4 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +4 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +5 -5
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +74 -48
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +11 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +11 -4
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +2 -2
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +7 -7
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +18 -9
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +2 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +15 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +227 -84
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/session-share.d.ts +2 -0
- package/dist/modes/interactive/session-share.d.ts.map +1 -1
- package/dist/modes/interactive/session-share.js +8 -4
- package/dist/modes/interactive/session-share.js.map +1 -1
- package/dist/modes/interactive/tui-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/tui-renderer.js +2 -2
- package/dist/modes/interactive/tui-renderer.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +2 -2
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts +7 -0
- package/dist/utils/clipboard-command.d.ts.map +1 -0
- package/dist/utils/clipboard-command.js +45 -0
- package/dist/utils/clipboard-command.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +53 -81
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +111 -121
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +11 -4
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/wsl.d.ts +3 -0
- package/dist/utils/wsl.d.ts.map +1 -0
- package/dist/utils/wsl.js +15 -0
- package/dist/utils/wsl.js.map +1 -0
- package/dist/utils/zip.d.ts +7 -0
- package/dist/utils/zip.d.ts.map +1 -0
- package/dist/utils/zip.js +60 -0
- package/dist/utils/zip.js.map +1 -0
- package/docs/compaction.md +39 -13
- package/docs/custom-provider.md +22 -13
- package/docs/development.md +4 -4
- package/docs/docs.json +4 -0
- package/docs/environment-variables.md +1 -0
- package/docs/extensions.md +57 -43
- package/docs/json.md +4 -4
- package/docs/models.md +33 -2
- package/docs/providers.md +10 -2
- package/docs/sdk.md +4 -2
- package/docs/security.md +1 -1
- package/docs/session-format.md +82 -40
- package/docs/sessions.md +27 -0
- package/docs/settings.md +60 -1
- package/docs/termux.md +0 -1
- package/docs/tui.md +2 -2
- package/docs/usage.md +1 -0
- package/examples/extensions/README.md +0 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +18 -12
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/prompt-customizer.ts +19 -67
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +435 -762
- package/package.json +17 -23
- package/dist/bundle/chunks/anthropic-messages-VWZZOSJQ.js +0 -6
- package/dist/bundle/chunks/azure-openai-responses-BJLAM6CD.js +0 -2
- package/dist/bundle/chunks/chunk-AXIIZGTV.js +0 -2
- package/dist/bundle/chunks/chunk-CLNPYIDP.js +0 -42
- package/dist/bundle/chunks/chunk-GMWCTUPB.js +0 -2
- package/dist/bundle/chunks/chunk-JJ2YFCJF.js +0 -1547
- package/dist/bundle/chunks/chunk-OUXLLA64.js +0 -11
- package/dist/bundle/chunks/chunk-U6ZMQKGD.js +0 -50
- package/dist/bundle/chunks/chunk-UAQELI3K.js +0 -2
- package/dist/bundle/chunks/google-generative-ai-Q2K7FBDI.js +0 -2
- package/dist/bundle/chunks/google-vertex-7UJBF4S7.js +0 -2
- package/dist/bundle/chunks/mistral-conversations-4M6BZBX6.js +0 -5
- package/dist/bundle/chunks/openai-codex-responses-R6VYZTVY.js +0 -10
- package/dist/bundle/chunks/openai-completions-EKZT2IH2.js +0 -7
- package/dist/bundle/chunks/openai-responses-TFDINO6W.js +0 -2
- package/dist/utils/clipboard-native.d.ts +0 -11
- package/dist/utils/clipboard-native.d.ts.map +0 -1
- package/dist/utils/clipboard-native.js +0 -20
- package/dist/utils/clipboard-native.js.map +0 -1
- package/examples/extensions/kimi-deferred-tools.ts +0 -61
package/docs/models.md
CHANGED
|
@@ -9,6 +9,7 @@ Add custom providers and models (Ollama, vLLM, LM Studio, proxies) via `~/.pi/ag
|
|
|
9
9
|
- [Supported APIs](#supported-apis)
|
|
10
10
|
- [Provider Configuration](#provider-configuration)
|
|
11
11
|
- [Model Configuration](#model-configuration)
|
|
12
|
+
- [Prompt Cache Lifetimes](#prompt-cache-lifetimes)
|
|
12
13
|
- [Overriding Built-in Providers](#overriding-built-in-providers)
|
|
13
14
|
- [Per-model Overrides](#per-model-overrides)
|
|
14
15
|
- [Anthropic Messages Compatibility](#anthropic-messages-compatibility)
|
|
@@ -208,6 +209,7 @@ If your command is slow, expensive, rate-limited, or should keep using a previou
|
|
|
208
209
|
| `maxTokens` | No | `16384` | Maximum output tokens |
|
|
209
210
|
| `samplingParams` | No | omitted | Sampling parameters merged verbatim into every request body (see below) |
|
|
210
211
|
| `cost` | No | all zeros | Per-million-token rates with optional request-wide input pricing tiers |
|
|
212
|
+
| `promptCache` | No | omitted | Best-effort prompt cache lifetime in seconds per retention tier (see below) |
|
|
211
213
|
| `compat` | No | provider `compat` | Provider compatibility overrides. Merged with provider-level `compat` when both are set. |
|
|
212
214
|
|
|
213
215
|
A cost tier supplies a complete alternate rate set and applies to the full request when total input usage (`input + cacheRead + cacheWrite`) exceeds `inputTokensAbove`. When multiple tiers match, the highest threshold wins.
|
|
@@ -236,6 +238,19 @@ Current behavior:
|
|
|
236
238
|
- `/model`, `--list-models`, and the interactive footer display entries by model `id`.
|
|
237
239
|
- The configured `name` is used for model matching and secondary model detail text. It does not replace the footer/status-bar model id.
|
|
238
240
|
|
|
241
|
+
### Prompt Cache Lifetimes
|
|
242
|
+
|
|
243
|
+
`promptCache` states how long the provider keeps a prompt cache entry alive for each retention tier pi can request (`short` is the default tier; `long` is used when `PI_CACHE_RETENTION=long`). Values are seconds and are estimates: providers publish ranges, so pick the conservative end.
|
|
244
|
+
|
|
245
|
+
```json
|
|
246
|
+
{
|
|
247
|
+
"id": "claude-sonnet-5",
|
|
248
|
+
"promptCache": { "short": 300, "long": 3600 }
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
The built-in catalog fills this in for direct Anthropic (5 min / 1 h). Other providers, including direct OpenAI, have no built-in lifetime until their cache-expiry and replay behavior has been validated for warming. A model without a value for the tier a request used is never warmed; custom models and provider overrides can opt in when the backing cache behavior is known. See [Cache Warming](settings.md#cache-warming).
|
|
253
|
+
|
|
239
254
|
### Sampling Parameters
|
|
240
255
|
|
|
241
256
|
`samplingParams` is a free-form object merged verbatim into every request body for the model, after the fields pi sets itself, so its keys win. Use it to send sampling parameters pi does not model — including server-specific ones like llama.cpp's `min_p` or vLLM's `top_k`:
|
|
@@ -359,7 +374,23 @@ Use `modelOverrides` to customize built-in models and matching extension-registe
|
|
|
359
374
|
}
|
|
360
375
|
```
|
|
361
376
|
|
|
362
|
-
`modelOverrides` supports these fields per model: `name`, `reasoning`, `thinkingLevelMap`, `input`, `cost` (partial), `contextWindow`, `maxTokens`, `samplingParams` (merged per key), `headers`, `compat`.
|
|
377
|
+
`modelOverrides` supports these fields per model: `name`, `reasoning`, `thinkingLevelMap`, `input`, `cost` (partial), `promptCache` (merged per tier), `contextWindow`, `maxTokens`, `samplingParams` (merged per key), `headers`, `compat`.
|
|
378
|
+
|
|
379
|
+
Use a `promptCache` override to enable cache warming through a proxy whose backing cache you know, for example OpenRouter routed to Anthropic:
|
|
380
|
+
|
|
381
|
+
```json
|
|
382
|
+
{
|
|
383
|
+
"providers": {
|
|
384
|
+
"openrouter": {
|
|
385
|
+
"modelOverrides": {
|
|
386
|
+
"anthropic/claude-sonnet-4": {
|
|
387
|
+
"promptCache": { "short": 300 }
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
```
|
|
363
394
|
|
|
364
395
|
Direct OpenAI GPT-5.6 Sol, Terra, and Luna default to a `272000` context window so requests remain within OpenAI's short-context pricing tier. To opt into OpenAI's 1.05M context window, increase it for each model you use:
|
|
365
396
|
|
|
@@ -435,6 +466,7 @@ Built-in Anthropic models enable `supportsStrictTools` in their model metadata.
|
|
|
435
466
|
| `supportsMidConvoEffort` | Whether the exact Claude model transport supports per-turn effort system messages and thinking binding controls. Pi persists native effort levels and always sends `drop_block` when enabled. Default: `false`. |
|
|
436
467
|
| `allowEmptySignature` | Whether to replay empty thinking signatures as `signature: ""` instead of converting thinking to text. Default: `false`. |
|
|
437
468
|
| `supportsStrictTools` | Whether the provider accepts strict JSON-schema tool definitions. Default: `false`; built-in Anthropic models enable it in generated metadata. |
|
|
469
|
+
| `allowedFallbackModels` | Up to three server-side fallback models, each with `provider`, `model`, and complete `cost` metadata. An empty array disables fallback. |
|
|
438
470
|
|
|
439
471
|
## OpenAI Compatibility
|
|
440
472
|
|
|
@@ -481,7 +513,6 @@ For providers with partial OpenAI compatibility, use the `compat` field.
|
|
|
481
513
|
| `sessionAffinityFormat` | For `openai-completions` and `openai-responses`, the session-affinity header format: `openai` sends `session_id`/`x-client-request-id` (completions also `x-session-affinity`), `openai-nosession` omits the underscore-containing `session_id` header, `openrouter` sends `x-session-id`. Does not affect the `prompt_cache_key` body param. Default: auto-detected. |
|
|
482
514
|
| `supportsStrictMode` | Whether the provider accepts strict JSON-schema function tool definitions. Defaults depend on the API; built-in OpenAI models carry explicit capability metadata. |
|
|
483
515
|
| `supportsOpenAIGrammarTools` | Whether OpenAI-compatible APIs emit custom Lark/regex grammar tools. When `false`, grammar-constrained tools fall back to normal function tools. Default: `false`; the built-in model catalog enables it for GPT-5+ models on OpenAI, OpenAI Codex, Azure OpenAI, GitHub Copilot, opencode, and Cloudflare AI Gateway. |
|
|
484
|
-
| `deferredToolsMode` | Use provider-specific deferred tool serialization. Currently only `"kimi"` is supported for Kimi's OpenAI-compatible Chat Completions format. |
|
|
485
516
|
| `supportsLongCacheRetention` | Whether the provider accepts long cache retention when cache retention is `long`: `prompt_cache_options.ttl: "30m"` for GPT-5.6+ Responses models, `prompt_cache_retention: "24h"` for earlier OpenAI models, or `cache_control.ttl: "1h"` when `cacheControlFormat` is `anthropic`. Default: `true`. |
|
|
486
517
|
| `openRouterRouting` | OpenRouter provider routing preferences. This object is sent as-is in the `provider` field of the [OpenRouter API request](https://openrouter.ai/docs/guides/routing/provider-selection). |
|
|
487
518
|
| `vercelGatewayRouting` | Vercel AI Gateway routing config for provider selection (`only`, `order`) |
|
package/docs/providers.md
CHANGED
|
@@ -20,6 +20,7 @@ Use `/login` in interactive mode, then select a provider:
|
|
|
20
20
|
- Claude Pro/Max
|
|
21
21
|
- GitHub Copilot
|
|
22
22
|
- xAI (Grok/X subscription)
|
|
23
|
+
- Meta (Muse subscription)
|
|
23
24
|
- OpenRouter (OAuth-minted API key billed from OpenRouter credits)
|
|
24
25
|
- Radius
|
|
25
26
|
|
|
@@ -44,6 +45,12 @@ Anthropic subscription auth is active for Claude Pro/Max accounts. Third-party h
|
|
|
44
45
|
- Run `/login xai`, then select **Use a subscription**
|
|
45
46
|
- `XAI_API_KEY` remains available through **Use an API key**
|
|
46
47
|
|
|
48
|
+
### Meta (Muse subscription)
|
|
49
|
+
|
|
50
|
+
- Run `/login meta`, then select **Sign in with Meta** to open the device authorization flow
|
|
51
|
+
- The login mints a Model API key that is re-minted automatically about once a day
|
|
52
|
+
- `META_API_KEY` remains available through **Use an API key**
|
|
53
|
+
|
|
47
54
|
### OpenRouter
|
|
48
55
|
|
|
49
56
|
- Run `/login openrouter`, then select **Sign in with OpenRouter** to open the OpenRouter PKCE authorization flow
|
|
@@ -53,7 +60,7 @@ Anthropic subscription auth is active for Claude Pro/Max accounts. Third-party h
|
|
|
53
60
|
|
|
54
61
|
### Radius
|
|
55
62
|
|
|
56
|
-
Radius is a
|
|
63
|
+
Radius is a `pi-messages` gateway. Pi ships the public Radius model catalog for immediate and offline model lookup, then overlays it with the effective gateway catalog after authentication. `/login radius` stores OAuth tokens in `auth.json`; refreshed catalogs are cached in `models-store.json`. Custom Radius gateways can be declared in `models.json` with `"oauth": "radius"` and a gateway `baseUrl`; they do not inherit the public `radius.pi.dev` catalog.
|
|
57
64
|
|
|
58
65
|
## API Keys
|
|
59
66
|
|
|
@@ -94,6 +101,7 @@ pi
|
|
|
94
101
|
| Together AI | `TOGETHER_API_KEY` | `together` |
|
|
95
102
|
| Baseten | `BASETEN_API_KEY` | `baseten` |
|
|
96
103
|
| Kimi For Coding | `KIMI_API_KEY` | `kimi-coding` |
|
|
104
|
+
| Meta | `META_API_KEY` | `meta` |
|
|
97
105
|
| MiniMax | `MINIMAX_API_KEY` | `minimax` |
|
|
98
106
|
| MiniMax (China) | `MINIMAX_CN_API_KEY` | `minimax-cn` |
|
|
99
107
|
| Qwen Token Plan (existing catalog) | `QWEN_TOKEN_PLAN_API_KEY` | `qwen-token-plan` |
|
|
@@ -104,7 +112,7 @@ pi
|
|
|
104
112
|
| Xiaomi MiMo Token Plan (Amsterdam) | `XIAOMI_TOKEN_PLAN_AMS_API_KEY` | `xiaomi-token-plan-ams` |
|
|
105
113
|
| Xiaomi MiMo Token Plan (Singapore) | `XIAOMI_TOKEN_PLAN_SGP_API_KEY` | `xiaomi-token-plan-sgp` |
|
|
106
114
|
|
|
107
|
-
Reference for environment variables and `auth.json` keys: [`const envMap`](https://github.com/earendil-works/pi
|
|
115
|
+
Reference for environment variables and `auth.json` keys: [`const envMap`](https://github.com/earendil-works/pi/blob/main/packages/ai/src/env-api-keys.ts) in [`packages/ai/src/env-api-keys.ts`](https://github.com/earendil-works/pi/blob/main/packages/ai/src/env-api-keys.ts).
|
|
108
116
|
|
|
109
117
|
#### Auth File
|
|
110
118
|
|
package/docs/sdk.md
CHANGED
|
@@ -111,6 +111,8 @@ interface AgentSession {
|
|
|
111
111
|
}
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
+
`session.navigateTree()` rejects while an agent response, manual or automatic compaction, or another tree navigation is active, even with `summarize: false`. It does not queue navigation or return `{ cancelled: true }` for these conflicts. Wait for the active operation to finish (for example, with `await session.waitForIdle()`) and retry. Rejection leaves the active branch unchanged.
|
|
115
|
+
|
|
114
116
|
Session replacement APIs such as new-session, resume, fork, and import live on `AgentSessionRuntime`, not on `AgentSession`.
|
|
115
117
|
|
|
116
118
|
### createAgentSessionRuntime() and AgentSessionRuntime
|
|
@@ -244,8 +246,8 @@ const state = session.agent.state;
|
|
|
244
246
|
// state.messages: AgentMessage[] - conversation history
|
|
245
247
|
// state.model: Model - current model
|
|
246
248
|
// state.thinkingLevel: ThinkingLevel - current thinking level
|
|
247
|
-
// state.systemPrompt: string - system
|
|
248
|
-
// state.tools: AgentTool[] -
|
|
249
|
+
// state.systemPrompt: string - read-only, replayed from the transcript's system messages
|
|
250
|
+
// state.tools: AgentTool[] - executable tools; changes are declared to the model before the next request
|
|
249
251
|
// state.streamingMessage?: AgentMessage - current partial assistant message
|
|
250
252
|
// state.errorMessage?: string - latest assistant error
|
|
251
253
|
|
package/docs/security.md
CHANGED
|
@@ -54,6 +54,6 @@ If you bind-mount a host workspace read/write, writes from inside the container
|
|
|
54
54
|
|
|
55
55
|
## Reporting Security Issues
|
|
56
56
|
|
|
57
|
-
To report a security issue, follow the repository [Security Policy](https://github.com/earendil-works/pi
|
|
57
|
+
To report a security issue, follow the repository [Security Policy](https://github.com/earendil-works/pi/blob/main/SECURITY.md). Do not open a public issue for security-sensitive reports.
|
|
58
58
|
|
|
59
59
|
Expected local-agent behavior, lack of a built-in sandbox, prompt injection from untrusted content, and behavior of user-installed extensions or skills are generally outside the security boundary unless the report demonstrates a real privilege-boundary bypass or shows how pi grants access that the local user did not already have.
|
package/docs/session-format.md
CHANGED
|
@@ -5,10 +5,10 @@ Sessions are stored as JSONL (JSON Lines) files. Each line is a JSON object with
|
|
|
5
5
|
## File Location
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
~/.pi/agent/sessions/--<path>--/<timestamp>_<
|
|
8
|
+
~/.pi/agent/sessions/--<path>--/<timestamp>_<session-id>.jsonl
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
By default, `<session-id>` is a UUID. Callers can supply a custom ID through the SDK or `--session-id`. For `<path>`, Pi removes the leading path separator and replaces `/`, `\\`, and `:` with `-`.
|
|
12
12
|
|
|
13
13
|
## Deleting Sessions
|
|
14
14
|
|
|
@@ -28,11 +28,11 @@ Existing sessions are automatically migrated to the current version (v3) when lo
|
|
|
28
28
|
|
|
29
29
|
## Source Files
|
|
30
30
|
|
|
31
|
-
Source on GitHub ([pi
|
|
32
|
-
- [`packages/coding-agent/src/core/session-manager.ts`](https://github.com/earendil-works/pi
|
|
33
|
-
- [`packages/coding-agent/src/core/messages.ts`](https://github.com/earendil-works/pi
|
|
34
|
-
- [`packages/ai/src/types.ts`](https://github.com/earendil-works/pi
|
|
35
|
-
- [`packages/agent/src/types.ts`](https://github.com/earendil-works/pi
|
|
31
|
+
Source on GitHub ([pi](https://github.com/earendil-works/pi)):
|
|
32
|
+
- [`packages/coding-agent/src/core/session-manager.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/session-manager.ts) - Session entry types and SessionManager
|
|
33
|
+
- [`packages/coding-agent/src/core/messages.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/messages.ts) - Extended message types (BashExecutionMessage, CustomMessage, etc.)
|
|
34
|
+
- [`packages/ai/src/types.ts`](https://github.com/earendil-works/pi/blob/main/packages/ai/src/types.ts) - Base message types (UserMessage, AssistantMessage, ToolResultMessage)
|
|
35
|
+
- [`packages/agent/src/types.ts`](https://github.com/earendil-works/pi/blob/main/packages/agent/src/types.ts) - AgentMessage union type
|
|
36
36
|
|
|
37
37
|
For TypeScript definitions in your project, inspect `node_modules/@earendil-works/pi-coding-agent/dist/` and `node_modules/@earendil-works/pi-ai/dist/`.
|
|
38
38
|
|
|
@@ -48,6 +48,7 @@ Messages contain arrays of typed content blocks:
|
|
|
48
48
|
interface TextContent {
|
|
49
49
|
type: "text";
|
|
50
50
|
text: string;
|
|
51
|
+
textSignature?: string;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
interface ImageContent {
|
|
@@ -59,6 +60,8 @@ interface ImageContent {
|
|
|
59
60
|
interface ThinkingContent {
|
|
60
61
|
type: "thinking";
|
|
61
62
|
thinking: string;
|
|
63
|
+
thinkingSignature?: string;
|
|
64
|
+
redacted?: boolean;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
interface ToolCall {
|
|
@@ -66,12 +69,22 @@ interface ToolCall {
|
|
|
66
69
|
id: string;
|
|
67
70
|
name: string;
|
|
68
71
|
arguments: Record<string, any>;
|
|
72
|
+
thoughtSignature?: string;
|
|
73
|
+
namespace?: string;
|
|
69
74
|
}
|
|
70
75
|
```
|
|
71
76
|
|
|
72
77
|
### Base Message Types (from pi-ai)
|
|
73
78
|
|
|
74
79
|
```typescript
|
|
80
|
+
interface SystemMessage {
|
|
81
|
+
role: "system";
|
|
82
|
+
content: string | TextContent[];
|
|
83
|
+
toolsAdded?: Tool[];
|
|
84
|
+
toolsRemoved?: Array<{ name: string }>;
|
|
85
|
+
timestamp: number; // Unix ms
|
|
86
|
+
}
|
|
87
|
+
|
|
75
88
|
interface UserMessage {
|
|
76
89
|
role: "user";
|
|
77
90
|
content: string | (TextContent | ImageContent)[];
|
|
@@ -84,9 +97,16 @@ interface AssistantMessage {
|
|
|
84
97
|
api: string;
|
|
85
98
|
provider: string;
|
|
86
99
|
model: string;
|
|
100
|
+
responseModel?: string;
|
|
101
|
+
responseId?: string;
|
|
102
|
+
providerThinkingLevel?: string;
|
|
103
|
+
diagnostics?: AssistantMessageDiagnostic[];
|
|
87
104
|
usage: Usage;
|
|
88
|
-
stopReason: "stop" | "length" | "toolUse" | "error" | "aborted";
|
|
105
|
+
stopReason: "pending" | "stop" | "length" | "toolUse" | "error" | "aborted" | "deferred";
|
|
106
|
+
deferred?: DeferredHandle;
|
|
89
107
|
errorMessage?: string;
|
|
108
|
+
rawStopReason?: string;
|
|
109
|
+
endTurn?: boolean;
|
|
90
110
|
timestamp: number;
|
|
91
111
|
}
|
|
92
112
|
|
|
@@ -106,6 +126,8 @@ interface Usage {
|
|
|
106
126
|
output: number;
|
|
107
127
|
cacheRead: number;
|
|
108
128
|
cacheWrite: number;
|
|
129
|
+
cacheWrite1h?: number;
|
|
130
|
+
reasoning?: number;
|
|
109
131
|
totalTokens: number;
|
|
110
132
|
cost: {
|
|
111
133
|
input: number;
|
|
@@ -117,7 +139,7 @@ interface Usage {
|
|
|
117
139
|
}
|
|
118
140
|
```
|
|
119
141
|
|
|
120
|
-
|
|
142
|
+
`"pending"` is reserved for partial messages in streaming events. Terminal events replace it with a completion reason before Pi persists the assistant message, so `"pending"` should never appear in session JSONL. `"deferred"` is a terminal reason for a provider response that will complete later; its `deferred` handle contains the provider data needed to retrieve that response.
|
|
121
143
|
|
|
122
144
|
### Extended Message Types (from pi-coding-agent)
|
|
123
145
|
|
|
@@ -146,7 +168,7 @@ interface CustomMessage {
|
|
|
146
168
|
interface BranchSummaryMessage {
|
|
147
169
|
role: "branchSummary";
|
|
148
170
|
summary: string;
|
|
149
|
-
fromId: string;
|
|
171
|
+
fromId: string | null; // Previous leaf whose abandoned path was summarized
|
|
150
172
|
timestamp: number;
|
|
151
173
|
}
|
|
152
174
|
|
|
@@ -162,6 +184,7 @@ interface CompactionSummaryMessage {
|
|
|
162
184
|
|
|
163
185
|
```typescript
|
|
164
186
|
type AgentMessage =
|
|
187
|
+
| SystemMessage
|
|
165
188
|
| UserMessage
|
|
166
189
|
| AssistantMessage
|
|
167
190
|
| ToolResultMessage
|
|
@@ -178,8 +201,8 @@ All entries (except `SessionHeader`) extend `SessionEntryBase`:
|
|
|
178
201
|
```typescript
|
|
179
202
|
interface SessionEntryBase {
|
|
180
203
|
type: string;
|
|
181
|
-
id: string; // 8-char hex ID
|
|
182
|
-
parentId: string | null; // Parent entry ID (null for
|
|
204
|
+
id: string; // Usually an 8-char hex ID; may fall back to a full UUID
|
|
205
|
+
parentId: string | null; // Parent entry ID (null for a root entry)
|
|
183
206
|
timestamp: string; // ISO timestamp
|
|
184
207
|
}
|
|
185
208
|
```
|
|
@@ -202,12 +225,19 @@ For sessions with a parent (created via `/fork`, `/clone`, or `newSession({ pare
|
|
|
202
225
|
|
|
203
226
|
### SessionMessageEntry
|
|
204
227
|
|
|
205
|
-
A message in the conversation. The `message` field contains an `AgentMessage`.
|
|
228
|
+
A message in the conversation. The `message` field contains an `AgentMessage`. System messages carry the prompt and tool loadout: the first request of a session persists one with every prompt section and tool declaration, and later changes persist as system messages that patch `sections` by name (`null` removes one) and list `toolsAdded`/`toolsRemoved`. Replaying them in order yields the current prompt and tools; there is no separate prompt state entry.
|
|
229
|
+
|
|
230
|
+
```json
|
|
231
|
+
{"type":"message","id":"a0b1c2d3","parentId":null,"timestamp":"2024-12-03T14:00:00.000Z","message":{"role":"system","content":"","sections":{"preamble":"You are an expert coding assistant...","tools":"<tools>\n- read: ...\n</tools>","cwd":"/project"},"toolsAdded":[{"name":"read","description":"...","parameters":{}}],"timestamp":1733234400000}}
|
|
232
|
+
{"type":"message","id":"d4e5f6g7","parentId":"c3d4e5f6","timestamp":"2024-12-03T14:04:00.000Z","message":{"role":"system","content":"","sections":{"skills":"<skills>...</skills>"},"toolsRemoved":[{"name":"write"}],"timestamp":1733234640000}}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Sessions created before system messages existed have no leading system message; the first request declares the current prompt as a later system message, which replays the same way.
|
|
206
236
|
|
|
207
237
|
```json
|
|
208
|
-
{"type":"message","id":"a1b2c3d4","parentId":"prev1234","timestamp":"2024-12-03T14:00:01.000Z","message":{"role":"user","content":"Hello"}}
|
|
209
|
-
{"type":"message","id":"b2c3d4e5","parentId":"a1b2c3d4","timestamp":"2024-12-03T14:00:02.000Z","message":{"role":"assistant","content":[{"type":"text","text":"Hi!"}],"provider":"anthropic","model":"claude-sonnet-4-5","usage":{...},"stopReason":"stop"}}
|
|
210
|
-
{"type":"message","id":"c3d4e5f6","parentId":"b2c3d4e5","timestamp":"2024-12-03T14:00:03.000Z","message":{"role":"toolResult","toolCallId":"call_123","toolName":"bash","content":[{"type":"text","text":"output"}],"isError":false}}
|
|
238
|
+
{"type":"message","id":"a1b2c3d4","parentId":"prev1234","timestamp":"2024-12-03T14:00:01.000Z","message":{"role":"user","content":"Hello","timestamp":1733234401000}}
|
|
239
|
+
{"type":"message","id":"b2c3d4e5","parentId":"a1b2c3d4","timestamp":"2024-12-03T14:00:02.000Z","message":{"role":"assistant","content":[{"type":"text","text":"Hi!"}],"api":"anthropic-messages","provider":"anthropic","model":"claude-sonnet-4-5","usage":{...},"stopReason":"stop","timestamp":1733234402000}}
|
|
240
|
+
{"type":"message","id":"c3d4e5f6","parentId":"b2c3d4e5","timestamp":"2024-12-03T14:00:03.000Z","message":{"role":"toolResult","toolCallId":"call_123","toolName":"bash","content":[{"type":"text","text":"output"}],"isError":false,"timestamp":1733234403000}}
|
|
211
241
|
```
|
|
212
242
|
|
|
213
243
|
### ModelChangeEntry
|
|
@@ -226,26 +256,31 @@ Emitted when the user changes the thinking/reasoning level.
|
|
|
226
256
|
{"type":"thinking_level_change","id":"e5f6g7h8","parentId":"d4e5f6g7","timestamp":"2024-12-03T14:06:00.000Z","thinkingLevel":"high"}
|
|
227
257
|
```
|
|
228
258
|
|
|
229
|
-
###
|
|
259
|
+
### UsageEntry
|
|
230
260
|
|
|
231
|
-
|
|
261
|
+
Records model-attributed usage that is not an assistant message and does not participate in LLM context. `kind` is an arbitrary string identifying the operation; for example, cache warming uses `"cache_warm"`.
|
|
232
262
|
|
|
233
263
|
```json
|
|
234
|
-
{"type":"
|
|
264
|
+
{"type":"usage","id":"f6g7h8i9","parentId":"e5f6g7h8","timestamp":"2024-12-03T14:08:00.000Z","kind":"cache_warm","provider":"anthropic","model":"claude-sonnet-4-5","usage":{"input":0,"output":0,"cacheRead":50000,"cacheWrite":0,"totalTokens":50000,"cost":{"input":0,"output":0,"cacheRead":0.015,"cacheWrite":0,"total":0.015}}}
|
|
235
265
|
```
|
|
236
266
|
|
|
237
|
-
|
|
267
|
+
Usage entries contribute to session token and cost totals. Pi hides them from the conversation tree. Consumers should treat unknown `kind` values as normal usage rather than rejecting them.
|
|
268
|
+
|
|
269
|
+
### CompactionEntry
|
|
270
|
+
|
|
271
|
+
Created when context is compacted. Stores a summary of earlier messages and a complete system prompt/tool checkpoint.
|
|
238
272
|
|
|
239
273
|
```json
|
|
240
|
-
{"type":"compaction","id":"f6g7h8i9","parentId":"e5f6g7h8","timestamp":"2024-12-03T14:10:00.000Z","summary":"User discussed X, Y, Z...","tokensBefore":50000,"
|
|
274
|
+
{"type":"compaction","id":"f6g7h8i9","parentId":"e5f6g7h8","timestamp":"2024-12-03T14:10:00.000Z","summary":"User discussed X, Y, Z...","firstKeptEntryId":"c3d4e5f6","tokensBefore":50000,"systemMessage":{"role":"system","content":"You are a coding assistant.","toolsAdded":[],"timestamp":1733235000000}}
|
|
241
275
|
```
|
|
242
276
|
|
|
277
|
+
`firstKeptEntryId` is required. It identifies the first entry retained from before the compaction entry. When rebuilding context, Pi replaces older summarized entries with the compaction summary and keeps the range beginning at this entry.
|
|
278
|
+
|
|
243
279
|
Optional fields:
|
|
280
|
+
- `systemMessage`: The replayed prompt sections and tool declarations at the compaction boundary; it becomes the leading system message of the compacted context, and system messages among the kept entries are dropped in its favor. It is absent on older session entries.
|
|
244
281
|
- `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.
|
|
246
282
|
- `details`: Implementation-specific data (e.g., `{ readFiles: string[], modifiedFiles: string[] }` for default, or custom data for extensions)
|
|
247
283
|
- `fromHook`: `true` if generated by an extension, `false`/`undefined` if pi-generated (legacy field name)
|
|
248
|
-
- `firstKeptEntryId`: for compatibility with old entry format.
|
|
249
284
|
|
|
250
285
|
### BranchSummaryEntry
|
|
251
286
|
|
|
@@ -255,6 +290,8 @@ Created when switching branches via `/tree` with an LLM generated summary of the
|
|
|
255
290
|
{"type":"branch_summary","id":"g7h8i9j0","parentId":"a1b2c3d4","timestamp":"2024-12-03T14:15:00.000Z","fromId":"f6g7h8i9","summary":"Branch explored approach A..."}
|
|
256
291
|
```
|
|
257
292
|
|
|
293
|
+
`parentId` is the entry from which the new branch continues. `fromId` is the previous leaf whose abandoned path was summarized.
|
|
294
|
+
|
|
258
295
|
Optional fields:
|
|
259
296
|
- `usage`: LLM usage from generating the summary; included in session token and cost totals
|
|
260
297
|
- `details`: File tracking data (`{ readFiles: string[], modifiedFiles: string[] }`) for default, or custom data for extensions
|
|
@@ -305,11 +342,12 @@ The session name is displayed in the session selector (`/resume`) instead of the
|
|
|
305
342
|
|
|
306
343
|
## Tree Structure
|
|
307
344
|
|
|
308
|
-
Entries form
|
|
309
|
-
-
|
|
310
|
-
- Each
|
|
345
|
+
Entries normally form one tree, but navigation APIs can create multiple roots:
|
|
346
|
+
- A root entry has `parentId: null`; the first entry is initially the root
|
|
347
|
+
- Each non-root entry points to its parent via `parentId`
|
|
311
348
|
- Branching creates new children from an earlier entry
|
|
312
349
|
- The "leaf" is the current position in the tree
|
|
350
|
+
- Calling `resetLeaf()` or `branchWithSummary(null, ...)` allows a later entry to become another root
|
|
313
351
|
|
|
314
352
|
```
|
|
315
353
|
[user msg] ─── [assistant] ─── [user msg] ─── [assistant] ─┬─ [user msg] ← current leaf
|
|
@@ -322,11 +360,10 @@ Entries form a tree:
|
|
|
322
360
|
`buildContextEntries()` walks from the current leaf to the root, producing the active entry list while honoring compaction:
|
|
323
361
|
|
|
324
362
|
1. Collects all entries on the path
|
|
325
|
-
2. If
|
|
363
|
+
2. If one or more `CompactionEntry` values are on the path, uses the latest one:
|
|
326
364
|
- Includes the compaction entry first
|
|
327
|
-
-
|
|
328
|
-
-
|
|
329
|
-
- Then entries after compaction are included
|
|
365
|
+
- Includes non-system entries from `firstKeptEntryId` up to, but not including, the compaction entry
|
|
366
|
+
- Includes entries after the compaction entry
|
|
330
367
|
3. Preserves non-message entries in the selected range so interactive mode can render them
|
|
331
368
|
|
|
332
369
|
`buildSessionContext()` builds on that entry list to produce the message list for the LLM:
|
|
@@ -334,12 +371,12 @@ Entries form a tree:
|
|
|
334
371
|
1. Extracts current model and thinking level settings from the full path
|
|
335
372
|
2. Converts selected entries to messages:
|
|
336
373
|
- `message` -> stored `AgentMessage`
|
|
337
|
-
- `compaction` ->
|
|
374
|
+
- `compaction` -> complete system checkpoint followed by `compactionSummary`
|
|
338
375
|
- `branch_summary` -> `branchSummary`
|
|
339
376
|
- `custom_message` -> `CustomMessage`
|
|
340
|
-
- `custom` -> no context message
|
|
377
|
+
- `usage` and `custom` -> no context message
|
|
341
378
|
|
|
342
|
-
|
|
379
|
+
The compaction summary replaces entries before `firstKeptEntryId`. Pre-compaction system messages are folded into the complete checkpoint rather than replayed from the retained range. Retained non-system entries and all entries after the compaction remain available to the LLM.
|
|
343
380
|
|
|
344
381
|
## Parsing Example
|
|
345
382
|
|
|
@@ -364,6 +401,9 @@ for (const line of lines) {
|
|
|
364
401
|
case "branch_summary":
|
|
365
402
|
console.log(`[${entry.id}] Branch from ${entry.fromId}`);
|
|
366
403
|
break;
|
|
404
|
+
case "usage":
|
|
405
|
+
console.log(`[${entry.id}] Usage (${entry.kind}): ${entry.usage.totalTokens} tokens`);
|
|
406
|
+
break;
|
|
367
407
|
case "custom":
|
|
368
408
|
console.log(`[${entry.id}] Custom (${entry.customType}): ${JSON.stringify(entry.data)}`);
|
|
369
409
|
break;
|
|
@@ -388,18 +428,19 @@ for (const line of lines) {
|
|
|
388
428
|
Key methods for working with sessions programmatically.
|
|
389
429
|
|
|
390
430
|
### Static Creation Methods
|
|
391
|
-
- `SessionManager.create(cwd, sessionDir?)` - New session
|
|
392
|
-
- `SessionManager.open(path, sessionDir?)` - Open existing session file
|
|
431
|
+
- `SessionManager.create(cwd, sessionDir?, options?)` - New session; `options` can set `id` and `parentSession`
|
|
432
|
+
- `SessionManager.open(path, sessionDir?, cwdOverride?)` - Open existing session file
|
|
393
433
|
- `SessionManager.continueRecent(cwd, sessionDir?)` - Continue most recent or create new
|
|
394
|
-
- `SessionManager.inMemory(cwd?)` - No file persistence
|
|
395
|
-
- `SessionManager.forkFrom(sourcePath, targetCwd, sessionDir?)` - Fork session from another project
|
|
434
|
+
- `SessionManager.inMemory(cwd?, options?, entries?)` - No file persistence, optionally initialized from entries
|
|
435
|
+
- `SessionManager.forkFrom(sourcePath, targetCwd, sessionDir?, options?)` - Fork session from another project
|
|
396
436
|
|
|
397
437
|
### Static Listing Methods
|
|
398
438
|
- `SessionManager.list(cwd, sessionDir?, onProgress?)` - List sessions for a directory
|
|
399
439
|
- `SessionManager.listAll(onProgress?)` - List all sessions across all projects
|
|
440
|
+
- `SessionManager.listAll(sessionDir?, onProgress?)` - List sessions from a custom session root
|
|
400
441
|
|
|
401
442
|
### Instance Methods - Session Management
|
|
402
|
-
- `newSession(options?)` - Start a new session (options: `{ parentSession?: string }`)
|
|
443
|
+
- `newSession(options?)` - Start a new session (options: `{ id?: string, parentSession?: string }`)
|
|
403
444
|
- `setSessionFile(path)` - Switch to a different session file
|
|
404
445
|
- `createBranchedSession(leafId)` - Extract branch to new session file
|
|
405
446
|
|
|
@@ -407,7 +448,8 @@ Key methods for working with sessions programmatically.
|
|
|
407
448
|
- `appendMessage(message)` - Add message
|
|
408
449
|
- `appendThinkingLevelChange(level)` - Record thinking change
|
|
409
450
|
- `appendModelChange(provider, modelId)` - Record model change
|
|
410
|
-
- `
|
|
451
|
+
- `appendUsage(kind, provider, model, usage)` - Record model-attributed usage outside the conversation
|
|
452
|
+
- `appendCompaction(summary, firstKeptEntryId, tokensBefore, details?, fromHook?, usage?)` - Add compaction
|
|
411
453
|
- `appendCustomEntry(customType, data?)` - Extension state (not in context)
|
|
412
454
|
- `appendSessionInfo(name)` - Set session display name
|
|
413
455
|
- `appendCustomMessageEntry(customType, content, display, details?)` - Extension message (in context)
|
|
@@ -423,7 +465,7 @@ Key methods for working with sessions programmatically.
|
|
|
423
465
|
- `getLabel(id)` - Get label for entry
|
|
424
466
|
- `branch(entryId)` - Move leaf to earlier entry
|
|
425
467
|
- `resetLeaf()` - Reset leaf to null (before any entries)
|
|
426
|
-
- `branchWithSummary(entryId, summary, details?, fromHook?)` - Branch with context summary
|
|
468
|
+
- `branchWithSummary(entryId, summary, details?, fromHook?, usage?)` - Branch with context summary; `entryId` may be `null` to branch from the root
|
|
427
469
|
|
|
428
470
|
### Instance Methods - Context & Info
|
|
429
471
|
- `buildContextEntries()` - Get active branch entries with compaction applied
|
package/docs/sessions.md
CHANGED
|
@@ -33,6 +33,7 @@ For the JSONL file format and SessionManager API, see [Session Format](session-f
|
|
|
33
33
|
| `/compact [prompt]` | Summarize older context; see [Compaction](compaction.md) |
|
|
34
34
|
| `/export [file]` | Export session to HTML |
|
|
35
35
|
| `/share` | Upload as private GitHub gist with shareable HTML link |
|
|
36
|
+
| `/bug [description]` | Report a bug to the Pi developers; see [Reporting Bugs](#reporting-bugs) |
|
|
36
37
|
|
|
37
38
|
## Resuming and Deleting Sessions
|
|
38
39
|
|
|
@@ -138,6 +139,32 @@ When prompted, choose one of:
|
|
|
138
139
|
|
|
139
140
|
See [Compaction](compaction.md) for branch summarization internals and extension hooks.
|
|
140
141
|
|
|
142
|
+
## Reporting Bugs
|
|
143
|
+
|
|
144
|
+
`/bug [description]` collects a bug report for the Pi developers. The report is not shared publicly. The dialog asks for an optional description and whether to include the session transcript. If you decline the transcript, pi offers to have the current model write a summary of what went wrong instead; the transcript is sent to your provider with your credentials, and only the summary is attached.
|
|
145
|
+
|
|
146
|
+
The last step chooses where the report goes:
|
|
147
|
+
|
|
148
|
+
- **Upload Report** sends it to the Pi developers through `radius.pi.dev`. No login is required; if you are logged into Radius, the report is attributed to your account so the developers can follow up. If the upload fails, pi offers to export the zip instead.
|
|
149
|
+
- **Export as Zip** writes a zip archive to the current directory. Attach it to an issue or send it to the developers yourself.
|
|
150
|
+
|
|
151
|
+
Both contain the same files:
|
|
152
|
+
|
|
153
|
+
| File | Content |
|
|
154
|
+
|------|---------|
|
|
155
|
+
| `report.json` | pi version, runtime, OS, terminal, current model and provider configuration, loaded extensions, and settings. API keys, header values, URL credentials, and the analytics tracking id are never included. |
|
|
156
|
+
| `diagnostics.json` | Provider and runtime error diagnostics attached to assistant messages across the whole session (failed or aborted turns, retries, error messages), plus any recorded crashes. Always included; message content is not. |
|
|
157
|
+
| `session.jsonl` | The current branch of the session, only when you chose to include it. It contains file contents and command output read during the session. |
|
|
158
|
+
| `summary.md` | The model-written summary, only when you chose to generate one. |
|
|
159
|
+
|
|
160
|
+
Each report has a UUID. pi shows it after upload or export and records it in the session as a `pi.bug-report` entry so you can refer to it later.
|
|
161
|
+
|
|
162
|
+
Set `PI_RADIUS_GATEWAY` to upload to a different Radius deployment.
|
|
163
|
+
|
|
164
|
+
### Crashes
|
|
165
|
+
|
|
166
|
+
When pi exits because of an uncaught exception or a fatal runtime error, it stores the error message and stack trace in `~/.pi/agent/crashes.json` (the newest five). The next interactive start shows a warning once; running `/bug` attaches the stored crashes to `diagnostics.json` and removes the file after the report is uploaded or exported. Resume the crashed session with `pi -r` first if you want the transcript in the report.
|
|
167
|
+
|
|
141
168
|
## Session Format
|
|
142
169
|
|
|
143
170
|
Session files are JSONL and contain message entries, model changes, thinking-level changes, labels, compactions, branch summaries, and extension entries.
|
package/docs/settings.md
CHANGED
|
@@ -32,8 +32,31 @@ Use `/trust` in interactive mode to save a project trust decision for future ses
|
|
|
32
32
|
| `defaultThinkingLevel` | string | - | Startup thinking level (saved with Ctrl+S in `/thinking`, or edited manually): `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"`, `"max"` |
|
|
33
33
|
| `modelThinkingLevels` | object | - | Per-model startup thinking levels keyed by `"provider/modelId"`; configure from `/settings` → Default thinking level per model or edit manually |
|
|
34
34
|
| `hideThinkingBlock` | boolean | `false` | Hide thinking blocks in output |
|
|
35
|
-
| `showCacheMissNotices` | boolean | `false` | Show transcript notices for significant prompt-cache misses, compaction or branch-summary usage, and provider recovery diagnostics such as dropped Anthropic thinking blocks |
|
|
35
|
+
| `showCacheMissNotices` | boolean | `false` | Show transcript notices for significant prompt-cache misses, successful cache-warming usage, compaction or branch-summary usage, and provider recovery diagnostics such as dropped Anthropic thinking blocks |
|
|
36
36
|
| `thinkingBudgets` | object | - | Custom token budgets per thinking level. Anthropic, Google, and Bedrock use these natively. OpenAI-compatible models use them when `compat.thinkingTokenBudgetField` (or `supportsThinkingTokenBudget`) is set. |
|
|
37
|
+
| `cacheWarming` | string | `"streaming"` | Prompt cache-warming mode: `"off"`, `"streaming"`, or `"idle"`. Global setting only. |
|
|
38
|
+
|
|
39
|
+
#### Cache Warming
|
|
40
|
+
|
|
41
|
+
Providers drop a prompt cache entry after a period of inactivity, so the first request after a pause pays full input price again. Cache warming re-sends the last request with a one-token output budget shortly before expiry:
|
|
42
|
+
|
|
43
|
+
- `"off"` disables warming.
|
|
44
|
+
- `"streaming"` protects expensive prefixes during long tool executions and stops as soon as the agent settles.
|
|
45
|
+
- `"idle"` also considers refreshes while waiting for your next prompt, using a fixed 15% continuation probability measured from real usage.
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"cacheWarming": "idle"
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
A refresh is sent only when the expected avoided cache-miss cost, minus the cost of the refresh, leaves at least $0.05 of expected savings. Active agent runs use 100% continuation probability. `/session` shows the next decision, continuation probability, expected savings, threshold, and estimated costs. When cache miss notices are enabled, each successful refresh appears in the transcript with its cost; notices identify extension overrides.
|
|
54
|
+
|
|
55
|
+
Warming stops when the context changes (model switch, compaction, branch navigation). Idle warming stops no later than 30 minutes after the last real provider request; warming during an active agent run stops after 60 minutes. Extensions can override each decision through the [`cache_warming_decision`](extensions.md#cache_warming_decision) event.
|
|
56
|
+
|
|
57
|
+
Each refresh is billed as a cache read of the full context plus one output token. Usage and cost show up in session totals but never enter model context. Pi schedules candidates at 90% of the cache lifetime while leaving at least ten seconds before expiry.
|
|
58
|
+
|
|
59
|
+
Warming needs a known cache lifetime for the model and the retention tier the request used (`short`, or `long` with `PI_CACHE_RETENTION=long`). The built-in catalog carries lifetimes for direct Anthropic; custom models and other providers can declare theirs with `promptCache` in `models.json` (see [Prompt Cache Lifetimes](models.md#prompt-cache-lifetimes)). Claude models that use budget-based rather than adaptive thinking are skipped while thinking is on, because Anthropic derives the thinking budget from `max_tokens` and keys the message cache on it, so a one-token request cannot reproduce the entry.
|
|
37
60
|
|
|
38
61
|
#### thinkingBudgets
|
|
39
62
|
|
|
@@ -118,6 +141,7 @@ Set `PI_SKIP_VERSION_CHECK=1` to disable the Pi version update check. Use `--off
|
|
|
118
141
|
| `compaction.enabled` | boolean | `true` | Enable auto-compaction |
|
|
119
142
|
| `compaction.reserveTokens` | number | `16384` | Tokens reserved for LLM response |
|
|
120
143
|
| `compaction.keepRecentTokens` | number | `20000` | Recent tokens to keep (not summarized) |
|
|
144
|
+
| `compaction.modelOverrides` | object | - | Per-model `reserveTokens` and `keepRecentTokens` overrides keyed by exact `"provider/modelId"` |
|
|
121
145
|
|
|
122
146
|
```json
|
|
123
147
|
{
|
|
@@ -129,6 +153,37 @@ Set `PI_SKIP_VERSION_CHECK=1` to disable the Pi version update check. Use `--off
|
|
|
129
153
|
}
|
|
130
154
|
```
|
|
131
155
|
|
|
156
|
+
#### Per-model compaction overrides
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"compaction": {
|
|
161
|
+
"enabled": true,
|
|
162
|
+
"reserveTokens": 16384,
|
|
163
|
+
"keepRecentTokens": 20000,
|
|
164
|
+
"modelOverrides": {
|
|
165
|
+
"some-provider/big-model": {
|
|
166
|
+
"reserveTokens": 400000
|
|
167
|
+
},
|
|
168
|
+
"local/small-model": {
|
|
169
|
+
"reserveTokens": 2048,
|
|
170
|
+
"keepRecentTokens": 4096
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Keys match exact, case-sensitive `provider/modelId` values, not names or glob patterns. Model IDs may contain slashes (for example, `openrouter/anthropic/claude-sonnet-4`).
|
|
178
|
+
|
|
179
|
+
Each token setting resolves independently: matching model override → ordinary `compaction` setting → built-in default. In the example, `some-provider/big-model` keeps the ordinary 20000 recent tokens. Token values must be non-negative safe integers. Invalid values in the matching model override produce an error when read; only omitted fields fall back to the ordinary setting. Model override entries must be objects. Invalid ordinary token settings produce an error when read, even if the active model has a valid override. Only omitted ordinary values use built-in defaults. Zero is accepted, but `reserveTokens: 0` leaves no response margin and also sets the summarization output budget to zero.
|
|
180
|
+
|
|
181
|
+
Global and project settings merge recursively **before** model lookup. A project can override one field for a model without replacing its other fields or other models. A global model-specific value takes precedence over a project-wide fallback; override the same model entry in the project to change it.
|
|
182
|
+
|
|
183
|
+
`enabled` is not model-specific. The active model's token settings apply to manual compaction, automatic threshold checks (including between assistant turns), and overflow recovery. Switching models takes effect on the next check or compaction. Configure overrides in JSON; `/settings` retains the ordinary auto-compaction toggle.
|
|
184
|
+
|
|
185
|
+
See [compaction.md](compaction.md) for trigger and summarization behavior.
|
|
186
|
+
|
|
132
187
|
### Branch Summary
|
|
133
188
|
|
|
134
189
|
| Setting | Type | Default | Description |
|
|
@@ -143,10 +198,13 @@ Set `PI_SKIP_VERSION_CHECK=1` to disable the Pi version update check. Use `--off
|
|
|
143
198
|
| `retry.enabled` | boolean | `true` | Enable automatic agent-level retry on transient errors |
|
|
144
199
|
| `retry.maxRetries` | number | `3` | Maximum agent-level retry attempts |
|
|
145
200
|
| `retry.baseDelayMs` | number | `2000` | Base delay for agent-level exponential backoff (2s, 4s, 8s) |
|
|
201
|
+
| `retry.maxAgentDelayMs` | number | `60000` | Max agent-level retry delay (60s) |
|
|
146
202
|
| `retry.provider.timeoutMs` | number | SDK default | Provider/SDK request timeout in milliseconds |
|
|
147
203
|
| `retry.provider.maxRetries` | number | `0` | Provider/SDK retry attempts |
|
|
148
204
|
| `retry.provider.maxRetryDelayMs` | number | `60000` | Max server-requested delay before failing (60s) |
|
|
149
205
|
|
|
206
|
+
Agent-level retries use exponential backoff capped by `retry.maxAgentDelayMs`, so long retry runs stay responsive after prolonged outages.
|
|
207
|
+
|
|
150
208
|
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.
|
|
151
209
|
|
|
152
210
|
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.
|
|
@@ -157,6 +215,7 @@ Keep `retry.provider.maxRetries` at `0` unless provider-level retries are explic
|
|
|
157
215
|
"enabled": true,
|
|
158
216
|
"maxRetries": 3,
|
|
159
217
|
"baseDelayMs": 2000,
|
|
218
|
+
"maxAgentDelayMs": 60000,
|
|
160
219
|
"provider": {
|
|
161
220
|
"timeoutMs": 3600000,
|
|
162
221
|
"maxRetries": 0,
|
package/docs/termux.md
CHANGED
|
@@ -96,7 +96,6 @@ termux-camera-photo out.jpg # Take photo
|
|
|
96
96
|
## Limitations
|
|
97
97
|
|
|
98
98
|
- **No image clipboard**: Termux clipboard API only supports text
|
|
99
|
-
- **No native binaries**: Some optional native dependencies (like the clipboard module) are unavailable on Android ARM64 and are skipped during installation
|
|
100
99
|
- **Storage access**: To access files in `/storage/emulated/0` (Downloads, etc.), run `termux-setup-storage` once to grant permissions
|
|
101
100
|
|
|
102
101
|
## Troubleshooting
|