Merge declarative custom and local providers
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* OFFLINE native Pi Google initialization gate (no generation or provider calls).
|
||||
* Unlike /api/models, this traverses Pi's lazy adapter and constructs GoogleGenAI.
|
||||
* The real onPayload hook throws a unique sentinel BEFORE generateContentStream.
|
||||
* OFFLINE native Pi Google/Bedrock initialization gate (no generation or provider calls).
|
||||
* Unlike /api/models, this traverses Pi's lazy adapters and constructs real SDK clients.
|
||||
* The real onPayload hook throws a unique sentinel BEFORE SDK request dispatch.
|
||||
* All file modules must resolve inside the payload, including nested dependencies.
|
||||
*
|
||||
* node scripts/smoke-provider-runtime.mjs [--standalone <dir>] [--runtime <Node/Electron>]
|
||||
@@ -81,17 +81,22 @@ async function probe(standalone) {
|
||||
const entry = pathToFileURL(path.join(root, "node_modules/@earendil-works/pi-ai/dist/index.js"));
|
||||
const { createModels } = await import(entry.href);
|
||||
const models = createModels();
|
||||
for (const [name, factory] of [["google", "googleProvider"], ["opencode", "opencodeProvider"], ["opencode-go", "opencodeGoProvider"]]) {
|
||||
for (const [name, factory, api, label] of [
|
||||
["google", "googleProvider", "google-generative-ai", "Google"],
|
||||
["opencode", "opencodeProvider", "google-generative-ai", "Google"],
|
||||
["opencode-go", "opencodeGoProvider", "google-generative-ai", "Google"],
|
||||
["amazon-bedrock", "amazonBedrockProvider", "bedrock-converse-stream", "Bedrock"],
|
||||
]) {
|
||||
const provider = (await import(new URL(`providers/${name}.js`, entry).href))[factory]();
|
||||
models.setProvider(provider);
|
||||
const model = provider.getModels().find((candidate) => candidate.api === "google-generative-ai");
|
||||
assert.ok(model, `${name}: missing Google-backed catalog model`);
|
||||
const model = provider.getModels().find((candidate) => candidate.api === api);
|
||||
assert.ok(model, `${name}: missing ${api} catalog model`);
|
||||
const sentinel = `LH_OFFLINE_ON_PAYLOAD_${randomUUID()}`;
|
||||
let reached = 0;
|
||||
const result = await models.streamSimple(model, { messages: [{ role: "user", content: "Offline initialization only", timestamp: 0 }] }, {
|
||||
apiKey: "dummy-offline-provider-gate-not-a-key",
|
||||
onPayload(payload, selected) {
|
||||
assert.equal(selected.api, "google-generative-ai");
|
||||
assert.equal(selected.api, api);
|
||||
assert.ok(payload && typeof payload === "object");
|
||||
reached++;
|
||||
throw new Error(sentinel);
|
||||
@@ -101,7 +106,7 @@ async function probe(standalone) {
|
||||
assert.equal(result.stopReason, "error");
|
||||
assert.equal(result.errorMessage, sentinel, `${name}: unexpected initialization error`);
|
||||
noNetwork();
|
||||
console.log(`[smoke-provider-runtime] ${name}: native lazy Google adapter reached onPayload; generation stopped`);
|
||||
console.log(`[smoke-provider-runtime] ${name}: native lazy ${label} adapter reached onPayload; generation stopped`);
|
||||
}
|
||||
// Exercise the public lazy OAuth surface offline. toAuth evaluates the
|
||||
// real flow module and its imports but neither logs in nor refreshes.
|
||||
|
||||
Reference in New Issue
Block a user