claude-use 14.3.1 → 14.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/README.md +1 -1
- package/dist/cli.cjs +2672 -2097
- package/dist/index.cjs +1437 -974
- package/dist/index.mjs +1396 -933
- package/dist/types/index.d.ts +190 -38
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1458,7 +1458,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
|
|
|
1458
1458
|
return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
|
|
1459
1459
|
}
|
|
1460
1460
|
function describeIgnoredKeys(filePath, ignored) {
|
|
1461
|
-
const places = ignored.map(({ path:
|
|
1461
|
+
const places = ignored.map(({ path: path59, keys }) => `${path59.length === 0 ? "" : `${path59.map(String).join(".")}.`}${keys.join(", ")}`);
|
|
1462
1462
|
return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
|
|
1463
1463
|
}
|
|
1464
1464
|
function noteIgnoredKeys(filePath, ignored) {
|
|
@@ -1480,9 +1480,9 @@ function restoreIgnoredKeys(filePath, value) {
|
|
|
1480
1480
|
return value;
|
|
1481
1481
|
}
|
|
1482
1482
|
const restored = structuredClone(value);
|
|
1483
|
-
for (const { path:
|
|
1483
|
+
for (const { path: path59, values } of ignored) {
|
|
1484
1484
|
let holder = restored;
|
|
1485
|
-
for (const step of
|
|
1485
|
+
for (const step of path59) {
|
|
1486
1486
|
holder = isRecord(holder) ? holder[step] : void 0;
|
|
1487
1487
|
}
|
|
1488
1488
|
if (isRecord(holder)) {
|
|
@@ -2642,6 +2642,7 @@ function planFarm(params) {
|
|
|
2642
2642
|
const entries = [];
|
|
2643
2643
|
const materialised = [];
|
|
2644
2644
|
const links = [];
|
|
2645
|
+
const dangling = [];
|
|
2645
2646
|
const conditionalPatterns = [...params.flattened.rules.values()].filter((rule) => rule.when !== void 0).map((rule) => rule.canonicalPattern);
|
|
2646
2647
|
const conditionalRuleCouldReach = (dir) => conditionalPatterns.some((pattern) => patternCouldReachUnder(pattern, dir));
|
|
2647
2648
|
const subtreeDecision = (rel) => {
|
|
@@ -2674,7 +2675,10 @@ function planFarm(params) {
|
|
|
2674
2675
|
return;
|
|
2675
2676
|
}
|
|
2676
2677
|
if (!fact.isDirectory) {
|
|
2677
|
-
if (decision?.shared === true) {
|
|
2678
|
+
if (decision?.shared === true && fact.isDanglingSymlink) {
|
|
2679
|
+
entries.push({ kind: "omit", rel });
|
|
2680
|
+
dangling.push(rel);
|
|
2681
|
+
} else if (decision?.shared === true) {
|
|
2678
2682
|
entries.push({ kind: "link", rel, target: linkTarget(rel) });
|
|
2679
2683
|
links.push({ rel, target: linkTarget(rel) });
|
|
2680
2684
|
} else {
|
|
@@ -2709,7 +2713,7 @@ function planFarm(params) {
|
|
|
2709
2713
|
for (const rel of children.get("") ?? []) {
|
|
2710
2714
|
visit(rel);
|
|
2711
2715
|
}
|
|
2712
|
-
return { entries, materialised, links };
|
|
2716
|
+
return { entries, materialised, links, dangling };
|
|
2713
2717
|
}
|
|
2714
2718
|
var init_plan = __esm({
|
|
2715
2719
|
"src/resolve/plan.ts"() {
|
|
@@ -2951,6 +2955,14 @@ function topLevelNames(facts) {
|
|
|
2951
2955
|
function descendPolicyFor(cascade, home) {
|
|
2952
2956
|
return descendPolicy(flattenLayers(assembleCascade(cascade).layers, { home }).rules.values());
|
|
2953
2957
|
}
|
|
2958
|
+
function danglingDiagnostic(rel) {
|
|
2959
|
+
return {
|
|
2960
|
+
code: "SHARED_ENTRY_DANGLING",
|
|
2961
|
+
severity: "warning",
|
|
2962
|
+
message: `"${rel}" is shared, but ~/.claude/${rel} is a symlink that leads nowhere, so the farm does not link it and this identity keeps its own copy. Once the symlink leads somewhere, the next launch, or \`agent-shim identity resync <identity>\` in this directory, links the entry.`,
|
|
2963
|
+
subject: rel
|
|
2964
|
+
};
|
|
2965
|
+
}
|
|
2954
2966
|
function resolveDecisions(input) {
|
|
2955
2967
|
const assembled = assembleCascade(input.cascade);
|
|
2956
2968
|
const flattened = flattenLayers(assembled.layers, { home: input.facts.home });
|
|
@@ -2970,7 +2982,7 @@ function resolveDecisions(input) {
|
|
|
2970
2982
|
classification,
|
|
2971
2983
|
decisions: resolved.decisions,
|
|
2972
2984
|
farm,
|
|
2973
|
-
diagnostics: [...assembled.diagnostics, ...resolved.diagnostics]
|
|
2985
|
+
diagnostics: [...assembled.diagnostics, ...resolved.diagnostics, ...farm.dangling.map(danglingDiagnostic)]
|
|
2974
2986
|
};
|
|
2975
2987
|
}
|
|
2976
2988
|
var init_pipeline = __esm({
|
|
@@ -3419,6 +3431,34 @@ function readFarmManifest(fs17, farmRoot) {
|
|
|
3419
3431
|
const result = FarmManifestSchema.safeParse(parsed);
|
|
3420
3432
|
return result.success ? result.data : void 0;
|
|
3421
3433
|
}
|
|
3434
|
+
function danglingFarmLinks(fs17, farmRoot) {
|
|
3435
|
+
const manifest = readFarmManifest(fs17, farmRoot);
|
|
3436
|
+
const recorded = new Map((manifest?.links ?? []).map((link) => [link.rel, link.target]));
|
|
3437
|
+
const materialised = new Set(manifest?.materialised ?? []);
|
|
3438
|
+
const candidates = new Set(recorded.keys());
|
|
3439
|
+
const walk2 = (rel) => {
|
|
3440
|
+
const stat = fs17.lstat(path10.join(farmRoot, rel));
|
|
3441
|
+
if (stat?.kind === "symlink") {
|
|
3442
|
+
candidates.add(rel);
|
|
3443
|
+
} else if (stat?.kind === "dir" && materialised.has(rel)) {
|
|
3444
|
+
for (const name of fs17.readdir(path10.join(farmRoot, rel))) {
|
|
3445
|
+
walk2(`${rel}/${name}`);
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
};
|
|
3449
|
+
for (const name of fs17.readdir(farmRoot)) {
|
|
3450
|
+
if (name !== FARM_MANIFEST_FILENAME && name !== LEGACY_FARM_MANIFEST_FILENAME) {
|
|
3451
|
+
walk2(name);
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
return [...candidates].sort().filter((rel) => {
|
|
3455
|
+
const absolute = path10.join(farmRoot, rel);
|
|
3456
|
+
return fs17.lstat(absolute)?.kind === "symlink" && !fs17.resolves(absolute);
|
|
3457
|
+
}).map((rel) => {
|
|
3458
|
+
const target = recorded.get(rel);
|
|
3459
|
+
return target === void 0 ? { rel } : { rel, target };
|
|
3460
|
+
});
|
|
3461
|
+
}
|
|
3422
3462
|
function buildEntryFacts(params) {
|
|
3423
3463
|
const entries = /* @__PURE__ */ new Map();
|
|
3424
3464
|
const visit = (rel) => {
|
|
@@ -3443,6 +3483,7 @@ function buildEntryFacts(params) {
|
|
|
3443
3483
|
relPath: rel,
|
|
3444
3484
|
isDirectory,
|
|
3445
3485
|
isSymlink: stat.kind === "symlink",
|
|
3486
|
+
isDanglingSymlink: stat.kind === "symlink" && !params.fs.resolves(absolute),
|
|
3446
3487
|
mtimeMs: stat.mtimeMs,
|
|
3447
3488
|
latestMtimeMs,
|
|
3448
3489
|
sizeBytes: stat.sizeBytes,
|
|
@@ -3805,6 +3846,7 @@ function resyncFarm(params) {
|
|
|
3805
3846
|
farmRoot,
|
|
3806
3847
|
noOp: true,
|
|
3807
3848
|
manifest: previousManifest,
|
|
3849
|
+
previousManifest,
|
|
3808
3850
|
resolved,
|
|
3809
3851
|
adopted: outcome.adopted,
|
|
3810
3852
|
recovery,
|
|
@@ -3827,6 +3869,7 @@ function resyncFarm(params) {
|
|
|
3827
3869
|
farmRoot,
|
|
3828
3870
|
noOp: false,
|
|
3829
3871
|
manifest,
|
|
3872
|
+
...previousManifest === void 0 ? {} : { previousManifest },
|
|
3830
3873
|
resolved,
|
|
3831
3874
|
adopted: outcome.adopted,
|
|
3832
3875
|
recovery,
|
|
@@ -5790,8 +5833,8 @@ function parseConnectTarget(authority) {
|
|
|
5790
5833
|
function isInterceptedHost(host, interceptHosts) {
|
|
5791
5834
|
return interceptHosts.includes(host);
|
|
5792
5835
|
}
|
|
5793
|
-
function servedByPipeline(
|
|
5794
|
-
return
|
|
5836
|
+
function servedByPipeline(path59) {
|
|
5837
|
+
return path59?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
5795
5838
|
}
|
|
5796
5839
|
function forwardableHeaders(headers) {
|
|
5797
5840
|
const connectionTokens = new Set(
|
|
@@ -6654,8 +6697,8 @@ function pathnameOf(url) {
|
|
|
6654
6697
|
return new URL(url ?? "/", "http://127.0.0.1").pathname;
|
|
6655
6698
|
}
|
|
6656
6699
|
function isRcSessionExchange(url) {
|
|
6657
|
-
const
|
|
6658
|
-
return
|
|
6700
|
+
const path59 = pathnameOf(url);
|
|
6701
|
+
return path59 === RC_SESSIONS_PATH_PREFIX || path59.startsWith(`${RC_SESSIONS_PATH_PREFIX}/`);
|
|
6659
6702
|
}
|
|
6660
6703
|
function isSuccessful(status) {
|
|
6661
6704
|
return status >= HTTP_STATUS.ok && status < SUCCESS_STATUS_MAX_EXCLUSIVE;
|
|
@@ -7389,8 +7432,8 @@ function buildRcGetContextUsagePayload(requestId, detail) {
|
|
|
7389
7432
|
function isRcReadFileEncoding(value) {
|
|
7390
7433
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
|
|
7391
7434
|
}
|
|
7392
|
-
function buildRcReadFilePayload(requestId,
|
|
7393
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
7435
|
+
function buildRcReadFilePayload(requestId, path59, options) {
|
|
7436
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path59, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
7394
7437
|
}
|
|
7395
7438
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
7396
7439
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -7524,15 +7567,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
7524
7567
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
7525
7568
|
return result.ok ? { ...result, requestId } : result;
|
|
7526
7569
|
}
|
|
7527
|
-
async function readRcSessionFile(deps, sessionId,
|
|
7528
|
-
if (
|
|
7570
|
+
async function readRcSessionFile(deps, sessionId, path59, options) {
|
|
7571
|
+
if (path59 === "") {
|
|
7529
7572
|
return { ok: false, message: "a read-file write needs a non-empty path: the SDK's own field names the file the worker resolves against the session's cwd, and an empty string names none" };
|
|
7530
7573
|
}
|
|
7531
7574
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
7532
7575
|
return { ok: false, message: "a read-file write's max-bytes is a positive whole number of bytes: the SDK's own field caps the read, and a zero or negative cap reads nothing" };
|
|
7533
7576
|
}
|
|
7534
7577
|
const requestId = deps.newUuid();
|
|
7535
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
7578
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path59, options), `read ${path59} from session ${sessionId}`);
|
|
7536
7579
|
return result.ok ? { ...result, requestId } : result;
|
|
7537
7580
|
}
|
|
7538
7581
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -7607,7 +7650,7 @@ import { z as z12 } from "zod";
|
|
|
7607
7650
|
function workerFactSchema(value) {
|
|
7608
7651
|
return z12.strictObject({ value, observedAt: z12.number() });
|
|
7609
7652
|
}
|
|
7610
|
-
var RcPermissionModeSchema, RcSessionSummarySchema, RcQuestionOptionSchema, RcPendingQuestionSchema, RcPendingRequestSummarySchema, RcSessionStatusSchema, RcStreamEnvelopeSchema, RcStreamEventSchema, RcRateLimitWindowSchema, RcRateLimitInfoSchema, RcLiveRateLimitSchema, RcSessionQuerySchema, RcSendInputSchema, RcQuestionSelectionSchema, RcQuestionChoicesSchema, RcAnswerInputSchema, RcInterruptInputSchema, RcSetModelInputSchema, RcSetPermissionModeInputSchema, RcEndSessionInputSchema, RcGetUsageInputSchema, RcGetContextUsageInputSchema, RcReadFileInputSchema, RcFileSuggestionsInputSchema, RcKeepAliveInputSchema, RcMcpStatusInputSchema, RcMcpReconnectInputSchema, RcMcpAuthenticateInputSchema, RcMcpOAuthCallbackUrlInputSchema, RcTeleportInputSchema, RcListOutputSchema, RcStatusOutputSchema, RcPendingOutputSchema, RcWriteOutputSchema, RcControlWriteOutputSchema, RcAnswerOutputSchema;
|
|
7653
|
+
var RcPermissionModeSchema, RcSessionSummarySchema, RcQuestionOptionSchema, RcPendingQuestionSchema, RcPendingRequestSummarySchema, RcSessionStatusSchema, RcStreamEnvelopeSchema, RcStreamEventSchema, RcRateLimitWindowSchema, RcRateLimitInfoSchema, RcLiveRateLimitSchema, RcSessionQuerySchema, RcSendInputSchema, RcQuestionSelectionSchema, RcQuestionChoicesSchema, RcAnswerInputSchema, RcInterruptInputSchema, RcSetModelInputSchema, RcSetPermissionModeInputSchema, RcEndSessionInputSchema, RcGetUsageInputSchema, RcGetContextUsageInputSchema, RcReadFileInputSchema, RcFileSuggestionsInputSchema, RcKeepAliveInputSchema, RcMcpStatusInputSchema, RcMcpReconnectInputSchema, RcMcpAuthenticateInputSchema, RcMcpOAuthCallbackUrlInputSchema, RcTeleportInputSchema, RcListOutputSchema, RcSessionRouteSchema, RcStatusOutputSchema, RcPendingOutputSchema, RcWriteOutputSchema, RcControlWriteOutputSchema, RcAnswerOutputSchema;
|
|
7611
7654
|
var init_rcSchemas = __esm({
|
|
7612
7655
|
"src/frontdoor/rcSchemas.ts"() {
|
|
7613
7656
|
"use strict";
|
|
@@ -7776,7 +7819,8 @@ var init_rcSchemas = __esm({
|
|
|
7776
7819
|
marker: z12.string().min(1)
|
|
7777
7820
|
});
|
|
7778
7821
|
RcListOutputSchema = z12.strictObject({ sessions: z12.readonly(z12.array(RcSessionSummarySchema)) });
|
|
7779
|
-
|
|
7822
|
+
RcSessionRouteSchema = z12.union([z12.strictObject({ route: z12.enum(["supervised", "launched", "self-hosted"]) }), z12.strictObject({ route: z12.null(), refused: z12.string() })]);
|
|
7823
|
+
RcStatusOutputSchema = z12.strictObject({ statuses: z12.readonly(z12.array(z12.strictObject({ ...RcSessionStatusSchema.shape, route: RcSessionRouteSchema }))) });
|
|
7780
7824
|
RcPendingOutputSchema = z12.strictObject({
|
|
7781
7825
|
pending: z12.readonly(z12.array(RcPendingRequestSummarySchema)),
|
|
7782
7826
|
/** The sessions that had requests the door did not list (past the per-session cap, or with an id the protocol does not mint), each with how many: a question the caller expects may be among them. Absent when none did. */
|
|
@@ -7911,11 +7955,11 @@ function createRcControlHandler(deps) {
|
|
|
7911
7955
|
path: "read-file",
|
|
7912
7956
|
read: (body) => {
|
|
7913
7957
|
const session = bodyString(body, "session");
|
|
7914
|
-
const
|
|
7958
|
+
const path59 = bodyString(body, "path");
|
|
7915
7959
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
7916
7960
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
7917
|
-
const refused2 = session === void 0 ||
|
|
7918
|
-
return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session,
|
|
7961
|
+
const refused2 = session === void 0 || path59 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
7962
|
+
return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path59, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
|
|
7919
7963
|
}
|
|
7920
7964
|
},
|
|
7921
7965
|
{
|
|
@@ -8238,9 +8282,9 @@ function requestIdOfBody(body) {
|
|
|
8238
8282
|
}
|
|
8239
8283
|
function frontDoorRcControl(transport, token) {
|
|
8240
8284
|
const headers = { authorization: `Bearer ${token}` };
|
|
8241
|
-
const listAnswerOf = async (
|
|
8285
|
+
const listAnswerOf = async (path59, what) => {
|
|
8242
8286
|
try {
|
|
8243
|
-
return await transport.request({ method: "GET", path:
|
|
8287
|
+
return await transport.request({ method: "GET", path: path59, headers });
|
|
8244
8288
|
} catch (error) {
|
|
8245
8289
|
throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
8246
8290
|
}
|
|
@@ -8312,10 +8356,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
8312
8356
|
}
|
|
8313
8357
|
return pending;
|
|
8314
8358
|
};
|
|
8315
|
-
const writeOf = async (
|
|
8359
|
+
const writeOf = async (path59, body, describeFailure2) => {
|
|
8316
8360
|
let answer;
|
|
8317
8361
|
try {
|
|
8318
|
-
answer = await transport.request({ method: "POST", path:
|
|
8362
|
+
answer = await transport.request({ method: "POST", path: path59, headers: { ...headers, "content-type": "application/json" }, body });
|
|
8319
8363
|
} catch (error) {
|
|
8320
8364
|
return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
|
|
8321
8365
|
}
|
|
@@ -8346,10 +8390,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
8346
8390
|
endSession: async (sessionId, reason) => await writeOf(`${CONTROL_PATH_PREFIX}/end-session`, JSON.stringify({ session: sessionId, ...reason === void 0 ? {} : { reason } }), (status, message) => `ending ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
8347
8391
|
getUsage: async (sessionId, skipBehaviors) => await writeOf(`${CONTROL_PATH_PREFIX}/get-usage`, JSON.stringify({ session: sessionId, ...skipBehaviors === void 0 ? {} : { skipBehaviors } }), (status, message) => `requesting the usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
8348
8392
|
getContextUsage: async (sessionId, detail) => await writeOf(`${CONTROL_PATH_PREFIX}/get-context-usage`, JSON.stringify({ session: sessionId, ...detail === void 0 ? {} : { detail } }), (status, message) => `requesting the context usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
8349
|
-
readFile: async (sessionId,
|
|
8393
|
+
readFile: async (sessionId, path59, options) => await writeOf(
|
|
8350
8394
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
8351
|
-
JSON.stringify({ session: sessionId, path:
|
|
8352
|
-
(status, message) => `reading ${
|
|
8395
|
+
JSON.stringify({ session: sessionId, path: path59, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
8396
|
+
(status, message) => `reading ${path59} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
8353
8397
|
),
|
|
8354
8398
|
fileSuggestions: async (sessionId, query) => await writeOf(`${CONTROL_PATH_PREFIX}/file-suggestions`, JSON.stringify({ session: sessionId, query }), (status, message) => `requesting file suggestions from ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
8355
8399
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -8590,12 +8634,12 @@ function tlsFacts(options) {
|
|
|
8590
8634
|
}
|
|
8591
8635
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
8592
8636
|
const agent = new ExemptTlsAgent();
|
|
8593
|
-
const post = async (
|
|
8637
|
+
const post = async (path59, headers, body) => await new Promise((resolve, reject) => {
|
|
8594
8638
|
const options = {
|
|
8595
8639
|
host: target.host,
|
|
8596
8640
|
port: target.port,
|
|
8597
8641
|
method: "POST",
|
|
8598
|
-
path:
|
|
8642
|
+
path: path59,
|
|
8599
8643
|
// The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
|
|
8600
8644
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
8601
8645
|
agent
|
|
@@ -8655,12 +8699,12 @@ function lateRcStreamDial(resolve) {
|
|
|
8655
8699
|
}
|
|
8656
8700
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
8657
8701
|
const agent = new ExemptTlsAgent();
|
|
8658
|
-
const request4 = async (method,
|
|
8702
|
+
const request4 = async (method, path59, headers, body, signal) => await new Promise((resolve, reject) => {
|
|
8659
8703
|
const options = {
|
|
8660
8704
|
host: target.host,
|
|
8661
8705
|
port: target.port,
|
|
8662
8706
|
method,
|
|
8663
|
-
path:
|
|
8707
|
+
path: path59,
|
|
8664
8708
|
// The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
|
|
8665
8709
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
8666
8710
|
agent,
|
|
@@ -8702,9 +8746,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
8702
8746
|
return { status, body: await readAll(response) };
|
|
8703
8747
|
},
|
|
8704
8748
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
8705
|
-
const
|
|
8749
|
+
const path59 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
|
|
8706
8750
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
8707
|
-
const { status, response } = await request4("GET",
|
|
8751
|
+
const { status, response } = await request4("GET", path59, streamHeaders, void 0, signal);
|
|
8708
8752
|
if (!isSuccessful2(status)) {
|
|
8709
8753
|
await readAll(response);
|
|
8710
8754
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -9192,9 +9236,9 @@ var init_identity2 = __esm({
|
|
|
9192
9236
|
|
|
9193
9237
|
// src/statusline/keys.ts
|
|
9194
9238
|
import { z as z13 } from "zod";
|
|
9195
|
-
function valueAt(source,
|
|
9239
|
+
function valueAt(source, path59) {
|
|
9196
9240
|
let current = source;
|
|
9197
|
-
for (const part of
|
|
9241
|
+
for (const part of path59) {
|
|
9198
9242
|
if (!isPlainObject(current)) {
|
|
9199
9243
|
return void 0;
|
|
9200
9244
|
}
|
|
@@ -9202,14 +9246,14 @@ function valueAt(source, path56) {
|
|
|
9202
9246
|
}
|
|
9203
9247
|
return current;
|
|
9204
9248
|
}
|
|
9205
|
-
function acceptsNull(
|
|
9206
|
-
const layer =
|
|
9249
|
+
function acceptsNull(path59) {
|
|
9250
|
+
const layer = path59.reduceRight((inner, part) => ({ [part]: inner }), null);
|
|
9207
9251
|
return StatuslineSchema.safeParse(layer).success;
|
|
9208
9252
|
}
|
|
9209
|
-
function keyOf(
|
|
9253
|
+
function keyOf(path59, declared) {
|
|
9210
9254
|
const optional = declared instanceof z13.ZodOptional;
|
|
9211
9255
|
const leaf = optional ? declared.unwrap() : declared;
|
|
9212
|
-
const common = { path:
|
|
9256
|
+
const common = { path: path59.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path59), optional, unsettable: acceptsNull(path59) };
|
|
9213
9257
|
if (leaf instanceof z13.ZodNumber) {
|
|
9214
9258
|
return { ...common, kind: "integer", choices: [] };
|
|
9215
9259
|
}
|
|
@@ -9234,7 +9278,7 @@ function keyOf(path56, declared) {
|
|
|
9234
9278
|
if (leaf instanceof z13.ZodArray && leaf.element instanceof z13.ZodString) {
|
|
9235
9279
|
return { ...common, kind: "textList", choices: [] };
|
|
9236
9280
|
}
|
|
9237
|
-
throw new TypeError(`statusline setting ${
|
|
9281
|
+
throw new TypeError(`statusline setting ${path59.join(".")} has a kind the key listing does not describe`);
|
|
9238
9282
|
}
|
|
9239
9283
|
function walk(shape, prefix) {
|
|
9240
9284
|
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof z13.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
@@ -9250,15 +9294,15 @@ var init_keys = __esm({
|
|
|
9250
9294
|
});
|
|
9251
9295
|
|
|
9252
9296
|
// src/statusline/change.ts
|
|
9253
|
-
function keyNamed(
|
|
9254
|
-
const found = statuslineKeys().find((key) => key.path ===
|
|
9297
|
+
function keyNamed(path59) {
|
|
9298
|
+
const found = statuslineKeys().find((key) => key.path === path59);
|
|
9255
9299
|
if (found === void 0) {
|
|
9256
|
-
throw new UsageError(`"${
|
|
9300
|
+
throw new UsageError(`"${path59}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
|
|
9257
9301
|
}
|
|
9258
9302
|
return found;
|
|
9259
9303
|
}
|
|
9260
|
-
function setAt(target,
|
|
9261
|
-
const [head, ...rest] =
|
|
9304
|
+
function setAt(target, path59, value) {
|
|
9305
|
+
const [head, ...rest] = path59;
|
|
9262
9306
|
if (head === void 0) {
|
|
9263
9307
|
return;
|
|
9264
9308
|
}
|
|
@@ -9271,8 +9315,8 @@ function setAt(target, path56, value) {
|
|
|
9271
9315
|
target[head] = next;
|
|
9272
9316
|
setAt(next, rest, value);
|
|
9273
9317
|
}
|
|
9274
|
-
function removeAt(target,
|
|
9275
|
-
const [head, ...rest] =
|
|
9318
|
+
function removeAt(target, path59) {
|
|
9319
|
+
const [head, ...rest] = path59;
|
|
9276
9320
|
if (head === void 0) {
|
|
9277
9321
|
return;
|
|
9278
9322
|
}
|
|
@@ -9290,13 +9334,13 @@ function removeAt(target, path56) {
|
|
|
9290
9334
|
}
|
|
9291
9335
|
function applyStatuslineChange(existing, change) {
|
|
9292
9336
|
const draft = structuredClone(existing ?? {});
|
|
9293
|
-
for (const [
|
|
9294
|
-
keyNamed(
|
|
9295
|
-
setAt(draft,
|
|
9337
|
+
for (const [path59, value] of Object.entries(change.set ?? {})) {
|
|
9338
|
+
keyNamed(path59);
|
|
9339
|
+
setAt(draft, path59.split("."), value);
|
|
9296
9340
|
}
|
|
9297
|
-
for (const
|
|
9298
|
-
keyNamed(
|
|
9299
|
-
removeAt(draft,
|
|
9341
|
+
for (const path59 of change.unset ?? []) {
|
|
9342
|
+
keyNamed(path59);
|
|
9343
|
+
removeAt(draft, path59.split("."));
|
|
9300
9344
|
}
|
|
9301
9345
|
const result = StatuslineSchema.safeParse(draft);
|
|
9302
9346
|
if (!result.success) {
|
|
@@ -9532,19 +9576,19 @@ function writePools(paths, pools) {
|
|
|
9532
9576
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
9533
9577
|
}
|
|
9534
9578
|
function poolCycleOf(pools, name) {
|
|
9535
|
-
const walk2 = (current,
|
|
9579
|
+
const walk2 = (current, path59) => {
|
|
9536
9580
|
for (const entry of pools[current]?.identities ?? []) {
|
|
9537
9581
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
9538
9582
|
if (nested === void 0) {
|
|
9539
9583
|
continue;
|
|
9540
9584
|
}
|
|
9541
9585
|
if (nested === name) {
|
|
9542
|
-
return [...
|
|
9586
|
+
return [...path59, nested];
|
|
9543
9587
|
}
|
|
9544
|
-
if (
|
|
9588
|
+
if (path59.includes(nested)) {
|
|
9545
9589
|
continue;
|
|
9546
9590
|
}
|
|
9547
|
-
const found = walk2(nested, [...
|
|
9591
|
+
const found = walk2(nested, [...path59, nested]);
|
|
9548
9592
|
if (found !== void 0) {
|
|
9549
9593
|
return found;
|
|
9550
9594
|
}
|
|
@@ -11046,15 +11090,15 @@ function pathDirectories(target, ports) {
|
|
|
11046
11090
|
}
|
|
11047
11091
|
return directories;
|
|
11048
11092
|
}
|
|
11049
|
-
function headroomDirectoryRefusal(directory, stat, uid,
|
|
11093
|
+
function headroomDirectoryRefusal(directory, stat, uid, remedy2) {
|
|
11050
11094
|
if (stat?.kind !== "dir") {
|
|
11051
11095
|
return `the directory ${directory} on the allowlist file's path is ${stat === void 0 ? "missing" : "not a directory"}, so headroom refuses the file`;
|
|
11052
11096
|
}
|
|
11053
11097
|
if (stat.uid !== uid && stat.uid !== ROOT_UID) {
|
|
11054
|
-
return `the directory ${directory} on the allowlist file's path is owned by uid ${String(stat.uid)}, not by this user (uid ${String(uid)}) or root, so headroom refuses the file${
|
|
11098
|
+
return `the directory ${directory} on the allowlist file's path is owned by uid ${String(stat.uid)}, not by this user (uid ${String(uid)}) or root, so headroom refuses the file${remedy2 ? `; ${MOVE_ROOT_REMEDY}` : ""}`;
|
|
11055
11099
|
}
|
|
11056
11100
|
if ((stat.mode & GROUP_OR_OTHER_WRITE_BITS) !== 0) {
|
|
11057
|
-
return `the directory ${directory} on the allowlist file's path is writable by group or others (mode ${stat.mode.toString(OCTAL_RADIX2).padStart(MODE_DIGITS, "0")}), so headroom refuses the file${
|
|
11101
|
+
return `the directory ${directory} on the allowlist file's path is writable by group or others (mode ${stat.mode.toString(OCTAL_RADIX2).padStart(MODE_DIGITS, "0")}), so headroom refuses the file${remedy2 ? `; ${stat.uid === uid && (stat.mode & STICKY_BIT) === 0 ? `run \`chmod go-w ${directory}\`` : MOVE_ROOT_REMEDY}` : ""}`;
|
|
11058
11102
|
}
|
|
11059
11103
|
return void 0;
|
|
11060
11104
|
}
|
|
@@ -11962,6 +12006,9 @@ var init_realPorts = __esm({
|
|
|
11962
12006
|
const kind = stat.isSymbolicLink() ? "symlink" : stat.isDirectory() ? "dir" : "file";
|
|
11963
12007
|
return { kind, mtimeMs: stat.mtimeMs, sizeBytes: stat.size };
|
|
11964
12008
|
},
|
|
12009
|
+
resolves(filePath) {
|
|
12010
|
+
return fs6.statSync(filePath, { throwIfNoEntry: false }) !== void 0;
|
|
12011
|
+
},
|
|
11965
12012
|
readdir(dirPath) {
|
|
11966
12013
|
try {
|
|
11967
12014
|
return fs6.readdirSync(dirPath);
|
|
@@ -14023,8 +14070,8 @@ var init_identityStore = __esm({
|
|
|
14023
14070
|
init_identityRecords();
|
|
14024
14071
|
init_launchRecords();
|
|
14025
14072
|
IdentityNotFoundError = class extends CliError {
|
|
14026
|
-
constructor(name,
|
|
14027
|
-
super(`No identity named "${name}". ${
|
|
14073
|
+
constructor(name, remedy2 = `Run \`agent-shim identity add ${name}\` first.`) {
|
|
14074
|
+
super(`No identity named "${name}". ${remedy2}`);
|
|
14028
14075
|
this.name = name;
|
|
14029
14076
|
this.name = "IdentityNotFoundError";
|
|
14030
14077
|
}
|
|
@@ -14082,7 +14129,7 @@ var init_package = __esm({
|
|
|
14082
14129
|
"package.json"() {
|
|
14083
14130
|
package_default = {
|
|
14084
14131
|
name: "claude-use",
|
|
14085
|
-
version: "14.
|
|
14132
|
+
version: "14.5.0",
|
|
14086
14133
|
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.",
|
|
14087
14134
|
license: "MIT",
|
|
14088
14135
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -14188,6 +14235,28 @@ var init_package = __esm({
|
|
|
14188
14235
|
}
|
|
14189
14236
|
});
|
|
14190
14237
|
|
|
14238
|
+
// src/supervise/sessionControl.ts
|
|
14239
|
+
import path33 from "node:path";
|
|
14240
|
+
import { z as z24 } from "zod";
|
|
14241
|
+
var RESULT_POLL_MS, SessionControlConversationSchema, REQUEST_INSTANT_DIGITS;
|
|
14242
|
+
var init_sessionControl = __esm({
|
|
14243
|
+
"src/supervise/sessionControl.ts"() {
|
|
14244
|
+
"use strict";
|
|
14245
|
+
RESULT_POLL_MS = 250;
|
|
14246
|
+
SessionControlConversationSchema = z24.object({ conversationId: z24.string().min(1), transcriptPath: z24.string().refine(path33.isAbsolute) });
|
|
14247
|
+
REQUEST_INSTANT_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
|
|
14248
|
+
}
|
|
14249
|
+
});
|
|
14250
|
+
|
|
14251
|
+
// src/supervise/verifiedVersions.ts
|
|
14252
|
+
var RC_SESSION_COMMAND_VERIFIED_VERSIONS;
|
|
14253
|
+
var init_verifiedVersions = __esm({
|
|
14254
|
+
"src/supervise/verifiedVersions.ts"() {
|
|
14255
|
+
"use strict";
|
|
14256
|
+
RC_SESSION_COMMAND_VERIFIED_VERSIONS = ["2.1.319", "2.1.325"];
|
|
14257
|
+
}
|
|
14258
|
+
});
|
|
14259
|
+
|
|
14191
14260
|
// src/launcher/claudeVersion.ts
|
|
14192
14261
|
function validated2(value, origin) {
|
|
14193
14262
|
if (!NUMERIC_DOTTED_VERSION_RE.test(value)) {
|
|
@@ -14291,8 +14360,8 @@ var init_commandDeps = __esm({
|
|
|
14291
14360
|
|
|
14292
14361
|
// src/claudeShim.ts
|
|
14293
14362
|
import fs9 from "node:fs";
|
|
14294
|
-
import
|
|
14295
|
-
import { z as
|
|
14363
|
+
import path34 from "node:path";
|
|
14364
|
+
import { z as z30 } from "zod";
|
|
14296
14365
|
function commandFilename(ownExecutablePath, commandName) {
|
|
14297
14366
|
return ownExecutablePath.toLowerCase().endsWith(".exe") ? `${commandName}.exe` : commandName;
|
|
14298
14367
|
}
|
|
@@ -14316,10 +14385,10 @@ function isLauncherScript(candidate) {
|
|
|
14316
14385
|
}
|
|
14317
14386
|
function resolveOwnBinaryCheck(paths, contentSourcePath) {
|
|
14318
14387
|
const state = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
14319
|
-
const recordedTarget = state === void 0 ? void 0 :
|
|
14388
|
+
const recordedTarget = state === void 0 ? void 0 : path34.resolve(state.targetPath);
|
|
14320
14389
|
let ownStat;
|
|
14321
14390
|
return (candidate) => {
|
|
14322
|
-
if (recordedTarget !== void 0 &&
|
|
14391
|
+
if (recordedTarget !== void 0 && path34.resolve(candidate) === recordedTarget) {
|
|
14323
14392
|
return true;
|
|
14324
14393
|
}
|
|
14325
14394
|
ownStat ??= statOrUndefined(contentSourcePath);
|
|
@@ -14343,15 +14412,15 @@ function statOrUndefined(target) {
|
|
|
14343
14412
|
}
|
|
14344
14413
|
}
|
|
14345
14414
|
function findPathShadow(params) {
|
|
14346
|
-
const resolvedTargetDir =
|
|
14415
|
+
const resolvedTargetDir = path34.resolve(params.targetDir);
|
|
14347
14416
|
for (const dir of params.pathDirs) {
|
|
14348
14417
|
const found = params.findExecutableInDir(dir, params.targetFilename);
|
|
14349
14418
|
if (found === void 0) {
|
|
14350
14419
|
continue;
|
|
14351
14420
|
}
|
|
14352
|
-
return
|
|
14421
|
+
return path34.resolve(dir) === resolvedTargetDir ? { status: "ok" } : { status: "shadowed", by: found };
|
|
14353
14422
|
}
|
|
14354
|
-
return params.pathDirs.some((dir) =>
|
|
14423
|
+
return params.pathDirs.some((dir) => path34.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
|
|
14355
14424
|
}
|
|
14356
14425
|
var ClaudeShimStateSchema, SCRIPT_HEAD_BYTES, LAUNCHER_NAME, EXEC_RUN, nodeLinkFs;
|
|
14357
14426
|
var init_claudeShim = __esm({
|
|
@@ -14361,10 +14430,10 @@ var init_claudeShim = __esm({
|
|
|
14361
14430
|
init_store();
|
|
14362
14431
|
init_realPorts();
|
|
14363
14432
|
init_cliError();
|
|
14364
|
-
ClaudeShimStateSchema =
|
|
14365
|
-
targetPath:
|
|
14366
|
-
method:
|
|
14367
|
-
installedAtMs:
|
|
14433
|
+
ClaudeShimStateSchema = z30.strictObject({
|
|
14434
|
+
targetPath: z30.string().min(1),
|
|
14435
|
+
method: z30.enum(["hardlink", "copy"]),
|
|
14436
|
+
installedAtMs: z30.number()
|
|
14368
14437
|
});
|
|
14369
14438
|
SCRIPT_HEAD_BYTES = 4096;
|
|
14370
14439
|
LAUNCHER_NAME = /\b(agent-shim|claude-use)\b/;
|
|
@@ -14749,7 +14818,7 @@ var init_reservedModelNames = __esm({
|
|
|
14749
14818
|
});
|
|
14750
14819
|
|
|
14751
14820
|
// src/providerAliases.ts
|
|
14752
|
-
import { z as
|
|
14821
|
+
import { z as z31 } from "zod";
|
|
14753
14822
|
function parseAliases(file, raw) {
|
|
14754
14823
|
const parsed = ProviderAliasesSchema.safeParse(raw);
|
|
14755
14824
|
if (!parsed.success) {
|
|
@@ -14788,7 +14857,7 @@ var init_providerAliases = __esm({
|
|
|
14788
14857
|
init_cliError();
|
|
14789
14858
|
init_load();
|
|
14790
14859
|
init_store();
|
|
14791
|
-
ProviderAliasesSchema =
|
|
14860
|
+
ProviderAliasesSchema = z31.record(z31.string().min(1), z31.string().min(1));
|
|
14792
14861
|
}
|
|
14793
14862
|
});
|
|
14794
14863
|
|
|
@@ -15360,18 +15429,18 @@ var init_envBool = __esm({
|
|
|
15360
15429
|
});
|
|
15361
15430
|
|
|
15362
15431
|
// src/pathNorm.ts
|
|
15363
|
-
import
|
|
15432
|
+
import path38 from "node:path";
|
|
15364
15433
|
function expandTilde(value, home) {
|
|
15365
15434
|
if (value === "~") {
|
|
15366
15435
|
return home;
|
|
15367
15436
|
}
|
|
15368
15437
|
if (value.startsWith("~/")) {
|
|
15369
|
-
return
|
|
15438
|
+
return path38.join(home, value.slice(2));
|
|
15370
15439
|
}
|
|
15371
15440
|
return value;
|
|
15372
15441
|
}
|
|
15373
15442
|
function normaliseRulePath(rulePath, home) {
|
|
15374
|
-
return
|
|
15443
|
+
return path38.resolve(expandTilde(rulePath, home));
|
|
15375
15444
|
}
|
|
15376
15445
|
var init_pathNorm = __esm({
|
|
15377
15446
|
"src/pathNorm.ts"() {
|
|
@@ -15380,7 +15449,7 @@ var init_pathNorm = __esm({
|
|
|
15380
15449
|
});
|
|
15381
15450
|
|
|
15382
15451
|
// src/launcher/cascade.ts
|
|
15383
|
-
import
|
|
15452
|
+
import path39 from "node:path";
|
|
15384
15453
|
function loadCascadeInput(params) {
|
|
15385
15454
|
const globalConfig = loadConfigFile(params.paths.globalConfigFile, GlobalConfigSchema, params.read);
|
|
15386
15455
|
const directoryRules = loadConfigFile(params.paths.directoryRulesFile, DirectoryRulesSchema, params.read);
|
|
@@ -15400,8 +15469,8 @@ function loadCascadeInput(params) {
|
|
|
15400
15469
|
});
|
|
15401
15470
|
const levels = [];
|
|
15402
15471
|
for (const dir of dirs) {
|
|
15403
|
-
const portable = loadConfigFile(
|
|
15404
|
-
const portableLocal = loadConfigFile(
|
|
15472
|
+
const portable = loadConfigFile(path39.join(dir, PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(path39.join(dir, LEGACY_PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read);
|
|
15473
|
+
const portableLocal = loadConfigFile(path39.join(dir, PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(path39.join(dir, LEGACY_PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read);
|
|
15405
15474
|
const rules = (directoryRules?.config.rules ?? []).map((rule, index) => ({ rule, index })).filter(({ rule }) => normaliseRulePath(rule.path, params.home) === dir).map(({ rule, index }) => {
|
|
15406
15475
|
const entryOrder = directoryRules?.ruleEntryOrders[index];
|
|
15407
15476
|
return {
|
|
@@ -15541,14 +15610,14 @@ var init_memberProvider = __esm({
|
|
|
15541
15610
|
// src/paths.ts
|
|
15542
15611
|
import fs12 from "node:fs";
|
|
15543
15612
|
import os6 from "node:os";
|
|
15544
|
-
import
|
|
15613
|
+
import path40 from "node:path";
|
|
15545
15614
|
function resolveAgentShimHome(env = process.env, home = os6.homedir(), isDirectory = isExistingDirectory) {
|
|
15546
15615
|
const fromEnv = env.AGENT_SHIM_HOME;
|
|
15547
15616
|
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15548
15617
|
return fromEnv;
|
|
15549
15618
|
}
|
|
15550
|
-
const current =
|
|
15551
|
-
const legacy =
|
|
15619
|
+
const current = path40.join(home, HOME_DIRNAME);
|
|
15620
|
+
const legacy = path40.join(home, LEGACY_HOME_DIRNAME);
|
|
15552
15621
|
return !isDirectory(current) && isDirectory(legacy) ? legacy : current;
|
|
15553
15622
|
}
|
|
15554
15623
|
function isExistingDirectory(candidate) {
|
|
@@ -15559,59 +15628,60 @@ function resolveClaudeHome() {
|
|
|
15559
15628
|
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15560
15629
|
return fromEnv;
|
|
15561
15630
|
}
|
|
15562
|
-
return
|
|
15631
|
+
return path40.join(os6.homedir(), ".claude");
|
|
15563
15632
|
}
|
|
15564
15633
|
function buildLayoutPaths(root) {
|
|
15565
15634
|
return {
|
|
15566
15635
|
root,
|
|
15567
|
-
identitiesDir:
|
|
15568
|
-
configProfilesDir:
|
|
15569
|
-
providersDir:
|
|
15570
|
-
providerAliasesFile:
|
|
15571
|
-
directoryRulesFile:
|
|
15572
|
-
activeIdentityFile:
|
|
15573
|
-
globalConfigFile:
|
|
15574
|
-
categoriesLocalFile:
|
|
15575
|
-
claudeShimFile:
|
|
15576
|
-
headroomDir:
|
|
15577
|
-
headroomStateFile:
|
|
15578
|
-
headroomRoutingFile:
|
|
15579
|
-
headroomLegacyStateFile:
|
|
15580
|
-
headroomAllowlistFile:
|
|
15581
|
-
headroomSocketDir:
|
|
15582
|
-
headroomLockFile:
|
|
15583
|
-
headroomSessionsDir:
|
|
15584
|
-
logsDir:
|
|
15585
|
-
headroomLogPath:
|
|
15586
|
-
frontdoorDir:
|
|
15587
|
-
frontdoorCaDir:
|
|
15588
|
-
frontdoorCaCertFile:
|
|
15589
|
-
frontdoorCaKeyFile:
|
|
15590
|
-
frontdoorCaBundlesDir:
|
|
15591
|
-
chatgptSignInFile:
|
|
15592
|
-
frontdoorStateFile:
|
|
15593
|
-
frontdoorLockFile:
|
|
15594
|
-
frontdoorControlTokenFile:
|
|
15595
|
-
frontdoorSessionsDir:
|
|
15596
|
-
frontdoorDirectRecordsDir:
|
|
15597
|
-
frontdoorDrainingDir:
|
|
15598
|
-
frontdoorRcCredentialsDir:
|
|
15599
|
-
frontdoorLogPath:
|
|
15600
|
-
usageDir:
|
|
15601
|
-
usageLogDir:
|
|
15602
|
-
usageSnapshotsDir:
|
|
15603
|
-
statuslineDir:
|
|
15604
|
-
catalogueDir:
|
|
15605
|
-
usagePicksFile:
|
|
15606
|
-
usageAnchorsFile:
|
|
15607
|
-
usageJobsFile:
|
|
15608
|
-
jobLogsDir:
|
|
15609
|
-
identityRenamesDir:
|
|
15610
|
-
identityNameRenamesDir:
|
|
15611
|
-
launchesDir:
|
|
15612
|
-
|
|
15613
|
-
|
|
15614
|
-
|
|
15636
|
+
identitiesDir: path40.join(root, "identities"),
|
|
15637
|
+
configProfilesDir: path40.join(root, "config-profiles"),
|
|
15638
|
+
providersDir: path40.join(root, "providers"),
|
|
15639
|
+
providerAliasesFile: path40.join(root, "provider-aliases.json"),
|
|
15640
|
+
directoryRulesFile: path40.join(root, "directory-rules.json"),
|
|
15641
|
+
activeIdentityFile: path40.join(root, "active-identity"),
|
|
15642
|
+
globalConfigFile: path40.join(root, "config.json"),
|
|
15643
|
+
categoriesLocalFile: path40.join(root, "categories.local.json"),
|
|
15644
|
+
claudeShimFile: path40.join(root, "claude-shim.json"),
|
|
15645
|
+
headroomDir: path40.join(root, "headroom"),
|
|
15646
|
+
headroomStateFile: path40.join(root, "headroom", "state.json"),
|
|
15647
|
+
headroomRoutingFile: path40.join(root, "headroom", "routing.json"),
|
|
15648
|
+
headroomLegacyStateFile: path40.join(root, "headroom", "state.v2.json"),
|
|
15649
|
+
headroomAllowlistFile: path40.join(root, "headroom", "run", "allowlist.txt"),
|
|
15650
|
+
headroomSocketDir: path40.join(root, "headroom", "run"),
|
|
15651
|
+
headroomLockFile: path40.join(root, "headroom", "start.lock"),
|
|
15652
|
+
headroomSessionsDir: path40.join(root, "headroom", "sessions"),
|
|
15653
|
+
logsDir: path40.join(root, "logs"),
|
|
15654
|
+
headroomLogPath: path40.join(root, "logs", "headroom.log"),
|
|
15655
|
+
frontdoorDir: path40.join(root, "frontdoor"),
|
|
15656
|
+
frontdoorCaDir: path40.join(root, "frontdoor", "ca"),
|
|
15657
|
+
frontdoorCaCertFile: path40.join(root, "frontdoor", "ca", "ca.pem"),
|
|
15658
|
+
frontdoorCaKeyFile: path40.join(root, "frontdoor", "ca", "ca.key"),
|
|
15659
|
+
frontdoorCaBundlesDir: path40.join(root, "frontdoor", "ca", "bundles"),
|
|
15660
|
+
chatgptSignInFile: path40.join(root, "codex", "chatgpt-sign-in.json"),
|
|
15661
|
+
frontdoorStateFile: path40.join(root, "frontdoor", "state.json"),
|
|
15662
|
+
frontdoorLockFile: path40.join(root, "frontdoor", "start.lock"),
|
|
15663
|
+
frontdoorControlTokenFile: path40.join(root, "frontdoor", "control-token"),
|
|
15664
|
+
frontdoorSessionsDir: path40.join(root, "frontdoor", "sessions"),
|
|
15665
|
+
frontdoorDirectRecordsDir: path40.join(root, "frontdoor", "direct"),
|
|
15666
|
+
frontdoorDrainingDir: path40.join(root, "frontdoor", "draining"),
|
|
15667
|
+
frontdoorRcCredentialsDir: path40.join(root, "frontdoor", "rc-credentials"),
|
|
15668
|
+
frontdoorLogPath: path40.join(root, "logs", "frontdoor.log"),
|
|
15669
|
+
usageDir: path40.join(root, "usage"),
|
|
15670
|
+
usageLogDir: path40.join(root, "usage", "log"),
|
|
15671
|
+
usageSnapshotsDir: path40.join(root, "usage", "snapshots"),
|
|
15672
|
+
statuslineDir: path40.join(root, "statusline"),
|
|
15673
|
+
catalogueDir: path40.join(root, "catalogues"),
|
|
15674
|
+
usagePicksFile: path40.join(root, "usage", "picks.json"),
|
|
15675
|
+
usageAnchorsFile: path40.join(root, "usage", "anchors.json"),
|
|
15676
|
+
usageJobsFile: path40.join(root, "usage", "jobs.json"),
|
|
15677
|
+
jobLogsDir: path40.join(root, "logs", "jobs"),
|
|
15678
|
+
identityRenamesDir: path40.join(root, "identity-renames"),
|
|
15679
|
+
identityNameRenamesDir: path40.join(root, "identity-name-renames"),
|
|
15680
|
+
launchesDir: path40.join(root, "launches"),
|
|
15681
|
+
launchControlDir: path40.join(root, "launch-control"),
|
|
15682
|
+
superviseDir: path40.join(root, "supervise"),
|
|
15683
|
+
modelMovesDir: path40.join(root, "model-moves"),
|
|
15684
|
+
mcpPermissionsFile: path40.join(root, "mcp", "permissions.json")
|
|
15615
15685
|
};
|
|
15616
15686
|
}
|
|
15617
15687
|
function resolveLayoutPaths() {
|
|
@@ -15625,7 +15695,7 @@ var init_paths = __esm({
|
|
|
15625
15695
|
});
|
|
15626
15696
|
|
|
15627
15697
|
// src/storedCatalogue.ts
|
|
15628
|
-
import
|
|
15698
|
+
import path42 from "node:path";
|
|
15629
15699
|
function catalogueReadFault(error) {
|
|
15630
15700
|
if (error instanceof UnreadableCatalogueError) {
|
|
15631
15701
|
return error.fault;
|
|
@@ -15634,10 +15704,10 @@ function catalogueReadFault(error) {
|
|
|
15634
15704
|
return typeof code === "string" && /^[A-Z0-9_]{1,32}$/u.test(code) ? code : error instanceof Error ? error.name : "an error";
|
|
15635
15705
|
}
|
|
15636
15706
|
function catalogueStatusFile(paths, owner, name) {
|
|
15637
|
-
return
|
|
15707
|
+
return path42.join(path42.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), `${name}.status.json`);
|
|
15638
15708
|
}
|
|
15639
15709
|
function catalogueFailureFile(paths, owner, name) {
|
|
15640
|
-
return
|
|
15710
|
+
return path42.join(path42.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), "failures", `${name}.json`);
|
|
15641
15711
|
}
|
|
15642
15712
|
var UnreadableCatalogueError, skipUnreadableCatalogue, TolerantReader, StoredCatalogue;
|
|
15643
15713
|
var init_storedCatalogue = __esm({
|
|
@@ -15728,12 +15798,12 @@ var init_tolerantReaders = __esm({
|
|
|
15728
15798
|
});
|
|
15729
15799
|
|
|
15730
15800
|
// src/frontdoor/catalogueState.ts
|
|
15731
|
-
import { z as
|
|
15801
|
+
import { z as z33 } from "zod";
|
|
15732
15802
|
function readCatalogueFailure(fs17, paths, pid, generation, name) {
|
|
15733
15803
|
const raw = new StoredCatalogue(paths, skippingReader(fs17)).failureText({ pid, generation }, name);
|
|
15734
15804
|
if (raw === void 0) return void 0;
|
|
15735
15805
|
try {
|
|
15736
|
-
const value =
|
|
15806
|
+
const value = z33.strictObject({ reason: z33.string().max(CATALOGUE_FAILURE_REASON_MAX_CHARS), redirected: z33.literal(true).optional(), settings: z33.string().optional() }).safeParse(JSON.parse(raw));
|
|
15737
15807
|
return value.success ? { reason: value.data.reason, redirected: value.data.redirected === true, settings: value.data.settings } : void 0;
|
|
15738
15808
|
} catch {
|
|
15739
15809
|
return void 0;
|
|
@@ -15743,7 +15813,7 @@ function readCatalogueStatus(fs17, paths, pid, generation, name) {
|
|
|
15743
15813
|
const raw = new StoredCatalogue(paths, skippingReader(fs17)).statusText({ pid, generation }, name);
|
|
15744
15814
|
if (raw === void 0) return void 0;
|
|
15745
15815
|
try {
|
|
15746
|
-
const value =
|
|
15816
|
+
const value = z33.strictObject({ status: z33.enum(["running", "ready", "failed"]), fingerprint: z33.string().min(1).optional(), recordedAt: z33.number().optional() }).safeParse(JSON.parse(raw));
|
|
15747
15817
|
return value.success ? value.data : void 0;
|
|
15748
15818
|
} catch {
|
|
15749
15819
|
return void 0;
|
|
@@ -15760,25 +15830,25 @@ var init_catalogueState = __esm({
|
|
|
15760
15830
|
});
|
|
15761
15831
|
|
|
15762
15832
|
// src/codex/auth.ts
|
|
15763
|
-
import { z as
|
|
15833
|
+
import { z as z34 } from "zod";
|
|
15764
15834
|
var AuthFileSchema, TokenGrantSchema, CodexAuthError;
|
|
15765
15835
|
var init_auth = __esm({
|
|
15766
15836
|
"src/codex/auth.ts"() {
|
|
15767
15837
|
"use strict";
|
|
15768
|
-
AuthFileSchema =
|
|
15769
|
-
tokens:
|
|
15770
|
-
access_token:
|
|
15771
|
-
refresh_token:
|
|
15772
|
-
id_token:
|
|
15773
|
-
account_id:
|
|
15838
|
+
AuthFileSchema = z34.looseObject({
|
|
15839
|
+
tokens: z34.looseObject({
|
|
15840
|
+
access_token: z34.string().optional(),
|
|
15841
|
+
refresh_token: z34.string().optional(),
|
|
15842
|
+
id_token: z34.string().optional(),
|
|
15843
|
+
account_id: z34.string().optional()
|
|
15774
15844
|
}).nullish(),
|
|
15775
|
-
last_refresh:
|
|
15845
|
+
last_refresh: z34.string().optional()
|
|
15776
15846
|
});
|
|
15777
|
-
TokenGrantSchema =
|
|
15778
|
-
access_token:
|
|
15779
|
-
refresh_token:
|
|
15780
|
-
id_token:
|
|
15781
|
-
account_id:
|
|
15847
|
+
TokenGrantSchema = z34.looseObject({
|
|
15848
|
+
access_token: z34.string().min(1).optional(),
|
|
15849
|
+
refresh_token: z34.string().min(1).optional(),
|
|
15850
|
+
id_token: z34.string().min(1).optional(),
|
|
15851
|
+
account_id: z34.string().min(1).optional()
|
|
15782
15852
|
});
|
|
15783
15853
|
CodexAuthError = class extends Error {
|
|
15784
15854
|
constructor(message) {
|
|
@@ -15790,7 +15860,7 @@ var init_auth = __esm({
|
|
|
15790
15860
|
});
|
|
15791
15861
|
|
|
15792
15862
|
// src/codex/siwc.ts
|
|
15793
|
-
import { z as
|
|
15863
|
+
import { z as z35 } from "zod";
|
|
15794
15864
|
var SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
|
|
15795
15865
|
var init_siwc = __esm({
|
|
15796
15866
|
"src/codex/siwc.ts"() {
|
|
@@ -15798,28 +15868,28 @@ var init_siwc = __esm({
|
|
|
15798
15868
|
SIWC_RESOURCE = "https://api.openai.com/v1";
|
|
15799
15869
|
SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
|
|
15800
15870
|
SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
|
|
15801
|
-
TokenResponseSchema =
|
|
15802
|
-
access_token:
|
|
15803
|
-
refresh_token:
|
|
15804
|
-
id_token:
|
|
15805
|
-
expires_in:
|
|
15806
|
-
scope:
|
|
15871
|
+
TokenResponseSchema = z35.looseObject({
|
|
15872
|
+
access_token: z35.string().min(1),
|
|
15873
|
+
refresh_token: z35.string().min(1).optional(),
|
|
15874
|
+
id_token: z35.string().min(1).optional(),
|
|
15875
|
+
expires_in: z35.number().positive(),
|
|
15876
|
+
scope: z35.string().optional()
|
|
15807
15877
|
});
|
|
15808
|
-
JwtHeaderSchema =
|
|
15809
|
-
IdTokenClaimsSchema =
|
|
15810
|
-
iss:
|
|
15811
|
-
sub:
|
|
15812
|
-
aud:
|
|
15813
|
-
exp:
|
|
15814
|
-
nonce:
|
|
15815
|
-
email:
|
|
15878
|
+
JwtHeaderSchema = z35.looseObject({ alg: z35.string(), kid: z35.string().optional() });
|
|
15879
|
+
IdTokenClaimsSchema = z35.looseObject({
|
|
15880
|
+
iss: z35.string(),
|
|
15881
|
+
sub: z35.string().min(1),
|
|
15882
|
+
aud: z35.union([z35.string(), z35.array(z35.string())]),
|
|
15883
|
+
exp: z35.number(),
|
|
15884
|
+
nonce: z35.string().optional(),
|
|
15885
|
+
email: z35.string().optional()
|
|
15816
15886
|
});
|
|
15817
|
-
JwksSchema =
|
|
15887
|
+
JwksSchema = z35.object({ keys: z35.array(z35.looseObject({ kid: z35.string().optional(), kty: z35.string() })) });
|
|
15818
15888
|
}
|
|
15819
15889
|
});
|
|
15820
15890
|
|
|
15821
15891
|
// src/codex/siwcStore.ts
|
|
15822
|
-
import { z as
|
|
15892
|
+
import { z as z36 } from "zod";
|
|
15823
15893
|
function parseSiwcFile(raw, filePath) {
|
|
15824
15894
|
let json;
|
|
15825
15895
|
try {
|
|
@@ -15839,18 +15909,18 @@ var init_siwcStore = __esm({
|
|
|
15839
15909
|
"use strict";
|
|
15840
15910
|
init_auth();
|
|
15841
15911
|
init_siwc();
|
|
15842
|
-
SiwcGrantSchema =
|
|
15843
|
-
clientId:
|
|
15844
|
-
sub:
|
|
15845
|
-
email:
|
|
15846
|
-
idToken:
|
|
15847
|
-
accessToken:
|
|
15848
|
-
refreshToken:
|
|
15849
|
-
scopes:
|
|
15912
|
+
SiwcGrantSchema = z36.strictObject({
|
|
15913
|
+
clientId: z36.string().min(1),
|
|
15914
|
+
sub: z36.string().min(1),
|
|
15915
|
+
email: z36.string().optional(),
|
|
15916
|
+
idToken: z36.string().min(1),
|
|
15917
|
+
accessToken: z36.string().min(1),
|
|
15918
|
+
refreshToken: z36.string().min(1),
|
|
15919
|
+
scopes: z36.array(z36.string()).readonly(),
|
|
15850
15920
|
/** When the access token stops working, in milliseconds since the epoch. */
|
|
15851
|
-
expiresAt:
|
|
15921
|
+
expiresAt: z36.number()
|
|
15852
15922
|
});
|
|
15853
|
-
SiwcFileSchema =
|
|
15923
|
+
SiwcFileSchema = z36.strictObject({ registeredClientId: z36.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
|
|
15854
15924
|
}
|
|
15855
15925
|
});
|
|
15856
15926
|
|
|
@@ -15909,8 +15979,8 @@ var init_modelsStore = __esm({
|
|
|
15909
15979
|
|
|
15910
15980
|
// src/codex/catalogueCredential.ts
|
|
15911
15981
|
import { createHash as createHash11 } from "node:crypto";
|
|
15912
|
-
import
|
|
15913
|
-
import { z as
|
|
15982
|
+
import path43 from "node:path";
|
|
15983
|
+
import { z as z37 } from "zod";
|
|
15914
15984
|
function parseCatalogueBinding(raw) {
|
|
15915
15985
|
if (raw === void 0) return void 0;
|
|
15916
15986
|
try {
|
|
@@ -15943,15 +16013,15 @@ function signInCatalogueFingerprint(raw, filePath) {
|
|
|
15943
16013
|
function savedCatalogueFingerprint(provider, paths, env, home, reader) {
|
|
15944
16014
|
if (provider.codex?.login === "chatgpt-sign-in") return signInCatalogueFingerprint(reader.read(paths.chatgptSignInFile), paths.chatgptSignInFile);
|
|
15945
16015
|
const configuredHome = env.CODEX_HOME;
|
|
15946
|
-
const codexHome = configuredHome === void 0 || configuredHome === "" ?
|
|
15947
|
-
return cliCatalogueFingerprint(reader.read(
|
|
16016
|
+
const codexHome = configuredHome === void 0 || configuredHome === "" ? path43.join(home, ".codex") : configuredHome;
|
|
16017
|
+
return cliCatalogueFingerprint(reader.read(path43.join(codexHome, "auth.json")));
|
|
15948
16018
|
}
|
|
15949
16019
|
var CatalogueBindingSchema;
|
|
15950
16020
|
var init_catalogueCredential = __esm({
|
|
15951
16021
|
"src/codex/catalogueCredential.ts"() {
|
|
15952
16022
|
"use strict";
|
|
15953
16023
|
init_siwcStore();
|
|
15954
|
-
CatalogueBindingSchema =
|
|
16024
|
+
CatalogueBindingSchema = z37.strictObject({ fingerprint: z37.string().min(1), source: z37.string().min(1), revision: z37.string().min(1) });
|
|
15955
16025
|
}
|
|
15956
16026
|
});
|
|
15957
16027
|
|
|
@@ -16002,64 +16072,64 @@ var init_signatures = __esm({
|
|
|
16002
16072
|
});
|
|
16003
16073
|
|
|
16004
16074
|
// src/codex/anthropic.ts
|
|
16005
|
-
import { z as
|
|
16075
|
+
import { z as z38 } from "zod";
|
|
16006
16076
|
var TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
|
|
16007
16077
|
var init_anthropic = __esm({
|
|
16008
16078
|
"src/codex/anthropic.ts"() {
|
|
16009
16079
|
"use strict";
|
|
16010
|
-
TextBlockSchema =
|
|
16011
|
-
Base64ImageSourceSchema =
|
|
16012
|
-
UrlImageSourceSchema =
|
|
16013
|
-
ImageBlockSchema =
|
|
16014
|
-
type:
|
|
16015
|
-
source:
|
|
16080
|
+
TextBlockSchema = z38.looseObject({ type: z38.literal("text"), text: z38.string() });
|
|
16081
|
+
Base64ImageSourceSchema = z38.looseObject({ type: z38.literal("base64"), media_type: z38.string().min(1), data: z38.string() });
|
|
16082
|
+
UrlImageSourceSchema = z38.looseObject({ type: z38.literal("url"), url: z38.string().min(1) });
|
|
16083
|
+
ImageBlockSchema = z38.looseObject({
|
|
16084
|
+
type: z38.literal("image"),
|
|
16085
|
+
source: z38.union([Base64ImageSourceSchema, UrlImageSourceSchema])
|
|
16016
16086
|
});
|
|
16017
|
-
ToolUseBlockSchema =
|
|
16018
|
-
type:
|
|
16019
|
-
id:
|
|
16020
|
-
name:
|
|
16021
|
-
input:
|
|
16087
|
+
ToolUseBlockSchema = z38.looseObject({
|
|
16088
|
+
type: z38.literal("tool_use"),
|
|
16089
|
+
id: z38.string().min(1),
|
|
16090
|
+
name: z38.string().min(1),
|
|
16091
|
+
input: z38.unknown()
|
|
16022
16092
|
});
|
|
16023
|
-
ToolResultContentBlockSchema =
|
|
16024
|
-
ToolResultBlockSchema =
|
|
16025
|
-
type:
|
|
16026
|
-
tool_use_id:
|
|
16027
|
-
content:
|
|
16093
|
+
ToolResultContentBlockSchema = z38.union([TextBlockSchema, z38.looseObject({ type: z38.string() })]);
|
|
16094
|
+
ToolResultBlockSchema = z38.looseObject({
|
|
16095
|
+
type: z38.literal("tool_result"),
|
|
16096
|
+
tool_use_id: z38.string().min(1),
|
|
16097
|
+
content: z38.union([z38.string(), z38.array(ToolResultContentBlockSchema)]).optional()
|
|
16028
16098
|
});
|
|
16029
|
-
OtherBlockSchema =
|
|
16030
|
-
ContentBlockSchema =
|
|
16031
|
-
MessageSchema =
|
|
16032
|
-
role:
|
|
16033
|
-
content:
|
|
16099
|
+
OtherBlockSchema = z38.looseObject({ type: z38.string() });
|
|
16100
|
+
ContentBlockSchema = z38.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
|
|
16101
|
+
MessageSchema = z38.looseObject({
|
|
16102
|
+
role: z38.enum(["user", "assistant", "system"]),
|
|
16103
|
+
content: z38.union([z38.string(), z38.array(ContentBlockSchema)])
|
|
16034
16104
|
});
|
|
16035
|
-
ToolSchema =
|
|
16036
|
-
name:
|
|
16037
|
-
description:
|
|
16038
|
-
input_schema:
|
|
16039
|
-
allowed_domains:
|
|
16040
|
-
blocked_domains:
|
|
16105
|
+
ToolSchema = z38.looseObject({
|
|
16106
|
+
name: z38.string().min(1),
|
|
16107
|
+
description: z38.string().optional(),
|
|
16108
|
+
input_schema: z38.record(z38.string(), z38.unknown()).optional(),
|
|
16109
|
+
allowed_domains: z38.array(z38.string()).optional(),
|
|
16110
|
+
blocked_domains: z38.array(z38.string()).optional()
|
|
16041
16111
|
});
|
|
16042
|
-
ToolChoiceSchema =
|
|
16043
|
-
|
|
16044
|
-
|
|
16112
|
+
ToolChoiceSchema = z38.union([
|
|
16113
|
+
z38.looseObject({ type: z38.enum(["auto", "none", "any"]) }),
|
|
16114
|
+
z38.looseObject({ type: z38.literal("tool"), name: z38.string().min(1) })
|
|
16045
16115
|
]);
|
|
16046
|
-
SystemSchema =
|
|
16047
|
-
MessagesRequestSchema =
|
|
16048
|
-
model:
|
|
16116
|
+
SystemSchema = z38.union([z38.string(), z38.array(z38.union([TextBlockSchema, OtherBlockSchema]))]);
|
|
16117
|
+
MessagesRequestSchema = z38.looseObject({
|
|
16118
|
+
model: z38.string().optional(),
|
|
16049
16119
|
system: SystemSchema.optional(),
|
|
16050
|
-
messages:
|
|
16051
|
-
tools:
|
|
16120
|
+
messages: z38.array(MessageSchema),
|
|
16121
|
+
tools: z38.array(ToolSchema).optional(),
|
|
16052
16122
|
tool_choice: ToolChoiceSchema.optional(),
|
|
16053
|
-
stream:
|
|
16123
|
+
stream: z38.boolean().optional(),
|
|
16054
16124
|
/** `user_id` is stable for one Claude Code session and differs between sessions, which is what makes it the right key for both the backend's prompt cache and its session header. */
|
|
16055
|
-
metadata:
|
|
16125
|
+
metadata: z38.looseObject({ user_id: z38.string().optional() }).optional(),
|
|
16056
16126
|
/** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
|
|
16057
|
-
output_config:
|
|
16127
|
+
output_config: z38.looseObject({ effort: z38.string().optional(), format: z38.object({ type: z38.literal("json_schema"), schema: z38.record(z38.string(), z38.unknown()) }).optional() }).optional()
|
|
16058
16128
|
});
|
|
16059
|
-
CountTokensRequestSchema =
|
|
16060
|
-
system:
|
|
16061
|
-
messages:
|
|
16062
|
-
tools:
|
|
16129
|
+
CountTokensRequestSchema = z38.looseObject({
|
|
16130
|
+
system: z38.unknown().optional(),
|
|
16131
|
+
messages: z38.unknown().optional(),
|
|
16132
|
+
tools: z38.unknown().optional()
|
|
16063
16133
|
});
|
|
16064
16134
|
}
|
|
16065
16135
|
});
|
|
@@ -16960,7 +17030,7 @@ var init_settings2 = __esm({
|
|
|
16960
17030
|
});
|
|
16961
17031
|
|
|
16962
17032
|
// src/launcher/flags.ts
|
|
16963
|
-
import
|
|
17033
|
+
import path51 from "node:path";
|
|
16964
17034
|
function resolveLaunchFlags(params) {
|
|
16965
17035
|
const statusline = resolveStatuslineSettings(params);
|
|
16966
17036
|
return {
|
|
@@ -17019,7 +17089,7 @@ function buildEnv(params) {
|
|
|
17019
17089
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
17020
17090
|
let providerCustomHeaders;
|
|
17021
17091
|
if (!params.configDirEscapeHatch && params.identityId !== void 0) {
|
|
17022
|
-
env.CLAUDE_CONFIG_DIR =
|
|
17092
|
+
env.CLAUDE_CONFIG_DIR = path51.join(params.identitiesDir, params.identityId);
|
|
17023
17093
|
}
|
|
17024
17094
|
if (params.provider !== void 0) {
|
|
17025
17095
|
const providerEnv = params.provider.definition.kind !== void 0 && params.provider.definition.kind !== "http" ? {} : params.provider.definition.env ?? {};
|
|
@@ -17135,7 +17205,7 @@ var init_extraFlags = __esm({
|
|
|
17135
17205
|
});
|
|
17136
17206
|
|
|
17137
17207
|
// src/usage/resumeContext.ts
|
|
17138
|
-
import
|
|
17208
|
+
import path52 from "node:path";
|
|
17139
17209
|
function projectDirNameOf(cwd) {
|
|
17140
17210
|
return cwd.replace(/[^A-Za-z0-9]/g, "-");
|
|
17141
17211
|
}
|
|
@@ -17193,7 +17263,7 @@ function newestTranscript(fs17, projectDir) {
|
|
|
17193
17263
|
if (!name.endsWith(".jsonl")) {
|
|
17194
17264
|
continue;
|
|
17195
17265
|
}
|
|
17196
|
-
const candidate =
|
|
17266
|
+
const candidate = path52.join(projectDir, name);
|
|
17197
17267
|
const stat = fs17.lstat(candidate);
|
|
17198
17268
|
if (stat?.kind === "file" && stat.mtimeMs > newestMs) {
|
|
17199
17269
|
newestMs = stat.mtimeMs;
|
|
@@ -17207,8 +17277,8 @@ function resumedContextTokens(fs17, params) {
|
|
|
17207
17277
|
if (target === void 0) {
|
|
17208
17278
|
return void 0;
|
|
17209
17279
|
}
|
|
17210
|
-
const projectDir =
|
|
17211
|
-
const file = target.kind === "id" ?
|
|
17280
|
+
const projectDir = path52.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
|
|
17281
|
+
const file = target.kind === "id" ? path52.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs17, projectDir);
|
|
17212
17282
|
const text = file === void 0 ? void 0 : fs17.readFileUtf8(file);
|
|
17213
17283
|
return text === void 0 ? void 0 : contextTokensOfTranscript(text);
|
|
17214
17284
|
}
|
|
@@ -17749,6 +17819,235 @@ var init_spawn = __esm({
|
|
|
17749
17819
|
}
|
|
17750
17820
|
});
|
|
17751
17821
|
|
|
17822
|
+
// src/supervise/sessionControlPlugin.ts
|
|
17823
|
+
import { lstatSync, mkdtempSync, mkdirSync as mkdirSync2, readdirSync, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
17824
|
+
import { tmpdir } from "node:os";
|
|
17825
|
+
import path53 from "node:path";
|
|
17826
|
+
function removeAbandonedPlugins(parent, isRunning) {
|
|
17827
|
+
const uid = process.getuid?.();
|
|
17828
|
+
for (const name of readdirSync(parent)) {
|
|
17829
|
+
const pid = Number(/^agent-shim-control-(\d+)-/u.exec(name)?.[1]);
|
|
17830
|
+
if (!name.startsWith(STAGED_PREFIX) || !Number.isInteger(pid) || isRunning(pid)) {
|
|
17831
|
+
continue;
|
|
17832
|
+
}
|
|
17833
|
+
const entry = path53.join(parent, name);
|
|
17834
|
+
const stat = lstatSync(entry, { throwIfNoEntry: false });
|
|
17835
|
+
if (stat?.isDirectory() === true && (uid === void 0 || stat.uid === uid)) {
|
|
17836
|
+
rmSync(entry, { recursive: true, force: true });
|
|
17837
|
+
}
|
|
17838
|
+
}
|
|
17839
|
+
}
|
|
17840
|
+
function stageSessionControlPlugin(options = {}) {
|
|
17841
|
+
const parent = options.parent ?? tmpdir();
|
|
17842
|
+
removeAbandonedPlugins(parent, options.isRunning ?? realIsProcessRunning);
|
|
17843
|
+
const directory = mkdtempSync(path53.join(parent, `${STAGED_PREFIX}${String(options.pid ?? process.pid)}-`));
|
|
17844
|
+
const { ready, session, requests, results } = sessionControlPluginPaths(directory);
|
|
17845
|
+
try {
|
|
17846
|
+
mkdirSync2(path53.join(directory, ".claude-plugin"), { mode: 448 });
|
|
17847
|
+
mkdirSync2(path53.join(directory, "hooks"), { mode: 448 });
|
|
17848
|
+
mkdirSync2(requests, { mode: 448 });
|
|
17849
|
+
mkdirSync2(results, { mode: 448 });
|
|
17850
|
+
writeFileSync2(path53.join(directory, ".claude-plugin", "plugin.json"), JSON.stringify({ name: SESSION_CONTROL_PLUGIN_NAME, version: "2.1.0", description: "Compacts, sets goals and submits a person's turns in sessions agent-shim launched, in process" }), { mode: 384 });
|
|
17851
|
+
writeFileSync2(path53.join(directory, "hooks", "hooks.json"), JSON.stringify({ modules: ["./register.js"] }), { mode: 384 });
|
|
17852
|
+
writeFileSync2(path53.join(directory, "hooks", "register.js"), pluginSource(ready, session, requests, results), { mode: 384 });
|
|
17853
|
+
return { directory, ready, session, requests, results, release: () => {
|
|
17854
|
+
rmSync(directory, { recursive: true, force: true });
|
|
17855
|
+
} };
|
|
17856
|
+
} catch (error) {
|
|
17857
|
+
rmSync(directory, { recursive: true, force: true });
|
|
17858
|
+
throw error;
|
|
17859
|
+
}
|
|
17860
|
+
}
|
|
17861
|
+
function sessionControlPluginPaths(directory) {
|
|
17862
|
+
return { directory, ready: path53.join(directory, "ready.json"), session: path53.join(directory, "session.json"), requests: path53.join(directory, "requests"), results: path53.join(directory, "results") };
|
|
17863
|
+
}
|
|
17864
|
+
function pluginSource(ready, session, requests, results) {
|
|
17865
|
+
return `const REQUESTS = ${JSON.stringify(requests)};
|
|
17866
|
+
const RESULTS = ${JSON.stringify(results)};
|
|
17867
|
+
function compacted(id, value) {
|
|
17868
|
+
return { id, ...(typeof value?.skip === 'string' ? { kind: 'unchanged', skip: value.skip } : { kind: 'compacted', tokensBefore: value?.tokensBefore, tokensAfter: value?.tokensAfter }) };
|
|
17869
|
+
}
|
|
17870
|
+
async function resultNames($) {
|
|
17871
|
+
return new Set((await $.fs.list(RESULTS)).map((entry) => entry.name));
|
|
17872
|
+
}
|
|
17873
|
+
async function recordSession($, event, next) {
|
|
17874
|
+
const answer = await next(event);
|
|
17875
|
+
if (typeof event?.session_id === 'string' && typeof event?.transcript_path === 'string') {
|
|
17876
|
+
const record = JSON.stringify({ conversationId: event.session_id, transcriptPath: event.transcript_path });
|
|
17877
|
+
$.clock.after(0, async () => {
|
|
17878
|
+
await $.fs.write(${JSON.stringify(session)}, record);
|
|
17879
|
+
});
|
|
17880
|
+
}
|
|
17881
|
+
return answer;
|
|
17882
|
+
}
|
|
17883
|
+
export function register(on) {
|
|
17884
|
+
let running = false;
|
|
17885
|
+
on('classic.SessionStart', recordSession);
|
|
17886
|
+
on('classic.UserPromptSubmit', recordSession);
|
|
17887
|
+
on('classic.Stop', recordSession);
|
|
17888
|
+
on('classic.PostCompact', async ($, event, next) => {
|
|
17889
|
+
const answer = await next(event);
|
|
17890
|
+
$.clock.after(0, async () => {
|
|
17891
|
+
for (const name of await resultNames($)) {
|
|
17892
|
+
const text = await $.fs.read(RESULTS + '/' + name);
|
|
17893
|
+
if (typeof text !== 'string') continue;
|
|
17894
|
+
const current = JSON.parse(text);
|
|
17895
|
+
if (current.kind === 'running' && current.op === 'compact' && typeof current.id === 'string') {
|
|
17896
|
+
await $.fs.write(RESULTS + '/' + name, JSON.stringify({ id: current.id, kind: 'compacted' }));
|
|
17897
|
+
}
|
|
17898
|
+
}
|
|
17899
|
+
});
|
|
17900
|
+
return answer;
|
|
17901
|
+
});
|
|
17902
|
+
on('session.start', async ($, event, next) => {
|
|
17903
|
+
const answer = await next(event);
|
|
17904
|
+
const version = await $.session.version();
|
|
17905
|
+
await $.fs.write(${JSON.stringify(ready)}, JSON.stringify({ ready: true, version: version.version }));
|
|
17906
|
+
$.clock.every(1000, async () => {
|
|
17907
|
+
if (running) return;
|
|
17908
|
+
running = true;
|
|
17909
|
+
try {
|
|
17910
|
+
const done = await resultNames($);
|
|
17911
|
+
const names = (await $.fs.list(REQUESTS)).map((entry) => entry.name).filter((name) => !name.startsWith('.') && name.endsWith('.json') && !done.has(name)).sort();
|
|
17912
|
+
const name = names[0];
|
|
17913
|
+
if (name === undefined) return;
|
|
17914
|
+
const text = await $.fs.read(REQUESTS + '/' + name);
|
|
17915
|
+
if (typeof text !== 'string') return;
|
|
17916
|
+
const item = JSON.parse(text);
|
|
17917
|
+
if (typeof item.id !== 'string' || name !== item.id + '.json') {
|
|
17918
|
+
await $.fs.write(RESULTS + '/' + name, JSON.stringify({ id: name.slice(0, -5), error: 'the request is not one this plugin reads' }));
|
|
17919
|
+
return;
|
|
17920
|
+
}
|
|
17921
|
+
await $.fs.write(RESULTS + '/' + name, JSON.stringify({ id: item.id, kind: 'running', op: item.op }));
|
|
17922
|
+
let response;
|
|
17923
|
+
try {
|
|
17924
|
+
if (typeof item.expiresAt !== 'number' || await $.clock.now() >= item.expiresAt) throw new Error('the request expired before the session could run it, so it was not run');
|
|
17925
|
+
if (typeof item.conversationId !== 'string' || await $.session.id() !== item.conversationId) throw new Error('the conversation changed before the request ran');
|
|
17926
|
+
if (item.op === 'compact') {
|
|
17927
|
+
response = compacted(item.id, await $.session.compact(typeof item.instructions === 'string' ? { instructions: item.instructions } : {}));
|
|
17928
|
+
} else if (item.op === 'goal' && typeof item.args === 'string' && item.args.trim() !== '') {
|
|
17929
|
+
const ran = await $.command.run({ command: 'goal', args: item.args });
|
|
17930
|
+
response = { id: item.id, kind: 'ran', ...(typeof ran?.text === 'string' ? { text: ran.text } : {}) };
|
|
17931
|
+
} else if (item.op === 'turn' && typeof item.text === 'string' && item.text.trim() !== '') {
|
|
17932
|
+
const submitted = await $.prompt.submit({ text: item.text, asUser: true });
|
|
17933
|
+
if (typeof submitted?.drop === 'string') throw new Error('a hook dropped the prompt: ' + submitted.drop);
|
|
17934
|
+
response = { id: item.id, kind: 'submitted', text: submitted?.text, origin: submitted?.origin };
|
|
17935
|
+
} else {
|
|
17936
|
+
throw new Error('the request names no operation this plugin performs');
|
|
17937
|
+
}
|
|
17938
|
+
} catch (error) {
|
|
17939
|
+
response = { id: item.id, error: error instanceof Error ? error.message : String(error) };
|
|
17940
|
+
}
|
|
17941
|
+
await $.fs.write(RESULTS + '/' + name, JSON.stringify(response));
|
|
17942
|
+
} finally {
|
|
17943
|
+
running = false;
|
|
17944
|
+
}
|
|
17945
|
+
});
|
|
17946
|
+
return answer;
|
|
17947
|
+
});
|
|
17948
|
+
}
|
|
17949
|
+
`;
|
|
17950
|
+
}
|
|
17951
|
+
function withSessionControlPlugin(args, directory) {
|
|
17952
|
+
const end = args.indexOf("--");
|
|
17953
|
+
const result = [...args];
|
|
17954
|
+
result.splice(end === -1 ? result.length : end, 0, "--plugin-dir", directory);
|
|
17955
|
+
return result;
|
|
17956
|
+
}
|
|
17957
|
+
var SESSION_CONTROL_PLUGIN_NAME, STAGED_PREFIX;
|
|
17958
|
+
var init_sessionControlPlugin = __esm({
|
|
17959
|
+
"src/supervise/sessionControlPlugin.ts"() {
|
|
17960
|
+
"use strict";
|
|
17961
|
+
init_realPorts();
|
|
17962
|
+
SESSION_CONTROL_PLUGIN_NAME = "agent-shim-control";
|
|
17963
|
+
STAGED_PREFIX = "agent-shim-control-";
|
|
17964
|
+
}
|
|
17965
|
+
});
|
|
17966
|
+
|
|
17967
|
+
// src/supervise/launchControl.ts
|
|
17968
|
+
import path54 from "node:path";
|
|
17969
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
17970
|
+
import { z as z49 } from "zod";
|
|
17971
|
+
function readRecord2(fs17, directory, name) {
|
|
17972
|
+
if (!name.endsWith(RECORD_SUFFIX3)) {
|
|
17973
|
+
return void 0;
|
|
17974
|
+
}
|
|
17975
|
+
const raw = fs17.readFileUtf8(path54.join(directory, name));
|
|
17976
|
+
if (raw === void 0) {
|
|
17977
|
+
return void 0;
|
|
17978
|
+
}
|
|
17979
|
+
try {
|
|
17980
|
+
const parsed = LaunchControlSchema.safeParse(JSON.parse(raw));
|
|
17981
|
+
return parsed.success ? parsed.data : void 0;
|
|
17982
|
+
} catch {
|
|
17983
|
+
return void 0;
|
|
17984
|
+
}
|
|
17985
|
+
}
|
|
17986
|
+
function registerLaunchControl(fs17, directory, control, isRunning) {
|
|
17987
|
+
fs17.mkdirPrivate(directory);
|
|
17988
|
+
for (const name of fs17.readdir(directory)) {
|
|
17989
|
+
const record = readRecord2(fs17, directory, name);
|
|
17990
|
+
if (record !== void 0 && !isRunning(record.pid)) {
|
|
17991
|
+
fs17.removeRecursive(path54.join(directory, name));
|
|
17992
|
+
}
|
|
17993
|
+
}
|
|
17994
|
+
const file = path54.join(directory, `${String(control.pid)}.${randomUUID6()}${RECORD_SUFFIX3}`);
|
|
17995
|
+
fs17.writeFilePrivate(file, `${JSON.stringify(LaunchControlSchema.parse(control))}
|
|
17996
|
+
`);
|
|
17997
|
+
return () => {
|
|
17998
|
+
fs17.removeRecursive(file);
|
|
17999
|
+
};
|
|
18000
|
+
}
|
|
18001
|
+
function launchLoadsControlPlugin(candidate) {
|
|
18002
|
+
const end = candidate.args.indexOf("--");
|
|
18003
|
+
const options = end === -1 ? candidate.args : candidate.args.slice(0, end);
|
|
18004
|
+
return !candidate.supervised && candidate.startsSession && !options.includes("--bare") && candidate.version !== void 0 && RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(candidate.version);
|
|
18005
|
+
}
|
|
18006
|
+
function stageControlPluginFor(candidate, stage, warn) {
|
|
18007
|
+
if (stage === void 0 || !launchLoadsControlPlugin(candidate)) {
|
|
18008
|
+
return void 0;
|
|
18009
|
+
}
|
|
18010
|
+
try {
|
|
18011
|
+
return stage();
|
|
18012
|
+
} catch (error) {
|
|
18013
|
+
warn(`agent-shim: the in-process control plugin could not be staged, so this session starts without it and the front door cannot reach it for goal, compaction and turn control: ${error instanceof Error ? error.message : String(error)}`);
|
|
18014
|
+
return void 0;
|
|
18015
|
+
}
|
|
18016
|
+
}
|
|
18017
|
+
function stageLaunchControl(params) {
|
|
18018
|
+
const plugin = stageSessionControlPlugin({ pid: params.pid, isRunning: params.isRunning, ...params.parent === void 0 ? {} : { parent: params.parent } });
|
|
18019
|
+
let unregister;
|
|
18020
|
+
try {
|
|
18021
|
+
unregister = registerLaunchControl(params.fs, params.paths.launchControlDir, { pid: params.pid, directory: plugin.directory }, params.isRunning);
|
|
18022
|
+
} catch (error) {
|
|
18023
|
+
plugin.release();
|
|
18024
|
+
throw error;
|
|
18025
|
+
}
|
|
18026
|
+
return {
|
|
18027
|
+
args: (args) => withSessionControlPlugin(args, plugin.directory),
|
|
18028
|
+
release: () => {
|
|
18029
|
+
unregister();
|
|
18030
|
+
plugin.release();
|
|
18031
|
+
}
|
|
18032
|
+
};
|
|
18033
|
+
}
|
|
18034
|
+
var LaunchControlSchema, RECORD_SUFFIX3;
|
|
18035
|
+
var init_launchControl = __esm({
|
|
18036
|
+
"src/supervise/launchControl.ts"() {
|
|
18037
|
+
"use strict";
|
|
18038
|
+
init_sessionControl();
|
|
18039
|
+
init_sessionControlPlugin();
|
|
18040
|
+
init_verifiedVersions();
|
|
18041
|
+
LaunchControlSchema = z49.strictObject({
|
|
18042
|
+
/** The launcher's process id, which tells a live channel from one a killed launcher left. */
|
|
18043
|
+
pid: z49.number().int().positive(),
|
|
18044
|
+
/** The plugin's directory, its request and result files beneath it. */
|
|
18045
|
+
directory: z49.string().min(1)
|
|
18046
|
+
});
|
|
18047
|
+
RECORD_SUFFIX3 = ".json";
|
|
18048
|
+
}
|
|
18049
|
+
});
|
|
18050
|
+
|
|
17752
18051
|
// src/update/launchHook.ts
|
|
17753
18052
|
function resolveUpdateMode(globalConfig) {
|
|
17754
18053
|
return globalConfig?.update?.mode ?? "off";
|
|
@@ -17819,10 +18118,10 @@ var init_launchHook = __esm({
|
|
|
17819
18118
|
});
|
|
17820
18119
|
|
|
17821
18120
|
// src/launcher.ts
|
|
17822
|
-
import { randomUUID as
|
|
18121
|
+
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
17823
18122
|
import os10 from "node:os";
|
|
17824
18123
|
import { isDeepStrictEqual } from "node:util";
|
|
17825
|
-
import
|
|
18124
|
+
import path55 from "node:path";
|
|
17826
18125
|
function resolveIdentityCredential(identity, credential, env, port) {
|
|
17827
18126
|
if (port === void 0) {
|
|
17828
18127
|
return { ok: false, status: 1, message: `agent-shim: identity ${identity.name} needs its credential resolved, but this launcher has no credential port wired` };
|
|
@@ -17924,7 +18223,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
17924
18223
|
const farmIdentity = configDirEscapeHatchApplies || identityDecision.name === void 0 ? void 0 : resolveIdentityId(paths.identitiesDir, identityDecision.name, fs17);
|
|
17925
18224
|
const farm = farmIdentity === void 0 ? void 0 : params.farm;
|
|
17926
18225
|
if (!readOnly && params.supervised?.member === void 0 && farmIdentity !== void 0 && identityDecision.name !== void 0) {
|
|
17927
|
-
warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name,
|
|
18226
|
+
warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name, path55.join(paths.identitiesDir, farmIdentity));
|
|
17928
18227
|
}
|
|
17929
18228
|
if (!readOnly && farm !== void 0 && farmIdentity !== void 0) {
|
|
17930
18229
|
try {
|
|
@@ -18118,8 +18417,8 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
18118
18417
|
if (definition.kind === "codex" && readOnly && cache !== void 0) {
|
|
18119
18418
|
const binding = parseCatalogueBinding(stored.bindingText(name, owner));
|
|
18120
18419
|
const configuredHome = catalogueEnv.CODEX_HOME;
|
|
18121
|
-
const home = configuredHome === void 0 || configuredHome === "" ?
|
|
18122
|
-
const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile :
|
|
18420
|
+
const home = configuredHome === void 0 || configuredHome === "" ? path55.join(os10.homedir(), ".codex") : configuredHome;
|
|
18421
|
+
const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile : path55.resolve(home, "auth.json");
|
|
18123
18422
|
const revision = params.fs.fileRevision?.(source);
|
|
18124
18423
|
if (binding === void 0 || binding.fingerprint !== cache.credentialFingerprint || binding.source !== source || revision === void 0 || revision !== binding.revision) return [];
|
|
18125
18424
|
}
|
|
@@ -18141,7 +18440,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
18141
18440
|
return { args: args2, pickerSuppressed: startsSession && pickerSettings !== void 0 && callerSettings };
|
|
18142
18441
|
};
|
|
18143
18442
|
const args = argsForSupervisor().args;
|
|
18144
|
-
const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR :
|
|
18443
|
+
const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR : path55.join(paths.identitiesDir, farmIdentity);
|
|
18145
18444
|
const decision = {
|
|
18146
18445
|
identitySource: identityDecision.source,
|
|
18147
18446
|
configDirEscapeHatch: identityDecision.configDirEscapeHatch,
|
|
@@ -18181,6 +18480,8 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
18181
18480
|
models,
|
|
18182
18481
|
globalModels,
|
|
18183
18482
|
bin: discovered.path,
|
|
18483
|
+
binVersion: discovered.version,
|
|
18484
|
+
startsSession,
|
|
18184
18485
|
args,
|
|
18185
18486
|
argsForSupervisor,
|
|
18186
18487
|
decision
|
|
@@ -18237,7 +18538,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18237
18538
|
let warnings = [];
|
|
18238
18539
|
const updateCheck = runLaunchUpdateCheck({
|
|
18239
18540
|
mode: params.updateMode ?? "off",
|
|
18240
|
-
checkPath:
|
|
18541
|
+
checkPath: path55.join(paths.root, "update.check"),
|
|
18241
18542
|
currentVersion: package_default.version,
|
|
18242
18543
|
port: params.update
|
|
18243
18544
|
});
|
|
@@ -18260,7 +18561,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18260
18561
|
classification: resyncFarmRuntime.classification,
|
|
18261
18562
|
now: resyncFarmRuntime.now,
|
|
18262
18563
|
uniqueSuffix: resyncFarmRuntime.uniqueSuffix,
|
|
18263
|
-
identityExists: () => params.fs.readConfigFile(
|
|
18564
|
+
identityExists: () => params.fs.readConfigFile(path55.join(paths.identitiesDir, resyncIdentity, IDENTITY_FILE)) !== void 0,
|
|
18264
18565
|
lock: resyncFarmRuntime.lock
|
|
18265
18566
|
});
|
|
18266
18567
|
} catch (error) {
|
|
@@ -18294,7 +18595,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18294
18595
|
log.error("agent-shim: this launch routes through the front-door daemon, but this launcher has no front-door port wired; refusing to launch without it.");
|
|
18295
18596
|
proc.exit(1);
|
|
18296
18597
|
}
|
|
18297
|
-
const sessionId = params.supervised?.sessionId ??
|
|
18598
|
+
const sessionId = params.supervised?.sessionId ?? randomUUID7();
|
|
18298
18599
|
const resolvedModels = decided.models ?? (decided.globalModels === void 0 ? void 0 : {});
|
|
18299
18600
|
const sessionModels = isDeepStrictEqual(resolvedModels, decided.globalModels) ? void 0 : resolvedModels;
|
|
18300
18601
|
const session = { sessionId, ...decided.farmIdentity === void 0 ? {} : { identity: decided.farmIdentity }, ...sessionModels === void 0 ? {} : { models: sessionModels } };
|
|
@@ -18339,16 +18640,17 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18339
18640
|
proxyBypass: resolvedFlags.proxyBypass,
|
|
18340
18641
|
...resolvedFlags.statusline === void 0 ? {} : { statusline: resolvedFlags.statusline }
|
|
18341
18642
|
});
|
|
18342
|
-
const
|
|
18643
|
+
const picker = decided.argsForSupervisor(frontDoor?.supervisorPid);
|
|
18644
|
+
const control = stageControlPluginFor({ args: picker.args, version: decided.binVersion, startsSession: decided.startsSession, supervised: params.supervised !== void 0 }, params.stageControlPlugin, log.warn);
|
|
18645
|
+
const releases = [...unregisterLaunch === void 0 ? [] : [unregisterLaunch], ...headroom === void 0 || headroomPort === void 0 ? [] : [headroomPort.release], ...frontDoorRelease === void 0 ? [] : [frontDoorRelease], ...control === void 0 ? [] : [control.release]];
|
|
18343
18646
|
const release = () => {
|
|
18344
18647
|
for (const registered of releases) {
|
|
18345
18648
|
registered();
|
|
18346
18649
|
}
|
|
18347
18650
|
};
|
|
18348
|
-
const picker = decided.argsForSupervisor(frontDoor?.supervisorPid);
|
|
18349
18651
|
if (picker.pickerSuppressed) rows.push(noteRow("--settings was passed, so /model keeps Claude Code's own model names"));
|
|
18350
18652
|
rows.push(...notes.map(noteRow));
|
|
18351
|
-
return { finalEnv, release, picker, sessionId };
|
|
18653
|
+
return { finalEnv, release, args: control === void 0 ? picker.args : control.args(picker.args), sessionId };
|
|
18352
18654
|
});
|
|
18353
18655
|
const unreachable = reachability?.line();
|
|
18354
18656
|
log.report(rows);
|
|
@@ -18357,7 +18659,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18357
18659
|
}
|
|
18358
18660
|
printDiagnosticLines(log, warnings, { errorsAsWarnings: false });
|
|
18359
18661
|
const hold = () => holdBeforeLaunch({ delayMs: resolvedFlags.delayMs, pause: resolvedFlags.pause }, params.hold, log);
|
|
18360
|
-
return { bin: decided.bin, args: brought.
|
|
18662
|
+
return { bin: decided.bin, args: brought.args, env: brought.finalEnv, sessionId: brought.sessionId, release: brought.release, markChildStarted: updateCheck.markChildStarted, hold, decision };
|
|
18361
18663
|
}
|
|
18362
18664
|
function resolveLaunch(params) {
|
|
18363
18665
|
const decided = decideLaunch(params, true);
|
|
@@ -18440,6 +18742,7 @@ var init_launcher = __esm({
|
|
|
18440
18742
|
init_resumeContext();
|
|
18441
18743
|
init_lock();
|
|
18442
18744
|
init_spawn();
|
|
18745
|
+
init_launchControl();
|
|
18443
18746
|
init_providersStore();
|
|
18444
18747
|
init_load();
|
|
18445
18748
|
init_flatten();
|
|
@@ -18461,12 +18764,12 @@ var init_launcher = __esm({
|
|
|
18461
18764
|
});
|
|
18462
18765
|
|
|
18463
18766
|
// src/ownCli.ts
|
|
18464
|
-
import
|
|
18767
|
+
import path56 from "node:path";
|
|
18465
18768
|
function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string" ? __AGENT_SHIM_DIST_DIR__ : void 0) {
|
|
18466
18769
|
if (distDir === void 0) {
|
|
18467
18770
|
throw new OwnCliPathUnknownError();
|
|
18468
18771
|
}
|
|
18469
|
-
return
|
|
18772
|
+
return path56.join(distDir, OWN_CLI_FILE_NAME);
|
|
18470
18773
|
}
|
|
18471
18774
|
var OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
|
|
18472
18775
|
var init_ownCli = __esm({
|
|
@@ -18512,10 +18815,10 @@ var init_selfIdentity = __esm({
|
|
|
18512
18815
|
|
|
18513
18816
|
// src/frontdoor/trust.ts
|
|
18514
18817
|
import { createHash as createHash12 } from "node:crypto";
|
|
18515
|
-
import
|
|
18818
|
+
import path57 from "node:path";
|
|
18516
18819
|
function resolveTrustBundle(params) {
|
|
18517
18820
|
const { caCertFile, bundlesDir, variable, inherited, fs: fs17 } = params;
|
|
18518
|
-
if (inherited === void 0 || inherited === "" ||
|
|
18821
|
+
if (inherited === void 0 || inherited === "" || path57.resolve(inherited) === path57.resolve(caCertFile)) {
|
|
18519
18822
|
return { path: caCertFile };
|
|
18520
18823
|
}
|
|
18521
18824
|
const caPem = fs17.readFileUtf8(caCertFile);
|
|
@@ -18533,7 +18836,7 @@ function resolveTrustBundle(params) {
|
|
|
18533
18836
|
}
|
|
18534
18837
|
const combined = `${inheritedPem.trimEnd()}
|
|
18535
18838
|
${caPem}`;
|
|
18536
|
-
const bundle =
|
|
18839
|
+
const bundle = path57.join(bundlesDir, `${createHash12("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
18537
18840
|
if (!fs17.exists(bundle)) {
|
|
18538
18841
|
fs17.mkdirp(bundlesDir);
|
|
18539
18842
|
fs17.writeFileAtomic(bundle, combined);
|
|
@@ -18706,8 +19009,8 @@ var init_realFrontDoorPort = __esm({
|
|
|
18706
19009
|
|
|
18707
19010
|
// src/launchWiring.ts
|
|
18708
19011
|
import os12 from "node:os";
|
|
18709
|
-
import
|
|
18710
|
-
import { randomUUID as
|
|
19012
|
+
import path58 from "node:path";
|
|
19013
|
+
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
18711
19014
|
function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
18712
19015
|
const home = os12.homedir();
|
|
18713
19016
|
const read = cosmiconfigReader();
|
|
@@ -18734,7 +19037,7 @@ function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
|
18734
19037
|
...cliOverride === void 0 ? {} : { cliOverride }
|
|
18735
19038
|
}).input,
|
|
18736
19039
|
now: () => Date.now(),
|
|
18737
|
-
uniqueSuffix: `${String(process.pid)}.${
|
|
19040
|
+
uniqueSuffix: `${String(process.pid)}.${randomUUID8()}`,
|
|
18738
19041
|
// Zombie-aware on purpose: a previous launcher that crashed out of a resync without releasing the lock may sit unreaped, still answering signal 0 as alive, and must read as a dead holder so this launch takes the lock over instead of timing out.
|
|
18739
19042
|
lock: { pid: process.pid, isRunning: realIsProcessRunning, sleep: realSleepSync }
|
|
18740
19043
|
},
|
|
@@ -18762,8 +19065,9 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
18762
19065
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
18763
19066
|
startBaseUrlProbe: realStartBaseUrlProbe,
|
|
18764
19067
|
hold: realHoldPort,
|
|
18765
|
-
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot:
|
|
18766
|
-
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin,
|
|
19068
|
+
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: path58.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
|
|
19069
|
+
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin, path58.join(paths.identitiesDir, identity), options.proc.env),
|
|
19070
|
+
stageControlPlugin: () => stageLaunchControl({ fs: realFarmFs, paths, pid: process.pid, isRunning: realIsProcessRunning }),
|
|
18767
19071
|
...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
|
|
18768
19072
|
...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
|
|
18769
19073
|
...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
|
|
@@ -18845,6 +19149,7 @@ var init_launchWiring = __esm({
|
|
|
18845
19149
|
init_paths();
|
|
18846
19150
|
init_signIn();
|
|
18847
19151
|
init_providerReachability();
|
|
19152
|
+
init_launchControl();
|
|
18848
19153
|
init_realPorts();
|
|
18849
19154
|
LaunchRefusedError = class extends CliError {
|
|
18850
19155
|
exitCode;
|
|
@@ -19056,7 +19361,7 @@ var init_identityClaude = __esm({
|
|
|
19056
19361
|
});
|
|
19057
19362
|
|
|
19058
19363
|
// src/usage/providerQuota.ts
|
|
19059
|
-
import { z as
|
|
19364
|
+
import { z as z50 } from "zod";
|
|
19060
19365
|
var MS_PER_SECOND9, SECONDS_PER_HOUR3, HOURS_PER_DAY6, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY2, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, FIVE_HOURS2, DAYS_PER_WEEK2, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema;
|
|
19061
19366
|
var init_providerQuota = __esm({
|
|
19062
19367
|
"src/usage/providerQuota.ts"() {
|
|
@@ -19075,35 +19380,35 @@ var init_providerQuota = __esm({
|
|
|
19075
19380
|
[ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND9],
|
|
19076
19381
|
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9]
|
|
19077
19382
|
]);
|
|
19078
|
-
ZaiLimitSchema =
|
|
19079
|
-
type:
|
|
19080
|
-
unit:
|
|
19081
|
-
number:
|
|
19082
|
-
percentage:
|
|
19083
|
-
nextResetTime:
|
|
19084
|
-
usage:
|
|
19085
|
-
currentValue:
|
|
19086
|
-
remaining:
|
|
19383
|
+
ZaiLimitSchema = z50.object({
|
|
19384
|
+
type: z50.string(),
|
|
19385
|
+
unit: z50.number().int(),
|
|
19386
|
+
number: z50.number().int().positive(),
|
|
19387
|
+
percentage: z50.number().nonnegative(),
|
|
19388
|
+
nextResetTime: z50.number().positive().optional(),
|
|
19389
|
+
usage: z50.number().nonnegative().optional(),
|
|
19390
|
+
currentValue: z50.number().nonnegative().optional(),
|
|
19391
|
+
remaining: z50.number().nonnegative().optional()
|
|
19087
19392
|
});
|
|
19088
|
-
ZaiResponseSchema =
|
|
19089
|
-
success:
|
|
19090
|
-
msg:
|
|
19091
|
-
data:
|
|
19393
|
+
ZaiResponseSchema = z50.object({
|
|
19394
|
+
success: z50.boolean(),
|
|
19395
|
+
msg: z50.string().optional(),
|
|
19396
|
+
data: z50.object({ level: z50.string().optional(), limits: z50.array(ZaiLimitSchema) })
|
|
19092
19397
|
});
|
|
19093
19398
|
OPENROUTER_HOST = "openrouter.ai";
|
|
19094
19399
|
OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
|
|
19095
19400
|
OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
|
|
19096
19401
|
MS_PER_DAY2 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
19097
|
-
OpenRouterKeySchema =
|
|
19098
|
-
data:
|
|
19099
|
-
limit:
|
|
19100
|
-
limit_remaining:
|
|
19101
|
-
limit_reset:
|
|
19102
|
-
is_free_tier:
|
|
19103
|
-
free_model_daily_requests:
|
|
19402
|
+
OpenRouterKeySchema = z50.object({
|
|
19403
|
+
data: z50.object({
|
|
19404
|
+
limit: z50.number().nonnegative().nullable(),
|
|
19405
|
+
limit_remaining: z50.number().nullable(),
|
|
19406
|
+
limit_reset: z50.string().nullable(),
|
|
19407
|
+
is_free_tier: z50.boolean().optional(),
|
|
19408
|
+
free_model_daily_requests: z50.object({ used: z50.number().nonnegative(), limit: z50.number().nonnegative(), remaining: z50.number() }).optional()
|
|
19104
19409
|
})
|
|
19105
19410
|
});
|
|
19106
|
-
OpenRouterCreditsSchema =
|
|
19411
|
+
OpenRouterCreditsSchema = z50.object({ data: z50.object({ total_credits: z50.number().nonnegative(), total_usage: z50.number().nonnegative() }) });
|
|
19107
19412
|
ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
|
|
19108
19413
|
ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
|
|
19109
19414
|
ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
|
|
@@ -19111,21 +19416,21 @@ var init_providerQuota = __esm({
|
|
|
19111
19416
|
DAYS_PER_WEEK2 = 7;
|
|
19112
19417
|
FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
19113
19418
|
WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
19114
|
-
AntigravityBucketSchema =
|
|
19115
|
-
bucketId:
|
|
19116
|
-
remainingFraction:
|
|
19117
|
-
resetTime:
|
|
19419
|
+
AntigravityBucketSchema = z50.object({
|
|
19420
|
+
bucketId: z50.string(),
|
|
19421
|
+
remainingFraction: z50.number().optional(),
|
|
19422
|
+
resetTime: z50.string().optional()
|
|
19118
19423
|
});
|
|
19119
|
-
AntigravitySummarySchema =
|
|
19120
|
-
GoogleTokenInfoSchema =
|
|
19121
|
-
email:
|
|
19122
|
-
sub:
|
|
19424
|
+
AntigravitySummarySchema = z50.object({ groups: z50.array(z50.object({ buckets: z50.array(AntigravityBucketSchema) })) });
|
|
19425
|
+
GoogleTokenInfoSchema = z50.object({
|
|
19426
|
+
email: z50.string().optional(),
|
|
19427
|
+
sub: z50.string().optional()
|
|
19123
19428
|
});
|
|
19124
|
-
AntigravityUserSchema =
|
|
19429
|
+
AntigravityUserSchema = z50.object({
|
|
19125
19430
|
/** The code-assist tier context, which defaults to the free tier for every account. */
|
|
19126
|
-
currentTier:
|
|
19431
|
+
currentTier: z50.object({ name: z50.string().optional(), id: z50.string().optional() }).optional(),
|
|
19127
19432
|
/** The account's paid subscription; absent when the account has none. */
|
|
19128
|
-
paidTier:
|
|
19433
|
+
paidTier: z50.object({ name: z50.string().optional(), id: z50.string().optional() }).optional()
|
|
19129
19434
|
});
|
|
19130
19435
|
}
|
|
19131
19436
|
});
|
|
@@ -19449,15 +19754,13 @@ init_rcWrites();
|
|
|
19449
19754
|
init_rcSchemas();
|
|
19450
19755
|
|
|
19451
19756
|
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
19452
|
-
import { z as
|
|
19757
|
+
import { z as z25 } from "zod";
|
|
19453
19758
|
|
|
19454
19759
|
// src/frontdoor/rcSessionCommands.ts
|
|
19455
19760
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
19456
19761
|
init_rcControl();
|
|
19457
|
-
|
|
19458
|
-
|
|
19459
|
-
var RESULT_POLL_MS = 250;
|
|
19460
|
-
var REQUEST_INSTANT_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
|
|
19762
|
+
init_sessionControl();
|
|
19763
|
+
init_verifiedVersions();
|
|
19461
19764
|
|
|
19462
19765
|
// src/frontdoor/rcSelfHostCommands.ts
|
|
19463
19766
|
init_connectEffects();
|
|
@@ -19577,9 +19880,7 @@ function recognise(command, event, name, args) {
|
|
|
19577
19880
|
}
|
|
19578
19881
|
return { ok: false, message: `the worker did not compact the session: ${answer.text}` };
|
|
19579
19882
|
}
|
|
19580
|
-
async function
|
|
19581
|
-
const { name, args } = commandLine(command);
|
|
19582
|
-
const text = args === "" ? `/${name}` : `/${name} ${args}`;
|
|
19883
|
+
async function writeAsPersonAndAwait(deps, sessionId, text, recogniseEvent, waitMs, signal) {
|
|
19583
19884
|
const early = [];
|
|
19584
19885
|
let after;
|
|
19585
19886
|
let settle;
|
|
@@ -19592,10 +19893,10 @@ async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signa
|
|
|
19592
19893
|
return;
|
|
19593
19894
|
}
|
|
19594
19895
|
if (isPeerDelivery(event, text)) {
|
|
19595
|
-
settle?.({ ok: false, message: `session ${sessionId}'s worker passed ${text} to its model as a peer's message
|
|
19896
|
+
settle?.({ ok: false, message: `session ${sessionId}'s worker passed ${text} to its model as a peer's message, so it did not read the write as a person's` });
|
|
19596
19897
|
return;
|
|
19597
19898
|
}
|
|
19598
|
-
const outcome =
|
|
19899
|
+
const outcome = recogniseEvent(event);
|
|
19599
19900
|
if (outcome !== void 0) {
|
|
19600
19901
|
settle?.(outcome);
|
|
19601
19902
|
}
|
|
@@ -19632,6 +19933,41 @@ async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signa
|
|
|
19632
19933
|
detach();
|
|
19633
19934
|
}
|
|
19634
19935
|
}
|
|
19936
|
+
async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signal) {
|
|
19937
|
+
const { name, args } = commandLine(command);
|
|
19938
|
+
const text = args === "" ? `/${name}` : `/${name} ${args}`;
|
|
19939
|
+
return await writeAsPersonAndAwait(deps, sessionId, text, (event) => recognise(command, event, name, args), waitMs, signal);
|
|
19940
|
+
}
|
|
19941
|
+
function userTextOf(message) {
|
|
19942
|
+
if (typeof message.content === "string") {
|
|
19943
|
+
return message.content;
|
|
19944
|
+
}
|
|
19945
|
+
if (!Array.isArray(message.content)) {
|
|
19946
|
+
return void 0;
|
|
19947
|
+
}
|
|
19948
|
+
const blocks = message.content;
|
|
19949
|
+
return blocks.flatMap((block) => isRecord8(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
|
|
19950
|
+
}
|
|
19951
|
+
function rcPersonTurnOf(event, text) {
|
|
19952
|
+
const payload = event.envelope.payload;
|
|
19953
|
+
if (!isRecord8(payload) || payload.type !== "user" || typeof payload.uuid !== "string" || !isRecord8(payload.origin) || payload.origin.kind !== "human" || !isRecord8(payload.message)) {
|
|
19954
|
+
return void 0;
|
|
19955
|
+
}
|
|
19956
|
+
return userTextOf(payload.message) === text ? payload.uuid : void 0;
|
|
19957
|
+
}
|
|
19958
|
+
async function runSelfHostedTurn(deps, sessionId, text, waitMs, signal) {
|
|
19959
|
+
return await writeAsPersonAndAwait(
|
|
19960
|
+
deps,
|
|
19961
|
+
sessionId,
|
|
19962
|
+
text,
|
|
19963
|
+
(event) => {
|
|
19964
|
+
const uuid = rcPersonTurnOf(event, text);
|
|
19965
|
+
return uuid === void 0 ? void 0 : { ok: true, report: { uuid } };
|
|
19966
|
+
},
|
|
19967
|
+
waitMs,
|
|
19968
|
+
signal
|
|
19969
|
+
);
|
|
19970
|
+
}
|
|
19635
19971
|
function createRcClaudeCodeVersions(fanout) {
|
|
19636
19972
|
const versions = /* @__PURE__ */ new Map();
|
|
19637
19973
|
fanout.subscribe(void 0, (event) => {
|
|
@@ -19653,18 +19989,21 @@ function createRcClaudeCodeVersions(fanout) {
|
|
|
19653
19989
|
}
|
|
19654
19990
|
|
|
19655
19991
|
// src/frontdoor/rcSessionCommands.ts
|
|
19656
|
-
var RC_SESSION_COMMAND_VERIFIED_VERSIONS = ["2.1.319"];
|
|
19657
19992
|
var RC_GOAL_CLEAR_WORDS = ["clear", "stop", "off", "reset", "none", "cancel"];
|
|
19658
19993
|
var RC_GOAL_CONDITION_MAX_CHARS = 4e3;
|
|
19659
19994
|
var MAX_JSON_BYTES_PER_CODE_UNIT = 6;
|
|
19660
19995
|
var RC_COMPACT_INSTRUCTIONS_MAX_CHARS = Math.floor(CONTROL_BODY_CAP_BYTES / MAX_JSON_BYTES_PER_CODE_UNIT);
|
|
19996
|
+
var RC_TURN_TEXT_MAX_CHARS = Math.floor(CONTROL_BODY_CAP_BYTES / MAX_JSON_BYTES_PER_CODE_UNIT);
|
|
19661
19997
|
var RC_SESSION_COMMAND_MAX_WAIT_MS = 2147483647;
|
|
19662
19998
|
function unverifiedVersionMessage(sessionId, version, source) {
|
|
19663
19999
|
const verified = RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ");
|
|
19664
|
-
return version === void 0 ? `session ${sessionId} has not reported its Claude Code version (${source}), and goal and
|
|
20000
|
+
return version === void 0 ? `session ${sessionId} has not reported its Claude Code version (${source}), and goal, compaction and turn control is verified only on Claude Code ${verified}` : `session ${sessionId} runs Claude Code ${version}, and goal, compaction and turn control is verified only on Claude Code ${verified}: the door will not act on a version whose behaviour it has not verified`;
|
|
20001
|
+
}
|
|
20002
|
+
function noPluginReason(sessionId) {
|
|
20003
|
+
return `no agent-shim launch's in-process control plugin records session ${sessionId}: it was started outside the launcher (with claude's own command, or agent-shim run --native), with --bare, on a Claude Code version the plugin is not verified on, or its plugin has not yet recorded its transcript, which it does from the session's first hook event`;
|
|
19665
20004
|
}
|
|
19666
20005
|
function unsupportedMessage(sessionId) {
|
|
19667
|
-
return
|
|
20006
|
+
return `${noPluginReason(sessionId)}, so the door has no in-process channel into it, and it is not on the door's own self-hosted surface. Over the real Remote Control service, Claude Code ${RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ")} takes a message as a person's (running it when it is a slash command) only when a person's app wrote it and treats any other writer as a peer, whose message the model reads as another session's, and the door does not claim to be a person's app on a service it does not run. Start the session through agent-shim run on Claude Code ${RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ")} without --bare, or run it against the door's self-hosted surface.`;
|
|
19668
20007
|
}
|
|
19669
20008
|
function createRcSessionCommands(deps) {
|
|
19670
20009
|
const queues = /* @__PURE__ */ new Map();
|
|
@@ -19681,57 +20020,78 @@ function createRcSessionCommands(deps) {
|
|
|
19681
20020
|
}
|
|
19682
20021
|
}
|
|
19683
20022
|
};
|
|
20023
|
+
const pluginRoute = async (sessionId, route, lookup2) => {
|
|
20024
|
+
const target = await lookup2(sessionId);
|
|
20025
|
+
if (target === void 0) {
|
|
20026
|
+
return void 0;
|
|
20027
|
+
}
|
|
20028
|
+
if ("refused" in target) {
|
|
20029
|
+
return { kind: "refused", message: target.refused };
|
|
20030
|
+
}
|
|
20031
|
+
if (target.version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(target.version)) {
|
|
20032
|
+
return { kind: "refused", message: unverifiedVersionMessage(sessionId, target.version, route === "supervised" ? "its supervisor's control plugin has not loaded" : "its launch's control plugin has not loaded") };
|
|
20033
|
+
}
|
|
20034
|
+
return { kind: route, target };
|
|
20035
|
+
};
|
|
20036
|
+
const resolveRoute = async (sessionId) => {
|
|
20037
|
+
const supervised = await pluginRoute(sessionId, "supervised", deps.supervisedOf);
|
|
20038
|
+
if (supervised !== void 0) {
|
|
20039
|
+
return supervised;
|
|
20040
|
+
}
|
|
20041
|
+
const launched = deps.launchedOf === void 0 ? void 0 : await pluginRoute(sessionId, "launched", deps.launchedOf);
|
|
20042
|
+
if (launched !== void 0) {
|
|
20043
|
+
return launched;
|
|
20044
|
+
}
|
|
20045
|
+
if (!deps.isObserved(sessionId)) {
|
|
20046
|
+
return { kind: "refused", message: `the front door has not observed Remote Control session ${sessionId}` };
|
|
20047
|
+
}
|
|
20048
|
+
if (deps.selfHost === void 0) {
|
|
20049
|
+
return { kind: "refused", message: unsupportedMessage(sessionId) };
|
|
20050
|
+
}
|
|
20051
|
+
const unavailable = deps.selfHost.unavailable();
|
|
20052
|
+
if (unavailable !== void 0) {
|
|
20053
|
+
return { kind: "refused", message: `${noPluginReason(sessionId)}, and the door's self-hosted surface cannot take a command: ${unavailable}` };
|
|
20054
|
+
}
|
|
20055
|
+
const version = deps.selfHost.versionOf(sessionId);
|
|
20056
|
+
if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
|
|
20057
|
+
return { kind: "refused", message: unverifiedVersionMessage(sessionId, version, "no system/init from its worker has been observed on its stream; send it a prompt so it reports one") };
|
|
20058
|
+
}
|
|
20059
|
+
return { kind: "self-hosted", selfHost: deps.selfHost };
|
|
20060
|
+
};
|
|
19684
20061
|
const onRoute = async (sessionId, options, actions) => await serialised(sessionId, async () => {
|
|
19685
20062
|
const { signal } = options;
|
|
19686
20063
|
if (signal?.aborted === true) {
|
|
19687
20064
|
return { ok: false, message: `the request for session ${sessionId} was aborted before it ran` };
|
|
19688
20065
|
}
|
|
19689
|
-
const
|
|
19690
|
-
if (
|
|
19691
|
-
return { ok: false, message:
|
|
20066
|
+
const resolved = await resolveRoute(sessionId);
|
|
20067
|
+
if (resolved.kind === "refused") {
|
|
20068
|
+
return { ok: false, message: resolved.message };
|
|
19692
20069
|
}
|
|
19693
|
-
if (
|
|
19694
|
-
|
|
19695
|
-
|
|
19696
|
-
|
|
19697
|
-
const waitMs = options.waitMs ?? COMPACT_TIMEOUT_MS;
|
|
19698
|
-
const timeout = AbortSignal.timeout(waitMs);
|
|
19699
|
-
const bounded3 = signal === void 0 ? timeout : AbortSignal.any([signal, timeout]);
|
|
20070
|
+
if (resolved.kind !== "self-hosted") {
|
|
20071
|
+
const waitMs2 = options.waitMs ?? COMPACT_TIMEOUT_MS;
|
|
20072
|
+
const timeout2 = AbortSignal.timeout(waitMs2);
|
|
20073
|
+
const bounded3 = signal === void 0 ? timeout2 : AbortSignal.any([signal, timeout2]);
|
|
19700
20074
|
try {
|
|
19701
|
-
return await actions.
|
|
20075
|
+
return await actions.plugin(resolved.target, resolved.kind, bounded3, waitMs2);
|
|
19702
20076
|
} catch (error) {
|
|
19703
|
-
if (
|
|
19704
|
-
return { ok: false, message: `session ${sessionId}'s control plugin did not answer within ${String(
|
|
20077
|
+
if (timeout2.aborted) {
|
|
20078
|
+
return { ok: false, message: `session ${sessionId}'s control plugin did not answer within ${String(waitMs2)} ms. A request the plugin had not started is withdrawn; one it had started runs once the session is idle (a turn waiting on a permission prompt holds it), so read the session's goal or transcript before asking again` };
|
|
19705
20079
|
}
|
|
19706
20080
|
return { ok: false, message: `session ${sessionId}'s control plugin did not complete the request: ${error instanceof Error ? error.message : String(error)}` };
|
|
19707
20081
|
}
|
|
19708
20082
|
}
|
|
19709
|
-
|
|
19710
|
-
|
|
19711
|
-
|
|
19712
|
-
if (
|
|
19713
|
-
|
|
19714
|
-
if (unavailable !== void 0) {
|
|
19715
|
-
return { ok: false, message: `session ${sessionId} was not launched under an agent-shim supervisor, and the door's self-hosted surface cannot take a command: ${unavailable}` };
|
|
19716
|
-
}
|
|
19717
|
-
const version = deps.selfHost.versionOf(sessionId);
|
|
19718
|
-
if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
|
|
19719
|
-
return { ok: false, message: unverifiedVersionMessage(sessionId, version, "no system/init from its worker has been observed on its stream; send it a prompt so it reports one") };
|
|
19720
|
-
}
|
|
19721
|
-
const waitMs = options.waitMs ?? deps.selfHost.defaultWaitMs;
|
|
19722
|
-
const timeout = AbortSignal.timeout(waitMs);
|
|
19723
|
-
const result = await actions.selfHosted(deps.selfHost, signal === void 0 ? timeout : AbortSignal.any([signal, timeout]));
|
|
19724
|
-
if (!result.ok && timeout.aborted) {
|
|
19725
|
-
return { ok: false, message: `session ${sessionId}'s worker did not answer within ${String(waitMs)} ms in all; it may still be queued behind a running turn, so read the session's stream before asking again` };
|
|
19726
|
-
}
|
|
19727
|
-
return result;
|
|
20083
|
+
const waitMs = options.waitMs ?? resolved.selfHost.defaultWaitMs;
|
|
20084
|
+
const timeout = AbortSignal.timeout(waitMs);
|
|
20085
|
+
const result = await actions.selfHosted(resolved.selfHost, signal === void 0 ? timeout : AbortSignal.any([signal, timeout]));
|
|
20086
|
+
if (!result.ok && timeout.aborted) {
|
|
20087
|
+
return { ok: false, message: `session ${sessionId}'s worker did not answer within ${String(waitMs)} ms in all; it may still be queued behind a running turn, so read the session's stream before asking again` };
|
|
19728
20088
|
}
|
|
19729
|
-
return
|
|
20089
|
+
return result;
|
|
19730
20090
|
});
|
|
19731
20091
|
const transcriptGoal = async (sessionId, target) => {
|
|
19732
20092
|
const goal = target.transcriptPath === void 0 ? void 0 : await deps.goalOf(target.transcriptPath);
|
|
19733
20093
|
if (goal === void 0) {
|
|
19734
|
-
return { ok: false, message: `session ${sessionId}'s
|
|
20094
|
+
return { ok: false, message: `session ${sessionId}'s transcript has not been recorded yet, which is where its goal is read from; retry once it has finished a turn` };
|
|
19735
20095
|
}
|
|
19736
20096
|
return { ok: true, report: goal };
|
|
19737
20097
|
};
|
|
@@ -19745,12 +20105,64 @@ function createRcSessionCommands(deps) {
|
|
|
19745
20105
|
}
|
|
19746
20106
|
};
|
|
19747
20107
|
const waitOf = (options) => options.waitMs;
|
|
20108
|
+
const transcriptPluginTurns = async (sessionId, target) => {
|
|
20109
|
+
const turns = target.transcriptPath === void 0 ? void 0 : await deps.pluginTurnsOf(target.transcriptPath);
|
|
20110
|
+
return turns === void 0 ? { ok: false, message: `session ${sessionId}'s transcript has not been recorded yet, which is where a turn is confirmed from; retry once it has finished a turn` } : { ok: true, report: turns };
|
|
20111
|
+
};
|
|
19748
20112
|
return {
|
|
20113
|
+
/** Which route the verbs would take for the session now, or the refusal naming why none would; reads only, outside the session's queue, so a verb waiting on the session never delays it. */
|
|
20114
|
+
routeOf: async (sessionId) => {
|
|
20115
|
+
const resolved = await resolveRoute(sessionId);
|
|
20116
|
+
return resolved.kind === "refused" ? { route: null, refused: resolved.message } : { route: resolved.kind };
|
|
20117
|
+
},
|
|
20118
|
+
/**
|
|
20119
|
+
* Puts `text` into the session as a person's typed turn, and resolves once the session recorded it as a user entry from the person, never as a peer's message: on the supervised route a transcript row the control plugin submitted as the person's words (`origin: { kind: "plugin", asUser: true }`), on the self-hosted route the worker's mirrored entry with a person's origin (`{ kind: "human" }`). The text reaches the session's model as its user's words (`docs/rc-slash-commands.md`, the trust boundary). Refused unsent: text that is empty, starts with `/` (a slash command, which the goal and compaction verbs run), or is longer than one request carries. Resolves when the turn entered the session, not when the model has answered it.
|
|
20120
|
+
*/
|
|
20121
|
+
turn: async (sessionId, text, options = {}) => {
|
|
20122
|
+
if (text.trim() === "") {
|
|
20123
|
+
return { ok: false, message: "a turn needs non-empty text" };
|
|
20124
|
+
}
|
|
20125
|
+
if (text.trimStart().startsWith("/")) {
|
|
20126
|
+
return { ok: false, message: "a turn's text starts with /, which the session would read as a slash command rather than a message, and the turn could not be confirmed as one; use the goal or compaction verbs for those commands, or start the text with something else" };
|
|
20127
|
+
}
|
|
20128
|
+
if (text.length > RC_TURN_TEXT_MAX_CHARS) {
|
|
20129
|
+
return { ok: false, message: `a turn's text is limited to ${String(RC_TURN_TEXT_MAX_CHARS)} characters, and this one has ${String(text.length)}` };
|
|
20130
|
+
}
|
|
20131
|
+
return await onRoute(sessionId, options, {
|
|
20132
|
+
plugin: async (target, route, signal, waitMs) => {
|
|
20133
|
+
const before = await transcriptPluginTurns(sessionId, target);
|
|
20134
|
+
if (!before.ok) {
|
|
20135
|
+
return before;
|
|
20136
|
+
}
|
|
20137
|
+
const submitted = await target.submitTurn(text, signal, waitMs);
|
|
20138
|
+
if (!submitted.asUser) {
|
|
20139
|
+
return { ok: false, message: `session ${sessionId}'s control plugin submitted the turn, but Claude Code did not stamp it as the person's words, so the model may read it framed as the plugin's` };
|
|
20140
|
+
}
|
|
20141
|
+
for (; ; ) {
|
|
20142
|
+
const after = await transcriptPluginTurns(sessionId, target);
|
|
20143
|
+
if (!after.ok) {
|
|
20144
|
+
return after;
|
|
20145
|
+
}
|
|
20146
|
+
if (after.report.count > before.report.count && after.report.last !== void 0) {
|
|
20147
|
+
return after.report.last.text === text ? { ok: true, report: { route, uuid: after.report.last.uuid } } : { ok: false, message: `session ${sessionId}'s transcript records a turn the control plugin submitted, but its text is not the text sent` };
|
|
20148
|
+
}
|
|
20149
|
+
if (signal.aborted) {
|
|
20150
|
+
return { ok: false, message: `session ${sessionId} accepted the turn but its transcript did not record it within ${String(waitMs)} ms; it is queued behind the running turn, so read the transcript before sending it again` };
|
|
20151
|
+
}
|
|
20152
|
+
await sleep(RESULT_POLL_MS);
|
|
20153
|
+
}
|
|
20154
|
+
},
|
|
20155
|
+
selfHosted: async (selfHost, signal) => {
|
|
20156
|
+
const delivered = await runSelfHostedTurn(selfHost, sessionId, text, waitOf(options), signal);
|
|
20157
|
+
return delivered.ok ? { ok: true, report: { route: "self-hosted", uuid: delivered.report.uuid } } : delivered;
|
|
20158
|
+
}
|
|
20159
|
+
});
|
|
20160
|
+
},
|
|
19749
20161
|
/** Reads the session's goal: from the transcript for a supervised session, with no effect on it; by running `/goal` on the self-hosted surface otherwise. */
|
|
19750
20162
|
goalGet: async (sessionId, options = {}) => await onRoute(sessionId, options, {
|
|
19751
|
-
|
|
20163
|
+
plugin: async (target, route) => {
|
|
19752
20164
|
const read = await transcriptGoal(sessionId, target);
|
|
19753
|
-
return
|
|
20165
|
+
return read.ok ? { ok: true, report: { route, goal: read.report } } : read;
|
|
19754
20166
|
},
|
|
19755
20167
|
selfHosted: async (selfHost, signal) => {
|
|
19756
20168
|
const read = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
|
|
@@ -19775,7 +20187,7 @@ function createRcSessionCommands(deps) {
|
|
|
19775
20187
|
return { ok: false, message: `a goal condition is limited to ${String(RC_GOAL_CONDITION_MAX_CHARS)} characters, and this one has ${String(trimmed.length)}` };
|
|
19776
20188
|
}
|
|
19777
20189
|
return await onRoute(sessionId, options, {
|
|
19778
|
-
|
|
20190
|
+
plugin: async (target, route, signal, waitMs) => {
|
|
19779
20191
|
const before = await transcriptGoal(sessionId, target);
|
|
19780
20192
|
if (!before.ok) {
|
|
19781
20193
|
return before;
|
|
@@ -19785,7 +20197,7 @@ function createRcSessionCommands(deps) {
|
|
|
19785
20197
|
if (!after.ok) {
|
|
19786
20198
|
return after;
|
|
19787
20199
|
}
|
|
19788
|
-
return after.report?.condition === trimmed ? { ok: true, report: { route
|
|
20200
|
+
return after.report?.condition === trimmed ? { ok: true, report: { route, condition: trimmed, superseded: before.report?.condition ?? null } } : { ok: false, message: `session ${sessionId} ran /goal but its transcript does not record the goal as set` };
|
|
19789
20201
|
},
|
|
19790
20202
|
selfHosted: async (selfHost, signal) => {
|
|
19791
20203
|
const before = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
|
|
@@ -19799,20 +20211,20 @@ function createRcSessionCommands(deps) {
|
|
|
19799
20211
|
},
|
|
19800
20212
|
/** Clears the session's goal and names the condition it cleared, or `null` when there was none, which is not a failure (clearing is idempotent). */
|
|
19801
20213
|
goalClear: async (sessionId, options = {}) => await onRoute(sessionId, options, {
|
|
19802
|
-
|
|
20214
|
+
plugin: async (target, route, signal, waitMs) => {
|
|
19803
20215
|
const before = await transcriptGoal(sessionId, target);
|
|
19804
20216
|
if (!before.ok) {
|
|
19805
20217
|
return before;
|
|
19806
20218
|
}
|
|
19807
20219
|
if (before.report === null) {
|
|
19808
|
-
return { ok: true, report: { route
|
|
20220
|
+
return { ok: true, report: { route, cleared: null } };
|
|
19809
20221
|
}
|
|
19810
20222
|
await target.runGoal("clear", signal, waitMs);
|
|
19811
20223
|
const after = await settledGoal(sessionId, target, signal, (goal) => goal === null);
|
|
19812
20224
|
if (!after.ok) {
|
|
19813
20225
|
return after;
|
|
19814
20226
|
}
|
|
19815
|
-
return after.report === null ? { ok: true, report: { route
|
|
20227
|
+
return after.report === null ? { ok: true, report: { route, cleared: before.report.condition } } : { ok: false, message: `session ${sessionId} ran /goal clear but its transcript still records the goal "${after.report.condition}"` };
|
|
19816
20228
|
},
|
|
19817
20229
|
selfHosted: async (selfHost, signal) => {
|
|
19818
20230
|
const cleared = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-clear" }, waitOf(options), signal);
|
|
@@ -19824,12 +20236,12 @@ function createRcSessionCommands(deps) {
|
|
|
19824
20236
|
const instructions = options.instructions?.trim();
|
|
19825
20237
|
const given = instructions === void 0 || instructions === "" ? void 0 : instructions;
|
|
19826
20238
|
return await onRoute(sessionId, options, {
|
|
19827
|
-
|
|
20239
|
+
plugin: async (target, route, signal, waitMs) => {
|
|
19828
20240
|
const result = await target.compact(signal, given, waitMs);
|
|
19829
20241
|
if (result.kind === "unchanged") {
|
|
19830
20242
|
return { ok: false, message: `session ${sessionId} was not compacted: ${result.reason}` };
|
|
19831
20243
|
}
|
|
19832
|
-
return { ok: true, report: { route
|
|
20244
|
+
return { ok: true, report: { route, trigger: "plugin", ...result.beforeTokens === void 0 ? {} : { preTokens: result.beforeTokens }, ...result.afterTokens === void 0 ? {} : { postTokens: result.afterTokens } } };
|
|
19833
20245
|
},
|
|
19834
20246
|
selfHosted: async (selfHost, signal) => {
|
|
19835
20247
|
const compacted = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "compact", instructions: given }, waitOf(options), signal);
|
|
@@ -19841,47 +20253,56 @@ function createRcSessionCommands(deps) {
|
|
|
19841
20253
|
}
|
|
19842
20254
|
|
|
19843
20255
|
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
19844
|
-
var WaitMsSchema =
|
|
19845
|
-
var RcGoalSessionInputSchema =
|
|
19846
|
-
session:
|
|
20256
|
+
var WaitMsSchema = z25.int().positive().max(RC_SESSION_COMMAND_MAX_WAIT_MS).optional();
|
|
20257
|
+
var RcGoalSessionInputSchema = z25.strictObject({
|
|
20258
|
+
session: z25.string().min(1),
|
|
20259
|
+
waitMs: WaitMsSchema
|
|
20260
|
+
});
|
|
20261
|
+
var RcGoalSetInputSchema = z25.strictObject({
|
|
20262
|
+
session: z25.string().min(1),
|
|
20263
|
+
condition: z25.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
|
|
19847
20264
|
waitMs: WaitMsSchema
|
|
19848
20265
|
});
|
|
19849
|
-
var
|
|
19850
|
-
session:
|
|
19851
|
-
condition: z24.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
|
|
20266
|
+
var RcCompactInputSchema = z25.strictObject({
|
|
20267
|
+
session: z25.string().min(1),
|
|
19852
20268
|
waitMs: WaitMsSchema
|
|
19853
20269
|
});
|
|
19854
|
-
var
|
|
19855
|
-
session:
|
|
20270
|
+
var RcCompactWithInstructionsInputSchema = z25.strictObject({
|
|
20271
|
+
session: z25.string().min(1),
|
|
20272
|
+
instructions: z25.string().trim().min(1).max(RC_COMPACT_INSTRUCTIONS_MAX_CHARS),
|
|
19856
20273
|
waitMs: WaitMsSchema
|
|
19857
20274
|
});
|
|
19858
|
-
var
|
|
19859
|
-
session:
|
|
19860
|
-
|
|
20275
|
+
var RcTurnInputSchema = z25.strictObject({
|
|
20276
|
+
session: z25.string().min(1),
|
|
20277
|
+
text: z25.string().min(1).max(RC_TURN_TEXT_MAX_CHARS),
|
|
19861
20278
|
waitMs: WaitMsSchema
|
|
19862
20279
|
});
|
|
19863
20280
|
var commandAnswerShape = {
|
|
19864
|
-
session:
|
|
19865
|
-
route:
|
|
20281
|
+
session: z25.string(),
|
|
20282
|
+
route: z25.enum(["supervised", "launched", "self-hosted"])
|
|
19866
20283
|
};
|
|
19867
|
-
var RcGoalGetOutputSchema =
|
|
20284
|
+
var RcGoalGetOutputSchema = z25.strictObject({
|
|
20285
|
+
...commandAnswerShape,
|
|
20286
|
+
goal: z25.strictObject({ condition: z25.string(), iterations: z25.int().nonnegative(), lastCheck: z25.string().optional() }).nullable()
|
|
20287
|
+
});
|
|
20288
|
+
var RcGoalSetOutputSchema = z25.strictObject({
|
|
19868
20289
|
...commandAnswerShape,
|
|
19869
|
-
|
|
20290
|
+
condition: z25.string(),
|
|
20291
|
+
superseded: z25.string().nullable()
|
|
19870
20292
|
});
|
|
19871
|
-
var
|
|
20293
|
+
var RcGoalClearOutputSchema = z25.strictObject({
|
|
19872
20294
|
...commandAnswerShape,
|
|
19873
|
-
|
|
19874
|
-
superseded: z24.string().nullable()
|
|
20295
|
+
cleared: z25.string().nullable()
|
|
19875
20296
|
});
|
|
19876
|
-
var
|
|
20297
|
+
var RcTurnOutputSchema = z25.strictObject({
|
|
19877
20298
|
...commandAnswerShape,
|
|
19878
|
-
|
|
20299
|
+
uuid: z25.string()
|
|
19879
20300
|
});
|
|
19880
|
-
var RcCompactOutputSchema =
|
|
20301
|
+
var RcCompactOutputSchema = z25.strictObject({
|
|
19881
20302
|
...commandAnswerShape,
|
|
19882
|
-
trigger:
|
|
19883
|
-
preTokens:
|
|
19884
|
-
postTokens:
|
|
20303
|
+
trigger: z25.string(),
|
|
20304
|
+
preTokens: z25.number().optional(),
|
|
20305
|
+
postTokens: z25.number().optional()
|
|
19885
20306
|
});
|
|
19886
20307
|
|
|
19887
20308
|
// src/frontdoor/rcApi.ts
|
|
@@ -19933,12 +20354,12 @@ function createRcApiRouter(deps) {
|
|
|
19933
20354
|
return {
|
|
19934
20355
|
rc: {
|
|
19935
20356
|
list: authed.meta(openapi({ method: "GET", path: "/rest/rc/sessions", summary: "List the observed Remote Control sessions", tags: [RC_API_TAG] })).output(RcListOutputSchema).handler(() => ({ sessions: deps.list() })),
|
|
19936
|
-
status: authed.meta(openapi({ method: "GET", path: "/rest/rc/status", summary: "Read session status, one session's when named", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output(RcStatusOutputSchema).handler(({ input }) => {
|
|
20357
|
+
status: authed.meta(openapi({ method: "GET", path: "/rest/rc/status", summary: "Read session status, one session's when named", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output(RcStatusOutputSchema).handler(async ({ input }) => {
|
|
19937
20358
|
const statuses = deps.statusOf(input.session);
|
|
19938
20359
|
if (input.session !== void 0 && !statuses.some((entry) => entry.id === input.session)) {
|
|
19939
20360
|
throw new ORPCError("NOT_FOUND", { message: rcSessionNotObservedMessage(input.session) });
|
|
19940
20361
|
}
|
|
19941
|
-
return { statuses };
|
|
20362
|
+
return { statuses: await Promise.all(statuses.map(async (status) => ({ ...status, route: await deps.routeOf(status.id) }))) };
|
|
19942
20363
|
}),
|
|
19943
20364
|
pending: authed.meta(openapi({ method: "GET", path: "/rest/rc/pending", summary: "Read the control requests awaiting an answer", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output(RcPendingOutputSchema).handler(({ input }) => {
|
|
19944
20365
|
const pending = deps.pendingOf(input.session);
|
|
@@ -19973,6 +20394,7 @@ function createRcApiRouter(deps) {
|
|
|
19973
20394
|
goalClear: authed.meta(openapi({ method: "POST", path: "/rest/rc/goal/clear", summary: "Clear a session's goal", tags: [RC_API_TAG] })).input(RcGoalSessionInputSchema).output(RcGoalClearOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.goalClear(input.session, optionsOf(input.waitMs, signal)))),
|
|
19974
20395
|
compact: authed.meta(openapi({ method: "POST", path: "/rest/rc/compact", summary: "Compact a session's conversation", tags: [RC_API_TAG] })).input(RcCompactInputSchema).output(RcCompactOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.compact(input.session, optionsOf(input.waitMs, signal)))),
|
|
19975
20396
|
compactWithInstructions: authed.meta(openapi({ method: "POST", path: "/rest/rc/compact-with-instructions", summary: "Compact a session's conversation under summary instructions, a directive to its model", tags: [RC_DIRECTIVE_TAG] })).input(RcCompactWithInstructionsInputSchema).output(RcCompactOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.compact(input.session, { ...optionsOf(input.waitMs, signal), instructions: input.instructions }))),
|
|
20397
|
+
turn: authed.meta(openapi({ method: "POST", path: "/rest/rc/turn", summary: "Put a person's typed turn into a session, which its model reads as its user's words", tags: [RC_DIRECTIVE_TAG] })).input(RcTurnInputSchema).output(RcTurnOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.turn(input.session, input.text, optionsOf(input.waitMs, signal)))),
|
|
19976
20398
|
subscribe: authed.meta(openapi({ method: "GET", path: "/rest/rc/events", summary: "Stream a session's Remote Control events (SSE)", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output(eventIterator(RcStreamEventSchema)).handler(async function* ({ input, signal }) {
|
|
19977
20399
|
const queue = [];
|
|
19978
20400
|
let wake;
|
|
@@ -20054,7 +20476,7 @@ function createRcApiNodeHandler(deps) {
|
|
|
20054
20476
|
return doorApiNodeHandlerOf(createRcApiRouter(deps), deps.expectedToken);
|
|
20055
20477
|
}
|
|
20056
20478
|
var DEFAULT_HEADERS_TIMEOUT_MS = 3e5;
|
|
20057
|
-
var SESSION_COMMAND_PROCEDURES = ["rc/goalGet", "rc/goalSet", "rc/goalClear", "rc/compact", "rc/compactWithInstructions"];
|
|
20479
|
+
var SESSION_COMMAND_PROCEDURES = ["rc/goalGet", "rc/goalSet", "rc/goalClear", "rc/compact", "rc/compactWithInstructions", "rc/turn"];
|
|
20058
20480
|
function headersTimeoutOf(url, body) {
|
|
20059
20481
|
if (!SESSION_COMMAND_PROCEDURES.some((procedure) => url.endsWith(`${RC_ORPC_PATH_PREFIX}/${procedure}`))) {
|
|
20060
20482
|
return DEFAULT_HEADERS_TIMEOUT_MS;
|
|
@@ -20102,48 +20524,48 @@ init_cliError();
|
|
|
20102
20524
|
init_package();
|
|
20103
20525
|
|
|
20104
20526
|
// src/codex/appServerSchemas.ts
|
|
20105
|
-
import { z as
|
|
20527
|
+
import { z as z26 } from "zod";
|
|
20106
20528
|
var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
|
|
20107
|
-
var RateLimitWindowSchema =
|
|
20108
|
-
usedPercent:
|
|
20109
|
-
resetsAt:
|
|
20110
|
-
windowDurationMins:
|
|
20111
|
-
});
|
|
20112
|
-
var RateLimitSnapshotSchema =
|
|
20113
|
-
limitId:
|
|
20114
|
-
limitName:
|
|
20115
|
-
planType:
|
|
20529
|
+
var RateLimitWindowSchema = z26.object({
|
|
20530
|
+
usedPercent: z26.number(),
|
|
20531
|
+
resetsAt: z26.number().nullish(),
|
|
20532
|
+
windowDurationMins: z26.number().nullish()
|
|
20533
|
+
});
|
|
20534
|
+
var RateLimitSnapshotSchema = z26.object({
|
|
20535
|
+
limitId: z26.string().nullish(),
|
|
20536
|
+
limitName: z26.string().nullish(),
|
|
20537
|
+
planType: z26.string().nullish(),
|
|
20116
20538
|
primary: RateLimitWindowSchema.nullish(),
|
|
20117
20539
|
secondary: RateLimitWindowSchema.nullish(),
|
|
20118
|
-
rateLimitReachedType:
|
|
20119
|
-
spendControlReached:
|
|
20120
|
-
});
|
|
20121
|
-
var RateLimitResetCreditSchema =
|
|
20122
|
-
id:
|
|
20123
|
-
grantedAt:
|
|
20124
|
-
expiresAt:
|
|
20125
|
-
resetType:
|
|
20126
|
-
status:
|
|
20127
|
-
title:
|
|
20128
|
-
description:
|
|
20129
|
-
});
|
|
20130
|
-
var CodexAccountSchema =
|
|
20131
|
-
|
|
20132
|
-
|
|
20133
|
-
|
|
20540
|
+
rateLimitReachedType: z26.string().nullish(),
|
|
20541
|
+
spendControlReached: z26.boolean().nullish()
|
|
20542
|
+
});
|
|
20543
|
+
var RateLimitResetCreditSchema = z26.object({
|
|
20544
|
+
id: z26.string(),
|
|
20545
|
+
grantedAt: z26.number(),
|
|
20546
|
+
expiresAt: z26.number().nullish(),
|
|
20547
|
+
resetType: z26.string(),
|
|
20548
|
+
status: z26.string(),
|
|
20549
|
+
title: z26.string().nullish(),
|
|
20550
|
+
description: z26.string().nullish()
|
|
20551
|
+
});
|
|
20552
|
+
var CodexAccountSchema = z26.discriminatedUnion("type", [
|
|
20553
|
+
z26.object({ type: z26.literal("apiKey") }),
|
|
20554
|
+
z26.object({ type: z26.literal("chatgpt"), email: z26.string().nullable(), planType: z26.string() }),
|
|
20555
|
+
z26.object({ type: z26.literal("amazonBedrock"), usesCodexManagedCredentials: z26.boolean().default(false) })
|
|
20134
20556
|
]);
|
|
20135
|
-
var CodexAccountReadSchema =
|
|
20557
|
+
var CodexAccountReadSchema = z26.object({
|
|
20136
20558
|
account: CodexAccountSchema.nullable(),
|
|
20137
|
-
requiresOpenaiAuth:
|
|
20559
|
+
requiresOpenaiAuth: z26.boolean()
|
|
20138
20560
|
});
|
|
20139
|
-
var CodexRateLimitsReadSchema =
|
|
20561
|
+
var CodexRateLimitsReadSchema = z26.object({
|
|
20140
20562
|
rateLimits: RateLimitSnapshotSchema,
|
|
20141
|
-
rateLimitsByLimitId:
|
|
20142
|
-
rateLimitResetCredits:
|
|
20143
|
-
accountId:
|
|
20144
|
-
ordinaryUsageAllowed:
|
|
20563
|
+
rateLimitsByLimitId: z26.record(z26.string(), RateLimitSnapshotSchema).nullish(),
|
|
20564
|
+
rateLimitResetCredits: z26.object({ availableCount: z26.number(), credits: z26.array(RateLimitResetCreditSchema).nullish() }).nullish(),
|
|
20565
|
+
accountId: z26.string().nullish(),
|
|
20566
|
+
ordinaryUsageAllowed: z26.boolean().nullish()
|
|
20145
20567
|
});
|
|
20146
|
-
var CodexInitializeResultSchema =
|
|
20568
|
+
var CodexInitializeResultSchema = z26.object({ userAgent: z26.string() });
|
|
20147
20569
|
|
|
20148
20570
|
// src/codex/appServer.ts
|
|
20149
20571
|
var CodexAppServerUnavailableError = class extends CliError {
|
|
@@ -20346,7 +20768,7 @@ init_schema();
|
|
|
20346
20768
|
init_claudeVersion();
|
|
20347
20769
|
init_identity2();
|
|
20348
20770
|
init_projects();
|
|
20349
|
-
import { z as
|
|
20771
|
+
import { z as z28 } from "zod";
|
|
20350
20772
|
|
|
20351
20773
|
// src/resolve/types.ts
|
|
20352
20774
|
var LAYER_KINDS = [
|
|
@@ -20401,135 +20823,137 @@ var DIAGNOSTIC_CODES = [
|
|
|
20401
20823
|
/** A previous launch was interrupted mid-swap and this launch completed or undid the half-finished work. */
|
|
20402
20824
|
"FARM_SWAP_RECOVERED",
|
|
20403
20825
|
/** A superseded farm could not be discarded because it still held data the new farm has its own entry for, so it was left on disk for the user to look at. */
|
|
20404
|
-
"FARM_PREVIOUS_RETAINED"
|
|
20826
|
+
"FARM_PREVIOUS_RETAINED",
|
|
20827
|
+
/** A shared `~/.claude` entry is a symlink that reaches nothing, so the farm does not link it and the identity keeps its own copy until the entry leads somewhere. */
|
|
20828
|
+
"SHARED_ENTRY_DANGLING"
|
|
20405
20829
|
];
|
|
20406
20830
|
var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
|
|
20407
20831
|
|
|
20408
20832
|
// src/usage/pickReportSchema.ts
|
|
20409
20833
|
init_plan2();
|
|
20410
|
-
import { z as
|
|
20411
|
-
var PoolPickCandidateViewSchema =
|
|
20412
|
-
identity:
|
|
20834
|
+
import { z as z27 } from "zod";
|
|
20835
|
+
var PoolPickCandidateViewSchema = z27.strictObject({
|
|
20836
|
+
identity: z27.string(),
|
|
20413
20837
|
/** In pick order: `scored` has usable quota data, `unknown` has none and no plan known to bill by use, `pay-per-use` bills by use whether or not usage is recorded, `ineligible` is refused right now. */
|
|
20414
|
-
class:
|
|
20838
|
+
class: z27.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
|
|
20415
20839
|
/** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
|
|
20416
|
-
score:
|
|
20840
|
+
score: z27.number().optional(),
|
|
20417
20841
|
/** Which window's reset divides the score: the seven-day window, or the five-hour one when the member reports no seven-day utilisation or its measured-ratio five-hour term outranks the weekly one; present with `score`. */
|
|
20418
|
-
scoreWindow:
|
|
20842
|
+
scoreWindow: z27.enum(["sevenDay", "fiveHour"]).optional(),
|
|
20419
20843
|
/** False when the five-hour window would run dry, at the observed pace, before it resets. */
|
|
20420
|
-
feasible:
|
|
20844
|
+
feasible: z27.boolean(),
|
|
20421
20845
|
/** When an `ineligible` member can be used again, as an ISO instant. */
|
|
20422
|
-
blockedUntil:
|
|
20846
|
+
blockedUntil: z27.iso.datetime().optional(),
|
|
20423
20847
|
plan: PlanClassSchema,
|
|
20424
20848
|
/** The provider the member was ranked on, when its launch spends one in place of its Claude account: its windows, refusals and plan are the provider's own. Absent when ranked on the Claude account. */
|
|
20425
|
-
provider:
|
|
20849
|
+
provider: z27.string().optional(),
|
|
20426
20850
|
/** The facts behind the class and score, in the order they matter. */
|
|
20427
|
-
reasons:
|
|
20851
|
+
reasons: z27.array(z27.string())
|
|
20428
20852
|
});
|
|
20429
|
-
var PoolPickReportSchema =
|
|
20430
|
-
pool:
|
|
20431
|
-
directory:
|
|
20853
|
+
var PoolPickReportSchema = z27.strictObject({
|
|
20854
|
+
pool: z27.string(),
|
|
20855
|
+
directory: z27.string(),
|
|
20432
20856
|
/** The member a launch would run as, absent when every member is refused. */
|
|
20433
|
-
pick:
|
|
20434
|
-
candidates:
|
|
20857
|
+
pick: z27.string().optional(),
|
|
20858
|
+
candidates: z27.array(PoolPickCandidateViewSchema),
|
|
20435
20859
|
/** Identity members anywhere in the pool's graph that do not exist; a launch skips them. */
|
|
20436
|
-
missing:
|
|
20860
|
+
missing: z27.array(z27.string()),
|
|
20437
20861
|
/** When nothing can be picked, the soonest any member returns. */
|
|
20438
|
-
earliestReturn:
|
|
20862
|
+
earliestReturn: z27.strictObject({ identity: z27.string(), at: z27.iso.datetime() }).optional(),
|
|
20439
20863
|
/** The member a resumed conversation started on but moved off, and why, when the ranking could not keep it. */
|
|
20440
|
-
movedOff:
|
|
20864
|
+
movedOff: z27.strictObject({ identity: z27.string(), reason: z27.string() }).optional(),
|
|
20441
20865
|
/** Why the last-pick record could not be read, when that is the case. */
|
|
20442
|
-
stickyProblem:
|
|
20866
|
+
stickyProblem: z27.string().optional()
|
|
20443
20867
|
});
|
|
20444
20868
|
|
|
20445
20869
|
// src/checkReportSchema.ts
|
|
20446
20870
|
var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
|
|
20447
|
-
var CheckLayerViewSchema =
|
|
20448
|
-
id:
|
|
20449
|
-
kind:
|
|
20450
|
-
source:
|
|
20451
|
-
});
|
|
20452
|
-
var CheckEntryViewSchema =
|
|
20453
|
-
path:
|
|
20454
|
-
shared:
|
|
20455
|
-
via:
|
|
20871
|
+
var CheckLayerViewSchema = z28.strictObject({
|
|
20872
|
+
id: z28.int(),
|
|
20873
|
+
kind: z28.enum(LAYER_KINDS),
|
|
20874
|
+
source: z28.string()
|
|
20875
|
+
});
|
|
20876
|
+
var CheckEntryViewSchema = z28.strictObject({
|
|
20877
|
+
path: z28.string(),
|
|
20878
|
+
shared: z28.boolean(),
|
|
20879
|
+
via: z28.enum(DECISION_VIAS),
|
|
20456
20880
|
/** The entry's real category, or null when nothing classifies it. */
|
|
20457
|
-
category:
|
|
20458
|
-
rule:
|
|
20881
|
+
category: z28.enum(CATEGORY_NAMES).nullable(),
|
|
20882
|
+
rule: z28.strictObject({ key: z28.string(), layer: z28.int() }).optional(),
|
|
20459
20883
|
/** Rules that matched but whose `when` condition failed, each with the conditions that failed. */
|
|
20460
|
-
eliminated:
|
|
20461
|
-
});
|
|
20462
|
-
var CheckDiagnosticSchema =
|
|
20463
|
-
code:
|
|
20464
|
-
severity:
|
|
20465
|
-
message:
|
|
20466
|
-
subject:
|
|
20467
|
-
layer:
|
|
20468
|
-
});
|
|
20469
|
-
var CheckAmbientCredentialSchema =
|
|
20470
|
-
var CheckKeychainSchema =
|
|
20471
|
-
checked:
|
|
20472
|
-
found:
|
|
20473
|
-
serviceName:
|
|
20474
|
-
note:
|
|
20475
|
-
});
|
|
20476
|
-
var CheckSettingsExposureSchema =
|
|
20477
|
-
file:
|
|
20478
|
-
envKeyNames:
|
|
20479
|
-
hookEventNames:
|
|
20480
|
-
hookCommandCount:
|
|
20481
|
-
});
|
|
20482
|
-
var CredentialSourceSummarySchema =
|
|
20483
|
-
|
|
20484
|
-
|
|
20485
|
-
|
|
20486
|
-
|
|
20487
|
-
|
|
20488
|
-
|
|
20884
|
+
eliminated: z28.readonly(z28.array(z28.strictObject({ key: z28.string(), failed: z28.readonly(z28.array(z28.string())) }))).optional()
|
|
20885
|
+
});
|
|
20886
|
+
var CheckDiagnosticSchema = z28.strictObject({
|
|
20887
|
+
code: z28.enum(DIAGNOSTIC_CODES),
|
|
20888
|
+
severity: z28.enum(DIAGNOSTIC_SEVERITIES),
|
|
20889
|
+
message: z28.string(),
|
|
20890
|
+
subject: z28.string().optional(),
|
|
20891
|
+
layer: z28.int().optional()
|
|
20892
|
+
});
|
|
20893
|
+
var CheckAmbientCredentialSchema = z28.union([z28.strictObject({ ok: z28.literal(true) }), z28.strictObject({ ok: z28.literal(false), variable: z28.string(), message: z28.string() })]);
|
|
20894
|
+
var CheckKeychainSchema = z28.strictObject({
|
|
20895
|
+
checked: z28.literal(true),
|
|
20896
|
+
found: z28.boolean(),
|
|
20897
|
+
serviceName: z28.string().optional(),
|
|
20898
|
+
note: z28.string()
|
|
20899
|
+
});
|
|
20900
|
+
var CheckSettingsExposureSchema = z28.strictObject({
|
|
20901
|
+
file: z28.string(),
|
|
20902
|
+
envKeyNames: z28.readonly(z28.array(z28.string())),
|
|
20903
|
+
hookEventNames: z28.readonly(z28.array(z28.string())),
|
|
20904
|
+
hookCommandCount: z28.int().nonnegative()
|
|
20905
|
+
});
|
|
20906
|
+
var CredentialSourceSummarySchema = z28.union([
|
|
20907
|
+
z28.strictObject({ kind: z28.literal("env"), variable: z28.string() }),
|
|
20908
|
+
z28.strictObject({ kind: z28.literal("file"), path: z28.string() }),
|
|
20909
|
+
z28.strictObject({ kind: z28.literal("command"), program: z28.string() }),
|
|
20910
|
+
z28.strictObject({ kind: z28.literal("op"), reference: z28.string() }),
|
|
20911
|
+
z28.strictObject({ kind: z28.literal("keychain"), service: z28.string(), account: z28.string().optional() }),
|
|
20912
|
+
z28.strictObject({ kind: z28.literal("literal") })
|
|
20489
20913
|
]);
|
|
20490
|
-
var CredentialSummarySchema =
|
|
20491
|
-
target:
|
|
20492
|
-
sources:
|
|
20914
|
+
var CredentialSummarySchema = z28.strictObject({
|
|
20915
|
+
target: z28.enum(CREDENTIAL_TARGETS),
|
|
20916
|
+
sources: z28.readonly(z28.array(CredentialSourceSummarySchema)),
|
|
20493
20917
|
cache: CredentialCacheSchema.optional()
|
|
20494
20918
|
});
|
|
20495
|
-
var CachedCredentialStateSchema =
|
|
20496
|
-
|
|
20497
|
-
|
|
20498
|
-
|
|
20919
|
+
var CachedCredentialStateSchema = z28.union([
|
|
20920
|
+
z28.strictObject({ store: z28.enum(CREDENTIAL_CACHE_STORES), status: z28.literal("empty") }),
|
|
20921
|
+
z28.strictObject({ store: z28.enum(CREDENTIAL_CACHE_STORES), status: z28.literal("unreadable"), reason: z28.string() }),
|
|
20922
|
+
z28.strictObject({ store: z28.enum(CREDENTIAL_CACHE_STORES), status: z28.enum(["fresh", "expired"]), ageMs: z28.number(), expiresInMs: z28.number().optional() })
|
|
20499
20923
|
]);
|
|
20500
|
-
var CheckCredentialProviderSchema =
|
|
20501
|
-
|
|
20502
|
-
|
|
20924
|
+
var CheckCredentialProviderSchema = z28.union([
|
|
20925
|
+
z28.strictObject({ name: z28.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
|
|
20926
|
+
z28.strictObject({ name: z28.string(), problem: z28.string() })
|
|
20503
20927
|
]);
|
|
20504
|
-
var CheckProviderReachabilitySchema =
|
|
20505
|
-
|
|
20506
|
-
|
|
20928
|
+
var CheckProviderReachabilitySchema = z28.union([
|
|
20929
|
+
z28.strictObject({ name: z28.string(), baseUrl: z28.string(), ok: z28.literal(true) }),
|
|
20930
|
+
z28.strictObject({ name: z28.string(), baseUrl: z28.string(), ok: z28.literal(false), message: z28.string() })
|
|
20507
20931
|
]);
|
|
20508
|
-
var CheckCredentialSchema =
|
|
20509
|
-
applies:
|
|
20932
|
+
var CheckCredentialSchema = z28.strictObject({
|
|
20933
|
+
applies: z28.enum(CHECK_CREDENTIAL_APPLIES),
|
|
20510
20934
|
provider: CheckCredentialProviderSchema.optional(),
|
|
20511
20935
|
identity: CredentialSummarySchema.optional(),
|
|
20512
20936
|
identityCached: CachedCredentialStateSchema.optional()
|
|
20513
20937
|
});
|
|
20514
|
-
var CheckClaudeVersionSchema =
|
|
20515
|
-
pinned:
|
|
20516
|
-
highestInstalled:
|
|
20517
|
-
installed:
|
|
20938
|
+
var CheckClaudeVersionSchema = z28.strictObject({
|
|
20939
|
+
pinned: z28.strictObject({ version: z28.string(), source: z28.enum(CLAUDE_VERSION_SOURCES), installed: z28.boolean() }).optional(),
|
|
20940
|
+
highestInstalled: z28.string().optional(),
|
|
20941
|
+
installed: z28.readonly(z28.array(z28.string()))
|
|
20518
20942
|
});
|
|
20519
|
-
var CheckReportJsonSchema =
|
|
20520
|
-
identity:
|
|
20943
|
+
var CheckReportJsonSchema = z28.strictObject({
|
|
20944
|
+
identity: z28.strictObject({ name: z28.string().nullable(), source: z28.enum(IDENTITY_DECISION_SOURCES) }),
|
|
20521
20945
|
/** The pool ranking, when the launch named a pool instead of an identity. */
|
|
20522
20946
|
pool: PoolPickReportSchema.optional(),
|
|
20523
|
-
configProfile:
|
|
20524
|
-
layers:
|
|
20525
|
-
entries:
|
|
20526
|
-
projectEncodingAmbiguities:
|
|
20527
|
-
|
|
20947
|
+
configProfile: z28.strictObject({ name: z28.string().nullable(), source: z28.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
|
|
20948
|
+
layers: z28.readonly(z28.array(CheckLayerViewSchema)),
|
|
20949
|
+
entries: z28.readonly(z28.array(CheckEntryViewSchema)),
|
|
20950
|
+
projectEncodingAmbiguities: z28.readonly(
|
|
20951
|
+
z28.array(z28.strictObject({ fragment: z28.string(), encoded: z28.string(), reason: z28.enum(ENCODING_AMBIGUITY_REASONS), detail: z28.string() }))
|
|
20528
20952
|
),
|
|
20529
|
-
diagnostics:
|
|
20953
|
+
diagnostics: z28.readonly(z28.array(CheckDiagnosticSchema)),
|
|
20530
20954
|
ambientCredential: CheckAmbientCredentialSchema,
|
|
20531
20955
|
keychain: CheckKeychainSchema.optional(),
|
|
20532
|
-
settingsExposure:
|
|
20956
|
+
settingsExposure: z28.readonly(z28.array(CheckSettingsExposureSchema)),
|
|
20533
20957
|
credential: CheckCredentialSchema,
|
|
20534
20958
|
claudeVersion: CheckClaudeVersionSchema.optional(),
|
|
20535
20959
|
providerReachability: CheckProviderReachabilitySchema.optional()
|
|
@@ -20541,28 +20965,28 @@ init_preflight();
|
|
|
20541
20965
|
init_resets();
|
|
20542
20966
|
|
|
20543
20967
|
// src/usage/resetsSchema.ts
|
|
20544
|
-
import { z as
|
|
20545
|
-
var ResetRowSchema =
|
|
20546
|
-
identity:
|
|
20547
|
-
provider:
|
|
20968
|
+
import { z as z29 } from "zod";
|
|
20969
|
+
var ResetRowSchema = z29.strictObject({
|
|
20970
|
+
identity: z29.string(),
|
|
20971
|
+
provider: z29.string(),
|
|
20548
20972
|
/** What the window is: `5h`, `7d` or `extra usage` for an Anthropic account, or the provider's own measure and period (`tokens 5h`). */
|
|
20549
|
-
window:
|
|
20973
|
+
window: z29.string(),
|
|
20550
20974
|
/** When the state the window comes from was observed, as an ISO instant. */
|
|
20551
|
-
observedAt:
|
|
20975
|
+
observedAt: z29.iso.datetime(),
|
|
20552
20976
|
/** When the window resets, as an ISO instant; absent when the upstream reported none. */
|
|
20553
|
-
resetsAt:
|
|
20977
|
+
resetsAt: z29.iso.datetime().optional(),
|
|
20554
20978
|
/** True when the reset time has passed, so the recorded observation describes a window that no longer exists and its utilisation reads as 0. */
|
|
20555
|
-
reset:
|
|
20979
|
+
reset: z29.boolean(),
|
|
20556
20980
|
/** The fraction used, as `effectiveWindow` reads it at the report's own clock. */
|
|
20557
|
-
utilization:
|
|
20981
|
+
utilization: z29.number().optional(),
|
|
20558
20982
|
/** The window's own status, for a window that has not reset yet. */
|
|
20559
|
-
status:
|
|
20983
|
+
status: z29.string().optional()
|
|
20560
20984
|
});
|
|
20561
|
-
var ResetScheduleSchema =
|
|
20985
|
+
var ResetScheduleSchema = z29.strictObject({ resets: z29.readonly(z29.array(ResetRowSchema)) });
|
|
20562
20986
|
|
|
20563
20987
|
// src/frontdoor/controlSchemas.ts
|
|
20564
|
-
import
|
|
20565
|
-
import { z as
|
|
20988
|
+
import path45 from "node:path";
|
|
20989
|
+
import { z as z39 } from "zod";
|
|
20566
20990
|
|
|
20567
20991
|
// src/codex/doctor.ts
|
|
20568
20992
|
function codexIdentityFindings(entry, identity) {
|
|
@@ -20582,13 +21006,13 @@ init_identityRecords();
|
|
|
20582
21006
|
|
|
20583
21007
|
// src/doctorIdentityRecords.ts
|
|
20584
21008
|
init_identityRecords();
|
|
20585
|
-
import
|
|
21009
|
+
import path35 from "node:path";
|
|
20586
21010
|
function identityRecordFindings(records, displaced, nameRenames, strayNameRenameFiles) {
|
|
20587
21011
|
return [
|
|
20588
21012
|
...strayNameRenameFiles.map((file) => ({
|
|
20589
21013
|
severity: "warn",
|
|
20590
21014
|
message: `${file} holds the record of a rename of an identity's name, but not under the file name that rename keeps it in, so nothing reads it or removes it. Remove it.`,
|
|
20591
|
-
subject:
|
|
21015
|
+
subject: path35.basename(file)
|
|
20592
21016
|
})),
|
|
20593
21017
|
...nameRenames.map(({ from, description }) => ({ severity: "fail", message: description, subject: from })),
|
|
20594
21018
|
...duplicateIdentityNames(records).map(({ name, ids }) => ({
|
|
@@ -20614,7 +21038,7 @@ init_blockingSpawn();
|
|
|
20614
21038
|
init_realPorts();
|
|
20615
21039
|
init_doorBounds();
|
|
20616
21040
|
import fs10 from "node:fs";
|
|
20617
|
-
import
|
|
21041
|
+
import path36 from "node:path";
|
|
20618
21042
|
function realpathOrSelf(target) {
|
|
20619
21043
|
try {
|
|
20620
21044
|
return fs10.realpathSync(target);
|
|
@@ -20625,14 +21049,14 @@ function realpathOrSelf(target) {
|
|
|
20625
21049
|
var MAX_FORWARDING_SCRIPT_BYTES = 8192;
|
|
20626
21050
|
function resolveMiseDispatcher(target, pathDirs, env, trustedExecutable) {
|
|
20627
21051
|
const executable = realpathOrSelf(target);
|
|
20628
|
-
const trustedMise =
|
|
20629
|
-
if (
|
|
20630
|
-
const result = spawnSyncBlocking("a mise shim lookup", executable, ["which",
|
|
21052
|
+
const trustedMise = path36.join(path36.dirname(trustedExecutable), "mise");
|
|
21053
|
+
if (path36.basename(executable) !== "mise" || realpathOrSelf(trustedMise) !== executable) return void 0;
|
|
21054
|
+
const result = spawnSyncBlocking("a mise shim lookup", executable, ["which", path36.basename(target)], { encoding: "utf8", env, timeout: BLOCKING_STEP_TIMEOUTS_MS.miseLookup });
|
|
20631
21055
|
if (result.error !== void 0) return void 0;
|
|
20632
21056
|
if (result.status === 0 && result.stdout.trim() !== "") return result.stdout.trim();
|
|
20633
21057
|
if (!result.stderr.includes("not currently active")) return void 0;
|
|
20634
21058
|
for (const dir of pathDirs) {
|
|
20635
|
-
const candidate = findExecutableInDir(dir,
|
|
21059
|
+
const candidate = findExecutableInDir(dir, path36.basename(target));
|
|
20636
21060
|
if (candidate !== void 0 && realpathOrSelf(candidate) !== executable) {
|
|
20637
21061
|
try {
|
|
20638
21062
|
const script = fs10.statSync(candidate).size <= MAX_FORWARDING_SCRIPT_BYTES ? realFsPort.readFileUtf8(candidate) : void 0;
|
|
@@ -20651,7 +21075,7 @@ init_signIn();
|
|
|
20651
21075
|
init_identityAccounts();
|
|
20652
21076
|
init_read();
|
|
20653
21077
|
init_providerReachability();
|
|
20654
|
-
import
|
|
21078
|
+
import path44 from "node:path";
|
|
20655
21079
|
|
|
20656
21080
|
// src/doctorNameFinding.ts
|
|
20657
21081
|
init_names();
|
|
@@ -20713,10 +21137,10 @@ var CODEX_CATEGORIES = {
|
|
|
20713
21137
|
|
|
20714
21138
|
// src/codex/identity.ts
|
|
20715
21139
|
init_envBool();
|
|
20716
|
-
import
|
|
21140
|
+
import path37 from "node:path";
|
|
20717
21141
|
var CODEX_AMBIENT_CREDENTIALS = ["OPENAI_API_KEY", "CODEX_API_KEY", "CODEX_ACCESS_TOKEN", "OPENAI_IDENTITY_TOKEN_FILE", "OPENAI_FEDERATION_RULE_ID"];
|
|
20718
21142
|
function canonicalCodexHome(env, home) {
|
|
20719
|
-
return
|
|
21143
|
+
return path37.resolve(env.AGENT_SHIM_CODEX_HOME === void 0 || env.AGENT_SHIM_CODEX_HOME === "" ? path37.join(home, ".codex") : env.AGENT_SHIM_CODEX_HOME);
|
|
20720
21144
|
}
|
|
20721
21145
|
function codexCredentialGuard(env, allowAmbientCredential) {
|
|
20722
21146
|
const variable = CODEX_AMBIENT_CREDENTIALS.find((key) => (env[key] ?? "") !== "");
|
|
@@ -20867,8 +21291,8 @@ init_providersStore();
|
|
|
20867
21291
|
init_projects();
|
|
20868
21292
|
init_injected();
|
|
20869
21293
|
init_pipeline();
|
|
20870
|
-
import
|
|
20871
|
-
import { z as
|
|
21294
|
+
import path41 from "node:path";
|
|
21295
|
+
import { z as z32 } from "zod";
|
|
20872
21296
|
var HISTORY_PROJECTS_KEY_PREFIX = "history/projects/";
|
|
20873
21297
|
function projectFragmentOf(rawKey) {
|
|
20874
21298
|
return rawKey.startsWith(HISTORY_PROJECTS_KEY_PREFIX) ? rawKey.slice(HISTORY_PROJECTS_KEY_PREFIX.length) : void 0;
|
|
@@ -20937,9 +21361,9 @@ function lookupKeychainService(run, farmRoot) {
|
|
|
20937
21361
|
}
|
|
20938
21362
|
return { checked: true, found: true, serviceName, note: `Keychain service name for this identity: "${serviceName}".` };
|
|
20939
21363
|
}
|
|
20940
|
-
var SettingsSecretsShapeSchema =
|
|
20941
|
-
env:
|
|
20942
|
-
hooks:
|
|
21364
|
+
var SettingsSecretsShapeSchema = z32.looseObject({
|
|
21365
|
+
env: z32.record(z32.string(), z32.unknown()).optional(),
|
|
21366
|
+
hooks: z32.record(z32.string(), z32.array(z32.unknown())).optional()
|
|
20943
21367
|
});
|
|
20944
21368
|
function hookCommandCountOf(group) {
|
|
20945
21369
|
if (typeof group !== "object" || group === null) {
|
|
@@ -21219,10 +21643,10 @@ function collectCheckReport(params) {
|
|
|
21219
21643
|
const providerName = cascadeProviderName(cascade, identityConfig?.provider);
|
|
21220
21644
|
const provider = providerName === void 0 ? void 0 : loadCheckProvider(paths, providerName);
|
|
21221
21645
|
const identityId = identityDecision.name === void 0 ? void 0 : identityIdOf(paths, identityDecision.name);
|
|
21222
|
-
const farmRoot = identityId === void 0 ? void 0 :
|
|
21646
|
+
const farmRoot = identityId === void 0 ? void 0 : path41.join(paths.identitiesDir, identityId);
|
|
21223
21647
|
const settingsFiles = isCodex ? {} : {
|
|
21224
|
-
"settings.json": realFsPort.readFileUtf8(
|
|
21225
|
-
"settings.local.json": realFsPort.readFileUtf8(
|
|
21648
|
+
"settings.json": realFsPort.readFileUtf8(path41.join(claudeHome, "settings.json")),
|
|
21649
|
+
"settings.local.json": realFsPort.readFileUtf8(path41.join(claudeHome, "settings.local.json"))
|
|
21226
21650
|
};
|
|
21227
21651
|
const report = runCheck({
|
|
21228
21652
|
...isCodex ? { agent: "codex" } : {},
|
|
@@ -21269,6 +21693,31 @@ function pushKeychainFindings(push, platform, run, identities, agentOf) {
|
|
|
21269
21693
|
}
|
|
21270
21694
|
}
|
|
21271
21695
|
|
|
21696
|
+
// src/doctorFarmLinks.ts
|
|
21697
|
+
function remedy(agent, name, rel) {
|
|
21698
|
+
if (agent === "codex") {
|
|
21699
|
+
return `Codex cannot write through it. A launch with \`agent-shim run --agent codex @${name}\` resyncs the farm and leaves the link out.`;
|
|
21700
|
+
}
|
|
21701
|
+
const lost = rel === "sessions" ? " (an interactive session's record under sessions/ is lost, so the session is missing from `claude agents`)" : "";
|
|
21702
|
+
return `Claude Code cannot write through it${lost}. A launch through agent-shim resyncs the farm and leaves the link out, but a session started with this directory as CLAUDE_CONFIG_DIR does not. Run \`agent-shim identity resync ${name}\` in the directory those sessions start in to bring the farm up to date without launching.`;
|
|
21703
|
+
}
|
|
21704
|
+
function pushFarmLinkFindings(push, farms, agentOf) {
|
|
21705
|
+
let found = false;
|
|
21706
|
+
for (const farm of farms) {
|
|
21707
|
+
for (const link of farm.dangling) {
|
|
21708
|
+
found = true;
|
|
21709
|
+
const points = link.target === void 0 ? "" : ` to ${link.target}`;
|
|
21710
|
+
push("farm-links", "warn", `identities/${farm.id}/${link.rel} is a farm link${points} that leads nowhere, so ${remedy(agentOf.get(farm.name) ?? "claude", farm.name, link.rel)}`, farm.name);
|
|
21711
|
+
}
|
|
21712
|
+
}
|
|
21713
|
+
if (!found) {
|
|
21714
|
+
push("farm-links", "pass", "Every identity's farm links lead somewhere.");
|
|
21715
|
+
}
|
|
21716
|
+
}
|
|
21717
|
+
|
|
21718
|
+
// src/doctorReport.ts
|
|
21719
|
+
init_farm();
|
|
21720
|
+
|
|
21272
21721
|
// src/frontdoor/catalogueFailures.ts
|
|
21273
21722
|
init_state();
|
|
21274
21723
|
init_catalogueState();
|
|
@@ -21678,6 +22127,7 @@ var DOCTOR_SECTIONS = [
|
|
|
21678
22127
|
"config-profile",
|
|
21679
22128
|
"identity",
|
|
21680
22129
|
"sign-in",
|
|
22130
|
+
"farm-links",
|
|
21681
22131
|
"pool",
|
|
21682
22132
|
"provider",
|
|
21683
22133
|
"keychain",
|
|
@@ -21723,7 +22173,7 @@ function tcpPortEraRecord(raw) {
|
|
|
21723
22173
|
return (has("port") || has("lastPort")) && !has("socketPath");
|
|
21724
22174
|
}
|
|
21725
22175
|
function pushPathResolution(push, resolution) {
|
|
21726
|
-
const ownDir =
|
|
22176
|
+
const ownDir = path44.dirname(resolution.ownExecutablePath);
|
|
21727
22177
|
switch (resolution.agentShim.status) {
|
|
21728
22178
|
case "ok":
|
|
21729
22179
|
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
@@ -21843,14 +22293,14 @@ function pushProvider(push, entry, cacheEnv, signIn, unreachable) {
|
|
|
21843
22293
|
}
|
|
21844
22294
|
function pushLegacyName(push, params) {
|
|
21845
22295
|
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
21846
|
-
if (legacyVariables.length === 0 &&
|
|
22296
|
+
if (legacyVariables.length === 0 && path44.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
21847
22297
|
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
21848
22298
|
return;
|
|
21849
22299
|
}
|
|
21850
22300
|
for (const name of legacyVariables) {
|
|
21851
22301
|
push("legacy-name", "warn", `${name} is the former name of ${name.replace(LEGACY_ENV_PREFIX, ENV_PREFIX)}. Rename it; the old name still works but is only a fallback.`, name);
|
|
21852
22302
|
}
|
|
21853
|
-
if (
|
|
22303
|
+
if (path44.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
21854
22304
|
push(
|
|
21855
22305
|
"legacy-name",
|
|
21856
22306
|
"warn",
|
|
@@ -21940,7 +22390,7 @@ function runDoctor(params) {
|
|
|
21940
22390
|
push("identity", "warn", `identities/${name} cannot be reached (${code}), so it is not counted as an identity. Repair the permissions of the directory or of what a symlink points through, or remove the entry.`, name);
|
|
21941
22391
|
}
|
|
21942
22392
|
for (const { file, detail } of params.renameJournals?.unreadable ?? []) {
|
|
21943
|
-
push("identity", "fail", `${file} is not a rename journal this agent-shim can read (${detail}), so no identity can be renamed until it is fixed or removed, and it may be the trace of a rename that was left unfinished.`,
|
|
22393
|
+
push("identity", "fail", `${file} is not a rename journal this agent-shim can read (${detail}), so no identity can be renamed until it is fixed or removed, and it may be the trace of a rename that was left unfinished.`, path44.basename(file));
|
|
21944
22394
|
}
|
|
21945
22395
|
const validIdentityAgents = /* @__PURE__ */ new Map();
|
|
21946
22396
|
const signedInAccounts = [];
|
|
@@ -22076,6 +22526,9 @@ function runDoctor(params) {
|
|
|
22076
22526
|
push("provider", finding.level, finding.message, finding.alias);
|
|
22077
22527
|
}
|
|
22078
22528
|
pushKeychainFindings(push, params.platform, params.run, params.identities, validIdentityAgents);
|
|
22529
|
+
if (params.farmLinks !== void 0) {
|
|
22530
|
+
pushFarmLinkFindings(push, params.farmLinks, validIdentityAgents);
|
|
22531
|
+
}
|
|
22079
22532
|
if (params.directoryRules.raw === void 0) {
|
|
22080
22533
|
push("directory-rules", "pass", "No directory-rules.json configured.");
|
|
22081
22534
|
} else {
|
|
@@ -22225,73 +22678,6 @@ function runDoctor(params) {
|
|
|
22225
22678
|
}
|
|
22226
22679
|
return { findings, ok: !findings.some((finding) => finding.severity === "fail") };
|
|
22227
22680
|
}
|
|
22228
|
-
var SECTION_TITLES = {
|
|
22229
|
-
models: "Virtual models",
|
|
22230
|
-
"ambient-credential": "Ambient-credential exposure",
|
|
22231
|
-
"binary-discovery": "Claude Code binary discovery",
|
|
22232
|
-
"claude-shim": "`claude` command shim",
|
|
22233
|
-
"path-resolution": "PATH resolution",
|
|
22234
|
-
"legacy-name": "Former `claude-use` name",
|
|
22235
|
-
"config-profile": "Configuration profiles",
|
|
22236
|
-
identity: "Identities",
|
|
22237
|
-
"sign-in": "Sign-in",
|
|
22238
|
-
pool: "Pools",
|
|
22239
|
-
provider: "Providers",
|
|
22240
|
-
keychain: "macOS Keychain",
|
|
22241
|
-
"directory-rules": "Directory rules",
|
|
22242
|
-
"global-config": "Global config",
|
|
22243
|
-
headroom: "Headroom daemon",
|
|
22244
|
-
frontdoor: "Front door",
|
|
22245
|
-
"categories-local": "categories.local.json",
|
|
22246
|
-
"active-identity": "Active identity"
|
|
22247
|
-
};
|
|
22248
|
-
var SECTION_ORDER = [
|
|
22249
|
-
"ambient-credential",
|
|
22250
|
-
"binary-discovery",
|
|
22251
|
-
"claude-shim",
|
|
22252
|
-
"path-resolution",
|
|
22253
|
-
"config-profile",
|
|
22254
|
-
"identity",
|
|
22255
|
-
"sign-in",
|
|
22256
|
-
"pool",
|
|
22257
|
-
"provider",
|
|
22258
|
-
"keychain",
|
|
22259
|
-
"directory-rules",
|
|
22260
|
-
"global-config",
|
|
22261
|
-
"headroom",
|
|
22262
|
-
"frontdoor",
|
|
22263
|
-
"categories-local",
|
|
22264
|
-
"active-identity"
|
|
22265
|
-
];
|
|
22266
|
-
function severityPrefix(severity) {
|
|
22267
|
-
switch (severity) {
|
|
22268
|
-
case "pass":
|
|
22269
|
-
return "[PASS]";
|
|
22270
|
-
case "warn":
|
|
22271
|
-
return "[WARN]";
|
|
22272
|
-
case "fail":
|
|
22273
|
-
return "[FAIL]";
|
|
22274
|
-
default:
|
|
22275
|
-
return severity;
|
|
22276
|
-
}
|
|
22277
|
-
}
|
|
22278
|
-
function formatDoctorReport(report) {
|
|
22279
|
-
const lines = [];
|
|
22280
|
-
for (const section of SECTION_ORDER) {
|
|
22281
|
-
const sectionFindings = report.findings.filter((finding) => finding.section === section);
|
|
22282
|
-
if (sectionFindings.length === 0) {
|
|
22283
|
-
continue;
|
|
22284
|
-
}
|
|
22285
|
-
lines.push("", `${SECTION_TITLES[section]}:`);
|
|
22286
|
-
for (const finding of sectionFindings) {
|
|
22287
|
-
const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
|
|
22288
|
-
lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
|
|
22289
|
-
}
|
|
22290
|
-
}
|
|
22291
|
-
const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
|
|
22292
|
-
lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
|
|
22293
|
-
return lines;
|
|
22294
|
-
}
|
|
22295
22681
|
function servingDoorListeners(paths) {
|
|
22296
22682
|
const state = readFrontDoorState(realFarmFs, paths.frontdoorStateFile) ?? {};
|
|
22297
22683
|
const alive = state.supervisorPid !== void 0 && realIsProcessRunning(state.supervisorPid);
|
|
@@ -22302,9 +22688,9 @@ function collectDoctorReport(params) {
|
|
|
22302
22688
|
const { names: identityNames, unreachable: unreachableIdentities } = listIdentityDirectories(paths);
|
|
22303
22689
|
const records = identityRecords(paths);
|
|
22304
22690
|
const displacedIdentities = records.filter((record) => !identityIdExists(paths, record.id) && !unreachableIdentities.some((entry) => entry.name === record.id));
|
|
22305
|
-
const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !fs14.existsSync(
|
|
22306
|
-
const farmRoot =
|
|
22307
|
-
const identityPath =
|
|
22691
|
+
const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !fs14.existsSync(path44.join(paths.identitiesDir, id, "identity.json"))) && !displacedIdentities.some((record) => record.id === id)).map((id) => {
|
|
22692
|
+
const farmRoot = path44.join(paths.identitiesDir, id);
|
|
22693
|
+
const identityPath = path44.join(farmRoot, "identity.json");
|
|
22308
22694
|
return { name: identityNameIn(records, id) ?? id, id, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: fs14.existsSync(credentialsFilePath(farmRoot)), account: readIdentityAccount(realFsPort, paths.identitiesDir, id)?.account };
|
|
22309
22695
|
});
|
|
22310
22696
|
const usageSnapshots = {};
|
|
@@ -22322,12 +22708,12 @@ function collectDoctorReport(params) {
|
|
|
22322
22708
|
}
|
|
22323
22709
|
const profileNames = fs14.existsSync(paths.configProfilesDir) ? fs14.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
22324
22710
|
const configProfiles = profileNames.map((name) => {
|
|
22325
|
-
const profilePath =
|
|
22711
|
+
const profilePath = path44.join(paths.configProfilesDir, `${name}.json`);
|
|
22326
22712
|
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
22327
22713
|
});
|
|
22328
22714
|
const providerNames = fs14.existsSync(paths.providersDir) ? fs14.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
22329
22715
|
const providers = providerNames.map((name) => {
|
|
22330
|
-
const providerPath =
|
|
22716
|
+
const providerPath = path44.join(paths.providersDir, `${name}.json`);
|
|
22331
22717
|
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
22332
22718
|
});
|
|
22333
22719
|
const ownExecutablePath = realOwnExecutablePath();
|
|
@@ -22339,12 +22725,12 @@ function collectDoctorReport(params) {
|
|
|
22339
22725
|
binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
|
|
22340
22726
|
}
|
|
22341
22727
|
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
22342
|
-
const pathDirs = (params.env.PATH ?? "").split(
|
|
22728
|
+
const pathDirs = (params.env.PATH ?? "").split(path44.delimiter).filter((dir) => dir !== "");
|
|
22343
22729
|
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
22344
22730
|
findPathShadow({
|
|
22345
22731
|
pathDirs,
|
|
22346
|
-
targetDir:
|
|
22347
|
-
targetFilename:
|
|
22732
|
+
targetDir: path44.dirname(shimState.targetPath),
|
|
22733
|
+
targetFilename: path44.basename(shimState.targetPath),
|
|
22348
22734
|
findExecutableInDir
|
|
22349
22735
|
}),
|
|
22350
22736
|
shimState.targetPath,
|
|
@@ -22364,6 +22750,7 @@ function collectDoctorReport(params) {
|
|
|
22364
22750
|
chatgptSignIn: { path: paths.chatgptSignInFile, raw: realFsPort.readFileUtf8(paths.chatgptSignInFile) },
|
|
22365
22751
|
installedClaudeVersions: realInstalledClaudeVersions(),
|
|
22366
22752
|
identities,
|
|
22753
|
+
farmLinks: identities.map(({ name, id, farmRoot }) => ({ name, id, dangling: danglingFarmLinks(realFarmFs, farmRoot) })),
|
|
22367
22754
|
usageSnapshots,
|
|
22368
22755
|
configProfiles,
|
|
22369
22756
|
providers,
|
|
@@ -22372,7 +22759,7 @@ function collectDoctorReport(params) {
|
|
|
22372
22759
|
catalogueRedirects: providersWithRedirectedCatalogue(realFarmFs, paths, new Map(providers.map((entry) => [entry.name, currentCatalogueSettings(paths, entry.name)]))),
|
|
22373
22760
|
renameJournals: listRenameJournals(realFarmFs, paths.identityRenamesDir),
|
|
22374
22761
|
unreachableIdentities,
|
|
22375
|
-
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: fs14.existsSync(
|
|
22762
|
+
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: fs14.existsSync(path44.join(paths.identitiesDir, record.id)) })), nameRenames: unfinishedNameRenames(paths).map((record) => ({ from: record.from, description: describeInterruptedNameRename(paths, record) })), strayNameRenameFiles: strayNameRenameRecordFiles(paths) },
|
|
22376
22763
|
directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
|
|
22377
22764
|
globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
|
|
22378
22765
|
models: readableOr(() => readGlobalConfig(paths)?.models, void 0),
|
|
@@ -22387,7 +22774,7 @@ function collectDoctorReport(params) {
|
|
|
22387
22774
|
agentShim: refinePathShadow(
|
|
22388
22775
|
findPathShadow({
|
|
22389
22776
|
pathDirs,
|
|
22390
|
-
targetDir:
|
|
22777
|
+
targetDir: path44.dirname(ownExecutablePath),
|
|
22391
22778
|
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
22392
22779
|
findExecutableInDir
|
|
22393
22780
|
}),
|
|
@@ -22430,93 +22817,93 @@ function collectDoctorReport(params) {
|
|
|
22430
22817
|
init_schema2();
|
|
22431
22818
|
init_rcSchemas();
|
|
22432
22819
|
init_state();
|
|
22433
|
-
var UsageListOutputSchema =
|
|
22434
|
-
var UsageWindowsInputSchema =
|
|
22435
|
-
identity:
|
|
22436
|
-
provider:
|
|
22820
|
+
var UsageListOutputSchema = z39.strictObject({ snapshots: z39.readonly(z39.array(UsageSnapshotSchema)) });
|
|
22821
|
+
var UsageWindowsInputSchema = z39.strictObject({
|
|
22822
|
+
identity: z39.string().min(1),
|
|
22823
|
+
provider: z39.string().min(1).optional()
|
|
22437
22824
|
});
|
|
22438
|
-
var EffectiveWindowSchema =
|
|
22825
|
+
var EffectiveWindowSchema = z39.strictObject({
|
|
22439
22826
|
/** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
|
|
22440
|
-
reset:
|
|
22827
|
+
reset: z39.boolean(),
|
|
22441
22828
|
/** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
|
|
22442
|
-
utilization:
|
|
22829
|
+
utilization: z39.number().optional(),
|
|
22443
22830
|
/** The reset instant, for a window that has not reset yet and reported one. */
|
|
22444
|
-
resetsAtMs:
|
|
22831
|
+
resetsAtMs: z39.number().optional(),
|
|
22445
22832
|
/** The window's own status, for a window that has not reset yet. */
|
|
22446
|
-
status:
|
|
22833
|
+
status: z39.string().optional()
|
|
22447
22834
|
});
|
|
22448
|
-
var UsageWindowsOutputSchema =
|
|
22449
|
-
identity:
|
|
22450
|
-
provider:
|
|
22835
|
+
var UsageWindowsOutputSchema = z39.strictObject({
|
|
22836
|
+
identity: z39.string(),
|
|
22837
|
+
provider: z39.string(),
|
|
22451
22838
|
/** When the rate-limit state the windows come from was observed. */
|
|
22452
|
-
observedAt:
|
|
22839
|
+
observedAt: z39.iso.datetime().optional(),
|
|
22453
22840
|
fiveHour: EffectiveWindowSchema.optional(),
|
|
22454
22841
|
sevenDay: EffectiveWindowSchema.optional()
|
|
22455
22842
|
});
|
|
22456
|
-
var UsageLiveOutputSchema =
|
|
22843
|
+
var UsageLiveOutputSchema = z39.strictObject({
|
|
22457
22844
|
/** The freshest observation the door holds, never narrowed by the read's session filter because it is the door's single latest statement of the account's quota; absent while no rate_limit_event has been filed at all. */
|
|
22458
22845
|
latest: RcLiveRateLimitSchema.optional(),
|
|
22459
22846
|
/** One observation per session whose stream has filed a rate_limit_event this door generation. */
|
|
22460
|
-
sessions:
|
|
22847
|
+
sessions: z39.readonly(z39.array(RcLiveRateLimitSchema))
|
|
22461
22848
|
});
|
|
22462
|
-
var FrontDoorSessionStatusSchema =
|
|
22463
|
-
pid:
|
|
22464
|
-
startedAt:
|
|
22465
|
-
alive:
|
|
22849
|
+
var FrontDoorSessionStatusSchema = z39.strictObject({
|
|
22850
|
+
pid: z39.int().positive(),
|
|
22851
|
+
startedAt: z39.number(),
|
|
22852
|
+
alive: z39.boolean()
|
|
22466
22853
|
});
|
|
22467
|
-
var HeadroomSocketTargetSchema =
|
|
22468
|
-
var FrontDoorStatusOutputSchema =
|
|
22854
|
+
var HeadroomSocketTargetSchema = z39.union([z39.strictObject({ socketPath: z39.string() }), z39.strictObject({ refused: z39.string() })]);
|
|
22855
|
+
var FrontDoorStatusOutputSchema = z39.strictObject({
|
|
22469
22856
|
state: FrontDoorStateSchema,
|
|
22470
|
-
supervisorAlive:
|
|
22857
|
+
supervisorAlive: z39.boolean(),
|
|
22471
22858
|
/** The pids of earlier doors that released their addresses and are finishing the connections they carried: running, but not serving anything new. */
|
|
22472
|
-
draining:
|
|
22473
|
-
sessions:
|
|
22859
|
+
draining: z39.readonly(z39.array(z39.number().int().positive())),
|
|
22860
|
+
sessions: z39.readonly(z39.array(FrontDoorSessionStatusSchema)),
|
|
22474
22861
|
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
22475
|
-
logPath:
|
|
22476
|
-
logExists:
|
|
22862
|
+
logPath: z39.string(),
|
|
22863
|
+
logExists: z39.boolean()
|
|
22477
22864
|
});
|
|
22478
|
-
var FrontDoorSessionsOutputSchema =
|
|
22865
|
+
var FrontDoorSessionsOutputSchema = z39.strictObject({ sessions: z39.readonly(z39.array(FrontDoorSessionStatusSchema)) });
|
|
22479
22866
|
var DOOR_REPORT_ENVIRONMENT_NOTE = "The report is collected in a worker thread of the door under the door's own environment and PATH, as a launch the door plans for itself would inherit them, not under the caller's shell: the identity is the caller's to name, the cascade is read from files at the path, and the environment-driven findings (AGENT_SHIM_IDENTITY, AGENT_SHIM_CONFIG_PROFILE, the Claude Code version pin, the ambient-credential check, and for doctor the PATH and shim findings) describe the door's launch. Run agent-shim check or agent-shim doctor from a shell for the caller's own reading.";
|
|
22480
|
-
var CheckRunInputSchema =
|
|
22481
|
-
path:
|
|
22482
|
-
identity:
|
|
22483
|
-
}).refine((input) =>
|
|
22484
|
-
var PoolPickInputSchema =
|
|
22485
|
-
pool:
|
|
22486
|
-
path:
|
|
22487
|
-
}).refine((input) =>
|
|
22488
|
-
var DoctorFindingSchema =
|
|
22489
|
-
section:
|
|
22490
|
-
subject:
|
|
22491
|
-
severity:
|
|
22492
|
-
message:
|
|
22493
|
-
});
|
|
22494
|
-
var DoctorRunOutputSchema =
|
|
22867
|
+
var CheckRunInputSchema = z39.strictObject({
|
|
22868
|
+
path: z39.string().min(1),
|
|
22869
|
+
identity: z39.string().min(1).optional()
|
|
22870
|
+
}).refine((input) => path45.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
22871
|
+
var PoolPickInputSchema = z39.strictObject({
|
|
22872
|
+
pool: z39.string().min(1),
|
|
22873
|
+
path: z39.string().min(1)
|
|
22874
|
+
}).refine((input) => path45.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
22875
|
+
var DoctorFindingSchema = z39.strictObject({
|
|
22876
|
+
section: z39.enum(DOCTOR_SECTIONS),
|
|
22877
|
+
subject: z39.string().optional(),
|
|
22878
|
+
severity: z39.enum(DOCTOR_SEVERITIES),
|
|
22879
|
+
message: z39.string()
|
|
22880
|
+
});
|
|
22881
|
+
var DoctorRunOutputSchema = z39.strictObject({
|
|
22495
22882
|
/** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
|
|
22496
|
-
ok:
|
|
22497
|
-
findings:
|
|
22498
|
-
});
|
|
22499
|
-
var FrontDoorRestartOutputSchema =
|
|
22500
|
-
action:
|
|
22501
|
-
previousPid:
|
|
22502
|
-
});
|
|
22503
|
-
var UpdateCheckOutputSchema =
|
|
22504
|
-
current:
|
|
22505
|
-
latest:
|
|
22506
|
-
action:
|
|
22507
|
-
});
|
|
22508
|
-
var CodexSignInSchema =
|
|
22509
|
-
|
|
22510
|
-
|
|
22511
|
-
|
|
22883
|
+
ok: z39.boolean(),
|
|
22884
|
+
findings: z39.readonly(z39.array(DoctorFindingSchema))
|
|
22885
|
+
});
|
|
22886
|
+
var FrontDoorRestartOutputSchema = z39.strictObject({
|
|
22887
|
+
action: z39.literal("restarting"),
|
|
22888
|
+
previousPid: z39.int().positive()
|
|
22889
|
+
});
|
|
22890
|
+
var UpdateCheckOutputSchema = z39.strictObject({
|
|
22891
|
+
current: z39.string(),
|
|
22892
|
+
latest: z39.string(),
|
|
22893
|
+
action: z39.enum(["current", "available", "updated"])
|
|
22894
|
+
});
|
|
22895
|
+
var CodexSignInSchema = z39.discriminatedUnion("state", [
|
|
22896
|
+
z39.strictObject({ state: z39.literal("none") }),
|
|
22897
|
+
z39.strictObject({ state: z39.literal("signed-in"), email: z39.string().optional(), planScope: z39.boolean(), accessTokenExpiresAt: z39.number() }),
|
|
22898
|
+
z39.strictObject({ state: z39.literal("unreadable"), message: z39.string() })
|
|
22512
22899
|
]);
|
|
22513
|
-
var CodexStatusOutputSchema =
|
|
22900
|
+
var CodexStatusOutputSchema = z39.strictObject({
|
|
22514
22901
|
signIn: CodexSignInSchema,
|
|
22515
|
-
codexProviders:
|
|
22902
|
+
codexProviders: z39.readonly(z39.array(z39.string()))
|
|
22516
22903
|
});
|
|
22517
|
-
var CodexLogoutOutputSchema =
|
|
22518
|
-
hadGrant:
|
|
22519
|
-
revoked:
|
|
22904
|
+
var CodexLogoutOutputSchema = z39.strictObject({
|
|
22905
|
+
hadGrant: z39.boolean(),
|
|
22906
|
+
revoked: z39.boolean()
|
|
22520
22907
|
});
|
|
22521
22908
|
|
|
22522
22909
|
// src/frontdoor/codexApi.ts
|
|
@@ -22537,21 +22924,21 @@ function createCodexApiRouter(deps) {
|
|
|
22537
22924
|
|
|
22538
22925
|
// src/frontdoor/doorWorker.ts
|
|
22539
22926
|
import { getAsset, isSea as isSea2 } from "node:sea";
|
|
22540
|
-
import { z as
|
|
22927
|
+
import { z as z41 } from "zod";
|
|
22541
22928
|
init_cliError();
|
|
22542
22929
|
init_doorBounds();
|
|
22543
22930
|
init_providerCatalogue();
|
|
22544
22931
|
|
|
22545
22932
|
// src/frontdoor/doorWorkerProtocol.ts
|
|
22546
22933
|
init_providerCatalogue();
|
|
22547
|
-
import { z as
|
|
22934
|
+
import { z as z40 } from "zod";
|
|
22548
22935
|
var doorWorkerInputSchemas = {
|
|
22549
22936
|
/** `agent-shim check` for `path` as `identity` (the identity a launch there would resolve when absent). */
|
|
22550
|
-
check:
|
|
22937
|
+
check: z40.strictObject({ root: z40.string().min(1), path: z40.string().min(1), identity: z40.string().min(1).optional() }),
|
|
22551
22938
|
/** `agent-shim doctor`. */
|
|
22552
|
-
doctor:
|
|
22939
|
+
doctor: z40.strictObject({ root: z40.string().min(1) }),
|
|
22553
22940
|
/** Fetch and store one provider's model catalogue for the door generation that asked. */
|
|
22554
|
-
"refresh-catalogue":
|
|
22941
|
+
"refresh-catalogue": z40.strictObject({ root: z40.string().min(1), name: z40.string().min(1), supervisorPid: z40.int().positive(), generation: z40.uuid() })
|
|
22555
22942
|
};
|
|
22556
22943
|
|
|
22557
22944
|
// src/frontdoor/doorWorker.ts
|
|
@@ -22645,68 +23032,68 @@ init_schema();
|
|
|
22645
23032
|
init_names();
|
|
22646
23033
|
init_keychainLogin();
|
|
22647
23034
|
init_statusline();
|
|
22648
|
-
import { z as
|
|
22649
|
-
var RemovalConfirmationSchema =
|
|
22650
|
-
var CredentialWriteSchema = (targets) =>
|
|
22651
|
-
sources:
|
|
22652
|
-
target:
|
|
22653
|
-
cache:
|
|
22654
|
-
});
|
|
22655
|
-
var CredentialSummarySchema2 =
|
|
22656
|
-
target:
|
|
22657
|
-
sources:
|
|
22658
|
-
|
|
22659
|
-
|
|
22660
|
-
|
|
22661
|
-
|
|
22662
|
-
|
|
22663
|
-
|
|
22664
|
-
|
|
23035
|
+
import { z as z42 } from "zod";
|
|
23036
|
+
var RemovalConfirmationSchema = z42.boolean();
|
|
23037
|
+
var CredentialWriteSchema = (targets) => z42.strictObject({
|
|
23038
|
+
sources: z42.array(RemoteCredentialSourceSchema).min(1).optional(),
|
|
23039
|
+
target: z42.enum(targets).optional(),
|
|
23040
|
+
cache: z42.union([z42.literal(false), CredentialCacheSchema]).optional()
|
|
23041
|
+
});
|
|
23042
|
+
var CredentialSummarySchema2 = z42.strictObject({
|
|
23043
|
+
target: z42.enum(CREDENTIAL_TARGETS),
|
|
23044
|
+
sources: z42.readonly(z42.array(
|
|
23045
|
+
z42.discriminatedUnion("kind", [
|
|
23046
|
+
z42.strictObject({ kind: z42.literal("env"), variable: z42.string() }),
|
|
23047
|
+
z42.strictObject({ kind: z42.literal("file"), path: z42.string() }),
|
|
23048
|
+
z42.strictObject({ kind: z42.literal("command"), program: z42.string() }),
|
|
23049
|
+
z42.strictObject({ kind: z42.literal("op"), reference: z42.string() }),
|
|
23050
|
+
z42.strictObject({ kind: z42.literal("keychain"), service: z42.string(), account: z42.string().optional() }),
|
|
23051
|
+
z42.strictObject({ kind: z42.literal("literal") })
|
|
22665
23052
|
])
|
|
22666
23053
|
)),
|
|
22667
23054
|
cache: CredentialCacheSchema.optional()
|
|
22668
23055
|
});
|
|
22669
|
-
var mutationOutput = (kind, action) =>
|
|
22670
|
-
var storedMutationOutput = (kind, action, value) =>
|
|
22671
|
-
var IdentityValueSchema =
|
|
22672
|
-
agent:
|
|
22673
|
-
name:
|
|
22674
|
-
label:
|
|
22675
|
-
defaultConfigProfile:
|
|
22676
|
-
provider:
|
|
22677
|
-
allowAmbientCredential:
|
|
23056
|
+
var mutationOutput = (kind, action) => z42.strictObject({ action: z42.literal(action), kind: z42.literal(kind), name: z42.string() });
|
|
23057
|
+
var storedMutationOutput = (kind, action, value) => z42.strictObject({ action: z42.literal(action), kind: z42.literal(kind), name: z42.string(), value });
|
|
23058
|
+
var IdentityValueSchema = z42.strictObject({
|
|
23059
|
+
agent: z42.enum(["claude", "codex"]).optional(),
|
|
23060
|
+
name: z42.string(),
|
|
23061
|
+
label: z42.string().optional(),
|
|
23062
|
+
defaultConfigProfile: z42.string().optional(),
|
|
23063
|
+
provider: z42.string().optional(),
|
|
23064
|
+
allowAmbientCredential: z42.boolean(),
|
|
22678
23065
|
credential: CredentialSummarySchema2.optional(),
|
|
22679
|
-
anchors:
|
|
23066
|
+
anchors: z42.array(AnchorSchema).optional()
|
|
22680
23067
|
});
|
|
22681
23068
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
22682
|
-
var ProviderValueSchema =
|
|
22683
|
-
name:
|
|
22684
|
-
kind:
|
|
22685
|
-
displayName:
|
|
22686
|
-
baseUrl:
|
|
23069
|
+
var ProviderValueSchema = z42.strictObject({
|
|
23070
|
+
name: z42.string(),
|
|
23071
|
+
kind: z42.enum(PROVIDER_KINDS),
|
|
23072
|
+
displayName: z42.string(),
|
|
23073
|
+
baseUrl: z42.string().optional(),
|
|
22687
23074
|
codex: CodexProviderConfigSchema.optional(),
|
|
22688
23075
|
credential: CredentialSummarySchema2.optional(),
|
|
22689
|
-
env:
|
|
23076
|
+
env: z42.record(z42.string(), z42.string()).optional()
|
|
22690
23077
|
});
|
|
22691
|
-
var ConfigNameInputSchema =
|
|
22692
|
-
var ConfigIdentityAddInputSchema =
|
|
23078
|
+
var ConfigNameInputSchema = z42.strictObject({ name: z42.string().min(1) });
|
|
23079
|
+
var ConfigIdentityAddInputSchema = z42.strictObject({ name: z42.string().min(1), keepKeychainLogin: z42.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
|
|
22693
23080
|
var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
|
|
22694
|
-
var ConfigIdentitySetInputSchema =
|
|
22695
|
-
name:
|
|
23081
|
+
var ConfigIdentitySetInputSchema = z42.strictObject({
|
|
23082
|
+
name: z42.string().min(1),
|
|
22696
23083
|
/** The identity's display label; `false` clears it. */
|
|
22697
|
-
label:
|
|
22698
|
-
defaultConfigProfile:
|
|
23084
|
+
label: z42.union([IdentityLabelSchema, z42.literal(false)]).optional(),
|
|
23085
|
+
defaultConfigProfile: z42.union([z42.string().min(1), z42.literal(false)]).optional(),
|
|
22699
23086
|
/** The provider the identity exists for; `false` clears it. */
|
|
22700
|
-
provider:
|
|
22701
|
-
allowAmbientCredential:
|
|
22702
|
-
credential:
|
|
23087
|
+
provider: z42.union([z42.string().min(1), z42.literal(false)]).optional(),
|
|
23088
|
+
allowAmbientCredential: z42.boolean().optional(),
|
|
23089
|
+
credential: z42.union([z42.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
|
|
22703
23090
|
/** `false` removes the anchors; a list replaces them. */
|
|
22704
|
-
anchors:
|
|
23091
|
+
anchors: z42.union([z42.literal(false), z42.array(AnchorSchema).min(1)]).optional()
|
|
22705
23092
|
});
|
|
22706
23093
|
var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
|
|
22707
|
-
var ConfigIdentityRemoveInputSchema =
|
|
23094
|
+
var ConfigIdentityRemoveInputSchema = z42.strictObject({ name: z42.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22708
23095
|
var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
|
|
22709
|
-
var ConfigStatuslineSetSchema =
|
|
23096
|
+
var ConfigStatuslineSetSchema = z42.record(z42.string(), z42.unknown()).superRefine((settings, context) => {
|
|
22710
23097
|
for (const key of Object.keys(settings)) {
|
|
22711
23098
|
if (key === STATUSLINE_EXTRA_GROUP || key.startsWith(`${STATUSLINE_EXTRA_GROUP}.`)) {
|
|
22712
23099
|
context.addIssue({ code: "custom", path: [key], message: `a config write through the API cannot set "${key}": the extra segment's command runs a program, so only your own configuration (the global config, a profile you edit yourself, a directory rule or a command-line assignment) may set it` });
|
|
@@ -22714,93 +23101,93 @@ var ConfigStatuslineSetSchema = z41.record(z41.string(), z41.unknown()).superRef
|
|
|
22714
23101
|
}
|
|
22715
23102
|
});
|
|
22716
23103
|
var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
|
|
22717
|
-
var ConfigProfileAddInputSchema =
|
|
22718
|
-
name:
|
|
22719
|
-
extends:
|
|
22720
|
-
description:
|
|
23104
|
+
var ConfigProfileAddInputSchema = z42.strictObject({
|
|
23105
|
+
name: z42.string().min(1),
|
|
23106
|
+
extends: z42.array(z42.string().min(1)).optional(),
|
|
23107
|
+
description: z42.string().optional()
|
|
22721
23108
|
});
|
|
22722
23109
|
var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
|
|
22723
|
-
var ConfigProfileSetInputSchema =
|
|
22724
|
-
name:
|
|
22725
|
-
category:
|
|
22726
|
-
entry:
|
|
22727
|
-
extends:
|
|
22728
|
-
description:
|
|
22729
|
-
launch:
|
|
22730
|
-
skipPermissions:
|
|
22731
|
-
remoteControl:
|
|
22732
|
-
headroom:
|
|
22733
|
-
trackUsage:
|
|
22734
|
-
provider:
|
|
22735
|
-
claudeVersion:
|
|
22736
|
-
delay:
|
|
22737
|
-
pause:
|
|
22738
|
-
explain:
|
|
22739
|
-
proxyBypass:
|
|
22740
|
-
statusline:
|
|
23110
|
+
var ConfigProfileSetInputSchema = z42.strictObject({
|
|
23111
|
+
name: z42.string().min(1),
|
|
23112
|
+
category: z42.record(z42.string(), z42.boolean()).optional(),
|
|
23113
|
+
entry: z42.record(z42.string(), z42.boolean()).optional(),
|
|
23114
|
+
extends: z42.union([z42.array(z42.string().min(1)), z42.literal(false)]).optional(),
|
|
23115
|
+
description: z42.union([z42.string(), z42.literal(false)]).optional(),
|
|
23116
|
+
launch: z42.strictObject({
|
|
23117
|
+
skipPermissions: z42.boolean().optional(),
|
|
23118
|
+
remoteControl: z42.boolean().optional(),
|
|
23119
|
+
headroom: z42.boolean().optional(),
|
|
23120
|
+
trackUsage: z42.boolean().optional(),
|
|
23121
|
+
provider: z42.union([z42.string().min(1), z42.literal(false)]).optional(),
|
|
23122
|
+
claudeVersion: z42.union([z42.string().min(1), z42.literal(false)]).optional(),
|
|
23123
|
+
delay: z42.union([z42.string().regex(DURATION_RE), z42.literal(false)]).optional(),
|
|
23124
|
+
pause: z42.boolean().optional(),
|
|
23125
|
+
explain: z42.boolean().optional(),
|
|
23126
|
+
proxyBypass: z42.union([z42.array(z42.string().min(1)), z42.literal(false)]).optional(),
|
|
23127
|
+
statusline: z42.strictObject({
|
|
22741
23128
|
set: ConfigStatuslineSetSchema.optional(),
|
|
22742
|
-
unset:
|
|
23129
|
+
unset: z42.array(z42.string()).optional()
|
|
22743
23130
|
}).optional()
|
|
22744
23131
|
}).optional()
|
|
22745
23132
|
});
|
|
22746
23133
|
var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
|
|
22747
|
-
var ConfigProfileRemoveInputSchema =
|
|
23134
|
+
var ConfigProfileRemoveInputSchema = z42.strictObject({ name: z42.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22748
23135
|
var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
|
|
22749
23136
|
var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
|
|
22750
|
-
var PoolMembersInputSchema =
|
|
22751
|
-
var ConfigPoolAddInputSchema =
|
|
22752
|
-
name:
|
|
23137
|
+
var PoolMembersInputSchema = z42.array(z42.string().min(1)).min(1);
|
|
23138
|
+
var ConfigPoolAddInputSchema = z42.strictObject({
|
|
23139
|
+
name: z42.string().min(1),
|
|
22753
23140
|
identities: PoolMembersInputSchema,
|
|
22754
|
-
preference:
|
|
22755
|
-
resumeOnLimit:
|
|
22756
|
-
compactBeforeLimit:
|
|
23141
|
+
preference: z42.enum(POOL_PREFERENCES).optional(),
|
|
23142
|
+
resumeOnLimit: z42.boolean().optional(),
|
|
23143
|
+
compactBeforeLimit: z42.boolean().optional(),
|
|
22757
23144
|
compactAtUtilisation: CompactAtUtilisationSchema.optional()
|
|
22758
23145
|
});
|
|
22759
23146
|
var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
|
|
22760
|
-
var ConfigPoolSetInputSchema =
|
|
22761
|
-
name:
|
|
23147
|
+
var ConfigPoolSetInputSchema = z42.strictObject({
|
|
23148
|
+
name: z42.string().min(1),
|
|
22762
23149
|
identities: PoolMembersInputSchema.optional(),
|
|
22763
|
-
preference:
|
|
22764
|
-
resumeOnLimit:
|
|
22765
|
-
compactBeforeLimit:
|
|
22766
|
-
compactAtUtilisation:
|
|
23150
|
+
preference: z42.union([z42.enum(POOL_PREFERENCES), z42.literal(false)]).optional(),
|
|
23151
|
+
resumeOnLimit: z42.boolean().optional(),
|
|
23152
|
+
compactBeforeLimit: z42.boolean().optional(),
|
|
23153
|
+
compactAtUtilisation: z42.union([CompactAtUtilisationSchema, z42.literal(false)]).optional()
|
|
22767
23154
|
});
|
|
22768
23155
|
var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
|
|
22769
|
-
var ConfigPoolRemoveInputSchema =
|
|
23156
|
+
var ConfigPoolRemoveInputSchema = z42.strictObject({ name: z42.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22770
23157
|
var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
|
|
22771
23158
|
var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
|
|
22772
|
-
var ConfigProviderAddInputSchema =
|
|
22773
|
-
name:
|
|
22774
|
-
kind:
|
|
22775
|
-
displayName:
|
|
22776
|
-
baseUrl:
|
|
23159
|
+
var ConfigProviderAddInputSchema = z42.strictObject({
|
|
23160
|
+
name: z42.string().min(1),
|
|
23161
|
+
kind: z42.enum(PROVIDER_KINDS).optional(),
|
|
23162
|
+
displayName: z42.string().min(1),
|
|
23163
|
+
baseUrl: z42.string().min(1).optional(),
|
|
22777
23164
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
|
|
22778
23165
|
codex: CodexProviderConfigSchema.optional()
|
|
22779
23166
|
});
|
|
22780
23167
|
var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
|
|
22781
|
-
var ConfigProviderSetInputSchema =
|
|
22782
|
-
name:
|
|
22783
|
-
displayName:
|
|
22784
|
-
baseUrl:
|
|
23168
|
+
var ConfigProviderSetInputSchema = z42.strictObject({
|
|
23169
|
+
name: z42.string().min(1),
|
|
23170
|
+
displayName: z42.string().min(1).optional(),
|
|
23171
|
+
baseUrl: z42.string().min(1).optional(),
|
|
22785
23172
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
|
|
22786
23173
|
codex: CodexProviderConfigSchema.optional()
|
|
22787
23174
|
});
|
|
22788
23175
|
var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
|
|
22789
|
-
var ConfigProviderRemoveInputSchema =
|
|
23176
|
+
var ConfigProviderRemoveInputSchema = z42.strictObject({ name: z42.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22790
23177
|
var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
|
|
22791
|
-
var ConfigRuleAddInputSchema =
|
|
22792
|
-
path:
|
|
22793
|
-
configProfile:
|
|
22794
|
-
identity:
|
|
23178
|
+
var ConfigRuleAddInputSchema = z42.strictObject({
|
|
23179
|
+
path: z42.string().min(1),
|
|
23180
|
+
configProfile: z42.string().min(1).optional(),
|
|
23181
|
+
identity: z42.string().min(1).optional()
|
|
22795
23182
|
});
|
|
22796
23183
|
var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
|
|
22797
|
-
var ConfigRuleSetInputSchema =
|
|
22798
|
-
path:
|
|
22799
|
-
configProfile:
|
|
22800
|
-
identity:
|
|
23184
|
+
var ConfigRuleSetInputSchema = z42.strictObject({
|
|
23185
|
+
path: z42.string().min(1),
|
|
23186
|
+
configProfile: z42.union([z42.string().min(1), z42.literal(false)]).optional(),
|
|
23187
|
+
identity: z42.union([z42.string().min(1), z42.literal(false)]).optional()
|
|
22801
23188
|
});
|
|
22802
23189
|
var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
|
|
22803
|
-
var ConfigRuleRemoveInputSchema =
|
|
23190
|
+
var ConfigRuleRemoveInputSchema = z42.strictObject({ path: z42.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22804
23191
|
var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
|
|
22805
23192
|
|
|
22806
23193
|
// src/frontdoor/configApi.ts
|
|
@@ -22874,7 +23261,7 @@ function profileValue(name, paths) {
|
|
|
22874
23261
|
function createConfigApiRouter(deps) {
|
|
22875
23262
|
const authed = doorApiAuth(deps.expectedToken);
|
|
22876
23263
|
const { paths } = deps;
|
|
22877
|
-
const route = (
|
|
23264
|
+
const route = (path59, summary) => authed.meta(openapi3({ method: "POST", path: path59, summary, tags: [CONFIG_API_TAG] }));
|
|
22878
23265
|
return {
|
|
22879
23266
|
config: {
|
|
22880
23267
|
identity: {
|
|
@@ -23145,50 +23532,50 @@ import { eventIterator as eventIterator2, withEventMeta as withEventMeta2 } from
|
|
|
23145
23532
|
|
|
23146
23533
|
// src/frontdoor/eventSchemas.ts
|
|
23147
23534
|
init_schema2();
|
|
23148
|
-
import { z as
|
|
23535
|
+
import { z as z43 } from "zod";
|
|
23149
23536
|
var DOOR_EVENT_SOURCE_RC = "rc";
|
|
23150
23537
|
var LAUNCH_EVENT_SOURCE = "launch";
|
|
23151
23538
|
var USAGE_EVENT_SOURCE = "usage";
|
|
23152
23539
|
var DOOR_HEALTH_EVENT_SOURCE = "door";
|
|
23153
23540
|
var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
|
|
23154
|
-
var DoorEventSchema =
|
|
23155
|
-
source:
|
|
23541
|
+
var DoorEventSchema = z43.strictObject({
|
|
23542
|
+
source: z43.string().min(1),
|
|
23156
23543
|
/** A positive integer because the backbone's counters start at one and only ever increase. */
|
|
23157
|
-
sequence:
|
|
23158
|
-
payload:
|
|
23159
|
-
});
|
|
23160
|
-
var DoorEventSourceQuerySchema =
|
|
23161
|
-
sources:
|
|
23162
|
-
});
|
|
23163
|
-
var LaunchLifecycleEventSchema =
|
|
23164
|
-
kind:
|
|
23165
|
-
pid:
|
|
23166
|
-
startedAt:
|
|
23167
|
-
observedAt:
|
|
23168
|
-
});
|
|
23169
|
-
var DoorHealthEventSchema =
|
|
23170
|
-
|
|
23171
|
-
|
|
23172
|
-
|
|
23173
|
-
|
|
23174
|
-
|
|
23175
|
-
|
|
23544
|
+
sequence: z43.number().int().positive(),
|
|
23545
|
+
payload: z43.unknown()
|
|
23546
|
+
});
|
|
23547
|
+
var DoorEventSourceQuerySchema = z43.strictObject({
|
|
23548
|
+
sources: z43.array(z43.string().min(1)).min(1).optional()
|
|
23549
|
+
});
|
|
23550
|
+
var LaunchLifecycleEventSchema = z43.strictObject({
|
|
23551
|
+
kind: z43.enum(["registered", "pruned", "ended"]),
|
|
23552
|
+
pid: z43.number().int().positive(),
|
|
23553
|
+
startedAt: z43.number(),
|
|
23554
|
+
observedAt: z43.number()
|
|
23555
|
+
});
|
|
23556
|
+
var DoorHealthEventSchema = z43.discriminatedUnion("kind", [
|
|
23557
|
+
z43.strictObject({ kind: z43.literal("generation"), pid: z43.number().int().positive(), providerPort: z43.number().int().positive(), connectPort: z43.number().int().positive(), directPort: z43.number().int().positive(), observedAt: z43.number() }),
|
|
23558
|
+
z43.strictObject({ kind: z43.literal("listenerFailed"), pid: z43.number().int().positive(), listener: z43.enum(["provider", "connect", "direct"]), message: z43.string(), observedAt: z43.number() }),
|
|
23559
|
+
z43.strictObject({ kind: z43.literal("binaryTurnover"), pid: z43.number().int().positive(), observedAt: z43.number() }),
|
|
23560
|
+
z43.strictObject({ kind: z43.literal("idleShutdown"), pid: z43.number().int().positive(), observedAt: z43.number() }),
|
|
23561
|
+
z43.strictObject({ kind: z43.literal("superseded"), pid: z43.number().int().positive(), ownerPid: z43.number().int().positive(), observedAt: z43.number() }),
|
|
23562
|
+
z43.strictObject({ kind: z43.literal("drained"), pid: z43.number().int().positive(), observedAt: z43.number() })
|
|
23176
23563
|
]);
|
|
23177
|
-
var QuotaExpiringEventSchema =
|
|
23564
|
+
var QuotaExpiringEventSchema = z43.strictObject({
|
|
23178
23565
|
/** The id of the identity whose window it is: what its usage is filed under, which a rename keeps. */
|
|
23179
|
-
id:
|
|
23566
|
+
id: z43.string().min(1),
|
|
23180
23567
|
/** The identity's name when the event was published, absent for an identity no longer stored under the id. */
|
|
23181
|
-
name:
|
|
23182
|
-
provider:
|
|
23183
|
-
window:
|
|
23568
|
+
name: z43.string().min(1).optional(),
|
|
23569
|
+
provider: z43.string().min(1),
|
|
23570
|
+
window: z43.enum(["fiveHour", "sevenDay"]),
|
|
23184
23571
|
/** The fraction of the window already used when it was seen expiring, always below one because a fully used window has nothing left to spend. */
|
|
23185
|
-
utilization:
|
|
23186
|
-
resetsAt:
|
|
23187
|
-
observedAt:
|
|
23572
|
+
utilization: z43.number().min(0).max(1),
|
|
23573
|
+
resetsAt: z43.iso.datetime(),
|
|
23574
|
+
observedAt: z43.number()
|
|
23188
23575
|
});
|
|
23189
23576
|
var UsageChangeEventSchema = UsageSnapshotSchema.extend({
|
|
23190
|
-
id:
|
|
23191
|
-
name:
|
|
23577
|
+
id: z43.string().min(1),
|
|
23578
|
+
name: z43.string().min(1).optional()
|
|
23192
23579
|
});
|
|
23193
23580
|
|
|
23194
23581
|
// src/frontdoor/eventsApi.ts
|
|
@@ -23233,14 +23620,14 @@ function createEventsApiRouter(deps) {
|
|
|
23233
23620
|
init_update();
|
|
23234
23621
|
import { ORPCError as ORPCError4 } from "@orpc/client";
|
|
23235
23622
|
import { openapi as openapi5 } from "@orpc/openapi";
|
|
23236
|
-
import { z as
|
|
23623
|
+
import { z as z44 } from "zod";
|
|
23237
23624
|
var FRONTDOOR_API_TAG = "frontdoor";
|
|
23238
23625
|
var UPDATE_API_TAG = "update";
|
|
23239
23626
|
function createLifecycleApiRouter(deps) {
|
|
23240
23627
|
const authed = doorApiAuth(deps.expectedToken);
|
|
23241
23628
|
return {
|
|
23242
23629
|
frontdoor: {
|
|
23243
|
-
refreshCatalogues: authed.meta(openapi5({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(
|
|
23630
|
+
refreshCatalogues: authed.meta(openapi5({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(z44.strictObject({ requested: z44.literal(true) })).handler(() => {
|
|
23244
23631
|
deps.refreshCatalogues();
|
|
23245
23632
|
return { requested: true };
|
|
23246
23633
|
}),
|
|
@@ -23276,65 +23663,65 @@ import { ORPCError as ORPCError5 } from "@orpc/client";
|
|
|
23276
23663
|
import { openapi as openapi6 } from "@orpc/openapi";
|
|
23277
23664
|
|
|
23278
23665
|
// src/frontdoor/launchSchemas.ts
|
|
23279
|
-
import
|
|
23280
|
-
import { z as
|
|
23666
|
+
import path46 from "node:path";
|
|
23667
|
+
import { z as z45 } from "zod";
|
|
23281
23668
|
init_statusline();
|
|
23282
23669
|
init_claudeVersion();
|
|
23283
23670
|
init_identity2();
|
|
23284
|
-
var LaunchResolveInputSchema =
|
|
23285
|
-
path:
|
|
23671
|
+
var LaunchResolveInputSchema = z45.strictObject({
|
|
23672
|
+
path: z45.string().min(1),
|
|
23286
23673
|
/** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
|
|
23287
|
-
argv:
|
|
23674
|
+
argv: z45.readonly(z45.array(z45.string())).optional(),
|
|
23288
23675
|
/** The launch's inherited environment. Absent means an empty one: the door's own environment is never a substitute for the caller's, so a caller that wants `AGENT_SHIM_*` switches or a `CLAUDE_CONFIG_DIR` considered names them here. Values are read, never reported. */
|
|
23289
|
-
env:
|
|
23290
|
-
}).refine((input) =>
|
|
23291
|
-
var LaunchPoolDecisionSchema =
|
|
23292
|
-
name:
|
|
23293
|
-
reasons:
|
|
23676
|
+
env: z45.record(z45.string(), z45.string()).optional()
|
|
23677
|
+
}).refine((input) => path46.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
23678
|
+
var LaunchPoolDecisionSchema = z45.strictObject({
|
|
23679
|
+
name: z45.string(),
|
|
23680
|
+
reasons: z45.readonly(z45.array(z45.string())),
|
|
23294
23681
|
/** The provider the ranking read for the chosen member, when the launch spends one in place of the member's Claude account. */
|
|
23295
|
-
provider:
|
|
23296
|
-
movedOff:
|
|
23682
|
+
provider: z45.string().optional(),
|
|
23683
|
+
movedOff: z45.strictObject({ identity: z45.string(), reason: z45.string() }).optional()
|
|
23297
23684
|
});
|
|
23298
|
-
var LaunchDecisionSchema =
|
|
23299
|
-
identity:
|
|
23300
|
-
identityId:
|
|
23301
|
-
identitySource:
|
|
23685
|
+
var LaunchDecisionSchema = z45.strictObject({
|
|
23686
|
+
identity: z45.string().optional(),
|
|
23687
|
+
identityId: z45.string().optional(),
|
|
23688
|
+
identitySource: z45.enum(IDENTITY_DECISION_SOURCES),
|
|
23302
23689
|
pool: LaunchPoolDecisionSchema.optional(),
|
|
23303
23690
|
/** True when `CLAUDE_CONFIG_DIR` was already set and nothing on the command line named an identity; an identity named there outranks the variable and leaves it false. */
|
|
23304
|
-
configDirEscapeHatch:
|
|
23305
|
-
configDir:
|
|
23306
|
-
configProfile:
|
|
23307
|
-
configProfileSource:
|
|
23308
|
-
provider:
|
|
23309
|
-
});
|
|
23310
|
-
var LaunchFlagsSchema =
|
|
23311
|
-
skipPermissions:
|
|
23312
|
-
remoteControl:
|
|
23313
|
-
headroom:
|
|
23314
|
-
trackUsage:
|
|
23315
|
-
pause:
|
|
23316
|
-
explain:
|
|
23691
|
+
configDirEscapeHatch: z45.boolean(),
|
|
23692
|
+
configDir: z45.string().optional(),
|
|
23693
|
+
configProfile: z45.string().optional(),
|
|
23694
|
+
configProfileSource: z45.enum(CONFIG_PROFILE_DECISION_SOURCES),
|
|
23695
|
+
provider: z45.string().optional()
|
|
23696
|
+
});
|
|
23697
|
+
var LaunchFlagsSchema = z45.strictObject({
|
|
23698
|
+
skipPermissions: z45.boolean(),
|
|
23699
|
+
remoteControl: z45.boolean(),
|
|
23700
|
+
headroom: z45.boolean(),
|
|
23701
|
+
trackUsage: z45.boolean(),
|
|
23702
|
+
pause: z45.boolean(),
|
|
23703
|
+
explain: z45.boolean(),
|
|
23317
23704
|
/** How long the launch waits after its own output before it starts claude, in milliseconds. */
|
|
23318
|
-
delayMs:
|
|
23705
|
+
delayMs: z45.number(),
|
|
23319
23706
|
/** The hosts the launch keeps off the front door by adding them to the child's `NO_PROXY`. */
|
|
23320
|
-
proxyBypass:
|
|
23707
|
+
proxyBypass: z45.array(z45.string()).readonly(),
|
|
23321
23708
|
/** How the session's built-in statusline looks, when the launch configures any of it. */
|
|
23322
23709
|
statusline: StatuslineSchema.optional()
|
|
23323
23710
|
});
|
|
23324
|
-
var LaunchResolveOutputSchema =
|
|
23711
|
+
var LaunchResolveOutputSchema = z45.strictObject({
|
|
23325
23712
|
decision: LaunchDecisionSchema,
|
|
23326
23713
|
flags: LaunchFlagsSchema,
|
|
23327
|
-
claudeVersion:
|
|
23714
|
+
claudeVersion: z45.strictObject({ version: z45.string(), source: z45.enum(CLAUDE_VERSION_SOURCES) }).optional(),
|
|
23328
23715
|
/** The real `claude` binary the launch would spawn, on the door's host. */
|
|
23329
|
-
bin:
|
|
23716
|
+
bin: z45.string(),
|
|
23330
23717
|
/** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
|
|
23331
|
-
args:
|
|
23718
|
+
args: z45.readonly(z45.array(z45.string())),
|
|
23332
23719
|
/** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
|
|
23333
|
-
credential:
|
|
23334
|
-
routing:
|
|
23720
|
+
credential: z45.strictObject({ subject: z45.enum(["provider", "identity"]), name: z45.string(), summary: CredentialSummarySchema }).optional(),
|
|
23721
|
+
routing: z45.strictObject({ frontDoor: z45.boolean(), headroom: z45.boolean() }),
|
|
23335
23722
|
/** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
|
|
23336
|
-
environment:
|
|
23337
|
-
warnings:
|
|
23723
|
+
environment: z45.readonly(z45.array(z45.string())),
|
|
23724
|
+
warnings: z45.readonly(z45.array(z45.string()))
|
|
23338
23725
|
});
|
|
23339
23726
|
|
|
23340
23727
|
// src/frontdoor/launchApi.ts
|
|
@@ -23373,21 +23760,21 @@ init_schema3();
|
|
|
23373
23760
|
init_cliError();
|
|
23374
23761
|
import { ORPCError as ORPCError6 } from "@orpc/client";
|
|
23375
23762
|
import { openapi as openapi7 } from "@orpc/openapi";
|
|
23376
|
-
import { z as
|
|
23377
|
-
var AgentTreesListInputSchema =
|
|
23763
|
+
import { z as z46 } from "zod";
|
|
23764
|
+
var AgentTreesListInputSchema = z46.strictObject({
|
|
23378
23765
|
/** Only this identity's sessions. */
|
|
23379
|
-
identity:
|
|
23766
|
+
identity: z46.string().optional(),
|
|
23380
23767
|
/** Include sessions that spawned no agent and ran no workflow. */
|
|
23381
|
-
all:
|
|
23768
|
+
all: z46.boolean().optional()
|
|
23382
23769
|
});
|
|
23383
|
-
var AgentTreesListOutputSchema =
|
|
23384
|
-
var AgentTreesShowInputSchema =
|
|
23770
|
+
var AgentTreesListOutputSchema = z46.array(SessionSummarySchema);
|
|
23771
|
+
var AgentTreesShowInputSchema = z46.strictObject({
|
|
23385
23772
|
/** A session id, or an unambiguous prefix of one. */
|
|
23386
|
-
session:
|
|
23773
|
+
session: z46.string().min(1),
|
|
23387
23774
|
/** Look only in this identity. */
|
|
23388
|
-
identity:
|
|
23775
|
+
identity: z46.string().optional()
|
|
23389
23776
|
});
|
|
23390
|
-
var AgentTreesShowOutputSchema =
|
|
23777
|
+
var AgentTreesShowOutputSchema = z46.strictObject({ identities: z46.array(z46.string()), ...MergedAgentTreeSchema.shape });
|
|
23391
23778
|
function asBadRequest(error) {
|
|
23392
23779
|
if (error instanceof CliError) {
|
|
23393
23780
|
throw new ORPCError6("BAD_REQUEST", { message: error.message });
|
|
@@ -23440,7 +23827,7 @@ import { openapi as openapi8 } from "@orpc/openapi";
|
|
|
23440
23827
|
import { eventIterator as eventIterator3, withEventMeta as withEventMeta3 } from "@orpc/server";
|
|
23441
23828
|
|
|
23442
23829
|
// src/frontdoor/rcEventLog.ts
|
|
23443
|
-
import { z as
|
|
23830
|
+
import { z as z47 } from "zod";
|
|
23444
23831
|
|
|
23445
23832
|
// src/frontdoor/eventHub.ts
|
|
23446
23833
|
var DOOR_EVENT_BUFFER_EVENTS = 100;
|
|
@@ -23565,46 +23952,46 @@ var NUMBER_FIELDS = ["at", "sequence"].length;
|
|
|
23565
23952
|
var BYTES_PER_CODE_UNIT = Uint16Array.BYTES_PER_ELEMENT;
|
|
23566
23953
|
var RC_SESSION_END_REASONS = ["expired", "archived", "conflict"];
|
|
23567
23954
|
var RC_PENDING_RETIRE_REASONS = ["answered", "withdrawn", "worker-stopped", "session-ended"];
|
|
23568
|
-
var transitionBase = { session:
|
|
23569
|
-
var cursorFields = { cursor:
|
|
23570
|
-
var sessionAppearedShape = { kind:
|
|
23571
|
-
var sessionEndedShape = { kind:
|
|
23572
|
-
var workerStateShape = { kind:
|
|
23573
|
-
var pendingBornShape = { kind:
|
|
23574
|
-
var pendingRetiredShape = { kind:
|
|
23575
|
-
var RcSessionTransitionSchema =
|
|
23576
|
-
|
|
23577
|
-
|
|
23578
|
-
|
|
23579
|
-
|
|
23580
|
-
|
|
23955
|
+
var transitionBase = { session: z47.string(), at: z47.number() };
|
|
23956
|
+
var cursorFields = { cursor: z47.string(), sequence: z47.int().positive() };
|
|
23957
|
+
var sessionAppearedShape = { kind: z47.literal("session-appeared"), ...transitionBase };
|
|
23958
|
+
var sessionEndedShape = { kind: z47.literal("session-ended"), reason: z47.enum(RC_SESSION_END_REASONS), ...transitionBase };
|
|
23959
|
+
var workerStateShape = { kind: z47.literal("worker-state"), state: z47.string(), previous: z47.string().optional(), ...transitionBase };
|
|
23960
|
+
var pendingBornShape = { kind: z47.literal("pending-born"), requestId: z47.string(), type: z47.string(), summary: z47.string(), ...transitionBase };
|
|
23961
|
+
var pendingRetiredShape = { kind: z47.literal("pending-retired"), requestId: z47.string(), reason: z47.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
|
|
23962
|
+
var RcSessionTransitionSchema = z47.discriminatedUnion("kind", [
|
|
23963
|
+
z47.strictObject(sessionAppearedShape),
|
|
23964
|
+
z47.strictObject(sessionEndedShape),
|
|
23965
|
+
z47.strictObject(workerStateShape),
|
|
23966
|
+
z47.strictObject(pendingBornShape),
|
|
23967
|
+
z47.strictObject(pendingRetiredShape)
|
|
23581
23968
|
]);
|
|
23582
23969
|
var KIND_MAX_CHARS = Math.max(...RcSessionTransitionSchema.options.map((option) => option.shape.kind.value.length));
|
|
23583
23970
|
var RC_SESSION_EVENT_MAX_BYTES = (RC_SESSION_EVENT_GENERATION_MAX_CHARS + ".".length + SEQUENCE_MAX_DIGITS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + KIND_MAX_CHARS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + RC_SESSION_EVENT_SUMMARY_MAX_CHARS) * BYTES_PER_CODE_UNIT + NUMBER_FIELDS * NUMBER_BYTES;
|
|
23584
23971
|
var RC_SESSION_EVENT_LOG_CAPACITY = Math.floor(CONTROL_BODY_CAP_BYTES / RC_SESSION_EVENT_MAX_BYTES);
|
|
23585
|
-
var RcSessionEventSchema =
|
|
23586
|
-
|
|
23587
|
-
|
|
23588
|
-
|
|
23589
|
-
|
|
23590
|
-
|
|
23972
|
+
var RcSessionEventSchema = z47.discriminatedUnion("kind", [
|
|
23973
|
+
z47.strictObject({ ...cursorFields, ...sessionAppearedShape }),
|
|
23974
|
+
z47.strictObject({ ...cursorFields, ...sessionEndedShape }),
|
|
23975
|
+
z47.strictObject({ ...cursorFields, ...workerStateShape }),
|
|
23976
|
+
z47.strictObject({ ...cursorFields, ...pendingBornShape }),
|
|
23977
|
+
z47.strictObject({ ...cursorFields, ...pendingRetiredShape })
|
|
23591
23978
|
]);
|
|
23592
|
-
var RcSessionEventsReadInputSchema =
|
|
23979
|
+
var RcSessionEventsReadInputSchema = z47.strictObject({
|
|
23593
23980
|
/** The cursor of the last event the caller saw; every retained event when omitted. */
|
|
23594
|
-
since:
|
|
23981
|
+
since: z47.string().min(1).optional(),
|
|
23595
23982
|
/** One `cse_` session id; every session when omitted. */
|
|
23596
|
-
session:
|
|
23983
|
+
session: z47.string().min(1).optional(),
|
|
23597
23984
|
/** The most events one answer carries; every event after `since` when omitted. */
|
|
23598
|
-
limit:
|
|
23985
|
+
limit: z47.int().positive().optional()
|
|
23599
23986
|
});
|
|
23600
23987
|
var RcSessionEventsPageInputSchema = RcSessionEventsReadInputSchema.extend({
|
|
23601
23988
|
/** The most events this page carries: by default and at most, the bound the door's event backbone already holds per slow consumer (`DOOR_EVENT_BUFFER_EVENTS`, oRPC's own documented default for that case). A page lands whole in its reader, so a reader receives at most one consumer buffer's worth at a time (at worst `DOOR_EVENT_BUFFER_EVENTS` times `RC_SESSION_EVENT_MAX_BYTES`) and pages on with the cursor for more; a maximum of the whole window would let one page carry the log's entire memory budget into an agent's context. */
|
|
23602
|
-
limit:
|
|
23989
|
+
limit: z47.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
|
|
23603
23990
|
});
|
|
23604
23991
|
var RcSessionEventsStreamInputSchema = RcSessionEventsReadInputSchema.omit({ limit: true });
|
|
23605
|
-
var RcSessionEventsReadOutputSchema =
|
|
23606
|
-
|
|
23607
|
-
|
|
23992
|
+
var RcSessionEventsReadOutputSchema = z47.discriminatedUnion("status", [
|
|
23993
|
+
z47.strictObject({ status: z47.literal("ok"), events: z47.readonly(z47.array(RcSessionEventSchema)), cursor: z47.string(), more: z47.boolean(), head: z47.string() }),
|
|
23994
|
+
z47.strictObject({ status: z47.literal("expired"), message: z47.string(), head: z47.string() })
|
|
23608
23995
|
]);
|
|
23609
23996
|
var CURSOR_SEPARATOR = ".";
|
|
23610
23997
|
var RESYNC_ADVICE = "cursor expired, resync from status: read `rc status` for every session's present state, then resume after the head this answer names";
|
|
@@ -24120,6 +24507,7 @@ function createQuotaExpiringPublisher(hub, deps) {
|
|
|
24120
24507
|
|
|
24121
24508
|
// src/index.ts
|
|
24122
24509
|
init_rcSchemas();
|
|
24510
|
+
init_verifiedVersions();
|
|
24123
24511
|
|
|
24124
24512
|
// src/frontdoor/rcLiveUsage.ts
|
|
24125
24513
|
init_rcSchemas();
|
|
@@ -25793,7 +26181,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
25793
26181
|
// src/frontdoor/rcSelfHostMint.ts
|
|
25794
26182
|
init_identityRecords();
|
|
25795
26183
|
init_account();
|
|
25796
|
-
import
|
|
26184
|
+
import path47 from "node:path";
|
|
25797
26185
|
var CREDENTIALS_FILE2 = ".credentials.json";
|
|
25798
26186
|
var CLAUDE_JSON2 = ".claude.json";
|
|
25799
26187
|
var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
|
|
@@ -25817,7 +26205,7 @@ function readJsonObject(fs17, file) {
|
|
|
25817
26205
|
return isRecord16(parsed) ? parsed : void 0;
|
|
25818
26206
|
}
|
|
25819
26207
|
function readRcSelfHostRecord(fs17, frontdoorDir) {
|
|
25820
|
-
const parsed = readJsonObject(fs17,
|
|
26208
|
+
const parsed = readJsonObject(fs17, path47.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
25821
26209
|
if (parsed === void 0) {
|
|
25822
26210
|
return void 0;
|
|
25823
26211
|
}
|
|
@@ -25835,11 +26223,11 @@ function mintRcSelfHostCredential(deps) {
|
|
|
25835
26223
|
if (id === void 0) {
|
|
25836
26224
|
throw new Error(`No identity named "${deps.identity}".`);
|
|
25837
26225
|
}
|
|
25838
|
-
const identityDir =
|
|
25839
|
-
const credentialsFile =
|
|
25840
|
-
const claudeJsonFile =
|
|
25841
|
-
const recordDir =
|
|
25842
|
-
const recordFile2 =
|
|
26226
|
+
const identityDir = path47.join(deps.identitiesDir, id);
|
|
26227
|
+
const credentialsFile = path47.join(identityDir, CREDENTIALS_FILE2);
|
|
26228
|
+
const claudeJsonFile = path47.join(identityDir, CLAUDE_JSON2);
|
|
26229
|
+
const recordDir = path47.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
|
|
26230
|
+
const recordFile2 = path47.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
25843
26231
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
25844
26232
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
25845
26233
|
const existingOauth = isRecord16(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
@@ -25855,7 +26243,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
25855
26243
|
const organizationUuid = deps.newUuid();
|
|
25856
26244
|
const accountUuid = deps.newUuid();
|
|
25857
26245
|
const mintedAt = new Date(deps.now()).toISOString();
|
|
25858
|
-
deps.fs.mkdirPrivate(
|
|
26246
|
+
deps.fs.mkdirPrivate(path47.dirname(credentialsFile));
|
|
25859
26247
|
deps.fs.writeFilePrivate(credentialsFile, `${JSON.stringify({ ...existingCredentials, claudeAiOauth: { accessToken, refreshToken, expiresAt: null, scopes: [...RC_SELF_HOST_SCOPE_LIST], subscriptionType: SELF_HOST_SUBSCRIPTION_TYPE, rateLimitTier: null } }, null, 2)}
|
|
25860
26248
|
`);
|
|
25861
26249
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
@@ -25893,7 +26281,7 @@ init_ensure2();
|
|
|
25893
26281
|
// src/frontdoor/liveSessionRegistry.ts
|
|
25894
26282
|
init_capability();
|
|
25895
26283
|
init_state();
|
|
25896
|
-
import
|
|
26284
|
+
import path48 from "node:path";
|
|
25897
26285
|
function sameStat(recorded, current) {
|
|
25898
26286
|
return recorded?.mtimeMs === current.mtimeMs && recorded.sizeBytes === current.sizeBytes;
|
|
25899
26287
|
}
|
|
@@ -25915,7 +26303,7 @@ function createLiveSessionRegistry(ports) {
|
|
|
25915
26303
|
const load = (name, stat) => {
|
|
25916
26304
|
known.set(name, { stat: { mtimeMs: stat.mtimeMs, sizeBytes: stat.sizeBytes }, record: readFrontDoorSessionRecord(fs17, sessionsDir, name) });
|
|
25917
26305
|
};
|
|
25918
|
-
const statOf = (name) => fs17.lstat(
|
|
26306
|
+
const statOf = (name) => fs17.lstat(path48.join(sessionsDir, name));
|
|
25919
26307
|
const reconcile = () => {
|
|
25920
26308
|
const names = new Set(recordNames());
|
|
25921
26309
|
let changed = false;
|
|
@@ -25990,8 +26378,8 @@ init_liveTasks();
|
|
|
25990
26378
|
|
|
25991
26379
|
// src/agents/read.ts
|
|
25992
26380
|
init_schema3();
|
|
25993
|
-
import
|
|
25994
|
-
import { z as
|
|
26381
|
+
import path49 from "node:path";
|
|
26382
|
+
import { z as z48 } from "zod";
|
|
25995
26383
|
var PROJECTS_DIR = "projects";
|
|
25996
26384
|
var TASKS_DIR = "tasks";
|
|
25997
26385
|
var SUBAGENTS_DIR = "subagents";
|
|
@@ -26016,15 +26404,15 @@ function parseEntry2(project, entry) {
|
|
|
26016
26404
|
}
|
|
26017
26405
|
function listSessions2(fs17, configDir) {
|
|
26018
26406
|
const found = [];
|
|
26019
|
-
for (const project of fs17.readdir(
|
|
26020
|
-
const projectDir =
|
|
26407
|
+
for (const project of fs17.readdir(path49.join(configDir, PROJECTS_DIR))) {
|
|
26408
|
+
const projectDir = path49.join(configDir, PROJECTS_DIR, project);
|
|
26021
26409
|
const entries = /* @__PURE__ */ new Set();
|
|
26022
26410
|
for (const name of fs17.readdir(projectDir)) {
|
|
26023
26411
|
if (name.endsWith(TRANSCRIPT_SUFFIX)) {
|
|
26024
26412
|
entries.add(name.slice(0, -TRANSCRIPT_SUFFIX.length));
|
|
26025
26413
|
continue;
|
|
26026
26414
|
}
|
|
26027
|
-
const children = fs17.readdir(
|
|
26415
|
+
const children = fs17.readdir(path49.join(projectDir, name));
|
|
26028
26416
|
if (children.includes(SUBAGENTS_DIR) || children.includes(WORKFLOWS_DIR)) {
|
|
26029
26417
|
entries.add(name);
|
|
26030
26418
|
}
|
|
@@ -26044,8 +26432,8 @@ function locateAgents(fs17, configDir, relativeDir, workflowRunId, report) {
|
|
|
26044
26432
|
const id = name.slice(AGENT_FILE_PREFIX.length, -META_SUFFIX.length);
|
|
26045
26433
|
located.push({
|
|
26046
26434
|
id,
|
|
26047
|
-
metaPath:
|
|
26048
|
-
transcriptPath:
|
|
26435
|
+
metaPath: path49.join(relativeDir, name),
|
|
26436
|
+
transcriptPath: path49.join(relativeDir, `${AGENT_FILE_PREFIX}${id}${TRANSCRIPT_SUFFIX}`),
|
|
26049
26437
|
workflowRunId
|
|
26050
26438
|
});
|
|
26051
26439
|
}
|
|
@@ -26088,7 +26476,7 @@ function describeFailure(error) {
|
|
|
26088
26476
|
}
|
|
26089
26477
|
function readFileOrReport(fs17, configDir, relative, report) {
|
|
26090
26478
|
try {
|
|
26091
|
-
return fs17.readFileUtf8(
|
|
26479
|
+
return fs17.readFileUtf8(path49.join(configDir, relative));
|
|
26092
26480
|
} catch (error) {
|
|
26093
26481
|
report({ path: relative, reason: `could not be read: ${describeFailure(error)}` });
|
|
26094
26482
|
return void 0;
|
|
@@ -26096,7 +26484,7 @@ function readFileOrReport(fs17, configDir, relative, report) {
|
|
|
26096
26484
|
}
|
|
26097
26485
|
function listDirOrReport(fs17, configDir, relative, report) {
|
|
26098
26486
|
try {
|
|
26099
|
-
return fs17.readdir(
|
|
26487
|
+
return fs17.readdir(path49.join(configDir, relative));
|
|
26100
26488
|
} catch (error) {
|
|
26101
26489
|
report({ path: relative, reason: `could not be listed: ${describeFailure(error)}` });
|
|
26102
26490
|
return [];
|
|
@@ -26110,28 +26498,28 @@ function parseJson2(text) {
|
|
|
26110
26498
|
return void 0;
|
|
26111
26499
|
}
|
|
26112
26500
|
}
|
|
26113
|
-
var TaskFileSchema =
|
|
26114
|
-
var WorkflowRunFileSchema =
|
|
26115
|
-
runId:
|
|
26116
|
-
workflowName:
|
|
26117
|
-
status:
|
|
26118
|
-
startTime:
|
|
26119
|
-
phases:
|
|
26120
|
-
summary:
|
|
26501
|
+
var TaskFileSchema = z48.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: z48.array(z48.string()).default([]), blockedBy: z48.array(z48.string()).default([]) });
|
|
26502
|
+
var WorkflowRunFileSchema = z48.object({
|
|
26503
|
+
runId: z48.string(),
|
|
26504
|
+
workflowName: z48.string().optional(),
|
|
26505
|
+
status: z48.string().optional(),
|
|
26506
|
+
startTime: z48.number().optional(),
|
|
26507
|
+
phases: z48.array(z48.object({ title: z48.string() })).default([]),
|
|
26508
|
+
summary: z48.string().optional()
|
|
26121
26509
|
});
|
|
26122
26510
|
function summariseSession(fs17, configDir, ref) {
|
|
26123
|
-
const sessionRelative =
|
|
26124
|
-
const subagentsRelative =
|
|
26125
|
-
const workflowsUnderSubagents =
|
|
26511
|
+
const sessionRelative = path49.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
26512
|
+
const subagentsRelative = path49.join(sessionRelative, SUBAGENTS_DIR);
|
|
26513
|
+
const workflowsUnderSubagents = path49.join(subagentsRelative, WORKFLOWS_DIR);
|
|
26126
26514
|
const isMeta = (name) => name.startsWith(AGENT_FILE_PREFIX) && name.endsWith(META_SUFFIX);
|
|
26127
|
-
let agentCount = fs17.readdir(
|
|
26128
|
-
for (const runDir of fs17.readdir(
|
|
26515
|
+
let agentCount = fs17.readdir(path49.join(configDir, subagentsRelative)).filter(isMeta).length;
|
|
26516
|
+
for (const runDir of fs17.readdir(path49.join(configDir, workflowsUnderSubagents))) {
|
|
26129
26517
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
26130
|
-
agentCount += fs17.readdir(
|
|
26518
|
+
agentCount += fs17.readdir(path49.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
|
|
26131
26519
|
}
|
|
26132
26520
|
}
|
|
26133
|
-
const workflowRunCount = fs17.readdir(
|
|
26134
|
-
const transcript = fs17.lstat(
|
|
26521
|
+
const workflowRunCount = fs17.readdir(path49.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
|
|
26522
|
+
const transcript = fs17.lstat(path49.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
|
|
26135
26523
|
return { ...ref, agentCount, workflowRunCount, ...transcript === void 0 ? {} : { updatedAt: new Date(transcript.mtimeMs).toISOString() } };
|
|
26136
26524
|
}
|
|
26137
26525
|
function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
@@ -26139,13 +26527,13 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
|
26139
26527
|
const report = (problem) => {
|
|
26140
26528
|
problems.push(problem);
|
|
26141
26529
|
};
|
|
26142
|
-
const sessionRelative =
|
|
26143
|
-
const subagentsRelative =
|
|
26144
|
-
const workflowsUnderSubagents =
|
|
26530
|
+
const sessionRelative = path49.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
26531
|
+
const subagentsRelative = path49.join(sessionRelative, SUBAGENTS_DIR);
|
|
26532
|
+
const workflowsUnderSubagents = path49.join(subagentsRelative, WORKFLOWS_DIR);
|
|
26145
26533
|
const located = locateAgents(fs17, configDir, subagentsRelative, void 0, report);
|
|
26146
26534
|
for (const runDir of listDirOrReport(fs17, configDir, workflowsUnderSubagents, report)) {
|
|
26147
26535
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
26148
|
-
located.push(...locateAgents(fs17, configDir,
|
|
26536
|
+
located.push(...locateAgents(fs17, configDir, path49.join(workflowsUnderSubagents, runDir), runDir, report));
|
|
26149
26537
|
}
|
|
26150
26538
|
}
|
|
26151
26539
|
const agents = /* @__PURE__ */ new Map();
|
|
@@ -26186,7 +26574,7 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
|
26186
26574
|
superseded: ref.superseded,
|
|
26187
26575
|
agents: roots.sort().map(build),
|
|
26188
26576
|
tasks: readTasks(fs17, configDir, ownTaskLists(ref.sessionId), [.../* @__PURE__ */ new Set([...teamNames, ...options.taskListIds ?? []])].filter((id) => !ownTaskLists(ref.sessionId).includes(id)), report),
|
|
26189
|
-
workflowRuns: readWorkflowRuns(fs17, configDir,
|
|
26577
|
+
workflowRuns: readWorkflowRuns(fs17, configDir, path49.join(sessionRelative, WORKFLOWS_DIR), report),
|
|
26190
26578
|
problems
|
|
26191
26579
|
};
|
|
26192
26580
|
}
|
|
@@ -26251,12 +26639,12 @@ function ownTaskLists(sessionId) {
|
|
|
26251
26639
|
function readTasks(fs17, configDir, ownLists, sharedLists, report) {
|
|
26252
26640
|
const tasks = [];
|
|
26253
26641
|
[...ownLists, ...sharedLists].forEach((scope, index) => {
|
|
26254
|
-
const relativeDir =
|
|
26642
|
+
const relativeDir = path49.join(TASKS_DIR, scope);
|
|
26255
26643
|
for (const name of [...listDirOrReport(fs17, configDir, relativeDir, report)].sort()) {
|
|
26256
26644
|
if (name.startsWith(".") || !name.endsWith(JSON_SUFFIX)) {
|
|
26257
26645
|
continue;
|
|
26258
26646
|
}
|
|
26259
|
-
const relative =
|
|
26647
|
+
const relative = path49.join(relativeDir, name);
|
|
26260
26648
|
const text = readFileOrReport(fs17, configDir, relative, report);
|
|
26261
26649
|
const parsed = TaskFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
26262
26650
|
if (parsed.success) {
|
|
@@ -26274,7 +26662,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
|
|
|
26274
26662
|
if (!name.startsWith(WORKFLOW_RUN_PREFIX) || !name.endsWith(JSON_SUFFIX)) {
|
|
26275
26663
|
continue;
|
|
26276
26664
|
}
|
|
26277
|
-
const relative =
|
|
26665
|
+
const relative = path49.join(relativeDir, name);
|
|
26278
26666
|
const text = readFileOrReport(fs17, configDir, relative, report);
|
|
26279
26667
|
const parsed = WorkflowRunFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
26280
26668
|
if (!parsed.success) {
|
|
@@ -26291,7 +26679,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
|
|
|
26291
26679
|
|
|
26292
26680
|
// src/agents/sessions.ts
|
|
26293
26681
|
init_cliError();
|
|
26294
|
-
import
|
|
26682
|
+
import path50 from "node:path";
|
|
26295
26683
|
var SessionLookupError = class extends CliError {
|
|
26296
26684
|
constructor(message) {
|
|
26297
26685
|
super(message);
|
|
@@ -26302,7 +26690,7 @@ function historyStores(fs17, configDirOf, identities) {
|
|
|
26302
26690
|
const byRealPath = /* @__PURE__ */ new Map();
|
|
26303
26691
|
for (const identity of identities) {
|
|
26304
26692
|
const configDir = configDirOf(identity);
|
|
26305
|
-
const real = fs17.realpath(
|
|
26693
|
+
const real = fs17.realpath(path50.join(configDir, "projects"));
|
|
26306
26694
|
if (real === void 0) {
|
|
26307
26695
|
continue;
|
|
26308
26696
|
}
|
|
@@ -26390,6 +26778,81 @@ init_names();
|
|
|
26390
26778
|
init_providersStore();
|
|
26391
26779
|
init_poolStore();
|
|
26392
26780
|
init_directoryRulesStore();
|
|
26781
|
+
|
|
26782
|
+
// src/doctorFormat.ts
|
|
26783
|
+
var SECTION_TITLES = {
|
|
26784
|
+
models: "Virtual models",
|
|
26785
|
+
"ambient-credential": "Ambient-credential exposure",
|
|
26786
|
+
"binary-discovery": "Claude Code binary discovery",
|
|
26787
|
+
"claude-shim": "`claude` command shim",
|
|
26788
|
+
"path-resolution": "PATH resolution",
|
|
26789
|
+
"legacy-name": "Former `claude-use` name",
|
|
26790
|
+
"config-profile": "Configuration profiles",
|
|
26791
|
+
identity: "Identities",
|
|
26792
|
+
"sign-in": "Sign-in",
|
|
26793
|
+
"farm-links": "Farm links",
|
|
26794
|
+
pool: "Pools",
|
|
26795
|
+
provider: "Providers",
|
|
26796
|
+
keychain: "macOS Keychain",
|
|
26797
|
+
"directory-rules": "Directory rules",
|
|
26798
|
+
"global-config": "Global config",
|
|
26799
|
+
headroom: "Headroom daemon",
|
|
26800
|
+
frontdoor: "Front door",
|
|
26801
|
+
"categories-local": "categories.local.json",
|
|
26802
|
+
"active-identity": "Active identity"
|
|
26803
|
+
};
|
|
26804
|
+
var SECTION_ORDER = [
|
|
26805
|
+
"ambient-credential",
|
|
26806
|
+
"binary-discovery",
|
|
26807
|
+
"claude-shim",
|
|
26808
|
+
"path-resolution",
|
|
26809
|
+
"legacy-name",
|
|
26810
|
+
"config-profile",
|
|
26811
|
+
"identity",
|
|
26812
|
+
"sign-in",
|
|
26813
|
+
"farm-links",
|
|
26814
|
+
"pool",
|
|
26815
|
+
"provider",
|
|
26816
|
+
"keychain",
|
|
26817
|
+
"directory-rules",
|
|
26818
|
+
"global-config",
|
|
26819
|
+
"models",
|
|
26820
|
+
"headroom",
|
|
26821
|
+
"frontdoor",
|
|
26822
|
+
"categories-local",
|
|
26823
|
+
"active-identity"
|
|
26824
|
+
];
|
|
26825
|
+
function severityPrefix(severity) {
|
|
26826
|
+
switch (severity) {
|
|
26827
|
+
case "pass":
|
|
26828
|
+
return "[PASS]";
|
|
26829
|
+
case "warn":
|
|
26830
|
+
return "[WARN]";
|
|
26831
|
+
case "fail":
|
|
26832
|
+
return "[FAIL]";
|
|
26833
|
+
default:
|
|
26834
|
+
return severity;
|
|
26835
|
+
}
|
|
26836
|
+
}
|
|
26837
|
+
function formatDoctorReport(report) {
|
|
26838
|
+
const lines = [];
|
|
26839
|
+
for (const section of SECTION_ORDER) {
|
|
26840
|
+
const sectionFindings = report.findings.filter((finding) => finding.section === section);
|
|
26841
|
+
if (sectionFindings.length === 0) {
|
|
26842
|
+
continue;
|
|
26843
|
+
}
|
|
26844
|
+
lines.push("", `${SECTION_TITLES[section]}:`);
|
|
26845
|
+
for (const finding of sectionFindings) {
|
|
26846
|
+
const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
|
|
26847
|
+
lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
|
|
26848
|
+
}
|
|
26849
|
+
}
|
|
26850
|
+
const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
|
|
26851
|
+
lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
|
|
26852
|
+
return lines;
|
|
26853
|
+
}
|
|
26854
|
+
|
|
26855
|
+
// src/index.ts
|
|
26393
26856
|
init_launcher();
|
|
26394
26857
|
init_spawn();
|
|
26395
26858
|
init_launchWiring();
|