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.cjs
CHANGED
|
@@ -1278,7 +1278,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
|
|
|
1278
1278
|
return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
|
|
1279
1279
|
}
|
|
1280
1280
|
function describeIgnoredKeys(filePath, ignored) {
|
|
1281
|
-
const places = ignored.map(({ path:
|
|
1281
|
+
const places = ignored.map(({ path: path42, keys }) => `${path42.length === 0 ? "" : `${path42.map(String).join(".")}.`}${keys.join(", ")}`);
|
|
1282
1282
|
return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
|
|
1283
1283
|
}
|
|
1284
1284
|
function noteIgnoredKeys(filePath, ignored) {
|
|
@@ -1300,9 +1300,9 @@ function restoreIgnoredKeys(filePath, value) {
|
|
|
1300
1300
|
return value;
|
|
1301
1301
|
}
|
|
1302
1302
|
const restored = structuredClone(value);
|
|
1303
|
-
for (const { path:
|
|
1303
|
+
for (const { path: path42, values } of ignored) {
|
|
1304
1304
|
let holder = restored;
|
|
1305
|
-
for (const step of
|
|
1305
|
+
for (const step of path42) {
|
|
1306
1306
|
holder = isRecord(holder) ? holder[step] : void 0;
|
|
1307
1307
|
}
|
|
1308
1308
|
if (isRecord(holder)) {
|
|
@@ -3933,28 +3933,38 @@ function recordOf(details) {
|
|
|
3933
3933
|
}
|
|
3934
3934
|
function writeFrontDoorSession(fs14, sessionsDir, session) {
|
|
3935
3935
|
fs14.mkdirPrivate(sessionsDir);
|
|
3936
|
-
fs14.writeFilePrivate(import_node_path9.default.join(sessionsDir,
|
|
3936
|
+
fs14.writeFilePrivate(import_node_path9.default.join(sessionsDir, sessionRecordName(session.pid)), `${JSON.stringify(session, null, 2)}
|
|
3937
3937
|
`);
|
|
3938
3938
|
}
|
|
3939
|
+
function sessionRecordName(pid) {
|
|
3940
|
+
return `${String(pid)}.json`;
|
|
3941
|
+
}
|
|
3942
|
+
function isSessionRecordName(name) {
|
|
3943
|
+
return name.endsWith(".json");
|
|
3944
|
+
}
|
|
3945
|
+
function summaryOf(session) {
|
|
3946
|
+
return { pid: session.pid, startedAt: session.startedAt, ...session.supervisorPid === void 0 ? {} : { supervisorPid: session.supervisorPid } };
|
|
3947
|
+
}
|
|
3948
|
+
function readFrontDoorSessionRecord(fs14, sessionsDir, name) {
|
|
3949
|
+
try {
|
|
3950
|
+
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs14.readFileUtf8(import_node_path9.default.join(sessionsDir, name)) ?? ""));
|
|
3951
|
+
return parsed.success ? parsed.data : void 0;
|
|
3952
|
+
} catch {
|
|
3953
|
+
return void 0;
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
3939
3956
|
function listFrontDoorSessions(fs14, sessionsDir) {
|
|
3940
3957
|
const sessions = [];
|
|
3941
3958
|
for (const name of fs14.readdir(sessionsDir)) {
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
try {
|
|
3946
|
-
const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs14.readFileUtf8(import_node_path9.default.join(sessionsDir, name)) ?? ""));
|
|
3947
|
-
if (parsed.success) {
|
|
3948
|
-
sessions.push({ pid: parsed.data.pid, startedAt: parsed.data.startedAt, ...parsed.data.supervisorPid === void 0 ? {} : { supervisorPid: parsed.data.supervisorPid } });
|
|
3949
|
-
}
|
|
3950
|
-
} catch {
|
|
3951
|
-
continue;
|
|
3959
|
+
const record = isSessionRecordName(name) ? readFrontDoorSessionRecord(fs14, sessionsDir, name) : void 0;
|
|
3960
|
+
if (record !== void 0) {
|
|
3961
|
+
sessions.push(summaryOf(record));
|
|
3952
3962
|
}
|
|
3953
3963
|
}
|
|
3954
3964
|
return sessions.sort((a, b) => a.pid - b.pid);
|
|
3955
3965
|
}
|
|
3956
3966
|
function removeFrontDoorSession(fs14, sessionsDir, pid) {
|
|
3957
|
-
fs14.removeRecursive(import_node_path9.default.join(sessionsDir,
|
|
3967
|
+
fs14.removeRecursive(import_node_path9.default.join(sessionsDir, sessionRecordName(pid)));
|
|
3958
3968
|
}
|
|
3959
3969
|
function pruneDeadFrontDoorSessions(fs14, sessionsDir, listed, isRunning) {
|
|
3960
3970
|
const removed = [];
|
|
@@ -4214,9 +4224,10 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
|
|
|
4214
4224
|
return FRONTDOOR_SUPERVISOR_STILL_RUNNING;
|
|
4215
4225
|
}
|
|
4216
4226
|
ticks += 1;
|
|
4217
|
-
const listed =
|
|
4227
|
+
const listed = ports.registry.rescan();
|
|
4218
4228
|
const running = await ports.runningAmong(listed.map((session) => session.pid));
|
|
4219
4229
|
const pruned = pruneDeadFrontDoorSessions(fs14, paths.frontdoorSessionsDir, listed, (pid) => running.has(pid));
|
|
4230
|
+
ports.registry.forget(pruned);
|
|
4220
4231
|
ports.observeLaunchRegistry(listed, pruned);
|
|
4221
4232
|
ports.checkQuotaExpiry();
|
|
4222
4233
|
const prunedPids = new Set(pruned);
|
|
@@ -4289,8 +4300,8 @@ function parseConnectTarget(authority) {
|
|
|
4289
4300
|
function isInterceptedHost(host, interceptHosts) {
|
|
4290
4301
|
return interceptHosts.includes(host);
|
|
4291
4302
|
}
|
|
4292
|
-
function servedByPipeline(
|
|
4293
|
-
return
|
|
4303
|
+
function servedByPipeline(path42) {
|
|
4304
|
+
return path42?.startsWith(ROUTED_PATH_PREFIX) === true;
|
|
4294
4305
|
}
|
|
4295
4306
|
function forwardableHeaders(headers) {
|
|
4296
4307
|
const connectionTokens = new Set(
|
|
@@ -4736,7 +4747,7 @@ var init_package = __esm({
|
|
|
4736
4747
|
"package.json"() {
|
|
4737
4748
|
package_default = {
|
|
4738
4749
|
name: "claude-use",
|
|
4739
|
-
version: "11.65.
|
|
4750
|
+
version: "11.65.2",
|
|
4740
4751
|
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.",
|
|
4741
4752
|
license: "MIT",
|
|
4742
4753
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -4788,9 +4799,9 @@ var init_package = __esm({
|
|
|
4788
4799
|
"@anthropic-ai/claude-agent-sdk": "0.3.292",
|
|
4789
4800
|
"@clack/prompts": "^1.8.0",
|
|
4790
4801
|
"@modelcontextprotocol/sdk": "1.32.0",
|
|
4791
|
-
"@orpc/client": "2.0.0-beta.
|
|
4792
|
-
"@orpc/openapi": "2.0.0-beta.
|
|
4793
|
-
"@orpc/server": "2.0.0-beta.
|
|
4802
|
+
"@orpc/client": "2.0.0-beta.43",
|
|
4803
|
+
"@orpc/openapi": "2.0.0-beta.43",
|
|
4804
|
+
"@orpc/server": "2.0.0-beta.43",
|
|
4794
4805
|
commander: "^15.0.0",
|
|
4795
4806
|
cosmiconfig: "^10.0.1",
|
|
4796
4807
|
picomatch: "^4.0.7",
|
|
@@ -7942,9 +7953,9 @@ var init_poolPick = __esm({
|
|
|
7942
7953
|
});
|
|
7943
7954
|
|
|
7944
7955
|
// src/statusline/keys.ts
|
|
7945
|
-
function valueAt(source,
|
|
7956
|
+
function valueAt(source, path42) {
|
|
7946
7957
|
let current = source;
|
|
7947
|
-
for (const part of
|
|
7958
|
+
for (const part of path42) {
|
|
7948
7959
|
if (!isPlainObject(current)) {
|
|
7949
7960
|
return void 0;
|
|
7950
7961
|
}
|
|
@@ -7952,10 +7963,10 @@ function valueAt(source, path41) {
|
|
|
7952
7963
|
}
|
|
7953
7964
|
return current;
|
|
7954
7965
|
}
|
|
7955
|
-
function keyOf(
|
|
7966
|
+
function keyOf(path42, declared) {
|
|
7956
7967
|
const optional = declared instanceof import_zod16.z.ZodOptional;
|
|
7957
7968
|
const leaf = optional ? declared.unwrap() : declared;
|
|
7958
|
-
const common = { path:
|
|
7969
|
+
const common = { path: path42.join("."), description: declared.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path42), optional };
|
|
7959
7970
|
if (leaf instanceof import_zod16.z.ZodNumber) {
|
|
7960
7971
|
return { ...common, kind: "integer", choices: [] };
|
|
7961
7972
|
}
|
|
@@ -7980,7 +7991,7 @@ function keyOf(path41, declared) {
|
|
|
7980
7991
|
if (leaf instanceof import_zod16.z.ZodArray && leaf.element instanceof import_zod16.z.ZodString) {
|
|
7981
7992
|
return { ...common, kind: "textList", choices: [] };
|
|
7982
7993
|
}
|
|
7983
|
-
throw new TypeError(`statusline setting ${
|
|
7994
|
+
throw new TypeError(`statusline setting ${path42.join(".")} has a kind the key listing does not describe`);
|
|
7984
7995
|
}
|
|
7985
7996
|
function walk(shape, prefix) {
|
|
7986
7997
|
return Object.entries(shape).flatMap(([name, schema]) => schema instanceof import_zod16.z.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
|
|
@@ -7998,15 +8009,15 @@ var init_keys = __esm({
|
|
|
7998
8009
|
});
|
|
7999
8010
|
|
|
8000
8011
|
// src/statusline/change.ts
|
|
8001
|
-
function keyNamed(
|
|
8002
|
-
const found = statuslineKeys().find((key) => key.path ===
|
|
8012
|
+
function keyNamed(path42) {
|
|
8013
|
+
const found = statuslineKeys().find((key) => key.path === path42);
|
|
8003
8014
|
if (found === void 0) {
|
|
8004
|
-
throw new UsageError(`"${
|
|
8015
|
+
throw new UsageError(`"${path42}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
|
|
8005
8016
|
}
|
|
8006
8017
|
return found;
|
|
8007
8018
|
}
|
|
8008
|
-
function setAt(target,
|
|
8009
|
-
const [head, ...rest] =
|
|
8019
|
+
function setAt(target, path42, value) {
|
|
8020
|
+
const [head, ...rest] = path42;
|
|
8010
8021
|
if (head === void 0) {
|
|
8011
8022
|
return;
|
|
8012
8023
|
}
|
|
@@ -8019,8 +8030,8 @@ function setAt(target, path41, value) {
|
|
|
8019
8030
|
target[head] = next;
|
|
8020
8031
|
setAt(next, rest, value);
|
|
8021
8032
|
}
|
|
8022
|
-
function removeAt(target,
|
|
8023
|
-
const [head, ...rest] =
|
|
8033
|
+
function removeAt(target, path42) {
|
|
8034
|
+
const [head, ...rest] = path42;
|
|
8024
8035
|
if (head === void 0) {
|
|
8025
8036
|
return;
|
|
8026
8037
|
}
|
|
@@ -8038,13 +8049,13 @@ function removeAt(target, path41) {
|
|
|
8038
8049
|
}
|
|
8039
8050
|
function applyStatuslineChange(existing, change) {
|
|
8040
8051
|
const draft = structuredClone(existing ?? {});
|
|
8041
|
-
for (const [
|
|
8042
|
-
keyNamed(
|
|
8043
|
-
setAt(draft,
|
|
8052
|
+
for (const [path42, value] of Object.entries(change.set ?? {})) {
|
|
8053
|
+
keyNamed(path42);
|
|
8054
|
+
setAt(draft, path42.split("."), value);
|
|
8044
8055
|
}
|
|
8045
|
-
for (const
|
|
8046
|
-
keyNamed(
|
|
8047
|
-
removeAt(draft,
|
|
8056
|
+
for (const path42 of change.unset ?? []) {
|
|
8057
|
+
keyNamed(path42);
|
|
8058
|
+
removeAt(draft, path42.split("."));
|
|
8048
8059
|
}
|
|
8049
8060
|
const result = StatuslineSchema.safeParse(draft);
|
|
8050
8061
|
if (!result.success) {
|
|
@@ -10837,7 +10848,7 @@ function buildEnv(params) {
|
|
|
10837
10848
|
const parentCustomHeaders = params.baseEnv.ANTHROPIC_CUSTOM_HEADERS;
|
|
10838
10849
|
let providerCustomHeaders;
|
|
10839
10850
|
if (!params.configDirEscapeHatch && params.resolvedIdentityName !== void 0) {
|
|
10840
|
-
env.CLAUDE_CONFIG_DIR =
|
|
10851
|
+
env.CLAUDE_CONFIG_DIR = import_node_path36.default.join(params.identitiesDir, params.resolvedIdentityName);
|
|
10841
10852
|
}
|
|
10842
10853
|
if (params.provider !== void 0) {
|
|
10843
10854
|
const providerEnv = params.provider.definition.kind !== void 0 && params.provider.definition.kind !== "http" ? {} : params.provider.definition.env ?? {};
|
|
@@ -10891,11 +10902,11 @@ function buildEnv(params) {
|
|
|
10891
10902
|
}
|
|
10892
10903
|
return env;
|
|
10893
10904
|
}
|
|
10894
|
-
var
|
|
10905
|
+
var import_node_path36, LOOPBACK_HOSTS, PROVIDER_SESSION_PLACEHOLDER;
|
|
10895
10906
|
var init_flags = __esm({
|
|
10896
10907
|
"src/launcher/flags.ts"() {
|
|
10897
10908
|
"use strict";
|
|
10898
|
-
|
|
10909
|
+
import_node_path36 = __toESM(require("node:path"), 1);
|
|
10899
10910
|
init_envBool();
|
|
10900
10911
|
init_cliError();
|
|
10901
10912
|
init_conditions();
|
|
@@ -10987,7 +10998,7 @@ function newestTranscript(fs14, projectDir) {
|
|
|
10987
10998
|
if (!name.endsWith(".jsonl")) {
|
|
10988
10999
|
continue;
|
|
10989
11000
|
}
|
|
10990
|
-
const candidate =
|
|
11001
|
+
const candidate = import_node_path37.default.join(projectDir, name);
|
|
10991
11002
|
const stat = fs14.lstat(candidate);
|
|
10992
11003
|
if (stat?.kind === "file" && stat.mtimeMs > newestMs) {
|
|
10993
11004
|
newestMs = stat.mtimeMs;
|
|
@@ -11001,16 +11012,16 @@ function resumedContextTokens(fs14, params) {
|
|
|
11001
11012
|
if (target === void 0) {
|
|
11002
11013
|
return void 0;
|
|
11003
11014
|
}
|
|
11004
|
-
const projectDir =
|
|
11005
|
-
const file = target.kind === "id" ?
|
|
11015
|
+
const projectDir = import_node_path37.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
|
|
11016
|
+
const file = target.kind === "id" ? import_node_path37.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs14, projectDir);
|
|
11006
11017
|
const text = file === void 0 ? void 0 : fs14.readFileUtf8(file);
|
|
11007
11018
|
return text === void 0 ? void 0 : contextTokensOfTranscript(text);
|
|
11008
11019
|
}
|
|
11009
|
-
var
|
|
11020
|
+
var import_node_path37;
|
|
11010
11021
|
var init_resumeContext = __esm({
|
|
11011
11022
|
"src/usage/resumeContext.ts"() {
|
|
11012
11023
|
"use strict";
|
|
11013
|
-
|
|
11024
|
+
import_node_path37 = __toESM(require("node:path"), 1);
|
|
11014
11025
|
}
|
|
11015
11026
|
});
|
|
11016
11027
|
|
|
@@ -11689,7 +11700,7 @@ function decideLaunch(params, readOnly) {
|
|
|
11689
11700
|
extraFlags: splitExtraFlags(env.CLAUDE_EXTRA_FLAGS),
|
|
11690
11701
|
passthrough: withLauncherSettings(params.supervised === void 0 ? parsedArgv.rest : withSupervision(parsedArgv.rest, params.supervised), launcherSettings)
|
|
11691
11702
|
});
|
|
11692
|
-
const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR :
|
|
11703
|
+
const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path38.default.join(paths.identitiesDir, identityDecision.name);
|
|
11693
11704
|
const decision = {
|
|
11694
11705
|
identitySource: identityDecision.source,
|
|
11695
11706
|
configDirEscapeHatch: identityDecision.configDirEscapeHatch,
|
|
@@ -11742,7 +11753,7 @@ function prepareLaunch(params) {
|
|
|
11742
11753
|
let warnings = [];
|
|
11743
11754
|
const updateCheck = runLaunchUpdateCheck({
|
|
11744
11755
|
mode: params.updateMode ?? "off",
|
|
11745
|
-
checkPath:
|
|
11756
|
+
checkPath: import_node_path38.default.join(paths.root, "update.check"),
|
|
11746
11757
|
currentVersion: package_default.version,
|
|
11747
11758
|
port: params.update
|
|
11748
11759
|
});
|
|
@@ -11889,13 +11900,13 @@ function runLaunchPlan(plan, spawn3) {
|
|
|
11889
11900
|
function runLauncher(params) {
|
|
11890
11901
|
params.proc.exit(runLaunchPlan(prepareLaunch(params), params.spawn));
|
|
11891
11902
|
}
|
|
11892
|
-
var import_node_crypto11, import_node_util2,
|
|
11903
|
+
var import_node_crypto11, import_node_util2, import_node_path38;
|
|
11893
11904
|
var init_launcher = __esm({
|
|
11894
11905
|
"src/launcher.ts"() {
|
|
11895
11906
|
"use strict";
|
|
11896
11907
|
import_node_crypto11 = require("node:crypto");
|
|
11897
11908
|
import_node_util2 = require("node:util");
|
|
11898
|
-
|
|
11909
|
+
import_node_path38 = __toESM(require("node:path"), 1);
|
|
11899
11910
|
init_package();
|
|
11900
11911
|
init_envBool();
|
|
11901
11912
|
init_argv();
|
|
@@ -11938,13 +11949,13 @@ function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string"
|
|
|
11938
11949
|
if (distDir === void 0) {
|
|
11939
11950
|
throw new OwnCliPathUnknownError();
|
|
11940
11951
|
}
|
|
11941
|
-
return
|
|
11952
|
+
return import_node_path39.default.join(distDir, OWN_CLI_FILE_NAME);
|
|
11942
11953
|
}
|
|
11943
|
-
var
|
|
11954
|
+
var import_node_path39, OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
|
|
11944
11955
|
var init_ownCli = __esm({
|
|
11945
11956
|
"src/ownCli.ts"() {
|
|
11946
11957
|
"use strict";
|
|
11947
|
-
|
|
11958
|
+
import_node_path39 = __toESM(require("node:path"), 1);
|
|
11948
11959
|
init_cliError();
|
|
11949
11960
|
OWN_CLI_FILE_NAME = "cli.cjs";
|
|
11950
11961
|
OwnCliPathUnknownError = class extends CliError {
|
|
@@ -11987,7 +11998,7 @@ var init_selfIdentity = __esm({
|
|
|
11987
11998
|
// src/frontdoor/trust.ts
|
|
11988
11999
|
function resolveTrustBundle(params) {
|
|
11989
12000
|
const { caCertFile, bundlesDir, variable, inherited, fs: fs14 } = params;
|
|
11990
|
-
if (inherited === void 0 || inherited === "" ||
|
|
12001
|
+
if (inherited === void 0 || inherited === "" || import_node_path40.default.resolve(inherited) === import_node_path40.default.resolve(caCertFile)) {
|
|
11991
12002
|
return { path: caCertFile };
|
|
11992
12003
|
}
|
|
11993
12004
|
const caPem = fs14.readFileUtf8(caCertFile);
|
|
@@ -12005,19 +12016,19 @@ function resolveTrustBundle(params) {
|
|
|
12005
12016
|
}
|
|
12006
12017
|
const combined = `${inheritedPem.trimEnd()}
|
|
12007
12018
|
${caPem}`;
|
|
12008
|
-
const bundle =
|
|
12019
|
+
const bundle = import_node_path40.default.join(bundlesDir, `${(0, import_node_crypto12.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
|
|
12009
12020
|
if (!fs14.exists(bundle)) {
|
|
12010
12021
|
fs14.mkdirp(bundlesDir);
|
|
12011
12022
|
fs14.writeFileAtomic(bundle, combined);
|
|
12012
12023
|
}
|
|
12013
12024
|
return { path: bundle };
|
|
12014
12025
|
}
|
|
12015
|
-
var import_node_crypto12,
|
|
12026
|
+
var import_node_crypto12, import_node_path40, BUNDLE_NAME_HEX_DIGITS;
|
|
12016
12027
|
var init_trust = __esm({
|
|
12017
12028
|
"src/frontdoor/trust.ts"() {
|
|
12018
12029
|
"use strict";
|
|
12019
12030
|
import_node_crypto12 = require("node:crypto");
|
|
12020
|
-
|
|
12031
|
+
import_node_path40 = __toESM(require("node:path"), 1);
|
|
12021
12032
|
BUNDLE_NAME_HEX_DIGITS = 16;
|
|
12022
12033
|
}
|
|
12023
12034
|
});
|
|
@@ -12192,7 +12203,7 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
12192
12203
|
frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
|
|
12193
12204
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
12194
12205
|
hold: realHoldPort,
|
|
12195
|
-
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot:
|
|
12206
|
+
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: import_node_path41.default.join(paths.identitiesDir, identity), hasCredentialBlock: false }).state !== "signed-out",
|
|
12196
12207
|
...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
|
|
12197
12208
|
...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
|
|
12198
12209
|
...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
|
|
@@ -12251,12 +12262,12 @@ function resolveClaudeLaunch(options, run = realRunPort) {
|
|
|
12251
12262
|
};
|
|
12252
12263
|
return { resolution: resolveLaunch(realPrepareLaunchParams(paths, { proc, log, spawnDaemon, run, farm: buildFarmRuntime(paths, options.cwd, run) })), warnings };
|
|
12253
12264
|
}
|
|
12254
|
-
var import_node_os7,
|
|
12265
|
+
var import_node_os7, import_node_path41, import_node_crypto13, LaunchRefusedError;
|
|
12255
12266
|
var init_launchWiring = __esm({
|
|
12256
12267
|
"src/launchWiring.ts"() {
|
|
12257
12268
|
"use strict";
|
|
12258
12269
|
import_node_os7 = __toESM(require("node:os"), 1);
|
|
12259
|
-
|
|
12270
|
+
import_node_path41 = __toESM(require("node:path"), 1);
|
|
12260
12271
|
import_node_crypto13 = require("node:crypto");
|
|
12261
12272
|
init_cliError();
|
|
12262
12273
|
init_claudeShim();
|
|
@@ -12859,6 +12870,7 @@ __export(index_exports, {
|
|
|
12859
12870
|
createLaunchEventPublisher: () => createLaunchEventPublisher,
|
|
12860
12871
|
createLeafCache: () => createLeafCache,
|
|
12861
12872
|
createLifecycleApiRouter: () => createLifecycleApiRouter,
|
|
12873
|
+
createLiveSessionRegistry: () => createLiveSessionRegistry,
|
|
12862
12874
|
createProfile: () => createProfile,
|
|
12863
12875
|
createQuotaExpiringPublisher: () => createQuotaExpiringPublisher,
|
|
12864
12876
|
createRcApiNodeHandler: () => createRcApiNodeHandler,
|
|
@@ -13472,11 +13484,11 @@ function createRcSessionTracker(deps) {
|
|
|
13472
13484
|
};
|
|
13473
13485
|
const observeExchange = (request4) => {
|
|
13474
13486
|
const method = (request4.method ?? "").toUpperCase();
|
|
13475
|
-
const
|
|
13476
|
-
if (!
|
|
13487
|
+
const path42 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
|
|
13488
|
+
if (!path42.startsWith(RC_SESSIONS_PATH_PREFIX)) {
|
|
13477
13489
|
return void 0;
|
|
13478
13490
|
}
|
|
13479
|
-
const tail =
|
|
13491
|
+
const tail = path42.slice(RC_SESSIONS_PATH_PREFIX.length);
|
|
13480
13492
|
const facts = {
|
|
13481
13493
|
oauthAuthorization: oauthAuthorizationOf(request4.headers),
|
|
13482
13494
|
anthropicVersion: singleHeader(request4.headers, "anthropic-version"),
|
|
@@ -13593,7 +13605,7 @@ function createRcSessionTracker(deps) {
|
|
|
13593
13605
|
}
|
|
13594
13606
|
};
|
|
13595
13607
|
};
|
|
13596
|
-
const
|
|
13608
|
+
const summaryOf2 = ({ id, createdAt, lastSeenAt }) => ({ id, createdAt, lastSeenAt });
|
|
13597
13609
|
const pendingSummaryOf = ({ sessionId, requestId, type, summary, observedAt: observedAt2 }) => ({ sessionId, requestId, type, summary, observedAt: observedAt2 });
|
|
13598
13610
|
const sortedEntries = () => [...entries.values()].sort((left, right) => left.createdAt - right.createdAt || (left.id < right.id ? -1 : 1));
|
|
13599
13611
|
const pendingSorted = (entry) => [...entry.pending.values()].sort((left, right) => left.observedAt - right.observedAt || (left.requestId < right.requestId ? -1 : 1)).map(pendingSummaryOf);
|
|
@@ -13601,11 +13613,11 @@ function createRcSessionTracker(deps) {
|
|
|
13601
13613
|
observeExchange,
|
|
13602
13614
|
list: () => {
|
|
13603
13615
|
sweep();
|
|
13604
|
-
return sortedEntries().map(
|
|
13616
|
+
return sortedEntries().map(summaryOf2);
|
|
13605
13617
|
},
|
|
13606
13618
|
statusOf: (sessionId) => {
|
|
13607
13619
|
sweep();
|
|
13608
|
-
return sortedEntries().filter((entry) => sessionId === void 0 || entry.id === sessionId).map((entry) => ({ ...
|
|
13620
|
+
return sortedEntries().filter((entry) => sessionId === void 0 || entry.id === sessionId).map((entry) => ({ ...summaryOf2(entry), workerState: entry.workerState, workerIdleSeconds: entry.workerIdleSeconds, pending: pendingSorted(entry) }));
|
|
13609
13621
|
},
|
|
13610
13622
|
pendingOf: (sessionId) => {
|
|
13611
13623
|
sweep();
|
|
@@ -13866,8 +13878,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
|
|
|
13866
13878
|
function isRcReadFileEncoding(value) {
|
|
13867
13879
|
return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
|
|
13868
13880
|
}
|
|
13869
|
-
function buildRcReadFilePayload(requestId,
|
|
13870
|
-
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path:
|
|
13881
|
+
function buildRcReadFilePayload(requestId, path42, options) {
|
|
13882
|
+
return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path42, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
|
|
13871
13883
|
}
|
|
13872
13884
|
function buildRcFileSuggestionsPayload(requestId, query) {
|
|
13873
13885
|
return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
|
|
@@ -13969,15 +13981,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
|
|
|
13969
13981
|
const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
|
|
13970
13982
|
return result.ok ? { ...result, requestId } : result;
|
|
13971
13983
|
}
|
|
13972
|
-
async function readRcSessionFile(deps, sessionId,
|
|
13973
|
-
if (
|
|
13984
|
+
async function readRcSessionFile(deps, sessionId, path42, options) {
|
|
13985
|
+
if (path42 === "") {
|
|
13974
13986
|
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" };
|
|
13975
13987
|
}
|
|
13976
13988
|
if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
|
|
13977
13989
|
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" };
|
|
13978
13990
|
}
|
|
13979
13991
|
const requestId = deps.newUuid();
|
|
13980
|
-
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId,
|
|
13992
|
+
const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path42, options), `read ${path42} from session ${sessionId}`);
|
|
13981
13993
|
return result.ok ? { ...result, requestId } : result;
|
|
13982
13994
|
}
|
|
13983
13995
|
async function suggestRcSessionFiles(deps, sessionId, query) {
|
|
@@ -14146,11 +14158,11 @@ function createRcControlHandler(deps) {
|
|
|
14146
14158
|
path: "read-file",
|
|
14147
14159
|
read: (body) => {
|
|
14148
14160
|
const session = bodyString(body, "session");
|
|
14149
|
-
const
|
|
14161
|
+
const path42 = bodyString(body, "path");
|
|
14150
14162
|
const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
|
|
14151
14163
|
const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
|
|
14152
|
-
const refused2 = session === void 0 ||
|
|
14153
|
-
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,
|
|
14164
|
+
const refused2 = session === void 0 || path42 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
|
|
14165
|
+
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 } }) };
|
|
14154
14166
|
}
|
|
14155
14167
|
},
|
|
14156
14168
|
{
|
|
@@ -14460,9 +14472,9 @@ function requestIdOfBody(body) {
|
|
|
14460
14472
|
}
|
|
14461
14473
|
function frontDoorRcControl(transport, token) {
|
|
14462
14474
|
const headers = { authorization: `Bearer ${token}` };
|
|
14463
|
-
const listAnswerOf = async (
|
|
14475
|
+
const listAnswerOf = async (path42, what) => {
|
|
14464
14476
|
try {
|
|
14465
|
-
return await transport.request({ method: "GET", path:
|
|
14477
|
+
return await transport.request({ method: "GET", path: path42, headers });
|
|
14466
14478
|
} catch (error) {
|
|
14467
14479
|
throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
14468
14480
|
}
|
|
@@ -14534,10 +14546,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
14534
14546
|
}
|
|
14535
14547
|
return pending;
|
|
14536
14548
|
};
|
|
14537
|
-
const writeOf = async (
|
|
14549
|
+
const writeOf = async (path42, body, describeFailure2) => {
|
|
14538
14550
|
let answer;
|
|
14539
14551
|
try {
|
|
14540
|
-
answer = await transport.request({ method: "POST", path:
|
|
14552
|
+
answer = await transport.request({ method: "POST", path: path42, headers: { ...headers, "content-type": "application/json" }, body });
|
|
14541
14553
|
} catch (error) {
|
|
14542
14554
|
return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
|
|
14543
14555
|
}
|
|
@@ -14568,10 +14580,10 @@ function frontDoorRcControl(transport, token) {
|
|
|
14568
14580
|
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}`),
|
|
14569
14581
|
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}`),
|
|
14570
14582
|
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}`),
|
|
14571
|
-
readFile: async (sessionId,
|
|
14583
|
+
readFile: async (sessionId, path42, options) => await writeOf(
|
|
14572
14584
|
`${CONTROL_PATH_PREFIX}/read-file`,
|
|
14573
|
-
JSON.stringify({ session: sessionId, path:
|
|
14574
|
-
(status, message) => `reading ${
|
|
14585
|
+
JSON.stringify({ session: sessionId, path: path42, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
|
|
14586
|
+
(status, message) => `reading ${path42} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
|
|
14575
14587
|
),
|
|
14576
14588
|
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}`),
|
|
14577
14589
|
keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
|
|
@@ -14730,12 +14742,12 @@ function tlsFacts(options) {
|
|
|
14730
14742
|
}
|
|
14731
14743
|
function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
14732
14744
|
const agent = new ExemptTlsAgent();
|
|
14733
|
-
const post = async (
|
|
14745
|
+
const post = async (path42, headers, body) => await new Promise((resolve, reject) => {
|
|
14734
14746
|
const options = {
|
|
14735
14747
|
host: target.host,
|
|
14736
14748
|
port: target.port,
|
|
14737
14749
|
method: "POST",
|
|
14738
|
-
path:
|
|
14750
|
+
path: path42,
|
|
14739
14751
|
// 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.
|
|
14740
14752
|
headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
|
|
14741
14753
|
agent
|
|
@@ -14800,12 +14812,12 @@ function lateRcStreamDial(resolve) {
|
|
|
14800
14812
|
}
|
|
14801
14813
|
function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
|
|
14802
14814
|
const agent = new ExemptTlsAgent();
|
|
14803
|
-
const request4 = async (method,
|
|
14815
|
+
const request4 = async (method, path42, headers, body, signal) => await new Promise((resolve, reject) => {
|
|
14804
14816
|
const options = {
|
|
14805
14817
|
host: target.host,
|
|
14806
14818
|
port: target.port,
|
|
14807
14819
|
method,
|
|
14808
|
-
path:
|
|
14820
|
+
path: path42,
|
|
14809
14821
|
// 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.
|
|
14810
14822
|
headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
|
|
14811
14823
|
agent,
|
|
@@ -14847,9 +14859,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
|
|
|
14847
14859
|
return { status, body: await readAll(response) };
|
|
14848
14860
|
},
|
|
14849
14861
|
openStream: async (sessionId, headers, resume, signal) => {
|
|
14850
|
-
const
|
|
14862
|
+
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)}`;
|
|
14851
14863
|
const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
|
|
14852
|
-
const { status, response } = await request4("GET",
|
|
14864
|
+
const { status, response } = await request4("GET", path42, streamHeaders, void 0, signal);
|
|
14853
14865
|
if (!isSuccessful2(status)) {
|
|
14854
14866
|
await readAll(response);
|
|
14855
14867
|
return { status, chunks: NO_CHUNKS };
|
|
@@ -15842,19 +15854,19 @@ function writePools(paths, pools) {
|
|
|
15842
15854
|
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
|
|
15843
15855
|
}
|
|
15844
15856
|
function poolCycleOf(pools, name) {
|
|
15845
|
-
const walk2 = (current,
|
|
15857
|
+
const walk2 = (current, path42) => {
|
|
15846
15858
|
for (const entry of pools[current]?.identities ?? []) {
|
|
15847
15859
|
const nested = poolNameOf(poolMemberIdentity(entry));
|
|
15848
15860
|
if (nested === void 0) {
|
|
15849
15861
|
continue;
|
|
15850
15862
|
}
|
|
15851
15863
|
if (nested === name) {
|
|
15852
|
-
return [...
|
|
15864
|
+
return [...path42, nested];
|
|
15853
15865
|
}
|
|
15854
|
-
if (
|
|
15866
|
+
if (path42.includes(nested)) {
|
|
15855
15867
|
continue;
|
|
15856
15868
|
}
|
|
15857
|
-
const found = walk2(nested, [...
|
|
15869
|
+
const found = walk2(nested, [...path42, nested]);
|
|
15858
15870
|
if (found !== void 0) {
|
|
15859
15871
|
return found;
|
|
15860
15872
|
}
|
|
@@ -18300,7 +18312,7 @@ function profileValue(name, paths) {
|
|
|
18300
18312
|
function createConfigApiRouter(deps) {
|
|
18301
18313
|
const authed = doorApiAuth(deps.expectedToken);
|
|
18302
18314
|
const { paths } = deps;
|
|
18303
|
-
const route = (
|
|
18315
|
+
const route = (path42, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path42, summary, tags: [CONFIG_API_TAG] }));
|
|
18304
18316
|
return {
|
|
18305
18317
|
config: {
|
|
18306
18318
|
identity: {
|
|
@@ -20951,6 +20963,85 @@ function mintRcSelfHostCredential(deps) {
|
|
|
20951
20963
|
|
|
20952
20964
|
// src/index.ts
|
|
20953
20965
|
init_ensure2();
|
|
20966
|
+
|
|
20967
|
+
// src/frontdoor/liveSessionRegistry.ts
|
|
20968
|
+
var import_node_path33 = __toESM(require("node:path"), 1);
|
|
20969
|
+
init_capability();
|
|
20970
|
+
init_state();
|
|
20971
|
+
function sameStat(recorded, current) {
|
|
20972
|
+
return recorded?.mtimeMs === current.mtimeMs && recorded.sizeBytes === current.sizeBytes;
|
|
20973
|
+
}
|
|
20974
|
+
function createLiveSessionRegistry(ports) {
|
|
20975
|
+
const { fs: fs14, sessionsDir } = ports;
|
|
20976
|
+
const known = /* @__PURE__ */ new Map();
|
|
20977
|
+
let tokens = /* @__PURE__ */ new Set();
|
|
20978
|
+
let bySessionId = /* @__PURE__ */ new Map();
|
|
20979
|
+
const recordNames = () => fs14.readdir(sessionsDir).filter(isSessionRecordName);
|
|
20980
|
+
const rebuildIndexes = () => {
|
|
20981
|
+
const records = [...known.values()].flatMap(({ record }) => record === void 0 ? [] : [record]);
|
|
20982
|
+
tokens = new Set(records.map((record) => record.token));
|
|
20983
|
+
bySessionId = new Map(records.flatMap((record) => record.sessionId === void 0 ? [] : [[record.sessionId, record]]));
|
|
20984
|
+
};
|
|
20985
|
+
const load = (name, stat) => {
|
|
20986
|
+
known.set(name, { stat: { mtimeMs: stat.mtimeMs, sizeBytes: stat.sizeBytes }, record: readFrontDoorSessionRecord(fs14, sessionsDir, name) });
|
|
20987
|
+
};
|
|
20988
|
+
const statOf = (name) => fs14.lstat(import_node_path33.default.join(sessionsDir, name));
|
|
20989
|
+
const reconcile = () => {
|
|
20990
|
+
const names = new Set(recordNames());
|
|
20991
|
+
let changed = false;
|
|
20992
|
+
for (const name of known.keys()) {
|
|
20993
|
+
if (!names.has(name)) {
|
|
20994
|
+
known.delete(name);
|
|
20995
|
+
changed = true;
|
|
20996
|
+
}
|
|
20997
|
+
}
|
|
20998
|
+
for (const name of names) {
|
|
20999
|
+
const held = known.get(name);
|
|
21000
|
+
const stat = statOf(name);
|
|
21001
|
+
if (stat === void 0) {
|
|
21002
|
+
changed = known.delete(name) || changed;
|
|
21003
|
+
} else if (!sameStat(held?.stat, stat)) {
|
|
21004
|
+
load(name, stat);
|
|
21005
|
+
changed = true;
|
|
21006
|
+
}
|
|
21007
|
+
}
|
|
21008
|
+
if (changed) {
|
|
21009
|
+
rebuildIndexes();
|
|
21010
|
+
}
|
|
21011
|
+
return changed;
|
|
21012
|
+
};
|
|
21013
|
+
return {
|
|
21014
|
+
admits: (token) => {
|
|
21015
|
+
if (isLiveCapability(token, tokens)) {
|
|
21016
|
+
return true;
|
|
21017
|
+
}
|
|
21018
|
+
return reconcile() && isLiveCapability(token, tokens);
|
|
21019
|
+
},
|
|
21020
|
+
modelsOf: (sessionId) => {
|
|
21021
|
+
const held = bySessionId.get(sessionId) ?? (reconcile() ? bySessionId.get(sessionId) : void 0);
|
|
21022
|
+
return held?.models;
|
|
21023
|
+
},
|
|
21024
|
+
rescan: () => {
|
|
21025
|
+
known.clear();
|
|
21026
|
+
for (const name of recordNames()) {
|
|
21027
|
+
const stat = statOf(name);
|
|
21028
|
+
if (stat !== void 0) {
|
|
21029
|
+
load(name, stat);
|
|
21030
|
+
}
|
|
21031
|
+
}
|
|
21032
|
+
rebuildIndexes();
|
|
21033
|
+
return [...known.values()].flatMap(({ record }) => record === void 0 ? [] : [summaryOf(record)]).sort((a, b) => a.pid - b.pid);
|
|
21034
|
+
},
|
|
21035
|
+
forget: (pids) => {
|
|
21036
|
+
for (const pid of pids) {
|
|
21037
|
+
known.delete(sessionRecordName(pid));
|
|
21038
|
+
}
|
|
21039
|
+
rebuildIndexes();
|
|
21040
|
+
}
|
|
21041
|
+
};
|
|
21042
|
+
}
|
|
21043
|
+
|
|
21044
|
+
// src/index.ts
|
|
20954
21045
|
init_supervisor();
|
|
20955
21046
|
init_read();
|
|
20956
21047
|
init_schema2();
|
|
@@ -20960,7 +21051,7 @@ init_plan2();
|
|
|
20960
21051
|
init_poolPick();
|
|
20961
21052
|
|
|
20962
21053
|
// src/agents/read.ts
|
|
20963
|
-
var
|
|
21054
|
+
var import_node_path34 = __toESM(require("node:path"), 1);
|
|
20964
21055
|
var import_zod34 = require("zod");
|
|
20965
21056
|
var PROJECTS_DIR = "projects";
|
|
20966
21057
|
var TASKS_DIR = "tasks";
|
|
@@ -20986,15 +21077,15 @@ function parseEntry2(project, entry) {
|
|
|
20986
21077
|
}
|
|
20987
21078
|
function listSessions2(fs14, configDir) {
|
|
20988
21079
|
const found = [];
|
|
20989
|
-
for (const project of fs14.readdir(
|
|
20990
|
-
const projectDir =
|
|
21080
|
+
for (const project of fs14.readdir(import_node_path34.default.join(configDir, PROJECTS_DIR))) {
|
|
21081
|
+
const projectDir = import_node_path34.default.join(configDir, PROJECTS_DIR, project);
|
|
20991
21082
|
const entries = /* @__PURE__ */ new Set();
|
|
20992
21083
|
for (const name of fs14.readdir(projectDir)) {
|
|
20993
21084
|
if (name.endsWith(TRANSCRIPT_SUFFIX)) {
|
|
20994
21085
|
entries.add(name.slice(0, -TRANSCRIPT_SUFFIX.length));
|
|
20995
21086
|
continue;
|
|
20996
21087
|
}
|
|
20997
|
-
const children = fs14.readdir(
|
|
21088
|
+
const children = fs14.readdir(import_node_path34.default.join(projectDir, name));
|
|
20998
21089
|
if (children.includes(SUBAGENTS_DIR) || children.includes(WORKFLOWS_DIR)) {
|
|
20999
21090
|
entries.add(name);
|
|
21000
21091
|
}
|
|
@@ -21014,8 +21105,8 @@ function locateAgents(fs14, configDir, relativeDir, workflowRunId, report) {
|
|
|
21014
21105
|
const id = name.slice(AGENT_FILE_PREFIX.length, -META_SUFFIX.length);
|
|
21015
21106
|
located.push({
|
|
21016
21107
|
id,
|
|
21017
|
-
metaPath:
|
|
21018
|
-
transcriptPath:
|
|
21108
|
+
metaPath: import_node_path34.default.join(relativeDir, name),
|
|
21109
|
+
transcriptPath: import_node_path34.default.join(relativeDir, `${AGENT_FILE_PREFIX}${id}${TRANSCRIPT_SUFFIX}`),
|
|
21019
21110
|
workflowRunId
|
|
21020
21111
|
});
|
|
21021
21112
|
}
|
|
@@ -21058,7 +21149,7 @@ function describeFailure(error) {
|
|
|
21058
21149
|
}
|
|
21059
21150
|
function readFileOrReport(fs14, configDir, relative, report) {
|
|
21060
21151
|
try {
|
|
21061
|
-
return fs14.readFileUtf8(
|
|
21152
|
+
return fs14.readFileUtf8(import_node_path34.default.join(configDir, relative));
|
|
21062
21153
|
} catch (error) {
|
|
21063
21154
|
report({ path: relative, reason: `could not be read: ${describeFailure(error)}` });
|
|
21064
21155
|
return void 0;
|
|
@@ -21066,7 +21157,7 @@ function readFileOrReport(fs14, configDir, relative, report) {
|
|
|
21066
21157
|
}
|
|
21067
21158
|
function listDirOrReport(fs14, configDir, relative, report) {
|
|
21068
21159
|
try {
|
|
21069
|
-
return fs14.readdir(
|
|
21160
|
+
return fs14.readdir(import_node_path34.default.join(configDir, relative));
|
|
21070
21161
|
} catch (error) {
|
|
21071
21162
|
report({ path: relative, reason: `could not be listed: ${describeFailure(error)}` });
|
|
21072
21163
|
return [];
|
|
@@ -21090,18 +21181,18 @@ var WorkflowRunFileSchema = import_zod34.z.object({
|
|
|
21090
21181
|
summary: import_zod34.z.string().optional()
|
|
21091
21182
|
});
|
|
21092
21183
|
function summariseSession(fs14, configDir, ref) {
|
|
21093
|
-
const sessionRelative =
|
|
21094
|
-
const subagentsRelative =
|
|
21095
|
-
const workflowsUnderSubagents =
|
|
21184
|
+
const sessionRelative = import_node_path34.default.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
21185
|
+
const subagentsRelative = import_node_path34.default.join(sessionRelative, SUBAGENTS_DIR);
|
|
21186
|
+
const workflowsUnderSubagents = import_node_path34.default.join(subagentsRelative, WORKFLOWS_DIR);
|
|
21096
21187
|
const isMeta = (name) => name.startsWith(AGENT_FILE_PREFIX) && name.endsWith(META_SUFFIX);
|
|
21097
|
-
let agentCount = fs14.readdir(
|
|
21098
|
-
for (const runDir of fs14.readdir(
|
|
21188
|
+
let agentCount = fs14.readdir(import_node_path34.default.join(configDir, subagentsRelative)).filter(isMeta).length;
|
|
21189
|
+
for (const runDir of fs14.readdir(import_node_path34.default.join(configDir, workflowsUnderSubagents))) {
|
|
21099
21190
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
21100
|
-
agentCount += fs14.readdir(
|
|
21191
|
+
agentCount += fs14.readdir(import_node_path34.default.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
|
|
21101
21192
|
}
|
|
21102
21193
|
}
|
|
21103
|
-
const workflowRunCount = fs14.readdir(
|
|
21104
|
-
const transcript = fs14.lstat(
|
|
21194
|
+
const workflowRunCount = fs14.readdir(import_node_path34.default.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
|
|
21195
|
+
const transcript = fs14.lstat(import_node_path34.default.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
|
|
21105
21196
|
return { ...ref, agentCount, workflowRunCount, ...transcript === void 0 ? {} : { updatedAt: new Date(transcript.mtimeMs).toISOString() } };
|
|
21106
21197
|
}
|
|
21107
21198
|
function readSessionAgentTree(fs14, configDir, ref, options = {}) {
|
|
@@ -21109,13 +21200,13 @@ function readSessionAgentTree(fs14, configDir, ref, options = {}) {
|
|
|
21109
21200
|
const report = (problem) => {
|
|
21110
21201
|
problems.push(problem);
|
|
21111
21202
|
};
|
|
21112
|
-
const sessionRelative =
|
|
21113
|
-
const subagentsRelative =
|
|
21114
|
-
const workflowsUnderSubagents =
|
|
21203
|
+
const sessionRelative = import_node_path34.default.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
21204
|
+
const subagentsRelative = import_node_path34.default.join(sessionRelative, SUBAGENTS_DIR);
|
|
21205
|
+
const workflowsUnderSubagents = import_node_path34.default.join(subagentsRelative, WORKFLOWS_DIR);
|
|
21115
21206
|
const located = locateAgents(fs14, configDir, subagentsRelative, void 0, report);
|
|
21116
21207
|
for (const runDir of listDirOrReport(fs14, configDir, workflowsUnderSubagents, report)) {
|
|
21117
21208
|
if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
|
|
21118
|
-
located.push(...locateAgents(fs14, configDir,
|
|
21209
|
+
located.push(...locateAgents(fs14, configDir, import_node_path34.default.join(workflowsUnderSubagents, runDir), runDir, report));
|
|
21119
21210
|
}
|
|
21120
21211
|
}
|
|
21121
21212
|
const agents = /* @__PURE__ */ new Map();
|
|
@@ -21156,7 +21247,7 @@ function readSessionAgentTree(fs14, configDir, ref, options = {}) {
|
|
|
21156
21247
|
superseded: ref.superseded,
|
|
21157
21248
|
agents: roots.sort().map(build),
|
|
21158
21249
|
tasks: readTasks(fs14, configDir, ownTaskLists(ref.sessionId), [.../* @__PURE__ */ new Set([...teamNames, ...options.taskListIds ?? []])].filter((id) => !ownTaskLists(ref.sessionId).includes(id)), report),
|
|
21159
|
-
workflowRuns: readWorkflowRuns(fs14, configDir,
|
|
21250
|
+
workflowRuns: readWorkflowRuns(fs14, configDir, import_node_path34.default.join(sessionRelative, WORKFLOWS_DIR), report),
|
|
21160
21251
|
problems
|
|
21161
21252
|
};
|
|
21162
21253
|
}
|
|
@@ -21221,12 +21312,12 @@ function ownTaskLists(sessionId) {
|
|
|
21221
21312
|
function readTasks(fs14, configDir, ownLists, sharedLists, report) {
|
|
21222
21313
|
const tasks = [];
|
|
21223
21314
|
[...ownLists, ...sharedLists].forEach((scope, index) => {
|
|
21224
|
-
const relativeDir =
|
|
21315
|
+
const relativeDir = import_node_path34.default.join(TASKS_DIR, scope);
|
|
21225
21316
|
for (const name of [...listDirOrReport(fs14, configDir, relativeDir, report)].sort()) {
|
|
21226
21317
|
if (name.startsWith(".") || !name.endsWith(JSON_SUFFIX)) {
|
|
21227
21318
|
continue;
|
|
21228
21319
|
}
|
|
21229
|
-
const relative =
|
|
21320
|
+
const relative = import_node_path34.default.join(relativeDir, name);
|
|
21230
21321
|
const text = readFileOrReport(fs14, configDir, relative, report);
|
|
21231
21322
|
const parsed = TaskFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
21232
21323
|
if (parsed.success) {
|
|
@@ -21244,7 +21335,7 @@ function readWorkflowRuns(fs14, configDir, relativeDir, report) {
|
|
|
21244
21335
|
if (!name.startsWith(WORKFLOW_RUN_PREFIX) || !name.endsWith(JSON_SUFFIX)) {
|
|
21245
21336
|
continue;
|
|
21246
21337
|
}
|
|
21247
|
-
const relative =
|
|
21338
|
+
const relative = import_node_path34.default.join(relativeDir, name);
|
|
21248
21339
|
const text = readFileOrReport(fs14, configDir, relative, report);
|
|
21249
21340
|
const parsed = WorkflowRunFileSchema.safeParse(text === void 0 ? void 0 : parseJson2(text));
|
|
21250
21341
|
if (!parsed.success) {
|
|
@@ -21260,7 +21351,7 @@ function readWorkflowRuns(fs14, configDir, relativeDir, report) {
|
|
|
21260
21351
|
}
|
|
21261
21352
|
|
|
21262
21353
|
// src/agents/sessions.ts
|
|
21263
|
-
var
|
|
21354
|
+
var import_node_path35 = __toESM(require("node:path"), 1);
|
|
21264
21355
|
init_cliError();
|
|
21265
21356
|
var SessionLookupError = class extends CliError {
|
|
21266
21357
|
constructor(message) {
|
|
@@ -21269,13 +21360,13 @@ var SessionLookupError = class extends CliError {
|
|
|
21269
21360
|
}
|
|
21270
21361
|
};
|
|
21271
21362
|
function identityConfigDir(identitiesDir, identity) {
|
|
21272
|
-
return
|
|
21363
|
+
return import_node_path35.default.join(identitiesDir, identity);
|
|
21273
21364
|
}
|
|
21274
21365
|
function historyStores(fs14, identitiesDir, identities) {
|
|
21275
21366
|
const byRealPath = /* @__PURE__ */ new Map();
|
|
21276
21367
|
for (const identity of identities) {
|
|
21277
21368
|
const configDir = identityConfigDir(identitiesDir, identity);
|
|
21278
|
-
const real = fs14.realpath(
|
|
21369
|
+
const real = fs14.realpath(import_node_path35.default.join(configDir, "projects"));
|
|
21279
21370
|
if (real === void 0) {
|
|
21280
21371
|
continue;
|
|
21281
21372
|
}
|
|
@@ -21681,6 +21772,7 @@ init_ownCli();
|
|
|
21681
21772
|
createLaunchEventPublisher,
|
|
21682
21773
|
createLeafCache,
|
|
21683
21774
|
createLifecycleApiRouter,
|
|
21775
|
+
createLiveSessionRegistry,
|
|
21684
21776
|
createProfile,
|
|
21685
21777
|
createQuotaExpiringPublisher,
|
|
21686
21778
|
createRcApiNodeHandler,
|