@eddyskywalker/dsh-chatgpt-subscription 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +3 -1
- package/lib/client.js +2 -2
- package/lib/client.js.map +1 -1
- package/lib/index.js +146 -70
- package/lib/types/client/locales.d.ts +3 -3
- package/lib/types/host/antigravity/adapter.d.ts +4 -1
- package/lib/types/host/antigravity/adapter.d.ts.map +1 -1
- package/lib/types/host/antigravity/client.d.ts +4 -4
- package/lib/types/host/antigravity/client.d.ts.map +1 -1
- package/lib/types/host/antigravity/mapper.d.ts.map +1 -1
- package/lib/types/host/antigravity/oauth.d.ts +6 -6
- package/lib/types/host/antigravity/oauth.d.ts.map +1 -1
- package/lib/types/host/antigravity/routes.d.ts +1 -1
- package/lib/types/host/antigravity/routes.d.ts.map +1 -1
- package/lib/types/host/antigravity/tool-schema.d.ts +2 -0
- package/lib/types/host/antigravity/tool-schema.d.ts.map +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -3080,7 +3080,7 @@ function field(value, name) {
|
|
|
3080
3080
|
const candidate = value[name];
|
|
3081
3081
|
return typeof candidate === "string" && candidate !== "" ? candidate : null;
|
|
3082
3082
|
}
|
|
3083
|
-
function isRecord$
|
|
3083
|
+
function isRecord$2(value) {
|
|
3084
3084
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3085
3085
|
}
|
|
3086
3086
|
function readPreferencesUpdate(value, current) {
|
|
@@ -3110,7 +3110,7 @@ function readPreferencesUpdate(value, current) {
|
|
|
3110
3110
|
patch.searchProvider = value.searchProvider;
|
|
3111
3111
|
}
|
|
3112
3112
|
if ("contextWindowOverrides" in value) {
|
|
3113
|
-
if (!isRecord$
|
|
3113
|
+
if (!isRecord$2(value.contextWindowOverrides)) throw new PreferenceError("contextWindowOverrides must be an object.");
|
|
3114
3114
|
const overrides = {};
|
|
3115
3115
|
for (const [model, contextWindow] of Object.entries(value.contextWindowOverrides)) {
|
|
3116
3116
|
if (!isConfigurableContextModelId(model)) throw new PreferenceError("This model does not support a configurable context window.");
|
|
@@ -4251,9 +4251,9 @@ function extractProjectId(data) {
|
|
|
4251
4251
|
}
|
|
4252
4252
|
}
|
|
4253
4253
|
}
|
|
4254
|
-
async function listCloudAICompanionProjects(token) {
|
|
4254
|
+
async function listCloudAICompanionProjects(token, fetchFn = fetch) {
|
|
4255
4255
|
for (const endpoint of endpointCandidates()) try {
|
|
4256
|
-
const response = await
|
|
4256
|
+
const response = await fetchFn(`${endpoint}/v1internal:listCloudAICompanionProjects`, {
|
|
4257
4257
|
method: "POST",
|
|
4258
4258
|
headers: antigravityHeaders(token),
|
|
4259
4259
|
body: JSON.stringify({}),
|
|
@@ -4263,7 +4263,7 @@ async function listCloudAICompanionProjects(token) {
|
|
|
4263
4263
|
return extractProjectId(await response.json());
|
|
4264
4264
|
} catch {}
|
|
4265
4265
|
}
|
|
4266
|
-
async function loadCodeAssist(token) {
|
|
4266
|
+
async function loadCodeAssist(token, fetchFn = fetch) {
|
|
4267
4267
|
const cached = projectCache.get(token);
|
|
4268
4268
|
if (cached && cached.expiresAt > Date.now()) return cached.projectId;
|
|
4269
4269
|
const body = JSON.stringify({ metadata: {
|
|
@@ -4272,7 +4272,7 @@ async function loadCodeAssist(token) {
|
|
|
4272
4272
|
pluginType: "GEMINI"
|
|
4273
4273
|
} });
|
|
4274
4274
|
for (const endpoint of endpointCandidates()) try {
|
|
4275
|
-
const response = await
|
|
4275
|
+
const response = await fetchFn(`${endpoint}/v1internal:loadCodeAssist`, {
|
|
4276
4276
|
method: "POST",
|
|
4277
4277
|
headers: antigravityHeaders(token),
|
|
4278
4278
|
body,
|
|
@@ -4287,7 +4287,7 @@ async function loadCodeAssist(token) {
|
|
|
4287
4287
|
});
|
|
4288
4288
|
return project;
|
|
4289
4289
|
}
|
|
4290
|
-
const listProj = await listCloudAICompanionProjects(token);
|
|
4290
|
+
const listProj = await listCloudAICompanionProjects(token, fetchFn);
|
|
4291
4291
|
if (listProj) {
|
|
4292
4292
|
projectCache.set(token, {
|
|
4293
4293
|
projectId: listProj,
|
|
@@ -4297,9 +4297,9 @@ async function loadCodeAssist(token) {
|
|
|
4297
4297
|
}
|
|
4298
4298
|
} catch {}
|
|
4299
4299
|
}
|
|
4300
|
-
async function postJson(path, token, body) {
|
|
4300
|
+
async function postJson(path, token, body, fetchFn = fetch) {
|
|
4301
4301
|
for (const endpoint of endpointCandidates()) try {
|
|
4302
|
-
const response = await
|
|
4302
|
+
const response = await fetchFn(`${endpoint}${path}`, {
|
|
4303
4303
|
method: "POST",
|
|
4304
4304
|
headers: jsonHeaders(token),
|
|
4305
4305
|
body: JSON.stringify(body)
|
|
@@ -4362,16 +4362,16 @@ function parseCatalogModels(data) {
|
|
|
4362
4362
|
}
|
|
4363
4363
|
return list;
|
|
4364
4364
|
}
|
|
4365
|
-
async function fetchAccountQuota(store = new FileCredentialStore(), modelSettings) {
|
|
4366
|
-
const { token, projectId: credentialProjectId } = await ensureApiKey(store);
|
|
4365
|
+
async function fetchAccountQuota(store = new FileCredentialStore(), modelSettings, fetchFn = fetch) {
|
|
4366
|
+
const { token, projectId: credentialProjectId } = await ensureApiKey(store, fetchFn);
|
|
4367
4367
|
const [assistResult, summaryResult] = await Promise.all([postJson("/v1internal:loadCodeAssist", token, { metadata: {
|
|
4368
4368
|
ideType: "ANTIGRAVITY",
|
|
4369
4369
|
platform: "PLATFORM_UNSPECIFIED",
|
|
4370
4370
|
pluginType: "GEMINI"
|
|
4371
|
-
} }).catch(() => null), postJson("/v1internal:retrieveUserQuotaSummary", token, {}).catch(() => null)]);
|
|
4371
|
+
} }, fetchFn).catch(() => null), postJson("/v1internal:retrieveUserQuotaSummary", token, {}, fetchFn).catch(() => null)]);
|
|
4372
4372
|
const discoveredProject = assistResult ? extractProjectId(assistResult.data) : void 0;
|
|
4373
4373
|
const projectId = credentialProjectId || discoveredProject || "antigravity-default";
|
|
4374
|
-
const modelsData = (await postJson("/v1internal:fetchAvailableModels", token, { project: projectId }).catch(() => null))?.data;
|
|
4374
|
+
const modelsData = (await postJson("/v1internal:fetchAvailableModels", token, { project: projectId }, fetchFn).catch(() => null))?.data;
|
|
4375
4375
|
const { groups, description } = summaryResult ? parseQuotaSummary(summaryResult.data) : { groups: [] };
|
|
4376
4376
|
const catalogModels = modelsData ? parseCatalogModels(modelsData) : [];
|
|
4377
4377
|
const assistData = assistResult?.data || {};
|
|
@@ -4469,9 +4469,9 @@ function openBrowser(url) {
|
|
|
4469
4469
|
});
|
|
4470
4470
|
} catch {}
|
|
4471
4471
|
}
|
|
4472
|
-
async function getUserEmail(token) {
|
|
4472
|
+
async function getUserEmail(token, fetchFn = fetch) {
|
|
4473
4473
|
try {
|
|
4474
|
-
const response = await
|
|
4474
|
+
const response = await fetchFn("https://www.googleapis.com/oauth2/v1/userinfo?alt=json", { headers: { Authorization: `Bearer ${token}` } });
|
|
4475
4475
|
if (!response.ok) return void 0;
|
|
4476
4476
|
const data = await response.json();
|
|
4477
4477
|
return typeof data.email === "string" ? data.email : void 0;
|
|
@@ -4550,8 +4550,8 @@ function startCallbackServer(expectedState) {
|
|
|
4550
4550
|
});
|
|
4551
4551
|
});
|
|
4552
4552
|
}
|
|
4553
|
-
async function exchangeOAuthCode(code, verifier, callbackUrl) {
|
|
4554
|
-
const tokenResponse = await
|
|
4553
|
+
async function exchangeOAuthCode(code, verifier, callbackUrl, fetchFn = fetch) {
|
|
4554
|
+
const tokenResponse = await fetchFn(TOKEN_URL, {
|
|
4555
4555
|
method: "POST",
|
|
4556
4556
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
4557
4557
|
body: new URLSearchParams$1({
|
|
@@ -4569,7 +4569,7 @@ async function exchangeOAuthCode(code, verifier, callbackUrl) {
|
|
|
4569
4569
|
const accessToken = typeof tokenData.access_token === "string" ? tokenData.access_token : "";
|
|
4570
4570
|
const expiresIn = typeof tokenData.expires_in === "number" ? tokenData.expires_in : 3600;
|
|
4571
4571
|
if (!refreshToken) throw new Error("No refresh token received. Re-run login and allow offline access.");
|
|
4572
|
-
const [email, discoveredProject] = await Promise.all([getUserEmail(accessToken), loadCodeAssist(accessToken).catch(() => void 0)]);
|
|
4572
|
+
const [email, discoveredProject] = await Promise.all([getUserEmail(accessToken, fetchFn), loadCodeAssist(accessToken, fetchFn).catch(() => void 0)]);
|
|
4573
4573
|
return {
|
|
4574
4574
|
refresh: refreshToken,
|
|
4575
4575
|
refresh_token: refreshToken,
|
|
@@ -4581,7 +4581,7 @@ async function exchangeOAuthCode(code, verifier, callbackUrl) {
|
|
|
4581
4581
|
email
|
|
4582
4582
|
};
|
|
4583
4583
|
}
|
|
4584
|
-
async function beginWebLogin(store) {
|
|
4584
|
+
async function beginWebLogin(store, fetchFn = fetch) {
|
|
4585
4585
|
if (webLoginFlow.status === "pending") return { ...webLoginFlow };
|
|
4586
4586
|
const { verifier, challenge } = generatePKCE();
|
|
4587
4587
|
const state = base64Url(randomBytes(32));
|
|
@@ -4607,7 +4607,7 @@ async function beginWebLogin(store) {
|
|
|
4607
4607
|
try {
|
|
4608
4608
|
const { code, state: returnedState } = await waitForCode();
|
|
4609
4609
|
if (returnedState !== state) throw new Error("OAuth state mismatch");
|
|
4610
|
-
const credentials = await exchangeOAuthCode(code, verifier, callbackUrl);
|
|
4610
|
+
const credentials = await exchangeOAuthCode(code, verifier, callbackUrl, fetchFn);
|
|
4611
4611
|
await store.write(credentials);
|
|
4612
4612
|
webLoginFlow.status = "complete";
|
|
4613
4613
|
webLoginFlow.email = credentials.email;
|
|
@@ -4625,10 +4625,10 @@ async function beginWebLogin(store) {
|
|
|
4625
4625
|
function getWebLoginStatus() {
|
|
4626
4626
|
return { ...webLoginFlow };
|
|
4627
4627
|
}
|
|
4628
|
-
async function refreshAntigravityToken(credentials) {
|
|
4628
|
+
async function refreshAntigravityToken(credentials, fetchFn = fetch) {
|
|
4629
4629
|
const refreshToken = credentials.refresh || credentials.refresh_token;
|
|
4630
4630
|
if (!refreshToken) throw new Error("Missing Antigravity refresh token.");
|
|
4631
|
-
const response = await
|
|
4631
|
+
const response = await fetchFn(TOKEN_URL, {
|
|
4632
4632
|
method: "POST",
|
|
4633
4633
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
4634
4634
|
body: new URLSearchParams$1({
|
|
@@ -4653,12 +4653,12 @@ async function refreshAntigravityToken(credentials) {
|
|
|
4653
4653
|
expires_at: Date.now() + expiresIn * 1e3 - 300 * 1e3
|
|
4654
4654
|
};
|
|
4655
4655
|
}
|
|
4656
|
-
async function ensureApiKey(store) {
|
|
4656
|
+
async function ensureApiKey(store, fetchFn = fetch) {
|
|
4657
4657
|
let credentials = await store.read();
|
|
4658
4658
|
if (!credentials) throw new Error("Not logged into Antigravity. Please log in from Settings > Antigravity.");
|
|
4659
4659
|
const expires = credentials.expires || credentials.expires_at || 0;
|
|
4660
4660
|
if (!(credentials.access || credentials.access_token) || expires <= Date.now() + 6e4) {
|
|
4661
|
-
credentials = await refreshAntigravityToken(credentials);
|
|
4661
|
+
credentials = await refreshAntigravityToken(credentials, fetchFn);
|
|
4662
4662
|
await store.write(credentials);
|
|
4663
4663
|
}
|
|
4664
4664
|
return {
|
|
@@ -4666,7 +4666,7 @@ async function ensureApiKey(store) {
|
|
|
4666
4666
|
projectId: credentials.projectId
|
|
4667
4667
|
};
|
|
4668
4668
|
}
|
|
4669
|
-
async function loginAndSave(store, signal, onUrl) {
|
|
4669
|
+
async function loginAndSave(store, signal, onUrl, fetchFn = fetch) {
|
|
4670
4670
|
const { verifier, challenge } = generatePKCE();
|
|
4671
4671
|
const state = base64Url(randomBytes(32));
|
|
4672
4672
|
const { server, waitForCode } = await startCallbackServer(state);
|
|
@@ -4688,7 +4688,7 @@ async function loginAndSave(store, signal, onUrl) {
|
|
|
4688
4688
|
if (signal?.aborted) throw new Error("OAuth login aborted");
|
|
4689
4689
|
const { code, state: returnedState } = await waitForCode();
|
|
4690
4690
|
if (returnedState !== state) throw new Error("OAuth state mismatch");
|
|
4691
|
-
const credentials = await exchangeOAuthCode(code, verifier, callbackUrl);
|
|
4691
|
+
const credentials = await exchangeOAuthCode(code, verifier, callbackUrl, fetchFn);
|
|
4692
4692
|
await store.write(credentials);
|
|
4693
4693
|
return credentials;
|
|
4694
4694
|
} finally {
|
|
@@ -4696,6 +4696,91 @@ async function loginAndSave(store, signal, onUrl) {
|
|
|
4696
4696
|
}
|
|
4697
4697
|
}
|
|
4698
4698
|
//#endregion
|
|
4699
|
+
//#region src/host/antigravity/tool-schema.ts
|
|
4700
|
+
const schemaFields = /* @__PURE__ */ new Set([
|
|
4701
|
+
"type",
|
|
4702
|
+
"format",
|
|
4703
|
+
"title",
|
|
4704
|
+
"description",
|
|
4705
|
+
"nullable",
|
|
4706
|
+
"enum",
|
|
4707
|
+
"default",
|
|
4708
|
+
"example",
|
|
4709
|
+
"minimum",
|
|
4710
|
+
"maximum",
|
|
4711
|
+
"minItems",
|
|
4712
|
+
"maxItems",
|
|
4713
|
+
"minLength",
|
|
4714
|
+
"maxLength",
|
|
4715
|
+
"minProperties",
|
|
4716
|
+
"maxProperties",
|
|
4717
|
+
"pattern",
|
|
4718
|
+
"required",
|
|
4719
|
+
"propertyOrdering"
|
|
4720
|
+
]);
|
|
4721
|
+
function isRecord$1(value) {
|
|
4722
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4723
|
+
}
|
|
4724
|
+
function mergeSchemas(left, right) {
|
|
4725
|
+
const merged = {
|
|
4726
|
+
...left,
|
|
4727
|
+
...right
|
|
4728
|
+
};
|
|
4729
|
+
if (isRecord$1(left.properties) && isRecord$1(right.properties)) merged.properties = {
|
|
4730
|
+
...left.properties,
|
|
4731
|
+
...right.properties
|
|
4732
|
+
};
|
|
4733
|
+
if (Array.isArray(left.required) && Array.isArray(right.required)) merged.required = [.../* @__PURE__ */ new Set([...left.required, ...right.required])];
|
|
4734
|
+
return merged;
|
|
4735
|
+
}
|
|
4736
|
+
function toAntigravityToolSchema(schema) {
|
|
4737
|
+
if (!isRecord$1(schema)) return schema;
|
|
4738
|
+
const root = schema;
|
|
4739
|
+
function resolveReference(reference) {
|
|
4740
|
+
let target = root;
|
|
4741
|
+
if (reference !== "#" && !reference.startsWith("#/")) throw new LlmError(`Antigravity tool schema requires a local reference: ${reference}`, "PROVIDER_ERROR");
|
|
4742
|
+
const path = reference === "#" ? [] : reference.slice(2).split("/");
|
|
4743
|
+
for (const segment of path) {
|
|
4744
|
+
const key = segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
4745
|
+
target = isRecord$1(target) && Object.hasOwn(target, key) ? target[key] : void 0;
|
|
4746
|
+
}
|
|
4747
|
+
if (!isRecord$1(target)) throw new LlmError(`Antigravity tool schema reference was not found: ${reference}`, "PROVIDER_ERROR");
|
|
4748
|
+
return target;
|
|
4749
|
+
}
|
|
4750
|
+
function convert(node, references) {
|
|
4751
|
+
if (!isRecord$1(node)) return {};
|
|
4752
|
+
let inherited = {};
|
|
4753
|
+
if (typeof node.$ref === "string") {
|
|
4754
|
+
if (references.has(node.$ref)) throw new LlmError(`Antigravity tool schema contains a recursive reference: ${node.$ref}`, "PROVIDER_ERROR");
|
|
4755
|
+
inherited = convert(resolveReference(node.$ref), /* @__PURE__ */ new Set([...references, node.$ref]));
|
|
4756
|
+
}
|
|
4757
|
+
if (Array.isArray(node.allOf)) for (const branch of node.allOf) inherited = mergeSchemas(inherited, convert(branch, references));
|
|
4758
|
+
const out = {};
|
|
4759
|
+
for (const [key, value] of Object.entries(node)) if (schemaFields.has(key)) out[key] = value;
|
|
4760
|
+
if (isRecord$1(node.properties)) out.properties = Object.fromEntries(Object.entries(node.properties).map(([name, child]) => [name, convert(child, references)]));
|
|
4761
|
+
if (isRecord$1(node.items)) out.items = convert(node.items, references);
|
|
4762
|
+
const alternatives = Array.isArray(node.anyOf) ? node.anyOf : node.oneOf;
|
|
4763
|
+
if (Array.isArray(alternatives)) out.anyOf = alternatives.map((child) => convert(child, references));
|
|
4764
|
+
if (Array.isArray(node.type)) {
|
|
4765
|
+
const types = node.type.filter((type) => typeof type === "string" && type !== "null");
|
|
4766
|
+
delete out.type;
|
|
4767
|
+
if (types.length === 1) out.type = types[0];
|
|
4768
|
+
else if (types.length > 1) out.anyOf = types.map((type) => ({ type }));
|
|
4769
|
+
if (node.type.includes("null")) out.nullable = true;
|
|
4770
|
+
}
|
|
4771
|
+
if (Object.hasOwn(node, "const") && !Object.hasOwn(node, "enum")) {
|
|
4772
|
+
if (node.const === null) out.nullable = true;
|
|
4773
|
+
else if ([
|
|
4774
|
+
"string",
|
|
4775
|
+
"number",
|
|
4776
|
+
"boolean"
|
|
4777
|
+
].includes(typeof node.const)) out.enum = [String(node.const)];
|
|
4778
|
+
} else if (Array.isArray(node.enum)) out.enum = node.enum.map((value) => String(value));
|
|
4779
|
+
return mergeSchemas(inherited, out);
|
|
4780
|
+
}
|
|
4781
|
+
return convert(root, /* @__PURE__ */ new Set());
|
|
4782
|
+
}
|
|
4783
|
+
//#endregion
|
|
4699
4784
|
//#region src/host/antigravity/mapper.ts
|
|
4700
4785
|
let toolCallCounter = 0;
|
|
4701
4786
|
function sanitizeText(text) {
|
|
@@ -4787,7 +4872,7 @@ function replayPart(part) {
|
|
|
4787
4872
|
if (typeof copy.text === "string") copy.text = sanitizeText(copy.text);
|
|
4788
4873
|
return copy;
|
|
4789
4874
|
}
|
|
4790
|
-
function assistantParts(message, model, runtimeModel,
|
|
4875
|
+
function assistantParts(message, model, runtimeModel, toolCalls) {
|
|
4791
4876
|
const parts = [];
|
|
4792
4877
|
if (!Array.isArray(message.content)) return parts;
|
|
4793
4878
|
for (let index = 0; index < message.content.length; index++) {
|
|
@@ -4815,14 +4900,18 @@ function assistantParts(message, model, runtimeModel, toolNames) {
|
|
|
4815
4900
|
} else if (block.type === "tool-call") {
|
|
4816
4901
|
const toolId = String(block.id || "");
|
|
4817
4902
|
const toolName = String(block.name || "");
|
|
4818
|
-
toolNames.set(toolId, toolName);
|
|
4819
4903
|
const originalCall = originalParts.find((part) => isRecord(part.functionCall));
|
|
4904
|
+
const wireId = asString((isRecord(originalCall?.functionCall) ? originalCall.functionCall : void 0)?.id) || (toolCallIdNeeded(model.id, runtimeModel) ? sanitizeToolCallId(toolId, toolName) : originalCall ? void 0 : toolId || void 0);
|
|
4905
|
+
toolCalls.set(toolId, {
|
|
4906
|
+
name: toolName,
|
|
4907
|
+
id: wireId
|
|
4908
|
+
});
|
|
4820
4909
|
const effectiveSignature = thoughtSignature(originalCall) || thoughtSignature(replay) || thoughtSignature(block) || (originalCall ? void 0 : "skip_thought_signature_validator");
|
|
4821
4910
|
parts.push({
|
|
4822
4911
|
functionCall: {
|
|
4823
4912
|
name: toolName,
|
|
4824
4913
|
args: parseArguments(block.arguments),
|
|
4825
|
-
...
|
|
4914
|
+
...wireId ? { id: wireId } : {}
|
|
4826
4915
|
},
|
|
4827
4916
|
...effectiveSignature ? { thoughtSignature: effectiveSignature } : {}
|
|
4828
4917
|
});
|
|
@@ -4831,14 +4920,16 @@ function assistantParts(message, model, runtimeModel, toolNames) {
|
|
|
4831
4920
|
}
|
|
4832
4921
|
return parts;
|
|
4833
4922
|
}
|
|
4834
|
-
function pushToolResult(contents, result,
|
|
4923
|
+
function pushToolResult(contents, result, toolCalls, model, runtimeModel) {
|
|
4835
4924
|
const toolCallId = String(result.toolCallId || "");
|
|
4836
|
-
const
|
|
4925
|
+
const call = toolCalls.get(toolCallId);
|
|
4926
|
+
const toolName = call?.name || "unknown";
|
|
4927
|
+
const wireId = call?.id || (toolCallIdNeeded(model.id, runtimeModel) ? sanitizeToolCallId(toolCallId, toolName) : void 0);
|
|
4837
4928
|
const responseText = toolResultText(result.content) || (result.isError ? "Tool failed" : "");
|
|
4838
4929
|
const part = { functionResponse: {
|
|
4839
4930
|
name: toolName,
|
|
4840
4931
|
response: result.isError ? { error: responseText } : { output: responseText },
|
|
4841
|
-
...
|
|
4932
|
+
...wireId ? { id: wireId } : {}
|
|
4842
4933
|
} };
|
|
4843
4934
|
const last = contents[contents.length - 1];
|
|
4844
4935
|
if (last?.role === GEMINI_ROLE.user && last.parts.some((entry) => "functionResponse" in entry)) last.parts.push(part);
|
|
@@ -4849,11 +4940,11 @@ function pushToolResult(contents, result, toolNames, model, runtimeModel) {
|
|
|
4849
4940
|
}
|
|
4850
4941
|
function convertMessages(options, model, runtimeModel) {
|
|
4851
4942
|
const contents = [];
|
|
4852
|
-
const
|
|
4943
|
+
const toolCalls = /* @__PURE__ */ new Map();
|
|
4853
4944
|
for (const message of options.messages) {
|
|
4854
4945
|
const role = message.role || (message.source?.kind === "model" ? "assistant" : "user");
|
|
4855
4946
|
if (role === "assistant" || message.source?.kind === "model") {
|
|
4856
|
-
const parts = assistantParts(message, model, runtimeModel,
|
|
4947
|
+
const parts = assistantParts(message, model, runtimeModel, toolCalls);
|
|
4857
4948
|
if (parts.length) contents.push({
|
|
4858
4949
|
role: GEMINI_ROLE.model,
|
|
4859
4950
|
parts
|
|
@@ -4873,25 +4964,12 @@ function convertMessages(options, model, runtimeModel) {
|
|
|
4873
4964
|
role: GEMINI_ROLE.user,
|
|
4874
4965
|
parts: userParts
|
|
4875
4966
|
});
|
|
4876
|
-
for (const b of content) if (isRecord(b) && b.type === "tool-result") pushToolResult(contents, b,
|
|
4967
|
+
for (const b of content) if (isRecord(b) && b.type === "tool-result") pushToolResult(contents, b, toolCalls, model, runtimeModel);
|
|
4877
4968
|
}
|
|
4878
4969
|
return contents;
|
|
4879
4970
|
}
|
|
4880
4971
|
function stripMetaSchema(schema) {
|
|
4881
|
-
|
|
4882
|
-
const omit = /* @__PURE__ */ new Set([
|
|
4883
|
-
"$schema",
|
|
4884
|
-
"$id",
|
|
4885
|
-
"$anchor",
|
|
4886
|
-
"$dynamicAnchor",
|
|
4887
|
-
"$vocabulary",
|
|
4888
|
-
"$comment",
|
|
4889
|
-
"$defs",
|
|
4890
|
-
"definitions"
|
|
4891
|
-
]);
|
|
4892
|
-
const out = {};
|
|
4893
|
-
for (const [k, v] of Object.entries(schema)) if (!omit.has(k)) out[k] = stripMetaSchema(v);
|
|
4894
|
-
return out;
|
|
4972
|
+
return toAntigravityToolSchema(schema);
|
|
4895
4973
|
}
|
|
4896
4974
|
function convertTools(tools) {
|
|
4897
4975
|
if (!tools || tools.length === 0) return void 0;
|
|
@@ -4934,10 +5012,9 @@ function buildRequest(options, model, projectId, runtimeModel, effort) {
|
|
|
4934
5012
|
const isGeminiAgent = runtimeModel === "gemini-pro-agent" || runtimeModel === "gemini-3-flash-agent";
|
|
4935
5013
|
if (isTiered) {
|
|
4936
5014
|
const selected = (effort || "medium").toLowerCase();
|
|
4937
|
-
const isOff = selected === "off" || selected === "none";
|
|
4938
5015
|
generationConfig.thinkingConfig = {
|
|
4939
|
-
thinkingLevel:
|
|
4940
|
-
includeThoughts: !
|
|
5016
|
+
thinkingLevel: selected === "high" || selected === "xhigh" ? "HIGH" : selected === "medium" ? "MEDIUM" : "LOW",
|
|
5017
|
+
includeThoughts: !(selected === "off" || selected === "none")
|
|
4941
5018
|
};
|
|
4942
5019
|
} else if (isSuffixed || isGemini3 || isGeminiAgent) {
|
|
4943
5020
|
const selected = (effort || "medium").toLowerCase();
|
|
@@ -5102,7 +5179,7 @@ function processStreamLine(line, state) {
|
|
|
5102
5179
|
out.push(...closeCurrentBlock(state));
|
|
5103
5180
|
const fc = part.functionCall;
|
|
5104
5181
|
const toolName = asString(fc.name) || "";
|
|
5105
|
-
const toolId =
|
|
5182
|
+
const toolId = asString(fc.id) || sanitizeToolCallId("", toolName);
|
|
5106
5183
|
const argsText = JSON.stringify(isRecord(fc.args) ? fc.args : {});
|
|
5107
5184
|
const index = state.blocks.length;
|
|
5108
5185
|
const block = {
|
|
@@ -5173,11 +5250,13 @@ var AntigravityAdapter = class extends LlmAdapter {
|
|
|
5173
5250
|
store;
|
|
5174
5251
|
modelSettings;
|
|
5175
5252
|
preferences;
|
|
5176
|
-
|
|
5253
|
+
options;
|
|
5254
|
+
constructor(store = new FileCredentialStore(), modelSettings = new FileModelSettingsStore(), preferences, options = {}) {
|
|
5177
5255
|
super();
|
|
5178
5256
|
this.store = store;
|
|
5179
5257
|
this.modelSettings = modelSettings;
|
|
5180
5258
|
this.preferences = preferences;
|
|
5259
|
+
this.options = options;
|
|
5181
5260
|
}
|
|
5182
5261
|
providerInfo(provider) {
|
|
5183
5262
|
return {
|
|
@@ -5257,7 +5336,8 @@ var AntigravityAdapter = class extends LlmAdapter {
|
|
|
5257
5336
|
yield* wrapStreamWithWatchdog((watchdogSignal) => this.requestStream(effectiveOptions, model, watchdogSignal), options.signal, STREAM_IDLE_TIMEOUT_MS, STREAM_IDLE_TIMEOUT_CODE, "Antigravity");
|
|
5258
5337
|
}
|
|
5259
5338
|
async *requestStream(options, model, signal) {
|
|
5260
|
-
const
|
|
5339
|
+
const fetchFn = this.options.fetchFn ?? fetch;
|
|
5340
|
+
const { token, projectId: defaultProj } = await ensureApiKey(this.store, fetchFn);
|
|
5261
5341
|
const projectId = defaultProj || "antigravity-default";
|
|
5262
5342
|
const effort = String(options.reasoningEffort || "medium").toLowerCase();
|
|
5263
5343
|
const routing = ROUTING[model.id];
|
|
@@ -5276,18 +5356,18 @@ var AntigravityAdapter = class extends LlmAdapter {
|
|
|
5276
5356
|
...model.id.startsWith("claude-") ? { "anthropic-beta": "interleaved-thinking-2025-05-14" } : {}
|
|
5277
5357
|
};
|
|
5278
5358
|
for (const endpoint of endpointCandidates()) try {
|
|
5279
|
-
response = await
|
|
5359
|
+
response = await fetchFn(`${endpoint}/v1internal:streamGenerateContent?alt=sse`, {
|
|
5280
5360
|
method: "POST",
|
|
5281
5361
|
headers,
|
|
5282
5362
|
body,
|
|
5283
5363
|
signal
|
|
5284
5364
|
});
|
|
5285
|
-
if (response.ok) break;
|
|
5365
|
+
if (response.ok || response.status === 400) break;
|
|
5286
5366
|
if (response.status === 404) break;
|
|
5287
5367
|
} catch (err) {
|
|
5288
5368
|
if (signal.aborted) throw new LlmError("Antigravity request aborted", "ABORTED", { cause: err });
|
|
5289
5369
|
}
|
|
5290
|
-
if (response && response.ok) break;
|
|
5370
|
+
if (response && (response.ok || response.status === 400)) break;
|
|
5291
5371
|
}
|
|
5292
5372
|
if (!response || !response.ok) {
|
|
5293
5373
|
const status = response?.status ?? 500;
|
|
@@ -5382,7 +5462,7 @@ async function getAntigravityWebStatus(store, modelSettings, preferences) {
|
|
|
5382
5462
|
defaultReasoningEffort: settings.defaultReasoningEffort || null
|
|
5383
5463
|
};
|
|
5384
5464
|
}
|
|
5385
|
-
function registerAntigravityRoutes(ctx, store, modelSettings, preferences) {
|
|
5465
|
+
function registerAntigravityRoutes(ctx, store, modelSettings, preferences, fetchFn = fetch) {
|
|
5386
5466
|
return ctx.webServer.register({
|
|
5387
5467
|
kind: "prefix",
|
|
5388
5468
|
path: "/antigravity/api",
|
|
@@ -5400,7 +5480,7 @@ function registerAntigravityRoutes(ctx, store, modelSettings, preferences) {
|
|
|
5400
5480
|
if (request.method !== "POST") return sendMethodNotAllowed(response);
|
|
5401
5481
|
return sendJson(response, 200, {
|
|
5402
5482
|
ok: true,
|
|
5403
|
-
value: await beginWebLogin(store)
|
|
5483
|
+
value: await beginWebLogin(store, fetchFn)
|
|
5404
5484
|
});
|
|
5405
5485
|
}
|
|
5406
5486
|
if (path === "login/status") {
|
|
@@ -5412,7 +5492,7 @@ function registerAntigravityRoutes(ctx, store, modelSettings, preferences) {
|
|
|
5412
5492
|
}
|
|
5413
5493
|
if (path === "quota") {
|
|
5414
5494
|
if (request.method !== "GET" && request.method !== "POST") return sendMethodNotAllowed(response);
|
|
5415
|
-
const quota = await fetchAccountQuota(store, modelSettings);
|
|
5495
|
+
const quota = await fetchAccountQuota(store, modelSettings, fetchFn);
|
|
5416
5496
|
return sendJson(response, 200, {
|
|
5417
5497
|
ok: true,
|
|
5418
5498
|
value: {
|
|
@@ -5485,21 +5565,15 @@ function apply(ctx) {
|
|
|
5485
5565
|
const antigravityStore = new FileCredentialStore();
|
|
5486
5566
|
const antigravityModelSettings = new FileModelSettingsStore();
|
|
5487
5567
|
const antigravityPreferences = registerAntigravityPreferenceStore(ctx.settings, antigravityModelSettings);
|
|
5488
|
-
const antigravityAdapter = new AntigravityAdapter(antigravityStore, antigravityModelSettings, antigravityPreferences);
|
|
5489
|
-
ctx.effect(() => {
|
|
5490
|
-
const disposeAntigravityAdapter = ctx.llm.registerAdapter([PROVIDER_ID], antigravityAdapter);
|
|
5491
|
-
const disposeAntigravityRoutes = registerAntigravityRoutes(ctx, antigravityStore, antigravityModelSettings, antigravityPreferences);
|
|
5492
|
-
return () => {
|
|
5493
|
-
disposeAntigravityRoutes();
|
|
5494
|
-
disposeAntigravityAdapter();
|
|
5495
|
-
};
|
|
5496
|
-
}, "dsh-antigravity: adapter, routes, and lifecycle");
|
|
5497
5568
|
ctx.effect(() => {
|
|
5498
5569
|
const proxyManager = new ProxyManager({
|
|
5499
5570
|
getPreferences: () => preferences.status(),
|
|
5500
5571
|
logger: ctx.logger
|
|
5501
5572
|
});
|
|
5502
5573
|
const proxyFetch = proxyManager.createFetch();
|
|
5574
|
+
const antigravityAdapter = new AntigravityAdapter(antigravityStore, antigravityModelSettings, antigravityPreferences, { fetchFn: proxyFetch });
|
|
5575
|
+
const disposeAntigravityAdapter = ctx.llm.registerAdapter([PROVIDER_ID], antigravityAdapter);
|
|
5576
|
+
const disposeAntigravityRoutes = registerAntigravityRoutes(ctx, antigravityStore, antigravityModelSettings, antigravityPreferences, proxyFetch);
|
|
5503
5577
|
const oauth = new OAuthService(store, {
|
|
5504
5578
|
fetchFn: proxyFetch,
|
|
5505
5579
|
logger: ctx.logger
|
|
@@ -5543,6 +5617,8 @@ function apply(ctx) {
|
|
|
5543
5617
|
disposeImageTool();
|
|
5544
5618
|
disposeAdapter();
|
|
5545
5619
|
disposeRoutes();
|
|
5620
|
+
disposeAntigravityRoutes();
|
|
5621
|
+
disposeAntigravityAdapter();
|
|
5546
5622
|
oauth.dispose();
|
|
5547
5623
|
proxyManager.dispose();
|
|
5548
5624
|
};
|
|
@@ -40,7 +40,7 @@ export declare const zh: {
|
|
|
40
40
|
readonly modelsHint: "勾选后模型才会显示在对话页的模型选择列表中;至少保留一个。";
|
|
41
41
|
readonly proxySettings: "网络代理";
|
|
42
42
|
readonly proxyMode: "代理模式";
|
|
43
|
-
readonly proxyModeHint: "
|
|
43
|
+
readonly proxyModeHint: "GPT 与 Antigravity(Gemini)共用此代理设置;支持自动读取系统代理,修改后对后续请求生效。";
|
|
44
44
|
readonly proxyModeAuto: "系统代理(自动检测)";
|
|
45
45
|
readonly proxyModeCustom: "自定义代理";
|
|
46
46
|
readonly proxyModeDirect: "直连(禁用代理)";
|
|
@@ -174,7 +174,7 @@ export declare const dictionaries: {
|
|
|
174
174
|
readonly modelsHint: "勾选后模型才会显示在对话页的模型选择列表中;至少保留一个。";
|
|
175
175
|
readonly proxySettings: "网络代理";
|
|
176
176
|
readonly proxyMode: "代理模式";
|
|
177
|
-
readonly proxyModeHint: "
|
|
177
|
+
readonly proxyModeHint: "GPT 与 Antigravity(Gemini)共用此代理设置;支持自动读取系统代理,修改后对后续请求生效。";
|
|
178
178
|
readonly proxyModeAuto: "系统代理(自动检测)";
|
|
179
179
|
readonly proxyModeCustom: "自定义代理";
|
|
180
180
|
readonly proxyModeDirect: "直连(禁用代理)";
|
|
@@ -264,6 +264,6 @@ export declare const dictionaries: {
|
|
|
264
264
|
readonly retry: "重试";
|
|
265
265
|
readonly unknown: "未知";
|
|
266
266
|
};
|
|
267
|
-
en: Record<"
|
|
267
|
+
en: Record<"tokens" | "title" | "intro" | "account" | "signedOut" | "signedIn" | "plan" | "accountId" | "expires" | "storage" | "storageWindows" | "storageMacKeychain" | "storageLinuxFile" | "storageMemory" | "storageUnavailable" | "securityWindows" | "securityMacKeychain" | "securityLinuxFile" | "securityMemory" | "securityUnavailable" | "signIn" | "signInAgain" | "cancel" | "signOut" | "refreshToken" | "pending" | "popupBlocked" | "continueLogin" | "loading" | "connection" | "provider" | "connectionState" | "connected" | "untested" | "testConnection" | "testing" | "latency" | "models" | "modelsHint" | "proxySettings" | "proxyMode" | "proxyModeHint" | "proxyModeAuto" | "proxyModeCustom" | "proxyModeDirect" | "customProxyUrl" | "customProxyUrlHint" | "customProxyUrlPlaceholder" | "saveProxyUrl" | "proxyDetected" | "proxyDetectedEffective" | "proxyNoneDetected" | "proxyDirectHint" | "enhancements" | "fastMode" | "fastModeHint" | "outputVerbosity" | "outputVerbosityHint" | "verbosityLow" | "verbosityMedium" | "verbosityHigh" | "reasoningSummary" | "reasoningSummaryHint" | "summaryAuto" | "summaryConcise" | "summaryDetailed" | "summaryNone" | "searchProvider" | "searchProviderHint" | "searchProviderDsh" | "searchProviderCodex" | "providerDefault" | "subagentEnhancements" | "subagentContextWindow" | "subagentContextWindowHint" | "subagentMaxDepth" | "subagentMaxDepthHint" | "subagentDisabled" | "levels" | "contextWindows" | "contextWindowsHint" | "contextWindow" | "contextWindowInvalid" | "saveContextWindow" | "save" | "quickQuota" | "quickQuotaHint" | "quota" | "quotaIntro" | "refreshQuota" | "refreshing" | "noQuota" | "quotaSignedOut" | "stale" | "updated" | "primary" | "secondary" | "limitWindow" | "used" | "remaining" | "available" | "unavailable" | "unlimited" | "credits" | "monthlySpend" | "resetCredits" | "resetCreditExpires" | "useResetCredit" | "usingResetCredit" | "useResetCreditConfirm" | "resetCreditUsed" | "spendControlReached" | "limit" | "exhausted" | "resets" | "quickQuotaLabel" | "quickQuotaLoading" | "imageToolRunning" | "imageToolDone" | "imageToolFailed" | "image" | "openImage" | "openNamedImage" | "imageLoading" | "imageLoadFailed" | "imagePreviewClose" | "imagePreviewOpenOriginal" | "retry" | "unknown", string>;
|
|
268
268
|
};
|
|
269
269
|
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -4,7 +4,10 @@ export declare class AntigravityAdapter extends LlmAdapter {
|
|
|
4
4
|
private readonly store;
|
|
5
5
|
private readonly modelSettings;
|
|
6
6
|
private readonly preferences?;
|
|
7
|
-
|
|
7
|
+
private readonly options;
|
|
8
|
+
constructor(store?: FileCredentialStore, modelSettings?: FileModelSettingsStore, preferences?: AntigravityPreferenceStore | undefined, options?: {
|
|
9
|
+
fetchFn?: typeof fetch;
|
|
10
|
+
});
|
|
8
11
|
providerInfo(provider: string): LlmProviderInfo;
|
|
9
12
|
listModels(provider?: string): Promise<readonly LlmModelInfo[]>;
|
|
10
13
|
resolveModel(provider: string, modelId: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/antigravity/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAGV,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAA;AAU7B,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,KAAK,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAM/G,qBAAa,kBAAmB,SAAQ,UAAU;IAE9C,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/antigravity/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAGV,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAA;AAU7B,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,KAAK,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAM/G,qBAAa,kBAAmB,SAAQ,UAAU;IAE9C,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAHP,KAAK,sBAA4B,EACjC,aAAa,yBAA+B,EAC5C,WAAW,CAAC,EAAE,0BAA0B,YAAA,EACxC,OAAO,GAAE;QAAE,OAAO,CAAC,EAAE,OAAO,KAAK,CAAA;KAAO;IAK3D,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe;IAIzC,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC;IAkB/D,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAqCpG,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO/F,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC;YAwBpD,aAAa;CAwG7B"}
|
|
@@ -4,9 +4,9 @@ export declare function defaultUserAgent(): string;
|
|
|
4
4
|
export declare function antigravityHeaders(token: string): Record<string, string>;
|
|
5
5
|
export declare function jsonHeaders(token: string): Record<string, string>;
|
|
6
6
|
export declare function endpointCandidates(): string[];
|
|
7
|
-
export declare function listCloudAICompanionProjects(token: string): Promise<string | undefined>;
|
|
8
|
-
export declare function loadCodeAssist(token: string): Promise<string | undefined>;
|
|
9
|
-
export declare function postJson(path: string, token: string, body: Record<string, unknown
|
|
7
|
+
export declare function listCloudAICompanionProjects(token: string, fetchFn?: typeof fetch): Promise<string | undefined>;
|
|
8
|
+
export declare function loadCodeAssist(token: string, fetchFn?: typeof fetch): Promise<string | undefined>;
|
|
9
|
+
export declare function postJson(path: string, token: string, body: Record<string, unknown>, fetchFn?: typeof fetch): Promise<{
|
|
10
10
|
endpoint: string;
|
|
11
11
|
status: number;
|
|
12
12
|
data: unknown;
|
|
@@ -16,6 +16,6 @@ export declare function parseQuotaSummary(data: unknown): {
|
|
|
16
16
|
description?: string;
|
|
17
17
|
};
|
|
18
18
|
export declare function parseCatalogModels(data: unknown): AntigravityCatalogModel[];
|
|
19
|
-
export declare function fetchAccountQuota(store?: FileCredentialStore, modelSettings?: FileModelSettingsStore): Promise<AntigravityAccountQuota>;
|
|
19
|
+
export declare function fetchAccountQuota(store?: FileCredentialStore, modelSettings?: FileModelSettingsStore, fetchFn?: typeof fetch): Promise<AntigravityAccountQuota>;
|
|
20
20
|
export declare function getCachedQuota(): AntigravityAccountQuota | undefined;
|
|
21
21
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/host/antigravity/client.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EACV,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,uCAAuC,CAAA;AAO9C,wBAAgB,gBAAgB,IAAI,MAAM,CAIzC;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAaxE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKjE;AAED,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAI7C;AA+BD,wBAAsB,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/host/antigravity/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B,CACrC,KAAK,sBAA4B,EACjC,aAAa,CAAC,EAAE,sBAAsB,EACtC,OAAO,GAAE,OAAO,KAAa,GAC5B,OAAO,CAAC,uBAAuB,CAAC,CAoDlC;AAED,wBAAgB,cAAc,IAAI,uBAAuB,GAAG,SAAS,CAEpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/host/antigravity/mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAEjB,KAAK,eAAe,EAEpB,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAOL,KAAK,mBAAmB,EACzB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/host/antigravity/mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAEjB,KAAK,eAAe,EAEpB,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAOL,KAAK,mBAAmB,EACzB,MAAM,YAAY,CAAA;AAyBnB,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAI3E;AA+LD,wBAAgB,eAAe,CAC7B,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,mBAAmB,EAC1B,YAAY,EAAE,MAAM,GACnB,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,CAAC,CA2BhE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAExD;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,GAC9B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAQ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openBrowser(url: string): void;
|
|
21
|
-
export declare function getUserEmail(token: string): Promise<string | undefined>;
|
|
21
|
+
export declare function getUserEmail(token: string, fetchFn?: typeof fetch): Promise<string | undefined>;
|
|
22
22
|
export declare function startCallbackServer(expectedState: string): Promise<{
|
|
23
23
|
server: Server;
|
|
24
24
|
waitForCode: () => Promise<{
|
|
@@ -26,13 +26,13 @@ export declare function startCallbackServer(expectedState: string): Promise<{
|
|
|
26
26
|
state: string;
|
|
27
27
|
}>;
|
|
28
28
|
}>;
|
|
29
|
-
export declare function exchangeOAuthCode(code: string, verifier: string, callbackUrl: string): Promise<AntigravityCredentials>;
|
|
30
|
-
export declare function beginWebLogin(store: FileCredentialStore): Promise<WebLoginFlowState>;
|
|
29
|
+
export declare function exchangeOAuthCode(code: string, verifier: string, callbackUrl: string, fetchFn?: typeof fetch): Promise<AntigravityCredentials>;
|
|
30
|
+
export declare function beginWebLogin(store: FileCredentialStore, fetchFn?: typeof fetch): Promise<WebLoginFlowState>;
|
|
31
31
|
export declare function getWebLoginStatus(): WebLoginFlowState;
|
|
32
|
-
export declare function refreshAntigravityToken(credentials: AntigravityCredentials): Promise<AntigravityCredentials>;
|
|
33
|
-
export declare function ensureApiKey(store: FileCredentialStore): Promise<{
|
|
32
|
+
export declare function refreshAntigravityToken(credentials: AntigravityCredentials, fetchFn?: typeof fetch): Promise<AntigravityCredentials>;
|
|
33
|
+
export declare function ensureApiKey(store: FileCredentialStore, fetchFn?: typeof fetch): Promise<{
|
|
34
34
|
token: string;
|
|
35
35
|
projectId?: string;
|
|
36
36
|
}>;
|
|
37
|
-
export declare function loginAndSave(store: FileCredentialStore, signal?: AbortSignal, onUrl?: (url: string) => void): Promise<AntigravityCredentials>;
|
|
37
|
+
export declare function loginAndSave(store: FileCredentialStore, signal?: AbortSignal, onUrl?: (url: string) => void, fetchFn?: typeof fetch): Promise<AntigravityCredentials>;
|
|
38
38
|
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../src/host/antigravity/oauth.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAA;AAYrD,OAAO,EAAE,mBAAmB,EAAE,KAAK,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAGnF,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,CAAA;IACjD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AASD,wBAAgB,YAAY,IAAI,MAAM,CAMrC;AAED,wBAAgB,mBAAmB,CAAC,GAAG,qBAAkC,GAAG,MAAM,CAIjF;AAED,wBAAgB,WAAW,IAAI,MAAM,CAKpC;AAED,wBAAgB,QAAQ,IAAI,MAAM,CAEjC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAMD,wBAAgB,YAAY,IAAI;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAItE;AAeD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAY7C;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../src/host/antigravity/oauth.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAA;AAYrD,OAAO,EAAE,mBAAmB,EAAE,KAAK,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAGnF,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,GAAG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;AAED,wBAAgB,iBAAiB,IAAI,iBAAiB,CAErD;AAED,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,sBAAsB,EACnC,OAAO,GAAE,OAAO,KAAa,GAC5B,OAAO,CAAC,sBAAsB,CAAC,CAiCjC;AAED,wBAAsB,YAAY,CAChC,KAAK,EAAE,mBAAmB,EAC1B,OAAO,GAAE,OAAO,KAAa,GAC5B,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBhD;AAED,wBAAsB,YAAY,CAChC,KAAK,EAAE,mBAAmB,EAC1B,MAAM,CAAC,EAAE,WAAW,EACpB,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,EAC7B,OAAO,GAAE,OAAO,KAAa,GAC5B,OAAO,CAAC,sBAAsB,CAAC,CAgCjC"}
|
|
@@ -2,5 +2,5 @@ import type { Context } from '@deepseek-ai/cordis';
|
|
|
2
2
|
import { FileCredentialStore, FileModelSettingsStore, type AntigravityPreferenceStore } from './token-store.ts';
|
|
3
3
|
import type { AntigravityWebStatus } from '../../shared/antigravity-contracts.ts';
|
|
4
4
|
export declare function getAntigravityWebStatus(store: FileCredentialStore, modelSettings: FileModelSettingsStore, preferences?: AntigravityPreferenceStore): Promise<AntigravityWebStatus>;
|
|
5
|
-
export declare function registerAntigravityRoutes(ctx: Context, store: FileCredentialStore, modelSettings: FileModelSettingsStore, preferences?: AntigravityPreferenceStore): () => void;
|
|
5
|
+
export declare function registerAntigravityRoutes(ctx: Context, store: FileCredentialStore, modelSettings: FileModelSettingsStore, preferences?: AntigravityPreferenceStore, fetchFn?: typeof fetch): () => void;
|
|
6
6
|
//# sourceMappingURL=routes.d.ts.map
|