agent-shim 14.21.0 → 14.22.0

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
@@ -41086,21 +41086,19 @@ function toolSurfaceOfPath(url2) {
41086
41086
  }
41087
41087
  return SURFACE_PATHS.find(([, prefix]) => path107 === prefix || path107.startsWith(`${prefix}/`))?.[0];
41088
41088
  }
41089
+ function lendingBearer(deps, borrowerId, surface) {
41090
+ const identities = deps.identities();
41091
+ const lenderId = identities.find((identity) => identity.id === borrowerId)?.toolLogins?.[surface];
41092
+ const granted = lenderId !== void 0 && identities.find((identity) => identity.id === lenderId)?.grants?.some((grant) => grant.to === borrowerId && grant.features.includes("server-tools")) === true;
41093
+ const login = granted ? readLenderLogin(deps.loginPorts, deps.identitiesDir, lenderId) : void 0;
41094
+ return login !== void 0 && lenderLoginUsable(login, deps.now(), LENDER_LOGIN_GRACE_MS2) ? login.token : void 0;
41095
+ }
41089
41096
  function toolSurfaceAuthorizationRewriter(deps) {
41090
41097
  return (host, request7, tunnelToken) => {
41091
41098
  const surface = host === CONNECT_INTERCEPT_HOST && tunnelToken !== void 0 ? toolSurfaceOfPath(request7.url) : void 0;
41092
41099
  const borrowerId = surface === void 0 || tunnelToken === void 0 ? void 0 : deps.identityOfToken(tunnelToken);
41093
- if (surface === void 0 || borrowerId === void 0 || request7.url === void 0) {
41094
- return void 0;
41095
- }
41096
- const identities = deps.identities();
41097
- const lenderId = identities.find((identity) => identity.id === borrowerId)?.toolLogins?.[surface];
41098
- const granted = lenderId !== void 0 && identities.find((identity) => identity.id === lenderId)?.grants?.some((grant) => grant.to === borrowerId && grant.features.includes("server-tools")) === true;
41099
- const login = granted ? readLenderLogin(deps.loginPorts, deps.identitiesDir, lenderId) : void 0;
41100
- if (login === void 0 || !lenderLoginUsable(login, deps.now(), LENDER_LOGIN_GRACE_MS2)) {
41101
- return void 0;
41102
- }
41103
- return { authorization: `Bearer ${login.token}`, url: request7.url };
41100
+ const token = surface === void 0 || borrowerId === void 0 || request7.url === void 0 ? void 0 : lendingBearer(deps, borrowerId, surface);
41101
+ return token === void 0 || request7.url === void 0 ? void 0 : { authorization: `Bearer ${token}`, url: request7.url };
41104
41102
  };
41105
41103
  }
41106
41104
  var LENDER_LOGIN_GRACE_MS2, SURFACE_PATHS;
@@ -41611,14 +41609,20 @@ function wiredAuthorizationRewriter(paths, identityOfToken, loginPorts) {
41611
41609
  loginPorts,
41612
41610
  now: Date.now
41613
41611
  });
41614
- const tools = toolSurfaceAuthorizationRewriter({
41615
- identityOfToken,
41612
+ const tools = toolSurfaceAuthorizationRewriter({ identityOfToken, ...toolSurfaceLendingDeps(paths, loginPorts) });
41613
+ return (host, request7, tunnelToken) => connector(host, request7, tunnelToken) ?? tools(host, request7, tunnelToken);
41614
+ }
41615
+ function toolSurfaceLendingDeps(paths, loginPorts) {
41616
+ return {
41616
41617
  identities: () => listIdentities(paths).flatMap((entry) => entry.problem === void 0 ? [{ id: entry.id, name: entry.name, grants: entry.identity.grants, toolLogins: entry.identity.toolLogins }] : []),
41617
41618
  identitiesDir: paths.identitiesDir,
41618
41619
  loginPorts,
41619
41620
  now: Date.now
41620
- });
41621
- return (host, request7, tunnelToken) => connector(host, request7, tunnelToken) ?? tools(host, request7, tunnelToken);
41621
+ };
41622
+ }
41623
+ function wiredLendWebSearch(paths, loginPorts) {
41624
+ const deps = toolSurfaceLendingDeps(paths, loginPorts);
41625
+ return (identityId) => lendingBearer(deps, identityId, "web-search");
41622
41626
  }
41623
41627
  function wiredMergeConnectorList2(paths, apiBase, loginPorts) {
41624
41628
  return wiredMergeConnectorList({
@@ -76955,7 +76959,7 @@ var init_package = __esm({
76955
76959
  "package.json"() {
76956
76960
  package_default = {
76957
76961
  name: "agent-shim",
76958
- version: "14.21.0",
76962
+ version: "14.22.0",
76959
76963
  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.",
76960
76964
  license: "MIT",
76961
76965
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -136830,7 +136834,8 @@ function createDoorPipelines(deps) {
136830
136834
  canonicalProvider: deps.canonicalProvider,
136831
136835
  now: deps.now,
136832
136836
  log: deps.log,
136833
- ...deps.mergeConnectorList === void 0 ? {} : { mergeConnectorList: deps.mergeConnectorList }
136837
+ ...deps.mergeConnectorList === void 0 ? {} : { mergeConnectorList: deps.mergeConnectorList },
136838
+ ...deps.lendWebSearch === void 0 ? {} : { lendWebSearch: deps.lendWebSearch }
136834
136839
  },
136835
136840
  direct: {
136836
136841
  resolveRoute: deps.resolveRoute,
@@ -151148,6 +151153,37 @@ function bufferingRoutedResponse(inner, transform2) {
151148
151153
  };
151149
151154
  }
151150
151155
 
151156
+ // src/webSearchRequest.ts
151157
+ var WEB_SEARCH_BODY_CAP_BYTES = 65536;
151158
+ var WEB_SEARCH_TOOL_PREFIX = "web_search_";
151159
+ function isWebSearchRequestBody(bodyText) {
151160
+ let parsed;
151161
+ try {
151162
+ parsed = JSON.parse(bodyText);
151163
+ } catch {
151164
+ return false;
151165
+ }
151166
+ if (typeof parsed !== "object" || parsed === null) {
151167
+ return false;
151168
+ }
151169
+ const tools = Reflect.get(parsed, "tools");
151170
+ return Array.isArray(tools) && tools.some((tool) => typeof tool === "object" && tool !== null && typeof Reflect.get(tool, "type") === "string" && String(Reflect.get(tool, "type")).startsWith(WEB_SEARCH_TOOL_PREFIX));
151171
+ }
151172
+
151173
+ // src/frontdoor/webSearchLending.ts
151174
+ var MESSAGES_PATH2 = "/v1/messages";
151175
+ async function withLentWebSearch(request7, identityId, lend) {
151176
+ if (lend === void 0 || identityId === void 0 || request7.method !== "POST" || request7.url.split("?", 1)[0] !== MESSAGES_PATH2 || request7.session.provider !== void 0 || !(declaredLength(request7.headers) <= WEB_SEARCH_BODY_CAP_BYTES)) {
151177
+ return request7;
151178
+ }
151179
+ const scanned = await scanRequestHead(request7, true, void 0, WEB_SEARCH_BODY_CAP_BYTES);
151180
+ if (scanned.tooLarge === true) {
151181
+ throw new Error("a request declared a body within the web-search read cap and then sent more");
151182
+ }
151183
+ const bearer = scanned.text !== void 0 && isWebSearchRequestBody(scanned.text) ? lend(identityId) : void 0;
151184
+ return bearer === void 0 ? scanned.replayed : { ...scanned.replayed, headers: { ...scanned.replayed.headers, authorization: `Bearer ${bearer}` } };
151185
+ }
151186
+
151151
151187
  // src/frontdoor/pipeline.ts
151152
151188
  var MCP_SERVERS_PATH2 = "/v1/mcp_servers";
151153
151189
  function errorTypeFor(status) {
@@ -151301,7 +151337,7 @@ async function serveRouted(incoming, givenDeps) {
151301
151337
  response2.end();
151302
151338
  return;
151303
151339
  }
151304
- const routed = {
151340
+ const unlent = {
151305
151341
  method: request7.method,
151306
151342
  url: request7.url,
151307
151343
  headers: admission.headers,
@@ -151313,6 +151349,7 @@ async function serveRouted(incoming, givenDeps) {
151313
151349
  ...admission.launch === void 0 ? {} : { launch: admission.launch }
151314
151350
  }
151315
151351
  };
151352
+ const routed = await withLentWebSearch(unlent, admission.identity, deps.lendWebSearch);
151316
151353
  const resolution = await deps.resolveRoute(routed);
151317
151354
  if (!resolution.ok) {
151318
151355
  const response2 = createRoutedResponse(request7.response, { deps, session: identified.session, route: "(unrouted)", request: observed, servedPath: observed.path });
@@ -158752,7 +158789,8 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
158752
158789
  headroomDecision,
158753
158790
  custody: createCredentialCustody(() => (0, import_node_crypto35.randomUUID)()),
158754
158791
  log,
158755
- mergeConnectorList: wiredMergeConnectorList2(paths, `https://${CONNECT_INTERCEPT_HOST}`, { fs: realFarmFs, run: realRunPort, platform: process.platform })
158792
+ mergeConnectorList: wiredMergeConnectorList2(paths, `https://${CONNECT_INTERCEPT_HOST}`, { fs: realFarmFs, run: realRunPort, platform: process.platform }),
158793
+ lendWebSearch: wiredLendWebSearch(paths, { fs: realFarmFs, run: realRunPort, platform: process.platform })
158756
158794
  });
158757
158795
  const onListenerError = (name) => (error63) => {
158758
158796
  appendDoorLog(paths, `frontdoor ${String(process.pid)}: ${name} listener failed: ${error63.message}; exiting`);
package/dist/index.cjs CHANGED
@@ -15420,7 +15420,7 @@ var init_package = __esm({
15420
15420
  "package.json"() {
15421
15421
  package_default = {
15422
15422
  name: "agent-shim",
15423
- version: "14.21.0",
15423
+ version: "14.22.0",
15424
15424
  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.",
15425
15425
  license: "MIT",
15426
15426
  author: "Joseph Mearman <joseph@mearman.co.uk>",
package/dist/index.mjs CHANGED
@@ -15391,7 +15391,7 @@ var init_package = __esm({
15391
15391
  "package.json"() {
15392
15392
  package_default = {
15393
15393
  name: "agent-shim",
15394
- version: "14.21.0",
15394
+ version: "14.22.0",
15395
15395
  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.",
15396
15396
  license: "MIT",
15397
15397
  author: "Joseph Mearman <joseph@mearman.co.uk>",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-shim",
3
- "version": "14.21.0",
3
+ "version": "14.22.0",
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>",