claude-use 9.18.0 → 9.19.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 CHANGED
@@ -30535,7 +30535,7 @@ function compile2(pattern, category, source, ordinal) {
30535
30535
  matches: isExact ? (name) => name === pattern : (name) => matcher(name)
30536
30536
  };
30537
30537
  }
30538
- function compileClassificationPatterns(defaults, overlay) {
30538
+ function compileClassificationPatterns(defaults, overlay2) {
30539
30539
  const compiled = [];
30540
30540
  let ordinal = 0;
30541
30541
  for (const category of CATEGORY_NAMES) {
@@ -30544,9 +30544,9 @@ function compileClassificationPatterns(defaults, overlay) {
30544
30544
  ordinal += 1;
30545
30545
  }
30546
30546
  }
30547
- if (overlay !== void 0) {
30547
+ if (overlay2 !== void 0) {
30548
30548
  for (const category of CATEGORY_NAMES) {
30549
- for (const pattern of overlay[category] ?? []) {
30549
+ for (const pattern of overlay2[category] ?? []) {
30550
30550
  compiled.push(compile2(pattern, category, "local", ordinal));
30551
30551
  ordinal += 1;
30552
30552
  }
@@ -30567,10 +30567,10 @@ function compareClassificationPatterns(a10, b) {
30567
30567
  return a10.ordinal - b.ordinal;
30568
30568
  }
30569
30569
  function loadClassification(paths) {
30570
- const overlay = readJson(paths.categoriesLocalFile, CategoryClassificationOverlaySchema);
30570
+ const overlay2 = readJson(paths.categoriesLocalFile, CategoryClassificationOverlaySchema);
30571
30571
  return {
30572
30572
  defaults: CategoryClassificationSchema.parse(categories_default_default),
30573
- ...overlay === void 0 ? {} : { overlay }
30573
+ ...overlay2 === void 0 ? {} : { overlay: overlay2 }
30574
30574
  };
30575
30575
  }
30576
30576
  function classifyEntries(names, options) {
@@ -33317,7 +33317,7 @@ var init_package = __esm({
33317
33317
  "package.json"() {
33318
33318
  package_default = {
33319
33319
  name: "claude-use",
33320
- version: "9.18.0",
33320
+ version: "9.19.1",
33321
33321
  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.",
33322
33322
  license: "MIT",
33323
33323
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -62756,10 +62756,10 @@ function resolveLaunch(params) {
62756
62756
  environment
62757
62757
  };
62758
62758
  }
62759
- function runLaunchPlan(plan, spawn4) {
62759
+ function runLaunchPlan(plan, spawn5) {
62760
62760
  try {
62761
62761
  plan.markChildStarted();
62762
- const result = spawn4.spawnSync(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
62762
+ const result = spawn5.spawnSync(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
62763
62763
  if (result.error !== void 0) {
62764
62764
  throw result.error;
62765
62765
  }
@@ -111655,10 +111655,11 @@ function registerCodexCommand(program2, deps) {
111655
111655
 
111656
111656
  // src/frontdoor/commands.ts
111657
111657
  var import_node_crypto20 = require("node:crypto");
111658
- var import_node_path49 = __toESM(require("node:path"), 1);
111658
+ var import_node_path48 = __toESM(require("node:path"), 1);
111659
111659
  var import_node_fs17 = __toESM(require("node:fs"), 1);
111660
111660
  init_commandDeps();
111661
111661
  init_schema();
111662
+ init_conditions();
111662
111663
 
111663
111664
  // src/agents/realFs.ts
111664
111665
  var import_node_fs12 = __toESM(require("node:fs"), 1);
@@ -111703,25 +111704,23 @@ var AgentMetaSchema = external_exports.looseObject({
111703
111704
  stoppedByUser: external_exports.boolean().optional()
111704
111705
  });
111705
111706
  var AgentKindSchema = external_exports.enum(["subagent", "fork", "workflow-agent", "teammate"]);
111706
- var AgentNodeSchema = external_exports.lazy(
111707
- () => external_exports.strictObject({
111708
- id: external_exports.string(),
111709
- kind: AgentKindSchema,
111710
- agentType: external_exports.string(),
111711
- description: external_exports.string().optional(),
111712
- name: external_exports.string().optional(),
111713
- toolUseId: external_exports.string().optional(),
111714
- spawnDepth: external_exports.number().int().nonnegative().optional(),
111715
- model: external_exports.string().optional(),
111716
- background: external_exports.boolean().optional(),
111717
- workflowRunId: external_exports.string().optional(),
111718
- workflowPhase: external_exports.string().optional(),
111719
- teamName: external_exports.string().optional(),
111720
- stoppedByUser: external_exports.boolean().optional(),
111721
- transcript: external_exports.string(),
111722
- children: external_exports.array(AgentNodeSchema)
111723
- })
111724
- );
111707
+ var AgentNodeFields = {
111708
+ id: external_exports.string(),
111709
+ kind: AgentKindSchema,
111710
+ agentType: external_exports.string(),
111711
+ description: external_exports.string().optional(),
111712
+ name: external_exports.string().optional(),
111713
+ toolUseId: external_exports.string().optional(),
111714
+ spawnDepth: external_exports.number().int().nonnegative().optional(),
111715
+ model: external_exports.string().optional(),
111716
+ background: external_exports.boolean().optional(),
111717
+ workflowRunId: external_exports.string().optional(),
111718
+ workflowPhase: external_exports.string().optional(),
111719
+ teamName: external_exports.string().optional(),
111720
+ stoppedByUser: external_exports.boolean().optional(),
111721
+ transcript: external_exports.string()
111722
+ };
111723
+ var AgentNodeSchema = external_exports.lazy(() => external_exports.strictObject({ ...AgentNodeFields, children: external_exports.array(AgentNodeSchema) }));
111725
111724
  var TaskItemSchema = external_exports.strictObject({
111726
111725
  id: external_exports.string(),
111727
111726
  subject: external_exports.string(),
@@ -112415,9 +112414,38 @@ init_anthropicUsageRefresh();
112415
112414
  init_poolPick();
112416
112415
  init_realAnthropicUsageProbe();
112417
112416
 
112418
- // src/usage/realJobRunner.ts
112419
- var import_node_path40 = __toESM(require("node:path"), 1);
112420
- init_conditions();
112417
+ // src/usage/childRun.ts
112418
+ var import_node_child_process5 = require("node:child_process");
112419
+ init_realPorts();
112420
+ var CHILD_GRACE_MS = 3e4;
112421
+ var STDERR_TAIL_CHARS = 2e3;
112422
+ async function runChild(options) {
112423
+ const invocation = (options.invocation ?? selfInvocation)(options.args);
112424
+ await new Promise((resolve2, reject) => {
112425
+ const child = (0, import_node_child_process5.spawn)(invocation.command, [...invocation.args], { stdio: ["ignore", "ignore", "pipe"], env: { ...process.env, AGENT_SHIM_HOME: options.paths.root } });
112426
+ let stderr = "";
112427
+ child.stderr.on("data", (chunk) => {
112428
+ stderr = `${stderr}${chunk.toString()}`.slice(-STDERR_TAIL_CHARS);
112429
+ });
112430
+ const killer = setTimeout(() => {
112431
+ child.kill("SIGKILL");
112432
+ }, options.timeoutMs + CHILD_GRACE_MS);
112433
+ child.on("error", (error63) => {
112434
+ clearTimeout(killer);
112435
+ reject(error63);
112436
+ });
112437
+ child.on("close", (code, signal) => {
112438
+ clearTimeout(killer);
112439
+ if (code === 0) {
112440
+ resolve2();
112441
+ return;
112442
+ }
112443
+ reject(new Error(stderr.trim() === "" ? `the child ended with ${signal === null ? `exit code ${String(code)}` : `signal ${signal}`}` : stderr.trim()));
112444
+ });
112445
+ });
112446
+ }
112447
+
112448
+ // src/usage/realWindowOpener.ts
112421
112449
  init_identityClaude();
112422
112450
 
112423
112451
  // src/usage/sdkResult.ts
@@ -112431,61 +112459,7 @@ function successfulResult(message) {
112431
112459
  return message.result;
112432
112460
  }
112433
112461
 
112434
- // src/usage/realJobRunner.ts
112435
- var JOB_LAUNCH_FLAGS = ["--no-headroom", "--no-remote-control", "--track-usage"];
112436
- var JOB_ISOLATION_OPTIONS = { settingSources: ["user"], mcpServers: {}, strictMcpConfig: true };
112437
- function logEntry(name, identity, endedAt, outcome) {
112438
- return `${endedAt.toISOString()} job ${name} as ${identity}
112439
- ${outcome.trimEnd()}
112440
-
112441
- `;
112442
- }
112443
- function createRealJobRunner(params) {
112444
- return async (name, identity, job) => {
112445
- const logFile = import_node_path40.default.join(params.paths.jobLogsDir, `${name}.log`);
112446
- const append = (outcome) => {
112447
- params.fs.mkdirPrivate(params.paths.jobLogsDir);
112448
- params.fs.appendFilePrivate(logFile, logEntry(name, identity, params.now(), outcome));
112449
- };
112450
- try {
112451
- const result = await withIdentityClaude({ paths: params.paths, spawnDaemon: params.spawnDaemon, cwd: job.cwd, timeoutMs: parseDuration(job.timeout) }, identity, JOB_LAUNCH_FLAGS, async ({ bin, env, cwd, abort }) => {
112452
- const { query } = await Promise.resolve().then(() => (init_sdk(), sdk_exports));
112453
- const session = query({
112454
- prompt: job.prompt,
112455
- options: {
112456
- pathToClaudeCodeExecutable: bin,
112457
- env,
112458
- cwd,
112459
- abortController: abort,
112460
- settingSources: [...JOB_ISOLATION_OPTIONS.settingSources],
112461
- mcpServers: JOB_ISOLATION_OPTIONS.mcpServers,
112462
- strictMcpConfig: JOB_ISOLATION_OPTIONS.strictMcpConfig,
112463
- permissionMode: "dontAsk",
112464
- ...job.model === void 0 ? {} : { model: job.model },
112465
- ...job.allowedTools === void 0 ? {} : { allowedTools: [...job.allowedTools] }
112466
- }
112467
- });
112468
- try {
112469
- for await (const message of session) {
112470
- if (message.type === "result") {
112471
- return successfulResult(message);
112472
- }
112473
- }
112474
- throw new Error("the run ended without a result");
112475
- } finally {
112476
- session.close();
112477
- }
112478
- });
112479
- append(result);
112480
- } catch (error63) {
112481
- append(`FAILED: ${error63 instanceof Error ? error63.message : String(error63)}`);
112482
- throw error63;
112483
- }
112484
- };
112485
- }
112486
-
112487
112462
  // src/usage/realWindowOpener.ts
112488
- init_identityClaude();
112489
112463
  var OPENER_LAUNCH_FLAGS = ["--no-headroom", "--no-remote-control", "--track-usage"];
112490
112464
  var WINDOW_OPENING_MODEL = "haiku";
112491
112465
  var WINDOW_OPENING_PROMPT = "ok";
@@ -112532,7 +112506,7 @@ function createRealWindowOpener(params) {
112532
112506
  init_conditions();
112533
112507
 
112534
112508
  // src/usage/handledStamps.ts
112535
- var import_node_path41 = __toESM(require("node:path"), 1);
112509
+ var import_node_path40 = __toESM(require("node:path"), 1);
112536
112510
  init_zod();
112537
112511
  var STAMPS_SCHEMA_VERSION = 1;
112538
112512
  var StampsFileSchema = external_exports.strictObject({
@@ -112555,7 +112529,7 @@ function readHandled(fs22, file2) {
112555
112529
  }
112556
112530
  function writeHandled(fs22, file2, handled) {
112557
112531
  const next = { schemaVersion: STAMPS_SCHEMA_VERSION, handled: Object.fromEntries(Object.entries(handled).map(([key, at2]) => [key, new Date(at2).toISOString()])) };
112558
- fs22.mkdirPrivate(import_node_path41.default.dirname(file2));
112532
+ fs22.mkdirPrivate(import_node_path40.default.dirname(file2));
112559
112533
  fs22.writeFilePrivate(file2, `${JSON.stringify(next, null, 2)}
112560
112534
  `);
112561
112535
  }
@@ -112846,7 +112820,7 @@ init_capability();
112846
112820
 
112847
112821
  // src/frontdoor/capture.ts
112848
112822
  var fs15 = __toESM(require("node:fs"), 1);
112849
- var path41 = __toESM(require("node:path"), 1);
112823
+ var path40 = __toESM(require("node:path"), 1);
112850
112824
  var SECRET_HEADER_NAME = /authorization|cookie|token|secret|credential|api[-_]key/i;
112851
112825
  var SECRET_JSON_KEY = /token|secret|password|credential|authorization|api[-_]key/i;
112852
112826
  var SECRET_BODY_PATTERNS = [
@@ -112890,10 +112864,10 @@ function redactBody(chunk) {
112890
112864
  }
112891
112865
  var CAPTURE_ENV = "AGENT_SHIM_FRONTDOOR_CAPTURE";
112892
112866
  function captureFromEnv(env, logsDir) {
112893
- return env[CAPTURE_ENV] === "1" ? createFileCapture(path41.join(logsDir, "frontdoor-capture.jsonl")) : void 0;
112867
+ return env[CAPTURE_ENV] === "1" ? createFileCapture(path40.join(logsDir, "frontdoor-capture.jsonl")) : void 0;
112894
112868
  }
112895
112869
  function createFileCapture(file2, now = () => /* @__PURE__ */ new Date()) {
112896
- fs15.mkdirSync(path41.dirname(file2), { recursive: true });
112870
+ fs15.mkdirSync(path40.dirname(file2), { recursive: true });
112897
112871
  let nextId = 0;
112898
112872
  const append = (record2) => {
112899
112873
  fs15.appendFileSync(file2, `${JSON.stringify({ ts: now().toISOString(), ...record2 })}
@@ -113312,14 +113286,14 @@ init_capability();
113312
113286
  init_route();
113313
113287
 
113314
113288
  // src/frontdoor/supervisor.ts
113315
- var import_node_path42 = __toESM(require("node:path"), 1);
113289
+ var import_node_path41 = __toESM(require("node:path"), 1);
113316
113290
  init_state2();
113317
113291
  function watchedInstallEntry(resolvedOwnExecutablePath, siblingExists) {
113318
- const parsed = import_node_path42.default.parse(resolvedOwnExecutablePath);
113292
+ const parsed = import_node_path41.default.parse(resolvedOwnExecutablePath);
113319
113293
  if (parsed.name === "agent-shim") {
113320
113294
  return resolvedOwnExecutablePath;
113321
113295
  }
113322
- const sibling = import_node_path42.default.join(parsed.dir, `agent-shim${parsed.ext}`);
113296
+ const sibling = import_node_path41.default.join(parsed.dir, `agent-shim${parsed.ext}`);
113323
113297
  return siblingExists(sibling) ? sibling : resolvedOwnExecutablePath;
113324
113298
  }
113325
113299
  var FRONTDOOR_SUPERVISOR_STILL_RUNNING = -1;
@@ -113861,6 +113835,171 @@ var https3 = __toESM(require("node:https"), 1);
113861
113835
  var net2 = __toESM(require("node:net"), 1);
113862
113836
  var tls = __toESM(require("node:tls"), 1);
113863
113837
 
113838
+ // src/agents/liveTasks.ts
113839
+ init_zod();
113840
+ var LIVE_TASK_CAP = 512;
113841
+ var RUNNING_STATUS = "running";
113842
+ var LiveTaskUsageSchema = external_exports.strictObject({
113843
+ totalTokens: external_exports.number().optional(),
113844
+ toolUses: external_exports.number().optional(),
113845
+ durationMs: external_exports.number().optional()
113846
+ });
113847
+ var LiveTaskSchema = external_exports.strictObject({
113848
+ /** The `task_id`: for an unnamed subagent the stem of its `agent-<id>` files on disk. */
113849
+ taskId: external_exports.string(),
113850
+ /** The `cse_` session whose stream carried the task. */
113851
+ sessionId: external_exports.string(),
113852
+ runId: external_exports.string().optional(),
113853
+ /** The `tool_use` block in the spawning transcript, which is the meta file's `toolUseId`. */
113854
+ toolUseId: external_exports.string().optional(),
113855
+ /** `local_agent` for a subagent, `local_bash` for a backgrounded command; open because other kinds may exist. */
113856
+ taskType: external_exports.string().optional(),
113857
+ description: external_exports.string().optional(),
113858
+ subagentType: external_exports.string().optional(),
113859
+ spawnDepth: external_exports.number().int().nonnegative().optional(),
113860
+ parentTaskId: external_exports.string().optional(),
113861
+ backgrounded: external_exports.boolean().optional(),
113862
+ status: external_exports.string(),
113863
+ /** `<tmpdir>/<project-slug>/<local session id>/tasks/<task_id>.output`, which embeds the local session id. */
113864
+ outputFile: external_exports.string().optional(),
113865
+ summary: external_exports.string().optional(),
113866
+ lastToolName: external_exports.string().optional(),
113867
+ usage: LiveTaskUsageSchema.optional(),
113868
+ /** When the door last observed an event for this task, in epoch milliseconds from its injected clock. */
113869
+ observedAt: external_exports.number()
113870
+ });
113871
+ var SYSTEM_SUBTYPES = ["task_started", "task_progress", "task_updated", "task_notification", "background_tasks_changed"];
113872
+ function isRecord3(value2) {
113873
+ return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
113874
+ }
113875
+ function stringField(record2, field) {
113876
+ const value2 = record2[field];
113877
+ return typeof value2 === "string" && value2 !== "" ? value2 : void 0;
113878
+ }
113879
+ function numberField(record2, field) {
113880
+ const value2 = record2[field];
113881
+ return typeof value2 === "number" && Number.isFinite(value2) ? value2 : void 0;
113882
+ }
113883
+ function booleanField(record2, field) {
113884
+ const value2 = record2[field];
113885
+ return typeof value2 === "boolean" ? value2 : void 0;
113886
+ }
113887
+ function usageOf(record2) {
113888
+ const raw = record2.usage;
113889
+ if (!isRecord3(raw)) {
113890
+ return void 0;
113891
+ }
113892
+ const totalTokens = numberField(raw, "total_tokens");
113893
+ const toolUses = numberField(raw, "tool_uses");
113894
+ const durationMs = numberField(raw, "duration_ms");
113895
+ if (totalTokens === void 0 && toolUses === void 0 && durationMs === void 0) {
113896
+ return void 0;
113897
+ }
113898
+ return { ...totalTokens === void 0 ? {} : { totalTokens }, ...toolUses === void 0 ? {} : { toolUses }, ...durationMs === void 0 ? {} : { durationMs } };
113899
+ }
113900
+ function overlay(base, fields) {
113901
+ const defined = Object.fromEntries(Object.entries(fields).filter(([, value2]) => value2 !== void 0));
113902
+ return LiveTaskSchema.parse({ ...base, ...defined });
113903
+ }
113904
+ function isFinished(task) {
113905
+ return task.status !== RUNNING_STATUS;
113906
+ }
113907
+ function bounded(book) {
113908
+ if (book.size <= LIVE_TASK_CAP) {
113909
+ return book;
113910
+ }
113911
+ const evictable = [...book.values()].filter(isFinished).sort((left, right) => left.observedAt - right.observedAt);
113912
+ for (const task of evictable) {
113913
+ if (book.size <= LIVE_TASK_CAP) {
113914
+ break;
113915
+ }
113916
+ book.delete(task.taskId);
113917
+ }
113918
+ return book;
113919
+ }
113920
+ function applyAgentTaskEvent(book, sessionId, payload, observedAt2) {
113921
+ if (!isRecord3(payload) || payload.type !== "system") {
113922
+ return book;
113923
+ }
113924
+ const subtype = payload.subtype;
113925
+ if (typeof subtype !== "string" || !SYSTEM_SUBTYPES.some((known) => known === subtype)) {
113926
+ return book;
113927
+ }
113928
+ const next = new Map(book);
113929
+ const upsert = (taskId2, fields) => {
113930
+ const existing = next.get(taskId2);
113931
+ const base = existing ?? { taskId: taskId2, sessionId, status: RUNNING_STATUS, observedAt: observedAt2 };
113932
+ next.set(taskId2, overlay(base, { ...fields, observedAt: observedAt2 }));
113933
+ };
113934
+ if (subtype === "background_tasks_changed") {
113935
+ const tasks = Array.isArray(payload.tasks) ? payload.tasks : [];
113936
+ for (const raw of tasks) {
113937
+ const taskId2 = isRecord3(raw) ? stringField(raw, "task_id") : void 0;
113938
+ if (isRecord3(raw) && taskId2 !== void 0) {
113939
+ upsert(taskId2, { runId: stringField(raw, "run_id"), taskType: stringField(raw, "task_type"), description: stringField(raw, "description") });
113940
+ }
113941
+ }
113942
+ return bounded(next);
113943
+ }
113944
+ const taskId = stringField(payload, "task_id");
113945
+ if (taskId === void 0) {
113946
+ return book;
113947
+ }
113948
+ const common = { runId: stringField(payload, "run_id"), toolUseId: stringField(payload, "tool_use_id"), description: stringField(payload, "description") };
113949
+ if (subtype === "task_started") {
113950
+ upsert(taskId, {
113951
+ ...common,
113952
+ taskType: stringField(payload, "task_type"),
113953
+ subagentType: stringField(payload, "subagent_type"),
113954
+ spawnDepth: numberField(payload, "spawn_depth"),
113955
+ parentTaskId: stringField(payload, "parent_task_id"),
113956
+ backgrounded: booleanField(payload, "is_backgrounded")
113957
+ });
113958
+ } else if (subtype === "task_progress") {
113959
+ upsert(taskId, { ...common, subagentType: stringField(payload, "subagent_type"), lastToolName: stringField(payload, "last_tool_name"), usage: usageOf(payload) });
113960
+ } else if (subtype === "task_updated") {
113961
+ const patch = isRecord3(payload.patch) ? payload.patch : {};
113962
+ upsert(taskId, { runId: stringField(payload, "run_id"), status: stringField(patch, "status") });
113963
+ } else {
113964
+ upsert(taskId, { ...common, status: stringField(payload, "status"), outputFile: stringField(payload, "output_file"), summary: stringField(payload, "summary"), usage: usageOf(payload) });
113965
+ }
113966
+ return bounded(next);
113967
+ }
113968
+ var MergedProvenanceSchema = external_exports.enum(["disk", "both"]);
113969
+ var MergedAgentNodeSchema = external_exports.lazy(
113970
+ () => external_exports.strictObject({
113971
+ ...AgentNodeFields,
113972
+ provenance: MergedProvenanceSchema,
113973
+ live: LiveTaskSchema.optional(),
113974
+ children: external_exports.array(MergedAgentNodeSchema)
113975
+ })
113976
+ );
113977
+ var MergedAgentTreeSchema = external_exports.strictObject({
113978
+ ...SessionAgentTreeSchema.shape,
113979
+ agents: external_exports.array(MergedAgentNodeSchema),
113980
+ /** The `cse_` sessions whose live tasks matched this session. Empty when the session is not live or the door has not observed it. */
113981
+ remoteSessions: external_exports.array(external_exports.string()),
113982
+ /** Live tasks of those sessions that match no disk agent (a backgrounded command, or an agent whose files have not appeared yet). */
113983
+ liveOnly: external_exports.array(LiveTaskSchema)
113984
+ });
113985
+ function mergeLiveTasks(tree, live) {
113986
+ const byTaskId = new Map(live.map((task) => [task.taskId, task]));
113987
+ const byToolUseId = new Map(live.flatMap((task) => task.toolUseId === void 0 ? [] : [[task.toolUseId, task]]));
113988
+ const claimed = /* @__PURE__ */ new Set();
113989
+ const merge2 = (node2) => {
113990
+ const task = byTaskId.get(node2.id) ?? (node2.toolUseId === void 0 ? void 0 : byToolUseId.get(node2.toolUseId));
113991
+ if (task !== void 0) {
113992
+ claimed.add(task.taskId);
113993
+ }
113994
+ return { ...node2, provenance: task === void 0 ? "disk" : "both", ...task === void 0 ? {} : { live: task }, children: node2.children.map(merge2) };
113995
+ };
113996
+ const agents = tree.agents.map(merge2);
113997
+ const sessionMarker = `/${tree.sessionId}/`;
113998
+ const liveOnly = live.filter((task) => !claimed.has(task.taskId) && task.outputFile?.includes(sessionMarker) === true);
113999
+ const remoteSessions = [...new Set([...claimed, ...liveOnly.map((task) => task.taskId)].flatMap((taskId) => byTaskId.get(taskId)?.sessionId ?? []))].sort();
114000
+ return { ...tree, agents, remoteSessions, liveOnly };
114001
+ }
114002
+
113864
114003
  // src/frontdoor/rcSessions.ts
113865
114004
  var RC_SESSIONS_PATH_PREFIX = "/v1/code/sessions";
113866
114005
  var RC_SESSION_ID_PREFIX = "cse_";
@@ -113901,7 +114040,7 @@ function sessionCreateId(body) {
113901
114040
  const id2 = session.id;
113902
114041
  return typeof id2 === "string" && id2.startsWith(RC_SESSION_ID_PREFIX) ? id2 : void 0;
113903
114042
  }
113904
- function isRecord3(value2) {
114043
+ function isRecord4(value2) {
113905
114044
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
113906
114045
  }
113907
114046
  function parseJsonObject(body) {
@@ -113911,7 +114050,7 @@ function parseJsonObject(body) {
113911
114050
  } catch {
113912
114051
  return void 0;
113913
114052
  }
113914
- return isRecord3(parsed) ? parsed : void 0;
114053
+ return isRecord4(parsed) ? parsed : void 0;
113915
114054
  }
113916
114055
  function nonEmptyString(record2, field) {
113917
114056
  const value2 = record2 === void 0 ? void 0 : record2[field];
@@ -113932,11 +114071,11 @@ function payloadEventsOf(body) {
113932
114071
  }
113933
114072
  const payloads = [];
113934
114073
  for (const event of events) {
113935
- if (!isRecord3(event)) {
114074
+ if (!isRecord4(event)) {
113936
114075
  continue;
113937
114076
  }
113938
114077
  const payload = event.payload;
113939
- if (!isRecord3(payload)) {
114078
+ if (!isRecord4(payload)) {
113940
114079
  continue;
113941
114080
  }
113942
114081
  payloads.push(payload);
@@ -113951,7 +114090,7 @@ function pendingOfControlRequestPayload(payload) {
113951
114090
  if (requestId === void 0) {
113952
114091
  return void 0;
113953
114092
  }
113954
- const request7 = isRecord3(payload.request) ? payload.request : void 0;
114093
+ const request7 = isRecord4(payload.request) ? payload.request : void 0;
113955
114094
  const subtype = nonEmptyString(request7, "subtype");
113956
114095
  const type2 = subtype ?? "control_request";
113957
114096
  let summary = "";
@@ -113968,20 +114107,21 @@ function answeredRequestIdsOfControlResponsePayload(payload) {
113968
114107
  if (payload.type !== "control_response") {
113969
114108
  return [];
113970
114109
  }
113971
- const response = isRecord3(payload.response) ? payload.response : void 0;
114110
+ const response = isRecord4(payload.response) ? payload.response : void 0;
113972
114111
  const id2 = nonEmptyString(response, "request_id") ?? nonEmptyString(payload, "request_id") ?? nonEmptyString(payload, "uuid");
113973
114112
  return id2 === void 0 ? [] : [id2];
113974
114113
  }
113975
114114
  function parseRcRequestBody(kind, body) {
113976
114115
  if (kind === "heartbeat") {
113977
- return { controlRequests: [], answeredRequestIds: [], idleSeconds: finiteNumber(parseJsonObject(body), "idle_seconds"), workerStatus: void 0 };
114116
+ return { controlRequests: [], answeredRequestIds: [], idleSeconds: finiteNumber(parseJsonObject(body), "idle_seconds"), workerStatus: void 0, payloads: [] };
113978
114117
  }
113979
114118
  if (kind === "worker-registration") {
113980
- return { controlRequests: [], answeredRequestIds: [], idleSeconds: void 0, workerStatus: nonEmptyString(parseJsonObject(body), "worker_status") };
114119
+ return { controlRequests: [], answeredRequestIds: [], idleSeconds: void 0, workerStatus: nonEmptyString(parseJsonObject(body), "worker_status"), payloads: [] };
113981
114120
  }
113982
114121
  const controlRequests = [];
113983
114122
  const answeredRequestIds = [];
113984
- for (const payload of payloadEventsOf(body)) {
114123
+ const payloads = payloadEventsOf(body);
114124
+ for (const payload of payloads) {
113985
114125
  const pending = pendingOfControlRequestPayload(payload);
113986
114126
  if (pending !== void 0) {
113987
114127
  controlRequests.push({ requestId: pending.requestId, type: pending.type, summary: pending.summary });
@@ -113989,7 +114129,7 @@ function parseRcRequestBody(kind, body) {
113989
114129
  }
113990
114130
  answeredRequestIds.push(...answeredRequestIdsOfControlResponsePayload(payload));
113991
114131
  }
113992
- return { controlRequests, answeredRequestIds, idleSeconds: void 0, workerStatus: void 0 };
114132
+ return { controlRequests, answeredRequestIds, idleSeconds: void 0, workerStatus: void 0, payloads };
113993
114133
  }
113994
114134
  function createRcSessionTracker(deps) {
113995
114135
  const entries = /* @__PURE__ */ new Map();
@@ -114015,7 +114155,7 @@ function createRcSessionTracker(deps) {
114015
114155
  const timer = setInterval(sweep, deps.idleMs);
114016
114156
  timer.unref();
114017
114157
  const birth = (id2, facts) => {
114018
- const record2 = { id: id2, createdAt: deps.now(), lastSeenAt: deps.now(), ...facts, pending: /* @__PURE__ */ new Map(), workerState: void 0, workerIdleSeconds: void 0, sequenceNum: void 0 };
114158
+ const record2 = { id: id2, createdAt: deps.now(), lastSeenAt: deps.now(), ...facts, pending: /* @__PURE__ */ new Map(), workerState: void 0, workerIdleSeconds: void 0, sequenceNum: void 0, liveTasks: /* @__PURE__ */ new Map() };
114019
114159
  entries.set(id2, record2);
114020
114160
  return record2;
114021
114161
  };
@@ -114103,6 +114243,9 @@ function createRcSessionTracker(deps) {
114103
114243
  for (const requestId of factsOfBody.answeredRequestIds) {
114104
114244
  entryNow.pending.delete(requestId);
114105
114245
  }
114246
+ for (const payload of factsOfBody.payloads) {
114247
+ entryNow.liveTasks = applyAgentTaskEvent(entryNow.liveTasks, id2, payload, now);
114248
+ }
114106
114249
  if (factsOfBody.idleSeconds !== void 0) {
114107
114250
  entryNow.workerIdleSeconds = { value: factsOfBody.idleSeconds, observedAt: now };
114108
114251
  }
@@ -114193,9 +114336,10 @@ function createRcSessionTracker(deps) {
114193
114336
  return;
114194
114337
  }
114195
114338
  entry.sequenceNum = entry.sequenceNum === void 0 || event.sequence_num > entry.sequenceNum ? event.sequence_num : entry.sequenceNum;
114196
- if (!isRecord3(event.payload)) {
114339
+ if (!isRecord4(event.payload)) {
114197
114340
  return;
114198
114341
  }
114342
+ entry.liveTasks = applyAgentTaskEvent(entry.liveTasks, sessionId, event.payload, deps.now());
114199
114343
  const pending = pendingOfControlRequestPayload(event.payload);
114200
114344
  if (pending !== void 0) {
114201
114345
  if (event.source === RC_STREAM_WORKER_SOURCE) {
@@ -114207,6 +114351,10 @@ function createRcSessionTracker(deps) {
114207
114351
  entry.pending.delete(requestId);
114208
114352
  }
114209
114353
  },
114354
+ liveTasksOf: (sessionId) => {
114355
+ sweep();
114356
+ return sortedEntries().filter((entry) => sessionId === void 0 || entry.id === sessionId).flatMap((entry) => [...entry.liveTasks.values()].sort((left, right) => left.observedAt - right.observedAt || (left.taskId < right.taskId ? -1 : 1)));
114357
+ },
114210
114358
  completePending: (sessionId, requestId) => {
114211
114359
  entries.get(sessionId)?.pending.delete(requestId);
114212
114360
  },
@@ -115727,10 +115875,10 @@ init_claudeShim();
115727
115875
  init_store();
115728
115876
  init_realPorts();
115729
115877
  var import_node_fs16 = __toESM(require("node:fs"), 1);
115730
- var import_node_path44 = __toESM(require("node:path"), 1);
115878
+ var import_node_path43 = __toESM(require("node:path"), 1);
115731
115879
 
115732
115880
  // src/usage/signIn.ts
115733
- var import_node_path43 = __toESM(require("node:path"), 1);
115881
+ var import_node_path42 = __toESM(require("node:path"), 1);
115734
115882
  var CREDENTIALS_FILE = ".credentials.json";
115735
115883
  function keychainHasItem(run, account) {
115736
115884
  return run.run("security", ["find-generic-password", "-a", account]).status === 0;
@@ -115748,7 +115896,7 @@ function decideSignIn(facts) {
115748
115896
  return { state: "signed-out", detail: facts.platform === "darwin" ? `no Keychain item and no ${CREDENTIALS_FILE}` : `no ${CREDENTIALS_FILE}` };
115749
115897
  }
115750
115898
  function credentialsFilePath(farmRoot) {
115751
- return import_node_path43.default.join(farmRoot, CREDENTIALS_FILE);
115899
+ return import_node_path42.default.join(farmRoot, CREDENTIALS_FILE);
115752
115900
  }
115753
115901
  function identitySignIn(fs22, probe, identity) {
115754
115902
  const probing = !identity.hasCredentialBlock;
@@ -115874,7 +116022,7 @@ function tcpPortEraRecord(raw) {
115874
116022
  return (has("port") || has("lastPort")) && !has("socketPath");
115875
116023
  }
115876
116024
  function pushPathResolution(push, resolution) {
115877
- const ownDir = import_node_path44.default.dirname(resolution.ownExecutablePath);
116025
+ const ownDir = import_node_path43.default.dirname(resolution.ownExecutablePath);
115878
116026
  switch (resolution.agentShim.status) {
115879
116027
  case "ok":
115880
116028
  push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
@@ -115973,14 +116121,14 @@ function pushProvider(push, entry, cacheEnv, signIn) {
115973
116121
  }
115974
116122
  function pushLegacyName(push, params) {
115975
116123
  const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
115976
- if (legacyVariables.length === 0 && import_node_path44.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
116124
+ if (legacyVariables.length === 0 && import_node_path43.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
115977
116125
  push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
115978
116126
  return;
115979
116127
  }
115980
116128
  for (const name of legacyVariables) {
115981
116129
  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);
115982
116130
  }
115983
- if (import_node_path44.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
116131
+ if (import_node_path43.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
115984
116132
  push(
115985
116133
  "legacy-name",
115986
116134
  "warn",
@@ -116353,18 +116501,18 @@ function collectDoctorReport(params) {
116353
116501
  const { paths } = params;
116354
116502
  const identityNames = import_node_fs16.default.existsSync(paths.identitiesDir) ? import_node_fs16.default.readdirSync(paths.identitiesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isIdentityDirectoryName(entry.name)).map((entry) => entry.name).sort() : [];
116355
116503
  const identities = identityNames.map((name) => {
116356
- const farmRoot = import_node_path44.default.join(paths.identitiesDir, name);
116357
- const identityPath = import_node_path44.default.join(farmRoot, "identity.json");
116504
+ const farmRoot = import_node_path43.default.join(paths.identitiesDir, name);
116505
+ const identityPath = import_node_path43.default.join(farmRoot, "identity.json");
116358
116506
  return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: import_node_fs16.default.existsSync(credentialsFilePath(farmRoot)) };
116359
116507
  });
116360
116508
  const profileNames = import_node_fs16.default.existsSync(paths.configProfilesDir) ? import_node_fs16.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
116361
116509
  const configProfiles = profileNames.map((name) => {
116362
- const profilePath = import_node_path44.default.join(paths.configProfilesDir, `${name}.json`);
116510
+ const profilePath = import_node_path43.default.join(paths.configProfilesDir, `${name}.json`);
116363
116511
  return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
116364
116512
  });
116365
116513
  const providerNames = import_node_fs16.default.existsSync(paths.providersDir) ? import_node_fs16.default.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
116366
116514
  const providers = providerNames.map((name) => {
116367
- const providerPath = import_node_path44.default.join(paths.providersDir, `${name}.json`);
116515
+ const providerPath = import_node_path43.default.join(paths.providersDir, `${name}.json`);
116368
116516
  return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
116369
116517
  });
116370
116518
  const ownExecutablePath = realOwnExecutablePath();
@@ -116376,12 +116524,12 @@ function collectDoctorReport(params) {
116376
116524
  binaryDiscovery = { ok: false, message: error63 instanceof Error ? error63.message : String(error63) };
116377
116525
  }
116378
116526
  const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
116379
- const pathDirs = (params.env.PATH ?? "").split(import_node_path44.default.delimiter).filter((dir) => dir !== "");
116527
+ const pathDirs = (params.env.PATH ?? "").split(import_node_path43.default.delimiter).filter((dir) => dir !== "");
116380
116528
  const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
116381
116529
  findPathShadow({
116382
116530
  pathDirs,
116383
- targetDir: import_node_path44.default.dirname(shimState.targetPath),
116384
- targetFilename: import_node_path44.default.basename(shimState.targetPath),
116531
+ targetDir: import_node_path43.default.dirname(shimState.targetPath),
116532
+ targetFilename: import_node_path43.default.basename(shimState.targetPath),
116385
116533
  findExecutableInDir
116386
116534
  }),
116387
116535
  shimState.targetPath,
@@ -116410,7 +116558,7 @@ function collectDoctorReport(params) {
116410
116558
  agentShim: refinePathShadow(
116411
116559
  findPathShadow({
116412
116560
  pathDirs,
116413
- targetDir: import_node_path44.default.dirname(ownExecutablePath),
116561
+ targetDir: import_node_path43.default.dirname(ownExecutablePath),
116414
116562
  targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
116415
116563
  findExecutableInDir
116416
116564
  }),
@@ -118934,7 +119082,7 @@ var HTTP_METHODS_UP_TO_V31 = [
118934
119082
  function operationFields(convert) {
118935
119083
  return Object.fromEntries(HTTP_METHODS_UP_TO_V31.map((method) => [method, convert]));
118936
119084
  }
118937
- function isRecord4(value2) {
119085
+ function isRecord5(value2) {
118938
119086
  if (typeof value2 !== "object" || value2 === null) {
118939
119087
  return false;
118940
119088
  }
@@ -118954,7 +119102,7 @@ function setOwn2(object3, key, value2) {
118954
119102
  }
118955
119103
  }
118956
119104
  function cloneValue(value2, seen) {
118957
- if (!(Array.isArray(value2) || isRecord4(value2))) {
119105
+ if (!(Array.isArray(value2) || isRecord5(value2))) {
118958
119106
  return value2;
118959
119107
  }
118960
119108
  const existing = seen.get(value2);
@@ -118977,14 +119125,14 @@ function cloneValue(value2, seen) {
118977
119125
  return out;
118978
119126
  }
118979
119127
  function deepClone(value2) {
118980
- if (!(Array.isArray(value2) || isRecord4(value2))) {
119128
+ if (!(Array.isArray(value2) || isRecord5(value2))) {
118981
119129
  return value2;
118982
119130
  }
118983
119131
  return cloneValue(value2, /* @__PURE__ */ new WeakMap());
118984
119132
  }
118985
119133
  var converting = /* @__PURE__ */ new WeakMap();
118986
119134
  function convertRecord(value2, fields, finish) {
118987
- if (!isRecord4(value2)) {
119135
+ if (!isRecord5(value2)) {
118988
119136
  return deepClone(value2);
118989
119137
  }
118990
119138
  const inProgress = converting.get(value2);
@@ -119010,7 +119158,7 @@ function convertRecord(value2, fields, finish) {
119010
119158
  }
119011
119159
  }
119012
119160
  function mapRecord(value2, convert) {
119013
- if (!isRecord4(value2)) {
119161
+ if (!isRecord5(value2)) {
119014
119162
  return deepClone(value2);
119015
119163
  }
119016
119164
  const out = {};
@@ -119029,7 +119177,7 @@ function mapArray(value2, convert) {
119029
119177
  return value2.map((item) => convert(item)).filter((item) => item !== DROP);
119030
119178
  }
119031
119179
  function getRef(value2) {
119032
- if (isRecord4(value2) && typeof value2.$ref === "string") {
119180
+ if (isRecord5(value2) && typeof value2.$ref === "string") {
119033
119181
  return value2.$ref;
119034
119182
  }
119035
119183
  return void 0;
@@ -119235,7 +119383,7 @@ function convertSchema2(schema) {
119235
119383
  if (schema === false) {
119236
119384
  return { not: {} };
119237
119385
  }
119238
- if (isRecord4(schema) && typeof schema.$ref === "string" && Object.keys(schema).length === 1) {
119386
+ if (isRecord5(schema) && typeof schema.$ref === "string" && Object.keys(schema).length === 1) {
119239
119387
  return { $ref: schema.$ref };
119240
119388
  }
119241
119389
  return convertRecord(schema, SCHEMA_FIELDS, finishSchema);
@@ -119247,7 +119395,7 @@ function resolveSchemeType(name, schemes, seen) {
119247
119395
  return void 0;
119248
119396
  }
119249
119397
  const scheme = schemes[name];
119250
- if (!isRecord4(scheme)) {
119398
+ if (!isRecord5(scheme)) {
119251
119399
  return void 0;
119252
119400
  }
119253
119401
  if (typeof scheme.type === "string") {
@@ -119264,11 +119412,11 @@ function resolveSchemeType(name, schemes, seen) {
119264
119412
  return void 0;
119265
119413
  }
119266
119414
  function createContext(spec) {
119267
- const components = isRecord4(spec) ? spec.components : void 0;
119268
- const pathItems = isRecord4(components) ? components.pathItems : void 0;
119269
- const schemes = isRecord4(components) ? components.securitySchemes : void 0;
119415
+ const components = isRecord5(spec) ? spec.components : void 0;
119416
+ const pathItems = isRecord5(components) ? components.pathItems : void 0;
119417
+ const schemes = isRecord5(components) ? components.securitySchemes : void 0;
119270
119418
  const schemeTypes = /* @__PURE__ */ new Map();
119271
- if (isRecord4(schemes)) {
119419
+ if (isRecord5(schemes)) {
119272
119420
  for (const name of Object.keys(schemes)) {
119273
119421
  const type2 = resolveSchemeType(name, schemes, /* @__PURE__ */ new Set());
119274
119422
  if (type2 !== void 0) {
@@ -119278,7 +119426,7 @@ function createContext(spec) {
119278
119426
  }
119279
119427
  return {
119280
119428
  inlining: /* @__PURE__ */ new Set(),
119281
- pathItems: isRecord4(pathItems) ? pathItems : void 0,
119429
+ pathItems: isRecord5(pathItems) ? pathItems : void 0,
119282
119430
  schemeTypes
119283
119431
  };
119284
119432
  }
@@ -119286,7 +119434,7 @@ function isMutualTls(name, context) {
119286
119434
  return context.schemeTypes.get(name) === "mutualTLS";
119287
119435
  }
119288
119436
  function convertRequirement(value2, context) {
119289
- if (!isRecord4(value2)) {
119437
+ if (!isRecord5(value2)) {
119290
119438
  return deepClone(value2);
119291
119439
  }
119292
119440
  const entries = Object.entries(value2);
@@ -119386,10 +119534,10 @@ function resolvePathItemRef(value2, context) {
119386
119534
  return void 0;
119387
119535
  }
119388
119536
  const target = context.pathItems[name];
119389
- return isRecord4(target) ? [name, target] : void 0;
119537
+ return isRecord5(target) ? [name, target] : void 0;
119390
119538
  }
119391
119539
  function convertPathItem(value2, context) {
119392
- if (!isRecord4(value2)) {
119540
+ if (!isRecord5(value2)) {
119393
119541
  return deepClone(value2);
119394
119542
  }
119395
119543
  const resolved = resolvePathItemRef(value2, context);
@@ -119489,7 +119637,7 @@ function convertExample(value2) {
119489
119637
  });
119490
119638
  }
119491
119639
  function isQuerystringParameter(value2) {
119492
- return isRecord4(value2) && value2.in === "querystring";
119640
+ return isRecord5(value2) && value2.in === "querystring";
119493
119641
  }
119494
119642
  function isRemovedRef(value2, removed) {
119495
119643
  const ref = getRef(value2);
@@ -119505,7 +119653,7 @@ function convertParameterOrHeader2(value2, context) {
119505
119653
  style: (item) => item === "cookie" ? DROP : deepClone(item)
119506
119654
  },
119507
119655
  (out, parameter) => {
119508
- const lostContent = isRecord4(parameter.content) && Object.keys(parameter.content).length > 0 && isRecord4(out.content) && Object.keys(out.content).length === 0;
119656
+ const lostContent = isRecord5(parameter.content) && Object.keys(parameter.content).length > 0 && isRecord5(out.content) && Object.keys(out.content).length === 0;
119509
119657
  return lostContent ? DROP : out;
119510
119658
  }
119511
119659
  );
@@ -119626,7 +119774,7 @@ function convertComponents2(value2, context) {
119626
119774
  });
119627
119775
  }
119628
119776
  function losesEntireContent(value2, mediaTypes) {
119629
- if (!(isRecord4(value2) && isRecord4(value2.content))) {
119777
+ if (!(isRecord5(value2) && isRecord5(value2.content))) {
119630
119778
  return false;
119631
119779
  }
119632
119780
  const entries = Object.values(value2.content);
@@ -119634,7 +119782,7 @@ function losesEntireContent(value2, mediaTypes) {
119634
119782
  }
119635
119783
  function indexRemovedComponentRefs(map2, prefix, mediaTypes, isDirectlyRemoved) {
119636
119784
  const removed = /* @__PURE__ */ new Set();
119637
- if (!isRecord4(map2)) {
119785
+ if (!isRecord5(map2)) {
119638
119786
  return removed;
119639
119787
  }
119640
119788
  const entries = Object.entries(map2);
@@ -119656,12 +119804,12 @@ function indexRemovedComponentRefs(map2, prefix, mediaTypes, isDirectlyRemoved)
119656
119804
  return removed;
119657
119805
  }
119658
119806
  function createContext2(spec) {
119659
- const components = isRecord4(spec) ? spec.components : void 0;
119660
- const mediaTypes = isRecord4(components) && isRecord4(components.mediaTypes) ? components.mediaTypes : void 0;
119807
+ const components = isRecord5(spec) ? spec.components : void 0;
119808
+ const mediaTypes = isRecord5(components) && isRecord5(components.mediaTypes) ? components.mediaTypes : void 0;
119661
119809
  return {
119662
119810
  mediaTypes,
119663
- removedHeaderRefs: indexRemovedComponentRefs(isRecord4(components) ? components.headers : void 0, HEADERS_REF_PREFIX, mediaTypes, () => false),
119664
- removedParameterRefs: indexRemovedComponentRefs(isRecord4(components) ? components.parameters : void 0, PARAMETERS_REF_PREFIX, mediaTypes, isQuerystringParameter)
119811
+ removedHeaderRefs: indexRemovedComponentRefs(isRecord5(components) ? components.headers : void 0, HEADERS_REF_PREFIX, mediaTypes, () => false),
119812
+ removedParameterRefs: indexRemovedComponentRefs(isRecord5(components) ? components.parameters : void 0, PARAMETERS_REF_PREFIX, mediaTypes, isQuerystringParameter)
119665
119813
  };
119666
119814
  }
119667
119815
  function convertJsonSchemaDialect(value2) {
@@ -121937,7 +122085,7 @@ var ResetRowSchema = external_exports.strictObject({
121937
122085
  var ResetScheduleSchema = external_exports.strictObject({ resets: external_exports.readonly(external_exports.array(ResetRowSchema)) });
121938
122086
 
121939
122087
  // src/frontdoor/controlSchemas.ts
121940
- var import_node_path45 = __toESM(require("node:path"), 1);
122088
+ var import_node_path44 = __toESM(require("node:path"), 1);
121941
122089
  init_zod();
121942
122090
  init_schema2();
121943
122091
 
@@ -122149,11 +122297,11 @@ var FrontDoorSessionsOutputSchema = external_exports.strictObject({ sessions: ex
122149
122297
  var CheckRunInputSchema = external_exports.strictObject({
122150
122298
  path: external_exports.string().min(1),
122151
122299
  identity: external_exports.string().min(1).optional()
122152
- }).refine((input2) => import_node_path45.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
122300
+ }).refine((input2) => import_node_path44.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
122153
122301
  var PoolPickInputSchema = external_exports.strictObject({
122154
122302
  pool: external_exports.string().min(1),
122155
122303
  path: external_exports.string().min(1)
122156
- }).refine((input2) => import_node_path45.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
122304
+ }).refine((input2) => import_node_path44.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
122157
122305
  var DoctorFindingSchema = external_exports.strictObject({
122158
122306
  section: external_exports.enum(DOCTOR_SECTIONS),
122159
122307
  subject: external_exports.string().optional(),
@@ -124982,7 +125130,7 @@ function createLifecycleApiRouter(deps) {
124982
125130
  init_cliError();
124983
125131
 
124984
125132
  // src/frontdoor/launchSchemas.ts
124985
- var import_node_path46 = __toESM(require("node:path"), 1);
125133
+ var import_node_path45 = __toESM(require("node:path"), 1);
124986
125134
  init_zod();
124987
125135
  init_claudeVersion();
124988
125136
  init_identity();
@@ -124992,7 +125140,7 @@ var LaunchResolveInputSchema = external_exports.strictObject({
124992
125140
  argv: external_exports.readonly(external_exports.array(external_exports.string())).optional(),
124993
125141
  /** 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. */
124994
125142
  env: external_exports.record(external_exports.string(), external_exports.string()).optional()
124995
- }).refine((input2) => import_node_path46.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
125143
+ }).refine((input2) => import_node_path45.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
124996
125144
  var LaunchPoolDecisionSchema = external_exports.strictObject({
124997
125145
  name: external_exports.string(),
124998
125146
  reasons: external_exports.readonly(external_exports.array(external_exports.string())),
@@ -125076,7 +125224,7 @@ var AgentTreesShowInputSchema = external_exports.strictObject({
125076
125224
  /** Look only in this identity. */
125077
125225
  identity: external_exports.string().optional()
125078
125226
  });
125079
- var AgentTreesShowOutputSchema = external_exports.strictObject({ identities: external_exports.array(external_exports.string()), ...SessionAgentTreeSchema.shape });
125227
+ var AgentTreesShowOutputSchema = external_exports.strictObject({ identities: external_exports.array(external_exports.string()), ...MergedAgentTreeSchema.shape });
125080
125228
  function asBadRequest(error63) {
125081
125229
  if (error63 instanceof CliError) {
125082
125230
  throw new ORPCError("BAD_REQUEST", { message: error63.message });
@@ -125107,14 +125255,14 @@ function createAgentTreesApiRouter(deps) {
125107
125255
  openapi({
125108
125256
  method: "POST",
125109
125257
  path: "/rest/agent-trees/show",
125110
- summary: "Show one session's agent tree, task list and workflow runs",
125258
+ summary: "Show one session's agent tree, task list and workflow runs, with the live Remote Control tasks merged in",
125111
125259
  tags: [SESSION_HISTORY_TAG],
125112
125260
  spec: (current) => ({ ...current, [READ_ONLY_OPERATION_EXTENSION]: true })
125113
125261
  })
125114
125262
  ).input(AgentTreesShowInputSchema).output(AgentTreesShowOutputSchema).handler(({ input: input2 }) => {
125115
125263
  try {
125116
125264
  const view = deps.sessionShow(input2.session, input2.identity);
125117
- return { identities: [...view.identities], ...view.tree };
125265
+ return { identities: [...view.identities], ...mergeLiveTasks(view.tree, deps.liveTasks()) };
125118
125266
  } catch (error63) {
125119
125267
  return asBadRequest(error63);
125120
125268
  }
@@ -126935,15 +127083,15 @@ function readFrontDoorControlMaterial(fsPort, paths, purpose) {
126935
127083
 
126936
127084
  // src/frontdoor/rcLiveUsage.ts
126937
127085
  var RC_RATE_LIMIT_EVENT_TYPE = "rate_limit_event";
126938
- function isRecord5(value2) {
127086
+ function isRecord6(value2) {
126939
127087
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
126940
127088
  }
126941
127089
  function rcRateLimitInfoOf(event) {
126942
127090
  const payload = event.envelope.payload;
126943
- if (!isRecord5(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
127091
+ if (!isRecord6(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
126944
127092
  return void 0;
126945
127093
  }
126946
- if (!isRecord5(payload.rate_limit_info)) {
127094
+ if (!isRecord6(payload.rate_limit_info)) {
126947
127095
  return void 0;
126948
127096
  }
126949
127097
  const parsed = RcRateLimitInfoSchema.safeParse(payload.rate_limit_info);
@@ -126970,7 +127118,7 @@ function createRcLiveUsage(deps) {
126970
127118
  }
126971
127119
 
126972
127120
  // src/frontdoor/rcSelfHostMint.ts
126973
- var import_node_path47 = __toESM(require("node:path"), 1);
127121
+ var import_node_path46 = __toESM(require("node:path"), 1);
126974
127122
  init_account();
126975
127123
 
126976
127124
  // src/frontdoor/rcSelfHostLocal.ts
@@ -126979,7 +127127,7 @@ var RC_SELF_HOST_SCOPE_LIST = ["user:profile", "user:inference", "user:sessions:
126979
127127
  var RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS = 3600;
126980
127128
  var MS_PER_SECOND9 = 1e3;
126981
127129
  var HTTP_SERVICE_UNAVAILABLE = 503;
126982
- function isRecord6(value2) {
127130
+ function isRecord7(value2) {
126983
127131
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
126984
127132
  }
126985
127133
  function parseJsonObject2(body) {
@@ -126989,7 +127137,7 @@ function parseJsonObject2(body) {
126989
127137
  } catch {
126990
127138
  return void 0;
126991
127139
  }
126992
- return isRecord6(parsed) ? parsed : void 0;
127140
+ return isRecord7(parsed) ? parsed : void 0;
126993
127141
  }
126994
127142
  function growthBookFeatures() {
126995
127143
  return {
@@ -127083,7 +127231,7 @@ var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
127083
127231
  var RC_SELF_HOST_RECORD_FILE = "credential.json";
127084
127232
  var SELF_HOST_EMAIL = "selfhost@agent-shim.invalid";
127085
127233
  var SELF_HOST_SUBSCRIPTION_TYPE = "max";
127086
- function isRecord7(value2) {
127234
+ function isRecord8(value2) {
127087
127235
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
127088
127236
  }
127089
127237
  function readJsonObject(fs22, file2) {
@@ -127097,10 +127245,10 @@ function readJsonObject(fs22, file2) {
127097
127245
  } catch {
127098
127246
  return void 0;
127099
127247
  }
127100
- return isRecord7(parsed) ? parsed : void 0;
127248
+ return isRecord8(parsed) ? parsed : void 0;
127101
127249
  }
127102
127250
  function readRcSelfHostRecord(fs22, frontdoorDir) {
127103
- const parsed = readJsonObject(fs22, import_node_path47.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
127251
+ const parsed = readJsonObject(fs22, import_node_path46.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
127104
127252
  if (parsed === void 0) {
127105
127253
  return void 0;
127106
127254
  }
@@ -127114,14 +127262,14 @@ function mintRcSelfHostCredential(deps) {
127114
127262
  if (!isIdentityName(deps.identity)) {
127115
127263
  throw new Error(`"${deps.identity}" is not a valid identity name.`);
127116
127264
  }
127117
- const identityDir = import_node_path47.default.join(deps.identitiesDir, deps.identity);
127118
- const credentialsFile = import_node_path47.default.join(identityDir, CREDENTIALS_FILE2);
127119
- const claudeJsonFile = import_node_path47.default.join(identityDir, CLAUDE_JSON2);
127120
- const recordDir = import_node_path47.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
127121
- const recordFile = import_node_path47.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
127265
+ const identityDir = import_node_path46.default.join(deps.identitiesDir, deps.identity);
127266
+ const credentialsFile = import_node_path46.default.join(identityDir, CREDENTIALS_FILE2);
127267
+ const claudeJsonFile = import_node_path46.default.join(identityDir, CLAUDE_JSON2);
127268
+ const recordDir = import_node_path46.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
127269
+ const recordFile = import_node_path46.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
127122
127270
  const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
127123
127271
  const existingCredentials = readJsonObject(deps.fs, credentialsFile);
127124
- const existingOauth = isRecord7(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
127272
+ const existingOauth = isRecord8(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
127125
127273
  const existingToken = typeof existingOauth?.accessToken === "string" && existingOauth.accessToken !== "" ? existingOauth.accessToken : void 0;
127126
127274
  const existingIsOwn = existingToken !== void 0 && previousRecord?.accessToken === existingToken;
127127
127275
  if (existingToken !== void 0 && !existingIsOwn && !deps.force) {
@@ -127134,11 +127282,11 @@ function mintRcSelfHostCredential(deps) {
127134
127282
  const organizationUuid = deps.newUuid();
127135
127283
  const accountUuid = deps.newUuid();
127136
127284
  const mintedAt = new Date(deps.now()).toISOString();
127137
- deps.fs.mkdirPrivate(import_node_path47.default.dirname(credentialsFile));
127285
+ deps.fs.mkdirPrivate(import_node_path46.default.dirname(credentialsFile));
127138
127286
  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)}
127139
127287
  `);
127140
127288
  const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
127141
- const existingBlock = (value2) => isRecord7(value2) ? value2 : {};
127289
+ const existingBlock = (value2) => isRecord8(value2) ? value2 : {};
127142
127290
  deps.fs.writeFilePrivate(claudeJsonFile, `${JSON.stringify({
127143
127291
  ...claudeJson,
127144
127292
  oauthAccount: {
@@ -127521,15 +127669,15 @@ function registerRcCommand(frontdoor, paths) {
127521
127669
  }
127522
127670
 
127523
127671
  // src/frontdoor/rcCredentialStore.ts
127524
- var import_node_path48 = __toESM(require("node:path"), 1);
127672
+ var import_node_path47 = __toESM(require("node:path"), 1);
127525
127673
  function isSafeSessionId(sessionId) {
127526
127674
  return /^[A-Za-z0-9_-]+$/.test(sessionId);
127527
127675
  }
127528
- function isRecord8(value2) {
127676
+ function isRecord9(value2) {
127529
127677
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
127530
127678
  }
127531
127679
  function credentialOfJson(parsed) {
127532
- if (!isRecord8(parsed)) {
127680
+ if (!isRecord9(parsed)) {
127533
127681
  return void 0;
127534
127682
  }
127535
127683
  const { authorization, anthropicVersion, anthropicClientPlatform } = parsed;
@@ -127547,7 +127695,7 @@ function sequenceNumOfJson(value2) {
127547
127695
  }
127548
127696
  function createRcCredentialStore(fs22, dir) {
127549
127697
  fs22.mkdirPrivate(dir);
127550
- const fileFor = (sessionId) => import_node_path48.default.join(dir, `${sessionId}.json`);
127698
+ const fileFor = (sessionId) => import_node_path47.default.join(dir, `${sessionId}.json`);
127551
127699
  const readParsed = (sessionId) => {
127552
127700
  const raw = fs22.readFileUtf8(fileFor(sessionId));
127553
127701
  if (raw === void 0) {
@@ -127559,7 +127707,7 @@ function createRcCredentialStore(fs22, dir) {
127559
127707
  } catch {
127560
127708
  return void 0;
127561
127709
  }
127562
- return isRecord8(parsed) ? parsed : void 0;
127710
+ return isRecord9(parsed) ? parsed : void 0;
127563
127711
  };
127564
127712
  return {
127565
127713
  read: (sessionId) => {
@@ -128127,7 +128275,7 @@ init_capability();
128127
128275
  // src/frontdoor/rcSelfHostEndpoints.ts
128128
128276
  var RC_SOURCE_WORKER = "worker";
128129
128277
  var RC_SOURCE_CLIENT = "client";
128130
- function isRecord9(value2) {
128278
+ function isRecord10(value2) {
128131
128279
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
128132
128280
  }
128133
128281
  function parseJsonObject3(body) {
@@ -128137,7 +128285,7 @@ function parseJsonObject3(body) {
128137
128285
  } catch {
128138
128286
  return void 0;
128139
128287
  }
128140
- return isRecord9(parsed) ? parsed : void 0;
128288
+ return isRecord10(parsed) ? parsed : void 0;
128141
128289
  }
128142
128290
  function nonEmptyString2(record2, field) {
128143
128291
  const value2 = record2 === void 0 ? void 0 : record2[field];
@@ -128211,7 +128359,7 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
128211
128359
  }
128212
128360
  const results = [];
128213
128361
  for (const event of events) {
128214
- if (!isRecord9(event) || !isRecord9(event.payload)) {
128362
+ if (!isRecord10(event) || !isRecord10(event.payload)) {
128215
128363
  await ctx.answerJson(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a teleport write is an object carrying one payload object" } });
128216
128364
  return true;
128217
128365
  }
@@ -128311,7 +128459,7 @@ async function serveRcCompatSessions(ctx, pathname, compatPath) {
128311
128459
  // src/frontdoor/rcSelfHostConversations.ts
128312
128460
  var RC_CONVERSATIONS_PATH_PREFIX = "/v1/code/conversations";
128313
128461
  var RC_CONVERSATION_ID_PREFIX = "conv_";
128314
- function isRecord10(value2) {
128462
+ function isRecord11(value2) {
128315
128463
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
128316
128464
  }
128317
128465
  function parseJsonObject4(body) {
@@ -128321,7 +128469,7 @@ function parseJsonObject4(body) {
128321
128469
  } catch {
128322
128470
  return void 0;
128323
128471
  }
128324
- return isRecord10(parsed) ? parsed : void 0;
128472
+ return isRecord11(parsed) ? parsed : void 0;
128325
128473
  }
128326
128474
  function nonEmptyString3(record2, field) {
128327
128475
  const value2 = record2 === void 0 ? void 0 : record2[field];
@@ -128375,7 +128523,7 @@ async function serveRcConversations(ctx, pathname, method) {
128375
128523
  }
128376
128524
  const results = [];
128377
128525
  for (const event of events) {
128378
- if (!isRecord10(event) || !isRecord10(event.payload)) {
128526
+ if (!isRecord11(event) || !isRecord11(event.payload)) {
128379
128527
  await ctx.answerJson(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a write is an object carrying one payload object" } });
128380
128528
  return;
128381
128529
  }
@@ -128668,7 +128816,7 @@ var RC_SELF_HOST_WORKER_EPOCH = 1;
128668
128816
  var RC_STREAM_EVENT_NAME = "client_event";
128669
128817
  var CONFLICT_REASON_HEADER2 = "x-ccr-conflict-reason";
128670
128818
  var CONFLICT_REASON_EPOCH_STALE = "epoch_stale";
128671
- function isRecord11(value2) {
128819
+ function isRecord12(value2) {
128672
128820
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
128673
128821
  }
128674
128822
  function isWebSearchRefusal(value2) {
@@ -128752,7 +128900,7 @@ function parseJsonObject5(body) {
128752
128900
  } catch {
128753
128901
  return void 0;
128754
128902
  }
128755
- return isRecord11(parsed) ? parsed : void 0;
128903
+ return isRecord12(parsed) ? parsed : void 0;
128756
128904
  }
128757
128905
  function mintWorkerJwt(randomToken, issuedAt) {
128758
128906
  const encode3 = (value2) => Buffer.from(JSON.stringify(value2), "utf8").toString("base64url");
@@ -129012,7 +129160,7 @@ data: ${JSON.stringify(envelope)}
129012
129160
  if (status !== void 0) {
129013
129161
  session.workerStatus = status;
129014
129162
  }
129015
- if (isRecord11(body?.external_metadata)) {
129163
+ if (isRecord12(body?.external_metadata)) {
129016
129164
  session.externalMetadata = body.external_metadata;
129017
129165
  }
129018
129166
  await answerJson2(response, HTTP_STATUS.ok, {});
@@ -129042,7 +129190,7 @@ data: ${JSON.stringify(envelope)}
129042
129190
  }
129043
129191
  const results = [];
129044
129192
  for (const event of events) {
129045
- if (!isRecord11(event) || !isRecord11(event.payload)) {
129193
+ if (!isRecord12(event) || !isRecord12(event.payload)) {
129046
129194
  await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a batch is an object carrying one payload object" } });
129047
129195
  return;
129048
129196
  }
@@ -129075,7 +129223,7 @@ data: ${JSON.stringify(envelope)}
129075
129223
  return;
129076
129224
  }
129077
129225
  for (const event of events) {
129078
- if (isRecord11(event)) {
129226
+ if (isRecord12(event)) {
129079
129227
  session.internalEvents.push({ eventId: deps.newUuid(), body: event });
129080
129228
  }
129081
129229
  }
@@ -129171,7 +129319,7 @@ data: ${JSON.stringify(envelope)}
129171
129319
  }
129172
129320
  const results = [];
129173
129321
  for (const event of events) {
129174
- if (!isRecord11(event) || !isRecord11(event.payload)) {
129322
+ if (!isRecord12(event) || !isRecord12(event.payload)) {
129175
129323
  await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a write is an object carrying one payload object" } });
129176
129324
  return;
129177
129325
  }
@@ -129361,7 +129509,7 @@ function createSseParser() {
129361
129509
  }
129362
129510
  };
129363
129511
  }
129364
- function isRecord12(value2) {
129512
+ function isRecord13(value2) {
129365
129513
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
129366
129514
  }
129367
129515
  function sequenceNumOf(value2) {
@@ -129383,7 +129531,7 @@ function parseRcStreamEnvelope(parsed) {
129383
129531
  } catch {
129384
129532
  return void 0;
129385
129533
  }
129386
- if (!isRecord12(data)) {
129534
+ if (!isRecord13(data)) {
129387
129535
  return void 0;
129388
129536
  }
129389
129537
  const eventType = data.event_type;
@@ -129834,7 +129982,9 @@ function realFrontDoorSupervisorPorts(paths) {
129834
129982
  log(`pool usage refresh failed: ${error63 instanceof Error ? error63.message : String(error63)}`);
129835
129983
  }
129836
129984
  }, ANTHROPIC_USAGE_FRESHNESS_MS).unref();
129837
- const windowOpener = createRealWindowOpener({ paths, cwd: process.cwd(), spawnDaemon: spawnDetachedSupervisor });
129985
+ const windowOpener = async (identity) => {
129986
+ await runChild({ paths, args: ["__open-window", identity], timeoutMs: WINDOW_OPEN_TIMEOUT_MS });
129987
+ };
129838
129988
  let keeperRunning = false;
129839
129989
  setInterval(() => {
129840
129990
  if (keeperRunning) {
@@ -129856,7 +130006,9 @@ function realFrontDoorSupervisorPorts(paths) {
129856
130006
  keeperRunning = false;
129857
130007
  });
129858
130008
  }, ANTHROPIC_USAGE_FRESHNESS_MS).unref();
129859
- const jobRunner = createRealJobRunner({ paths, spawnDaemon: spawnDetachedSupervisor, fs: realFarmFs, now: () => /* @__PURE__ */ new Date() });
130009
+ const jobRunner = async (name, identity, job) => {
130010
+ await runChild({ paths, args: ["__run-job", name, identity], timeoutMs: parseDuration(job.timeout) });
130011
+ };
129860
130012
  const runningJobs = /* @__PURE__ */ new Set();
129861
130013
  setInterval(() => {
129862
130014
  try {
@@ -129952,6 +130104,7 @@ function realFrontDoorSupervisorPorts(paths) {
129952
130104
  resolveLaunch: (request7) => resolveClaudeLaunch({ argv: request7.argv, cwd: request7.path, env: request7.env, paths }),
129953
130105
  // The identities are read per call, like the pool table, so an identity added after the door started is listed the moment the CLI would see it.
129954
130106
  sessionList: (filters) => collectSessionList(realSessionFs, paths.identitiesDir, listIdentities(paths).map((entry) => entry.name), { ...filters.identity === void 0 ? {} : { identity: filters.identity }, ...filters.all === void 0 ? {} : { all: filters.all } }),
130107
+ liveTasks: () => rcTracker.liveTasksOf(),
129955
130108
  sessionShow: (query, identity) => showSession(realSessionFs, paths.identitiesDir, listIdentities(paths).map((entry) => entry.name), query, identity)
129956
130109
  };
129957
130110
  const lifecycleAndCodexDeps = {
@@ -130022,7 +130175,7 @@ function realFrontDoorSupervisorPorts(paths) {
130022
130175
  const leafFor = createLeafCache(loadCa(), () => /* @__PURE__ */ new Date());
130023
130176
  const capture = captureFromEnv(process.env, paths.logsDir);
130024
130177
  if (capture !== void 0) {
130025
- log(`capture enabled, recording CONNECT targets and piped exchanges to ${import_node_path49.default.join(paths.logsDir, "frontdoor-capture.jsonl")}`);
130178
+ log(`capture enabled, recording CONNECT targets and piped exchanges to ${import_node_path48.default.join(paths.logsDir, "frontdoor-capture.jsonl")}`);
130026
130179
  }
130027
130180
  if (rcSelfHostSurface !== void 0) {
130028
130181
  log("self-hosted Remote Control surface on: the door serves the CCR session family itself, and its own client-half dials its own transparent surface");
@@ -139889,7 +140042,7 @@ async function serveMcp(mcp, transport, options = {}) {
139889
140042
 
139890
140043
  // src/mcp/permissions.ts
139891
140044
  var import_node_fs18 = __toESM(require("node:fs"), 1);
139892
- var import_node_path50 = __toESM(require("node:path"), 1);
140045
+ var import_node_path49 = __toESM(require("node:path"), 1);
139893
140046
  init_zod();
139894
140047
  init_store();
139895
140048
  var StoredMcpPermissionsSchema = external_exports.strictObject({
@@ -139911,10 +140064,10 @@ function effectiveMcpPermissions(flags, stored) {
139911
140064
  return { writes: flags.writes || stored.writes, remoteControl: flags.remoteControl || stored.remoteControl, history: flags.history || stored.history };
139912
140065
  }
139913
140066
  function watchMcpPermissions(paths, onChange) {
139914
- const directory = import_node_path50.default.dirname(paths.mcpPermissionsFile);
140067
+ const directory = import_node_path49.default.dirname(paths.mcpPermissionsFile);
139915
140068
  import_node_fs18.default.mkdirSync(directory, { recursive: true });
139916
140069
  const watcher = import_node_fs18.default.watch(directory, (_event, filename) => {
139917
- if (filename === null || filename === import_node_path50.default.basename(paths.mcpPermissionsFile)) {
140070
+ if (filename === null || filename === import_node_path49.default.basename(paths.mcpPermissionsFile)) {
139918
140071
  onChange();
139919
140072
  }
139920
140073
  });
@@ -140219,7 +140372,7 @@ function registerCompletionCommand(program2) {
140219
140372
  }
140220
140373
 
140221
140374
  // src/credentialCommand.ts
140222
- var import_node_child_process5 = require("node:child_process");
140375
+ var import_node_child_process6 = require("node:child_process");
140223
140376
  init_commandDeps();
140224
140377
  init_cliError();
140225
140378
  init_credential();
@@ -140227,16 +140380,16 @@ init_credentialCache();
140227
140380
 
140228
140381
  // src/identityToken.ts
140229
140382
  var import_node_fs19 = __toESM(require("node:fs"), 1);
140230
- var import_node_path51 = __toESM(require("node:path"), 1);
140383
+ var import_node_path50 = __toESM(require("node:path"), 1);
140231
140384
  init_cliError();
140232
140385
  var TOKEN_FILE_MODE = 384;
140233
140386
  var TOKEN_DIR_MODE = 448;
140234
140387
  var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
140235
140388
  function identityTokenDir(paths) {
140236
- return import_node_path51.default.join(paths.root, "credentials");
140389
+ return import_node_path50.default.join(paths.root, "credentials");
140237
140390
  }
140238
140391
  function identityTokenPath(paths, identityName) {
140239
- return import_node_path51.default.join(identityTokenDir(paths), `${identityName}.token`);
140392
+ return import_node_path50.default.join(identityTokenDir(paths), `${identityName}.token`);
140240
140393
  }
140241
140394
  function storeIdentityToken(paths, identityName, raw) {
140242
140395
  const token = raw.trim();
@@ -140247,7 +140400,7 @@ function storeIdentityToken(paths, identityName, raw) {
140247
140400
  import_node_fs19.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
140248
140401
  import_node_fs19.default.chmodSync(dir, TOKEN_DIR_MODE);
140249
140402
  const target = identityTokenPath(paths, identityName);
140250
- const temp = import_node_path51.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
140403
+ const temp = import_node_path50.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
140251
140404
  import_node_fs19.default.writeFileSync(temp, `${token}
140252
140405
  `, { mode: TOKEN_FILE_MODE });
140253
140406
  import_node_fs19.default.renameSync(temp, target);
@@ -140279,7 +140432,7 @@ function realCommandPorts(deps) {
140279
140432
  cache: createRealCredentialCache(deps.paths.root),
140280
140433
  platform: process.platform,
140281
140434
  now: () => Date.now(),
140282
- ssh: (host, remoteCommand, input2) => (0, import_node_child_process5.spawnSync)("ssh", ["--", host, remoteCommand], { input: input2, stdio: ["pipe", "inherit", "inherit"] }).status
140435
+ ssh: (host, remoteCommand, input2) => (0, import_node_child_process6.spawnSync)("ssh", ["--", host, remoteCommand], { input: input2, stdio: ["pipe", "inherit", "inherit"] }).status
140283
140436
  };
140284
140437
  }
140285
140438
  var REMOTE_ROOT_SCRIPT = 'root="${AGENT_SHIM_HOME:-${CLAUDE_USE_HOME:-}}"; if [ -z "$root" ]; then if [ ! -d "$HOME/.agent-shim" ] && [ -d "$HOME/.claude-use" ]; then root="$HOME/.claude-use"; else root="$HOME/.agent-shim"; fi; fi';
@@ -140415,8 +140568,8 @@ function registerDoctorCommand(program2, deps) {
140415
140568
  // src/headroom/commands.ts
140416
140569
  var import_node_fs20 = __toESM(require("node:fs"), 1);
140417
140570
  var import_node_http4 = __toESM(require("node:http"), 1);
140418
- var import_node_path52 = __toESM(require("node:path"), 1);
140419
- var import_node_child_process6 = require("node:child_process");
140571
+ var import_node_path51 = __toESM(require("node:path"), 1);
140572
+ var import_node_child_process7 = require("node:child_process");
140420
140573
  init_commandDeps();
140421
140574
  init_realFrontDoorPort();
140422
140575
  init_trust();
@@ -140541,16 +140694,16 @@ async function readyOverSocket(socketPath) {
140541
140694
  }
140542
140695
  var HEADROOM_TOOL_NAME = "headroom-ai";
140543
140696
  function readInstalledHeadroomCommit() {
140544
- const toolDir = (0, import_node_child_process6.spawnSync)("uv", ["tool", "dir"], { encoding: "utf8" });
140697
+ const toolDir = (0, import_node_child_process7.spawnSync)("uv", ["tool", "dir"], { encoding: "utf8" });
140545
140698
  if (toolDir.status !== 0) {
140546
140699
  return void 0;
140547
140700
  }
140548
- const libDir = import_node_path52.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
140701
+ const libDir = import_node_path51.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
140549
140702
  for (const python of realFarmFs.readdir(libDir)) {
140550
- const sitePackages = import_node_path52.default.join(libDir, python, "site-packages");
140703
+ const sitePackages = import_node_path51.default.join(libDir, python, "site-packages");
140551
140704
  for (const entry of realFarmFs.readdir(sitePackages)) {
140552
140705
  if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
140553
- const directUrl = realFarmFs.readFileUtf8(import_node_path52.default.join(sitePackages, entry, "direct_url.json"));
140706
+ const directUrl = realFarmFs.readFileUtf8(import_node_path51.default.join(sitePackages, entry, "direct_url.json"));
140554
140707
  return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
140555
140708
  }
140556
140709
  }
@@ -140581,7 +140734,7 @@ function realSupervisorPorts(paths) {
140581
140734
  }
140582
140735
  const logFd = import_node_fs20.default.openSync(paths.headroomLogPath, "a");
140583
140736
  try {
140584
- const child = (0, import_node_child_process6.spawn)("headroom", headroomProxyArgs(socketPath, settings2), {
140737
+ const child = (0, import_node_child_process7.spawn)("headroom", headroomProxyArgs(socketPath, settings2), {
140585
140738
  detached: true,
140586
140739
  stdio: ["ignore", logFd, logFd],
140587
140740
  env: headroomSpawnEnv(process.env, allowlist, settings2, trust?.path)
@@ -140621,7 +140774,7 @@ function realSupervisorPorts(paths) {
140621
140774
  },
140622
140775
  ready: readyOverSocket,
140623
140776
  install: (spec) => {
140624
- const result = (0, import_node_child_process6.spawnSync)("uv", ["tool", "install", spec], { encoding: "utf8" });
140777
+ const result = (0, import_node_child_process7.spawnSync)("uv", ["tool", "install", spec], { encoding: "utf8" });
140625
140778
  if (result.error !== void 0) {
140626
140779
  return { ok: false, error: `uv is not installed or not on PATH (${result.error.message})` };
140627
140780
  }
@@ -140634,7 +140787,7 @@ function realSupervisorPorts(paths) {
140634
140787
  return result.status === 0 ? { ok: true } : { ok: false, error: `uv tool install exited ${String(result.status)}` };
140635
140788
  },
140636
140789
  headroomVersion: () => {
140637
- const result = (0, import_node_child_process6.spawnSync)("headroom", ["--version"], { encoding: "utf8" });
140790
+ const result = (0, import_node_child_process7.spawnSync)("headroom", ["--version"], { encoding: "utf8" });
140638
140791
  return result.status === 0 ? result.stdout.trim() : void 0;
140639
140792
  },
140640
140793
  installedCommit: readInstalledHeadroomCommit,
@@ -140685,6 +140838,76 @@ function registerHeadroomCommand(program2, deps) {
140685
140838
  });
140686
140839
  }
140687
140840
 
140841
+ // src/headlessCommands.ts
140842
+ init_realPorts();
140843
+
140844
+ // src/usage/realJobRunner.ts
140845
+ var import_node_path52 = __toESM(require("node:path"), 1);
140846
+ init_conditions();
140847
+ init_identityClaude();
140848
+ var JOB_LAUNCH_FLAGS = ["--no-headroom", "--no-remote-control", "--track-usage"];
140849
+ var JOB_ISOLATION_OPTIONS = { settingSources: ["user"], mcpServers: {}, strictMcpConfig: true };
140850
+ function logEntry(name, identity, endedAt, outcome) {
140851
+ return `${endedAt.toISOString()} job ${name} as ${identity}
140852
+ ${outcome.trimEnd()}
140853
+
140854
+ `;
140855
+ }
140856
+ function createRealJobRunner(params) {
140857
+ return async (name, identity, job) => {
140858
+ const logFile = import_node_path52.default.join(params.paths.jobLogsDir, `${name}.log`);
140859
+ const append = (outcome) => {
140860
+ params.fs.mkdirPrivate(params.paths.jobLogsDir);
140861
+ params.fs.appendFilePrivate(logFile, logEntry(name, identity, params.now(), outcome));
140862
+ };
140863
+ try {
140864
+ const result = await withIdentityClaude({ paths: params.paths, spawnDaemon: params.spawnDaemon, cwd: job.cwd, timeoutMs: parseDuration(job.timeout) }, identity, JOB_LAUNCH_FLAGS, async ({ bin, env, cwd, abort }) => {
140865
+ const { query } = await Promise.resolve().then(() => (init_sdk(), sdk_exports));
140866
+ const session = query({
140867
+ prompt: job.prompt,
140868
+ options: {
140869
+ pathToClaudeCodeExecutable: bin,
140870
+ env,
140871
+ cwd,
140872
+ abortController: abort,
140873
+ settingSources: [...JOB_ISOLATION_OPTIONS.settingSources],
140874
+ mcpServers: JOB_ISOLATION_OPTIONS.mcpServers,
140875
+ strictMcpConfig: JOB_ISOLATION_OPTIONS.strictMcpConfig,
140876
+ permissionMode: "dontAsk",
140877
+ ...job.model === void 0 ? {} : { model: job.model },
140878
+ ...job.allowedTools === void 0 ? {} : { allowedTools: [...job.allowedTools] }
140879
+ }
140880
+ });
140881
+ try {
140882
+ for await (const message of session) {
140883
+ if (message.type === "result") {
140884
+ return successfulResult(message);
140885
+ }
140886
+ }
140887
+ throw new Error("the run ended without a result");
140888
+ } finally {
140889
+ session.close();
140890
+ }
140891
+ });
140892
+ append(result);
140893
+ } catch (error63) {
140894
+ append(`FAILED: ${error63 instanceof Error ? error63.message : String(error63)}`);
140895
+ throw error63;
140896
+ }
140897
+ };
140898
+ }
140899
+
140900
+ // src/headlessCommands.ts
140901
+ function registerHeadlessCommands(program2, deps) {
140902
+ const { paths } = deps;
140903
+ program2.command("__open-window <identity>", { hidden: true }).description("Internal: open a five-hour window for an identity with one request. Started by the front door's window keeper.").action(async (identity) => {
140904
+ await createRealWindowOpener({ paths, cwd: process.cwd(), spawnDaemon: spawnDetachedSupervisor })(identity);
140905
+ });
140906
+ program2.command("__run-job <name> <identity>", { hidden: true }).description("Internal: run a job as an identity. Started by the front door's job keeper.").action(async (name, identity) => {
140907
+ await createRealJobRunner({ paths, spawnDaemon: spawnDetachedSupervisor, fs: realFarmFs, now: () => /* @__PURE__ */ new Date() })(name, identity, requireJob(paths, name));
140908
+ });
140909
+ }
140910
+
140688
140911
  // src/jobs.ts
140689
140912
  var import_node_path53 = __toESM(require("node:path"), 1);
140690
140913
  init_commandDeps();
@@ -141603,6 +141826,7 @@ function buildProgram(deps) {
141603
141826
  registerProfileCommand(program2, deps);
141604
141827
  registerPoolCommand(program2, deps);
141605
141828
  registerJobCommand(program2, deps);
141829
+ registerHeadlessCommands(program2, deps);
141606
141830
  registerProviderCommand(program2, deps);
141607
141831
  registerRuleCommand(program2, deps);
141608
141832
  registerCredentialCommand(program2, deps, deps.credentialPorts);