@anthonyhaussman/opencode-agy-auth 1.2.17-alpha.0 → 1.2.17

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/dist/index.js CHANGED
@@ -579,12 +579,6 @@ async function resolveQuotaResetDelay(accessToken, projectId, model, userAgentMo
579
579
  return null;
580
580
  }
581
581
  }
582
- var retryInternals = {
583
- parseRetryDelayValue,
584
- parseRetryDelayFromMessage,
585
- findResetTimeForModel,
586
- resolveQuotaResetDelay
587
- };
588
582
 
589
583
  // src/sdk/retry/helpers.ts
590
584
  var DEFAULT_MAX_ATTEMPTS = 3;
@@ -1581,11 +1575,7 @@ function createOAuthAuthorizeMethod(options) {
1581
1575
  const isHeadless = !!(process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY || process.env.OPENCODE_HEADLESS);
1582
1576
  const authorization = await authorizeAgy();
1583
1577
  if (!isHeadless) {
1584
- if (options?.openBrowser) {
1585
- options.openBrowser(authorization.url);
1586
- } else {
1587
- openBrowserUrl(authorization.url);
1588
- }
1578
+ openBrowserUrl(authorization.url);
1589
1579
  }
1590
1580
  return {
1591
1581
  url: authorization.url,
@@ -1639,23 +1629,16 @@ function parseOAuthCallbackInput(input) {
1639
1629
  }
1640
1630
  return { code: trimmed };
1641
1631
  }
1642
- function defaultOpenBrowserLauncher(command, args) {
1643
- const child = spawn(command, args, {
1644
- stdio: "ignore",
1645
- detached: true
1646
- });
1647
- child.unref?.();
1648
- }
1649
- var openBrowserLauncher = defaultOpenBrowserLauncher;
1650
1632
  function openBrowserUrl(url2) {
1651
- if ((process.env.NODE_ENV === "test" || process.env.VITEST) && openBrowserLauncher === defaultOpenBrowserLauncher) {
1652
- return;
1653
- }
1654
1633
  try {
1655
1634
  const platform2 = process.platform;
1656
1635
  const command = platform2 === "darwin" ? "open" : platform2 === "win32" ? "rundll32" : "xdg-open";
1657
1636
  const args = platform2 === "win32" ? ["url.dll,FileProtocolHandler", url2] : [url2];
1658
- openBrowserLauncher(command, args);
1637
+ const child = spawn(command, args, {
1638
+ stdio: "ignore",
1639
+ detached: true
1640
+ });
1641
+ child.unref?.();
1659
1642
  } catch {
1660
1643
  }
1661
1644
  }
@@ -15337,12 +15320,6 @@ function formatRelativeResetTime(resetTime) {
15337
15320
 
15338
15321
  // src/plugin/quota.ts
15339
15322
  var AGY_QUOTA_TOOL_NAME = "agy_quota";
15340
- var AGY_V2_QUOTA_COMMAND = "agy-quota";
15341
- var AGY_V2_QUOTA_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota usage for the current authenticated account.
15342
-
15343
- Immediately call \`${AGY_QUOTA_TOOL_NAME}\` with no arguments and return its output verbatim.
15344
- Do not call other tools.
15345
- `;
15346
15323
  function createAgyQuotaTool({
15347
15324
  client,
15348
15325
  getAuthResolver,
@@ -15582,12 +15559,6 @@ function splitModelVariant(modelId) {
15582
15559
 
15583
15560
  // src/plugin/quota-summary.ts
15584
15561
  var AGY_QUOTA_SUMMARY_TOOL_NAME = "agy_quota_summary";
15585
- var AGY_V2_QUOTA_SUMMARY_COMMAND = "agy-quota-summary";
15586
- var AGY_V2_QUOTA_SUMMARY_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota summary (weekly and 5-hour limits by model group) for the current authenticated account.
15587
-
15588
- Immediately call \`${AGY_QUOTA_SUMMARY_TOOL_NAME}\` with no arguments and return its output verbatim.
15589
- Do not call other tools.
15590
- `;
15591
15562
  function createAgyQuotaSummaryTool({
15592
15563
  client,
15593
15564
  getAuthResolver,
@@ -19963,14 +19934,9 @@ function normalizeToolSchemaTypes(tools, toolMapper) {
19963
19934
  fn.name = toolMapper ? toolMapper.toGemini(fn.name) : sanitizeToolName(fn.name);
19964
19935
  }
19965
19936
  if (fn) {
19966
- if (!fn.parameters) {
19967
- fn.parameters = fn.parameters_json_schema ?? fn.parametersJsonSchema;
19968
- }
19969
19937
  if (!fn.parameters) {
19970
19938
  fn.parameters = { type: "OBJECT", properties: {} };
19971
19939
  }
19972
- delete fn.parameters_json_schema;
19973
- delete fn.parametersJsonSchema;
19974
19940
  sanitizeSchema(fn.parameters);
19975
19941
  }
19976
19942
  }
@@ -20395,81 +20361,22 @@ var ChatLoggerImpl = class {
20395
20361
  }
20396
20362
  };
20397
20363
 
20398
- // src/plugin/headers.ts
20399
- function getSafeHeader(headers, key) {
20400
- if (!headers) {
20401
- return void 0;
20402
- }
20403
- const targetKey = key.toLowerCase();
20404
- if (typeof headers.get === "function") {
20405
- try {
20406
- return headers.get(targetKey) || void 0;
20407
- } catch {
20408
- }
20409
- }
20410
- if (Array.isArray(headers)) {
20411
- const found = headers.find((item) => {
20412
- if (Array.isArray(item) && typeof item[0] === "string") {
20413
- return item[0].toLowerCase() === targetKey;
20414
- }
20415
- return false;
20416
- });
20417
- return found ? String(found[1]) : void 0;
20418
- }
20419
- if (typeof headers === "object") {
20420
- const foundKey = Object.keys(headers).find((k) => k.toLowerCase() === targetKey);
20421
- return foundKey ? headers[foundKey] !== void 0 ? String(headers[foundKey]) : void 0 : void 0;
20422
- }
20423
- return void 0;
20424
- }
20425
- function setSafeHeaders(initHeaders, newHeaders) {
20426
- if (typeof globalThis.Headers !== "undefined") {
20427
- const headers = new globalThis.Headers(initHeaders ?? {});
20428
- for (const [k, v] of Object.entries(newHeaders)) {
20429
- headers.set(k, v);
20430
- }
20431
- return headers;
20432
- }
20433
- if (Array.isArray(initHeaders)) {
20434
- const nextHeaders2 = [...initHeaders];
20435
- for (const [k, v] of Object.entries(newHeaders)) {
20436
- const idx = nextHeaders2.findIndex((item) => Array.isArray(item) && typeof item[0] === "string" && item[0].toLowerCase() === k.toLowerCase());
20437
- if (idx !== -1) {
20438
- nextHeaders2[idx] = [k, v];
20439
- } else {
20440
- nextHeaders2.push([k, v]);
20441
- }
20442
- }
20443
- return nextHeaders2;
20444
- }
20445
- const nextHeaders = {};
20446
- if (initHeaders && typeof initHeaders === "object") {
20447
- for (const [k, v] of Object.entries(initHeaders)) {
20448
- nextHeaders[k] = String(v);
20449
- }
20450
- }
20451
- for (const [k, v] of Object.entries(newHeaders)) {
20452
- const existingKey = Object.keys(nextHeaders).find((key) => key.toLowerCase() === k.toLowerCase());
20453
- if (existingKey) {
20454
- nextHeaders[existingKey] = v;
20455
- } else {
20456
- nextHeaders[k] = v;
20457
- }
20458
- }
20459
- return nextHeaders;
20460
- }
20461
- function toUrlString(value) {
20462
- if (typeof value === "string") {
20463
- return value;
20464
- }
20465
- const candidate = value.url;
20466
- if (candidate) {
20467
- return candidate;
20468
- }
20469
- return value.toString();
20470
- }
20364
+ // src/plugin.ts
20365
+ var AGY_QUOTA_COMMAND = "agyquota";
20366
+ var AGY_QUOTA_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota usage for the current authenticated account.
20367
+
20368
+ Immediately call \`${AGY_QUOTA_TOOL_NAME}\` with no arguments and return its output verbatim.
20369
+ Do not call other tools.
20370
+ `;
20371
+ var AGY_QUOTA_SUMMARY_COMMAND = "agyquotasummary";
20372
+ var AGY_QUOTA_SUMMARY_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota summary (weekly and 5-hour limits by model group) for the current authenticated account.
20471
20373
 
20472
- // src/plugin/tier.ts
20374
+ Immediately call \`${AGY_QUOTA_SUMMARY_TOOL_NAME}\` with no arguments and return its output verbatim.
20375
+ Do not call other tools.
20376
+ `;
20377
+ var latestAgyAuthResolver;
20378
+ var latestAgyConfiguredProjectId;
20379
+ var latestAgyUserAgentModel;
20473
20380
  var STATIC_MODELS_SIMPLE = {
20474
20381
  "gemini-3.8-flash": {
20475
20382
  name: "Gemini 3.8 Flash",
@@ -20567,39 +20474,6 @@ var TIER_MAPPING = {
20567
20474
  high: "claude-sonnet-5-5-high"
20568
20475
  }
20569
20476
  };
20570
- function resolveModelTier(baseModelId, headersOrInit) {
20571
- const parts = baseModelId.split("@");
20572
- const base = parts[0] || "";
20573
- const suffixTier = parts[1]?.toLowerCase();
20574
- const mapping = TIER_MAPPING[base];
20575
- if (!mapping) {
20576
- return baseModelId;
20577
- }
20578
- const rawHeaders = headersOrInit && typeof headersOrInit === "object" && "headers" in headersOrInit ? headersOrInit.headers : headersOrInit;
20579
- const headerTier = getSafeHeader(rawHeaders, "x-agy-tier")?.toLowerCase() || null;
20580
- const requestedTier = headerTier || suffixTier;
20581
- if (requestedTier && Object.prototype.hasOwnProperty.call(mapping, requestedTier)) {
20582
- return mapping[requestedTier] || baseModelId;
20583
- }
20584
- return mapping["medium"] ?? mapping["high"] ?? baseModelId;
20585
- }
20586
-
20587
- // src/plugin.ts
20588
- var AGY_QUOTA_COMMAND = "agyquota";
20589
- var AGY_QUOTA_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota usage for the current authenticated account.
20590
-
20591
- Immediately call \`${AGY_QUOTA_TOOL_NAME}\` with no arguments and return its output verbatim.
20592
- Do not call other tools.
20593
- `;
20594
- var AGY_QUOTA_SUMMARY_COMMAND = "agyquotasummary";
20595
- var AGY_QUOTA_SUMMARY_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota summary (weekly and 5-hour limits by model group) for the current authenticated account.
20596
-
20597
- Immediately call \`${AGY_QUOTA_SUMMARY_TOOL_NAME}\` with no arguments and return its output verbatim.
20598
- Do not call other tools.
20599
- `;
20600
- var latestAgyAuthResolver;
20601
- var latestAgyConfiguredProjectId;
20602
- var latestAgyUserAgentModel;
20603
20477
  var buildModelFromSimple = (modelId, simple) => {
20604
20478
  const isClaude = modelId.startsWith("claude-");
20605
20479
  const isGpt = modelId.startsWith("gpt-");
@@ -20693,6 +20567,83 @@ var STATIC_MODELS = {};
20693
20567
  for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
20694
20568
  STATIC_MODELS[modelId] = buildModelFromSimple(modelId, simple);
20695
20569
  }
20570
+ function getSafeHeader(headers, key) {
20571
+ if (!headers) {
20572
+ return void 0;
20573
+ }
20574
+ const targetKey = key.toLowerCase();
20575
+ if (typeof headers.get === "function") {
20576
+ try {
20577
+ return headers.get(targetKey) || void 0;
20578
+ } catch {
20579
+ }
20580
+ }
20581
+ if (Array.isArray(headers)) {
20582
+ const found = headers.find((item) => {
20583
+ if (Array.isArray(item) && typeof item[0] === "string") {
20584
+ return item[0].toLowerCase() === targetKey;
20585
+ }
20586
+ return false;
20587
+ });
20588
+ return found ? String(found[1]) : void 0;
20589
+ }
20590
+ if (typeof headers === "object") {
20591
+ const foundKey = Object.keys(headers).find((k) => k.toLowerCase() === targetKey);
20592
+ return foundKey ? headers[foundKey] !== void 0 ? String(headers[foundKey]) : void 0 : void 0;
20593
+ }
20594
+ return void 0;
20595
+ }
20596
+ function setSafeHeaders(initHeaders, newHeaders) {
20597
+ if (typeof globalThis.Headers !== "undefined") {
20598
+ const headers = new globalThis.Headers(initHeaders ?? {});
20599
+ for (const [k, v] of Object.entries(newHeaders)) {
20600
+ headers.set(k, v);
20601
+ }
20602
+ return headers;
20603
+ }
20604
+ if (Array.isArray(initHeaders)) {
20605
+ const nextHeaders2 = [...initHeaders];
20606
+ for (const [k, v] of Object.entries(newHeaders)) {
20607
+ const idx = nextHeaders2.findIndex((item) => Array.isArray(item) && typeof item[0] === "string" && item[0].toLowerCase() === k.toLowerCase());
20608
+ if (idx !== -1) {
20609
+ nextHeaders2[idx] = [k, v];
20610
+ } else {
20611
+ nextHeaders2.push([k, v]);
20612
+ }
20613
+ }
20614
+ return nextHeaders2;
20615
+ }
20616
+ const nextHeaders = {};
20617
+ if (initHeaders && typeof initHeaders === "object") {
20618
+ for (const [k, v] of Object.entries(initHeaders)) {
20619
+ nextHeaders[k] = String(v);
20620
+ }
20621
+ }
20622
+ for (const [k, v] of Object.entries(newHeaders)) {
20623
+ const existingKey = Object.keys(nextHeaders).find((key) => key.toLowerCase() === k.toLowerCase());
20624
+ if (existingKey) {
20625
+ nextHeaders[existingKey] = v;
20626
+ } else {
20627
+ nextHeaders[k] = v;
20628
+ }
20629
+ }
20630
+ return nextHeaders;
20631
+ }
20632
+ function resolveModelTier(baseModelId, init) {
20633
+ const parts = baseModelId.split("@");
20634
+ const base = parts[0] || "";
20635
+ const suffixTier = parts[1]?.toLowerCase();
20636
+ const mapping = TIER_MAPPING[base];
20637
+ if (!mapping) {
20638
+ return baseModelId;
20639
+ }
20640
+ const headerTier = getSafeHeader(init?.headers, "x-agy-tier")?.toLowerCase() || null;
20641
+ const requestedTier = headerTier || suffixTier;
20642
+ if (requestedTier && Object.prototype.hasOwnProperty.call(mapping, requestedTier)) {
20643
+ return mapping[requestedTier] || baseModelId;
20644
+ }
20645
+ return mapping["medium"] ?? mapping["high"];
20646
+ }
20696
20647
  var AgyCLIOAuthPlugin = async ({ client }) => {
20697
20648
  let latestConfig;
20698
20649
  updateStaticModelsWithPricing(STATIC_MODELS);
@@ -21020,782 +20971,25 @@ async function ensureProjectContextOrThrow(authRecord, client, configuredProject
21020
20971
  throw error45;
21021
20972
  }
21022
20973
  }
21023
-
21024
- // src/plugin/types.ts
21025
- function defineOpenCodeV2Plugin(def) {
21026
- return def;
21027
- }
21028
-
21029
- // src/plugin/v2-storage.ts
21030
- import { closeSync, existsSync as existsSync6, mkdirSync as mkdirSync5, openSync, readFileSync as readFileSync5, renameSync as renameSync4, unlinkSync as unlinkSync4, writeFileSync as writeFileSync5 } from "fs";
21031
- import { randomUUID as randomUUID4 } from "crypto";
21032
- import { homedir as homedir4 } from "os";
21033
- import { join as join6 } from "path";
21034
- var storedAuthOverrideForTesting = void 0;
21035
- function loadStoredAuthFromJson() {
21036
- if (storedAuthOverrideForTesting !== void 0) {
21037
- return storedAuthOverrideForTesting;
21038
- }
21039
- const authPath = join6(homedir4(), ".local", "share", "opencode", "auth.json");
21040
- try {
21041
- if (existsSync6(authPath)) {
21042
- const content = readFileSync5(authPath, "utf8");
21043
- const data = JSON.parse(content);
21044
- return data?.[AGY_PROVIDER_ID];
21045
- }
21046
- } catch {
21047
- }
21048
- return void 0;
21049
- }
21050
- function saveStoredAuthToJson(authRecord) {
21051
- if (process.env.NODE_ENV === "test" || process.env.VITEST || storedAuthOverrideForTesting !== void 0) {
21052
- return;
21053
- }
21054
- const dirPath = join6(homedir4(), ".local", "share", "opencode");
21055
- if (!existsSync6(dirPath)) {
21056
- mkdirSync5(dirPath, { recursive: true });
21057
- }
21058
- const authPath = join6(dirPath, "auth.json");
21059
- const data = existsSync6(authPath) ? JSON.parse(readFileSync5(authPath, "utf8")) : {};
21060
- data[AGY_PROVIDER_ID] = {
21061
- type: "oauth",
21062
- refresh: authRecord.refresh,
21063
- access: authRecord.access,
21064
- expires: authRecord.expires
21065
- };
21066
- const tempPath = `${authPath}.${process.pid}.${randomUUID4()}.tmp`;
21067
- let tempFileDescriptor;
21068
- let ownsTempFile = false;
21069
- try {
21070
- tempFileDescriptor = openSync(tempPath, "wx", 384);
21071
- ownsTempFile = true;
21072
- writeFileSync5(tempFileDescriptor, JSON.stringify(data, null, 2), {
21073
- encoding: "utf8"
21074
- });
21075
- closeSync(tempFileDescriptor);
21076
- tempFileDescriptor = void 0;
21077
- renameSync4(tempPath, authPath);
21078
- } catch (error45) {
21079
- if (tempFileDescriptor !== void 0) {
21080
- try {
21081
- closeSync(tempFileDescriptor);
21082
- } catch {
21083
- }
21084
- }
21085
- if (ownsTempFile) {
21086
- try {
21087
- unlinkSync4(tempPath);
21088
- } catch {
21089
- }
21090
- }
21091
- throw error45;
21092
- }
21093
- }
21094
-
21095
- // src/plugin/v2-fetch.ts
21096
- function createV2FetchInterceptor(getAuthSnapshot) {
21097
- return async function agyV2Fetch(input, init) {
21098
- const isGL = isGenerativeLanguageRequest(input);
21099
- const isInternal = toUrlString(input).includes("cloudcode-pa.googleapis.com");
21100
- if (!isGL && !isInternal) {
21101
- return (globalThis.fetch || fetch)(input, init);
21102
- }
21103
- let rawAuth = getAuthSnapshot ? await getAuthSnapshot() : void 0;
21104
- if (!rawAuth) {
21105
- rawAuth = loadStoredAuthFromJson();
21106
- }
21107
- if (!rawAuth || !isOAuthAuth(rawAuth)) {
21108
- return (globalThis.fetch || fetch)(input, init);
21109
- }
21110
- let authRecord = resolveCachedAuth(rawAuth);
21111
- if (accessTokenExpired(authRecord)) {
21112
- const refreshed = await refreshAccessToken(authRecord, { auth: { set: async () => {
21113
- } } });
21114
- if (refreshed) {
21115
- authRecord = refreshed;
21116
- }
21117
- }
21118
- if (!authRecord.access) {
21119
- return (globalThis.fetch || fetch)(input, init);
21120
- }
21121
- if (isInternal) {
21122
- const hasAuth = getSafeHeader(init?.headers, "Authorization") !== void 0;
21123
- if (hasAuth) {
21124
- return (globalThis.fetch || fetch)(input, init);
21125
- }
21126
- const userAgent = buildAgyCliUserAgent();
21127
- const headers = setSafeHeaders(init?.headers, {
21128
- Authorization: `Bearer ${authRecord.access}`,
21129
- "User-Agent": userAgent
21130
- });
21131
- return (globalThis.fetch || fetch)(input, {
21132
- ...init,
21133
- headers
21134
- });
21135
- }
21136
- const requestTarget = parseGenerativeLanguageRequest(input);
21137
- const requestUserAgentModel = requestTarget?.effectiveModel;
21138
- let projectContext;
21139
- try {
21140
- projectContext = await ensureProjectContext(
21141
- authRecord,
21142
- { auth: { set: async () => {
21143
- } } },
21144
- void 0,
21145
- requestUserAgentModel
21146
- );
21147
- } catch {
21148
- projectContext = {
21149
- effectiveProjectId: parseRefreshParts(authRecord.refresh).projectId || "antigravity",
21150
- auth: authRecord
21151
- };
21152
- }
21153
- const originalRequestedModel = parseGenerativeLanguageRequest(input)?.effectiveModel;
21154
- let modifiedInput = input;
21155
- if (isGL && originalRequestedModel) {
21156
- const originalBase = originalRequestedModel.replace("google-agy/", "");
21157
- const resolvedBase = resolveModelTier(originalBase, init);
21158
- if (originalBase !== resolvedBase) {
21159
- if (typeof modifiedInput === "string") {
21160
- modifiedInput = modifiedInput.replace(`models/${originalBase}`, `models/${resolvedBase}`);
21161
- } else if (typeof Request !== "undefined" && modifiedInput instanceof Request) {
21162
- const newUrl = modifiedInput.url.replace(`models/${originalBase}`, `models/${resolvedBase}`);
21163
- modifiedInput = new Request(newUrl, modifiedInput);
21164
- }
21165
- }
21166
- }
21167
- const transformed = prepareAgyRequest(
21168
- modifiedInput,
21169
- init,
21170
- authRecord.access,
21171
- projectContext.effectiveProjectId,
21172
- void 0
21173
- );
21174
- const chatLogger = createChatLogger();
21175
- if (chatLogger) {
21176
- chatLogger.logRequest(
21177
- toUrlString(transformed.request),
21178
- transformed.init.method || "GET",
21179
- transformed.init.headers,
21180
- transformed.init.body
21181
- );
21182
- }
21183
- const response = await fetchWithRetry(transformed.request, transformed.init);
21184
- return transformAgyResponse(
21185
- response,
21186
- transformed.streaming,
21187
- null,
21188
- transformed.requestedModel,
21189
- transformed.sessionId,
21190
- chatLogger
21191
- );
21192
- };
21193
- }
21194
-
21195
- // src/plugin/v2-session.ts
21196
- function createV2HttpRequestHook(state = {}) {
21197
- return async (event) => {
21198
- if (!event) return;
21199
- const rawUrl = typeof event.url === "string" ? event.url : event.request?.url || "";
21200
- const isGL = isGenerativeLanguageRequest(rawUrl);
21201
- const isInternal = rawUrl.includes("cloudcode-pa.googleapis.com");
21202
- if (!isGL && !isInternal) {
21203
- return;
21204
- }
21205
- event.headers = event.headers || {};
21206
- let modelName;
21207
- let rawAuth = event.auth;
21208
- if (rawAuth && !rawAuth.type) {
21209
- const tokenVal = rawAuth.access || rawAuth.token;
21210
- if (tokenVal || rawAuth.refresh) {
21211
- rawAuth = { type: "oauth", access: tokenVal, ...rawAuth };
21212
- }
21213
- }
21214
- if (!rawAuth || !isOAuthAuth(rawAuth)) {
21215
- rawAuth = loadStoredAuthFromJson();
21216
- }
21217
- let authRecord = rawAuth && isOAuthAuth(rawAuth) ? resolveCachedAuth(rawAuth) : void 0;
21218
- if (authRecord && accessTokenExpired(authRecord)) {
21219
- const refreshed = await refreshAccessToken(authRecord, { auth: { set: async () => {
21220
- } } });
21221
- if (refreshed) {
21222
- authRecord = refreshed;
21223
- try {
21224
- saveStoredAuthToJson(refreshed);
21225
- } catch {
21226
- console.warn("[Agy Auth] Refreshed credentials could not be persisted; the current request will continue.");
21227
- }
21228
- }
21229
- }
21230
- if (isGL) {
21231
- const parsed = parseGenerativeLanguageRequest(rawUrl);
21232
- modelName = parsed?.effectiveModel;
21233
- if (modelName) {
21234
- state.lastInterceptedModel = modelName;
21235
- }
21236
- if (typeof event.headers.delete === "function") {
21237
- event.headers.delete("x-goog-api-key");
21238
- event.headers.delete("api-key");
21239
- } else {
21240
- for (const key of Object.keys(event.headers)) {
21241
- const lower = key.toLowerCase();
21242
- if (lower === "x-goog-api-key" || lower === "api-key") {
21243
- delete event.headers[key];
21244
- }
21245
- }
21246
- }
21247
- if (event.request?.headers) {
21248
- if (typeof event.request.headers.delete === "function") {
21249
- event.request.headers.delete("x-goog-api-key");
21250
- event.request.headers.delete("api-key");
21251
- } else {
21252
- for (const key of Object.keys(event.request.headers)) {
21253
- const lower = key.toLowerCase();
21254
- if (lower === "x-goog-api-key" || lower === "api-key") {
21255
- delete event.request.headers[key];
21256
- }
21257
- }
21258
- }
21259
- }
21260
- let cleanUrl = rawUrl;
21261
- try {
21262
- const parsedUrl = new URL(rawUrl);
21263
- let urlChanged = false;
21264
- for (const param of ["key", "x-goog-api-key", "api-key"]) {
21265
- if (parsedUrl.searchParams.has(param)) {
21266
- parsedUrl.searchParams.delete(param);
21267
- urlChanged = true;
21268
- }
21269
- }
21270
- if (urlChanged) {
21271
- cleanUrl = parsedUrl.toString();
21272
- }
21273
- } catch {
21274
- }
21275
- if (authRecord && authRecord.access) {
21276
- let projectContext;
21277
- try {
21278
- projectContext = await ensureProjectContext(
21279
- authRecord,
21280
- { auth: { set: async () => {
21281
- } } },
21282
- void 0,
21283
- modelName
21284
- );
21285
- } catch {
21286
- projectContext = {
21287
- effectiveProjectId: parseRefreshParts(authRecord.refresh).projectId || "antigravity",
21288
- auth: authRecord
21289
- };
21290
- }
21291
- const originalRequestedModel = modelName;
21292
- let modifiedUrl = cleanUrl;
21293
- if (originalRequestedModel) {
21294
- const originalBase = originalRequestedModel.replace("google-agy/", "");
21295
- const initHeaders = event.headers instanceof Headers ? event.headers : event.request?.headers;
21296
- const resolvedBase = resolveModelTier(originalBase, { headers: initHeaders });
21297
- if (originalBase !== resolvedBase) {
21298
- modifiedUrl = modifiedUrl.replace(`models/${originalBase}`, `models/${resolvedBase}`);
21299
- }
21300
- }
21301
- let bodyPayload = event.body;
21302
- if (bodyPayload === void 0 && event.request) {
21303
- if (typeof event.request.clone === "function") {
21304
- try {
21305
- bodyPayload = await event.request.clone().text();
21306
- } catch {
21307
- }
21308
- } else if (event.request.body !== void 0) {
21309
- bodyPayload = event.request.body;
21310
- }
21311
- }
21312
- let preExistingUserAgent;
21313
- if (typeof event.headers?.get === "function") {
21314
- preExistingUserAgent = event.headers.get("user-agent") || event.headers.get("User-Agent") || void 0;
21315
- } else if (event.headers && typeof event.headers === "object") {
21316
- preExistingUserAgent = event.headers["user-agent"] || event.headers["User-Agent"] || void 0;
21317
- }
21318
- if (!preExistingUserAgent && typeof event.request?.headers?.get === "function") {
21319
- preExistingUserAgent = event.request.headers.get("user-agent") || event.request.headers.get("User-Agent") || void 0;
21320
- } else if (!preExistingUserAgent && event.request?.headers && typeof event.request.headers === "object") {
21321
- preExistingUserAgent = event.request.headers["user-agent"] || event.request.headers["User-Agent"] || void 0;
21322
- }
21323
- const method = event.method || event.request?.method || "POST";
21324
- const requestHeaders = event.headers || event.request?.headers;
21325
- const transformed = prepareAgyRequest(
21326
- modifiedUrl,
21327
- {
21328
- method,
21329
- headers: requestHeaders,
21330
- body: bodyPayload
21331
- },
21332
- authRecord.access,
21333
- projectContext.effectiveProjectId
21334
- );
21335
- const targetUrl = toUrlString(transformed.request);
21336
- if (typeof event.url === "string") {
21337
- event.url = targetUrl;
21338
- }
21339
- if (event.request && typeof event.request === "object") {
21340
- if (typeof Request !== "undefined" && event.request instanceof Request) {
21341
- event.request = new Request(targetUrl, {
21342
- method: transformed.init.method,
21343
- headers: transformed.init.headers,
21344
- body: transformed.init.body
21345
- });
21346
- } else if (typeof event.request.url === "string") {
21347
- try {
21348
- event.request.url = targetUrl;
21349
- } catch {
21350
- }
21351
- }
21352
- }
21353
- const headerEntries = transformed.init.headers instanceof Headers ? Array.from(transformed.init.headers.entries()) : Object.entries(transformed.init.headers || {});
21354
- for (const [k, v] of headerEntries) {
21355
- const lowerK = k.toLowerCase();
21356
- if (lowerK === "user-agent") {
21357
- if (preExistingUserAgent) {
21358
- continue;
21359
- }
21360
- if (typeof event.headers?.set === "function") {
21361
- event.headers.set("User-Agent", v);
21362
- } else if (event.headers) {
21363
- event.headers["User-Agent"] = v;
21364
- }
21365
- if (event.request?.headers && typeof event.request.headers.set === "function") {
21366
- event.request.headers.set("User-Agent", v);
21367
- } else if (event.request?.headers && typeof event.request.headers === "object") {
21368
- event.request.headers["User-Agent"] = v;
21369
- }
21370
- continue;
21371
- }
21372
- if (typeof event.headers?.set === "function") {
21373
- event.headers.set(k, v);
21374
- } else if (event.headers) {
21375
- event.headers[k] = v;
21376
- }
21377
- if (event.request?.headers && typeof event.request.headers.set === "function") {
21378
- event.request.headers.set(k, v);
21379
- } else if (event.request?.headers && typeof event.request.headers === "object") {
21380
- event.request.headers[k] = v;
21381
- }
21382
- }
21383
- if (transformed.init.body !== void 0) {
21384
- event.body = transformed.init.body;
21385
- if (event.request && typeof event.request === "object" && !(event.request instanceof Request)) {
21386
- event.request.body = transformed.init.body;
21387
- }
21388
- }
21389
- } else {
21390
- if (typeof event.url === "string") {
21391
- event.url = cleanUrl;
21392
- }
21393
- if (event.request && typeof event.request === "object") {
21394
- if (typeof Request !== "undefined" && event.request instanceof Request) {
21395
- event.request = new Request(cleanUrl, event.request);
21396
- } else if (typeof event.request.url === "string") {
21397
- try {
21398
- event.request.url = cleanUrl;
21399
- } catch {
21400
- }
21401
- }
21402
- }
21403
- }
21404
- }
21405
- if (authRecord && authRecord.access) {
21406
- if (typeof event.headers?.set === "function") {
21407
- event.headers.set("Authorization", `Bearer ${authRecord.access}`);
21408
- } else if (event.headers) {
21409
- event.headers["Authorization"] = `Bearer ${authRecord.access}`;
21410
- }
21411
- if (event.request?.headers && typeof event.request.headers.set === "function") {
21412
- event.request.headers.set("Authorization", `Bearer ${authRecord.access}`);
21413
- } else if (event.request?.headers && typeof event.request.headers === "object") {
21414
- event.request.headers["Authorization"] = `Bearer ${authRecord.access}`;
21415
- }
21416
- }
21417
- const userAgent = buildAgyCliUserAgent(modelName);
21418
- if (typeof event.headers?.set === "function") {
21419
- if (!event.headers.get("User-Agent") && !event.headers.get("user-agent")) {
21420
- event.headers.set("User-Agent", userAgent);
21421
- }
21422
- } else if (event.headers) {
21423
- if (!event.headers["User-Agent"] && !event.headers["user-agent"]) {
21424
- event.headers["User-Agent"] = userAgent;
21425
- }
21426
- }
21427
- if (event.request?.headers && typeof event.request.headers.set === "function") {
21428
- if (!event.request.headers.get("User-Agent") && !event.request.headers.get("user-agent")) {
21429
- event.request.headers.set("User-Agent", userAgent);
21430
- }
21431
- } else if (event.request?.headers && typeof event.request.headers === "object") {
21432
- if (!event.request.headers["User-Agent"] && !event.request.headers["user-agent"]) {
21433
- event.request.headers["User-Agent"] = userAgent;
21434
- }
21435
- }
21436
- };
21437
- }
21438
- function createV2HttpResponseHook(state = {}) {
21439
- return async (event) => {
21440
- if (!event || !event.response) return;
21441
- const rawUrl = typeof event.url === "string" ? event.url : event.request?.url || "";
21442
- const isInternal = rawUrl.includes("cloudcode-pa.googleapis.com");
21443
- if (isInternal && event.response instanceof Response) {
21444
- const isStreaming = rawUrl.includes(":streamGenerateCode") || event.response.headers.get("content-type")?.includes("text/event-stream");
21445
- const parsedModel = parseGenerativeLanguageRequest(rawUrl)?.effectiveModel || state.lastInterceptedModel;
21446
- const transformed = await transformAgyResponse(
21447
- event.response,
21448
- !!isStreaming,
21449
- null,
21450
- parsedModel,
21451
- void 0,
21452
- void 0
21453
- );
21454
- event.response = transformed;
21455
- }
21456
- };
21457
- }
21458
- function createV2RetryHook() {
21459
- return async (event) => {
21460
- if (!event) return;
21461
- const response = event.response;
21462
- if (response instanceof Response) {
21463
- if (response.status === 429 || response.status === 503) {
21464
- const quota = await classifyQuotaResponse(response);
21465
- if (quota?.retryDelayMs) {
21466
- event.retryDelayMs = quota.retryDelayMs;
21467
- } else {
21468
- event.retryDelayMs = await resolveRetryDelayMs(response, event.attempt || 1);
21469
- }
21470
- }
21471
- } else if (event.details && Array.isArray(event.details)) {
21472
- const retryInfo = event.details.find(
21473
- (d) => d && d["@type"] === "type.googleapis.com/google.rpc.RetryInfo"
21474
- );
21475
- if (retryInfo?.retryDelay) {
21476
- const delayMs = retryInternals.parseRetryDelayValue(retryInfo.retryDelay);
21477
- if (delayMs !== null) {
21478
- event.retryDelayMs = delayMs;
21479
- }
21480
- }
21481
- }
21482
- };
21483
- }
21484
- function registerV2SessionHooks(ctx) {
21485
- const state = {};
21486
- ctx.session.hook("http.request", createV2HttpRequestHook(state), { providerID: AGY_PROVIDER_ID });
21487
- ctx.session.hook("http.response", createV2HttpResponseHook(state), { providerID: AGY_PROVIDER_ID });
21488
- ctx.session.hook("retry", createV2RetryHook(), { providerID: AGY_PROVIDER_ID });
21489
- }
21490
-
21491
- // src/plugin/v2.ts
21492
- async function setupOpenCodeV2(ctx) {
21493
- const resolveVariants = (modelId) => {
21494
- const mapping = TIER_MAPPING[modelId];
21495
- if (!mapping) return void 0;
21496
- const variants = [];
21497
- if (mapping.minimal !== void 0) variants.push({ id: "minimal" });
21498
- if (mapping.low !== void 0) variants.push({ id: "low" });
21499
- if (mapping.medium !== void 0) variants.push({ id: "medium" });
21500
- if (mapping.high !== void 0) variants.push({ id: "high" });
21501
- return variants.length > 0 ? variants : void 0;
21502
- };
21503
- const updateProviderRecord = (p) => {
21504
- p.name = "Antigravity CLI";
21505
- p.activation = "enabled";
21506
- p.package = "aisdk:@ai-sdk/google";
21507
- p.description = "Google Gemini Antigravity Code Assist OAuth provider";
21508
- p.settings = { ...p.settings || {}, apiKey: "dummy" };
21509
- p.integrationID = AGY_PROVIDER_ID;
21510
- };
21511
- const buildModelRecord = (modelId, simple, existingModel) => {
21512
- const isClaude = modelId.startsWith("claude-");
21513
- const isGpt = modelId.startsWith("gpt-");
21514
- const variants = resolveVariants(modelId);
21515
- return {
21516
- id: modelId,
21517
- providerID: AGY_PROVIDER_ID,
21518
- name: simple.name,
21519
- description: simple.description,
21520
- family: modelId.includes("gemini") ? "gemini" : isClaude ? "claude" : isGpt ? "gpt" : "unknown",
21521
- reasoning: simple.reasoning,
21522
- attachment: simple.attachment,
21523
- tool_call: simple.toolCall,
21524
- limit: {
21525
- context: simple.maxTokens,
21526
- output: simple.maxOutputTokens
21527
- },
21528
- cost: simple.cost || { input: 0, output: 0 },
21529
- ...variants ? { variants } : {},
21530
- ...existingModel || {}
21531
- };
21532
- };
21533
- const updateModelRecord = (m, modelId, simple) => {
21534
- m.name = simple.name;
21535
- m.capabilities = {
21536
- tools: true,
21537
- input: ["text", "image"],
21538
- output: ["text"]
21539
- };
21540
- m.limit = {
21541
- context: simple.maxTokens,
21542
- output: simple.maxOutputTokens
21543
- };
21544
- m.family = "gemini";
21545
- if (simple.cost) {
21546
- m.cost = simple.cost;
21547
- }
21548
- const variants = resolveVariants(modelId);
21549
- if (variants) {
21550
- m.variants = variants;
21551
- }
21552
- };
21553
- if (ctx.provider?.transform) {
21554
- ctx.provider.transform(async (editor) => {
21555
- if (!editor) return;
21556
- if (typeof editor.update === "function") {
21557
- editor.update(AGY_PROVIDER_ID, updateProviderRecord);
21558
- } else if (typeof editor.set === "function") {
21559
- const p = { id: AGY_PROVIDER_ID };
21560
- updateProviderRecord(p);
21561
- editor.set(AGY_PROVIDER_ID, p);
21562
- } else if (typeof editor === "object") {
21563
- const p = editor[AGY_PROVIDER_ID] || { id: AGY_PROVIDER_ID };
21564
- updateProviderRecord(p);
21565
- editor[AGY_PROVIDER_ID] = p;
21566
- }
21567
- });
21568
- }
21569
- if (ctx.model?.transform) {
21570
- ctx.model.transform(async (editor) => {
21571
- if (!editor) return;
21572
- if (typeof editor.update === "function") {
21573
- for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
21574
- editor.update(AGY_PROVIDER_ID, modelId, (m) => updateModelRecord(m, modelId, simple));
21575
- }
21576
- } else if (typeof editor.set === "function") {
21577
- for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
21578
- const m = buildModelRecord(modelId, simple);
21579
- editor.set(`${AGY_PROVIDER_ID}:${modelId}`, m);
21580
- }
21581
- } else if (typeof editor === "object") {
21582
- for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
21583
- const key = `${AGY_PROVIDER_ID}:${modelId}`;
21584
- editor[key] = buildModelRecord(modelId, simple, editor[key]);
21585
- }
21586
- }
21587
- });
20974
+ function toUrlString(value) {
20975
+ if (typeof value === "string") {
20976
+ return value;
21588
20977
  }
21589
- if (ctx.catalog?.transform) {
21590
- ctx.catalog.transform(async (editor) => {
21591
- if (!editor) return;
21592
- if (typeof editor?.provider?.update === "function") {
21593
- editor.provider.update(AGY_PROVIDER_ID, updateProviderRecord);
21594
- if (typeof editor?.model?.update === "function") {
21595
- for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
21596
- editor.model.update(AGY_PROVIDER_ID, modelId, (m) => updateModelRecord(m, modelId, simple));
21597
- }
21598
- }
21599
- return;
21600
- }
21601
- const catalog = editor;
21602
- catalog.providers = catalog.providers || {};
21603
- catalog.providers[AGY_PROVIDER_ID] = {
21604
- id: AGY_PROVIDER_ID,
21605
- name: "Antigravity CLI",
21606
- npm: "aisdk:@ai-sdk/google",
21607
- settings: { apiKey: "dummy" },
21608
- integrationID: AGY_PROVIDER_ID,
21609
- models: { ...catalog.providers[AGY_PROVIDER_ID]?.models || {} },
21610
- ...catalog.providers[AGY_PROVIDER_ID]
21611
- };
21612
- if (catalog.providers[AGY_PROVIDER_ID].settings) {
21613
- catalog.providers[AGY_PROVIDER_ID].settings = {
21614
- ...catalog.providers[AGY_PROVIDER_ID].settings,
21615
- apiKey: "dummy"
21616
- };
21617
- } else {
21618
- catalog.providers[AGY_PROVIDER_ID].settings = { apiKey: "dummy" };
21619
- }
21620
- catalog.providers[AGY_PROVIDER_ID].integrationID = AGY_PROVIDER_ID;
21621
- const targetModels = catalog.providers[AGY_PROVIDER_ID].models;
21622
- for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
21623
- targetModels[modelId] = buildModelRecord(modelId, simple, targetModels[modelId]);
21624
- }
21625
- });
20978
+ const candidate = value.url;
20979
+ if (candidate) {
20980
+ return candidate;
21626
20981
  }
21627
- ctx.tool.transform(async (editor) => {
21628
- if (!editor) return;
21629
- const quotaTool = createAgyQuotaTool({
21630
- client: void 0,
21631
- getAuthResolver: () => void 0,
21632
- getConfiguredProjectId: () => void 0,
21633
- getUserAgentModel: () => void 0
21634
- });
21635
- const quotaSummaryTool = createAgyQuotaSummaryTool({
21636
- client: void 0,
21637
- getAuthResolver: () => void 0,
21638
- getConfiguredProjectId: () => void 0,
21639
- getUserAgentModel: () => void 0
21640
- });
21641
- if (typeof editor.add === "function") {
21642
- editor.add({
21643
- name: AGY_QUOTA_TOOL_NAME,
21644
- description: quotaTool.description,
21645
- input: {},
21646
- execute: async (args, context) => quotaTool.execute(args, context)
21647
- });
21648
- editor.add({
21649
- name: AGY_QUOTA_SUMMARY_TOOL_NAME,
21650
- description: quotaSummaryTool.description,
21651
- input: {},
21652
- execute: async (args, context) => quotaSummaryTool.execute(args, context)
21653
- });
21654
- } else if (typeof editor.set === "function") {
21655
- editor.set(AGY_QUOTA_TOOL_NAME, quotaTool);
21656
- editor.set(AGY_QUOTA_SUMMARY_TOOL_NAME, quotaSummaryTool);
21657
- } else if (editor.tools && typeof editor.tools === "object") {
21658
- editor.tools[AGY_QUOTA_TOOL_NAME] = quotaTool;
21659
- editor.tools[AGY_QUOTA_SUMMARY_TOOL_NAME] = quotaSummaryTool;
21660
- } else if (typeof editor === "object") {
21661
- editor[AGY_QUOTA_TOOL_NAME] = quotaTool;
21662
- editor[AGY_QUOTA_SUMMARY_TOOL_NAME] = quotaSummaryTool;
21663
- }
21664
- });
21665
- ctx.command.transform(async (editor) => {
21666
- if (!editor) return;
21667
- const commands = {
21668
- [AGY_V2_QUOTA_COMMAND]: {
21669
- description: "Show Agy Code Assist quota usage",
21670
- template: AGY_V2_QUOTA_COMMAND_TEMPLATE
21671
- },
21672
- [AGY_V2_QUOTA_SUMMARY_COMMAND]: {
21673
- description: "Show Agy Code Assist quota summary with weekly and 5-hour limits",
21674
- template: AGY_V2_QUOTA_SUMMARY_COMMAND_TEMPLATE
21675
- }
21676
- };
21677
- if (typeof editor.add === "function") {
21678
- editor.add({
21679
- name: AGY_V2_QUOTA_COMMAND,
21680
- description: "Display current Antigravity quota usage",
21681
- template: AGY_V2_QUOTA_COMMAND_TEMPLATE
21682
- });
21683
- editor.add({
21684
- name: AGY_V2_QUOTA_SUMMARY_COMMAND,
21685
- description: "Display Antigravity quota summary grouped by model family",
21686
- template: AGY_V2_QUOTA_SUMMARY_COMMAND_TEMPLATE
21687
- });
21688
- } else if (typeof editor.set === "function") {
21689
- editor.set(AGY_V2_QUOTA_COMMAND, commands[AGY_V2_QUOTA_COMMAND]);
21690
- editor.set(AGY_V2_QUOTA_SUMMARY_COMMAND, commands[AGY_V2_QUOTA_SUMMARY_COMMAND]);
21691
- } else if (editor.commands && typeof editor.commands === "object") {
21692
- editor.commands[AGY_V2_QUOTA_COMMAND] = commands[AGY_V2_QUOTA_COMMAND];
21693
- editor.commands[AGY_V2_QUOTA_SUMMARY_COMMAND] = commands[AGY_V2_QUOTA_SUMMARY_COMMAND];
21694
- } else if (typeof editor === "object") {
21695
- editor[AGY_V2_QUOTA_COMMAND] = commands[AGY_V2_QUOTA_COMMAND];
21696
- editor[AGY_V2_QUOTA_SUMMARY_COMMAND] = commands[AGY_V2_QUOTA_SUMMARY_COMMAND];
21697
- }
21698
- });
21699
- ctx.integration?.transform?.((editor) => {
21700
- if (!editor) return;
21701
- editor.update?.(AGY_PROVIDER_ID, (integration) => {
21702
- integration.name = "Antigravity CLI (plugin)";
21703
- });
21704
- editor.method?.update?.({
21705
- integrationID: AGY_PROVIDER_ID,
21706
- method: {
21707
- id: "oauth",
21708
- type: "oauth",
21709
- label: "Antigravity CLI (OAuth)"
21710
- },
21711
- authorize: async () => {
21712
- const authorization = await authorizeAgy();
21713
- return {
21714
- mode: "code",
21715
- url: authorization.url,
21716
- instructions: "Please complete Google account authorization in your browser. After authorization, copy the full redirect URL or code and paste it below:",
21717
- callback: async (code) => {
21718
- const trimmed = code.trim();
21719
- const parsed = parseOAuthCallbackInput(trimmed);
21720
- const authCode = parsed.code || trimmed;
21721
- if (!authCode) {
21722
- return { type: "failed", error: "Missing authorization code in callback input" };
21723
- }
21724
- if (parsed.state && parsed.state !== authorization.state) {
21725
- return { type: "failed", error: "State mismatch in callback input (possible CSRF attempt)" };
21726
- }
21727
- const exchangeResult = await exchangeAgyWithVerifier(authCode, authorization.verifier);
21728
- if (exchangeResult.type !== "success") {
21729
- return exchangeResult;
21730
- }
21731
- const initialRefresh = formatRefreshParts({
21732
- refreshToken: exchangeResult.refresh
21733
- });
21734
- let authRecord = {
21735
- type: "oauth",
21736
- refresh: initialRefresh,
21737
- access: exchangeResult.access,
21738
- expires: exchangeResult.expires
21739
- };
21740
- try {
21741
- const projectContext = await ensureProjectContext(
21742
- authRecord,
21743
- { auth: { set: async () => {
21744
- } } }
21745
- );
21746
- authRecord = {
21747
- ...authRecord,
21748
- refresh: projectContext.auth.refresh
21749
- };
21750
- } catch {
21751
- }
21752
- try {
21753
- saveStoredAuthToJson(authRecord);
21754
- } catch {
21755
- return {
21756
- type: "failed",
21757
- error: "Google authentication succeeded but AGY credentials could not be stored. Check filesystem access and retry."
21758
- };
21759
- }
21760
- return {
21761
- type: "oauth",
21762
- methodID: "oauth",
21763
- refresh: authRecord.refresh,
21764
- access: authRecord.access,
21765
- expires: authRecord.expires
21766
- };
21767
- }
21768
- };
21769
- }
21770
- });
21771
- });
21772
- ctx.aisdk?.hook("sdk", async (event) => {
21773
- if (!event) return;
21774
- const isMatchingProvider = event.providerID === AGY_PROVIDER_ID || event.model?.providerID === AGY_PROVIDER_ID;
21775
- if (!isMatchingProvider) return;
21776
- event.options = event.options || {};
21777
- event.options.apiKey = "dummy";
21778
- event.options.fetch = createV2FetchInterceptor();
21779
- });
21780
- registerV2SessionHooks(ctx);
20982
+ return value.toString();
21781
20983
  }
21782
- var v2PluginDefinition = defineOpenCodeV2Plugin({
21783
- id: AGY_PROVIDER_ID,
21784
- setup: setupOpenCodeV2
21785
- });
21786
20984
 
21787
20985
  // index.ts
21788
- var dualPlugin = {
21789
- ...v2PluginDefinition,
20986
+ var index_default = {
20987
+ id: "@anthonyhaussman/opencode-agy-auth",
21790
20988
  server: AgyCLIOAuthPlugin
21791
20989
  };
21792
- var index_default = dualPlugin;
21793
20990
  export {
21794
20991
  AgyCLIOAuthPlugin,
21795
20992
  GoogleOAuthPlugin,
21796
- index_default as default,
21797
- defineOpenCodeV2Plugin,
21798
- setupOpenCodeV2,
21799
- v2PluginDefinition
20993
+ index_default as default
21800
20994
  };
21801
20995
  //# sourceMappingURL=index.js.map