chore(vendor): import pi 1.3.0

Imported as a linear vendor commit so forge rebases do not replay the upstream root tree.

git-subtree-dir: third_party/pi

git-subtree-split: 71023aec1546d6d677a65669c5665c0927ce0dd0
This commit is contained in:
2026-10-15 17:58:48 -04:00
parent 719370c8f7
commit 6081e3e325
1743 changed files with 205460 additions and 131705 deletions

View File

@@ -91,6 +91,50 @@ describe("extension provider model lifecycle", () => {
expect(registry.getProvider("extension-native")).toBeUndefined();
});
// Regression for #9962: initial model selection reads the snapshot before the async refresh finishes.
it("marks a native provider with a stored credential as configured when it registers", async () => {
const runtime = await ModelRuntime.create({
credentials: AuthStorage.inMemory({
"extension-native": {
type: "oauth",
access: "access",
refresh: "refresh",
expires: Date.now() + 3_600_000,
},
}),
modelsStore: new InMemoryModelsStore(),
modelsPath: null,
allowModelNetwork: false,
});
const nativeModel = { ...model("native"), provider: "extension-native" };
const unused = () => {
throw new Error("unused");
};
const provider: Provider = {
id: "extension-native",
name: "Extension Native",
auth: {
oauth: {
name: "Native OAuth",
login: unused,
refresh: async (credential) => credential,
toAuth: async (credential) => ({ apiKey: credential.access }),
},
},
getModels: () => [nativeModel],
stream: unused,
streamSimple: unused,
};
runtime.registerNativeProvider(provider);
expect(runtime.hasConfiguredAuth("extension-native")).toBe(true);
expect(runtime.isUsingOAuth("extension-native")).toBe(true);
expect(runtime.getAvailableSnapshot().map((m) => `${m.provider}/${m.id}`)).toContain("extension-native/native");
await runtime.refresh({ allowNetwork: false });
expect(runtime.hasConfiguredAuth("extension-native")).toBe(true);
});
it("preserves native deferred methods through provider overlays", async () => {
const tempDir = mkdtempSync(join(tmpdir(), "pi-native-provider-deferred-"));
const modelsPath = join(tempDir, "models.json");