feat: add app-owned Copilot and Grok subscription connections

This commit is contained in:
amosblomqvist
2026-10-25 00:27:52 +03:00
parent e8c81faad9
commit d6e317c6fe
49 changed files with 1709 additions and 248 deletions
+23
View File
@@ -103,6 +103,29 @@ async function probe(standalone) {
noNetwork();
console.log(`[smoke-provider-runtime] ${name}: native lazy Google 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.
for (const [name, factory] of [["github-copilot", "githubCopilotProvider"], ["xai", "xaiProvider"]]) {
const provider = (await import(new URL(`providers/${name}.js`, entry).href))[factory]();
const credential = { type: "oauth", access: name === "github-copilot" ? "tid=offline;proxy-ep=proxy.individual.githubcopilot.com;" : "offline-xai-oauth-not-a-token", refresh: "offline-refresh-not-a-token", expires: Date.now() + 3600000, availableModelIds: provider.getModels().map((model) => model.id) };
const auth = await provider.auth.oauth.toAuth(credential);
assert.equal(auth.apiKey, credential.access);
if (name === "github-copilot") assert.equal(auth.baseUrl, "https://api.individual.githubcopilot.com");
const seenApis = new Set();
for (const model of provider.getModels()) {
if (seenApis.has(model.api)) continue;
seenApis.add(model.api);
const sentinel = `LH_OFFLINE_SUBSCRIPTION_${randomUUID()}`;
let reached = 0;
const result = await provider.streamSimple({ ...model, ...(auth.baseUrl ? { baseUrl: auth.baseUrl } : {}) }, { messages: [{ role: "user", content: "Offline initialization only", timestamp: 0 }] }, {
...auth, maxRetries: 0, onPayload() { reached++; throw new Error(sentinel); },
}).result();
assert.equal(reached, 1, `${name}/${model.api}: ${result.errorMessage}`);
assert.equal(result.errorMessage, sentinel);
}
noNetwork();
console.log(`[smoke-provider-runtime] ${name}: public native OAuth and ${seenApis.size} transport APIs initialized offline`);
}
// Resolution/evaluation, not folder-exists checks. This also covers the
// previously missing transitive edge and permits legitimate nested deps.
for (const name of ["@google/genai", "google-auth-library", "gcp-metadata", "json-bigint", "bignumber.js"]) {