agent-shim 11.87.0 → 11.87.2

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/cli.cjs CHANGED
@@ -41960,7 +41960,7 @@ var init_package = __esm({
41960
41960
  "package.json"() {
41961
41961
  package_default = {
41962
41962
  name: "agent-shim",
41963
- version: "11.87.0",
41963
+ version: "11.87.2",
41964
41964
  description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
41965
41965
  license: "MIT",
41966
41966
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -142539,6 +142539,60 @@ async function serveRouted(incoming, deps) {
142539
142539
  }
142540
142540
  }
142541
142541
 
142542
+ // src/antigravity/agyCredential.ts
142543
+ var PREFIX = "go-keyring-base64:";
142544
+ var COMMAND_TIMEOUT_MS = 3e4;
142545
+ function envelope(raw) {
142546
+ if (!raw.startsWith(PREFIX)) return void 0;
142547
+ try {
142548
+ const data = JSON.parse(Buffer.from(raw.slice(PREFIX.length), "base64").toString("utf8"));
142549
+ if (typeof data !== "object" || data === null || !("token" in data)) return void 0;
142550
+ const token = data.token;
142551
+ if (typeof token !== "object" || token === null || !("access_token" in token) || !("expiry" in token)) return void 0;
142552
+ if (typeof token.access_token !== "string" || token.access_token === "" || typeof token.expiry !== "string") return void 0;
142553
+ const expiry = Date.parse(token.expiry);
142554
+ return Number.isFinite(expiry) ? { token: token.access_token, expiry } : void 0;
142555
+ } catch {
142556
+ return void 0;
142557
+ }
142558
+ }
142559
+ function createAgyCredentialResolver(port, now = Date.now) {
142560
+ let inFlight;
142561
+ async function resolve3(result) {
142562
+ if (!result.ok) return result;
142563
+ const source = result.credential.source;
142564
+ if (!("keychain" in source) || source.keychain.service !== "gemini" || source.keychain.account !== "antigravity") return result;
142565
+ const read = async () => {
142566
+ const item2 = await port.runCommand(["security", "find-generic-password", "-s", "gemini", "-a", "antigravity", "-w"], { timeoutMs: 1e4, interactive: false });
142567
+ return item2.status === 0 && !item2.timedOut ? item2.stdout.trim() : void 0;
142568
+ };
142569
+ const raw = await read();
142570
+ if (raw === void 0) return { ok: false, message: "Unable to read the agy credential envelope." };
142571
+ if (!raw.startsWith(PREFIX)) return result;
142572
+ let item = envelope(raw);
142573
+ if (item === void 0) return { ok: false, message: "Unable to read the agy credential envelope." };
142574
+ if (item.expiry <= now()) {
142575
+ const refreshed = await port.runCommand(["agy", "models"], { timeoutMs: COMMAND_TIMEOUT_MS, interactive: false });
142576
+ if (refreshed.status !== 0 || refreshed.timedOut) return { ok: false, message: "agy could not refresh its credential; check agy authentication." };
142577
+ const refreshedRaw = await read();
142578
+ item = refreshedRaw === void 0 ? void 0 : envelope(refreshedRaw);
142579
+ if (item === void 0 || item.expiry <= now()) return { ok: false, message: "agy did not provide a fresh credential." };
142580
+ }
142581
+ return { ok: true, credential: { ...result.credential, token: item.token } };
142582
+ }
142583
+ return async (result) => {
142584
+ if (!result.ok || !("keychain" in result.credential.source) || result.credential.source.keychain.service !== "gemini" || result.credential.source.keychain.account !== "antigravity") return result;
142585
+ if (inFlight !== void 0) return await inFlight;
142586
+ const pending = resolve3(result);
142587
+ inFlight = pending;
142588
+ try {
142589
+ return await pending;
142590
+ } finally {
142591
+ if (inFlight === pending) inFlight = void 0;
142592
+ }
142593
+ };
142594
+ }
142595
+
142542
142596
  // src/frontdoor/providerRoute.ts
142543
142597
  init_load();
142544
142598
  init_names();
@@ -143004,8 +143058,8 @@ function createCodexRoute(ports) {
143004
143058
  const detail = (await upstream.text()).slice(0, UPSTREAM_DETAIL_CHARS);
143005
143059
  let quotaError;
143006
143060
  try {
143007
- const envelope = CodexErrorEnvelopeSchema.safeParse(JSON.parse(detail));
143008
- quotaError = envelope.success ? envelope.data.error : void 0;
143061
+ const envelope2 = CodexErrorEnvelopeSchema.safeParse(JSON.parse(detail));
143062
+ quotaError = envelope2.success ? envelope2.data.error : void 0;
143009
143063
  } catch {
143010
143064
  }
143011
143065
  const rejected = upstream.status === HTTP_STATUS.tooManyRequests;
@@ -143395,12 +143449,24 @@ function descend(value3, key) {
143395
143449
  if (Array.isArray(value3) && /^\d+$/u.test(key)) return value3[Number(key)];
143396
143450
  return record2(value3) && Object.hasOwn(value3, key) ? value3[key] : void 0;
143397
143451
  }
143452
+ function descendExpanded(root, value3, key) {
143453
+ const seen = /* @__PURE__ */ new Set();
143454
+ let current = value3;
143455
+ for (; ; ) {
143456
+ const child = descend(current, key);
143457
+ if (child !== void 0) return child;
143458
+ if (!record2(current) || typeof current.$ref !== "string" || !current.$ref.startsWith("#/") || seen.has(current.$ref)) return void 0;
143459
+ const ref = current.$ref;
143460
+ seen.add(ref);
143461
+ current = root;
143462
+ for (const part of ref.slice(2).split("/")) current = descend(current, part.replaceAll("~1", "/").replaceAll("~0", "~"));
143463
+ }
143464
+ }
143398
143465
  function relaxRejectedRecursiveProperty(request7, body) {
143399
143466
  const path92 = rejectedPath(body);
143400
143467
  if (path92 === void 0) return void 0;
143401
- const propertyIndex = path92.lastIndexOf("properties");
143402
- const name = path92[propertyIndex + 1];
143403
- if (propertyIndex < 0 || name === void 0) return void 0;
143468
+ const propertyIndices = path92.flatMap((part, index) => part === "properties" && path92[index + 1] !== void 0 ? [index] : []).reverse();
143469
+ if (propertyIndices.length === 0) return void 0;
143404
143470
  const copy2 = structuredClone(request7);
143405
143471
  let changed = false;
143406
143472
  for (const tool of copy2.tools ?? []) {
@@ -143408,18 +143474,38 @@ function relaxRejectedRecursiveProperty(request7, body) {
143408
143474
  const schema = declaration.parametersJsonSchema;
143409
143475
  if (schema === void 0) continue;
143410
143476
  let leaf = schema;
143411
- for (const part of path92) leaf = descend(leaf, part);
143477
+ for (const part of path92) leaf = descendExpanded(schema, leaf, part);
143412
143478
  if (!record2(leaf) || typeof leaf.$ref !== "string") continue;
143413
- let owner = schema;
143414
- for (const part of path92.slice(0, propertyIndex)) owner = descend(owner, part);
143415
- if (!record2(owner) || !Array.isArray(owner.required) || !owner.required.includes(name) || !record2(owner.properties)) continue;
143416
- const property = owner.properties[name];
143417
- if (!record2(property)) continue;
143418
- owner.required = owner.required.filter((item) => item !== name);
143419
- const description = typeof property.description === "string" ? `${property.description}
143479
+ let repairedProperty = false;
143480
+ for (const propertyIndex of propertyIndices) {
143481
+ const name = path92[propertyIndex + 1];
143482
+ if (name === void 0) continue;
143483
+ let owner = schema;
143484
+ for (const part of path92.slice(0, propertyIndex)) owner = descendExpanded(schema, owner, part);
143485
+ if (!record2(owner) || !Array.isArray(owner.required) || !owner.required.includes(name) || !record2(owner.properties)) continue;
143486
+ const property = owner.properties[name];
143487
+ if (!record2(property)) continue;
143488
+ owner.required = owner.required.filter((item) => item !== name);
143489
+ const description = typeof property.description === "string" ? `${property.description}
143420
143490
  ` : "";
143421
- property.description = `${description}This property is required by the original tool schema.`;
143422
- changed = true;
143491
+ property.description = `${description}This property is required by the original tool schema.`;
143492
+ changed = true;
143493
+ repairedProperty = true;
143494
+ break;
143495
+ }
143496
+ if (!repairedProperty) {
143497
+ let parent = schema;
143498
+ for (const part of path92.slice(0, -1)) parent = descendExpanded(schema, parent, part);
143499
+ const key = path92.at(-1);
143500
+ const truncated = { description: "Recursive value: the original tool schema validates this value." };
143501
+ if (record2(parent) && key !== void 0 && Object.hasOwn(parent, key)) {
143502
+ parent[key] = truncated;
143503
+ changed = true;
143504
+ } else if (Array.isArray(parent) && key !== void 0 && /^\d+$/u.test(key) && Number(key) < parent.length) {
143505
+ parent[Number(key)] = truncated;
143506
+ changed = true;
143507
+ }
143508
+ }
143423
143509
  }
143424
143510
  }
143425
143511
  return changed ? copy2 : void 0;
@@ -143612,7 +143698,7 @@ async function* callLocalAntigravity(params) {
143612
143698
  init_quota();
143613
143699
  var MS_PER_SECOND13 = 1e3;
143614
143700
  var ROUTING_MEMORY_SESSIONS = 256;
143615
- var MAX_SCHEMA_RETRIES = 16;
143701
+ var MAX_SCHEMA_RETRIES = 32;
143616
143702
  function exhaustedMessage(exhaustion) {
143617
143703
  const window = exhaustion.window === "five_hour" ? "5-hour" : "weekly";
143618
143704
  return `Antigravity ${window} limit reached; it resets at ${new Date(exhaustion.resetSec * MS_PER_SECOND13).toISOString()}.`;
@@ -144236,6 +144322,7 @@ function resolveAccountTarget(model, models) {
144236
144322
  function createProviderRouteResolver(deps) {
144237
144323
  const oauthRoute = createPassthroughRoute("anthropic", { baseUrl: `https://${CONNECT_INTERCEPT_HOST}:${String(HTTPS_PORT)}`, stripPrefix: void 0, headroomUpstream: void 0 });
144238
144324
  const resolveCredential2 = shareInFlightResolutions(resolveCredentialAsync);
144325
+ const resolveAgyCredential = createAgyCredentialResolver(deps.credentials);
144239
144326
  const antigravityQuotaSources = /* @__PURE__ */ new Map();
144240
144327
  const antigravityRoutingMemory = /* @__PURE__ */ new Map();
144241
144328
  const antigravityExhaustedModels = /* @__PURE__ */ new Map();
@@ -144274,7 +144361,7 @@ function createProviderRouteResolver(deps) {
144274
144361
  const source = createCachedAntigravityQuotaSource({
144275
144362
  now: () => Date.now(),
144276
144363
  fetchSummary: async (nowMs) => {
144277
- const res = await resolveCredential2({ credential: definition.credential, env: deps.env, port: deps.credentials, subject: `provider ${provider}` });
144364
+ const res = await resolveAgyCredential(await resolveCredential2({ credential: definition.credential, env: deps.env, port: deps.credentials, subject: `provider ${provider}` }));
144278
144365
  if (!res.ok) {
144279
144366
  return void 0;
144280
144367
  }
@@ -144344,12 +144431,12 @@ function createProviderRouteResolver(deps) {
144344
144431
  route: createAntigravityRouteMount(
144345
144432
  {
144346
144433
  loadProvider: async () => {
144347
- const res = await resolveCredential2({
144434
+ const res = await resolveAgyCredential(await resolveCredential2({
144348
144435
  credential: antigravityProvider.credential,
144349
144436
  env: deps.env,
144350
144437
  port: deps.credentials,
144351
144438
  subject: `provider ${provider}`
144352
- });
144439
+ }));
144353
144440
  if (!res.ok) {
144354
144441
  return { ok: false, status: HTTP_STATUS.unauthorized, message: res.message };
144355
144442
  }
@@ -145115,10 +145202,10 @@ function formatRcRateLimitInfo(info) {
145115
145202
  return parts.join(" ");
145116
145203
  }
145117
145204
  function formatRcStreamEvent(event) {
145118
- const { envelope } = event;
145205
+ const { envelope: envelope2 } = event;
145119
145206
  const rateLimit = rcRateLimitInfoOf(event);
145120
- const sketch = rateLimit !== void 0 ? ` ${formatRcRateLimitInfo(rateLimit)}` : envelope.payload === void 0 ? "" : ` ${eventExcerpt(JSON.stringify(envelope.payload))}`;
145121
- return `${event.session} ${envelope.event_type} sequence_num ${String(envelope.sequence_num)} source ${envelope.source}${sketch}`;
145207
+ const sketch = rateLimit !== void 0 ? ` ${formatRcRateLimitInfo(rateLimit)}` : envelope2.payload === void 0 ? "" : ` ${eventExcerpt(JSON.stringify(envelope2.payload))}`;
145208
+ return `${event.session} ${envelope2.event_type} sequence_num ${String(envelope2.sequence_num)} source ${envelope2.source}${sketch}`;
145122
145209
  }
145123
145210
  function formatRcSelfHostMint(result) {
145124
145211
  return [
@@ -146688,7 +146775,7 @@ function createRcSelfHostSurface(deps) {
146688
146775
  const workerRefusal = (headers, session) => presentsWorkerJwt(headers, session) ? void 0 : presentationRefusal(headers);
146689
146776
  const workerOrCredentialRefusal = (headers, session) => presentsWorkerJwt(headers, session) || presentsCredential(headers) ? void 0 : presentationRefusal(headers);
146690
146777
  const frameOf = (event) => {
146691
- const envelope = {
146778
+ const envelope2 = {
146692
146779
  event_id: event.eventId,
146693
146780
  event_type: nonEmptyString4(event.payload, "type") ?? "event",
146694
146781
  sequence_num: event.sequenceNum,
@@ -146698,7 +146785,7 @@ function createRcSelfHostSurface(deps) {
146698
146785
  };
146699
146786
  return `event: ${RC_STREAM_EVENT_NAME}
146700
146787
  id: ${String(event.sequenceNum)}
146701
- data: ${JSON.stringify(envelope)}
146788
+ data: ${JSON.stringify(envelope2)}
146702
146789
 
146703
146790
  `;
146704
146791
  };
@@ -147366,14 +147453,14 @@ function createRcStreamHub(deps) {
147366
147453
  attachment.controller.signal.throwIfAborted();
147367
147454
  let lastEventId;
147368
147455
  for (const parsed of parser.write(Buffer.from(chunk2).toString("utf8"))) {
147369
- const envelope = parseRcStreamEnvelope(parsed);
147370
- if (envelope === void 0) {
147456
+ const envelope2 = parseRcStreamEnvelope(parsed);
147457
+ if (envelope2 === void 0) {
147371
147458
  continue;
147372
147459
  }
147373
- deps.fileStreamEvent(attachment.sessionId, envelope);
147374
- deps.fanout.publish({ session: attachment.sessionId, envelope });
147375
- if (typeof envelope.event_id === "string" && envelope.event_type !== "mark_read") {
147376
- lastEventId = envelope.event_id;
147460
+ deps.fileStreamEvent(attachment.sessionId, envelope2);
147461
+ deps.fanout.publish({ session: attachment.sessionId, envelope: envelope2 });
147462
+ if (typeof envelope2.event_id === "string" && envelope2.event_type !== "mark_read") {
147463
+ lastEventId = envelope2.event_id;
147377
147464
  }
147378
147465
  }
147379
147466
  sendReceipt(attachment, headers, lastEventId);
package/dist/index.cjs CHANGED
@@ -5173,7 +5173,7 @@ var init_package = __esm({
5173
5173
  "package.json"() {
5174
5174
  package_default = {
5175
5175
  name: "agent-shim",
5176
- version: "11.87.0",
5176
+ version: "11.87.2",
5177
5177
  description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
5178
5178
  license: "MIT",
5179
5179
  author: "Joseph Mearman <joseph@mearman.co.uk>",
package/dist/index.mjs CHANGED
@@ -5148,7 +5148,7 @@ var init_package = __esm({
5148
5148
  "package.json"() {
5149
5149
  package_default = {
5150
5150
  name: "agent-shim",
5151
- version: "11.87.0",
5151
+ version: "11.87.2",
5152
5152
  description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
5153
5153
  license: "MIT",
5154
5154
  author: "Joseph Mearman <joseph@mearman.co.uk>",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-shim",
3
- "version": "11.87.0",
3
+ "version": "11.87.2",
4
4
  "description": "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
5
5
  "license": "MIT",
6
6
  "author": "Joseph Mearman <joseph@mearman.co.uk>",