diff --git a/CHANGELOG.md b/CHANGELOG.md
index a208494..8e98a61 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Changed
+
+- Support Pi 0.86 and 0.87: widen the `@earendil-works/pi-ai` and `@earendil-works/pi-coding-agent` peer ranges to `>=0.83.0 <0.88.0` and typecheck/test against 0.87.1. The extension still overrides Pi's built-in `meta` provider on 0.87.1.
+
## [0.6.1] - 2026-09-04
### Fixed
diff --git a/package.json b/package.json
index cb61543..e36113f 100644
--- a/package.json
+++ b/package.json
@@ -31,12 +31,12 @@
"image": "https://raw.githubusercontent.com/BlockedPath/pi-meta-oauth/main/preview.png"
},
"peerDependencies": {
- "@earendil-works/pi-ai": ">=0.83.0 <0.86.0",
- "@earendil-works/pi-coding-agent": ">=0.83.0 <0.86.0"
+ "@earendil-works/pi-ai": ">=0.83.0 <0.88.0",
+ "@earendil-works/pi-coding-agent": ">=0.83.0 <0.88.0"
},
"devDependencies": {
- "@earendil-works/pi-ai": "0.85.1",
- "@earendil-works/pi-coding-agent": "0.85.1",
+ "@earendil-works/pi-ai": "0.87.1",
+ "@earendil-works/pi-coding-agent": "0.87.1",
"bun-types": "latest",
"typescript": "^5.9.0"
},
diff --git a/tests/meta-cache.test.ts b/tests/meta-cache.test.ts
index f507e3b..71bb36f 100644
--- a/tests/meta-cache.test.ts
+++ b/tests/meta-cache.test.ts
@@ -1,6 +1,7 @@
///
import { describe, expect, test } from "bun:test";
-import type { Model } from "@earendil-works/pi-ai";
+import * as piAi from "@earendil-works/pi-ai";
+import type { Context, Model } from "@earendil-works/pi-ai";
import { streamSimple } from "@earendil-works/pi-ai/api/openai-responses";
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
import {
@@ -19,6 +20,17 @@ import { join } from "node:path";
const LIVE_CACHE_MODEL = "muse-spark-1.2-contributor";
const LIVE_CACHE_KEY = "pi-meta-oauth-live-cache-probe-v1";
+// Pi 0.86+ stream functions take a branded TranscriptContext built by
+// normalizeContext(); Pi 0.83–0.85 take a plain Context and do not export
+// normalizeContext. A namespace import keeps the file loadable on both.
+function toStreamContext(context: Context): Parameters[1] {
+ const normalize = (piAi as { normalizeContext?: (c: Context) => unknown })
+ .normalizeContext;
+ return (
+ typeof normalize === "function" ? normalize(context) : context
+ ) as Parameters[1];
+}
+
function resolveLiveMetaApiKey(): string | undefined {
for (const value of [
process.env.PI_META_LIVE_API_KEY,
@@ -82,9 +94,9 @@ async function captureResponsesRequest(options?: {
let payload: Record | undefined;
const events = streamSimple(
museModel(),
- {
+ toStreamContext({
messages: [{ role: "user", content: "Hi", timestamp: Date.now() }],
- },
+ }),
{
apiKey: "test-key",
sessionId: options?.sessionId ?? "sid",