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/index.cjs CHANGED
@@ -5498,7 +5498,7 @@ function pruneDeadFrontDoorDirectRecords(fs17, recordsDir, records, liveness) {
5498
5498
  }
5499
5499
  }
5500
5500
  function recordOf(details) {
5501
- 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 } };
5501
+ 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 } };
5502
5502
  }
5503
5503
  function writeFrontDoorSession(fs17, sessionsDir, session) {
5504
5504
  fs17.mkdirPrivate(sessionsDir);
@@ -5574,9 +5574,9 @@ var init_state = __esm({
5574
5574
  import_zod9 = require("zod");
5575
5575
  init_schema();
5576
5576
  init_baseUrlDial();
5577
- FRONT_DOOR_PROTOCOL = 10;
5577
+ FRONT_DOOR_PROTOCOL = 11;
5578
5578
  FRONT_DOOR_HANDOVER_PROTOCOL = 6;
5579
- FrontDoorSessionSchema = import_zod9.z.strictObject({ pid: import_zod9.z.number().int().positive(), startedAt: import_zod9.z.number(), token: import_zod9.z.string().min(1), supervisorPid: import_zod9.z.number().int().positive().optional(), sessionId: import_zod9.z.string().min(1).optional(), identity: import_zod9.z.string().min(1).optional(), models: ModelsConfigSchema.optional(), configDir: import_zod9.z.string().min(1).optional() });
5579
+ FrontDoorSessionSchema = import_zod9.z.strictObject({ pid: import_zod9.z.number().int().positive(), startedAt: import_zod9.z.number(), token: import_zod9.z.string().min(1), supervisorPid: import_zod9.z.number().int().positive().optional(), sessionId: import_zod9.z.string().min(1).optional(), identity: import_zod9.z.string().min(1).optional(), models: ModelsConfigSchema.optional(), configDir: import_zod9.z.string().min(1).optional(), claudeVersion: import_zod9.z.string().min(1).optional() });
5580
5580
  MAX_CONTEXT_TEXT_LENGTH = 256;
5581
5581
  ContextText = import_zod9.z.string().min(1).max(MAX_CONTEXT_TEXT_LENGTH);
5582
5582
  LaunchRouteSchema = import_zod9.z.union([import_zod9.z.strictObject({ kind: import_zod9.z.literal("anthropic") }), import_zod9.z.strictObject({ kind: import_zod9.z.literal("provider"), provider: import_zod9.z.string().min(1) })]);
@@ -7532,7 +7532,7 @@ function rcEventWriteResultFromAnswer(answer) {
7532
7532
  return { ok: true, sequenceNums };
7533
7533
  }
7534
7534
  function noOAuthCredentialResult(sessionId) {
7535
- 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` };
7535
+ 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" };
7536
7536
  }
7537
7537
  function rcSessionNotObservedMessage(sessionId) {
7538
7538
  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)`;
@@ -7553,7 +7553,7 @@ function rcWriteHeaders(credential) {
7553
7553
  async function injectRcUserMessage(deps, sessionId, text) {
7554
7554
  const credential = deps.credentialOf(sessionId);
7555
7555
  if (credential === void 0) {
7556
- return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
7556
+ return { ok: false, message: rcSessionNotObservedMessage(sessionId), refusal: "not-observed" };
7557
7557
  }
7558
7558
  if (credential.authorization === void 0) {
7559
7559
  return noOAuthCredentialResult(sessionId);
@@ -7650,22 +7650,22 @@ function questionAnswerInput(deps, sessionId, pending, decision) {
7650
7650
  async function answerRcControlRequest(deps, sessionId, requestId, decision) {
7651
7651
  const credential = deps.credentialOf(sessionId);
7652
7652
  if (credential === void 0) {
7653
- return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
7653
+ return { ok: false, message: rcSessionNotObservedMessage(sessionId), refusal: "not-observed" };
7654
7654
  }
7655
7655
  if (credential.authorization === void 0) {
7656
7656
  return noOAuthCredentialResult(sessionId);
7657
7657
  }
7658
7658
  const pending = deps.pendingOf(sessionId).find((candidate) => candidate.requestId === requestId);
7659
7659
  if (pending === void 0) {
7660
- 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` };
7660
+ 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" };
7661
7661
  }
7662
7662
  const updatedInput = questionAnswerInput(deps, sessionId, pending, decision);
7663
7663
  if (updatedInput !== void 0 && "error" in updatedInput) {
7664
- return { ok: false, message: updatedInput.error };
7664
+ return { ok: false, message: updatedInput.error, refusal: "invalid-input" };
7665
7665
  }
7666
7666
  const release = deps.claimPending(sessionId, requestId);
7667
7667
  if (release === void 0) {
7668
- 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` };
7668
+ 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" };
7669
7669
  }
7670
7670
  const body = JSON.stringify(buildRcEventWriteBody(buildRcControlResponsePayload(requestId, decision, updatedInput?.input)));
7671
7671
  let answer;
@@ -7686,7 +7686,7 @@ async function answerRcControlRequest(deps, sessionId, requestId, decision) {
7686
7686
  async function deliverRcClientPayload(deps, sessionId, payload, action, to = "events") {
7687
7687
  const credential = deps.credentialOf(sessionId);
7688
7688
  if (credential === void 0) {
7689
- return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
7689
+ return { ok: false, message: rcSessionNotObservedMessage(sessionId), refusal: "not-observed" };
7690
7690
  }
7691
7691
  if (credential.authorization === void 0) {
7692
7692
  return noOAuthCredentialResult(sessionId);
@@ -7711,7 +7711,7 @@ async function interruptRcSession(deps, sessionId) {
7711
7711
  }
7712
7712
  async function setRcSessionModel(deps, sessionId, model) {
7713
7713
  if (model === "") {
7714
- 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" };
7714
+ 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" };
7715
7715
  }
7716
7716
  const requestId = deps.newUuid();
7717
7717
  const result = await deliverRcClientPayload(deps, sessionId, buildRcSetModelPayload(requestId, model), `set the model on session ${sessionId}`);
@@ -7724,7 +7724,7 @@ async function setRcSessionPermissionMode(deps, sessionId, mode) {
7724
7724
  }
7725
7725
  async function endRcSession(deps, sessionId, reason) {
7726
7726
  if (reason === "") {
7727
- 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" };
7727
+ 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" };
7728
7728
  }
7729
7729
  const requestId = deps.newUuid();
7730
7730
  const result = await deliverRcClientPayload(deps, sessionId, buildRcEndSessionPayload(requestId, reason), `end session ${sessionId}`);
@@ -7742,10 +7742,10 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
7742
7742
  }
7743
7743
  async function readRcSessionFile(deps, sessionId, path59, options) {
7744
7744
  if (path59 === "") {
7745
- 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" };
7745
+ 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" };
7746
7746
  }
7747
7747
  if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
7748
- 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" };
7748
+ 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" };
7749
7749
  }
7750
7750
  const requestId = deps.newUuid();
7751
7751
  const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path59, options), `read ${path59} from session ${sessionId}`);
@@ -7763,7 +7763,7 @@ async function getRcSessionMcpStatus(deps, sessionId) {
7763
7763
  }
7764
7764
  async function reconnectRcSessionMcpServer(deps, sessionId, serverName) {
7765
7765
  if (serverName === "") {
7766
- 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" };
7766
+ 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" };
7767
7767
  }
7768
7768
  const requestId = deps.newUuid();
7769
7769
  const result = await deliverRcClientPayload(deps, sessionId, buildRcMcpReconnectPayload(requestId, serverName), `reconnect MCP server ${serverName} on session ${sessionId}`);
@@ -7771,7 +7771,7 @@ async function reconnectRcSessionMcpServer(deps, sessionId, serverName) {
7771
7771
  }
7772
7772
  async function authenticateRcSessionMcpServer(deps, sessionId, serverName, redirectUri) {
7773
7773
  if (serverName === "" || redirectUri === "") {
7774
- 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" };
7774
+ 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" };
7775
7775
  }
7776
7776
  const requestId = deps.newUuid();
7777
7777
  const result = await deliverRcClientPayload(deps, sessionId, buildRcMcpAuthenticatePayload(requestId, serverName, redirectUri), `authenticate MCP server ${serverName} on session ${sessionId}`);
@@ -7779,7 +7779,7 @@ async function authenticateRcSessionMcpServer(deps, sessionId, serverName, redir
7779
7779
  }
7780
7780
  async function submitRcSessionMcpOAuthCallbackUrl(deps, sessionId, serverName, callbackUrl) {
7781
7781
  if (serverName === "" || callbackUrl === "") {
7782
- 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" };
7782
+ 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" };
7783
7783
  }
7784
7784
  const requestId = deps.newUuid();
7785
7785
  const result = await deliverRcClientPayload(deps, sessionId, buildRcMcpOAuthCallbackUrlPayload(requestId, serverName, callbackUrl), `hand MCP server ${serverName}'s OAuth callback to session ${sessionId}`);
@@ -7790,7 +7790,7 @@ async function sendRcKeepAlive(deps, sessionId) {
7790
7790
  }
7791
7791
  async function teleportRcSession(deps, sessionId, marker) {
7792
7792
  if (marker === "") {
7793
- 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" };
7793
+ 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" };
7794
7794
  }
7795
7795
  return await deliverRcClientPayload(deps, sessionId, buildRcUserMessagePayload(deps.newUuid(), sessionId, marker), `teleport a marker into session ${sessionId}`, "teleport-events");
7796
7796
  }
@@ -14304,7 +14304,7 @@ var init_package = __esm({
14304
14304
  "package.json"() {
14305
14305
  package_default = {
14306
14306
  name: "claude-use",
14307
- version: "14.6.0",
14307
+ version: "14.7.0",
14308
14308
  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.",
14309
14309
  license: "MIT",
14310
14310
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -18773,7 +18773,7 @@ function prepareRegisteredLaunch(params, onRecorded) {
18773
18773
  const sessionId = params.supervised?.sessionId ?? (0, import_node_crypto19.randomUUID)();
18774
18774
  const resolvedModels = decided.models ?? (decided.globalModels === void 0 ? void 0 : {});
18775
18775
  const sessionModels = (0, import_node_util2.isDeepStrictEqual)(resolvedModels, decided.globalModels) ? void 0 : resolvedModels;
18776
- const session = { sessionId, ...decided.farmIdentity === void 0 ? {} : { identity: decided.farmIdentity }, ...sessionModels === void 0 ? {} : { models: sessionModels }, configDir: decision.configDir ?? import_node_path55.default.join(import_node_os10.default.homedir(), ".claude") };
18776
+ const session = { sessionId, ...decided.farmIdentity === void 0 ? {} : { identity: decided.farmIdentity }, ...sessionModels === void 0 ? {} : { models: sessionModels }, configDir: decision.configDir ?? import_node_path55.default.join(import_node_os10.default.homedir(), ".claude"), ...decided.binVersion === void 0 ? {} : { claudeVersion: decided.binVersion } };
18777
18777
  let frontDoor = frontDoorEngaged && frontDoorPort !== void 0 ? frontDoorPort.ensure(env.NODE_EXTRA_CA_CERTS, session) : void 0;
18778
18778
  if (frontDoor !== void 0 && frontDoorPort !== void 0) {
18779
18779
  let beforePid = frontDoor.supervisorPid;
@@ -20625,10 +20625,10 @@ function createRcSessionCommands(deps) {
20625
20625
  return void 0;
20626
20626
  }
20627
20627
  if ("refused" in target) {
20628
- return { kind: "refused", message: target.refused };
20628
+ return { kind: "refused", message: target.refused, refusal: "session-state" };
20629
20629
  }
20630
20630
  if (target.version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(target.version)) {
20631
- 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") };
20631
+ 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" };
20632
20632
  }
20633
20633
  return { kind: route, target };
20634
20634
  };
@@ -20642,18 +20642,18 @@ function createRcSessionCommands(deps) {
20642
20642
  return launched;
20643
20643
  }
20644
20644
  if (!deps.isObserved(sessionId)) {
20645
- return { kind: "refused", message: `the front door has not observed Remote Control session ${sessionId}` };
20645
+ return { kind: "refused", message: `the front door has not observed Remote Control session ${sessionId}`, refusal: "not-observed" };
20646
20646
  }
20647
20647
  if (deps.selfHost === void 0) {
20648
- return { kind: "refused", message: unsupportedMessage(sessionId) };
20648
+ return { kind: "refused", message: unsupportedMessage(sessionId), refusal: "session-state" };
20649
20649
  }
20650
20650
  const unavailable = deps.selfHost.unavailable();
20651
20651
  if (unavailable !== void 0) {
20652
- return { kind: "refused", message: `${noPluginReason(sessionId)}, and the door's self-hosted surface cannot take a command: ${unavailable}` };
20652
+ return { kind: "refused", message: `${noPluginReason(sessionId)}, and the door's self-hosted surface cannot take a command: ${unavailable}`, refusal: "session-state" };
20653
20653
  }
20654
20654
  const version = deps.selfHost.versionOf(sessionId);
20655
20655
  if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
20656
- 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") };
20656
+ return { kind: "refused", message: unverifiedVersionMessage(sessionId, version, "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" };
20657
20657
  }
20658
20658
  return { kind: "self-hosted", selfHost: deps.selfHost };
20659
20659
  };
@@ -20664,7 +20664,7 @@ function createRcSessionCommands(deps) {
20664
20664
  }
20665
20665
  const resolved = await resolveRoute(sessionId);
20666
20666
  if (resolved.kind === "refused") {
20667
- return { ok: false, message: resolved.message };
20667
+ return { ok: false, message: resolved.message, refusal: resolved.refusal };
20668
20668
  }
20669
20669
  if (resolved.kind !== "self-hosted") {
20670
20670
  const waitMs2 = options.waitMs ?? COMPACT_TIMEOUT_MS;
@@ -20690,7 +20690,7 @@ function createRcSessionCommands(deps) {
20690
20690
  const transcriptGoal = async (sessionId, target) => {
20691
20691
  const goal = target.transcriptPath === void 0 ? void 0 : await deps.goalOf(target.transcriptPath);
20692
20692
  if (goal === void 0) {
20693
- 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` };
20693
+ 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" };
20694
20694
  }
20695
20695
  return { ok: true, report: goal };
20696
20696
  };
@@ -20706,7 +20706,7 @@ function createRcSessionCommands(deps) {
20706
20706
  const waitOf = (options) => options.waitMs;
20707
20707
  const transcriptPluginTurns = async (sessionId, target) => {
20708
20708
  const turns = target.transcriptPath === void 0 ? void 0 : await deps.pluginTurnsOf(target.transcriptPath);
20709
- 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 };
20709
+ 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 };
20710
20710
  };
20711
20711
  return {
20712
20712
  /** 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. */
@@ -20719,13 +20719,13 @@ function createRcSessionCommands(deps) {
20719
20719
  */
20720
20720
  turn: async (sessionId, text, options = {}) => {
20721
20721
  if (text.trim() === "") {
20722
- return { ok: false, message: "a turn needs non-empty text" };
20722
+ return { ok: false, message: "a turn needs non-empty text", refusal: "invalid-input" };
20723
20723
  }
20724
20724
  if (text.trimStart().startsWith("/")) {
20725
- 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" };
20725
+ 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" };
20726
20726
  }
20727
20727
  if (text.length > RC_TURN_TEXT_MAX_CHARS) {
20728
- 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)}` };
20728
+ 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)}`, refusal: "invalid-input" };
20729
20729
  }
20730
20730
  return await onRoute(sessionId, options, {
20731
20731
  plugin: async (target, route, signal, waitMs) => {
@@ -20774,16 +20774,16 @@ function createRcSessionCommands(deps) {
20774
20774
  goalSet: async (sessionId, condition, options = {}) => {
20775
20775
  const trimmed = condition.trim();
20776
20776
  if (trimmed === "") {
20777
- return { ok: false, message: "a goal set needs a non-empty condition" };
20777
+ return { ok: false, message: "a goal set needs a non-empty condition", refusal: "invalid-input" };
20778
20778
  }
20779
20779
  if (RC_GOAL_CLEAR_WORDS.includes(trimmed.toLowerCase())) {
20780
- 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` };
20780
+ 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" };
20781
20781
  }
20782
20782
  if (/[\r\n]/u.test(trimmed)) {
20783
- 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" };
20783
+ 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" };
20784
20784
  }
20785
20785
  if (trimmed.length > RC_GOAL_CONDITION_MAX_CHARS) {
20786
- return { ok: false, message: `a goal condition is limited to ${String(RC_GOAL_CONDITION_MAX_CHARS)} characters, and this one has ${String(trimmed.length)}` };
20786
+ 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" };
20787
20787
  }
20788
20788
  return await onRoute(sessionId, options, {
20789
20789
  plugin: async (target, route, signal, waitMs) => {
@@ -20926,17 +20926,25 @@ function doorApiAuth(expectedToken) {
20926
20926
  }
20927
20927
  var RC_API_TAG = "remote-control";
20928
20928
  var RC_DIRECTIVE_TAG = "remote-control-directives";
20929
+ var RC_REFUSAL_CODES = {
20930
+ "invalid-input": "BAD_REQUEST",
20931
+ "not-observed": "NOT_FOUND",
20932
+ "session-state": "CONFLICT"
20933
+ };
20934
+ function refusalOf(failure) {
20935
+ return new import_client.ORPCError(failure.refusal === void 0 ? "BAD_GATEWAY" : RC_REFUSAL_CODES[failure.refusal], { message: failure.message });
20936
+ }
20929
20937
  function createRcApiRouter(deps) {
20930
20938
  const authed = doorApiAuth(deps.expectedToken);
20931
20939
  const delivered = (sessionId, result) => {
20932
20940
  if (!result.ok) {
20933
- throw new import_client.ORPCError("BAD_GATEWAY", { message: result.message });
20941
+ throw refusalOf(result);
20934
20942
  }
20935
20943
  return result.sequenceNums;
20936
20944
  };
20937
20945
  const deliveredControl = (sessionId, result) => {
20938
20946
  if (!result.ok) {
20939
- throw new import_client.ORPCError("BAD_GATEWAY", { message: result.message });
20947
+ throw refusalOf(result);
20940
20948
  }
20941
20949
  if (result.requestId === void 0) {
20942
20950
  throw new import_client.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" });
@@ -20945,7 +20953,7 @@ function createRcApiRouter(deps) {
20945
20953
  };
20946
20954
  const commanded = (sessionId, result) => {
20947
20955
  if (!result.ok) {
20948
- throw new import_client.ORPCError("BAD_GATEWAY", { message: result.message });
20956
+ throw refusalOf(result);
20949
20957
  }
20950
20958
  return { session: sessionId, ...result.report };
20951
20959
  };
@@ -26912,7 +26920,8 @@ data: ${JSON.stringify(envelope)}
26912
26920
  clients: /* @__PURE__ */ new Map(),
26913
26921
  workerStatus: void 0,
26914
26922
  externalMetadata: void 0,
26915
- lastTrafficAt: deps.now()
26923
+ lastTrafficAt: deps.now(),
26924
+ launchVersion: request4.session.launch === void 0 ? void 0 : deps.launchVersionOf(request4.session.launch)
26916
26925
  };
26917
26926
  conversation.sessionIds.add(session.id);
26918
26927
  sessions.set(session.id, session);
@@ -26947,6 +26956,7 @@ data: ${JSON.stringify(envelope)}
26947
26956
  return {
26948
26957
  route,
26949
26958
  local,
26959
+ launchVersionOf: (sessionId) => sessions.get(sessionId)?.launchVersion,
26950
26960
  close: () => {
26951
26961
  clearInterval(timer);
26952
26962
  clearInterval(keepalive);
@@ -26979,12 +26989,14 @@ function createLiveSessionRegistry(ports) {
26979
26989
  let bySessionId = /* @__PURE__ */ new Map();
26980
26990
  let launches = /* @__PURE__ */ new Set();
26981
26991
  const recordNames = () => fs17.readdir(sessionsDir).filter(isSessionRecordName);
26992
+ let byLaunch = /* @__PURE__ */ new Map();
26982
26993
  const rebuildIndexes = () => {
26983
26994
  const records = [...known.values()].flatMap(({ record }) => record === void 0 ? [] : [record]);
26984
26995
  tokens = new Set(records.map((record) => record.token));
26985
26996
  byToken = new Map(records.map((record) => [record.token, record]));
26986
26997
  bySessionId = new Map(records.flatMap((record) => record.sessionId === void 0 ? [] : [[record.sessionId, record]]));
26987
26998
  launches = new Set(records.map(launchKeyOf));
26999
+ byLaunch = new Map(records.map((record) => [launchKeyOf(record), record]));
26988
27000
  };
26989
27001
  const load = (name, stat) => {
26990
27002
  known.set(name, { stat: { mtimeMs: stat.mtimeMs, sizeBytes: stat.sizeBytes }, record: readFrontDoorSessionRecord(fs17, sessionsDir, name) });
@@ -27031,6 +27043,7 @@ function createLiveSessionRegistry(ports) {
27031
27043
  return held?.sessionId === void 0 ? void 0 : { pid: held.pid, startedAt: held.startedAt };
27032
27044
  },
27033
27045
  holdsLaunch: (launch) => launches.has(launchKeyOf(launch)) || reconcile() && launches.has(launchKeyOf(launch)),
27046
+ claudeVersionOf: (launch) => (byLaunch.get(launchKeyOf(launch)) ?? (reconcile() ? byLaunch.get(launchKeyOf(launch)) : void 0))?.claudeVersion,
27034
27047
  rescan: () => {
27035
27048
  known.clear();
27036
27049
  for (const name of recordNames()) {