@astralyn/pi 0.85.3 → 0.86.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 +52 -0
- package/dist/bundle/chunks/anthropic-messages-R2LYJUDD.js +6 -0
- package/dist/bundle/chunks/azure-openai-responses-HS35BQV6.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +36 -32
- package/dist/bundle/chunks/{chunk-S2DJQQI2.js → chunk-2IO5GDBS.js} +10 -1
- package/dist/bundle/chunks/chunk-DAEM5JIZ.js +2 -0
- package/dist/bundle/chunks/{chunk-LB4P77SH.js → chunk-GTBMYBFG.js} +777 -762
- package/dist/bundle/chunks/{chunk-7LO5Z4WE.js → chunk-I5IVW2WS.js} +1 -1
- package/dist/bundle/chunks/chunk-JI4WGISU.js +2 -0
- package/dist/bundle/chunks/chunk-LPQCB2VJ.js +44 -0
- package/dist/bundle/chunks/chunk-NW5FIDD7.js +11 -0
- package/dist/bundle/chunks/chunk-PJVFYVHE.js +42 -0
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/google-generative-ai-NOVAJBFC.js +2 -0
- package/dist/bundle/chunks/google-vertex-4VHCZJV5.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-JOOPB4RE.js +16 -0
- package/dist/bundle/chunks/jiti-loader-BFSSLU7G.js +21 -0
- package/dist/bundle/chunks/jiti-static-loader-CLT3YR3B.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-WC6A2WCJ.js +5 -0
- package/dist/bundle/chunks/{node-G4XOIDPH.js → node-CXWYTK2I.js} +1 -1
- package/dist/bundle/chunks/openai-codex-responses-XCDG75W2.js +10 -0
- package/dist/bundle/chunks/openai-completions-6SMWQWQN.js +7 -0
- package/dist/bundle/chunks/openai-responses-UT6XFKC7.js +2 -0
- package/dist/bundle/chunks/{pi-messages-PE6B42TG.js → pi-messages-MQMPIPNC.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-OHUZ2T7X.js +2 -0
- package/dist/bundle/cli.js +1 -1
- 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 +13 -11
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +56 -14
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +305 -176
- 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 +333 -0
- package/dist/core/cache-warmer.js.map +1 -0
- 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 +14 -9
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +30 -23
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/settings.d.ts +17 -20
- package/dist/core/compaction/settings.d.ts.map +1 -1
- package/dist/core/compaction/settings.js +19 -26
- package/dist/core/compaction/settings.js.map +1 -1
- package/dist/core/context-snapshot.d.ts +16 -5
- package/dist/core/context-snapshot.d.ts.map +1 -1
- package/dist/core/context-snapshot.js +20 -10
- package/dist/core/context-snapshot.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 +39 -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.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 +46 -18
- 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 +31 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +65 -8
- 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 +6 -3
- 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/shell-execution.js +2 -2
- package/dist/core/tools/shell-execution.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 +4 -1
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/extensions/background/schema.d.ts +1 -1
- package/dist/extensions/btw/agent.d.ts.map +1 -1
- package/dist/extensions/btw/agent.js +3 -2
- package/dist/extensions/btw/agent.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/extensions/provider/compat-fields.d.ts.map +1 -1
- package/dist/extensions/provider/compat-fields.js +5 -2
- package/dist/extensions/provider/compat-fields.js.map +1 -1
- package/dist/extensions/provider/ui/app.js +2 -2
- package/dist/extensions/provider/ui/app.js.map +1 -1
- package/dist/extensions/todo/schema.d.ts +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.js +1 -1
- package/dist/modes/interactive/chat-viewport.js.map +1 -1
- package/dist/modes/interactive/components/armin.d.ts.map +1 -1
- package/dist/modes/interactive/components/armin.js +0 -5
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +0 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +2 -3
- package/dist/modes/interactive/components/bash-execution.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/countdown-timer.d.ts +6 -13
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +15 -51
- package/dist/modes/interactive/components/countdown-timer.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 -2
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +4 -2
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +5 -8
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +72 -95
- 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-chrome.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-chrome.js +4 -1
- package/dist/modes/interactive/components/tool-chrome.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +4 -3
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -10
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +4 -51
- 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 +234 -91
- 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.js +2 -2
- package/dist/modes/interactive/tui-renderer.js.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/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 +32 -11
- package/docs/custom-provider.md +19 -8
- package/docs/environment-variables.md +1 -0
- package/docs/extensions.md +50 -34
- package/docs/models.md +38 -3
- package/docs/providers.md +9 -1
- package/docs/sdk.md +4 -2
- package/docs/session-format.md +63 -24
- package/docs/sessions.md +28 -1
- package/docs/settings.md +58 -4
- package/docs/termux.md +0 -1
- package/docs/tui.md +2 -0
- 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-gitlab-duo/index.ts +2 -2
- package/examples/extensions/prompt-customizer.ts +19 -67
- package/npm-shrinkwrap.json +275 -1028
- package/package.json +17 -23
- package/dist/bundle/chunks/anthropic-messages-IHRRITCV.js +0 -6
- package/dist/bundle/chunks/azure-openai-responses-QXBIDYXO.js +0 -2
- package/dist/bundle/chunks/chunk-JSJPY26N.js +0 -2
- package/dist/bundle/chunks/chunk-KI6LC764.js +0 -42
- package/dist/bundle/chunks/chunk-OWESLY5T.js +0 -11
- package/dist/bundle/chunks/chunk-RRBI7OUG.js +0 -50
- package/dist/bundle/chunks/chunk-YZJWMPUI.js +0 -2
- package/dist/bundle/chunks/google-generative-ai-NBOR3IQR.js +0 -2
- package/dist/bundle/chunks/google-vertex-VTHX3SUB.js +0 -2
- package/dist/bundle/chunks/https-proxy-agent-2VXB7436.js +0 -13
- package/dist/bundle/chunks/mistral-conversations-NO4ANAA5.js +0 -5
- package/dist/bundle/chunks/openai-codex-responses-5S3T3HMA.js +0 -10
- package/dist/bundle/chunks/openai-completions-CXRRTRWE.js +0 -7
- package/dist/bundle/chunks/openai-responses-CV3MH6VP.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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
/** Windows Subsystem for Linux, where Windows executables are reachable through interop. */
|
|
3
|
+
export function isWSL(env = process.env) {
|
|
4
|
+
if (env.WSL_DISTRO_NAME || env.WSLENV) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
try {
|
|
8
|
+
const release = readFileSync("/proc/version", "utf-8");
|
|
9
|
+
return /microsoft|wsl/i.test(release);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=wsl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wsl.js","sourceRoot":"","sources":["../../src/utils/wsl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,4FAA4F;AAC5F,MAAM,UAAU,KAAK,CAAC,MAAyB,OAAO,CAAC,GAAG;IACzD,IAAI,GAAG,CAAC,eAAe,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,CAAC;QACJ,MAAM,OAAO,GAAG,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QACvD,OAAO,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC","sourcesContent":["import { readFileSync } from \"node:fs\";\n\n/** Windows Subsystem for Linux, where Windows executables are reachable through interop. */\nexport function isWSL(env: NodeJS.ProcessEnv = process.env): boolean {\n\tif (env.WSL_DISTRO_NAME || env.WSLENV) {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tconst release = readFileSync(\"/proc/version\", \"utf-8\");\n\t\treturn /microsoft|wsl/i.test(release);\n\t} catch {\n\t\treturn false;\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../src/utils/zip.ts"],"names":[],"mappings":"AAGA,UAAU,QAAQ;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CAC1B;AA+DD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7F"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { writeFile } from "node:fs/promises";
|
|
2
|
+
import { crc32, deflateRawSync } from "node:zlib";
|
|
3
|
+
function dosDateTime(date) {
|
|
4
|
+
return {
|
|
5
|
+
time: (date.getHours() << 11) | (date.getMinutes() << 5) | (date.getSeconds() >> 1),
|
|
6
|
+
day: ((Math.max(1980, date.getFullYear()) - 1980) << 9) | ((date.getMonth() + 1) << 5) | date.getDate(),
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/** Create the small, classic ZIP archives used by bug reports. */
|
|
10
|
+
function createZipArchive(entries) {
|
|
11
|
+
const files = [];
|
|
12
|
+
const directory = [];
|
|
13
|
+
const { time, day } = dosDateTime(new Date());
|
|
14
|
+
let offset = 0;
|
|
15
|
+
for (const entry of entries) {
|
|
16
|
+
const name = Buffer.from(entry.name);
|
|
17
|
+
const data = typeof entry.data === "string" ? Buffer.from(entry.data) : Buffer.from(entry.data);
|
|
18
|
+
const compressed = deflateRawSync(data);
|
|
19
|
+
const checksum = crc32(data);
|
|
20
|
+
const local = Buffer.alloc(30);
|
|
21
|
+
local.writeUInt32LE(0x04034b50, 0);
|
|
22
|
+
local.writeUInt16LE(20, 4);
|
|
23
|
+
local.writeUInt16LE(0x0800, 6);
|
|
24
|
+
local.writeUInt16LE(8, 8);
|
|
25
|
+
local.writeUInt16LE(time, 10);
|
|
26
|
+
local.writeUInt16LE(day, 12);
|
|
27
|
+
local.writeUInt32LE(checksum, 14);
|
|
28
|
+
local.writeUInt32LE(compressed.length, 18);
|
|
29
|
+
local.writeUInt32LE(data.length, 22);
|
|
30
|
+
local.writeUInt16LE(name.length, 26);
|
|
31
|
+
const central = Buffer.alloc(46);
|
|
32
|
+
central.writeUInt32LE(0x02014b50, 0);
|
|
33
|
+
central.writeUInt16LE(20, 4);
|
|
34
|
+
central.writeUInt16LE(20, 6);
|
|
35
|
+
central.writeUInt16LE(0x0800, 8);
|
|
36
|
+
central.writeUInt16LE(8, 10);
|
|
37
|
+
central.writeUInt16LE(time, 12);
|
|
38
|
+
central.writeUInt16LE(day, 14);
|
|
39
|
+
central.writeUInt32LE(checksum, 16);
|
|
40
|
+
central.writeUInt32LE(compressed.length, 20);
|
|
41
|
+
central.writeUInt32LE(data.length, 24);
|
|
42
|
+
central.writeUInt16LE(name.length, 28);
|
|
43
|
+
central.writeUInt32LE(offset, 42);
|
|
44
|
+
files.push(local, name, compressed);
|
|
45
|
+
directory.push(central, name);
|
|
46
|
+
offset += local.length + name.length + compressed.length;
|
|
47
|
+
}
|
|
48
|
+
const centralDirectory = Buffer.concat(directory);
|
|
49
|
+
const end = Buffer.alloc(22);
|
|
50
|
+
end.writeUInt32LE(0x06054b50, 0);
|
|
51
|
+
end.writeUInt16LE(entries.length, 8);
|
|
52
|
+
end.writeUInt16LE(entries.length, 10);
|
|
53
|
+
end.writeUInt32LE(centralDirectory.length, 12);
|
|
54
|
+
end.writeUInt32LE(offset, 16);
|
|
55
|
+
return Buffer.concat([...files, centralDirectory, end]);
|
|
56
|
+
}
|
|
57
|
+
export function writeZipArchive(filePath, entries) {
|
|
58
|
+
return writeFile(filePath, createZipArchive(entries));
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=zip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../../src/utils/zip.ts"],"names":[],"mappings":"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","sourcesContent":["import { writeFile } from \"node:fs/promises\";\nimport { crc32, deflateRawSync } from \"node:zlib\";\n\ninterface ZipEntry {\n\tname: string;\n\tdata: string | Uint8Array;\n}\n\nfunction dosDateTime(date: Date): { time: number; day: number } {\n\treturn {\n\t\ttime: (date.getHours() << 11) | (date.getMinutes() << 5) | (date.getSeconds() >> 1),\n\t\tday: ((Math.max(1980, date.getFullYear()) - 1980) << 9) | ((date.getMonth() + 1) << 5) | date.getDate(),\n\t};\n}\n\n/** Create the small, classic ZIP archives used by bug reports. */\nfunction createZipArchive(entries: readonly ZipEntry[]): Buffer {\n\tconst files: Buffer[] = [];\n\tconst directory: Buffer[] = [];\n\tconst { time, day } = dosDateTime(new Date());\n\tlet offset = 0;\n\n\tfor (const entry of entries) {\n\t\tconst name = Buffer.from(entry.name);\n\t\tconst data = typeof entry.data === \"string\" ? Buffer.from(entry.data) : Buffer.from(entry.data);\n\t\tconst compressed = deflateRawSync(data);\n\t\tconst checksum = crc32(data);\n\n\t\tconst local = Buffer.alloc(30);\n\t\tlocal.writeUInt32LE(0x04034b50, 0);\n\t\tlocal.writeUInt16LE(20, 4);\n\t\tlocal.writeUInt16LE(0x0800, 6);\n\t\tlocal.writeUInt16LE(8, 8);\n\t\tlocal.writeUInt16LE(time, 10);\n\t\tlocal.writeUInt16LE(day, 12);\n\t\tlocal.writeUInt32LE(checksum, 14);\n\t\tlocal.writeUInt32LE(compressed.length, 18);\n\t\tlocal.writeUInt32LE(data.length, 22);\n\t\tlocal.writeUInt16LE(name.length, 26);\n\n\t\tconst central = Buffer.alloc(46);\n\t\tcentral.writeUInt32LE(0x02014b50, 0);\n\t\tcentral.writeUInt16LE(20, 4);\n\t\tcentral.writeUInt16LE(20, 6);\n\t\tcentral.writeUInt16LE(0x0800, 8);\n\t\tcentral.writeUInt16LE(8, 10);\n\t\tcentral.writeUInt16LE(time, 12);\n\t\tcentral.writeUInt16LE(day, 14);\n\t\tcentral.writeUInt32LE(checksum, 16);\n\t\tcentral.writeUInt32LE(compressed.length, 20);\n\t\tcentral.writeUInt32LE(data.length, 24);\n\t\tcentral.writeUInt16LE(name.length, 28);\n\t\tcentral.writeUInt32LE(offset, 42);\n\n\t\tfiles.push(local, name, compressed);\n\t\tdirectory.push(central, name);\n\t\toffset += local.length + name.length + compressed.length;\n\t}\n\n\tconst centralDirectory = Buffer.concat(directory);\n\tconst end = Buffer.alloc(22);\n\tend.writeUInt32LE(0x06054b50, 0);\n\tend.writeUInt16LE(entries.length, 8);\n\tend.writeUInt16LE(entries.length, 10);\n\tend.writeUInt32LE(centralDirectory.length, 12);\n\tend.writeUInt32LE(offset, 16);\n\treturn Buffer.concat([...files, centralDirectory, end]);\n}\n\nexport function writeZipArchive(filePath: string, entries: readonly ZipEntry[]): Promise<void> {\n\treturn writeFile(filePath, createZipArchive(entries));\n}\n"]}
|
package/docs/compaction.md
CHANGED
|
@@ -26,12 +26,12 @@ Both use the same structured summary format and track file operations cumulative
|
|
|
26
26
|
Auto-compaction triggers when:
|
|
27
27
|
|
|
28
28
|
```
|
|
29
|
-
contextTokens > contextWindow
|
|
29
|
+
contextTokens > contextWindow − reserveTokens
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
`reserveTokens` comes from `triggerPercent` (default 85, accepted range 20–95 with out-of-range values clamped, configurable in `~/.pi/agent/settings.json` or `<project-dir>/.pi/settings.json`): the reserve is whatever is left above that percentage of the active model's context window. Compaction therefore starts once usage passes 85% of the window — ~850K tokens on a 1M window, ~170K on a 200K window. Non-finite values fall back to 85.
|
|
33
33
|
|
|
34
|
-
> **Distribution note:** upstream Pi
|
|
34
|
+
> **Distribution note:** upstream Pi's default is a fixed 16384-token reserve, which on large windows delays compaction until ~98% usage. This distribution derives the reserve from `triggerPercent` instead. Setting `compaction.reserveTokens` explicitly — globally or per model — still wins and restores upstream's fixed-reserve behavior for that model.
|
|
35
35
|
|
|
36
36
|
During a multi-turn agent run, Pi checks this threshold after tools finish and their results are appended, before starting the next assistant response. If the threshold is crossed, Pi compacts inside the same agent run and resumes with the summary and retained messages. It skips this between-turn check when the completed tool batch terminates the run and no queued message requires another response. Pi also checks the threshold before a new user prompt and after a low-level agent run ends.
|
|
37
37
|
|
|
@@ -41,17 +41,15 @@ You can also trigger manually with `/compact [instructions]`, where optional ins
|
|
|
41
41
|
|
|
42
42
|
### How It Works
|
|
43
43
|
|
|
44
|
-
1. **Find cut point**: Walk backwards from newest message until the effective retention target is reached: `keepRecentTokens` (default 20k), capped at half the
|
|
44
|
+
1. **Find cut point**: Walk backwards from newest message until the effective retention target is reached: `keepRecentTokens` (default 20k), capped at half the trigger line when the reserve comes from `triggerPercent`
|
|
45
45
|
2. **Extract messages**: Collect messages from the previous kept boundary (or session start) up to the cut point
|
|
46
46
|
3. **Generate summary**: Call LLM to summarize with structured format, passing the previous summary as iterative context when present
|
|
47
47
|
4. **Append entry**: Save `CompactionEntry` with summary and `firstKeptEntryId`
|
|
48
48
|
5. **Rebuilds context**: Session rebuilds the context for the next request, using summary + messages from `firstKeptEntryId` onwards
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
Retaining more than half the trigger line would leave the compacted context close to the line again, so a derived reserve also caps the recent-message target at half that line. History summaries can use 80% of `reserveTokens` and split-turn prefix summaries can use 50%; each is also limited by the model's output cap, which is the binding limit whenever the derived reserve is large. These are budget targets, not hard bounds on retained content: whole messages and tool-call/result groups remain intact and can exceed the target.
|
|
51
51
|
|
|
52
|
-
For example, a 64K window with `triggerPercent: 20` triggers above 12.8K tokens
|
|
53
|
-
|
|
54
|
-
SDK callers using `prepareCompaction()` directly should pass `model.contextWindow` as the third argument to apply the same retention cap. The two-argument form preserves the configured retention target when the window is unknown.
|
|
52
|
+
For example, a 64K window with `triggerPercent: 20` triggers above 12.8K tokens, reserves the remaining 51.2K, and retains at most 6.4K of recent messages. The configured settings are not rewritten; `compaction.keepRecentTokens` keeps its configured value for models whose window is unknown.
|
|
55
53
|
|
|
56
54
|
```
|
|
57
55
|
Before compaction:
|
|
@@ -299,7 +297,7 @@ pi.on("session_before_compact", async (event, ctx) => {
|
|
|
299
297
|
// preparation.fileOps - extracted file operations
|
|
300
298
|
// preparation.tokensBefore - context tokens before compaction
|
|
301
299
|
// preparation.firstKeptEntryId - where kept messages start
|
|
302
|
-
// preparation.settings -
|
|
300
|
+
// preparation.settings - effective settings after applying model overrides
|
|
303
301
|
|
|
304
302
|
// branchEntries - all entries on current branch (for custom state)
|
|
305
303
|
// reason - "manual" (/compact), "threshold", or "overflow"
|
|
@@ -421,8 +419,31 @@ Configure compaction in `~/.pi/agent/settings.json` or `<project-dir>/.pi/settin
|
|
|
421
419
|
|---------|---------|-------------|
|
|
422
420
|
| `enabled` | `true` | Enable auto-compaction |
|
|
423
421
|
| `triggerPercent` | `85` | Percentage of the context window that triggers auto-compaction (clamped to 20–95) |
|
|
424
|
-
| `
|
|
422
|
+
| `reserveTokens` | derived | Fixed reserve below the window; overrides `triggerPercent` for the models it applies to |
|
|
423
|
+
| `keepRecentTokens` | `20000` | Recent-message retention target, capped at half the trigger line when the reserve is derived |
|
|
425
424
|
|
|
426
425
|
Disable auto-compaction with `"enabled": false`. You can still compact manually with `/compact`.
|
|
427
426
|
|
|
428
|
-
|
|
427
|
+
### Per-model overrides
|
|
428
|
+
|
|
429
|
+
Use `compaction.modelOverrides` to tune the reserve and the retention target per model:
|
|
430
|
+
|
|
431
|
+
```json
|
|
432
|
+
{
|
|
433
|
+
"compaction": {
|
|
434
|
+
"keepRecentTokens": 20000,
|
|
435
|
+
"modelOverrides": {
|
|
436
|
+
"some-provider/big-model": {
|
|
437
|
+
"reserveTokens": 32768,
|
|
438
|
+
"keepRecentTokens": 150000
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
Keys are exact, case-sensitive `provider/modelId` values, including any slashes within the model ID. Each value falls back independently from the model override to the ordinary setting to the built-in default; an override's `reserveTokens` replaces the percentage-derived reserve for that model only. 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. `enabled` and `triggerPercent` remain global, not model-specific.
|
|
446
|
+
|
|
447
|
+
These resolved values are used for manual compaction, all automatic threshold checks, overflow recovery, and extension-visible `preparation.settings`, which carries the resolved `reserveTokens` rather than the percentage. Model switches affect subsequent checks and compactions without changing ordinary settings. Compaction already in progress uses the model and settings captured for that operation. Branch summarization settings are unaffected.
|
|
448
|
+
|
|
449
|
+
Overrides work in both global and project settings. The files merge recursively before lookup, so a global model-specific value beats a project-wide fallback; a project must override that model entry to change it. See [settings.md](settings.md#per-model-compaction-overrides) for details.
|
package/docs/custom-provider.md
CHANGED
|
@@ -303,24 +303,32 @@ Implement `streamSimple` only for a protocol that cannot use a built-in API tag
|
|
|
303
303
|
|
|
304
304
|
The configuration-form handler signature is exactly:
|
|
305
305
|
|
|
306
|
+
The context is a normalized transcript: the system prompt and tool declarations live in its system messages, so read them with `getCurrentSystemPrompt(context.messages)` and `getCurrentTools(context.messages)` rather than expecting `context.systemPrompt` or `context.tools`. Models that accept system messages mid-conversation can send them in place; otherwise call `collapseSystemMessages(context)` first to fold later system messages into the leading one.
|
|
307
|
+
|
|
306
308
|
```typescript
|
|
307
309
|
import {
|
|
308
310
|
type Api,
|
|
309
311
|
type AssistantMessage,
|
|
310
312
|
type AssistantMessageEventStream,
|
|
311
|
-
calculateCost,
|
|
312
|
-
type Context,
|
|
313
|
-
createAssistantMessageEventStream,
|
|
314
313
|
type Model,
|
|
315
314
|
type SimpleStreamOptions,
|
|
315
|
+
type TranscriptContext,
|
|
316
|
+
calculateCost,
|
|
317
|
+
collapseSystemMessages,
|
|
318
|
+
createAssistantMessageEventStream,
|
|
319
|
+
getCurrentSystemPrompt,
|
|
320
|
+
getCurrentTools,
|
|
316
321
|
} from "@earendil-works/pi-ai";
|
|
317
322
|
|
|
318
323
|
function streamMyProvider(
|
|
319
|
-
model: Model<
|
|
320
|
-
context:
|
|
321
|
-
options?: SimpleStreamOptions
|
|
324
|
+
model: Model<any>,
|
|
325
|
+
context: TranscriptContext,
|
|
326
|
+
options?: SimpleStreamOptions
|
|
322
327
|
): AssistantMessageEventStream {
|
|
323
328
|
const stream = createAssistantMessageEventStream();
|
|
329
|
+
const transcript = collapseSystemMessages(context);
|
|
330
|
+
const systemPrompt = getCurrentSystemPrompt(transcript.messages);
|
|
331
|
+
const tools = getCurrentTools(transcript.messages);
|
|
324
332
|
|
|
325
333
|
void (async () => {
|
|
326
334
|
const output: AssistantMessage = {
|
|
@@ -496,10 +504,10 @@ interface ProviderConfig {
|
|
|
496
504
|
/** API type for streaming. Required at provider or model level when defining models. */
|
|
497
505
|
api?: Api;
|
|
498
506
|
|
|
499
|
-
/** Custom streaming implementation for non-standard APIs. */
|
|
507
|
+
/** Custom streaming implementation for non-standard APIs. Receives a normalized transcript. */
|
|
500
508
|
streamSimple?: (
|
|
501
509
|
model: Model<Api>,
|
|
502
|
-
context:
|
|
510
|
+
context: TranscriptContext,
|
|
503
511
|
options?: SimpleStreamOptions
|
|
504
512
|
) => AssistantMessageEventStream;
|
|
505
513
|
|
|
@@ -555,6 +563,9 @@ interface ProviderModelConfig {
|
|
|
555
563
|
cacheWrite: number;
|
|
556
564
|
};
|
|
557
565
|
|
|
566
|
+
/** Best-effort prompt cache lifetime in seconds per retention tier. Unset disables cache warming. */
|
|
567
|
+
promptCache?: { short?: number; long?: number };
|
|
568
|
+
|
|
558
569
|
/** Maximum context window size in tokens. */
|
|
559
570
|
contextWindow: number;
|
|
560
571
|
|
|
@@ -86,6 +86,7 @@ These variables are read by Pi itself:
|
|
|
86
86
|
| `PI_TELEMETRY` | Override optional provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no`. This does not disable version checks |
|
|
87
87
|
| `PI_CACHE_RETENTION` | Set to `long` for extended provider prompt caching where supported |
|
|
88
88
|
| `PI_SHARE_VIEWER_URL` | Override the base URL used by `/share` |
|
|
89
|
+
| `PI_RADIUS_GATEWAY` | Override the Radius gateway origin used by `/bug` uploads and Radius relay connections |
|
|
89
90
|
| `PI_HARDWARE_CURSOR` | Set to `1` to show the hardware cursor; see [Terminal setup](terminal-setup.md) |
|
|
90
91
|
| `PI_HYPERLINKS` | Override OSC 8 hyperlink detection with `1`, `0`, or `auto` |
|
|
91
92
|
| `PI_IMAGE_PROTOCOL` | Override inline image detection with `kitty`, `iterm2`, `none`, or `auto` |
|
package/docs/extensions.md
CHANGED
|
@@ -550,10 +550,13 @@ pi.on("before_agent_start", async (event, ctx) => {
|
|
|
550
550
|
// event.systemPrompt - current chained system prompt for this handler
|
|
551
551
|
// (includes changes from earlier before_agent_start handlers)
|
|
552
552
|
// event.systemPromptOptions - structured options used to build the system prompt
|
|
553
|
-
// .customPrompt -
|
|
553
|
+
// .customPrompt - exact prompt prefix from --system-prompt, SYSTEM.md, or custom templates
|
|
554
|
+
// .forceSystemPrompt - optional exact replacement for the complete prompt
|
|
554
555
|
// .selectedTools - tools currently active in the prompt
|
|
555
556
|
// .toolSnippets - one-line descriptions for each tool
|
|
556
|
-
// .
|
|
557
|
+
// .toolGuidelines - guideline bullets keyed by tool name
|
|
558
|
+
// .promptGuidelines - additional custom guideline bullets
|
|
559
|
+
// .sections - custom XML-wrapped sections keyed by tag name
|
|
557
560
|
// .appendSystemPrompt - text from --append-system-prompt flags
|
|
558
561
|
// .cwd - working directory
|
|
559
562
|
// .contextFiles - AGENTS.md files and other loaded context files
|
|
@@ -572,7 +575,7 @@ pi.on("before_agent_start", async (event, ctx) => {
|
|
|
572
575
|
});
|
|
573
576
|
```
|
|
574
577
|
|
|
575
|
-
The `systemPromptOptions` field gives extensions access to the same structured data Pi uses to build the system prompt.
|
|
578
|
+
The `systemPromptOptions` field gives extensions access to the same structured data Pi uses to build the system prompt. Collections are mutable. Prefer changing `sections`, `selectedTools`, or `promptGuidelines`: Pi diffs the resulting prompt sections against what the model already has and appends one system message patching only the changed sections. Returning `systemPrompt`, or setting `forceSystemPrompt`, replaces the whole prompt for the run: every provider receives the forced text as its leading system prompt (a cache miss when it changes), and the session transcript keeps recording the structured sections. Tool selection changes update both the prompt contributions and executable provider tools; calling `pi.setActiveTools()` inside the handler has the same effect as editing `selectedTools`. Models that accept system messages mid-conversation receive the patch in place and keep their cached prefix; other models get the replayed prompt as their system prompt, which is a cache miss once per change.
|
|
576
579
|
|
|
577
580
|
Inside `before_agent_start`, `event.systemPrompt` and `ctx.getSystemPrompt()` both reflect the chained system prompt as of the current handler. Later `before_agent_start` handlers can still modify it again.
|
|
578
581
|
|
|
@@ -749,6 +752,25 @@ pi.on("after_provider_response", (event, ctx) => {
|
|
|
749
752
|
|
|
750
753
|
Header availability depends on provider and transport. Providers that abstract HTTP responses may not expose headers.
|
|
751
754
|
|
|
755
|
+
#### cache_warming_decision
|
|
756
|
+
|
|
757
|
+
Fired before each prompt-cache refresh with pi's decision filled in. The event carries only pi's cost estimates; use `ctx.model`, `ctx.isIdle()`, and `ctx.getContextUsage()` for everything else.
|
|
758
|
+
|
|
759
|
+
```typescript
|
|
760
|
+
pi.on("cache_warming_decision", (event, ctx) => {
|
|
761
|
+
// event.warmCost: price of this refresh
|
|
762
|
+
// event.missCost: extra price of the next request if the entry is lost
|
|
763
|
+
// event.continuationProbability: pi's estimate that a request arrives in time
|
|
764
|
+
// event.action: "warm" | "stop", pi's decision
|
|
765
|
+
|
|
766
|
+
if (ctx.model?.provider === "my-provider") {
|
|
767
|
+
return { action: "stop" };
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
```
|
|
771
|
+
|
|
772
|
+
Return `{ action: "warm" }` or `{ action: "stop" }` to override; the last handler that returns an action wins. `"stop"` ends warming until the next real request.
|
|
773
|
+
|
|
752
774
|
### Model Events
|
|
753
775
|
|
|
754
776
|
#### model_select
|
|
@@ -923,6 +945,8 @@ pi.on("user_bash", (event, ctx) => {
|
|
|
923
945
|
});
|
|
924
946
|
```
|
|
925
947
|
|
|
948
|
+
Returning `undefined` continues to the next handler, then local execution if none handles the event. A valid result stops propagation: `operations` executes the command through the supplied backend, while `result` records the completed command without executing it.
|
|
949
|
+
|
|
926
950
|
### Input Events
|
|
927
951
|
|
|
928
952
|
#### input
|
|
@@ -1033,6 +1057,12 @@ Access to models, providers, and resolved authentication. `ctx.modelRegistry.get
|
|
|
1033
1057
|
|
|
1034
1058
|
`ctx.scopedModels` is the read-only list of models scoped to the current session—the same set shown by `/scoped-models`. Pi resolves it at session start from `--models` and the `enabledModels` setting, matching `provider/modelId` or bare `modelId` patterns with minimatch. An empty list means no scope is configured and every available model is usable. Each entry is `{ model, thinkingLevel? }`; use this list when a custom model picker should mirror the built-in scope rather than enumerate the full registry.
|
|
1035
1059
|
|
|
1060
|
+
#### Streaming model calls
|
|
1061
|
+
|
|
1062
|
+
Use `ctx.modelRegistry.streamSimple(model, context, options)` for provider-neutral options such as `reasoning`, or `stream()` for API-specific options. Both use configured providers and resolve authentication, including for providers registered with `pi.registerProvider()`. Use these instead of `pi-ai/compat` streaming functions, which cannot see extension provider registrations.
|
|
1063
|
+
|
|
1064
|
+
Both return an `AssistantMessageEventStream`. Iterate it for response events and await `.result()` for the final message. Setup failures produce error events and error results.
|
|
1065
|
+
|
|
1036
1066
|
### ctx.signal
|
|
1037
1067
|
|
|
1038
1068
|
The current agent abort signal, or `undefined` when no agent turn is active.
|
|
@@ -1194,6 +1224,8 @@ if (usage && usage.tokens > 100_000) {
|
|
|
1194
1224
|
|
|
1195
1225
|
Returns a `Promise<ContextSnapshot>` with detached stable messages, effective system prompt, model, thinking level, active tool metadata in order, source session/leaf IDs, capture time, and `streamOptions`. It captures source state synchronously before awaiting preparation; partially streamed assistant frames are excluded. It throws if no model is selected.
|
|
1196
1226
|
|
|
1227
|
+
`messages` is the prepared transcript, so it starts with the session's `system` message once a request has been made, and `systemPrompt` is the prompt replayed from that transcript, including a prompt forced by `before_agent_start` for the last request. A native `Agent` seeded with these messages keeps that leading system message instead of declaring `systemPrompt` again. Before the first request, `messages` carry no system message and `systemPrompt` is the session's current prompt.
|
|
1228
|
+
|
|
1197
1229
|
The SDK reuses the message prefix already prepared for the most recent main request when it still matches the current branch and image policy, then converts newly settled messages. This preserves context-hook changes without replaying those hooks over the prefix. Before the first request, or after replacing the branch or image policy, it prepares the detached context once through the current context hooks and message conversion. It does not rerun `before_agent_start`, persist messages, or execute tools.
|
|
1198
1230
|
|
|
1199
1231
|
`streamOptions` includes transport, thinking budgets, timeouts, retries, provider hooks and header transforms. It contains callbacks, so the snapshot is not a JSON serialization format. Credentials are resolved through `ctx.modelRuntime`; the main run's abort signal and tool executors are never included. Provider hooks still run for each request and can change serialized payloads, so arbitrary external hooks can affect prefix reuse.
|
|
@@ -1252,7 +1284,7 @@ const options = ctx.getSystemPromptOptions();
|
|
|
1252
1284
|
const contextPaths = options.contextFiles?.map((file) => file.path) ?? [];
|
|
1253
1285
|
```
|
|
1254
1286
|
|
|
1255
|
-
This has the same shape and mutability as `before_agent_start` `event.systemPromptOptions`: custom prompt, active tools, tool snippets,
|
|
1287
|
+
This has the same shape and mutability as `before_agent_start` `event.systemPromptOptions`: custom or forced prompt, active tools, tool snippets, per-tool and custom rules, custom sections, appended prompt text, cwd, loaded context files, and loaded skills. It may include full context file contents, so treat it as sensitive extension-local data and avoid exposing it through command lists, logs, or autocomplete metadata.
|
|
1256
1288
|
|
|
1257
1289
|
This reports the current base prompt inputs. It does not include per-turn `before_agent_start` chained system-prompt changes, later `context` event message mutations, or `before_provider_request` payload rewrites.
|
|
1258
1290
|
|
|
@@ -1330,7 +1362,7 @@ Options:
|
|
|
1330
1362
|
|
|
1331
1363
|
### ctx.navigateTree(targetId, options?)
|
|
1332
1364
|
|
|
1333
|
-
Navigate to a different point in the session tree:
|
|
1365
|
+
Navigate to a different point in the session tree. Rejects while an agent response, manual or automatic compaction, or another tree navigation is active, even with `summarize: false`. These conflicts leave the active branch unchanged and reject the promise rather than returning `{ cancelled: true }`. Wait for the active operation to finish (for example, with `await ctx.waitForIdle()` in a command handler) and retry:
|
|
1334
1366
|
|
|
1335
1367
|
```typescript
|
|
1336
1368
|
const result = await ctx.navigateTree("entry-id-456", {
|
|
@@ -1499,7 +1531,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
1499
1531
|
|
|
1500
1532
|
### pi.on(event, handler)
|
|
1501
1533
|
|
|
1502
|
-
Subscribe to events. See [Events](#events) for event types and return values.
|
|
1534
|
+
Subscribe to events. Returns an unsubscribe function that removes only that registration. See [Events](#events) for event types and return values.
|
|
1535
|
+
|
|
1536
|
+
```typescript
|
|
1537
|
+
const unsubscribe = pi.on("agent_end", async (event) => {
|
|
1538
|
+
unsubscribe();
|
|
1539
|
+
await updateIntegration(event.messages);
|
|
1540
|
+
});
|
|
1541
|
+
```
|
|
1542
|
+
|
|
1543
|
+
Handlers run in extension load order, then registration order within each extension. Adding or removing a handler does not affect a dispatch already in progress.
|
|
1503
1544
|
|
|
1504
1545
|
### pi.registerTool(definition)
|
|
1505
1546
|
|
|
@@ -2523,38 +2564,13 @@ If a slot renderer is not defined or throws:
|
|
|
2523
2564
|
|
|
2524
2565
|
### Dynamic Tool Loading
|
|
2525
2566
|
|
|
2526
|
-
Extensions can register many tools while keeping only a small initial set active. A tool can then
|
|
2527
|
-
|
|
2528
|
-
This works with every model. Models with native deferred-loading support preserve the stable prompt prefix and load the new definitions at the tool-result position. Other models use the fallback described below.
|
|
2567
|
+
Extensions can register many tools while keeping only a small initial set active. A tool can then change the active set with `pi.setActiveTools()` during execution. Pi stores the initial prompt and tool loadout in the transcript's first system message, then appends tool and prompt deltas before the next model request. Providers that cannot represent a transition receive a complete transcript checkpoint, which may invalidate the cached prefix.
|
|
2529
2568
|
|
|
2530
2569
|
The lifecycle is:
|
|
2531
2570
|
|
|
2532
2571
|
1. Register every tool with `pi.registerTool()` so it appears in `pi.getAllTools()`.
|
|
2533
2572
|
2. Keep loader tools, such as `search_tools`, active and leave searchable tools inactive.
|
|
2534
|
-
3. During loader execution, call `pi.setActiveTools(
|
|
2535
|
-
4. Pi records which tools were added on the loader's tool result.
|
|
2536
|
-
5. Before the next model response, Pi exposes the added definitions using native deferred loading when supported, or the normal active tool list otherwise.
|
|
2537
|
-
|
|
2538
|
-
You do not need to return provider-specific tool references or mark the loader as a special search tool. The active-tool change is the signal. Names passed to `pi.setActiveTools()` must already be registered; unknown names are ignored.
|
|
2539
|
-
|
|
2540
|
-
#### Models with native deferred loading
|
|
2541
|
-
|
|
2542
|
-
- **Anthropic**
|
|
2543
|
-
- **Models:** Sonnet, Opus, Fable version 4.5 or newer (without Haiku)
|
|
2544
|
-
- **Native representation:** Deferred definitions use `defer_loading`; the load point uses `tool_reference` content.
|
|
2545
|
-
- **OpenAI**
|
|
2546
|
-
- **Models:** `gpt-5.4` and newer family
|
|
2547
|
-
- **Native representation:** Pi adds completed client `tool_search_call` and `tool_search_output` items at the load point.
|
|
2548
|
-
|
|
2549
|
-
For a verified custom model or proxy, native handling can be enabled with `compat.supportsToolReferences: true` for `anthropic-messages`, or `compat.supportsToolSearch: true` for `openai-responses` and `openai-codex-responses`. Leave these disabled unless the endpoint and model accept the corresponding native protocol.
|
|
2550
|
-
|
|
2551
|
-
#### Fallback behavior
|
|
2552
|
-
|
|
2553
|
-
For all other models and providers, dynamic activation still works: Pi sends the complete current active tool list normally on the next request. The model can call the newly activated tools, but adding their definitions may invalidate the provider's cached prompt prefix.
|
|
2554
|
-
|
|
2555
|
-
Pi also uses this safe fallback when the active set is not purely additive, such as replacing one group of tools with another. Tool removals therefore work, but they do not use deferred loading.
|
|
2556
|
-
|
|
2557
|
-
For the best cache behavior, keep the loader tool active for the whole session and add tools instead of replacing the active set. Also note that activating a tool with `promptSnippet` or `promptGuidelines` rebuilds the system prompt; that system-prompt change can invalidate the prefix even when the provider supports deferred schemas. Lazily loaded tools should usually rely on their tool `description` and omit active-only prompt metadata.
|
|
2573
|
+
3. During loader execution, call `pi.setActiveTools()` with the desired active tool names. Names must already be registered; unknown names are ignored.
|
|
2558
2574
|
|
|
2559
2575
|
#### Search tool example
|
|
2560
2576
|
|
|
@@ -2656,7 +2672,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
2656
2672
|
}
|
|
2657
2673
|
```
|
|
2658
2674
|
|
|
2659
|
-
When `search_tools` adds a match, the model receives
|
|
2675
|
+
When `search_tools` adds a match, the model receives the complete updated tool list on the immediately following request.
|
|
2660
2676
|
|
|
2661
2677
|
## Custom UI
|
|
2662
2678
|
|
package/docs/models.md
CHANGED
|
@@ -15,6 +15,7 @@ Pi reads this file at startup and on a model refresh, including when you open `/
|
|
|
15
15
|
- [Custom Headers](#custom-headers)
|
|
16
16
|
- [Model Configuration](#model-configuration)
|
|
17
17
|
- [Thinking Level Map](#thinking-level-map)
|
|
18
|
+
- [Prompt Cache Lifetimes](#prompt-cache-lifetimes)
|
|
18
19
|
- [Overriding Built-in Providers](#overriding-built-in-providers)
|
|
19
20
|
- [Per-model Overrides](#per-model-overrides)
|
|
20
21
|
- [Compatibility Options](#compatibility-options)
|
|
@@ -246,6 +247,7 @@ A `models` entry supplies a complete custom model definition with useful default
|
|
|
246
247
|
| `maxTokens` | No | `16384` | Maximum generated tokens. |
|
|
247
248
|
| `samplingParams` | No | omitted | Free-form sampling parameters merged verbatim into every request body; see [Sampling Parameters](#sampling-parameters). |
|
|
248
249
|
| `cost` | No | all rates `0` | Per-million-token rates and optional request-wide price tiers. |
|
|
250
|
+
| `promptCache` | No | omitted | Best-effort prompt cache lifetime in seconds per retention tier; see [Prompt Cache Lifetimes](#prompt-cache-lifetimes). |
|
|
249
251
|
| `headers` | No | omitted | Model-specific request headers; see [Custom Headers](#custom-headers). |
|
|
250
252
|
| `compat` | No | provider `compat` | Compatibility refinements merged with provider defaults. |
|
|
251
253
|
|
|
@@ -273,6 +275,19 @@ When `cost` is supplied on a `models` entry, it must contain all four base rates
|
|
|
273
275
|
}
|
|
274
276
|
```
|
|
275
277
|
|
|
278
|
+
### Prompt Cache Lifetimes
|
|
279
|
+
|
|
280
|
+
`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.
|
|
281
|
+
|
|
282
|
+
```json
|
|
283
|
+
{
|
|
284
|
+
"id": "claude-sonnet-5",
|
|
285
|
+
"promptCache": { "short": 300, "long": 3600 }
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
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).
|
|
290
|
+
|
|
276
291
|
### Sampling Parameters
|
|
277
292
|
|
|
278
293
|
`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`:
|
|
@@ -390,7 +405,23 @@ The built-in models remain. A new custom `id` is added, while a matching ID is r
|
|
|
390
405
|
}
|
|
391
406
|
```
|
|
392
407
|
|
|
393
|
-
An override supports `name`, `reasoning`, `thinkingLevelMap`, `input`, `cost`, `contextWindow`, `maxTokens`, `samplingParams` (merged per key), `headers`, and `compat`. Its `cost` base rates are individually optional and retain omitted values; a supplied `tiers` array replaces the existing array. Thinking maps merge by level. `compat` merges by field, and its `openRouterRouting`, `vercelGatewayRouting`, and `chatTemplateKwargs` objects merge by key.
|
|
408
|
+
An override supports `name`, `reasoning`, `thinkingLevelMap`, `input`, `cost`, `promptCache` (merged per tier), `contextWindow`, `maxTokens`, `samplingParams` (merged per key), `headers`, and `compat`. Its `cost` base rates are individually optional and retain omitted values; a supplied `tiers` array replaces the existing array. Thinking maps merge by level. `compat` merges by field, and its `openRouterRouting`, `vercelGatewayRouting`, and `chatTemplateKwargs` objects merge by key.
|
|
409
|
+
|
|
410
|
+
Use a `promptCache` override to enable cache warming through a proxy whose backing cache you know, for example OpenRouter routed to Anthropic:
|
|
411
|
+
|
|
412
|
+
```json
|
|
413
|
+
{
|
|
414
|
+
"providers": {
|
|
415
|
+
"openrouter": {
|
|
416
|
+
"modelOverrides": {
|
|
417
|
+
"anthropic/claude-sonnet-4": {
|
|
418
|
+
"promptCache": { "short": 300 }
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
```
|
|
394
425
|
|
|
395
426
|
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 use the 1.05M context window, override each model you use:
|
|
396
427
|
|
|
@@ -428,7 +459,10 @@ For `api: "anthropic-messages"`, use these options for Anthropic-compatible endp
|
|
|
428
459
|
| `forceAdaptiveThinking` | Uses adaptive thinking (`thinking.type: "adaptive"` and `output_config.effort`) regardless of model ID. Default: `false`. |
|
|
429
460
|
| `allowEmptySignature` | Replays an empty thinking signature as `signature: ""` instead of converting the thinking block to text. Default: `false`. |
|
|
430
461
|
| `supportsStrictTools` | Accepts strict JSON-schema tool definitions. Default: `false`; capable built-in Anthropic models set it in their metadata. |
|
|
431
|
-
| `
|
|
462
|
+
| `supportsMidConvoEffort` | Accepts effort-only system messages and thinking binding controls. Default: `false`. |
|
|
463
|
+
| `supportsMidConvoSystemMessages` | Accepts system-role messages inside the conversation. When `false`, later system messages fold into the top-level system prompt. Default: `false`. |
|
|
464
|
+
| `supportsMidConvoToolChanges` | Accepts mid-conversation `tool_addition` and `tool_removal` blocks. Requires `supportsMidConvoSystemMessages`. Default: `false`. |
|
|
465
|
+
| `allowedFallbackModels` | Models Anthropic accepts in `fallbacks` for server-side refusal fallback, with local pricing metadata for returned fallback responses. Omit `fallbacks` when empty. |
|
|
432
466
|
|
|
433
467
|
For example, a proxy that lacks eager streaming but supports long cache retention and adaptive thinking can use:
|
|
434
468
|
|
|
@@ -486,7 +520,8 @@ For `api: "openai-completions"`, Pi auto-detects many defaults from the provider
|
|
|
486
520
|
| `sessionAffinityFormat` | `openai` sends `session_id`, `x-client-request-id`, and `x-session-affinity`; `openai-nosession` omits `session_id`; `openrouter` sends `x-session-id`. It does not change `prompt_cache_key`. Default: URL-detected. |
|
|
487
521
|
| `supportsStrictMode` | Accepts strict JSON-schema function tools. Default: URL-detected. |
|
|
488
522
|
| `supportsOpenAIGrammarTools` | Emits OpenAI Lark/regex grammar tools. When `false`, grammar-constrained tools fall back to normal function tools. Default: `false`. |
|
|
489
|
-
| `
|
|
523
|
+
| `supportsMidConvoSystemMessages` | Accepts system or developer messages after the conversation has started. When `false`, later system messages fold into the leading system message. Default: `false`. |
|
|
524
|
+
| `supportsMidConvoToolAdditions` | Accepts tools introduced by mid-conversation system messages. Requires `supportsMidConvoSystemMessages`. Default: `false`. |
|
|
490
525
|
| `supportsLongCacheRetention` | Accepts long prompt-cache retention: `prompt_cache_retention: "24h"`, or `cache_control.ttl: "1h"` with `cacheControlFormat: "anthropic"`. Default: `true` except URL-detected incompatible endpoints. |
|
|
491
526
|
| `openRouterRouting` | OpenRouter routing preferences sent unchanged in the request `provider` field. |
|
|
492
527
|
| `vercelGatewayRouting` | Vercel AI Gateway routing preferences (`only`, `order`) sent as `providerOptions.gateway`. |
|
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` |
|
package/docs/sdk.md
CHANGED
|
@@ -118,6 +118,8 @@ interface AgentSession {
|
|
|
118
118
|
}
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
+
`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.
|
|
122
|
+
|
|
121
123
|
Session replacement APIs such as new-session, resume, fork, and import live on `AgentSessionRuntime`, not on `AgentSession`.
|
|
122
124
|
|
|
123
125
|
### createAgentSessionRuntime() and AgentSessionRuntime
|
|
@@ -330,8 +332,8 @@ const state = session.agent.state;
|
|
|
330
332
|
// state.messages: AgentMessage[] - conversation history
|
|
331
333
|
// state.model: Model - current model
|
|
332
334
|
// state.thinkingLevel: ThinkingLevel - current thinking level
|
|
333
|
-
// state.systemPrompt: string - system
|
|
334
|
-
// state.tools: AgentTool[] -
|
|
335
|
+
// state.systemPrompt: string - read-only, replayed from the transcript's system messages
|
|
336
|
+
// state.tools: AgentTool[] - executable tools; changes are declared to the model before the next request
|
|
335
337
|
// state.streamingMessage?: AgentMessage - current partial assistant message
|
|
336
338
|
// state.errorMessage?: string - latest assistant error
|
|
337
339
|
|