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.mjs
CHANGED
|
@@ -1458,7 +1458,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
|
|
|
1458
1458
|
return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
|
|
1459
1459
|
}
|
|
1460
1460
|
function describeIgnoredKeys(filePath, ignored) {
|
|
1461
|
-
const places = ignored.map(({ path:
|
|
1461
|
+
const places = ignored.map(({ path: path59, keys }) => `${path59.length === 0 ? "" : `${path59.map(String).join(".")}.`}${keys.join(", ")}`);
|
|
1462
1462
|
return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
|
|
1463
1463
|
}
|
|
1464
1464
|
function noteIgnoredKeys(filePath, ignored) {
|
|
@@ -1480,9 +1480,9 @@ function restoreIgnoredKeys(filePath, value) {
|
|
|
1480
1480
|
return value;
|
|
1481
1481
|
}
|
|
1482
1482
|
const restored = structuredClone(value);
|
|
1483
|
-
for (const { path:
|
|
1483
|
+
for (const { path: path59, values } of ignored) {
|
|
1484
1484
|
let holder = restored;
|
|
1485
|
-
for (const step of
|
|
1485
|
+
for (const step of path59) {
|
|
1486
1486
|
holder = isRecord(holder) ? holder[step] : void 0;
|
|
1487
1487
|
}
|
|
1488
1488
|
if (isRecord(holder)) {
|
|
@@ -5833,8 +5833,8 @@ function parseConnectTarget(authority) {
|
|
|
5833
5833
|
function isInterceptedHost(host, interceptHosts) {
|
|
5834
5834
|
return interceptHosts.includes(host);
|
|
5835
5835
|
}
|
|
5836
|
-
function servedByPipeline(
|
|
5837
|
-
return
|
|
5836
|
+
function servedByPipeline(path59) {
|
|
5837
|
+
return path59?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
5838
5838
|
}
|
|
5839
5839
|
function forwardableHeaders(headers) {
|
|
5840
5840
|
const connectionTokens = new Set(
|
|
@@ -6697,8 +6697,8 @@ function pathnameOf(url) {
|
|
|
6697
6697
|
return new URL(url ?? "/", "http://127.0.0.1").pathname;
|
|
6698
6698
|
}
|
|
6699
6699
|
function isRcSessionExchange(url) {
|
|
6700
|
-
const
|
|
6701
|
-
return
|
|
6700
|
+
const path59 = pathnameOf(url);
|
|
6701
|
+
return path59 === RC_SESSIONS_PATH_PREFIX || path59.startsWith(`${RC_SESSIONS_PATH_PREFIX}/`);
|
|
6702
6702
|
}
|
|
6703
6703
|
function isSuccessful(status) {
|
|
6704
6704
|
return status >= HTTP_STATUS.ok && status < SUCCESS_STATUS_MAX_EXCLUSIVE;
|
|
@@ -7432,8 +7432,8 @@ function buildRcGetContextUsagePayload(requestId, detail) {
|
|
|
7432
7432
|
function isRcReadFileEncoding(value) {
|
|
7433
7433
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
|
|
7434
7434
|
}
|
|
7435
|
-
function buildRcReadFilePayload(requestId,
|
|
7436
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
7435
|
+
function buildRcReadFilePayload(requestId, path59, options) {
|
|
7436
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path59, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
7437
7437
|
}
|
|
7438
7438
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
7439
7439
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -7567,15 +7567,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
7567
7567
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
7568
7568
|
return result.ok ? { ...result, requestId } : result;
|
|
7569
7569
|
}
|
|
7570
|
-
async function readRcSessionFile(deps, sessionId,
|
|
7571
|
-
if (
|
|
7570
|
+
async function readRcSessionFile(deps, sessionId, path59, options) {
|
|
7571
|
+
if (path59 === "") {
|
|
7572
7572
|
return { ok: false, message: "a read-file write needs a non-empty path: the SDK's own field names the file the worker resolves against the session's cwd, and an empty string names none" };
|
|
7573
7573
|
}
|
|
7574
7574
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
7575
7575
|
return { ok: false, message: "a read-file write's max-bytes is a positive whole number of bytes: the SDK's own field caps the read, and a zero or negative cap reads nothing" };
|
|
7576
7576
|
}
|
|
7577
7577
|
const requestId = deps.newUuid();
|
|
7578
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
7578
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path59, options), `read ${path59} from session ${sessionId}`);
|
|
7579
7579
|
return result.ok ? { ...result, requestId } : result;
|
|
7580
7580
|
}
|
|
7581
7581
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -7650,7 +7650,7 @@ import { z as z12 } from "zod";
|
|
|
7650
7650
|
function workerFactSchema(value) {
|
|
7651
7651
|
return z12.strictObject({ value, observedAt: z12.number() });
|
|
7652
7652
|
}
|
|
7653
|
-
var RcPermissionModeSchema, RcSessionSummarySchema, RcQuestionOptionSchema, RcPendingQuestionSchema, RcPendingRequestSummarySchema, RcSessionStatusSchema, RcStreamEnvelopeSchema, RcStreamEventSchema, RcRateLimitWindowSchema, RcRateLimitInfoSchema, RcLiveRateLimitSchema, RcSessionQuerySchema, RcSendInputSchema, RcQuestionSelectionSchema, RcQuestionChoicesSchema, RcAnswerInputSchema, RcInterruptInputSchema, RcSetModelInputSchema, RcSetPermissionModeInputSchema, RcEndSessionInputSchema, RcGetUsageInputSchema, RcGetContextUsageInputSchema, RcReadFileInputSchema, RcFileSuggestionsInputSchema, RcKeepAliveInputSchema, RcMcpStatusInputSchema, RcMcpReconnectInputSchema, RcMcpAuthenticateInputSchema, RcMcpOAuthCallbackUrlInputSchema, RcTeleportInputSchema, RcListOutputSchema, RcStatusOutputSchema, RcPendingOutputSchema, RcWriteOutputSchema, RcControlWriteOutputSchema, RcAnswerOutputSchema;
|
|
7653
|
+
var RcPermissionModeSchema, RcSessionSummarySchema, RcQuestionOptionSchema, RcPendingQuestionSchema, RcPendingRequestSummarySchema, RcSessionStatusSchema, RcStreamEnvelopeSchema, RcStreamEventSchema, RcRateLimitWindowSchema, RcRateLimitInfoSchema, RcLiveRateLimitSchema, RcSessionQuerySchema, RcSendInputSchema, RcQuestionSelectionSchema, RcQuestionChoicesSchema, RcAnswerInputSchema, RcInterruptInputSchema, RcSetModelInputSchema, RcSetPermissionModeInputSchema, RcEndSessionInputSchema, RcGetUsageInputSchema, RcGetContextUsageInputSchema, RcReadFileInputSchema, RcFileSuggestionsInputSchema, RcKeepAliveInputSchema, RcMcpStatusInputSchema, RcMcpReconnectInputSchema, RcMcpAuthenticateInputSchema, RcMcpOAuthCallbackUrlInputSchema, RcTeleportInputSchema, RcListOutputSchema, RcSessionRouteSchema, RcStatusOutputSchema, RcPendingOutputSchema, RcWriteOutputSchema, RcControlWriteOutputSchema, RcAnswerOutputSchema;
|
|
7654
7654
|
var init_rcSchemas = __esm({
|
|
7655
7655
|
"src/frontdoor/rcSchemas.ts"() {
|
|
7656
7656
|
"use strict";
|
|
@@ -7819,7 +7819,8 @@ var init_rcSchemas = __esm({
|
|
|
7819
7819
|
marker: z12.string().min(1)
|
|
7820
7820
|
});
|
|
7821
7821
|
RcListOutputSchema = z12.strictObject({ sessions: z12.readonly(z12.array(RcSessionSummarySchema)) });
|
|
7822
|
-
|
|
7822
|
+
RcSessionRouteSchema = z12.union([z12.strictObject({ route: z12.enum(["supervised", "launched", "self-hosted"]) }), z12.strictObject({ route: z12.null(), refused: z12.string() })]);
|
|
7823
|
+
RcStatusOutputSchema = z12.strictObject({ statuses: z12.readonly(z12.array(z12.strictObject({ ...RcSessionStatusSchema.shape, route: RcSessionRouteSchema }))) });
|
|
7823
7824
|
RcPendingOutputSchema = z12.strictObject({
|
|
7824
7825
|
pending: z12.readonly(z12.array(RcPendingRequestSummarySchema)),
|
|
7825
7826
|
/** The sessions that had requests the door did not list (past the per-session cap, or with an id the protocol does not mint), each with how many: a question the caller expects may be among them. Absent when none did. */
|
|
@@ -7954,11 +7955,11 @@ function createRcControlHandler(deps) {
|
|
|
7954
7955
|
path: "read-file",
|
|
7955
7956
|
read: (body) => {
|
|
7956
7957
|
const session = bodyString(body, "session");
|
|
7957
|
-
const
|
|
7958
|
+
const path59 = bodyString(body, "path");
|
|
7958
7959
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
7959
7960
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
7960
|
-
const refused2 = session === void 0 ||
|
|
7961
|
-
return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session,
|
|
7961
|
+
const refused2 = session === void 0 || path59 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
7962
|
+
return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path59, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
|
|
7962
7963
|
}
|
|
7963
7964
|
},
|
|
7964
7965
|
{
|
|
@@ -8281,9 +8282,9 @@ function requestIdOfBody(body) {
|
|
|
8281
8282
|
}
|
|
8282
8283
|
function frontDoorRcControl(transport, token) {
|
|
8283
8284
|
const headers = { authorization: `Bearer ${token}` };
|
|
8284
|
-
const listAnswerOf = async (
|
|
8285
|
+
const listAnswerOf = async (path59, what) => {
|
|
8285
8286
|
try {
|
|
8286
|
-
return await transport.request({ method: "GET", path:
|
|
8287
|
+
return await transport.request({ method: "GET", path: path59, headers });
|
|
8287
8288
|
} catch (error) {
|
|
8288
8289
|
throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
8289
8290
|
}
|
|
@@ -8355,10 +8356,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
8355
8356
|
}
|
|
8356
8357
|
return pending;
|
|
8357
8358
|
};
|
|
8358
|
-
const writeOf = async (
|
|
8359
|
+
const writeOf = async (path59, body, describeFailure2) => {
|
|
8359
8360
|
let answer;
|
|
8360
8361
|
try {
|
|
8361
|
-
answer = await transport.request({ method: "POST", path:
|
|
8362
|
+
answer = await transport.request({ method: "POST", path: path59, headers: { ...headers, "content-type": "application/json" }, body });
|
|
8362
8363
|
} catch (error) {
|
|
8363
8364
|
return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
|
|
8364
8365
|
}
|
|
@@ -8389,10 +8390,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
8389
8390
|
endSession: async (sessionId, reason) => await writeOf(`${CONTROL_PATH_PREFIX}/end-session`, JSON.stringify({ session: sessionId, ...reason === void 0 ? {} : { reason } }), (status, message) => `ending ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
8390
8391
|
getUsage: async (sessionId, skipBehaviors) => await writeOf(`${CONTROL_PATH_PREFIX}/get-usage`, JSON.stringify({ session: sessionId, ...skipBehaviors === void 0 ? {} : { skipBehaviors } }), (status, message) => `requesting the usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
8391
8392
|
getContextUsage: async (sessionId, detail) => await writeOf(`${CONTROL_PATH_PREFIX}/get-context-usage`, JSON.stringify({ session: sessionId, ...detail === void 0 ? {} : { detail } }), (status, message) => `requesting the context usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
8392
|
-
readFile: async (sessionId,
|
|
8393
|
+
readFile: async (sessionId, path59, options) => await writeOf(
|
|
8393
8394
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
8394
|
-
JSON.stringify({ session: sessionId, path:
|
|
8395
|
-
(status, message) => `reading ${
|
|
8395
|
+
JSON.stringify({ session: sessionId, path: path59, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
8396
|
+
(status, message) => `reading ${path59} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
8396
8397
|
),
|
|
8397
8398
|
fileSuggestions: async (sessionId, query) => await writeOf(`${CONTROL_PATH_PREFIX}/file-suggestions`, JSON.stringify({ session: sessionId, query }), (status, message) => `requesting file suggestions from ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
8398
8399
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -8633,12 +8634,12 @@ function tlsFacts(options) {
|
|
|
8633
8634
|
}
|
|
8634
8635
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
8635
8636
|
const agent = new ExemptTlsAgent();
|
|
8636
|
-
const post = async (
|
|
8637
|
+
const post = async (path59, headers, body) => await new Promise((resolve, reject) => {
|
|
8637
8638
|
const options = {
|
|
8638
8639
|
host: target.host,
|
|
8639
8640
|
port: target.port,
|
|
8640
8641
|
method: "POST",
|
|
8641
|
-
path:
|
|
8642
|
+
path: path59,
|
|
8642
8643
|
// The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
|
|
8643
8644
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
8644
8645
|
agent
|
|
@@ -8698,12 +8699,12 @@ function lateRcStreamDial(resolve) {
|
|
|
8698
8699
|
}
|
|
8699
8700
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
8700
8701
|
const agent = new ExemptTlsAgent();
|
|
8701
|
-
const request4 = async (method,
|
|
8702
|
+
const request4 = async (method, path59, headers, body, signal) => await new Promise((resolve, reject) => {
|
|
8702
8703
|
const options = {
|
|
8703
8704
|
host: target.host,
|
|
8704
8705
|
port: target.port,
|
|
8705
8706
|
method,
|
|
8706
|
-
path:
|
|
8707
|
+
path: path59,
|
|
8707
8708
|
// The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
|
|
8708
8709
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
8709
8710
|
agent,
|
|
@@ -8745,9 +8746,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
8745
8746
|
return { status, body: await readAll(response) };
|
|
8746
8747
|
},
|
|
8747
8748
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
8748
|
-
const
|
|
8749
|
+
const path59 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
|
|
8749
8750
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
8750
|
-
const { status, response } = await request4("GET",
|
|
8751
|
+
const { status, response } = await request4("GET", path59, streamHeaders, void 0, signal);
|
|
8751
8752
|
if (!isSuccessful2(status)) {
|
|
8752
8753
|
await readAll(response);
|
|
8753
8754
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -9235,9 +9236,9 @@ var init_identity2 = __esm({
|
|
|
9235
9236
|
|
|
9236
9237
|
// src/statusline/keys.ts
|
|
9237
9238
|
import { z as z13 } from "zod";
|
|
9238
|
-
function valueAt(source,
|
|
9239
|
+
function valueAt(source, path59) {
|
|
9239
9240
|
let current = source;
|
|
9240
|
-
for (const part of
|
|
9241
|
+
for (const part of path59) {
|
|
9241
9242
|
if (!isPlainObject(current)) {
|
|
9242
9243
|
return void 0;
|
|
9243
9244
|
}
|
|
@@ -9245,14 +9246,14 @@ function valueAt(source, path56) {
|
|
|
9245
9246
|
}
|
|
9246
9247
|
return current;
|
|
9247
9248
|
}
|
|
9248
|
-
function acceptsNull(
|
|
9249
|
-
const layer =
|
|
9249
|
+
function acceptsNull(path59) {
|
|
9250
|
+
const layer = path59.reduceRight((inner, part) => ({ [part]: inner }), null);
|
|
9250
9251
|
return StatuslineSchema.safeParse(layer).success;
|
|
9251
9252
|
}
|
|
9252
|
-
function keyOf(
|
|
9253
|
+
function keyOf(path59, declared) {
|
|
9253
9254
|
const optional = declared instanceof z13.ZodOptional;
|
|
9254
9255
|
const leaf = optional ? declared.unwrap() : declared;
|
|
9255
|
-
const common = { path:
|
|
9256
|
+
const common = { path: path59.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path59), optional, unsettable: acceptsNull(path59) };
|
|
9256
9257
|
if (leaf instanceof z13.ZodNumber) {
|
|
9257
9258
|
return { ...common, kind: "integer", choices: [] };
|
|
9258
9259
|
}
|
|
@@ -9277,7 +9278,7 @@ function keyOf(path56, declared) {
|
|
|
9277
9278
|
if (leaf instanceof z13.ZodArray && leaf.element instanceof z13.ZodString) {
|
|
9278
9279
|
return { ...common, kind: "textList", choices: [] };
|
|
9279
9280
|
}
|
|
9280
|
-
throw new TypeError(`statusline setting ${
|
|
9281
|
+
throw new TypeError(`statusline setting ${path59.join(".")} has a kind the key listing does not describe`);
|
|
9281
9282
|
}
|
|
9282
9283
|
function walk(shape, prefix) {
|
|
9283
9284
|
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof z13.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
@@ -9293,15 +9294,15 @@ var init_keys = __esm({
|
|
|
9293
9294
|
});
|
|
9294
9295
|
|
|
9295
9296
|
// src/statusline/change.ts
|
|
9296
|
-
function keyNamed(
|
|
9297
|
-
const found = statuslineKeys().find((key) => key.path ===
|
|
9297
|
+
function keyNamed(path59) {
|
|
9298
|
+
const found = statuslineKeys().find((key) => key.path === path59);
|
|
9298
9299
|
if (found === void 0) {
|
|
9299
|
-
throw new UsageError(`"${
|
|
9300
|
+
throw new UsageError(`"${path59}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
|
|
9300
9301
|
}
|
|
9301
9302
|
return found;
|
|
9302
9303
|
}
|
|
9303
|
-
function setAt(target,
|
|
9304
|
-
const [head, ...rest] =
|
|
9304
|
+
function setAt(target, path59, value) {
|
|
9305
|
+
const [head, ...rest] = path59;
|
|
9305
9306
|
if (head === void 0) {
|
|
9306
9307
|
return;
|
|
9307
9308
|
}
|
|
@@ -9314,8 +9315,8 @@ function setAt(target, path56, value) {
|
|
|
9314
9315
|
target[head] = next;
|
|
9315
9316
|
setAt(next, rest, value);
|
|
9316
9317
|
}
|
|
9317
|
-
function removeAt(target,
|
|
9318
|
-
const [head, ...rest] =
|
|
9318
|
+
function removeAt(target, path59) {
|
|
9319
|
+
const [head, ...rest] = path59;
|
|
9319
9320
|
if (head === void 0) {
|
|
9320
9321
|
return;
|
|
9321
9322
|
}
|
|
@@ -9333,13 +9334,13 @@ function removeAt(target, path56) {
|
|
|
9333
9334
|
}
|
|
9334
9335
|
function applyStatuslineChange(existing, change) {
|
|
9335
9336
|
const draft = structuredClone(existing ?? {});
|
|
9336
|
-
for (const [
|
|
9337
|
-
keyNamed(
|
|
9338
|
-
setAt(draft,
|
|
9337
|
+
for (const [path59, value] of Object.entries(change.set ?? {})) {
|
|
9338
|
+
keyNamed(path59);
|
|
9339
|
+
setAt(draft, path59.split("."), value);
|
|
9339
9340
|
}
|
|
9340
|
-
for (const
|
|
9341
|
-
keyNamed(
|
|
9342
|
-
removeAt(draft,
|
|
9341
|
+
for (const path59 of change.unset ?? []) {
|
|
9342
|
+
keyNamed(path59);
|
|
9343
|
+
removeAt(draft, path59.split("."));
|
|
9343
9344
|
}
|
|
9344
9345
|
const result = StatuslineSchema.safeParse(draft);
|
|
9345
9346
|
if (!result.success) {
|
|
@@ -9575,19 +9576,19 @@ function writePools(paths, pools) {
|
|
|
9575
9576
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
9576
9577
|
}
|
|
9577
9578
|
function poolCycleOf(pools, name) {
|
|
9578
|
-
const walk2 = (current,
|
|
9579
|
+
const walk2 = (current, path59) => {
|
|
9579
9580
|
for (const entry of pools[current]?.identities ?? []) {
|
|
9580
9581
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
9581
9582
|
if (nested === void 0) {
|
|
9582
9583
|
continue;
|
|
9583
9584
|
}
|
|
9584
9585
|
if (nested === name) {
|
|
9585
|
-
return [...
|
|
9586
|
+
return [...path59, nested];
|
|
9586
9587
|
}
|
|
9587
|
-
if (
|
|
9588
|
+
if (path59.includes(nested)) {
|
|
9588
9589
|
continue;
|
|
9589
9590
|
}
|
|
9590
|
-
const found = walk2(nested, [...
|
|
9591
|
+
const found = walk2(nested, [...path59, nested]);
|
|
9591
9592
|
if (found !== void 0) {
|
|
9592
9593
|
return found;
|
|
9593
9594
|
}
|
|
@@ -14128,7 +14129,7 @@ var init_package = __esm({
|
|
|
14128
14129
|
"package.json"() {
|
|
14129
14130
|
package_default = {
|
|
14130
14131
|
name: "claude-use",
|
|
14131
|
-
version: "14.
|
|
14132
|
+
version: "14.5.1",
|
|
14132
14133
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
14133
14134
|
license: "MIT",
|
|
14134
14135
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -14234,6 +14235,28 @@ var init_package = __esm({
|
|
|
14234
14235
|
}
|
|
14235
14236
|
});
|
|
14236
14237
|
|
|
14238
|
+
// src/supervise/sessionControl.ts
|
|
14239
|
+
import path33 from "node:path";
|
|
14240
|
+
import { z as z24 } from "zod";
|
|
14241
|
+
var RESULT_POLL_MS, SessionControlConversationSchema, REQUEST_INSTANT_DIGITS;
|
|
14242
|
+
var init_sessionControl = __esm({
|
|
14243
|
+
"src/supervise/sessionControl.ts"() {
|
|
14244
|
+
"use strict";
|
|
14245
|
+
RESULT_POLL_MS = 250;
|
|
14246
|
+
SessionControlConversationSchema = z24.object({ conversationId: z24.string().min(1), transcriptPath: z24.string().refine(path33.isAbsolute) });
|
|
14247
|
+
REQUEST_INSTANT_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
|
|
14248
|
+
}
|
|
14249
|
+
});
|
|
14250
|
+
|
|
14251
|
+
// src/supervise/verifiedVersions.ts
|
|
14252
|
+
var RC_SESSION_COMMAND_VERIFIED_VERSIONS;
|
|
14253
|
+
var init_verifiedVersions = __esm({
|
|
14254
|
+
"src/supervise/verifiedVersions.ts"() {
|
|
14255
|
+
"use strict";
|
|
14256
|
+
RC_SESSION_COMMAND_VERIFIED_VERSIONS = ["2.1.319", "2.1.325"];
|
|
14257
|
+
}
|
|
14258
|
+
});
|
|
14259
|
+
|
|
14237
14260
|
// src/launcher/claudeVersion.ts
|
|
14238
14261
|
function validated2(value, origin) {
|
|
14239
14262
|
if (!NUMERIC_DOTTED_VERSION_RE.test(value)) {
|
|
@@ -14337,8 +14360,8 @@ var init_commandDeps = __esm({
|
|
|
14337
14360
|
|
|
14338
14361
|
// src/claudeShim.ts
|
|
14339
14362
|
import fs9 from "node:fs";
|
|
14340
|
-
import
|
|
14341
|
-
import { z as
|
|
14363
|
+
import path34 from "node:path";
|
|
14364
|
+
import { z as z30 } from "zod";
|
|
14342
14365
|
function commandFilename(ownExecutablePath, commandName) {
|
|
14343
14366
|
return ownExecutablePath.toLowerCase().endsWith(".exe") ? `${commandName}.exe` : commandName;
|
|
14344
14367
|
}
|
|
@@ -14362,10 +14385,10 @@ function isLauncherScript(candidate) {
|
|
|
14362
14385
|
}
|
|
14363
14386
|
function resolveOwnBinaryCheck(paths, contentSourcePath) {
|
|
14364
14387
|
const state = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
14365
|
-
const recordedTarget = state === void 0 ? void 0 :
|
|
14388
|
+
const recordedTarget = state === void 0 ? void 0 : path34.resolve(state.targetPath);
|
|
14366
14389
|
let ownStat;
|
|
14367
14390
|
return (candidate) => {
|
|
14368
|
-
if (recordedTarget !== void 0 &&
|
|
14391
|
+
if (recordedTarget !== void 0 && path34.resolve(candidate) === recordedTarget) {
|
|
14369
14392
|
return true;
|
|
14370
14393
|
}
|
|
14371
14394
|
ownStat ??= statOrUndefined(contentSourcePath);
|
|
@@ -14389,15 +14412,15 @@ function statOrUndefined(target) {
|
|
|
14389
14412
|
}
|
|
14390
14413
|
}
|
|
14391
14414
|
function findPathShadow(params) {
|
|
14392
|
-
const resolvedTargetDir =
|
|
14415
|
+
const resolvedTargetDir = path34.resolve(params.targetDir);
|
|
14393
14416
|
for (const dir of params.pathDirs) {
|
|
14394
14417
|
const found = params.findExecutableInDir(dir, params.targetFilename);
|
|
14395
14418
|
if (found === void 0) {
|
|
14396
14419
|
continue;
|
|
14397
14420
|
}
|
|
14398
|
-
return
|
|
14421
|
+
return path34.resolve(dir) === resolvedTargetDir ? { status: "ok" } : { status: "shadowed", by: found };
|
|
14399
14422
|
}
|
|
14400
|
-
return params.pathDirs.some((dir) =>
|
|
14423
|
+
return params.pathDirs.some((dir) => path34.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
|
|
14401
14424
|
}
|
|
14402
14425
|
var ClaudeShimStateSchema, SCRIPT_HEAD_BYTES, LAUNCHER_NAME, EXEC_RUN, nodeLinkFs;
|
|
14403
14426
|
var init_claudeShim = __esm({
|
|
@@ -14407,10 +14430,10 @@ var init_claudeShim = __esm({
|
|
|
14407
14430
|
init_store();
|
|
14408
14431
|
init_realPorts();
|
|
14409
14432
|
init_cliError();
|
|
14410
|
-
ClaudeShimStateSchema =
|
|
14411
|
-
targetPath:
|
|
14412
|
-
method:
|
|
14413
|
-
installedAtMs:
|
|
14433
|
+
ClaudeShimStateSchema = z30.strictObject({
|
|
14434
|
+
targetPath: z30.string().min(1),
|
|
14435
|
+
method: z30.enum(["hardlink", "copy"]),
|
|
14436
|
+
installedAtMs: z30.number()
|
|
14414
14437
|
});
|
|
14415
14438
|
SCRIPT_HEAD_BYTES = 4096;
|
|
14416
14439
|
LAUNCHER_NAME = /\b(agent-shim|claude-use)\b/;
|
|
@@ -14795,7 +14818,7 @@ var init_reservedModelNames = __esm({
|
|
|
14795
14818
|
});
|
|
14796
14819
|
|
|
14797
14820
|
// src/providerAliases.ts
|
|
14798
|
-
import { z as
|
|
14821
|
+
import { z as z31 } from "zod";
|
|
14799
14822
|
function parseAliases(file, raw) {
|
|
14800
14823
|
const parsed = ProviderAliasesSchema.safeParse(raw);
|
|
14801
14824
|
if (!parsed.success) {
|
|
@@ -14834,7 +14857,7 @@ var init_providerAliases = __esm({
|
|
|
14834
14857
|
init_cliError();
|
|
14835
14858
|
init_load();
|
|
14836
14859
|
init_store();
|
|
14837
|
-
ProviderAliasesSchema =
|
|
14860
|
+
ProviderAliasesSchema = z31.record(z31.string().min(1), z31.string().min(1));
|
|
14838
14861
|
}
|
|
14839
14862
|
});
|
|
14840
14863
|
|
|
@@ -15406,18 +15429,18 @@ var init_envBool = __esm({
|
|
|
15406
15429
|
});
|
|
15407
15430
|
|
|
15408
15431
|
// src/pathNorm.ts
|
|
15409
|
-
import
|
|
15432
|
+
import path38 from "node:path";
|
|
15410
15433
|
function expandTilde(value, home) {
|
|
15411
15434
|
if (value === "~") {
|
|
15412
15435
|
return home;
|
|
15413
15436
|
}
|
|
15414
15437
|
if (value.startsWith("~/")) {
|
|
15415
|
-
return
|
|
15438
|
+
return path38.join(home, value.slice(2));
|
|
15416
15439
|
}
|
|
15417
15440
|
return value;
|
|
15418
15441
|
}
|
|
15419
15442
|
function normaliseRulePath(rulePath, home) {
|
|
15420
|
-
return
|
|
15443
|
+
return path38.resolve(expandTilde(rulePath, home));
|
|
15421
15444
|
}
|
|
15422
15445
|
var init_pathNorm = __esm({
|
|
15423
15446
|
"src/pathNorm.ts"() {
|
|
@@ -15426,7 +15449,7 @@ var init_pathNorm = __esm({
|
|
|
15426
15449
|
});
|
|
15427
15450
|
|
|
15428
15451
|
// src/launcher/cascade.ts
|
|
15429
|
-
import
|
|
15452
|
+
import path39 from "node:path";
|
|
15430
15453
|
function loadCascadeInput(params) {
|
|
15431
15454
|
const globalConfig = loadConfigFile(params.paths.globalConfigFile, GlobalConfigSchema, params.read);
|
|
15432
15455
|
const directoryRules = loadConfigFile(params.paths.directoryRulesFile, DirectoryRulesSchema, params.read);
|
|
@@ -15446,8 +15469,8 @@ function loadCascadeInput(params) {
|
|
|
15446
15469
|
});
|
|
15447
15470
|
const levels = [];
|
|
15448
15471
|
for (const dir of dirs) {
|
|
15449
|
-
const portable = loadConfigFile(
|
|
15450
|
-
const portableLocal = loadConfigFile(
|
|
15472
|
+
const portable = loadConfigFile(path39.join(dir, PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(path39.join(dir, LEGACY_PORTABLE_CONFIG_FILENAME), PortableConfigSchema, params.read);
|
|
15473
|
+
const portableLocal = loadConfigFile(path39.join(dir, PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read) ?? loadConfigFile(path39.join(dir, LEGACY_PORTABLE_LOCAL_CONFIG_FILENAME), PortableConfigSchema, params.read);
|
|
15451
15474
|
const rules = (directoryRules?.config.rules ?? []).map((rule, index) => ({ rule, index })).filter(({ rule }) => normaliseRulePath(rule.path, params.home) === dir).map(({ rule, index }) => {
|
|
15452
15475
|
const entryOrder = directoryRules?.ruleEntryOrders[index];
|
|
15453
15476
|
return {
|
|
@@ -15587,14 +15610,14 @@ var init_memberProvider = __esm({
|
|
|
15587
15610
|
// src/paths.ts
|
|
15588
15611
|
import fs12 from "node:fs";
|
|
15589
15612
|
import os6 from "node:os";
|
|
15590
|
-
import
|
|
15613
|
+
import path40 from "node:path";
|
|
15591
15614
|
function resolveAgentShimHome(env = process.env, home = os6.homedir(), isDirectory = isExistingDirectory) {
|
|
15592
15615
|
const fromEnv = env.AGENT_SHIM_HOME;
|
|
15593
15616
|
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15594
15617
|
return fromEnv;
|
|
15595
15618
|
}
|
|
15596
|
-
const current =
|
|
15597
|
-
const legacy =
|
|
15619
|
+
const current = path40.join(home, HOME_DIRNAME);
|
|
15620
|
+
const legacy = path40.join(home, LEGACY_HOME_DIRNAME);
|
|
15598
15621
|
return !isDirectory(current) && isDirectory(legacy) ? legacy : current;
|
|
15599
15622
|
}
|
|
15600
15623
|
function isExistingDirectory(candidate) {
|
|
@@ -15605,59 +15628,60 @@ function resolveClaudeHome() {
|
|
|
15605
15628
|
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
15606
15629
|
return fromEnv;
|
|
15607
15630
|
}
|
|
15608
|
-
return
|
|
15631
|
+
return path40.join(os6.homedir(), ".claude");
|
|
15609
15632
|
}
|
|
15610
15633
|
function buildLayoutPaths(root) {
|
|
15611
15634
|
return {
|
|
15612
15635
|
root,
|
|
15613
|
-
identitiesDir:
|
|
15614
|
-
configProfilesDir:
|
|
15615
|
-
providersDir:
|
|
15616
|
-
providerAliasesFile:
|
|
15617
|
-
directoryRulesFile:
|
|
15618
|
-
activeIdentityFile:
|
|
15619
|
-
globalConfigFile:
|
|
15620
|
-
categoriesLocalFile:
|
|
15621
|
-
claudeShimFile:
|
|
15622
|
-
headroomDir:
|
|
15623
|
-
headroomStateFile:
|
|
15624
|
-
headroomRoutingFile:
|
|
15625
|
-
headroomLegacyStateFile:
|
|
15626
|
-
headroomAllowlistFile:
|
|
15627
|
-
headroomSocketDir:
|
|
15628
|
-
headroomLockFile:
|
|
15629
|
-
headroomSessionsDir:
|
|
15630
|
-
logsDir:
|
|
15631
|
-
headroomLogPath:
|
|
15632
|
-
frontdoorDir:
|
|
15633
|
-
frontdoorCaDir:
|
|
15634
|
-
frontdoorCaCertFile:
|
|
15635
|
-
frontdoorCaKeyFile:
|
|
15636
|
-
frontdoorCaBundlesDir:
|
|
15637
|
-
chatgptSignInFile:
|
|
15638
|
-
frontdoorStateFile:
|
|
15639
|
-
frontdoorLockFile:
|
|
15640
|
-
frontdoorControlTokenFile:
|
|
15641
|
-
frontdoorSessionsDir:
|
|
15642
|
-
frontdoorDirectRecordsDir:
|
|
15643
|
-
frontdoorDrainingDir:
|
|
15644
|
-
frontdoorRcCredentialsDir:
|
|
15645
|
-
frontdoorLogPath:
|
|
15646
|
-
usageDir:
|
|
15647
|
-
usageLogDir:
|
|
15648
|
-
usageSnapshotsDir:
|
|
15649
|
-
statuslineDir:
|
|
15650
|
-
catalogueDir:
|
|
15651
|
-
usagePicksFile:
|
|
15652
|
-
usageAnchorsFile:
|
|
15653
|
-
usageJobsFile:
|
|
15654
|
-
jobLogsDir:
|
|
15655
|
-
identityRenamesDir:
|
|
15656
|
-
identityNameRenamesDir:
|
|
15657
|
-
launchesDir:
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
|
|
15636
|
+
identitiesDir: path40.join(root, "identities"),
|
|
15637
|
+
configProfilesDir: path40.join(root, "config-profiles"),
|
|
15638
|
+
providersDir: path40.join(root, "providers"),
|
|
15639
|
+
providerAliasesFile: path40.join(root, "provider-aliases.json"),
|
|
15640
|
+
directoryRulesFile: path40.join(root, "directory-rules.json"),
|
|
15641
|
+
activeIdentityFile: path40.join(root, "active-identity"),
|
|
15642
|
+
globalConfigFile: path40.join(root, "config.json"),
|
|
15643
|
+
categoriesLocalFile: path40.join(root, "categories.local.json"),
|
|
15644
|
+
claudeShimFile: path40.join(root, "claude-shim.json"),
|
|
15645
|
+
headroomDir: path40.join(root, "headroom"),
|
|
15646
|
+
headroomStateFile: path40.join(root, "headroom", "state.json"),
|
|
15647
|
+
headroomRoutingFile: path40.join(root, "headroom", "routing.json"),
|
|
15648
|
+
headroomLegacyStateFile: path40.join(root, "headroom", "state.v2.json"),
|
|
15649
|
+
headroomAllowlistFile: path40.join(root, "headroom", "run", "allowlist.txt"),
|
|
15650
|
+
headroomSocketDir: path40.join(root, "headroom", "run"),
|
|
15651
|
+
headroomLockFile: path40.join(root, "headroom", "start.lock"),
|
|
15652
|
+
headroomSessionsDir: path40.join(root, "headroom", "sessions"),
|
|
15653
|
+
logsDir: path40.join(root, "logs"),
|
|
15654
|
+
headroomLogPath: path40.join(root, "logs", "headroom.log"),
|
|
15655
|
+
frontdoorDir: path40.join(root, "frontdoor"),
|
|
15656
|
+
frontdoorCaDir: path40.join(root, "frontdoor", "ca"),
|
|
15657
|
+
frontdoorCaCertFile: path40.join(root, "frontdoor", "ca", "ca.pem"),
|
|
15658
|
+
frontdoorCaKeyFile: path40.join(root, "frontdoor", "ca", "ca.key"),
|
|
15659
|
+
frontdoorCaBundlesDir: path40.join(root, "frontdoor", "ca", "bundles"),
|
|
15660
|
+
chatgptSignInFile: path40.join(root, "codex", "chatgpt-sign-in.json"),
|
|
15661
|
+
frontdoorStateFile: path40.join(root, "frontdoor", "state.json"),
|
|
15662
|
+
frontdoorLockFile: path40.join(root, "frontdoor", "start.lock"),
|
|
15663
|
+
frontdoorControlTokenFile: path40.join(root, "frontdoor", "control-token"),
|
|
15664
|
+
frontdoorSessionsDir: path40.join(root, "frontdoor", "sessions"),
|
|
15665
|
+
frontdoorDirectRecordsDir: path40.join(root, "frontdoor", "direct"),
|
|
15666
|
+
frontdoorDrainingDir: path40.join(root, "frontdoor", "draining"),
|
|
15667
|
+
frontdoorRcCredentialsDir: path40.join(root, "frontdoor", "rc-credentials"),
|
|
15668
|
+
frontdoorLogPath: path40.join(root, "logs", "frontdoor.log"),
|
|
15669
|
+
usageDir: path40.join(root, "usage"),
|
|
15670
|
+
usageLogDir: path40.join(root, "usage", "log"),
|
|
15671
|
+
usageSnapshotsDir: path40.join(root, "usage", "snapshots"),
|
|
15672
|
+
statuslineDir: path40.join(root, "statusline"),
|
|
15673
|
+
catalogueDir: path40.join(root, "catalogues"),
|
|
15674
|
+
usagePicksFile: path40.join(root, "usage", "picks.json"),
|
|
15675
|
+
usageAnchorsFile: path40.join(root, "usage", "anchors.json"),
|
|
15676
|
+
usageJobsFile: path40.join(root, "usage", "jobs.json"),
|
|
15677
|
+
jobLogsDir: path40.join(root, "logs", "jobs"),
|
|
15678
|
+
identityRenamesDir: path40.join(root, "identity-renames"),
|
|
15679
|
+
identityNameRenamesDir: path40.join(root, "identity-name-renames"),
|
|
15680
|
+
launchesDir: path40.join(root, "launches"),
|
|
15681
|
+
launchControlDir: path40.join(root, "launch-control"),
|
|
15682
|
+
superviseDir: path40.join(root, "supervise"),
|
|
15683
|
+
modelMovesDir: path40.join(root, "model-moves"),
|
|
15684
|
+
mcpPermissionsFile: path40.join(root, "mcp", "permissions.json")
|
|
15661
15685
|
};
|
|
15662
15686
|
}
|
|
15663
15687
|
function resolveLayoutPaths() {
|
|
@@ -15671,7 +15695,7 @@ var init_paths = __esm({
|
|
|
15671
15695
|
});
|
|
15672
15696
|
|
|
15673
15697
|
// src/storedCatalogue.ts
|
|
15674
|
-
import
|
|
15698
|
+
import path42 from "node:path";
|
|
15675
15699
|
function catalogueReadFault(error) {
|
|
15676
15700
|
if (error instanceof UnreadableCatalogueError) {
|
|
15677
15701
|
return error.fault;
|
|
@@ -15680,10 +15704,10 @@ function catalogueReadFault(error) {
|
|
|
15680
15704
|
return typeof code === "string" && /^[A-Z0-9_]{1,32}$/u.test(code) ? code : error instanceof Error ? error.name : "an error";
|
|
15681
15705
|
}
|
|
15682
15706
|
function catalogueStatusFile(paths, owner, name) {
|
|
15683
|
-
return
|
|
15707
|
+
return path42.join(path42.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), `${name}.status.json`);
|
|
15684
15708
|
}
|
|
15685
15709
|
function catalogueFailureFile(paths, owner, name) {
|
|
15686
|
-
return
|
|
15710
|
+
return path42.join(path42.dirname(catalogueCachePath(paths, name, owner.pid, owner.generation)), "failures", `${name}.json`);
|
|
15687
15711
|
}
|
|
15688
15712
|
var UnreadableCatalogueError, skipUnreadableCatalogue, TolerantReader, StoredCatalogue;
|
|
15689
15713
|
var init_storedCatalogue = __esm({
|
|
@@ -15774,12 +15798,12 @@ var init_tolerantReaders = __esm({
|
|
|
15774
15798
|
});
|
|
15775
15799
|
|
|
15776
15800
|
// src/frontdoor/catalogueState.ts
|
|
15777
|
-
import { z as
|
|
15801
|
+
import { z as z33 } from "zod";
|
|
15778
15802
|
function readCatalogueFailure(fs17, paths, pid, generation, name) {
|
|
15779
15803
|
const raw = new StoredCatalogue(paths, skippingReader(fs17)).failureText({ pid, generation }, name);
|
|
15780
15804
|
if (raw === void 0) return void 0;
|
|
15781
15805
|
try {
|
|
15782
|
-
const value =
|
|
15806
|
+
const value = z33.strictObject({ reason: z33.string().max(CATALOGUE_FAILURE_REASON_MAX_CHARS), redirected: z33.literal(true).optional(), settings: z33.string().optional() }).safeParse(JSON.parse(raw));
|
|
15783
15807
|
return value.success ? { reason: value.data.reason, redirected: value.data.redirected === true, settings: value.data.settings } : void 0;
|
|
15784
15808
|
} catch {
|
|
15785
15809
|
return void 0;
|
|
@@ -15789,7 +15813,7 @@ function readCatalogueStatus(fs17, paths, pid, generation, name) {
|
|
|
15789
15813
|
const raw = new StoredCatalogue(paths, skippingReader(fs17)).statusText({ pid, generation }, name);
|
|
15790
15814
|
if (raw === void 0) return void 0;
|
|
15791
15815
|
try {
|
|
15792
|
-
const value =
|
|
15816
|
+
const value = z33.strictObject({ status: z33.enum(["running", "ready", "failed"]), fingerprint: z33.string().min(1).optional(), recordedAt: z33.number().optional() }).safeParse(JSON.parse(raw));
|
|
15793
15817
|
return value.success ? value.data : void 0;
|
|
15794
15818
|
} catch {
|
|
15795
15819
|
return void 0;
|
|
@@ -15806,25 +15830,25 @@ var init_catalogueState = __esm({
|
|
|
15806
15830
|
});
|
|
15807
15831
|
|
|
15808
15832
|
// src/codex/auth.ts
|
|
15809
|
-
import { z as
|
|
15833
|
+
import { z as z34 } from "zod";
|
|
15810
15834
|
var AuthFileSchema, TokenGrantSchema, CodexAuthError;
|
|
15811
15835
|
var init_auth = __esm({
|
|
15812
15836
|
"src/codex/auth.ts"() {
|
|
15813
15837
|
"use strict";
|
|
15814
|
-
AuthFileSchema =
|
|
15815
|
-
tokens:
|
|
15816
|
-
access_token:
|
|
15817
|
-
refresh_token:
|
|
15818
|
-
id_token:
|
|
15819
|
-
account_id:
|
|
15838
|
+
AuthFileSchema = z34.looseObject({
|
|
15839
|
+
tokens: z34.looseObject({
|
|
15840
|
+
access_token: z34.string().optional(),
|
|
15841
|
+
refresh_token: z34.string().optional(),
|
|
15842
|
+
id_token: z34.string().optional(),
|
|
15843
|
+
account_id: z34.string().optional()
|
|
15820
15844
|
}).nullish(),
|
|
15821
|
-
last_refresh:
|
|
15845
|
+
last_refresh: z34.string().optional()
|
|
15822
15846
|
});
|
|
15823
|
-
TokenGrantSchema =
|
|
15824
|
-
access_token:
|
|
15825
|
-
refresh_token:
|
|
15826
|
-
id_token:
|
|
15827
|
-
account_id:
|
|
15847
|
+
TokenGrantSchema = z34.looseObject({
|
|
15848
|
+
access_token: z34.string().min(1).optional(),
|
|
15849
|
+
refresh_token: z34.string().min(1).optional(),
|
|
15850
|
+
id_token: z34.string().min(1).optional(),
|
|
15851
|
+
account_id: z34.string().min(1).optional()
|
|
15828
15852
|
});
|
|
15829
15853
|
CodexAuthError = class extends Error {
|
|
15830
15854
|
constructor(message) {
|
|
@@ -15836,7 +15860,7 @@ var init_auth = __esm({
|
|
|
15836
15860
|
});
|
|
15837
15861
|
|
|
15838
15862
|
// src/codex/siwc.ts
|
|
15839
|
-
import { z as
|
|
15863
|
+
import { z as z35 } from "zod";
|
|
15840
15864
|
var SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
|
|
15841
15865
|
var init_siwc = __esm({
|
|
15842
15866
|
"src/codex/siwc.ts"() {
|
|
@@ -15844,28 +15868,28 @@ var init_siwc = __esm({
|
|
|
15844
15868
|
SIWC_RESOURCE = "https://api.openai.com/v1";
|
|
15845
15869
|
SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
|
|
15846
15870
|
SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
|
|
15847
|
-
TokenResponseSchema =
|
|
15848
|
-
access_token:
|
|
15849
|
-
refresh_token:
|
|
15850
|
-
id_token:
|
|
15851
|
-
expires_in:
|
|
15852
|
-
scope:
|
|
15871
|
+
TokenResponseSchema = z35.looseObject({
|
|
15872
|
+
access_token: z35.string().min(1),
|
|
15873
|
+
refresh_token: z35.string().min(1).optional(),
|
|
15874
|
+
id_token: z35.string().min(1).optional(),
|
|
15875
|
+
expires_in: z35.number().positive(),
|
|
15876
|
+
scope: z35.string().optional()
|
|
15853
15877
|
});
|
|
15854
|
-
JwtHeaderSchema =
|
|
15855
|
-
IdTokenClaimsSchema =
|
|
15856
|
-
iss:
|
|
15857
|
-
sub:
|
|
15858
|
-
aud:
|
|
15859
|
-
exp:
|
|
15860
|
-
nonce:
|
|
15861
|
-
email:
|
|
15878
|
+
JwtHeaderSchema = z35.looseObject({ alg: z35.string(), kid: z35.string().optional() });
|
|
15879
|
+
IdTokenClaimsSchema = z35.looseObject({
|
|
15880
|
+
iss: z35.string(),
|
|
15881
|
+
sub: z35.string().min(1),
|
|
15882
|
+
aud: z35.union([z35.string(), z35.array(z35.string())]),
|
|
15883
|
+
exp: z35.number(),
|
|
15884
|
+
nonce: z35.string().optional(),
|
|
15885
|
+
email: z35.string().optional()
|
|
15862
15886
|
});
|
|
15863
|
-
JwksSchema =
|
|
15887
|
+
JwksSchema = z35.object({ keys: z35.array(z35.looseObject({ kid: z35.string().optional(), kty: z35.string() })) });
|
|
15864
15888
|
}
|
|
15865
15889
|
});
|
|
15866
15890
|
|
|
15867
15891
|
// src/codex/siwcStore.ts
|
|
15868
|
-
import { z as
|
|
15892
|
+
import { z as z36 } from "zod";
|
|
15869
15893
|
function parseSiwcFile(raw, filePath) {
|
|
15870
15894
|
let json;
|
|
15871
15895
|
try {
|
|
@@ -15885,18 +15909,18 @@ var init_siwcStore = __esm({
|
|
|
15885
15909
|
"use strict";
|
|
15886
15910
|
init_auth();
|
|
15887
15911
|
init_siwc();
|
|
15888
|
-
SiwcGrantSchema =
|
|
15889
|
-
clientId:
|
|
15890
|
-
sub:
|
|
15891
|
-
email:
|
|
15892
|
-
idToken:
|
|
15893
|
-
accessToken:
|
|
15894
|
-
refreshToken:
|
|
15895
|
-
scopes:
|
|
15912
|
+
SiwcGrantSchema = z36.strictObject({
|
|
15913
|
+
clientId: z36.string().min(1),
|
|
15914
|
+
sub: z36.string().min(1),
|
|
15915
|
+
email: z36.string().optional(),
|
|
15916
|
+
idToken: z36.string().min(1),
|
|
15917
|
+
accessToken: z36.string().min(1),
|
|
15918
|
+
refreshToken: z36.string().min(1),
|
|
15919
|
+
scopes: z36.array(z36.string()).readonly(),
|
|
15896
15920
|
/** When the access token stops working, in milliseconds since the epoch. */
|
|
15897
|
-
expiresAt:
|
|
15921
|
+
expiresAt: z36.number()
|
|
15898
15922
|
});
|
|
15899
|
-
SiwcFileSchema =
|
|
15923
|
+
SiwcFileSchema = z36.strictObject({ registeredClientId: z36.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
|
|
15900
15924
|
}
|
|
15901
15925
|
});
|
|
15902
15926
|
|
|
@@ -15955,8 +15979,8 @@ var init_modelsStore = __esm({
|
|
|
15955
15979
|
|
|
15956
15980
|
// src/codex/catalogueCredential.ts
|
|
15957
15981
|
import { createHash as createHash11 } from "node:crypto";
|
|
15958
|
-
import
|
|
15959
|
-
import { z as
|
|
15982
|
+
import path43 from "node:path";
|
|
15983
|
+
import { z as z37 } from "zod";
|
|
15960
15984
|
function parseCatalogueBinding(raw) {
|
|
15961
15985
|
if (raw === void 0) return void 0;
|
|
15962
15986
|
try {
|
|
@@ -15989,15 +16013,15 @@ function signInCatalogueFingerprint(raw, filePath) {
|
|
|
15989
16013
|
function savedCatalogueFingerprint(provider, paths, env, home, reader) {
|
|
15990
16014
|
if (provider.codex?.login === "chatgpt-sign-in") return signInCatalogueFingerprint(reader.read(paths.chatgptSignInFile), paths.chatgptSignInFile);
|
|
15991
16015
|
const configuredHome = env.CODEX_HOME;
|
|
15992
|
-
const codexHome = configuredHome === void 0 || configuredHome === "" ?
|
|
15993
|
-
return cliCatalogueFingerprint(reader.read(
|
|
16016
|
+
const codexHome = configuredHome === void 0 || configuredHome === "" ? path43.join(home, ".codex") : configuredHome;
|
|
16017
|
+
return cliCatalogueFingerprint(reader.read(path43.join(codexHome, "auth.json")));
|
|
15994
16018
|
}
|
|
15995
16019
|
var CatalogueBindingSchema;
|
|
15996
16020
|
var init_catalogueCredential = __esm({
|
|
15997
16021
|
"src/codex/catalogueCredential.ts"() {
|
|
15998
16022
|
"use strict";
|
|
15999
16023
|
init_siwcStore();
|
|
16000
|
-
CatalogueBindingSchema =
|
|
16024
|
+
CatalogueBindingSchema = z37.strictObject({ fingerprint: z37.string().min(1), source: z37.string().min(1), revision: z37.string().min(1) });
|
|
16001
16025
|
}
|
|
16002
16026
|
});
|
|
16003
16027
|
|
|
@@ -16048,64 +16072,64 @@ var init_signatures = __esm({
|
|
|
16048
16072
|
});
|
|
16049
16073
|
|
|
16050
16074
|
// src/codex/anthropic.ts
|
|
16051
|
-
import { z as
|
|
16075
|
+
import { z as z38 } from "zod";
|
|
16052
16076
|
var TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
|
|
16053
16077
|
var init_anthropic = __esm({
|
|
16054
16078
|
"src/codex/anthropic.ts"() {
|
|
16055
16079
|
"use strict";
|
|
16056
|
-
TextBlockSchema =
|
|
16057
|
-
Base64ImageSourceSchema =
|
|
16058
|
-
UrlImageSourceSchema =
|
|
16059
|
-
ImageBlockSchema =
|
|
16060
|
-
type:
|
|
16061
|
-
source:
|
|
16080
|
+
TextBlockSchema = z38.looseObject({ type: z38.literal("text"), text: z38.string() });
|
|
16081
|
+
Base64ImageSourceSchema = z38.looseObject({ type: z38.literal("base64"), media_type: z38.string().min(1), data: z38.string() });
|
|
16082
|
+
UrlImageSourceSchema = z38.looseObject({ type: z38.literal("url"), url: z38.string().min(1) });
|
|
16083
|
+
ImageBlockSchema = z38.looseObject({
|
|
16084
|
+
type: z38.literal("image"),
|
|
16085
|
+
source: z38.union([Base64ImageSourceSchema, UrlImageSourceSchema])
|
|
16062
16086
|
});
|
|
16063
|
-
ToolUseBlockSchema =
|
|
16064
|
-
type:
|
|
16065
|
-
id:
|
|
16066
|
-
name:
|
|
16067
|
-
input:
|
|
16087
|
+
ToolUseBlockSchema = z38.looseObject({
|
|
16088
|
+
type: z38.literal("tool_use"),
|
|
16089
|
+
id: z38.string().min(1),
|
|
16090
|
+
name: z38.string().min(1),
|
|
16091
|
+
input: z38.unknown()
|
|
16068
16092
|
});
|
|
16069
|
-
ToolResultContentBlockSchema =
|
|
16070
|
-
ToolResultBlockSchema =
|
|
16071
|
-
type:
|
|
16072
|
-
tool_use_id:
|
|
16073
|
-
content:
|
|
16093
|
+
ToolResultContentBlockSchema = z38.union([TextBlockSchema, z38.looseObject({ type: z38.string() })]);
|
|
16094
|
+
ToolResultBlockSchema = z38.looseObject({
|
|
16095
|
+
type: z38.literal("tool_result"),
|
|
16096
|
+
tool_use_id: z38.string().min(1),
|
|
16097
|
+
content: z38.union([z38.string(), z38.array(ToolResultContentBlockSchema)]).optional()
|
|
16074
16098
|
});
|
|
16075
|
-
OtherBlockSchema =
|
|
16076
|
-
ContentBlockSchema =
|
|
16077
|
-
MessageSchema =
|
|
16078
|
-
role:
|
|
16079
|
-
content:
|
|
16099
|
+
OtherBlockSchema = z38.looseObject({ type: z38.string() });
|
|
16100
|
+
ContentBlockSchema = z38.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
|
|
16101
|
+
MessageSchema = z38.looseObject({
|
|
16102
|
+
role: z38.enum(["user", "assistant", "system"]),
|
|
16103
|
+
content: z38.union([z38.string(), z38.array(ContentBlockSchema)])
|
|
16080
16104
|
});
|
|
16081
|
-
ToolSchema =
|
|
16082
|
-
name:
|
|
16083
|
-
description:
|
|
16084
|
-
input_schema:
|
|
16085
|
-
allowed_domains:
|
|
16086
|
-
blocked_domains:
|
|
16105
|
+
ToolSchema = z38.looseObject({
|
|
16106
|
+
name: z38.string().min(1),
|
|
16107
|
+
description: z38.string().optional(),
|
|
16108
|
+
input_schema: z38.record(z38.string(), z38.unknown()).optional(),
|
|
16109
|
+
allowed_domains: z38.array(z38.string()).optional(),
|
|
16110
|
+
blocked_domains: z38.array(z38.string()).optional()
|
|
16087
16111
|
});
|
|
16088
|
-
ToolChoiceSchema =
|
|
16089
|
-
|
|
16090
|
-
|
|
16112
|
+
ToolChoiceSchema = z38.union([
|
|
16113
|
+
z38.looseObject({ type: z38.enum(["auto", "none", "any"]) }),
|
|
16114
|
+
z38.looseObject({ type: z38.literal("tool"), name: z38.string().min(1) })
|
|
16091
16115
|
]);
|
|
16092
|
-
SystemSchema =
|
|
16093
|
-
MessagesRequestSchema =
|
|
16094
|
-
model:
|
|
16116
|
+
SystemSchema = z38.union([z38.string(), z38.array(z38.union([TextBlockSchema, OtherBlockSchema]))]);
|
|
16117
|
+
MessagesRequestSchema = z38.looseObject({
|
|
16118
|
+
model: z38.string().optional(),
|
|
16095
16119
|
system: SystemSchema.optional(),
|
|
16096
|
-
messages:
|
|
16097
|
-
tools:
|
|
16120
|
+
messages: z38.array(MessageSchema),
|
|
16121
|
+
tools: z38.array(ToolSchema).optional(),
|
|
16098
16122
|
tool_choice: ToolChoiceSchema.optional(),
|
|
16099
|
-
stream:
|
|
16123
|
+
stream: z38.boolean().optional(),
|
|
16100
16124
|
/** `user_id` is stable for one Claude Code session and differs between sessions, which is what makes it the right key for both the backend's prompt cache and its session header. */
|
|
16101
|
-
metadata:
|
|
16125
|
+
metadata: z38.looseObject({ user_id: z38.string().optional() }).optional(),
|
|
16102
16126
|
/** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
|
|
16103
|
-
output_config:
|
|
16127
|
+
output_config: z38.looseObject({ effort: z38.string().optional(), format: z38.object({ type: z38.literal("json_schema"), schema: z38.record(z38.string(), z38.unknown()) }).optional() }).optional()
|
|
16104
16128
|
});
|
|
16105
|
-
CountTokensRequestSchema =
|
|
16106
|
-
system:
|
|
16107
|
-
messages:
|
|
16108
|
-
tools:
|
|
16129
|
+
CountTokensRequestSchema = z38.looseObject({
|
|
16130
|
+
system: z38.unknown().optional(),
|
|
16131
|
+
messages: z38.unknown().optional(),
|
|
16132
|
+
tools: z38.unknown().optional()
|
|
16109
16133
|
});
|
|
16110
16134
|
}
|
|
16111
16135
|
});
|
|
@@ -17006,7 +17030,7 @@ var init_settings2 = __esm({
|
|
|
17006
17030
|
});
|
|
17007
17031
|
|
|
17008
17032
|
// src/launcher/flags.ts
|
|
17009
|
-
import
|
|
17033
|
+
import path51 from "node:path";
|
|
17010
17034
|
function resolveLaunchFlags(params) {
|
|
17011
17035
|
const statusline = resolveStatuslineSettings(params);
|
|
17012
17036
|
return {
|
|
@@ -17065,7 +17089,7 @@ function buildEnv(params) {
|
|
|
17065
17089
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
17066
17090
|
let providerCustomHeaders;
|
|
17067
17091
|
if (!params.configDirEscapeHatch && params.identityId !== void 0) {
|
|
17068
|
-
env.CLAUDE_CONFIG_DIR =
|
|
17092
|
+
env.CLAUDE_CONFIG_DIR = path51.join(params.identitiesDir, params.identityId);
|
|
17069
17093
|
}
|
|
17070
17094
|
if (params.provider !== void 0) {
|
|
17071
17095
|
const providerEnv = params.provider.definition.kind !== void 0 && params.provider.definition.kind !== "http" ? {} : params.provider.definition.env ?? {};
|
|
@@ -17181,7 +17205,7 @@ var init_extraFlags = __esm({
|
|
|
17181
17205
|
});
|
|
17182
17206
|
|
|
17183
17207
|
// src/usage/resumeContext.ts
|
|
17184
|
-
import
|
|
17208
|
+
import path52 from "node:path";
|
|
17185
17209
|
function projectDirNameOf(cwd) {
|
|
17186
17210
|
return cwd.replace(/[^A-Za-z0-9]/g, "-");
|
|
17187
17211
|
}
|
|
@@ -17239,7 +17263,7 @@ function newestTranscript(fs17, projectDir) {
|
|
|
17239
17263
|
if (!name.endsWith(".jsonl")) {
|
|
17240
17264
|
continue;
|
|
17241
17265
|
}
|
|
17242
|
-
const candidate =
|
|
17266
|
+
const candidate = path52.join(projectDir, name);
|
|
17243
17267
|
const stat = fs17.lstat(candidate);
|
|
17244
17268
|
if (stat?.kind === "file" && stat.mtimeMs > newestMs) {
|
|
17245
17269
|
newestMs = stat.mtimeMs;
|
|
@@ -17253,8 +17277,8 @@ function resumedContextTokens(fs17, params) {
|
|
|
17253
17277
|
if (target === void 0) {
|
|
17254
17278
|
return void 0;
|
|
17255
17279
|
}
|
|
17256
|
-
const projectDir =
|
|
17257
|
-
const file = target.kind === "id" ?
|
|
17280
|
+
const projectDir = path52.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
|
|
17281
|
+
const file = target.kind === "id" ? path52.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs17, projectDir);
|
|
17258
17282
|
const text = file === void 0 ? void 0 : fs17.readFileUtf8(file);
|
|
17259
17283
|
return text === void 0 ? void 0 : contextTokensOfTranscript(text);
|
|
17260
17284
|
}
|
|
@@ -17795,6 +17819,235 @@ var init_spawn = __esm({
|
|
|
17795
17819
|
}
|
|
17796
17820
|
});
|
|
17797
17821
|
|
|
17822
|
+
// src/supervise/sessionControlPlugin.ts
|
|
17823
|
+
import { lstatSync, mkdtempSync, mkdirSync as mkdirSync2, readdirSync, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
17824
|
+
import { tmpdir } from "node:os";
|
|
17825
|
+
import path53 from "node:path";
|
|
17826
|
+
function removeAbandonedPlugins(parent, isRunning) {
|
|
17827
|
+
const uid = process.getuid?.();
|
|
17828
|
+
for (const name of readdirSync(parent)) {
|
|
17829
|
+
const pid = Number(/^agent-shim-control-(\d+)-/u.exec(name)?.[1]);
|
|
17830
|
+
if (!name.startsWith(STAGED_PREFIX) || !Number.isInteger(pid) || isRunning(pid)) {
|
|
17831
|
+
continue;
|
|
17832
|
+
}
|
|
17833
|
+
const entry = path53.join(parent, name);
|
|
17834
|
+
const stat = lstatSync(entry, { throwIfNoEntry: false });
|
|
17835
|
+
if (stat?.isDirectory() === true && (uid === void 0 || stat.uid === uid)) {
|
|
17836
|
+
rmSync(entry, { recursive: true, force: true });
|
|
17837
|
+
}
|
|
17838
|
+
}
|
|
17839
|
+
}
|
|
17840
|
+
function stageSessionControlPlugin(options = {}) {
|
|
17841
|
+
const parent = options.parent ?? tmpdir();
|
|
17842
|
+
removeAbandonedPlugins(parent, options.isRunning ?? realIsProcessRunning);
|
|
17843
|
+
const directory = mkdtempSync(path53.join(parent, `${STAGED_PREFIX}${String(options.pid ?? process.pid)}-`));
|
|
17844
|
+
const { ready, session, requests, results } = sessionControlPluginPaths(directory);
|
|
17845
|
+
try {
|
|
17846
|
+
mkdirSync2(path53.join(directory, ".claude-plugin"), { mode: 448 });
|
|
17847
|
+
mkdirSync2(path53.join(directory, "hooks"), { mode: 448 });
|
|
17848
|
+
mkdirSync2(requests, { mode: 448 });
|
|
17849
|
+
mkdirSync2(results, { mode: 448 });
|
|
17850
|
+
writeFileSync2(path53.join(directory, ".claude-plugin", "plugin.json"), JSON.stringify({ name: SESSION_CONTROL_PLUGIN_NAME, version: "2.1.0", description: "Compacts, sets goals and submits a person's turns in sessions agent-shim launched, in process" }), { mode: 384 });
|
|
17851
|
+
writeFileSync2(path53.join(directory, "hooks", "hooks.json"), JSON.stringify({ modules: ["./register.js"] }), { mode: 384 });
|
|
17852
|
+
writeFileSync2(path53.join(directory, "hooks", "register.js"), pluginSource(ready, session, requests, results), { mode: 384 });
|
|
17853
|
+
return { directory, ready, session, requests, results, release: () => {
|
|
17854
|
+
rmSync(directory, { recursive: true, force: true });
|
|
17855
|
+
} };
|
|
17856
|
+
} catch (error) {
|
|
17857
|
+
rmSync(directory, { recursive: true, force: true });
|
|
17858
|
+
throw error;
|
|
17859
|
+
}
|
|
17860
|
+
}
|
|
17861
|
+
function sessionControlPluginPaths(directory) {
|
|
17862
|
+
return { directory, ready: path53.join(directory, "ready.json"), session: path53.join(directory, "session.json"), requests: path53.join(directory, "requests"), results: path53.join(directory, "results") };
|
|
17863
|
+
}
|
|
17864
|
+
function pluginSource(ready, session, requests, results) {
|
|
17865
|
+
return `const REQUESTS = ${JSON.stringify(requests)};
|
|
17866
|
+
const RESULTS = ${JSON.stringify(results)};
|
|
17867
|
+
function compacted(id, value) {
|
|
17868
|
+
return { id, ...(typeof value?.skip === 'string' ? { kind: 'unchanged', skip: value.skip } : { kind: 'compacted', tokensBefore: value?.tokensBefore, tokensAfter: value?.tokensAfter }) };
|
|
17869
|
+
}
|
|
17870
|
+
async function resultNames($) {
|
|
17871
|
+
return new Set((await $.fs.list(RESULTS)).map((entry) => entry.name));
|
|
17872
|
+
}
|
|
17873
|
+
async function recordSession($, event, next) {
|
|
17874
|
+
const answer = await next(event);
|
|
17875
|
+
if (typeof event?.session_id === 'string' && typeof event?.transcript_path === 'string') {
|
|
17876
|
+
const record = JSON.stringify({ conversationId: event.session_id, transcriptPath: event.transcript_path });
|
|
17877
|
+
$.clock.after(0, async () => {
|
|
17878
|
+
await $.fs.write(${JSON.stringify(session)}, record);
|
|
17879
|
+
});
|
|
17880
|
+
}
|
|
17881
|
+
return answer;
|
|
17882
|
+
}
|
|
17883
|
+
export function register(on) {
|
|
17884
|
+
let running = false;
|
|
17885
|
+
on('classic.SessionStart', recordSession);
|
|
17886
|
+
on('classic.UserPromptSubmit', recordSession);
|
|
17887
|
+
on('classic.Stop', recordSession);
|
|
17888
|
+
on('classic.PostCompact', async ($, event, next) => {
|
|
17889
|
+
const answer = await next(event);
|
|
17890
|
+
$.clock.after(0, async () => {
|
|
17891
|
+
for (const name of await resultNames($)) {
|
|
17892
|
+
const text = await $.fs.read(RESULTS + '/' + name);
|
|
17893
|
+
if (typeof text !== 'string') continue;
|
|
17894
|
+
const current = JSON.parse(text);
|
|
17895
|
+
if (current.kind === 'running' && current.op === 'compact' && typeof current.id === 'string') {
|
|
17896
|
+
await $.fs.write(RESULTS + '/' + name, JSON.stringify({ id: current.id, kind: 'compacted' }));
|
|
17897
|
+
}
|
|
17898
|
+
}
|
|
17899
|
+
});
|
|
17900
|
+
return answer;
|
|
17901
|
+
});
|
|
17902
|
+
on('session.start', async ($, event, next) => {
|
|
17903
|
+
const answer = await next(event);
|
|
17904
|
+
const version = await $.session.version();
|
|
17905
|
+
await $.fs.write(${JSON.stringify(ready)}, JSON.stringify({ ready: true, version: version.version }));
|
|
17906
|
+
$.clock.every(1000, async () => {
|
|
17907
|
+
if (running) return;
|
|
17908
|
+
running = true;
|
|
17909
|
+
try {
|
|
17910
|
+
const done = await resultNames($);
|
|
17911
|
+
const names = (await $.fs.list(REQUESTS)).map((entry) => entry.name).filter((name) => !name.startsWith('.') && name.endsWith('.json') && !done.has(name)).sort();
|
|
17912
|
+
const name = names[0];
|
|
17913
|
+
if (name === undefined) return;
|
|
17914
|
+
const text = await $.fs.read(REQUESTS + '/' + name);
|
|
17915
|
+
if (typeof text !== 'string') return;
|
|
17916
|
+
const item = JSON.parse(text);
|
|
17917
|
+
if (typeof item.id !== 'string' || name !== item.id + '.json') {
|
|
17918
|
+
await $.fs.write(RESULTS + '/' + name, JSON.stringify({ id: name.slice(0, -5), error: 'the request is not one this plugin reads' }));
|
|
17919
|
+
return;
|
|
17920
|
+
}
|
|
17921
|
+
await $.fs.write(RESULTS + '/' + name, JSON.stringify({ id: item.id, kind: 'running', op: item.op }));
|
|
17922
|
+
let response;
|
|
17923
|
+
try {
|
|
17924
|
+
if (typeof item.expiresAt !== 'number' || await $.clock.now() >= item.expiresAt) throw new Error('the request expired before the session could run it, so it was not run');
|
|
17925
|
+
if (typeof item.conversationId !== 'string' || await $.session.id() !== item.conversationId) throw new Error('the conversation changed before the request ran');
|
|
17926
|
+
if (item.op === 'compact') {
|
|
17927
|
+
response = compacted(item.id, await $.session.compact(typeof item.instructions === 'string' ? { instructions: item.instructions } : {}));
|
|
17928
|
+
} else if (item.op === 'goal' && typeof item.args === 'string' && item.args.trim() !== '') {
|
|
17929
|
+
const ran = await $.command.run({ command: 'goal', args: item.args });
|
|
17930
|
+
response = { id: item.id, kind: 'ran', ...(typeof ran?.text === 'string' ? { text: ran.text } : {}) };
|
|
17931
|
+
} else if (item.op === 'turn' && typeof item.text === 'string' && item.text.trim() !== '') {
|
|
17932
|
+
const submitted = await $.prompt.submit({ text: item.text, asUser: true });
|
|
17933
|
+
if (typeof submitted?.drop === 'string') throw new Error('a hook dropped the prompt: ' + submitted.drop);
|
|
17934
|
+
response = { id: item.id, kind: 'submitted', text: submitted?.text, origin: submitted?.origin };
|
|
17935
|
+
} else {
|
|
17936
|
+
throw new Error('the request names no operation this plugin performs');
|
|
17937
|
+
}
|
|
17938
|
+
} catch (error) {
|
|
17939
|
+
response = { id: item.id, error: error instanceof Error ? error.message : String(error) };
|
|
17940
|
+
}
|
|
17941
|
+
await $.fs.write(RESULTS + '/' + name, JSON.stringify(response));
|
|
17942
|
+
} finally {
|
|
17943
|
+
running = false;
|
|
17944
|
+
}
|
|
17945
|
+
});
|
|
17946
|
+
return answer;
|
|
17947
|
+
});
|
|
17948
|
+
}
|
|
17949
|
+
`;
|
|
17950
|
+
}
|
|
17951
|
+
function withSessionControlPlugin(args, directory) {
|
|
17952
|
+
const end = args.indexOf("--");
|
|
17953
|
+
const result = [...args];
|
|
17954
|
+
result.splice(end === -1 ? result.length : end, 0, "--plugin-dir", directory);
|
|
17955
|
+
return result;
|
|
17956
|
+
}
|
|
17957
|
+
var SESSION_CONTROL_PLUGIN_NAME, STAGED_PREFIX;
|
|
17958
|
+
var init_sessionControlPlugin = __esm({
|
|
17959
|
+
"src/supervise/sessionControlPlugin.ts"() {
|
|
17960
|
+
"use strict";
|
|
17961
|
+
init_realPorts();
|
|
17962
|
+
SESSION_CONTROL_PLUGIN_NAME = "agent-shim-control";
|
|
17963
|
+
STAGED_PREFIX = "agent-shim-control-";
|
|
17964
|
+
}
|
|
17965
|
+
});
|
|
17966
|
+
|
|
17967
|
+
// src/supervise/launchControl.ts
|
|
17968
|
+
import path54 from "node:path";
|
|
17969
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
17970
|
+
import { z as z49 } from "zod";
|
|
17971
|
+
function readRecord2(fs17, directory, name) {
|
|
17972
|
+
if (!name.endsWith(RECORD_SUFFIX3)) {
|
|
17973
|
+
return void 0;
|
|
17974
|
+
}
|
|
17975
|
+
const raw = fs17.readFileUtf8(path54.join(directory, name));
|
|
17976
|
+
if (raw === void 0) {
|
|
17977
|
+
return void 0;
|
|
17978
|
+
}
|
|
17979
|
+
try {
|
|
17980
|
+
const parsed = LaunchControlSchema.safeParse(JSON.parse(raw));
|
|
17981
|
+
return parsed.success ? parsed.data : void 0;
|
|
17982
|
+
} catch {
|
|
17983
|
+
return void 0;
|
|
17984
|
+
}
|
|
17985
|
+
}
|
|
17986
|
+
function registerLaunchControl(fs17, directory, control, isRunning) {
|
|
17987
|
+
fs17.mkdirPrivate(directory);
|
|
17988
|
+
for (const name of fs17.readdir(directory)) {
|
|
17989
|
+
const record = readRecord2(fs17, directory, name);
|
|
17990
|
+
if (record !== void 0 && !isRunning(record.pid)) {
|
|
17991
|
+
fs17.removeRecursive(path54.join(directory, name));
|
|
17992
|
+
}
|
|
17993
|
+
}
|
|
17994
|
+
const file = path54.join(directory, `${String(control.pid)}.${randomUUID6()}${RECORD_SUFFIX3}`);
|
|
17995
|
+
fs17.writeFilePrivate(file, `${JSON.stringify(LaunchControlSchema.parse(control))}
|
|
17996
|
+
`);
|
|
17997
|
+
return () => {
|
|
17998
|
+
fs17.removeRecursive(file);
|
|
17999
|
+
};
|
|
18000
|
+
}
|
|
18001
|
+
function launchLoadsControlPlugin(candidate) {
|
|
18002
|
+
const end = candidate.args.indexOf("--");
|
|
18003
|
+
const options = end === -1 ? candidate.args : candidate.args.slice(0, end);
|
|
18004
|
+
return !candidate.supervised && candidate.startsSession && !options.includes("--bare") && candidate.version !== void 0 && RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(candidate.version);
|
|
18005
|
+
}
|
|
18006
|
+
function stageControlPluginFor(candidate, stage, warn) {
|
|
18007
|
+
if (stage === void 0 || !launchLoadsControlPlugin(candidate)) {
|
|
18008
|
+
return void 0;
|
|
18009
|
+
}
|
|
18010
|
+
try {
|
|
18011
|
+
return stage();
|
|
18012
|
+
} catch (error) {
|
|
18013
|
+
warn(`agent-shim: the in-process control plugin could not be staged, so this session starts without it and the front door cannot reach it for goal, compaction and turn control: ${error instanceof Error ? error.message : String(error)}`);
|
|
18014
|
+
return void 0;
|
|
18015
|
+
}
|
|
18016
|
+
}
|
|
18017
|
+
function stageLaunchControl(params) {
|
|
18018
|
+
const plugin = stageSessionControlPlugin({ pid: params.pid, isRunning: params.isRunning, ...params.parent === void 0 ? {} : { parent: params.parent } });
|
|
18019
|
+
let unregister;
|
|
18020
|
+
try {
|
|
18021
|
+
unregister = registerLaunchControl(params.fs, params.paths.launchControlDir, { pid: params.pid, directory: plugin.directory }, params.isRunning);
|
|
18022
|
+
} catch (error) {
|
|
18023
|
+
plugin.release();
|
|
18024
|
+
throw error;
|
|
18025
|
+
}
|
|
18026
|
+
return {
|
|
18027
|
+
args: (args) => withSessionControlPlugin(args, plugin.directory),
|
|
18028
|
+
release: () => {
|
|
18029
|
+
unregister();
|
|
18030
|
+
plugin.release();
|
|
18031
|
+
}
|
|
18032
|
+
};
|
|
18033
|
+
}
|
|
18034
|
+
var LaunchControlSchema, RECORD_SUFFIX3;
|
|
18035
|
+
var init_launchControl = __esm({
|
|
18036
|
+
"src/supervise/launchControl.ts"() {
|
|
18037
|
+
"use strict";
|
|
18038
|
+
init_sessionControl();
|
|
18039
|
+
init_sessionControlPlugin();
|
|
18040
|
+
init_verifiedVersions();
|
|
18041
|
+
LaunchControlSchema = z49.strictObject({
|
|
18042
|
+
/** The launcher's process id, which tells a live channel from one a killed launcher left. */
|
|
18043
|
+
pid: z49.number().int().positive(),
|
|
18044
|
+
/** The plugin's directory, its request and result files beneath it. */
|
|
18045
|
+
directory: z49.string().min(1)
|
|
18046
|
+
});
|
|
18047
|
+
RECORD_SUFFIX3 = ".json";
|
|
18048
|
+
}
|
|
18049
|
+
});
|
|
18050
|
+
|
|
17798
18051
|
// src/update/launchHook.ts
|
|
17799
18052
|
function resolveUpdateMode(globalConfig) {
|
|
17800
18053
|
return globalConfig?.update?.mode ?? "off";
|
|
@@ -17865,10 +18118,10 @@ var init_launchHook = __esm({
|
|
|
17865
18118
|
});
|
|
17866
18119
|
|
|
17867
18120
|
// src/launcher.ts
|
|
17868
|
-
import { randomUUID as
|
|
18121
|
+
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
17869
18122
|
import os10 from "node:os";
|
|
17870
18123
|
import { isDeepStrictEqual } from "node:util";
|
|
17871
|
-
import
|
|
18124
|
+
import path55 from "node:path";
|
|
17872
18125
|
function resolveIdentityCredential(identity, credential, env, port) {
|
|
17873
18126
|
if (port === void 0) {
|
|
17874
18127
|
return { ok: false, status: 1, message: `agent-shim: identity ${identity.name} needs its credential resolved, but this launcher has no credential port wired` };
|
|
@@ -17970,7 +18223,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
17970
18223
|
const farmIdentity = configDirEscapeHatchApplies || identityDecision.name === void 0 ? void 0 : resolveIdentityId(paths.identitiesDir, identityDecision.name, fs17);
|
|
17971
18224
|
const farm = farmIdentity === void 0 ? void 0 : params.farm;
|
|
17972
18225
|
if (!readOnly && params.supervised?.member === void 0 && farmIdentity !== void 0 && identityDecision.name !== void 0) {
|
|
17973
|
-
warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name,
|
|
18226
|
+
warnOfSupersededConfigDir(log.warn, fs17, identityDecision.supersededConfigDir, identityDecision.name, path55.join(paths.identitiesDir, farmIdentity));
|
|
17974
18227
|
}
|
|
17975
18228
|
if (!readOnly && farm !== void 0 && farmIdentity !== void 0) {
|
|
17976
18229
|
try {
|
|
@@ -18164,8 +18417,8 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
18164
18417
|
if (definition.kind === "codex" && readOnly && cache !== void 0) {
|
|
18165
18418
|
const binding = parseCatalogueBinding(stored.bindingText(name, owner));
|
|
18166
18419
|
const configuredHome = catalogueEnv.CODEX_HOME;
|
|
18167
|
-
const home = configuredHome === void 0 || configuredHome === "" ?
|
|
18168
|
-
const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile :
|
|
18420
|
+
const home = configuredHome === void 0 || configuredHome === "" ? path55.join(os10.homedir(), ".codex") : configuredHome;
|
|
18421
|
+
const source = definition.codex?.login === "chatgpt-sign-in" ? paths.chatgptSignInFile : path55.resolve(home, "auth.json");
|
|
18169
18422
|
const revision = params.fs.fileRevision?.(source);
|
|
18170
18423
|
if (binding === void 0 || binding.fingerprint !== cache.credentialFingerprint || binding.source !== source || revision === void 0 || revision !== binding.revision) return [];
|
|
18171
18424
|
}
|
|
@@ -18187,7 +18440,7 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
18187
18440
|
return { args: args2, pickerSuppressed: startsSession && pickerSettings !== void 0 && callerSettings };
|
|
18188
18441
|
};
|
|
18189
18442
|
const args = argsForSupervisor().args;
|
|
18190
|
-
const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR :
|
|
18443
|
+
const configDir = configDirEscapeHatchApplies || farmIdentity === void 0 ? env.CLAUDE_CONFIG_DIR : path55.join(paths.identitiesDir, farmIdentity);
|
|
18191
18444
|
const decision = {
|
|
18192
18445
|
identitySource: identityDecision.source,
|
|
18193
18446
|
configDirEscapeHatch: identityDecision.configDirEscapeHatch,
|
|
@@ -18227,6 +18480,8 @@ function decideLaunch(params, readOnly, onRecorded) {
|
|
|
18227
18480
|
models,
|
|
18228
18481
|
globalModels,
|
|
18229
18482
|
bin: discovered.path,
|
|
18483
|
+
binVersion: discovered.version,
|
|
18484
|
+
startsSession,
|
|
18230
18485
|
args,
|
|
18231
18486
|
argsForSupervisor,
|
|
18232
18487
|
decision
|
|
@@ -18283,7 +18538,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18283
18538
|
let warnings = [];
|
|
18284
18539
|
const updateCheck = runLaunchUpdateCheck({
|
|
18285
18540
|
mode: params.updateMode ?? "off",
|
|
18286
|
-
checkPath:
|
|
18541
|
+
checkPath: path55.join(paths.root, "update.check"),
|
|
18287
18542
|
currentVersion: package_default.version,
|
|
18288
18543
|
port: params.update
|
|
18289
18544
|
});
|
|
@@ -18306,7 +18561,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18306
18561
|
classification: resyncFarmRuntime.classification,
|
|
18307
18562
|
now: resyncFarmRuntime.now,
|
|
18308
18563
|
uniqueSuffix: resyncFarmRuntime.uniqueSuffix,
|
|
18309
|
-
identityExists: () => params.fs.readConfigFile(
|
|
18564
|
+
identityExists: () => params.fs.readConfigFile(path55.join(paths.identitiesDir, resyncIdentity, IDENTITY_FILE)) !== void 0,
|
|
18310
18565
|
lock: resyncFarmRuntime.lock
|
|
18311
18566
|
});
|
|
18312
18567
|
} catch (error) {
|
|
@@ -18340,7 +18595,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18340
18595
|
log.error("agent-shim: this launch routes through the front-door daemon, but this launcher has no front-door port wired; refusing to launch without it.");
|
|
18341
18596
|
proc.exit(1);
|
|
18342
18597
|
}
|
|
18343
|
-
const sessionId = params.supervised?.sessionId ??
|
|
18598
|
+
const sessionId = params.supervised?.sessionId ?? randomUUID7();
|
|
18344
18599
|
const resolvedModels = decided.models ?? (decided.globalModels === void 0 ? void 0 : {});
|
|
18345
18600
|
const sessionModels = isDeepStrictEqual(resolvedModels, decided.globalModels) ? void 0 : resolvedModels;
|
|
18346
18601
|
const session = { sessionId, ...decided.farmIdentity === void 0 ? {} : { identity: decided.farmIdentity }, ...sessionModels === void 0 ? {} : { models: sessionModels } };
|
|
@@ -18385,16 +18640,17 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18385
18640
|
proxyBypass: resolvedFlags.proxyBypass,
|
|
18386
18641
|
...resolvedFlags.statusline === void 0 ? {} : { statusline: resolvedFlags.statusline }
|
|
18387
18642
|
});
|
|
18388
|
-
const
|
|
18643
|
+
const picker = decided.argsForSupervisor(frontDoor?.supervisorPid);
|
|
18644
|
+
const control = stageControlPluginFor({ args: picker.args, version: decided.binVersion, startsSession: decided.startsSession, supervised: params.supervised !== void 0 }, params.stageControlPlugin, log.warn);
|
|
18645
|
+
const releases = [...unregisterLaunch === void 0 ? [] : [unregisterLaunch], ...headroom === void 0 || headroomPort === void 0 ? [] : [headroomPort.release], ...frontDoorRelease === void 0 ? [] : [frontDoorRelease], ...control === void 0 ? [] : [control.release]];
|
|
18389
18646
|
const release = () => {
|
|
18390
18647
|
for (const registered of releases) {
|
|
18391
18648
|
registered();
|
|
18392
18649
|
}
|
|
18393
18650
|
};
|
|
18394
|
-
const picker = decided.argsForSupervisor(frontDoor?.supervisorPid);
|
|
18395
18651
|
if (picker.pickerSuppressed) rows.push(noteRow("--settings was passed, so /model keeps Claude Code's own model names"));
|
|
18396
18652
|
rows.push(...notes.map(noteRow));
|
|
18397
|
-
return { finalEnv, release, picker, sessionId };
|
|
18653
|
+
return { finalEnv, release, args: control === void 0 ? picker.args : control.args(picker.args), sessionId };
|
|
18398
18654
|
});
|
|
18399
18655
|
const unreachable = reachability?.line();
|
|
18400
18656
|
log.report(rows);
|
|
@@ -18403,7 +18659,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
18403
18659
|
}
|
|
18404
18660
|
printDiagnosticLines(log, warnings, { errorsAsWarnings: false });
|
|
18405
18661
|
const hold = () => holdBeforeLaunch({ delayMs: resolvedFlags.delayMs, pause: resolvedFlags.pause }, params.hold, log);
|
|
18406
|
-
return { bin: decided.bin, args: brought.
|
|
18662
|
+
return { bin: decided.bin, args: brought.args, env: brought.finalEnv, sessionId: brought.sessionId, release: brought.release, markChildStarted: updateCheck.markChildStarted, hold, decision };
|
|
18407
18663
|
}
|
|
18408
18664
|
function resolveLaunch(params) {
|
|
18409
18665
|
const decided = decideLaunch(params, true);
|
|
@@ -18486,6 +18742,7 @@ var init_launcher = __esm({
|
|
|
18486
18742
|
init_resumeContext();
|
|
18487
18743
|
init_lock();
|
|
18488
18744
|
init_spawn();
|
|
18745
|
+
init_launchControl();
|
|
18489
18746
|
init_providersStore();
|
|
18490
18747
|
init_load();
|
|
18491
18748
|
init_flatten();
|
|
@@ -18507,12 +18764,12 @@ var init_launcher = __esm({
|
|
|
18507
18764
|
});
|
|
18508
18765
|
|
|
18509
18766
|
// src/ownCli.ts
|
|
18510
|
-
import
|
|
18767
|
+
import path56 from "node:path";
|
|
18511
18768
|
function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string" ? __AGENT_SHIM_DIST_DIR__ : void 0) {
|
|
18512
18769
|
if (distDir === void 0) {
|
|
18513
18770
|
throw new OwnCliPathUnknownError();
|
|
18514
18771
|
}
|
|
18515
|
-
return
|
|
18772
|
+
return path56.join(distDir, OWN_CLI_FILE_NAME);
|
|
18516
18773
|
}
|
|
18517
18774
|
var OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
|
|
18518
18775
|
var init_ownCli = __esm({
|
|
@@ -18558,10 +18815,10 @@ var init_selfIdentity = __esm({
|
|
|
18558
18815
|
|
|
18559
18816
|
// src/frontdoor/trust.ts
|
|
18560
18817
|
import { createHash as createHash12 } from "node:crypto";
|
|
18561
|
-
import
|
|
18818
|
+
import path57 from "node:path";
|
|
18562
18819
|
function resolveTrustBundle(params) {
|
|
18563
18820
|
const { caCertFile, bundlesDir, variable, inherited, fs: fs17 } = params;
|
|
18564
|
-
if (inherited === void 0 || inherited === "" ||
|
|
18821
|
+
if (inherited === void 0 || inherited === "" || path57.resolve(inherited) === path57.resolve(caCertFile)) {
|
|
18565
18822
|
return { path: caCertFile };
|
|
18566
18823
|
}
|
|
18567
18824
|
const caPem = fs17.readFileUtf8(caCertFile);
|
|
@@ -18579,7 +18836,7 @@ function resolveTrustBundle(params) {
|
|
|
18579
18836
|
}
|
|
18580
18837
|
const combined = `${inheritedPem.trimEnd()}
|
|
18581
18838
|
${caPem}`;
|
|
18582
|
-
const bundle =
|
|
18839
|
+
const bundle = path57.join(bundlesDir, `${createHash12("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
18583
18840
|
if (!fs17.exists(bundle)) {
|
|
18584
18841
|
fs17.mkdirp(bundlesDir);
|
|
18585
18842
|
fs17.writeFileAtomic(bundle, combined);
|
|
@@ -18752,8 +19009,8 @@ var init_realFrontDoorPort = __esm({
|
|
|
18752
19009
|
|
|
18753
19010
|
// src/launchWiring.ts
|
|
18754
19011
|
import os12 from "node:os";
|
|
18755
|
-
import
|
|
18756
|
-
import { randomUUID as
|
|
19012
|
+
import path58 from "node:path";
|
|
19013
|
+
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
18757
19014
|
function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
18758
19015
|
const home = os12.homedir();
|
|
18759
19016
|
const read = cosmiconfigReader();
|
|
@@ -18780,7 +19037,7 @@ function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
|
18780
19037
|
...cliOverride === void 0 ? {} : { cliOverride }
|
|
18781
19038
|
}).input,
|
|
18782
19039
|
now: () => Date.now(),
|
|
18783
|
-
uniqueSuffix: `${String(process.pid)}.${
|
|
19040
|
+
uniqueSuffix: `${String(process.pid)}.${randomUUID8()}`,
|
|
18784
19041
|
// Zombie-aware on purpose: a previous launcher that crashed out of a resync without releasing the lock may sit unreaped, still answering signal 0 as alive, and must read as a dead holder so this launch takes the lock over instead of timing out.
|
|
18785
19042
|
lock: { pid: process.pid, isRunning: realIsProcessRunning, sleep: realSleepSync }
|
|
18786
19043
|
},
|
|
@@ -18808,8 +19065,9 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
18808
19065
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
18809
19066
|
startBaseUrlProbe: realStartBaseUrlProbe,
|
|
18810
19067
|
hold: realHoldPort,
|
|
18811
|
-
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot:
|
|
18812
|
-
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin,
|
|
19068
|
+
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: path58.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
|
|
19069
|
+
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin, path58.join(paths.identitiesDir, identity), options.proc.env),
|
|
19070
|
+
stageControlPlugin: () => stageLaunchControl({ fs: realFarmFs, paths, pid: process.pid, isRunning: realIsProcessRunning }),
|
|
18813
19071
|
...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
|
|
18814
19072
|
...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
|
|
18815
19073
|
...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
|
|
@@ -18891,6 +19149,7 @@ var init_launchWiring = __esm({
|
|
|
18891
19149
|
init_paths();
|
|
18892
19150
|
init_signIn();
|
|
18893
19151
|
init_providerReachability();
|
|
19152
|
+
init_launchControl();
|
|
18894
19153
|
init_realPorts();
|
|
18895
19154
|
LaunchRefusedError = class extends CliError {
|
|
18896
19155
|
exitCode;
|
|
@@ -19102,7 +19361,7 @@ var init_identityClaude = __esm({
|
|
|
19102
19361
|
});
|
|
19103
19362
|
|
|
19104
19363
|
// src/usage/providerQuota.ts
|
|
19105
|
-
import { z as
|
|
19364
|
+
import { z as z50 } from "zod";
|
|
19106
19365
|
var MS_PER_SECOND9, SECONDS_PER_HOUR3, HOURS_PER_DAY6, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY2, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, FIVE_HOURS2, DAYS_PER_WEEK2, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema;
|
|
19107
19366
|
var init_providerQuota = __esm({
|
|
19108
19367
|
"src/usage/providerQuota.ts"() {
|
|
@@ -19121,35 +19380,35 @@ var init_providerQuota = __esm({
|
|
|
19121
19380
|
[ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND9],
|
|
19122
19381
|
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9]
|
|
19123
19382
|
]);
|
|
19124
|
-
ZaiLimitSchema =
|
|
19125
|
-
type:
|
|
19126
|
-
unit:
|
|
19127
|
-
number:
|
|
19128
|
-
percentage:
|
|
19129
|
-
nextResetTime:
|
|
19130
|
-
usage:
|
|
19131
|
-
currentValue:
|
|
19132
|
-
remaining:
|
|
19383
|
+
ZaiLimitSchema = z50.object({
|
|
19384
|
+
type: z50.string(),
|
|
19385
|
+
unit: z50.number().int(),
|
|
19386
|
+
number: z50.number().int().positive(),
|
|
19387
|
+
percentage: z50.number().nonnegative(),
|
|
19388
|
+
nextResetTime: z50.number().positive().optional(),
|
|
19389
|
+
usage: z50.number().nonnegative().optional(),
|
|
19390
|
+
currentValue: z50.number().nonnegative().optional(),
|
|
19391
|
+
remaining: z50.number().nonnegative().optional()
|
|
19133
19392
|
});
|
|
19134
|
-
ZaiResponseSchema =
|
|
19135
|
-
success:
|
|
19136
|
-
msg:
|
|
19137
|
-
data:
|
|
19393
|
+
ZaiResponseSchema = z50.object({
|
|
19394
|
+
success: z50.boolean(),
|
|
19395
|
+
msg: z50.string().optional(),
|
|
19396
|
+
data: z50.object({ level: z50.string().optional(), limits: z50.array(ZaiLimitSchema) })
|
|
19138
19397
|
});
|
|
19139
19398
|
OPENROUTER_HOST = "openrouter.ai";
|
|
19140
19399
|
OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
|
|
19141
19400
|
OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
|
|
19142
19401
|
MS_PER_DAY2 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
19143
|
-
OpenRouterKeySchema =
|
|
19144
|
-
data:
|
|
19145
|
-
limit:
|
|
19146
|
-
limit_remaining:
|
|
19147
|
-
limit_reset:
|
|
19148
|
-
is_free_tier:
|
|
19149
|
-
free_model_daily_requests:
|
|
19402
|
+
OpenRouterKeySchema = z50.object({
|
|
19403
|
+
data: z50.object({
|
|
19404
|
+
limit: z50.number().nonnegative().nullable(),
|
|
19405
|
+
limit_remaining: z50.number().nullable(),
|
|
19406
|
+
limit_reset: z50.string().nullable(),
|
|
19407
|
+
is_free_tier: z50.boolean().optional(),
|
|
19408
|
+
free_model_daily_requests: z50.object({ used: z50.number().nonnegative(), limit: z50.number().nonnegative(), remaining: z50.number() }).optional()
|
|
19150
19409
|
})
|
|
19151
19410
|
});
|
|
19152
|
-
OpenRouterCreditsSchema =
|
|
19411
|
+
OpenRouterCreditsSchema = z50.object({ data: z50.object({ total_credits: z50.number().nonnegative(), total_usage: z50.number().nonnegative() }) });
|
|
19153
19412
|
ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
|
|
19154
19413
|
ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
|
|
19155
19414
|
ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
|
|
@@ -19157,21 +19416,21 @@ var init_providerQuota = __esm({
|
|
|
19157
19416
|
DAYS_PER_WEEK2 = 7;
|
|
19158
19417
|
FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
19159
19418
|
WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
19160
|
-
AntigravityBucketSchema =
|
|
19161
|
-
bucketId:
|
|
19162
|
-
remainingFraction:
|
|
19163
|
-
resetTime:
|
|
19419
|
+
AntigravityBucketSchema = z50.object({
|
|
19420
|
+
bucketId: z50.string(),
|
|
19421
|
+
remainingFraction: z50.number().optional(),
|
|
19422
|
+
resetTime: z50.string().optional()
|
|
19164
19423
|
});
|
|
19165
|
-
AntigravitySummarySchema =
|
|
19166
|
-
GoogleTokenInfoSchema =
|
|
19167
|
-
email:
|
|
19168
|
-
sub:
|
|
19424
|
+
AntigravitySummarySchema = z50.object({ groups: z50.array(z50.object({ buckets: z50.array(AntigravityBucketSchema) })) });
|
|
19425
|
+
GoogleTokenInfoSchema = z50.object({
|
|
19426
|
+
email: z50.string().optional(),
|
|
19427
|
+
sub: z50.string().optional()
|
|
19169
19428
|
});
|
|
19170
|
-
AntigravityUserSchema =
|
|
19429
|
+
AntigravityUserSchema = z50.object({
|
|
19171
19430
|
/** The code-assist tier context, which defaults to the free tier for every account. */
|
|
19172
|
-
currentTier:
|
|
19431
|
+
currentTier: z50.object({ name: z50.string().optional(), id: z50.string().optional() }).optional(),
|
|
19173
19432
|
/** The account's paid subscription; absent when the account has none. */
|
|
19174
|
-
paidTier:
|
|
19433
|
+
paidTier: z50.object({ name: z50.string().optional(), id: z50.string().optional() }).optional()
|
|
19175
19434
|
});
|
|
19176
19435
|
}
|
|
19177
19436
|
});
|
|
@@ -19495,15 +19754,13 @@ init_rcWrites();
|
|
|
19495
19754
|
init_rcSchemas();
|
|
19496
19755
|
|
|
19497
19756
|
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
19498
|
-
import { z as
|
|
19757
|
+
import { z as z25 } from "zod";
|
|
19499
19758
|
|
|
19500
19759
|
// src/frontdoor/rcSessionCommands.ts
|
|
19501
19760
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
19502
19761
|
init_rcControl();
|
|
19503
|
-
|
|
19504
|
-
|
|
19505
|
-
var RESULT_POLL_MS = 250;
|
|
19506
|
-
var REQUEST_INSTANT_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
|
|
19762
|
+
init_sessionControl();
|
|
19763
|
+
init_verifiedVersions();
|
|
19507
19764
|
|
|
19508
19765
|
// src/frontdoor/rcSelfHostCommands.ts
|
|
19509
19766
|
init_connectEffects();
|
|
@@ -19623,9 +19880,7 @@ function recognise(command, event, name, args) {
|
|
|
19623
19880
|
}
|
|
19624
19881
|
return { ok: false, message: `the worker did not compact the session: ${answer.text}` };
|
|
19625
19882
|
}
|
|
19626
|
-
async function
|
|
19627
|
-
const { name, args } = commandLine(command);
|
|
19628
|
-
const text = args === "" ? `/${name}` : `/${name} ${args}`;
|
|
19883
|
+
async function writeAsPersonAndAwait(deps, sessionId, text, recogniseEvent, waitMs, signal) {
|
|
19629
19884
|
const early = [];
|
|
19630
19885
|
let after;
|
|
19631
19886
|
let settle;
|
|
@@ -19638,10 +19893,10 @@ async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signa
|
|
|
19638
19893
|
return;
|
|
19639
19894
|
}
|
|
19640
19895
|
if (isPeerDelivery(event, text)) {
|
|
19641
|
-
settle?.({ ok: false, message: `session ${sessionId}'s worker passed ${text} to its model as a peer's message
|
|
19896
|
+
settle?.({ ok: false, message: `session ${sessionId}'s worker passed ${text} to its model as a peer's message, so it did not read the write as a person's` });
|
|
19642
19897
|
return;
|
|
19643
19898
|
}
|
|
19644
|
-
const outcome =
|
|
19899
|
+
const outcome = recogniseEvent(event);
|
|
19645
19900
|
if (outcome !== void 0) {
|
|
19646
19901
|
settle?.(outcome);
|
|
19647
19902
|
}
|
|
@@ -19678,6 +19933,41 @@ async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signa
|
|
|
19678
19933
|
detach();
|
|
19679
19934
|
}
|
|
19680
19935
|
}
|
|
19936
|
+
async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signal) {
|
|
19937
|
+
const { name, args } = commandLine(command);
|
|
19938
|
+
const text = args === "" ? `/${name}` : `/${name} ${args}`;
|
|
19939
|
+
return await writeAsPersonAndAwait(deps, sessionId, text, (event) => recognise(command, event, name, args), waitMs, signal);
|
|
19940
|
+
}
|
|
19941
|
+
function userTextOf(message) {
|
|
19942
|
+
if (typeof message.content === "string") {
|
|
19943
|
+
return message.content;
|
|
19944
|
+
}
|
|
19945
|
+
if (!Array.isArray(message.content)) {
|
|
19946
|
+
return void 0;
|
|
19947
|
+
}
|
|
19948
|
+
const blocks = message.content;
|
|
19949
|
+
return blocks.flatMap((block) => isRecord8(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
|
|
19950
|
+
}
|
|
19951
|
+
function rcPersonTurnOf(event, text) {
|
|
19952
|
+
const payload = event.envelope.payload;
|
|
19953
|
+
if (!isRecord8(payload) || payload.type !== "user" || typeof payload.uuid !== "string" || !isRecord8(payload.origin) || payload.origin.kind !== "human" || !isRecord8(payload.message)) {
|
|
19954
|
+
return void 0;
|
|
19955
|
+
}
|
|
19956
|
+
return userTextOf(payload.message) === text ? payload.uuid : void 0;
|
|
19957
|
+
}
|
|
19958
|
+
async function runSelfHostedTurn(deps, sessionId, text, waitMs, signal) {
|
|
19959
|
+
return await writeAsPersonAndAwait(
|
|
19960
|
+
deps,
|
|
19961
|
+
sessionId,
|
|
19962
|
+
text,
|
|
19963
|
+
(event) => {
|
|
19964
|
+
const uuid = rcPersonTurnOf(event, text);
|
|
19965
|
+
return uuid === void 0 ? void 0 : { ok: true, report: { uuid } };
|
|
19966
|
+
},
|
|
19967
|
+
waitMs,
|
|
19968
|
+
signal
|
|
19969
|
+
);
|
|
19970
|
+
}
|
|
19681
19971
|
function createRcClaudeCodeVersions(fanout) {
|
|
19682
19972
|
const versions = /* @__PURE__ */ new Map();
|
|
19683
19973
|
fanout.subscribe(void 0, (event) => {
|
|
@@ -19699,18 +19989,21 @@ function createRcClaudeCodeVersions(fanout) {
|
|
|
19699
19989
|
}
|
|
19700
19990
|
|
|
19701
19991
|
// src/frontdoor/rcSessionCommands.ts
|
|
19702
|
-
var RC_SESSION_COMMAND_VERIFIED_VERSIONS = ["2.1.319"];
|
|
19703
19992
|
var RC_GOAL_CLEAR_WORDS = ["clear", "stop", "off", "reset", "none", "cancel"];
|
|
19704
19993
|
var RC_GOAL_CONDITION_MAX_CHARS = 4e3;
|
|
19705
19994
|
var MAX_JSON_BYTES_PER_CODE_UNIT = 6;
|
|
19706
19995
|
var RC_COMPACT_INSTRUCTIONS_MAX_CHARS = Math.floor(CONTROL_BODY_CAP_BYTES / MAX_JSON_BYTES_PER_CODE_UNIT);
|
|
19996
|
+
var RC_TURN_TEXT_MAX_CHARS = Math.floor(CONTROL_BODY_CAP_BYTES / MAX_JSON_BYTES_PER_CODE_UNIT);
|
|
19707
19997
|
var RC_SESSION_COMMAND_MAX_WAIT_MS = 2147483647;
|
|
19708
19998
|
function unverifiedVersionMessage(sessionId, version, source) {
|
|
19709
19999
|
const verified = RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ");
|
|
19710
|
-
return version === void 0 ? `session ${sessionId} has not reported its Claude Code version (${source}), and goal and
|
|
20000
|
+
return version === void 0 ? `session ${sessionId} has not reported its Claude Code version (${source}), and goal, compaction and turn control is verified only on Claude Code ${verified}` : `session ${sessionId} runs Claude Code ${version}, and goal, compaction and turn control is verified only on Claude Code ${verified}: the door will not act on a version whose behaviour it has not verified`;
|
|
20001
|
+
}
|
|
20002
|
+
function noPluginReason(sessionId) {
|
|
20003
|
+
return `no agent-shim launch's in-process control plugin records session ${sessionId}: it was started outside the launcher (with claude's own command, or agent-shim run --native), with --bare, on a Claude Code version the plugin is not verified on, or its plugin has not yet recorded its transcript, which it does from the session's first hook event`;
|
|
19711
20004
|
}
|
|
19712
20005
|
function unsupportedMessage(sessionId) {
|
|
19713
|
-
return
|
|
20006
|
+
return `${noPluginReason(sessionId)}, so the door has no in-process channel into it, and it is not on the door's own self-hosted surface. Over the real Remote Control service, Claude Code ${RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ")} takes a message as a person's (running it when it is a slash command) only when a person's app wrote it and treats any other writer as a peer, whose message the model reads as another session's, and the door does not claim to be a person's app on a service it does not run. Start the session through agent-shim run on Claude Code ${RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ")} without --bare, or run it against the door's self-hosted surface.`;
|
|
19714
20007
|
}
|
|
19715
20008
|
function createRcSessionCommands(deps) {
|
|
19716
20009
|
const queues = /* @__PURE__ */ new Map();
|
|
@@ -19727,57 +20020,78 @@ function createRcSessionCommands(deps) {
|
|
|
19727
20020
|
}
|
|
19728
20021
|
}
|
|
19729
20022
|
};
|
|
20023
|
+
const pluginRoute = async (sessionId, route, lookup2) => {
|
|
20024
|
+
const target = await lookup2(sessionId);
|
|
20025
|
+
if (target === void 0) {
|
|
20026
|
+
return void 0;
|
|
20027
|
+
}
|
|
20028
|
+
if ("refused" in target) {
|
|
20029
|
+
return { kind: "refused", message: target.refused };
|
|
20030
|
+
}
|
|
20031
|
+
if (target.version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(target.version)) {
|
|
20032
|
+
return { kind: "refused", message: unverifiedVersionMessage(sessionId, target.version, route === "supervised" ? "its supervisor's control plugin has not loaded" : "its launch's control plugin has not loaded") };
|
|
20033
|
+
}
|
|
20034
|
+
return { kind: route, target };
|
|
20035
|
+
};
|
|
20036
|
+
const resolveRoute = async (sessionId) => {
|
|
20037
|
+
const supervised = await pluginRoute(sessionId, "supervised", deps.supervisedOf);
|
|
20038
|
+
if (supervised !== void 0) {
|
|
20039
|
+
return supervised;
|
|
20040
|
+
}
|
|
20041
|
+
const launched = deps.launchedOf === void 0 ? void 0 : await pluginRoute(sessionId, "launched", deps.launchedOf);
|
|
20042
|
+
if (launched !== void 0) {
|
|
20043
|
+
return launched;
|
|
20044
|
+
}
|
|
20045
|
+
if (!deps.isObserved(sessionId)) {
|
|
20046
|
+
return { kind: "refused", message: `the front door has not observed Remote Control session ${sessionId}` };
|
|
20047
|
+
}
|
|
20048
|
+
if (deps.selfHost === void 0) {
|
|
20049
|
+
return { kind: "refused", message: unsupportedMessage(sessionId) };
|
|
20050
|
+
}
|
|
20051
|
+
const unavailable = deps.selfHost.unavailable();
|
|
20052
|
+
if (unavailable !== void 0) {
|
|
20053
|
+
return { kind: "refused", message: `${noPluginReason(sessionId)}, and the door's self-hosted surface cannot take a command: ${unavailable}` };
|
|
20054
|
+
}
|
|
20055
|
+
const version = deps.selfHost.versionOf(sessionId);
|
|
20056
|
+
if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
|
|
20057
|
+
return { kind: "refused", message: unverifiedVersionMessage(sessionId, version, "no system/init from its worker has been observed on its stream; send it a prompt so it reports one") };
|
|
20058
|
+
}
|
|
20059
|
+
return { kind: "self-hosted", selfHost: deps.selfHost };
|
|
20060
|
+
};
|
|
19730
20061
|
const onRoute = async (sessionId, options, actions) => await serialised(sessionId, async () => {
|
|
19731
20062
|
const { signal } = options;
|
|
19732
20063
|
if (signal?.aborted === true) {
|
|
19733
20064
|
return { ok: false, message: `the request for session ${sessionId} was aborted before it ran` };
|
|
19734
20065
|
}
|
|
19735
|
-
const
|
|
19736
|
-
if (
|
|
19737
|
-
return { ok: false, message:
|
|
20066
|
+
const resolved = await resolveRoute(sessionId);
|
|
20067
|
+
if (resolved.kind === "refused") {
|
|
20068
|
+
return { ok: false, message: resolved.message };
|
|
19738
20069
|
}
|
|
19739
|
-
if (
|
|
19740
|
-
|
|
19741
|
-
|
|
19742
|
-
|
|
19743
|
-
const waitMs = options.waitMs ?? COMPACT_TIMEOUT_MS;
|
|
19744
|
-
const timeout = AbortSignal.timeout(waitMs);
|
|
19745
|
-
const bounded3 = signal === void 0 ? timeout : AbortSignal.any([signal, timeout]);
|
|
20070
|
+
if (resolved.kind !== "self-hosted") {
|
|
20071
|
+
const waitMs2 = options.waitMs ?? COMPACT_TIMEOUT_MS;
|
|
20072
|
+
const timeout2 = AbortSignal.timeout(waitMs2);
|
|
20073
|
+
const bounded3 = signal === void 0 ? timeout2 : AbortSignal.any([signal, timeout2]);
|
|
19746
20074
|
try {
|
|
19747
|
-
return await actions.
|
|
20075
|
+
return await actions.plugin(resolved.target, resolved.kind, bounded3, waitMs2);
|
|
19748
20076
|
} catch (error) {
|
|
19749
|
-
if (
|
|
19750
|
-
return { ok: false, message: `session ${sessionId}'s control plugin did not answer within ${String(
|
|
20077
|
+
if (timeout2.aborted) {
|
|
20078
|
+
return { ok: false, message: `session ${sessionId}'s control plugin did not answer within ${String(waitMs2)} ms. A request the plugin had not started is withdrawn; one it had started runs once the session is idle (a turn waiting on a permission prompt holds it), so read the session's goal or transcript before asking again` };
|
|
19751
20079
|
}
|
|
19752
20080
|
return { ok: false, message: `session ${sessionId}'s control plugin did not complete the request: ${error instanceof Error ? error.message : String(error)}` };
|
|
19753
20081
|
}
|
|
19754
20082
|
}
|
|
19755
|
-
|
|
19756
|
-
|
|
20083
|
+
const waitMs = options.waitMs ?? resolved.selfHost.defaultWaitMs;
|
|
20084
|
+
const timeout = AbortSignal.timeout(waitMs);
|
|
20085
|
+
const result = await actions.selfHosted(resolved.selfHost, signal === void 0 ? timeout : AbortSignal.any([signal, timeout]));
|
|
20086
|
+
if (!result.ok && timeout.aborted) {
|
|
20087
|
+
return { ok: false, message: `session ${sessionId}'s worker did not answer within ${String(waitMs)} ms in all; it may still be queued behind a running turn, so read the session's stream before asking again` };
|
|
19757
20088
|
}
|
|
19758
|
-
|
|
19759
|
-
const unavailable = deps.selfHost.unavailable();
|
|
19760
|
-
if (unavailable !== void 0) {
|
|
19761
|
-
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}` };
|
|
19762
|
-
}
|
|
19763
|
-
const version = deps.selfHost.versionOf(sessionId);
|
|
19764
|
-
if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
|
|
19765
|
-
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") };
|
|
19766
|
-
}
|
|
19767
|
-
const waitMs = options.waitMs ?? deps.selfHost.defaultWaitMs;
|
|
19768
|
-
const timeout = AbortSignal.timeout(waitMs);
|
|
19769
|
-
const result = await actions.selfHosted(deps.selfHost, signal === void 0 ? timeout : AbortSignal.any([signal, timeout]));
|
|
19770
|
-
if (!result.ok && timeout.aborted) {
|
|
19771
|
-
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` };
|
|
19772
|
-
}
|
|
19773
|
-
return result;
|
|
19774
|
-
}
|
|
19775
|
-
return { ok: false, message: unsupportedMessage(sessionId) };
|
|
20089
|
+
return result;
|
|
19776
20090
|
});
|
|
19777
20091
|
const transcriptGoal = async (sessionId, target) => {
|
|
19778
20092
|
const goal = target.transcriptPath === void 0 ? void 0 : await deps.goalOf(target.transcriptPath);
|
|
19779
20093
|
if (goal === void 0) {
|
|
19780
|
-
return { ok: false, message: `session ${sessionId}'s
|
|
20094
|
+
return { ok: false, message: `session ${sessionId}'s transcript has not been recorded yet, which is where its goal is read from; retry once it has finished a turn` };
|
|
19781
20095
|
}
|
|
19782
20096
|
return { ok: true, report: goal };
|
|
19783
20097
|
};
|
|
@@ -19791,12 +20105,64 @@ function createRcSessionCommands(deps) {
|
|
|
19791
20105
|
}
|
|
19792
20106
|
};
|
|
19793
20107
|
const waitOf = (options) => options.waitMs;
|
|
20108
|
+
const transcriptPluginTurns = async (sessionId, target) => {
|
|
20109
|
+
const turns = target.transcriptPath === void 0 ? void 0 : await deps.pluginTurnsOf(target.transcriptPath);
|
|
20110
|
+
return turns === void 0 ? { ok: false, message: `session ${sessionId}'s transcript has not been recorded yet, which is where a turn is confirmed from; retry once it has finished a turn` } : { ok: true, report: turns };
|
|
20111
|
+
};
|
|
19794
20112
|
return {
|
|
20113
|
+
/** Which route the verbs would take for the session now, or the refusal naming why none would; reads only, outside the session's queue, so a verb waiting on the session never delays it. */
|
|
20114
|
+
routeOf: async (sessionId) => {
|
|
20115
|
+
const resolved = await resolveRoute(sessionId);
|
|
20116
|
+
return resolved.kind === "refused" ? { route: null, refused: resolved.message } : { route: resolved.kind };
|
|
20117
|
+
},
|
|
20118
|
+
/**
|
|
20119
|
+
* Puts `text` into the session as a person's typed turn, and resolves once the session recorded it as a user entry from the person, never as a peer's message: on the supervised route a transcript row the control plugin submitted as the person's words (`origin: { kind: "plugin", asUser: true }`), on the self-hosted route the worker's mirrored entry with a person's origin (`{ kind: "human" }`). The text reaches the session's model as its user's words (`docs/rc-slash-commands.md`, the trust boundary). Refused unsent: text that is empty, starts with `/` (a slash command, which the goal and compaction verbs run), or is longer than one request carries. Resolves when the turn entered the session, not when the model has answered it.
|
|
20120
|
+
*/
|
|
20121
|
+
turn: async (sessionId, text, options = {}) => {
|
|
20122
|
+
if (text.trim() === "") {
|
|
20123
|
+
return { ok: false, message: "a turn needs non-empty text" };
|
|
20124
|
+
}
|
|
20125
|
+
if (text.trimStart().startsWith("/")) {
|
|
20126
|
+
return { ok: false, message: "a turn's text starts with /, which the session would read as a slash command rather than a message, and the turn could not be confirmed as one; use the goal or compaction verbs for those commands, or start the text with something else" };
|
|
20127
|
+
}
|
|
20128
|
+
if (text.length > RC_TURN_TEXT_MAX_CHARS) {
|
|
20129
|
+
return { ok: false, message: `a turn's text is limited to ${String(RC_TURN_TEXT_MAX_CHARS)} characters, and this one has ${String(text.length)}` };
|
|
20130
|
+
}
|
|
20131
|
+
return await onRoute(sessionId, options, {
|
|
20132
|
+
plugin: async (target, route, signal, waitMs) => {
|
|
20133
|
+
const before = await transcriptPluginTurns(sessionId, target);
|
|
20134
|
+
if (!before.ok) {
|
|
20135
|
+
return before;
|
|
20136
|
+
}
|
|
20137
|
+
const submitted = await target.submitTurn(text, signal, waitMs);
|
|
20138
|
+
if (!submitted.asUser) {
|
|
20139
|
+
return { ok: false, message: `session ${sessionId}'s control plugin submitted the turn, but Claude Code did not stamp it as the person's words, so the model may read it framed as the plugin's` };
|
|
20140
|
+
}
|
|
20141
|
+
for (; ; ) {
|
|
20142
|
+
const after = await transcriptPluginTurns(sessionId, target);
|
|
20143
|
+
if (!after.ok) {
|
|
20144
|
+
return after;
|
|
20145
|
+
}
|
|
20146
|
+
if (after.report.count > before.report.count && after.report.last !== void 0) {
|
|
20147
|
+
return after.report.last.text === text ? { ok: true, report: { route, uuid: after.report.last.uuid } } : { ok: false, message: `session ${sessionId}'s transcript records a turn the control plugin submitted, but its text is not the text sent` };
|
|
20148
|
+
}
|
|
20149
|
+
if (signal.aborted) {
|
|
20150
|
+
return { ok: false, message: `session ${sessionId} accepted the turn but its transcript did not record it within ${String(waitMs)} ms; it is queued behind the running turn, so read the transcript before sending it again` };
|
|
20151
|
+
}
|
|
20152
|
+
await sleep(RESULT_POLL_MS);
|
|
20153
|
+
}
|
|
20154
|
+
},
|
|
20155
|
+
selfHosted: async (selfHost, signal) => {
|
|
20156
|
+
const delivered = await runSelfHostedTurn(selfHost, sessionId, text, waitOf(options), signal);
|
|
20157
|
+
return delivered.ok ? { ok: true, report: { route: "self-hosted", uuid: delivered.report.uuid } } : delivered;
|
|
20158
|
+
}
|
|
20159
|
+
});
|
|
20160
|
+
},
|
|
19795
20161
|
/** Reads the session's goal: from the transcript for a supervised session, with no effect on it; by running `/goal` on the self-hosted surface otherwise. */
|
|
19796
20162
|
goalGet: async (sessionId, options = {}) => await onRoute(sessionId, options, {
|
|
19797
|
-
|
|
20163
|
+
plugin: async (target, route) => {
|
|
19798
20164
|
const read = await transcriptGoal(sessionId, target);
|
|
19799
|
-
return
|
|
20165
|
+
return read.ok ? { ok: true, report: { route, goal: read.report } } : read;
|
|
19800
20166
|
},
|
|
19801
20167
|
selfHosted: async (selfHost, signal) => {
|
|
19802
20168
|
const read = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
|
|
@@ -19821,7 +20187,7 @@ function createRcSessionCommands(deps) {
|
|
|
19821
20187
|
return { ok: false, message: `a goal condition is limited to ${String(RC_GOAL_CONDITION_MAX_CHARS)} characters, and this one has ${String(trimmed.length)}` };
|
|
19822
20188
|
}
|
|
19823
20189
|
return await onRoute(sessionId, options, {
|
|
19824
|
-
|
|
20190
|
+
plugin: async (target, route, signal, waitMs) => {
|
|
19825
20191
|
const before = await transcriptGoal(sessionId, target);
|
|
19826
20192
|
if (!before.ok) {
|
|
19827
20193
|
return before;
|
|
@@ -19831,7 +20197,7 @@ function createRcSessionCommands(deps) {
|
|
|
19831
20197
|
if (!after.ok) {
|
|
19832
20198
|
return after;
|
|
19833
20199
|
}
|
|
19834
|
-
return after.report?.condition === trimmed ? { ok: true, report: { route
|
|
20200
|
+
return after.report?.condition === trimmed ? { ok: true, report: { route, condition: trimmed, superseded: before.report?.condition ?? null } } : { ok: false, message: `session ${sessionId} ran /goal but its transcript does not record the goal as set` };
|
|
19835
20201
|
},
|
|
19836
20202
|
selfHosted: async (selfHost, signal) => {
|
|
19837
20203
|
const before = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
|
|
@@ -19845,20 +20211,20 @@ function createRcSessionCommands(deps) {
|
|
|
19845
20211
|
},
|
|
19846
20212
|
/** Clears the session's goal and names the condition it cleared, or `null` when there was none, which is not a failure (clearing is idempotent). */
|
|
19847
20213
|
goalClear: async (sessionId, options = {}) => await onRoute(sessionId, options, {
|
|
19848
|
-
|
|
20214
|
+
plugin: async (target, route, signal, waitMs) => {
|
|
19849
20215
|
const before = await transcriptGoal(sessionId, target);
|
|
19850
20216
|
if (!before.ok) {
|
|
19851
20217
|
return before;
|
|
19852
20218
|
}
|
|
19853
20219
|
if (before.report === null) {
|
|
19854
|
-
return { ok: true, report: { route
|
|
20220
|
+
return { ok: true, report: { route, cleared: null } };
|
|
19855
20221
|
}
|
|
19856
20222
|
await target.runGoal("clear", signal, waitMs);
|
|
19857
20223
|
const after = await settledGoal(sessionId, target, signal, (goal) => goal === null);
|
|
19858
20224
|
if (!after.ok) {
|
|
19859
20225
|
return after;
|
|
19860
20226
|
}
|
|
19861
|
-
return after.report === null ? { ok: true, report: { route
|
|
20227
|
+
return after.report === null ? { ok: true, report: { route, cleared: before.report.condition } } : { ok: false, message: `session ${sessionId} ran /goal clear but its transcript still records the goal "${after.report.condition}"` };
|
|
19862
20228
|
},
|
|
19863
20229
|
selfHosted: async (selfHost, signal) => {
|
|
19864
20230
|
const cleared = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-clear" }, waitOf(options), signal);
|
|
@@ -19870,12 +20236,12 @@ function createRcSessionCommands(deps) {
|
|
|
19870
20236
|
const instructions = options.instructions?.trim();
|
|
19871
20237
|
const given = instructions === void 0 || instructions === "" ? void 0 : instructions;
|
|
19872
20238
|
return await onRoute(sessionId, options, {
|
|
19873
|
-
|
|
20239
|
+
plugin: async (target, route, signal, waitMs) => {
|
|
19874
20240
|
const result = await target.compact(signal, given, waitMs);
|
|
19875
20241
|
if (result.kind === "unchanged") {
|
|
19876
20242
|
return { ok: false, message: `session ${sessionId} was not compacted: ${result.reason}` };
|
|
19877
20243
|
}
|
|
19878
|
-
return { ok: true, report: { route
|
|
20244
|
+
return { ok: true, report: { route, trigger: "plugin", ...result.beforeTokens === void 0 ? {} : { preTokens: result.beforeTokens }, ...result.afterTokens === void 0 ? {} : { postTokens: result.afterTokens } } };
|
|
19879
20245
|
},
|
|
19880
20246
|
selfHosted: async (selfHost, signal) => {
|
|
19881
20247
|
const compacted = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "compact", instructions: given }, waitOf(options), signal);
|
|
@@ -19887,47 +20253,56 @@ function createRcSessionCommands(deps) {
|
|
|
19887
20253
|
}
|
|
19888
20254
|
|
|
19889
20255
|
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
19890
|
-
var WaitMsSchema =
|
|
19891
|
-
var RcGoalSessionInputSchema =
|
|
19892
|
-
session:
|
|
20256
|
+
var WaitMsSchema = z25.int().positive().max(RC_SESSION_COMMAND_MAX_WAIT_MS).optional();
|
|
20257
|
+
var RcGoalSessionInputSchema = z25.strictObject({
|
|
20258
|
+
session: z25.string().min(1),
|
|
20259
|
+
waitMs: WaitMsSchema
|
|
20260
|
+
});
|
|
20261
|
+
var RcGoalSetInputSchema = z25.strictObject({
|
|
20262
|
+
session: z25.string().min(1),
|
|
20263
|
+
condition: z25.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
|
|
19893
20264
|
waitMs: WaitMsSchema
|
|
19894
20265
|
});
|
|
19895
|
-
var
|
|
19896
|
-
session:
|
|
19897
|
-
condition: z24.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
|
|
20266
|
+
var RcCompactInputSchema = z25.strictObject({
|
|
20267
|
+
session: z25.string().min(1),
|
|
19898
20268
|
waitMs: WaitMsSchema
|
|
19899
20269
|
});
|
|
19900
|
-
var
|
|
19901
|
-
session:
|
|
20270
|
+
var RcCompactWithInstructionsInputSchema = z25.strictObject({
|
|
20271
|
+
session: z25.string().min(1),
|
|
20272
|
+
instructions: z25.string().trim().min(1).max(RC_COMPACT_INSTRUCTIONS_MAX_CHARS),
|
|
19902
20273
|
waitMs: WaitMsSchema
|
|
19903
20274
|
});
|
|
19904
|
-
var
|
|
19905
|
-
session:
|
|
19906
|
-
|
|
20275
|
+
var RcTurnInputSchema = z25.strictObject({
|
|
20276
|
+
session: z25.string().min(1),
|
|
20277
|
+
text: z25.string().min(1).max(RC_TURN_TEXT_MAX_CHARS),
|
|
19907
20278
|
waitMs: WaitMsSchema
|
|
19908
20279
|
});
|
|
19909
20280
|
var commandAnswerShape = {
|
|
19910
|
-
session:
|
|
19911
|
-
route:
|
|
20281
|
+
session: z25.string(),
|
|
20282
|
+
route: z25.enum(["supervised", "launched", "self-hosted"])
|
|
19912
20283
|
};
|
|
19913
|
-
var RcGoalGetOutputSchema =
|
|
20284
|
+
var RcGoalGetOutputSchema = z25.strictObject({
|
|
19914
20285
|
...commandAnswerShape,
|
|
19915
|
-
goal:
|
|
20286
|
+
goal: z25.strictObject({ condition: z25.string(), iterations: z25.int().nonnegative(), lastCheck: z25.string().optional() }).nullable()
|
|
19916
20287
|
});
|
|
19917
|
-
var RcGoalSetOutputSchema =
|
|
20288
|
+
var RcGoalSetOutputSchema = z25.strictObject({
|
|
19918
20289
|
...commandAnswerShape,
|
|
19919
|
-
condition:
|
|
19920
|
-
superseded:
|
|
20290
|
+
condition: z25.string(),
|
|
20291
|
+
superseded: z25.string().nullable()
|
|
19921
20292
|
});
|
|
19922
|
-
var RcGoalClearOutputSchema =
|
|
20293
|
+
var RcGoalClearOutputSchema = z25.strictObject({
|
|
19923
20294
|
...commandAnswerShape,
|
|
19924
|
-
cleared:
|
|
20295
|
+
cleared: z25.string().nullable()
|
|
19925
20296
|
});
|
|
19926
|
-
var
|
|
20297
|
+
var RcTurnOutputSchema = z25.strictObject({
|
|
19927
20298
|
...commandAnswerShape,
|
|
19928
|
-
|
|
19929
|
-
|
|
19930
|
-
|
|
20299
|
+
uuid: z25.string()
|
|
20300
|
+
});
|
|
20301
|
+
var RcCompactOutputSchema = z25.strictObject({
|
|
20302
|
+
...commandAnswerShape,
|
|
20303
|
+
trigger: z25.string(),
|
|
20304
|
+
preTokens: z25.number().optional(),
|
|
20305
|
+
postTokens: z25.number().optional()
|
|
19931
20306
|
});
|
|
19932
20307
|
|
|
19933
20308
|
// src/frontdoor/rcApi.ts
|
|
@@ -19979,12 +20354,12 @@ function createRcApiRouter(deps) {
|
|
|
19979
20354
|
return {
|
|
19980
20355
|
rc: {
|
|
19981
20356
|
list: authed.meta(openapi({ method: "GET", path: "/rest/rc/sessions", summary: "List the observed Remote Control sessions", tags: [RC_API_TAG] })).output(RcListOutputSchema).handler(() => ({ sessions: deps.list() })),
|
|
19982
|
-
status: authed.meta(openapi({ method: "GET", path: "/rest/rc/status", summary: "Read session status, one session's when named", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output(RcStatusOutputSchema).handler(({ input }) => {
|
|
20357
|
+
status: authed.meta(openapi({ method: "GET", path: "/rest/rc/status", summary: "Read session status, one session's when named", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output(RcStatusOutputSchema).handler(async ({ input }) => {
|
|
19983
20358
|
const statuses = deps.statusOf(input.session);
|
|
19984
20359
|
if (input.session !== void 0 && !statuses.some((entry) => entry.id === input.session)) {
|
|
19985
20360
|
throw new ORPCError("NOT_FOUND", { message: rcSessionNotObservedMessage(input.session) });
|
|
19986
20361
|
}
|
|
19987
|
-
return { statuses };
|
|
20362
|
+
return { statuses: await Promise.all(statuses.map(async (status) => ({ ...status, route: await deps.routeOf(status.id) }))) };
|
|
19988
20363
|
}),
|
|
19989
20364
|
pending: authed.meta(openapi({ method: "GET", path: "/rest/rc/pending", summary: "Read the control requests awaiting an answer", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output(RcPendingOutputSchema).handler(({ input }) => {
|
|
19990
20365
|
const pending = deps.pendingOf(input.session);
|
|
@@ -20019,6 +20394,7 @@ function createRcApiRouter(deps) {
|
|
|
20019
20394
|
goalClear: authed.meta(openapi({ method: "POST", path: "/rest/rc/goal/clear", summary: "Clear a session's goal", tags: [RC_API_TAG] })).input(RcGoalSessionInputSchema).output(RcGoalClearOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.goalClear(input.session, optionsOf(input.waitMs, signal)))),
|
|
20020
20395
|
compact: authed.meta(openapi({ method: "POST", path: "/rest/rc/compact", summary: "Compact a session's conversation", tags: [RC_API_TAG] })).input(RcCompactInputSchema).output(RcCompactOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.compact(input.session, optionsOf(input.waitMs, signal)))),
|
|
20021
20396
|
compactWithInstructions: authed.meta(openapi({ method: "POST", path: "/rest/rc/compact-with-instructions", summary: "Compact a session's conversation under summary instructions, a directive to its model", tags: [RC_DIRECTIVE_TAG] })).input(RcCompactWithInstructionsInputSchema).output(RcCompactOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.compact(input.session, { ...optionsOf(input.waitMs, signal), instructions: input.instructions }))),
|
|
20397
|
+
turn: authed.meta(openapi({ method: "POST", path: "/rest/rc/turn", summary: "Put a person's typed turn into a session, which its model reads as its user's words", tags: [RC_DIRECTIVE_TAG] })).input(RcTurnInputSchema).output(RcTurnOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.turn(input.session, input.text, optionsOf(input.waitMs, signal)))),
|
|
20022
20398
|
subscribe: authed.meta(openapi({ method: "GET", path: "/rest/rc/events", summary: "Stream a session's Remote Control events (SSE)", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output(eventIterator(RcStreamEventSchema)).handler(async function* ({ input, signal }) {
|
|
20023
20399
|
const queue = [];
|
|
20024
20400
|
let wake;
|
|
@@ -20100,7 +20476,7 @@ function createRcApiNodeHandler(deps) {
|
|
|
20100
20476
|
return doorApiNodeHandlerOf(createRcApiRouter(deps), deps.expectedToken);
|
|
20101
20477
|
}
|
|
20102
20478
|
var DEFAULT_HEADERS_TIMEOUT_MS = 3e5;
|
|
20103
|
-
var SESSION_COMMAND_PROCEDURES = ["rc/goalGet", "rc/goalSet", "rc/goalClear", "rc/compact", "rc/compactWithInstructions"];
|
|
20479
|
+
var SESSION_COMMAND_PROCEDURES = ["rc/goalGet", "rc/goalSet", "rc/goalClear", "rc/compact", "rc/compactWithInstructions", "rc/turn"];
|
|
20104
20480
|
function headersTimeoutOf(url, body) {
|
|
20105
20481
|
if (!SESSION_COMMAND_PROCEDURES.some((procedure) => url.endsWith(`${RC_ORPC_PATH_PREFIX}/${procedure}`))) {
|
|
20106
20482
|
return DEFAULT_HEADERS_TIMEOUT_MS;
|
|
@@ -20148,48 +20524,48 @@ init_cliError();
|
|
|
20148
20524
|
init_package();
|
|
20149
20525
|
|
|
20150
20526
|
// src/codex/appServerSchemas.ts
|
|
20151
|
-
import { z as
|
|
20527
|
+
import { z as z26 } from "zod";
|
|
20152
20528
|
var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
|
|
20153
|
-
var RateLimitWindowSchema =
|
|
20154
|
-
usedPercent:
|
|
20155
|
-
resetsAt:
|
|
20156
|
-
windowDurationMins:
|
|
20157
|
-
});
|
|
20158
|
-
var RateLimitSnapshotSchema =
|
|
20159
|
-
limitId:
|
|
20160
|
-
limitName:
|
|
20161
|
-
planType:
|
|
20529
|
+
var RateLimitWindowSchema = z26.object({
|
|
20530
|
+
usedPercent: z26.number(),
|
|
20531
|
+
resetsAt: z26.number().nullish(),
|
|
20532
|
+
windowDurationMins: z26.number().nullish()
|
|
20533
|
+
});
|
|
20534
|
+
var RateLimitSnapshotSchema = z26.object({
|
|
20535
|
+
limitId: z26.string().nullish(),
|
|
20536
|
+
limitName: z26.string().nullish(),
|
|
20537
|
+
planType: z26.string().nullish(),
|
|
20162
20538
|
primary: RateLimitWindowSchema.nullish(),
|
|
20163
20539
|
secondary: RateLimitWindowSchema.nullish(),
|
|
20164
|
-
rateLimitReachedType:
|
|
20165
|
-
spendControlReached:
|
|
20166
|
-
});
|
|
20167
|
-
var RateLimitResetCreditSchema =
|
|
20168
|
-
id:
|
|
20169
|
-
grantedAt:
|
|
20170
|
-
expiresAt:
|
|
20171
|
-
resetType:
|
|
20172
|
-
status:
|
|
20173
|
-
title:
|
|
20174
|
-
description:
|
|
20175
|
-
});
|
|
20176
|
-
var CodexAccountSchema =
|
|
20177
|
-
|
|
20178
|
-
|
|
20179
|
-
|
|
20540
|
+
rateLimitReachedType: z26.string().nullish(),
|
|
20541
|
+
spendControlReached: z26.boolean().nullish()
|
|
20542
|
+
});
|
|
20543
|
+
var RateLimitResetCreditSchema = z26.object({
|
|
20544
|
+
id: z26.string(),
|
|
20545
|
+
grantedAt: z26.number(),
|
|
20546
|
+
expiresAt: z26.number().nullish(),
|
|
20547
|
+
resetType: z26.string(),
|
|
20548
|
+
status: z26.string(),
|
|
20549
|
+
title: z26.string().nullish(),
|
|
20550
|
+
description: z26.string().nullish()
|
|
20551
|
+
});
|
|
20552
|
+
var CodexAccountSchema = z26.discriminatedUnion("type", [
|
|
20553
|
+
z26.object({ type: z26.literal("apiKey") }),
|
|
20554
|
+
z26.object({ type: z26.literal("chatgpt"), email: z26.string().nullable(), planType: z26.string() }),
|
|
20555
|
+
z26.object({ type: z26.literal("amazonBedrock"), usesCodexManagedCredentials: z26.boolean().default(false) })
|
|
20180
20556
|
]);
|
|
20181
|
-
var CodexAccountReadSchema =
|
|
20557
|
+
var CodexAccountReadSchema = z26.object({
|
|
20182
20558
|
account: CodexAccountSchema.nullable(),
|
|
20183
|
-
requiresOpenaiAuth:
|
|
20559
|
+
requiresOpenaiAuth: z26.boolean()
|
|
20184
20560
|
});
|
|
20185
|
-
var CodexRateLimitsReadSchema =
|
|
20561
|
+
var CodexRateLimitsReadSchema = z26.object({
|
|
20186
20562
|
rateLimits: RateLimitSnapshotSchema,
|
|
20187
|
-
rateLimitsByLimitId:
|
|
20188
|
-
rateLimitResetCredits:
|
|
20189
|
-
accountId:
|
|
20190
|
-
ordinaryUsageAllowed:
|
|
20563
|
+
rateLimitsByLimitId: z26.record(z26.string(), RateLimitSnapshotSchema).nullish(),
|
|
20564
|
+
rateLimitResetCredits: z26.object({ availableCount: z26.number(), credits: z26.array(RateLimitResetCreditSchema).nullish() }).nullish(),
|
|
20565
|
+
accountId: z26.string().nullish(),
|
|
20566
|
+
ordinaryUsageAllowed: z26.boolean().nullish()
|
|
20191
20567
|
});
|
|
20192
|
-
var CodexInitializeResultSchema =
|
|
20568
|
+
var CodexInitializeResultSchema = z26.object({ userAgent: z26.string() });
|
|
20193
20569
|
|
|
20194
20570
|
// src/codex/appServer.ts
|
|
20195
20571
|
var CodexAppServerUnavailableError = class extends CliError {
|
|
@@ -20392,7 +20768,7 @@ init_schema();
|
|
|
20392
20768
|
init_claudeVersion();
|
|
20393
20769
|
init_identity2();
|
|
20394
20770
|
init_projects();
|
|
20395
|
-
import { z as
|
|
20771
|
+
import { z as z28 } from "zod";
|
|
20396
20772
|
|
|
20397
20773
|
// src/resolve/types.ts
|
|
20398
20774
|
var LAYER_KINDS = [
|
|
@@ -20455,129 +20831,129 @@ var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
|
|
|
20455
20831
|
|
|
20456
20832
|
// src/usage/pickReportSchema.ts
|
|
20457
20833
|
init_plan2();
|
|
20458
|
-
import { z as
|
|
20459
|
-
var PoolPickCandidateViewSchema =
|
|
20460
|
-
identity:
|
|
20834
|
+
import { z as z27 } from "zod";
|
|
20835
|
+
var PoolPickCandidateViewSchema = z27.strictObject({
|
|
20836
|
+
identity: z27.string(),
|
|
20461
20837
|
/** In pick order: `scored` has usable quota data, `unknown` has none and no plan known to bill by use, `pay-per-use` bills by use whether or not usage is recorded, `ineligible` is refused right now. */
|
|
20462
|
-
class:
|
|
20838
|
+
class: z27.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
|
|
20463
20839
|
/** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
|
|
20464
|
-
score:
|
|
20840
|
+
score: z27.number().optional(),
|
|
20465
20841
|
/** Which window's reset divides the score: the seven-day window, or the five-hour one when the member reports no seven-day utilisation or its measured-ratio five-hour term outranks the weekly one; present with `score`. */
|
|
20466
|
-
scoreWindow:
|
|
20842
|
+
scoreWindow: z27.enum(["sevenDay", "fiveHour"]).optional(),
|
|
20467
20843
|
/** False when the five-hour window would run dry, at the observed pace, before it resets. */
|
|
20468
|
-
feasible:
|
|
20844
|
+
feasible: z27.boolean(),
|
|
20469
20845
|
/** When an `ineligible` member can be used again, as an ISO instant. */
|
|
20470
|
-
blockedUntil:
|
|
20846
|
+
blockedUntil: z27.iso.datetime().optional(),
|
|
20471
20847
|
plan: PlanClassSchema,
|
|
20472
20848
|
/** The provider the member was ranked on, when its launch spends one in place of its Claude account: its windows, refusals and plan are the provider's own. Absent when ranked on the Claude account. */
|
|
20473
|
-
provider:
|
|
20849
|
+
provider: z27.string().optional(),
|
|
20474
20850
|
/** The facts behind the class and score, in the order they matter. */
|
|
20475
|
-
reasons:
|
|
20851
|
+
reasons: z27.array(z27.string())
|
|
20476
20852
|
});
|
|
20477
|
-
var PoolPickReportSchema =
|
|
20478
|
-
pool:
|
|
20479
|
-
directory:
|
|
20853
|
+
var PoolPickReportSchema = z27.strictObject({
|
|
20854
|
+
pool: z27.string(),
|
|
20855
|
+
directory: z27.string(),
|
|
20480
20856
|
/** The member a launch would run as, absent when every member is refused. */
|
|
20481
|
-
pick:
|
|
20482
|
-
candidates:
|
|
20857
|
+
pick: z27.string().optional(),
|
|
20858
|
+
candidates: z27.array(PoolPickCandidateViewSchema),
|
|
20483
20859
|
/** Identity members anywhere in the pool's graph that do not exist; a launch skips them. */
|
|
20484
|
-
missing:
|
|
20860
|
+
missing: z27.array(z27.string()),
|
|
20485
20861
|
/** When nothing can be picked, the soonest any member returns. */
|
|
20486
|
-
earliestReturn:
|
|
20862
|
+
earliestReturn: z27.strictObject({ identity: z27.string(), at: z27.iso.datetime() }).optional(),
|
|
20487
20863
|
/** The member a resumed conversation started on but moved off, and why, when the ranking could not keep it. */
|
|
20488
|
-
movedOff:
|
|
20864
|
+
movedOff: z27.strictObject({ identity: z27.string(), reason: z27.string() }).optional(),
|
|
20489
20865
|
/** Why the last-pick record could not be read, when that is the case. */
|
|
20490
|
-
stickyProblem:
|
|
20866
|
+
stickyProblem: z27.string().optional()
|
|
20491
20867
|
});
|
|
20492
20868
|
|
|
20493
20869
|
// src/checkReportSchema.ts
|
|
20494
20870
|
var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
|
|
20495
|
-
var CheckLayerViewSchema =
|
|
20496
|
-
id:
|
|
20497
|
-
kind:
|
|
20498
|
-
source:
|
|
20499
|
-
});
|
|
20500
|
-
var CheckEntryViewSchema =
|
|
20501
|
-
path:
|
|
20502
|
-
shared:
|
|
20503
|
-
via:
|
|
20871
|
+
var CheckLayerViewSchema = z28.strictObject({
|
|
20872
|
+
id: z28.int(),
|
|
20873
|
+
kind: z28.enum(LAYER_KINDS),
|
|
20874
|
+
source: z28.string()
|
|
20875
|
+
});
|
|
20876
|
+
var CheckEntryViewSchema = z28.strictObject({
|
|
20877
|
+
path: z28.string(),
|
|
20878
|
+
shared: z28.boolean(),
|
|
20879
|
+
via: z28.enum(DECISION_VIAS),
|
|
20504
20880
|
/** The entry's real category, or null when nothing classifies it. */
|
|
20505
|
-
category:
|
|
20506
|
-
rule:
|
|
20881
|
+
category: z28.enum(CATEGORY_NAMES).nullable(),
|
|
20882
|
+
rule: z28.strictObject({ key: z28.string(), layer: z28.int() }).optional(),
|
|
20507
20883
|
/** Rules that matched but whose `when` condition failed, each with the conditions that failed. */
|
|
20508
|
-
eliminated:
|
|
20509
|
-
});
|
|
20510
|
-
var CheckDiagnosticSchema =
|
|
20511
|
-
code:
|
|
20512
|
-
severity:
|
|
20513
|
-
message:
|
|
20514
|
-
subject:
|
|
20515
|
-
layer:
|
|
20516
|
-
});
|
|
20517
|
-
var CheckAmbientCredentialSchema =
|
|
20518
|
-
var CheckKeychainSchema =
|
|
20519
|
-
checked:
|
|
20520
|
-
found:
|
|
20521
|
-
serviceName:
|
|
20522
|
-
note:
|
|
20523
|
-
});
|
|
20524
|
-
var CheckSettingsExposureSchema =
|
|
20525
|
-
file:
|
|
20526
|
-
envKeyNames:
|
|
20527
|
-
hookEventNames:
|
|
20528
|
-
hookCommandCount:
|
|
20529
|
-
});
|
|
20530
|
-
var CredentialSourceSummarySchema =
|
|
20531
|
-
|
|
20532
|
-
|
|
20533
|
-
|
|
20534
|
-
|
|
20535
|
-
|
|
20536
|
-
|
|
20884
|
+
eliminated: z28.readonly(z28.array(z28.strictObject({ key: z28.string(), failed: z28.readonly(z28.array(z28.string())) }))).optional()
|
|
20885
|
+
});
|
|
20886
|
+
var CheckDiagnosticSchema = z28.strictObject({
|
|
20887
|
+
code: z28.enum(DIAGNOSTIC_CODES),
|
|
20888
|
+
severity: z28.enum(DIAGNOSTIC_SEVERITIES),
|
|
20889
|
+
message: z28.string(),
|
|
20890
|
+
subject: z28.string().optional(),
|
|
20891
|
+
layer: z28.int().optional()
|
|
20892
|
+
});
|
|
20893
|
+
var CheckAmbientCredentialSchema = z28.union([z28.strictObject({ ok: z28.literal(true) }), z28.strictObject({ ok: z28.literal(false), variable: z28.string(), message: z28.string() })]);
|
|
20894
|
+
var CheckKeychainSchema = z28.strictObject({
|
|
20895
|
+
checked: z28.literal(true),
|
|
20896
|
+
found: z28.boolean(),
|
|
20897
|
+
serviceName: z28.string().optional(),
|
|
20898
|
+
note: z28.string()
|
|
20899
|
+
});
|
|
20900
|
+
var CheckSettingsExposureSchema = z28.strictObject({
|
|
20901
|
+
file: z28.string(),
|
|
20902
|
+
envKeyNames: z28.readonly(z28.array(z28.string())),
|
|
20903
|
+
hookEventNames: z28.readonly(z28.array(z28.string())),
|
|
20904
|
+
hookCommandCount: z28.int().nonnegative()
|
|
20905
|
+
});
|
|
20906
|
+
var CredentialSourceSummarySchema = z28.union([
|
|
20907
|
+
z28.strictObject({ kind: z28.literal("env"), variable: z28.string() }),
|
|
20908
|
+
z28.strictObject({ kind: z28.literal("file"), path: z28.string() }),
|
|
20909
|
+
z28.strictObject({ kind: z28.literal("command"), program: z28.string() }),
|
|
20910
|
+
z28.strictObject({ kind: z28.literal("op"), reference: z28.string() }),
|
|
20911
|
+
z28.strictObject({ kind: z28.literal("keychain"), service: z28.string(), account: z28.string().optional() }),
|
|
20912
|
+
z28.strictObject({ kind: z28.literal("literal") })
|
|
20537
20913
|
]);
|
|
20538
|
-
var CredentialSummarySchema =
|
|
20539
|
-
target:
|
|
20540
|
-
sources:
|
|
20914
|
+
var CredentialSummarySchema = z28.strictObject({
|
|
20915
|
+
target: z28.enum(CREDENTIAL_TARGETS),
|
|
20916
|
+
sources: z28.readonly(z28.array(CredentialSourceSummarySchema)),
|
|
20541
20917
|
cache: CredentialCacheSchema.optional()
|
|
20542
20918
|
});
|
|
20543
|
-
var CachedCredentialStateSchema =
|
|
20544
|
-
|
|
20545
|
-
|
|
20546
|
-
|
|
20919
|
+
var CachedCredentialStateSchema = z28.union([
|
|
20920
|
+
z28.strictObject({ store: z28.enum(CREDENTIAL_CACHE_STORES), status: z28.literal("empty") }),
|
|
20921
|
+
z28.strictObject({ store: z28.enum(CREDENTIAL_CACHE_STORES), status: z28.literal("unreadable"), reason: z28.string() }),
|
|
20922
|
+
z28.strictObject({ store: z28.enum(CREDENTIAL_CACHE_STORES), status: z28.enum(["fresh", "expired"]), ageMs: z28.number(), expiresInMs: z28.number().optional() })
|
|
20547
20923
|
]);
|
|
20548
|
-
var CheckCredentialProviderSchema =
|
|
20549
|
-
|
|
20550
|
-
|
|
20924
|
+
var CheckCredentialProviderSchema = z28.union([
|
|
20925
|
+
z28.strictObject({ name: z28.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
|
|
20926
|
+
z28.strictObject({ name: z28.string(), problem: z28.string() })
|
|
20551
20927
|
]);
|
|
20552
|
-
var CheckProviderReachabilitySchema =
|
|
20553
|
-
|
|
20554
|
-
|
|
20928
|
+
var CheckProviderReachabilitySchema = z28.union([
|
|
20929
|
+
z28.strictObject({ name: z28.string(), baseUrl: z28.string(), ok: z28.literal(true) }),
|
|
20930
|
+
z28.strictObject({ name: z28.string(), baseUrl: z28.string(), ok: z28.literal(false), message: z28.string() })
|
|
20555
20931
|
]);
|
|
20556
|
-
var CheckCredentialSchema =
|
|
20557
|
-
applies:
|
|
20932
|
+
var CheckCredentialSchema = z28.strictObject({
|
|
20933
|
+
applies: z28.enum(CHECK_CREDENTIAL_APPLIES),
|
|
20558
20934
|
provider: CheckCredentialProviderSchema.optional(),
|
|
20559
20935
|
identity: CredentialSummarySchema.optional(),
|
|
20560
20936
|
identityCached: CachedCredentialStateSchema.optional()
|
|
20561
20937
|
});
|
|
20562
|
-
var CheckClaudeVersionSchema =
|
|
20563
|
-
pinned:
|
|
20564
|
-
highestInstalled:
|
|
20565
|
-
installed:
|
|
20938
|
+
var CheckClaudeVersionSchema = z28.strictObject({
|
|
20939
|
+
pinned: z28.strictObject({ version: z28.string(), source: z28.enum(CLAUDE_VERSION_SOURCES), installed: z28.boolean() }).optional(),
|
|
20940
|
+
highestInstalled: z28.string().optional(),
|
|
20941
|
+
installed: z28.readonly(z28.array(z28.string()))
|
|
20566
20942
|
});
|
|
20567
|
-
var CheckReportJsonSchema =
|
|
20568
|
-
identity:
|
|
20943
|
+
var CheckReportJsonSchema = z28.strictObject({
|
|
20944
|
+
identity: z28.strictObject({ name: z28.string().nullable(), source: z28.enum(IDENTITY_DECISION_SOURCES) }),
|
|
20569
20945
|
/** The pool ranking, when the launch named a pool instead of an identity. */
|
|
20570
20946
|
pool: PoolPickReportSchema.optional(),
|
|
20571
|
-
configProfile:
|
|
20572
|
-
layers:
|
|
20573
|
-
entries:
|
|
20574
|
-
projectEncodingAmbiguities:
|
|
20575
|
-
|
|
20947
|
+
configProfile: z28.strictObject({ name: z28.string().nullable(), source: z28.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
|
|
20948
|
+
layers: z28.readonly(z28.array(CheckLayerViewSchema)),
|
|
20949
|
+
entries: z28.readonly(z28.array(CheckEntryViewSchema)),
|
|
20950
|
+
projectEncodingAmbiguities: z28.readonly(
|
|
20951
|
+
z28.array(z28.strictObject({ fragment: z28.string(), encoded: z28.string(), reason: z28.enum(ENCODING_AMBIGUITY_REASONS), detail: z28.string() }))
|
|
20576
20952
|
),
|
|
20577
|
-
diagnostics:
|
|
20953
|
+
diagnostics: z28.readonly(z28.array(CheckDiagnosticSchema)),
|
|
20578
20954
|
ambientCredential: CheckAmbientCredentialSchema,
|
|
20579
20955
|
keychain: CheckKeychainSchema.optional(),
|
|
20580
|
-
settingsExposure:
|
|
20956
|
+
settingsExposure: z28.readonly(z28.array(CheckSettingsExposureSchema)),
|
|
20581
20957
|
credential: CheckCredentialSchema,
|
|
20582
20958
|
claudeVersion: CheckClaudeVersionSchema.optional(),
|
|
20583
20959
|
providerReachability: CheckProviderReachabilitySchema.optional()
|
|
@@ -20589,28 +20965,28 @@ init_preflight();
|
|
|
20589
20965
|
init_resets();
|
|
20590
20966
|
|
|
20591
20967
|
// src/usage/resetsSchema.ts
|
|
20592
|
-
import { z as
|
|
20593
|
-
var ResetRowSchema =
|
|
20594
|
-
identity:
|
|
20595
|
-
provider:
|
|
20968
|
+
import { z as z29 } from "zod";
|
|
20969
|
+
var ResetRowSchema = z29.strictObject({
|
|
20970
|
+
identity: z29.string(),
|
|
20971
|
+
provider: z29.string(),
|
|
20596
20972
|
/** What the window is: `5h`, `7d` or `extra usage` for an Anthropic account, or the provider's own measure and period (`tokens 5h`). */
|
|
20597
|
-
window:
|
|
20973
|
+
window: z29.string(),
|
|
20598
20974
|
/** When the state the window comes from was observed, as an ISO instant. */
|
|
20599
|
-
observedAt:
|
|
20975
|
+
observedAt: z29.iso.datetime(),
|
|
20600
20976
|
/** When the window resets, as an ISO instant; absent when the upstream reported none. */
|
|
20601
|
-
resetsAt:
|
|
20977
|
+
resetsAt: z29.iso.datetime().optional(),
|
|
20602
20978
|
/** True when the reset time has passed, so the recorded observation describes a window that no longer exists and its utilisation reads as 0. */
|
|
20603
|
-
reset:
|
|
20979
|
+
reset: z29.boolean(),
|
|
20604
20980
|
/** The fraction used, as `effectiveWindow` reads it at the report's own clock. */
|
|
20605
|
-
utilization:
|
|
20981
|
+
utilization: z29.number().optional(),
|
|
20606
20982
|
/** The window's own status, for a window that has not reset yet. */
|
|
20607
|
-
status:
|
|
20983
|
+
status: z29.string().optional()
|
|
20608
20984
|
});
|
|
20609
|
-
var ResetScheduleSchema =
|
|
20985
|
+
var ResetScheduleSchema = z29.strictObject({ resets: z29.readonly(z29.array(ResetRowSchema)) });
|
|
20610
20986
|
|
|
20611
20987
|
// src/frontdoor/controlSchemas.ts
|
|
20612
|
-
import
|
|
20613
|
-
import { z as
|
|
20988
|
+
import path45 from "node:path";
|
|
20989
|
+
import { z as z39 } from "zod";
|
|
20614
20990
|
|
|
20615
20991
|
// src/codex/doctor.ts
|
|
20616
20992
|
function codexIdentityFindings(entry, identity) {
|
|
@@ -20630,13 +21006,13 @@ init_identityRecords();
|
|
|
20630
21006
|
|
|
20631
21007
|
// src/doctorIdentityRecords.ts
|
|
20632
21008
|
init_identityRecords();
|
|
20633
|
-
import
|
|
21009
|
+
import path35 from "node:path";
|
|
20634
21010
|
function identityRecordFindings(records, displaced, nameRenames, strayNameRenameFiles) {
|
|
20635
21011
|
return [
|
|
20636
21012
|
...strayNameRenameFiles.map((file) => ({
|
|
20637
21013
|
severity: "warn",
|
|
20638
21014
|
message: `${file} holds the record of a rename of an identity's name, but not under the file name that rename keeps it in, so nothing reads it or removes it. Remove it.`,
|
|
20639
|
-
subject:
|
|
21015
|
+
subject: path35.basename(file)
|
|
20640
21016
|
})),
|
|
20641
21017
|
...nameRenames.map(({ from, description }) => ({ severity: "fail", message: description, subject: from })),
|
|
20642
21018
|
...duplicateIdentityNames(records).map(({ name, ids }) => ({
|
|
@@ -20662,7 +21038,7 @@ init_blockingSpawn();
|
|
|
20662
21038
|
init_realPorts();
|
|
20663
21039
|
init_doorBounds();
|
|
20664
21040
|
import fs10 from "node:fs";
|
|
20665
|
-
import
|
|
21041
|
+
import path36 from "node:path";
|
|
20666
21042
|
function realpathOrSelf(target) {
|
|
20667
21043
|
try {
|
|
20668
21044
|
return fs10.realpathSync(target);
|
|
@@ -20673,14 +21049,14 @@ function realpathOrSelf(target) {
|
|
|
20673
21049
|
var MAX_FORWARDING_SCRIPT_BYTES = 8192;
|
|
20674
21050
|
function resolveMiseDispatcher(target, pathDirs, env, trustedExecutable) {
|
|
20675
21051
|
const executable = realpathOrSelf(target);
|
|
20676
|
-
const trustedMise =
|
|
20677
|
-
if (
|
|
20678
|
-
const result = spawnSyncBlocking("a mise shim lookup", executable, ["which",
|
|
21052
|
+
const trustedMise = path36.join(path36.dirname(trustedExecutable), "mise");
|
|
21053
|
+
if (path36.basename(executable) !== "mise" || realpathOrSelf(trustedMise) !== executable) return void 0;
|
|
21054
|
+
const result = spawnSyncBlocking("a mise shim lookup", executable, ["which", path36.basename(target)], { encoding: "utf8", env, timeout: BLOCKING_STEP_TIMEOUTS_MS.miseLookup });
|
|
20679
21055
|
if (result.error !== void 0) return void 0;
|
|
20680
21056
|
if (result.status === 0 && result.stdout.trim() !== "") return result.stdout.trim();
|
|
20681
21057
|
if (!result.stderr.includes("not currently active")) return void 0;
|
|
20682
21058
|
for (const dir of pathDirs) {
|
|
20683
|
-
const candidate = findExecutableInDir(dir,
|
|
21059
|
+
const candidate = findExecutableInDir(dir, path36.basename(target));
|
|
20684
21060
|
if (candidate !== void 0 && realpathOrSelf(candidate) !== executable) {
|
|
20685
21061
|
try {
|
|
20686
21062
|
const script = fs10.statSync(candidate).size <= MAX_FORWARDING_SCRIPT_BYTES ? realFsPort.readFileUtf8(candidate) : void 0;
|
|
@@ -20699,7 +21075,7 @@ init_signIn();
|
|
|
20699
21075
|
init_identityAccounts();
|
|
20700
21076
|
init_read();
|
|
20701
21077
|
init_providerReachability();
|
|
20702
|
-
import
|
|
21078
|
+
import path44 from "node:path";
|
|
20703
21079
|
|
|
20704
21080
|
// src/doctorNameFinding.ts
|
|
20705
21081
|
init_names();
|
|
@@ -20761,10 +21137,10 @@ var CODEX_CATEGORIES = {
|
|
|
20761
21137
|
|
|
20762
21138
|
// src/codex/identity.ts
|
|
20763
21139
|
init_envBool();
|
|
20764
|
-
import
|
|
21140
|
+
import path37 from "node:path";
|
|
20765
21141
|
var CODEX_AMBIENT_CREDENTIALS = ["OPENAI_API_KEY", "CODEX_API_KEY", "CODEX_ACCESS_TOKEN", "OPENAI_IDENTITY_TOKEN_FILE", "OPENAI_FEDERATION_RULE_ID"];
|
|
20766
21142
|
function canonicalCodexHome(env, home) {
|
|
20767
|
-
return
|
|
21143
|
+
return path37.resolve(env.AGENT_SHIM_CODEX_HOME === void 0 || env.AGENT_SHIM_CODEX_HOME === "" ? path37.join(home, ".codex") : env.AGENT_SHIM_CODEX_HOME);
|
|
20768
21144
|
}
|
|
20769
21145
|
function codexCredentialGuard(env, allowAmbientCredential) {
|
|
20770
21146
|
const variable = CODEX_AMBIENT_CREDENTIALS.find((key) => (env[key] ?? "") !== "");
|
|
@@ -20915,8 +21291,8 @@ init_providersStore();
|
|
|
20915
21291
|
init_projects();
|
|
20916
21292
|
init_injected();
|
|
20917
21293
|
init_pipeline();
|
|
20918
|
-
import
|
|
20919
|
-
import { z as
|
|
21294
|
+
import path41 from "node:path";
|
|
21295
|
+
import { z as z32 } from "zod";
|
|
20920
21296
|
var HISTORY_PROJECTS_KEY_PREFIX = "history/projects/";
|
|
20921
21297
|
function projectFragmentOf(rawKey) {
|
|
20922
21298
|
return rawKey.startsWith(HISTORY_PROJECTS_KEY_PREFIX) ? rawKey.slice(HISTORY_PROJECTS_KEY_PREFIX.length) : void 0;
|
|
@@ -20985,9 +21361,9 @@ function lookupKeychainService(run, farmRoot) {
|
|
|
20985
21361
|
}
|
|
20986
21362
|
return { checked: true, found: true, serviceName, note: `Keychain service name for this identity: "${serviceName}".` };
|
|
20987
21363
|
}
|
|
20988
|
-
var SettingsSecretsShapeSchema =
|
|
20989
|
-
env:
|
|
20990
|
-
hooks:
|
|
21364
|
+
var SettingsSecretsShapeSchema = z32.looseObject({
|
|
21365
|
+
env: z32.record(z32.string(), z32.unknown()).optional(),
|
|
21366
|
+
hooks: z32.record(z32.string(), z32.array(z32.unknown())).optional()
|
|
20991
21367
|
});
|
|
20992
21368
|
function hookCommandCountOf(group) {
|
|
20993
21369
|
if (typeof group !== "object" || group === null) {
|
|
@@ -21267,10 +21643,10 @@ function collectCheckReport(params) {
|
|
|
21267
21643
|
const providerName = cascadeProviderName(cascade, identityConfig?.provider);
|
|
21268
21644
|
const provider = providerName === void 0 ? void 0 : loadCheckProvider(paths, providerName);
|
|
21269
21645
|
const identityId = identityDecision.name === void 0 ? void 0 : identityIdOf(paths, identityDecision.name);
|
|
21270
|
-
const farmRoot = identityId === void 0 ? void 0 :
|
|
21646
|
+
const farmRoot = identityId === void 0 ? void 0 : path41.join(paths.identitiesDir, identityId);
|
|
21271
21647
|
const settingsFiles = isCodex ? {} : {
|
|
21272
|
-
"settings.json": realFsPort.readFileUtf8(
|
|
21273
|
-
"settings.local.json": realFsPort.readFileUtf8(
|
|
21648
|
+
"settings.json": realFsPort.readFileUtf8(path41.join(claudeHome, "settings.json")),
|
|
21649
|
+
"settings.local.json": realFsPort.readFileUtf8(path41.join(claudeHome, "settings.local.json"))
|
|
21274
21650
|
};
|
|
21275
21651
|
const report = runCheck({
|
|
21276
21652
|
...isCodex ? { agent: "codex" } : {},
|
|
@@ -21797,7 +22173,7 @@ function tcpPortEraRecord(raw) {
|
|
|
21797
22173
|
return (has("port") || has("lastPort")) && !has("socketPath");
|
|
21798
22174
|
}
|
|
21799
22175
|
function pushPathResolution(push, resolution) {
|
|
21800
|
-
const ownDir =
|
|
22176
|
+
const ownDir = path44.dirname(resolution.ownExecutablePath);
|
|
21801
22177
|
switch (resolution.agentShim.status) {
|
|
21802
22178
|
case "ok":
|
|
21803
22179
|
push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
|
|
@@ -21917,14 +22293,14 @@ function pushProvider(push, entry, cacheEnv, signIn, unreachable) {
|
|
|
21917
22293
|
}
|
|
21918
22294
|
function pushLegacyName(push, params) {
|
|
21919
22295
|
const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
|
|
21920
|
-
if (legacyVariables.length === 0 &&
|
|
22296
|
+
if (legacyVariables.length === 0 && path44.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
|
|
21921
22297
|
push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
|
|
21922
22298
|
return;
|
|
21923
22299
|
}
|
|
21924
22300
|
for (const name of legacyVariables) {
|
|
21925
22301
|
push("legacy-name", "warn", `${name} is the former name of ${name.replace(LEGACY_ENV_PREFIX, ENV_PREFIX)}. Rename it; the old name still works but is only a fallback.`, name);
|
|
21926
22302
|
}
|
|
21927
|
-
if (
|
|
22303
|
+
if (path44.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
|
|
21928
22304
|
push(
|
|
21929
22305
|
"legacy-name",
|
|
21930
22306
|
"warn",
|
|
@@ -22014,7 +22390,7 @@ function runDoctor(params) {
|
|
|
22014
22390
|
push("identity", "warn", `identities/${name} cannot be reached (${code}), so it is not counted as an identity. Repair the permissions of the directory or of what a symlink points through, or remove the entry.`, name);
|
|
22015
22391
|
}
|
|
22016
22392
|
for (const { file, detail } of params.renameJournals?.unreadable ?? []) {
|
|
22017
|
-
push("identity", "fail", `${file} is not a rename journal this agent-shim can read (${detail}), so no identity can be renamed until it is fixed or removed, and it may be the trace of a rename that was left unfinished.`,
|
|
22393
|
+
push("identity", "fail", `${file} is not a rename journal this agent-shim can read (${detail}), so no identity can be renamed until it is fixed or removed, and it may be the trace of a rename that was left unfinished.`, path44.basename(file));
|
|
22018
22394
|
}
|
|
22019
22395
|
const validIdentityAgents = /* @__PURE__ */ new Map();
|
|
22020
22396
|
const signedInAccounts = [];
|
|
@@ -22312,9 +22688,9 @@ function collectDoctorReport(params) {
|
|
|
22312
22688
|
const { names: identityNames, unreachable: unreachableIdentities } = listIdentityDirectories(paths);
|
|
22313
22689
|
const records = identityRecords(paths);
|
|
22314
22690
|
const displacedIdentities = records.filter((record) => !identityIdExists(paths, record.id) && !unreachableIdentities.some((entry) => entry.name === record.id));
|
|
22315
|
-
const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !fs14.existsSync(
|
|
22316
|
-
const farmRoot =
|
|
22317
|
-
const identityPath =
|
|
22691
|
+
const identities = identityNames.filter((id) => (records.some((record) => record.id === id) || !fs14.existsSync(path44.join(paths.identitiesDir, id, "identity.json"))) && !displacedIdentities.some((record) => record.id === id)).map((id) => {
|
|
22692
|
+
const farmRoot = path44.join(paths.identitiesDir, id);
|
|
22693
|
+
const identityPath = path44.join(farmRoot, "identity.json");
|
|
22318
22694
|
return { name: identityNameIn(records, id) ?? id, id, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: fs14.existsSync(credentialsFilePath(farmRoot)), account: readIdentityAccount(realFsPort, paths.identitiesDir, id)?.account };
|
|
22319
22695
|
});
|
|
22320
22696
|
const usageSnapshots = {};
|
|
@@ -22332,12 +22708,12 @@ function collectDoctorReport(params) {
|
|
|
22332
22708
|
}
|
|
22333
22709
|
const profileNames = fs14.existsSync(paths.configProfilesDir) ? fs14.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
22334
22710
|
const configProfiles = profileNames.map((name) => {
|
|
22335
|
-
const profilePath =
|
|
22711
|
+
const profilePath = path44.join(paths.configProfilesDir, `${name}.json`);
|
|
22336
22712
|
return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
|
|
22337
22713
|
});
|
|
22338
22714
|
const providerNames = fs14.existsSync(paths.providersDir) ? fs14.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
|
|
22339
22715
|
const providers = providerNames.map((name) => {
|
|
22340
|
-
const providerPath =
|
|
22716
|
+
const providerPath = path44.join(paths.providersDir, `${name}.json`);
|
|
22341
22717
|
return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
|
|
22342
22718
|
});
|
|
22343
22719
|
const ownExecutablePath = realOwnExecutablePath();
|
|
@@ -22349,12 +22725,12 @@ function collectDoctorReport(params) {
|
|
|
22349
22725
|
binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
|
|
22350
22726
|
}
|
|
22351
22727
|
const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
|
|
22352
|
-
const pathDirs = (params.env.PATH ?? "").split(
|
|
22728
|
+
const pathDirs = (params.env.PATH ?? "").split(path44.delimiter).filter((dir) => dir !== "");
|
|
22353
22729
|
const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
|
|
22354
22730
|
findPathShadow({
|
|
22355
22731
|
pathDirs,
|
|
22356
|
-
targetDir:
|
|
22357
|
-
targetFilename:
|
|
22732
|
+
targetDir: path44.dirname(shimState.targetPath),
|
|
22733
|
+
targetFilename: path44.basename(shimState.targetPath),
|
|
22358
22734
|
findExecutableInDir
|
|
22359
22735
|
}),
|
|
22360
22736
|
shimState.targetPath,
|
|
@@ -22383,7 +22759,7 @@ function collectDoctorReport(params) {
|
|
|
22383
22759
|
catalogueRedirects: providersWithRedirectedCatalogue(realFarmFs, paths, new Map(providers.map((entry) => [entry.name, currentCatalogueSettings(paths, entry.name)]))),
|
|
22384
22760
|
renameJournals: listRenameJournals(realFarmFs, paths.identityRenamesDir),
|
|
22385
22761
|
unreachableIdentities,
|
|
22386
|
-
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: fs14.existsSync(
|
|
22762
|
+
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: fs14.existsSync(path44.join(paths.identitiesDir, record.id)) })), nameRenames: unfinishedNameRenames(paths).map((record) => ({ from: record.from, description: describeInterruptedNameRename(paths, record) })), strayNameRenameFiles: strayNameRenameRecordFiles(paths) },
|
|
22387
22763
|
directoryRules: { path: paths.directoryRulesFile, raw: realFsPort.readFileUtf8(paths.directoryRulesFile) },
|
|
22388
22764
|
globalConfig: { path: paths.globalConfigFile, raw: realFsPort.readFileUtf8(paths.globalConfigFile) },
|
|
22389
22765
|
models: readableOr(() => readGlobalConfig(paths)?.models, void 0),
|
|
@@ -22398,7 +22774,7 @@ function collectDoctorReport(params) {
|
|
|
22398
22774
|
agentShim: refinePathShadow(
|
|
22399
22775
|
findPathShadow({
|
|
22400
22776
|
pathDirs,
|
|
22401
|
-
targetDir:
|
|
22777
|
+
targetDir: path44.dirname(ownExecutablePath),
|
|
22402
22778
|
targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
|
|
22403
22779
|
findExecutableInDir
|
|
22404
22780
|
}),
|
|
@@ -22441,93 +22817,93 @@ function collectDoctorReport(params) {
|
|
|
22441
22817
|
init_schema2();
|
|
22442
22818
|
init_rcSchemas();
|
|
22443
22819
|
init_state();
|
|
22444
|
-
var UsageListOutputSchema =
|
|
22445
|
-
var UsageWindowsInputSchema =
|
|
22446
|
-
identity:
|
|
22447
|
-
provider:
|
|
22820
|
+
var UsageListOutputSchema = z39.strictObject({ snapshots: z39.readonly(z39.array(UsageSnapshotSchema)) });
|
|
22821
|
+
var UsageWindowsInputSchema = z39.strictObject({
|
|
22822
|
+
identity: z39.string().min(1),
|
|
22823
|
+
provider: z39.string().min(1).optional()
|
|
22448
22824
|
});
|
|
22449
|
-
var EffectiveWindowSchema =
|
|
22825
|
+
var EffectiveWindowSchema = z39.strictObject({
|
|
22450
22826
|
/** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
|
|
22451
|
-
reset:
|
|
22827
|
+
reset: z39.boolean(),
|
|
22452
22828
|
/** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
|
|
22453
|
-
utilization:
|
|
22829
|
+
utilization: z39.number().optional(),
|
|
22454
22830
|
/** The reset instant, for a window that has not reset yet and reported one. */
|
|
22455
|
-
resetsAtMs:
|
|
22831
|
+
resetsAtMs: z39.number().optional(),
|
|
22456
22832
|
/** The window's own status, for a window that has not reset yet. */
|
|
22457
|
-
status:
|
|
22833
|
+
status: z39.string().optional()
|
|
22458
22834
|
});
|
|
22459
|
-
var UsageWindowsOutputSchema =
|
|
22460
|
-
identity:
|
|
22461
|
-
provider:
|
|
22835
|
+
var UsageWindowsOutputSchema = z39.strictObject({
|
|
22836
|
+
identity: z39.string(),
|
|
22837
|
+
provider: z39.string(),
|
|
22462
22838
|
/** When the rate-limit state the windows come from was observed. */
|
|
22463
|
-
observedAt:
|
|
22839
|
+
observedAt: z39.iso.datetime().optional(),
|
|
22464
22840
|
fiveHour: EffectiveWindowSchema.optional(),
|
|
22465
22841
|
sevenDay: EffectiveWindowSchema.optional()
|
|
22466
22842
|
});
|
|
22467
|
-
var UsageLiveOutputSchema =
|
|
22843
|
+
var UsageLiveOutputSchema = z39.strictObject({
|
|
22468
22844
|
/** The freshest observation the door holds, never narrowed by the read's session filter because it is the door's single latest statement of the account's quota; absent while no rate_limit_event has been filed at all. */
|
|
22469
22845
|
latest: RcLiveRateLimitSchema.optional(),
|
|
22470
22846
|
/** One observation per session whose stream has filed a rate_limit_event this door generation. */
|
|
22471
|
-
sessions:
|
|
22847
|
+
sessions: z39.readonly(z39.array(RcLiveRateLimitSchema))
|
|
22472
22848
|
});
|
|
22473
|
-
var FrontDoorSessionStatusSchema =
|
|
22474
|
-
pid:
|
|
22475
|
-
startedAt:
|
|
22476
|
-
alive:
|
|
22849
|
+
var FrontDoorSessionStatusSchema = z39.strictObject({
|
|
22850
|
+
pid: z39.int().positive(),
|
|
22851
|
+
startedAt: z39.number(),
|
|
22852
|
+
alive: z39.boolean()
|
|
22477
22853
|
});
|
|
22478
|
-
var HeadroomSocketTargetSchema =
|
|
22479
|
-
var FrontDoorStatusOutputSchema =
|
|
22854
|
+
var HeadroomSocketTargetSchema = z39.union([z39.strictObject({ socketPath: z39.string() }), z39.strictObject({ refused: z39.string() })]);
|
|
22855
|
+
var FrontDoorStatusOutputSchema = z39.strictObject({
|
|
22480
22856
|
state: FrontDoorStateSchema,
|
|
22481
|
-
supervisorAlive:
|
|
22857
|
+
supervisorAlive: z39.boolean(),
|
|
22482
22858
|
/** The pids of earlier doors that released their addresses and are finishing the connections they carried: running, but not serving anything new. */
|
|
22483
|
-
draining:
|
|
22484
|
-
sessions:
|
|
22859
|
+
draining: z39.readonly(z39.array(z39.number().int().positive())),
|
|
22860
|
+
sessions: z39.readonly(z39.array(FrontDoorSessionStatusSchema)),
|
|
22485
22861
|
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
22486
|
-
logPath:
|
|
22487
|
-
logExists:
|
|
22862
|
+
logPath: z39.string(),
|
|
22863
|
+
logExists: z39.boolean()
|
|
22488
22864
|
});
|
|
22489
|
-
var FrontDoorSessionsOutputSchema =
|
|
22865
|
+
var FrontDoorSessionsOutputSchema = z39.strictObject({ sessions: z39.readonly(z39.array(FrontDoorSessionStatusSchema)) });
|
|
22490
22866
|
var DOOR_REPORT_ENVIRONMENT_NOTE = "The report is collected in a worker thread of the door under the door's own environment and PATH, as a launch the door plans for itself would inherit them, not under the caller's shell: the identity is the caller's to name, the cascade is read from files at the path, and the environment-driven findings (AGENT_SHIM_IDENTITY, AGENT_SHIM_CONFIG_PROFILE, the Claude Code version pin, the ambient-credential check, and for doctor the PATH and shim findings) describe the door's launch. Run agent-shim check or agent-shim doctor from a shell for the caller's own reading.";
|
|
22491
|
-
var CheckRunInputSchema =
|
|
22492
|
-
path:
|
|
22493
|
-
identity:
|
|
22494
|
-
}).refine((input) =>
|
|
22495
|
-
var PoolPickInputSchema =
|
|
22496
|
-
pool:
|
|
22497
|
-
path:
|
|
22498
|
-
}).refine((input) =>
|
|
22499
|
-
var DoctorFindingSchema =
|
|
22500
|
-
section:
|
|
22501
|
-
subject:
|
|
22502
|
-
severity:
|
|
22503
|
-
message:
|
|
22504
|
-
});
|
|
22505
|
-
var DoctorRunOutputSchema =
|
|
22867
|
+
var CheckRunInputSchema = z39.strictObject({
|
|
22868
|
+
path: z39.string().min(1),
|
|
22869
|
+
identity: z39.string().min(1).optional()
|
|
22870
|
+
}).refine((input) => path45.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
22871
|
+
var PoolPickInputSchema = z39.strictObject({
|
|
22872
|
+
pool: z39.string().min(1),
|
|
22873
|
+
path: z39.string().min(1)
|
|
22874
|
+
}).refine((input) => path45.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
22875
|
+
var DoctorFindingSchema = z39.strictObject({
|
|
22876
|
+
section: z39.enum(DOCTOR_SECTIONS),
|
|
22877
|
+
subject: z39.string().optional(),
|
|
22878
|
+
severity: z39.enum(DOCTOR_SEVERITIES),
|
|
22879
|
+
message: z39.string()
|
|
22880
|
+
});
|
|
22881
|
+
var DoctorRunOutputSchema = z39.strictObject({
|
|
22506
22882
|
/** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
|
|
22507
|
-
ok:
|
|
22508
|
-
findings:
|
|
22509
|
-
});
|
|
22510
|
-
var FrontDoorRestartOutputSchema =
|
|
22511
|
-
action:
|
|
22512
|
-
previousPid:
|
|
22513
|
-
});
|
|
22514
|
-
var UpdateCheckOutputSchema =
|
|
22515
|
-
current:
|
|
22516
|
-
latest:
|
|
22517
|
-
action:
|
|
22518
|
-
});
|
|
22519
|
-
var CodexSignInSchema =
|
|
22520
|
-
|
|
22521
|
-
|
|
22522
|
-
|
|
22883
|
+
ok: z39.boolean(),
|
|
22884
|
+
findings: z39.readonly(z39.array(DoctorFindingSchema))
|
|
22885
|
+
});
|
|
22886
|
+
var FrontDoorRestartOutputSchema = z39.strictObject({
|
|
22887
|
+
action: z39.literal("restarting"),
|
|
22888
|
+
previousPid: z39.int().positive()
|
|
22889
|
+
});
|
|
22890
|
+
var UpdateCheckOutputSchema = z39.strictObject({
|
|
22891
|
+
current: z39.string(),
|
|
22892
|
+
latest: z39.string(),
|
|
22893
|
+
action: z39.enum(["current", "available", "updated"])
|
|
22894
|
+
});
|
|
22895
|
+
var CodexSignInSchema = z39.discriminatedUnion("state", [
|
|
22896
|
+
z39.strictObject({ state: z39.literal("none") }),
|
|
22897
|
+
z39.strictObject({ state: z39.literal("signed-in"), email: z39.string().optional(), planScope: z39.boolean(), accessTokenExpiresAt: z39.number() }),
|
|
22898
|
+
z39.strictObject({ state: z39.literal("unreadable"), message: z39.string() })
|
|
22523
22899
|
]);
|
|
22524
|
-
var CodexStatusOutputSchema =
|
|
22900
|
+
var CodexStatusOutputSchema = z39.strictObject({
|
|
22525
22901
|
signIn: CodexSignInSchema,
|
|
22526
|
-
codexProviders:
|
|
22902
|
+
codexProviders: z39.readonly(z39.array(z39.string()))
|
|
22527
22903
|
});
|
|
22528
|
-
var CodexLogoutOutputSchema =
|
|
22529
|
-
hadGrant:
|
|
22530
|
-
revoked:
|
|
22904
|
+
var CodexLogoutOutputSchema = z39.strictObject({
|
|
22905
|
+
hadGrant: z39.boolean(),
|
|
22906
|
+
revoked: z39.boolean()
|
|
22531
22907
|
});
|
|
22532
22908
|
|
|
22533
22909
|
// src/frontdoor/codexApi.ts
|
|
@@ -22548,21 +22924,21 @@ function createCodexApiRouter(deps) {
|
|
|
22548
22924
|
|
|
22549
22925
|
// src/frontdoor/doorWorker.ts
|
|
22550
22926
|
import { getAsset, isSea as isSea2 } from "node:sea";
|
|
22551
|
-
import { z as
|
|
22927
|
+
import { z as z41 } from "zod";
|
|
22552
22928
|
init_cliError();
|
|
22553
22929
|
init_doorBounds();
|
|
22554
22930
|
init_providerCatalogue();
|
|
22555
22931
|
|
|
22556
22932
|
// src/frontdoor/doorWorkerProtocol.ts
|
|
22557
22933
|
init_providerCatalogue();
|
|
22558
|
-
import { z as
|
|
22934
|
+
import { z as z40 } from "zod";
|
|
22559
22935
|
var doorWorkerInputSchemas = {
|
|
22560
22936
|
/** `agent-shim check` for `path` as `identity` (the identity a launch there would resolve when absent). */
|
|
22561
|
-
check:
|
|
22937
|
+
check: z40.strictObject({ root: z40.string().min(1), path: z40.string().min(1), identity: z40.string().min(1).optional() }),
|
|
22562
22938
|
/** `agent-shim doctor`. */
|
|
22563
|
-
doctor:
|
|
22939
|
+
doctor: z40.strictObject({ root: z40.string().min(1) }),
|
|
22564
22940
|
/** Fetch and store one provider's model catalogue for the door generation that asked. */
|
|
22565
|
-
"refresh-catalogue":
|
|
22941
|
+
"refresh-catalogue": z40.strictObject({ root: z40.string().min(1), name: z40.string().min(1), supervisorPid: z40.int().positive(), generation: z40.uuid() })
|
|
22566
22942
|
};
|
|
22567
22943
|
|
|
22568
22944
|
// src/frontdoor/doorWorker.ts
|
|
@@ -22656,68 +23032,68 @@ init_schema();
|
|
|
22656
23032
|
init_names();
|
|
22657
23033
|
init_keychainLogin();
|
|
22658
23034
|
init_statusline();
|
|
22659
|
-
import { z as
|
|
22660
|
-
var RemovalConfirmationSchema =
|
|
22661
|
-
var CredentialWriteSchema = (targets) =>
|
|
22662
|
-
sources:
|
|
22663
|
-
target:
|
|
22664
|
-
cache:
|
|
22665
|
-
});
|
|
22666
|
-
var CredentialSummarySchema2 =
|
|
22667
|
-
target:
|
|
22668
|
-
sources:
|
|
22669
|
-
|
|
22670
|
-
|
|
22671
|
-
|
|
22672
|
-
|
|
22673
|
-
|
|
22674
|
-
|
|
22675
|
-
|
|
23035
|
+
import { z as z42 } from "zod";
|
|
23036
|
+
var RemovalConfirmationSchema = z42.boolean();
|
|
23037
|
+
var CredentialWriteSchema = (targets) => z42.strictObject({
|
|
23038
|
+
sources: z42.array(RemoteCredentialSourceSchema).min(1).optional(),
|
|
23039
|
+
target: z42.enum(targets).optional(),
|
|
23040
|
+
cache: z42.union([z42.literal(false), CredentialCacheSchema]).optional()
|
|
23041
|
+
});
|
|
23042
|
+
var CredentialSummarySchema2 = z42.strictObject({
|
|
23043
|
+
target: z42.enum(CREDENTIAL_TARGETS),
|
|
23044
|
+
sources: z42.readonly(z42.array(
|
|
23045
|
+
z42.discriminatedUnion("kind", [
|
|
23046
|
+
z42.strictObject({ kind: z42.literal("env"), variable: z42.string() }),
|
|
23047
|
+
z42.strictObject({ kind: z42.literal("file"), path: z42.string() }),
|
|
23048
|
+
z42.strictObject({ kind: z42.literal("command"), program: z42.string() }),
|
|
23049
|
+
z42.strictObject({ kind: z42.literal("op"), reference: z42.string() }),
|
|
23050
|
+
z42.strictObject({ kind: z42.literal("keychain"), service: z42.string(), account: z42.string().optional() }),
|
|
23051
|
+
z42.strictObject({ kind: z42.literal("literal") })
|
|
22676
23052
|
])
|
|
22677
23053
|
)),
|
|
22678
23054
|
cache: CredentialCacheSchema.optional()
|
|
22679
23055
|
});
|
|
22680
|
-
var mutationOutput = (kind, action) =>
|
|
22681
|
-
var storedMutationOutput = (kind, action, value) =>
|
|
22682
|
-
var IdentityValueSchema =
|
|
22683
|
-
agent:
|
|
22684
|
-
name:
|
|
22685
|
-
label:
|
|
22686
|
-
defaultConfigProfile:
|
|
22687
|
-
provider:
|
|
22688
|
-
allowAmbientCredential:
|
|
23056
|
+
var mutationOutput = (kind, action) => z42.strictObject({ action: z42.literal(action), kind: z42.literal(kind), name: z42.string() });
|
|
23057
|
+
var storedMutationOutput = (kind, action, value) => z42.strictObject({ action: z42.literal(action), kind: z42.literal(kind), name: z42.string(), value });
|
|
23058
|
+
var IdentityValueSchema = z42.strictObject({
|
|
23059
|
+
agent: z42.enum(["claude", "codex"]).optional(),
|
|
23060
|
+
name: z42.string(),
|
|
23061
|
+
label: z42.string().optional(),
|
|
23062
|
+
defaultConfigProfile: z42.string().optional(),
|
|
23063
|
+
provider: z42.string().optional(),
|
|
23064
|
+
allowAmbientCredential: z42.boolean(),
|
|
22689
23065
|
credential: CredentialSummarySchema2.optional(),
|
|
22690
|
-
anchors:
|
|
23066
|
+
anchors: z42.array(AnchorSchema).optional()
|
|
22691
23067
|
});
|
|
22692
23068
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
22693
|
-
var ProviderValueSchema =
|
|
22694
|
-
name:
|
|
22695
|
-
kind:
|
|
22696
|
-
displayName:
|
|
22697
|
-
baseUrl:
|
|
23069
|
+
var ProviderValueSchema = z42.strictObject({
|
|
23070
|
+
name: z42.string(),
|
|
23071
|
+
kind: z42.enum(PROVIDER_KINDS),
|
|
23072
|
+
displayName: z42.string(),
|
|
23073
|
+
baseUrl: z42.string().optional(),
|
|
22698
23074
|
codex: CodexProviderConfigSchema.optional(),
|
|
22699
23075
|
credential: CredentialSummarySchema2.optional(),
|
|
22700
|
-
env:
|
|
23076
|
+
env: z42.record(z42.string(), z42.string()).optional()
|
|
22701
23077
|
});
|
|
22702
|
-
var ConfigNameInputSchema =
|
|
22703
|
-
var ConfigIdentityAddInputSchema =
|
|
23078
|
+
var ConfigNameInputSchema = z42.strictObject({ name: z42.string().min(1) });
|
|
23079
|
+
var ConfigIdentityAddInputSchema = z42.strictObject({ name: z42.string().min(1), keepKeychainLogin: z42.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
|
|
22704
23080
|
var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
|
|
22705
|
-
var ConfigIdentitySetInputSchema =
|
|
22706
|
-
name:
|
|
23081
|
+
var ConfigIdentitySetInputSchema = z42.strictObject({
|
|
23082
|
+
name: z42.string().min(1),
|
|
22707
23083
|
/** The identity's display label; `false` clears it. */
|
|
22708
|
-
label:
|
|
22709
|
-
defaultConfigProfile:
|
|
23084
|
+
label: z42.union([IdentityLabelSchema, z42.literal(false)]).optional(),
|
|
23085
|
+
defaultConfigProfile: z42.union([z42.string().min(1), z42.literal(false)]).optional(),
|
|
22710
23086
|
/** The provider the identity exists for; `false` clears it. */
|
|
22711
|
-
provider:
|
|
22712
|
-
allowAmbientCredential:
|
|
22713
|
-
credential:
|
|
23087
|
+
provider: z42.union([z42.string().min(1), z42.literal(false)]).optional(),
|
|
23088
|
+
allowAmbientCredential: z42.boolean().optional(),
|
|
23089
|
+
credential: z42.union([z42.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
|
|
22714
23090
|
/** `false` removes the anchors; a list replaces them. */
|
|
22715
|
-
anchors:
|
|
23091
|
+
anchors: z42.union([z42.literal(false), z42.array(AnchorSchema).min(1)]).optional()
|
|
22716
23092
|
});
|
|
22717
23093
|
var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
|
|
22718
|
-
var ConfigIdentityRemoveInputSchema =
|
|
23094
|
+
var ConfigIdentityRemoveInputSchema = z42.strictObject({ name: z42.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22719
23095
|
var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
|
|
22720
|
-
var ConfigStatuslineSetSchema =
|
|
23096
|
+
var ConfigStatuslineSetSchema = z42.record(z42.string(), z42.unknown()).superRefine((settings, context) => {
|
|
22721
23097
|
for (const key of Object.keys(settings)) {
|
|
22722
23098
|
if (key === STATUSLINE_EXTRA_GROUP || key.startsWith(`${STATUSLINE_EXTRA_GROUP}.`)) {
|
|
22723
23099
|
context.addIssue({ code: "custom", path: [key], message: `a config write through the API cannot set "${key}": the extra segment's command runs a program, so only your own configuration (the global config, a profile you edit yourself, a directory rule or a command-line assignment) may set it` });
|
|
@@ -22725,93 +23101,93 @@ var ConfigStatuslineSetSchema = z41.record(z41.string(), z41.unknown()).superRef
|
|
|
22725
23101
|
}
|
|
22726
23102
|
});
|
|
22727
23103
|
var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
|
|
22728
|
-
var ConfigProfileAddInputSchema =
|
|
22729
|
-
name:
|
|
22730
|
-
extends:
|
|
22731
|
-
description:
|
|
23104
|
+
var ConfigProfileAddInputSchema = z42.strictObject({
|
|
23105
|
+
name: z42.string().min(1),
|
|
23106
|
+
extends: z42.array(z42.string().min(1)).optional(),
|
|
23107
|
+
description: z42.string().optional()
|
|
22732
23108
|
});
|
|
22733
23109
|
var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
|
|
22734
|
-
var ConfigProfileSetInputSchema =
|
|
22735
|
-
name:
|
|
22736
|
-
category:
|
|
22737
|
-
entry:
|
|
22738
|
-
extends:
|
|
22739
|
-
description:
|
|
22740
|
-
launch:
|
|
22741
|
-
skipPermissions:
|
|
22742
|
-
remoteControl:
|
|
22743
|
-
headroom:
|
|
22744
|
-
trackUsage:
|
|
22745
|
-
provider:
|
|
22746
|
-
claudeVersion:
|
|
22747
|
-
delay:
|
|
22748
|
-
pause:
|
|
22749
|
-
explain:
|
|
22750
|
-
proxyBypass:
|
|
22751
|
-
statusline:
|
|
23110
|
+
var ConfigProfileSetInputSchema = z42.strictObject({
|
|
23111
|
+
name: z42.string().min(1),
|
|
23112
|
+
category: z42.record(z42.string(), z42.boolean()).optional(),
|
|
23113
|
+
entry: z42.record(z42.string(), z42.boolean()).optional(),
|
|
23114
|
+
extends: z42.union([z42.array(z42.string().min(1)), z42.literal(false)]).optional(),
|
|
23115
|
+
description: z42.union([z42.string(), z42.literal(false)]).optional(),
|
|
23116
|
+
launch: z42.strictObject({
|
|
23117
|
+
skipPermissions: z42.boolean().optional(),
|
|
23118
|
+
remoteControl: z42.boolean().optional(),
|
|
23119
|
+
headroom: z42.boolean().optional(),
|
|
23120
|
+
trackUsage: z42.boolean().optional(),
|
|
23121
|
+
provider: z42.union([z42.string().min(1), z42.literal(false)]).optional(),
|
|
23122
|
+
claudeVersion: z42.union([z42.string().min(1), z42.literal(false)]).optional(),
|
|
23123
|
+
delay: z42.union([z42.string().regex(DURATION_RE), z42.literal(false)]).optional(),
|
|
23124
|
+
pause: z42.boolean().optional(),
|
|
23125
|
+
explain: z42.boolean().optional(),
|
|
23126
|
+
proxyBypass: z42.union([z42.array(z42.string().min(1)), z42.literal(false)]).optional(),
|
|
23127
|
+
statusline: z42.strictObject({
|
|
22752
23128
|
set: ConfigStatuslineSetSchema.optional(),
|
|
22753
|
-
unset:
|
|
23129
|
+
unset: z42.array(z42.string()).optional()
|
|
22754
23130
|
}).optional()
|
|
22755
23131
|
}).optional()
|
|
22756
23132
|
});
|
|
22757
23133
|
var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
|
|
22758
|
-
var ConfigProfileRemoveInputSchema =
|
|
23134
|
+
var ConfigProfileRemoveInputSchema = z42.strictObject({ name: z42.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22759
23135
|
var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
|
|
22760
23136
|
var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
|
|
22761
|
-
var PoolMembersInputSchema =
|
|
22762
|
-
var ConfigPoolAddInputSchema =
|
|
22763
|
-
name:
|
|
23137
|
+
var PoolMembersInputSchema = z42.array(z42.string().min(1)).min(1);
|
|
23138
|
+
var ConfigPoolAddInputSchema = z42.strictObject({
|
|
23139
|
+
name: z42.string().min(1),
|
|
22764
23140
|
identities: PoolMembersInputSchema,
|
|
22765
|
-
preference:
|
|
22766
|
-
resumeOnLimit:
|
|
22767
|
-
compactBeforeLimit:
|
|
23141
|
+
preference: z42.enum(POOL_PREFERENCES).optional(),
|
|
23142
|
+
resumeOnLimit: z42.boolean().optional(),
|
|
23143
|
+
compactBeforeLimit: z42.boolean().optional(),
|
|
22768
23144
|
compactAtUtilisation: CompactAtUtilisationSchema.optional()
|
|
22769
23145
|
});
|
|
22770
23146
|
var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
|
|
22771
|
-
var ConfigPoolSetInputSchema =
|
|
22772
|
-
name:
|
|
23147
|
+
var ConfigPoolSetInputSchema = z42.strictObject({
|
|
23148
|
+
name: z42.string().min(1),
|
|
22773
23149
|
identities: PoolMembersInputSchema.optional(),
|
|
22774
|
-
preference:
|
|
22775
|
-
resumeOnLimit:
|
|
22776
|
-
compactBeforeLimit:
|
|
22777
|
-
compactAtUtilisation:
|
|
23150
|
+
preference: z42.union([z42.enum(POOL_PREFERENCES), z42.literal(false)]).optional(),
|
|
23151
|
+
resumeOnLimit: z42.boolean().optional(),
|
|
23152
|
+
compactBeforeLimit: z42.boolean().optional(),
|
|
23153
|
+
compactAtUtilisation: z42.union([CompactAtUtilisationSchema, z42.literal(false)]).optional()
|
|
22778
23154
|
});
|
|
22779
23155
|
var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
|
|
22780
|
-
var ConfigPoolRemoveInputSchema =
|
|
23156
|
+
var ConfigPoolRemoveInputSchema = z42.strictObject({ name: z42.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22781
23157
|
var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
|
|
22782
23158
|
var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
|
|
22783
|
-
var ConfigProviderAddInputSchema =
|
|
22784
|
-
name:
|
|
22785
|
-
kind:
|
|
22786
|
-
displayName:
|
|
22787
|
-
baseUrl:
|
|
23159
|
+
var ConfigProviderAddInputSchema = z42.strictObject({
|
|
23160
|
+
name: z42.string().min(1),
|
|
23161
|
+
kind: z42.enum(PROVIDER_KINDS).optional(),
|
|
23162
|
+
displayName: z42.string().min(1),
|
|
23163
|
+
baseUrl: z42.string().min(1).optional(),
|
|
22788
23164
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
|
|
22789
23165
|
codex: CodexProviderConfigSchema.optional()
|
|
22790
23166
|
});
|
|
22791
23167
|
var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
|
|
22792
|
-
var ConfigProviderSetInputSchema =
|
|
22793
|
-
name:
|
|
22794
|
-
displayName:
|
|
22795
|
-
baseUrl:
|
|
23168
|
+
var ConfigProviderSetInputSchema = z42.strictObject({
|
|
23169
|
+
name: z42.string().min(1),
|
|
23170
|
+
displayName: z42.string().min(1).optional(),
|
|
23171
|
+
baseUrl: z42.string().min(1).optional(),
|
|
22796
23172
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
|
|
22797
23173
|
codex: CodexProviderConfigSchema.optional()
|
|
22798
23174
|
});
|
|
22799
23175
|
var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
|
|
22800
|
-
var ConfigProviderRemoveInputSchema =
|
|
23176
|
+
var ConfigProviderRemoveInputSchema = z42.strictObject({ name: z42.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22801
23177
|
var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
|
|
22802
|
-
var ConfigRuleAddInputSchema =
|
|
22803
|
-
path:
|
|
22804
|
-
configProfile:
|
|
22805
|
-
identity:
|
|
23178
|
+
var ConfigRuleAddInputSchema = z42.strictObject({
|
|
23179
|
+
path: z42.string().min(1),
|
|
23180
|
+
configProfile: z42.string().min(1).optional(),
|
|
23181
|
+
identity: z42.string().min(1).optional()
|
|
22806
23182
|
});
|
|
22807
23183
|
var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
|
|
22808
|
-
var ConfigRuleSetInputSchema =
|
|
22809
|
-
path:
|
|
22810
|
-
configProfile:
|
|
22811
|
-
identity:
|
|
23184
|
+
var ConfigRuleSetInputSchema = z42.strictObject({
|
|
23185
|
+
path: z42.string().min(1),
|
|
23186
|
+
configProfile: z42.union([z42.string().min(1), z42.literal(false)]).optional(),
|
|
23187
|
+
identity: z42.union([z42.string().min(1), z42.literal(false)]).optional()
|
|
22812
23188
|
});
|
|
22813
23189
|
var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
|
|
22814
|
-
var ConfigRuleRemoveInputSchema =
|
|
23190
|
+
var ConfigRuleRemoveInputSchema = z42.strictObject({ path: z42.string().min(1), confirm: RemovalConfirmationSchema });
|
|
22815
23191
|
var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
|
|
22816
23192
|
|
|
22817
23193
|
// src/frontdoor/configApi.ts
|
|
@@ -22885,7 +23261,7 @@ function profileValue(name, paths) {
|
|
|
22885
23261
|
function createConfigApiRouter(deps) {
|
|
22886
23262
|
const authed = doorApiAuth(deps.expectedToken);
|
|
22887
23263
|
const { paths } = deps;
|
|
22888
|
-
const route = (
|
|
23264
|
+
const route = (path59, summary) => authed.meta(openapi3({ method: "POST", path: path59, summary, tags: [CONFIG_API_TAG] }));
|
|
22889
23265
|
return {
|
|
22890
23266
|
config: {
|
|
22891
23267
|
identity: {
|
|
@@ -23156,50 +23532,50 @@ import { eventIterator as eventIterator2, withEventMeta as withEventMeta2 } from
|
|
|
23156
23532
|
|
|
23157
23533
|
// src/frontdoor/eventSchemas.ts
|
|
23158
23534
|
init_schema2();
|
|
23159
|
-
import { z as
|
|
23535
|
+
import { z as z43 } from "zod";
|
|
23160
23536
|
var DOOR_EVENT_SOURCE_RC = "rc";
|
|
23161
23537
|
var LAUNCH_EVENT_SOURCE = "launch";
|
|
23162
23538
|
var USAGE_EVENT_SOURCE = "usage";
|
|
23163
23539
|
var DOOR_HEALTH_EVENT_SOURCE = "door";
|
|
23164
23540
|
var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
|
|
23165
|
-
var DoorEventSchema =
|
|
23166
|
-
source:
|
|
23541
|
+
var DoorEventSchema = z43.strictObject({
|
|
23542
|
+
source: z43.string().min(1),
|
|
23167
23543
|
/** A positive integer because the backbone's counters start at one and only ever increase. */
|
|
23168
|
-
sequence:
|
|
23169
|
-
payload:
|
|
23170
|
-
});
|
|
23171
|
-
var DoorEventSourceQuerySchema =
|
|
23172
|
-
sources:
|
|
23173
|
-
});
|
|
23174
|
-
var LaunchLifecycleEventSchema =
|
|
23175
|
-
kind:
|
|
23176
|
-
pid:
|
|
23177
|
-
startedAt:
|
|
23178
|
-
observedAt:
|
|
23179
|
-
});
|
|
23180
|
-
var DoorHealthEventSchema =
|
|
23181
|
-
|
|
23182
|
-
|
|
23183
|
-
|
|
23184
|
-
|
|
23185
|
-
|
|
23186
|
-
|
|
23544
|
+
sequence: z43.number().int().positive(),
|
|
23545
|
+
payload: z43.unknown()
|
|
23546
|
+
});
|
|
23547
|
+
var DoorEventSourceQuerySchema = z43.strictObject({
|
|
23548
|
+
sources: z43.array(z43.string().min(1)).min(1).optional()
|
|
23549
|
+
});
|
|
23550
|
+
var LaunchLifecycleEventSchema = z43.strictObject({
|
|
23551
|
+
kind: z43.enum(["registered", "pruned", "ended"]),
|
|
23552
|
+
pid: z43.number().int().positive(),
|
|
23553
|
+
startedAt: z43.number(),
|
|
23554
|
+
observedAt: z43.number()
|
|
23555
|
+
});
|
|
23556
|
+
var DoorHealthEventSchema = z43.discriminatedUnion("kind", [
|
|
23557
|
+
z43.strictObject({ kind: z43.literal("generation"), pid: z43.number().int().positive(), providerPort: z43.number().int().positive(), connectPort: z43.number().int().positive(), directPort: z43.number().int().positive(), observedAt: z43.number() }),
|
|
23558
|
+
z43.strictObject({ kind: z43.literal("listenerFailed"), pid: z43.number().int().positive(), listener: z43.enum(["provider", "connect", "direct"]), message: z43.string(), observedAt: z43.number() }),
|
|
23559
|
+
z43.strictObject({ kind: z43.literal("binaryTurnover"), pid: z43.number().int().positive(), observedAt: z43.number() }),
|
|
23560
|
+
z43.strictObject({ kind: z43.literal("idleShutdown"), pid: z43.number().int().positive(), observedAt: z43.number() }),
|
|
23561
|
+
z43.strictObject({ kind: z43.literal("superseded"), pid: z43.number().int().positive(), ownerPid: z43.number().int().positive(), observedAt: z43.number() }),
|
|
23562
|
+
z43.strictObject({ kind: z43.literal("drained"), pid: z43.number().int().positive(), observedAt: z43.number() })
|
|
23187
23563
|
]);
|
|
23188
|
-
var QuotaExpiringEventSchema =
|
|
23564
|
+
var QuotaExpiringEventSchema = z43.strictObject({
|
|
23189
23565
|
/** The id of the identity whose window it is: what its usage is filed under, which a rename keeps. */
|
|
23190
|
-
id:
|
|
23566
|
+
id: z43.string().min(1),
|
|
23191
23567
|
/** The identity's name when the event was published, absent for an identity no longer stored under the id. */
|
|
23192
|
-
name:
|
|
23193
|
-
provider:
|
|
23194
|
-
window:
|
|
23568
|
+
name: z43.string().min(1).optional(),
|
|
23569
|
+
provider: z43.string().min(1),
|
|
23570
|
+
window: z43.enum(["fiveHour", "sevenDay"]),
|
|
23195
23571
|
/** The fraction of the window already used when it was seen expiring, always below one because a fully used window has nothing left to spend. */
|
|
23196
|
-
utilization:
|
|
23197
|
-
resetsAt:
|
|
23198
|
-
observedAt:
|
|
23572
|
+
utilization: z43.number().min(0).max(1),
|
|
23573
|
+
resetsAt: z43.iso.datetime(),
|
|
23574
|
+
observedAt: z43.number()
|
|
23199
23575
|
});
|
|
23200
23576
|
var UsageChangeEventSchema = UsageSnapshotSchema.extend({
|
|
23201
|
-
id:
|
|
23202
|
-
name:
|
|
23577
|
+
id: z43.string().min(1),
|
|
23578
|
+
name: z43.string().min(1).optional()
|
|
23203
23579
|
});
|
|
23204
23580
|
|
|
23205
23581
|
// src/frontdoor/eventsApi.ts
|
|
@@ -23244,14 +23620,14 @@ function createEventsApiRouter(deps) {
|
|
|
23244
23620
|
init_update();
|
|
23245
23621
|
import { ORPCError as ORPCError4 } from "@orpc/client";
|
|
23246
23622
|
import { openapi as openapi5 } from "@orpc/openapi";
|
|
23247
|
-
import { z as
|
|
23623
|
+
import { z as z44 } from "zod";
|
|
23248
23624
|
var FRONTDOOR_API_TAG = "frontdoor";
|
|
23249
23625
|
var UPDATE_API_TAG = "update";
|
|
23250
23626
|
function createLifecycleApiRouter(deps) {
|
|
23251
23627
|
const authed = doorApiAuth(deps.expectedToken);
|
|
23252
23628
|
return {
|
|
23253
23629
|
frontdoor: {
|
|
23254
|
-
refreshCatalogues: authed.meta(openapi5({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(
|
|
23630
|
+
refreshCatalogues: authed.meta(openapi5({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(z44.strictObject({ requested: z44.literal(true) })).handler(() => {
|
|
23255
23631
|
deps.refreshCatalogues();
|
|
23256
23632
|
return { requested: true };
|
|
23257
23633
|
}),
|
|
@@ -23287,65 +23663,65 @@ import { ORPCError as ORPCError5 } from "@orpc/client";
|
|
|
23287
23663
|
import { openapi as openapi6 } from "@orpc/openapi";
|
|
23288
23664
|
|
|
23289
23665
|
// src/frontdoor/launchSchemas.ts
|
|
23290
|
-
import
|
|
23291
|
-
import { z as
|
|
23666
|
+
import path46 from "node:path";
|
|
23667
|
+
import { z as z45 } from "zod";
|
|
23292
23668
|
init_statusline();
|
|
23293
23669
|
init_claudeVersion();
|
|
23294
23670
|
init_identity2();
|
|
23295
|
-
var LaunchResolveInputSchema =
|
|
23296
|
-
path:
|
|
23671
|
+
var LaunchResolveInputSchema = z45.strictObject({
|
|
23672
|
+
path: z45.string().min(1),
|
|
23297
23673
|
/** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
|
|
23298
|
-
argv:
|
|
23674
|
+
argv: z45.readonly(z45.array(z45.string())).optional(),
|
|
23299
23675
|
/** The launch's inherited environment. Absent means an empty one: the door's own environment is never a substitute for the caller's, so a caller that wants `AGENT_SHIM_*` switches or a `CLAUDE_CONFIG_DIR` considered names them here. Values are read, never reported. */
|
|
23300
|
-
env:
|
|
23301
|
-
}).refine((input) =>
|
|
23302
|
-
var LaunchPoolDecisionSchema =
|
|
23303
|
-
name:
|
|
23304
|
-
reasons:
|
|
23676
|
+
env: z45.record(z45.string(), z45.string()).optional()
|
|
23677
|
+
}).refine((input) => path46.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
23678
|
+
var LaunchPoolDecisionSchema = z45.strictObject({
|
|
23679
|
+
name: z45.string(),
|
|
23680
|
+
reasons: z45.readonly(z45.array(z45.string())),
|
|
23305
23681
|
/** The provider the ranking read for the chosen member, when the launch spends one in place of the member's Claude account. */
|
|
23306
|
-
provider:
|
|
23307
|
-
movedOff:
|
|
23682
|
+
provider: z45.string().optional(),
|
|
23683
|
+
movedOff: z45.strictObject({ identity: z45.string(), reason: z45.string() }).optional()
|
|
23308
23684
|
});
|
|
23309
|
-
var LaunchDecisionSchema =
|
|
23310
|
-
identity:
|
|
23311
|
-
identityId:
|
|
23312
|
-
identitySource:
|
|
23685
|
+
var LaunchDecisionSchema = z45.strictObject({
|
|
23686
|
+
identity: z45.string().optional(),
|
|
23687
|
+
identityId: z45.string().optional(),
|
|
23688
|
+
identitySource: z45.enum(IDENTITY_DECISION_SOURCES),
|
|
23313
23689
|
pool: LaunchPoolDecisionSchema.optional(),
|
|
23314
23690
|
/** True when `CLAUDE_CONFIG_DIR` was already set and nothing on the command line named an identity; an identity named there outranks the variable and leaves it false. */
|
|
23315
|
-
configDirEscapeHatch:
|
|
23316
|
-
configDir:
|
|
23317
|
-
configProfile:
|
|
23318
|
-
configProfileSource:
|
|
23319
|
-
provider:
|
|
23320
|
-
});
|
|
23321
|
-
var LaunchFlagsSchema =
|
|
23322
|
-
skipPermissions:
|
|
23323
|
-
remoteControl:
|
|
23324
|
-
headroom:
|
|
23325
|
-
trackUsage:
|
|
23326
|
-
pause:
|
|
23327
|
-
explain:
|
|
23691
|
+
configDirEscapeHatch: z45.boolean(),
|
|
23692
|
+
configDir: z45.string().optional(),
|
|
23693
|
+
configProfile: z45.string().optional(),
|
|
23694
|
+
configProfileSource: z45.enum(CONFIG_PROFILE_DECISION_SOURCES),
|
|
23695
|
+
provider: z45.string().optional()
|
|
23696
|
+
});
|
|
23697
|
+
var LaunchFlagsSchema = z45.strictObject({
|
|
23698
|
+
skipPermissions: z45.boolean(),
|
|
23699
|
+
remoteControl: z45.boolean(),
|
|
23700
|
+
headroom: z45.boolean(),
|
|
23701
|
+
trackUsage: z45.boolean(),
|
|
23702
|
+
pause: z45.boolean(),
|
|
23703
|
+
explain: z45.boolean(),
|
|
23328
23704
|
/** How long the launch waits after its own output before it starts claude, in milliseconds. */
|
|
23329
|
-
delayMs:
|
|
23705
|
+
delayMs: z45.number(),
|
|
23330
23706
|
/** The hosts the launch keeps off the front door by adding them to the child's `NO_PROXY`. */
|
|
23331
|
-
proxyBypass:
|
|
23707
|
+
proxyBypass: z45.array(z45.string()).readonly(),
|
|
23332
23708
|
/** How the session's built-in statusline looks, when the launch configures any of it. */
|
|
23333
23709
|
statusline: StatuslineSchema.optional()
|
|
23334
23710
|
});
|
|
23335
|
-
var LaunchResolveOutputSchema =
|
|
23711
|
+
var LaunchResolveOutputSchema = z45.strictObject({
|
|
23336
23712
|
decision: LaunchDecisionSchema,
|
|
23337
23713
|
flags: LaunchFlagsSchema,
|
|
23338
|
-
claudeVersion:
|
|
23714
|
+
claudeVersion: z45.strictObject({ version: z45.string(), source: z45.enum(CLAUDE_VERSION_SOURCES) }).optional(),
|
|
23339
23715
|
/** The real `claude` binary the launch would spawn, on the door's host. */
|
|
23340
|
-
bin:
|
|
23716
|
+
bin: z45.string(),
|
|
23341
23717
|
/** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
|
|
23342
|
-
args:
|
|
23718
|
+
args: z45.readonly(z45.array(z45.string())),
|
|
23343
23719
|
/** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
|
|
23344
|
-
credential:
|
|
23345
|
-
routing:
|
|
23720
|
+
credential: z45.strictObject({ subject: z45.enum(["provider", "identity"]), name: z45.string(), summary: CredentialSummarySchema }).optional(),
|
|
23721
|
+
routing: z45.strictObject({ frontDoor: z45.boolean(), headroom: z45.boolean() }),
|
|
23346
23722
|
/** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
|
|
23347
|
-
environment:
|
|
23348
|
-
warnings:
|
|
23723
|
+
environment: z45.readonly(z45.array(z45.string())),
|
|
23724
|
+
warnings: z45.readonly(z45.array(z45.string()))
|
|
23349
23725
|
});
|
|
23350
23726
|
|
|
23351
23727
|
// src/frontdoor/launchApi.ts
|
|
@@ -23384,21 +23760,21 @@ init_schema3();
|
|
|
23384
23760
|
init_cliError();
|
|
23385
23761
|
import { ORPCError as ORPCError6 } from "@orpc/client";
|
|
23386
23762
|
import { openapi as openapi7 } from "@orpc/openapi";
|
|
23387
|
-
import { z as
|
|
23388
|
-
var AgentTreesListInputSchema =
|
|
23763
|
+
import { z as z46 } from "zod";
|
|
23764
|
+
var AgentTreesListInputSchema = z46.strictObject({
|
|
23389
23765
|
/** Only this identity's sessions. */
|
|
23390
|
-
identity:
|
|
23766
|
+
identity: z46.string().optional(),
|
|
23391
23767
|
/** Include sessions that spawned no agent and ran no workflow. */
|
|
23392
|
-
all:
|
|
23768
|
+
all: z46.boolean().optional()
|
|
23393
23769
|
});
|
|
23394
|
-
var AgentTreesListOutputSchema =
|
|
23395
|
-
var AgentTreesShowInputSchema =
|
|
23770
|
+
var AgentTreesListOutputSchema = z46.array(SessionSummarySchema);
|
|
23771
|
+
var AgentTreesShowInputSchema = z46.strictObject({
|
|
23396
23772
|
/** A session id, or an unambiguous prefix of one. */
|
|
23397
|
-
session:
|
|
23773
|
+
session: z46.string().min(1),
|
|
23398
23774
|
/** Look only in this identity. */
|
|
23399
|
-
identity:
|
|
23775
|
+
identity: z46.string().optional()
|
|
23400
23776
|
});
|
|
23401
|
-
var AgentTreesShowOutputSchema =
|
|
23777
|
+
var AgentTreesShowOutputSchema = z46.strictObject({ identities: z46.array(z46.string()), ...MergedAgentTreeSchema.shape });
|
|
23402
23778
|
function asBadRequest(error) {
|
|
23403
23779
|
if (error instanceof CliError) {
|
|
23404
23780
|
throw new ORPCError6("BAD_REQUEST", { message: error.message });
|
|
@@ -23451,7 +23827,7 @@ import { openapi as openapi8 } from "@orpc/openapi";
|
|
|
23451
23827
|
import { eventIterator as eventIterator3, withEventMeta as withEventMeta3 } from "@orpc/server";
|
|
23452
23828
|
|
|
23453
23829
|
// src/frontdoor/rcEventLog.ts
|
|
23454
|
-
import { z as
|
|
23830
|
+
import { z as z47 } from "zod";
|
|
23455
23831
|
|
|
23456
23832
|
// src/frontdoor/eventHub.ts
|
|
23457
23833
|
var DOOR_EVENT_BUFFER_EVENTS = 100;
|
|
@@ -23576,46 +23952,46 @@ var NUMBER_FIELDS = ["at", "sequence"].length;
|
|
|
23576
23952
|
var BYTES_PER_CODE_UNIT = Uint16Array.BYTES_PER_ELEMENT;
|
|
23577
23953
|
var RC_SESSION_END_REASONS = ["expired", "archived", "conflict"];
|
|
23578
23954
|
var RC_PENDING_RETIRE_REASONS = ["answered", "withdrawn", "worker-stopped", "session-ended"];
|
|
23579
|
-
var transitionBase = { session:
|
|
23580
|
-
var cursorFields = { cursor:
|
|
23581
|
-
var sessionAppearedShape = { kind:
|
|
23582
|
-
var sessionEndedShape = { kind:
|
|
23583
|
-
var workerStateShape = { kind:
|
|
23584
|
-
var pendingBornShape = { kind:
|
|
23585
|
-
var pendingRetiredShape = { kind:
|
|
23586
|
-
var RcSessionTransitionSchema =
|
|
23587
|
-
|
|
23588
|
-
|
|
23589
|
-
|
|
23590
|
-
|
|
23591
|
-
|
|
23955
|
+
var transitionBase = { session: z47.string(), at: z47.number() };
|
|
23956
|
+
var cursorFields = { cursor: z47.string(), sequence: z47.int().positive() };
|
|
23957
|
+
var sessionAppearedShape = { kind: z47.literal("session-appeared"), ...transitionBase };
|
|
23958
|
+
var sessionEndedShape = { kind: z47.literal("session-ended"), reason: z47.enum(RC_SESSION_END_REASONS), ...transitionBase };
|
|
23959
|
+
var workerStateShape = { kind: z47.literal("worker-state"), state: z47.string(), previous: z47.string().optional(), ...transitionBase };
|
|
23960
|
+
var pendingBornShape = { kind: z47.literal("pending-born"), requestId: z47.string(), type: z47.string(), summary: z47.string(), ...transitionBase };
|
|
23961
|
+
var pendingRetiredShape = { kind: z47.literal("pending-retired"), requestId: z47.string(), reason: z47.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
|
|
23962
|
+
var RcSessionTransitionSchema = z47.discriminatedUnion("kind", [
|
|
23963
|
+
z47.strictObject(sessionAppearedShape),
|
|
23964
|
+
z47.strictObject(sessionEndedShape),
|
|
23965
|
+
z47.strictObject(workerStateShape),
|
|
23966
|
+
z47.strictObject(pendingBornShape),
|
|
23967
|
+
z47.strictObject(pendingRetiredShape)
|
|
23592
23968
|
]);
|
|
23593
23969
|
var KIND_MAX_CHARS = Math.max(...RcSessionTransitionSchema.options.map((option) => option.shape.kind.value.length));
|
|
23594
23970
|
var RC_SESSION_EVENT_MAX_BYTES = (RC_SESSION_EVENT_GENERATION_MAX_CHARS + ".".length + SEQUENCE_MAX_DIGITS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + KIND_MAX_CHARS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + RC_SESSION_EVENT_SUMMARY_MAX_CHARS) * BYTES_PER_CODE_UNIT + NUMBER_FIELDS * NUMBER_BYTES;
|
|
23595
23971
|
var RC_SESSION_EVENT_LOG_CAPACITY = Math.floor(CONTROL_BODY_CAP_BYTES / RC_SESSION_EVENT_MAX_BYTES);
|
|
23596
|
-
var RcSessionEventSchema =
|
|
23597
|
-
|
|
23598
|
-
|
|
23599
|
-
|
|
23600
|
-
|
|
23601
|
-
|
|
23972
|
+
var RcSessionEventSchema = z47.discriminatedUnion("kind", [
|
|
23973
|
+
z47.strictObject({ ...cursorFields, ...sessionAppearedShape }),
|
|
23974
|
+
z47.strictObject({ ...cursorFields, ...sessionEndedShape }),
|
|
23975
|
+
z47.strictObject({ ...cursorFields, ...workerStateShape }),
|
|
23976
|
+
z47.strictObject({ ...cursorFields, ...pendingBornShape }),
|
|
23977
|
+
z47.strictObject({ ...cursorFields, ...pendingRetiredShape })
|
|
23602
23978
|
]);
|
|
23603
|
-
var RcSessionEventsReadInputSchema =
|
|
23979
|
+
var RcSessionEventsReadInputSchema = z47.strictObject({
|
|
23604
23980
|
/** The cursor of the last event the caller saw; every retained event when omitted. */
|
|
23605
|
-
since:
|
|
23981
|
+
since: z47.string().min(1).optional(),
|
|
23606
23982
|
/** One `cse_` session id; every session when omitted. */
|
|
23607
|
-
session:
|
|
23983
|
+
session: z47.string().min(1).optional(),
|
|
23608
23984
|
/** The most events one answer carries; every event after `since` when omitted. */
|
|
23609
|
-
limit:
|
|
23985
|
+
limit: z47.int().positive().optional()
|
|
23610
23986
|
});
|
|
23611
23987
|
var RcSessionEventsPageInputSchema = RcSessionEventsReadInputSchema.extend({
|
|
23612
23988
|
/** The most events this page carries: by default and at most, the bound the door's event backbone already holds per slow consumer (`DOOR_EVENT_BUFFER_EVENTS`, oRPC's own documented default for that case). A page lands whole in its reader, so a reader receives at most one consumer buffer's worth at a time (at worst `DOOR_EVENT_BUFFER_EVENTS` times `RC_SESSION_EVENT_MAX_BYTES`) and pages on with the cursor for more; a maximum of the whole window would let one page carry the log's entire memory budget into an agent's context. */
|
|
23613
|
-
limit:
|
|
23989
|
+
limit: z47.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
|
|
23614
23990
|
});
|
|
23615
23991
|
var RcSessionEventsStreamInputSchema = RcSessionEventsReadInputSchema.omit({ limit: true });
|
|
23616
|
-
var RcSessionEventsReadOutputSchema =
|
|
23617
|
-
|
|
23618
|
-
|
|
23992
|
+
var RcSessionEventsReadOutputSchema = z47.discriminatedUnion("status", [
|
|
23993
|
+
z47.strictObject({ status: z47.literal("ok"), events: z47.readonly(z47.array(RcSessionEventSchema)), cursor: z47.string(), more: z47.boolean(), head: z47.string() }),
|
|
23994
|
+
z47.strictObject({ status: z47.literal("expired"), message: z47.string(), head: z47.string() })
|
|
23619
23995
|
]);
|
|
23620
23996
|
var CURSOR_SEPARATOR = ".";
|
|
23621
23997
|
var RESYNC_ADVICE = "cursor expired, resync from status: read `rc status` for every session's present state, then resume after the head this answer names";
|
|
@@ -24131,6 +24507,7 @@ function createQuotaExpiringPublisher(hub, deps) {
|
|
|
24131
24507
|
|
|
24132
24508
|
// src/index.ts
|
|
24133
24509
|
init_rcSchemas();
|
|
24510
|
+
init_verifiedVersions();
|
|
24134
24511
|
|
|
24135
24512
|
// src/frontdoor/rcLiveUsage.ts
|
|
24136
24513
|
init_rcSchemas();
|
|
@@ -25804,7 +26181,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
25804
26181
|
// src/frontdoor/rcSelfHostMint.ts
|
|
25805
26182
|
init_identityRecords();
|
|
25806
26183
|
init_account();
|
|
25807
|
-
import
|
|
26184
|
+
import path47 from "node:path";
|
|
25808
26185
|
var CREDENTIALS_FILE2 = ".credentials.json";
|
|
25809
26186
|
var CLAUDE_JSON2 = ".claude.json";
|
|
25810
26187
|
var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
|
|
@@ -25828,7 +26205,7 @@ function readJsonObject(fs17, file) {
|
|
|
25828
26205
|
return isRecord16(parsed) ? parsed : void 0;
|
|
25829
26206
|
}
|
|
25830
26207
|
function readRcSelfHostRecord(fs17, frontdoorDir) {
|
|
25831
|
-
const parsed = readJsonObject(fs17,
|
|
26208
|
+
const parsed = readJsonObject(fs17, path47.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
25832
26209
|
if (parsed === void 0) {
|
|
25833
26210
|
return void 0;
|
|
25834
26211
|
}
|
|
@@ -25846,11 +26223,11 @@ function mintRcSelfHostCredential(deps) {
|
|
|
25846
26223
|
if (id === void 0) {
|
|
25847
26224
|
throw new Error(`No identity named "${deps.identity}".`);
|
|
25848
26225
|
}
|
|
25849
|
-
const identityDir =
|
|
25850
|
-
const credentialsFile =
|
|
25851
|
-
const claudeJsonFile =
|
|
25852
|
-
const recordDir =
|
|
25853
|
-
const recordFile2 =
|
|
26226
|
+
const identityDir = path47.join(deps.identitiesDir, id);
|
|
26227
|
+
const credentialsFile = path47.join(identityDir, CREDENTIALS_FILE2);
|
|
26228
|
+
const claudeJsonFile = path47.join(identityDir, CLAUDE_JSON2);
|
|
26229
|
+
const recordDir = path47.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
|
|
26230
|
+
const recordFile2 = path47.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
25854
26231
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
25855
26232
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
25856
26233
|
const existingOauth = isRecord16(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
@@ -25866,7 +26243,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
25866
26243
|
const organizationUuid = deps.newUuid();
|
|
25867
26244
|
const accountUuid = deps.newUuid();
|
|
25868
26245
|
const mintedAt = new Date(deps.now()).toISOString();
|
|
25869
|
-
deps.fs.mkdirPrivate(
|
|
26246
|
+
deps.fs.mkdirPrivate(path47.dirname(credentialsFile));
|
|
25870
26247
|
deps.fs.writeFilePrivate(credentialsFile, `${JSON.stringify({ ...existingCredentials, claudeAiOauth: { accessToken, refreshToken, expiresAt: null, scopes: [...RC_SELF_HOST_SCOPE_LIST], subscriptionType: SELF_HOST_SUBSCRIPTION_TYPE, rateLimitTier: null } }, null, 2)}
|
|
25871
26248
|
`);
|
|
25872
26249
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
@@ -25904,7 +26281,7 @@ init_ensure2();
|
|
|
25904
26281
|
// src/frontdoor/liveSessionRegistry.ts
|
|
25905
26282
|
init_capability();
|
|
25906
26283
|
init_state();
|
|
25907
|
-
import
|
|
26284
|
+
import path48 from "node:path";
|
|
25908
26285
|
function sameStat(recorded, current) {
|
|
25909
26286
|
return recorded?.mtimeMs === current.mtimeMs && recorded.sizeBytes === current.sizeBytes;
|
|
25910
26287
|
}
|
|
@@ -25926,7 +26303,7 @@ function createLiveSessionRegistry(ports) {
|
|
|
25926
26303
|
const load = (name, stat) => {
|
|
25927
26304
|
known.set(name, { stat: { mtimeMs: stat.mtimeMs, sizeBytes: stat.sizeBytes }, record: readFrontDoorSessionRecord(fs17, sessionsDir, name) });
|
|
25928
26305
|
};
|
|
25929
|
-
const statOf = (name) => fs17.lstat(
|
|
26306
|
+
const statOf = (name) => fs17.lstat(path48.join(sessionsDir, name));
|
|
25930
26307
|
const reconcile = () => {
|
|
25931
26308
|
const names = new Set(recordNames());
|
|
25932
26309
|
let changed = false;
|
|
@@ -26001,8 +26378,8 @@ init_liveTasks();
|
|
|
26001
26378
|
|
|
26002
26379
|
// src/agents/read.ts
|
|
26003
26380
|
init_schema3();
|
|
26004
|
-
import
|
|
26005
|
-
import { z as
|
|
26381
|
+
import path49 from "node:path";
|
|
26382
|
+
import { z as z48 } from "zod";
|
|
26006
26383
|
var PROJECTS_DIR = "projects";
|
|
26007
26384
|
var TASKS_DIR = "tasks";
|
|
26008
26385
|
var SUBAGENTS_DIR = "subagents";
|
|
@@ -26027,15 +26404,15 @@ function parseEntry2(project, entry) {
|
|
|
26027
26404
|
}
|
|
26028
26405
|
function listSessions2(fs17, configDir) {
|
|
26029
26406
|
const found = [];
|
|
26030
|
-
for (const project of fs17.readdir(
|
|
26031
|
-
const projectDir =
|
|
26407
|
+
for (const project of fs17.readdir(path49.join(configDir, PROJECTS_DIR))) {
|
|
26408
|
+
const projectDir = path49.join(configDir, PROJECTS_DIR, project);
|
|
26032
26409
|
const entries = /* @__PURE__ */ new Set();
|
|
26033
26410
|
for (const name of fs17.readdir(projectDir)) {
|
|
26034
26411
|
if (name.endsWith(TRANSCRIPT_SUFFIX)) {
|
|
26035
26412
|
entries.add(name.slice(0, -TRANSCRIPT_SUFFIX.length));
|
|
26036
26413
|
continue;
|
|
26037
26414
|
}
|
|
26038
|
-
const children = fs17.readdir(
|
|
26415
|
+
const children = fs17.readdir(path49.join(projectDir, name));
|
|
26039
26416
|
if (children.includes(SUBAGENTS_DIR) || children.includes(WORKFLOWS_DIR)) {
|
|
26040
26417
|
entries.add(name);
|
|
26041
26418
|
}
|
|
@@ -26055,8 +26432,8 @@ function locateAgents(fs17, configDir, relativeDir, workflowRunId, report) {
|
|
|
26055
26432
|
const id = name.slice(AGENT_FILE_PREFIX.length, -META_SUFFIX.length);
|
|
26056
26433
|
located.push({
|
|
26057
26434
|
id,
|
|
26058
|
-
metaPath:
|
|
26059
|
-
transcriptPath:
|
|
26435
|
+
metaPath: path49.join(relativeDir, name),
|
|
26436
|
+
transcriptPath: path49.join(relativeDir, `${AGENT_FILE_PREFIX}${id}${TRANSCRIPT_SUFFIX}`),
|
|
26060
26437
|
workflowRunId
|
|
26061
26438
|
});
|
|
26062
26439
|
}
|
|
@@ -26099,7 +26476,7 @@ function describeFailure(error) {
|
|
|
26099
26476
|
}
|
|
26100
26477
|
function readFileOrReport(fs17, configDir, relative, report) {
|
|
26101
26478
|
try {
|
|
26102
|
-
return fs17.readFileUtf8(
|
|
26479
|
+
return fs17.readFileUtf8(path49.join(configDir, relative));
|
|
26103
26480
|
} catch (error) {
|
|
26104
26481
|
report({ path: relative, reason: `could not be read: ${describeFailure(error)}` });
|
|
26105
26482
|
return void 0;
|
|
@@ -26107,7 +26484,7 @@ function readFileOrReport(fs17, configDir, relative, report) {
|
|
|
26107
26484
|
}
|
|
26108
26485
|
function listDirOrReport(fs17, configDir, relative, report) {
|
|
26109
26486
|
try {
|
|
26110
|
-
return fs17.readdir(
|
|
26487
|
+
return fs17.readdir(path49.join(configDir, relative));
|
|
26111
26488
|
} catch (error) {
|
|
26112
26489
|
report({ path: relative, reason: `could not be listed: ${describeFailure(error)}` });
|
|
26113
26490
|
return [];
|
|
@@ -26121,28 +26498,28 @@ function parseJson2(text) {
|
|
|
26121
26498
|
return void 0;
|
|
26122
26499
|
}
|
|
26123
26500
|
}
|
|
26124
|
-
var TaskFileSchema =
|
|
26125
|
-
var WorkflowRunFileSchema =
|
|
26126
|
-
runId:
|
|
26127
|
-
workflowName:
|
|
26128
|
-
status:
|
|
26129
|
-
startTime:
|
|
26130
|
-
phases:
|
|
26131
|
-
summary:
|
|
26501
|
+
var TaskFileSchema = z48.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: z48.array(z48.string()).default([]), blockedBy: z48.array(z48.string()).default([]) });
|
|
26502
|
+
var WorkflowRunFileSchema = z48.object({
|
|
26503
|
+
runId: z48.string(),
|
|
26504
|
+
workflowName: z48.string().optional(),
|
|
26505
|
+
status: z48.string().optional(),
|
|
26506
|
+
startTime: z48.number().optional(),
|
|
26507
|
+
phases: z48.array(z48.object({ title: z48.string() })).default([]),
|
|
26508
|
+
summary: z48.string().optional()
|
|
26132
26509
|
});
|
|
26133
26510
|
function summariseSession(fs17, configDir, ref) {
|
|
26134
|
-
const sessionRelative =
|
|
26135
|
-
const subagentsRelative =
|
|
26136
|
-
const workflowsUnderSubagents =
|
|
26511
|
+
const sessionRelative = path49.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
26512
|
+
const subagentsRelative = path49.join(sessionRelative, SUBAGENTS_DIR);
|
|
26513
|
+
const workflowsUnderSubagents = path49.join(subagentsRelative, WORKFLOWS_DIR);
|
|
26137
26514
|
const isMeta = (name) => name.startsWith(AGENT_FILE_PREFIX) && name.endsWith(META_SUFFIX);
|
|
26138
|
-
let agentCount = fs17.readdir(
|
|
26139
|
-
for (const runDir of fs17.readdir(
|
|
26515
|
+
let agentCount = fs17.readdir(path49.join(configDir, subagentsRelative)).filter(isMeta).length;
|
|
26516
|
+
for (const runDir of fs17.readdir(path49.join(configDir, workflowsUnderSubagents))) {
|
|
26140
26517
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
26141
|
-
agentCount += fs17.readdir(
|
|
26518
|
+
agentCount += fs17.readdir(path49.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
|
|
26142
26519
|
}
|
|
26143
26520
|
}
|
|
26144
|
-
const workflowRunCount = fs17.readdir(
|
|
26145
|
-
const transcript = fs17.lstat(
|
|
26521
|
+
const workflowRunCount = fs17.readdir(path49.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
|
|
26522
|
+
const transcript = fs17.lstat(path49.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
|
|
26146
26523
|
return { ...ref, agentCount, workflowRunCount, ...transcript === void 0 ? {} : { updatedAt: new Date(transcript.mtimeMs).toISOString() } };
|
|
26147
26524
|
}
|
|
26148
26525
|
function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
@@ -26150,13 +26527,13 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
|
26150
26527
|
const report = (problem) => {
|
|
26151
26528
|
problems.push(problem);
|
|
26152
26529
|
};
|
|
26153
|
-
const sessionRelative =
|
|
26154
|
-
const subagentsRelative =
|
|
26155
|
-
const workflowsUnderSubagents =
|
|
26530
|
+
const sessionRelative = path49.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
26531
|
+
const subagentsRelative = path49.join(sessionRelative, SUBAGENTS_DIR);
|
|
26532
|
+
const workflowsUnderSubagents = path49.join(subagentsRelative, WORKFLOWS_DIR);
|
|
26156
26533
|
const located = locateAgents(fs17, configDir, subagentsRelative, void 0, report);
|
|
26157
26534
|
for (const runDir of listDirOrReport(fs17, configDir, workflowsUnderSubagents, report)) {
|
|
26158
26535
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
26159
|
-
located.push(...locateAgents(fs17, configDir,
|
|
26536
|
+
located.push(...locateAgents(fs17, configDir, path49.join(workflowsUnderSubagents, runDir), runDir, report));
|
|
26160
26537
|
}
|
|
26161
26538
|
}
|
|
26162
26539
|
const agents = /* @__PURE__ */ new Map();
|
|
@@ -26197,7 +26574,7 @@ function readSessionAgentTree(fs17, configDir, ref, options = {}) {
|
|
|
26197
26574
|
superseded: ref.superseded,
|
|
26198
26575
|
agents: roots.sort().map(build),
|
|
26199
26576
|
tasks: readTasks(fs17, configDir, ownTaskLists(ref.sessionId), [.../* @__PURE__ */ new Set([...teamNames, ...options.taskListIds ?? []])].filter((id) => !ownTaskLists(ref.sessionId).includes(id)), report),
|
|
26200
|
-
workflowRuns: readWorkflowRuns(fs17, configDir,
|
|
26577
|
+
workflowRuns: readWorkflowRuns(fs17, configDir, path49.join(sessionRelative, WORKFLOWS_DIR), report),
|
|
26201
26578
|
problems
|
|
26202
26579
|
};
|
|
26203
26580
|
}
|
|
@@ -26262,12 +26639,12 @@ function ownTaskLists(sessionId) {
|
|
|
26262
26639
|
function readTasks(fs17, configDir, ownLists, sharedLists, report) {
|
|
26263
26640
|
const tasks = [];
|
|
26264
26641
|
[...ownLists, ...sharedLists].forEach((scope, index) => {
|
|
26265
|
-
const relativeDir =
|
|
26642
|
+
const relativeDir = path49.join(TASKS_DIR, scope);
|
|
26266
26643
|
for (const name of [...listDirOrReport(fs17, configDir, relativeDir, report)].sort()) {
|
|
26267
26644
|
if (name.startsWith(".") || !name.endsWith(JSON_SUFFIX)) {
|
|
26268
26645
|
continue;
|
|
26269
26646
|
}
|
|
26270
|
-
const relative =
|
|
26647
|
+
const relative = path49.join(relativeDir, name);
|
|
26271
26648
|
const text = readFileOrReport(fs17, configDir, relative, report);
|
|
26272
26649
|
const parsed = TaskFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
26273
26650
|
if (parsed.success) {
|
|
@@ -26285,7 +26662,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
|
|
|
26285
26662
|
if (!name.startsWith(WORKFLOW_RUN_PREFIX) || !name.endsWith(JSON_SUFFIX)) {
|
|
26286
26663
|
continue;
|
|
26287
26664
|
}
|
|
26288
|
-
const relative =
|
|
26665
|
+
const relative = path49.join(relativeDir, name);
|
|
26289
26666
|
const text = readFileOrReport(fs17, configDir, relative, report);
|
|
26290
26667
|
const parsed = WorkflowRunFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
26291
26668
|
if (!parsed.success) {
|
|
@@ -26302,7 +26679,7 @@ function readWorkflowRuns(fs17, configDir, relativeDir, report) {
|
|
|
26302
26679
|
|
|
26303
26680
|
// src/agents/sessions.ts
|
|
26304
26681
|
init_cliError();
|
|
26305
|
-
import
|
|
26682
|
+
import path50 from "node:path";
|
|
26306
26683
|
var SessionLookupError = class extends CliError {
|
|
26307
26684
|
constructor(message) {
|
|
26308
26685
|
super(message);
|
|
@@ -26313,7 +26690,7 @@ function historyStores(fs17, configDirOf, identities) {
|
|
|
26313
26690
|
const byRealPath = /* @__PURE__ */ new Map();
|
|
26314
26691
|
for (const identity of identities) {
|
|
26315
26692
|
const configDir = configDirOf(identity);
|
|
26316
|
-
const real = fs17.realpath(
|
|
26693
|
+
const real = fs17.realpath(path50.join(configDir, "projects"));
|
|
26317
26694
|
if (real === void 0) {
|
|
26318
26695
|
continue;
|
|
26319
26696
|
}
|