mirror of
https://github.com/earendil-works/pi.git
synced 2026-06-18 15:54:04 +08:00
8a0903ebf2
The root barrel is now core-only and side-effect free: types, createModels/createProvider, auth substrate, lazyStream/lazyApi, faux, utils. Generated catalogs, api-registry, env-api-keys, images, global stream functions, and per-API lazy wrappers leave the root. New @earendil-works/pi-ai/compat preserves the old surface verbatim as a strict superset of the root: api-dispatch stream/complete with env key injection, the builtin registration side effect (skip-if-present so it cannot clobber earlier overrides), deprecated getModel/getModels/ getProviders aliases of the new getBuiltin* reads in providers/all, lazy api wrappers + setBedrockProviderModule, and image generation. Compat dies with the coding-agent ModelManager migration. Packaging: exports map gains ./compat, ./providers/*, ./api/*; sideEffects array lists only the effectful modules. Old-global imports across agent/coding-agent/examples and pi-ai tests switch to /compat (path-only; compat is a superset). The coding-agent extension loader resolves the pi-ai ROOT specifier to compat, so existing user extensions using the old global API keep working at runtime until compat is removed. vitest configs alias /compat to src; browser smoke imports old globals from /compat.
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { complete, getModel } from "../src/compat.ts";
|
|
import type { Context } from "../src/types.ts";
|
|
import { resolveApiKey } from "./oauth.ts";
|
|
|
|
const codexToken = await resolveApiKey("openai-codex");
|
|
|
|
describe("openai-codex cache affinity e2e", () => {
|
|
it.skipIf(!codexToken)("handles SSE requests with aligned cache-affinity identifiers", async () => {
|
|
const model = getModel("openai-codex", "gpt-5.5");
|
|
const sessionId = "0195d6e4-4cf9-7f44-a2d8-f8f7f49ee9d3";
|
|
const context: Context = {
|
|
systemPrompt: "You are a helpful assistant. Reply exactly as requested.",
|
|
messages: [
|
|
{
|
|
role: "user",
|
|
content: "Reply with exactly: cache affinity e2e success",
|
|
timestamp: Date.now(),
|
|
},
|
|
],
|
|
};
|
|
|
|
const response = await complete(model, context, {
|
|
apiKey: codexToken,
|
|
sessionId,
|
|
transport: "sse",
|
|
});
|
|
|
|
expect(response.stopReason, response.errorMessage).not.toBe("error");
|
|
expect(response.errorMessage).toBeUndefined();
|
|
expect(response.content.map((block) => (block.type === "text" ? block.text : "")).join("")).toContain(
|
|
"cache affinity e2e success",
|
|
);
|
|
});
|
|
});
|