agent-shim 11.87.0 → 11.87.1

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.1",
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;
@@ -144236,6 +144290,7 @@ function resolveAccountTarget(model, models) {
144236
144290
  function createProviderRouteResolver(deps) {
144237
144291
  const oauthRoute = createPassthroughRoute("anthropic", { baseUrl: `https://${CONNECT_INTERCEPT_HOST}:${String(HTTPS_PORT)}`, stripPrefix: void 0, headroomUpstream: void 0 });
144238
144292
  const resolveCredential2 = shareInFlightResolutions(resolveCredentialAsync);
144293
+ const resolveAgyCredential = createAgyCredentialResolver(deps.credentials);
144239
144294
  const antigravityQuotaSources = /* @__PURE__ */ new Map();
144240
144295
  const antigravityRoutingMemory = /* @__PURE__ */ new Map();
144241
144296
  const antigravityExhaustedModels = /* @__PURE__ */ new Map();
@@ -144274,7 +144329,7 @@ function createProviderRouteResolver(deps) {
144274
144329
  const source = createCachedAntigravityQuotaSource({
144275
144330
  now: () => Date.now(),
144276
144331
  fetchSummary: async (nowMs) => {
144277
- const res = await resolveCredential2({ credential: definition.credential, env: deps.env, port: deps.credentials, subject: `provider ${provider}` });
144332
+ const res = await resolveAgyCredential(await resolveCredential2({ credential: definition.credential, env: deps.env, port: deps.credentials, subject: `provider ${provider}` }));
144278
144333
  if (!res.ok) {
144279
144334
  return void 0;
144280
144335
  }
@@ -144344,12 +144399,12 @@ function createProviderRouteResolver(deps) {
144344
144399
  route: createAntigravityRouteMount(
144345
144400
  {
144346
144401
  loadProvider: async () => {
144347
- const res = await resolveCredential2({
144402
+ const res = await resolveAgyCredential(await resolveCredential2({
144348
144403
  credential: antigravityProvider.credential,
144349
144404
  env: deps.env,
144350
144405
  port: deps.credentials,
144351
144406
  subject: `provider ${provider}`
144352
- });
144407
+ }));
144353
144408
  if (!res.ok) {
144354
144409
  return { ok: false, status: HTTP_STATUS.unauthorized, message: res.message };
144355
144410
  }
@@ -145115,10 +145170,10 @@ function formatRcRateLimitInfo(info) {
145115
145170
  return parts.join(" ");
145116
145171
  }
145117
145172
  function formatRcStreamEvent(event) {
145118
- const { envelope } = event;
145173
+ const { envelope: envelope2 } = event;
145119
145174
  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}`;
145175
+ const sketch = rateLimit !== void 0 ? ` ${formatRcRateLimitInfo(rateLimit)}` : envelope2.payload === void 0 ? "" : ` ${eventExcerpt(JSON.stringify(envelope2.payload))}`;
145176
+ return `${event.session} ${envelope2.event_type} sequence_num ${String(envelope2.sequence_num)} source ${envelope2.source}${sketch}`;
145122
145177
  }
145123
145178
  function formatRcSelfHostMint(result) {
145124
145179
  return [
@@ -146688,7 +146743,7 @@ function createRcSelfHostSurface(deps) {
146688
146743
  const workerRefusal = (headers, session) => presentsWorkerJwt(headers, session) ? void 0 : presentationRefusal(headers);
146689
146744
  const workerOrCredentialRefusal = (headers, session) => presentsWorkerJwt(headers, session) || presentsCredential(headers) ? void 0 : presentationRefusal(headers);
146690
146745
  const frameOf = (event) => {
146691
- const envelope = {
146746
+ const envelope2 = {
146692
146747
  event_id: event.eventId,
146693
146748
  event_type: nonEmptyString4(event.payload, "type") ?? "event",
146694
146749
  sequence_num: event.sequenceNum,
@@ -146698,7 +146753,7 @@ function createRcSelfHostSurface(deps) {
146698
146753
  };
146699
146754
  return `event: ${RC_STREAM_EVENT_NAME}
146700
146755
  id: ${String(event.sequenceNum)}
146701
- data: ${JSON.stringify(envelope)}
146756
+ data: ${JSON.stringify(envelope2)}
146702
146757
 
146703
146758
  `;
146704
146759
  };
@@ -147366,14 +147421,14 @@ function createRcStreamHub(deps) {
147366
147421
  attachment.controller.signal.throwIfAborted();
147367
147422
  let lastEventId;
147368
147423
  for (const parsed of parser.write(Buffer.from(chunk2).toString("utf8"))) {
147369
- const envelope = parseRcStreamEnvelope(parsed);
147370
- if (envelope === void 0) {
147424
+ const envelope2 = parseRcStreamEnvelope(parsed);
147425
+ if (envelope2 === void 0) {
147371
147426
  continue;
147372
147427
  }
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;
147428
+ deps.fileStreamEvent(attachment.sessionId, envelope2);
147429
+ deps.fanout.publish({ session: attachment.sessionId, envelope: envelope2 });
147430
+ if (typeof envelope2.event_id === "string" && envelope2.event_type !== "mark_read") {
147431
+ lastEventId = envelope2.event_id;
147377
147432
  }
147378
147433
  }
147379
147434
  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.1",
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.1",
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.1",
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>",