claude-use 14.6.0 → 14.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +89 -52
- package/dist/index.cjs +53 -40
- package/dist/index.mjs +53 -40
- package/dist/types/index.d.ts +16 -3
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -29787,7 +29787,7 @@ function pruneDeadFrontDoorDirectRecords(fs37, recordsDir, records, liveness) {
|
|
|
29787
29787
|
}
|
|
29788
29788
|
}
|
|
29789
29789
|
function recordOf(details) {
|
|
29790
|
-
return details === void 0 ? {} : { sessionId: details.sessionId, ...details.identity === void 0 ? {} : { identity: details.identity }, ...details.models === void 0 ? {} : { models: details.models }, ...details.configDir === void 0 ? {} : { configDir: details.configDir } };
|
|
29790
|
+
return details === void 0 ? {} : { sessionId: details.sessionId, ...details.identity === void 0 ? {} : { identity: details.identity }, ...details.models === void 0 ? {} : { models: details.models }, ...details.configDir === void 0 ? {} : { configDir: details.configDir }, ...details.claudeVersion === void 0 ? {} : { claudeVersion: details.claudeVersion } };
|
|
29791
29791
|
}
|
|
29792
29792
|
function launchRouteStore(fs37, sessionsDir, log) {
|
|
29793
29793
|
const failing = /* @__PURE__ */ new Set();
|
|
@@ -29962,9 +29962,9 @@ var init_state = __esm({
|
|
|
29962
29962
|
init_zod();
|
|
29963
29963
|
init_schema();
|
|
29964
29964
|
init_baseUrlDial();
|
|
29965
|
-
FRONT_DOOR_PROTOCOL =
|
|
29965
|
+
FRONT_DOOR_PROTOCOL = 11;
|
|
29966
29966
|
FRONT_DOOR_HANDOVER_PROTOCOL = 6;
|
|
29967
|
-
FrontDoorSessionSchema = external_exports.strictObject({ pid: external_exports.number().int().positive(), startedAt: external_exports.number(), token: external_exports.string().min(1), supervisorPid: external_exports.number().int().positive().optional(), sessionId: external_exports.string().min(1).optional(), identity: external_exports.string().min(1).optional(), models: ModelsConfigSchema.optional(), configDir: external_exports.string().min(1).optional() });
|
|
29967
|
+
FrontDoorSessionSchema = external_exports.strictObject({ pid: external_exports.number().int().positive(), startedAt: external_exports.number(), token: external_exports.string().min(1), supervisorPid: external_exports.number().int().positive().optional(), sessionId: external_exports.string().min(1).optional(), identity: external_exports.string().min(1).optional(), models: ModelsConfigSchema.optional(), configDir: external_exports.string().min(1).optional(), claudeVersion: external_exports.string().min(1).optional() });
|
|
29968
29968
|
MAX_CONTEXT_TEXT_LENGTH = 256;
|
|
29969
29969
|
ContextText = external_exports.string().min(1).max(MAX_CONTEXT_TEXT_LENGTH);
|
|
29970
29970
|
LaunchRouteSchema = external_exports.union([external_exports.strictObject({ kind: external_exports.literal("anthropic") }), external_exports.strictObject({ kind: external_exports.literal("provider"), provider: external_exports.string().min(1) })]);
|
|
@@ -44182,7 +44182,7 @@ function rcEventWriteResultFromAnswer(answer) {
|
|
|
44182
44182
|
return { ok: true, sequenceNums };
|
|
44183
44183
|
}
|
|
44184
44184
|
function noOAuthCredentialResult(sessionId) {
|
|
44185
|
-
return { ok: false, message: `no claude.ai OAuth bearer has been observed for session ${sessionId}: only worker calls crossed this door, and the worker JWT they carry is answered 401 on the client half. Reconnect Remote Control through this door and the create's own bearer will be observed
|
|
44185
|
+
return { ok: false, message: `no claude.ai OAuth bearer has been observed for session ${sessionId}: only worker calls crossed this door, and the worker JWT they carry is answered 401 on the client half. Reconnect Remote Control through this door and the create's own bearer will be observed`, refusal: "session-state" };
|
|
44186
44186
|
}
|
|
44187
44187
|
function rcSessionNotObservedMessage(sessionId) {
|
|
44188
44188
|
return `the front door has not observed Remote Control session ${sessionId}: it may never have passed through this door, or it ended or expired (an entry lives only a bounded idle period past its last observed traffic)`;
|
|
@@ -44203,7 +44203,7 @@ function rcWriteHeaders(credential) {
|
|
|
44203
44203
|
async function injectRcUserMessage(deps, sessionId, text5) {
|
|
44204
44204
|
const credential = deps.credentialOf(sessionId);
|
|
44205
44205
|
if (credential === void 0) {
|
|
44206
|
-
return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
|
|
44206
|
+
return { ok: false, message: rcSessionNotObservedMessage(sessionId), refusal: "not-observed" };
|
|
44207
44207
|
}
|
|
44208
44208
|
if (credential.authorization === void 0) {
|
|
44209
44209
|
return noOAuthCredentialResult(sessionId);
|
|
@@ -44300,22 +44300,22 @@ function questionAnswerInput(deps, sessionId, pending, decision) {
|
|
|
44300
44300
|
async function answerRcControlRequest(deps, sessionId, requestId, decision) {
|
|
44301
44301
|
const credential = deps.credentialOf(sessionId);
|
|
44302
44302
|
if (credential === void 0) {
|
|
44303
|
-
return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
|
|
44303
|
+
return { ok: false, message: rcSessionNotObservedMessage(sessionId), refusal: "not-observed" };
|
|
44304
44304
|
}
|
|
44305
44305
|
if (credential.authorization === void 0) {
|
|
44306
44306
|
return noOAuthCredentialResult(sessionId);
|
|
44307
44307
|
}
|
|
44308
44308
|
const pending = deps.pendingOf(sessionId).find((candidate) => candidate.requestId === requestId);
|
|
44309
44309
|
if (pending === void 0) {
|
|
44310
|
-
return { ok: false, message: `the front door has not observed control request ${requestId} pending on session ${sessionId}: it was answered already (by this door, by an attached client or in the session's own terminal), the worker withdrew it, or it never passed through this door
|
|
44310
|
+
return { ok: false, message: `the front door has not observed control request ${requestId} pending on session ${sessionId}: it was answered already (by this door, by an attached client or in the session's own terminal), the worker withdrew it, or it never passed through this door`, refusal: "not-observed" };
|
|
44311
44311
|
}
|
|
44312
44312
|
const updatedInput = questionAnswerInput(deps, sessionId, pending, decision);
|
|
44313
44313
|
if (updatedInput !== void 0 && "error" in updatedInput) {
|
|
44314
|
-
return { ok: false, message: updatedInput.error };
|
|
44314
|
+
return { ok: false, message: updatedInput.error, refusal: "invalid-input" };
|
|
44315
44315
|
}
|
|
44316
44316
|
const release = deps.claimPending(sessionId, requestId);
|
|
44317
44317
|
if (release === void 0) {
|
|
44318
|
-
return { ok: false, message: `another answer to control request ${requestId} on session ${sessionId} is being written right now; the worker takes only one, so this one was not sent
|
|
44318
|
+
return { ok: false, message: `another answer to control request ${requestId} on session ${sessionId} is being written right now; the worker takes only one, so this one was not sent`, refusal: "session-state" };
|
|
44319
44319
|
}
|
|
44320
44320
|
const body = JSON.stringify(buildRcEventWriteBody(buildRcControlResponsePayload(requestId, decision, updatedInput?.input)));
|
|
44321
44321
|
let answer;
|
|
@@ -44336,7 +44336,7 @@ async function answerRcControlRequest(deps, sessionId, requestId, decision) {
|
|
|
44336
44336
|
async function deliverRcClientPayload(deps, sessionId, payload, action, to2 = "events") {
|
|
44337
44337
|
const credential = deps.credentialOf(sessionId);
|
|
44338
44338
|
if (credential === void 0) {
|
|
44339
|
-
return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
|
|
44339
|
+
return { ok: false, message: rcSessionNotObservedMessage(sessionId), refusal: "not-observed" };
|
|
44340
44340
|
}
|
|
44341
44341
|
if (credential.authorization === void 0) {
|
|
44342
44342
|
return noOAuthCredentialResult(sessionId);
|
|
@@ -44361,7 +44361,7 @@ async function interruptRcSession(deps, sessionId) {
|
|
|
44361
44361
|
}
|
|
44362
44362
|
async function setRcSessionModel(deps, sessionId, model) {
|
|
44363
44363
|
if (model === "") {
|
|
44364
|
-
return { ok: false, message: "a set-model write needs a non-empty model id: the SDK's own field treats an omitted or null value as a reset to the session default, which this operation never sends, and an empty string is neither" };
|
|
44364
|
+
return { ok: false, message: "a set-model write needs a non-empty model id: the SDK's own field treats an omitted or null value as a reset to the session default, which this operation never sends, and an empty string is neither", refusal: "invalid-input" };
|
|
44365
44365
|
}
|
|
44366
44366
|
const requestId = deps.newUuid();
|
|
44367
44367
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcSetModelPayload(requestId, model), `set the model on session ${sessionId}`);
|
|
@@ -44374,7 +44374,7 @@ async function setRcSessionPermissionMode(deps, sessionId, mode) {
|
|
|
44374
44374
|
}
|
|
44375
44375
|
async function endRcSession(deps, sessionId, reason) {
|
|
44376
44376
|
if (reason === "") {
|
|
44377
|
-
return { ok: false, message: "an end-session write needs either no reason or a non-empty one: the worker reads an absent reason as its own unspecified form, and an empty string is neither" };
|
|
44377
|
+
return { ok: false, message: "an end-session write needs either no reason or a non-empty one: the worker reads an absent reason as its own unspecified form, and an empty string is neither", refusal: "invalid-input" };
|
|
44378
44378
|
}
|
|
44379
44379
|
const requestId = deps.newUuid();
|
|
44380
44380
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcEndSessionPayload(requestId, reason), `end session ${sessionId}`);
|
|
@@ -44392,10 +44392,10 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
44392
44392
|
}
|
|
44393
44393
|
async function readRcSessionFile(deps, sessionId, path106, options) {
|
|
44394
44394
|
if (path106 === "") {
|
|
44395
|
-
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" };
|
|
44395
|
+
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", refusal: "invalid-input" };
|
|
44396
44396
|
}
|
|
44397
44397
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
44398
|
-
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" };
|
|
44398
|
+
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", refusal: "invalid-input" };
|
|
44399
44399
|
}
|
|
44400
44400
|
const requestId = deps.newUuid();
|
|
44401
44401
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path106, options), `read ${path106} from session ${sessionId}`);
|
|
@@ -44413,7 +44413,7 @@ async function getRcSessionMcpStatus(deps, sessionId) {
|
|
|
44413
44413
|
}
|
|
44414
44414
|
async function reconnectRcSessionMcpServer(deps, sessionId, serverName) {
|
|
44415
44415
|
if (serverName === "") {
|
|
44416
|
-
return { ok: false, message: "an mcp-reconnect write needs a non-empty server name: the SDK's own field names the server as mcp_status reports it, and an empty string names none" };
|
|
44416
|
+
return { ok: false, message: "an mcp-reconnect write needs a non-empty server name: the SDK's own field names the server as mcp_status reports it, and an empty string names none", refusal: "invalid-input" };
|
|
44417
44417
|
}
|
|
44418
44418
|
const requestId = deps.newUuid();
|
|
44419
44419
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcMcpReconnectPayload(requestId, serverName), `reconnect MCP server ${serverName} on session ${sessionId}`);
|
|
@@ -44421,7 +44421,7 @@ async function reconnectRcSessionMcpServer(deps, sessionId, serverName) {
|
|
|
44421
44421
|
}
|
|
44422
44422
|
async function authenticateRcSessionMcpServer(deps, sessionId, serverName, redirectUri) {
|
|
44423
44423
|
if (serverName === "" || redirectUri === "") {
|
|
44424
|
-
return { ok: false, message: "an mcp-authenticate write needs a non-empty server name and redirect URI: the CLI's own request names the server and where its OAuth flow redirects back to, and an empty string names neither" };
|
|
44424
|
+
return { ok: false, message: "an mcp-authenticate write needs a non-empty server name and redirect URI: the CLI's own request names the server and where its OAuth flow redirects back to, and an empty string names neither", refusal: "invalid-input" };
|
|
44425
44425
|
}
|
|
44426
44426
|
const requestId = deps.newUuid();
|
|
44427
44427
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcMcpAuthenticatePayload(requestId, serverName, redirectUri), `authenticate MCP server ${serverName} on session ${sessionId}`);
|
|
@@ -44429,7 +44429,7 @@ async function authenticateRcSessionMcpServer(deps, sessionId, serverName, redir
|
|
|
44429
44429
|
}
|
|
44430
44430
|
async function submitRcSessionMcpOAuthCallbackUrl(deps, sessionId, serverName, callbackUrl) {
|
|
44431
44431
|
if (serverName === "" || callbackUrl === "") {
|
|
44432
|
-
return { ok: false, message: "an mcp-oauth-callback-url write needs a non-empty server name and callback URL: the CLI's own request names the server and the URL its OAuth flow landed on, and an empty string names neither" };
|
|
44432
|
+
return { ok: false, message: "an mcp-oauth-callback-url write needs a non-empty server name and callback URL: the CLI's own request names the server and the URL its OAuth flow landed on, and an empty string names neither", refusal: "invalid-input" };
|
|
44433
44433
|
}
|
|
44434
44434
|
const requestId = deps.newUuid();
|
|
44435
44435
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcMcpOAuthCallbackUrlPayload(requestId, serverName, callbackUrl), `hand MCP server ${serverName}'s OAuth callback to session ${sessionId}`);
|
|
@@ -44440,7 +44440,7 @@ async function sendRcKeepAlive(deps, sessionId) {
|
|
|
44440
44440
|
}
|
|
44441
44441
|
async function teleportRcSession(deps, sessionId, marker) {
|
|
44442
44442
|
if (marker === "") {
|
|
44443
|
-
return { ok: false, message: "a teleport write needs a non-empty marker: the teleport relay anchors on a marker line's uuid and string content, and an empty string carries neither" };
|
|
44443
|
+
return { ok: false, message: "a teleport write needs a non-empty marker: the teleport relay anchors on a marker line's uuid and string content, and an empty string carries neither", refusal: "invalid-input" };
|
|
44444
44444
|
}
|
|
44445
44445
|
return await deliverRcClientPayload(deps, sessionId, buildRcUserMessagePayload(deps.newUuid(), sessionId, marker), `teleport a marker into session ${sessionId}`, "teleport-events");
|
|
44446
44446
|
}
|
|
@@ -75621,7 +75621,7 @@ var init_package = __esm({
|
|
|
75621
75621
|
"package.json"() {
|
|
75622
75622
|
package_default = {
|
|
75623
75623
|
name: "claude-use",
|
|
75624
|
-
version: "14.
|
|
75624
|
+
version: "14.7.0",
|
|
75625
75625
|
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.",
|
|
75626
75626
|
license: "MIT",
|
|
75627
75627
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -78075,7 +78075,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
78075
78075
|
const sessionId = params.supervised?.sessionId ?? (0, import_node_crypto29.randomUUID)();
|
|
78076
78076
|
const resolvedModels = decided.models ?? (decided.globalModels === void 0 ? void 0 : {});
|
|
78077
78077
|
const sessionModels = (0, import_node_util6.isDeepStrictEqual)(resolvedModels, decided.globalModels) ? void 0 : resolvedModels;
|
|
78078
|
-
const session = { sessionId, ...decided.farmIdentity === void 0 ? {} : { identity: decided.farmIdentity }, ...sessionModels === void 0 ? {} : { models: sessionModels }, configDir: decision.configDir ?? import_node_path57.default.join(import_node_os14.default.homedir(), ".claude") };
|
|
78078
|
+
const session = { sessionId, ...decided.farmIdentity === void 0 ? {} : { identity: decided.farmIdentity }, ...sessionModels === void 0 ? {} : { models: sessionModels }, configDir: decision.configDir ?? import_node_path57.default.join(import_node_os14.default.homedir(), ".claude"), ...decided.binVersion === void 0 ? {} : { claudeVersion: decided.binVersion } };
|
|
78079
78079
|
let frontDoor = frontDoorEngaged && frontDoorPort !== void 0 ? frontDoorPort.ensure(env.NODE_EXTRA_CA_CERTS, session) : void 0;
|
|
78080
78080
|
if (frontDoor !== void 0 && frontDoorPort !== void 0) {
|
|
78081
78081
|
let beforePid = frontDoor.supervisorPid;
|
|
@@ -144955,6 +144955,21 @@ async function runSelfHostedTurn(deps, sessionId, text5, waitMs, signal) {
|
|
|
144955
144955
|
signal
|
|
144956
144956
|
);
|
|
144957
144957
|
}
|
|
144958
|
+
function createSelfHostedSessionVersions(sources) {
|
|
144959
|
+
const warned2 = /* @__PURE__ */ new Set();
|
|
144960
|
+
return (sessionId) => {
|
|
144961
|
+
const reported = sources.reported(sessionId);
|
|
144962
|
+
const recorded = sources.recorded(sessionId);
|
|
144963
|
+
if (reported !== void 0 && recorded !== void 0 && reported !== recorded) {
|
|
144964
|
+
const key = `${sessionId} ${recorded} ${reported}`;
|
|
144965
|
+
if (!warned2.has(key)) {
|
|
144966
|
+
warned2.add(key);
|
|
144967
|
+
sources.warn(`rc selfhost ${sessionId}: its launch recorded Claude Code ${recorded} and its worker reports ${reported}; the worker's report is the version its verbs are gated on`);
|
|
144968
|
+
}
|
|
144969
|
+
}
|
|
144970
|
+
return reported ?? recorded;
|
|
144971
|
+
};
|
|
144972
|
+
}
|
|
144958
144973
|
function createRcClaudeCodeVersions(fanout) {
|
|
144959
144974
|
const versions = /* @__PURE__ */ new Map();
|
|
144960
144975
|
fanout.subscribe(void 0, (event) => {
|
|
@@ -145013,10 +145028,10 @@ function createRcSessionCommands(deps) {
|
|
|
145013
145028
|
return void 0;
|
|
145014
145029
|
}
|
|
145015
145030
|
if ("refused" in target) {
|
|
145016
|
-
return { kind: "refused", message: target.refused };
|
|
145031
|
+
return { kind: "refused", message: target.refused, refusal: "session-state" };
|
|
145017
145032
|
}
|
|
145018
145033
|
if (target.version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(target.version)) {
|
|
145019
|
-
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") };
|
|
145034
|
+
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"), refusal: "session-state" };
|
|
145020
145035
|
}
|
|
145021
145036
|
return { kind: route, target };
|
|
145022
145037
|
};
|
|
@@ -145030,18 +145045,18 @@ function createRcSessionCommands(deps) {
|
|
|
145030
145045
|
return launched;
|
|
145031
145046
|
}
|
|
145032
145047
|
if (!deps.isObserved(sessionId)) {
|
|
145033
|
-
return { kind: "refused", message: `the front door has not observed Remote Control session ${sessionId}
|
|
145048
|
+
return { kind: "refused", message: `the front door has not observed Remote Control session ${sessionId}`, refusal: "not-observed" };
|
|
145034
145049
|
}
|
|
145035
145050
|
if (deps.selfHost === void 0) {
|
|
145036
|
-
return { kind: "refused", message: unsupportedMessage(sessionId) };
|
|
145051
|
+
return { kind: "refused", message: unsupportedMessage(sessionId), refusal: "session-state" };
|
|
145037
145052
|
}
|
|
145038
145053
|
const unavailable = deps.selfHost.unavailable();
|
|
145039
145054
|
if (unavailable !== void 0) {
|
|
145040
|
-
return { kind: "refused", message: `${noPluginReason(sessionId)}, and the door's self-hosted surface cannot take a command: ${unavailable}
|
|
145055
|
+
return { kind: "refused", message: `${noPluginReason(sessionId)}, and the door's self-hosted surface cannot take a command: ${unavailable}`, refusal: "session-state" };
|
|
145041
145056
|
}
|
|
145042
145057
|
const version2 = deps.selfHost.versionOf(sessionId);
|
|
145043
145058
|
if (version2 === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version2)) {
|
|
145044
|
-
return { kind: "refused", message: unverifiedVersionMessage(sessionId, version2, "no system/init from its worker has been observed on its stream; send it a prompt so it reports one") };
|
|
145059
|
+
return { kind: "refused", message: unverifiedVersionMessage(sessionId, version2, "its launch recorded none and no system/init from its worker has been observed on its stream; send it a prompt so it reports one"), refusal: "session-state" };
|
|
145045
145060
|
}
|
|
145046
145061
|
return { kind: "self-hosted", selfHost: deps.selfHost };
|
|
145047
145062
|
};
|
|
@@ -145052,7 +145067,7 @@ function createRcSessionCommands(deps) {
|
|
|
145052
145067
|
}
|
|
145053
145068
|
const resolved = await resolveRoute(sessionId);
|
|
145054
145069
|
if (resolved.kind === "refused") {
|
|
145055
|
-
return { ok: false, message: resolved.message };
|
|
145070
|
+
return { ok: false, message: resolved.message, refusal: resolved.refusal };
|
|
145056
145071
|
}
|
|
145057
145072
|
if (resolved.kind !== "self-hosted") {
|
|
145058
145073
|
const waitMs2 = options.waitMs ?? COMPACT_TIMEOUT_MS;
|
|
@@ -145078,7 +145093,7 @@ function createRcSessionCommands(deps) {
|
|
|
145078
145093
|
const transcriptGoal = async (sessionId, target) => {
|
|
145079
145094
|
const goal = target.transcriptPath === void 0 ? void 0 : await deps.goalOf(target.transcriptPath);
|
|
145080
145095
|
if (goal === void 0) {
|
|
145081
|
-
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
|
|
145096
|
+
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`, refusal: "session-state" };
|
|
145082
145097
|
}
|
|
145083
145098
|
return { ok: true, report: goal };
|
|
145084
145099
|
};
|
|
@@ -145094,7 +145109,7 @@ function createRcSessionCommands(deps) {
|
|
|
145094
145109
|
const waitOf = (options) => options.waitMs;
|
|
145095
145110
|
const transcriptPluginTurns = async (sessionId, target) => {
|
|
145096
145111
|
const turns = target.transcriptPath === void 0 ? void 0 : await deps.pluginTurnsOf(target.transcriptPath);
|
|
145097
|
-
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
|
|
145112
|
+
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`, refusal: "session-state" } : { ok: true, report: turns };
|
|
145098
145113
|
};
|
|
145099
145114
|
return {
|
|
145100
145115
|
/** 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. */
|
|
@@ -145107,13 +145122,13 @@ function createRcSessionCommands(deps) {
|
|
|
145107
145122
|
*/
|
|
145108
145123
|
turn: async (sessionId, text5, options = {}) => {
|
|
145109
145124
|
if (text5.trim() === "") {
|
|
145110
|
-
return { ok: false, message: "a turn needs non-empty text" };
|
|
145125
|
+
return { ok: false, message: "a turn needs non-empty text", refusal: "invalid-input" };
|
|
145111
145126
|
}
|
|
145112
145127
|
if (text5.trimStart().startsWith("/")) {
|
|
145113
|
-
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" };
|
|
145128
|
+
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", refusal: "invalid-input" };
|
|
145114
145129
|
}
|
|
145115
145130
|
if (text5.length > RC_TURN_TEXT_MAX_CHARS) {
|
|
145116
|
-
return { ok: false, message: `a turn's text is limited to ${String(RC_TURN_TEXT_MAX_CHARS)} characters, and this one has ${String(text5.length)}
|
|
145131
|
+
return { ok: false, message: `a turn's text is limited to ${String(RC_TURN_TEXT_MAX_CHARS)} characters, and this one has ${String(text5.length)}`, refusal: "invalid-input" };
|
|
145117
145132
|
}
|
|
145118
145133
|
return await onRoute(sessionId, options, {
|
|
145119
145134
|
plugin: async (target, route, signal, waitMs) => {
|
|
@@ -145162,16 +145177,16 @@ function createRcSessionCommands(deps) {
|
|
|
145162
145177
|
goalSet: async (sessionId, condition, options = {}) => {
|
|
145163
145178
|
const trimmed = condition.trim();
|
|
145164
145179
|
if (trimmed === "") {
|
|
145165
|
-
return { ok: false, message: "a goal set needs a non-empty condition" };
|
|
145180
|
+
return { ok: false, message: "a goal set needs a non-empty condition", refusal: "invalid-input" };
|
|
145166
145181
|
}
|
|
145167
145182
|
if (RC_GOAL_CLEAR_WORDS.includes(trimmed.toLowerCase())) {
|
|
145168
|
-
return { ok: false, message: `"${trimmed}" cannot be set as a goal condition: /goal reads ${RC_GOAL_CLEAR_WORDS.join(", ")} as a request to clear the goal, so use the clear verb for that
|
|
145183
|
+
return { ok: false, message: `"${trimmed}" cannot be set as a goal condition: /goal reads ${RC_GOAL_CLEAR_WORDS.join(", ")} as a request to clear the goal, so use the clear verb for that`, refusal: "invalid-input" };
|
|
145169
145184
|
}
|
|
145170
145185
|
if (/[\r\n]/u.test(trimmed)) {
|
|
145171
|
-
return { ok: false, message: "a goal condition is one line: /goal reads its condition from the line it is typed on, and both routes confirm the goal by the exact condition, so a condition spanning lines is refused rather than set as something else" };
|
|
145186
|
+
return { ok: false, message: "a goal condition is one line: /goal reads its condition from the line it is typed on, and both routes confirm the goal by the exact condition, so a condition spanning lines is refused rather than set as something else", refusal: "invalid-input" };
|
|
145172
145187
|
}
|
|
145173
145188
|
if (trimmed.length > RC_GOAL_CONDITION_MAX_CHARS) {
|
|
145174
|
-
return { ok: false, message: `a goal condition is limited to ${String(RC_GOAL_CONDITION_MAX_CHARS)} characters, and this one has ${String(trimmed.length)}
|
|
145189
|
+
return { ok: false, message: `a goal condition is limited to ${String(RC_GOAL_CONDITION_MAX_CHARS)} characters, and this one has ${String(trimmed.length)}`, refusal: "invalid-input" };
|
|
145175
145190
|
}
|
|
145176
145191
|
return await onRoute(sessionId, options, {
|
|
145177
145192
|
plugin: async (target, route, signal, waitMs) => {
|
|
@@ -145314,17 +145329,25 @@ function doorApiAuth(expectedToken) {
|
|
|
145314
145329
|
}
|
|
145315
145330
|
var RC_API_TAG = "remote-control";
|
|
145316
145331
|
var RC_DIRECTIVE_TAG = "remote-control-directives";
|
|
145332
|
+
var RC_REFUSAL_CODES = {
|
|
145333
|
+
"invalid-input": "BAD_REQUEST",
|
|
145334
|
+
"not-observed": "NOT_FOUND",
|
|
145335
|
+
"session-state": "CONFLICT"
|
|
145336
|
+
};
|
|
145337
|
+
function refusalOf(failure2) {
|
|
145338
|
+
return new ORPCError(failure2.refusal === void 0 ? "BAD_GATEWAY" : RC_REFUSAL_CODES[failure2.refusal], { message: failure2.message });
|
|
145339
|
+
}
|
|
145317
145340
|
function createRcApiRouter(deps) {
|
|
145318
145341
|
const authed = doorApiAuth(deps.expectedToken);
|
|
145319
145342
|
const delivered = (sessionId, result) => {
|
|
145320
145343
|
if (!result.ok) {
|
|
145321
|
-
throw
|
|
145344
|
+
throw refusalOf(result);
|
|
145322
145345
|
}
|
|
145323
145346
|
return result.sequenceNums;
|
|
145324
145347
|
};
|
|
145325
145348
|
const deliveredControl = (sessionId, result) => {
|
|
145326
145349
|
if (!result.ok) {
|
|
145327
|
-
throw
|
|
145350
|
+
throw refusalOf(result);
|
|
145328
145351
|
}
|
|
145329
145352
|
if (result.requestId === void 0) {
|
|
145330
145353
|
throw new ORPCError("INTERNAL_SERVER_ERROR", { message: "the control request was delivered but the door cannot name the request id it minted, so the worker's answer cannot be matched" });
|
|
@@ -145333,7 +145356,7 @@ function createRcApiRouter(deps) {
|
|
|
145333
145356
|
};
|
|
145334
145357
|
const commanded = (sessionId, result) => {
|
|
145335
145358
|
if (!result.ok) {
|
|
145336
|
-
throw
|
|
145359
|
+
throw refusalOf(result);
|
|
145337
145360
|
}
|
|
145338
145361
|
return { session: sessionId, ...result.report };
|
|
145339
145362
|
};
|
|
@@ -146902,12 +146925,14 @@ function createLiveSessionRegistry(ports) {
|
|
|
146902
146925
|
let bySessionId = /* @__PURE__ */ new Map();
|
|
146903
146926
|
let launches = /* @__PURE__ */ new Set();
|
|
146904
146927
|
const recordNames = () => fs37.readdir(sessionsDir).filter(isSessionRecordName);
|
|
146928
|
+
let byLaunch = /* @__PURE__ */ new Map();
|
|
146905
146929
|
const rebuildIndexes = () => {
|
|
146906
146930
|
const records = [...known.values()].flatMap(({ record: record3 }) => record3 === void 0 ? [] : [record3]);
|
|
146907
146931
|
tokens = new Set(records.map((record3) => record3.token));
|
|
146908
146932
|
byToken = new Map(records.map((record3) => [record3.token, record3]));
|
|
146909
146933
|
bySessionId = new Map(records.flatMap((record3) => record3.sessionId === void 0 ? [] : [[record3.sessionId, record3]]));
|
|
146910
146934
|
launches = new Set(records.map(launchKeyOf));
|
|
146935
|
+
byLaunch = new Map(records.map((record3) => [launchKeyOf(record3), record3]));
|
|
146911
146936
|
};
|
|
146912
146937
|
const load = (name, stat2) => {
|
|
146913
146938
|
known.set(name, { stat: { mtimeMs: stat2.mtimeMs, sizeBytes: stat2.sizeBytes }, record: readFrontDoorSessionRecord(fs37, sessionsDir, name) });
|
|
@@ -146954,6 +146979,7 @@ function createLiveSessionRegistry(ports) {
|
|
|
146954
146979
|
return held?.sessionId === void 0 ? void 0 : { pid: held.pid, startedAt: held.startedAt };
|
|
146955
146980
|
},
|
|
146956
146981
|
holdsLaunch: (launch) => launches.has(launchKeyOf(launch)) || reconcile() && launches.has(launchKeyOf(launch)),
|
|
146982
|
+
claudeVersionOf: (launch) => (byLaunch.get(launchKeyOf(launch)) ?? (reconcile() ? byLaunch.get(launchKeyOf(launch)) : void 0))?.claudeVersion,
|
|
146957
146983
|
rescan: () => {
|
|
146958
146984
|
known.clear();
|
|
146959
146985
|
for (const name of recordNames()) {
|
|
@@ -153913,7 +153939,8 @@ data: ${JSON.stringify(envelope2)}
|
|
|
153913
153939
|
clients: /* @__PURE__ */ new Map(),
|
|
153914
153940
|
workerStatus: void 0,
|
|
153915
153941
|
externalMetadata: void 0,
|
|
153916
|
-
lastTrafficAt: deps.now()
|
|
153942
|
+
lastTrafficAt: deps.now(),
|
|
153943
|
+
launchVersion: request7.session.launch === void 0 ? void 0 : deps.launchVersionOf(request7.session.launch)
|
|
153917
153944
|
};
|
|
153918
153945
|
conversation.sessionIds.add(session.id);
|
|
153919
153946
|
sessions.set(session.id, session);
|
|
@@ -153948,6 +153975,7 @@ data: ${JSON.stringify(envelope2)}
|
|
|
153948
153975
|
return {
|
|
153949
153976
|
route,
|
|
153950
153977
|
local,
|
|
153978
|
+
launchVersionOf: (sessionId) => sessions.get(sessionId)?.launchVersion,
|
|
153951
153979
|
close: () => {
|
|
153952
153980
|
clearInterval(timer);
|
|
153953
153981
|
clearInterval(keepalive);
|
|
@@ -154130,7 +154158,7 @@ function attributeRcSelfHostMint(paths, log) {
|
|
|
154130
154158
|
log(`self-hosted Remote Control surface: the minted credential names no identity and ${String(backfill.holders)} identities hold it, so no launch can be told apart from it and every launch's calls on the intercepted hosts are refused until the identity is minted again (agent-shim frontdoor rc selfhost mint <identity>)`);
|
|
154131
154159
|
}
|
|
154132
154160
|
}
|
|
154133
|
-
function createRealRcSelfHostSurface(paths, doorPid, env, log) {
|
|
154161
|
+
function createRealRcSelfHostSurface(paths, doorPid, env, launchVersionOf, log) {
|
|
154134
154162
|
const ownership = realRcSelfHostLaunchCheck(paths, doorPid);
|
|
154135
154163
|
return createRcSelfHostSurface({
|
|
154136
154164
|
now: () => Date.now(),
|
|
@@ -154140,6 +154168,7 @@ function createRealRcSelfHostSurface(paths, doorPid, env, log) {
|
|
|
154140
154168
|
webFetch: realRcWebFetch({ allowPrivate: rcWebFetchAllowsPrivateFromEnv(env) }),
|
|
154141
154169
|
ownsLaunch: ownership.ownsLaunch,
|
|
154142
154170
|
ownsPeer: ownership.ownsPeer,
|
|
154171
|
+
launchVersionOf,
|
|
154143
154172
|
log
|
|
154144
154173
|
});
|
|
154145
154174
|
}
|
|
@@ -154478,10 +154507,14 @@ function createDoorRcSessionCommands(deps) {
|
|
|
154478
154507
|
personWrite: selfHost.personWrite,
|
|
154479
154508
|
unavailable: selfHost.unavailable,
|
|
154480
154509
|
fanout: selfHost.fanout,
|
|
154481
|
-
versionOf: (
|
|
154482
|
-
|
|
154483
|
-
|
|
154484
|
-
|
|
154510
|
+
versionOf: createSelfHostedSessionVersions({
|
|
154511
|
+
reported: (sessionId) => {
|
|
154512
|
+
selfHost.versions.sweep(deps.isTracked);
|
|
154513
|
+
return selfHost.versions.versionOf(sessionId);
|
|
154514
|
+
},
|
|
154515
|
+
recorded: selfHost.launchVersionOf,
|
|
154516
|
+
warn: selfHost.log
|
|
154517
|
+
}),
|
|
154485
154518
|
setTimer: (action, ms) => {
|
|
154486
154519
|
const timer = setTimeout(action, ms);
|
|
154487
154520
|
return () => {
|
|
@@ -155306,7 +155339,8 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
155306
155339
|
selfHostDialTarget ??= { host: "127.0.0.1", port: transparentPort, servername: CONNECT_INTERCEPT_HOST, ca: [loadCa().certPem] };
|
|
155307
155340
|
return selfHostDialTarget;
|
|
155308
155341
|
};
|
|
155309
|
-
const
|
|
155342
|
+
const sessionRegistry = createLiveSessionRegistry({ fs: realFarmFs, sessionsDir: paths.frontdoorSessionsDir });
|
|
155343
|
+
const rcSelfHostSurface = rcSelfHost ? createRealRcSelfHostSurface(paths, process.pid, process.env, sessionRegistry.claudeVersionOf, log) : void 0;
|
|
155310
155344
|
const rcCredentialStore = createRcCredentialStore(realFarmFs, paths.frontdoorRcCredentialsDir);
|
|
155311
155345
|
const rcSessionEvents = createRcSessionEventLog({ generation: (0, import_node_crypto35.randomUUID)(), capacity: RC_SESSION_EVENT_LOG_CAPACITY });
|
|
155312
155346
|
const rcTracker = createRcSessionTracker({ now: () => Date.now(), idleMs: RC_IDLE_EXPIRY_MS, credentialStore: rcCredentialStore, onTransition: rcSessionEvents.append, onClose: rcSessionEvents.close });
|
|
@@ -155351,7 +155385,6 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
155351
155385
|
const routingSnapshots = /* @__PURE__ */ new Map();
|
|
155352
155386
|
const rcControlToken = lifecycle.predecessor === void 0 ? (0, import_node_crypto35.randomUUID)() : inheritedControlToken(paths);
|
|
155353
155387
|
const capture = captureFromEnv(process.env, paths.logsDir);
|
|
155354
|
-
const sessionRegistry = createLiveSessionRegistry({ fs: realFarmFs, sessionsDir: paths.frontdoorSessionsDir });
|
|
155355
155388
|
const resolveRoute = rcObservingResolver(
|
|
155356
155389
|
createProviderRouteResolver({
|
|
155357
155390
|
// Read live so a models-block edit reaches the next request without a door restart.
|
|
@@ -155583,11 +155616,15 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
155583
155616
|
const rcSessionCommands = createDoorRcSessionCommands({
|
|
155584
155617
|
paths,
|
|
155585
155618
|
isTracked: (sessionId) => rcTracker.statusOf(sessionId).length > 0,
|
|
155586
|
-
selfHost:
|
|
155619
|
+
selfHost: rcSelfHostSurface !== void 0 ? {
|
|
155587
155620
|
personWrite: { credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, newUuid: import_node_crypto35.randomUUID, dial: rcSelfHostEventDial(rcSelfHostDialTarget) },
|
|
155588
155621
|
unavailable: () => rcSelfHostDialTarget() === void 0 ? selfHostSurfaceUnboundReason(process.env.AGENT_SHIM_TRANSPARENT_SURFACE) : void 0,
|
|
155589
155622
|
fanout: rcFanout,
|
|
155590
|
-
versions: rcClaudeCodeVersions
|
|
155623
|
+
versions: rcClaudeCodeVersions,
|
|
155624
|
+
launchVersionOf: rcSelfHostSurface.launchVersionOf,
|
|
155625
|
+
log: (line) => {
|
|
155626
|
+
appendDoorLog(paths, `frontdoor ${String(process.pid)}: ${line}`);
|
|
155627
|
+
}
|
|
155591
155628
|
} : void 0
|
|
155592
155629
|
});
|
|
155593
155630
|
const controlDeps = {
|
|
@@ -173805,7 +173842,7 @@ function memberTexts(member, nowMs) {
|
|
|
173805
173842
|
...quotaRow2 === void 0 ? {} : { quota: quotaRow2.detail === void 0 ? quotaRow2.value : `${quotaRow2.value} (${quotaRow2.detail})` }
|
|
173806
173843
|
};
|
|
173807
173844
|
}
|
|
173808
|
-
function
|
|
173845
|
+
function refusalOf2(candidate) {
|
|
173809
173846
|
return candidate.class === "ineligible" ? candidate.reasons[0] : void 0;
|
|
173810
173847
|
}
|
|
173811
173848
|
function accountsDiffer(members2, left, right) {
|
|
@@ -173845,7 +173882,7 @@ function poolContext(params, poolName, resuming, nowMs) {
|
|
|
173845
173882
|
rank: index + 1,
|
|
173846
173883
|
heading: candidateHeading(candidate),
|
|
173847
173884
|
picked: candidate.identity === pick2,
|
|
173848
|
-
detail:
|
|
173885
|
+
detail: refusalOf2(candidate),
|
|
173849
173886
|
...memberTexts(members2.find((member) => member.identity === candidate.identity), nowMs)
|
|
173850
173887
|
})
|
|
173851
173888
|
})),
|
|
@@ -173875,7 +173912,7 @@ function identityContext(params, resuming, nowMs) {
|
|
|
173875
173912
|
const limited = named !== void 0 && candidates.some((candidate) => candidate.identity === named && candidate.class === "ineligible");
|
|
173876
173913
|
const identityEntries = candidates.map((candidate) => ({
|
|
173877
173914
|
value: candidate.identity,
|
|
173878
|
-
label: pickerLabel({ identity: candidate.identity, detail:
|
|
173915
|
+
label: pickerLabel({ identity: candidate.identity, detail: refusalOf2(candidate), ...memberTexts(members2.find((member) => member.identity === candidate.identity), nowMs) })
|
|
173879
173916
|
}));
|
|
173880
173917
|
const poolEntries = Object.entries(params.pools ?? {}).map(([name, pool]) => ({
|
|
173881
173918
|
value: `pool:${name}`,
|