@kingingwang/pi-darwin-arm64 0.85.1 → 0.87.0
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/bin/CHANGELOG.md +148 -0
- package/bin/README.md +39 -1
- package/bin/docs/compaction.md +62 -17
- package/bin/docs/custom-provider.md +22 -13
- package/bin/docs/development.md +4 -4
- package/bin/docs/docs.json +4 -0
- package/bin/docs/environment-variables.md +1 -0
- package/bin/docs/extensions.md +127 -49
- package/bin/docs/json.md +4 -4
- package/bin/docs/models.md +61 -2
- package/bin/docs/providers.md +10 -2
- package/bin/docs/sdk.md +17 -4
- package/bin/docs/security.md +1 -1
- package/bin/docs/session-format.md +96 -41
- package/bin/docs/sessions.md +27 -0
- package/bin/docs/settings.md +56 -1
- package/bin/docs/termux.md +0 -1
- package/bin/docs/tui.md +2 -2
- package/bin/docs/usage.md +1 -0
- package/bin/examples/extensions/README.md +0 -1
- package/bin/examples/extensions/custom-provider-anthropic/index.ts +18 -12
- package/bin/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/bin/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/bin/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
- package/bin/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/bin/examples/extensions/gondolin/package-lock.json +2 -2
- package/bin/examples/extensions/gondolin/package.json +1 -1
- package/bin/examples/extensions/prompt-customizer.ts +19 -67
- package/bin/examples/extensions/sandbox/package-lock.json +2 -2
- package/bin/examples/extensions/sandbox/package.json +1 -1
- package/bin/examples/extensions/with-deps/package-lock.json +2 -2
- package/bin/examples/extensions/with-deps/package.json +1 -1
- package/bin/examples/plugins/pi-example-plugin/src/session.ts +3 -2
- package/bin/export-html/template.js +6 -1
- package/bin/native/darwin/prebuilds/darwin-arm64/{darwin-modifiers.node → darwin-platform.node} +0 -0
- package/bin/package.json +17 -23
- package/bin/pi +2 -2
- package/package.json +1 -1
- package/bin/examples/extensions/kimi-deferred-tools.ts +0 -61
- package/bin/node_modules/@mariozechner/clipboard/.yarnrc.yml +0 -1
- package/bin/node_modules/@mariozechner/clipboard/Cargo.toml +0 -45
- package/bin/node_modules/@mariozechner/clipboard/README.md +0 -60
- package/bin/node_modules/@mariozechner/clipboard/build.rs +0 -5
- package/bin/node_modules/@mariozechner/clipboard/clipboard.darwin-arm64.node +0 -0
- package/bin/node_modules/@mariozechner/clipboard/exp.ts +0 -12
- package/bin/node_modules/@mariozechner/clipboard/index.d.ts +0 -37
- package/bin/node_modules/@mariozechner/clipboard/index.js +0 -606
- package/bin/node_modules/@mariozechner/clipboard/package.json +0 -56
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/common.rs +0 -307
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/mod.rs +0 -93
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/ios.rs +0 -313
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/macos.rs +0 -471
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/mod.rs +0 -252
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/wayland.rs +0 -431
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/win.rs +0 -712
- package/bin/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/x11.rs +0 -916
- package/bin/node_modules/@mariozechner/clipboard/src/lib.rs +0 -194
package/bin/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,152 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.87.0] - 2026-09-21
|
|
4
|
+
|
|
5
|
+
### New Features
|
|
6
|
+
|
|
7
|
+
- **Canonical session context and extension boundaries** — Edit model context without rewriting history and add actionable lifecycle hooks. See [ContextEditEntry](docs/session-format.md#contexteditentry) and [extension events](docs/extensions.md#extension-events).
|
|
8
|
+
- **Full-transcript context extensions** — Use `context_with_system` for per-request system-message transformations. See [`context_with_system`](docs/extensions.md#context_with_system).
|
|
9
|
+
- **Per-model image input limits** — Configure cache-safe image resizing per model for attachments, `read`, and tool-result images. See [Image Input Limits](docs/models.md#image-input-limits).
|
|
10
|
+
|
|
11
|
+
### Breaking Changes
|
|
12
|
+
|
|
13
|
+
- Removed the inherited `shouldStopAfterTurn` agent option. Use `finishTurn` and return `{ action: "end" }` instead. `finishTurn` runs before `turn_end` but applies the decision afterward, and it also receives error and aborted responses; migrate normal-response predicates by returning `undefined` for those hard exits. See the `@earendil-works/pi-agent-core` changelog for a complete before-and-after example.
|
|
14
|
+
- Added `ContextEditEntry` to the exported `SessionEntry` union. TypeScript consumers with exhaustive entry switches must handle `context_edit`; use `replacement: null` for omission and a content replacement otherwise.
|
|
15
|
+
- Made `SessionManager` canonical for `AgentSession` provider context. Assigning `session.agent.state.messages` no longer replaces future request history; restore with `SessionManager.inMemory(cwd, { id }, entries)`, navigate with `session.navigateTree()`, or append through `session.sessionManager` and call `session.refreshContext()`.
|
|
16
|
+
- Expanded `TurnEndEvent` with required boundary fields and added `AgentBeforeSettleEvent` to the exported `ExtensionEvent` union. Consumers constructing events or exhaustively switching on `ExtensionEvent` must handle the new shapes. `ExtensionRunner.emit()` no longer accepts `turn_end`; host integrations dispatch actionable boundaries with `emitBoundary(baseEvent, buildContext)`.
|
|
17
|
+
- Deferred runs requested from `agent_settled` handlers until all settled handlers finish. Handlers still observe `ctx.isIdle() === true`, but no longer see a reentrant `agent_start` during the same notification dispatch.
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- Added append-only model-context edits. For example, `sessionManager.appendContextEdit(entryId, null)` omits one message from future provider context without changing raw history, usage, or UI history.
|
|
22
|
+
- Added actionable `turn_end` and `agent_before_settle` extension boundaries. Return `{ entries: [...event.entries, draft], continue: true }` to persist structural entries in order and ensure one next provider request without changing steering or follow-up scheduling.
|
|
23
|
+
- Added retain-none compaction input: `sessionManager.appendCompaction(summary, null, tokensBefore)` stores the compaction's own ID as its kept boundary.
|
|
24
|
+
- Added the `context_with_system` extension event, which runs after `context` handlers on the full transcript including system messages and sends its result verbatim. See [`context_with_system`](docs/extensions.md#context_with_system).
|
|
25
|
+
- Added per-model image resize profiles through `inputLimits.images.resize` in `models.json`, applied to file attachments, image reads, and tool-result images ([#9631](https://github.com/earendil-works/pi/issues/9631)).
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- Fixed string context-edit replacements producing invalid assistant and tool-result message content instead of text blocks.
|
|
30
|
+
- Fixed context-invisible boundary metadata and replacement edits causing newly appended or replaced input to be summarized before its first provider request.
|
|
31
|
+
- Fixed edited-context accounting both discarding valid assistant usage captured after the latest context edit and reusing that usage after a later compaction made it stale.
|
|
32
|
+
- Fixed selected error retries and final length/overflow recovery retaining abandoned model attempts in future provider context; post-run recovery omissions are now persisted without hiding raw transcript history or changing queue scheduling.
|
|
33
|
+
- Fixed `context` handlers that filter or slice messages dropping the prompt and tool declarations, which after extension-driven compaction left requests without built-in tools or made Codex emit raw tool-call text. Handlers no longer see system messages; Pi restores the prompt and tool state after they run. See [`context`](docs/extensions.md#context) ([#9789](https://github.com/earendil-works/pi/issues/9789), [#9822](https://github.com/earendil-works/pi/issues/9822)).
|
|
34
|
+
- Fixed `/bug` allowing uploads in offline mode while preserving local zip exports ([#9841](https://github.com/earendil-works/pi/pull/9841) by [@christianklotz](https://github.com/christianklotz)).
|
|
35
|
+
- Fixed idle prompt-cache warming rebuilding expired caches when its timer or an extension decision is delayed.
|
|
36
|
+
- Improved crash diagnostics with hints identifying loaded extensions that appear in the stack trace.
|
|
37
|
+
- Fixed text files beginning with `GIF` being misclassified as images and omitted from `read` and CLI `@file` input ([#9755](https://github.com/earendil-works/pi/issues/9755)).
|
|
38
|
+
- Fixed malformed prompt template frontmatter being silently ignored instead of reported as a resource warning ([#9830](https://github.com/earendil-works/pi/pull/9830) by [@christianklotz](https://github.com/christianklotz)).
|
|
39
|
+
- Fixed inherited unknown OpenAI-compatible Chat Completions endpoints receiving strict tool schemas unless they explicitly advertise support ([#9816](https://github.com/earendil-works/pi/issues/9816)).
|
|
40
|
+
|
|
41
|
+
## [0.86.1] - 2026-09-20
|
|
42
|
+
|
|
43
|
+
### New Features
|
|
44
|
+
|
|
45
|
+
- **Meta Muse provider** — Sign in with Meta using `/login meta` or use `META_API_KEY` to access Muse Spark models. See [Meta (Muse subscription)](docs/providers.md#meta-muse-subscription).
|
|
46
|
+
|
|
47
|
+
### Added
|
|
48
|
+
|
|
49
|
+
- Added Meta (Muse subscription) login via `/login meta` with automatic Model API key refresh, plus `META_API_KEY` support ([#9096](https://github.com/earendil-works/pi/pull/9096) by [@xl0](https://github.com/xl0)).
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
|
|
53
|
+
- Enabled Node's persistent compile cache before loading the bundled CLI runtime, reducing repeat launch time.
|
|
54
|
+
|
|
55
|
+
### Fixed
|
|
56
|
+
|
|
57
|
+
- Fixed `/bug` descriptions dropping line breaks from pasted diagnostics.
|
|
58
|
+
- Fixed `/bug` hints appearing for user cancellations and retryable provider failures such as service unavailability.
|
|
59
|
+
- Fixed clipboard copy failing in containers and WSL without WSLg by restoring the OSC 52 fallback when no display is available, and added a verified Windows clipboard backend for WSL ([#9688](https://github.com/earendil-works/pi/issues/9688)).
|
|
60
|
+
- Fixed inherited z.ai `Prompt too long` errors not being recognized as context overflow ([#9805](https://github.com/earendil-works/pi/issues/9805)).
|
|
61
|
+
- Fixed inherited Cerebras models advertising unsupported strict tool schemas, which caused HTTP 400 errors when strict and non-strict tools were mixed ([#9804](https://github.com/earendil-works/pi/pull/9804) by [@EdenGottlieb](https://github.com/EdenGottlieb)).
|
|
62
|
+
|
|
63
|
+
## [0.86.0] - 2026-09-19
|
|
64
|
+
|
|
65
|
+
### New Features
|
|
66
|
+
|
|
67
|
+
- **Prompt cache warming** — Keep valuable prompt caches alive during long tool runs and optionally while idle using cost-aware refreshes. See [Cache Warming](docs/settings.md#cache-warming).
|
|
68
|
+
- **Bug reporting** — Report problems with `/bug` using redacted diagnostics, optional transcripts, or exported ZIP archives. See [Reporting Bugs](docs/sessions.md#reporting-bugs).
|
|
69
|
+
- **Transcript-aware prompt and tool updates** — Preserve instruction and tool changes across resume and branch navigation while retaining cached prefixes. See [`before_agent_start`](docs/extensions.md#before_agent_start).
|
|
70
|
+
- **Offline Radius model catalog** — Select Radius models immediately, with cached and live catalogs overlaid when available. See [Radius](docs/providers.md#radius).
|
|
71
|
+
- **Per-model compaction budgets** — Configure reserved and recent-token budgets by model. See [Per-model overrides](docs/compaction.md#per-model-overrides).
|
|
72
|
+
|
|
73
|
+
### Breaking Changes
|
|
74
|
+
|
|
75
|
+
- Changed inherited pi-ai provider stream inputs from `Context` to normalized `TranscriptContext` values. Custom providers must read system prompts and tool declarations from `context.messages` with `getCurrentSystemPrompt()` and `getCurrentTools()`. See [Custom Streaming API](docs/custom-provider.md#custom-streaming-api).
|
|
76
|
+
- Restricted inherited `ToolCall.arguments` and `ToolResultMessage.details` to JSON-compatible values, changed `ToolResultMessage` into a conditional type, and made `JsonValue` arrays readonly.
|
|
77
|
+
- `user_bash` now fails closed: errors or invalid defined results abort the command without invoking later handlers or executing locally. Return `undefined` to continue propagation; otherwise return `{ operations }` or `{ result }` ([#9068](https://github.com/earendil-works/pi/issues/9068)).
|
|
78
|
+
|
|
79
|
+
### Added
|
|
80
|
+
|
|
81
|
+
- Added transcript-backed mid-conversation system prompt and tool changes so instruction and tool updates survive resume and branch navigation while preserving cached prefixes on supported models. See [`before_agent_start`](docs/extensions.md#before_agent_start) and [Entry Types](docs/session-format.md#entry-types) ([#9548](https://github.com/earendil-works/pi/pull/9548)).
|
|
82
|
+
- Added inherited native deferred tool loading for Fireworks Messages models. Use `ToolSearch` or `tool_search` as the loader name for prompt-prefix deferral ([#9323](https://github.com/earendil-works/pi/issues/9323)).
|
|
83
|
+
- Added click toggling for branch summaries, compaction summaries, and skill invocation entries.
|
|
84
|
+
- Added the public Radius model catalog for immediate and offline model selection, with cached and live gateway catalogs overlaid when available.
|
|
85
|
+
- Added `ctx.modelRegistry.stream()` and `streamSimple()` for extension model calls through configured providers with resolved authentication ([#8964](https://github.com/earendil-works/pi/issues/8964)).
|
|
86
|
+
- Added per-model `reserveTokens` and `keepRecentTokens` settings through `compaction.modelOverrides`, with ordinary compaction settings as fallback ([#8133](https://github.com/earendil-works/pi-mono/issues/8133)).
|
|
87
|
+
- Added `compat.allowedFallbackModels` configuration for overriding or disabling Anthropic server-side fallback models ([#9294](https://github.com/earendil-works/pi/issues/9294)).
|
|
88
|
+
- Added an unsubscribe function from `pi.on()` so extensions can drop event handlers. Handlers added or removed during a dispatch apply to later dispatches, not the current one ([#8967](https://github.com/earendil-works/pi/issues/8967)).
|
|
89
|
+
- Exported extension hook event and result types that were previously omitted from the package entry points ([#9642](https://github.com/earendil-works/pi/pull/9642)).
|
|
90
|
+
- Added `/bug [description]` to report a bug to the Pi developers. The report bundles environment, model, provider, extension, and settings metadata (secrets redacted), assistant message diagnostics from the session, optionally the session transcript, or a model-written summary of what went wrong instead. It is uploaded to Radius (no login required; attributed when logged in) or exported as a zip archive, and the report id is recorded in the session as a `pi.bug-report` entry. Crashes are recorded in `~/.pi/agent/crashes.json`, announced once on the next start, and attached to the next report; unexplained errors and exhausted retries point at `/bug` once per session.
|
|
91
|
+
- Added cost-aware prompt-cache warming during long tool runs and optionally while idle, with configurable modes, model cache-lifetime metadata, `/session` diagnostics, transcript notices, and the `cache_warming_decision` extension event. See [Cache Warming](docs/settings.md#cache-warming) ([#9668](https://github.com/earendil-works/pi/pull/9668)).
|
|
92
|
+
|
|
93
|
+
### Changed
|
|
94
|
+
|
|
95
|
+
- Enabled Node's persistent compile cache before loading the bundled CLI runtime, reducing repeat launch time.
|
|
96
|
+
- Made `--resume` session results appear progressively, using file modification times to prioritize all-folder loading and cancelling outstanding transcript reads after selection.
|
|
97
|
+
- Reduced `--continue` startup time by checking candidate session headers in modification-time order and stopping after the newest matching session.
|
|
98
|
+
- Replaced the external native clipboard dependency with bundled asynchronous macOS, Windows, and X11 helpers while preserving platform command and OSC 52 fallbacks ([#9163](https://github.com/earendil-works/pi/pull/9163)).
|
|
99
|
+
- Reduced inherited fuzzy search latency for long texts by using native substring search instead of scanning each character in JavaScript ([#9267](https://github.com/earendil-works/pi/issues/9267)).
|
|
100
|
+
- Moved compaction, branch summarization, and retry spinners into the editor border alongside the working indicator. Custom editors use the same embedding opt-in for all status spinners.
|
|
101
|
+
- Enabled strict-prefer JSON-schema sampling by default for built-in `read`, `bash`, `powershell`, `edit`, and `write` tools, without requiring `PI_EXPERIMENTAL`. Extensions can re-register tool definitions with `constrainedSampling: false`.
|
|
102
|
+
- Formatted Bash and PowerShell tool durations of at least one minute as minutes and seconds, with hours when needed ([#9628](https://github.com/earendil-works/pi/issues/9628)).
|
|
103
|
+
- Deferred the extension compiler and bundled virtual modules until a filesystem extension is loaded, reducing the baseline SDK import cost ([#9540](https://github.com/earendil-works/pi/issues/9540)).
|
|
104
|
+
|
|
105
|
+
### Fixed
|
|
106
|
+
|
|
107
|
+
- Fixed GitHub Copilot GPT models, including GPT-6 Astra, using the Chat Completions adapter instead of the required Responses adapter ([#9253](https://github.com/earendil-works/pi/pull/9253) by [@petrroll](https://github.com/petrroll)).
|
|
108
|
+
- Fixed inherited DeepSeek V4.1 thinking levels on OpenRouter and OpenCode Go preserving provider effort metadata ([#9485](https://github.com/earendil-works/pi/issues/9485)).
|
|
109
|
+
- Fixed inherited bodyless HTTP 400/413 errors from non-Cerebras providers being misclassified as context overflow ([#9482](https://github.com/earendil-works/pi/issues/9482)).
|
|
110
|
+
- Fixed inherited Vercel AI Gateway replaying unsigned thinking as assistant text ([#9676](https://github.com/earendil-works/pi/issues/9676)).
|
|
111
|
+
- Fixed inherited Google Generative AI and Vertex AI using unsupported thinking levels when reasoning is omitted or when model capabilities differ within a Gemini family ([#9455](https://github.com/earendil-works/pi/issues/9455)).
|
|
112
|
+
- Fixed inherited Anthropic-compatible relays breaking signed thinking replay when they report a different response model, while preserving fallback pricing ([#9188](https://github.com/earendil-works/pi/issues/9188)).
|
|
113
|
+
- Fixed inherited Amazon Bedrock one-hour cache writes being priced at the five-minute rate ([#9457](https://github.com/earendil-works/pi/issues/9457)).
|
|
114
|
+
- Fixed inherited quadratic CPU usage when draining buffered `EventStream` events ([#9055](https://github.com/earendil-works/pi/issues/9055)).
|
|
115
|
+
- Fixed inherited Mistral Medium reasoning requests to use `reasoning_effort` for all reasoning-capable `mistral-medium-*` model IDs instead of the unsupported `prompt_mode` ([#8700](https://github.com/earendil-works/pi/issues/8700)).
|
|
116
|
+
- Fixed inherited OpenCode and OpenCode Go requests to send `x-opencode-session` from `sessionId` across all supported API adapters ([#9326](https://github.com/earendil-works/pi/issues/9326)).
|
|
117
|
+
- Fixed inherited OpenAI Codex requests to send the model's Off reasoning effort instead of omitting it, while respecting unsupported Off mappings ([#9191](https://github.com/earendil-works/pi/issues/9191)).
|
|
118
|
+
- Fixed inherited Fireworks unsigned thinking replay and reasoning effort selection using catalog metadata, with verified DeepSeek V4 and Qwen3.8 fallbacks and removal of redundant GLM 5.2 and Kimi K3 effort aliases ([#9323](https://github.com/earendil-works/pi/issues/9323)).
|
|
119
|
+
- Fixed inherited OpenRouter requests to send `x-session-id` from `sessionId` for Chat Completions and Anthropic Messages models when prompt caching is enabled ([#9102](https://github.com/earendil-works/pi/issues/9102)).
|
|
120
|
+
- Fixed the inherited DeepSeek catalog to advertise `deepseek-flash` for DeepSeek V4.1 Flash instead of retired Flash aliases, and refreshed DeepSeek pricing metadata ([#9423](https://github.com/earendil-works/pi/issues/9423)).
|
|
121
|
+
- Fixed inherited Mistral-hosted GLM-5.2 reasoning requests to use `reasoning_effort` instead of the ignored `prompt_mode` ([#9375](https://github.com/earendil-works/pi/issues/9375)).
|
|
122
|
+
- Fixed inherited OpenAI-compatible Responses errors to identify the actual provider instead of always labeling them as OpenAI errors ([#9298](https://github.com/earendil-works/pi/issues/9298)).
|
|
123
|
+
- Fixed inherited Baseten requests to send session-affinity headers from `sessionId` for automatic prompt-cache routing ([#9629](https://github.com/earendil-works/pi/issues/9629)).
|
|
124
|
+
- Fixed inherited retry classification for Cloudflare 520 responses ([#9627](https://github.com/earendil-works/pi/issues/9627)).
|
|
125
|
+
- Fixed inherited retry classification for transient Azure peak-load capacity errors ([#9669](https://github.com/earendil-works/pi/issues/9669)).
|
|
126
|
+
- Fixed session tree navigation racing with active compaction and replacing its progress UI ([#9179](https://github.com/earendil-works/pi/pull/9179) by [@acmerfight](https://github.com/acmerfight)).
|
|
127
|
+
- Fixed exact session ID lookup scanning complete transcript bodies instead of reading session headers ([#9601](https://github.com/earendil-works/pi/pull/9601) by [@metaist](https://github.com/metaist)).
|
|
128
|
+
- Fixed repeated Anthropic thinking-drop notices being shown for the same dropped blocks, and shortened notices while retaining details in the session ([#9391](https://github.com/earendil-works/pi/issues/9391)).
|
|
129
|
+
- Fixed mid-run threshold compaction silently skipping oversized trailing tool results ([#9740](https://github.com/earendil-works/pi/issues/9740)).
|
|
130
|
+
- Fixed signal-terminated local shell commands being reported as successful with partial output ([#9577](https://github.com/earendil-works/pi/issues/9577) by [@BrendanJMurphy](https://github.com/BrendanJMurphy)).
|
|
131
|
+
- Fixed local clipboard failures reporting success when the terminal ignored the fallback OSC 52 write, and added platform-specific setup guidance when no clipboard backend works ([#9618](https://github.com/earendil-works/pi/issues/9618)).
|
|
132
|
+
- Capped agent-level retry backoff at `retry.maxAgentDelayMs` (60s by default) so long retry runs stay responsive during prolonged transient outages ([#8826](https://github.com/earendil-works/pi/issues/8826)).
|
|
133
|
+
- Fixed direct RPC `steer` and `follow_up` commands bypassing extension `input` handlers ([#8718](https://github.com/earendil-works/pi/issues/8718)).
|
|
134
|
+
- Fixed premature missing-model errors after login by waiting for catalog discovery. Radius now defaults to `balanced`, falling back to the first available Radius model when needed.
|
|
135
|
+
- Fixed fullscreen mode reserving a blank row for custom footers that render zero rows ([#8919](https://github.com/earendil-works/pi/issues/8919)).
|
|
136
|
+
- Fixed extension tools without parameter schemas to be rejected during registration instead of breaking provider requests ([#9300](https://github.com/earendil-works/pi/issues/9300)).
|
|
137
|
+
- Fixed `before_agent_start` handlers returning `systemPrompt` (and `forceSystemPrompt`) on models with mid-conversation system messages: the forced prompt is now sent as the provider's leading system prompt instead of being appended as a section patch after the original prompt.
|
|
138
|
+
- Fixed loaded llama.cpp models with `enable_thinking` chat templates ignoring Pi's thinking level ([#9528](https://github.com/earendil-works/pi/issues/9528)).
|
|
139
|
+
- Fixed cancellation races that could start automatic compaction, leave stale retry state, or miss cancellation while waiting for summarization authentication ([#9340](https://github.com/earendil-works/pi/issues/9340), [#9777](https://github.com/earendil-works/pi/issues/9777)).
|
|
140
|
+
- Fixed asynchronous Kitty image conversion replacing newer partial tool output images ([#8743](https://github.com/earendil-works/pi/pull/8743) by [@wutongyuonce](https://github.com/wutongyuonce)).
|
|
141
|
+
- Fixed inherited skill slash-command autocomplete ranking the `skill:` prefix instead of the bare skill name ([#9120](https://github.com/earendil-works/pi/pull/9120) by [@yearth](https://github.com/yearth)).
|
|
142
|
+
- Fixed inherited file autocomplete boundaries and path quoting around CJK punctuation ([#9746](https://github.com/earendil-works/pi/pull/9746) by [@haoqixu](https://github.com/haoqixu)).
|
|
143
|
+
- Fixed inherited LaTeX legacy font switches falling back to raw source, centered `cases` layouts around surrounding equations, and vertically laid out unsupported and nested display scripts ([#8827](https://github.com/earendil-works/pi/issues/8827), [#9564](https://github.com/earendil-works/pi/issues/9564), [#7929](https://github.com/earendil-works/pi/issues/7929)).
|
|
144
|
+
- Fixed inherited fullscreen Kitty images being erased by later row clears in WezTerm ([#9169](https://github.com/earendil-works/pi/issues/9169)).
|
|
145
|
+
|
|
146
|
+
### Removed
|
|
147
|
+
|
|
148
|
+
- Removed unavailable inherited GPT-5.4 and GPT-5.4 mini models from OpenAI Codex selection ([#9394](https://github.com/earendil-works/pi/issues/9394)).
|
|
149
|
+
|
|
3
150
|
## [0.85.1] - 2026-09-05
|
|
4
151
|
|
|
5
152
|
### New Features
|
|
@@ -32,6 +179,7 @@
|
|
|
32
179
|
- Added inherited OpenAI-compatible `vllmPriority` and `supportsMaxOutputTokens` model settings for vLLM scheduler priority and OpenAI Responses output-token limits ([#9004](https://github.com/earendil-works/pi/pull/9004) by [@AppleDannyClegg](https://github.com/AppleDannyClegg), [#8941](https://github.com/earendil-works/pi/pull/8941) by [@scturtle](https://github.com/scturtle)).
|
|
33
180
|
- Added inherited LaTeX rendering for relational algebra join symbols ([#9050](https://github.com/earendil-works/pi/pull/9050) by [@haoqixu](https://github.com/haoqixu)).
|
|
34
181
|
- Added a clickable "Jump to latest message" label with the `tui.altScreen.bottom` shortcut to the fullscreen transcript while it is scrolled up ([#9080](https://github.com/earendil-works/pi/pull/9080) by [@rwachtler](https://github.com/rwachtler)).
|
|
182
|
+
- Added Meta (Muse subscription) login via `/login meta` with automatic Model API key refresh, plus `META_API_KEY` support.
|
|
35
183
|
|
|
36
184
|
### Changed
|
|
37
185
|
|
package/bin/README.md
CHANGED
|
@@ -130,6 +130,7 @@ For each built-in provider, pi maintains a list of tool-capable models. Configur
|
|
|
130
130
|
- Together AI
|
|
131
131
|
- Baseten
|
|
132
132
|
- Kimi For Coding
|
|
133
|
+
- Meta
|
|
133
134
|
- MiniMax
|
|
134
135
|
- Xiaomi MiMo
|
|
135
136
|
- Xiaomi MiMo Token Plan (China)
|
|
@@ -195,6 +196,7 @@ Type `/` in the editor to trigger commands. [Extensions](#extensions) can regist
|
|
|
195
196
|
| `/export [file]` | Export session to HTML or JSONL file |
|
|
196
197
|
| `/import <file>` | Import and resume a session from a JSONL file |
|
|
197
198
|
| `/share` | Upload as private GitHub gist with shareable HTML link |
|
|
199
|
+
| `/bug [description]` | Report a bug to the Pi developers; see [Sessions](docs/sessions.md#reporting-bugs) |
|
|
198
200
|
| `/reload` | Reload keybindings, extensions, skills, prompts, themes, and context files |
|
|
199
201
|
| `/hotkeys` | Show all keyboard shortcuts |
|
|
200
202
|
| `/changelog` | Display version history |
|
|
@@ -255,7 +257,7 @@ Use `/session` in interactive mode to see the current session ID before reusing
|
|
|
255
257
|
|
|
256
258
|
### Branching
|
|
257
259
|
|
|
258
|
-
**`/tree`** - Navigate the session tree in-place. Select any previous point, continue from there, and switch between branches. All history preserved in a single file.
|
|
260
|
+
**`/tree`** - Navigate the session tree in-place. Select any previous point, continue from there, and switch between branches. All history preserved in a single file. Selecting a point while the model is responding cancels that response. Navigation cannot proceed while compaction or another tree navigation is still running; wait for it to finish and retry.
|
|
259
261
|
|
|
260
262
|
<p align="center"><img src="docs/images/tree-view.png" alt="Tree View" width="600"></p>
|
|
261
263
|
|
|
@@ -280,6 +282,15 @@ Long sessions can exhaust context windows. Compaction summarizes older messages
|
|
|
280
282
|
|
|
281
283
|
Compaction is lossy. The full history remains in the JSONL file; use `/tree` to revisit. Customize compaction behavior via [extensions](#extensions). See [docs/compaction.md](docs/compaction.md) for internals.
|
|
282
284
|
|
|
285
|
+
Session model context is projected from append-only history. Extensions can append a `context_edit` to omit or replace an earlier message only for future model requests; raw history and usage remain unchanged:
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
const assistantId = sessionManager.appendMessage(partialAssistant);
|
|
289
|
+
sessionManager.appendContextEdit(assistantId, null); // Hidden from model context, retained in JSONL.
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
A retain-none compaction uses `appendCompaction(summary, null, tokensBefore)` to make the exact summary the new context root while preserving prior raw entries.
|
|
293
|
+
|
|
283
294
|
---
|
|
284
295
|
|
|
285
296
|
## Settings
|
|
@@ -381,6 +392,33 @@ export default function (pi: ExtensionAPI) {
|
|
|
381
392
|
}
|
|
382
393
|
```
|
|
383
394
|
|
|
395
|
+
`turn_end` and `agent_before_settle` are actionable persistence boundaries. Handlers can append structural entries and request one continuation. Later handlers see earlier proposals:
|
|
396
|
+
|
|
397
|
+
```typescript
|
|
398
|
+
let replacedResponse = false;
|
|
399
|
+
pi.on("turn_end", (event) => {
|
|
400
|
+
if (replacedResponse || event.outcome !== "completed" || event.toolResults.length > 0) return;
|
|
401
|
+
replacedResponse = true;
|
|
402
|
+
return {
|
|
403
|
+
entries: [
|
|
404
|
+
...event.entries,
|
|
405
|
+
{ type: "context_edit", targetId: event.messageEntryId, replacement: null },
|
|
406
|
+
{
|
|
407
|
+
type: "custom_message",
|
|
408
|
+
customType: "replacement-instruction",
|
|
409
|
+
content: "Answer again using the persisted user request.",
|
|
410
|
+
display: false,
|
|
411
|
+
},
|
|
412
|
+
],
|
|
413
|
+
continue: true,
|
|
414
|
+
};
|
|
415
|
+
});
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
Continuation is one-shot per boundary result, not per registered handler. It ensures one next provider request: tool-result, steering, or follow-up scheduling can satisfy that request without adding another one; otherwise Pi makes one context-only request. Guard handlers like the example above because an unconditional `continue: true` is evaluated again after the next response and can loop indefinitely. Error and aborted responses remain hard exits.
|
|
419
|
+
|
|
420
|
+
Use `agent_before_settle` for final actions after retries, compaction, and queued input are exhausted. See [docs/extensions.md](docs/extensions.md#agent_start--agent_end--agent_before_settle--agent_settled).
|
|
421
|
+
|
|
384
422
|
The default export can also be `async`. pi waits for async extension factories before startup continues, which is useful for one-time initialization such as fetching remote model lists before calling `pi.registerProvider()`.
|
|
385
423
|
|
|
386
424
|
**What's possible:**
|
package/bin/docs/compaction.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
LLMs have limited context windows. When conversations grow too long, Pi uses compaction to summarize older content while preserving recent work. This page covers both auto-compaction and branch summarization.
|
|
4
4
|
|
|
5
|
-
**Source files** ([pi
|
|
6
|
-
- [`packages/coding-agent/src/core/compaction/compaction.ts`](https://github.com/earendil-works/pi
|
|
7
|
-
- [`packages/coding-agent/src/core/compaction/branch-summarization.ts`](https://github.com/earendil-works/pi
|
|
8
|
-
- [`packages/coding-agent/src/core/compaction/utils.ts`](https://github.com/earendil-works/pi
|
|
9
|
-
- [`packages/coding-agent/src/core/session-manager.ts`](https://github.com/earendil-works/pi
|
|
10
|
-
- [`packages/coding-agent/src/core/extensions/types.ts`](https://github.com/earendil-works/pi
|
|
5
|
+
**Source files** ([pi](https://github.com/earendil-works/pi)):
|
|
6
|
+
- [`packages/coding-agent/src/core/compaction/compaction.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) - Auto-compaction logic
|
|
7
|
+
- [`packages/coding-agent/src/core/compaction/branch-summarization.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/branch-summarization.ts) - Branch summarization
|
|
8
|
+
- [`packages/coding-agent/src/core/compaction/utils.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/utils.ts) - Shared utilities (file tracking, serialization)
|
|
9
|
+
- [`packages/coding-agent/src/core/session-manager.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/session-manager.ts) - Entry types (`CompactionEntry`, `BranchSummaryEntry`)
|
|
10
|
+
- [`packages/coding-agent/src/core/extensions/types.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/extensions/types.ts) - Extension event types
|
|
11
11
|
|
|
12
12
|
For TypeScript definitions in your project, inspect `node_modules/@earendil-works/pi-coding-agent/dist/`.
|
|
13
13
|
|
|
@@ -34,14 +34,16 @@ contextTokens > contextWindow - reserveTokens
|
|
|
34
34
|
|
|
35
35
|
By default, `reserveTokens` is 16384 tokens (configurable in `~/.pi/agent/settings.json` or `<project-dir>/.pi/settings.json`). This leaves room for the LLM's response.
|
|
36
36
|
|
|
37
|
-
During a multi-turn agent run, Pi checks
|
|
37
|
+
During a multi-turn agent run, Pi checks the canonical projected context after tools finish and their results are appended, before starting the next assistant response. If the threshold is crossed, Pi compacts during `prepareNextTurn`, then performs the existing catch-up steering poll before `turn_start`. It skips this between-turn check when the completed tool batch terminates the run and no queued message requires another response. Pi also checks before a new user prompt and performs final-attempt overflow recovery after the low-level run ends.
|
|
38
|
+
|
|
39
|
+
A provider context-overflow error or an early final `stopReason: "length"` can select one compact-and-retry recovery attempt. Length responses with tool calls retain their synthetic failed tool results and follow the ordinary tool/queue scheduler rather than forcing the run to end.
|
|
38
40
|
|
|
39
41
|
You can also trigger manually with `/compact [instructions]`, where optional instructions focus the summary.
|
|
40
42
|
|
|
41
43
|
### How It Works
|
|
42
44
|
|
|
43
|
-
1. **Find cut point**: Walk backwards
|
|
44
|
-
2. **Extract messages**: Collect messages from the previous kept boundary (or session start) up to the cut point
|
|
45
|
+
1. **Find cut point**: Walk backwards through the finalized session projection, accumulating token estimates until `keepRecentTokens` (default 20k, configurable in `~/.pi/agent/settings.json` or `<project-dir>/.pi/settings.json`) is reached
|
|
46
|
+
2. **Extract messages**: Collect projected messages from the previous kept boundary (or session start) up to the cut point
|
|
45
47
|
3. **Generate summary**: Call LLM to summarize with structured format, passing the previous summary as iterative context when present
|
|
46
48
|
4. **Append entry**: Save `CompactionEntry` with summary and `firstKeptEntryId`
|
|
47
49
|
5. **Rebuilds context**: Session rebuilds the context for the next request, using summary + messages from `firstKeptEntryId` onwards
|
|
@@ -78,7 +80,22 @@ What the LLM sees:
|
|
|
78
80
|
prompt from cmp messages from firstKeptEntryId
|
|
79
81
|
```
|
|
80
82
|
|
|
81
|
-
On repeated compactions, the summarized span starts at the previous compaction's kept boundary (`firstKeptEntryId`), not at the compaction entry itself, falling back to the entry after the previous compaction if that kept entry cannot be found in the path. This preserves messages that survived the earlier compaction by including them in the next summarization pass as well. Pi also recalculates `tokensBefore` from the rebuilt session
|
|
83
|
+
On repeated compactions, the summarized span starts at the previous compaction's kept boundary (`firstKeptEntryId`), not at the compaction entry itself, falling back to the entry after the previous compaction if that kept entry cannot be found in the path. A retain-none compaction records its own ID as `firstKeptEntryId`; repeated compaction starts after that entry. This preserves messages that survived the earlier compaction by including them in the next summarization pass as well. Pi also recalculates `tokensBefore` from the rebuilt, context-edited session projection before writing the new `CompactionEntry`, so the token count reflects the actual pre-compaction context being replaced. Omitted raw entries remain stored but do not affect cut selection, summaries, checkpoints, or token estimates.
|
|
84
|
+
|
|
85
|
+
### Overflow and Length Recovery Ordering
|
|
86
|
+
|
|
87
|
+
Recovery preserves the existing lifecycle and queue order. The completed attempt remains visible to `turn_end` and `agent_end`; post-run recovery then repairs persisted model context before a fresh retry:
|
|
88
|
+
|
|
89
|
+
```text
|
|
90
|
+
persist final assistant response
|
|
91
|
+
→ extension/public turn_end
|
|
92
|
+
→ extension/public agent_end
|
|
93
|
+
→ append context_edit omissions for the selected attempt
|
|
94
|
+
→ for overflow/length: run session_before_compact and append compaction on success
|
|
95
|
+
→ start the retry as a fresh run
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
If recovery compaction fails or is cancelled, Pi keeps the omission edits, appends no compaction, and schedules no internal retry. Existing queued work remains governed by ordinary steering and follow-up rules. `agent_before_settle` sees the repaired projection after recovery processing. Raw transcript history, exports, billing totals, and history-search extensions can still inspect the omitted attempt.
|
|
82
99
|
|
|
83
100
|
### Split Turns
|
|
84
101
|
|
|
@@ -118,9 +135,11 @@ Valid cut points are:
|
|
|
118
135
|
|
|
119
136
|
Never cut at tool results (they must stay with their tool call).
|
|
120
137
|
|
|
138
|
+
Preparation advances the kept boundary into a context-invisible suffix only when that suffix contains an omitted assistant attempt and no unomitted context-producing entries. Recovery `context_edit` omissions satisfy this rule; intrinsically context-invisible metadata may coexist with them. Metadata alone and newly appended custom messages do not move the cut. A replacement edit affecting the candidate input or summarized prefix also blocks advancement because the omitted assistant answered the pre-edit input; replacements of suffix entries that are ultimately omitted remain safe. This allows an over-budget recovered input to be summarized while retaining the edits that keep the abandoned attempt omitted, without making bookkeeping change whether new model input is preserved verbatim.
|
|
139
|
+
|
|
121
140
|
### CompactionEntry Structure
|
|
122
141
|
|
|
123
|
-
Defined in [`session-manager.ts`](https://github.com/earendil-works/pi
|
|
142
|
+
Defined in [`session-manager.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/session-manager.ts):
|
|
124
143
|
|
|
125
144
|
```typescript
|
|
126
145
|
interface CompactionEntry<T = unknown> {
|
|
@@ -145,7 +164,7 @@ interface CompactionDetails {
|
|
|
145
164
|
|
|
146
165
|
Extensions can store any JSON-serializable data in `details`. The default compaction tracks file operations, but custom extension implementations can use their own structure. Generated and extension-provided summaries store their LLM `usage` when available so session totals include summarization work.
|
|
147
166
|
|
|
148
|
-
See [`prepareCompaction()`](https://github.com/earendil-works/pi
|
|
167
|
+
See [`prepareCompaction()`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) and [`compact()`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) for the implementation. For direct programmatic summarization, `generateSummary()` returns the summary text and `generateSummaryWithUsage()` returns `{ text, usage }`.
|
|
149
168
|
|
|
150
169
|
## Branch Summarization
|
|
151
170
|
|
|
@@ -188,7 +207,7 @@ This means file tracking accumulates across multiple compactions or nested branc
|
|
|
188
207
|
|
|
189
208
|
### BranchSummaryEntry Structure
|
|
190
209
|
|
|
191
|
-
Defined in [`session-manager.ts`](https://github.com/earendil-works/pi
|
|
210
|
+
Defined in [`session-manager.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/session-manager.ts):
|
|
192
211
|
|
|
193
212
|
```typescript
|
|
194
213
|
interface BranchSummaryEntry<T = unknown> {
|
|
@@ -212,7 +231,7 @@ interface BranchSummaryDetails {
|
|
|
212
231
|
|
|
213
232
|
Same as compaction, extensions can store custom data in `details`.
|
|
214
233
|
|
|
215
|
-
See [`collectEntriesForBranchSummary()`](https://github.com/earendil-works/pi
|
|
234
|
+
See [`collectEntriesForBranchSummary()`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/branch-summarization.ts), [`prepareBranchEntries()`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/branch-summarization.ts), and [`generateBranchSummary()`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/branch-summarization.ts) for the implementation.
|
|
216
235
|
|
|
217
236
|
## Summary Format
|
|
218
237
|
|
|
@@ -256,7 +275,7 @@ path/to/changed.ts
|
|
|
256
275
|
|
|
257
276
|
### Message Serialization
|
|
258
277
|
|
|
259
|
-
Before summarization, messages are serialized to text via [`serializeConversation()`](https://github.com/earendil-works/pi
|
|
278
|
+
Before summarization, messages are serialized to text via [`serializeConversation()`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/compaction/utils.ts):
|
|
260
279
|
|
|
261
280
|
```
|
|
262
281
|
[User]: What they said
|
|
@@ -272,7 +291,7 @@ Tool results are truncated to 2000 characters during serialization. Content beyo
|
|
|
272
291
|
|
|
273
292
|
## Custom Summarization via Extensions
|
|
274
293
|
|
|
275
|
-
Extensions can intercept and customize both compaction and branch summarization. See [`extensions/types.ts`](https://github.com/earendil-works/pi
|
|
294
|
+
Extensions can intercept and customize both compaction and branch summarization. See [`extensions/types.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/extensions/types.ts) for event type definitions.
|
|
276
295
|
|
|
277
296
|
### session_before_compact
|
|
278
297
|
|
|
@@ -288,7 +307,7 @@ pi.on("session_before_compact", async (event, ctx) => {
|
|
|
288
307
|
// preparation.fileOps - extracted file operations
|
|
289
308
|
// preparation.tokensBefore - context tokens before compaction
|
|
290
309
|
// preparation.firstKeptEntryId - where kept messages start
|
|
291
|
-
// preparation.settings -
|
|
310
|
+
// preparation.settings - effective settings after applying model overrides
|
|
292
311
|
|
|
293
312
|
// branchEntries - all entries on current branch (for custom state)
|
|
294
313
|
// reason - "manual" (/compact), "threshold", or "overflow"
|
|
@@ -416,3 +435,29 @@ Configure compaction in `~/.pi/agent/settings.json` or `<project-dir>/.pi/settin
|
|
|
416
435
|
| `keepRecentTokens` | `20000` | Recent tokens to keep (not summarized) |
|
|
417
436
|
|
|
418
437
|
Disable auto-compaction with `"enabled": false`. You can still compact manually with `/compact`.
|
|
438
|
+
|
|
439
|
+
### Per-model overrides
|
|
440
|
+
|
|
441
|
+
Use `compaction.modelOverrides` to tune token budgets for different models:
|
|
442
|
+
|
|
443
|
+
```json
|
|
444
|
+
{
|
|
445
|
+
"compaction": {
|
|
446
|
+
"reserveTokens": 16384,
|
|
447
|
+
"keepRecentTokens": 20000,
|
|
448
|
+
"modelOverrides": {
|
|
449
|
+
"some-provider/big-model": {
|
|
450
|
+
"reserveTokens": 400000
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
For a model with a 1M context window, this override triggers compaction above 600K tokens and keeps the ordinary 20000 recent tokens. Other models retain the ordinary 16384-token reserve. `reserveTokens` also influences summarization output limits, capped by the model's maximum output tokens; it is not solely a trigger threshold.
|
|
458
|
+
|
|
459
|
+
Keys are exact, case-sensitive `provider/modelId` values, including any slashes within the model ID. Each `reserveTokens` and `keepRecentTokens` value falls back independently from the model override to the ordinary setting to the built-in default. 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. `enabled` remains global, not model-specific.
|
|
460
|
+
|
|
461
|
+
These resolved values are used for manual compaction, all automatic threshold checks, overflow recovery, and extension-visible `preparation.settings`. 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.
|
|
462
|
+
|
|
463
|
+
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.
|
|
@@ -397,34 +397,40 @@ interface OAuthCredentials {
|
|
|
397
397
|
For providers with non-standard APIs, implement `streamSimple`. Study the existing API implementations before writing your own:
|
|
398
398
|
|
|
399
399
|
**Reference implementations:**
|
|
400
|
-
- [anthropic-messages.ts](https://github.com/earendil-works/pi
|
|
401
|
-
- [mistral-conversations.ts](https://github.com/earendil-works/pi
|
|
402
|
-
- [openai-completions.ts](https://github.com/earendil-works/pi
|
|
403
|
-
- [openai-responses.ts](https://github.com/earendil-works/pi
|
|
404
|
-
- [google-generative-ai.ts](https://github.com/earendil-works/pi
|
|
405
|
-
- [bedrock-converse-stream.ts](https://github.com/earendil-works/pi
|
|
400
|
+
- [anthropic-messages.ts](https://github.com/earendil-works/pi/blob/main/packages/ai/src/api/anthropic-messages.ts) - Anthropic Messages API
|
|
401
|
+
- [mistral-conversations.ts](https://github.com/earendil-works/pi/blob/main/packages/ai/src/api/mistral-conversations.ts) - Mistral Conversations API
|
|
402
|
+
- [openai-completions.ts](https://github.com/earendil-works/pi/blob/main/packages/ai/src/api/openai-completions.ts) - OpenAI Chat Completions
|
|
403
|
+
- [openai-responses.ts](https://github.com/earendil-works/pi/blob/main/packages/ai/src/api/openai-responses.ts) - OpenAI Responses API
|
|
404
|
+
- [google-generative-ai.ts](https://github.com/earendil-works/pi/blob/main/packages/ai/src/api/google-generative-ai.ts) - Google Generative AI
|
|
405
|
+
- [bedrock-converse-stream.ts](https://github.com/earendil-works/pi/blob/main/packages/ai/src/api/bedrock-converse-stream.ts) - AWS Bedrock
|
|
406
406
|
|
|
407
407
|
### Stream Pattern
|
|
408
408
|
|
|
409
|
-
All providers follow the same pattern:
|
|
409
|
+
All providers follow the same pattern. 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.
|
|
410
410
|
|
|
411
411
|
```typescript
|
|
412
412
|
import {
|
|
413
413
|
type AssistantMessage,
|
|
414
414
|
type AssistantMessageEventStream,
|
|
415
|
-
type Context,
|
|
416
415
|
type Model,
|
|
417
416
|
type SimpleStreamOptions,
|
|
417
|
+
type TranscriptContext,
|
|
418
418
|
calculateCost,
|
|
419
|
+
collapseSystemMessages,
|
|
419
420
|
createAssistantMessageEventStream,
|
|
421
|
+
getCurrentSystemPrompt,
|
|
422
|
+
getCurrentTools,
|
|
420
423
|
} from "@earendil-works/pi-ai";
|
|
421
424
|
|
|
422
425
|
function streamMyProvider(
|
|
423
426
|
model: Model<any>,
|
|
424
|
-
context:
|
|
427
|
+
context: TranscriptContext,
|
|
425
428
|
options?: SimpleStreamOptions
|
|
426
429
|
): AssistantMessageEventStream {
|
|
427
430
|
const stream = createAssistantMessageEventStream();
|
|
431
|
+
const transcript = collapseSystemMessages(context);
|
|
432
|
+
const systemPrompt = getCurrentSystemPrompt(transcript.messages);
|
|
433
|
+
const tools = getCurrentTools(transcript.messages);
|
|
428
434
|
|
|
429
435
|
(async () => {
|
|
430
436
|
// Initialize output message
|
|
@@ -571,7 +577,7 @@ When a request exceeds the model's context window, pi can recover automatically
|
|
|
571
577
|
Detection runs on the finalized assistant message:
|
|
572
578
|
|
|
573
579
|
- `stopReason === "error"`
|
|
574
|
-
- `errorMessage` matches one of pi's known overflow patterns (see [`packages/ai/src/utils/overflow.ts`](https://github.com/earendil-works/pi
|
|
580
|
+
- `errorMessage` matches one of pi's known overflow patterns (see [`packages/ai/src/utils/overflow.ts`](https://github.com/earendil-works/pi/blob/main/packages/ai/src/utils/overflow.ts))
|
|
575
581
|
|
|
576
582
|
If your provider returns overflow errors with a message pi does not recognize, normalize the error from the same extension that registers the provider. Use a `message_end` handler to rewrite the assistant message so its `errorMessage` starts with a phrase pi recognizes. The generic fallback `context_length_exceeded` is the safest choice.
|
|
577
583
|
|
|
@@ -634,7 +640,7 @@ pi.registerProvider("my-provider", {
|
|
|
634
640
|
|
|
635
641
|
## Testing Your Implementation
|
|
636
642
|
|
|
637
|
-
Test your provider against the same test suites used by built-in providers. Copy and adapt these test files from [packages/ai/test/](https://github.com/earendil-works/pi
|
|
643
|
+
Test your provider against the same test suites used by built-in providers. Copy and adapt these test files from [packages/ai/test/](https://github.com/earendil-works/pi/tree/main/packages/ai/test):
|
|
638
644
|
|
|
639
645
|
| Test | Purpose |
|
|
640
646
|
|------|---------|
|
|
@@ -668,10 +674,10 @@ interface ProviderConfig {
|
|
|
668
674
|
/** API type for streaming. Required at provider or model level when defining models. */
|
|
669
675
|
api?: Api;
|
|
670
676
|
|
|
671
|
-
/** Custom streaming implementation for non-standard APIs. */
|
|
677
|
+
/** Custom streaming implementation for non-standard APIs. Receives a normalized transcript. */
|
|
672
678
|
streamSimple?: (
|
|
673
679
|
model: Model<Api>,
|
|
674
|
-
context:
|
|
680
|
+
context: TranscriptContext,
|
|
675
681
|
options?: SimpleStreamOptions
|
|
676
682
|
) => AssistantMessageEventStream;
|
|
677
683
|
|
|
@@ -727,6 +733,9 @@ interface ProviderModelConfig {
|
|
|
727
733
|
cacheWrite: number;
|
|
728
734
|
};
|
|
729
735
|
|
|
736
|
+
/** Best-effort prompt cache lifetime in seconds per retention tier. Unset disables cache warming. */
|
|
737
|
+
promptCache?: { short?: number; long?: number };
|
|
738
|
+
|
|
730
739
|
/** Maximum context window size in tokens. */
|
|
731
740
|
contextWindow: number;
|
|
732
741
|
|
package/bin/docs/development.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Development
|
|
2
2
|
|
|
3
|
-
See [AGENTS.md](https://github.com/earendil-works/pi
|
|
3
|
+
See [AGENTS.md](https://github.com/earendil-works/pi/blob/main/AGENTS.md) for additional guidelines.
|
|
4
4
|
|
|
5
5
|
## Setup
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
git clone https://github.com/earendil-works/pi
|
|
9
|
-
cd pi
|
|
8
|
+
git clone https://github.com/earendil-works/pi
|
|
9
|
+
cd pi
|
|
10
10
|
npm install
|
|
11
11
|
npm run build
|
|
12
12
|
```
|
|
@@ -14,7 +14,7 @@ npm run build
|
|
|
14
14
|
Run from source:
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
/path/to/pi
|
|
17
|
+
/path/to/pi/pi-test.sh
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
The script can be run from any directory. Pi keeps the caller's current working directory.
|
package/bin/docs/docs.json
CHANGED
|
@@ -86,6 +86,7 @@ These variables are read by Pi itself:
|
|
|
86
86
|
| `PI_TELEMETRY` | Override install/update telemetry and provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no` |
|
|
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` |
|