claude-use 11.65.0 → 11.65.2
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 +2993 -1926
- package/dist/index.cjs +213 -121
- package/dist/index.mjs +206 -115
- package/dist/types/index.d.ts +39 -2
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1256,7 +1256,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
|
|
|
1256
1256
|
return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
|
|
1257
1257
|
}
|
|
1258
1258
|
function describeIgnoredKeys(filePath, ignored) {
|
|
1259
|
-
const places = ignored.map(({ path:
|
|
1259
|
+
const places = ignored.map(({ path: path42, keys }) => `${path42.length === 0 ? "" : `${path42.map(String).join(".")}.`}${keys.join(", ")}`);
|
|
1260
1260
|
return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
|
|
1261
1261
|
}
|
|
1262
1262
|
function noteIgnoredKeys(filePath, ignored) {
|
|
@@ -1278,9 +1278,9 @@ function restoreIgnoredKeys(filePath, value) {
|
|
|
1278
1278
|
return value;
|
|
1279
1279
|
}
|
|
1280
1280
|
const restored = structuredClone(value);
|
|
1281
|
-
for (const { path:
|
|
1281
|
+
for (const { path: path42, values } of ignored) {
|
|
1282
1282
|
let holder = restored;
|
|
1283
|
-
for (const step of
|
|
1283
|
+
for (const step of path42) {
|
|
1284
1284
|
holder = isRecord(holder) ? holder[step] : void 0;
|
|
1285
1285
|
}
|
|
1286
1286
|
if (isRecord(holder)) {
|
|
@@ -3911,28 +3911,38 @@ function recordOf(details) {
|
|
|
3911
3911
|
}
|
|
3912
3912
|
function writeFrontDoorSession(fs14, sessionsDir, session) {
|
|
3913
3913
|
fs14.mkdirPrivate(sessionsDir);
|
|
3914
|
-
fs14.writeFilePrivate(path9.join(sessionsDir,
|
|
3914
|
+
fs14.writeFilePrivate(path9.join(sessionsDir, sessionRecordName(session.pid)), `${JSON.stringify(session, null, 2)}
|
|
3915
3915
|
`);
|
|
3916
3916
|
}
|
|
3917
|
+
function sessionRecordName(pid) {
|
|
3918
|
+
return `${String(pid)}.json`;
|
|
3919
|
+
}
|
|
3920
|
+
function isSessionRecordName(name) {
|
|
3921
|
+
return name.endsWith(".json");
|
|
3922
|
+
}
|
|
3923
|
+
function summaryOf(session) {
|
|
3924
|
+
return { pid: session.pid, startedAt: session.startedAt, ...session.supervisorPid === void 0 ? {} : { supervisorPid: session.supervisorPid } };
|
|
3925
|
+
}
|
|
3926
|
+
function readFrontDoorSessionRecord(fs14, sessionsDir, name) {
|
|
3927
|
+
try {
|
|
3928
|
+
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs14.readFileUtf8(path9.join(sessionsDir, name)) ?? ""));
|
|
3929
|
+
return parsed.success ? parsed.data : void 0;
|
|
3930
|
+
} catch {
|
|
3931
|
+
return void 0;
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3917
3934
|
function listFrontDoorSessions(fs14, sessionsDir) {
|
|
3918
3935
|
const sessions = [];
|
|
3919
3936
|
for (const name of fs14.readdir(sessionsDir)) {
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
try {
|
|
3924
|
-
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs14.readFileUtf8(path9.join(sessionsDir, name)) ?? ""));
|
|
3925
|
-
if (parsed.success) {
|
|
3926
|
-
sessions.push({ pid: parsed.data.pid, startedAt: parsed.data.startedAt, ...parsed.data.supervisorPid === void 0 ? {} : { supervisorPid: parsed.data.supervisorPid } });
|
|
3927
|
-
}
|
|
3928
|
-
} catch {
|
|
3929
|
-
continue;
|
|
3937
|
+
const record = isSessionRecordName(name) ? readFrontDoorSessionRecord(fs14, sessionsDir, name) : void 0;
|
|
3938
|
+
if (record !== void 0) {
|
|
3939
|
+
sessions.push(summaryOf(record));
|
|
3930
3940
|
}
|
|
3931
3941
|
}
|
|
3932
3942
|
return sessions.sort((a, b) => a.pid - b.pid);
|
|
3933
3943
|
}
|
|
3934
3944
|
function removeFrontDoorSession(fs14, sessionsDir, pid) {
|
|
3935
|
-
fs14.removeRecursive(path9.join(sessionsDir,
|
|
3945
|
+
fs14.removeRecursive(path9.join(sessionsDir, sessionRecordName(pid)));
|
|
3936
3946
|
}
|
|
3937
3947
|
function pruneDeadFrontDoorSessions(fs14, sessionsDir, listed, isRunning) {
|
|
3938
3948
|
const removed = [];
|
|
@@ -4191,9 +4201,10 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
|
|
|
4191
4201
|
return FRONTDOOR_SUPERVISOR_STILL_RUNNING;
|
|
4192
4202
|
}
|
|
4193
4203
|
ticks += 1;
|
|
4194
|
-
const listed =
|
|
4204
|
+
const listed = ports.registry.rescan();
|
|
4195
4205
|
const running = await ports.runningAmong(listed.map((session) => session.pid));
|
|
4196
4206
|
const pruned = pruneDeadFrontDoorSessions(fs14, paths.frontdoorSessionsDir, listed, (pid) => running.has(pid));
|
|
4207
|
+
ports.registry.forget(pruned);
|
|
4197
4208
|
ports.observeLaunchRegistry(listed, pruned);
|
|
4198
4209
|
ports.checkQuotaExpiry();
|
|
4199
4210
|
const prunedPids = new Set(pruned);
|
|
@@ -4267,8 +4278,8 @@ function parseConnectTarget(authority) {
|
|
|
4267
4278
|
function isInterceptedHost(host, interceptHosts) {
|
|
4268
4279
|
return interceptHosts.includes(host);
|
|
4269
4280
|
}
|
|
4270
|
-
function servedByPipeline(
|
|
4271
|
-
return
|
|
4281
|
+
function servedByPipeline(path42) {
|
|
4282
|
+
return path42?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
4272
4283
|
}
|
|
4273
4284
|
function forwardableHeaders(headers) {
|
|
4274
4285
|
const connectionTokens = new Set(
|
|
@@ -4712,7 +4723,7 @@ var init_package = __esm({
|
|
|
4712
4723
|
"package.json"() {
|
|
4713
4724
|
package_default = {
|
|
4714
4725
|
name: "claude-use",
|
|
4715
|
-
version: "11.65.
|
|
4726
|
+
version: "11.65.2",
|
|
4716
4727
|
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.",
|
|
4717
4728
|
license: "MIT",
|
|
4718
4729
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -4764,9 +4775,9 @@ var init_package = __esm({
|
|
|
4764
4775
|
"@anthropic-ai/claude-agent-sdk": "0.3.292",
|
|
4765
4776
|
"@clack/prompts": "^1.8.0",
|
|
4766
4777
|
"@modelcontextprotocol/sdk": "1.32.0",
|
|
4767
|
-
"@orpc/client": "2.0.0-beta.
|
|
4768
|
-
"@orpc/openapi": "2.0.0-beta.
|
|
4769
|
-
"@orpc/server": "2.0.0-beta.
|
|
4778
|
+
"@orpc/client": "2.0.0-beta.43",
|
|
4779
|
+
"@orpc/openapi": "2.0.0-beta.43",
|
|
4780
|
+
"@orpc/server": "2.0.0-beta.43",
|
|
4770
4781
|
commander: "^15.0.0",
|
|
4771
4782
|
cosmiconfig: "^10.0.1",
|
|
4772
4783
|
picomatch: "^4.0.7",
|
|
@@ -7918,9 +7929,9 @@ var init_poolPick = __esm({
|
|
|
7918
7929
|
|
|
7919
7930
|
// src/statusline/keys.ts
|
|
7920
7931
|
import { z as z16 } from "zod";
|
|
7921
|
-
function valueAt(source,
|
|
7932
|
+
function valueAt(source, path42) {
|
|
7922
7933
|
let current = source;
|
|
7923
|
-
for (const part of
|
|
7934
|
+
for (const part of path42) {
|
|
7924
7935
|
if (!isPlainObject(current)) {
|
|
7925
7936
|
return void 0;
|
|
7926
7937
|
}
|
|
@@ -7928,10 +7939,10 @@ function valueAt(source, path41) {
|
|
|
7928
7939
|
}
|
|
7929
7940
|
return current;
|
|
7930
7941
|
}
|
|
7931
|
-
function keyOf(
|
|
7942
|
+
function keyOf(path42, declared) {
|
|
7932
7943
|
const optional = declared instanceof z16.ZodOptional;
|
|
7933
7944
|
const leaf = optional ? declared.unwrap() : declared;
|
|
7934
|
-
const common = { path:
|
|
7945
|
+
const common = { path: path42.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path42), optional };
|
|
7935
7946
|
if (leaf instanceof z16.ZodNumber) {
|
|
7936
7947
|
return { ...common, kind: "integer", choices: [] };
|
|
7937
7948
|
}
|
|
@@ -7956,7 +7967,7 @@ function keyOf(path41, declared) {
|
|
|
7956
7967
|
if (leaf instanceof z16.ZodArray && leaf.element instanceof z16.ZodString) {
|
|
7957
7968
|
return { ...common, kind: "textList", choices: [] };
|
|
7958
7969
|
}
|
|
7959
|
-
throw new TypeError(`statusline setting ${
|
|
7970
|
+
throw new TypeError(`statusline setting ${path42.join(".")} has a kind the key listing does not describe`);
|
|
7960
7971
|
}
|
|
7961
7972
|
function walk(shape, prefix) {
|
|
7962
7973
|
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof z16.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
@@ -7972,15 +7983,15 @@ var init_keys = __esm({
|
|
|
7972
7983
|
});
|
|
7973
7984
|
|
|
7974
7985
|
// src/statusline/change.ts
|
|
7975
|
-
function keyNamed(
|
|
7976
|
-
const found = statuslineKeys().find((key) => key.path ===
|
|
7986
|
+
function keyNamed(path42) {
|
|
7987
|
+
const found = statuslineKeys().find((key) => key.path === path42);
|
|
7977
7988
|
if (found === void 0) {
|
|
7978
|
-
throw new UsageError(`"${
|
|
7989
|
+
throw new UsageError(`"${path42}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
|
|
7979
7990
|
}
|
|
7980
7991
|
return found;
|
|
7981
7992
|
}
|
|
7982
|
-
function setAt(target,
|
|
7983
|
-
const [head, ...rest] =
|
|
7993
|
+
function setAt(target, path42, value) {
|
|
7994
|
+
const [head, ...rest] = path42;
|
|
7984
7995
|
if (head === void 0) {
|
|
7985
7996
|
return;
|
|
7986
7997
|
}
|
|
@@ -7993,8 +8004,8 @@ function setAt(target, path41, value) {
|
|
|
7993
8004
|
target[head] = next;
|
|
7994
8005
|
setAt(next, rest, value);
|
|
7995
8006
|
}
|
|
7996
|
-
function removeAt(target,
|
|
7997
|
-
const [head, ...rest] =
|
|
8007
|
+
function removeAt(target, path42) {
|
|
8008
|
+
const [head, ...rest] = path42;
|
|
7998
8009
|
if (head === void 0) {
|
|
7999
8010
|
return;
|
|
8000
8011
|
}
|
|
@@ -8012,13 +8023,13 @@ function removeAt(target, path41) {
|
|
|
8012
8023
|
}
|
|
8013
8024
|
function applyStatuslineChange(existing, change) {
|
|
8014
8025
|
const draft = structuredClone(existing ?? {});
|
|
8015
|
-
for (const [
|
|
8016
|
-
keyNamed(
|
|
8017
|
-
setAt(draft,
|
|
8026
|
+
for (const [path42, value] of Object.entries(change.set ?? {})) {
|
|
8027
|
+
keyNamed(path42);
|
|
8028
|
+
setAt(draft, path42.split("."), value);
|
|
8018
8029
|
}
|
|
8019
|
-
for (const
|
|
8020
|
-
keyNamed(
|
|
8021
|
-
removeAt(draft,
|
|
8030
|
+
for (const path42 of change.unset ?? []) {
|
|
8031
|
+
keyNamed(path42);
|
|
8032
|
+
removeAt(draft, path42.split("."));
|
|
8022
8033
|
}
|
|
8023
8034
|
const result = StatuslineSchema.safeParse(draft);
|
|
8024
8035
|
if (!result.success) {
|
|
@@ -10755,7 +10766,7 @@ var init_settings2 = __esm({
|
|
|
10755
10766
|
});
|
|
10756
10767
|
|
|
10757
10768
|
// src/launcher/flags.ts
|
|
10758
|
-
import
|
|
10769
|
+
import path36 from "node:path";
|
|
10759
10770
|
function resolveLaunchFlags(params) {
|
|
10760
10771
|
const statusline = resolveStatuslineSettings(params);
|
|
10761
10772
|
return {
|
|
@@ -10811,7 +10822,7 @@ function buildEnv(params) {
|
|
|
10811
10822
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
10812
10823
|
let providerCustomHeaders;
|
|
10813
10824
|
if (!params.configDirEscapeHatch && params.resolvedIdentityName !== void 0) {
|
|
10814
|
-
env.CLAUDE_CONFIG_DIR =
|
|
10825
|
+
env.CLAUDE_CONFIG_DIR = path36.join(params.identitiesDir, params.resolvedIdentityName);
|
|
10815
10826
|
}
|
|
10816
10827
|
if (params.provider !== void 0) {
|
|
10817
10828
|
const providerEnv = params.provider.definition.kind !== void 0 && params.provider.definition.kind !== "http" ? {} : params.provider.definition.env ?? {};
|
|
@@ -10903,7 +10914,7 @@ var init_extraFlags = __esm({
|
|
|
10903
10914
|
});
|
|
10904
10915
|
|
|
10905
10916
|
// src/usage/resumeContext.ts
|
|
10906
|
-
import
|
|
10917
|
+
import path37 from "node:path";
|
|
10907
10918
|
function projectDirNameOf(cwd) {
|
|
10908
10919
|
return cwd.replace(/[^A-Za-z0-9]/g, "-");
|
|
10909
10920
|
}
|
|
@@ -10961,7 +10972,7 @@ function newestTranscript(fs14, projectDir) {
|
|
|
10961
10972
|
if (!name.endsWith(".jsonl")) {
|
|
10962
10973
|
continue;
|
|
10963
10974
|
}
|
|
10964
|
-
const candidate =
|
|
10975
|
+
const candidate = path37.join(projectDir, name);
|
|
10965
10976
|
const stat = fs14.lstat(candidate);
|
|
10966
10977
|
if (stat?.kind === "file" && stat.mtimeMs > newestMs) {
|
|
10967
10978
|
newestMs = stat.mtimeMs;
|
|
@@ -10975,8 +10986,8 @@ function resumedContextTokens(fs14, params) {
|
|
|
10975
10986
|
if (target === void 0) {
|
|
10976
10987
|
return void 0;
|
|
10977
10988
|
}
|
|
10978
|
-
const projectDir =
|
|
10979
|
-
const file = target.kind === "id" ?
|
|
10989
|
+
const projectDir = path37.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
|
|
10990
|
+
const file = target.kind === "id" ? path37.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs14, projectDir);
|
|
10980
10991
|
const text = file === void 0 ? void 0 : fs14.readFileUtf8(file);
|
|
10981
10992
|
return text === void 0 ? void 0 : contextTokensOfTranscript(text);
|
|
10982
10993
|
}
|
|
@@ -11421,7 +11432,7 @@ var init_launchHook = __esm({
|
|
|
11421
11432
|
// src/launcher.ts
|
|
11422
11433
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
11423
11434
|
import { isDeepStrictEqual } from "node:util";
|
|
11424
|
-
import
|
|
11435
|
+
import path38 from "node:path";
|
|
11425
11436
|
function resolveIdentityCredential(identity, credential, env, port) {
|
|
11426
11437
|
if (port === void 0) {
|
|
11427
11438
|
return { ok: false, status: 1, message: `agent-shim: identity ${identity} needs its credential resolved, but this launcher has no credential port wired` };
|
|
@@ -11664,7 +11675,7 @@ function decideLaunch(params, readOnly) {
|
|
|
11664
11675
|
extraFlags: splitExtraFlags(env.CLAUDE_EXTRA_FLAGS),
|
|
11665
11676
|
passthrough: withLauncherSettings(params.supervised === void 0 ? parsedArgv.rest : withSupervision(parsedArgv.rest, params.supervised), launcherSettings)
|
|
11666
11677
|
});
|
|
11667
|
-
const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR :
|
|
11678
|
+
const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR : path38.join(paths.identitiesDir, identityDecision.name);
|
|
11668
11679
|
const decision = {
|
|
11669
11680
|
identitySource: identityDecision.source,
|
|
11670
11681
|
configDirEscapeHatch: identityDecision.configDirEscapeHatch,
|
|
@@ -11717,7 +11728,7 @@ function prepareLaunch(params) {
|
|
|
11717
11728
|
let warnings = [];
|
|
11718
11729
|
const updateCheck = runLaunchUpdateCheck({
|
|
11719
11730
|
mode: params.updateMode ?? "off",
|
|
11720
|
-
checkPath:
|
|
11731
|
+
checkPath: path38.join(paths.root, "update.check"),
|
|
11721
11732
|
currentVersion: package_default.version,
|
|
11722
11733
|
port: params.update
|
|
11723
11734
|
});
|
|
@@ -11905,12 +11916,12 @@ var init_launcher = __esm({
|
|
|
11905
11916
|
});
|
|
11906
11917
|
|
|
11907
11918
|
// src/ownCli.ts
|
|
11908
|
-
import
|
|
11919
|
+
import path39 from "node:path";
|
|
11909
11920
|
function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string" ? __AGENT_SHIM_DIST_DIR__ : void 0) {
|
|
11910
11921
|
if (distDir === void 0) {
|
|
11911
11922
|
throw new OwnCliPathUnknownError();
|
|
11912
11923
|
}
|
|
11913
|
-
return
|
|
11924
|
+
return path39.join(distDir, OWN_CLI_FILE_NAME);
|
|
11914
11925
|
}
|
|
11915
11926
|
var OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
|
|
11916
11927
|
var init_ownCli = __esm({
|
|
@@ -11956,10 +11967,10 @@ var init_selfIdentity = __esm({
|
|
|
11956
11967
|
|
|
11957
11968
|
// src/frontdoor/trust.ts
|
|
11958
11969
|
import { createHash as createHash7 } from "node:crypto";
|
|
11959
|
-
import
|
|
11970
|
+
import path40 from "node:path";
|
|
11960
11971
|
function resolveTrustBundle(params) {
|
|
11961
11972
|
const { caCertFile, bundlesDir, variable, inherited, fs: fs14 } = params;
|
|
11962
|
-
if (inherited === void 0 || inherited === "" ||
|
|
11973
|
+
if (inherited === void 0 || inherited === "" || path40.resolve(inherited) === path40.resolve(caCertFile)) {
|
|
11963
11974
|
return { path: caCertFile };
|
|
11964
11975
|
}
|
|
11965
11976
|
const caPem = fs14.readFileUtf8(caCertFile);
|
|
@@ -11977,7 +11988,7 @@ function resolveTrustBundle(params) {
|
|
|
11977
11988
|
}
|
|
11978
11989
|
const combined = `${inheritedPem.trimEnd()}
|
|
11979
11990
|
${caPem}`;
|
|
11980
|
-
const bundle =
|
|
11991
|
+
const bundle = path40.join(bundlesDir, `${createHash7("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
11981
11992
|
if (!fs14.exists(bundle)) {
|
|
11982
11993
|
fs14.mkdirp(bundlesDir);
|
|
11983
11994
|
fs14.writeFileAtomic(bundle, combined);
|
|
@@ -12110,7 +12121,7 @@ var init_replayRun = __esm({
|
|
|
12110
12121
|
|
|
12111
12122
|
// src/launchWiring.ts
|
|
12112
12123
|
import os8 from "node:os";
|
|
12113
|
-
import
|
|
12124
|
+
import path41 from "node:path";
|
|
12114
12125
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
12115
12126
|
function buildFarmRuntime(paths, cwd, run = realRunPort) {
|
|
12116
12127
|
const home = os8.homedir();
|
|
@@ -12165,7 +12176,7 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
12165
12176
|
frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
|
|
12166
12177
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
12167
12178
|
hold: realHoldPort,
|
|
12168
|
-
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot:
|
|
12179
|
+
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: path41.join(paths.identitiesDir, identity), hasCredentialBlock: false }).state !== "signed-out",
|
|
12169
12180
|
...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
|
|
12170
12181
|
...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
|
|
12171
12182
|
...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
|
|
@@ -13058,11 +13069,11 @@ function createRcSessionTracker(deps) {
|
|
|
13058
13069
|
};
|
|
13059
13070
|
const observeExchange = (request4) => {
|
|
13060
13071
|
const method = (request4.method ?? "").toUpperCase();
|
|
13061
|
-
const
|
|
13062
|
-
if (!
|
|
13072
|
+
const path42 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
|
|
13073
|
+
if (!path42.startsWith(RC_SESSIONS_PATH_PREFIX)) {
|
|
13063
13074
|
return void 0;
|
|
13064
13075
|
}
|
|
13065
|
-
const tail =
|
|
13076
|
+
const tail = path42.slice(RC_SESSIONS_PATH_PREFIX.length);
|
|
13066
13077
|
const facts = {
|
|
13067
13078
|
oauthAuthorization: oauthAuthorizationOf(request4.headers),
|
|
13068
13079
|
anthropicVersion: singleHeader(request4.headers, "anthropic-version"),
|
|
@@ -13179,7 +13190,7 @@ function createRcSessionTracker(deps) {
|
|
|
13179
13190
|
}
|
|
13180
13191
|
};
|
|
13181
13192
|
};
|
|
13182
|
-
const
|
|
13193
|
+
const summaryOf2 = ({ id, createdAt, lastSeenAt }) => ({ id, createdAt, lastSeenAt });
|
|
13183
13194
|
const pendingSummaryOf = ({ sessionId, requestId, type, summary, observedAt: observedAt2 }) => ({ sessionId, requestId, type, summary, observedAt: observedAt2 });
|
|
13184
13195
|
const sortedEntries = () => [...entries.values()].sort((left, right) => left.createdAt - right.createdAt || (left.id < right.id ? -1 : 1));
|
|
13185
13196
|
const pendingSorted = (entry) => [...entry.pending.values()].sort((left, right) => left.observedAt - right.observedAt || (left.requestId < right.requestId ? -1 : 1)).map(pendingSummaryOf);
|
|
@@ -13187,11 +13198,11 @@ function createRcSessionTracker(deps) {
|
|
|
13187
13198
|
observeExchange,
|
|
13188
13199
|
list: () => {
|
|
13189
13200
|
sweep();
|
|
13190
|
-
return sortedEntries().map(
|
|
13201
|
+
return sortedEntries().map(summaryOf2);
|
|
13191
13202
|
},
|
|
13192
13203
|
statusOf: (sessionId) => {
|
|
13193
13204
|
sweep();
|
|
13194
|
-
return sortedEntries().filter((entry) => sessionId === void 0 || entry.id === sessionId).map((entry) => ({ ...
|
|
13205
|
+
return sortedEntries().filter((entry) => sessionId === void 0 || entry.id === sessionId).map((entry) => ({ ...summaryOf2(entry), workerState: entry.workerState, workerIdleSeconds: entry.workerIdleSeconds, pending: pendingSorted(entry) }));
|
|
13195
13206
|
},
|
|
13196
13207
|
pendingOf: (sessionId) => {
|
|
13197
13208
|
sweep();
|
|
@@ -13452,8 +13463,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
|
|
|
13452
13463
|
function isRcReadFileEncoding(value) {
|
|
13453
13464
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
|
|
13454
13465
|
}
|
|
13455
|
-
function buildRcReadFilePayload(requestId,
|
|
13456
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
13466
|
+
function buildRcReadFilePayload(requestId, path42, options) {
|
|
13467
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path42, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
13457
13468
|
}
|
|
13458
13469
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
13459
13470
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -13555,15 +13566,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
13555
13566
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
13556
13567
|
return result.ok ? { ...result, requestId } : result;
|
|
13557
13568
|
}
|
|
13558
|
-
async function readRcSessionFile(deps, sessionId,
|
|
13559
|
-
if (
|
|
13569
|
+
async function readRcSessionFile(deps, sessionId, path42, options) {
|
|
13570
|
+
if (path42 === "") {
|
|
13560
13571
|
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" };
|
|
13561
13572
|
}
|
|
13562
13573
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
13563
13574
|
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" };
|
|
13564
13575
|
}
|
|
13565
13576
|
const requestId = deps.newUuid();
|
|
13566
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
13577
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path42, options), `read ${path42} from session ${sessionId}`);
|
|
13567
13578
|
return result.ok ? { ...result, requestId } : result;
|
|
13568
13579
|
}
|
|
13569
13580
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -13732,11 +13743,11 @@ function createRcControlHandler(deps) {
|
|
|
13732
13743
|
path: "read-file",
|
|
13733
13744
|
read: (body) => {
|
|
13734
13745
|
const session = bodyString(body, "session");
|
|
13735
|
-
const
|
|
13746
|
+
const path42 = bodyString(body, "path");
|
|
13736
13747
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
13737
13748
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
13738
|
-
const refused2 = session === void 0 ||
|
|
13739
|
-
return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session,
|
|
13749
|
+
const refused2 = session === void 0 || path42 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
13750
|
+
return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path42, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
|
|
13740
13751
|
}
|
|
13741
13752
|
},
|
|
13742
13753
|
{
|
|
@@ -14046,9 +14057,9 @@ function requestIdOfBody(body) {
|
|
|
14046
14057
|
}
|
|
14047
14058
|
function frontDoorRcControl(transport, token) {
|
|
14048
14059
|
const headers = { authorization: `Bearer ${token}` };
|
|
14049
|
-
const listAnswerOf = async (
|
|
14060
|
+
const listAnswerOf = async (path42, what) => {
|
|
14050
14061
|
try {
|
|
14051
|
-
return await transport.request({ method: "GET", path:
|
|
14062
|
+
return await transport.request({ method: "GET", path: path42, headers });
|
|
14052
14063
|
} catch (error) {
|
|
14053
14064
|
throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
14054
14065
|
}
|
|
@@ -14120,10 +14131,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
14120
14131
|
}
|
|
14121
14132
|
return pending;
|
|
14122
14133
|
};
|
|
14123
|
-
const writeOf = async (
|
|
14134
|
+
const writeOf = async (path42, body, describeFailure2) => {
|
|
14124
14135
|
let answer;
|
|
14125
14136
|
try {
|
|
14126
|
-
answer = await transport.request({ method: "POST", path:
|
|
14137
|
+
answer = await transport.request({ method: "POST", path: path42, headers: { ...headers, "content-type": "application/json" }, body });
|
|
14127
14138
|
} catch (error) {
|
|
14128
14139
|
return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
|
|
14129
14140
|
}
|
|
@@ -14154,10 +14165,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
14154
14165
|
endSession: async (sessionId, reason) => await writeOf(`${CONTROL_PATH_PREFIX}/end-session`, JSON.stringify({ session: sessionId, ...reason === void 0 ? {} : { reason } }), (status, message) => `ending ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
14155
14166
|
getUsage: async (sessionId, skipBehaviors) => await writeOf(`${CONTROL_PATH_PREFIX}/get-usage`, JSON.stringify({ session: sessionId, ...skipBehaviors === void 0 ? {} : { skipBehaviors } }), (status, message) => `requesting the usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
14156
14167
|
getContextUsage: async (sessionId, detail) => await writeOf(`${CONTROL_PATH_PREFIX}/get-context-usage`, JSON.stringify({ session: sessionId, ...detail === void 0 ? {} : { detail } }), (status, message) => `requesting the context usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
14157
|
-
readFile: async (sessionId,
|
|
14168
|
+
readFile: async (sessionId, path42, options) => await writeOf(
|
|
14158
14169
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
14159
|
-
JSON.stringify({ session: sessionId, path:
|
|
14160
|
-
(status, message) => `reading ${
|
|
14170
|
+
JSON.stringify({ session: sessionId, path: path42, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
14171
|
+
(status, message) => `reading ${path42} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
14161
14172
|
),
|
|
14162
14173
|
fileSuggestions: async (sessionId, query) => await writeOf(`${CONTROL_PATH_PREFIX}/file-suggestions`, JSON.stringify({ session: sessionId, query }), (status, message) => `requesting file suggestions from ${sessionId} failed (HTTP ${String(status)}): ${message}`),
|
|
14163
14174
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -14316,12 +14327,12 @@ function tlsFacts(options) {
|
|
|
14316
14327
|
}
|
|
14317
14328
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
14318
14329
|
const agent = new ExemptTlsAgent();
|
|
14319
|
-
const post = async (
|
|
14330
|
+
const post = async (path42, headers, body) => await new Promise((resolve, reject) => {
|
|
14320
14331
|
const options = {
|
|
14321
14332
|
host: target.host,
|
|
14322
14333
|
port: target.port,
|
|
14323
14334
|
method: "POST",
|
|
14324
|
-
path:
|
|
14335
|
+
path: path42,
|
|
14325
14336
|
// The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
|
|
14326
14337
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
14327
14338
|
agent
|
|
@@ -14386,12 +14397,12 @@ function lateRcStreamDial(resolve) {
|
|
|
14386
14397
|
}
|
|
14387
14398
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
14388
14399
|
const agent = new ExemptTlsAgent();
|
|
14389
|
-
const request4 = async (method,
|
|
14400
|
+
const request4 = async (method, path42, headers, body, signal) => await new Promise((resolve, reject) => {
|
|
14390
14401
|
const options = {
|
|
14391
14402
|
host: target.host,
|
|
14392
14403
|
port: target.port,
|
|
14393
14404
|
method,
|
|
14394
|
-
path:
|
|
14405
|
+
path: path42,
|
|
14395
14406
|
// The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
|
|
14396
14407
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
14397
14408
|
agent,
|
|
@@ -14433,9 +14444,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
14433
14444
|
return { status, body: await readAll(response) };
|
|
14434
14445
|
},
|
|
14435
14446
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
14436
|
-
const
|
|
14447
|
+
const path42 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
|
|
14437
14448
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
14438
|
-
const { status, response } = await request4("GET",
|
|
14449
|
+
const { status, response } = await request4("GET", path42, streamHeaders, void 0, signal);
|
|
14439
14450
|
if (!isSuccessful2(status)) {
|
|
14440
14451
|
await readAll(response);
|
|
14441
14452
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -15428,19 +15439,19 @@ function writePools(paths, pools) {
|
|
|
15428
15439
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
15429
15440
|
}
|
|
15430
15441
|
function poolCycleOf(pools, name) {
|
|
15431
|
-
const walk2 = (current,
|
|
15442
|
+
const walk2 = (current, path42) => {
|
|
15432
15443
|
for (const entry of pools[current]?.identities ?? []) {
|
|
15433
15444
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
15434
15445
|
if (nested === void 0) {
|
|
15435
15446
|
continue;
|
|
15436
15447
|
}
|
|
15437
15448
|
if (nested === name) {
|
|
15438
|
-
return [...
|
|
15449
|
+
return [...path42, nested];
|
|
15439
15450
|
}
|
|
15440
|
-
if (
|
|
15451
|
+
if (path42.includes(nested)) {
|
|
15441
15452
|
continue;
|
|
15442
15453
|
}
|
|
15443
|
-
const found = walk2(nested, [...
|
|
15454
|
+
const found = walk2(nested, [...path42, nested]);
|
|
15444
15455
|
if (found !== void 0) {
|
|
15445
15456
|
return found;
|
|
15446
15457
|
}
|
|
@@ -17886,7 +17897,7 @@ function profileValue(name, paths) {
|
|
|
17886
17897
|
function createConfigApiRouter(deps) {
|
|
17887
17898
|
const authed = doorApiAuth(deps.expectedToken);
|
|
17888
17899
|
const { paths } = deps;
|
|
17889
|
-
const route = (
|
|
17900
|
+
const route = (path42, summary) => authed.meta(openapi3({ method: "POST", path: path42, summary, tags: [CONFIG_API_TAG] }));
|
|
17890
17901
|
return {
|
|
17891
17902
|
config: {
|
|
17892
17903
|
identity: {
|
|
@@ -20537,6 +20548,85 @@ function mintRcSelfHostCredential(deps) {
|
|
|
20537
20548
|
|
|
20538
20549
|
// src/index.ts
|
|
20539
20550
|
init_ensure2();
|
|
20551
|
+
|
|
20552
|
+
// src/frontdoor/liveSessionRegistry.ts
|
|
20553
|
+
init_capability();
|
|
20554
|
+
init_state();
|
|
20555
|
+
import path33 from "node:path";
|
|
20556
|
+
function sameStat(recorded, current) {
|
|
20557
|
+
return recorded?.mtimeMs === current.mtimeMs && recorded.sizeBytes === current.sizeBytes;
|
|
20558
|
+
}
|
|
20559
|
+
function createLiveSessionRegistry(ports) {
|
|
20560
|
+
const { fs: fs14, sessionsDir } = ports;
|
|
20561
|
+
const known = /* @__PURE__ */ new Map();
|
|
20562
|
+
let tokens = /* @__PURE__ */ new Set();
|
|
20563
|
+
let bySessionId = /* @__PURE__ */ new Map();
|
|
20564
|
+
const recordNames = () => fs14.readdir(sessionsDir).filter(isSessionRecordName);
|
|
20565
|
+
const rebuildIndexes = () => {
|
|
20566
|
+
const records = [...known.values()].flatMap(({ record }) => record === void 0 ? [] : [record]);
|
|
20567
|
+
tokens = new Set(records.map((record) => record.token));
|
|
20568
|
+
bySessionId = new Map(records.flatMap((record) => record.sessionId === void 0 ? [] : [[record.sessionId, record]]));
|
|
20569
|
+
};
|
|
20570
|
+
const load = (name, stat) => {
|
|
20571
|
+
known.set(name, { stat: { mtimeMs: stat.mtimeMs, sizeBytes: stat.sizeBytes }, record: readFrontDoorSessionRecord(fs14, sessionsDir, name) });
|
|
20572
|
+
};
|
|
20573
|
+
const statOf = (name) => fs14.lstat(path33.join(sessionsDir, name));
|
|
20574
|
+
const reconcile = () => {
|
|
20575
|
+
const names = new Set(recordNames());
|
|
20576
|
+
let changed = false;
|
|
20577
|
+
for (const name of known.keys()) {
|
|
20578
|
+
if (!names.has(name)) {
|
|
20579
|
+
known.delete(name);
|
|
20580
|
+
changed = true;
|
|
20581
|
+
}
|
|
20582
|
+
}
|
|
20583
|
+
for (const name of names) {
|
|
20584
|
+
const held = known.get(name);
|
|
20585
|
+
const stat = statOf(name);
|
|
20586
|
+
if (stat === void 0) {
|
|
20587
|
+
changed = known.delete(name) || changed;
|
|
20588
|
+
} else if (!sameStat(held?.stat, stat)) {
|
|
20589
|
+
load(name, stat);
|
|
20590
|
+
changed = true;
|
|
20591
|
+
}
|
|
20592
|
+
}
|
|
20593
|
+
if (changed) {
|
|
20594
|
+
rebuildIndexes();
|
|
20595
|
+
}
|
|
20596
|
+
return changed;
|
|
20597
|
+
};
|
|
20598
|
+
return {
|
|
20599
|
+
admits: (token) => {
|
|
20600
|
+
if (isLiveCapability(token, tokens)) {
|
|
20601
|
+
return true;
|
|
20602
|
+
}
|
|
20603
|
+
return reconcile() && isLiveCapability(token, tokens);
|
|
20604
|
+
},
|
|
20605
|
+
modelsOf: (sessionId) => {
|
|
20606
|
+
const held = bySessionId.get(sessionId) ?? (reconcile() ? bySessionId.get(sessionId) : void 0);
|
|
20607
|
+
return held?.models;
|
|
20608
|
+
},
|
|
20609
|
+
rescan: () => {
|
|
20610
|
+
known.clear();
|
|
20611
|
+
for (const name of recordNames()) {
|
|
20612
|
+
const stat = statOf(name);
|
|
20613
|
+
if (stat !== void 0) {
|
|
20614
|
+
load(name, stat);
|
|
20615
|
+
}
|
|
20616
|
+
}
|
|
20617
|
+
rebuildIndexes();
|
|
20618
|
+
return [...known.values()].flatMap(({ record }) => record === void 0 ? [] : [summaryOf(record)]).sort((a, b) => a.pid - b.pid);
|
|
20619
|
+
},
|
|
20620
|
+
forget: (pids) => {
|
|
20621
|
+
for (const pid of pids) {
|
|
20622
|
+
known.delete(sessionRecordName(pid));
|
|
20623
|
+
}
|
|
20624
|
+
rebuildIndexes();
|
|
20625
|
+
}
|
|
20626
|
+
};
|
|
20627
|
+
}
|
|
20628
|
+
|
|
20629
|
+
// src/index.ts
|
|
20540
20630
|
init_supervisor();
|
|
20541
20631
|
init_read();
|
|
20542
20632
|
init_schema2();
|
|
@@ -20546,7 +20636,7 @@ init_plan2();
|
|
|
20546
20636
|
init_poolPick();
|
|
20547
20637
|
|
|
20548
20638
|
// src/agents/read.ts
|
|
20549
|
-
import
|
|
20639
|
+
import path34 from "node:path";
|
|
20550
20640
|
import { z as z34 } from "zod";
|
|
20551
20641
|
var PROJECTS_DIR = "projects";
|
|
20552
20642
|
var TASKS_DIR = "tasks";
|
|
@@ -20572,15 +20662,15 @@ function parseEntry2(project, entry) {
|
|
|
20572
20662
|
}
|
|
20573
20663
|
function listSessions2(fs14, configDir) {
|
|
20574
20664
|
const found = [];
|
|
20575
|
-
for (const project of fs14.readdir(
|
|
20576
|
-
const projectDir =
|
|
20665
|
+
for (const project of fs14.readdir(path34.join(configDir, PROJECTS_DIR))) {
|
|
20666
|
+
const projectDir = path34.join(configDir, PROJECTS_DIR, project);
|
|
20577
20667
|
const entries = /* @__PURE__ */ new Set();
|
|
20578
20668
|
for (const name of fs14.readdir(projectDir)) {
|
|
20579
20669
|
if (name.endsWith(TRANSCRIPT_SUFFIX)) {
|
|
20580
20670
|
entries.add(name.slice(0, -TRANSCRIPT_SUFFIX.length));
|
|
20581
20671
|
continue;
|
|
20582
20672
|
}
|
|
20583
|
-
const children = fs14.readdir(
|
|
20673
|
+
const children = fs14.readdir(path34.join(projectDir, name));
|
|
20584
20674
|
if (children.includes(SUBAGENTS_DIR) || children.includes(WORKFLOWS_DIR)) {
|
|
20585
20675
|
entries.add(name);
|
|
20586
20676
|
}
|
|
@@ -20600,8 +20690,8 @@ function locateAgents(fs14, configDir, relativeDir, workflowRunId, report) {
|
|
|
20600
20690
|
const id = name.slice(AGENT_FILE_PREFIX.length, -META_SUFFIX.length);
|
|
20601
20691
|
located.push({
|
|
20602
20692
|
id,
|
|
20603
|
-
metaPath:
|
|
20604
|
-
transcriptPath:
|
|
20693
|
+
metaPath: path34.join(relativeDir, name),
|
|
20694
|
+
transcriptPath: path34.join(relativeDir, `${AGENT_FILE_PREFIX}${id}${TRANSCRIPT_SUFFIX}`),
|
|
20605
20695
|
workflowRunId
|
|
20606
20696
|
});
|
|
20607
20697
|
}
|
|
@@ -20644,7 +20734,7 @@ function describeFailure(error) {
|
|
|
20644
20734
|
}
|
|
20645
20735
|
function readFileOrReport(fs14, configDir, relative, report) {
|
|
20646
20736
|
try {
|
|
20647
|
-
return fs14.readFileUtf8(
|
|
20737
|
+
return fs14.readFileUtf8(path34.join(configDir, relative));
|
|
20648
20738
|
} catch (error) {
|
|
20649
20739
|
report({ path: relative, reason: `could not be read: ${describeFailure(error)}` });
|
|
20650
20740
|
return void 0;
|
|
@@ -20652,7 +20742,7 @@ function readFileOrReport(fs14, configDir, relative, report) {
|
|
|
20652
20742
|
}
|
|
20653
20743
|
function listDirOrReport(fs14, configDir, relative, report) {
|
|
20654
20744
|
try {
|
|
20655
|
-
return fs14.readdir(
|
|
20745
|
+
return fs14.readdir(path34.join(configDir, relative));
|
|
20656
20746
|
} catch (error) {
|
|
20657
20747
|
report({ path: relative, reason: `could not be listed: ${describeFailure(error)}` });
|
|
20658
20748
|
return [];
|
|
@@ -20676,18 +20766,18 @@ var WorkflowRunFileSchema = z34.object({
|
|
|
20676
20766
|
summary: z34.string().optional()
|
|
20677
20767
|
});
|
|
20678
20768
|
function summariseSession(fs14, configDir, ref) {
|
|
20679
|
-
const sessionRelative =
|
|
20680
|
-
const subagentsRelative =
|
|
20681
|
-
const workflowsUnderSubagents =
|
|
20769
|
+
const sessionRelative = path34.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
20770
|
+
const subagentsRelative = path34.join(sessionRelative, SUBAGENTS_DIR);
|
|
20771
|
+
const workflowsUnderSubagents = path34.join(subagentsRelative, WORKFLOWS_DIR);
|
|
20682
20772
|
const isMeta = (name) => name.startsWith(AGENT_FILE_PREFIX) && name.endsWith(META_SUFFIX);
|
|
20683
|
-
let agentCount = fs14.readdir(
|
|
20684
|
-
for (const runDir of fs14.readdir(
|
|
20773
|
+
let agentCount = fs14.readdir(path34.join(configDir, subagentsRelative)).filter(isMeta).length;
|
|
20774
|
+
for (const runDir of fs14.readdir(path34.join(configDir, workflowsUnderSubagents))) {
|
|
20685
20775
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
20686
|
-
agentCount += fs14.readdir(
|
|
20776
|
+
agentCount += fs14.readdir(path34.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
|
|
20687
20777
|
}
|
|
20688
20778
|
}
|
|
20689
|
-
const workflowRunCount = fs14.readdir(
|
|
20690
|
-
const transcript = fs14.lstat(
|
|
20779
|
+
const workflowRunCount = fs14.readdir(path34.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
|
|
20780
|
+
const transcript = fs14.lstat(path34.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
|
|
20691
20781
|
return { ...ref, agentCount, workflowRunCount, ...transcript === void 0 ? {} : { updatedAt: new Date(transcript.mtimeMs).toISOString() } };
|
|
20692
20782
|
}
|
|
20693
20783
|
function readSessionAgentTree(fs14, configDir, ref, options = {}) {
|
|
@@ -20695,13 +20785,13 @@ function readSessionAgentTree(fs14, configDir, ref, options = {}) {
|
|
|
20695
20785
|
const report = (problem) => {
|
|
20696
20786
|
problems.push(problem);
|
|
20697
20787
|
};
|
|
20698
|
-
const sessionRelative =
|
|
20699
|
-
const subagentsRelative =
|
|
20700
|
-
const workflowsUnderSubagents =
|
|
20788
|
+
const sessionRelative = path34.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
20789
|
+
const subagentsRelative = path34.join(sessionRelative, SUBAGENTS_DIR);
|
|
20790
|
+
const workflowsUnderSubagents = path34.join(subagentsRelative, WORKFLOWS_DIR);
|
|
20701
20791
|
const located = locateAgents(fs14, configDir, subagentsRelative, void 0, report);
|
|
20702
20792
|
for (const runDir of listDirOrReport(fs14, configDir, workflowsUnderSubagents, report)) {
|
|
20703
20793
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
20704
|
-
located.push(...locateAgents(fs14, configDir,
|
|
20794
|
+
located.push(...locateAgents(fs14, configDir, path34.join(workflowsUnderSubagents, runDir), runDir, report));
|
|
20705
20795
|
}
|
|
20706
20796
|
}
|
|
20707
20797
|
const agents = /* @__PURE__ */ new Map();
|
|
@@ -20742,7 +20832,7 @@ function readSessionAgentTree(fs14, configDir, ref, options = {}) {
|
|
|
20742
20832
|
superseded: ref.superseded,
|
|
20743
20833
|
agents: roots.sort().map(build),
|
|
20744
20834
|
tasks: readTasks(fs14, configDir, ownTaskLists(ref.sessionId), [.../* @__PURE__ */ new Set([...teamNames, ...options.taskListIds ?? []])].filter((id) => !ownTaskLists(ref.sessionId).includes(id)), report),
|
|
20745
|
-
workflowRuns: readWorkflowRuns(fs14, configDir,
|
|
20835
|
+
workflowRuns: readWorkflowRuns(fs14, configDir, path34.join(sessionRelative, WORKFLOWS_DIR), report),
|
|
20746
20836
|
problems
|
|
20747
20837
|
};
|
|
20748
20838
|
}
|
|
@@ -20807,12 +20897,12 @@ function ownTaskLists(sessionId) {
|
|
|
20807
20897
|
function readTasks(fs14, configDir, ownLists, sharedLists, report) {
|
|
20808
20898
|
const tasks = [];
|
|
20809
20899
|
[...ownLists, ...sharedLists].forEach((scope, index) => {
|
|
20810
|
-
const relativeDir =
|
|
20900
|
+
const relativeDir = path34.join(TASKS_DIR, scope);
|
|
20811
20901
|
for (const name of [...listDirOrReport(fs14, configDir, relativeDir, report)].sort()) {
|
|
20812
20902
|
if (name.startsWith(".") || !name.endsWith(JSON_SUFFIX)) {
|
|
20813
20903
|
continue;
|
|
20814
20904
|
}
|
|
20815
|
-
const relative =
|
|
20905
|
+
const relative = path34.join(relativeDir, name);
|
|
20816
20906
|
const text = readFileOrReport(fs14, configDir, relative, report);
|
|
20817
20907
|
const parsed = TaskFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
20818
20908
|
if (parsed.success) {
|
|
@@ -20830,7 +20920,7 @@ function readWorkflowRuns(fs14, configDir, relativeDir, report) {
|
|
|
20830
20920
|
if (!name.startsWith(WORKFLOW_RUN_PREFIX) || !name.endsWith(JSON_SUFFIX)) {
|
|
20831
20921
|
continue;
|
|
20832
20922
|
}
|
|
20833
|
-
const relative =
|
|
20923
|
+
const relative = path34.join(relativeDir, name);
|
|
20834
20924
|
const text = readFileOrReport(fs14, configDir, relative, report);
|
|
20835
20925
|
const parsed = WorkflowRunFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
20836
20926
|
if (!parsed.success) {
|
|
@@ -20847,7 +20937,7 @@ function readWorkflowRuns(fs14, configDir, relativeDir, report) {
|
|
|
20847
20937
|
|
|
20848
20938
|
// src/agents/sessions.ts
|
|
20849
20939
|
init_cliError();
|
|
20850
|
-
import
|
|
20940
|
+
import path35 from "node:path";
|
|
20851
20941
|
var SessionLookupError = class extends CliError {
|
|
20852
20942
|
constructor(message) {
|
|
20853
20943
|
super(message);
|
|
@@ -20855,13 +20945,13 @@ var SessionLookupError = class extends CliError {
|
|
|
20855
20945
|
}
|
|
20856
20946
|
};
|
|
20857
20947
|
function identityConfigDir(identitiesDir, identity) {
|
|
20858
|
-
return
|
|
20948
|
+
return path35.join(identitiesDir, identity);
|
|
20859
20949
|
}
|
|
20860
20950
|
function historyStores(fs14, identitiesDir, identities) {
|
|
20861
20951
|
const byRealPath = /* @__PURE__ */ new Map();
|
|
20862
20952
|
for (const identity of identities) {
|
|
20863
20953
|
const configDir = identityConfigDir(identitiesDir, identity);
|
|
20864
|
-
const real = fs14.realpath(
|
|
20954
|
+
const real = fs14.realpath(path35.join(configDir, "projects"));
|
|
20865
20955
|
if (real === void 0) {
|
|
20866
20956
|
continue;
|
|
20867
20957
|
}
|
|
@@ -21266,6 +21356,7 @@ export {
|
|
|
21266
21356
|
createLaunchEventPublisher,
|
|
21267
21357
|
createLeafCache,
|
|
21268
21358
|
createLifecycleApiRouter,
|
|
21359
|
+
createLiveSessionRegistry,
|
|
21269
21360
|
createProfile,
|
|
21270
21361
|
createQuotaExpiringPublisher,
|
|
21271
21362
|
createRcApiNodeHandler,
|