Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

chore(deps): upgrade Pi runtime to 1.5.2 and adopt its features

vastsa72254b8131e8
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index 44c39d7ec..73ca0a588 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -36,8 +36,8 @@
"electron-updater": "^6.8.9"
},
"devDependencies": {
- "@earendil-works/pi-ai": "1.5.0",
- "@earendil-works/pi-mcp": "1.5.0",
+ "@earendil-works/pi-ai": "1.5.2",
+ "@earendil-works/pi-mcp": "1.5.2",
"@pi-desktop/agent-host": "workspace:*",
"@pi-desktop/computer-use": "workspace:*",
"@pi-desktop/agent-runtime": "workspace:*",
diff --git a/apps/desktop/test/anthropic-oauth-retry.test.mjs b/apps/desktop/test/anthropic-oauth-retry.test.mjs
index 36e6a5749..f8ad3101d 100644
--- a/apps/desktop/test/anthropic-oauth-retry.test.mjs
+++ b/apps/desktop/test/anthropic-oauth-retry.test.mjs
@@ -144,7 +144,7 @@ test("token requests identify the client instead of inheriting a browser User-Ag
assert.equal((await signIn()).kind, "done");
await oauth.resolveAuth(seed());
assert.deepEqual(requests.map(req => req.body.grant_type), ["authorization_code", "refresh_token"]);
- for (const req of requests) assert.match(req.headers["user-agent"], /^pi\/1\.5\.0 \(/);
+ for (const req of requests) assert.match(req.headers["user-agent"], /^pi\/1\.5\.2 \(/);
});
});
diff --git a/docs/project/README.md b/docs/project/README.md
index 8a0b81777..2fe9d1ae4 100644
--- a/docs/project/README.md
+++ b/docs/project/README.md
@@ -6,7 +6,7 @@ Retired records remain available in git history.
- Historical project board (archived; last refreshed 2026-08-11 for the 0.5.x line): [`BOARD.md`](BOARD.md)
- Plan implementation plan: [`plan-mode-implementation-plan.md`](plan-mode-implementation-plan.md)
-- Pi runtime adoption: [0.99.1](pi-0991-adoption.md) · [1.3.0](pi-130-adoption.md) · [1.4.0](pi-140-adoption.md) · [1.5.0](pi-150-adoption.md)
+- Pi runtime adoption: [0.99.1](pi-0991-adoption.md) · [1.3.0](pi-130-adoption.md) · [1.4.0](pi-140-adoption.md) · [1.5.0](pi-150-adoption.md) · [1.5.2](pi-152-adoption.md)
- [Pi coding agent design review](pi-coding-agent-design-review.md)
- [Hosted search contract verification](hosted-search-contract-verification.md)
- [Windows native snap replay](windows-native-snap-replay.md) and its evidence under `windows-native-snap-evidence/`
diff --git a/docs/project/pi-152-adoption.md b/docs/project/pi-152-adoption.md
new file mode 100644
index 000000000..6b297c74d
--- /dev/null
+++ b/docs/project/pi-152-adoption.md
@@ -0,0 +1,105 @@
+# Pi 1.5.2 adoption
+
+## Scope
+
+Upgrade Agent Runtime's `pi-agent-core`, `pi-ai`, and `pi-coding-agent`, plus
+Desktop's `pi-ai` and `pi-mcp`, from 1.5.0 to exactly 1.5.2, keeping the whole
+Pi release group (including `pi-codemode`, `pi-schema`, `pi-telemetry`, and
+`pi-tui`) aligned through the lockfile and exact release-age exclusions. No
+Host protocol, database schema, persisted provider endpoint, permission
+policy, extension `VERSION` marker, or storage ownership changes.
+
+Official release notes: [Pi 1.5.1](https://github.com/earendil-works/pi/releases/tag/v1.5.1),
+[Pi 1.5.2](https://github.com/earendil-works/pi/releases/tag/v1.5.2).
+
+## Compatibility work
+
+- Rebase the three pnpm patches onto the published 1.5.2 layouts.
+ `pi-agent-core` applied unchanged. Manual ports:
+ - `pi-ai` Anthropic adapter: 1.5.1 reads `compat` once at the top of
+ `stream()` and adds message threads. The patch keeps transcript
+ normalization inside the guarded `try` (so preparation errors still map to
+ local request errors), marks preparation finished after the payload is
+ serialized and before the threaded or plain send, and re-inserts the local
+ request-error mapping in the catch path, now around upstream's
+ `withCauseDetail` message.
+ - The Claude Code version bump hunk is dropped: 1.5.2 ships the same
+ `2.1.322` itself ("Anthropic OAuth requests reporting an outdated Claude
+ Code version").
+ - `pi-ai` `clampMaxTokensToContext`: 1.5.1 replaced the fixed margin with a
+ 15% input-proportional margin (#10497). The patch keeps upstream's new
+ margin and only re-applies the model-aware `estimateContextTokens(context,
+ model)` call.
+ - `pi-coding-agent` compaction utils: re-add the `hostedSearchReplayProjection`
+ import next to upstream's new `sliceHead` import.
+- `pi-coding-agent` swaps its TUI Mermaid renderer (`grok-mermaid` to
+ `lovely-mermaid`); Desktop does not use the TUI. Its `undici` stays 8.12.3,
+ so the single-instance sidecar topology from 1.5.0 is unchanged.
+- pi-ai 1.5.1 sends the documented `session-id` header instead of `session_id`
+ on OpenAI Responses (#11639). Desktop adds `x-session-affinity` on top and
+ never read the underscore form; the affinity test now asserts the new name.
+
+## Adopted 1.5.1 / 1.5.2 features
+
+- **Anthropic message threads.** pi-ai 1.5.1 sends only new messages and lets
+ the server continue the conversation, keyed by the request's `sessionId`
+ (default on for the `anthropic` provider at `api.anthropic.com`, opt-in via
+ `compat.supportsMessageThreads`). Desktop's main turns already send the
+ session id, so they get threads unchanged. Delegates and compaction
+ summaries share that session id for gateway affinity, so they now pass
+ `disableContinuation: true`: they neither continue nor overwrite the
+ conversation's single continuation slot, which would otherwise force the
+ next main turn back to a full request.
+- **Session resource cleanup.** `DesktopAgentRuntime.dispose()` calls pi-ai's
+ `cleanupSessionResources(sessionId)` after extensions close, releasing the
+ per-session thread state and the strict-tool downgrade memory added in 1.5.1
+ (#11626), as the upstream coding agent does on session teardown.
+- **Qwen Token Plan Individual (China).** The new
+ `qwen-token-plan-individual-cn` provider uses the same endpoint as the
+ existing `alibaba-token-plan-cn` preset, so it becomes an alias of that row.
+- **Inherited without Desktop code changes:** OpenAI-compatible requests omit
+ an empty `tools` array (vLLM 0.20+), the `requiresToolsWithToolHistory`,
+ `requiresNonNullAssistantContent`, and `promptCacheKeyMode` compat fields
+ through catalog `compat`, Anthropic non-strict schemas keep root `$defs`,
+ the OpenRouter output-limit margin, retries for streams cut short after the
+ reply began, abort-during-lazy-load reported as abort, Azure GPT-6 context
+ windows and long-context pricing, Claude Sonnet 5 temperature, OpenCode Go
+ Claude 5.5 thinking-block binding, new default models, and Claude Fable 5.2
+ in pi-ai's built-in catalog. Desktop's bundled models.dev catalog and
+ overlays remain the source of what the UI offers.
+- **Not applicable to Desktop:** idle prompt-cache warming (`cacheWarming`
+ lives in the coding-agent session, which is not Desktop's agent loop),
+ `pi auth login`, `pi update` summaries, TUI Mermaid rendering, terminal
+ overlays and keybindings, grep/find/read/edit tool changes in the coding
+ agent's own tools, RPC-mode shutdown, and the session fork prompt for a
+ missing working directory (1.5.2).
+
+## Explicitly unchanged
+
+- Existing user data needs no migration. No persisted format, RPC, Plugin
+ SDK, or permission contract changes.
+- `pi-coding-agent` remains transitional; it is not the normal Desktop agent
+ loop, compaction engine, or durable session store.
+
+## Validation
+
+Task candidate: `chore/pi-1-5-2-upgrade` on `047c4eab1` (`origin/main`,
+2026-11-18), run from the dedicated request worktree. No real provider or live
+service was used.
+
+- `pnpm build:js`, Desktop and Agent Runtime typecheck, `pnpm lint`,
+ `pnpm check:agent-policy`, `pnpm check:pi-patches`,
+ `pnpm check:pi-dependencies`, and `scripts/pi-patch-hash.test.mjs` passed.
+- Agent Runtime: 136 test files, 2,041 tests passed, including the new
+ `pi-anthropic-message-threads.test.ts`. Removing either
+ `disableContinuation` or the dispose cleanup makes it fail.
+- Shared 1,442, plugin-sdk 386, i18n 31, voice-runtime 52, plugin-devkit 53,
+ computer-use 31, agent-host 66, racp 28, host-runtime 190, pi-host 68
+ (1 skipped), and docs 14 tests passed.
+- Desktop: 5,221 tests, 5,215 passed, 4 skipped, 2 failed, using the primary
+ checkout's Electron 43.6.0 binary by link. `market-browse-user-path` timed
+ out only under the full parallel run and passes alone.
+ `image-model-disclosure-user-path` ("Saved marking must exclude chat") fails
+ identically on the unmodified base commit; it exercises renderer model
+ selection only and is outside this change.
+- Rust host-core is untouched and was not run.
diff --git a/docs/spec/02-architecture/02-tech-stack.md b/docs/spec/02-architecture/02-tech-stack.md
index b303d0ff4..bfdac366d 100644
--- a/docs/spec/02-architecture/02-tech-stack.md
+++ b/docs/spec/02-architecture/02-tech-stack.md
@@ -12,9 +12,9 @@
| Host backend | **Rust** | stable Rust toolchain | tools/plugins/permissions/persistence adapters |
| Rust async | tokio | stable | host services |
| Host RPC | stdio JSON-RPC (NDJSON) | frozen (D001) | Electron main ↔ Rust host |
-| Agent engine | `@earendil-works/pi-agent-core` | 1.5.0 | agent loop |
-| Model API | `@earendil-works/pi-ai` | 1.5.0 | provider adapters, OAuth, and stream handling |
-| Model catalog | models.dev + Pi Providers/Models | bundled models.dev + pinned Pi 1.5.0 | models.dev chat metadata; Pi account IDs, wire capabilities, and typed operations |
+| Agent engine | `@earendil-works/pi-agent-core` | 1.5.2 | agent loop |
+| Model API | `@earendil-works/pi-ai` | 1.5.2 | provider adapters, OAuth, and stream handling |
+| Model catalog | models.dev + Pi Providers/Models | bundled models.dev + pinned Pi 1.5.2 | models.dev chat metadata; Pi account IDs, wire capabilities, and typed operations |
> models.dev owns published chat metadata; pi-ai owns transports and auth.
> Host persists Desktop account rows, credentials, and explicit binding overrides.
diff --git a/docs/spec/02-architecture/06-pi-runtime-dependency-boundary.md b/docs/spec/02-architecture/06-pi-runtime-dependency-boundary.md
index 68357c334..026ed395c 100644
--- a/docs/spec/02-architecture/06-pi-runtime-dependency-boundary.md
+++ b/docs/spec/02-architecture/06-pi-runtime-dependency-boundary.md
@@ -9,10 +9,11 @@ boundaries must keep that split clear as upstream packages evolve.
## 2. Current ownership
The sidecar pins `@earendil-works/pi-agent-core`, `pi-ai`, and
-`pi-coding-agent` together at exactly `1.5.0`; Desktop's `pi-ai` and `pi-mcp`
+`pi-coding-agent` together at exactly `1.5.2`; Desktop's `pi-ai` and `pi-mcp`
development dependencies use the same release. Target-release package patches
remain narrow compatibility deltas and are listed with their audited behavior
-in `docs/project/pi-150-adoption.md`.
+in `docs/project/pi-150-adoption.md` and updated for 1.5.2 in
+`docs/project/pi-152-adoption.md`.
- `@earendil-works/pi-agent-core` supplies the agent loop and its stable agent,
event, and tool types. Agent Runtime owns desktop-specific compaction,
@@ -39,7 +40,7 @@ in `docs/project/pi-150-adoption.md`.
attribution follows that SDK's install-telemetry setting. The Desktop-owned
main and delegated Agent paths use the explicit identity above.
-The extension shim is a versioned compatibility subset, not the full 1.5.0
+The extension shim is a versioned compatibility subset, not the full 1.5.2
coding-agent API. Its legacy `VERSION` marker remains sourced from
`TRUSTED_EXTENSION_KERNEL_VERSION` and intentionally identifies the modeled
0.87.1 extension surface.
diff --git a/docs/spec/03-runtime/12-provider-config-schema.md b/docs/spec/03-runtime/12-provider-config-schema.md
index 4482dca4b..39ae46c1c 100644
--- a/docs/spec/03-runtime/12-provider-config-schema.md
+++ b/docs/spec/03-runtime/12-provider-config-schema.md
@@ -444,7 +444,8 @@ MiniMax (OpenAI) (`chat_completions` at `https://api.minimaxi.com/v1`, aliases
`minimax-openai` / `minimax-compatible`), Kimi For Coding (`anthropic_messages`),
Qwen Token Plan (`alibaba-token-plan`, aliases `qwen-token-plan` /
`qwen-token-plan-individual`), Qwen Token Plan (China)
-(`alibaba-token-plan-cn`, alias `qwen-token-plan-cn`), Xiaomi Token Plan
+(`alibaba-token-plan-cn`, aliases `qwen-token-plan-cn` /
+`qwen-token-plan-individual-cn`), Xiaomi Token Plan
(`xiaomi-token-plan-cn` / `-ams` / `-sgp`).
StepFun Plan uses the `stepfun-plan` preset with catalog vendor key
diff --git a/docs/spec/06-delivery/e2e/providers-and-models.md b/docs/spec/06-delivery/e2e/providers-and-models.md
index f7853a739..95eab7eee 100644
--- a/docs/spec/06-delivery/e2e/providers-and-models.md
+++ b/docs/spec/06-delivery/e2e/providers-and-models.md
@@ -2409,3 +2409,31 @@ conversation content or credentials. A skipped test remains NOT RUN, not PASS.
## E2E-ISSUE-1789
Image-model marking explains chat/default-menu exclusion and distinguishes generation from image input. Collapsed model rows retain an image-model badge. Verify marking, help, collapsing, unmarking and restored chat eligibility through `image-model-disclosure-user-path.test.mjs`.
+
+## E2E-PI-152-kernel-upgrade
+
+- **Preconditions:** Exact Pi 1.5.2 release-group pins and rebased package
+ patches in a dedicated worktree, isolated fixture state, and no real provider
+ credentials.
+- **Steps:** Run the runtime, native Pi session, identity, and patch-gate
+ suites against the installed 1.5.2 packages. Drive an Anthropic-compatible
+ loopback gateway with message threads enabled through a main turn, a
+ delegate request and a compaction summary that share the session id, then a
+ second main turn. Dispose the runtime and start a new one for the same
+ session id.
+- **Expected:** The main conversation creates one thread and continues it with
+ only the new turn; delegate and summary requests send no `thread` field and
+ leave the conversation's continuation intact. After disposal the next
+ runtime creates a new thread. Hosted-search capture and local request-error
+ mapping from the Desktop patches remain intact. Identity headers report
+ 1.5.2. No provider credentials or live services are used.
+- **Coverage:** `pi-anthropic-message-threads.test.ts`,
+ `pi-upstream-1.5-identity.test.ts`, `pi-upstream-1.5-contract.test.ts`,
+ `pi-1.5-adapter-features.test.ts`, `pi-anthropic-strict-fallback.test.ts`,
+ `pi-ai-provider-sync.test.ts`, `provider-presets.test.ts`,
+ `scripts/pi-patch-hash.test.mjs`, `pnpm check:pi-patches`,
+ `pnpm check:pi-dependencies`.
+- **Specs:** [Pi dependency boundary](../../02-architecture/06-pi-runtime-dependency-boundary.md).
+- **Acceptance:** Offline runtime/contract validation.
+- **Milestone:** Maintenance.
+- **Status:** Candidate validation recorded in `docs/project/pi-152-adoption.md`.
diff --git a/packages/agent-runtime/package.json b/packages/agent-runtime/package.json
index 6104e6620..9f778ae74 100644
--- a/packages/agent-runtime/package.json
+++ b/packages/agent-runtime/package.json
@@ -31,9 +31,9 @@
"clean": "node -e \"fs.rmSync('dist',{recursive:true,force:true});fs.rmSync('dist-bundle',{recursive:true,force:true})\""
},
"dependencies": {
- "@earendil-works/pi-agent-core": "1.5.0",
- "@earendil-works/pi-ai": "1.5.0",
- "@earendil-works/pi-coding-agent": "1.5.0",
+ "@earendil-works/pi-agent-core": "1.5.2",
+ "@earendil-works/pi-ai": "1.5.2",
+ "@earendil-works/pi-coding-agent": "1.5.2",
"@pi-desktop/shared": "workspace:*",
"jiti": "2.7.0",
"typebox": "1.3.27",
diff --git a/packages/agent-runtime/src/compaction-request.ts b/packages/agent-runtime/src/compaction-request.ts
index a008377a4..33f2fdf33 100644
--- a/packages/agent-runtime/src/compaction-request.ts
+++ b/packages/agent-runtime/src/compaction-request.ts
@@ -42,7 +42,10 @@ import { compactionRequestShape, type CompactionRequestShape } from "./compactio
*
* The session id is the runtime's own, not a per-call id, so the summary reaches
* the same gateway backend as the conversation
- * it summarizes — the same id the session's turns already send.
+ * it summarizes — the same id the session's turns already send. The summary
+ * must not continue or replace the conversation's server-side thread (pi-ai
+ * Anthropic message threads key that state by session id), so continuation is
+ * disabled for it.
*/
export function compactionRequestOptions(input: {
provider: RuntimeProviderConfig;
@@ -55,7 +58,12 @@ export function compactionRequestOptions(input: {
return withSessionAffinityOptions(
withProviderHeaders(
withOpenCodeSessionHeaders(
- { ...options, sessionId, reasoning: requestThinkingLevel(model, options?.reasoning ?? "off") },
+ {
+ ...options,
+ sessionId,
+ disableContinuation: true,
+ reasoning: requestThinkingLevel(model, options?.reasoning ?? "off"),
+ },
{ ...openCodeEndpointFromProvider(provider, model), sessionId },
),
mergeProviderHeaders(
diff --git a/packages/agent-runtime/src/native-pi-session.test.ts b/packages/agent-runtime/src/native-pi-session.test.ts
index 93a641407..40a03d3fa 100644
--- a/packages/agent-runtime/src/native-pi-session.test.ts
+++ b/packages/agent-runtime/src/native-pi-session.test.ts
@@ -524,7 +524,7 @@ describe("native continuation review regressions", () => {
expect(identities).toHaveLength(1);
expect(identities[0]).toMatchObject({
userAgent: "detailed",
- version: "1.5.0",
+ version: "1.5.2",
attribution: enabled ? PI_ATTRIBUTION : null,
});
} finally {
diff --git a/packages/agent-runtime/src/pi-anthropic-message-threads.test.ts b/packages/agent-runtime/src/pi-anthropic-message-threads.test.ts
new file mode 100644
index 000000000..4a4a256bb
--- /dev/null
+++ b/packages/agent-runtime/src/pi-anthropic-message-threads.test.ts
@@ -0,0 +1,163 @@
+import { createServer } from "node:http";
+import { afterEach, describe, expect, it } from "vitest";
+import { normalizeContext, type Message } from "@earendil-works/pi-ai";
+import type { UiMessage } from "@pi-desktop/shared";
+import { withCompactionRequestHeaders } from "./compaction-request.js";
+import { DesktopAgentRuntime } from "./runtime.js";
+import {
+ buildProviderModel,
+ createProviderModels,
+ type RuntimeProviderConfig,
+} from "./provider-binding.js";
+import { subagentModelBinding } from "./subagent-model-binding.js";
+
+/**
+ * Pi 1.5.1 Anthropic message threads keep one continuation slot per session
+ * id. Desktop's side requests share the conversation's session id for gateway
+ * affinity, so they must neither continue nor replace that slot, and the
+ * runtime must release it when the session's runtime is disposed.
+ */
+
+type ThreadField = { type: "create" } | { type: "continue"; previous_message_id: string };
+type WireRequest = { thread?: ThreadField; messages: unknown[] };
+
+const cleanups: Array<() => Promise<void>> = [];
+afterEach(async () => {
+ for (const cleanup of cleanups.splice(0).reverse()) await cleanup();
+});
+
+async function anthropicGateway(): Promise<{ baseUrl: string; requests: WireRequest[] }> {
+ const requests: WireRequest[] = [];
+ const server = createServer(async (req, res) => {
+ let raw = "";
+ for await (const part of req) raw += part;
+ requests.push(JSON.parse(raw) as WireRequest);
+ const id = `msg_${requests.length}`;
+ const events = [
+ { type: "message_start", message: {
+ id, type: "message", role: "assistant", model: "claude-fixture", content: [],
+ usage: { input_tokens: 10, output_tokens: 0 },
+ } },
+ { type: "content_block_start", index: 0, content_block: { type: "text", text: "" } },
+ { type: "content_block_delta", index: 0, delta: { type: "text_delta", text: `Reply ${requests.length}.` } },
+ { type: "content_block_stop", index: 0 },
+ { type: "message_delta", delta: { stop_reason: "end_turn" }, usage: { output_tokens: 3 } },
+ { type: "message_stop" },
+ ];
+ res.writeHead(200, { "content-type": "text/event-stream" });
+ for (const event of events) res.write(`event: ${event.type}\ndata: ${JSON.stringify(event)}\n\n`);
+ res.end();
+ });
+ await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
+ cleanups.push(async () => {
+ server.closeAllConnections();
+ await new Promise<void>((resolve) => server.close(() => resolve()));
+ });
+ const address = server.address();
+ if (!address || typeof address === "string") throw new Error("fixture address missing");
+ return { baseUrl: `http://127.0.0.1:${address.port}`, requests };
+}
+
+/** An Anthropic-compatible gateway whose catalog entry opts into message threads. */
+function anthropicProvider(baseUrl: string): RuntimeProviderConfig {
+ return {
+ id: "anthropic-row", name: "Anthropic", vendorKey: "anthropic", baseUrl,
+ modelId: "claude-fixture", apiKey: "fixture-not-real", apiStyle: "anthropic_messages",
+ supportsReasoning: false, supportedThinkingLevels: ["off"],
+ modelConfig: {
+ source: "generic", name: "Claude fixture", baseUrl, reasoning: false, input: ["text"],
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
+ contextWindow: 200_000, maxTokens: 4_096,
+ compat: { supportsMessageThreads: true },
+ },
+ };
+}
+
+function createRuntime(sessionId: string, provider: RuntimeProviderConfig, history: UiMessage[] = []) {
+ return new DesktopAgentRuntime({
+ sessionId, mode: "agent", provider, history, thinkingLevel: "omit",
+ commandShell: { id: "bash", label: "Bash", dialect: "posix", available: true, isDefault: true },
+ host: {
+ call: async <T>(method: string): Promise<T> => {
+ if (method === "tools.fileBatchCapabilities") return { version: 1, supported: false } as T;
+ if (method === "session.appendMessage") return undefined as T;
+ throw new Error(`Unexpected host method: ${method}`);
+ },
+ onNotification: () => () => {},
+ },
+ onEvent: () => {},
+ });
+}
+
+const threadType = (request: WireRequest | undefined) => request?.thread?.type;
+
+describe("Anthropic message threads with Desktop side requests", () => {
+ it("continues the conversation thread across delegate and summary requests", async () => {
+ const { baseUrl, requests } = await anthropicGateway();
+ const provider = anthropicProvider(baseUrl);
+ const runtime = createRuntime("thread-session", provider);
+ cleanups.push(async () => { await runtime.dispose(); });
+
+ await runtime.prompt("First question");
+ expect(requests).toHaveLength(1);
+ expect(threadType(requests[0])).toBe("create");
+
+ // A delegate shares the parent's session id.
+ const binding = subagentModelBinding(
+ { provider, thinkingLevel: "off", sessionId: "thread-session" },
+ { claim: () => undefined },
+ );
+ const delegateMessages: Message[] = [{ role: "user", content: "Delegate task.", timestamp: 1 }];
+ const delegate = await binding.streamFn(
+ binding.model, normalizeContext({ messages: delegateMessages }), {},
+ ).result();
+ expect(delegate.stopReason).toBe("stop");
+ expect(requests).toHaveLength(2);
+ expect(requests[1].thread).toBeUndefined();
+
+ // So does a compaction summary, even when its caller keeps cache retention.
+ const model = buildProviderModel(provider);
+ const summaryModels = withCompactionRequestHeaders(
+ createProviderModels(provider, model), provider, "thread-session",
+ );
+ const summaryMessages: Message[] = [{ role: "user", content: "Summarize.", timestamp: 2 }];
+ const summary = await summaryModels.completeSimple(
+ model, normalizeContext({ messages: summaryMessages }), {},
+ );
+ expect(summary.stopReason).toBe("stop");
+ expect(requests).toHaveLength(3);
+ expect(requests[2].thread).toBeUndefined();
+
+ // The conversation still continues its own thread with only the new turn.
+ await runtime.prompt("Second question");
+ expect(requests).toHaveLength(4);
+ expect(requests[3].thread).toEqual({ type: "continue", previous_message_id: "msg_1" });
+ expect(requests[3].messages.length).toBeLessThan(requests[0].messages.length + 2);
+ });
+
+ it("releases the session's thread when the runtime is disposed", async () => {
+ const { baseUrl, requests } = await anthropicGateway();
+ const provider = anthropicProvider(baseUrl);
+ const first = createRuntime("disposed-session", provider);
+ await first.prompt("First question");
+ expect(threadType(requests[0])).toBe("create");
+ await first.prompt("Second question");
+ expect(threadType(requests[1])).toBe("continue");
+ await first.dispose();
+
+ // A later runtime for the same session id (for example after a restart)
+ // starts a new thread instead of continuing the released one.
+ const createdAt = "2026-11-18T10:00:00.000Z";
+ const history: UiMessage[] = [
+ { id: "u1", role: "user", content: "First question", createdAt, status: "complete" },
+ { id: "a1", role: "assistant", content: "Reply 1.", createdAt, status: "complete" },
+ { id: "u2", role: "user", content: "Second question", createdAt, status: "complete" },
+ { id: "a2", role: "assistant", content: "Reply 2.", createdAt, status: "complete" },
+ ];
+ const second = createRuntime("disposed-session", provider, history);
+ cleanups.push(async () => { await second.dispose(); });
+ await second.prompt("Third question");
+ expect(requests).toHaveLength(3);
+ expect(threadType(requests[2])).toBe("create");
+ });
+});
diff --git a/packages/agent-runtime/src/pi-upstream-1.5-identity.test.ts b/packages/agent-runtime/src/pi-upstream-1.5-identity.test.ts
index 78d791d78..2887b389c 100644
--- a/packages/agent-runtime/src/pi-upstream-1.5-identity.test.ts
+++ b/packages/agent-runtime/src/pi-upstream-1.5-identity.test.ts
@@ -15,7 +15,7 @@ describe("Pi 1.5 client identity", () => {
);
expect(identity?.attribution).toBeNull();
- expect(formatUserAgent(identity)).toMatch(/^pi\/1\.5\.0 \(/);
+ expect(formatUserAgent(identity)).toMatch(/^pi\/1\.5\.2 \(/);
for (const target of [
{ provider: "openrouter", baseUrl: "https://openrouter.ai/api/v1" },
{ provider: "nvidia", baseUrl: "https://integrate.api.nvidia.com/v1" },
diff --git a/packages/agent-runtime/src/runtime.ts b/packages/agent-runtime/src/runtime.ts
index 7f8c5c6d9..aae9c51ae 100644
--- a/packages/agent-runtime/src/runtime.ts
+++ b/packages/agent-runtime/src/runtime.ts
@@ -49,6 +49,7 @@ import {
type PrepareNextTurnContext,
} from "@earendil-works/pi-agent-core";
import {
+ cleanupSessionResources,
isContextOverflow,
getCurrentTools,
getToolStateChanges,
@@ -9847,5 +9848,8 @@ Do not invent objections or turn speculative risks into blockers. Stop when the
if (this.compactionInProgress) this.compactionAborted = true;
this.compactionAbort?.abort();
await closingExtensions;
+ // Release pi-ai's per-session provider state (Anthropic message-thread
+ // continuation, strict-tool downgrades) once nothing can send for it.
+ cleanupSessionResources(this.sessionId);
}
}
diff --git a/packages/agent-runtime/src/session-affinity.test.ts b/packages/agent-runtime/src/session-affinity.test.ts
index 002d89b67..9cbf34e10 100644
--- a/packages/agent-runtime/src/session-affinity.test.ts
+++ b/packages/agent-runtime/src/session-affinity.test.ts
@@ -559,7 +559,9 @@ describe("the pi-ai Responses adapter's proxy-safe session identity", () => {
).result();
expect(sent).toHaveLength(1);
- expect(sent[0].headers.get("session_id")).toBe("session-42");
+ // pi-ai 1.5.1 sends the documented hyphenated header, not `session_id`.
+ expect(sent[0].headers.get("session-id")).toBe("session-42");
+ expect(sent[0].headers.get("session_id")).toBeNull();
expect(sent[0].headers.get("x-client-request-id")).toBe("session-42");
expect(sent[0].headers.get("x-session-affinity")).toBe("session-42");
});
diff --git a/packages/agent-runtime/src/session-affinity.ts b/packages/agent-runtime/src/session-affinity.ts
index 185dbbf59..3f17a3749 100644
--- a/packages/agent-runtime/src/session-affinity.ts
+++ b/packages/agent-runtime/src/session-affinity.ts
@@ -135,8 +135,8 @@ export function withSessionPromptCacheKey(input: {
/**
* `options` with session identity appended at the request boundary. Responses
- * already emits `session_id`, but common reverse proxies drop underscore
- * headers; add the stable hyphenated alias for custom endpoints. Completions
+ * already emits `session-id`; custom endpoints also get the stable
+ * `x-session-affinity` alias their routers key on. Completions
* gets its missing body key after every other `onPayload` hook, so a
* payload-rewriting extension cannot drop it.
*
diff --git a/packages/agent-runtime/src/subagent-model-binding.ts b/packages/agent-runtime/src/subagent-model-binding.ts
index d4ba834bf..7dd9ac6d0 100644
--- a/packages/agent-runtime/src/subagent-model-binding.ts
+++ b/packages/agent-runtime/src/subagent-model-binding.ts
@@ -79,6 +79,10 @@ export function subagentModelBinding(opts: {
maxTokens: clampOutputToContext(m, requestContext, options?.maxTokens),
maxRetries: 0,
sessionId: opts.sessionId,
+ // The delegate shares the parent's session id for gateway
+ // affinity, so it must not continue or replace the parent's
+ // server-side message thread, which pi-ai keys by session id.
+ disableContinuation: true,
fetch: providerRequestFetch(
m.api,
captureProviderResponse(options?.fetch, (response, _bytes, failure) => {
diff --git a/packages/shared/src/provider-presets.test.ts b/packages/shared/src/provider-presets.test.ts
index c47237d89..1e1910544 100644
--- a/packages/shared/src/provider-presets.test.ts
+++ b/packages/shared/src/provider-presets.test.ts
@@ -293,6 +293,9 @@ describe("pi-ai built-in API-key services", () => {
expect(matchNamedPreset({ vendorKey: "qwen-token-plan-cn" })?.vendorKey).toBe(
"alibaba-token-plan-cn",
);
+ expect(
+ matchNamedPreset({ vendorKey: "qwen-token-plan-individual-cn" })?.vendorKey,
+ ).toBe("alibaba-token-plan-cn");
});
it("keeps OpenCode Zen and OpenCode Go as separate services", () => {
diff --git a/packages/shared/src/provider-presets.ts b/packages/shared/src/provider-presets.ts
index fff151f03..427a604c9 100644
--- a/packages/shared/src/provider-presets.ts
+++ b/packages/shared/src/provider-presets.ts
@@ -337,7 +337,7 @@ export const NAMED_ENDPOINT_PRESETS: readonly NamedEndpointPreset[] = [
baseUrl: "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
apiStyle: "chat_completions",
labelKey: "settings.presetAlibabaTokenPlanCn",
- aliases: ["qwen-token-plan-cn"],
+ aliases: ["qwen-token-plan-cn", "qwen-token-plan-individual-cn"],
},
{
id: "xiaomi-token-plan-cn",
diff --git a/patches/@[email protected] b/patches/@[email protected]
similarity index 100%
rename from patches/@[email protected]
rename to patches/@[email protected]
diff --git a/patches/@[email protected] b/patches/@[email protected]
similarity index 93%
rename from patches/@[email protected]
rename to patches/@[email protected]
index e47b33457..110931ede 100644
--- a/patches/@[email protected]
+++ b/patches/@[email protected]
@@ -1,5 +1,5 @@
diff --git a/dist/api/anthropic-messages.js b/dist/api/anthropic-messages.js
-index de2b2d8c209f5576c18b020de297d4ef5fad5960..037ecdaea6efcb76f827ba2dd69bc3a09a3d78f7 100644
+index 4f7052d2bb80b14c00ac3a1ef0684bbcac166a5b..870f2b559b8d9fe9bf3f797e94f1bcfec12f02b8 100644
--- a/dist/api/anthropic-messages.js
+++ b/dist/api/anthropic-messages.js
@@ -1,3 +1,6 @@
@@ -9,50 +9,45 @@ index de2b2d8c209f5576c18b020de297d4ef5fad5960..037ecdaea6efcb76f827ba2dd69bc3a0
import Anthropic, {} from "@anthropic-ai/sdk";
import { ANTHROPIC_FEDERATION_RULE_ID_ENV, ANTHROPIC_IDENTITY_TOKEN_FILE_ENV, ANTHROPIC_ORGANIZATION_ID_ENV, ANTHROPIC_SERVICE_ACCOUNT_ID_ENV, ANTHROPIC_WORKSPACE_ID_ENV, } from "../env-api-keys.js";
import { calculateCost } from "../models.js";
-@@ -44,3 +47,3 @@ function mergeHeaders(...headerSources) {
- // Stealth mode: Mimic Claude Code's tool naming exactly
--const claudeCodeVersion = "2.1.280";
-+const claudeCodeVersion = "2.1.322";
- // Claude Code 2.x tool names (canonical casing)
-@@ -377,8 +380,6 @@ async function* iterateAnthropicEvents(response, signal) {
- }
+@@ -553,8 +556,6 @@ async function* iterateAnthropicEvents(response, signal) {
export const stream = (model, context, options) => {
const stream = new AssistantMessageEventStream();
-- const normalizedContext = resolveTranscript(context, getAnthropicCompat(model).supportsMidConvoSystemMessages);
+ const compat = getAnthropicCompat(model);
+- const normalizedContext = resolveTranscript(context, compat.supportsMidConvoSystemMessages);
- const currentTools = getCurrentTools(normalizedContext.messages);
(async () => {
const output = {
role: "assistant",
-@@ -397,7 +398,11 @@ export const stream = (model, context, options) => {
+@@ -573,7 +574,11 @@ export const stream = (model, context, options) => {
stopReason: "pending",
timestamp: Date.now(),
};
+ let preparingRequest = true;
try {
-+ const normalizedContext = resolveTranscript(context, getAnthropicCompat(model).supportsMidConvoSystemMessages);
++ const normalizedContext = resolveTranscript(context, compat.supportsMidConvoSystemMessages);
+ validateHostedSearchMessages(normalizedContext.messages);
+ const currentTools = getCurrentTools(normalizedContext.messages);
let client;
let isOAuth;
let usageModel = model;
-@@ -433,6 +438,7 @@ export const stream = (model, context, options) => {
- let disablePreferredStrictTools = false;
- let response;
+@@ -621,6 +626,7 @@ export const stream = (model, context, options) => {
+ // The thread request that produced the response; undefined when no `thread` was sent.
+ let thread;
for (;;) {
+ preparingRequest = true;
options?.signal?.throwIfAborted();
- const built = buildParams(model, normalizedContext, isOAuth, options, disablePreferredStrictTools);
- if (built.providerThinkingLevel)
-@@ -442,6 +448,8 @@ export const stream = (model, context, options) => {
- if (nextParams !== undefined) {
- params = { ...nextParams, stream: true };
- }
+ const built = buildParams(model, normalizedContext, isOAuth, options, {
+ disablePreferredStrictTools,
+@@ -636,6 +642,8 @@ export const stream = (model, context, options) => {
+ const prepared = threadSessionId !== undefined && options?.disableContinuation !== true
+ ? prepareThreadRequest(model, threadSessionId, params)
+ : undefined;
+ JSON.stringify(params);
+ preparingRequest = false;
try {
- response = await retryProviderRequest(() => client.beta.messages.create(params, requestOptions).asResponse(), {
- maxRetries: options?.maxRetries,
-@@ -550,38 +558,83 @@ export const stream = (model, context, options) => {
+ const sent = prepared
+ ? await sendThreadRequest(prepared, params, send, output, options?.signal)
+@@ -745,38 +753,83 @@ export const stream = (model, context, options) => {
});
stream.push({ type: "toolcall_start", contentIndex: output.content.length - 1, partial: output });
}
@@ -142,7 +137,7 @@ index de2b2d8c209f5576c18b020de297d4ef5fad5960..037ecdaea6efcb76f827ba2dd69bc3a0
partial: output,
});
}
-@@ -589,7 +642,19 @@ export const stream = (model, context, options) => {
+@@ -784,7 +837,19 @@ export const stream = (model, context, options) => {
else if (event.delta.type === "signature_delta") {
if (open?.block.type === "thinking") {
open.block.thinkingSignature = open.block.thinkingSignature || "";
@@ -163,7 +158,7 @@ index de2b2d8c209f5576c18b020de297d4ef5fad5960..037ecdaea6efcb76f827ba2dd69bc3a0
}
}
}
-@@ -700,8 +765,13 @@ export const stream = (model, context, options) => {
+@@ -897,8 +962,13 @@ export const stream = (model, context, options) => {
stream.end();
}
catch (error) {
@@ -173,12 +168,12 @@ index de2b2d8c209f5576c18b020de297d4ef5fad5960..037ecdaea6efcb76f827ba2dd69bc3a0
+ if (errorDetails)
+ output.errorDetails = errorDetails;
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
-- output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
-+ output.errorMessage = errorDetails?.message ?? (error instanceof Error ? error.message : JSON.stringify(error));
+- output.errorMessage = error instanceof Error ? withCauseDetail(error) : JSON.stringify(error);
++ output.errorMessage = errorDetails?.message ?? (error instanceof Error ? withCauseDetail(error) : JSON.stringify(error));
stream.push({ type: "error", reason: output.stopReason, error: output });
stream.end();
}
-@@ -729,7 +799,7 @@ function mapThinkingLevelToEffort(model, level) {
+@@ -926,7 +996,7 @@ function mapThinkingLevelToEffort(model, level) {
return "high";
}
}
@@ -187,7 +182,7 @@ index de2b2d8c209f5576c18b020de297d4ef5fad5960..037ecdaea6efcb76f827ba2dd69bc3a0
if (!getAnthropicFederation(model, options?.apiKey, options?.headers, options?.env)) {
assertRequestAuth(model.provider, options?.apiKey, options?.headers);
}
-@@ -763,7 +833,7 @@ export const streamSimple = (model, context, options) => {
+@@ -960,7 +1030,7 @@ export const streamSimple = (model, context, options) => {
thinkingEnabled: true,
thinkingBudgetTokens: Math.min(adjusted.thinkingBudget, Math.max(0, maxTokens - 1024)),
});
@@ -196,7 +191,7 @@ index de2b2d8c209f5576c18b020de297d4ef5fad5960..037ecdaea6efcb76f827ba2dd69bc3a0
function isOAuthToken(apiKey) {
return apiKey.includes("sk-ant-oat");
}
-@@ -956,6 +1026,15 @@ function buildParams(model, context, isOAuthToken, options, disablePreferredStri
+@@ -1159,6 +1229,15 @@ function buildParams(model, context, isOAuthToken, options, flags) {
params.tools = convertToolDefinitions(tools, toolCacheControl);
}
}
@@ -212,7 +207,7 @@ index de2b2d8c209f5576c18b020de297d4ef5fad5960..037ecdaea6efcb76f827ba2dd69bc3a0
if (thinkingDisabled) {
// No effort is sent, so the model default applies. Anthropic rejects `block_binding`
// with disabled thinking.
-@@ -1161,6 +1240,15 @@ convertToolDefinitions) {
+@@ -1364,6 +1443,15 @@ convertToolDefinitions) {
input: block.arguments ?? {},
});
}
@@ -229,7 +224,7 @@ index de2b2d8c209f5576c18b020de297d4ef5fad5960..037ecdaea6efcb76f827ba2dd69bc3a0
if (blocks.length === 0)
continue;
diff --git a/dist/api/azure-openai-responses.js b/dist/api/azure-openai-responses.js
-index e6a50f20ab31a3f3de0d2a71190dd98b6f1d401d..8620aa5ecb7cd7c4220347792e6e119408e3a497 100644
+index 837fdb43c986af72b0f9c49ce6e7ec4412838322..8a1d8fd344b94599fe6d7ae41db041aae3a8fdf1 100644
--- a/dist/api/azure-openai-responses.js
+++ b/dist/api/azure-openai-responses.js
@@ -1,3 +1,5 @@
@@ -338,10 +333,10 @@ index 51de5ed18b59979d0e7aa883f46ecdc05ab274a7..da385ff92649735f8850b6ac6511f46d
id: block.id,
type: "function",
diff --git a/dist/api/openai-codex-responses.js b/dist/api/openai-codex-responses.js
-index 427df0a7054cc4b2071c8e5c2dc2ac1a82ea166a..fce4d2181faaec2e18357c20eade7da2cecd3c29 100644
+index e64cc029276fdb45c8ebf6d16a7d9573df223798..e805097358d6231db75ae1471884f5d2e00ee65b 100644
--- a/dist/api/openai-codex-responses.js
+++ b/dist/api/openai-codex-responses.js
-@@ -413,6 +413,12 @@ function buildRequestBody(model, context, options, cacheSessionId, grammarToolIn
+@@ -417,6 +417,12 @@ function buildRequestBody(model, context, options, cacheSessionId, grammarToolIn
supportsOpenAIGrammarTools,
});
}
@@ -355,10 +350,10 @@ index 427df0a7054cc4b2071c8e5c2dc2ac1a82ea166a..fce4d2181faaec2e18357c20eade7da2
const effort = options.reasoningEffort === "none"
? model.thinkingLevelMap?.off === undefined
diff --git a/dist/api/openai-completions.js b/dist/api/openai-completions.js
-index 12ec37eaf976340d2b29234dab2f17964ed56c91..02d3cdec478f40f40c312dea4d412f9e7c24003b 100644
+index c1b6038c2220633a8caf710288a8f6e6301f7a28..2b6e6d5a48731a37812cd42740156fe8fe0fd2e8 100644
--- a/dist/api/openai-completions.js
+++ b/dist/api/openai-completions.js
-@@ -1034,21 +1034,27 @@ export function convertMessages(model, context, compat, options) {
+@@ -1037,21 +1037,27 @@ export function convertMessages(model, context, compat, options) {
if (preservedReasoningDetails) {
assistantMsg.reasoning_details = preservedReasoningDetails;
}
@@ -392,7 +387,7 @@ index 12ec37eaf976340d2b29234dab2f17964ed56c91..02d3cdec478f40f40c312dea4d412f9e
}
params.push(assistantMsg);
}
-@@ -1116,6 +1122,49 @@ export function convertMessages(model, context, compat, options) {
+@@ -1119,6 +1125,49 @@ export function convertMessages(model, context, compat, options) {
}
lastRole = msg.role;
}
@@ -442,8 +437,8 @@ index 12ec37eaf976340d2b29234dab2f17964ed56c91..02d3cdec478f40f40c312dea4d412f9e
return params;
}
function convertTools(tools, compat) {
-@@ -1266,6 +1315,9 @@ function detectCompat(model) {
- requiresAssistantAfterToolResult: false,
+@@ -1271,6 +1320,9 @@ function detectCompat(model) {
+ requiresToolsWithToolHistory: false,
requiresThinkingAsText: false,
requiresReasoningContentOnAssistantMessages: isDeepSeek,
+ // Relays that reject an empty reasoning echo must set this explicitly:
@@ -452,7 +447,7 @@ index 12ec37eaf976340d2b29234dab2f17964ed56c91..02d3cdec478f40f40c312dea4d412f9e
thinkingFormat: isDeepSeek
? "deepseek"
: isZai
-@@ -1319,6 +1371,8 @@ function getCompat(model) {
+@@ -1326,6 +1378,8 @@ function getCompat(model) {
requiresThinkingAsText: model.compat.requiresThinkingAsText ?? detected.requiresThinkingAsText,
requiresReasoningContentOnAssistantMessages: model.compat.requiresReasoningContentOnAssistantMessages ??
detected.requiresReasoningContentOnAssistantMessages,
@@ -636,7 +631,7 @@ index 3901bfc4bc6dee0eb45a209dbcbdb59d6c55d054..60b63766576f463b83a964ef9b16d394
else if (event.type === "error") {
throw new Error(`Error Code ${event.code}: ${event.message}` || "Unknown error");
diff --git a/dist/api/openai-responses.js b/dist/api/openai-responses.js
-index 7b3b0d733c3495fd0815f563212acac457224dc0..c9e536a33e7e955db48c3c2e2dc7667b41da85d4 100644
+index 0977a46594d2caa8c92b90e267158ee5efb74938..84594bc4ee233f095a2dc200373b6c6eeacc47ce 100644
--- a/dist/api/openai-responses.js
+++ b/dist/api/openai-responses.js
@@ -1,3 +1,5 @@
@@ -645,7 +640,7 @@ index 7b3b0d733c3495fd0815f563212acac457224dc0..c9e536a33e7e955db48c3c2e2dc7667b
import OpenAI from "openai";
import { clampThinkingLevel } from "../models.js";
import { formatProviderError, normalizeProviderError } from "../utils/error-body.js";
-@@ -106,7 +108,6 @@ function getPromptCacheOptions(compat, cacheRetention) {
+@@ -107,7 +109,6 @@ function getPromptCacheOptions(compat, cacheRetention) {
*/
export const stream = (model, context, options) => {
const stream = new AssistantMessageEventStream();
@@ -653,7 +648,7 @@ index 7b3b0d733c3495fd0815f563212acac457224dc0..c9e536a33e7e955db48c3c2e2dc7667b
// Start async processing
(async () => {
const compat = getCompat(model);
-@@ -129,7 +130,9 @@ export const stream = (model, context, options) => {
+@@ -130,7 +131,9 @@ export const stream = (model, context, options) => {
stopReason: "pending",
timestamp: Date.now(),
};
@@ -663,7 +658,7 @@ index 7b3b0d733c3495fd0815f563212acac457224dc0..c9e536a33e7e955db48c3c2e2dc7667b
// Create OpenAI client
const apiKey = getClientApiKey(model.provider, options?.apiKey, options?.headers);
const cacheRetention = resolveCacheRetention(options?.cacheRetention, options?.env);
-@@ -146,6 +149,9 @@ export const stream = (model, context, options) => {
+@@ -147,6 +150,9 @@ export const stream = (model, context, options) => {
...(options?.timeoutMs !== undefined ? { timeout: options.timeoutMs } : {}),
maxRetries: 0,
};
@@ -673,7 +668,7 @@ index 7b3b0d733c3495fd0815f563212acac457224dc0..c9e536a33e7e955db48c3c2e2dc7667b
const { data: openaiStream, response } = await retryProviderRequest(() => client.responses.create(params, requestOptions).withResponse(), {
maxRetries: options?.maxRetries,
maxRetryDelayMs: options?.maxRetryDelayMs,
-@@ -172,8 +178,13 @@ export const stream = (model, context, options) => {
+@@ -173,8 +179,13 @@ export const stream = (model, context, options) => {
stream.end();
}
catch (error) {
@@ -688,7 +683,7 @@ index 7b3b0d733c3495fd0815f563212acac457224dc0..c9e536a33e7e955db48c3c2e2dc7667b
// Sign in with ChatGPT shares the subscription's usage limit with other apps.
// On ChatGPT Business plans, the workspace admin also sets a per-user limit.
if (errorMessage.includes("subscription_sharing_usage_limit_exceeded")) {
-@@ -191,7 +202,7 @@ export const stream = (model, context, options) => {
+@@ -192,7 +203,7 @@ export const stream = (model, context, options) => {
})();
return stream;
};
@@ -697,7 +692,7 @@ index 7b3b0d733c3495fd0815f563212acac457224dc0..c9e536a33e7e955db48c3c2e2dc7667b
getClientApiKey(model.provider, options?.apiKey, options?.headers);
const base = {
...buildBaseOptions(model, context, options, options?.apiKey),
-@@ -203,7 +214,7 @@ export const streamSimple = (model, context, options) => {
+@@ -204,7 +215,7 @@ export const streamSimple = (model, context, options) => {
...base,
reasoningEffort,
});
@@ -706,7 +701,7 @@ index 7b3b0d733c3495fd0815f563212acac457224dc0..c9e536a33e7e955db48c3c2e2dc7667b
function createClient(model, context, apiKey, optionsHeaders, identity, fetch, sessionId) {
const compat = getCompat(model);
const headers = { ...getIdentityHeaders(model, identity), ...model.headers };
-@@ -278,6 +289,12 @@ function buildParams(model, context, options, compat, grammarToolInputProperties
+@@ -280,6 +291,12 @@ function buildParams(model, context, options, compat, grammarToolInputProperties
supportsOpenAIGrammarTools: compat.supportsOpenAIGrammarTools,
});
}
@@ -719,7 +714,7 @@ index 7b3b0d733c3495fd0815f563212acac457224dc0..c9e536a33e7e955db48c3c2e2dc7667b
if (options?.toolChoice !== undefined) {
params.tool_choice = options.toolChoice;
}
-@@ -302,6 +319,10 @@ function buildParams(model, context, options, compat, grammarToolInputProperties
+@@ -304,6 +321,10 @@ function buildParams(model, context, options, compat, grammarToolInputProperties
if (model.provider === "xai")
params.include = ["reasoning.encrypted_content"];
}
@@ -731,19 +726,19 @@ index 7b3b0d733c3495fd0815f563212acac457224dc0..c9e536a33e7e955db48c3c2e2dc7667b
const samplingParams = resolveSamplingParams(model, reasoningEffort ?? "off", options?.samplingParams);
if (samplingParams) {
diff --git a/dist/api/simple-options.js b/dist/api/simple-options.js
-index ed753df7ea29238c5ef2f1543c3568173be00df7..0a1621a162bc6cff3b81550395c0efea0ef1149b 100644
+index a119bf912008e77ec051af6d9701e24c9f2b468b..0bed45d53b0eec8821165a76d6d406b0fdfa46b1 100644
--- a/dist/api/simple-options.js
+++ b/dist/api/simple-options.js
-@@ -5,7 +5,7 @@ const MIN_MAX_TOKENS = 1;
+@@ -13,7 +13,7 @@ const MIN_MAX_TOKENS = 1;
export function clampMaxTokensToContext(model, context, maxTokens) {
if (model.contextWindow <= 0)
return Math.max(MIN_MAX_TOKENS, maxTokens);
-- const available = model.contextWindow - estimateContextTokens(context).tokens - CONTEXT_SAFETY_TOKENS;
-+ const available = model.contextWindow - estimateContextTokens(context, model).tokens - CONTEXT_SAFETY_TOKENS;
- return Math.min(maxTokens, Math.max(MIN_MAX_TOKENS, available));
- }
- export function resolveSamplingParams(model, thinkingLevel, requestParams) {
-@@ -31,6 +31,7 @@ export function buildBaseOptions(model, context, options, apiKey) {
+- const input = estimateContextTokens(context).tokens;
++ const input = estimateContextTokens(context, model).tokens;
+ const margin = Math.max(CONTEXT_SAFETY_TOKENS, Math.ceil(input * CONTEXT_SAFETY_RATIO));
+ let room = model.contextWindow - input - margin;
+ if (room < MIN_OUTPUT_WITH_RATIO_MARGIN) {
+@@ -45,6 +45,7 @@ export function buildBaseOptions(model, context, options, apiKey) {
headers: options?.headers,
identity: options?.identity,
onPayload: options?.onPayload,
@@ -909,10 +904,10 @@ index 0823512eb83d74167335cde72ae21ea32384572e..338b1571d1e5e2cd6596b98f4ae6c3ff
return {
type: "oauth",
diff --git a/dist/index.d.ts b/dist/index.d.ts
-index 5f531d7dbaf7a79972629f7cb5e096af75116d02..f8d9596dffdc83fb087e5d9ab1f3aea8caac7e84 100644
+index 9c19bb0fd38cc51e814d3680e8e06519908874b5..c21e498b68fbac814e7486a79aff2ae6234d9f99 100644
--- a/dist/index.d.ts
+++ b/dist/index.d.ts
-@@ -32,5 +32,8 @@ export { contentText, getSystemMessageText, renderSystemMessageUpdate } from "./
+@@ -33,5 +33,8 @@ export { contentText, getSystemMessageText, renderSystemMessageUpdate } from "./
export * from "./utils/transcript.ts";
export { uuidv7 } from "./utils/uuid.ts";
export * from "./utils/validation.ts";
@@ -923,10 +918,10 @@ index 5f531d7dbaf7a79972629f7cb5e096af75116d02..f8d9596dffdc83fb087e5d9ab1f3aea8
//# sourceMappingURL=index.d.ts.map
\ No newline at end of file
diff --git a/dist/index.js b/dist/index.js
-index d1ec9f0c1d3cbe644ba80e81e61cb58becc9ae2d..062642acfad612f54ae0b05af168017501e4e795 100644
+index a45b61643634b192fb41453b8869e1be3eaab658..19867491db5facf83b034f967e3d81921aaea905 100644
--- a/dist/index.js
+++ b/dist/index.js
-@@ -20,5 +20,7 @@ export { contentText, getSystemMessageText, renderSystemMessageUpdate } from "./
+@@ -21,5 +21,7 @@ export { contentText, getSystemMessageText, renderSystemMessageUpdate } from "./
export * from "./utils/transcript.js";
export { uuidv7 } from "./utils/uuid.js";
export * from "./utils/validation.js";
@@ -936,27 +931,27 @@ index d1ec9f0c1d3cbe644ba80e81e61cb58becc9ae2d..062642acfad612f54ae0b05af1680175
//# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/dist/providers/compat-schema.d.ts b/dist/providers/compat-schema.d.ts
-index 0e906dc7d9fa39dad8d52d0c0e6da63351cbeb45..f7e64e2c207605835d81ee094c776fe17d92a73c 100644
+index 5305046223864cac3aa1b86d129b7eac2b60d6a1..dae03b94fc47fcde2345c4b466ca374badbbd046 100644
--- a/dist/providers/compat-schema.d.ts
+++ b/dist/providers/compat-schema.d.ts
-@@ -71,6 +71,7 @@ export declare const OpenAICompletionsCompatSchema: import("@earendil-works/pi-s
- requiresAssistantAfterToolResult?: boolean | undefined;
+@@ -73,6 +73,7 @@ export declare const OpenAICompletionsCompatSchema: import("@earendil-works/pi-s
+ requiresToolsWithToolHistory?: boolean | undefined;
requiresThinkingAsText?: boolean | undefined;
requiresReasoningContentOnAssistantMessages?: boolean | undefined;
+ requiresNonEmptyReasoningReplay?: boolean | undefined;
thinkingFormat?: "ant-ling" | "baseten" | "chat-template" | "deepseek" | "openai" | "openrouter" | "qwen" | "qwen-chat-template" | "string-thinking" | "together" | "zai" | undefined;
chatTemplateKwargs?: Record<string, string | number | boolean | {
$var: "thinking.budget" | "thinking.effort" | "thinking.enabled";
-@@ -198,6 +199,7 @@ export declare const CompatSchemasByApi: {
- requiresAssistantAfterToolResult?: boolean | undefined;
+@@ -205,6 +206,7 @@ export declare const CompatSchemasByApi: {
+ requiresToolsWithToolHistory?: boolean | undefined;
requiresThinkingAsText?: boolean | undefined;
requiresReasoningContentOnAssistantMessages?: boolean | undefined;
+ requiresNonEmptyReasoningReplay?: boolean | undefined;
thinkingFormat?: "ant-ling" | "baseten" | "chat-template" | "deepseek" | "openai" | "openrouter" | "qwen" | "qwen-chat-template" | "string-thinking" | "together" | "zai" | undefined;
chatTemplateKwargs?: Record<string, string | number | boolean | {
$var: "thinking.budget" | "thinking.effort" | "thinking.enabled";
-@@ -353,6 +355,7 @@ export declare const ProviderCompatSchema: import("@earendil-works/pi-schema").S
- requiresAssistantAfterToolResult?: boolean | undefined;
+@@ -367,6 +369,7 @@ export declare const ProviderCompatSchema: import("@earendil-works/pi-schema").S
+ requiresToolsWithToolHistory?: boolean | undefined;
requiresThinkingAsText?: boolean | undefined;
requiresReasoningContentOnAssistantMessages?: boolean | undefined;
+ requiresNonEmptyReasoningReplay?: boolean | undefined;
@@ -964,11 +959,11 @@ index 0e906dc7d9fa39dad8d52d0c0e6da63351cbeb45..f7e64e2c207605835d81ee094c776fe1
chatTemplateKwargs?: Record<string, string | number | boolean | {
$var: "thinking.budget" | "thinking.effort" | "thinking.enabled";
diff --git a/dist/providers/compat-schema.js b/dist/providers/compat-schema.js
-index cc9e60a5f8ef12c976984a8a4c8f55eb588896f5..a9dafd908c5cca6cc275985853d7acccaef74709 100644
+index f90e7b193997a6dd8f82434a88e573899f60f3a6..ead467a23fe6502869a204dd30c1825f183aba28 100644
--- a/dist/providers/compat-schema.js
+++ b/dist/providers/compat-schema.js
-@@ -111,6 +111,9 @@ function optionalSessionAffinityFormat(options) {
- return opt(sessionAffinityFormat(options));
+@@ -114,6 +114,9 @@ function optionalPromptCacheKeyMode(options) {
+ return opt(union([stringLiteral("auto"), stringLiteral("enabled"), stringLiteral("disabled")], options));
}
const OpenAICompletionsCompatProperties = {
+ requiresNonEmptyReasoningReplay: opt(bool({
@@ -985,10 +980,10 @@ index 1443bb592b2913ba09579f3f555a2b09456e63cf..5fc0625778014863aa267ac5186db2cd
-{"openai-completions":{"chat:deepseek-flash":{"id":"deepseek-flash","name":"DeepSeek V4.1 Flash","api":"openai-completions","baseUrl":"https://api.deepseek.com","provider":"deepseek","reasoning":true,"thinkingLevelMap":{"minimal":null,"low":"low","medium":null,"high":"high","max":"max"},"input":["text","image"],"cost":{"input":0.3,"output":1.2,"cacheRead":0.006,"cacheWrite":0},"contextWindow":1000000,"maxTokens":384000,"compat":{"supportsStore":false,"supportsDeveloperRole":false,"maxTokensField":"max_tokens","requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek","supportsStrictMode":true},"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:deepseek-v4-pro":{"id":"deepseek-v4-pro","name":"DeepSeek V4 Pro","api":"openai-completions","baseUrl":"https://api.deepseek.com","provider":"deepseek","reasoning":true,"input":["text"],"cost":{"input":1.32,"output":3.96,"cacheRead":0.044,"cacheWrite":0},"contextWindow":1000000,"maxTokens":384000,"compat":{"supportsStore":false,"supportsDeveloperRole":false,"maxTokensField":"max_tokens","requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek","supportsStrictMode":true,"supportsMidConvoSystemMessages":true},"thinkingLevelMap":{"minimal":null,"low":null,"medium":null,"high":"high","max":"max"},"type":"chat"}}}
+{"openai-completions":{"chat:deepseek-flash":{"id":"deepseek-flash","name":"DeepSeek V4.1 Flash","api":"openai-completions","baseUrl":"https://api.deepseek.com","provider":"deepseek","reasoning":true,"thinkingLevelMap":{"minimal":null,"low":"low","medium":null,"high":"high","max":"max"},"input":["text","image"],"cost":{"input":0.3,"output":1.2,"cacheRead":0.006,"cacheWrite":0},"contextWindow":1000000,"maxTokens":384000,"compat":{"supportsStore":false,"supportsDeveloperRole":false,"maxTokensField":"max_tokens","requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek","supportsStrictMode":true,"supportsMidConvoSystemMessages":true},"inputLimits":{"images":{"resize":{"maxWidth":2000,"maxHeight":2000,"maxBytes":4718592,"jpegQuality":80}}},"type":"chat"},"chat:deepseek-v4-pro":{"id":"deepseek-v4-pro","name":"DeepSeek V4 Pro","api":"openai-completions","baseUrl":"https://api.deepseek.com","provider":"deepseek","reasoning":true,"input":["text"],"cost":{"input":1.32,"output":3.96,"cacheRead":0.044,"cacheWrite":0},"contextWindow":1000000,"maxTokens":384000,"compat":{"supportsStore":false,"supportsDeveloperRole":false,"maxTokensField":"max_tokens","requiresReasoningContentOnAssistantMessages":true,"thinkingFormat":"deepseek","supportsStrictMode":true,"supportsMidConvoSystemMessages":true},"thinkingLevelMap":{"minimal":null,"low":null,"medium":null,"high":"high","max":"max"},"type":"chat"}}}
diff --git a/dist/types.d.ts b/dist/types.d.ts
-index 2d650ea3ece9ed470dc6c60538409e2b84f06f32..c814ef7e9187fd57b26cbefc8722c81ed5e68159 100644
+index b410a7bab16c395090ab63e362288306950dec64..c815f3d49ae8d0e1ab0b7b68db03880c88e8aa36 100644
--- a/dist/types.d.ts
+++ b/dist/types.d.ts
-@@ -240,6 +240,8 @@ export interface SimpleStreamOptions extends StreamOptions {
+@@ -247,6 +247,8 @@ export interface SimpleStreamOptions extends StreamOptions {
};
/** Custom token budgets for thinking levels (token-based providers only) */
thinkingBudgets?: ThinkingBudgets;
@@ -997,7 +992,7 @@ index 2d650ea3ece9ed470dc6c60538409e2b84f06f32..c814ef7e9187fd57b26cbefc8722c81e
}
export type StreamFunction<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> = (model: Model<TApi>, context: TranscriptContext, options?: TOptions) => AssistantMessageEventStream;
export type ImagesFunction<TOptions extends ImagesOptions = ImagesOptions> = (model: ImageModel<ImageApi>, context: ImagesContext, options?: TOptions) => Promise<AssistantImages>;
-@@ -282,6 +284,30 @@ export interface ToolCall {
+@@ -289,6 +291,30 @@ export interface ToolCall {
*/
argumentsError?: string;
}
@@ -1028,7 +1023,7 @@ index 2d650ea3ece9ed470dc6c60538409e2b84f06f32..c814ef7e9187fd57b26cbefc8722c81e
export interface Usage {
input: number;
output: number;
-@@ -374,7 +400,7 @@ export interface UserMessage {
+@@ -381,7 +407,7 @@ export interface UserMessage {
}
export interface AssistantMessage {
role: "assistant";
@@ -1037,7 +1032,7 @@ index 2d650ea3ece9ed470dc6c60538409e2b84f06f32..c814ef7e9187fd57b26cbefc8722c81e
api: Api;
provider: ProviderId;
model: string;
-@@ -389,6 +415,8 @@ export interface AssistantMessage {
+@@ -396,6 +422,8 @@ export interface AssistantMessage {
stopReason: StopReason;
deferred?: DeferredHandle;
errorMessage?: string;
@@ -1046,7 +1041,7 @@ index 2d650ea3ece9ed470dc6c60538409e2b84f06f32..c814ef7e9187fd57b26cbefc8722c81e
rawStopReason?: string;
/**
* Provider indication of whether the model explicitly ended its turn.
-@@ -627,6 +655,10 @@ export type AssistantMessageEvent = {
+@@ -634,6 +662,10 @@ export type AssistantMessageEvent = {
contentIndex: number;
toolCall: ToolCall;
partial: AssistantMessage;
@@ -1057,7 +1052,7 @@ index 2d650ea3ece9ed470dc6c60538409e2b84f06f32..c814ef7e9187fd57b26cbefc8722c81e
} | {
type: "done";
reason: Extract<StopReason, "stop" | "length" | "toolUse" | "deferred">;
-@@ -658,6 +690,8 @@ export interface Model<TApi extends Api> extends BaseModel<TApi> {
+@@ -665,6 +697,8 @@ export interface Model<TApi extends Api> extends BaseModel<TApi> {
*/
type?: "chat";
reasoning: boolean;
diff --git a/patches/@[email protected] b/patches/@[email protected]
similarity index 96%
rename from patches/@[email protected]
rename to patches/@[email protected]
index 0c89c5077..0bce34727 100644
--- a/patches/@[email protected]
+++ b/patches/@[email protected]
@@ -1,5 +1,5 @@
diff --git a/dist/core/agent-session.js b/dist/core/agent-session.js
-index ccbb5a96b093a95499f1caa4a30371c3ebd4102a..d423f0fd3348981f738b4229ad5c9f43b72e380b 100644
+index d67feeb70a00ff60a93583bf4ffb79a3d780fa9b..de9958124712d6326b21fb1585da1a90e09b9849 100644
--- a/dist/core/agent-session.js
+++ b/dist/core/agent-session.js
@@ -79,10 +79,10 @@ function withoutDeletedHeaders(headers) {
@@ -15,7 +15,7 @@ index ccbb5a96b093a95499f1caa4a30371c3ebd4102a..d423f0fd3348981f738b4229ad5c9f43
}
return tokens;
}
-@@ -431,7 +431,7 @@ export class AgentSession {
+@@ -473,7 +473,7 @@ export class AgentSession {
_exceedsCompactionThreshold(model, projection) {
if (model.contextWindow <= 0)
return false;
@@ -24,7 +24,7 @@ index ccbb5a96b093a95499f1caa4a30371c3ebd4102a..d423f0fd3348981f738b4229ad5c9f43
}
async _compactBeforeNextAssistantResponse(context) {
const projection = this.sessionManager.buildSessionProjection();
-@@ -603,7 +603,7 @@ export class AgentSession {
+@@ -645,7 +645,7 @@ export class AgentSession {
entryId = manager.appendContextEdit(draft.targetId, draft.replacement);
break;
case "compaction": {
@@ -33,7 +33,7 @@ index ccbb5a96b093a95499f1caa4a30371c3ebd4102a..d423f0fd3348981f738b4229ad5c9f43
entryId = manager.appendCompaction(draft.summary, draft.firstKeptEntryId, tokensBefore, draft.details, true, draft.usage);
break;
}
-@@ -2258,7 +2258,7 @@ export class AgentSession {
+@@ -2336,7 +2336,7 @@ export class AgentSession {
}
const settings = this.settingsManager.getCompactionSettings(model);
const pathEntries = this.sessionManager.getBranch();
@@ -42,7 +42,7 @@ index ccbb5a96b093a95499f1caa4a30371c3ebd4102a..d423f0fd3348981f738b4229ad5c9f43
if (!preparation) {
// Check why we can't compact
const lastEntry = pathEntries[pathEntries.length - 1];
-@@ -2315,7 +2315,7 @@ export class AgentSession {
+@@ -2393,7 +2393,7 @@ export class AgentSession {
this.sessionManager.appendCompaction(summary, firstKeptEntryId, tokensBefore, details, fromExtension, usage);
const newEntries = this.sessionManager.getEntries();
this._refreshFinalizedContext();
@@ -51,7 +51,7 @@ index ccbb5a96b093a95499f1caa4a30371c3ebd4102a..d423f0fd3348981f738b4229ad5c9f43
// Get the saved compaction entry for the extension event
const savedCompactionEntry = newEntries.find((e) => e.type === "compaction" && e.summary === summary);
if (this._extensionRunner && savedCompactionEntry) {
-@@ -2498,11 +2498,11 @@ export class AgentSession {
+@@ -2576,11 +2576,11 @@ export class AgentSession {
const hasContextEdits = projection.entries.some((entry) => entry.sourceEntry.type === "context_edit");
const directContextTokens = assistantMessage.usage ? calculateContextTokens(assistantMessage.usage) : 0;
if (hasContextEdits) {
@@ -65,7 +65,7 @@ index ccbb5a96b093a95499f1caa4a30371c3ebd4102a..d423f0fd3348981f738b4229ad5c9f43
// Without provider usage, estimate.tokens is the pure message-size estimate.
// Only usage-backed estimates need the stale pre-compaction check.
if (estimate.lastUsageIndex !== null) {
-@@ -2548,7 +2548,7 @@ export class AgentSession {
+@@ -2626,7 +2626,7 @@ export class AgentSession {
return false;
}
const pathEntries = this.sessionManager.getBranch();
@@ -74,7 +74,7 @@ index ccbb5a96b093a95499f1caa4a30371c3ebd4102a..d423f0fd3348981f738b4229ad5c9f43
if (!preparation) {
return false;
}
-@@ -2604,7 +2604,7 @@ export class AgentSession {
+@@ -2682,7 +2682,7 @@ export class AgentSession {
this.sessionManager.appendCompaction(summary, firstKeptEntryId, tokensBefore, details, fromExtension, usage);
const newEntries = this.sessionManager.getEntries();
this._refreshFinalizedContext();
@@ -83,7 +83,7 @@ index ccbb5a96b093a95499f1caa4a30371c3ebd4102a..d423f0fd3348981f738b4229ad5c9f43
// Get the saved compaction entry for the extension event
const savedCompactionEntry = newEntries.find((e) => e.type === "compaction" && e.summary === summary);
if (this._extensionRunner && savedCompactionEntry) {
-@@ -3542,7 +3542,7 @@ export class AgentSession {
+@@ -3631,7 +3631,7 @@ export class AgentSession {
if (!hasPostCompactionUsage)
return { tokens: null, contextWindow, percent: null };
}
@@ -424,7 +424,7 @@ index 9b1a409d96b39413d8598c79f14fee72f4cd533c..95f9b8fb0f6e64f23e6923a7b87b02a5
if (!firstKeptEntry?.id)
return undefined;
diff --git a/dist/core/compaction/utils.js b/dist/core/compaction/utils.js
-index ff5292a31ab6a81a34c58c2eba0c49c5197f28fc..7f190eed0fe7df13fefec09ced8ab2fc5233b064 100644
+index 94da1909f2f2c850bee737b4cd2d12c4a1caf9ec..c265d5ea3b2ac99041c3ede42d192e5aab8221b8 100644
--- a/dist/core/compaction/utils.js
+++ b/dist/core/compaction/utils.js
@@ -2,6 +2,7 @@
@@ -432,10 +432,10 @@ index ff5292a31ab6a81a34c58c2eba0c49c5197f28fc..7f190eed0fe7df13fefec09ced8ab2fc
*/
import { contentText } from "@earendil-works/pi-ai";
+import { hostedSearchReplayProjection } from "@earendil-works/pi-ai/utils/hosted-search";
+ import { sliceHead } from "../tools/truncate.js";
export function createFileOps() {
return {
- read: new Set(),
-@@ -114,6 +115,7 @@ export function serializeConversation(messages) {
+@@ -115,6 +116,7 @@ export function serializeConversation(messages) {
}
else if (msg.role === "assistant") {
const toolCalls = [];
@@ -443,7 +443,7 @@ index ff5292a31ab6a81a34c58c2eba0c49c5197f28fc..7f190eed0fe7df13fefec09ced8ab2fc
for (const block of msg.content) {
if (block.type === "toolCall") {
const args = block.arguments;
-@@ -122,6 +124,13 @@ export function serializeConversation(messages) {
+@@ -123,6 +125,13 @@ export function serializeConversation(messages) {
.join(", ");
toolCalls.push(`${block.name}(${argsStr})`);
}
@@ -457,7 +457,7 @@ index ff5292a31ab6a81a34c58c2eba0c49c5197f28fc..7f190eed0fe7df13fefec09ced8ab2fc
}
if (msg.content.some((block) => block.type === "text")) {
parts.push(`[Assistant]: ${contentText(msg.content)}`);
-@@ -129,6 +138,9 @@ export function serializeConversation(messages) {
+@@ -130,6 +139,9 @@ export function serializeConversation(messages) {
if (toolCalls.length > 0) {
parts.push(`[Assistant tool calls]: ${toolCalls.join("; ")}`);
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a5b87358e..8311ee5b7 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -205,9 +205,9 @@ overrides:
vite@5: '>=6.4.3 <7'
patchedDependencies:
- '@earendil-works/[email protected]': f7df81a6d069cd0287276085d46d531684234acb7243dc032b1a1d73b17019da
- '@earendil-works/[email protected]': 531d8160f4e83fe7d3ad9089fd256b6fd657d9fa09c3978e70d727ba7982b666
- '@earendil-works/[email protected]': 1d20a271da819982a9d458d6064c51e5e06fc28637c2efa94d5683e5b3867d90
+ '@earendil-works/[email protected]': f7df81a6d069cd0287276085d46d531684234acb7243dc032b1a1d73b17019da
+ '@earendil-works/[email protected]': c262edebba33ec73c9ed0b89f801984f76dc8647ffa0c179b9a0d30d372ad78a
+ '@earendil-works/[email protected]': b1ad25365da34b5862e5263254f499e8c28a8344d66609110df5d2061c519bf9
importers:
@@ -233,11 +233,11 @@ importers:
version: 0.2.2
devDependencies:
'@earendil-works/pi-ai':
- specifier: 1.5.0
- version: 1.5.0(patch_hash=531d8160f4e83fe7d3ad9089fd256b6fd657d9fa09c3978e70d727ba7982b666)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
+ specifier: 1.5.2
+ version: 1.5.2(patch_hash=c262edebba33ec73c9ed0b89f801984f76dc8647ffa0c179b9a0d30d372ad78a)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
'@earendil-works/pi-mcp':
- specifier: 1.5.0
- version: 1.5.0
+ specifier: 1.5.2
+ version: 1.5.2
'@pi-desktop/agent-host':
specifier: workspace:*
version: link:../../packages/agent-host
@@ -434,14 +434,14 @@ importers:
packages/agent-runtime:
dependencies:
'@earendil-works/pi-agent-core':
- specifier: 1.5.0
- version: 1.5.0(patch_hash=f7df81a6d069cd0287276085d46d531684234acb7243dc032b1a1d73b17019da)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
+ specifier: 1.5.2
+ version: 1.5.2(patch_hash=f7df81a6d069cd0287276085d46d531684234acb7243dc032b1a1d73b17019da)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
'@earendil-works/pi-ai':
- specifier: 1.5.0
- version: 1.5.0(patch_hash=531d8160f4e83fe7d3ad9089fd256b6fd657d9fa09c3978e70d727ba7982b666)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
+ specifier: 1.5.2
+ version: 1.5.2(patch_hash=c262edebba33ec73c9ed0b89f801984f76dc8647ffa0c179b9a0d30d372ad78a)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
'@earendil-works/pi-coding-agent':
- specifier: 1.5.0
- version: 1.5.0(patch_hash=1d20a271da819982a9d458d6064c51e5e06fc28637c2efa94d5683e5b3867d90)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])
+ specifier: 1.5.2
+ version: 1.5.2(patch_hash=b1ad25365da34b5862e5263254f499e8c28a8344d66609110df5d2061c519bf9)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])
'@pi-desktop/shared':
specifier: workspace:*
version: link:../shared
@@ -969,38 +969,38 @@ packages:
search-insights:
optional: true
- '@earendil-works/[email protected]':
- resolution: {integrity: sha512-FOj+jXj48DbzMycR/ghNa2KcsqWmvOln24e0FnQOVgnd8vn5H79g335WdHaZUVdRo+zCeogb40/qPPlCWFuvmA==}
+ '@earendil-works/[email protected]':
+ resolution: {integrity: sha512-ie5mejS7mGfXt//9As7i3LfxVXdktZvF1JP4EQsUXTp4mU437h23MNGx7wXZ5VYs3YiG/Qnj3e7OZ2HC069OMw==}
engines: {node: '>=22.19.0'}
- '@earendil-works/[email protected]':
- resolution: {integrity: sha512-VeWxNqTHSqRCf8AcY/6kvNwh+neRL6MPxZPePVztIQy6qqK9MR/YoCSN/ZgDnIyCD3pqEXgRyQbzk4KV4uvjbg==}
+ '@earendil-works/[email protected]':
+ resolution: {integrity: sha512-2tWPSnV3qzfiDIY3aWluBag3vC++Vs+VsXt/UquSU5onPMohPih72FUhIhaqmDdMYubOgB3Byl9uF4Vk40JLvQ==}
engines: {node: '>=22.19.0'}
hasBin: true
- '@earendil-works/[email protected]':
- resolution: {integrity: sha512-PLBJZ17AEWGzOlAAcFuOkw3PxkOti0JlFuZQyeF2GRTqbpuYo4k9t8YqUV2uOQVzrUnKdxahwaFUqc1eNS1WAg==}
+ '@earendil-works/[email protected]':
+ resolution: {integrity: sha512-HoZQ40a9RgdZ1VgmrX6x8887cNXedaRJT1l+Ie5YRIMK4gY7v0EpsiNqf6dmixrKylZlTgUSyR+vE8xhjfkr+w==}
engines: {node: '>=22.19.0'}
- '@earendil-works/[email protected]':
- resolution: {integrity: sha512-xNDZ5kqowO6Z03FS2gwAkPEGk1ssxVcYKQ6qZId84mFEvwACvvyc2l0vAMOS+c5zvxLRMLBE9r4y44IGYkMJaQ==}
+ '@earendil-works/[email protected]':
+ resolution: {integrity: sha512-mUWI04rqF1Vd/m1q+Ps1XeWsTXEVvRUnsmRa83I3Dzua0Tx5bYS93imeqtIfrXf7PkkaR6ERz+AuQhIJlom5yA==}
engines: {node: '>=22.19.0'}
hasBin: true
- '@earendil-works/[email protected]':
- resolution: {integrity: sha512-DURw3IwHCTMHV8CzUJWVp9css27NowsCWfXt4xg2r09IZ+P1O/Uq58hp0hb9WJO0dbkaKGXKBIkV4LVXcu2nlg==}
+ '@earendil-works/[email protected]':
+ resolution: {integrity: sha512-zU1UgeXDlbixPqGEWD7Ql0brEMIpYr7aEWjoEE5h5enJbM/kQ2jIr7lN8JoR80oUnq1fJSU7SC8kLx2Fx/IZYg==}
engines: {node: '>=22.19.0'}
- '@earendil-works/[email protected]':
- resolution: {integrity: sha512-RW0MbT2tR65OY6xMsgB/yVBb7m/RTNwA+9hurSN1vVXfHZRVmVnXbruBPrx/PzbrQnW5yLVlMRWxErGDQtF1Hg==}
+ '@earendil-works/[email protected]':
+ resolution: {integrity: sha512-hJoyCXWUhsSrXY5wJo2Q4kHXUsR51pNhkJHAMkWRwVMLDRtMDPkKNaa+JlVRVqTw1hjdSxcVVaFLSDbKlaTXEQ==}
engines: {node: '>=22.19.0'}
- '@earendil-works/[email protected]':
- resolution: {integrity: sha512-VW3tcVdnNfl/Vk8wHPTzZdKkxcsCOM12ppiO4DXnd9wMxUCmOfLt/wvUnWeKWbTVlVSRg0uqKtnnhE2UCsG2Bw==}
+ '@earendil-works/[email protected]':
+ resolution: {integrity: sha512-m+cumjIqNh1aMISi/9ttcG3ZOwIdriPbz/eMyWmRMJCGa/WcgY1RX4lrb7HvsHhSfI/JUeBESA4nOCr8C3y5ow==}
engines: {node: '>=22.19.0'}
- '@earendil-works/[email protected]':
- resolution: {integrity: sha512-56KqrDVeLF18k+syppVbT35Ai1opbM44ot+sL7O3K40CaWwXCiwOpqEFugDBAILtAhseZh6uYIuYxPPOJHLFAA==}
+ '@earendil-works/[email protected]':
+ resolution: {integrity: sha512-WK8ih+c88GWizaB79y7Pq3PV7ySf5VI1pZ1i/6aBBjDOAiG2EE3ojKjl+pxQqLfyQGnzHYu4VfakOBJgumuoyw==}
engines: {node: '>=22.19.0'}
'@electron-internal/[email protected]':
@@ -3057,10 +3057,6 @@ packages:
resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
- resolution: {integrity: sha512-/4KopAbsjvuRP9MdPtlDjOHUmUVEohOX73JNcsWpzAtFxh+bq5+Dhb6gzvRieLDwIPQIR3/vy8V1NNTuz4Zsmg==}
- engines: {node: '>=18'}
-
resolution: {integrity: sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg==}
@@ -3422,6 +3418,10 @@ packages:
resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==}
+ resolution: {integrity: sha512-EMLJS934qwt2MLO/a5o+T/89HGbuXZPwmCpHIhHO+DVrm+y5tHlEHgpZzlC2o4yW/rFPHRFO9xSMafzqH4wH5A==}
+ engines: {node: '>=18'}
+
resolution: {integrity: sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==}
engines: {node: '>=8'}
@@ -5147,10 +5147,10 @@ snapshots:
transitivePeerDependencies:
- '@algolia/client-search'
- '@earendil-works/[email protected](patch_hash=f7df81a6d069cd0287276085d46d531684234acb7243dc032b1a1d73b17019da)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])':
+ '@earendil-works/[email protected](patch_hash=f7df81a6d069cd0287276085d46d531684234acb7243dc032b1a1d73b17019da)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])':
dependencies:
- '@earendil-works/pi-ai': 1.5.0(patch_hash=531d8160f4e83fe7d3ad9089fd256b6fd657d9fa09c3978e70d727ba7982b666)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
- '@earendil-works/pi-schema': 1.5.0
+ '@earendil-works/pi-ai': 1.5.2(patch_hash=c262edebba33ec73c9ed0b89f801984f76dc8647ffa0c179b9a0d30d372ad78a)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
+ '@earendil-works/pi-schema': 1.5.2
transitivePeerDependencies:
- '@aws-sdk/credential-provider-node'
- '@modelcontextprotocol/sdk'
@@ -5164,12 +5164,12 @@ snapshots:
- ws
- zod
- '@earendil-works/[email protected](patch_hash=531d8160f4e83fe7d3ad9089fd256b6fd657d9fa09c3978e70d727ba7982b666)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])':
+ '@earendil-works/[email protected](patch_hash=c262edebba33ec73c9ed0b89f801984f76dc8647ffa0c179b9a0d30d372ad78a)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])':
dependencies:
'@anthropic-ai/sdk': 0.129.0([email protected])
'@aws-sdk/client-bedrock-runtime': 3.1127.0
- '@earendil-works/pi-schema': 1.5.0
- '@earendil-works/pi-telemetry': 1.5.0
+ '@earendil-works/pi-schema': 1.5.2
+ '@earendil-works/pi-telemetry': 1.5.2
'@google/genai': 2.21.0([email protected])
'@smithy/node-http-handler': 4.12.1
http-proxy-agent: 9.1.0([email protected])
@@ -5189,12 +5189,12 @@ snapshots:
- ws
- zod
- '@earendil-works/[email protected](patch_hash=531d8160f4e83fe7d3ad9089fd256b6fd657d9fa09c3978e70d727ba7982b666)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])':
+ '@earendil-works/[email protected](patch_hash=c262edebba33ec73c9ed0b89f801984f76dc8647ffa0c179b9a0d30d372ad78a)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])':
dependencies:
'@anthropic-ai/sdk': 0.129.0([email protected])
'@aws-sdk/client-bedrock-runtime': 3.1127.0
- '@earendil-works/pi-schema': 1.5.0
- '@earendil-works/pi-telemetry': 1.5.0
+ '@earendil-works/pi-schema': 1.5.2
+ '@earendil-works/pi-telemetry': 1.5.2
'@google/genai': 2.21.0([email protected])
'@smithy/node-http-handler': 4.12.1
http-proxy-agent: 9.1.0([email protected])
@@ -5214,27 +5214,27 @@ snapshots:
- ws
- zod
- '@earendil-works/[email protected]':
+ '@earendil-works/[email protected]':
dependencies:
quickjs-wasi: 3.6.2
- '@earendil-works/[email protected](patch_hash=1d20a271da819982a9d458d6064c51e5e06fc28637c2efa94d5683e5b3867d90)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])':
+ '@earendil-works/[email protected](patch_hash=b1ad25365da34b5862e5263254f499e8c28a8344d66609110df5d2061c519bf9)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])':
dependencies:
- '@earendil-works/pi-agent-core': 1.5.0(patch_hash=f7df81a6d069cd0287276085d46d531684234acb7243dc032b1a1d73b17019da)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
- '@earendil-works/pi-ai': 1.5.0(patch_hash=531d8160f4e83fe7d3ad9089fd256b6fd657d9fa09c3978e70d727ba7982b666)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
- '@earendil-works/pi-codemode': 1.5.0
- '@earendil-works/pi-mcp': 1.5.0
- '@earendil-works/pi-tui': 1.5.0
+ '@earendil-works/pi-agent-core': 1.5.2(patch_hash=f7df81a6d069cd0287276085d46d531684234acb7243dc032b1a1d73b17019da)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
+ '@earendil-works/pi-ai': 1.5.2(patch_hash=c262edebba33ec73c9ed0b89f801984f76dc8647ffa0c179b9a0d30d372ad78a)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
+ '@earendil-works/pi-codemode': 1.5.2
+ '@earendil-works/pi-mcp': 1.5.2
+ '@earendil-works/pi-tui': 1.5.2
'@silvia-odwyer/photon-node': 0.3.4
brace-expansion: 5.0.12
chalk: 6.0.0
cross-spawn: 7.0.6
diff: 8.0.4
- grok-mermaid: 0.2.3
highlight.js: 10.7.3
hosted-git-info: 9.0.3
ignore: 7.0.8
jiti: 2.7.0
+ lovely-mermaid: 0.3.3
minimatch: 11.0.3
proper-lockfile: 4.1.2
quickjs-wasi: 3.6.2
@@ -5254,15 +5254,15 @@ snapshots:
- ws
- zod
- '@earendil-works/[email protected]':
+ '@earendil-works/[email protected]':
dependencies:
cross-spawn: 7.0.6
- '@earendil-works/[email protected]': {}
+ '@earendil-works/[email protected]': {}
- '@earendil-works/[email protected]': {}
+ '@earendil-works/[email protected]': {}
- '@earendil-works/[email protected]':
+ '@earendil-works/[email protected]':
dependencies:
get-east-asian-width: 1.6.0
marked: 18.0.11
@@ -7360,8 +7360,6 @@ snapshots:
-
@@ -7775,6 +7773,8 @@ snapshots:
+
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 861f04ad7..7f7bed4c6 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -13,17 +13,17 @@ allowBuilds:
# binary; its from-source install script was never approved and is not needed.
koffi: false
# pnpm records exact-version exclusions for the current, explicitly requested
-# Pi 1.5.0 release while it is inside the minimum release age window. Keep these
+# Pi 1.5.2 release while it is inside the minimum release age window. Keep these
# entries exact; do not widen them to package names or ranges.
minimumReleaseAgeExclude:
- - '@earendil-works/[email protected]'
- - '@earendil-works/[email protected]'
- - '@earendil-works/[email protected]'
- - '@earendil-works/[email protected]'
- - '@earendil-works/[email protected]'
- - '@earendil-works/[email protected]'
- - '@earendil-works/[email protected]'
- - '@earendil-works/[email protected]'
+ - '@earendil-works/[email protected]'
+ - '@earendil-works/[email protected]'
+ - '@earendil-works/[email protected]'
+ - '@earendil-works/[email protected]'
+ - '@earendil-works/[email protected]'
+ - '@earendil-works/[email protected]'
+ - '@earendil-works/[email protected]'
+ - '@earendil-works/[email protected]'
# Advisory fixes for transitives whose parents still resolve the vulnerable
# version. Drop each one once its parent ships a release that resolves the
# patched version on its own.
@@ -59,9 +59,9 @@ overrides:
# every range to its floor — silently downgrading dependencies instead of
# refreshing them. Pin the intent: `pnpm update` means "newest within range".
patchedDependencies:
- '@earendil-works/[email protected]': patches/@[email protected]
- '@earendil-works/[email protected]': patches/@[email protected]
- '@earendil-works/[email protected]': patches/@[email protected]
+ '@earendil-works/[email protected]': patches/@[email protected]
+ '@earendil-works/[email protected]': patches/@[email protected]
+ '@earendil-works/[email protected]': patches/@[email protected]
resolutionMode: highest
# shamefully-hoist also lives in .npmrc, but pnpm 12 applies it only from
# here; without it public hoisting is empty and examples/ plugins cannot
diff --git a/scripts/check-pi-dependencies.mjs b/scripts/check-pi-dependencies.mjs
index 764682dbb..73671a2ae 100644
--- a/scripts/check-pi-dependencies.mjs
+++ b/scripts/check-pi-dependencies.mjs
@@ -25,7 +25,7 @@ function parseArgs(argv) {
}
const root = parseArgs(process.argv.slice(2));
-const targetVersion = "1.5.0";
+const targetVersion = "1.5.2";
function readJson(path) {
return JSON.parse(readFileSync(join(root, path), "utf8"));
@@ -81,17 +81,17 @@ const actualReleaseAgeExclusions = [...releaseAgeExclusions.matchAll(/^[ \t]+-[
.map((match) => match[1])
.sort();
const expectedReleaseAgeExclusions = [
- "@earendil-works/[email protected]",
- "@earendil-works/[email protected]",
- "@earendil-works/[email protected]",
- "@earendil-works/[email protected]",
- "@earendil-works/[email protected]",
- "@earendil-works/[email protected]",
- "@earendil-works/[email protected]",
- "@earendil-works/[email protected]",
+ "@earendil-works/[email protected]",
+ "@earendil-works/[email protected]",
+ "@earendil-works/[email protected]",
+ "@earendil-works/[email protected]",
+ "@earendil-works/[email protected]",
+ "@earendil-works/[email protected]",
+ "@earendil-works/[email protected]",
+ "@earendil-works/[email protected]",
].sort();
if (JSON.stringify(actualReleaseAgeExclusions) !== JSON.stringify(expectedReleaseAgeExclusions)) {
- throw new Error("Pi minimumReleaseAgeExclude entries must match only the exact 1.5.0 release packages");
+ throw new Error("Pi minimumReleaseAgeExclude entries must match only the exact 1.5.2 release packages");
}
process.stdout.write(`Pi direct pins and installed package instances are aligned at ${targetVersion}.\n`);
diff --git a/scripts/check-pi-patches.mjs b/scripts/check-pi-patches.mjs
index 671c82714..8b74c4e8d 100644
--- a/scripts/check-pi-patches.mjs
+++ b/scripts/check-pi-patches.mjs
@@ -25,7 +25,7 @@ function parseArgs(argv) {
}
const root = parseArgs(process.argv.slice(2));
-const targetVersion = "1.5.0";
+const targetVersion = "1.5.2";
const entries = [
{
name: "@earendil-works/pi-agent-core",
diff --git a/scripts/pi-patch-hash.test.mjs b/scripts/pi-patch-hash.test.mjs
index a60d1dfbe..2ac17d308 100644
--- a/scripts/pi-patch-hash.test.mjs
+++ b/scripts/pi-patch-hash.test.mjs
@@ -11,7 +11,7 @@ const here = dirname(fileURLToPath(import.meta.url));
const patchDependencyCheck = join(here, "check-pi-dependencies.mjs");
const patchCheck = join(here, "check-pi-patches.mjs");
-const TARGET = "1.5.0";
+const TARGET = "1.5.2";
const PATCHED = [
{
name: "@earendil-works/pi-agent-core",