agent-shim 11.0.0 → 11.1.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 +45 -3
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -33969,7 +33969,7 @@ var init_package = __esm({
|
|
|
33969
33969
|
"package.json"() {
|
|
33970
33970
|
package_default = {
|
|
33971
33971
|
name: "agent-shim",
|
|
33972
|
-
version: "11.
|
|
33972
|
+
version: "11.1.0",
|
|
33973
33973
|
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.",
|
|
33974
33974
|
license: "MIT",
|
|
33975
33975
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -113453,6 +113453,7 @@ function createDoorPipelines(deps) {
|
|
|
113453
113453
|
responseObservers: deps.responseObservers,
|
|
113454
113454
|
admit: admitLaunch(deps.isLiveToken),
|
|
113455
113455
|
headroom: { headroomSocket: deps.headroomSocket, hopSecret: deps.hopSecret, custody: deps.custody, log: deps.log },
|
|
113456
|
+
headroomDecision: deps.headroomDecision,
|
|
113456
113457
|
now: deps.now,
|
|
113457
113458
|
log: deps.log
|
|
113458
113459
|
},
|
|
@@ -113460,12 +113461,45 @@ function createDoorPipelines(deps) {
|
|
|
113460
113461
|
resolveRoute: deps.resolveRoute,
|
|
113461
113462
|
responseObservers: [],
|
|
113462
113463
|
admit: admitHop(deps.hopSecret, deps.custody),
|
|
113464
|
+
headroomDecision: deps.headroomDecision,
|
|
113463
113465
|
now: deps.now,
|
|
113464
113466
|
log: deps.log
|
|
113465
113467
|
}
|
|
113466
113468
|
};
|
|
113467
113469
|
}
|
|
113468
113470
|
|
|
113471
|
+
// src/frontdoor/headroomDecision.ts
|
|
113472
|
+
init_pick();
|
|
113473
|
+
function createHeadroomDecision() {
|
|
113474
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
113475
|
+
return {
|
|
113476
|
+
decide: (sessionId, wanted, nowMs) => {
|
|
113477
|
+
if (sessionId === void 0) {
|
|
113478
|
+
return wanted;
|
|
113479
|
+
}
|
|
113480
|
+
const state = sessions.get(sessionId);
|
|
113481
|
+
const atBoundary = state === void 0 || nowMs - state.lastEndedAtMs > PROMPT_CACHE_TTL_MS || state.cacheReadInputTokens === 0;
|
|
113482
|
+
const viaHeadroom = atBoundary ? wanted : state.viaHeadroom;
|
|
113483
|
+
sessions.set(sessionId, { viaHeadroom, lastEndedAtMs: state?.lastEndedAtMs ?? nowMs, cacheReadInputTokens: state?.cacheReadInputTokens ?? 0 });
|
|
113484
|
+
return viaHeadroom;
|
|
113485
|
+
},
|
|
113486
|
+
observe: ({ sessionId, endedAtMs, cacheReadInputTokens }) => {
|
|
113487
|
+
if (sessionId === void 0 || cacheReadInputTokens === void 0) {
|
|
113488
|
+
return;
|
|
113489
|
+
}
|
|
113490
|
+
const state = sessions.get(sessionId);
|
|
113491
|
+
if (state !== void 0) {
|
|
113492
|
+
sessions.set(sessionId, { ...state, lastEndedAtMs: endedAtMs, cacheReadInputTokens });
|
|
113493
|
+
}
|
|
113494
|
+
for (const [id2, held] of sessions) {
|
|
113495
|
+
if (endedAtMs - held.lastEndedAtMs > PROMPT_CACHE_TTL_MS) {
|
|
113496
|
+
sessions.delete(id2);
|
|
113497
|
+
}
|
|
113498
|
+
}
|
|
113499
|
+
}
|
|
113500
|
+
};
|
|
113501
|
+
}
|
|
113502
|
+
|
|
113469
113503
|
// src/frontdoor/commands.ts
|
|
113470
113504
|
init_capability();
|
|
113471
113505
|
init_capture();
|
|
@@ -126451,7 +126485,8 @@ async function serveRouted(request7, deps) {
|
|
|
126451
126485
|
response2.end();
|
|
126452
126486
|
return;
|
|
126453
126487
|
}
|
|
126454
|
-
const
|
|
126488
|
+
const wantsHeadroom = deps.headroomDecision.decide(identified.session.sessionId, identified.session.headroom, deps.now());
|
|
126489
|
+
const viaHeadroom = wantsHeadroom && resolution.route.headroomEligible && deps.headroom !== void 0;
|
|
126455
126490
|
const response = createRoutedResponse(request7.response, { deps, session: identified.session, route: resolution.route.name, request: { ...observed, viaHeadroom } });
|
|
126456
126491
|
try {
|
|
126457
126492
|
if (viaHeadroom) {
|
|
@@ -130625,8 +130660,14 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
130625
130660
|
log(`job keeper failed: ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
130626
130661
|
}
|
|
130627
130662
|
}, ANTHROPIC_USAGE_FRESHNESS_MS).unref();
|
|
130663
|
+
const headroomDecision = createHeadroomDecision();
|
|
130664
|
+
const recordUsage = withQuotaRefresh(usageStore.record, quotaRefresher);
|
|
130628
130665
|
const usageMiddleware = createUsageMiddleware({
|
|
130629
|
-
|
|
130666
|
+
// Each finished response also tells the per-session headroom decision when the session's cache was last touched and whether it read from it.
|
|
130667
|
+
record: (record2) => {
|
|
130668
|
+
headroomDecision.observe({ sessionId: record2.sessionId, endedAtMs: Date.parse(record2.at) + record2.durationMs, cacheReadInputTokens: record2.usage?.cacheReadInputTokens });
|
|
130669
|
+
recordUsage(record2);
|
|
130670
|
+
},
|
|
130630
130671
|
defer: (task) => {
|
|
130631
130672
|
setImmediate(task);
|
|
130632
130673
|
},
|
|
@@ -130641,6 +130682,7 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
130641
130682
|
headroomSocket: () => headroomSocketTarget(realFarmFs, realHeadroomSocketTrust, paths),
|
|
130642
130683
|
// The per-generation capability the direct listener demands: held only in this process's memory, so a loopback process that discovers the direct port still cannot use it.
|
|
130643
130684
|
hopSecret: (0, import_node_crypto20.randomUUID)(),
|
|
130685
|
+
headroomDecision,
|
|
130644
130686
|
custody: createCredentialCustody(() => (0, import_node_crypto20.randomUUID)()),
|
|
130645
130687
|
log
|
|
130646
130688
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -2758,7 +2758,7 @@ var init_package = __esm({
|
|
|
2758
2758
|
"package.json"() {
|
|
2759
2759
|
package_default = {
|
|
2760
2760
|
name: "agent-shim",
|
|
2761
|
-
version: "11.
|
|
2761
|
+
version: "11.1.0",
|
|
2762
2762
|
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.",
|
|
2763
2763
|
license: "MIT",
|
|
2764
2764
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
package/dist/index.mjs
CHANGED
|
@@ -2734,7 +2734,7 @@ var init_package = __esm({
|
|
|
2734
2734
|
"package.json"() {
|
|
2735
2735
|
package_default = {
|
|
2736
2736
|
name: "agent-shim",
|
|
2737
|
-
version: "11.
|
|
2737
|
+
version: "11.1.0",
|
|
2738
2738
|
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.",
|
|
2739
2739
|
license: "MIT",
|
|
2740
2740
|
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.
|
|
3
|
+
"version": "11.1.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>",
|