agent-shim 11.4.1 → 11.5.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 +334 -63
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/types/index.d.ts +28 -28
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -23007,7 +23007,7 @@ var require_dumper = __commonJS({
|
|
|
23007
23007
|
}
|
|
23008
23008
|
return false;
|
|
23009
23009
|
}
|
|
23010
|
-
function
|
|
23010
|
+
function isWhitespace2(c10) {
|
|
23011
23011
|
return c10 === CHAR_SPACE || c10 === CHAR_TAB;
|
|
23012
23012
|
}
|
|
23013
23013
|
function isPrintable(c10) {
|
|
@@ -23019,19 +23019,19 @@ var require_dumper = __commonJS({
|
|
|
23019
23019
|
}
|
|
23020
23020
|
function isPlainSafe(c10, prev, inblock) {
|
|
23021
23021
|
const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c10);
|
|
23022
|
-
const cIsNsChar = cIsNsCharOrWhitespace && !
|
|
23022
|
+
const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace2(c10);
|
|
23023
23023
|
return (
|
|
23024
23024
|
// ns-plain-safe
|
|
23025
23025
|
(inblock ? cIsNsCharOrWhitespace : cIsNsCharOrWhitespace && // - c-flow-indicator
|
|
23026
23026
|
c10 !== CHAR_COMMA && c10 !== CHAR_LEFT_SQUARE_BRACKET && c10 !== CHAR_RIGHT_SQUARE_BRACKET && c10 !== CHAR_LEFT_CURLY_BRACKET && c10 !== CHAR_RIGHT_CURLY_BRACKET) && // ns-plain-char
|
|
23027
23027
|
c10 !== CHAR_SHARP && // false on '#'
|
|
23028
23028
|
!(prev === CHAR_COLON && !cIsNsChar) || // false on ': '
|
|
23029
|
-
isNsCharOrWhitespace(prev) && !
|
|
23029
|
+
isNsCharOrWhitespace(prev) && !isWhitespace2(prev) && c10 === CHAR_SHARP || // change to true on '[^ ]#'
|
|
23030
23030
|
prev === CHAR_COLON && cIsNsChar
|
|
23031
23031
|
);
|
|
23032
23032
|
}
|
|
23033
23033
|
function isPlainSafeFirst(c10) {
|
|
23034
|
-
return isPrintable(c10) && c10 !== CHAR_BOM && !
|
|
23034
|
+
return isPrintable(c10) && c10 !== CHAR_BOM && !isWhitespace2(c10) && // - s-white
|
|
23035
23035
|
// - (c-indicator ::=
|
|
23036
23036
|
// “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
|
|
23037
23037
|
c10 !== CHAR_MINUS && c10 !== CHAR_QUESTION && c10 !== CHAR_COLON && c10 !== CHAR_COMMA && c10 !== CHAR_LEFT_SQUARE_BRACKET && c10 !== CHAR_RIGHT_SQUARE_BRACKET && c10 !== CHAR_LEFT_CURLY_BRACKET && c10 !== CHAR_RIGHT_CURLY_BRACKET && // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
|
|
@@ -23039,7 +23039,7 @@ var require_dumper = __commonJS({
|
|
|
23039
23039
|
c10 !== CHAR_PERCENT && c10 !== CHAR_COMMERCIAL_AT && c10 !== CHAR_GRAVE_ACCENT;
|
|
23040
23040
|
}
|
|
23041
23041
|
function isPlainSafeLast(c10) {
|
|
23042
|
-
return !
|
|
23042
|
+
return !isWhitespace2(c10) && c10 !== CHAR_COLON;
|
|
23043
23043
|
}
|
|
23044
23044
|
function codePointAt(string4, pos) {
|
|
23045
23045
|
const first = string4.charCodeAt(pos);
|
|
@@ -31952,9 +31952,9 @@ function referencesFact(when, key) {
|
|
|
31952
31952
|
if (when === void 0 || !("kind" in when)) {
|
|
31953
31953
|
return false;
|
|
31954
31954
|
}
|
|
31955
|
-
const
|
|
31955
|
+
const walk2 = (node2) => {
|
|
31956
31956
|
if (Array.isArray(node2)) {
|
|
31957
|
-
return node2.some(
|
|
31957
|
+
return node2.some(walk2);
|
|
31958
31958
|
}
|
|
31959
31959
|
if (typeof node2 !== "object" || node2 === null) {
|
|
31960
31960
|
return false;
|
|
@@ -31962,9 +31962,9 @@ function referencesFact(when, key) {
|
|
|
31962
31962
|
if ("kind" in node2 && node2.kind === "reference" && "key" in node2 && node2.key === key) {
|
|
31963
31963
|
return true;
|
|
31964
31964
|
}
|
|
31965
|
-
return Object.values(node2).some(
|
|
31965
|
+
return Object.values(node2).some(walk2);
|
|
31966
31966
|
};
|
|
31967
|
-
return
|
|
31967
|
+
return walk2(when);
|
|
31968
31968
|
}
|
|
31969
31969
|
function isVacuousWhen(when) {
|
|
31970
31970
|
return when !== void 0 && !("kind" in when) && Object.keys(when).length === 0;
|
|
@@ -33976,7 +33976,7 @@ var init_package = __esm({
|
|
|
33976
33976
|
"package.json"() {
|
|
33977
33977
|
package_default = {
|
|
33978
33978
|
name: "agent-shim",
|
|
33979
|
-
version: "11.
|
|
33979
|
+
version: "11.5.0",
|
|
33980
33980
|
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.",
|
|
33981
33981
|
license: "MIT",
|
|
33982
33982
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -34635,7 +34635,7 @@ function createUsageMiddleware(deps) {
|
|
|
34635
34635
|
const endedAt = deps.now();
|
|
34636
34636
|
deps.defer(() => {
|
|
34637
34637
|
try {
|
|
34638
|
-
deps.record(buildRecord(event, { headAt, endedAt, outcome, scan: scanning && scanner !== void 0 ? scanner.result() : void 0 }));
|
|
34638
|
+
deps.record(buildRecord(event, { headAt, endedAt, outcome, scan: scanning && scanner !== void 0 ? scanner.result() : void 0 }), event);
|
|
34639
34639
|
} catch (error63) {
|
|
34640
34640
|
deps.log(`usage: could not record ${event.method} ${event.path} (${String(event.status)}): ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
34641
34641
|
}
|
|
@@ -40329,7 +40329,7 @@ var require_webidl = __commonJS({
|
|
|
40329
40329
|
var { runtimeFeatures } = require_runtime_features();
|
|
40330
40330
|
var UNDEFINED = 1;
|
|
40331
40331
|
var BOOLEAN = 2;
|
|
40332
|
-
var
|
|
40332
|
+
var STRING2 = 3;
|
|
40333
40333
|
var SYMBOL = 4;
|
|
40334
40334
|
var NUMBER = 5;
|
|
40335
40335
|
var BIGINT = 6;
|
|
@@ -40400,7 +40400,7 @@ var require_webidl = __commonJS({
|
|
|
40400
40400
|
case "boolean":
|
|
40401
40401
|
return BOOLEAN;
|
|
40402
40402
|
case "string":
|
|
40403
|
-
return
|
|
40403
|
+
return STRING2;
|
|
40404
40404
|
case "symbol":
|
|
40405
40405
|
return SYMBOL;
|
|
40406
40406
|
case "number":
|
|
@@ -40419,7 +40419,7 @@ var require_webidl = __commonJS({
|
|
|
40419
40419
|
webidl.util.Types = {
|
|
40420
40420
|
UNDEFINED,
|
|
40421
40421
|
BOOLEAN,
|
|
40422
|
-
STRING,
|
|
40422
|
+
STRING: STRING2,
|
|
40423
40423
|
SYMBOL,
|
|
40424
40424
|
NUMBER,
|
|
40425
40425
|
BIGINT,
|
|
@@ -40432,7 +40432,7 @@ var require_webidl = __commonJS({
|
|
|
40432
40432
|
return "Undefined";
|
|
40433
40433
|
case BOOLEAN:
|
|
40434
40434
|
return "Boolean";
|
|
40435
|
-
case
|
|
40435
|
+
case STRING2:
|
|
40436
40436
|
return "String";
|
|
40437
40437
|
case SYMBOL:
|
|
40438
40438
|
return "Symbol";
|
|
@@ -40518,7 +40518,7 @@ var require_webidl = __commonJS({
|
|
|
40518
40518
|
return `Symbol(${V7.description})`;
|
|
40519
40519
|
case OBJECT:
|
|
40520
40520
|
return inspect(V7);
|
|
40521
|
-
case
|
|
40521
|
+
case STRING2:
|
|
40522
40522
|
return `"${V7}"`;
|
|
40523
40523
|
case BIGINT:
|
|
40524
40524
|
return `${V7}n`;
|
|
@@ -60955,8 +60955,8 @@ var require_eventsource_stream = __commonJS({
|
|
|
60955
60955
|
var BOM = [239, 187, 191];
|
|
60956
60956
|
var LF3 = 10;
|
|
60957
60957
|
var CR3 = 13;
|
|
60958
|
-
var
|
|
60959
|
-
var
|
|
60958
|
+
var COLON2 = 58;
|
|
60959
|
+
var SPACE3 = 32;
|
|
60960
60960
|
var DATA = Buffer.from("data");
|
|
60961
60961
|
var EVENT = Buffer.from("event");
|
|
60962
60962
|
var ID2 = Buffer.from("id");
|
|
@@ -61101,7 +61101,7 @@ var require_eventsource_stream = __commonJS({
|
|
|
61101
61101
|
if (line.length === 0) {
|
|
61102
61102
|
return;
|
|
61103
61103
|
}
|
|
61104
|
-
const colonPosition = line.indexOf(
|
|
61104
|
+
const colonPosition = line.indexOf(COLON2);
|
|
61105
61105
|
if (colonPosition === 0) {
|
|
61106
61106
|
return;
|
|
61107
61107
|
}
|
|
@@ -61110,7 +61110,7 @@ var require_eventsource_stream = __commonJS({
|
|
|
61110
61110
|
if (colonPosition !== -1) {
|
|
61111
61111
|
fieldLength = colonPosition;
|
|
61112
61112
|
valueStart = colonPosition + 1;
|
|
61113
|
-
if (line[valueStart] ===
|
|
61113
|
+
if (line[valueStart] === SPACE3) {
|
|
61114
61114
|
++valueStart;
|
|
61115
61115
|
}
|
|
61116
61116
|
}
|
|
@@ -61304,7 +61304,7 @@ var require_eventsource = __commonJS({
|
|
|
61304
61304
|
var experimentalWarned = false;
|
|
61305
61305
|
var defaultReconnectionTime = 3e3;
|
|
61306
61306
|
var CONNECTING = 0;
|
|
61307
|
-
var
|
|
61307
|
+
var OPEN2 = 1;
|
|
61308
61308
|
var CLOSED = 2;
|
|
61309
61309
|
var ANONYMOUS = "anonymous";
|
|
61310
61310
|
var USE_CREDENTIALS = "use-credentials";
|
|
@@ -61437,7 +61437,7 @@ var require_eventsource = __commonJS({
|
|
|
61437
61437
|
this.dispatchEvent(new Event("error"));
|
|
61438
61438
|
return;
|
|
61439
61439
|
}
|
|
61440
|
-
this.#readyState =
|
|
61440
|
+
this.#readyState = OPEN2;
|
|
61441
61441
|
this.dispatchEvent(new Event("open"));
|
|
61442
61442
|
this.#state.origin = response.urlList[response.urlList.length - 1].origin;
|
|
61443
61443
|
const eventSourceStream = new EventSourceStream({
|
|
@@ -61547,7 +61547,7 @@ var require_eventsource = __commonJS({
|
|
|
61547
61547
|
__proto__: null,
|
|
61548
61548
|
configurable: false,
|
|
61549
61549
|
enumerable: true,
|
|
61550
|
-
value:
|
|
61550
|
+
value: OPEN2,
|
|
61551
61551
|
writable: false
|
|
61552
61552
|
},
|
|
61553
61553
|
CLOSED: {
|
|
@@ -62357,7 +62357,7 @@ function isAnthropicUsageStale(member, nowMs) {
|
|
|
62357
62357
|
function poolIdentityNames(pools, poolName) {
|
|
62358
62358
|
const seenPools = /* @__PURE__ */ new Set();
|
|
62359
62359
|
const identities = /* @__PURE__ */ new Set();
|
|
62360
|
-
const
|
|
62360
|
+
const walk2 = (name) => {
|
|
62361
62361
|
const pool = pools[name];
|
|
62362
62362
|
if (pool === void 0 || seenPools.has(name)) {
|
|
62363
62363
|
return;
|
|
@@ -62369,11 +62369,11 @@ function poolIdentityNames(pools, poolName) {
|
|
|
62369
62369
|
if (nested === void 0) {
|
|
62370
62370
|
identities.add(member);
|
|
62371
62371
|
} else {
|
|
62372
|
-
|
|
62372
|
+
walk2(nested);
|
|
62373
62373
|
}
|
|
62374
62374
|
}
|
|
62375
62375
|
};
|
|
62376
|
-
|
|
62376
|
+
walk2(poolName);
|
|
62377
62377
|
return [...identities];
|
|
62378
62378
|
}
|
|
62379
62379
|
function describeError(error63) {
|
|
@@ -109499,7 +109499,7 @@ function writePools(paths, pools) {
|
|
|
109499
109499
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
109500
109500
|
}
|
|
109501
109501
|
function poolCycleOf(pools, name) {
|
|
109502
|
-
const
|
|
109502
|
+
const walk2 = (current, path59) => {
|
|
109503
109503
|
for (const entry of pools[current]?.identities ?? []) {
|
|
109504
109504
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
109505
109505
|
if (nested === void 0) {
|
|
@@ -109511,14 +109511,14 @@ function poolCycleOf(pools, name) {
|
|
|
109511
109511
|
if (path59.includes(nested)) {
|
|
109512
109512
|
continue;
|
|
109513
109513
|
}
|
|
109514
|
-
const found =
|
|
109514
|
+
const found = walk2(nested, [...path59, nested]);
|
|
109515
109515
|
if (found !== void 0) {
|
|
109516
109516
|
return found;
|
|
109517
109517
|
}
|
|
109518
109518
|
}
|
|
109519
109519
|
return void 0;
|
|
109520
109520
|
};
|
|
109521
|
-
return
|
|
109521
|
+
return walk2(name, [name]);
|
|
109522
109522
|
}
|
|
109523
109523
|
function validateMembers(pools, name, members2) {
|
|
109524
109524
|
for (const entry of members2) {
|
|
@@ -112452,7 +112452,7 @@ function registerCodexCommand(program2, deps) {
|
|
|
112452
112452
|
}
|
|
112453
112453
|
|
|
112454
112454
|
// src/frontdoor/commands.ts
|
|
112455
|
-
var
|
|
112455
|
+
var import_node_crypto21 = require("node:crypto");
|
|
112456
112456
|
var import_node_path51 = __toESM(require("node:path"), 1);
|
|
112457
112457
|
var import_node_fs18 = __toESM(require("node:fs"), 1);
|
|
112458
112458
|
init_commandDeps();
|
|
@@ -113671,8 +113671,11 @@ function createRoutingSettingReader(paths) {
|
|
|
113671
113671
|
|
|
113672
113672
|
// src/frontdoor/headroomDecision.ts
|
|
113673
113673
|
init_pick();
|
|
113674
|
+
var CONSECUTIVE_PREFIX_MISSES = 2;
|
|
113675
|
+
var SHORTEST_PROMPT_CACHE_TTL_MS = 3e5;
|
|
113674
113676
|
function createHeadroomDecision(setting) {
|
|
113675
113677
|
const sessions = /* @__PURE__ */ new Map();
|
|
113678
|
+
const threads = /* @__PURE__ */ new Map();
|
|
113676
113679
|
return {
|
|
113677
113680
|
decide: async (sessionId, launchFlag, nowMs, available) => {
|
|
113678
113681
|
const choice = choiceFor(setting(), sessionId);
|
|
@@ -113683,29 +113686,46 @@ function createHeadroomDecision(setting) {
|
|
|
113683
113686
|
const state = sessions.get(sessionId);
|
|
113684
113687
|
const forced = choice?.force !== void 0 && choice.force !== state?.appliedForce;
|
|
113685
113688
|
const atBoundary = forced || state === void 0 || nowMs - state.lastEndedAtMs > PROMPT_CACHE_TTL_MS || state.cacheSurplusTokens <= 0;
|
|
113686
|
-
const
|
|
113689
|
+
const prefixBroken = state?.prefixBroken ?? false;
|
|
113690
|
+
const viaHeadroom = atBoundary ? wanted && !prefixBroken && await available() : state.viaHeadroom;
|
|
113687
113691
|
sessions.set(sessionId, {
|
|
113688
113692
|
viaHeadroom,
|
|
113689
113693
|
lastEndedAtMs: state?.lastEndedAtMs ?? nowMs,
|
|
113690
113694
|
cacheSurplusTokens: state?.cacheSurplusTokens ?? 0,
|
|
113691
|
-
appliedForce: choice?.force ?? state?.appliedForce
|
|
113695
|
+
appliedForce: choice?.force ?? state?.appliedForce,
|
|
113696
|
+
prefixMisses: state?.prefixMisses ?? 0,
|
|
113697
|
+
prefixBroken
|
|
113692
113698
|
});
|
|
113693
113699
|
return viaHeadroom;
|
|
113694
113700
|
},
|
|
113695
|
-
observe: ({ sessionId, endedAtMs, cache }) => {
|
|
113701
|
+
observe: ({ sessionId, startedAtMs, endedAtMs, viaHeadroom, lineage, cache }) => {
|
|
113696
113702
|
if (sessionId === void 0 || cache === void 0) {
|
|
113697
113703
|
return;
|
|
113698
113704
|
}
|
|
113699
113705
|
const cacheSurplusTokens = cache.readTokens - cache.writtenTokens - cache.uncachedTokens;
|
|
113700
113706
|
const state = sessions.get(sessionId);
|
|
113707
|
+
let { prefixMisses, prefixBroken } = state ?? { prefixMisses: 0, prefixBroken: false };
|
|
113708
|
+
if (lineage !== void 0) {
|
|
113709
|
+
const previous = lineage.parentKey === void 0 ? void 0 : threads.get(`${sessionId}:${lineage.parentKey}`);
|
|
113710
|
+
if (previous !== void 0 && previous.viaHeadroom && viaHeadroom && startedAtMs - previous.endedAtMs <= SHORTEST_PROMPT_CACHE_TTL_MS) {
|
|
113711
|
+
prefixMisses = cache.readTokens < previous.cachedTokens ? prefixMisses + 1 : 0;
|
|
113712
|
+
prefixBroken = prefixBroken || prefixMisses >= CONSECUTIVE_PREFIX_MISSES;
|
|
113713
|
+
}
|
|
113714
|
+
threads.set(`${sessionId}:${lineage.ownKey}`, { cachedTokens: cache.readTokens + cache.writtenTokens, endedAtMs, viaHeadroom });
|
|
113715
|
+
}
|
|
113701
113716
|
if (state !== void 0) {
|
|
113702
|
-
sessions.set(sessionId, { ...state, lastEndedAtMs: endedAtMs, cacheSurplusTokens });
|
|
113717
|
+
sessions.set(sessionId, { ...state, lastEndedAtMs: endedAtMs, cacheSurplusTokens, prefixMisses, prefixBroken });
|
|
113703
113718
|
}
|
|
113704
113719
|
for (const [id2, held] of sessions) {
|
|
113705
113720
|
if (endedAtMs - held.lastEndedAtMs > PROMPT_CACHE_TTL_MS) {
|
|
113706
113721
|
sessions.delete(id2);
|
|
113707
113722
|
}
|
|
113708
113723
|
}
|
|
113724
|
+
for (const [id2, point] of threads) {
|
|
113725
|
+
if (endedAtMs - point.endedAtMs > PROMPT_CACHE_TTL_MS) {
|
|
113726
|
+
threads.delete(id2);
|
|
113727
|
+
}
|
|
113728
|
+
}
|
|
113709
113729
|
}
|
|
113710
113730
|
};
|
|
113711
113731
|
}
|
|
@@ -126414,6 +126434,212 @@ function createLaunchEventPublisher(hub, now) {
|
|
|
126414
126434
|
var http4 = __toESM(require("node:http"), 1);
|
|
126415
126435
|
var import_consumers = require("node:stream/consumers");
|
|
126416
126436
|
init_route();
|
|
126437
|
+
|
|
126438
|
+
// src/frontdoor/lineage.ts
|
|
126439
|
+
var import_node_crypto18 = require("node:crypto");
|
|
126440
|
+
var CACHE_MARKER_KEY = '"cache_control"';
|
|
126441
|
+
var THREAD_MEMBER_KEYS = /* @__PURE__ */ new Set(['"model"', '"system"', '"tools"']);
|
|
126442
|
+
var MESSAGES_KEY = '"messages"';
|
|
126443
|
+
var NESTING_DEPTH_LIMIT = 64;
|
|
126444
|
+
var MESSAGES_PER_REQUEST_LIMIT = 1e5;
|
|
126445
|
+
var CONTEXT_WINDOW_TOKENS = 1e6;
|
|
126446
|
+
var BYTES_PER_TOKEN = 4;
|
|
126447
|
+
var LINEAGE_BODY_BYTES_LIMIT = CONTEXT_WINDOW_TOKENS * BYTES_PER_TOKEN;
|
|
126448
|
+
var MESSAGES_ARRAY_DEPTH = 2;
|
|
126449
|
+
var MESSAGES_PER_TURN = 2;
|
|
126450
|
+
var QUOTE = 34;
|
|
126451
|
+
var BACKSLASH = 92;
|
|
126452
|
+
var OPEN_BRACE = 123;
|
|
126453
|
+
var CLOSE_BRACE = 125;
|
|
126454
|
+
var OPEN_BRACKET = 91;
|
|
126455
|
+
var CLOSE_BRACKET = 93;
|
|
126456
|
+
var COLON = 58;
|
|
126457
|
+
var COMMA = 44;
|
|
126458
|
+
var SEPARATOR = Buffer.from([0]);
|
|
126459
|
+
var SPACE2 = 32;
|
|
126460
|
+
var TAB = 9;
|
|
126461
|
+
var LINE_FEED2 = 10;
|
|
126462
|
+
var CARRIAGE_RETURN = 13;
|
|
126463
|
+
function isWhitespace(byte) {
|
|
126464
|
+
return byte === SPACE2 || byte === TAB || byte === LINE_FEED2 || byte === CARRIAGE_RETURN;
|
|
126465
|
+
}
|
|
126466
|
+
var STRING = 1;
|
|
126467
|
+
var OPEN = 2;
|
|
126468
|
+
var CLOSE = 3;
|
|
126469
|
+
var COLON_TOKEN = 4;
|
|
126470
|
+
var COMMA_TOKEN = 5;
|
|
126471
|
+
var SCALAR = 6;
|
|
126472
|
+
var END = 0;
|
|
126473
|
+
var tokenStart = 0;
|
|
126474
|
+
var tokenEnd = 0;
|
|
126475
|
+
function nextToken(body, from) {
|
|
126476
|
+
let index = from;
|
|
126477
|
+
while (index < body.length && isWhitespace(body[index] ?? 0)) {
|
|
126478
|
+
index += 1;
|
|
126479
|
+
}
|
|
126480
|
+
if (index >= body.length) {
|
|
126481
|
+
return END;
|
|
126482
|
+
}
|
|
126483
|
+
tokenStart = index;
|
|
126484
|
+
const byte = body[index] ?? 0;
|
|
126485
|
+
if (byte === QUOTE) {
|
|
126486
|
+
let end = index + 1;
|
|
126487
|
+
while (end < body.length && body[end] !== QUOTE) {
|
|
126488
|
+
end += body[end] === BACKSLASH ? 2 : 1;
|
|
126489
|
+
}
|
|
126490
|
+
tokenEnd = Math.min(end + 1, body.length);
|
|
126491
|
+
return STRING;
|
|
126492
|
+
}
|
|
126493
|
+
tokenEnd = index + 1;
|
|
126494
|
+
if (byte === OPEN_BRACE || byte === OPEN_BRACKET) {
|
|
126495
|
+
return OPEN;
|
|
126496
|
+
}
|
|
126497
|
+
if (byte === CLOSE_BRACE || byte === CLOSE_BRACKET) {
|
|
126498
|
+
return CLOSE;
|
|
126499
|
+
}
|
|
126500
|
+
if (byte === COLON) {
|
|
126501
|
+
return COLON_TOKEN;
|
|
126502
|
+
}
|
|
126503
|
+
if (byte === COMMA) {
|
|
126504
|
+
return COMMA_TOKEN;
|
|
126505
|
+
}
|
|
126506
|
+
while (tokenEnd < body.length) {
|
|
126507
|
+
const next = body[tokenEnd] ?? 0;
|
|
126508
|
+
if (isWhitespace(next) || next === COMMA || next === CLOSE_BRACE || next === CLOSE_BRACKET || next === COLON) {
|
|
126509
|
+
break;
|
|
126510
|
+
}
|
|
126511
|
+
tokenEnd += 1;
|
|
126512
|
+
}
|
|
126513
|
+
return SCALAR;
|
|
126514
|
+
}
|
|
126515
|
+
function walk(body, hashing, parentAfter) {
|
|
126516
|
+
const thread = (0, import_node_crypto18.createHash)("sha256");
|
|
126517
|
+
const messages = (0, import_node_crypto18.createHash)("sha256");
|
|
126518
|
+
let parentDigest;
|
|
126519
|
+
let elements = 0;
|
|
126520
|
+
let depth = 0;
|
|
126521
|
+
let topKey;
|
|
126522
|
+
let inMessages = false;
|
|
126523
|
+
let sawMessages = false;
|
|
126524
|
+
const expectKey = [];
|
|
126525
|
+
let skipUntilDepth;
|
|
126526
|
+
let skipNextValue = false;
|
|
126527
|
+
const elementEnded = () => {
|
|
126528
|
+
elements += 1;
|
|
126529
|
+
if (hashing && parentAfter !== void 0 && elements === parentAfter) {
|
|
126530
|
+
parentDigest = messages.copy().digest("hex");
|
|
126531
|
+
}
|
|
126532
|
+
return elements > MESSAGES_PER_REQUEST_LIMIT;
|
|
126533
|
+
};
|
|
126534
|
+
const overLimit = () => ({ abandoned: true, sawMessages, elements, threadDigest: "", messagesDigest: "", parentDigest: void 0 });
|
|
126535
|
+
let cursor3 = 0;
|
|
126536
|
+
let lexicalTokens = 0;
|
|
126537
|
+
for (; ; ) {
|
|
126538
|
+
const kind = nextToken(body, cursor3);
|
|
126539
|
+
if (kind === END) {
|
|
126540
|
+
break;
|
|
126541
|
+
}
|
|
126542
|
+
lexicalTokens += 1;
|
|
126543
|
+
if (lexicalTokens > CONTEXT_WINDOW_TOKENS) {
|
|
126544
|
+
return overLimit();
|
|
126545
|
+
}
|
|
126546
|
+
const start = tokenStart;
|
|
126547
|
+
const end = tokenEnd;
|
|
126548
|
+
cursor3 = end;
|
|
126549
|
+
if (skipUntilDepth !== void 0) {
|
|
126550
|
+
if (kind === OPEN) {
|
|
126551
|
+
depth += 1;
|
|
126552
|
+
} else if (kind === CLOSE) {
|
|
126553
|
+
depth -= 1;
|
|
126554
|
+
if (depth === skipUntilDepth) {
|
|
126555
|
+
skipUntilDepth = void 0;
|
|
126556
|
+
}
|
|
126557
|
+
}
|
|
126558
|
+
continue;
|
|
126559
|
+
}
|
|
126560
|
+
if (kind === COMMA_TOKEN) {
|
|
126561
|
+
if (depth >= 1) {
|
|
126562
|
+
expectKey[depth - 1] = true;
|
|
126563
|
+
}
|
|
126564
|
+
continue;
|
|
126565
|
+
}
|
|
126566
|
+
if (kind === COLON_TOKEN) {
|
|
126567
|
+
if (depth >= 1) {
|
|
126568
|
+
expectKey[depth - 1] = false;
|
|
126569
|
+
}
|
|
126570
|
+
if (skipNextValue) {
|
|
126571
|
+
skipNextValue = false;
|
|
126572
|
+
const valueKind = nextToken(body, cursor3);
|
|
126573
|
+
if (valueKind !== END) {
|
|
126574
|
+
cursor3 = tokenEnd;
|
|
126575
|
+
if (valueKind === OPEN) {
|
|
126576
|
+
skipUntilDepth = depth;
|
|
126577
|
+
depth += 1;
|
|
126578
|
+
}
|
|
126579
|
+
}
|
|
126580
|
+
}
|
|
126581
|
+
continue;
|
|
126582
|
+
}
|
|
126583
|
+
const isKey = kind === STRING && depth >= 1 && expectKey[depth - 1] === true;
|
|
126584
|
+
const text2 = isKey ? body.toString("latin1", start, end) : void 0;
|
|
126585
|
+
if (isKey && text2 === CACHE_MARKER_KEY) {
|
|
126586
|
+
skipNextValue = true;
|
|
126587
|
+
continue;
|
|
126588
|
+
}
|
|
126589
|
+
if (depth === 1 && isKey) {
|
|
126590
|
+
topKey = text2;
|
|
126591
|
+
}
|
|
126592
|
+
const closesMessages = kind === CLOSE && inMessages && depth === MESSAGES_ARRAY_DEPTH;
|
|
126593
|
+
if (hashing && !closesMessages && !(depth === 1 && isKey && !THREAD_MEMBER_KEYS.has(text2 ?? ""))) {
|
|
126594
|
+
const target = inMessages ? messages : depth >= 1 && topKey !== void 0 && THREAD_MEMBER_KEYS.has(topKey) ? thread : void 0;
|
|
126595
|
+
if (target !== void 0) {
|
|
126596
|
+
target.update(body.subarray(start, end));
|
|
126597
|
+
target.update(SEPARATOR);
|
|
126598
|
+
}
|
|
126599
|
+
}
|
|
126600
|
+
if (kind === OPEN) {
|
|
126601
|
+
if (depth >= NESTING_DEPTH_LIMIT) {
|
|
126602
|
+
return { abandoned: true, sawMessages, elements, threadDigest: "", messagesDigest: "", parentDigest: void 0 };
|
|
126603
|
+
}
|
|
126604
|
+
const startsMessages = depth === 1 && topKey === MESSAGES_KEY && body[start] === OPEN_BRACKET && !sawMessages;
|
|
126605
|
+
depth += 1;
|
|
126606
|
+
expectKey.push(body[start] === OPEN_BRACE);
|
|
126607
|
+
if (startsMessages) {
|
|
126608
|
+
inMessages = true;
|
|
126609
|
+
sawMessages = true;
|
|
126610
|
+
}
|
|
126611
|
+
} else if (kind === CLOSE) {
|
|
126612
|
+
expectKey.pop();
|
|
126613
|
+
depth -= 1;
|
|
126614
|
+
if (inMessages && depth === 1) {
|
|
126615
|
+
inMessages = false;
|
|
126616
|
+
} else if (inMessages && depth === 2 && elementEnded()) {
|
|
126617
|
+
return overLimit();
|
|
126618
|
+
}
|
|
126619
|
+
} else if (inMessages && depth === 2 && kind === SCALAR && elementEnded()) {
|
|
126620
|
+
return overLimit();
|
|
126621
|
+
}
|
|
126622
|
+
if (depth < 0) {
|
|
126623
|
+
break;
|
|
126624
|
+
}
|
|
126625
|
+
}
|
|
126626
|
+
return { abandoned: false, sawMessages, elements, threadDigest: thread.digest("hex"), messagesDigest: messages.digest("hex"), parentDigest };
|
|
126627
|
+
}
|
|
126628
|
+
function lineageOf(body) {
|
|
126629
|
+
if (body.length > LINEAGE_BODY_BYTES_LIMIT) {
|
|
126630
|
+
return void 0;
|
|
126631
|
+
}
|
|
126632
|
+
const counted = walk(body, false, void 0);
|
|
126633
|
+
if (counted.abandoned || !counted.sawMessages) {
|
|
126634
|
+
return void 0;
|
|
126635
|
+
}
|
|
126636
|
+
const parentAfter = counted.elements > MESSAGES_PER_TURN ? counted.elements - MESSAGES_PER_TURN : void 0;
|
|
126637
|
+
const hashed = walk(body, true, parentAfter);
|
|
126638
|
+
const combine = (messagesDigest) => (0, import_node_crypto18.createHash)("sha256").update(hashed.threadDigest).update(messagesDigest).digest("hex");
|
|
126639
|
+
return { ownKey: combine(hashed.messagesDigest), parentKey: hashed.parentDigest === void 0 ? void 0 : combine(hashed.parentDigest) };
|
|
126640
|
+
}
|
|
126641
|
+
|
|
126642
|
+
// src/frontdoor/headroomHop.ts
|
|
126417
126643
|
var HTTP_BAD_GATEWAY2 = HTTP_STATUS.badGateway;
|
|
126418
126644
|
function responseHeaders(headers) {
|
|
126419
126645
|
const result = {};
|
|
@@ -126425,7 +126651,7 @@ function responseHeaders(headers) {
|
|
|
126425
126651
|
}
|
|
126426
126652
|
return result;
|
|
126427
126653
|
}
|
|
126428
|
-
async function applyHeadroomHop(request7, response, upstream, deps) {
|
|
126654
|
+
async function applyHeadroomHop(request7, response, upstream, deps, onThread) {
|
|
126429
126655
|
const target = deps.headroomSocket();
|
|
126430
126656
|
if (target === void 0) {
|
|
126431
126657
|
await answerBadGateway(response, "agent-shim front door: the headroom daemon is restarting");
|
|
@@ -126461,7 +126687,7 @@ async function applyHeadroomHop(request7, response, upstream, deps) {
|
|
|
126461
126687
|
}
|
|
126462
126688
|
headers[HOP_SECRET_HEADER] = deps.hopSecret;
|
|
126463
126689
|
try {
|
|
126464
|
-
await forwardThroughHeadroom(request7, response, { socketPath, headers, log: deps.log });
|
|
126690
|
+
await forwardThroughHeadroom(request7, response, { socketPath, headers, log: deps.log, onThread });
|
|
126465
126691
|
} finally {
|
|
126466
126692
|
if (hopId !== void 0) {
|
|
126467
126693
|
deps.custody.release(hopId);
|
|
@@ -126503,19 +126729,59 @@ async function headroomReady(deps, signal) {
|
|
|
126503
126729
|
}
|
|
126504
126730
|
var HOP_RESET_RETRIES = 1;
|
|
126505
126731
|
var HOP_RESET_CODES = /* @__PURE__ */ new Set(["ECONNRESET", "EPIPE"]);
|
|
126506
|
-
|
|
126507
|
-
|
|
126508
|
-
|
|
126509
|
-
|
|
126510
|
-
|
|
126511
|
-
|
|
126732
|
+
var BYTES_PER_MIB = 1048576;
|
|
126733
|
+
var MESSAGES_API_LIMIT_MIB = 32;
|
|
126734
|
+
var MAX_BODY_BYTES = MESSAGES_API_LIMIT_MIB * BYTES_PER_MIB;
|
|
126735
|
+
async function collectBody(body) {
|
|
126736
|
+
return await new Promise((resolve2) => {
|
|
126737
|
+
const chunks = [];
|
|
126738
|
+
let size = 0;
|
|
126739
|
+
let settled = false;
|
|
126740
|
+
const settle2 = (result) => {
|
|
126741
|
+
if (!settled) {
|
|
126742
|
+
settled = true;
|
|
126743
|
+
resolve2(result);
|
|
126744
|
+
}
|
|
126745
|
+
};
|
|
126746
|
+
body.on("data", (chunk) => {
|
|
126747
|
+
if (settled) {
|
|
126748
|
+
return;
|
|
126749
|
+
}
|
|
126750
|
+
const piece = typeof chunk === "string" ? Buffer.from(chunk) : chunk instanceof Uint8Array ? Buffer.from(chunk) : void 0;
|
|
126751
|
+
if (piece === void 0) {
|
|
126752
|
+
settle2({ kind: "failed" });
|
|
126753
|
+
return;
|
|
126754
|
+
}
|
|
126755
|
+
size += piece.length;
|
|
126756
|
+
if (size > MAX_BODY_BYTES) {
|
|
126757
|
+
chunks.length = 0;
|
|
126758
|
+
settle2({ kind: "too-large" });
|
|
126759
|
+
return;
|
|
126760
|
+
}
|
|
126761
|
+
chunks.push(piece);
|
|
126762
|
+
});
|
|
126763
|
+
body.on("end", () => {
|
|
126764
|
+
settle2({ kind: "body", body: Buffer.concat(chunks) });
|
|
126765
|
+
});
|
|
126766
|
+
body.on("error", () => {
|
|
126767
|
+
settle2({ kind: "failed" });
|
|
126768
|
+
});
|
|
126769
|
+
});
|
|
126512
126770
|
}
|
|
126513
126771
|
async function forwardThroughHeadroom(request7, response, target) {
|
|
126514
|
-
const
|
|
126515
|
-
if (
|
|
126772
|
+
const collected = await collectBody(request7.body);
|
|
126773
|
+
if (collected.kind === "failed") {
|
|
126516
126774
|
response.destroy();
|
|
126517
126775
|
return;
|
|
126518
126776
|
}
|
|
126777
|
+
if (collected.kind === "too-large") {
|
|
126778
|
+
response.start(HTTP_STATUS.payloadTooLarge, { "Content-Type": "application/json" });
|
|
126779
|
+
await response.write(JSON.stringify({ type: "error", error: { type: "request_too_large", message: "agent-shim front door: the request body is larger than the Messages API accepts" } }));
|
|
126780
|
+
response.end();
|
|
126781
|
+
return;
|
|
126782
|
+
}
|
|
126783
|
+
const { body } = collected;
|
|
126784
|
+
target.onThread(lineageOf(body));
|
|
126519
126785
|
for (let retriesLeft = HOP_RESET_RETRIES; ; retriesLeft -= 1) {
|
|
126520
126786
|
const outcome = await hopOnce(request7, response, target, body, retriesLeft > 0);
|
|
126521
126787
|
if (outcome === "settled") {
|
|
@@ -126655,7 +126921,7 @@ function createRoutedResponse(response, context) {
|
|
|
126655
126921
|
start: (status, headers) => {
|
|
126656
126922
|
for (const observe of deps.responseObservers) {
|
|
126657
126923
|
try {
|
|
126658
|
-
const body = observe({ session, route, method: request7.method, path: request7.path, receivedAt: request7.receivedAt, viaHeadroom: request7.viaHeadroom, status, headers });
|
|
126924
|
+
const body = observe({ session, route, method: request7.method, path: request7.path, receivedAt: request7.receivedAt, viaHeadroom: request7.viaHeadroom, lineage: request7.thread.lineage, status, headers });
|
|
126659
126925
|
if (body !== void 0) {
|
|
126660
126926
|
bodyObservers.push(body);
|
|
126661
126927
|
}
|
|
@@ -126696,7 +126962,7 @@ function createRoutedResponse(response, context) {
|
|
|
126696
126962
|
};
|
|
126697
126963
|
}
|
|
126698
126964
|
async function serveRouted(request7, deps) {
|
|
126699
|
-
const observed = { method: request7.method, path: pathOf(request7.url), receivedAt: deps.now(), viaHeadroom: false };
|
|
126965
|
+
const observed = { method: request7.method, path: pathOf(request7.url), receivedAt: deps.now(), viaHeadroom: false, thread: { lineage: void 0 } };
|
|
126700
126966
|
const identified = identifyRequest(request7.headers);
|
|
126701
126967
|
const admission = deps.admit({ url: request7.url, headers: request7.headers, forwardable: identified.forwardableHeaders });
|
|
126702
126968
|
if (!admission.ok) {
|
|
@@ -126723,12 +126989,14 @@ async function serveRouted(request7, deps) {
|
|
|
126723
126989
|
return;
|
|
126724
126990
|
}
|
|
126725
126991
|
const { headroom } = deps;
|
|
126726
|
-
const wantsHeadroom = await deps.headroomDecision.decide(identified.session.sessionId, identified.session.headroom, deps.now(), async () =>
|
|
126992
|
+
const wantsHeadroom = headroom !== void 0 && await deps.headroomDecision.decide(identified.session.sessionId, identified.session.headroom, deps.now(), async () => await headroomReady(headroom, request7.signal));
|
|
126727
126993
|
const viaHeadroom = wantsHeadroom && resolution.route.headroomEligible && deps.headroom !== void 0;
|
|
126728
126994
|
const response = createRoutedResponse(request7.response, { deps, session: identified.session, route: resolution.route.name, request: { ...observed, viaHeadroom } });
|
|
126729
126995
|
try {
|
|
126730
126996
|
if (viaHeadroom) {
|
|
126731
|
-
await applyHeadroomHop(routed, response, resolution.route.headroomUpstream, deps.headroom)
|
|
126997
|
+
await applyHeadroomHop(routed, response, resolution.route.headroomUpstream, deps.headroom, (lineage) => {
|
|
126998
|
+
observed.thread.lineage = lineage;
|
|
126999
|
+
});
|
|
126732
127000
|
} else {
|
|
126733
127001
|
await resolution.route.serve(routed, response);
|
|
126734
127002
|
}
|
|
@@ -126752,7 +127020,7 @@ init_load();
|
|
|
126752
127020
|
init_schema();
|
|
126753
127021
|
|
|
126754
127022
|
// src/codex/translate.ts
|
|
126755
|
-
var
|
|
127023
|
+
var import_node_crypto19 = require("node:crypto");
|
|
126756
127024
|
init_schema();
|
|
126757
127025
|
|
|
126758
127026
|
// src/codex/anthropic.ts
|
|
@@ -126867,7 +127135,7 @@ function shortToolName(name, names) {
|
|
|
126867
127135
|
if (name.length <= CODEX_TOOL_NAME_LIMIT) {
|
|
126868
127136
|
return name;
|
|
126869
127137
|
}
|
|
126870
|
-
const hash2 = (0,
|
|
127138
|
+
const hash2 = (0, import_node_crypto19.createHash)("sha256").update(name).digest("hex").slice(0, TOOL_NAME_HASH_CHARS);
|
|
126871
127139
|
const shortened = `${name.slice(0, CODEX_TOOL_NAME_LIMIT - TOOL_NAME_HASH_CHARS - 1)}_${hash2}`;
|
|
126872
127140
|
names.set(shortened, name);
|
|
126873
127141
|
return shortened;
|
|
@@ -127914,7 +128182,7 @@ function attachingProviderCredential(route, deps) {
|
|
|
127914
128182
|
init_realFrontDoorPort();
|
|
127915
128183
|
|
|
127916
128184
|
// src/frontdoor/rcCommands.ts
|
|
127917
|
-
var
|
|
128185
|
+
var import_node_crypto20 = require("node:crypto");
|
|
127918
128186
|
init_commandDeps();
|
|
127919
128187
|
init_cliError();
|
|
127920
128188
|
init_realPorts();
|
|
@@ -128521,8 +128789,8 @@ function registerRcCommand(frontdoor, paths) {
|
|
|
128521
128789
|
identitiesDir: paths.identitiesDir,
|
|
128522
128790
|
frontdoorDir: paths.frontdoorDir,
|
|
128523
128791
|
identity,
|
|
128524
|
-
newUuid:
|
|
128525
|
-
randomToken: () => (0,
|
|
128792
|
+
newUuid: import_node_crypto20.randomUUID,
|
|
128793
|
+
randomToken: () => (0, import_node_crypto20.randomBytes)(MINTED_TOKEN_RANDOM_BYTES).toString("base64url"),
|
|
128526
128794
|
force: options.force === true,
|
|
128527
128795
|
now: () => Date.now()
|
|
128528
128796
|
});
|
|
@@ -130775,8 +131043,8 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
130775
131043
|
};
|
|
130776
131044
|
const rcSelfHostSurface = rcSelfHost ? createRcSelfHostSurface({
|
|
130777
131045
|
now: () => Date.now(),
|
|
130778
|
-
newUuid:
|
|
130779
|
-
randomToken: () => (0,
|
|
131046
|
+
newUuid: import_node_crypto21.randomUUID,
|
|
131047
|
+
randomToken: () => (0, import_node_crypto21.randomBytes)(MINTED_TOKEN_RANDOM_BYTES).toString("base64url"),
|
|
130780
131048
|
credentialRecord: () => readRcSelfHostRecord(realFarmFs, paths.frontdoorDir),
|
|
130781
131049
|
webFetch: realRcWebFetch({ allowPrivate: rcWebFetchAllowsPrivateFromEnv(process.env) }),
|
|
130782
131050
|
log
|
|
@@ -130799,7 +131067,7 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
130799
131067
|
saveSequenceNum: rcCredentialStore.writeCursor,
|
|
130800
131068
|
dial: rcSelfHost ? lateRcStreamDial(rcSelfHostDialTarget) : realRcStreamDial(),
|
|
130801
131069
|
fanout: rcFanout,
|
|
130802
|
-
newClientId:
|
|
131070
|
+
newClientId: import_node_crypto21.randomUUID,
|
|
130803
131071
|
backoffMs: RC_STREAM_BACKOFF_MS,
|
|
130804
131072
|
sleep: async (ms2) => {
|
|
130805
131073
|
await new Promise((resolve2) => {
|
|
@@ -130811,7 +131079,7 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
130811
131079
|
}
|
|
130812
131080
|
});
|
|
130813
131081
|
const routingSnapshots = /* @__PURE__ */ new Map();
|
|
130814
|
-
const rcControlToken = (0,
|
|
131082
|
+
const rcControlToken = (0, import_node_crypto21.randomUUID)();
|
|
130815
131083
|
const resolveRoute = rcObservingResolver(
|
|
130816
131084
|
createProviderRouteResolver({
|
|
130817
131085
|
fs: realFsPort,
|
|
@@ -130902,10 +131170,13 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
130902
131170
|
const recordUsage = withQuotaRefresh(usageStore.record, quotaRefresher);
|
|
130903
131171
|
const usageMiddleware = createUsageMiddleware({
|
|
130904
131172
|
// Each finished response also tells the per-session headroom decision when the session's cache was last touched and whether it read from it.
|
|
130905
|
-
record: (record2) => {
|
|
131173
|
+
record: (record2, event) => {
|
|
130906
131174
|
const { usage } = record2;
|
|
130907
131175
|
headroomDecision.observe({
|
|
130908
131176
|
sessionId: record2.sessionId,
|
|
131177
|
+
startedAtMs: Date.parse(record2.at),
|
|
131178
|
+
viaHeadroom: record2.viaHeadroom === true,
|
|
131179
|
+
lineage: event.lineage,
|
|
130909
131180
|
endedAtMs: Date.parse(record2.at) + record2.durationMs,
|
|
130910
131181
|
cache: usage === void 0 ? void 0 : { readTokens: usage.cacheReadInputTokens ?? 0, writtenTokens: usage.cacheCreationInputTokens ?? 0, uncachedTokens: usage.inputTokens ?? 0 }
|
|
130911
131182
|
});
|
|
@@ -130924,9 +131195,9 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
130924
131195
|
now: () => Date.now(),
|
|
130925
131196
|
headroomSocket: () => headroomSocketTarget(realFarmFs, realHeadroomSocketTrust, paths),
|
|
130926
131197
|
// 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.
|
|
130927
|
-
hopSecret: (0,
|
|
131198
|
+
hopSecret: (0, import_node_crypto21.randomUUID)(),
|
|
130928
131199
|
headroomDecision,
|
|
130929
|
-
custody: createCredentialCustody(() => (0,
|
|
131200
|
+
custody: createCredentialCustody(() => (0, import_node_crypto21.randomUUID)()),
|
|
130930
131201
|
log
|
|
130931
131202
|
});
|
|
130932
131203
|
const onListenerError = (name) => (error63) => {
|
|
@@ -130949,9 +131220,9 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
130949
131220
|
startProviderListener: async (preferredPort) => {
|
|
130950
131221
|
const authority = loadCa();
|
|
130951
131222
|
const rcDial = rcSelfHost ? lateRcEventDial(rcSelfHostDialTarget) : realRcEventDial();
|
|
130952
|
-
const rcInject = async (sessionId, text2) => await injectRcUserMessage({ credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid:
|
|
131223
|
+
const rcInject = async (sessionId, text2) => await injectRcUserMessage({ credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid: import_node_crypto21.randomUUID }, sessionId, text2);
|
|
130953
131224
|
const rcAnswer = async (sessionId, requestId, decision) => await answerRcControlRequest({ credentialOf: rcTracker.credentialOf, pendingOf: (id2) => rcTracker.pendingOf(id2), completePending: rcTracker.completePending, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial }, sessionId, requestId, decision);
|
|
130954
|
-
const rcControlRequestDeps = { credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid:
|
|
131225
|
+
const rcControlRequestDeps = { credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid: import_node_crypto21.randomUUID };
|
|
130955
131226
|
const rcInterrupt = async (sessionId) => await interruptRcSession(rcControlRequestDeps, sessionId);
|
|
130956
131227
|
const rcSetModel = async (sessionId, model) => await setRcSessionModel(rcControlRequestDeps, sessionId, model);
|
|
130957
131228
|
const rcSetPermissionMode = async (sessionId, mode) => await setRcSessionPermissionMode(rcControlRequestDeps, sessionId, mode);
|
|
@@ -131050,7 +131321,7 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
131050
131321
|
},
|
|
131051
131322
|
startConnectListener: async (preferredPort) => {
|
|
131052
131323
|
const wantedTransparentPort = process.env.AGENT_SHIM_TRANSPARENT_SURFACE === void 0 ? void 0 : Number(process.env.AGENT_SHIM_TRANSPARENT_SURFACE);
|
|
131053
|
-
const transparentCapability = wantedTransparentPort === void 0 || Number.isNaN(wantedTransparentPort) ? void 0 : (0,
|
|
131324
|
+
const transparentCapability = wantedTransparentPort === void 0 || Number.isNaN(wantedTransparentPort) ? void 0 : (0, import_node_crypto21.randomUUID)();
|
|
131054
131325
|
if (transparentCapability !== void 0) {
|
|
131055
131326
|
writeFrontDoorSession(realFarmFs, paths.frontdoorSessionsDir, { pid: process.pid, startedAt: Date.now(), token: transparentCapability });
|
|
131056
131327
|
}
|
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.5.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.5.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/dist/types/index.d.ts
CHANGED
|
@@ -1332,8 +1332,8 @@ declare const HeadroomGlobalConfigSchema: z.ZodObject<{
|
|
|
1332
1332
|
targetRatio: z.ZodOptional<z.ZodNumber>;
|
|
1333
1333
|
ccr: z.ZodOptional<z.ZodEnum<{
|
|
1334
1334
|
default: "default";
|
|
1335
|
-
lossless: "lossless";
|
|
1336
1335
|
none: "none";
|
|
1336
|
+
lossless: "lossless";
|
|
1337
1337
|
}>>;
|
|
1338
1338
|
rolloutChannel: z.ZodOptional<z.ZodEnum<{
|
|
1339
1339
|
beta: "beta";
|
|
@@ -1460,8 +1460,8 @@ declare const GlobalConfigSchema: z.ZodObject<{
|
|
|
1460
1460
|
targetRatio: z.ZodOptional<z.ZodNumber>;
|
|
1461
1461
|
ccr: z.ZodOptional<z.ZodEnum<{
|
|
1462
1462
|
default: "default";
|
|
1463
|
-
lossless: "lossless";
|
|
1464
1463
|
none: "none";
|
|
1464
|
+
lossless: "lossless";
|
|
1465
1465
|
}>>;
|
|
1466
1466
|
rolloutChannel: z.ZodOptional<z.ZodEnum<{
|
|
1467
1467
|
beta: "beta";
|
|
@@ -4163,12 +4163,12 @@ declare const CheckReportJsonSchema: z.ZodObject<{
|
|
|
4163
4163
|
identity: z.ZodObject<{
|
|
4164
4164
|
name: z.ZodNullable<z.ZodString>;
|
|
4165
4165
|
source: z.ZodEnum<{
|
|
4166
|
-
env: "env";
|
|
4167
|
-
none: "none";
|
|
4168
4166
|
"config-dir-escape-hatch": "config-dir-escape-hatch";
|
|
4169
4167
|
argv: "argv";
|
|
4168
|
+
env: "env";
|
|
4170
4169
|
"directory-pin": "directory-pin";
|
|
4171
4170
|
"active-identity-file": "active-identity-file";
|
|
4171
|
+
none: "none";
|
|
4172
4172
|
}>;
|
|
4173
4173
|
}, z.core.$strict>;
|
|
4174
4174
|
pool: z.ZodOptional<z.ZodObject<{
|
|
@@ -4246,11 +4246,11 @@ declare const CheckReportJsonSchema: z.ZodObject<{
|
|
|
4246
4246
|
"category-default": "category-default";
|
|
4247
4247
|
}>;
|
|
4248
4248
|
category: z.ZodNullable<z.ZodEnum<{
|
|
4249
|
+
secret: "secret";
|
|
4249
4250
|
runtime: "runtime";
|
|
4250
4251
|
history: "history";
|
|
4251
4252
|
knowledge: "knowledge";
|
|
4252
4253
|
settings: "settings";
|
|
4253
|
-
secret: "secret";
|
|
4254
4254
|
}>>;
|
|
4255
4255
|
rule: z.ZodOptional<z.ZodObject<{
|
|
4256
4256
|
key: z.ZodString;
|
|
@@ -6942,9 +6942,9 @@ declare function createLifecycleApiRouter(deps: LifecycleApiDeps): {
|
|
|
6942
6942
|
current: zod.ZodString;
|
|
6943
6943
|
latest: zod.ZodString;
|
|
6944
6944
|
action: zod.ZodEnum<{
|
|
6945
|
-
updated: "updated";
|
|
6946
6945
|
current: "current";
|
|
6947
6946
|
available: "available";
|
|
6947
|
+
updated: "updated";
|
|
6948
6948
|
}>;
|
|
6949
6949
|
}, zod_v4_core.$strict>, MergedErrorMap<$ErrorMap, TErrorMap>>;
|
|
6950
6950
|
};
|
|
@@ -7191,12 +7191,12 @@ declare function createLaunchApiRouter(deps: LaunchApiDeps): {
|
|
|
7191
7191
|
decision: zod.ZodObject<{
|
|
7192
7192
|
identity: zod.ZodOptional<zod.ZodString>;
|
|
7193
7193
|
identitySource: zod.ZodEnum<{
|
|
7194
|
-
env: "env";
|
|
7195
|
-
none: "none";
|
|
7196
7194
|
"config-dir-escape-hatch": "config-dir-escape-hatch";
|
|
7197
7195
|
argv: "argv";
|
|
7196
|
+
env: "env";
|
|
7198
7197
|
"directory-pin": "directory-pin";
|
|
7199
7198
|
"active-identity-file": "active-identity-file";
|
|
7199
|
+
none: "none";
|
|
7200
7200
|
}>;
|
|
7201
7201
|
pool: zod.ZodOptional<zod.ZodObject<{
|
|
7202
7202
|
name: zod.ZodString;
|
|
@@ -7791,12 +7791,12 @@ declare function createControlApiRouter(deps: ControlApiDeps): {
|
|
|
7791
7791
|
identity: zod.ZodObject<{
|
|
7792
7792
|
name: zod.ZodNullable<zod.ZodString>;
|
|
7793
7793
|
source: zod.ZodEnum<{
|
|
7794
|
-
env: "env";
|
|
7795
|
-
none: "none";
|
|
7796
7794
|
"config-dir-escape-hatch": "config-dir-escape-hatch";
|
|
7797
7795
|
argv: "argv";
|
|
7796
|
+
env: "env";
|
|
7798
7797
|
"directory-pin": "directory-pin";
|
|
7799
7798
|
"active-identity-file": "active-identity-file";
|
|
7799
|
+
none: "none";
|
|
7800
7800
|
}>;
|
|
7801
7801
|
}, zod_v4_core.$strict>;
|
|
7802
7802
|
pool: zod.ZodOptional<zod.ZodObject<{
|
|
@@ -7874,11 +7874,11 @@ declare function createControlApiRouter(deps: ControlApiDeps): {
|
|
|
7874
7874
|
"category-default": "category-default";
|
|
7875
7875
|
}>;
|
|
7876
7876
|
category: zod.ZodNullable<zod.ZodEnum<{
|
|
7877
|
+
secret: "secret";
|
|
7877
7878
|
runtime: "runtime";
|
|
7878
7879
|
history: "history";
|
|
7879
7880
|
knowledge: "knowledge";
|
|
7880
7881
|
settings: "settings";
|
|
7881
|
-
secret: "secret";
|
|
7882
7882
|
}>>;
|
|
7883
7883
|
rule: zod.ZodOptional<zod.ZodObject<{
|
|
7884
7884
|
key: zod.ZodString;
|
|
@@ -8097,11 +8097,10 @@ declare function createControlApiRouter(deps: ControlApiDeps): {
|
|
|
8097
8097
|
"global-config": "global-config";
|
|
8098
8098
|
"config-profile": "config-profile";
|
|
8099
8099
|
identity: "identity";
|
|
8100
|
-
keychain: "keychain";
|
|
8101
8100
|
provider: "provider";
|
|
8102
|
-
headroom: "headroom";
|
|
8103
8101
|
frontdoor: "frontdoor";
|
|
8104
8102
|
pool: "pool";
|
|
8103
|
+
keychain: "keychain";
|
|
8105
8104
|
"ambient-credential": "ambient-credential";
|
|
8106
8105
|
"binary-discovery": "binary-discovery";
|
|
8107
8106
|
"claude-shim": "claude-shim";
|
|
@@ -8111,6 +8110,7 @@ declare function createControlApiRouter(deps: ControlApiDeps): {
|
|
|
8111
8110
|
"directory-rules": "directory-rules";
|
|
8112
8111
|
"categories-local": "categories-local";
|
|
8113
8112
|
"active-identity": "active-identity";
|
|
8113
|
+
headroom: "headroom";
|
|
8114
8114
|
}>;
|
|
8115
8115
|
subject: zod.ZodOptional<zod.ZodString>;
|
|
8116
8116
|
severity: zod.ZodEnum<{
|
|
@@ -8303,12 +8303,12 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
|
|
|
8303
8303
|
decision: zod.ZodObject<{
|
|
8304
8304
|
identity: zod.ZodOptional<zod.ZodString>;
|
|
8305
8305
|
identitySource: zod.ZodEnum<{
|
|
8306
|
-
env: "env";
|
|
8307
|
-
none: "none";
|
|
8308
8306
|
"config-dir-escape-hatch": "config-dir-escape-hatch";
|
|
8309
8307
|
argv: "argv";
|
|
8308
|
+
env: "env";
|
|
8310
8309
|
"directory-pin": "directory-pin";
|
|
8311
8310
|
"active-identity-file": "active-identity-file";
|
|
8311
|
+
none: "none";
|
|
8312
8312
|
}>;
|
|
8313
8313
|
pool: zod.ZodOptional<zod.ZodObject<{
|
|
8314
8314
|
name: zod.ZodString;
|
|
@@ -9684,9 +9684,9 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
|
|
|
9684
9684
|
current: zod.ZodString;
|
|
9685
9685
|
latest: zod.ZodString;
|
|
9686
9686
|
action: zod.ZodEnum<{
|
|
9687
|
-
updated: "updated";
|
|
9688
9687
|
current: "current";
|
|
9689
9688
|
available: "available";
|
|
9689
|
+
updated: "updated";
|
|
9690
9690
|
}>;
|
|
9691
9691
|
}, zod_v4_core.$strict>, MergedErrorMap<$ErrorMap, TErrorMap>>;
|
|
9692
9692
|
};
|
|
@@ -9885,12 +9885,12 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
|
|
|
9885
9885
|
identity: zod.ZodObject<{
|
|
9886
9886
|
name: zod.ZodNullable<zod.ZodString>;
|
|
9887
9887
|
source: zod.ZodEnum<{
|
|
9888
|
-
env: "env";
|
|
9889
|
-
none: "none";
|
|
9890
9888
|
"config-dir-escape-hatch": "config-dir-escape-hatch";
|
|
9891
9889
|
argv: "argv";
|
|
9890
|
+
env: "env";
|
|
9892
9891
|
"directory-pin": "directory-pin";
|
|
9893
9892
|
"active-identity-file": "active-identity-file";
|
|
9893
|
+
none: "none";
|
|
9894
9894
|
}>;
|
|
9895
9895
|
}, zod_v4_core.$strict>;
|
|
9896
9896
|
pool: zod.ZodOptional<zod.ZodObject<{
|
|
@@ -9968,11 +9968,11 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
|
|
|
9968
9968
|
"category-default": "category-default";
|
|
9969
9969
|
}>;
|
|
9970
9970
|
category: zod.ZodNullable<zod.ZodEnum<{
|
|
9971
|
+
secret: "secret";
|
|
9971
9972
|
runtime: "runtime";
|
|
9972
9973
|
history: "history";
|
|
9973
9974
|
knowledge: "knowledge";
|
|
9974
9975
|
settings: "settings";
|
|
9975
|
-
secret: "secret";
|
|
9976
9976
|
}>>;
|
|
9977
9977
|
rule: zod.ZodOptional<zod.ZodObject<{
|
|
9978
9978
|
key: zod.ZodString;
|
|
@@ -10191,11 +10191,10 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
|
|
|
10191
10191
|
"global-config": "global-config";
|
|
10192
10192
|
"config-profile": "config-profile";
|
|
10193
10193
|
identity: "identity";
|
|
10194
|
-
keychain: "keychain";
|
|
10195
10194
|
provider: "provider";
|
|
10196
|
-
headroom: "headroom";
|
|
10197
10195
|
frontdoor: "frontdoor";
|
|
10198
10196
|
pool: "pool";
|
|
10197
|
+
keychain: "keychain";
|
|
10199
10198
|
"ambient-credential": "ambient-credential";
|
|
10200
10199
|
"binary-discovery": "binary-discovery";
|
|
10201
10200
|
"claude-shim": "claude-shim";
|
|
@@ -10205,6 +10204,7 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
|
|
|
10205
10204
|
"directory-rules": "directory-rules";
|
|
10206
10205
|
"categories-local": "categories-local";
|
|
10207
10206
|
"active-identity": "active-identity";
|
|
10207
|
+
headroom: "headroom";
|
|
10208
10208
|
}>;
|
|
10209
10209
|
subject: zod.ZodOptional<zod.ZodString>;
|
|
10210
10210
|
severity: zod.ZodEnum<{
|
|
@@ -12037,11 +12037,10 @@ declare const DoctorFindingSchema: z.ZodObject<{
|
|
|
12037
12037
|
"global-config": "global-config";
|
|
12038
12038
|
"config-profile": "config-profile";
|
|
12039
12039
|
identity: "identity";
|
|
12040
|
-
keychain: "keychain";
|
|
12041
12040
|
provider: "provider";
|
|
12042
|
-
headroom: "headroom";
|
|
12043
12041
|
frontdoor: "frontdoor";
|
|
12044
12042
|
pool: "pool";
|
|
12043
|
+
keychain: "keychain";
|
|
12045
12044
|
"ambient-credential": "ambient-credential";
|
|
12046
12045
|
"binary-discovery": "binary-discovery";
|
|
12047
12046
|
"claude-shim": "claude-shim";
|
|
@@ -12051,6 +12050,7 @@ declare const DoctorFindingSchema: z.ZodObject<{
|
|
|
12051
12050
|
"directory-rules": "directory-rules";
|
|
12052
12051
|
"categories-local": "categories-local";
|
|
12053
12052
|
"active-identity": "active-identity";
|
|
12053
|
+
headroom: "headroom";
|
|
12054
12054
|
}>;
|
|
12055
12055
|
subject: z.ZodOptional<z.ZodString>;
|
|
12056
12056
|
severity: z.ZodEnum<{
|
|
@@ -12068,11 +12068,10 @@ declare const DoctorRunOutputSchema: z.ZodObject<{
|
|
|
12068
12068
|
"global-config": "global-config";
|
|
12069
12069
|
"config-profile": "config-profile";
|
|
12070
12070
|
identity: "identity";
|
|
12071
|
-
keychain: "keychain";
|
|
12072
12071
|
provider: "provider";
|
|
12073
|
-
headroom: "headroom";
|
|
12074
12072
|
frontdoor: "frontdoor";
|
|
12075
12073
|
pool: "pool";
|
|
12074
|
+
keychain: "keychain";
|
|
12076
12075
|
"ambient-credential": "ambient-credential";
|
|
12077
12076
|
"binary-discovery": "binary-discovery";
|
|
12078
12077
|
"claude-shim": "claude-shim";
|
|
@@ -12082,6 +12081,7 @@ declare const DoctorRunOutputSchema: z.ZodObject<{
|
|
|
12082
12081
|
"directory-rules": "directory-rules";
|
|
12083
12082
|
"categories-local": "categories-local";
|
|
12084
12083
|
"active-identity": "active-identity";
|
|
12084
|
+
headroom: "headroom";
|
|
12085
12085
|
}>;
|
|
12086
12086
|
subject: z.ZodOptional<z.ZodString>;
|
|
12087
12087
|
severity: z.ZodEnum<{
|
|
@@ -12102,9 +12102,9 @@ declare const UpdateCheckOutputSchema: z.ZodObject<{
|
|
|
12102
12102
|
current: z.ZodString;
|
|
12103
12103
|
latest: z.ZodString;
|
|
12104
12104
|
action: z.ZodEnum<{
|
|
12105
|
-
updated: "updated";
|
|
12106
12105
|
current: "current";
|
|
12107
12106
|
available: "available";
|
|
12107
|
+
updated: "updated";
|
|
12108
12108
|
}>;
|
|
12109
12109
|
}, z.core.$strict>;
|
|
12110
12110
|
/** The Sign in with ChatGPT login's state as `codex status` reports it: no sign-in yet, signed in (with who, whether the plan scope was granted, and when the access token lapses), or a file that cannot be read. */
|
|
@@ -12154,12 +12154,12 @@ declare const LaunchResolveOutputSchema: z.ZodObject<{
|
|
|
12154
12154
|
decision: z.ZodObject<{
|
|
12155
12155
|
identity: z.ZodOptional<z.ZodString>;
|
|
12156
12156
|
identitySource: z.ZodEnum<{
|
|
12157
|
-
env: "env";
|
|
12158
|
-
none: "none";
|
|
12159
12157
|
"config-dir-escape-hatch": "config-dir-escape-hatch";
|
|
12160
12158
|
argv: "argv";
|
|
12159
|
+
env: "env";
|
|
12161
12160
|
"directory-pin": "directory-pin";
|
|
12162
12161
|
"active-identity-file": "active-identity-file";
|
|
12162
|
+
none: "none";
|
|
12163
12163
|
}>;
|
|
12164
12164
|
pool: z.ZodOptional<z.ZodObject<{
|
|
12165
12165
|
name: z.ZodString;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-shim",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.5.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>",
|