claude-use 14.4.0 → 14.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1536 -1173
- package/dist/index.cjs +1275 -898
- package/dist/index.mjs +1234 -857
- package/dist/types/index.d.ts +180 -62
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1480,7 +1480,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
|
|
|
1480
1480
|
return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
|
|
1481
1481
|
}
|
|
1482
1482
|
function describeIgnoredKeys(filePath, ignored) {
|
|
1483
|
-
const places = ignored.map(({ path:
|
|
1483
|
+
const places = ignored.map(({ path: path59, keys }) => `${path59.length === 0 ? "" : `${path59.map(String).join(".")}.`}${keys.join(", ")}`);
|
|
1484
1484
|
return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
|
|
1485
1485
|
}
|
|
1486
1486
|
function noteIgnoredKeys(filePath, ignored) {
|
|
@@ -1502,9 +1502,9 @@ function restoreIgnoredKeys(filePath, value) {
|
|
|
1502
1502
|
return value;
|
|
1503
1503
|
}
|
|
1504
1504
|
const restored = structuredClone(value);
|
|
1505
|
-
for (const { path:
|
|
1505
|
+
for (const { path: path59, values } of ignored) {
|
|
1506
1506
|
let holder = restored;
|
|
1507
|
-
for (const step of
|
|
1507
|
+
for (const step of path59) {
|
|
1508
1508
|
holder = isRecord(holder) ? holder[step] : void 0;
|
|
1509
1509
|
}
|
|
1510
1510
|
if (isRecord(holder)) {
|
|
@@ -5856,8 +5856,8 @@ function parseConnectTarget(authority) {
|
|
|
5856
5856
|
function isInterceptedHost(host, interceptHosts) {
|
|
5857
5857
|
return interceptHosts.includes(host);
|
|
5858
5858
|
}
|
|
5859
|
-
function servedByPipeline(
|
|
5860
|
-
return
|
|
5859
|
+
function servedByPipeline(path59) {
|
|
5860
|
+
return path59?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
5861
5861
|
}
|
|
5862
5862
|
function forwardableHeaders(headers) {
|
|
5863
5863
|
const connectionTokens = new Set(
|
|
@@ -6721,8 +6721,8 @@ function pathnameOf(url) {
|
|
|
6721
6721
|
return new URL(url ?? "/", "http://127.0.0.1").pathname;
|
|
6722
6722
|
}
|
|
6723
6723
|
function isRcSessionExchange(url) {
|
|
6724
|
-
const
|
|
6725
|
-
return
|
|
6724
|
+
const path59 = pathnameOf(url);
|
|
6725
|
+
return path59 === RC_SESSIONS_PATH_PREFIX || path59.startsWith(`${RC_SESSIONS_PATH_PREFIX}/`);
|
|
6726
6726
|
}
|
|
6727
6727
|
function isSuccessful(status) {
|
|
6728
6728
|
return status >= HTTP_STATUS.ok && status < SUCCESS_STATUS_MAX_EXCLUSIVE;
|
|
@@ -7457,8 +7457,8 @@ function buildRcGetContextUsagePayload(requestId, detail) {
|
|
|
7457
7457
|
function isRcReadFileEncoding(value) {
|
|
7458
7458
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
|
|
7459
7459
|
}
|
|
7460
|
-
function buildRcReadFilePayload(requestId,
|
|
7461
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
7460
|
+
function buildRcReadFilePayload(requestId, path59, options) {
|
|
7461
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path59, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
7462
7462
|
}
|
|
7463
7463
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
7464
7464
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -7592,15 +7592,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
7592
7592
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
7593
7593
|
return result.ok ? { ...result, requestId } : result;
|
|
7594
7594
|
}
|
|
7595
|
-
async function readRcSessionFile(deps, sessionId,
|
|
7596
|
-
if (
|
|
7595
|
+
async function readRcSessionFile(deps, sessionId, path59, options) {
|
|
7596
|
+
if (path59 === "") {
|
|
7597
7597
|
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" };
|
|
7598
7598
|
}
|
|
7599
7599
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
7600
7600
|
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" };
|
|
7601
7601
|
}
|
|
7602
7602
|
const requestId = deps.newUuid();
|
|
7603
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
7603
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path59, options), `read ${path59} from session ${sessionId}`);
|
|
7604
7604
|
return result.ok ? { ...result, requestId } : result;
|
|
7605
7605
|
}
|
|
7606
7606
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -7674,7 +7674,7 @@ var init_machineLoad = __esm({
|
|
|
7674
7674
|
function workerFactSchema(value) {
|
|
7675
7675
|
return import_zod12.z.strictObject({ value, observedAt: import_zod12.z.number() });
|
|
7676
7676
|
}
|
|
7677
|
-
var import_zod12, 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;
|
|
7677
|
+
var import_zod12, 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;
|
|
7678
7678
|
var init_rcSchemas = __esm({
|
|
7679
7679
|
"src/frontdoor/rcSchemas.ts"() {
|
|
7680
7680
|
"use strict";
|
|
@@ -7844,7 +7844,8 @@ var init_rcSchemas = __esm({
|
|
|
7844
7844
|
marker: import_zod12.z.string().min(1)
|
|
7845
7845
|
});
|
|
7846
7846
|
RcListOutputSchema = import_zod12.z.strictObject({ sessions: import_zod12.z.readonly(import_zod12.z.array(RcSessionSummarySchema)) });
|
|
7847
|
-
|
|
7847
|
+
RcSessionRouteSchema = import_zod12.z.union([import_zod12.z.strictObject({ route: import_zod12.z.enum(["supervised", "launched", "self-hosted"]) }), import_zod12.z.strictObject({ route: import_zod12.z.null(), refused: import_zod12.z.string() })]);
|
|
7848
|
+
RcStatusOutputSchema = import_zod12.z.strictObject({ statuses: import_zod12.z.readonly(import_zod12.z.array(import_zod12.z.strictObject({ ...RcSessionStatusSchema.shape, route: RcSessionRouteSchema }))) });
|
|
7848
7849
|
RcPendingOutputSchema = import_zod12.z.strictObject({
|
|
7849
7850
|
pending: import_zod12.z.readonly(import_zod12.z.array(RcPendingRequestSummarySchema)),
|
|
7850
7851
|
/** 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. */
|
|
@@ -7978,11 +7979,11 @@ function createRcControlHandler(deps) {
|
|
|
7978
7979
|
path: "read-file",
|
|
7979
7980
|
read: (body) => {
|
|
7980
7981
|
const session = bodyString(body, "session");
|
|
7981
|
-
const
|
|
7982
|
+
const path59 = bodyString(body, "path");
|
|
7982
7983
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
7983
7984
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
7984
|
-
const refused2 = session === void 0 ||
|
|
7985
|
-
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,
|
|
7985
|
+
const refused2 = session === void 0 || path59 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
7986
|
+
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 } }) };
|
|
7986
7987
|
}
|
|
7987
7988
|
},
|
|
7988
7989
|
{
|
|
@@ -8305,9 +8306,9 @@ function requestIdOfBody(body) {
|
|
|
8305
8306
|
}
|
|
8306
8307
|
function frontDoorRcControl(transport, token) {
|
|
8307
8308
|
const headers = { authorization: `Bearer ${token}` };
|
|
8308
|
-
const listAnswerOf = async (
|
|
8309
|
+
const listAnswerOf = async (path59, what) => {
|
|
8309
8310
|
try {
|
|
8310
|
-
return await transport.request({ method: "GET", path:
|
|
8311
|
+
return await transport.request({ method: "GET", path: path59, headers });
|
|
8311
8312
|
} catch (error) {
|
|
8312
8313
|
throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
8313
8314
|
}
|
|
@@ -8379,10 +8380,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
8379
8380
|
}
|
|
8380
8381
|
return pending;
|
|
8381
8382
|
};
|
|
8382
|
-
const writeOf = async (
|
|
8383
|
+
const writeOf = async (path59, body, describeFailure2) => {
|
|
8383
8384
|
let answer;
|
|
8384
8385
|
try {
|
|
8385
|
-
answer = await transport.request({ method: "POST", path:
|
|
8386
|
+
answer = await transport.request({ method: "POST", path: path59, headers: { ...headers, "content-type": "application/json" }, body });
|
|
8386
8387
|
} catch (error) {
|
|
8387
8388
|
return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
|
|
8388
8389
|
}
|
|
@@ -8413,10 +8414,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
8413
8414
|
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}`),
|
|
8414
8415
|
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}`),
|
|
8415
8416
|
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}`),
|
|
8416
|
-
readFile: async (sessionId,
|
|
8417
|
+
readFile: async (sessionId, path59, options) => await writeOf(
|
|
8417
8418
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
8418
|
-
JSON.stringify({ session: sessionId, path:
|
|
8419
|
-
(status, message) => `reading ${
|
|
8419
|
+
JSON.stringify({ session: sessionId, path: path59, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
8420
|
+
(status, message) => `reading ${path59} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
8420
8421
|
),
|
|
8421
8422
|
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}`),
|
|
8422
8423
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -8653,12 +8654,12 @@ function tlsFacts(options) {
|
|
|
8653
8654
|
}
|
|
8654
8655
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
8655
8656
|
const agent = new ExemptTlsAgent();
|
|
8656
|
-
const post = async (
|
|
8657
|
+
const post = async (path59, headers, body) => await new Promise((resolve, reject) => {
|
|
8657
8658
|
const options = {
|
|
8658
8659
|
host: target.host,
|
|
8659
8660
|
port: target.port,
|
|
8660
8661
|
method: "POST",
|
|
8661
|
-
path:
|
|
8662
|
+
path: path59,
|
|
8662
8663
|
// 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.
|
|
8663
8664
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
8664
8665
|
agent
|
|
@@ -8718,12 +8719,12 @@ function lateRcStreamDial(resolve) {
|
|
|
8718
8719
|
}
|
|
8719
8720
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
8720
8721
|
const agent = new ExemptTlsAgent();
|
|
8721
|
-
const request4 = async (method,
|
|
8722
|
+
const request4 = async (method, path59, headers, body, signal) => await new Promise((resolve, reject) => {
|
|
8722
8723
|
const options = {
|
|
8723
8724
|
host: target.host,
|
|
8724
8725
|
port: target.port,
|
|
8725
8726
|
method,
|
|
8726
|
-
path:
|
|
8727
|
+
path: path59,
|
|
8727
8728
|
// 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.
|
|
8728
8729
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
8729
8730
|
agent,
|
|
@@ -8765,9 +8766,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
8765
8766
|
return { status, body: await readAll(response) };
|
|
8766
8767
|
},
|
|
8767
8768
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
8768
|
-
const
|
|
8769
|
+
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)}`;
|
|
8769
8770
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
8770
|
-
const { status, response } = await request4("GET",
|
|
8771
|
+
const { status, response } = await request4("GET", path59, streamHeaders, void 0, signal);
|
|
8771
8772
|
if (!isSuccessful2(status)) {
|
|
8772
8773
|
await readAll(response);
|
|
8773
8774
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -9259,9 +9260,9 @@ var init_identity2 = __esm({
|
|
|
9259
9260
|
});
|
|
9260
9261
|
|
|
9261
9262
|
// src/statusline/keys.ts
|
|
9262
|
-
function valueAt(source,
|
|
9263
|
+
function valueAt(source, path59) {
|
|
9263
9264
|
let current = source;
|
|
9264
|
-
for (const part of
|
|
9265
|
+
for (const part of path59) {
|
|
9265
9266
|
if (!isPlainObject(current)) {
|
|
9266
9267
|
return void 0;
|
|
9267
9268
|
}
|
|
@@ -9269,14 +9270,14 @@ function valueAt(source, path56) {
|
|
|
9269
9270
|
}
|
|
9270
9271
|
return current;
|
|
9271
9272
|
}
|
|
9272
|
-
function acceptsNull(
|
|
9273
|
-
const layer =
|
|
9273
|
+
function acceptsNull(path59) {
|
|
9274
|
+
const layer = path59.reduceRight((inner, part) => ({ [part]: inner }), null);
|
|
9274
9275
|
return StatuslineSchema.safeParse(layer).success;
|
|
9275
9276
|
}
|
|
9276
|
-
function keyOf(
|
|
9277
|
+
function keyOf(path59, declared) {
|
|
9277
9278
|
const optional = declared instanceof import_zod13.z.ZodOptional;
|
|
9278
9279
|
const leaf = optional ? declared.unwrap() : declared;
|
|
9279
|
-
const common = { path:
|
|
9280
|
+
const common = { path: path59.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path59), optional, unsettable: acceptsNull(path59) };
|
|
9280
9281
|
if (leaf instanceof import_zod13.z.ZodNumber) {
|
|
9281
9282
|
return { ...common, kind: "integer", choices: [] };
|
|
9282
9283
|
}
|
|
@@ -9301,7 +9302,7 @@ function keyOf(path56, declared) {
|
|
|
9301
9302
|
if (leaf instanceof import_zod13.z.ZodArray && leaf.element instanceof import_zod13.z.ZodString) {
|
|
9302
9303
|
return { ...common, kind: "textList", choices: [] };
|
|
9303
9304
|
}
|
|
9304
|
-
throw new TypeError(`statusline setting ${
|
|
9305
|
+
throw new TypeError(`statusline setting ${path59.join(".")} has a kind the key listing does not describe`);
|
|
9305
9306
|
}
|
|
9306
9307
|
function walk(shape, prefix) {
|
|
9307
9308
|
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof import_zod13.z.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
@@ -9319,15 +9320,15 @@ var init_keys = __esm({
|
|
|
9319
9320
|
});
|
|
9320
9321
|
|
|
9321
9322
|
// src/statusline/change.ts
|
|
9322
|
-
function keyNamed(
|
|
9323
|
-
const found = statuslineKeys().find((key) => key.path ===
|
|
9323
|
+
function keyNamed(path59) {
|
|
9324
|
+
const found = statuslineKeys().find((key) => key.path === path59);
|
|
9324
9325
|
if (found === void 0) {
|
|
9325
|
-
throw new UsageError(`"${
|
|
9326
|
+
throw new UsageError(`"${path59}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
|
|
9326
9327
|
}
|
|
9327
9328
|
return found;
|
|
9328
9329
|
}
|
|
9329
|
-
function setAt(target,
|
|
9330
|
-
const [head, ...rest] =
|
|
9330
|
+
function setAt(target, path59, value) {
|
|
9331
|
+
const [head, ...rest] = path59;
|
|
9331
9332
|
if (head === void 0) {
|
|
9332
9333
|
return;
|
|
9333
9334
|
}
|
|
@@ -9340,8 +9341,8 @@ function setAt(target, path56, value) {
|
|
|
9340
9341
|
target[head] = next;
|
|
9341
9342
|
setAt(next, rest, value);
|
|
9342
9343
|
}
|
|
9343
|
-
function removeAt(target,
|
|
9344
|
-
const [head, ...rest] =
|
|
9344
|
+
function removeAt(target, path59) {
|
|
9345
|
+
const [head, ...rest] = path59;
|
|
9345
9346
|
if (head === void 0) {
|
|
9346
9347
|
return;
|
|
9347
9348
|
}
|
|
@@ -9359,13 +9360,13 @@ function removeAt(target, path56) {
|
|
|
9359
9360
|
}
|
|
9360
9361
|
function applyStatuslineChange(existing, change) {
|
|
9361
9362
|
const draft = structuredClone(existing ?? {});
|
|
9362
|
-
for (const [
|
|
9363
|
-
keyNamed(
|
|
9364
|
-
setAt(draft,
|
|
9363
|
+
for (const [path59, value] of Object.entries(change.set ?? {})) {
|
|
9364
|
+
keyNamed(path59);
|
|
9365
|
+
setAt(draft, path59.split("."), value);
|
|
9365
9366
|
}
|
|
9366
|
-
for (const
|
|
9367
|
-
keyNamed(
|
|
9368
|
-
removeAt(draft,
|
|
9367
|
+
for (const path59 of change.unset ?? []) {
|
|
9368
|
+
keyNamed(path59);
|
|
9369
|
+
removeAt(draft, path59.split("."));
|
|
9369
9370
|
}
|
|
9370
9371
|
const result = StatuslineSchema.safeParse(draft);
|
|
9371
9372
|
if (!result.success) {
|
|
@@ -9601,19 +9602,19 @@ function writePools(paths, pools) {
|
|
|
9601
9602
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
9602
9603
|
}
|
|
9603
9604
|
function poolCycleOf(pools, name) {
|
|
9604
|
-
const walk2 = (current,
|
|
9605
|
+
const walk2 = (current, path59) => {
|
|
9605
9606
|
for (const entry of pools[current]?.identities ?? []) {
|
|
9606
9607
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
9607
9608
|
if (nested === void 0) {
|
|
9608
9609
|
continue;
|
|
9609
9610
|
}
|
|
9610
9611
|
if (nested === name) {
|
|
9611
|
-
return [...
|
|
9612
|
+
return [...path59, nested];
|
|
9612
9613
|
}
|
|
9613
|
-
if (
|
|
9614
|
+
if (path59.includes(nested)) {
|
|
9614
9615
|
continue;
|
|
9615
9616
|
}
|
|
9616
|
-
const found = walk2(nested, [...
|
|
9617
|
+
const found = walk2(nested, [...path59, nested]);
|
|
9617
9618
|
if (found !== void 0) {
|
|
9618
9619
|
return found;
|
|
9619
9620
|
}
|
|
@@ -14155,7 +14156,7 @@ var init_package = __esm({
|
|
|
14155
14156
|
"package.json"() {
|
|
14156
14157
|
package_default = {
|
|
14157
14158
|
name: "claude-use",
|
|
14158
|
-
version: "14.
|
|
14159
|
+
version: "14.5.1",
|
|
14159
14160
|
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.",
|
|
14160
14161
|
license: "MIT",
|
|
14161
14162
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -14261,6 +14262,28 @@ var init_package = __esm({
|
|
|
14261
14262
|
}
|
|
14262
14263
|
});
|
|
14263
14264
|
|
|
14265
|
+
// src/supervise/sessionControl.ts
|
|
14266
|
+
var import_node_path33, import_zod24, RESULT_POLL_MS, SessionControlConversationSchema, REQUEST_INSTANT_DIGITS;
|
|
14267
|
+
var init_sessionControl = __esm({
|
|
14268
|
+
"src/supervise/sessionControl.ts"() {
|
|
14269
|
+
"use strict";
|
|
14270
|
+
import_node_path33 = __toESM(require("node:path"), 1);
|
|
14271
|
+
import_zod24 = require("zod");
|
|
14272
|
+
RESULT_POLL_MS = 250;
|
|
14273
|
+
SessionControlConversationSchema = import_zod24.z.object({ conversationId: import_zod24.z.string().min(1), transcriptPath: import_zod24.z.string().refine(import_node_path33.default.isAbsolute) });
|
|
14274
|
+
REQUEST_INSTANT_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
|
|
14275
|
+
}
|
|
14276
|
+
});
|
|
14277
|
+
|
|
14278
|
+
// src/supervise/verifiedVersions.ts
|
|
14279
|
+
var RC_SESSION_COMMAND_VERIFIED_VERSIONS;
|
|
14280
|
+
var init_verifiedVersions = __esm({
|
|
14281
|
+
"src/supervise/verifiedVersions.ts"() {
|
|
14282
|
+
"use strict";
|
|
14283
|
+
RC_SESSION_COMMAND_VERIFIED_VERSIONS = ["2.1.319", "2.1.325"];
|
|
14284
|
+
}
|
|
14285
|
+
});
|
|
14286
|
+
|
|
14264
14287
|
// src/launcher/claudeVersion.ts
|
|
14265
14288
|
function validated2(value, origin) {
|
|
14266
14289
|
if (!NUMERIC_DOTTED_VERSION_RE.test(value)) {
|
|
@@ -14386,10 +14409,10 @@ function isLauncherScript(candidate) {
|
|
|
14386
14409
|
}
|
|
14387
14410
|
function resolveOwnBinaryCheck(paths, contentSourcePath) {
|
|
14388
14411
|
const state = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
14389
|
-
const recordedTarget = state === void 0 ? void 0 :
|
|
14412
|
+
const recordedTarget = state === void 0 ? void 0 : import_node_path34.default.resolve(state.targetPath);
|
|
14390
14413
|
let ownStat;
|
|
14391
14414
|
return (candidate) => {
|
|
14392
|
-
if (recordedTarget !== void 0 &&
|
|
14415
|
+
if (recordedTarget !== void 0 && import_node_path34.default.resolve(candidate) === recordedTarget) {
|
|
14393
14416
|
return true;
|
|
14394
14417
|
}
|
|
14395
14418
|
ownStat ??= statOrUndefined(contentSourcePath);
|
|
@@ -14413,31 +14436,31 @@ function statOrUndefined(target) {
|
|
|
14413
14436
|
}
|
|
14414
14437
|
}
|
|
14415
14438
|
function findPathShadow(params) {
|
|
14416
|
-
const resolvedTargetDir =
|
|
14439
|
+
const resolvedTargetDir = import_node_path34.default.resolve(params.targetDir);
|
|
14417
14440
|
for (const dir of params.pathDirs) {
|
|
14418
14441
|
const found = params.findExecutableInDir(dir, params.targetFilename);
|
|
14419
14442
|
if (found === void 0) {
|
|
14420
14443
|
continue;
|
|
14421
14444
|
}
|
|
14422
|
-
return
|
|
14445
|
+
return import_node_path34.default.resolve(dir) === resolvedTargetDir ? { status: "ok" } : { status: "shadowed", by: found };
|
|
14423
14446
|
}
|
|
14424
|
-
return params.pathDirs.some((dir) =>
|
|
14447
|
+
return params.pathDirs.some((dir) => import_node_path34.default.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
|
|
14425
14448
|
}
|
|
14426
|
-
var import_node_fs9,
|
|
14449
|
+
var import_node_fs9, import_node_path34, import_zod30, ClaudeShimStateSchema, SCRIPT_HEAD_BYTES, LAUNCHER_NAME, EXEC_RUN, nodeLinkFs;
|
|
14427
14450
|
var init_claudeShim = __esm({
|
|
14428
14451
|
"src/claudeShim.ts"() {
|
|
14429
14452
|
"use strict";
|
|
14430
14453
|
import_node_fs9 = __toESM(require("node:fs"), 1);
|
|
14431
|
-
|
|
14432
|
-
|
|
14454
|
+
import_node_path34 = __toESM(require("node:path"), 1);
|
|
14455
|
+
import_zod30 = require("zod");
|
|
14433
14456
|
init_commandDeps();
|
|
14434
14457
|
init_store();
|
|
14435
14458
|
init_realPorts();
|
|
14436
14459
|
init_cliError();
|
|
14437
|
-
ClaudeShimStateSchema =
|
|
14438
|
-
targetPath:
|
|
14439
|
-
method:
|
|
14440
|
-
installedAtMs:
|
|
14460
|
+
ClaudeShimStateSchema = import_zod30.z.strictObject({
|
|
14461
|
+
targetPath: import_zod30.z.string().min(1),
|
|
14462
|
+
method: import_zod30.z.enum(["hardlink", "copy"]),
|
|
14463
|
+
installedAtMs: import_zod30.z.number()
|
|
14441
14464
|
});
|
|
14442
14465
|
SCRIPT_HEAD_BYTES = 4096;
|
|
14443
14466
|
LAUNCHER_NAME = /\b(agent-shim|claude-use)\b/;
|
|
@@ -14853,15 +14876,15 @@ function aliasFindings(aliases, providerNames) {
|
|
|
14853
14876
|
return { level: "pass", alias, message: `${alias} is a former name of ${target}, still honoured for sessions launched under it. Run \`agent-shim provider unalias ${alias}\` once none is running.` };
|
|
14854
14877
|
});
|
|
14855
14878
|
}
|
|
14856
|
-
var
|
|
14879
|
+
var import_zod31, ProviderAliasesSchema;
|
|
14857
14880
|
var init_providerAliases = __esm({
|
|
14858
14881
|
"src/providerAliases.ts"() {
|
|
14859
14882
|
"use strict";
|
|
14860
|
-
|
|
14883
|
+
import_zod31 = require("zod");
|
|
14861
14884
|
init_cliError();
|
|
14862
14885
|
init_load();
|
|
14863
14886
|
init_store();
|
|
14864
|
-
ProviderAliasesSchema =
|
|
14887
|
+
ProviderAliasesSchema = import_zod31.z.record(import_zod31.z.string().min(1), import_zod31.z.string().min(1));
|
|
14865
14888
|
}
|
|
14866
14889
|
});
|
|
14867
14890
|
|
|
@@ -15438,18 +15461,18 @@ function expandTilde(value, home) {
|
|
|
15438
15461
|
return home;
|
|
15439
15462
|
}
|
|
15440
15463
|
if (value.startsWith("~/")) {
|
|
15441
|
-
return
|
|
15464
|
+
return import_node_path38.default.join(home, value.slice(2));
|
|
15442
15465
|
}
|
|
15443
15466
|
return value;
|
|
15444
15467
|
}
|
|
15445
15468
|
function normaliseRulePath(rulePath, home) {
|
|
15446
|
-
return
|
|
15469
|
+
return import_node_path38.default.resolve(expandTilde(rulePath, home));
|
|
15447
15470
|
}
|
|
15448
|
-
var
|
|
15471
|
+
var import_node_path38;
|
|
15449
15472
|
var init_pathNorm = __esm({
|
|
15450
15473
|
"src/pathNorm.ts"() {
|
|
15451
15474
|
"use strict";
|
|
15452
|
-
|
|
15475
|
+
import_node_path38 = __toESM(require("node:path"), 1);
|
|
15453
15476
|
}
|
|
15454
15477
|
});
|
|
15455
15478
|
|
|
@@ -15473,8 +15496,8 @@ function loadCascadeInput(params) {
|
|
|
15473
15496
|
});
|
|
15474
15497
|
const levels = [];
|
|
15475
15498
|
for (const dir of dirs) {
|
|
15476
|
-
const portable = loadConfigFile(
|
|
15477
|
-
const portableLocal = loadConfigFile(
|
|
15499
|
+
const portable = loadConfigFile(import_node_path39.default.join(dir, PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(import_node_path39.default.join(dir, LEGACY_PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read);
|
|
15500
|
+
const portableLocal = loadConfigFile(import_node_path39.default.join(dir, PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(import_node_path39.default.join(dir, LEGACY_PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read);
|
|
15478
15501
|
const rules = (directoryRules?.config.rules ?? []).map((rule, index) => ({ rule, index })).filter(({ rule }) => normaliseRulePath(rule.path, params.home) === dir).map(({ rule, index }) => {
|
|
15479
15502
|
const entryOrder = directoryRules?.ruleEntryOrders[index];
|
|
15480
15503
|
return {
|
|
@@ -15521,11 +15544,11 @@ function readDirectorySelections(loaded) {
|
|
|
15521
15544
|
}
|
|
15522
15545
|
return { ...identity === void 0 ? {} : { identity }, ...configProfile === void 0 ? {} : { configProfile } };
|
|
15523
15546
|
}
|
|
15524
|
-
var
|
|
15547
|
+
var import_node_path39, PORTABLE_CONFIG_FILENAME, PORTABLE_LOCAL_CONFIG_FILENAME;
|
|
15525
15548
|
var init_cascade = __esm({
|
|
15526
15549
|
"src/launcher/cascade.ts"() {
|
|
15527
15550
|
"use strict";
|
|
15528
|
-
|
|
15551
|
+
import_node_path39 = __toESM(require("node:path"), 1);
|
|
15529
15552
|
init_load();
|
|
15530
15553
|
init_schema();
|
|
15531
15554
|
init_pathNorm();
|
|
@@ -15618,8 +15641,8 @@ function resolveAgentShimHome(env = process.env, home = import_node_os5.default.
|
|
|
15618
15641
|
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15619
15642
|
return fromEnv;
|
|
15620
15643
|
}
|
|
15621
|
-
const current =
|
|
15622
|
-
const legacy =
|
|
15644
|
+
const current = import_node_path40.default.join(home, HOME_DIRNAME);
|
|
15645
|
+
const legacy = import_node_path40.default.join(home, LEGACY_HOME_DIRNAME);
|
|
15623
15646
|
return !isDirectory(current) && isDirectory(legacy) ? legacy : current;
|
|
15624
15647
|
}
|
|
15625
15648
|
function isExistingDirectory(candidate) {
|
|
@@ -15630,71 +15653,72 @@ function resolveClaudeHome() {
|
|
|
15630
15653
|
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15631
15654
|
return fromEnv;
|
|
15632
15655
|
}
|
|
15633
|
-
return
|
|
15656
|
+
return import_node_path40.default.join(import_node_os5.default.homedir(), ".claude");
|
|
15634
15657
|
}
|
|
15635
15658
|
function buildLayoutPaths(root) {
|
|
15636
15659
|
return {
|
|
15637
15660
|
root,
|
|
15638
|
-
identitiesDir:
|
|
15639
|
-
configProfilesDir:
|
|
15640
|
-
providersDir:
|
|
15641
|
-
providerAliasesFile:
|
|
15642
|
-
directoryRulesFile:
|
|
15643
|
-
activeIdentityFile:
|
|
15644
|
-
globalConfigFile:
|
|
15645
|
-
categoriesLocalFile:
|
|
15646
|
-
claudeShimFile:
|
|
15647
|
-
headroomDir:
|
|
15648
|
-
headroomStateFile:
|
|
15649
|
-
headroomRoutingFile:
|
|
15650
|
-
headroomLegacyStateFile:
|
|
15651
|
-
headroomAllowlistFile:
|
|
15652
|
-
headroomSocketDir:
|
|
15653
|
-
headroomLockFile:
|
|
15654
|
-
headroomSessionsDir:
|
|
15655
|
-
logsDir:
|
|
15656
|
-
headroomLogPath:
|
|
15657
|
-
frontdoorDir:
|
|
15658
|
-
frontdoorCaDir:
|
|
15659
|
-
frontdoorCaCertFile:
|
|
15660
|
-
frontdoorCaKeyFile:
|
|
15661
|
-
frontdoorCaBundlesDir:
|
|
15662
|
-
chatgptSignInFile:
|
|
15663
|
-
frontdoorStateFile:
|
|
15664
|
-
frontdoorLockFile:
|
|
15665
|
-
frontdoorControlTokenFile:
|
|
15666
|
-
frontdoorSessionsDir:
|
|
15667
|
-
frontdoorDirectRecordsDir:
|
|
15668
|
-
frontdoorDrainingDir:
|
|
15669
|
-
frontdoorRcCredentialsDir:
|
|
15670
|
-
frontdoorLogPath:
|
|
15671
|
-
usageDir:
|
|
15672
|
-
usageLogDir:
|
|
15673
|
-
usageSnapshotsDir:
|
|
15674
|
-
statuslineDir:
|
|
15675
|
-
catalogueDir:
|
|
15676
|
-
usagePicksFile:
|
|
15677
|
-
usageAnchorsFile:
|
|
15678
|
-
usageJobsFile:
|
|
15679
|
-
jobLogsDir:
|
|
15680
|
-
identityRenamesDir:
|
|
15681
|
-
identityNameRenamesDir:
|
|
15682
|
-
launchesDir:
|
|
15683
|
-
|
|
15684
|
-
|
|
15685
|
-
|
|
15661
|
+
identitiesDir: import_node_path40.default.join(root, "identities"),
|
|
15662
|
+
configProfilesDir: import_node_path40.default.join(root, "config-profiles"),
|
|
15663
|
+
providersDir: import_node_path40.default.join(root, "providers"),
|
|
15664
|
+
providerAliasesFile: import_node_path40.default.join(root, "provider-aliases.json"),
|
|
15665
|
+
directoryRulesFile: import_node_path40.default.join(root, "directory-rules.json"),
|
|
15666
|
+
activeIdentityFile: import_node_path40.default.join(root, "active-identity"),
|
|
15667
|
+
globalConfigFile: import_node_path40.default.join(root, "config.json"),
|
|
15668
|
+
categoriesLocalFile: import_node_path40.default.join(root, "categories.local.json"),
|
|
15669
|
+
claudeShimFile: import_node_path40.default.join(root, "claude-shim.json"),
|
|
15670
|
+
headroomDir: import_node_path40.default.join(root, "headroom"),
|
|
15671
|
+
headroomStateFile: import_node_path40.default.join(root, "headroom", "state.json"),
|
|
15672
|
+
headroomRoutingFile: import_node_path40.default.join(root, "headroom", "routing.json"),
|
|
15673
|
+
headroomLegacyStateFile: import_node_path40.default.join(root, "headroom", "state.v2.json"),
|
|
15674
|
+
headroomAllowlistFile: import_node_path40.default.join(root, "headroom", "run", "allowlist.txt"),
|
|
15675
|
+
headroomSocketDir: import_node_path40.default.join(root, "headroom", "run"),
|
|
15676
|
+
headroomLockFile: import_node_path40.default.join(root, "headroom", "start.lock"),
|
|
15677
|
+
headroomSessionsDir: import_node_path40.default.join(root, "headroom", "sessions"),
|
|
15678
|
+
logsDir: import_node_path40.default.join(root, "logs"),
|
|
15679
|
+
headroomLogPath: import_node_path40.default.join(root, "logs", "headroom.log"),
|
|
15680
|
+
frontdoorDir: import_node_path40.default.join(root, "frontdoor"),
|
|
15681
|
+
frontdoorCaDir: import_node_path40.default.join(root, "frontdoor", "ca"),
|
|
15682
|
+
frontdoorCaCertFile: import_node_path40.default.join(root, "frontdoor", "ca", "ca.pem"),
|
|
15683
|
+
frontdoorCaKeyFile: import_node_path40.default.join(root, "frontdoor", "ca", "ca.key"),
|
|
15684
|
+
frontdoorCaBundlesDir: import_node_path40.default.join(root, "frontdoor", "ca", "bundles"),
|
|
15685
|
+
chatgptSignInFile: import_node_path40.default.join(root, "codex", "chatgpt-sign-in.json"),
|
|
15686
|
+
frontdoorStateFile: import_node_path40.default.join(root, "frontdoor", "state.json"),
|
|
15687
|
+
frontdoorLockFile: import_node_path40.default.join(root, "frontdoor", "start.lock"),
|
|
15688
|
+
frontdoorControlTokenFile: import_node_path40.default.join(root, "frontdoor", "control-token"),
|
|
15689
|
+
frontdoorSessionsDir: import_node_path40.default.join(root, "frontdoor", "sessions"),
|
|
15690
|
+
frontdoorDirectRecordsDir: import_node_path40.default.join(root, "frontdoor", "direct"),
|
|
15691
|
+
frontdoorDrainingDir: import_node_path40.default.join(root, "frontdoor", "draining"),
|
|
15692
|
+
frontdoorRcCredentialsDir: import_node_path40.default.join(root, "frontdoor", "rc-credentials"),
|
|
15693
|
+
frontdoorLogPath: import_node_path40.default.join(root, "logs", "frontdoor.log"),
|
|
15694
|
+
usageDir: import_node_path40.default.join(root, "usage"),
|
|
15695
|
+
usageLogDir: import_node_path40.default.join(root, "usage", "log"),
|
|
15696
|
+
usageSnapshotsDir: import_node_path40.default.join(root, "usage", "snapshots"),
|
|
15697
|
+
statuslineDir: import_node_path40.default.join(root, "statusline"),
|
|
15698
|
+
catalogueDir: import_node_path40.default.join(root, "catalogues"),
|
|
15699
|
+
usagePicksFile: import_node_path40.default.join(root, "usage", "picks.json"),
|
|
15700
|
+
usageAnchorsFile: import_node_path40.default.join(root, "usage", "anchors.json"),
|
|
15701
|
+
usageJobsFile: import_node_path40.default.join(root, "usage", "jobs.json"),
|
|
15702
|
+
jobLogsDir: import_node_path40.default.join(root, "logs", "jobs"),
|
|
15703
|
+
identityRenamesDir: import_node_path40.default.join(root, "identity-renames"),
|
|
15704
|
+
identityNameRenamesDir: import_node_path40.default.join(root, "identity-name-renames"),
|
|
15705
|
+
launchesDir: import_node_path40.default.join(root, "launches"),
|
|
15706
|
+
launchControlDir: import_node_path40.default.join(root, "launch-control"),
|
|
15707
|
+
superviseDir: import_node_path40.default.join(root, "supervise"),
|
|
15708
|
+
modelMovesDir: import_node_path40.default.join(root, "model-moves"),
|
|
15709
|
+
mcpPermissionsFile: import_node_path40.default.join(root, "mcp", "permissions.json")
|
|
15686
15710
|
};
|
|
15687
15711
|
}
|
|
15688
15712
|
function resolveLayoutPaths() {
|
|
15689
15713
|
return buildLayoutPaths(resolveAgentShimHome());
|
|
15690
15714
|
}
|
|
15691
|
-
var import_node_fs12, import_node_os5,
|
|
15715
|
+
var import_node_fs12, import_node_os5, import_node_path40;
|
|
15692
15716
|
var init_paths = __esm({
|
|
15693
15717
|
"src/paths.ts"() {
|
|
15694
15718
|
"use strict";
|
|
15695
15719
|
import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
15696
15720
|
import_node_os5 = __toESM(require("node:os"), 1);
|
|
15697
|
-
|
|
15721
|
+
import_node_path40 = __toESM(require("node:path"), 1);
|
|
15698
15722
|
init_legacy();
|
|
15699
15723
|
}
|
|
15700
15724
|
});
|
|
@@ -15708,16 +15732,16 @@ function catalogueReadFault(error) {
|
|
|
15708
15732
|
return typeof code === "string" && /^[A-Z0-9_]{1,32}$/u.test(code) ? code : error instanceof Error ? error.name : "an error";
|
|
15709
15733
|
}
|
|
15710
15734
|
function catalogueStatusFile(paths, owner, name) {
|
|
15711
|
-
return
|
|
15735
|
+
return import_node_path42.default.join(import_node_path42.default.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), `${name}.status.json`);
|
|
15712
15736
|
}
|
|
15713
15737
|
function catalogueFailureFile(paths, owner, name) {
|
|
15714
|
-
return
|
|
15738
|
+
return import_node_path42.default.join(import_node_path42.default.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), "failures", `${name}.json`);
|
|
15715
15739
|
}
|
|
15716
|
-
var
|
|
15740
|
+
var import_node_path42, UnreadableCatalogueError, skipUnreadableCatalogue, TolerantReader, StoredCatalogue;
|
|
15717
15741
|
var init_storedCatalogue = __esm({
|
|
15718
15742
|
"src/storedCatalogue.ts"() {
|
|
15719
15743
|
"use strict";
|
|
15720
|
-
|
|
15744
|
+
import_node_path42 = __toESM(require("node:path"), 1);
|
|
15721
15745
|
init_providerCatalogue();
|
|
15722
15746
|
UnreadableCatalogueError = class extends Error {
|
|
15723
15747
|
fault;
|
|
@@ -15807,7 +15831,7 @@ function readCatalogueFailure(fs17, paths, pid, generation, name) {
|
|
|
15807
15831
|
const raw = new StoredCatalogue(paths, skippingReader(fs17)).failureText({ pid, generation }, name);
|
|
15808
15832
|
if (raw === void 0) return void 0;
|
|
15809
15833
|
try {
|
|
15810
|
-
const value =
|
|
15834
|
+
const value = import_zod33.z.strictObject({ reason: import_zod33.z.string().max(CATALOGUE_FAILURE_REASON_MAX_CHARS), redirected: import_zod33.z.literal(true).optional(), settings: import_zod33.z.string().optional() }).safeParse(JSON.parse(raw));
|
|
15811
15835
|
return value.success ? { reason: value.data.reason, redirected: value.data.redirected === true, settings: value.data.settings } : void 0;
|
|
15812
15836
|
} catch {
|
|
15813
15837
|
return void 0;
|
|
@@ -15817,17 +15841,17 @@ function readCatalogueStatus(fs17, paths, pid, generation, name) {
|
|
|
15817
15841
|
const raw = new StoredCatalogue(paths, skippingReader(fs17)).statusText({ pid, generation }, name);
|
|
15818
15842
|
if (raw === void 0) return void 0;
|
|
15819
15843
|
try {
|
|
15820
|
-
const value =
|
|
15844
|
+
const value = import_zod33.z.strictObject({ status: import_zod33.z.enum(["running", "ready", "failed"]), fingerprint: import_zod33.z.string().min(1).optional(), recordedAt: import_zod33.z.number().optional() }).safeParse(JSON.parse(raw));
|
|
15821
15845
|
return value.success ? value.data : void 0;
|
|
15822
15846
|
} catch {
|
|
15823
15847
|
return void 0;
|
|
15824
15848
|
}
|
|
15825
15849
|
}
|
|
15826
|
-
var
|
|
15850
|
+
var import_zod33, CATALOGUE_FAILURE_REASON_MAX_CHARS;
|
|
15827
15851
|
var init_catalogueState = __esm({
|
|
15828
15852
|
"src/frontdoor/catalogueState.ts"() {
|
|
15829
15853
|
"use strict";
|
|
15830
|
-
|
|
15854
|
+
import_zod33 = require("zod");
|
|
15831
15855
|
init_storedCatalogue();
|
|
15832
15856
|
init_tolerantReaders();
|
|
15833
15857
|
CATALOGUE_FAILURE_REASON_MAX_CHARS = 600;
|
|
@@ -15835,25 +15859,25 @@ var init_catalogueState = __esm({
|
|
|
15835
15859
|
});
|
|
15836
15860
|
|
|
15837
15861
|
// src/codex/auth.ts
|
|
15838
|
-
var
|
|
15862
|
+
var import_zod34, AuthFileSchema, TokenGrantSchema, CodexAuthError;
|
|
15839
15863
|
var init_auth = __esm({
|
|
15840
15864
|
"src/codex/auth.ts"() {
|
|
15841
15865
|
"use strict";
|
|
15842
|
-
|
|
15843
|
-
AuthFileSchema =
|
|
15844
|
-
tokens:
|
|
15845
|
-
access_token:
|
|
15846
|
-
refresh_token:
|
|
15847
|
-
id_token:
|
|
15848
|
-
account_id:
|
|
15866
|
+
import_zod34 = require("zod");
|
|
15867
|
+
AuthFileSchema = import_zod34.z.looseObject({
|
|
15868
|
+
tokens: import_zod34.z.looseObject({
|
|
15869
|
+
access_token: import_zod34.z.string().optional(),
|
|
15870
|
+
refresh_token: import_zod34.z.string().optional(),
|
|
15871
|
+
id_token: import_zod34.z.string().optional(),
|
|
15872
|
+
account_id: import_zod34.z.string().optional()
|
|
15849
15873
|
}).nullish(),
|
|
15850
|
-
last_refresh:
|
|
15874
|
+
last_refresh: import_zod34.z.string().optional()
|
|
15851
15875
|
});
|
|
15852
|
-
TokenGrantSchema =
|
|
15853
|
-
access_token:
|
|
15854
|
-
refresh_token:
|
|
15855
|
-
id_token:
|
|
15856
|
-
account_id:
|
|
15876
|
+
TokenGrantSchema = import_zod34.z.looseObject({
|
|
15877
|
+
access_token: import_zod34.z.string().min(1).optional(),
|
|
15878
|
+
refresh_token: import_zod34.z.string().min(1).optional(),
|
|
15879
|
+
id_token: import_zod34.z.string().min(1).optional(),
|
|
15880
|
+
account_id: import_zod34.z.string().min(1).optional()
|
|
15857
15881
|
});
|
|
15858
15882
|
CodexAuthError = class extends Error {
|
|
15859
15883
|
constructor(message) {
|
|
@@ -15865,31 +15889,31 @@ var init_auth = __esm({
|
|
|
15865
15889
|
});
|
|
15866
15890
|
|
|
15867
15891
|
// src/codex/siwc.ts
|
|
15868
|
-
var
|
|
15892
|
+
var import_zod35, SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
|
|
15869
15893
|
var init_siwc = __esm({
|
|
15870
15894
|
"src/codex/siwc.ts"() {
|
|
15871
15895
|
"use strict";
|
|
15872
|
-
|
|
15896
|
+
import_zod35 = require("zod");
|
|
15873
15897
|
SIWC_RESOURCE = "https://api.openai.com/v1";
|
|
15874
15898
|
SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
|
|
15875
15899
|
SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
|
|
15876
|
-
TokenResponseSchema =
|
|
15877
|
-
access_token:
|
|
15878
|
-
refresh_token:
|
|
15879
|
-
id_token:
|
|
15880
|
-
expires_in:
|
|
15881
|
-
scope:
|
|
15900
|
+
TokenResponseSchema = import_zod35.z.looseObject({
|
|
15901
|
+
access_token: import_zod35.z.string().min(1),
|
|
15902
|
+
refresh_token: import_zod35.z.string().min(1).optional(),
|
|
15903
|
+
id_token: import_zod35.z.string().min(1).optional(),
|
|
15904
|
+
expires_in: import_zod35.z.number().positive(),
|
|
15905
|
+
scope: import_zod35.z.string().optional()
|
|
15882
15906
|
});
|
|
15883
|
-
JwtHeaderSchema =
|
|
15884
|
-
IdTokenClaimsSchema =
|
|
15885
|
-
iss:
|
|
15886
|
-
sub:
|
|
15887
|
-
aud:
|
|
15888
|
-
exp:
|
|
15889
|
-
nonce:
|
|
15890
|
-
email:
|
|
15907
|
+
JwtHeaderSchema = import_zod35.z.looseObject({ alg: import_zod35.z.string(), kid: import_zod35.z.string().optional() });
|
|
15908
|
+
IdTokenClaimsSchema = import_zod35.z.looseObject({
|
|
15909
|
+
iss: import_zod35.z.string(),
|
|
15910
|
+
sub: import_zod35.z.string().min(1),
|
|
15911
|
+
aud: import_zod35.z.union([import_zod35.z.string(), import_zod35.z.array(import_zod35.z.string())]),
|
|
15912
|
+
exp: import_zod35.z.number(),
|
|
15913
|
+
nonce: import_zod35.z.string().optional(),
|
|
15914
|
+
email: import_zod35.z.string().optional()
|
|
15891
15915
|
});
|
|
15892
|
-
JwksSchema =
|
|
15916
|
+
JwksSchema = import_zod35.z.object({ keys: import_zod35.z.array(import_zod35.z.looseObject({ kid: import_zod35.z.string().optional(), kty: import_zod35.z.string() })) });
|
|
15893
15917
|
}
|
|
15894
15918
|
});
|
|
15895
15919
|
|
|
@@ -15907,25 +15931,25 @@ function parseSiwcFile(raw, filePath) {
|
|
|
15907
15931
|
}
|
|
15908
15932
|
return parsed.data;
|
|
15909
15933
|
}
|
|
15910
|
-
var
|
|
15934
|
+
var import_zod36, SiwcGrantSchema, SiwcFileSchema;
|
|
15911
15935
|
var init_siwcStore = __esm({
|
|
15912
15936
|
"src/codex/siwcStore.ts"() {
|
|
15913
15937
|
"use strict";
|
|
15914
|
-
|
|
15938
|
+
import_zod36 = require("zod");
|
|
15915
15939
|
init_auth();
|
|
15916
15940
|
init_siwc();
|
|
15917
|
-
SiwcGrantSchema =
|
|
15918
|
-
clientId:
|
|
15919
|
-
sub:
|
|
15920
|
-
email:
|
|
15921
|
-
idToken:
|
|
15922
|
-
accessToken:
|
|
15923
|
-
refreshToken:
|
|
15924
|
-
scopes:
|
|
15941
|
+
SiwcGrantSchema = import_zod36.z.strictObject({
|
|
15942
|
+
clientId: import_zod36.z.string().min(1),
|
|
15943
|
+
sub: import_zod36.z.string().min(1),
|
|
15944
|
+
email: import_zod36.z.string().optional(),
|
|
15945
|
+
idToken: import_zod36.z.string().min(1),
|
|
15946
|
+
accessToken: import_zod36.z.string().min(1),
|
|
15947
|
+
refreshToken: import_zod36.z.string().min(1),
|
|
15948
|
+
scopes: import_zod36.z.array(import_zod36.z.string()).readonly(),
|
|
15925
15949
|
/** When the access token stops working, in milliseconds since the epoch. */
|
|
15926
|
-
expiresAt:
|
|
15950
|
+
expiresAt: import_zod36.z.number()
|
|
15927
15951
|
});
|
|
15928
|
-
SiwcFileSchema =
|
|
15952
|
+
SiwcFileSchema = import_zod36.z.strictObject({ registeredClientId: import_zod36.z.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
|
|
15929
15953
|
}
|
|
15930
15954
|
});
|
|
15931
15955
|
|
|
@@ -16015,18 +16039,18 @@ function signInCatalogueFingerprint(raw, filePath) {
|
|
|
16015
16039
|
function savedCatalogueFingerprint(provider, paths, env, home, reader) {
|
|
16016
16040
|
if (provider.codex?.login === "chatgpt-sign-in") return signInCatalogueFingerprint(reader.read(paths.chatgptSignInFile), paths.chatgptSignInFile);
|
|
16017
16041
|
const configuredHome = env.CODEX_HOME;
|
|
16018
|
-
const codexHome = configuredHome === void 0 || configuredHome === "" ?
|
|
16019
|
-
return cliCatalogueFingerprint(reader.read(
|
|
16042
|
+
const codexHome = configuredHome === void 0 || configuredHome === "" ? import_node_path43.default.join(home, ".codex") : configuredHome;
|
|
16043
|
+
return cliCatalogueFingerprint(reader.read(import_node_path43.default.join(codexHome, "auth.json")));
|
|
16020
16044
|
}
|
|
16021
|
-
var import_node_crypto16,
|
|
16045
|
+
var import_node_crypto16, import_node_path43, import_zod37, CatalogueBindingSchema;
|
|
16022
16046
|
var init_catalogueCredential = __esm({
|
|
16023
16047
|
"src/codex/catalogueCredential.ts"() {
|
|
16024
16048
|
"use strict";
|
|
16025
16049
|
import_node_crypto16 = require("node:crypto");
|
|
16026
|
-
|
|
16027
|
-
|
|
16050
|
+
import_node_path43 = __toESM(require("node:path"), 1);
|
|
16051
|
+
import_zod37 = require("zod");
|
|
16028
16052
|
init_siwcStore();
|
|
16029
|
-
CatalogueBindingSchema =
|
|
16053
|
+
CatalogueBindingSchema = import_zod37.z.strictObject({ fingerprint: import_zod37.z.string().min(1), source: import_zod37.z.string().min(1), revision: import_zod37.z.string().min(1) });
|
|
16030
16054
|
}
|
|
16031
16055
|
});
|
|
16032
16056
|
|
|
@@ -16077,64 +16101,64 @@ var init_signatures = __esm({
|
|
|
16077
16101
|
});
|
|
16078
16102
|
|
|
16079
16103
|
// src/codex/anthropic.ts
|
|
16080
|
-
var
|
|
16104
|
+
var import_zod38, TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
|
|
16081
16105
|
var init_anthropic = __esm({
|
|
16082
16106
|
"src/codex/anthropic.ts"() {
|
|
16083
16107
|
"use strict";
|
|
16084
|
-
|
|
16085
|
-
TextBlockSchema =
|
|
16086
|
-
Base64ImageSourceSchema =
|
|
16087
|
-
UrlImageSourceSchema =
|
|
16088
|
-
ImageBlockSchema =
|
|
16089
|
-
type:
|
|
16090
|
-
source:
|
|
16108
|
+
import_zod38 = require("zod");
|
|
16109
|
+
TextBlockSchema = import_zod38.z.looseObject({ type: import_zod38.z.literal("text"), text: import_zod38.z.string() });
|
|
16110
|
+
Base64ImageSourceSchema = import_zod38.z.looseObject({ type: import_zod38.z.literal("base64"), media_type: import_zod38.z.string().min(1), data: import_zod38.z.string() });
|
|
16111
|
+
UrlImageSourceSchema = import_zod38.z.looseObject({ type: import_zod38.z.literal("url"), url: import_zod38.z.string().min(1) });
|
|
16112
|
+
ImageBlockSchema = import_zod38.z.looseObject({
|
|
16113
|
+
type: import_zod38.z.literal("image"),
|
|
16114
|
+
source: import_zod38.z.union([Base64ImageSourceSchema, UrlImageSourceSchema])
|
|
16091
16115
|
});
|
|
16092
|
-
ToolUseBlockSchema =
|
|
16093
|
-
type:
|
|
16094
|
-
id:
|
|
16095
|
-
name:
|
|
16096
|
-
input:
|
|
16116
|
+
ToolUseBlockSchema = import_zod38.z.looseObject({
|
|
16117
|
+
type: import_zod38.z.literal("tool_use"),
|
|
16118
|
+
id: import_zod38.z.string().min(1),
|
|
16119
|
+
name: import_zod38.z.string().min(1),
|
|
16120
|
+
input: import_zod38.z.unknown()
|
|
16097
16121
|
});
|
|
16098
|
-
ToolResultContentBlockSchema =
|
|
16099
|
-
ToolResultBlockSchema =
|
|
16100
|
-
type:
|
|
16101
|
-
tool_use_id:
|
|
16102
|
-
content:
|
|
16122
|
+
ToolResultContentBlockSchema = import_zod38.z.union([TextBlockSchema, import_zod38.z.looseObject({ type: import_zod38.z.string() })]);
|
|
16123
|
+
ToolResultBlockSchema = import_zod38.z.looseObject({
|
|
16124
|
+
type: import_zod38.z.literal("tool_result"),
|
|
16125
|
+
tool_use_id: import_zod38.z.string().min(1),
|
|
16126
|
+
content: import_zod38.z.union([import_zod38.z.string(), import_zod38.z.array(ToolResultContentBlockSchema)]).optional()
|
|
16103
16127
|
});
|
|
16104
|
-
OtherBlockSchema =
|
|
16105
|
-
ContentBlockSchema =
|
|
16106
|
-
MessageSchema =
|
|
16107
|
-
role:
|
|
16108
|
-
content:
|
|
16128
|
+
OtherBlockSchema = import_zod38.z.looseObject({ type: import_zod38.z.string() });
|
|
16129
|
+
ContentBlockSchema = import_zod38.z.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
|
|
16130
|
+
MessageSchema = import_zod38.z.looseObject({
|
|
16131
|
+
role: import_zod38.z.enum(["user", "assistant", "system"]),
|
|
16132
|
+
content: import_zod38.z.union([import_zod38.z.string(), import_zod38.z.array(ContentBlockSchema)])
|
|
16109
16133
|
});
|
|
16110
|
-
ToolSchema =
|
|
16111
|
-
name:
|
|
16112
|
-
description:
|
|
16113
|
-
input_schema:
|
|
16114
|
-
allowed_domains:
|
|
16115
|
-
blocked_domains:
|
|
16134
|
+
ToolSchema = import_zod38.z.looseObject({
|
|
16135
|
+
name: import_zod38.z.string().min(1),
|
|
16136
|
+
description: import_zod38.z.string().optional(),
|
|
16137
|
+
input_schema: import_zod38.z.record(import_zod38.z.string(), import_zod38.z.unknown()).optional(),
|
|
16138
|
+
allowed_domains: import_zod38.z.array(import_zod38.z.string()).optional(),
|
|
16139
|
+
blocked_domains: import_zod38.z.array(import_zod38.z.string()).optional()
|
|
16116
16140
|
});
|
|
16117
|
-
ToolChoiceSchema =
|
|
16118
|
-
|
|
16119
|
-
|
|
16141
|
+
ToolChoiceSchema = import_zod38.z.union([
|
|
16142
|
+
import_zod38.z.looseObject({ type: import_zod38.z.enum(["auto", "none", "any"]) }),
|
|
16143
|
+
import_zod38.z.looseObject({ type: import_zod38.z.literal("tool"), name: import_zod38.z.string().min(1) })
|
|
16120
16144
|
]);
|
|
16121
|
-
SystemSchema =
|
|
16122
|
-
MessagesRequestSchema =
|
|
16123
|
-
model:
|
|
16145
|
+
SystemSchema = import_zod38.z.union([import_zod38.z.string(), import_zod38.z.array(import_zod38.z.union([TextBlockSchema, OtherBlockSchema]))]);
|
|
16146
|
+
MessagesRequestSchema = import_zod38.z.looseObject({
|
|
16147
|
+
model: import_zod38.z.string().optional(),
|
|
16124
16148
|
system: SystemSchema.optional(),
|
|
16125
|
-
messages:
|
|
16126
|
-
tools:
|
|
16149
|
+
messages: import_zod38.z.array(MessageSchema),
|
|
16150
|
+
tools: import_zod38.z.array(ToolSchema).optional(),
|
|
16127
16151
|
tool_choice: ToolChoiceSchema.optional(),
|
|
16128
|
-
stream:
|
|
16152
|
+
stream: import_zod38.z.boolean().optional(),
|
|
16129
16153
|
/** `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. */
|
|
16130
|
-
metadata:
|
|
16154
|
+
metadata: import_zod38.z.looseObject({ user_id: import_zod38.z.string().optional() }).optional(),
|
|
16131
16155
|
/** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
|
|
16132
|
-
output_config:
|
|
16156
|
+
output_config: import_zod38.z.looseObject({ effort: import_zod38.z.string().optional(), format: import_zod38.z.object({ type: import_zod38.z.literal("json_schema"), schema: import_zod38.z.record(import_zod38.z.string(), import_zod38.z.unknown()) }).optional() }).optional()
|
|
16133
16157
|
});
|
|
16134
|
-
CountTokensRequestSchema =
|
|
16135
|
-
system:
|
|
16136
|
-
messages:
|
|
16137
|
-
tools:
|
|
16158
|
+
CountTokensRequestSchema = import_zod38.z.looseObject({
|
|
16159
|
+
system: import_zod38.z.unknown().optional(),
|
|
16160
|
+
messages: import_zod38.z.unknown().optional(),
|
|
16161
|
+
tools: import_zod38.z.unknown().optional()
|
|
16138
16162
|
});
|
|
16139
16163
|
}
|
|
16140
16164
|
});
|
|
@@ -17094,7 +17118,7 @@ function buildEnv(params) {
|
|
|
17094
17118
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
17095
17119
|
let providerCustomHeaders;
|
|
17096
17120
|
if (!params.configDirEscapeHatch && params.identityId !== void 0) {
|
|
17097
|
-
env.CLAUDE_CONFIG_DIR =
|
|
17121
|
+
env.CLAUDE_CONFIG_DIR = import_node_path51.default.join(params.identitiesDir, params.identityId);
|
|
17098
17122
|
}
|
|
17099
17123
|
if (params.provider !== void 0) {
|
|
17100
17124
|
const providerEnv = params.provider.definition.kind !== void 0 && params.provider.definition.kind !== "http" ? {} : params.provider.definition.env ?? {};
|
|
@@ -17171,11 +17195,11 @@ function buildEnv(params) {
|
|
|
17171
17195
|
injections.finish();
|
|
17172
17196
|
return env;
|
|
17173
17197
|
}
|
|
17174
|
-
var
|
|
17198
|
+
var import_node_path51, LOOPBACK_HOSTS, PROVIDER_SESSION_PLACEHOLDER;
|
|
17175
17199
|
var init_flags = __esm({
|
|
17176
17200
|
"src/launcher/flags.ts"() {
|
|
17177
17201
|
"use strict";
|
|
17178
|
-
|
|
17202
|
+
import_node_path51 = __toESM(require("node:path"), 1);
|
|
17179
17203
|
init_envBool();
|
|
17180
17204
|
init_cliError();
|
|
17181
17205
|
init_conditions();
|
|
@@ -17268,7 +17292,7 @@ function newestTranscript(fs17, projectDir) {
|
|
|
17268
17292
|
if (!name.endsWith(".jsonl")) {
|
|
17269
17293
|
continue;
|
|
17270
17294
|
}
|
|
17271
|
-
const candidate =
|
|
17295
|
+
const candidate = import_node_path52.default.join(projectDir, name);
|
|
17272
17296
|
const stat = fs17.lstat(candidate);
|
|
17273
17297
|
if (stat?.kind === "file" && stat.mtimeMs > newestMs) {
|
|
17274
17298
|
newestMs = stat.mtimeMs;
|
|
@@ -17282,16 +17306,16 @@ function resumedContextTokens(fs17, params) {
|
|
|
17282
17306
|
if (target === void 0) {
|
|
17283
17307
|
return void 0;
|
|
17284
17308
|
}
|
|
17285
|
-
const projectDir =
|
|
17286
|
-
const file = target.kind === "id" ?
|
|
17309
|
+
const projectDir = import_node_path52.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
|
|
17310
|
+
const file = target.kind === "id" ? import_node_path52.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs17, projectDir);
|
|
17287
17311
|
const text = file === void 0 ? void 0 : fs17.readFileUtf8(file);
|
|
17288
17312
|
return text === void 0 ? void 0 : contextTokensOfTranscript(text);
|
|
17289
17313
|
}
|
|
17290
|
-
var
|
|
17314
|
+
var import_node_path52;
|
|
17291
17315
|
var init_resumeContext = __esm({
|
|
17292
17316
|
"src/usage/resumeContext.ts"() {
|
|
17293
17317
|
"use strict";
|
|
17294
|
-
|
|
17318
|
+
import_node_path52 = __toESM(require("node:path"), 1);
|
|
17295
17319
|
}
|
|
17296
17320
|
});
|
|
17297
17321
|
|
|
@@ -17826,6 +17850,235 @@ var init_spawn = __esm({
|
|
|
17826
17850
|
}
|
|
17827
17851
|
});
|
|
17828
17852
|
|
|
17853
|
+
// src/supervise/sessionControlPlugin.ts
|
|
17854
|
+
function removeAbandonedPlugins(parent, isRunning) {
|
|
17855
|
+
const uid = process.getuid?.();
|
|
17856
|
+
for (const name of (0, import_node_fs16.readdirSync)(parent)) {
|
|
17857
|
+
const pid = Number(/^agent-shim-control-(\d+)-/u.exec(name)?.[1]);
|
|
17858
|
+
if (!name.startsWith(STAGED_PREFIX) || !Number.isInteger(pid) || isRunning(pid)) {
|
|
17859
|
+
continue;
|
|
17860
|
+
}
|
|
17861
|
+
const entry = import_node_path53.default.join(parent, name);
|
|
17862
|
+
const stat = (0, import_node_fs16.lstatSync)(entry, { throwIfNoEntry: false });
|
|
17863
|
+
if (stat?.isDirectory() === true && (uid === void 0 || stat.uid === uid)) {
|
|
17864
|
+
(0, import_node_fs16.rmSync)(entry, { recursive: true, force: true });
|
|
17865
|
+
}
|
|
17866
|
+
}
|
|
17867
|
+
}
|
|
17868
|
+
function stageSessionControlPlugin(options = {}) {
|
|
17869
|
+
const parent = options.parent ?? (0, import_node_os9.tmpdir)();
|
|
17870
|
+
removeAbandonedPlugins(parent, options.isRunning ?? realIsProcessRunning);
|
|
17871
|
+
const directory = (0, import_node_fs16.mkdtempSync)(import_node_path53.default.join(parent, `${STAGED_PREFIX}${String(options.pid ?? process.pid)}-`));
|
|
17872
|
+
const { ready, session, requests, results } = sessionControlPluginPaths(directory);
|
|
17873
|
+
try {
|
|
17874
|
+
(0, import_node_fs16.mkdirSync)(import_node_path53.default.join(directory, ".claude-plugin"), { mode: 448 });
|
|
17875
|
+
(0, import_node_fs16.mkdirSync)(import_node_path53.default.join(directory, "hooks"), { mode: 448 });
|
|
17876
|
+
(0, import_node_fs16.mkdirSync)(requests, { mode: 448 });
|
|
17877
|
+
(0, import_node_fs16.mkdirSync)(results, { mode: 448 });
|
|
17878
|
+
(0, import_node_fs16.writeFileSync)(import_node_path53.default.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 });
|
|
17879
|
+
(0, import_node_fs16.writeFileSync)(import_node_path53.default.join(directory, "hooks", "hooks.json"), JSON.stringify({ modules: ["./register.js"] }), { mode: 384 });
|
|
17880
|
+
(0, import_node_fs16.writeFileSync)(import_node_path53.default.join(directory, "hooks", "register.js"), pluginSource(ready, session, requests, results), { mode: 384 });
|
|
17881
|
+
return { directory, ready, session, requests, results, release: () => {
|
|
17882
|
+
(0, import_node_fs16.rmSync)(directory, { recursive: true, force: true });
|
|
17883
|
+
} };
|
|
17884
|
+
} catch (error) {
|
|
17885
|
+
(0, import_node_fs16.rmSync)(directory, { recursive: true, force: true });
|
|
17886
|
+
throw error;
|
|
17887
|
+
}
|
|
17888
|
+
}
|
|
17889
|
+
function sessionControlPluginPaths(directory) {
|
|
17890
|
+
return { directory, ready: import_node_path53.default.join(directory, "ready.json"), session: import_node_path53.default.join(directory, "session.json"), requests: import_node_path53.default.join(directory, "requests"), results: import_node_path53.default.join(directory, "results") };
|
|
17891
|
+
}
|
|
17892
|
+
function pluginSource(ready, session, requests, results) {
|
|
17893
|
+
return `const REQUESTS = ${JSON.stringify(requests)};
|
|
17894
|
+
const RESULTS = ${JSON.stringify(results)};
|
|
17895
|
+
function compacted(id, value) {
|
|
17896
|
+
return { id, ...(typeof value?.skip === 'string' ? { kind: 'unchanged', skip: value.skip } : { kind: 'compacted', tokensBefore: value?.tokensBefore, tokensAfter: value?.tokensAfter }) };
|
|
17897
|
+
}
|
|
17898
|
+
async function resultNames($) {
|
|
17899
|
+
return new Set((await $.fs.list(RESULTS)).map((entry) => entry.name));
|
|
17900
|
+
}
|
|
17901
|
+
async function recordSession($, event, next) {
|
|
17902
|
+
const answer = await next(event);
|
|
17903
|
+
if (typeof event?.session_id === 'string' && typeof event?.transcript_path === 'string') {
|
|
17904
|
+
const record = JSON.stringify({ conversationId: event.session_id, transcriptPath: event.transcript_path });
|
|
17905
|
+
$.clock.after(0, async () => {
|
|
17906
|
+
await $.fs.write(${JSON.stringify(session)}, record);
|
|
17907
|
+
});
|
|
17908
|
+
}
|
|
17909
|
+
return answer;
|
|
17910
|
+
}
|
|
17911
|
+
export function register(on) {
|
|
17912
|
+
let running = false;
|
|
17913
|
+
on('classic.SessionStart', recordSession);
|
|
17914
|
+
on('classic.UserPromptSubmit', recordSession);
|
|
17915
|
+
on('classic.Stop', recordSession);
|
|
17916
|
+
on('classic.PostCompact', async ($, event, next) => {
|
|
17917
|
+
const answer = await next(event);
|
|
17918
|
+
$.clock.after(0, async () => {
|
|
17919
|
+
for (const name of await resultNames($)) {
|
|
17920
|
+
const text = await $.fs.read(RESULTS + '/' + name);
|
|
17921
|
+
if (typeof text !== 'string') continue;
|
|
17922
|
+
const current = JSON.parse(text);
|
|
17923
|
+
if (current.kind === 'running' && current.op === 'compact' && typeof current.id === 'string') {
|
|
17924
|
+
await $.fs.write(RESULTS + '/' + name, JSON.stringify({ id: current.id, kind: 'compacted' }));
|
|
17925
|
+
}
|
|
17926
|
+
}
|
|
17927
|
+
});
|
|
17928
|
+
return answer;
|
|
17929
|
+
});
|
|
17930
|
+
on('session.start', async ($, event, next) => {
|
|
17931
|
+
const answer = await next(event);
|
|
17932
|
+
const version = await $.session.version();
|
|
17933
|
+
await $.fs.write(${JSON.stringify(ready)}, JSON.stringify({ ready: true, version: version.version }));
|
|
17934
|
+
$.clock.every(1000, async () => {
|
|
17935
|
+
if (running) return;
|
|
17936
|
+
running = true;
|
|
17937
|
+
try {
|
|
17938
|
+
const done = await resultNames($);
|
|
17939
|
+
const names = (await $.fs.list(REQUESTS)).map((entry) => entry.name).filter((name) => !name.startsWith('.') && name.endsWith('.json') && !done.has(name)).sort();
|
|
17940
|
+
const name = names[0];
|
|
17941
|
+
if (name === undefined) return;
|
|
17942
|
+
const text = await $.fs.read(REQUESTS + '/' + name);
|
|
17943
|
+
if (typeof text !== 'string') return;
|
|
17944
|
+
const item = JSON.parse(text);
|
|
17945
|
+
if (typeof item.id !== 'string' || name !== item.id + '.json') {
|
|
17946
|
+
await $.fs.write(RESULTS + '/' + name, JSON.stringify({ id: name.slice(0, -5), error: 'the request is not one this plugin reads' }));
|
|
17947
|
+
return;
|
|
17948
|
+
}
|
|
17949
|
+
await $.fs.write(RESULTS + '/' + name, JSON.stringify({ id: item.id, kind: 'running', op: item.op }));
|
|
17950
|
+
let response;
|
|
17951
|
+
try {
|
|
17952
|
+
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');
|
|
17953
|
+
if (typeof item.conversationId !== 'string' || await $.session.id() !== item.conversationId) throw new Error('the conversation changed before the request ran');
|
|
17954
|
+
if (item.op === 'compact') {
|
|
17955
|
+
response = compacted(item.id, await $.session.compact(typeof item.instructions === 'string' ? { instructions: item.instructions } : {}));
|
|
17956
|
+
} else if (item.op === 'goal' && typeof item.args === 'string' && item.args.trim() !== '') {
|
|
17957
|
+
const ran = await $.command.run({ command: 'goal', args: item.args });
|
|
17958
|
+
response = { id: item.id, kind: 'ran', ...(typeof ran?.text === 'string' ? { text: ran.text } : {}) };
|
|
17959
|
+
} else if (item.op === 'turn' && typeof item.text === 'string' && item.text.trim() !== '') {
|
|
17960
|
+
const submitted = await $.prompt.submit({ text: item.text, asUser: true });
|
|
17961
|
+
if (typeof submitted?.drop === 'string') throw new Error('a hook dropped the prompt: ' + submitted.drop);
|
|
17962
|
+
response = { id: item.id, kind: 'submitted', text: submitted?.text, origin: submitted?.origin };
|
|
17963
|
+
} else {
|
|
17964
|
+
throw new Error('the request names no operation this plugin performs');
|
|
17965
|
+
}
|
|
17966
|
+
} catch (error) {
|
|
17967
|
+
response = { id: item.id, error: error instanceof Error ? error.message : String(error) };
|
|
17968
|
+
}
|
|
17969
|
+
await $.fs.write(RESULTS + '/' + name, JSON.stringify(response));
|
|
17970
|
+
} finally {
|
|
17971
|
+
running = false;
|
|
17972
|
+
}
|
|
17973
|
+
});
|
|
17974
|
+
return answer;
|
|
17975
|
+
});
|
|
17976
|
+
}
|
|
17977
|
+
`;
|
|
17978
|
+
}
|
|
17979
|
+
function withSessionControlPlugin(args, directory) {
|
|
17980
|
+
const end = args.indexOf("--");
|
|
17981
|
+
const result = [...args];
|
|
17982
|
+
result.splice(end === -1 ? result.length : end, 0, "--plugin-dir", directory);
|
|
17983
|
+
return result;
|
|
17984
|
+
}
|
|
17985
|
+
var import_node_fs16, import_node_os9, import_node_path53, SESSION_CONTROL_PLUGIN_NAME, STAGED_PREFIX;
|
|
17986
|
+
var init_sessionControlPlugin = __esm({
|
|
17987
|
+
"src/supervise/sessionControlPlugin.ts"() {
|
|
17988
|
+
"use strict";
|
|
17989
|
+
import_node_fs16 = require("node:fs");
|
|
17990
|
+
import_node_os9 = require("node:os");
|
|
17991
|
+
import_node_path53 = __toESM(require("node:path"), 1);
|
|
17992
|
+
init_realPorts();
|
|
17993
|
+
SESSION_CONTROL_PLUGIN_NAME = "agent-shim-control";
|
|
17994
|
+
STAGED_PREFIX = "agent-shim-control-";
|
|
17995
|
+
}
|
|
17996
|
+
});
|
|
17997
|
+
|
|
17998
|
+
// src/supervise/launchControl.ts
|
|
17999
|
+
function readRecord2(fs17, directory, name) {
|
|
18000
|
+
if (!name.endsWith(RECORD_SUFFIX3)) {
|
|
18001
|
+
return void 0;
|
|
18002
|
+
}
|
|
18003
|
+
const raw = fs17.readFileUtf8(import_node_path54.default.join(directory, name));
|
|
18004
|
+
if (raw === void 0) {
|
|
18005
|
+
return void 0;
|
|
18006
|
+
}
|
|
18007
|
+
try {
|
|
18008
|
+
const parsed = LaunchControlSchema.safeParse(JSON.parse(raw));
|
|
18009
|
+
return parsed.success ? parsed.data : void 0;
|
|
18010
|
+
} catch {
|
|
18011
|
+
return void 0;
|
|
18012
|
+
}
|
|
18013
|
+
}
|
|
18014
|
+
function registerLaunchControl(fs17, directory, control, isRunning) {
|
|
18015
|
+
fs17.mkdirPrivate(directory);
|
|
18016
|
+
for (const name of fs17.readdir(directory)) {
|
|
18017
|
+
const record = readRecord2(fs17, directory, name);
|
|
18018
|
+
if (record !== void 0 && !isRunning(record.pid)) {
|
|
18019
|
+
fs17.removeRecursive(import_node_path54.default.join(directory, name));
|
|
18020
|
+
}
|
|
18021
|
+
}
|
|
18022
|
+
const file = import_node_path54.default.join(directory, `${String(control.pid)}.${(0, import_node_crypto18.randomUUID)()}${RECORD_SUFFIX3}`);
|
|
18023
|
+
fs17.writeFilePrivate(file, `${JSON.stringify(LaunchControlSchema.parse(control))}
|
|
18024
|
+
`);
|
|
18025
|
+
return () => {
|
|
18026
|
+
fs17.removeRecursive(file);
|
|
18027
|
+
};
|
|
18028
|
+
}
|
|
18029
|
+
function launchLoadsControlPlugin(candidate) {
|
|
18030
|
+
const end = candidate.args.indexOf("--");
|
|
18031
|
+
const options = end === -1 ? candidate.args : candidate.args.slice(0, end);
|
|
18032
|
+
return !candidate.supervised && candidate.startsSession && !options.includes("--bare") && candidate.version !== void 0 && RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(candidate.version);
|
|
18033
|
+
}
|
|
18034
|
+
function stageControlPluginFor(candidate, stage, warn) {
|
|
18035
|
+
if (stage === void 0 || !launchLoadsControlPlugin(candidate)) {
|
|
18036
|
+
return void 0;
|
|
18037
|
+
}
|
|
18038
|
+
try {
|
|
18039
|
+
return stage();
|
|
18040
|
+
} catch (error) {
|
|
18041
|
+
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)}`);
|
|
18042
|
+
return void 0;
|
|
18043
|
+
}
|
|
18044
|
+
}
|
|
18045
|
+
function stageLaunchControl(params) {
|
|
18046
|
+
const plugin = stageSessionControlPlugin({ pid: params.pid, isRunning: params.isRunning, ...params.parent === void 0 ? {} : { parent: params.parent } });
|
|
18047
|
+
let unregister;
|
|
18048
|
+
try {
|
|
18049
|
+
unregister = registerLaunchControl(params.fs, params.paths.launchControlDir, { pid: params.pid, directory: plugin.directory }, params.isRunning);
|
|
18050
|
+
} catch (error) {
|
|
18051
|
+
plugin.release();
|
|
18052
|
+
throw error;
|
|
18053
|
+
}
|
|
18054
|
+
return {
|
|
18055
|
+
args: (args) => withSessionControlPlugin(args, plugin.directory),
|
|
18056
|
+
release: () => {
|
|
18057
|
+
unregister();
|
|
18058
|
+
plugin.release();
|
|
18059
|
+
}
|
|
18060
|
+
};
|
|
18061
|
+
}
|
|
18062
|
+
var import_node_path54, import_node_crypto18, import_zod49, LaunchControlSchema, RECORD_SUFFIX3;
|
|
18063
|
+
var init_launchControl = __esm({
|
|
18064
|
+
"src/supervise/launchControl.ts"() {
|
|
18065
|
+
"use strict";
|
|
18066
|
+
import_node_path54 = __toESM(require("node:path"), 1);
|
|
18067
|
+
import_node_crypto18 = require("node:crypto");
|
|
18068
|
+
import_zod49 = require("zod");
|
|
18069
|
+
init_sessionControl();
|
|
18070
|
+
init_sessionControlPlugin();
|
|
18071
|
+
init_verifiedVersions();
|
|
18072
|
+
LaunchControlSchema = import_zod49.z.strictObject({
|
|
18073
|
+
/** The launcher's process id, which tells a live channel from one a killed launcher left. */
|
|
18074
|
+
pid: import_zod49.z.number().int().positive(),
|
|
18075
|
+
/** The plugin's directory, its request and result files beneath it. */
|
|
18076
|
+
directory: import_zod49.z.string().min(1)
|
|
18077
|
+
});
|
|
18078
|
+
RECORD_SUFFIX3 = ".json";
|
|
18079
|
+
}
|
|
18080
|
+
});
|
|
18081
|
+
|
|
17829
18082
|
// src/update/launchHook.ts
|
|
17830
18083
|
function resolveUpdateMode(globalConfig) {
|
|
17831
18084
|
return globalConfig?.update?.mode ?? "off";
|
|
@@ -17997,7 +18250,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
17997
18250
|
const farmIdentity = configDirEscapeHatchApplies || identityDecision.name === void 0 ? void 0 : resolveIdentityId(paths.identitiesDir, identityDecision.name, fs17);
|
|
17998
18251
|
const farm = farmIdentity === void 0 ? void 0 : params.farm;
|
|
17999
18252
|
if (!readOnly && params.supervised?.member === void 0 && farmIdentity !== void 0 && identityDecision.name !== void 0) {
|
|
18000
|
-
warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name,
|
|
18253
|
+
warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name, import_node_path55.default.join(paths.identitiesDir, farmIdentity));
|
|
18001
18254
|
}
|
|
18002
18255
|
if (!readOnly && farm !== void 0 && farmIdentity !== void 0) {
|
|
18003
18256
|
try {
|
|
@@ -18191,12 +18444,12 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
18191
18444
|
if (definition.kind === "codex" && readOnly && cache !== void 0) {
|
|
18192
18445
|
const binding = parseCatalogueBinding(stored.bindingText(name, owner));
|
|
18193
18446
|
const configuredHome = catalogueEnv.CODEX_HOME;
|
|
18194
|
-
const home = configuredHome === void 0 || configuredHome === "" ?
|
|
18195
|
-
const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile :
|
|
18447
|
+
const home = configuredHome === void 0 || configuredHome === "" ? import_node_path55.default.join(import_node_os10.default.homedir(), ".codex") : configuredHome;
|
|
18448
|
+
const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile : import_node_path55.default.resolve(home, "auth.json");
|
|
18196
18449
|
const revision = params.fs.fileRevision?.(source);
|
|
18197
18450
|
if (binding === void 0 || binding.fingerprint !== cache.credentialFingerprint || binding.source !== source || revision === void 0 || revision !== binding.revision) return [];
|
|
18198
18451
|
}
|
|
18199
|
-
const fingerprint = definition.kind === "codex" && !readOnly ? savedCatalogueFingerprint(definition, paths, catalogueEnv,
|
|
18452
|
+
const fingerprint = definition.kind === "codex" && !readOnly ? savedCatalogueFingerprint(definition, paths, catalogueEnv, import_node_os10.default.homedir(), reader) : void 0;
|
|
18200
18453
|
if (definition.kind === "codex" && !readOnly && cache !== void 0 && (fingerprint === void 0 || cache.credentialFingerprint !== fingerprint)) return [];
|
|
18201
18454
|
if (isHttpProvider(definition) && cache !== void 0 && !catalogueMatchesSettings(parseCatalogueSettings(stored.digestText(name)), cache, definition)) return [[name, definition, []]];
|
|
18202
18455
|
return [[name, definition, cache?.models ?? []]];
|
|
@@ -18214,7 +18467,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
18214
18467
|
return { args: args2, pickerSuppressed: startsSession && pickerSettings !== void 0 && callerSettings };
|
|
18215
18468
|
};
|
|
18216
18469
|
const args = argsForSupervisor().args;
|
|
18217
|
-
const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR :
|
|
18470
|
+
const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path55.default.join(paths.identitiesDir, farmIdentity);
|
|
18218
18471
|
const decision = {
|
|
18219
18472
|
identitySource: identityDecision.source,
|
|
18220
18473
|
configDirEscapeHatch: identityDecision.configDirEscapeHatch,
|
|
@@ -18254,6 +18507,8 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
18254
18507
|
models,
|
|
18255
18508
|
globalModels,
|
|
18256
18509
|
bin: discovered.path,
|
|
18510
|
+
binVersion: discovered.version,
|
|
18511
|
+
startsSession,
|
|
18257
18512
|
args,
|
|
18258
18513
|
argsForSupervisor,
|
|
18259
18514
|
decision
|
|
@@ -18310,7 +18565,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18310
18565
|
let warnings = [];
|
|
18311
18566
|
const updateCheck = runLaunchUpdateCheck({
|
|
18312
18567
|
mode: params.updateMode ?? "off",
|
|
18313
|
-
checkPath:
|
|
18568
|
+
checkPath: import_node_path55.default.join(paths.root, "update.check"),
|
|
18314
18569
|
currentVersion: package_default.version,
|
|
18315
18570
|
port: params.update
|
|
18316
18571
|
});
|
|
@@ -18333,7 +18588,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18333
18588
|
classification: resyncFarmRuntime.classification,
|
|
18334
18589
|
now: resyncFarmRuntime.now,
|
|
18335
18590
|
uniqueSuffix: resyncFarmRuntime.uniqueSuffix,
|
|
18336
|
-
identityExists: () => params.fs.readConfigFile(
|
|
18591
|
+
identityExists: () => params.fs.readConfigFile(import_node_path55.default.join(paths.identitiesDir, resyncIdentity, IDENTITY_FILE)) !== void 0,
|
|
18337
18592
|
lock: resyncFarmRuntime.lock
|
|
18338
18593
|
});
|
|
18339
18594
|
} catch (error) {
|
|
@@ -18367,7 +18622,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18367
18622
|
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.");
|
|
18368
18623
|
proc.exit(1);
|
|
18369
18624
|
}
|
|
18370
|
-
const sessionId = params.supervised?.sessionId ?? (0,
|
|
18625
|
+
const sessionId = params.supervised?.sessionId ?? (0, import_node_crypto19.randomUUID)();
|
|
18371
18626
|
const resolvedModels = decided.models ?? (decided.globalModels === void 0 ? void 0 : {});
|
|
18372
18627
|
const sessionModels = (0, import_node_util2.isDeepStrictEqual)(resolvedModels, decided.globalModels) ? void 0 : resolvedModels;
|
|
18373
18628
|
const session = { sessionId, ...decided.farmIdentity === void 0 ? {} : { identity: decided.farmIdentity }, ...sessionModels === void 0 ? {} : { models: sessionModels } };
|
|
@@ -18412,16 +18667,17 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18412
18667
|
proxyBypass: resolvedFlags.proxyBypass,
|
|
18413
18668
|
...resolvedFlags.statusline === void 0 ? {} : { statusline: resolvedFlags.statusline }
|
|
18414
18669
|
});
|
|
18415
|
-
const
|
|
18670
|
+
const picker = decided.argsForSupervisor(frontDoor?.supervisorPid);
|
|
18671
|
+
const control = stageControlPluginFor({ args: picker.args, version: decided.binVersion, startsSession: decided.startsSession, supervised: params.supervised !== void 0 }, params.stageControlPlugin, log.warn);
|
|
18672
|
+
const releases = [...unregisterLaunch === void 0 ? [] : [unregisterLaunch], ...headroom === void 0 || headroomPort === void 0 ? [] : [headroomPort.release], ...frontDoorRelease === void 0 ? [] : [frontDoorRelease], ...control === void 0 ? [] : [control.release]];
|
|
18416
18673
|
const release = () => {
|
|
18417
18674
|
for (const registered of releases) {
|
|
18418
18675
|
registered();
|
|
18419
18676
|
}
|
|
18420
18677
|
};
|
|
18421
|
-
const picker = decided.argsForSupervisor(frontDoor?.supervisorPid);
|
|
18422
18678
|
if (picker.pickerSuppressed) rows.push(noteRow("--settings was passed, so /model keeps Claude Code's own model names"));
|
|
18423
18679
|
rows.push(...notes.map(noteRow));
|
|
18424
|
-
return { finalEnv, release, picker, sessionId };
|
|
18680
|
+
return { finalEnv, release, args: control === void 0 ? picker.args : control.args(picker.args), sessionId };
|
|
18425
18681
|
});
|
|
18426
18682
|
const unreachable = reachability?.line();
|
|
18427
18683
|
log.report(rows);
|
|
@@ -18430,7 +18686,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18430
18686
|
}
|
|
18431
18687
|
printDiagnosticLines(log, warnings, { errorsAsWarnings: false });
|
|
18432
18688
|
const hold = () => holdBeforeLaunch({ delayMs: resolvedFlags.delayMs, pause: resolvedFlags.pause }, params.hold, log);
|
|
18433
|
-
return { bin: decided.bin, args: brought.
|
|
18689
|
+
return { bin: decided.bin, args: brought.args, env: brought.finalEnv, sessionId: brought.sessionId, release: brought.release, markChildStarted: updateCheck.markChildStarted, hold, decision };
|
|
18434
18690
|
}
|
|
18435
18691
|
function resolveLaunch(params) {
|
|
18436
18692
|
const decided = decideLaunch(params, true);
|
|
@@ -18481,15 +18737,15 @@ function runLaunchPlan(plan, spawn3) {
|
|
|
18481
18737
|
function runLauncher(params) {
|
|
18482
18738
|
params.proc.exit(runLaunchPlan(prepareLaunch(params), params.spawn));
|
|
18483
18739
|
}
|
|
18484
|
-
var
|
|
18740
|
+
var import_node_crypto19, import_node_os10, import_node_util2, import_node_path55;
|
|
18485
18741
|
var init_launcher = __esm({
|
|
18486
18742
|
"src/launcher.ts"() {
|
|
18487
18743
|
"use strict";
|
|
18488
|
-
|
|
18489
|
-
|
|
18744
|
+
import_node_crypto19 = require("node:crypto");
|
|
18745
|
+
import_node_os10 = __toESM(require("node:os"), 1);
|
|
18490
18746
|
init_catalogueCredential();
|
|
18491
18747
|
import_node_util2 = require("node:util");
|
|
18492
|
-
|
|
18748
|
+
import_node_path55 = __toESM(require("node:path"), 1);
|
|
18493
18749
|
init_package();
|
|
18494
18750
|
init_envBool();
|
|
18495
18751
|
init_argv();
|
|
@@ -18518,6 +18774,7 @@ var init_launcher = __esm({
|
|
|
18518
18774
|
init_resumeContext();
|
|
18519
18775
|
init_lock();
|
|
18520
18776
|
init_spawn();
|
|
18777
|
+
init_launchControl();
|
|
18521
18778
|
init_providersStore();
|
|
18522
18779
|
init_load();
|
|
18523
18780
|
init_flatten();
|
|
@@ -18543,13 +18800,13 @@ function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string"
|
|
|
18543
18800
|
if (distDir === void 0) {
|
|
18544
18801
|
throw new OwnCliPathUnknownError();
|
|
18545
18802
|
}
|
|
18546
|
-
return
|
|
18803
|
+
return import_node_path56.default.join(distDir, OWN_CLI_FILE_NAME);
|
|
18547
18804
|
}
|
|
18548
|
-
var
|
|
18805
|
+
var import_node_path56, OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
|
|
18549
18806
|
var init_ownCli = __esm({
|
|
18550
18807
|
"src/ownCli.ts"() {
|
|
18551
18808
|
"use strict";
|
|
18552
|
-
|
|
18809
|
+
import_node_path56 = __toESM(require("node:path"), 1);
|
|
18553
18810
|
init_cliError();
|
|
18554
18811
|
OWN_CLI_FILE_NAME = "cli.cjs";
|
|
18555
18812
|
OwnCliPathUnknownError = class extends CliError {
|
|
@@ -18563,15 +18820,15 @@ var init_ownCli = __esm({
|
|
|
18563
18820
|
|
|
18564
18821
|
// src/frontdoor/doorLog.ts
|
|
18565
18822
|
function appendDoorLog(paths, line) {
|
|
18566
|
-
|
|
18567
|
-
|
|
18823
|
+
import_node_fs17.default.mkdirSync(paths.logsDir, { recursive: true });
|
|
18824
|
+
import_node_fs17.default.appendFileSync(paths.frontdoorLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
18568
18825
|
`);
|
|
18569
18826
|
}
|
|
18570
|
-
var
|
|
18827
|
+
var import_node_fs17;
|
|
18571
18828
|
var init_doorLog = __esm({
|
|
18572
18829
|
"src/frontdoor/doorLog.ts"() {
|
|
18573
18830
|
"use strict";
|
|
18574
|
-
|
|
18831
|
+
import_node_fs17 = __toESM(require("node:fs"), 1);
|
|
18575
18832
|
}
|
|
18576
18833
|
});
|
|
18577
18834
|
|
|
@@ -18592,7 +18849,7 @@ var init_selfIdentity = __esm({
|
|
|
18592
18849
|
// src/frontdoor/trust.ts
|
|
18593
18850
|
function resolveTrustBundle(params) {
|
|
18594
18851
|
const { caCertFile, bundlesDir, variable, inherited, fs: fs17 } = params;
|
|
18595
|
-
if (inherited === void 0 || inherited === "" ||
|
|
18852
|
+
if (inherited === void 0 || inherited === "" || import_node_path57.default.resolve(inherited) === import_node_path57.default.resolve(caCertFile)) {
|
|
18596
18853
|
return { path: caCertFile };
|
|
18597
18854
|
}
|
|
18598
18855
|
const caPem = fs17.readFileUtf8(caCertFile);
|
|
@@ -18610,19 +18867,19 @@ function resolveTrustBundle(params) {
|
|
|
18610
18867
|
}
|
|
18611
18868
|
const combined = `${inheritedPem.trimEnd()}
|
|
18612
18869
|
${caPem}`;
|
|
18613
|
-
const bundle =
|
|
18870
|
+
const bundle = import_node_path57.default.join(bundlesDir, `${(0, import_node_crypto20.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
18614
18871
|
if (!fs17.exists(bundle)) {
|
|
18615
18872
|
fs17.mkdirp(bundlesDir);
|
|
18616
18873
|
fs17.writeFileAtomic(bundle, combined);
|
|
18617
18874
|
}
|
|
18618
18875
|
return { path: bundle };
|
|
18619
18876
|
}
|
|
18620
|
-
var
|
|
18877
|
+
var import_node_crypto20, import_node_path57, BUNDLE_NAME_HEX_DIGITS;
|
|
18621
18878
|
var init_trust = __esm({
|
|
18622
18879
|
"src/frontdoor/trust.ts"() {
|
|
18623
18880
|
"use strict";
|
|
18624
|
-
|
|
18625
|
-
|
|
18881
|
+
import_node_crypto20 = require("node:crypto");
|
|
18882
|
+
import_node_path57 = __toESM(require("node:path"), 1);
|
|
18626
18883
|
BUNDLE_NAME_HEX_DIGITS = 16;
|
|
18627
18884
|
}
|
|
18628
18885
|
});
|
|
@@ -18664,7 +18921,7 @@ function realEnsurePorts(paths, spawnDaemon) {
|
|
|
18664
18921
|
}
|
|
18665
18922
|
},
|
|
18666
18923
|
// Read fresh for each probe: a replacement supervisor may have regenerated an unparseable CA, and the probe must trust exactly what the serving door's leaf chains to.
|
|
18667
|
-
verifyListener: (port) => probeFrontDoorSync(port,
|
|
18924
|
+
verifyListener: (port) => probeFrontDoorSync(port, import_node_fs18.default.readFileSync(paths.frontdoorCaCertFile, "utf8"))
|
|
18668
18925
|
};
|
|
18669
18926
|
}
|
|
18670
18927
|
function realFrontDoorPort(paths, spawnDaemon) {
|
|
@@ -18693,7 +18950,7 @@ function realFrontDoorPort(paths, spawnDaemon) {
|
|
|
18693
18950
|
let fingerprint;
|
|
18694
18951
|
let loginFault;
|
|
18695
18952
|
try {
|
|
18696
|
-
fingerprint = savedCatalogueFingerprint(provider, paths, { ...process.env, CODEX_HOME: owner.codexHome },
|
|
18953
|
+
fingerprint = savedCatalogueFingerprint(provider, paths, { ...process.env, CODEX_HOME: owner.codexHome }, import_node_os11.default.homedir(), new TolerantReader((file) => realFarmFs.readFileUtf8(file), (fault) => {
|
|
18697
18954
|
loginFault = fault;
|
|
18698
18955
|
}));
|
|
18699
18956
|
} catch (error) {
|
|
@@ -18749,12 +19006,12 @@ function realFrontDoorPort(paths, spawnDaemon) {
|
|
|
18749
19006
|
}
|
|
18750
19007
|
};
|
|
18751
19008
|
}
|
|
18752
|
-
var
|
|
19009
|
+
var import_node_fs18, import_node_os11, realTrustBundleFs;
|
|
18753
19010
|
var init_realFrontDoorPort = __esm({
|
|
18754
19011
|
"src/frontdoor/realFrontDoorPort.ts"() {
|
|
18755
19012
|
"use strict";
|
|
18756
|
-
|
|
18757
|
-
|
|
19013
|
+
import_node_fs18 = __toESM(require("node:fs"), 1);
|
|
19014
|
+
import_node_os11 = __toESM(require("node:os"), 1);
|
|
18758
19015
|
init_providersStore();
|
|
18759
19016
|
init_schema();
|
|
18760
19017
|
init_providerCatalogue();
|
|
@@ -18771,10 +19028,10 @@ var init_realFrontDoorPort = __esm({
|
|
|
18771
19028
|
init_trust();
|
|
18772
19029
|
init_monotonicClock();
|
|
18773
19030
|
realTrustBundleFs = {
|
|
18774
|
-
readFileUtf8: (file) =>
|
|
18775
|
-
exists: (file) =>
|
|
19031
|
+
readFileUtf8: (file) => import_node_fs18.default.readFileSync(file, "utf8"),
|
|
19032
|
+
exists: (file) => import_node_fs18.default.existsSync(file),
|
|
18776
19033
|
mkdirp: (dir) => {
|
|
18777
|
-
|
|
19034
|
+
import_node_fs18.default.mkdirSync(dir, { recursive: true });
|
|
18778
19035
|
},
|
|
18779
19036
|
writeFileAtomic: (file, contents) => {
|
|
18780
19037
|
realFarmFs.writeFilePrivate(file, contents);
|
|
@@ -18785,7 +19042,7 @@ var init_realFrontDoorPort = __esm({
|
|
|
18785
19042
|
|
|
18786
19043
|
// src/launchWiring.ts
|
|
18787
19044
|
function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
18788
|
-
const home =
|
|
19045
|
+
const home = import_node_os12.default.homedir();
|
|
18789
19046
|
const read = cosmiconfigReader();
|
|
18790
19047
|
const classification = loadClassification(paths);
|
|
18791
19048
|
const loaded = loadCascadeInput({ paths, home, cwd, read });
|
|
@@ -18810,7 +19067,7 @@ function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
|
18810
19067
|
...cliOverride === void 0 ? {} : { cliOverride }
|
|
18811
19068
|
}).input,
|
|
18812
19069
|
now: () => Date.now(),
|
|
18813
|
-
uniqueSuffix: `${String(process.pid)}.${(0,
|
|
19070
|
+
uniqueSuffix: `${String(process.pid)}.${(0, import_node_crypto21.randomUUID)()}`,
|
|
18814
19071
|
// 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.
|
|
18815
19072
|
lock: { pid: process.pid, isRunning: realIsProcessRunning, sleep: realSleepSync }
|
|
18816
19073
|
},
|
|
@@ -18838,8 +19095,9 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
18838
19095
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
18839
19096
|
startBaseUrlProbe: realStartBaseUrlProbe,
|
|
18840
19097
|
hold: realHoldPort,
|
|
18841
|
-
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot:
|
|
18842
|
-
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin,
|
|
19098
|
+
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: import_node_path58.default.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
|
|
19099
|
+
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin, import_node_path58.default.join(paths.identitiesDir, identity), options.proc.env),
|
|
19100
|
+
stageControlPlugin: () => stageLaunchControl({ fs: realFarmFs, paths, pid: process.pid, isRunning: realIsProcessRunning }),
|
|
18843
19101
|
...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
|
|
18844
19102
|
...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
|
|
18845
19103
|
...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
|
|
@@ -18903,13 +19161,13 @@ function resolveClaudeLaunch(options, run = realRunPort) {
|
|
|
18903
19161
|
};
|
|
18904
19162
|
return { resolution: resolveLaunch(realPrepareLaunchParams(paths, { proc, log, spawnDaemon, run, farm: buildFarmRuntime(paths, options.cwd, run) })), warnings };
|
|
18905
19163
|
}
|
|
18906
|
-
var
|
|
19164
|
+
var import_node_os12, import_node_path58, import_node_crypto21, LaunchRefusedError;
|
|
18907
19165
|
var init_launchWiring = __esm({
|
|
18908
19166
|
"src/launchWiring.ts"() {
|
|
18909
19167
|
"use strict";
|
|
18910
|
-
|
|
18911
|
-
|
|
18912
|
-
|
|
19168
|
+
import_node_os12 = __toESM(require("node:os"), 1);
|
|
19169
|
+
import_node_path58 = __toESM(require("node:path"), 1);
|
|
19170
|
+
import_node_crypto21 = require("node:crypto");
|
|
18913
19171
|
init_cliError();
|
|
18914
19172
|
init_claudeShim();
|
|
18915
19173
|
init_classify();
|
|
@@ -18924,6 +19182,7 @@ var init_launchWiring = __esm({
|
|
|
18924
19182
|
init_paths();
|
|
18925
19183
|
init_signIn();
|
|
18926
19184
|
init_providerReachability();
|
|
19185
|
+
init_launchControl();
|
|
18927
19186
|
init_realPorts();
|
|
18928
19187
|
LaunchRefusedError = class extends CliError {
|
|
18929
19188
|
exitCode;
|
|
@@ -19135,11 +19394,11 @@ var init_identityClaude = __esm({
|
|
|
19135
19394
|
});
|
|
19136
19395
|
|
|
19137
19396
|
// src/usage/providerQuota.ts
|
|
19138
|
-
var
|
|
19397
|
+
var import_zod50, 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;
|
|
19139
19398
|
var init_providerQuota = __esm({
|
|
19140
19399
|
"src/usage/providerQuota.ts"() {
|
|
19141
19400
|
"use strict";
|
|
19142
|
-
|
|
19401
|
+
import_zod50 = require("zod");
|
|
19143
19402
|
init_cloudUpstream();
|
|
19144
19403
|
init_schema2();
|
|
19145
19404
|
MS_PER_SECOND9 = 1e3;
|
|
@@ -19154,35 +19413,35 @@ var init_providerQuota = __esm({
|
|
|
19154
19413
|
[ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND9],
|
|
19155
19414
|
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9]
|
|
19156
19415
|
]);
|
|
19157
|
-
ZaiLimitSchema =
|
|
19158
|
-
type:
|
|
19159
|
-
unit:
|
|
19160
|
-
number:
|
|
19161
|
-
percentage:
|
|
19162
|
-
nextResetTime:
|
|
19163
|
-
usage:
|
|
19164
|
-
currentValue:
|
|
19165
|
-
remaining:
|
|
19416
|
+
ZaiLimitSchema = import_zod50.z.object({
|
|
19417
|
+
type: import_zod50.z.string(),
|
|
19418
|
+
unit: import_zod50.z.number().int(),
|
|
19419
|
+
number: import_zod50.z.number().int().positive(),
|
|
19420
|
+
percentage: import_zod50.z.number().nonnegative(),
|
|
19421
|
+
nextResetTime: import_zod50.z.number().positive().optional(),
|
|
19422
|
+
usage: import_zod50.z.number().nonnegative().optional(),
|
|
19423
|
+
currentValue: import_zod50.z.number().nonnegative().optional(),
|
|
19424
|
+
remaining: import_zod50.z.number().nonnegative().optional()
|
|
19166
19425
|
});
|
|
19167
|
-
ZaiResponseSchema =
|
|
19168
|
-
success:
|
|
19169
|
-
msg:
|
|
19170
|
-
data:
|
|
19426
|
+
ZaiResponseSchema = import_zod50.z.object({
|
|
19427
|
+
success: import_zod50.z.boolean(),
|
|
19428
|
+
msg: import_zod50.z.string().optional(),
|
|
19429
|
+
data: import_zod50.z.object({ level: import_zod50.z.string().optional(), limits: import_zod50.z.array(ZaiLimitSchema) })
|
|
19171
19430
|
});
|
|
19172
19431
|
OPENROUTER_HOST = "openrouter.ai";
|
|
19173
19432
|
OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
|
|
19174
19433
|
OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
|
|
19175
19434
|
MS_PER_DAY2 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
19176
|
-
OpenRouterKeySchema =
|
|
19177
|
-
data:
|
|
19178
|
-
limit:
|
|
19179
|
-
limit_remaining:
|
|
19180
|
-
limit_reset:
|
|
19181
|
-
is_free_tier:
|
|
19182
|
-
free_model_daily_requests:
|
|
19435
|
+
OpenRouterKeySchema = import_zod50.z.object({
|
|
19436
|
+
data: import_zod50.z.object({
|
|
19437
|
+
limit: import_zod50.z.number().nonnegative().nullable(),
|
|
19438
|
+
limit_remaining: import_zod50.z.number().nullable(),
|
|
19439
|
+
limit_reset: import_zod50.z.string().nullable(),
|
|
19440
|
+
is_free_tier: import_zod50.z.boolean().optional(),
|
|
19441
|
+
free_model_daily_requests: import_zod50.z.object({ used: import_zod50.z.number().nonnegative(), limit: import_zod50.z.number().nonnegative(), remaining: import_zod50.z.number() }).optional()
|
|
19183
19442
|
})
|
|
19184
19443
|
});
|
|
19185
|
-
OpenRouterCreditsSchema =
|
|
19444
|
+
OpenRouterCreditsSchema = import_zod50.z.object({ data: import_zod50.z.object({ total_credits: import_zod50.z.number().nonnegative(), total_usage: import_zod50.z.number().nonnegative() }) });
|
|
19186
19445
|
ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
|
|
19187
19446
|
ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
|
|
19188
19447
|
ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
|
|
@@ -19190,21 +19449,21 @@ var init_providerQuota = __esm({
|
|
|
19190
19449
|
DAYS_PER_WEEK2 = 7;
|
|
19191
19450
|
FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
19192
19451
|
WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
19193
|
-
AntigravityBucketSchema =
|
|
19194
|
-
bucketId:
|
|
19195
|
-
remainingFraction:
|
|
19196
|
-
resetTime:
|
|
19452
|
+
AntigravityBucketSchema = import_zod50.z.object({
|
|
19453
|
+
bucketId: import_zod50.z.string(),
|
|
19454
|
+
remainingFraction: import_zod50.z.number().optional(),
|
|
19455
|
+
resetTime: import_zod50.z.string().optional()
|
|
19197
19456
|
});
|
|
19198
|
-
AntigravitySummarySchema =
|
|
19199
|
-
GoogleTokenInfoSchema =
|
|
19200
|
-
email:
|
|
19201
|
-
sub:
|
|
19457
|
+
AntigravitySummarySchema = import_zod50.z.object({ groups: import_zod50.z.array(import_zod50.z.object({ buckets: import_zod50.z.array(AntigravityBucketSchema) })) });
|
|
19458
|
+
GoogleTokenInfoSchema = import_zod50.z.object({
|
|
19459
|
+
email: import_zod50.z.string().optional(),
|
|
19460
|
+
sub: import_zod50.z.string().optional()
|
|
19202
19461
|
});
|
|
19203
|
-
AntigravityUserSchema =
|
|
19462
|
+
AntigravityUserSchema = import_zod50.z.object({
|
|
19204
19463
|
/** The code-assist tier context, which defaults to the free tier for every account. */
|
|
19205
|
-
currentTier:
|
|
19464
|
+
currentTier: import_zod50.z.object({ name: import_zod50.z.string().optional(), id: import_zod50.z.string().optional() }).optional(),
|
|
19206
19465
|
/** The account's paid subscription; absent when the account has none. */
|
|
19207
|
-
paidTier:
|
|
19466
|
+
paidTier: import_zod50.z.object({ name: import_zod50.z.string().optional(), id: import_zod50.z.string().optional() }).optional()
|
|
19208
19467
|
});
|
|
19209
19468
|
}
|
|
19210
19469
|
});
|
|
@@ -19272,14 +19531,14 @@ function createRealAnthropicUsageRefresher(params) {
|
|
|
19272
19531
|
},
|
|
19273
19532
|
now: () => Date.now(),
|
|
19274
19533
|
log: params.log,
|
|
19275
|
-
concurrency: (0,
|
|
19534
|
+
concurrency: (0, import_node_os13.availableParallelism)()
|
|
19276
19535
|
});
|
|
19277
19536
|
}
|
|
19278
|
-
var
|
|
19537
|
+
var import_node_os13, PROBE_LAUNCH_FLAGS;
|
|
19279
19538
|
var init_realAnthropicUsageProbe = __esm({
|
|
19280
19539
|
"src/usage/realAnthropicUsageProbe.ts"() {
|
|
19281
19540
|
"use strict";
|
|
19282
|
-
|
|
19541
|
+
import_node_os13 = require("node:os");
|
|
19283
19542
|
init_identityStore();
|
|
19284
19543
|
init_anthropicUsageRefresh();
|
|
19285
19544
|
init_identityClaude();
|
|
@@ -19946,15 +20205,13 @@ init_rcWrites();
|
|
|
19946
20205
|
init_rcSchemas();
|
|
19947
20206
|
|
|
19948
20207
|
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
19949
|
-
var
|
|
20208
|
+
var import_zod25 = require("zod");
|
|
19950
20209
|
|
|
19951
20210
|
// src/frontdoor/rcSessionCommands.ts
|
|
19952
20211
|
var import_promises = require("node:timers/promises");
|
|
19953
20212
|
init_rcControl();
|
|
19954
|
-
|
|
19955
|
-
|
|
19956
|
-
var RESULT_POLL_MS = 250;
|
|
19957
|
-
var REQUEST_INSTANT_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
|
|
20213
|
+
init_sessionControl();
|
|
20214
|
+
init_verifiedVersions();
|
|
19958
20215
|
|
|
19959
20216
|
// src/frontdoor/rcSelfHostCommands.ts
|
|
19960
20217
|
init_connectEffects();
|
|
@@ -20074,9 +20331,7 @@ function recognise(command, event, name, args) {
|
|
|
20074
20331
|
}
|
|
20075
20332
|
return { ok: false, message: `the worker did not compact the session: ${answer.text}` };
|
|
20076
20333
|
}
|
|
20077
|
-
async function
|
|
20078
|
-
const { name, args } = commandLine(command);
|
|
20079
|
-
const text = args === "" ? `/${name}` : `/${name} ${args}`;
|
|
20334
|
+
async function writeAsPersonAndAwait(deps, sessionId, text, recogniseEvent, waitMs, signal) {
|
|
20080
20335
|
const early = [];
|
|
20081
20336
|
let after;
|
|
20082
20337
|
let settle;
|
|
@@ -20089,10 +20344,10 @@ async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signa
|
|
|
20089
20344
|
return;
|
|
20090
20345
|
}
|
|
20091
20346
|
if (isPeerDelivery(event, text)) {
|
|
20092
|
-
settle?.({ ok: false, message: `session ${sessionId}'s worker passed ${text} to its model as a peer's message
|
|
20347
|
+
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` });
|
|
20093
20348
|
return;
|
|
20094
20349
|
}
|
|
20095
|
-
const outcome =
|
|
20350
|
+
const outcome = recogniseEvent(event);
|
|
20096
20351
|
if (outcome !== void 0) {
|
|
20097
20352
|
settle?.(outcome);
|
|
20098
20353
|
}
|
|
@@ -20129,6 +20384,41 @@ async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signa
|
|
|
20129
20384
|
detach();
|
|
20130
20385
|
}
|
|
20131
20386
|
}
|
|
20387
|
+
async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signal) {
|
|
20388
|
+
const { name, args } = commandLine(command);
|
|
20389
|
+
const text = args === "" ? `/${name}` : `/${name} ${args}`;
|
|
20390
|
+
return await writeAsPersonAndAwait(deps, sessionId, text, (event) => recognise(command, event, name, args), waitMs, signal);
|
|
20391
|
+
}
|
|
20392
|
+
function userTextOf(message) {
|
|
20393
|
+
if (typeof message.content === "string") {
|
|
20394
|
+
return message.content;
|
|
20395
|
+
}
|
|
20396
|
+
if (!Array.isArray(message.content)) {
|
|
20397
|
+
return void 0;
|
|
20398
|
+
}
|
|
20399
|
+
const blocks = message.content;
|
|
20400
|
+
return blocks.flatMap((block) => isRecord8(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
|
|
20401
|
+
}
|
|
20402
|
+
function rcPersonTurnOf(event, text) {
|
|
20403
|
+
const payload = event.envelope.payload;
|
|
20404
|
+
if (!isRecord8(payload) || payload.type !== "user" || typeof payload.uuid !== "string" || !isRecord8(payload.origin) || payload.origin.kind !== "human" || !isRecord8(payload.message)) {
|
|
20405
|
+
return void 0;
|
|
20406
|
+
}
|
|
20407
|
+
return userTextOf(payload.message) === text ? payload.uuid : void 0;
|
|
20408
|
+
}
|
|
20409
|
+
async function runSelfHostedTurn(deps, sessionId, text, waitMs, signal) {
|
|
20410
|
+
return await writeAsPersonAndAwait(
|
|
20411
|
+
deps,
|
|
20412
|
+
sessionId,
|
|
20413
|
+
text,
|
|
20414
|
+
(event) => {
|
|
20415
|
+
const uuid = rcPersonTurnOf(event, text);
|
|
20416
|
+
return uuid === void 0 ? void 0 : { ok: true, report: { uuid } };
|
|
20417
|
+
},
|
|
20418
|
+
waitMs,
|
|
20419
|
+
signal
|
|
20420
|
+
);
|
|
20421
|
+
}
|
|
20132
20422
|
function createRcClaudeCodeVersions(fanout) {
|
|
20133
20423
|
const versions = /* @__PURE__ */ new Map();
|
|
20134
20424
|
fanout.subscribe(void 0, (event) => {
|
|
@@ -20150,18 +20440,21 @@ function createRcClaudeCodeVersions(fanout) {
|
|
|
20150
20440
|
}
|
|
20151
20441
|
|
|
20152
20442
|
// src/frontdoor/rcSessionCommands.ts
|
|
20153
|
-
var RC_SESSION_COMMAND_VERIFIED_VERSIONS = ["2.1.319"];
|
|
20154
20443
|
var RC_GOAL_CLEAR_WORDS = ["clear", "stop", "off", "reset", "none", "cancel"];
|
|
20155
20444
|
var RC_GOAL_CONDITION_MAX_CHARS = 4e3;
|
|
20156
20445
|
var MAX_JSON_BYTES_PER_CODE_UNIT = 6;
|
|
20157
20446
|
var RC_COMPACT_INSTRUCTIONS_MAX_CHARS = Math.floor(CONTROL_BODY_CAP_BYTES / MAX_JSON_BYTES_PER_CODE_UNIT);
|
|
20447
|
+
var RC_TURN_TEXT_MAX_CHARS = Math.floor(CONTROL_BODY_CAP_BYTES / MAX_JSON_BYTES_PER_CODE_UNIT);
|
|
20158
20448
|
var RC_SESSION_COMMAND_MAX_WAIT_MS = 2147483647;
|
|
20159
20449
|
function unverifiedVersionMessage(sessionId, version, source) {
|
|
20160
20450
|
const verified = RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ");
|
|
20161
|
-
return version === void 0 ? `session ${sessionId} has not reported its Claude Code version (${source}), and goal and
|
|
20451
|
+
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`;
|
|
20452
|
+
}
|
|
20453
|
+
function noPluginReason(sessionId) {
|
|
20454
|
+
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`;
|
|
20162
20455
|
}
|
|
20163
20456
|
function unsupportedMessage(sessionId) {
|
|
20164
|
-
return
|
|
20457
|
+
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.`;
|
|
20165
20458
|
}
|
|
20166
20459
|
function createRcSessionCommands(deps) {
|
|
20167
20460
|
const queues = /* @__PURE__ */ new Map();
|
|
@@ -20178,57 +20471,78 @@ function createRcSessionCommands(deps) {
|
|
|
20178
20471
|
}
|
|
20179
20472
|
}
|
|
20180
20473
|
};
|
|
20474
|
+
const pluginRoute = async (sessionId, route, lookup2) => {
|
|
20475
|
+
const target = await lookup2(sessionId);
|
|
20476
|
+
if (target === void 0) {
|
|
20477
|
+
return void 0;
|
|
20478
|
+
}
|
|
20479
|
+
if ("refused" in target) {
|
|
20480
|
+
return { kind: "refused", message: target.refused };
|
|
20481
|
+
}
|
|
20482
|
+
if (target.version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(target.version)) {
|
|
20483
|
+
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") };
|
|
20484
|
+
}
|
|
20485
|
+
return { kind: route, target };
|
|
20486
|
+
};
|
|
20487
|
+
const resolveRoute = async (sessionId) => {
|
|
20488
|
+
const supervised = await pluginRoute(sessionId, "supervised", deps.supervisedOf);
|
|
20489
|
+
if (supervised !== void 0) {
|
|
20490
|
+
return supervised;
|
|
20491
|
+
}
|
|
20492
|
+
const launched = deps.launchedOf === void 0 ? void 0 : await pluginRoute(sessionId, "launched", deps.launchedOf);
|
|
20493
|
+
if (launched !== void 0) {
|
|
20494
|
+
return launched;
|
|
20495
|
+
}
|
|
20496
|
+
if (!deps.isObserved(sessionId)) {
|
|
20497
|
+
return { kind: "refused", message: `the front door has not observed Remote Control session ${sessionId}` };
|
|
20498
|
+
}
|
|
20499
|
+
if (deps.selfHost === void 0) {
|
|
20500
|
+
return { kind: "refused", message: unsupportedMessage(sessionId) };
|
|
20501
|
+
}
|
|
20502
|
+
const unavailable = deps.selfHost.unavailable();
|
|
20503
|
+
if (unavailable !== void 0) {
|
|
20504
|
+
return { kind: "refused", message: `${noPluginReason(sessionId)}, and the door's self-hosted surface cannot take a command: ${unavailable}` };
|
|
20505
|
+
}
|
|
20506
|
+
const version = deps.selfHost.versionOf(sessionId);
|
|
20507
|
+
if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
|
|
20508
|
+
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") };
|
|
20509
|
+
}
|
|
20510
|
+
return { kind: "self-hosted", selfHost: deps.selfHost };
|
|
20511
|
+
};
|
|
20181
20512
|
const onRoute = async (sessionId, options, actions) => await serialised(sessionId, async () => {
|
|
20182
20513
|
const { signal } = options;
|
|
20183
20514
|
if (signal?.aborted === true) {
|
|
20184
20515
|
return { ok: false, message: `the request for session ${sessionId} was aborted before it ran` };
|
|
20185
20516
|
}
|
|
20186
|
-
const
|
|
20187
|
-
if (
|
|
20188
|
-
return { ok: false, message:
|
|
20517
|
+
const resolved = await resolveRoute(sessionId);
|
|
20518
|
+
if (resolved.kind === "refused") {
|
|
20519
|
+
return { ok: false, message: resolved.message };
|
|
20189
20520
|
}
|
|
20190
|
-
if (
|
|
20191
|
-
|
|
20192
|
-
|
|
20193
|
-
|
|
20194
|
-
const waitMs = options.waitMs ?? COMPACT_TIMEOUT_MS;
|
|
20195
|
-
const timeout = AbortSignal.timeout(waitMs);
|
|
20196
|
-
const bounded3 = signal === void 0 ? timeout : AbortSignal.any([signal, timeout]);
|
|
20521
|
+
if (resolved.kind !== "self-hosted") {
|
|
20522
|
+
const waitMs2 = options.waitMs ?? COMPACT_TIMEOUT_MS;
|
|
20523
|
+
const timeout2 = AbortSignal.timeout(waitMs2);
|
|
20524
|
+
const bounded3 = signal === void 0 ? timeout2 : AbortSignal.any([signal, timeout2]);
|
|
20197
20525
|
try {
|
|
20198
|
-
return await actions.
|
|
20526
|
+
return await actions.plugin(resolved.target, resolved.kind, bounded3, waitMs2);
|
|
20199
20527
|
} catch (error) {
|
|
20200
|
-
if (
|
|
20201
|
-
return { ok: false, message: `session ${sessionId}'s control plugin did not answer within ${String(
|
|
20528
|
+
if (timeout2.aborted) {
|
|
20529
|
+
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` };
|
|
20202
20530
|
}
|
|
20203
20531
|
return { ok: false, message: `session ${sessionId}'s control plugin did not complete the request: ${error instanceof Error ? error.message : String(error)}` };
|
|
20204
20532
|
}
|
|
20205
20533
|
}
|
|
20206
|
-
|
|
20207
|
-
|
|
20534
|
+
const waitMs = options.waitMs ?? resolved.selfHost.defaultWaitMs;
|
|
20535
|
+
const timeout = AbortSignal.timeout(waitMs);
|
|
20536
|
+
const result = await actions.selfHosted(resolved.selfHost, signal === void 0 ? timeout : AbortSignal.any([signal, timeout]));
|
|
20537
|
+
if (!result.ok && timeout.aborted) {
|
|
20538
|
+
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` };
|
|
20208
20539
|
}
|
|
20209
|
-
|
|
20210
|
-
const unavailable = deps.selfHost.unavailable();
|
|
20211
|
-
if (unavailable !== void 0) {
|
|
20212
|
-
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}` };
|
|
20213
|
-
}
|
|
20214
|
-
const version = deps.selfHost.versionOf(sessionId);
|
|
20215
|
-
if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
|
|
20216
|
-
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") };
|
|
20217
|
-
}
|
|
20218
|
-
const waitMs = options.waitMs ?? deps.selfHost.defaultWaitMs;
|
|
20219
|
-
const timeout = AbortSignal.timeout(waitMs);
|
|
20220
|
-
const result = await actions.selfHosted(deps.selfHost, signal === void 0 ? timeout : AbortSignal.any([signal, timeout]));
|
|
20221
|
-
if (!result.ok && timeout.aborted) {
|
|
20222
|
-
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` };
|
|
20223
|
-
}
|
|
20224
|
-
return result;
|
|
20225
|
-
}
|
|
20226
|
-
return { ok: false, message: unsupportedMessage(sessionId) };
|
|
20540
|
+
return result;
|
|
20227
20541
|
});
|
|
20228
20542
|
const transcriptGoal = async (sessionId, target) => {
|
|
20229
20543
|
const goal = target.transcriptPath === void 0 ? void 0 : await deps.goalOf(target.transcriptPath);
|
|
20230
20544
|
if (goal === void 0) {
|
|
20231
|
-
return { ok: false, message: `session ${sessionId}'s
|
|
20545
|
+
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` };
|
|
20232
20546
|
}
|
|
20233
20547
|
return { ok: true, report: goal };
|
|
20234
20548
|
};
|
|
@@ -20242,12 +20556,64 @@ function createRcSessionCommands(deps) {
|
|
|
20242
20556
|
}
|
|
20243
20557
|
};
|
|
20244
20558
|
const waitOf = (options) => options.waitMs;
|
|
20559
|
+
const transcriptPluginTurns = async (sessionId, target) => {
|
|
20560
|
+
const turns = target.transcriptPath === void 0 ? void 0 : await deps.pluginTurnsOf(target.transcriptPath);
|
|
20561
|
+
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 };
|
|
20562
|
+
};
|
|
20245
20563
|
return {
|
|
20564
|
+
/** 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. */
|
|
20565
|
+
routeOf: async (sessionId) => {
|
|
20566
|
+
const resolved = await resolveRoute(sessionId);
|
|
20567
|
+
return resolved.kind === "refused" ? { route: null, refused: resolved.message } : { route: resolved.kind };
|
|
20568
|
+
},
|
|
20569
|
+
/**
|
|
20570
|
+
* 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.
|
|
20571
|
+
*/
|
|
20572
|
+
turn: async (sessionId, text, options = {}) => {
|
|
20573
|
+
if (text.trim() === "") {
|
|
20574
|
+
return { ok: false, message: "a turn needs non-empty text" };
|
|
20575
|
+
}
|
|
20576
|
+
if (text.trimStart().startsWith("/")) {
|
|
20577
|
+
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" };
|
|
20578
|
+
}
|
|
20579
|
+
if (text.length > RC_TURN_TEXT_MAX_CHARS) {
|
|
20580
|
+
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)}` };
|
|
20581
|
+
}
|
|
20582
|
+
return await onRoute(sessionId, options, {
|
|
20583
|
+
plugin: async (target, route, signal, waitMs) => {
|
|
20584
|
+
const before = await transcriptPluginTurns(sessionId, target);
|
|
20585
|
+
if (!before.ok) {
|
|
20586
|
+
return before;
|
|
20587
|
+
}
|
|
20588
|
+
const submitted = await target.submitTurn(text, signal, waitMs);
|
|
20589
|
+
if (!submitted.asUser) {
|
|
20590
|
+
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` };
|
|
20591
|
+
}
|
|
20592
|
+
for (; ; ) {
|
|
20593
|
+
const after = await transcriptPluginTurns(sessionId, target);
|
|
20594
|
+
if (!after.ok) {
|
|
20595
|
+
return after;
|
|
20596
|
+
}
|
|
20597
|
+
if (after.report.count > before.report.count && after.report.last !== void 0) {
|
|
20598
|
+
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` };
|
|
20599
|
+
}
|
|
20600
|
+
if (signal.aborted) {
|
|
20601
|
+
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` };
|
|
20602
|
+
}
|
|
20603
|
+
await (0, import_promises.setTimeout)(RESULT_POLL_MS);
|
|
20604
|
+
}
|
|
20605
|
+
},
|
|
20606
|
+
selfHosted: async (selfHost, signal) => {
|
|
20607
|
+
const delivered = await runSelfHostedTurn(selfHost, sessionId, text, waitOf(options), signal);
|
|
20608
|
+
return delivered.ok ? { ok: true, report: { route: "self-hosted", uuid: delivered.report.uuid } } : delivered;
|
|
20609
|
+
}
|
|
20610
|
+
});
|
|
20611
|
+
},
|
|
20246
20612
|
/** 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. */
|
|
20247
20613
|
goalGet: async (sessionId, options = {}) => await onRoute(sessionId, options, {
|
|
20248
|
-
|
|
20614
|
+
plugin: async (target, route) => {
|
|
20249
20615
|
const read = await transcriptGoal(sessionId, target);
|
|
20250
|
-
return
|
|
20616
|
+
return read.ok ? { ok: true, report: { route, goal: read.report } } : read;
|
|
20251
20617
|
},
|
|
20252
20618
|
selfHosted: async (selfHost, signal) => {
|
|
20253
20619
|
const read = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
|
|
@@ -20272,7 +20638,7 @@ function createRcSessionCommands(deps) {
|
|
|
20272
20638
|
return { ok: false, message: `a goal condition is limited to ${String(RC_GOAL_CONDITION_MAX_CHARS)} characters, and this one has ${String(trimmed.length)}` };
|
|
20273
20639
|
}
|
|
20274
20640
|
return await onRoute(sessionId, options, {
|
|
20275
|
-
|
|
20641
|
+
plugin: async (target, route, signal, waitMs) => {
|
|
20276
20642
|
const before = await transcriptGoal(sessionId, target);
|
|
20277
20643
|
if (!before.ok) {
|
|
20278
20644
|
return before;
|
|
@@ -20282,7 +20648,7 @@ function createRcSessionCommands(deps) {
|
|
|
20282
20648
|
if (!after.ok) {
|
|
20283
20649
|
return after;
|
|
20284
20650
|
}
|
|
20285
|
-
return after.report?.condition === trimmed ? { ok: true, report: { route
|
|
20651
|
+
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` };
|
|
20286
20652
|
},
|
|
20287
20653
|
selfHosted: async (selfHost, signal) => {
|
|
20288
20654
|
const before = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
|
|
@@ -20296,20 +20662,20 @@ function createRcSessionCommands(deps) {
|
|
|
20296
20662
|
},
|
|
20297
20663
|
/** 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). */
|
|
20298
20664
|
goalClear: async (sessionId, options = {}) => await onRoute(sessionId, options, {
|
|
20299
|
-
|
|
20665
|
+
plugin: async (target, route, signal, waitMs) => {
|
|
20300
20666
|
const before = await transcriptGoal(sessionId, target);
|
|
20301
20667
|
if (!before.ok) {
|
|
20302
20668
|
return before;
|
|
20303
20669
|
}
|
|
20304
20670
|
if (before.report === null) {
|
|
20305
|
-
return { ok: true, report: { route
|
|
20671
|
+
return { ok: true, report: { route, cleared: null } };
|
|
20306
20672
|
}
|
|
20307
20673
|
await target.runGoal("clear", signal, waitMs);
|
|
20308
20674
|
const after = await settledGoal(sessionId, target, signal, (goal) => goal === null);
|
|
20309
20675
|
if (!after.ok) {
|
|
20310
20676
|
return after;
|
|
20311
20677
|
}
|
|
20312
|
-
return after.report === null ? { ok: true, report: { route
|
|
20678
|
+
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}"` };
|
|
20313
20679
|
},
|
|
20314
20680
|
selfHosted: async (selfHost, signal) => {
|
|
20315
20681
|
const cleared = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-clear" }, waitOf(options), signal);
|
|
@@ -20321,12 +20687,12 @@ function createRcSessionCommands(deps) {
|
|
|
20321
20687
|
const instructions = options.instructions?.trim();
|
|
20322
20688
|
const given = instructions === void 0 || instructions === "" ? void 0 : instructions;
|
|
20323
20689
|
return await onRoute(sessionId, options, {
|
|
20324
|
-
|
|
20690
|
+
plugin: async (target, route, signal, waitMs) => {
|
|
20325
20691
|
const result = await target.compact(signal, given, waitMs);
|
|
20326
20692
|
if (result.kind === "unchanged") {
|
|
20327
20693
|
return { ok: false, message: `session ${sessionId} was not compacted: ${result.reason}` };
|
|
20328
20694
|
}
|
|
20329
|
-
return { ok: true, report: { route
|
|
20695
|
+
return { ok: true, report: { route, trigger: "plugin", ...result.beforeTokens === void 0 ? {} : { preTokens: result.beforeTokens }, ...result.afterTokens === void 0 ? {} : { postTokens: result.afterTokens } } };
|
|
20330
20696
|
},
|
|
20331
20697
|
selfHosted: async (selfHost, signal) => {
|
|
20332
20698
|
const compacted = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "compact", instructions: given }, waitOf(options), signal);
|
|
@@ -20338,47 +20704,56 @@ function createRcSessionCommands(deps) {
|
|
|
20338
20704
|
}
|
|
20339
20705
|
|
|
20340
20706
|
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
20341
|
-
var WaitMsSchema =
|
|
20342
|
-
var RcGoalSessionInputSchema =
|
|
20343
|
-
session:
|
|
20707
|
+
var WaitMsSchema = import_zod25.z.int().positive().max(RC_SESSION_COMMAND_MAX_WAIT_MS).optional();
|
|
20708
|
+
var RcGoalSessionInputSchema = import_zod25.z.strictObject({
|
|
20709
|
+
session: import_zod25.z.string().min(1),
|
|
20710
|
+
waitMs: WaitMsSchema
|
|
20711
|
+
});
|
|
20712
|
+
var RcGoalSetInputSchema = import_zod25.z.strictObject({
|
|
20713
|
+
session: import_zod25.z.string().min(1),
|
|
20714
|
+
condition: import_zod25.z.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
|
|
20344
20715
|
waitMs: WaitMsSchema
|
|
20345
20716
|
});
|
|
20346
|
-
var
|
|
20347
|
-
session:
|
|
20348
|
-
condition: import_zod24.z.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
|
|
20717
|
+
var RcCompactInputSchema = import_zod25.z.strictObject({
|
|
20718
|
+
session: import_zod25.z.string().min(1),
|
|
20349
20719
|
waitMs: WaitMsSchema
|
|
20350
20720
|
});
|
|
20351
|
-
var
|
|
20352
|
-
session:
|
|
20721
|
+
var RcCompactWithInstructionsInputSchema = import_zod25.z.strictObject({
|
|
20722
|
+
session: import_zod25.z.string().min(1),
|
|
20723
|
+
instructions: import_zod25.z.string().trim().min(1).max(RC_COMPACT_INSTRUCTIONS_MAX_CHARS),
|
|
20353
20724
|
waitMs: WaitMsSchema
|
|
20354
20725
|
});
|
|
20355
|
-
var
|
|
20356
|
-
session:
|
|
20357
|
-
|
|
20726
|
+
var RcTurnInputSchema = import_zod25.z.strictObject({
|
|
20727
|
+
session: import_zod25.z.string().min(1),
|
|
20728
|
+
text: import_zod25.z.string().min(1).max(RC_TURN_TEXT_MAX_CHARS),
|
|
20358
20729
|
waitMs: WaitMsSchema
|
|
20359
20730
|
});
|
|
20360
20731
|
var commandAnswerShape = {
|
|
20361
|
-
session:
|
|
20362
|
-
route:
|
|
20732
|
+
session: import_zod25.z.string(),
|
|
20733
|
+
route: import_zod25.z.enum(["supervised", "launched", "self-hosted"])
|
|
20363
20734
|
};
|
|
20364
|
-
var RcGoalGetOutputSchema =
|
|
20735
|
+
var RcGoalGetOutputSchema = import_zod25.z.strictObject({
|
|
20736
|
+
...commandAnswerShape,
|
|
20737
|
+
goal: import_zod25.z.strictObject({ condition: import_zod25.z.string(), iterations: import_zod25.z.int().nonnegative(), lastCheck: import_zod25.z.string().optional() }).nullable()
|
|
20738
|
+
});
|
|
20739
|
+
var RcGoalSetOutputSchema = import_zod25.z.strictObject({
|
|
20365
20740
|
...commandAnswerShape,
|
|
20366
|
-
|
|
20741
|
+
condition: import_zod25.z.string(),
|
|
20742
|
+
superseded: import_zod25.z.string().nullable()
|
|
20367
20743
|
});
|
|
20368
|
-
var
|
|
20744
|
+
var RcGoalClearOutputSchema = import_zod25.z.strictObject({
|
|
20369
20745
|
...commandAnswerShape,
|
|
20370
|
-
|
|
20371
|
-
superseded: import_zod24.z.string().nullable()
|
|
20746
|
+
cleared: import_zod25.z.string().nullable()
|
|
20372
20747
|
});
|
|
20373
|
-
var
|
|
20748
|
+
var RcTurnOutputSchema = import_zod25.z.strictObject({
|
|
20374
20749
|
...commandAnswerShape,
|
|
20375
|
-
|
|
20750
|
+
uuid: import_zod25.z.string()
|
|
20376
20751
|
});
|
|
20377
|
-
var RcCompactOutputSchema =
|
|
20752
|
+
var RcCompactOutputSchema = import_zod25.z.strictObject({
|
|
20378
20753
|
...commandAnswerShape,
|
|
20379
|
-
trigger:
|
|
20380
|
-
preTokens:
|
|
20381
|
-
postTokens:
|
|
20754
|
+
trigger: import_zod25.z.string(),
|
|
20755
|
+
preTokens: import_zod25.z.number().optional(),
|
|
20756
|
+
postTokens: import_zod25.z.number().optional()
|
|
20382
20757
|
});
|
|
20383
20758
|
|
|
20384
20759
|
// src/frontdoor/rcApi.ts
|
|
@@ -20430,12 +20805,12 @@ function createRcApiRouter(deps) {
|
|
|
20430
20805
|
return {
|
|
20431
20806
|
rc: {
|
|
20432
20807
|
list: authed.meta((0, import_openapi.openapi)({ method: "GET", path: "/rest/rc/sessions", summary: "List the observed Remote Control sessions", tags: [RC_API_TAG] })).output(RcListOutputSchema).handler(() => ({ sessions: deps.list() })),
|
|
20433
|
-
status: authed.meta((0, import_openapi.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 }) => {
|
|
20808
|
+
status: authed.meta((0, import_openapi.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 }) => {
|
|
20434
20809
|
const statuses = deps.statusOf(input.session);
|
|
20435
20810
|
if (input.session !== void 0 && !statuses.some((entry) => entry.id === input.session)) {
|
|
20436
20811
|
throw new import_client.ORPCError("NOT_FOUND", { message: rcSessionNotObservedMessage(input.session) });
|
|
20437
20812
|
}
|
|
20438
|
-
return { statuses };
|
|
20813
|
+
return { statuses: await Promise.all(statuses.map(async (status) => ({ ...status, route: await deps.routeOf(status.id) }))) };
|
|
20439
20814
|
}),
|
|
20440
20815
|
pending: authed.meta((0, import_openapi.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 }) => {
|
|
20441
20816
|
const pending = deps.pendingOf(input.session);
|
|
@@ -20470,6 +20845,7 @@ function createRcApiRouter(deps) {
|
|
|
20470
20845
|
goalClear: authed.meta((0, import_openapi.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)))),
|
|
20471
20846
|
compact: authed.meta((0, import_openapi.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)))),
|
|
20472
20847
|
compactWithInstructions: authed.meta((0, import_openapi.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 }))),
|
|
20848
|
+
turn: authed.meta((0, import_openapi.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)))),
|
|
20473
20849
|
subscribe: authed.meta((0, import_openapi.openapi)({ method: "GET", path: "/rest/rc/events", summary: "Stream a session's Remote Control events (SSE)", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output((0, import_server2.eventIterator)(RcStreamEventSchema)).handler(async function* ({ input, signal }) {
|
|
20474
20850
|
const queue = [];
|
|
20475
20851
|
let wake;
|
|
@@ -20551,7 +20927,7 @@ function createRcApiNodeHandler(deps) {
|
|
|
20551
20927
|
return doorApiNodeHandlerOf(createRcApiRouter(deps), deps.expectedToken);
|
|
20552
20928
|
}
|
|
20553
20929
|
var DEFAULT_HEADERS_TIMEOUT_MS = 3e5;
|
|
20554
|
-
var SESSION_COMMAND_PROCEDURES = ["rc/goalGet", "rc/goalSet", "rc/goalClear", "rc/compact", "rc/compactWithInstructions"];
|
|
20930
|
+
var SESSION_COMMAND_PROCEDURES = ["rc/goalGet", "rc/goalSet", "rc/goalClear", "rc/compact", "rc/compactWithInstructions", "rc/turn"];
|
|
20555
20931
|
function headersTimeoutOf(url, body) {
|
|
20556
20932
|
if (!SESSION_COMMAND_PROCEDURES.some((procedure) => url.endsWith(`${RC_ORPC_PATH_PREFIX}/${procedure}`))) {
|
|
20557
20933
|
return DEFAULT_HEADERS_TIMEOUT_MS;
|
|
@@ -20599,48 +20975,48 @@ init_cliError();
|
|
|
20599
20975
|
init_package();
|
|
20600
20976
|
|
|
20601
20977
|
// src/codex/appServerSchemas.ts
|
|
20602
|
-
var
|
|
20978
|
+
var import_zod26 = require("zod");
|
|
20603
20979
|
var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
|
|
20604
|
-
var RateLimitWindowSchema =
|
|
20605
|
-
usedPercent:
|
|
20606
|
-
resetsAt:
|
|
20607
|
-
windowDurationMins:
|
|
20608
|
-
});
|
|
20609
|
-
var RateLimitSnapshotSchema =
|
|
20610
|
-
limitId:
|
|
20611
|
-
limitName:
|
|
20612
|
-
planType:
|
|
20980
|
+
var RateLimitWindowSchema = import_zod26.z.object({
|
|
20981
|
+
usedPercent: import_zod26.z.number(),
|
|
20982
|
+
resetsAt: import_zod26.z.number().nullish(),
|
|
20983
|
+
windowDurationMins: import_zod26.z.number().nullish()
|
|
20984
|
+
});
|
|
20985
|
+
var RateLimitSnapshotSchema = import_zod26.z.object({
|
|
20986
|
+
limitId: import_zod26.z.string().nullish(),
|
|
20987
|
+
limitName: import_zod26.z.string().nullish(),
|
|
20988
|
+
planType: import_zod26.z.string().nullish(),
|
|
20613
20989
|
primary: RateLimitWindowSchema.nullish(),
|
|
20614
20990
|
secondary: RateLimitWindowSchema.nullish(),
|
|
20615
|
-
rateLimitReachedType:
|
|
20616
|
-
spendControlReached:
|
|
20617
|
-
});
|
|
20618
|
-
var RateLimitResetCreditSchema =
|
|
20619
|
-
id:
|
|
20620
|
-
grantedAt:
|
|
20621
|
-
expiresAt:
|
|
20622
|
-
resetType:
|
|
20623
|
-
status:
|
|
20624
|
-
title:
|
|
20625
|
-
description:
|
|
20626
|
-
});
|
|
20627
|
-
var CodexAccountSchema =
|
|
20628
|
-
|
|
20629
|
-
|
|
20630
|
-
|
|
20991
|
+
rateLimitReachedType: import_zod26.z.string().nullish(),
|
|
20992
|
+
spendControlReached: import_zod26.z.boolean().nullish()
|
|
20993
|
+
});
|
|
20994
|
+
var RateLimitResetCreditSchema = import_zod26.z.object({
|
|
20995
|
+
id: import_zod26.z.string(),
|
|
20996
|
+
grantedAt: import_zod26.z.number(),
|
|
20997
|
+
expiresAt: import_zod26.z.number().nullish(),
|
|
20998
|
+
resetType: import_zod26.z.string(),
|
|
20999
|
+
status: import_zod26.z.string(),
|
|
21000
|
+
title: import_zod26.z.string().nullish(),
|
|
21001
|
+
description: import_zod26.z.string().nullish()
|
|
21002
|
+
});
|
|
21003
|
+
var CodexAccountSchema = import_zod26.z.discriminatedUnion("type", [
|
|
21004
|
+
import_zod26.z.object({ type: import_zod26.z.literal("apiKey") }),
|
|
21005
|
+
import_zod26.z.object({ type: import_zod26.z.literal("chatgpt"), email: import_zod26.z.string().nullable(), planType: import_zod26.z.string() }),
|
|
21006
|
+
import_zod26.z.object({ type: import_zod26.z.literal("amazonBedrock"), usesCodexManagedCredentials: import_zod26.z.boolean().default(false) })
|
|
20631
21007
|
]);
|
|
20632
|
-
var CodexAccountReadSchema =
|
|
21008
|
+
var CodexAccountReadSchema = import_zod26.z.object({
|
|
20633
21009
|
account: CodexAccountSchema.nullable(),
|
|
20634
|
-
requiresOpenaiAuth:
|
|
21010
|
+
requiresOpenaiAuth: import_zod26.z.boolean()
|
|
20635
21011
|
});
|
|
20636
|
-
var CodexRateLimitsReadSchema =
|
|
21012
|
+
var CodexRateLimitsReadSchema = import_zod26.z.object({
|
|
20637
21013
|
rateLimits: RateLimitSnapshotSchema,
|
|
20638
|
-
rateLimitsByLimitId:
|
|
20639
|
-
rateLimitResetCredits:
|
|
20640
|
-
accountId:
|
|
20641
|
-
ordinaryUsageAllowed:
|
|
21014
|
+
rateLimitsByLimitId: import_zod26.z.record(import_zod26.z.string(), RateLimitSnapshotSchema).nullish(),
|
|
21015
|
+
rateLimitResetCredits: import_zod26.z.object({ availableCount: import_zod26.z.number(), credits: import_zod26.z.array(RateLimitResetCreditSchema).nullish() }).nullish(),
|
|
21016
|
+
accountId: import_zod26.z.string().nullish(),
|
|
21017
|
+
ordinaryUsageAllowed: import_zod26.z.boolean().nullish()
|
|
20642
21018
|
});
|
|
20643
|
-
var CodexInitializeResultSchema =
|
|
21019
|
+
var CodexInitializeResultSchema = import_zod26.z.object({ userAgent: import_zod26.z.string() });
|
|
20644
21020
|
|
|
20645
21021
|
// src/codex/appServer.ts
|
|
20646
21022
|
var CodexAppServerUnavailableError = class extends CliError {
|
|
@@ -20839,7 +21215,7 @@ var import_client8 = require("@orpc/client");
|
|
|
20839
21215
|
var import_openapi9 = require("@orpc/openapi");
|
|
20840
21216
|
|
|
20841
21217
|
// src/checkReportSchema.ts
|
|
20842
|
-
var
|
|
21218
|
+
var import_zod28 = require("zod");
|
|
20843
21219
|
init_schema();
|
|
20844
21220
|
init_claudeVersion();
|
|
20845
21221
|
init_identity2();
|
|
@@ -20905,130 +21281,130 @@ var DIAGNOSTIC_CODES = [
|
|
|
20905
21281
|
var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
|
|
20906
21282
|
|
|
20907
21283
|
// src/usage/pickReportSchema.ts
|
|
20908
|
-
var
|
|
21284
|
+
var import_zod27 = require("zod");
|
|
20909
21285
|
init_plan2();
|
|
20910
|
-
var PoolPickCandidateViewSchema =
|
|
20911
|
-
identity:
|
|
21286
|
+
var PoolPickCandidateViewSchema = import_zod27.z.strictObject({
|
|
21287
|
+
identity: import_zod27.z.string(),
|
|
20912
21288
|
/** 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. */
|
|
20913
|
-
class:
|
|
21289
|
+
class: import_zod27.z.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
|
|
20914
21290
|
/** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
|
|
20915
|
-
score:
|
|
21291
|
+
score: import_zod27.z.number().optional(),
|
|
20916
21292
|
/** 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`. */
|
|
20917
|
-
scoreWindow:
|
|
21293
|
+
scoreWindow: import_zod27.z.enum(["sevenDay", "fiveHour"]).optional(),
|
|
20918
21294
|
/** False when the five-hour window would run dry, at the observed pace, before it resets. */
|
|
20919
|
-
feasible:
|
|
21295
|
+
feasible: import_zod27.z.boolean(),
|
|
20920
21296
|
/** When an `ineligible` member can be used again, as an ISO instant. */
|
|
20921
|
-
blockedUntil:
|
|
21297
|
+
blockedUntil: import_zod27.z.iso.datetime().optional(),
|
|
20922
21298
|
plan: PlanClassSchema,
|
|
20923
21299
|
/** 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. */
|
|
20924
|
-
provider:
|
|
21300
|
+
provider: import_zod27.z.string().optional(),
|
|
20925
21301
|
/** The facts behind the class and score, in the order they matter. */
|
|
20926
|
-
reasons:
|
|
21302
|
+
reasons: import_zod27.z.array(import_zod27.z.string())
|
|
20927
21303
|
});
|
|
20928
|
-
var PoolPickReportSchema =
|
|
20929
|
-
pool:
|
|
20930
|
-
directory:
|
|
21304
|
+
var PoolPickReportSchema = import_zod27.z.strictObject({
|
|
21305
|
+
pool: import_zod27.z.string(),
|
|
21306
|
+
directory: import_zod27.z.string(),
|
|
20931
21307
|
/** The member a launch would run as, absent when every member is refused. */
|
|
20932
|
-
pick:
|
|
20933
|
-
candidates:
|
|
21308
|
+
pick: import_zod27.z.string().optional(),
|
|
21309
|
+
candidates: import_zod27.z.array(PoolPickCandidateViewSchema),
|
|
20934
21310
|
/** Identity members anywhere in the pool's graph that do not exist; a launch skips them. */
|
|
20935
|
-
missing:
|
|
21311
|
+
missing: import_zod27.z.array(import_zod27.z.string()),
|
|
20936
21312
|
/** When nothing can be picked, the soonest any member returns. */
|
|
20937
|
-
earliestReturn:
|
|
21313
|
+
earliestReturn: import_zod27.z.strictObject({ identity: import_zod27.z.string(), at: import_zod27.z.iso.datetime() }).optional(),
|
|
20938
21314
|
/** The member a resumed conversation started on but moved off, and why, when the ranking could not keep it. */
|
|
20939
|
-
movedOff:
|
|
21315
|
+
movedOff: import_zod27.z.strictObject({ identity: import_zod27.z.string(), reason: import_zod27.z.string() }).optional(),
|
|
20940
21316
|
/** Why the last-pick record could not be read, when that is the case. */
|
|
20941
|
-
stickyProblem:
|
|
21317
|
+
stickyProblem: import_zod27.z.string().optional()
|
|
20942
21318
|
});
|
|
20943
21319
|
|
|
20944
21320
|
// src/checkReportSchema.ts
|
|
20945
21321
|
var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
|
|
20946
|
-
var CheckLayerViewSchema =
|
|
20947
|
-
id:
|
|
20948
|
-
kind:
|
|
20949
|
-
source:
|
|
20950
|
-
});
|
|
20951
|
-
var CheckEntryViewSchema =
|
|
20952
|
-
path:
|
|
20953
|
-
shared:
|
|
20954
|
-
via:
|
|
21322
|
+
var CheckLayerViewSchema = import_zod28.z.strictObject({
|
|
21323
|
+
id: import_zod28.z.int(),
|
|
21324
|
+
kind: import_zod28.z.enum(LAYER_KINDS),
|
|
21325
|
+
source: import_zod28.z.string()
|
|
21326
|
+
});
|
|
21327
|
+
var CheckEntryViewSchema = import_zod28.z.strictObject({
|
|
21328
|
+
path: import_zod28.z.string(),
|
|
21329
|
+
shared: import_zod28.z.boolean(),
|
|
21330
|
+
via: import_zod28.z.enum(DECISION_VIAS),
|
|
20955
21331
|
/** The entry's real category, or null when nothing classifies it. */
|
|
20956
|
-
category:
|
|
20957
|
-
rule:
|
|
21332
|
+
category: import_zod28.z.enum(CATEGORY_NAMES).nullable(),
|
|
21333
|
+
rule: import_zod28.z.strictObject({ key: import_zod28.z.string(), layer: import_zod28.z.int() }).optional(),
|
|
20958
21334
|
/** Rules that matched but whose `when` condition failed, each with the conditions that failed. */
|
|
20959
|
-
eliminated:
|
|
20960
|
-
});
|
|
20961
|
-
var CheckDiagnosticSchema =
|
|
20962
|
-
code:
|
|
20963
|
-
severity:
|
|
20964
|
-
message:
|
|
20965
|
-
subject:
|
|
20966
|
-
layer:
|
|
20967
|
-
});
|
|
20968
|
-
var CheckAmbientCredentialSchema =
|
|
20969
|
-
var CheckKeychainSchema =
|
|
20970
|
-
checked:
|
|
20971
|
-
found:
|
|
20972
|
-
serviceName:
|
|
20973
|
-
note:
|
|
20974
|
-
});
|
|
20975
|
-
var CheckSettingsExposureSchema =
|
|
20976
|
-
file:
|
|
20977
|
-
envKeyNames:
|
|
20978
|
-
hookEventNames:
|
|
20979
|
-
hookCommandCount:
|
|
20980
|
-
});
|
|
20981
|
-
var CredentialSourceSummarySchema =
|
|
20982
|
-
|
|
20983
|
-
|
|
20984
|
-
|
|
20985
|
-
|
|
20986
|
-
|
|
20987
|
-
|
|
21335
|
+
eliminated: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.strictObject({ key: import_zod28.z.string(), failed: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string())) }))).optional()
|
|
21336
|
+
});
|
|
21337
|
+
var CheckDiagnosticSchema = import_zod28.z.strictObject({
|
|
21338
|
+
code: import_zod28.z.enum(DIAGNOSTIC_CODES),
|
|
21339
|
+
severity: import_zod28.z.enum(DIAGNOSTIC_SEVERITIES),
|
|
21340
|
+
message: import_zod28.z.string(),
|
|
21341
|
+
subject: import_zod28.z.string().optional(),
|
|
21342
|
+
layer: import_zod28.z.int().optional()
|
|
21343
|
+
});
|
|
21344
|
+
var CheckAmbientCredentialSchema = import_zod28.z.union([import_zod28.z.strictObject({ ok: import_zod28.z.literal(true) }), import_zod28.z.strictObject({ ok: import_zod28.z.literal(false), variable: import_zod28.z.string(), message: import_zod28.z.string() })]);
|
|
21345
|
+
var CheckKeychainSchema = import_zod28.z.strictObject({
|
|
21346
|
+
checked: import_zod28.z.literal(true),
|
|
21347
|
+
found: import_zod28.z.boolean(),
|
|
21348
|
+
serviceName: import_zod28.z.string().optional(),
|
|
21349
|
+
note: import_zod28.z.string()
|
|
21350
|
+
});
|
|
21351
|
+
var CheckSettingsExposureSchema = import_zod28.z.strictObject({
|
|
21352
|
+
file: import_zod28.z.string(),
|
|
21353
|
+
envKeyNames: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string())),
|
|
21354
|
+
hookEventNames: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string())),
|
|
21355
|
+
hookCommandCount: import_zod28.z.int().nonnegative()
|
|
21356
|
+
});
|
|
21357
|
+
var CredentialSourceSummarySchema = import_zod28.z.union([
|
|
21358
|
+
import_zod28.z.strictObject({ kind: import_zod28.z.literal("env"), variable: import_zod28.z.string() }),
|
|
21359
|
+
import_zod28.z.strictObject({ kind: import_zod28.z.literal("file"), path: import_zod28.z.string() }),
|
|
21360
|
+
import_zod28.z.strictObject({ kind: import_zod28.z.literal("command"), program: import_zod28.z.string() }),
|
|
21361
|
+
import_zod28.z.strictObject({ kind: import_zod28.z.literal("op"), reference: import_zod28.z.string() }),
|
|
21362
|
+
import_zod28.z.strictObject({ kind: import_zod28.z.literal("keychain"), service: import_zod28.z.string(), account: import_zod28.z.string().optional() }),
|
|
21363
|
+
import_zod28.z.strictObject({ kind: import_zod28.z.literal("literal") })
|
|
20988
21364
|
]);
|
|
20989
|
-
var CredentialSummarySchema =
|
|
20990
|
-
target:
|
|
20991
|
-
sources:
|
|
21365
|
+
var CredentialSummarySchema = import_zod28.z.strictObject({
|
|
21366
|
+
target: import_zod28.z.enum(CREDENTIAL_TARGETS),
|
|
21367
|
+
sources: import_zod28.z.readonly(import_zod28.z.array(CredentialSourceSummarySchema)),
|
|
20992
21368
|
cache: CredentialCacheSchema.optional()
|
|
20993
21369
|
});
|
|
20994
|
-
var CachedCredentialStateSchema =
|
|
20995
|
-
|
|
20996
|
-
|
|
20997
|
-
|
|
21370
|
+
var CachedCredentialStateSchema = import_zod28.z.union([
|
|
21371
|
+
import_zod28.z.strictObject({ store: import_zod28.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod28.z.literal("empty") }),
|
|
21372
|
+
import_zod28.z.strictObject({ store: import_zod28.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod28.z.literal("unreadable"), reason: import_zod28.z.string() }),
|
|
21373
|
+
import_zod28.z.strictObject({ store: import_zod28.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod28.z.enum(["fresh", "expired"]), ageMs: import_zod28.z.number(), expiresInMs: import_zod28.z.number().optional() })
|
|
20998
21374
|
]);
|
|
20999
|
-
var CheckCredentialProviderSchema =
|
|
21000
|
-
|
|
21001
|
-
|
|
21375
|
+
var CheckCredentialProviderSchema = import_zod28.z.union([
|
|
21376
|
+
import_zod28.z.strictObject({ name: import_zod28.z.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
|
|
21377
|
+
import_zod28.z.strictObject({ name: import_zod28.z.string(), problem: import_zod28.z.string() })
|
|
21002
21378
|
]);
|
|
21003
|
-
var CheckProviderReachabilitySchema =
|
|
21004
|
-
|
|
21005
|
-
|
|
21379
|
+
var CheckProviderReachabilitySchema = import_zod28.z.union([
|
|
21380
|
+
import_zod28.z.strictObject({ name: import_zod28.z.string(), baseUrl: import_zod28.z.string(), ok: import_zod28.z.literal(true) }),
|
|
21381
|
+
import_zod28.z.strictObject({ name: import_zod28.z.string(), baseUrl: import_zod28.z.string(), ok: import_zod28.z.literal(false), message: import_zod28.z.string() })
|
|
21006
21382
|
]);
|
|
21007
|
-
var CheckCredentialSchema =
|
|
21008
|
-
applies:
|
|
21383
|
+
var CheckCredentialSchema = import_zod28.z.strictObject({
|
|
21384
|
+
applies: import_zod28.z.enum(CHECK_CREDENTIAL_APPLIES),
|
|
21009
21385
|
provider: CheckCredentialProviderSchema.optional(),
|
|
21010
21386
|
identity: CredentialSummarySchema.optional(),
|
|
21011
21387
|
identityCached: CachedCredentialStateSchema.optional()
|
|
21012
21388
|
});
|
|
21013
|
-
var CheckClaudeVersionSchema =
|
|
21014
|
-
pinned:
|
|
21015
|
-
highestInstalled:
|
|
21016
|
-
installed:
|
|
21389
|
+
var CheckClaudeVersionSchema = import_zod28.z.strictObject({
|
|
21390
|
+
pinned: import_zod28.z.strictObject({ version: import_zod28.z.string(), source: import_zod28.z.enum(CLAUDE_VERSION_SOURCES), installed: import_zod28.z.boolean() }).optional(),
|
|
21391
|
+
highestInstalled: import_zod28.z.string().optional(),
|
|
21392
|
+
installed: import_zod28.z.readonly(import_zod28.z.array(import_zod28.z.string()))
|
|
21017
21393
|
});
|
|
21018
|
-
var CheckReportJsonSchema =
|
|
21019
|
-
identity:
|
|
21394
|
+
var CheckReportJsonSchema = import_zod28.z.strictObject({
|
|
21395
|
+
identity: import_zod28.z.strictObject({ name: import_zod28.z.string().nullable(), source: import_zod28.z.enum(IDENTITY_DECISION_SOURCES) }),
|
|
21020
21396
|
/** The pool ranking, when the launch named a pool instead of an identity. */
|
|
21021
21397
|
pool: PoolPickReportSchema.optional(),
|
|
21022
|
-
configProfile:
|
|
21023
|
-
layers:
|
|
21024
|
-
entries:
|
|
21025
|
-
projectEncodingAmbiguities:
|
|
21026
|
-
|
|
21398
|
+
configProfile: import_zod28.z.strictObject({ name: import_zod28.z.string().nullable(), source: import_zod28.z.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
|
|
21399
|
+
layers: import_zod28.z.readonly(import_zod28.z.array(CheckLayerViewSchema)),
|
|
21400
|
+
entries: import_zod28.z.readonly(import_zod28.z.array(CheckEntryViewSchema)),
|
|
21401
|
+
projectEncodingAmbiguities: import_zod28.z.readonly(
|
|
21402
|
+
import_zod28.z.array(import_zod28.z.strictObject({ fragment: import_zod28.z.string(), encoded: import_zod28.z.string(), reason: import_zod28.z.enum(ENCODING_AMBIGUITY_REASONS), detail: import_zod28.z.string() }))
|
|
21027
21403
|
),
|
|
21028
|
-
diagnostics:
|
|
21404
|
+
diagnostics: import_zod28.z.readonly(import_zod28.z.array(CheckDiagnosticSchema)),
|
|
21029
21405
|
ambientCredential: CheckAmbientCredentialSchema,
|
|
21030
21406
|
keychain: CheckKeychainSchema.optional(),
|
|
21031
|
-
settingsExposure:
|
|
21407
|
+
settingsExposure: import_zod28.z.readonly(import_zod28.z.array(CheckSettingsExposureSchema)),
|
|
21032
21408
|
credential: CheckCredentialSchema,
|
|
21033
21409
|
claudeVersion: CheckClaudeVersionSchema.optional(),
|
|
21034
21410
|
providerReachability: CheckProviderReachabilitySchema.optional()
|
|
@@ -21040,28 +21416,28 @@ init_preflight();
|
|
|
21040
21416
|
init_resets();
|
|
21041
21417
|
|
|
21042
21418
|
// src/usage/resetsSchema.ts
|
|
21043
|
-
var
|
|
21044
|
-
var ResetRowSchema =
|
|
21045
|
-
identity:
|
|
21046
|
-
provider:
|
|
21419
|
+
var import_zod29 = require("zod");
|
|
21420
|
+
var ResetRowSchema = import_zod29.z.strictObject({
|
|
21421
|
+
identity: import_zod29.z.string(),
|
|
21422
|
+
provider: import_zod29.z.string(),
|
|
21047
21423
|
/** What the window is: `5h`, `7d` or `extra usage` for an Anthropic account, or the provider's own measure and period (`tokens 5h`). */
|
|
21048
|
-
window:
|
|
21424
|
+
window: import_zod29.z.string(),
|
|
21049
21425
|
/** When the state the window comes from was observed, as an ISO instant. */
|
|
21050
|
-
observedAt:
|
|
21426
|
+
observedAt: import_zod29.z.iso.datetime(),
|
|
21051
21427
|
/** When the window resets, as an ISO instant; absent when the upstream reported none. */
|
|
21052
|
-
resetsAt:
|
|
21428
|
+
resetsAt: import_zod29.z.iso.datetime().optional(),
|
|
21053
21429
|
/** True when the reset time has passed, so the recorded observation describes a window that no longer exists and its utilisation reads as 0. */
|
|
21054
|
-
reset:
|
|
21430
|
+
reset: import_zod29.z.boolean(),
|
|
21055
21431
|
/** The fraction used, as `effectiveWindow` reads it at the report's own clock. */
|
|
21056
|
-
utilization:
|
|
21432
|
+
utilization: import_zod29.z.number().optional(),
|
|
21057
21433
|
/** The window's own status, for a window that has not reset yet. */
|
|
21058
|
-
status:
|
|
21434
|
+
status: import_zod29.z.string().optional()
|
|
21059
21435
|
});
|
|
21060
|
-
var ResetScheduleSchema =
|
|
21436
|
+
var ResetScheduleSchema = import_zod29.z.strictObject({ resets: import_zod29.z.readonly(import_zod29.z.array(ResetRowSchema)) });
|
|
21061
21437
|
|
|
21062
21438
|
// src/frontdoor/controlSchemas.ts
|
|
21063
|
-
var
|
|
21064
|
-
var
|
|
21439
|
+
var import_node_path45 = __toESM(require("node:path"), 1);
|
|
21440
|
+
var import_zod39 = require("zod");
|
|
21065
21441
|
|
|
21066
21442
|
// src/codex/doctor.ts
|
|
21067
21443
|
function codexIdentityFindings(entry, identity) {
|
|
@@ -21080,14 +21456,14 @@ init_identityStore();
|
|
|
21080
21456
|
init_identityRecords();
|
|
21081
21457
|
|
|
21082
21458
|
// src/doctorIdentityRecords.ts
|
|
21083
|
-
var
|
|
21459
|
+
var import_node_path35 = __toESM(require("node:path"), 1);
|
|
21084
21460
|
init_identityRecords();
|
|
21085
21461
|
function identityRecordFindings(records, displaced, nameRenames, strayNameRenameFiles) {
|
|
21086
21462
|
return [
|
|
21087
21463
|
...strayNameRenameFiles.map((file) => ({
|
|
21088
21464
|
severity: "warn",
|
|
21089
21465
|
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.`,
|
|
21090
|
-
subject:
|
|
21466
|
+
subject: import_node_path35.default.basename(file)
|
|
21091
21467
|
})),
|
|
21092
21468
|
...nameRenames.map(({ from, description }) => ({ severity: "fail", message: description, subject: from })),
|
|
21093
21469
|
...duplicateIdentityNames(records).map(({ name, ids }) => ({
|
|
@@ -21110,7 +21486,7 @@ var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
|
21110
21486
|
|
|
21111
21487
|
// src/doctorPath.ts
|
|
21112
21488
|
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
21113
|
-
var
|
|
21489
|
+
var import_node_path36 = __toESM(require("node:path"), 1);
|
|
21114
21490
|
init_blockingSpawn();
|
|
21115
21491
|
init_realPorts();
|
|
21116
21492
|
init_doorBounds();
|
|
@@ -21124,14 +21500,14 @@ function realpathOrSelf(target) {
|
|
|
21124
21500
|
var MAX_FORWARDING_SCRIPT_BYTES = 8192;
|
|
21125
21501
|
function resolveMiseDispatcher(target, pathDirs, env, trustedExecutable) {
|
|
21126
21502
|
const executable = realpathOrSelf(target);
|
|
21127
|
-
const trustedMise =
|
|
21128
|
-
if (
|
|
21129
|
-
const result = spawnSyncBlocking("a mise shim lookup", executable, ["which",
|
|
21503
|
+
const trustedMise = import_node_path36.default.join(import_node_path36.default.dirname(trustedExecutable), "mise");
|
|
21504
|
+
if (import_node_path36.default.basename(executable) !== "mise" || realpathOrSelf(trustedMise) !== executable) return void 0;
|
|
21505
|
+
const result = spawnSyncBlocking("a mise shim lookup", executable, ["which", import_node_path36.default.basename(target)], { encoding: "utf8", env, timeout: BLOCKING_STEP_TIMEOUTS_MS.miseLookup });
|
|
21130
21506
|
if (result.error !== void 0) return void 0;
|
|
21131
21507
|
if (result.status === 0 && result.stdout.trim() !== "") return result.stdout.trim();
|
|
21132
21508
|
if (!result.stderr.includes("not currently active")) return void 0;
|
|
21133
21509
|
for (const dir of pathDirs) {
|
|
21134
|
-
const candidate = findExecutableInDir(dir,
|
|
21510
|
+
const candidate = findExecutableInDir(dir, import_node_path36.default.basename(target));
|
|
21135
21511
|
if (candidate !== void 0 && realpathOrSelf(candidate) !== executable) {
|
|
21136
21512
|
try {
|
|
21137
21513
|
const script = import_node_fs10.default.statSync(candidate).size <= MAX_FORWARDING_SCRIPT_BYTES ? realFsPort.readFileUtf8(candidate) : void 0;
|
|
@@ -21146,7 +21522,7 @@ function resolveMiseDispatcher(target, pathDirs, env, trustedExecutable) {
|
|
|
21146
21522
|
}
|
|
21147
21523
|
|
|
21148
21524
|
// src/doctorReport.ts
|
|
21149
|
-
var
|
|
21525
|
+
var import_node_path44 = __toESM(require("node:path"), 1);
|
|
21150
21526
|
init_signIn();
|
|
21151
21527
|
init_identityAccounts();
|
|
21152
21528
|
init_read();
|
|
@@ -21211,11 +21587,11 @@ var CODEX_CATEGORIES = {
|
|
|
21211
21587
|
};
|
|
21212
21588
|
|
|
21213
21589
|
// src/codex/identity.ts
|
|
21214
|
-
var
|
|
21590
|
+
var import_node_path37 = __toESM(require("node:path"), 1);
|
|
21215
21591
|
init_envBool();
|
|
21216
21592
|
var CODEX_AMBIENT_CREDENTIALS = ["OPENAI_API_KEY", "CODEX_API_KEY", "CODEX_ACCESS_TOKEN", "OPENAI_IDENTITY_TOKEN_FILE", "OPENAI_FEDERATION_RULE_ID"];
|
|
21217
21593
|
function canonicalCodexHome(env, home) {
|
|
21218
|
-
return
|
|
21594
|
+
return import_node_path37.default.resolve(env.AGENT_SHIM_CODEX_HOME === void 0 || env.AGENT_SHIM_CODEX_HOME === "" ? import_node_path37.default.join(home, ".codex") : env.AGENT_SHIM_CODEX_HOME);
|
|
21219
21595
|
}
|
|
21220
21596
|
function codexCredentialGuard(env, allowAmbientCredential) {
|
|
21221
21597
|
const variable = CODEX_AMBIENT_CREDENTIALS.find((key) => (env[key] ?? "") !== "");
|
|
@@ -21351,8 +21727,8 @@ init_realCredentialCache();
|
|
|
21351
21727
|
init_providersStore();
|
|
21352
21728
|
init_signIn();
|
|
21353
21729
|
init_realPorts();
|
|
21354
|
-
var
|
|
21355
|
-
var
|
|
21730
|
+
var import_node_path41 = __toESM(require("node:path"), 1);
|
|
21731
|
+
var import_zod32 = require("zod");
|
|
21356
21732
|
init_envBool();
|
|
21357
21733
|
init_load();
|
|
21358
21734
|
init_schema();
|
|
@@ -21436,9 +21812,9 @@ function lookupKeychainService(run, farmRoot) {
|
|
|
21436
21812
|
}
|
|
21437
21813
|
return { checked: true, found: true, serviceName, note: `Keychain service name for this identity: "${serviceName}".` };
|
|
21438
21814
|
}
|
|
21439
|
-
var SettingsSecretsShapeSchema =
|
|
21440
|
-
env:
|
|
21441
|
-
hooks:
|
|
21815
|
+
var SettingsSecretsShapeSchema = import_zod32.z.looseObject({
|
|
21816
|
+
env: import_zod32.z.record(import_zod32.z.string(), import_zod32.z.unknown()).optional(),
|
|
21817
|
+
hooks: import_zod32.z.record(import_zod32.z.string(), import_zod32.z.array(import_zod32.z.unknown())).optional()
|
|
21442
21818
|
});
|
|
21443
21819
|
function hookCommandCountOf(group) {
|
|
21444
21820
|
if (typeof group !== "object" || group === null) {
|
|
@@ -21718,10 +22094,10 @@ function collectCheckReport(params) {
|
|
|
21718
22094
|
const providerName = cascadeProviderName(cascade, identityConfig?.provider);
|
|
21719
22095
|
const provider = providerName === void 0 ? void 0 : loadCheckProvider(paths, providerName);
|
|
21720
22096
|
const identityId = identityDecision.name === void 0 ? void 0 : identityIdOf(paths, identityDecision.name);
|
|
21721
|
-
const farmRoot = identityId === void 0 ? void 0 :
|
|
22097
|
+
const farmRoot = identityId === void 0 ? void 0 : import_node_path41.default.join(paths.identitiesDir, identityId);
|
|
21722
22098
|
const settingsFiles = isCodex ? {} : {
|
|
21723
|
-
"settings.json": realFsPort.readFileUtf8(
|
|
21724
|
-
"settings.local.json": realFsPort.readFileUtf8(
|
|
22099
|
+
"settings.json": realFsPort.readFileUtf8(import_node_path41.default.join(claudeHome, "settings.json")),
|
|
22100
|
+
"settings.local.json": realFsPort.readFileUtf8(import_node_path41.default.join(claudeHome, "settings.local.json"))
|
|
21725
22101
|
};
|
|
21726
22102
|
const report = runCheck({
|
|
21727
22103
|
...isCodex ? { agent: "codex" } : {},
|
|
@@ -22248,7 +22624,7 @@ function tcpPortEraRecord(raw) {
|
|
|
22248
22624
|
return (has("port") || has("lastPort")) && !has("socketPath");
|
|
22249
22625
|
}
|
|
22250
22626
|
function pushPathResolution(push, resolution) {
|
|
22251
|
-
const ownDir =
|
|
22627
|
+
const ownDir = import_node_path44.default.dirname(resolution.ownExecutablePath);
|
|
22252
22628
|
switch (resolution.agentShim.status) {
|
|
22253
22629
|
case "ok":
|
|
22254
22630
|
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
@@ -22368,14 +22744,14 @@ function pushProvider(push, entry, cacheEnv, signIn, unreachable) {
|
|
|
22368
22744
|
}
|
|
22369
22745
|
function pushLegacyName(push, params) {
|
|
22370
22746
|
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
22371
|
-
if (legacyVariables.length === 0 &&
|
|
22747
|
+
if (legacyVariables.length === 0 && import_node_path44.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
22372
22748
|
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
22373
22749
|
return;
|
|
22374
22750
|
}
|
|
22375
22751
|
for (const name of legacyVariables) {
|
|
22376
22752
|
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);
|
|
22377
22753
|
}
|
|
22378
|
-
if (
|
|
22754
|
+
if (import_node_path44.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
22379
22755
|
push(
|
|
22380
22756
|
"legacy-name",
|
|
22381
22757
|
"warn",
|
|
@@ -22465,7 +22841,7 @@ function runDoctor(params) {
|
|
|
22465
22841
|
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);
|
|
22466
22842
|
}
|
|
22467
22843
|
for (const { file, detail } of params.renameJournals?.unreadable ?? []) {
|
|
22468
|
-
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.`,
|
|
22844
|
+
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.`, import_node_path44.default.basename(file));
|
|
22469
22845
|
}
|
|
22470
22846
|
const validIdentityAgents = /* @__PURE__ */ new Map();
|
|
22471
22847
|
const signedInAccounts = [];
|
|
@@ -22763,9 +23139,9 @@ function collectDoctorReport(params) {
|
|
|
22763
23139
|
const { names: identityNames, unreachable: unreachableIdentities } = listIdentityDirectories(paths);
|
|
22764
23140
|
const records = identityRecords(paths);
|
|
22765
23141
|
const displacedIdentities = records.filter((record) => !identityIdExists(paths, record.id) && !unreachableIdentities.some((entry) => entry.name === record.id));
|
|
22766
|
-
const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !import_node_fs14.default.existsSync(
|
|
22767
|
-
const farmRoot =
|
|
22768
|
-
const identityPath =
|
|
23142
|
+
const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !import_node_fs14.default.existsSync(import_node_path44.default.join(paths.identitiesDir, id, "identity.json"))) && !displacedIdentities.some((record) => record.id === id)).map((id) => {
|
|
23143
|
+
const farmRoot = import_node_path44.default.join(paths.identitiesDir, id);
|
|
23144
|
+
const identityPath = import_node_path44.default.join(farmRoot, "identity.json");
|
|
22769
23145
|
return { name: identityNameIn(records, id) ?? id, id, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: import_node_fs14.default.existsSync(credentialsFilePath(farmRoot)), account: readIdentityAccount(realFsPort, paths.identitiesDir, id)?.account };
|
|
22770
23146
|
});
|
|
22771
23147
|
const usageSnapshots = {};
|
|
@@ -22783,12 +23159,12 @@ function collectDoctorReport(params) {
|
|
|
22783
23159
|
}
|
|
22784
23160
|
const profileNames = import_node_fs14.default.existsSync(paths.configProfilesDir) ? import_node_fs14.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
22785
23161
|
const configProfiles = profileNames.map((name) => {
|
|
22786
|
-
const profilePath =
|
|
23162
|
+
const profilePath = import_node_path44.default.join(paths.configProfilesDir, `${name}.json`);
|
|
22787
23163
|
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
22788
23164
|
});
|
|
22789
23165
|
const providerNames = import_node_fs14.default.existsSync(paths.providersDir) ? import_node_fs14.default.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
22790
23166
|
const providers = providerNames.map((name) => {
|
|
22791
|
-
const providerPath =
|
|
23167
|
+
const providerPath = import_node_path44.default.join(paths.providersDir, `${name}.json`);
|
|
22792
23168
|
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
22793
23169
|
});
|
|
22794
23170
|
const ownExecutablePath = realOwnExecutablePath();
|
|
@@ -22800,12 +23176,12 @@ function collectDoctorReport(params) {
|
|
|
22800
23176
|
binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
|
|
22801
23177
|
}
|
|
22802
23178
|
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
22803
|
-
const pathDirs = (params.env.PATH ?? "").split(
|
|
23179
|
+
const pathDirs = (params.env.PATH ?? "").split(import_node_path44.default.delimiter).filter((dir) => dir !== "");
|
|
22804
23180
|
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
22805
23181
|
findPathShadow({
|
|
22806
23182
|
pathDirs,
|
|
22807
|
-
targetDir:
|
|
22808
|
-
targetFilename:
|
|
23183
|
+
targetDir: import_node_path44.default.dirname(shimState.targetPath),
|
|
23184
|
+
targetFilename: import_node_path44.default.basename(shimState.targetPath),
|
|
22809
23185
|
findExecutableInDir
|
|
22810
23186
|
}),
|
|
22811
23187
|
shimState.targetPath,
|
|
@@ -22834,7 +23210,7 @@ function collectDoctorReport(params) {
|
|
|
22834
23210
|
catalogueRedirects: providersWithRedirectedCatalogue(realFarmFs, paths, new Map(providers.map((entry) => [entry.name, currentCatalogueSettings(paths, entry.name)]))),
|
|
22835
23211
|
renameJournals: listRenameJournals(realFarmFs, paths.identityRenamesDir),
|
|
22836
23212
|
unreachableIdentities,
|
|
22837
|
-
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: import_node_fs14.default.existsSync(
|
|
23213
|
+
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: import_node_fs14.default.existsSync(import_node_path44.default.join(paths.identitiesDir, record.id)) })), nameRenames: unfinishedNameRenames(paths).map((record) => ({ from: record.from, description: describeInterruptedNameRename(paths, record) })), strayNameRenameFiles: strayNameRenameRecordFiles(paths) },
|
|
22838
23214
|
directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
|
|
22839
23215
|
globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
|
|
22840
23216
|
models: readableOr(() => readGlobalConfig(paths)?.models, void 0),
|
|
@@ -22849,7 +23225,7 @@ function collectDoctorReport(params) {
|
|
|
22849
23225
|
agentShim: refinePathShadow(
|
|
22850
23226
|
findPathShadow({
|
|
22851
23227
|
pathDirs,
|
|
22852
|
-
targetDir:
|
|
23228
|
+
targetDir: import_node_path44.default.dirname(ownExecutablePath),
|
|
22853
23229
|
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
22854
23230
|
findExecutableInDir
|
|
22855
23231
|
}),
|
|
@@ -22892,93 +23268,93 @@ function collectDoctorReport(params) {
|
|
|
22892
23268
|
init_schema2();
|
|
22893
23269
|
init_rcSchemas();
|
|
22894
23270
|
init_state();
|
|
22895
|
-
var UsageListOutputSchema =
|
|
22896
|
-
var UsageWindowsInputSchema =
|
|
22897
|
-
identity:
|
|
22898
|
-
provider:
|
|
23271
|
+
var UsageListOutputSchema = import_zod39.z.strictObject({ snapshots: import_zod39.z.readonly(import_zod39.z.array(UsageSnapshotSchema)) });
|
|
23272
|
+
var UsageWindowsInputSchema = import_zod39.z.strictObject({
|
|
23273
|
+
identity: import_zod39.z.string().min(1),
|
|
23274
|
+
provider: import_zod39.z.string().min(1).optional()
|
|
22899
23275
|
});
|
|
22900
|
-
var EffectiveWindowSchema =
|
|
23276
|
+
var EffectiveWindowSchema = import_zod39.z.strictObject({
|
|
22901
23277
|
/** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
|
|
22902
|
-
reset:
|
|
23278
|
+
reset: import_zod39.z.boolean(),
|
|
22903
23279
|
/** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
|
|
22904
|
-
utilization:
|
|
23280
|
+
utilization: import_zod39.z.number().optional(),
|
|
22905
23281
|
/** The reset instant, for a window that has not reset yet and reported one. */
|
|
22906
|
-
resetsAtMs:
|
|
23282
|
+
resetsAtMs: import_zod39.z.number().optional(),
|
|
22907
23283
|
/** The window's own status, for a window that has not reset yet. */
|
|
22908
|
-
status:
|
|
23284
|
+
status: import_zod39.z.string().optional()
|
|
22909
23285
|
});
|
|
22910
|
-
var UsageWindowsOutputSchema =
|
|
22911
|
-
identity:
|
|
22912
|
-
provider:
|
|
23286
|
+
var UsageWindowsOutputSchema = import_zod39.z.strictObject({
|
|
23287
|
+
identity: import_zod39.z.string(),
|
|
23288
|
+
provider: import_zod39.z.string(),
|
|
22913
23289
|
/** When the rate-limit state the windows come from was observed. */
|
|
22914
|
-
observedAt:
|
|
23290
|
+
observedAt: import_zod39.z.iso.datetime().optional(),
|
|
22915
23291
|
fiveHour: EffectiveWindowSchema.optional(),
|
|
22916
23292
|
sevenDay: EffectiveWindowSchema.optional()
|
|
22917
23293
|
});
|
|
22918
|
-
var UsageLiveOutputSchema =
|
|
23294
|
+
var UsageLiveOutputSchema = import_zod39.z.strictObject({
|
|
22919
23295
|
/** 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. */
|
|
22920
23296
|
latest: RcLiveRateLimitSchema.optional(),
|
|
22921
23297
|
/** One observation per session whose stream has filed a rate_limit_event this door generation. */
|
|
22922
|
-
sessions:
|
|
23298
|
+
sessions: import_zod39.z.readonly(import_zod39.z.array(RcLiveRateLimitSchema))
|
|
22923
23299
|
});
|
|
22924
|
-
var FrontDoorSessionStatusSchema =
|
|
22925
|
-
pid:
|
|
22926
|
-
startedAt:
|
|
22927
|
-
alive:
|
|
23300
|
+
var FrontDoorSessionStatusSchema = import_zod39.z.strictObject({
|
|
23301
|
+
pid: import_zod39.z.int().positive(),
|
|
23302
|
+
startedAt: import_zod39.z.number(),
|
|
23303
|
+
alive: import_zod39.z.boolean()
|
|
22928
23304
|
});
|
|
22929
|
-
var HeadroomSocketTargetSchema =
|
|
22930
|
-
var FrontDoorStatusOutputSchema =
|
|
23305
|
+
var HeadroomSocketTargetSchema = import_zod39.z.union([import_zod39.z.strictObject({ socketPath: import_zod39.z.string() }), import_zod39.z.strictObject({ refused: import_zod39.z.string() })]);
|
|
23306
|
+
var FrontDoorStatusOutputSchema = import_zod39.z.strictObject({
|
|
22931
23307
|
state: FrontDoorStateSchema,
|
|
22932
|
-
supervisorAlive:
|
|
23308
|
+
supervisorAlive: import_zod39.z.boolean(),
|
|
22933
23309
|
/** The pids of earlier doors that released their addresses and are finishing the connections they carried: running, but not serving anything new. */
|
|
22934
|
-
draining:
|
|
22935
|
-
sessions:
|
|
23310
|
+
draining: import_zod39.z.readonly(import_zod39.z.array(import_zod39.z.number().int().positive())),
|
|
23311
|
+
sessions: import_zod39.z.readonly(import_zod39.z.array(FrontDoorSessionStatusSchema)),
|
|
22936
23312
|
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
22937
|
-
logPath:
|
|
22938
|
-
logExists:
|
|
23313
|
+
logPath: import_zod39.z.string(),
|
|
23314
|
+
logExists: import_zod39.z.boolean()
|
|
22939
23315
|
});
|
|
22940
|
-
var FrontDoorSessionsOutputSchema =
|
|
23316
|
+
var FrontDoorSessionsOutputSchema = import_zod39.z.strictObject({ sessions: import_zod39.z.readonly(import_zod39.z.array(FrontDoorSessionStatusSchema)) });
|
|
22941
23317
|
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.";
|
|
22942
|
-
var CheckRunInputSchema =
|
|
22943
|
-
path:
|
|
22944
|
-
identity:
|
|
22945
|
-
}).refine((input) =>
|
|
22946
|
-
var PoolPickInputSchema =
|
|
22947
|
-
pool:
|
|
22948
|
-
path:
|
|
22949
|
-
}).refine((input) =>
|
|
22950
|
-
var DoctorFindingSchema =
|
|
22951
|
-
section:
|
|
22952
|
-
subject:
|
|
22953
|
-
severity:
|
|
22954
|
-
message:
|
|
22955
|
-
});
|
|
22956
|
-
var DoctorRunOutputSchema =
|
|
23318
|
+
var CheckRunInputSchema = import_zod39.z.strictObject({
|
|
23319
|
+
path: import_zod39.z.string().min(1),
|
|
23320
|
+
identity: import_zod39.z.string().min(1).optional()
|
|
23321
|
+
}).refine((input) => import_node_path45.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
23322
|
+
var PoolPickInputSchema = import_zod39.z.strictObject({
|
|
23323
|
+
pool: import_zod39.z.string().min(1),
|
|
23324
|
+
path: import_zod39.z.string().min(1)
|
|
23325
|
+
}).refine((input) => import_node_path45.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
23326
|
+
var DoctorFindingSchema = import_zod39.z.strictObject({
|
|
23327
|
+
section: import_zod39.z.enum(DOCTOR_SECTIONS),
|
|
23328
|
+
subject: import_zod39.z.string().optional(),
|
|
23329
|
+
severity: import_zod39.z.enum(DOCTOR_SEVERITIES),
|
|
23330
|
+
message: import_zod39.z.string()
|
|
23331
|
+
});
|
|
23332
|
+
var DoctorRunOutputSchema = import_zod39.z.strictObject({
|
|
22957
23333
|
/** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
|
|
22958
|
-
ok:
|
|
22959
|
-
findings:
|
|
22960
|
-
});
|
|
22961
|
-
var FrontDoorRestartOutputSchema =
|
|
22962
|
-
action:
|
|
22963
|
-
previousPid:
|
|
22964
|
-
});
|
|
22965
|
-
var UpdateCheckOutputSchema =
|
|
22966
|
-
current:
|
|
22967
|
-
latest:
|
|
22968
|
-
action:
|
|
22969
|
-
});
|
|
22970
|
-
var CodexSignInSchema =
|
|
22971
|
-
|
|
22972
|
-
|
|
22973
|
-
|
|
23334
|
+
ok: import_zod39.z.boolean(),
|
|
23335
|
+
findings: import_zod39.z.readonly(import_zod39.z.array(DoctorFindingSchema))
|
|
23336
|
+
});
|
|
23337
|
+
var FrontDoorRestartOutputSchema = import_zod39.z.strictObject({
|
|
23338
|
+
action: import_zod39.z.literal("restarting"),
|
|
23339
|
+
previousPid: import_zod39.z.int().positive()
|
|
23340
|
+
});
|
|
23341
|
+
var UpdateCheckOutputSchema = import_zod39.z.strictObject({
|
|
23342
|
+
current: import_zod39.z.string(),
|
|
23343
|
+
latest: import_zod39.z.string(),
|
|
23344
|
+
action: import_zod39.z.enum(["current", "available", "updated"])
|
|
23345
|
+
});
|
|
23346
|
+
var CodexSignInSchema = import_zod39.z.discriminatedUnion("state", [
|
|
23347
|
+
import_zod39.z.strictObject({ state: import_zod39.z.literal("none") }),
|
|
23348
|
+
import_zod39.z.strictObject({ state: import_zod39.z.literal("signed-in"), email: import_zod39.z.string().optional(), planScope: import_zod39.z.boolean(), accessTokenExpiresAt: import_zod39.z.number() }),
|
|
23349
|
+
import_zod39.z.strictObject({ state: import_zod39.z.literal("unreadable"), message: import_zod39.z.string() })
|
|
22974
23350
|
]);
|
|
22975
|
-
var CodexStatusOutputSchema =
|
|
23351
|
+
var CodexStatusOutputSchema = import_zod39.z.strictObject({
|
|
22976
23352
|
signIn: CodexSignInSchema,
|
|
22977
|
-
codexProviders:
|
|
23353
|
+
codexProviders: import_zod39.z.readonly(import_zod39.z.array(import_zod39.z.string()))
|
|
22978
23354
|
});
|
|
22979
|
-
var CodexLogoutOutputSchema =
|
|
22980
|
-
hadGrant:
|
|
22981
|
-
revoked:
|
|
23355
|
+
var CodexLogoutOutputSchema = import_zod39.z.strictObject({
|
|
23356
|
+
hadGrant: import_zod39.z.boolean(),
|
|
23357
|
+
revoked: import_zod39.z.boolean()
|
|
22982
23358
|
});
|
|
22983
23359
|
|
|
22984
23360
|
// src/frontdoor/codexApi.ts
|
|
@@ -22999,21 +23375,21 @@ function createCodexApiRouter(deps) {
|
|
|
22999
23375
|
|
|
23000
23376
|
// src/frontdoor/doorWorker.ts
|
|
23001
23377
|
var import_node_sea2 = require("node:sea");
|
|
23002
|
-
var
|
|
23378
|
+
var import_zod41 = require("zod");
|
|
23003
23379
|
init_cliError();
|
|
23004
23380
|
init_doorBounds();
|
|
23005
23381
|
init_providerCatalogue();
|
|
23006
23382
|
|
|
23007
23383
|
// src/frontdoor/doorWorkerProtocol.ts
|
|
23008
|
-
var
|
|
23384
|
+
var import_zod40 = require("zod");
|
|
23009
23385
|
init_providerCatalogue();
|
|
23010
23386
|
var doorWorkerInputSchemas = {
|
|
23011
23387
|
/** `agent-shim check` for `path` as `identity` (the identity a launch there would resolve when absent). */
|
|
23012
|
-
check:
|
|
23388
|
+
check: import_zod40.z.strictObject({ root: import_zod40.z.string().min(1), path: import_zod40.z.string().min(1), identity: import_zod40.z.string().min(1).optional() }),
|
|
23013
23389
|
/** `agent-shim doctor`. */
|
|
23014
|
-
doctor:
|
|
23390
|
+
doctor: import_zod40.z.strictObject({ root: import_zod40.z.string().min(1) }),
|
|
23015
23391
|
/** Fetch and store one provider's model catalogue for the door generation that asked. */
|
|
23016
|
-
"refresh-catalogue":
|
|
23392
|
+
"refresh-catalogue": import_zod40.z.strictObject({ root: import_zod40.z.string().min(1), name: import_zod40.z.string().min(1), supervisorPid: import_zod40.z.int().positive(), generation: import_zod40.z.uuid() })
|
|
23017
23393
|
};
|
|
23018
23394
|
|
|
23019
23395
|
// src/frontdoor/doorWorker.ts
|
|
@@ -23103,72 +23479,72 @@ init_baseUrlDisplay();
|
|
|
23103
23479
|
init_providersStore();
|
|
23104
23480
|
|
|
23105
23481
|
// src/frontdoor/configSchemas.ts
|
|
23106
|
-
var
|
|
23482
|
+
var import_zod42 = require("zod");
|
|
23107
23483
|
init_schema();
|
|
23108
23484
|
init_names();
|
|
23109
23485
|
init_keychainLogin();
|
|
23110
23486
|
init_statusline();
|
|
23111
|
-
var RemovalConfirmationSchema =
|
|
23112
|
-
var CredentialWriteSchema = (targets) =>
|
|
23113
|
-
sources:
|
|
23114
|
-
target:
|
|
23115
|
-
cache:
|
|
23116
|
-
});
|
|
23117
|
-
var CredentialSummarySchema2 =
|
|
23118
|
-
target:
|
|
23119
|
-
sources:
|
|
23120
|
-
|
|
23121
|
-
|
|
23122
|
-
|
|
23123
|
-
|
|
23124
|
-
|
|
23125
|
-
|
|
23126
|
-
|
|
23487
|
+
var RemovalConfirmationSchema = import_zod42.z.boolean();
|
|
23488
|
+
var CredentialWriteSchema = (targets) => import_zod42.z.strictObject({
|
|
23489
|
+
sources: import_zod42.z.array(RemoteCredentialSourceSchema).min(1).optional(),
|
|
23490
|
+
target: import_zod42.z.enum(targets).optional(),
|
|
23491
|
+
cache: import_zod42.z.union([import_zod42.z.literal(false), CredentialCacheSchema]).optional()
|
|
23492
|
+
});
|
|
23493
|
+
var CredentialSummarySchema2 = import_zod42.z.strictObject({
|
|
23494
|
+
target: import_zod42.z.enum(CREDENTIAL_TARGETS),
|
|
23495
|
+
sources: import_zod42.z.readonly(import_zod42.z.array(
|
|
23496
|
+
import_zod42.z.discriminatedUnion("kind", [
|
|
23497
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("env"), variable: import_zod42.z.string() }),
|
|
23498
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("file"), path: import_zod42.z.string() }),
|
|
23499
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("command"), program: import_zod42.z.string() }),
|
|
23500
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("op"), reference: import_zod42.z.string() }),
|
|
23501
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("keychain"), service: import_zod42.z.string(), account: import_zod42.z.string().optional() }),
|
|
23502
|
+
import_zod42.z.strictObject({ kind: import_zod42.z.literal("literal") })
|
|
23127
23503
|
])
|
|
23128
23504
|
)),
|
|
23129
23505
|
cache: CredentialCacheSchema.optional()
|
|
23130
23506
|
});
|
|
23131
|
-
var mutationOutput = (kind, action) =>
|
|
23132
|
-
var storedMutationOutput = (kind, action, value) =>
|
|
23133
|
-
var IdentityValueSchema =
|
|
23134
|
-
agent:
|
|
23135
|
-
name:
|
|
23136
|
-
label:
|
|
23137
|
-
defaultConfigProfile:
|
|
23138
|
-
provider:
|
|
23139
|
-
allowAmbientCredential:
|
|
23507
|
+
var mutationOutput = (kind, action) => import_zod42.z.strictObject({ action: import_zod42.z.literal(action), kind: import_zod42.z.literal(kind), name: import_zod42.z.string() });
|
|
23508
|
+
var storedMutationOutput = (kind, action, value) => import_zod42.z.strictObject({ action: import_zod42.z.literal(action), kind: import_zod42.z.literal(kind), name: import_zod42.z.string(), value });
|
|
23509
|
+
var IdentityValueSchema = import_zod42.z.strictObject({
|
|
23510
|
+
agent: import_zod42.z.enum(["claude", "codex"]).optional(),
|
|
23511
|
+
name: import_zod42.z.string(),
|
|
23512
|
+
label: import_zod42.z.string().optional(),
|
|
23513
|
+
defaultConfigProfile: import_zod42.z.string().optional(),
|
|
23514
|
+
provider: import_zod42.z.string().optional(),
|
|
23515
|
+
allowAmbientCredential: import_zod42.z.boolean(),
|
|
23140
23516
|
credential: CredentialSummarySchema2.optional(),
|
|
23141
|
-
anchors:
|
|
23517
|
+
anchors: import_zod42.z.array(AnchorSchema).optional()
|
|
23142
23518
|
});
|
|
23143
23519
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
23144
|
-
var ProviderValueSchema =
|
|
23145
|
-
name:
|
|
23146
|
-
kind:
|
|
23147
|
-
displayName:
|
|
23148
|
-
baseUrl:
|
|
23520
|
+
var ProviderValueSchema = import_zod42.z.strictObject({
|
|
23521
|
+
name: import_zod42.z.string(),
|
|
23522
|
+
kind: import_zod42.z.enum(PROVIDER_KINDS),
|
|
23523
|
+
displayName: import_zod42.z.string(),
|
|
23524
|
+
baseUrl: import_zod42.z.string().optional(),
|
|
23149
23525
|
codex: CodexProviderConfigSchema.optional(),
|
|
23150
23526
|
credential: CredentialSummarySchema2.optional(),
|
|
23151
|
-
env:
|
|
23527
|
+
env: import_zod42.z.record(import_zod42.z.string(), import_zod42.z.string()).optional()
|
|
23152
23528
|
});
|
|
23153
|
-
var ConfigNameInputSchema =
|
|
23154
|
-
var ConfigIdentityAddInputSchema =
|
|
23529
|
+
var ConfigNameInputSchema = import_zod42.z.strictObject({ name: import_zod42.z.string().min(1) });
|
|
23530
|
+
var ConfigIdentityAddInputSchema = import_zod42.z.strictObject({ name: import_zod42.z.string().min(1), keepKeychainLogin: import_zod42.z.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
|
|
23155
23531
|
var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
|
|
23156
|
-
var ConfigIdentitySetInputSchema =
|
|
23157
|
-
name:
|
|
23532
|
+
var ConfigIdentitySetInputSchema = import_zod42.z.strictObject({
|
|
23533
|
+
name: import_zod42.z.string().min(1),
|
|
23158
23534
|
/** The identity's display label; `false` clears it. */
|
|
23159
|
-
label:
|
|
23160
|
-
defaultConfigProfile:
|
|
23535
|
+
label: import_zod42.z.union([IdentityLabelSchema, import_zod42.z.literal(false)]).optional(),
|
|
23536
|
+
defaultConfigProfile: import_zod42.z.union([import_zod42.z.string().min(1), import_zod42.z.literal(false)]).optional(),
|
|
23161
23537
|
/** The provider the identity exists for; `false` clears it. */
|
|
23162
|
-
provider:
|
|
23163
|
-
allowAmbientCredential:
|
|
23164
|
-
credential:
|
|
23538
|
+
provider: import_zod42.z.union([import_zod42.z.string().min(1), import_zod42.z.literal(false)]).optional(),
|
|
23539
|
+
allowAmbientCredential: import_zod42.z.boolean().optional(),
|
|
23540
|
+
credential: import_zod42.z.union([import_zod42.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
|
|
23165
23541
|
/** `false` removes the anchors; a list replaces them. */
|
|
23166
|
-
anchors:
|
|
23542
|
+
anchors: import_zod42.z.union([import_zod42.z.literal(false), import_zod42.z.array(AnchorSchema).min(1)]).optional()
|
|
23167
23543
|
});
|
|
23168
23544
|
var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
|
|
23169
|
-
var ConfigIdentityRemoveInputSchema =
|
|
23545
|
+
var ConfigIdentityRemoveInputSchema = import_zod42.z.strictObject({ name: import_zod42.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
23170
23546
|
var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
|
|
23171
|
-
var ConfigStatuslineSetSchema =
|
|
23547
|
+
var ConfigStatuslineSetSchema = import_zod42.z.record(import_zod42.z.string(), import_zod42.z.unknown()).superRefine((settings, context) => {
|
|
23172
23548
|
for (const key of Object.keys(settings)) {
|
|
23173
23549
|
if (key === STATUSLINE_EXTRA_GROUP || key.startsWith(`${STATUSLINE_EXTRA_GROUP}.`)) {
|
|
23174
23550
|
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` });
|
|
@@ -23176,93 +23552,93 @@ var ConfigStatuslineSetSchema = import_zod41.z.record(import_zod41.z.string(), i
|
|
|
23176
23552
|
}
|
|
23177
23553
|
});
|
|
23178
23554
|
var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
|
|
23179
|
-
var ConfigProfileAddInputSchema =
|
|
23180
|
-
name:
|
|
23181
|
-
extends:
|
|
23182
|
-
description:
|
|
23555
|
+
var ConfigProfileAddInputSchema = import_zod42.z.strictObject({
|
|
23556
|
+
name: import_zod42.z.string().min(1),
|
|
23557
|
+
extends: import_zod42.z.array(import_zod42.z.string().min(1)).optional(),
|
|
23558
|
+
description: import_zod42.z.string().optional()
|
|
23183
23559
|
});
|
|
23184
23560
|
var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
|
|
23185
|
-
var ConfigProfileSetInputSchema =
|
|
23186
|
-
name:
|
|
23187
|
-
category:
|
|
23188
|
-
entry:
|
|
23189
|
-
extends:
|
|
23190
|
-
description:
|
|
23191
|
-
launch:
|
|
23192
|
-
skipPermissions:
|
|
23193
|
-
remoteControl:
|
|
23194
|
-
headroom:
|
|
23195
|
-
trackUsage:
|
|
23196
|
-
provider:
|
|
23197
|
-
claudeVersion:
|
|
23198
|
-
delay:
|
|
23199
|
-
pause:
|
|
23200
|
-
explain:
|
|
23201
|
-
proxyBypass:
|
|
23202
|
-
statusline:
|
|
23561
|
+
var ConfigProfileSetInputSchema = import_zod42.z.strictObject({
|
|
23562
|
+
name: import_zod42.z.string().min(1),
|
|
23563
|
+
category: import_zod42.z.record(import_zod42.z.string(), import_zod42.z.boolean()).optional(),
|
|
23564
|
+
entry: import_zod42.z.record(import_zod42.z.string(), import_zod42.z.boolean()).optional(),
|
|
23565
|
+
extends: import_zod42.z.union([import_zod42.z.array(import_zod42.z.string().min(1)), import_zod42.z.literal(false)]).optional(),
|
|
23566
|
+
description: import_zod42.z.union([import_zod42.z.string(), import_zod42.z.literal(false)]).optional(),
|
|
23567
|
+
launch: import_zod42.z.strictObject({
|
|
23568
|
+
skipPermissions: import_zod42.z.boolean().optional(),
|
|
23569
|
+
remoteControl: import_zod42.z.boolean().optional(),
|
|
23570
|
+
headroom: import_zod42.z.boolean().optional(),
|
|
23571
|
+
trackUsage: import_zod42.z.boolean().optional(),
|
|
23572
|
+
provider: import_zod42.z.union([import_zod42.z.string().min(1), import_zod42.z.literal(false)]).optional(),
|
|
23573
|
+
claudeVersion: import_zod42.z.union([import_zod42.z.string().min(1), import_zod42.z.literal(false)]).optional(),
|
|
23574
|
+
delay: import_zod42.z.union([import_zod42.z.string().regex(DURATION_RE), import_zod42.z.literal(false)]).optional(),
|
|
23575
|
+
pause: import_zod42.z.boolean().optional(),
|
|
23576
|
+
explain: import_zod42.z.boolean().optional(),
|
|
23577
|
+
proxyBypass: import_zod42.z.union([import_zod42.z.array(import_zod42.z.string().min(1)), import_zod42.z.literal(false)]).optional(),
|
|
23578
|
+
statusline: import_zod42.z.strictObject({
|
|
23203
23579
|
set: ConfigStatuslineSetSchema.optional(),
|
|
23204
|
-
unset:
|
|
23580
|
+
unset: import_zod42.z.array(import_zod42.z.string()).optional()
|
|
23205
23581
|
}).optional()
|
|
23206
23582
|
}).optional()
|
|
23207
23583
|
});
|
|
23208
23584
|
var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
|
|
23209
|
-
var ConfigProfileRemoveInputSchema =
|
|
23585
|
+
var ConfigProfileRemoveInputSchema = import_zod42.z.strictObject({ name: import_zod42.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
23210
23586
|
var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
|
|
23211
23587
|
var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
|
|
23212
|
-
var PoolMembersInputSchema =
|
|
23213
|
-
var ConfigPoolAddInputSchema =
|
|
23214
|
-
name:
|
|
23588
|
+
var PoolMembersInputSchema = import_zod42.z.array(import_zod42.z.string().min(1)).min(1);
|
|
23589
|
+
var ConfigPoolAddInputSchema = import_zod42.z.strictObject({
|
|
23590
|
+
name: import_zod42.z.string().min(1),
|
|
23215
23591
|
identities: PoolMembersInputSchema,
|
|
23216
|
-
preference:
|
|
23217
|
-
resumeOnLimit:
|
|
23218
|
-
compactBeforeLimit:
|
|
23592
|
+
preference: import_zod42.z.enum(POOL_PREFERENCES).optional(),
|
|
23593
|
+
resumeOnLimit: import_zod42.z.boolean().optional(),
|
|
23594
|
+
compactBeforeLimit: import_zod42.z.boolean().optional(),
|
|
23219
23595
|
compactAtUtilisation: CompactAtUtilisationSchema.optional()
|
|
23220
23596
|
});
|
|
23221
23597
|
var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
|
|
23222
|
-
var ConfigPoolSetInputSchema =
|
|
23223
|
-
name:
|
|
23598
|
+
var ConfigPoolSetInputSchema = import_zod42.z.strictObject({
|
|
23599
|
+
name: import_zod42.z.string().min(1),
|
|
23224
23600
|
identities: PoolMembersInputSchema.optional(),
|
|
23225
|
-
preference:
|
|
23226
|
-
resumeOnLimit:
|
|
23227
|
-
compactBeforeLimit:
|
|
23228
|
-
compactAtUtilisation:
|
|
23601
|
+
preference: import_zod42.z.union([import_zod42.z.enum(POOL_PREFERENCES), import_zod42.z.literal(false)]).optional(),
|
|
23602
|
+
resumeOnLimit: import_zod42.z.boolean().optional(),
|
|
23603
|
+
compactBeforeLimit: import_zod42.z.boolean().optional(),
|
|
23604
|
+
compactAtUtilisation: import_zod42.z.union([CompactAtUtilisationSchema, import_zod42.z.literal(false)]).optional()
|
|
23229
23605
|
});
|
|
23230
23606
|
var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
|
|
23231
|
-
var ConfigPoolRemoveInputSchema =
|
|
23607
|
+
var ConfigPoolRemoveInputSchema = import_zod42.z.strictObject({ name: import_zod42.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
23232
23608
|
var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
|
|
23233
23609
|
var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
|
|
23234
|
-
var ConfigProviderAddInputSchema =
|
|
23235
|
-
name:
|
|
23236
|
-
kind:
|
|
23237
|
-
displayName:
|
|
23238
|
-
baseUrl:
|
|
23610
|
+
var ConfigProviderAddInputSchema = import_zod42.z.strictObject({
|
|
23611
|
+
name: import_zod42.z.string().min(1),
|
|
23612
|
+
kind: import_zod42.z.enum(PROVIDER_KINDS).optional(),
|
|
23613
|
+
displayName: import_zod42.z.string().min(1),
|
|
23614
|
+
baseUrl: import_zod42.z.string().min(1).optional(),
|
|
23239
23615
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
|
|
23240
23616
|
codex: CodexProviderConfigSchema.optional()
|
|
23241
23617
|
});
|
|
23242
23618
|
var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
|
|
23243
|
-
var ConfigProviderSetInputSchema =
|
|
23244
|
-
name:
|
|
23245
|
-
displayName:
|
|
23246
|
-
baseUrl:
|
|
23619
|
+
var ConfigProviderSetInputSchema = import_zod42.z.strictObject({
|
|
23620
|
+
name: import_zod42.z.string().min(1),
|
|
23621
|
+
displayName: import_zod42.z.string().min(1).optional(),
|
|
23622
|
+
baseUrl: import_zod42.z.string().min(1).optional(),
|
|
23247
23623
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
|
|
23248
23624
|
codex: CodexProviderConfigSchema.optional()
|
|
23249
23625
|
});
|
|
23250
23626
|
var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
|
|
23251
|
-
var ConfigProviderRemoveInputSchema =
|
|
23627
|
+
var ConfigProviderRemoveInputSchema = import_zod42.z.strictObject({ name: import_zod42.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
23252
23628
|
var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
|
|
23253
|
-
var ConfigRuleAddInputSchema =
|
|
23254
|
-
path:
|
|
23255
|
-
configProfile:
|
|
23256
|
-
identity:
|
|
23629
|
+
var ConfigRuleAddInputSchema = import_zod42.z.strictObject({
|
|
23630
|
+
path: import_zod42.z.string().min(1),
|
|
23631
|
+
configProfile: import_zod42.z.string().min(1).optional(),
|
|
23632
|
+
identity: import_zod42.z.string().min(1).optional()
|
|
23257
23633
|
});
|
|
23258
23634
|
var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
|
|
23259
|
-
var ConfigRuleSetInputSchema =
|
|
23260
|
-
path:
|
|
23261
|
-
configProfile:
|
|
23262
|
-
identity:
|
|
23635
|
+
var ConfigRuleSetInputSchema = import_zod42.z.strictObject({
|
|
23636
|
+
path: import_zod42.z.string().min(1),
|
|
23637
|
+
configProfile: import_zod42.z.union([import_zod42.z.string().min(1), import_zod42.z.literal(false)]).optional(),
|
|
23638
|
+
identity: import_zod42.z.union([import_zod42.z.string().min(1), import_zod42.z.literal(false)]).optional()
|
|
23263
23639
|
});
|
|
23264
23640
|
var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
|
|
23265
|
-
var ConfigRuleRemoveInputSchema =
|
|
23641
|
+
var ConfigRuleRemoveInputSchema = import_zod42.z.strictObject({ path: import_zod42.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
23266
23642
|
var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
|
|
23267
23643
|
|
|
23268
23644
|
// src/frontdoor/configApi.ts
|
|
@@ -23336,7 +23712,7 @@ function profileValue(name, paths) {
|
|
|
23336
23712
|
function createConfigApiRouter(deps) {
|
|
23337
23713
|
const authed = doorApiAuth(deps.expectedToken);
|
|
23338
23714
|
const { paths } = deps;
|
|
23339
|
-
const route = (
|
|
23715
|
+
const route = (path59, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path59, summary, tags: [CONFIG_API_TAG] }));
|
|
23340
23716
|
return {
|
|
23341
23717
|
config: {
|
|
23342
23718
|
identity: {
|
|
@@ -23606,51 +23982,51 @@ var import_openapi4 = require("@orpc/openapi");
|
|
|
23606
23982
|
var import_server3 = require("@orpc/server");
|
|
23607
23983
|
|
|
23608
23984
|
// src/frontdoor/eventSchemas.ts
|
|
23609
|
-
var
|
|
23985
|
+
var import_zod43 = require("zod");
|
|
23610
23986
|
init_schema2();
|
|
23611
23987
|
var DOOR_EVENT_SOURCE_RC = "rc";
|
|
23612
23988
|
var LAUNCH_EVENT_SOURCE = "launch";
|
|
23613
23989
|
var USAGE_EVENT_SOURCE = "usage";
|
|
23614
23990
|
var DOOR_HEALTH_EVENT_SOURCE = "door";
|
|
23615
23991
|
var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
|
|
23616
|
-
var DoorEventSchema =
|
|
23617
|
-
source:
|
|
23992
|
+
var DoorEventSchema = import_zod43.z.strictObject({
|
|
23993
|
+
source: import_zod43.z.string().min(1),
|
|
23618
23994
|
/** A positive integer because the backbone's counters start at one and only ever increase. */
|
|
23619
|
-
sequence:
|
|
23620
|
-
payload:
|
|
23621
|
-
});
|
|
23622
|
-
var DoorEventSourceQuerySchema =
|
|
23623
|
-
sources:
|
|
23624
|
-
});
|
|
23625
|
-
var LaunchLifecycleEventSchema =
|
|
23626
|
-
kind:
|
|
23627
|
-
pid:
|
|
23628
|
-
startedAt:
|
|
23629
|
-
observedAt:
|
|
23630
|
-
});
|
|
23631
|
-
var DoorHealthEventSchema =
|
|
23632
|
-
|
|
23633
|
-
|
|
23634
|
-
|
|
23635
|
-
|
|
23636
|
-
|
|
23637
|
-
|
|
23995
|
+
sequence: import_zod43.z.number().int().positive(),
|
|
23996
|
+
payload: import_zod43.z.unknown()
|
|
23997
|
+
});
|
|
23998
|
+
var DoorEventSourceQuerySchema = import_zod43.z.strictObject({
|
|
23999
|
+
sources: import_zod43.z.array(import_zod43.z.string().min(1)).min(1).optional()
|
|
24000
|
+
});
|
|
24001
|
+
var LaunchLifecycleEventSchema = import_zod43.z.strictObject({
|
|
24002
|
+
kind: import_zod43.z.enum(["registered", "pruned", "ended"]),
|
|
24003
|
+
pid: import_zod43.z.number().int().positive(),
|
|
24004
|
+
startedAt: import_zod43.z.number(),
|
|
24005
|
+
observedAt: import_zod43.z.number()
|
|
24006
|
+
});
|
|
24007
|
+
var DoorHealthEventSchema = import_zod43.z.discriminatedUnion("kind", [
|
|
24008
|
+
import_zod43.z.strictObject({ kind: import_zod43.z.literal("generation"), pid: import_zod43.z.number().int().positive(), providerPort: import_zod43.z.number().int().positive(), connectPort: import_zod43.z.number().int().positive(), directPort: import_zod43.z.number().int().positive(), observedAt: import_zod43.z.number() }),
|
|
24009
|
+
import_zod43.z.strictObject({ kind: import_zod43.z.literal("listenerFailed"), pid: import_zod43.z.number().int().positive(), listener: import_zod43.z.enum(["provider", "connect", "direct"]), message: import_zod43.z.string(), observedAt: import_zod43.z.number() }),
|
|
24010
|
+
import_zod43.z.strictObject({ kind: import_zod43.z.literal("binaryTurnover"), pid: import_zod43.z.number().int().positive(), observedAt: import_zod43.z.number() }),
|
|
24011
|
+
import_zod43.z.strictObject({ kind: import_zod43.z.literal("idleShutdown"), pid: import_zod43.z.number().int().positive(), observedAt: import_zod43.z.number() }),
|
|
24012
|
+
import_zod43.z.strictObject({ kind: import_zod43.z.literal("superseded"), pid: import_zod43.z.number().int().positive(), ownerPid: import_zod43.z.number().int().positive(), observedAt: import_zod43.z.number() }),
|
|
24013
|
+
import_zod43.z.strictObject({ kind: import_zod43.z.literal("drained"), pid: import_zod43.z.number().int().positive(), observedAt: import_zod43.z.number() })
|
|
23638
24014
|
]);
|
|
23639
|
-
var QuotaExpiringEventSchema =
|
|
24015
|
+
var QuotaExpiringEventSchema = import_zod43.z.strictObject({
|
|
23640
24016
|
/** The id of the identity whose window it is: what its usage is filed under, which a rename keeps. */
|
|
23641
|
-
id:
|
|
24017
|
+
id: import_zod43.z.string().min(1),
|
|
23642
24018
|
/** The identity's name when the event was published, absent for an identity no longer stored under the id. */
|
|
23643
|
-
name:
|
|
23644
|
-
provider:
|
|
23645
|
-
window:
|
|
24019
|
+
name: import_zod43.z.string().min(1).optional(),
|
|
24020
|
+
provider: import_zod43.z.string().min(1),
|
|
24021
|
+
window: import_zod43.z.enum(["fiveHour", "sevenDay"]),
|
|
23646
24022
|
/** 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. */
|
|
23647
|
-
utilization:
|
|
23648
|
-
resetsAt:
|
|
23649
|
-
observedAt:
|
|
24023
|
+
utilization: import_zod43.z.number().min(0).max(1),
|
|
24024
|
+
resetsAt: import_zod43.z.iso.datetime(),
|
|
24025
|
+
observedAt: import_zod43.z.number()
|
|
23650
24026
|
});
|
|
23651
24027
|
var UsageChangeEventSchema = UsageSnapshotSchema.extend({
|
|
23652
|
-
id:
|
|
23653
|
-
name:
|
|
24028
|
+
id: import_zod43.z.string().min(1),
|
|
24029
|
+
name: import_zod43.z.string().min(1).optional()
|
|
23654
24030
|
});
|
|
23655
24031
|
|
|
23656
24032
|
// src/frontdoor/eventsApi.ts
|
|
@@ -23694,7 +24070,7 @@ function createEventsApiRouter(deps) {
|
|
|
23694
24070
|
// src/frontdoor/lifecycleApi.ts
|
|
23695
24071
|
var import_client4 = require("@orpc/client");
|
|
23696
24072
|
var import_openapi5 = require("@orpc/openapi");
|
|
23697
|
-
var
|
|
24073
|
+
var import_zod44 = require("zod");
|
|
23698
24074
|
init_update();
|
|
23699
24075
|
var FRONTDOOR_API_TAG = "frontdoor";
|
|
23700
24076
|
var UPDATE_API_TAG = "update";
|
|
@@ -23702,7 +24078,7 @@ function createLifecycleApiRouter(deps) {
|
|
|
23702
24078
|
const authed = doorApiAuth(deps.expectedToken);
|
|
23703
24079
|
return {
|
|
23704
24080
|
frontdoor: {
|
|
23705
|
-
refreshCatalogues: authed.meta((0, import_openapi5.openapi)({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(
|
|
24081
|
+
refreshCatalogues: authed.meta((0, import_openapi5.openapi)({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(import_zod44.z.strictObject({ requested: import_zod44.z.literal(true) })).handler(() => {
|
|
23706
24082
|
deps.refreshCatalogues();
|
|
23707
24083
|
return { requested: true };
|
|
23708
24084
|
}),
|
|
@@ -23738,65 +24114,65 @@ var import_openapi6 = require("@orpc/openapi");
|
|
|
23738
24114
|
init_cliError();
|
|
23739
24115
|
|
|
23740
24116
|
// src/frontdoor/launchSchemas.ts
|
|
23741
|
-
var
|
|
23742
|
-
var
|
|
24117
|
+
var import_node_path46 = __toESM(require("node:path"), 1);
|
|
24118
|
+
var import_zod45 = require("zod");
|
|
23743
24119
|
init_statusline();
|
|
23744
24120
|
init_claudeVersion();
|
|
23745
24121
|
init_identity2();
|
|
23746
|
-
var LaunchResolveInputSchema =
|
|
23747
|
-
path:
|
|
24122
|
+
var LaunchResolveInputSchema = import_zod45.z.strictObject({
|
|
24123
|
+
path: import_zod45.z.string().min(1),
|
|
23748
24124
|
/** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
|
|
23749
|
-
argv:
|
|
24125
|
+
argv: import_zod45.z.readonly(import_zod45.z.array(import_zod45.z.string())).optional(),
|
|
23750
24126
|
/** 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. */
|
|
23751
|
-
env:
|
|
23752
|
-
}).refine((input) =>
|
|
23753
|
-
var LaunchPoolDecisionSchema =
|
|
23754
|
-
name:
|
|
23755
|
-
reasons:
|
|
24127
|
+
env: import_zod45.z.record(import_zod45.z.string(), import_zod45.z.string()).optional()
|
|
24128
|
+
}).refine((input) => import_node_path46.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
24129
|
+
var LaunchPoolDecisionSchema = import_zod45.z.strictObject({
|
|
24130
|
+
name: import_zod45.z.string(),
|
|
24131
|
+
reasons: import_zod45.z.readonly(import_zod45.z.array(import_zod45.z.string())),
|
|
23756
24132
|
/** The provider the ranking read for the chosen member, when the launch spends one in place of the member's Claude account. */
|
|
23757
|
-
provider:
|
|
23758
|
-
movedOff:
|
|
24133
|
+
provider: import_zod45.z.string().optional(),
|
|
24134
|
+
movedOff: import_zod45.z.strictObject({ identity: import_zod45.z.string(), reason: import_zod45.z.string() }).optional()
|
|
23759
24135
|
});
|
|
23760
|
-
var LaunchDecisionSchema =
|
|
23761
|
-
identity:
|
|
23762
|
-
identityId:
|
|
23763
|
-
identitySource:
|
|
24136
|
+
var LaunchDecisionSchema = import_zod45.z.strictObject({
|
|
24137
|
+
identity: import_zod45.z.string().optional(),
|
|
24138
|
+
identityId: import_zod45.z.string().optional(),
|
|
24139
|
+
identitySource: import_zod45.z.enum(IDENTITY_DECISION_SOURCES),
|
|
23764
24140
|
pool: LaunchPoolDecisionSchema.optional(),
|
|
23765
24141
|
/** 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. */
|
|
23766
|
-
configDirEscapeHatch:
|
|
23767
|
-
configDir:
|
|
23768
|
-
configProfile:
|
|
23769
|
-
configProfileSource:
|
|
23770
|
-
provider:
|
|
23771
|
-
});
|
|
23772
|
-
var LaunchFlagsSchema =
|
|
23773
|
-
skipPermissions:
|
|
23774
|
-
remoteControl:
|
|
23775
|
-
headroom:
|
|
23776
|
-
trackUsage:
|
|
23777
|
-
pause:
|
|
23778
|
-
explain:
|
|
24142
|
+
configDirEscapeHatch: import_zod45.z.boolean(),
|
|
24143
|
+
configDir: import_zod45.z.string().optional(),
|
|
24144
|
+
configProfile: import_zod45.z.string().optional(),
|
|
24145
|
+
configProfileSource: import_zod45.z.enum(CONFIG_PROFILE_DECISION_SOURCES),
|
|
24146
|
+
provider: import_zod45.z.string().optional()
|
|
24147
|
+
});
|
|
24148
|
+
var LaunchFlagsSchema = import_zod45.z.strictObject({
|
|
24149
|
+
skipPermissions: import_zod45.z.boolean(),
|
|
24150
|
+
remoteControl: import_zod45.z.boolean(),
|
|
24151
|
+
headroom: import_zod45.z.boolean(),
|
|
24152
|
+
trackUsage: import_zod45.z.boolean(),
|
|
24153
|
+
pause: import_zod45.z.boolean(),
|
|
24154
|
+
explain: import_zod45.z.boolean(),
|
|
23779
24155
|
/** How long the launch waits after its own output before it starts claude, in milliseconds. */
|
|
23780
|
-
delayMs:
|
|
24156
|
+
delayMs: import_zod45.z.number(),
|
|
23781
24157
|
/** The hosts the launch keeps off the front door by adding them to the child's `NO_PROXY`. */
|
|
23782
|
-
proxyBypass:
|
|
24158
|
+
proxyBypass: import_zod45.z.array(import_zod45.z.string()).readonly(),
|
|
23783
24159
|
/** How the session's built-in statusline looks, when the launch configures any of it. */
|
|
23784
24160
|
statusline: StatuslineSchema.optional()
|
|
23785
24161
|
});
|
|
23786
|
-
var LaunchResolveOutputSchema =
|
|
24162
|
+
var LaunchResolveOutputSchema = import_zod45.z.strictObject({
|
|
23787
24163
|
decision: LaunchDecisionSchema,
|
|
23788
24164
|
flags: LaunchFlagsSchema,
|
|
23789
|
-
claudeVersion:
|
|
24165
|
+
claudeVersion: import_zod45.z.strictObject({ version: import_zod45.z.string(), source: import_zod45.z.enum(CLAUDE_VERSION_SOURCES) }).optional(),
|
|
23790
24166
|
/** The real `claude` binary the launch would spawn, on the door's host. */
|
|
23791
|
-
bin:
|
|
24167
|
+
bin: import_zod45.z.string(),
|
|
23792
24168
|
/** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
|
|
23793
|
-
args:
|
|
24169
|
+
args: import_zod45.z.readonly(import_zod45.z.array(import_zod45.z.string())),
|
|
23794
24170
|
/** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
|
|
23795
|
-
credential:
|
|
23796
|
-
routing:
|
|
24171
|
+
credential: import_zod45.z.strictObject({ subject: import_zod45.z.enum(["provider", "identity"]), name: import_zod45.z.string(), summary: CredentialSummarySchema }).optional(),
|
|
24172
|
+
routing: import_zod45.z.strictObject({ frontDoor: import_zod45.z.boolean(), headroom: import_zod45.z.boolean() }),
|
|
23797
24173
|
/** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
|
|
23798
|
-
environment:
|
|
23799
|
-
warnings:
|
|
24174
|
+
environment: import_zod45.z.readonly(import_zod45.z.array(import_zod45.z.string())),
|
|
24175
|
+
warnings: import_zod45.z.readonly(import_zod45.z.array(import_zod45.z.string()))
|
|
23800
24176
|
});
|
|
23801
24177
|
|
|
23802
24178
|
// src/frontdoor/launchApi.ts
|
|
@@ -23832,24 +24208,24 @@ function createLaunchApiRouter(deps) {
|
|
|
23832
24208
|
// src/frontdoor/agentTreesApi.ts
|
|
23833
24209
|
var import_client6 = require("@orpc/client");
|
|
23834
24210
|
var import_openapi7 = require("@orpc/openapi");
|
|
23835
|
-
var
|
|
24211
|
+
var import_zod46 = require("zod");
|
|
23836
24212
|
init_liveTasks();
|
|
23837
24213
|
init_schema3();
|
|
23838
24214
|
init_cliError();
|
|
23839
|
-
var AgentTreesListInputSchema =
|
|
24215
|
+
var AgentTreesListInputSchema = import_zod46.z.strictObject({
|
|
23840
24216
|
/** Only this identity's sessions. */
|
|
23841
|
-
identity:
|
|
24217
|
+
identity: import_zod46.z.string().optional(),
|
|
23842
24218
|
/** Include sessions that spawned no agent and ran no workflow. */
|
|
23843
|
-
all:
|
|
24219
|
+
all: import_zod46.z.boolean().optional()
|
|
23844
24220
|
});
|
|
23845
|
-
var AgentTreesListOutputSchema =
|
|
23846
|
-
var AgentTreesShowInputSchema =
|
|
24221
|
+
var AgentTreesListOutputSchema = import_zod46.z.array(SessionSummarySchema);
|
|
24222
|
+
var AgentTreesShowInputSchema = import_zod46.z.strictObject({
|
|
23847
24223
|
/** A session id, or an unambiguous prefix of one. */
|
|
23848
|
-
session:
|
|
24224
|
+
session: import_zod46.z.string().min(1),
|
|
23849
24225
|
/** Look only in this identity. */
|
|
23850
|
-
identity:
|
|
24226
|
+
identity: import_zod46.z.string().optional()
|
|
23851
24227
|
});
|
|
23852
|
-
var AgentTreesShowOutputSchema =
|
|
24228
|
+
var AgentTreesShowOutputSchema = import_zod46.z.strictObject({ identities: import_zod46.z.array(import_zod46.z.string()), ...MergedAgentTreeSchema.shape });
|
|
23853
24229
|
function asBadRequest(error) {
|
|
23854
24230
|
if (error instanceof CliError) {
|
|
23855
24231
|
throw new import_client6.ORPCError("BAD_REQUEST", { message: error.message });
|
|
@@ -23902,7 +24278,7 @@ var import_openapi8 = require("@orpc/openapi");
|
|
|
23902
24278
|
var import_server4 = require("@orpc/server");
|
|
23903
24279
|
|
|
23904
24280
|
// src/frontdoor/rcEventLog.ts
|
|
23905
|
-
var
|
|
24281
|
+
var import_zod47 = require("zod");
|
|
23906
24282
|
|
|
23907
24283
|
// src/frontdoor/eventHub.ts
|
|
23908
24284
|
var DOOR_EVENT_BUFFER_EVENTS = 100;
|
|
@@ -24027,46 +24403,46 @@ var NUMBER_FIELDS = ["at", "sequence"].length;
|
|
|
24027
24403
|
var BYTES_PER_CODE_UNIT = Uint16Array.BYTES_PER_ELEMENT;
|
|
24028
24404
|
var RC_SESSION_END_REASONS = ["expired", "archived", "conflict"];
|
|
24029
24405
|
var RC_PENDING_RETIRE_REASONS = ["answered", "withdrawn", "worker-stopped", "session-ended"];
|
|
24030
|
-
var transitionBase = { session:
|
|
24031
|
-
var cursorFields = { cursor:
|
|
24032
|
-
var sessionAppearedShape = { kind:
|
|
24033
|
-
var sessionEndedShape = { kind:
|
|
24034
|
-
var workerStateShape = { kind:
|
|
24035
|
-
var pendingBornShape = { kind:
|
|
24036
|
-
var pendingRetiredShape = { kind:
|
|
24037
|
-
var RcSessionTransitionSchema =
|
|
24038
|
-
|
|
24039
|
-
|
|
24040
|
-
|
|
24041
|
-
|
|
24042
|
-
|
|
24406
|
+
var transitionBase = { session: import_zod47.z.string(), at: import_zod47.z.number() };
|
|
24407
|
+
var cursorFields = { cursor: import_zod47.z.string(), sequence: import_zod47.z.int().positive() };
|
|
24408
|
+
var sessionAppearedShape = { kind: import_zod47.z.literal("session-appeared"), ...transitionBase };
|
|
24409
|
+
var sessionEndedShape = { kind: import_zod47.z.literal("session-ended"), reason: import_zod47.z.enum(RC_SESSION_END_REASONS), ...transitionBase };
|
|
24410
|
+
var workerStateShape = { kind: import_zod47.z.literal("worker-state"), state: import_zod47.z.string(), previous: import_zod47.z.string().optional(), ...transitionBase };
|
|
24411
|
+
var pendingBornShape = { kind: import_zod47.z.literal("pending-born"), requestId: import_zod47.z.string(), type: import_zod47.z.string(), summary: import_zod47.z.string(), ...transitionBase };
|
|
24412
|
+
var pendingRetiredShape = { kind: import_zod47.z.literal("pending-retired"), requestId: import_zod47.z.string(), reason: import_zod47.z.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
|
|
24413
|
+
var RcSessionTransitionSchema = import_zod47.z.discriminatedUnion("kind", [
|
|
24414
|
+
import_zod47.z.strictObject(sessionAppearedShape),
|
|
24415
|
+
import_zod47.z.strictObject(sessionEndedShape),
|
|
24416
|
+
import_zod47.z.strictObject(workerStateShape),
|
|
24417
|
+
import_zod47.z.strictObject(pendingBornShape),
|
|
24418
|
+
import_zod47.z.strictObject(pendingRetiredShape)
|
|
24043
24419
|
]);
|
|
24044
24420
|
var KIND_MAX_CHARS = Math.max(...RcSessionTransitionSchema.options.map((option) => option.shape.kind.value.length));
|
|
24045
24421
|
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;
|
|
24046
24422
|
var RC_SESSION_EVENT_LOG_CAPACITY = Math.floor(CONTROL_BODY_CAP_BYTES / RC_SESSION_EVENT_MAX_BYTES);
|
|
24047
|
-
var RcSessionEventSchema =
|
|
24048
|
-
|
|
24049
|
-
|
|
24050
|
-
|
|
24051
|
-
|
|
24052
|
-
|
|
24423
|
+
var RcSessionEventSchema = import_zod47.z.discriminatedUnion("kind", [
|
|
24424
|
+
import_zod47.z.strictObject({ ...cursorFields, ...sessionAppearedShape }),
|
|
24425
|
+
import_zod47.z.strictObject({ ...cursorFields, ...sessionEndedShape }),
|
|
24426
|
+
import_zod47.z.strictObject({ ...cursorFields, ...workerStateShape }),
|
|
24427
|
+
import_zod47.z.strictObject({ ...cursorFields, ...pendingBornShape }),
|
|
24428
|
+
import_zod47.z.strictObject({ ...cursorFields, ...pendingRetiredShape })
|
|
24053
24429
|
]);
|
|
24054
|
-
var RcSessionEventsReadInputSchema =
|
|
24430
|
+
var RcSessionEventsReadInputSchema = import_zod47.z.strictObject({
|
|
24055
24431
|
/** The cursor of the last event the caller saw; every retained event when omitted. */
|
|
24056
|
-
since:
|
|
24432
|
+
since: import_zod47.z.string().min(1).optional(),
|
|
24057
24433
|
/** One `cse_` session id; every session when omitted. */
|
|
24058
|
-
session:
|
|
24434
|
+
session: import_zod47.z.string().min(1).optional(),
|
|
24059
24435
|
/** The most events one answer carries; every event after `since` when omitted. */
|
|
24060
|
-
limit:
|
|
24436
|
+
limit: import_zod47.z.int().positive().optional()
|
|
24061
24437
|
});
|
|
24062
24438
|
var RcSessionEventsPageInputSchema = RcSessionEventsReadInputSchema.extend({
|
|
24063
24439
|
/** 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. */
|
|
24064
|
-
limit:
|
|
24440
|
+
limit: import_zod47.z.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
|
|
24065
24441
|
});
|
|
24066
24442
|
var RcSessionEventsStreamInputSchema = RcSessionEventsReadInputSchema.omit({ limit: true });
|
|
24067
|
-
var RcSessionEventsReadOutputSchema =
|
|
24068
|
-
|
|
24069
|
-
|
|
24443
|
+
var RcSessionEventsReadOutputSchema = import_zod47.z.discriminatedUnion("status", [
|
|
24444
|
+
import_zod47.z.strictObject({ status: import_zod47.z.literal("ok"), events: import_zod47.z.readonly(import_zod47.z.array(RcSessionEventSchema)), cursor: import_zod47.z.string(), more: import_zod47.z.boolean(), head: import_zod47.z.string() }),
|
|
24445
|
+
import_zod47.z.strictObject({ status: import_zod47.z.literal("expired"), message: import_zod47.z.string(), head: import_zod47.z.string() })
|
|
24070
24446
|
]);
|
|
24071
24447
|
var CURSOR_SEPARATOR = ".";
|
|
24072
24448
|
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";
|
|
@@ -24582,6 +24958,7 @@ function createQuotaExpiringPublisher(hub, deps) {
|
|
|
24582
24958
|
|
|
24583
24959
|
// src/index.ts
|
|
24584
24960
|
init_rcSchemas();
|
|
24961
|
+
init_verifiedVersions();
|
|
24585
24962
|
|
|
24586
24963
|
// src/frontdoor/rcLiveUsage.ts
|
|
24587
24964
|
init_rcSchemas();
|
|
@@ -26253,7 +26630,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
26253
26630
|
}
|
|
26254
26631
|
|
|
26255
26632
|
// src/frontdoor/rcSelfHostMint.ts
|
|
26256
|
-
var
|
|
26633
|
+
var import_node_path47 = __toESM(require("node:path"), 1);
|
|
26257
26634
|
init_identityRecords();
|
|
26258
26635
|
init_account();
|
|
26259
26636
|
var CREDENTIALS_FILE2 = ".credentials.json";
|
|
@@ -26279,7 +26656,7 @@ function readJsonObject(fs17, file) {
|
|
|
26279
26656
|
return isRecord16(parsed) ? parsed : void 0;
|
|
26280
26657
|
}
|
|
26281
26658
|
function readRcSelfHostRecord(fs17, frontdoorDir) {
|
|
26282
|
-
const parsed = readJsonObject(fs17,
|
|
26659
|
+
const parsed = readJsonObject(fs17, import_node_path47.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
26283
26660
|
if (parsed === void 0) {
|
|
26284
26661
|
return void 0;
|
|
26285
26662
|
}
|
|
@@ -26297,11 +26674,11 @@ function mintRcSelfHostCredential(deps) {
|
|
|
26297
26674
|
if (id === void 0) {
|
|
26298
26675
|
throw new Error(`No identity named "${deps.identity}".`);
|
|
26299
26676
|
}
|
|
26300
|
-
const identityDir =
|
|
26301
|
-
const credentialsFile =
|
|
26302
|
-
const claudeJsonFile =
|
|
26303
|
-
const recordDir =
|
|
26304
|
-
const recordFile2 =
|
|
26677
|
+
const identityDir = import_node_path47.default.join(deps.identitiesDir, id);
|
|
26678
|
+
const credentialsFile = import_node_path47.default.join(identityDir, CREDENTIALS_FILE2);
|
|
26679
|
+
const claudeJsonFile = import_node_path47.default.join(identityDir, CLAUDE_JSON2);
|
|
26680
|
+
const recordDir = import_node_path47.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
|
|
26681
|
+
const recordFile2 = import_node_path47.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
26305
26682
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
26306
26683
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
26307
26684
|
const existingOauth = isRecord16(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
@@ -26317,7 +26694,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
26317
26694
|
const organizationUuid = deps.newUuid();
|
|
26318
26695
|
const accountUuid = deps.newUuid();
|
|
26319
26696
|
const mintedAt = new Date(deps.now()).toISOString();
|
|
26320
|
-
deps.fs.mkdirPrivate(
|
|
26697
|
+
deps.fs.mkdirPrivate(import_node_path47.default.dirname(credentialsFile));
|
|
26321
26698
|
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)}
|
|
26322
26699
|
`);
|
|
26323
26700
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
@@ -26353,7 +26730,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
26353
26730
|
init_ensure2();
|
|
26354
26731
|
|
|
26355
26732
|
// src/frontdoor/liveSessionRegistry.ts
|
|
26356
|
-
var
|
|
26733
|
+
var import_node_path48 = __toESM(require("node:path"), 1);
|
|
26357
26734
|
init_capability();
|
|
26358
26735
|
init_state();
|
|
26359
26736
|
function sameStat(recorded, current) {
|
|
@@ -26377,7 +26754,7 @@ function createLiveSessionRegistry(ports) {
|
|
|
26377
26754
|
const load = (name, stat) => {
|
|
26378
26755
|
known.set(name, { stat: { mtimeMs: stat.mtimeMs, sizeBytes: stat.sizeBytes }, record: readFrontDoorSessionRecord(fs17, sessionsDir, name) });
|
|
26379
26756
|
};
|
|
26380
|
-
const statOf = (name) => fs17.lstat(
|
|
26757
|
+
const statOf = (name) => fs17.lstat(import_node_path48.default.join(sessionsDir, name));
|
|
26381
26758
|
const reconcile = () => {
|
|
26382
26759
|
const names = new Set(recordNames());
|
|
26383
26760
|
let changed = false;
|
|
@@ -26451,8 +26828,8 @@ init_poolPick();
|
|
|
26451
26828
|
init_liveTasks();
|
|
26452
26829
|
|
|
26453
26830
|
// src/agents/read.ts
|
|
26454
|
-
var
|
|
26455
|
-
var
|
|
26831
|
+
var import_node_path49 = __toESM(require("node:path"), 1);
|
|
26832
|
+
var import_zod48 = require("zod");
|
|
26456
26833
|
init_schema3();
|
|
26457
26834
|
var PROJECTS_DIR = "projects";
|
|
26458
26835
|
var TASKS_DIR = "tasks";
|
|
@@ -26478,15 +26855,15 @@ function parseEntry2(project, entry) {
|
|
|
26478
26855
|
}
|
|
26479
26856
|
function listSessions2(fs17, configDir) {
|
|
26480
26857
|
const found = [];
|
|
26481
|
-
for (const project of fs17.readdir(
|
|
26482
|
-
const projectDir =
|
|
26858
|
+
for (const project of fs17.readdir(import_node_path49.default.join(configDir, PROJECTS_DIR))) {
|
|
26859
|
+
const projectDir = import_node_path49.default.join(configDir, PROJECTS_DIR, project);
|
|
26483
26860
|
const entries = /* @__PURE__ */ new Set();
|
|
26484
26861
|
for (const name of fs17.readdir(projectDir)) {
|
|
26485
26862
|
if (name.endsWith(TRANSCRIPT_SUFFIX)) {
|
|
26486
26863
|
entries.add(name.slice(0, -TRANSCRIPT_SUFFIX.length));
|
|
26487
26864
|
continue;
|
|
26488
26865
|
}
|
|
26489
|
-
const children = fs17.readdir(
|
|
26866
|
+
const children = fs17.readdir(import_node_path49.default.join(projectDir, name));
|
|
26490
26867
|
if (children.includes(SUBAGENTS_DIR) || children.includes(WORKFLOWS_DIR)) {
|
|
26491
26868
|
entries.add(name);
|
|
26492
26869
|
}
|
|
@@ -26506,8 +26883,8 @@ function locateAgents(fs17, configDir, relativeDir, workflowRunId, report) {
|
|
|
26506
26883
|
const id = name.slice(AGENT_FILE_PREFIX.length, -META_SUFFIX.length);
|
|
26507
26884
|
located.push({
|
|
26508
26885
|
id,
|
|
26509
|
-
metaPath:
|
|
26510
|
-
transcriptPath:
|
|
26886
|
+
metaPath: import_node_path49.default.join(relativeDir, name),
|
|
26887
|
+
transcriptPath: import_node_path49.default.join(relativeDir, `${AGENT_FILE_PREFIX}${id}${TRANSCRIPT_SUFFIX}`),
|
|
26511
26888
|
workflowRunId
|
|
26512
26889
|
});
|
|
26513
26890
|
}
|
|
@@ -26550,7 +26927,7 @@ function describeFailure(error) {
|
|
|
26550
26927
|
}
|
|
26551
26928
|
function readFileOrReport(fs17, configDir, relative, report) {
|
|
26552
26929
|
try {
|
|
26553
|
-
return fs17.readFileUtf8(
|
|
26930
|
+
return fs17.readFileUtf8(import_node_path49.default.join(configDir, relative));
|
|
26554
26931
|
} catch (error) {
|
|
26555
26932
|
report({ path: relative, reason: `could not be read: ${describeFailure(error)}` });
|
|
26556
26933
|
return void 0;
|
|
@@ -26558,7 +26935,7 @@ function readFileOrReport(fs17, configDir, relative, report) {
|
|
|
26558
26935
|
}
|
|
26559
26936
|
function listDirOrReport(fs17, configDir, relative, report) {
|
|
26560
26937
|
try {
|
|
26561
|
-
return fs17.readdir(
|
|
26938
|
+
return fs17.readdir(import_node_path49.default.join(configDir, relative));
|
|
26562
26939
|
} catch (error) {
|
|
26563
26940
|
report({ path: relative, reason: `could not be listed: ${describeFailure(error)}` });
|
|
26564
26941
|
return [];
|
|
@@ -26572,28 +26949,28 @@ function parseJson2(text) {
|
|
|
26572
26949
|
return void 0;
|
|
26573
26950
|
}
|
|
26574
26951
|
}
|
|
26575
|
-
var TaskFileSchema =
|
|
26576
|
-
var WorkflowRunFileSchema =
|
|
26577
|
-
runId:
|
|
26578
|
-
workflowName:
|
|
26579
|
-
status:
|
|
26580
|
-
startTime:
|
|
26581
|
-
phases:
|
|
26582
|
-
summary:
|
|
26952
|
+
var TaskFileSchema = import_zod48.z.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: import_zod48.z.array(import_zod48.z.string()).default([]), blockedBy: import_zod48.z.array(import_zod48.z.string()).default([]) });
|
|
26953
|
+
var WorkflowRunFileSchema = import_zod48.z.object({
|
|
26954
|
+
runId: import_zod48.z.string(),
|
|
26955
|
+
workflowName: import_zod48.z.string().optional(),
|
|
26956
|
+
status: import_zod48.z.string().optional(),
|
|
26957
|
+
startTime: import_zod48.z.number().optional(),
|
|
26958
|
+
phases: import_zod48.z.array(import_zod48.z.object({ title: import_zod48.z.string() })).default([]),
|
|
26959
|
+
summary: import_zod48.z.string().optional()
|
|
26583
26960
|
});
|
|
26584
26961
|
function summariseSession(fs17, configDir, ref) {
|
|
26585
|
-
const sessionRelative =
|
|
26586
|
-
const subagentsRelative =
|
|
26587
|
-
const workflowsUnderSubagents =
|
|
26962
|
+
const sessionRelative = import_node_path49.default.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
26963
|
+
const subagentsRelative = import_node_path49.default.join(sessionRelative, SUBAGENTS_DIR);
|
|
26964
|
+
const workflowsUnderSubagents = import_node_path49.default.join(subagentsRelative, WORKFLOWS_DIR);
|
|
26588
26965
|
const isMeta = (name) => name.startsWith(AGENT_FILE_PREFIX) && name.endsWith(META_SUFFIX);
|
|
26589
|
-
let agentCount = fs17.readdir(
|
|
26590
|
-
for (const runDir of fs17.readdir(
|
|
26966
|
+
let agentCount = fs17.readdir(import_node_path49.default.join(configDir, subagentsRelative)).filter(isMeta).length;
|
|
26967
|
+
for (const runDir of fs17.readdir(import_node_path49.default.join(configDir, workflowsUnderSubagents))) {
|
|
26591
26968
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
26592
|
-
agentCount += fs17.readdir(
|
|
26969
|
+
agentCount += fs17.readdir(import_node_path49.default.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
|
|
26593
26970
|
}
|
|
26594
26971
|
}
|
|
26595
|
-
const workflowRunCount = fs17.readdir(
|
|
26596
|
-
const transcript = fs17.lstat(
|
|
26972
|
+
const workflowRunCount = fs17.readdir(import_node_path49.default.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
|
|
26973
|
+
const transcript = fs17.lstat(import_node_path49.default.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
|
|
26597
26974
|
return { ...ref, agentCount, workflowRunCount, ...transcript === void 0 ? {} : { updatedAt: new Date(transcript.mtimeMs).toISOString() } };
|
|
26598
26975
|
}
|
|
26599
26976
|
function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
@@ -26601,13 +26978,13 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
|
26601
26978
|
const report = (problem) => {
|
|
26602
26979
|
problems.push(problem);
|
|
26603
26980
|
};
|
|
26604
|
-
const sessionRelative =
|
|
26605
|
-
const subagentsRelative =
|
|
26606
|
-
const workflowsUnderSubagents =
|
|
26981
|
+
const sessionRelative = import_node_path49.default.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
26982
|
+
const subagentsRelative = import_node_path49.default.join(sessionRelative, SUBAGENTS_DIR);
|
|
26983
|
+
const workflowsUnderSubagents = import_node_path49.default.join(subagentsRelative, WORKFLOWS_DIR);
|
|
26607
26984
|
const located = locateAgents(fs17, configDir, subagentsRelative, void 0, report);
|
|
26608
26985
|
for (const runDir of listDirOrReport(fs17, configDir, workflowsUnderSubagents, report)) {
|
|
26609
26986
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
26610
|
-
located.push(...locateAgents(fs17, configDir,
|
|
26987
|
+
located.push(...locateAgents(fs17, configDir, import_node_path49.default.join(workflowsUnderSubagents, runDir), runDir, report));
|
|
26611
26988
|
}
|
|
26612
26989
|
}
|
|
26613
26990
|
const agents = /* @__PURE__ */ new Map();
|
|
@@ -26648,7 +27025,7 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
|
26648
27025
|
superseded: ref.superseded,
|
|
26649
27026
|
agents: roots.sort().map(build),
|
|
26650
27027
|
tasks: readTasks(fs17, configDir, ownTaskLists(ref.sessionId), [.../* @__PURE__ */ new Set([...teamNames, ...options.taskListIds ?? []])].filter((id) => !ownTaskLists(ref.sessionId).includes(id)), report),
|
|
26651
|
-
workflowRuns: readWorkflowRuns(fs17, configDir,
|
|
27028
|
+
workflowRuns: readWorkflowRuns(fs17, configDir, import_node_path49.default.join(sessionRelative, WORKFLOWS_DIR), report),
|
|
26652
27029
|
problems
|
|
26653
27030
|
};
|
|
26654
27031
|
}
|
|
@@ -26713,12 +27090,12 @@ function ownTaskLists(sessionId) {
|
|
|
26713
27090
|
function readTasks(fs17, configDir, ownLists, sharedLists, report) {
|
|
26714
27091
|
const tasks = [];
|
|
26715
27092
|
[...ownLists, ...sharedLists].forEach((scope, index) => {
|
|
26716
|
-
const relativeDir =
|
|
27093
|
+
const relativeDir = import_node_path49.default.join(TASKS_DIR, scope);
|
|
26717
27094
|
for (const name of [...listDirOrReport(fs17, configDir, relativeDir, report)].sort()) {
|
|
26718
27095
|
if (name.startsWith(".") || !name.endsWith(JSON_SUFFIX)) {
|
|
26719
27096
|
continue;
|
|
26720
27097
|
}
|
|
26721
|
-
const relative =
|
|
27098
|
+
const relative = import_node_path49.default.join(relativeDir, name);
|
|
26722
27099
|
const text = readFileOrReport(fs17, configDir, relative, report);
|
|
26723
27100
|
const parsed = TaskFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
26724
27101
|
if (parsed.success) {
|
|
@@ -26736,7 +27113,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
|
|
|
26736
27113
|
if (!name.startsWith(WORKFLOW_RUN_PREFIX) || !name.endsWith(JSON_SUFFIX)) {
|
|
26737
27114
|
continue;
|
|
26738
27115
|
}
|
|
26739
|
-
const relative =
|
|
27116
|
+
const relative = import_node_path49.default.join(relativeDir, name);
|
|
26740
27117
|
const text = readFileOrReport(fs17, configDir, relative, report);
|
|
26741
27118
|
const parsed = WorkflowRunFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
26742
27119
|
if (!parsed.success) {
|
|
@@ -26752,7 +27129,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
|
|
|
26752
27129
|
}
|
|
26753
27130
|
|
|
26754
27131
|
// src/agents/sessions.ts
|
|
26755
|
-
var
|
|
27132
|
+
var import_node_path50 = __toESM(require("node:path"), 1);
|
|
26756
27133
|
init_cliError();
|
|
26757
27134
|
var SessionLookupError = class extends CliError {
|
|
26758
27135
|
constructor(message) {
|
|
@@ -26764,7 +27141,7 @@ function historyStores(fs17, configDirOf, identities) {
|
|
|
26764
27141
|
const byRealPath = /* @__PURE__ */ new Map();
|
|
26765
27142
|
for (const identity of identities) {
|
|
26766
27143
|
const configDir = configDirOf(identity);
|
|
26767
|
-
const real = fs17.realpath(
|
|
27144
|
+
const real = fs17.realpath(import_node_path50.default.join(configDir, "projects"));
|
|
26768
27145
|
if (real === void 0) {
|
|
26769
27146
|
continue;
|
|
26770
27147
|
}
|
|
@@ -26936,7 +27313,7 @@ init_launcher();
|
|
|
26936
27313
|
init_launchWiring();
|
|
26937
27314
|
|
|
26938
27315
|
// src/poolUsageRefresh.ts
|
|
26939
|
-
var
|
|
27316
|
+
var import_node_os14 = __toESM(require("node:os"), 1);
|
|
26940
27317
|
init_load();
|
|
26941
27318
|
init_launchWiring();
|
|
26942
27319
|
init_argv();
|
|
@@ -26999,7 +27376,7 @@ async function refreshPoolUsage(params) {
|
|
|
26999
27376
|
}
|
|
27000
27377
|
function poolSelectedByLaunch(options) {
|
|
27001
27378
|
const paths = options.paths ?? resolveLayoutPaths();
|
|
27002
|
-
const loaded = loadCascadeInput({ paths, home:
|
|
27379
|
+
const loaded = loadCascadeInput({ paths, home: import_node_os14.default.homedir(), cwd: options.cwd, read: cosmiconfigReader() });
|
|
27003
27380
|
return decideIdentity({
|
|
27004
27381
|
env: options.env,
|
|
27005
27382
|
argv0Identity: parseLauncherArgv(options.argv).identity,
|