claude-use 11.89.0 → 11.90.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cli.cjs +1878 -1020
- package/dist/index.cjs +1094 -596
- package/dist/index.mjs +1076 -587
- package/dist/types/index.d.ts +1463 -1103
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7294,30 +7294,30 @@ var init_state2 = __esm({
|
|
|
7294
7294
|
});
|
|
7295
7295
|
|
|
7296
7296
|
// src/headroom/earlierRelease.ts
|
|
7297
|
-
function withoutOurSocket(
|
|
7297
|
+
function withoutOurSocket(commandLine2, socketPath) {
|
|
7298
7298
|
for (const argument of [`--uds ${socketPath}`, `--uds=${socketPath}`]) {
|
|
7299
7299
|
let from = 0;
|
|
7300
7300
|
for (; ; ) {
|
|
7301
|
-
const index =
|
|
7301
|
+
const index = commandLine2.indexOf(argument, from);
|
|
7302
7302
|
if (index === -1) {
|
|
7303
7303
|
break;
|
|
7304
7304
|
}
|
|
7305
7305
|
const end = index + argument.length;
|
|
7306
|
-
const startsArgument = index === 0 || /\s/.test(
|
|
7307
|
-
const endsArgument = end ===
|
|
7306
|
+
const startsArgument = index === 0 || /\s/.test(commandLine2.charAt(index - 1));
|
|
7307
|
+
const endsArgument = end === commandLine2.length || /\s/.test(commandLine2.charAt(end));
|
|
7308
7308
|
if (startsArgument && endsArgument) {
|
|
7309
|
-
return `${
|
|
7309
|
+
return `${commandLine2.slice(0, index)} ${commandLine2.slice(end)}`;
|
|
7310
7310
|
}
|
|
7311
7311
|
from = index + 1;
|
|
7312
7312
|
}
|
|
7313
7313
|
}
|
|
7314
7314
|
return void 0;
|
|
7315
7315
|
}
|
|
7316
|
-
function daemonIdentity(
|
|
7317
|
-
if (
|
|
7316
|
+
function daemonIdentity(commandLine2, socketPath) {
|
|
7317
|
+
if (commandLine2 === void 0) {
|
|
7318
7318
|
return "unreadable";
|
|
7319
7319
|
}
|
|
7320
|
-
const rest = withoutOurSocket(
|
|
7320
|
+
const rest = withoutOurSocket(commandLine2, socketPath);
|
|
7321
7321
|
const argumentsList = rest === void 0 ? [] : rest.trim().split(/\s+/);
|
|
7322
7322
|
if (rest === void 0 || !argumentsList.includes("proxy")) {
|
|
7323
7323
|
return "not-headroom";
|
|
@@ -7416,8 +7416,8 @@ function ensureHeadroom(params) {
|
|
|
7416
7416
|
writeSession(ports.fs, paths.headroomSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), supervisorPid: state.supervisorPid });
|
|
7417
7417
|
return { socketPath: state.socketPath };
|
|
7418
7418
|
}
|
|
7419
|
-
const
|
|
7420
|
-
const earlierRelease = earlierReleaseDaemon(ports.fs, paths, { commandLine, socketPath: state.socketPath, recordedHash: state.allowlistHash });
|
|
7419
|
+
const commandLine2 = commandLineOf(state.headroomPid);
|
|
7420
|
+
const earlierRelease = earlierReleaseDaemon(ports.fs, paths, { commandLine: commandLine2, socketPath: state.socketPath, recordedHash: state.allowlistHash });
|
|
7421
7421
|
if (earlierRelease !== void 0) {
|
|
7422
7422
|
if (earlierRelease.admitsServingDoor) {
|
|
7423
7423
|
writeSession(ports.fs, paths.headroomSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), supervisorPid: state.supervisorPid });
|
|
@@ -7427,7 +7427,7 @@ function ensureHeadroom(params) {
|
|
|
7427
7427
|
`the running headroom daemon (pid ${String(state.headroomPid)}) was ${EARLIER_RELEASE_ALLOWLIST}, and its allowlist cannot be shown to admit the serving front door; launch with --no-headroom until then. Supervisor and daemon log: ${paths.headroomLogPath}`
|
|
7428
7428
|
);
|
|
7429
7429
|
}
|
|
7430
|
-
awaiting = { daemonPid: state.headroomPid, identity: daemonIdentity(
|
|
7430
|
+
awaiting = { daemonPid: state.headroomPid, identity: daemonIdentity(commandLine2, state.socketPath) };
|
|
7431
7431
|
}
|
|
7432
7432
|
if (state.lastError !== void 0) {
|
|
7433
7433
|
throw new HeadroomStartError(
|
|
@@ -9238,6 +9238,9 @@ function assessIdentity(member, nowMs) {
|
|
|
9238
9238
|
const state = member.snapshot?.providers[ANTHROPIC_PROVIDER];
|
|
9239
9239
|
const unified = unifiedOf(state);
|
|
9240
9240
|
if (member.snapshot === void 0 || state === void 0 || unified === void 0) {
|
|
9241
|
+
if (plan.kind === "pay-per-use") {
|
|
9242
|
+
return { candidate: { ...base, class: "pay-per-use", usageUnrecorded: true, reasons: [...planReasons, "no usage recorded yet, so its spend is not tracked (turn on trackUsage for it)"] } };
|
|
9243
|
+
}
|
|
9241
9244
|
return { candidate: { ...base, class: "unknown", reasons: ["no usage recorded yet, so its quota is unknown (turn on trackUsage for it)", ...planReasons] } };
|
|
9242
9245
|
}
|
|
9243
9246
|
const observedAgo = state.rateLimit === void 0 ? "" : ` (last seen ${formatAge(nowMs - Date.parse(state.rateLimit.observedAt))} ago)`;
|
|
@@ -9369,7 +9372,7 @@ function rankPool(input) {
|
|
|
9369
9372
|
return { ...candidate, feasible: false, runsDryAtMs: nowMs + Math.min(...dryAfterMs), reasons: [...drySpots, ...candidate.reasons] };
|
|
9370
9373
|
});
|
|
9371
9374
|
const ordered = input.preference === "listed" ? [...candidates] : [...candidates].sort(
|
|
9372
|
-
(left, right) => CLASS_ORDER[left.class] - CLASS_ORDER[right.class] || Number(left.policyDemoted ?? false) - Number(right.policyDemoted ?? false) || Number(right.feasible) - Number(left.feasible) || (right.headroom ?? 1) - (left.headroom ?? 1) || (right.score ?? 0) - (left.score ?? 0) || left.identity.localeCompare(right.identity)
|
|
9375
|
+
(left, right) => CLASS_ORDER[left.class] - CLASS_ORDER[right.class] || Number(left.policyDemoted ?? false) - Number(right.policyDemoted ?? false) || Number(right.feasible) - Number(left.feasible) || Number(left.usageUnrecorded ?? false) - Number(right.usageUnrecorded ?? false) || (right.headroom ?? 1) - (left.headroom ?? 1) || (right.score ?? 0) - (left.score ?? 0) || left.identity.localeCompare(right.identity)
|
|
9373
9376
|
);
|
|
9374
9377
|
const sticky = input.sticky;
|
|
9375
9378
|
const stickyIndex = sticky === void 0 ? -1 : ordered.findIndex((candidate) => candidate.identity === sticky.identity);
|
|
@@ -10516,7 +10519,7 @@ var init_package = __esm({
|
|
|
10516
10519
|
"package.json"() {
|
|
10517
10520
|
package_default = {
|
|
10518
10521
|
name: "claude-use",
|
|
10519
|
-
version: "11.
|
|
10522
|
+
version: "11.90.0",
|
|
10520
10523
|
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.",
|
|
10521
10524
|
license: "MIT",
|
|
10522
10525
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -10895,15 +10898,15 @@ function aliasFindings(aliases, providerNames) {
|
|
|
10895
10898
|
return { level: "pass", alias, message: `${alias} is a former name of ${target}, still honoured for sessions launched under it. Run \`agent-shim provider unalias ${alias}\` once none is running.` };
|
|
10896
10899
|
});
|
|
10897
10900
|
}
|
|
10898
|
-
var
|
|
10901
|
+
var import_zod25, ProviderAliasesSchema;
|
|
10899
10902
|
var init_providerAliases = __esm({
|
|
10900
10903
|
"src/providerAliases.ts"() {
|
|
10901
10904
|
"use strict";
|
|
10902
|
-
|
|
10905
|
+
import_zod25 = require("zod");
|
|
10903
10906
|
init_cliError();
|
|
10904
10907
|
init_load();
|
|
10905
10908
|
init_store();
|
|
10906
|
-
ProviderAliasesSchema =
|
|
10909
|
+
ProviderAliasesSchema = import_zod25.z.record(import_zod25.z.string().min(1), import_zod25.z.string().min(1));
|
|
10907
10910
|
}
|
|
10908
10911
|
});
|
|
10909
10912
|
|
|
@@ -11127,14 +11130,14 @@ function requireProviderExists(paths, name) {
|
|
|
11127
11130
|
throw new ProviderNotFoundError(name);
|
|
11128
11131
|
}
|
|
11129
11132
|
}
|
|
11130
|
-
function
|
|
11133
|
+
function isRecord8(value) {
|
|
11131
11134
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11132
11135
|
}
|
|
11133
11136
|
function legacyProviderConversion(raw) {
|
|
11134
|
-
if (!
|
|
11137
|
+
if (!isRecord8(raw) || "credential" in raw) {
|
|
11135
11138
|
return void 0;
|
|
11136
11139
|
}
|
|
11137
|
-
const env =
|
|
11140
|
+
const env = isRecord8(raw.env) ? raw.env : void 0;
|
|
11138
11141
|
const legacyEnvKeys = env === void 0 ? [] : Object.keys(env).filter((key) => LEGACY_ENV_CREDENTIAL_KEYS.includes(key));
|
|
11139
11142
|
const fields = [...LEGACY_PROVIDER_FIELDS.filter((field) => field in raw), ...legacyEnvKeys.map((key) => `env.${key}`)];
|
|
11140
11143
|
if (fields.length === 0) {
|
|
@@ -11701,17 +11704,17 @@ function withoutInjected(env) {
|
|
|
11701
11704
|
});
|
|
11702
11705
|
return Object.fromEntries(entries);
|
|
11703
11706
|
}
|
|
11704
|
-
var import_node_crypto13,
|
|
11707
|
+
var import_node_crypto13, import_zod26, INJECTED_ENV, CUSTOM_HEADERS_ENV, HEADER_KEY_PREFIX, InjectedSchema;
|
|
11705
11708
|
var init_injected = __esm({
|
|
11706
11709
|
"src/launcher/injected.ts"() {
|
|
11707
11710
|
"use strict";
|
|
11708
11711
|
import_node_crypto13 = require("node:crypto");
|
|
11709
|
-
|
|
11712
|
+
import_zod26 = require("zod");
|
|
11710
11713
|
init_headers();
|
|
11711
11714
|
INJECTED_ENV = "AGENT_SHIM_INJECTED";
|
|
11712
11715
|
CUSTOM_HEADERS_ENV = "ANTHROPIC_CUSTOM_HEADERS";
|
|
11713
11716
|
HEADER_KEY_PREFIX = `${CUSTOM_HEADERS_ENV}:`;
|
|
11714
|
-
InjectedSchema =
|
|
11717
|
+
InjectedSchema = import_zod26.z.record(import_zod26.z.string(), import_zod26.z.string());
|
|
11715
11718
|
}
|
|
11716
11719
|
});
|
|
11717
11720
|
|
|
@@ -11886,46 +11889,46 @@ function findPathShadow(params) {
|
|
|
11886
11889
|
}
|
|
11887
11890
|
return params.pathDirs.some((dir) => import_node_path38.default.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
|
|
11888
11891
|
}
|
|
11889
|
-
var import_node_fs11, import_node_path38,
|
|
11892
|
+
var import_node_fs11, import_node_path38, import_zod31, ClaudeShimStateSchema, nodeLinkFs;
|
|
11890
11893
|
var init_claudeShim = __esm({
|
|
11891
11894
|
"src/claudeShim.ts"() {
|
|
11892
11895
|
"use strict";
|
|
11893
11896
|
import_node_fs11 = __toESM(require("node:fs"), 1);
|
|
11894
11897
|
import_node_path38 = __toESM(require("node:path"), 1);
|
|
11895
|
-
|
|
11898
|
+
import_zod31 = require("zod");
|
|
11896
11899
|
init_commandDeps();
|
|
11897
11900
|
init_store();
|
|
11898
11901
|
init_realPorts();
|
|
11899
11902
|
init_cliError();
|
|
11900
|
-
ClaudeShimStateSchema =
|
|
11901
|
-
targetPath:
|
|
11902
|
-
method:
|
|
11903
|
-
installedAtMs:
|
|
11903
|
+
ClaudeShimStateSchema = import_zod31.z.strictObject({
|
|
11904
|
+
targetPath: import_zod31.z.string().min(1),
|
|
11905
|
+
method: import_zod31.z.enum(["hardlink", "copy"]),
|
|
11906
|
+
installedAtMs: import_zod31.z.number()
|
|
11904
11907
|
});
|
|
11905
11908
|
nodeLinkFs = { link: import_node_fs11.default.linkSync, copyFile: import_node_fs11.default.copyFileSync, chmod: import_node_fs11.default.chmodSync };
|
|
11906
11909
|
}
|
|
11907
11910
|
});
|
|
11908
11911
|
|
|
11909
11912
|
// src/codex/auth.ts
|
|
11910
|
-
var
|
|
11913
|
+
var import_zod32, AuthFileSchema, TokenGrantSchema, CodexAuthError;
|
|
11911
11914
|
var init_auth = __esm({
|
|
11912
11915
|
"src/codex/auth.ts"() {
|
|
11913
11916
|
"use strict";
|
|
11914
|
-
|
|
11915
|
-
AuthFileSchema =
|
|
11916
|
-
tokens:
|
|
11917
|
-
access_token:
|
|
11918
|
-
refresh_token:
|
|
11919
|
-
id_token:
|
|
11920
|
-
account_id:
|
|
11917
|
+
import_zod32 = require("zod");
|
|
11918
|
+
AuthFileSchema = import_zod32.z.looseObject({
|
|
11919
|
+
tokens: import_zod32.z.looseObject({
|
|
11920
|
+
access_token: import_zod32.z.string().optional(),
|
|
11921
|
+
refresh_token: import_zod32.z.string().optional(),
|
|
11922
|
+
id_token: import_zod32.z.string().optional(),
|
|
11923
|
+
account_id: import_zod32.z.string().optional()
|
|
11921
11924
|
}).nullish(),
|
|
11922
|
-
last_refresh:
|
|
11925
|
+
last_refresh: import_zod32.z.string().optional()
|
|
11923
11926
|
});
|
|
11924
|
-
TokenGrantSchema =
|
|
11925
|
-
access_token:
|
|
11926
|
-
refresh_token:
|
|
11927
|
-
id_token:
|
|
11928
|
-
account_id:
|
|
11927
|
+
TokenGrantSchema = import_zod32.z.looseObject({
|
|
11928
|
+
access_token: import_zod32.z.string().min(1).optional(),
|
|
11929
|
+
refresh_token: import_zod32.z.string().min(1).optional(),
|
|
11930
|
+
id_token: import_zod32.z.string().min(1).optional(),
|
|
11931
|
+
account_id: import_zod32.z.string().min(1).optional()
|
|
11929
11932
|
});
|
|
11930
11933
|
CodexAuthError = class extends Error {
|
|
11931
11934
|
constructor(message) {
|
|
@@ -11937,31 +11940,31 @@ var init_auth = __esm({
|
|
|
11937
11940
|
});
|
|
11938
11941
|
|
|
11939
11942
|
// src/codex/siwc.ts
|
|
11940
|
-
var
|
|
11943
|
+
var import_zod33, SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
|
|
11941
11944
|
var init_siwc = __esm({
|
|
11942
11945
|
"src/codex/siwc.ts"() {
|
|
11943
11946
|
"use strict";
|
|
11944
|
-
|
|
11947
|
+
import_zod33 = require("zod");
|
|
11945
11948
|
SIWC_RESOURCE = "https://api.openai.com/v1";
|
|
11946
11949
|
SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
|
|
11947
11950
|
SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
|
|
11948
|
-
TokenResponseSchema =
|
|
11949
|
-
access_token:
|
|
11950
|
-
refresh_token:
|
|
11951
|
-
id_token:
|
|
11952
|
-
expires_in:
|
|
11953
|
-
scope:
|
|
11951
|
+
TokenResponseSchema = import_zod33.z.looseObject({
|
|
11952
|
+
access_token: import_zod33.z.string().min(1),
|
|
11953
|
+
refresh_token: import_zod33.z.string().min(1).optional(),
|
|
11954
|
+
id_token: import_zod33.z.string().min(1).optional(),
|
|
11955
|
+
expires_in: import_zod33.z.number().positive(),
|
|
11956
|
+
scope: import_zod33.z.string().optional()
|
|
11954
11957
|
});
|
|
11955
|
-
JwtHeaderSchema =
|
|
11956
|
-
IdTokenClaimsSchema =
|
|
11957
|
-
iss:
|
|
11958
|
-
sub:
|
|
11959
|
-
aud:
|
|
11960
|
-
exp:
|
|
11961
|
-
nonce:
|
|
11962
|
-
email:
|
|
11958
|
+
JwtHeaderSchema = import_zod33.z.looseObject({ alg: import_zod33.z.string(), kid: import_zod33.z.string().optional() });
|
|
11959
|
+
IdTokenClaimsSchema = import_zod33.z.looseObject({
|
|
11960
|
+
iss: import_zod33.z.string(),
|
|
11961
|
+
sub: import_zod33.z.string().min(1),
|
|
11962
|
+
aud: import_zod33.z.union([import_zod33.z.string(), import_zod33.z.array(import_zod33.z.string())]),
|
|
11963
|
+
exp: import_zod33.z.number(),
|
|
11964
|
+
nonce: import_zod33.z.string().optional(),
|
|
11965
|
+
email: import_zod33.z.string().optional()
|
|
11963
11966
|
});
|
|
11964
|
-
JwksSchema =
|
|
11967
|
+
JwksSchema = import_zod33.z.object({ keys: import_zod33.z.array(import_zod33.z.looseObject({ kid: import_zod33.z.string().optional(), kty: import_zod33.z.string() })) });
|
|
11965
11968
|
}
|
|
11966
11969
|
});
|
|
11967
11970
|
|
|
@@ -11979,25 +11982,25 @@ function parseSiwcFile(raw, filePath) {
|
|
|
11979
11982
|
}
|
|
11980
11983
|
return parsed.data;
|
|
11981
11984
|
}
|
|
11982
|
-
var
|
|
11985
|
+
var import_zod34, SiwcGrantSchema, SiwcFileSchema;
|
|
11983
11986
|
var init_siwcStore = __esm({
|
|
11984
11987
|
"src/codex/siwcStore.ts"() {
|
|
11985
11988
|
"use strict";
|
|
11986
|
-
|
|
11989
|
+
import_zod34 = require("zod");
|
|
11987
11990
|
init_auth();
|
|
11988
11991
|
init_siwc();
|
|
11989
|
-
SiwcGrantSchema =
|
|
11990
|
-
clientId:
|
|
11991
|
-
sub:
|
|
11992
|
-
email:
|
|
11993
|
-
idToken:
|
|
11994
|
-
accessToken:
|
|
11995
|
-
refreshToken:
|
|
11996
|
-
scopes:
|
|
11992
|
+
SiwcGrantSchema = import_zod34.z.strictObject({
|
|
11993
|
+
clientId: import_zod34.z.string().min(1),
|
|
11994
|
+
sub: import_zod34.z.string().min(1),
|
|
11995
|
+
email: import_zod34.z.string().optional(),
|
|
11996
|
+
idToken: import_zod34.z.string().min(1),
|
|
11997
|
+
accessToken: import_zod34.z.string().min(1),
|
|
11998
|
+
refreshToken: import_zod34.z.string().min(1),
|
|
11999
|
+
scopes: import_zod34.z.array(import_zod34.z.string()).readonly(),
|
|
11997
12000
|
/** When the access token stops working, in milliseconds since the epoch. */
|
|
11998
|
-
expiresAt:
|
|
12001
|
+
expiresAt: import_zod34.z.number()
|
|
11999
12002
|
});
|
|
12000
|
-
SiwcFileSchema =
|
|
12003
|
+
SiwcFileSchema = import_zod34.z.strictObject({ registeredClientId: import_zod34.z.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
|
|
12001
12004
|
}
|
|
12002
12005
|
});
|
|
12003
12006
|
|
|
@@ -12090,15 +12093,15 @@ function savedCatalogueFingerprint(provider, paths, env, home, read) {
|
|
|
12090
12093
|
const codexHome = configuredHome === void 0 || configuredHome === "" ? import_node_path41.default.join(home, ".codex") : configuredHome;
|
|
12091
12094
|
return cliCatalogueFingerprint(read(import_node_path41.default.join(codexHome, "auth.json")));
|
|
12092
12095
|
}
|
|
12093
|
-
var import_node_crypto14, import_node_path41,
|
|
12096
|
+
var import_node_crypto14, import_node_path41, import_zod35, CatalogueBindingSchema;
|
|
12094
12097
|
var init_catalogueCredential = __esm({
|
|
12095
12098
|
"src/codex/catalogueCredential.ts"() {
|
|
12096
12099
|
"use strict";
|
|
12097
12100
|
import_node_crypto14 = require("node:crypto");
|
|
12098
12101
|
import_node_path41 = __toESM(require("node:path"), 1);
|
|
12099
|
-
|
|
12102
|
+
import_zod35 = require("zod");
|
|
12100
12103
|
init_siwcStore();
|
|
12101
|
-
CatalogueBindingSchema =
|
|
12104
|
+
CatalogueBindingSchema = import_zod35.z.strictObject({ fingerprint: import_zod35.z.string().min(1), source: import_zod35.z.string().min(1), revision: import_zod35.z.string().min(1) });
|
|
12102
12105
|
}
|
|
12103
12106
|
});
|
|
12104
12107
|
|
|
@@ -12149,64 +12152,64 @@ var init_signatures = __esm({
|
|
|
12149
12152
|
});
|
|
12150
12153
|
|
|
12151
12154
|
// src/codex/anthropic.ts
|
|
12152
|
-
var
|
|
12155
|
+
var import_zod36, TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
|
|
12153
12156
|
var init_anthropic = __esm({
|
|
12154
12157
|
"src/codex/anthropic.ts"() {
|
|
12155
12158
|
"use strict";
|
|
12156
|
-
|
|
12157
|
-
TextBlockSchema =
|
|
12158
|
-
Base64ImageSourceSchema =
|
|
12159
|
-
UrlImageSourceSchema =
|
|
12160
|
-
ImageBlockSchema =
|
|
12161
|
-
type:
|
|
12162
|
-
source:
|
|
12159
|
+
import_zod36 = require("zod");
|
|
12160
|
+
TextBlockSchema = import_zod36.z.looseObject({ type: import_zod36.z.literal("text"), text: import_zod36.z.string() });
|
|
12161
|
+
Base64ImageSourceSchema = import_zod36.z.looseObject({ type: import_zod36.z.literal("base64"), media_type: import_zod36.z.string().min(1), data: import_zod36.z.string() });
|
|
12162
|
+
UrlImageSourceSchema = import_zod36.z.looseObject({ type: import_zod36.z.literal("url"), url: import_zod36.z.string().min(1) });
|
|
12163
|
+
ImageBlockSchema = import_zod36.z.looseObject({
|
|
12164
|
+
type: import_zod36.z.literal("image"),
|
|
12165
|
+
source: import_zod36.z.union([Base64ImageSourceSchema, UrlImageSourceSchema])
|
|
12163
12166
|
});
|
|
12164
|
-
ToolUseBlockSchema =
|
|
12165
|
-
type:
|
|
12166
|
-
id:
|
|
12167
|
-
name:
|
|
12168
|
-
input:
|
|
12167
|
+
ToolUseBlockSchema = import_zod36.z.looseObject({
|
|
12168
|
+
type: import_zod36.z.literal("tool_use"),
|
|
12169
|
+
id: import_zod36.z.string().min(1),
|
|
12170
|
+
name: import_zod36.z.string().min(1),
|
|
12171
|
+
input: import_zod36.z.unknown()
|
|
12169
12172
|
});
|
|
12170
|
-
ToolResultContentBlockSchema =
|
|
12171
|
-
ToolResultBlockSchema =
|
|
12172
|
-
type:
|
|
12173
|
-
tool_use_id:
|
|
12174
|
-
content:
|
|
12173
|
+
ToolResultContentBlockSchema = import_zod36.z.union([TextBlockSchema, import_zod36.z.looseObject({ type: import_zod36.z.string() })]);
|
|
12174
|
+
ToolResultBlockSchema = import_zod36.z.looseObject({
|
|
12175
|
+
type: import_zod36.z.literal("tool_result"),
|
|
12176
|
+
tool_use_id: import_zod36.z.string().min(1),
|
|
12177
|
+
content: import_zod36.z.union([import_zod36.z.string(), import_zod36.z.array(ToolResultContentBlockSchema)]).optional()
|
|
12175
12178
|
});
|
|
12176
|
-
OtherBlockSchema =
|
|
12177
|
-
ContentBlockSchema =
|
|
12178
|
-
MessageSchema =
|
|
12179
|
-
role:
|
|
12180
|
-
content:
|
|
12179
|
+
OtherBlockSchema = import_zod36.z.looseObject({ type: import_zod36.z.string() });
|
|
12180
|
+
ContentBlockSchema = import_zod36.z.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
|
|
12181
|
+
MessageSchema = import_zod36.z.looseObject({
|
|
12182
|
+
role: import_zod36.z.enum(["user", "assistant", "system"]),
|
|
12183
|
+
content: import_zod36.z.union([import_zod36.z.string(), import_zod36.z.array(ContentBlockSchema)])
|
|
12181
12184
|
});
|
|
12182
|
-
ToolSchema =
|
|
12183
|
-
name:
|
|
12184
|
-
description:
|
|
12185
|
-
input_schema:
|
|
12186
|
-
allowed_domains:
|
|
12187
|
-
blocked_domains:
|
|
12185
|
+
ToolSchema = import_zod36.z.looseObject({
|
|
12186
|
+
name: import_zod36.z.string().min(1),
|
|
12187
|
+
description: import_zod36.z.string().optional(),
|
|
12188
|
+
input_schema: import_zod36.z.record(import_zod36.z.string(), import_zod36.z.unknown()).optional(),
|
|
12189
|
+
allowed_domains: import_zod36.z.array(import_zod36.z.string()).optional(),
|
|
12190
|
+
blocked_domains: import_zod36.z.array(import_zod36.z.string()).optional()
|
|
12188
12191
|
});
|
|
12189
|
-
ToolChoiceSchema =
|
|
12190
|
-
|
|
12191
|
-
|
|
12192
|
+
ToolChoiceSchema = import_zod36.z.union([
|
|
12193
|
+
import_zod36.z.looseObject({ type: import_zod36.z.enum(["auto", "none", "any"]) }),
|
|
12194
|
+
import_zod36.z.looseObject({ type: import_zod36.z.literal("tool"), name: import_zod36.z.string().min(1) })
|
|
12192
12195
|
]);
|
|
12193
|
-
SystemSchema =
|
|
12194
|
-
MessagesRequestSchema =
|
|
12195
|
-
model:
|
|
12196
|
+
SystemSchema = import_zod36.z.union([import_zod36.z.string(), import_zod36.z.array(import_zod36.z.union([TextBlockSchema, OtherBlockSchema]))]);
|
|
12197
|
+
MessagesRequestSchema = import_zod36.z.looseObject({
|
|
12198
|
+
model: import_zod36.z.string().optional(),
|
|
12196
12199
|
system: SystemSchema.optional(),
|
|
12197
|
-
messages:
|
|
12198
|
-
tools:
|
|
12200
|
+
messages: import_zod36.z.array(MessageSchema),
|
|
12201
|
+
tools: import_zod36.z.array(ToolSchema).optional(),
|
|
12199
12202
|
tool_choice: ToolChoiceSchema.optional(),
|
|
12200
|
-
stream:
|
|
12203
|
+
stream: import_zod36.z.boolean().optional(),
|
|
12201
12204
|
/** `user_id` is stable for one Claude Code session and differs between sessions, which is what makes it the right key for both the backend's prompt cache and its session header. */
|
|
12202
|
-
metadata:
|
|
12205
|
+
metadata: import_zod36.z.looseObject({ user_id: import_zod36.z.string().optional() }).optional(),
|
|
12203
12206
|
/** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
|
|
12204
|
-
output_config:
|
|
12207
|
+
output_config: import_zod36.z.looseObject({ effort: import_zod36.z.string().optional(), format: import_zod36.z.object({ type: import_zod36.z.literal("json_schema"), schema: import_zod36.z.record(import_zod36.z.string(), import_zod36.z.unknown()) }).optional() }).optional()
|
|
12205
12208
|
});
|
|
12206
|
-
CountTokensRequestSchema =
|
|
12207
|
-
system:
|
|
12208
|
-
messages:
|
|
12209
|
-
tools:
|
|
12209
|
+
CountTokensRequestSchema = import_zod36.z.looseObject({
|
|
12210
|
+
system: import_zod36.z.unknown().optional(),
|
|
12211
|
+
messages: import_zod36.z.unknown().optional(),
|
|
12212
|
+
tools: import_zod36.z.unknown().optional()
|
|
12210
12213
|
});
|
|
12211
12214
|
}
|
|
12212
12215
|
});
|
|
@@ -13562,7 +13565,7 @@ function withLauncherSettings(passthrough, settings) {
|
|
|
13562
13565
|
}
|
|
13563
13566
|
return [...kept, "--settings", settings, ...tail];
|
|
13564
13567
|
}
|
|
13565
|
-
function
|
|
13568
|
+
function isRecord16(value) {
|
|
13566
13569
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13567
13570
|
}
|
|
13568
13571
|
function mergeSettings(parts) {
|
|
@@ -13573,7 +13576,7 @@ function mergeSettings(parts) {
|
|
|
13573
13576
|
continue;
|
|
13574
13577
|
}
|
|
13575
13578
|
const parsed = JSON.parse(part);
|
|
13576
|
-
if (!
|
|
13579
|
+
if (!isRecord16(parsed)) {
|
|
13577
13580
|
throw new Error("a launch's settings part is not a JSON object");
|
|
13578
13581
|
}
|
|
13579
13582
|
for (const [key, value] of Object.entries(parsed)) {
|
|
@@ -15257,11 +15260,11 @@ var init_identityClaude = __esm({
|
|
|
15257
15260
|
});
|
|
15258
15261
|
|
|
15259
15262
|
// src/usage/providerQuota.ts
|
|
15260
|
-
var
|
|
15263
|
+
var import_zod45, MS_PER_SECOND9, SECONDS_PER_HOUR3, HOURS_PER_DAY6, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY2, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, FIVE_HOURS2, DAYS_PER_WEEK2, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema;
|
|
15261
15264
|
var init_providerQuota = __esm({
|
|
15262
15265
|
"src/usage/providerQuota.ts"() {
|
|
15263
15266
|
"use strict";
|
|
15264
|
-
|
|
15267
|
+
import_zod45 = require("zod");
|
|
15265
15268
|
init_cloudUpstream();
|
|
15266
15269
|
init_schema2();
|
|
15267
15270
|
MS_PER_SECOND9 = 1e3;
|
|
@@ -15276,35 +15279,35 @@ var init_providerQuota = __esm({
|
|
|
15276
15279
|
[ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND9],
|
|
15277
15280
|
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9]
|
|
15278
15281
|
]);
|
|
15279
|
-
ZaiLimitSchema =
|
|
15280
|
-
type:
|
|
15281
|
-
unit:
|
|
15282
|
-
number:
|
|
15283
|
-
percentage:
|
|
15284
|
-
nextResetTime:
|
|
15285
|
-
usage:
|
|
15286
|
-
currentValue:
|
|
15287
|
-
remaining:
|
|
15282
|
+
ZaiLimitSchema = import_zod45.z.object({
|
|
15283
|
+
type: import_zod45.z.string(),
|
|
15284
|
+
unit: import_zod45.z.number().int(),
|
|
15285
|
+
number: import_zod45.z.number().int().positive(),
|
|
15286
|
+
percentage: import_zod45.z.number().nonnegative(),
|
|
15287
|
+
nextResetTime: import_zod45.z.number().positive().optional(),
|
|
15288
|
+
usage: import_zod45.z.number().nonnegative().optional(),
|
|
15289
|
+
currentValue: import_zod45.z.number().nonnegative().optional(),
|
|
15290
|
+
remaining: import_zod45.z.number().nonnegative().optional()
|
|
15288
15291
|
});
|
|
15289
|
-
ZaiResponseSchema =
|
|
15290
|
-
success:
|
|
15291
|
-
msg:
|
|
15292
|
-
data:
|
|
15292
|
+
ZaiResponseSchema = import_zod45.z.object({
|
|
15293
|
+
success: import_zod45.z.boolean(),
|
|
15294
|
+
msg: import_zod45.z.string().optional(),
|
|
15295
|
+
data: import_zod45.z.object({ level: import_zod45.z.string().optional(), limits: import_zod45.z.array(ZaiLimitSchema) })
|
|
15293
15296
|
});
|
|
15294
15297
|
OPENROUTER_HOST = "openrouter.ai";
|
|
15295
15298
|
OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
|
|
15296
15299
|
OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
|
|
15297
15300
|
MS_PER_DAY2 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
15298
|
-
OpenRouterKeySchema =
|
|
15299
|
-
data:
|
|
15300
|
-
limit:
|
|
15301
|
-
limit_remaining:
|
|
15302
|
-
limit_reset:
|
|
15303
|
-
is_free_tier:
|
|
15304
|
-
free_model_daily_requests:
|
|
15301
|
+
OpenRouterKeySchema = import_zod45.z.object({
|
|
15302
|
+
data: import_zod45.z.object({
|
|
15303
|
+
limit: import_zod45.z.number().nonnegative().nullable(),
|
|
15304
|
+
limit_remaining: import_zod45.z.number().nullable(),
|
|
15305
|
+
limit_reset: import_zod45.z.string().nullable(),
|
|
15306
|
+
is_free_tier: import_zod45.z.boolean().optional(),
|
|
15307
|
+
free_model_daily_requests: import_zod45.z.object({ used: import_zod45.z.number().nonnegative(), limit: import_zod45.z.number().nonnegative(), remaining: import_zod45.z.number() }).optional()
|
|
15305
15308
|
})
|
|
15306
15309
|
});
|
|
15307
|
-
OpenRouterCreditsSchema =
|
|
15310
|
+
OpenRouterCreditsSchema = import_zod45.z.object({ data: import_zod45.z.object({ total_credits: import_zod45.z.number().nonnegative(), total_usage: import_zod45.z.number().nonnegative() }) });
|
|
15308
15311
|
ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
|
|
15309
15312
|
ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
|
|
15310
15313
|
ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
|
|
@@ -15312,21 +15315,21 @@ var init_providerQuota = __esm({
|
|
|
15312
15315
|
DAYS_PER_WEEK2 = 7;
|
|
15313
15316
|
FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
15314
15317
|
WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
15315
|
-
AntigravityBucketSchema =
|
|
15316
|
-
bucketId:
|
|
15317
|
-
remainingFraction:
|
|
15318
|
-
resetTime:
|
|
15318
|
+
AntigravityBucketSchema = import_zod45.z.object({
|
|
15319
|
+
bucketId: import_zod45.z.string(),
|
|
15320
|
+
remainingFraction: import_zod45.z.number().optional(),
|
|
15321
|
+
resetTime: import_zod45.z.string().optional()
|
|
15319
15322
|
});
|
|
15320
|
-
AntigravitySummarySchema =
|
|
15321
|
-
GoogleTokenInfoSchema =
|
|
15322
|
-
email:
|
|
15323
|
-
sub:
|
|
15323
|
+
AntigravitySummarySchema = import_zod45.z.object({ groups: import_zod45.z.array(import_zod45.z.object({ buckets: import_zod45.z.array(AntigravityBucketSchema) })) });
|
|
15324
|
+
GoogleTokenInfoSchema = import_zod45.z.object({
|
|
15325
|
+
email: import_zod45.z.string().optional(),
|
|
15326
|
+
sub: import_zod45.z.string().optional()
|
|
15324
15327
|
});
|
|
15325
|
-
AntigravityUserSchema =
|
|
15328
|
+
AntigravityUserSchema = import_zod45.z.object({
|
|
15326
15329
|
/** The code-assist tier context, which defaults to the free tier for every account. */
|
|
15327
|
-
currentTier:
|
|
15330
|
+
currentTier: import_zod45.z.object({ name: import_zod45.z.string().optional(), id: import_zod45.z.string().optional() }).optional(),
|
|
15328
15331
|
/** The account's paid subscription; absent when the account has none. */
|
|
15329
|
-
paidTier:
|
|
15332
|
+
paidTier: import_zod45.z.object({ name: import_zod45.z.string().optional(), id: import_zod45.z.string().optional() }).optional()
|
|
15330
15333
|
});
|
|
15331
15334
|
}
|
|
15332
15335
|
});
|
|
@@ -15546,6 +15549,8 @@ __export(index_exports, {
|
|
|
15546
15549
|
QUOTA_EXPIRING_EVENT_SOURCE: () => QUOTA_EXPIRING_EVENT_SOURCE,
|
|
15547
15550
|
QuotaExpiringEventSchema: () => QuotaExpiringEventSchema,
|
|
15548
15551
|
RC_CONTEXT_USAGE_DETAILS: () => RC_CONTEXT_USAGE_DETAILS,
|
|
15552
|
+
RC_GOAL_CLEAR_WORDS: () => RC_GOAL_CLEAR_WORDS,
|
|
15553
|
+
RC_GOAL_CONDITION_MAX_CHARS: () => RC_GOAL_CONDITION_MAX_CHARS,
|
|
15549
15554
|
RC_IDLE_EXPIRY_MS: () => RC_IDLE_EXPIRY_MS,
|
|
15550
15555
|
RC_ORPC_PATH_PREFIX: () => RC_ORPC_PATH_PREFIX,
|
|
15551
15556
|
RC_PENDING_DEADLINE_MS: () => RC_PENDING_DEADLINE_MS,
|
|
@@ -15561,6 +15566,8 @@ __export(index_exports, {
|
|
|
15561
15566
|
RC_SELF_HOST_SCOPE_LIST: () => RC_SELF_HOST_SCOPE_LIST,
|
|
15562
15567
|
RC_SELF_HOST_WORKER_JWT_TTL_SECONDS: () => RC_SELF_HOST_WORKER_JWT_TTL_SECONDS,
|
|
15563
15568
|
RC_SESSIONS_PATH_PREFIX: () => RC_SESSIONS_PATH_PREFIX,
|
|
15569
|
+
RC_SESSION_COMMAND_MAX_WAIT_MS: () => RC_SESSION_COMMAND_MAX_WAIT_MS,
|
|
15570
|
+
RC_SESSION_COMMAND_VERIFIED_VERSIONS: () => RC_SESSION_COMMAND_VERIFIED_VERSIONS,
|
|
15564
15571
|
RC_SESSION_END_REASONS: () => RC_SESSION_END_REASONS,
|
|
15565
15572
|
RC_SESSION_EVENT_LOG_CAPACITY: () => RC_SESSION_EVENT_LOG_CAPACITY,
|
|
15566
15573
|
RC_STREAM_BACKOFF_MS: () => RC_STREAM_BACKOFF_MS,
|
|
@@ -15656,11 +15663,13 @@ __export(index_exports, {
|
|
|
15656
15663
|
createQuotaExpiringPublisher: () => createQuotaExpiringPublisher,
|
|
15657
15664
|
createRcApiNodeHandler: () => createRcApiNodeHandler,
|
|
15658
15665
|
createRcApiRouter: () => createRcApiRouter,
|
|
15666
|
+
createRcClaudeCodeVersions: () => createRcClaudeCodeVersions,
|
|
15659
15667
|
createRcControlHandler: () => createRcControlHandler,
|
|
15660
15668
|
createRcCredentialStore: () => createRcCredentialStore,
|
|
15661
15669
|
createRcEventFanout: () => createRcEventFanout,
|
|
15662
15670
|
createRcLiveUsage: () => createRcLiveUsage,
|
|
15663
15671
|
createRcSelfHostSurface: () => createRcSelfHostSurface,
|
|
15672
|
+
createRcSessionCommands: () => createRcSessionCommands,
|
|
15664
15673
|
createRcSessionEventLog: () => createRcSessionEventLog,
|
|
15665
15674
|
createRcSessionEventsApiRouter: () => createRcSessionEventsApiRouter,
|
|
15666
15675
|
createRcSessionRegistryReader: () => createRcSessionRegistryReader,
|
|
@@ -15723,6 +15732,7 @@ __export(index_exports, {
|
|
|
15723
15732
|
mintRcSelfHostCredential: () => mintRcSelfHostCredential,
|
|
15724
15733
|
observingRoutedRoute: () => observingRoutedRoute,
|
|
15725
15734
|
parseConnectTarget: () => parseConnectTarget,
|
|
15735
|
+
parseRcGoalOutput: () => parseRcGoalOutput,
|
|
15726
15736
|
parseRcStreamEnvelope: () => parseRcStreamEnvelope,
|
|
15727
15737
|
planOf: () => planOf,
|
|
15728
15738
|
poolIdentities: () => poolIdentities,
|
|
@@ -15734,6 +15744,8 @@ __export(index_exports, {
|
|
|
15734
15744
|
rankPool: () => rankPool,
|
|
15735
15745
|
rcEventWriteResultFromAnswer: () => rcEventWriteResultFromAnswer,
|
|
15736
15746
|
rcFanoutOnDoorHub: () => rcFanoutOnDoorHub,
|
|
15747
|
+
rcLocalCommandAnswerOf: () => rcLocalCommandAnswerOf,
|
|
15748
|
+
rcManualCompactBoundaryOf: () => rcManualCompactBoundaryOf,
|
|
15737
15749
|
rcObserverAsPassthrough: () => rcObserverAsPassthrough,
|
|
15738
15750
|
rcRateLimitInfoOf: () => rcRateLimitInfoOf,
|
|
15739
15751
|
rcSelfHostFromEnv: () => rcSelfHostFromEnv,
|
|
@@ -16388,9 +16400,11 @@ function createRcSessionTracker(deps) {
|
|
|
16388
16400
|
if (id?.startsWith(RC_SESSION_ID_PREFIX) !== true) {
|
|
16389
16401
|
return void 0;
|
|
16390
16402
|
}
|
|
16403
|
+
const isClientWrite = method === "POST" && (rest === `${id}/events` || rest === `${id}/teleport-events`);
|
|
16404
|
+
const sessionFacts = isClientWrite ? { ...facts, anthropicClientPlatform: void 0 } : facts;
|
|
16391
16405
|
const tracked = entries.get(id);
|
|
16392
16406
|
if (tracked !== void 0) {
|
|
16393
|
-
refresh(tracked,
|
|
16407
|
+
refresh(tracked, sessionFacts);
|
|
16394
16408
|
}
|
|
16395
16409
|
const bodyKind = method === "POST" && rest === `${id}/worker/events` ? "worker-events" : method === "POST" && rest === `${id}/events` ? "client-events" : method === "POST" && rest === `${id}/worker/heartbeat` ? "heartbeat" : method === "PUT" && rest === `${id}/worker` ? "worker-registration" : void 0;
|
|
16396
16410
|
let chunks = [];
|
|
@@ -16460,7 +16474,7 @@ function createRcSessionTracker(deps) {
|
|
|
16460
16474
|
}
|
|
16461
16475
|
accepted = isSuccessful(status);
|
|
16462
16476
|
if (accepted && !entries.has(id)) {
|
|
16463
|
-
persistCredential(birth(id,
|
|
16477
|
+
persistCredential(birth(id, sessionFacts));
|
|
16464
16478
|
}
|
|
16465
16479
|
file();
|
|
16466
16480
|
},
|
|
@@ -18185,6 +18199,11 @@ var import_server2 = require("@orpc/server");
|
|
|
18185
18199
|
var import_node2 = require("@orpc/server/node");
|
|
18186
18200
|
var import_undici = require("undici");
|
|
18187
18201
|
init_package();
|
|
18202
|
+
|
|
18203
|
+
// src/supervise/compactTimeout.ts
|
|
18204
|
+
var COMPACT_TIMEOUT_MS = 9e5;
|
|
18205
|
+
|
|
18206
|
+
// src/frontdoor/rcApi.ts
|
|
18188
18207
|
init_capability();
|
|
18189
18208
|
|
|
18190
18209
|
// src/frontdoor/rcSchemas.ts
|
|
@@ -18356,6 +18375,438 @@ var RcAnswerOutputSchema = import_zod22.z.strictObject({
|
|
|
18356
18375
|
sequenceNums: import_zod22.z.readonly(import_zod22.z.array(import_zod22.z.number()))
|
|
18357
18376
|
});
|
|
18358
18377
|
|
|
18378
|
+
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
18379
|
+
var import_zod23 = require("zod");
|
|
18380
|
+
|
|
18381
|
+
// src/frontdoor/rcSessionCommands.ts
|
|
18382
|
+
var import_promises = require("node:timers/promises");
|
|
18383
|
+
|
|
18384
|
+
// src/supervise/sessionControl.ts
|
|
18385
|
+
var RESULT_POLL_MS = 250;
|
|
18386
|
+
var REQUEST_INSTANT_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
|
|
18387
|
+
|
|
18388
|
+
// src/frontdoor/rcSelfHostCommands.ts
|
|
18389
|
+
var RC_PERSON_CLIENT_PLATFORM = "web_claude_ai";
|
|
18390
|
+
async function writeRcPersonMessage(deps, sessionId, text) {
|
|
18391
|
+
const credential = deps.credentialOf(sessionId);
|
|
18392
|
+
if (credential === void 0) {
|
|
18393
|
+
return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
|
|
18394
|
+
}
|
|
18395
|
+
if (credential.authorization === void 0) {
|
|
18396
|
+
return noOAuthCredentialResult(sessionId);
|
|
18397
|
+
}
|
|
18398
|
+
const body = JSON.stringify(buildRcEventWriteBody(buildRcUserMessagePayload(deps.newUuid(), sessionId, text)));
|
|
18399
|
+
const bytes = Buffer.byteLength(body, "utf8");
|
|
18400
|
+
if (bytes > CONTROL_BODY_CAP_BYTES) {
|
|
18401
|
+
return { ok: false, message: `the command for session ${sessionId} makes an event write of ${String(bytes)} bytes, over the ${String(CONTROL_BODY_CAP_BYTES)} bytes the door's self-hosted surface reads; shorten its arguments` };
|
|
18402
|
+
}
|
|
18403
|
+
let answer;
|
|
18404
|
+
try {
|
|
18405
|
+
answer = await deps.dial.writeEvents(sessionId, rcWriteHeaders({ ...credential, anthropicClientPlatform: RC_PERSON_CLIENT_PLATFORM }), body);
|
|
18406
|
+
} catch (error) {
|
|
18407
|
+
return { ok: false, message: `the door could not write to its own self-hosted surface for session ${sessionId}: ${error instanceof Error ? error.message : String(error)}` };
|
|
18408
|
+
}
|
|
18409
|
+
const result = rcEventWriteResultFromAnswer(answer);
|
|
18410
|
+
if (result.ok) {
|
|
18411
|
+
deps.noteSequenceNums(sessionId, result.sequenceNums);
|
|
18412
|
+
}
|
|
18413
|
+
return result;
|
|
18414
|
+
}
|
|
18415
|
+
function isRecord7(value) {
|
|
18416
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18417
|
+
}
|
|
18418
|
+
function rcLocalCommandAnswerOf(event, command, args) {
|
|
18419
|
+
const payload = event.envelope.payload;
|
|
18420
|
+
if (!isRecord7(payload) || payload.type !== "assistant" || !isRecord7(payload.local_command_run) || payload.local_command_run.command !== command || payload.local_command_run.args !== args) {
|
|
18421
|
+
return void 0;
|
|
18422
|
+
}
|
|
18423
|
+
const message = payload.message;
|
|
18424
|
+
if (!isRecord7(message) || !Array.isArray(message.content)) {
|
|
18425
|
+
return void 0;
|
|
18426
|
+
}
|
|
18427
|
+
const blocks = message.content;
|
|
18428
|
+
const text = blocks.flatMap((block) => isRecord7(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
|
|
18429
|
+
const outcome = isRecord7(payload.local_command_outcome) && typeof payload.local_command_outcome.kind === "string" ? payload.local_command_outcome.kind : void 0;
|
|
18430
|
+
return { text, outcome };
|
|
18431
|
+
}
|
|
18432
|
+
function rcManualCompactBoundaryOf(event) {
|
|
18433
|
+
const payload = event.envelope.payload;
|
|
18434
|
+
if (!isRecord7(payload) || payload.type !== "system" || payload.subtype !== "compact_boundary" || !isRecord7(payload.compact_metadata)) {
|
|
18435
|
+
return void 0;
|
|
18436
|
+
}
|
|
18437
|
+
const metadata = payload.compact_metadata;
|
|
18438
|
+
if (metadata.trigger !== "manual" || typeof metadata.pre_tokens !== "number" || typeof metadata.post_tokens !== "number") {
|
|
18439
|
+
return void 0;
|
|
18440
|
+
}
|
|
18441
|
+
return { trigger: metadata.trigger, preTokens: metadata.pre_tokens, postTokens: metadata.post_tokens };
|
|
18442
|
+
}
|
|
18443
|
+
function isPeerDelivery(event, text) {
|
|
18444
|
+
const payload = event.envelope.payload;
|
|
18445
|
+
if (!isRecord7(payload) || payload.type !== "user" || !isRecord7(payload.origin) || payload.origin.kind !== "peer" || !isRecord7(payload.message)) {
|
|
18446
|
+
return false;
|
|
18447
|
+
}
|
|
18448
|
+
return typeof payload.message.content === "string" && payload.message.content.includes(text);
|
|
18449
|
+
}
|
|
18450
|
+
var NO_GOAL_PREFIX = "No goal set";
|
|
18451
|
+
var ACTIVE_GOAL_PATTERN = /^Goal active: (?<condition>[\s\S]*?) \((?:not yet evaluated|(?<iterations>\d+) turns?)\)(?:\nLast check: (?<lastCheck>[\s\S]*))?$/u;
|
|
18452
|
+
function parseRcGoalOutput(output) {
|
|
18453
|
+
if (output.startsWith(NO_GOAL_PREFIX)) {
|
|
18454
|
+
return { goal: null };
|
|
18455
|
+
}
|
|
18456
|
+
const groups = ACTIVE_GOAL_PATTERN.exec(output)?.groups;
|
|
18457
|
+
const condition = groups?.condition;
|
|
18458
|
+
if (condition === void 0) {
|
|
18459
|
+
return void 0;
|
|
18460
|
+
}
|
|
18461
|
+
return { goal: { condition, iterations: groups?.iterations === void 0 ? 0 : Number(groups.iterations), ...groups?.lastCheck === void 0 ? {} : { lastCheck: groups.lastCheck } } };
|
|
18462
|
+
}
|
|
18463
|
+
var GOAL_CLEARED_PREFIX = "Goal cleared: ";
|
|
18464
|
+
var GOAL_SET_PREFIX = "Goal set: ";
|
|
18465
|
+
function commandLine(command) {
|
|
18466
|
+
if (command.kind === "goal-set") {
|
|
18467
|
+
return { name: "goal", args: command.condition };
|
|
18468
|
+
}
|
|
18469
|
+
if (command.kind === "compact") {
|
|
18470
|
+
return { name: "compact", args: command.instructions ?? "" };
|
|
18471
|
+
}
|
|
18472
|
+
return { name: "goal", args: command.kind === "goal-clear" ? "clear" : "" };
|
|
18473
|
+
}
|
|
18474
|
+
function recognise(command, event, name, args) {
|
|
18475
|
+
if (command.kind === "compact") {
|
|
18476
|
+
const boundary = rcManualCompactBoundaryOf(event);
|
|
18477
|
+
if (boundary !== void 0) {
|
|
18478
|
+
return { ok: true, report: boundary };
|
|
18479
|
+
}
|
|
18480
|
+
}
|
|
18481
|
+
const answer = rcLocalCommandAnswerOf(event, name, args);
|
|
18482
|
+
if (answer === void 0) {
|
|
18483
|
+
return void 0;
|
|
18484
|
+
}
|
|
18485
|
+
if (answer.outcome === "failed") {
|
|
18486
|
+
return { ok: false, message: `the worker reported /${name} failed: ${answer.text}` };
|
|
18487
|
+
}
|
|
18488
|
+
if (command.kind === "goal-get") {
|
|
18489
|
+
const report = parseRcGoalOutput(answer.text);
|
|
18490
|
+
return report === void 0 ? { ok: false, message: `the worker answered /goal with text the verified versions never produce: ${answer.text}` } : { ok: true, report };
|
|
18491
|
+
}
|
|
18492
|
+
if (command.kind === "goal-set") {
|
|
18493
|
+
return answer.text.startsWith(GOAL_SET_PREFIX) ? { ok: true, report: { condition: answer.text.slice(GOAL_SET_PREFIX.length) } } : { ok: false, message: `the worker did not set the goal: ${answer.text}` };
|
|
18494
|
+
}
|
|
18495
|
+
if (command.kind === "goal-clear") {
|
|
18496
|
+
if (answer.text.startsWith(GOAL_CLEARED_PREFIX)) {
|
|
18497
|
+
return { ok: true, report: { cleared: answer.text.slice(GOAL_CLEARED_PREFIX.length) } };
|
|
18498
|
+
}
|
|
18499
|
+
return answer.text === NO_GOAL_PREFIX ? { ok: true, report: { cleared: null } } : { ok: false, message: `the worker answered /goal clear with text the verified versions never produce: ${answer.text}` };
|
|
18500
|
+
}
|
|
18501
|
+
return { ok: false, message: `the worker did not compact the session: ${answer.text}` };
|
|
18502
|
+
}
|
|
18503
|
+
async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signal) {
|
|
18504
|
+
const { name, args } = commandLine(command);
|
|
18505
|
+
const text = args === "" ? `/${name}` : `/${name} ${args}`;
|
|
18506
|
+
const early = [];
|
|
18507
|
+
let after;
|
|
18508
|
+
let settle;
|
|
18509
|
+
const judge = (event) => {
|
|
18510
|
+
if (after === void 0) {
|
|
18511
|
+
early.push(event);
|
|
18512
|
+
return;
|
|
18513
|
+
}
|
|
18514
|
+
if (event.envelope.sequence_num <= after || event.envelope.source !== "worker") {
|
|
18515
|
+
return;
|
|
18516
|
+
}
|
|
18517
|
+
if (isPeerDelivery(event, text)) {
|
|
18518
|
+
settle?.({ ok: false, message: `session ${sessionId}'s worker passed ${text} to its model as a peer's message instead of running it, so it did not read the write as a person's` });
|
|
18519
|
+
return;
|
|
18520
|
+
}
|
|
18521
|
+
const outcome = recognise(command, event, name, args);
|
|
18522
|
+
if (outcome !== void 0) {
|
|
18523
|
+
settle?.(outcome);
|
|
18524
|
+
}
|
|
18525
|
+
};
|
|
18526
|
+
const detach = deps.fanout.subscribe(sessionId, judge);
|
|
18527
|
+
let cancelTimer;
|
|
18528
|
+
const onAbort = () => {
|
|
18529
|
+
settle?.({ ok: false, message: `the request for ${text} on session ${sessionId} was aborted before the worker answered` });
|
|
18530
|
+
};
|
|
18531
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
18532
|
+
try {
|
|
18533
|
+
const answered = new Promise((resolve) => {
|
|
18534
|
+
settle = resolve;
|
|
18535
|
+
});
|
|
18536
|
+
const written = await writeRcPersonMessage(deps.personWrite, sessionId, text);
|
|
18537
|
+
if (!written.ok) {
|
|
18538
|
+
return written;
|
|
18539
|
+
}
|
|
18540
|
+
if (signal.aborted) {
|
|
18541
|
+
return { ok: false, message: `the request for ${text} on session ${sessionId} was aborted after it was written (sequence_num ${written.sequenceNums.join(", ")})` };
|
|
18542
|
+
}
|
|
18543
|
+
after = Math.max(...written.sequenceNums);
|
|
18544
|
+
const bound = waitMs ?? deps.defaultWaitMs;
|
|
18545
|
+
cancelTimer = deps.setTimer(() => {
|
|
18546
|
+
settle?.({ ok: false, message: `${text} was delivered to session ${sessionId} (sequence_num ${written.sequenceNums.join(", ")}) but the worker reported no outcome within ${String(bound)} ms; it may still be queued behind a running turn, so read the session's stream before sending it again` });
|
|
18547
|
+
}, bound);
|
|
18548
|
+
for (const event of early.splice(0)) {
|
|
18549
|
+
judge(event);
|
|
18550
|
+
}
|
|
18551
|
+
return await answered;
|
|
18552
|
+
} finally {
|
|
18553
|
+
signal.removeEventListener("abort", onAbort);
|
|
18554
|
+
cancelTimer?.();
|
|
18555
|
+
detach();
|
|
18556
|
+
}
|
|
18557
|
+
}
|
|
18558
|
+
function createRcClaudeCodeVersions(fanout) {
|
|
18559
|
+
const versions = /* @__PURE__ */ new Map();
|
|
18560
|
+
fanout.subscribe(void 0, (event) => {
|
|
18561
|
+
const payload = event.envelope.payload;
|
|
18562
|
+
if (event.envelope.source === "worker" && isRecord7(payload) && payload.type === "system" && payload.subtype === "init" && typeof payload.claude_code_version === "string") {
|
|
18563
|
+
versions.set(event.session, payload.claude_code_version);
|
|
18564
|
+
}
|
|
18565
|
+
});
|
|
18566
|
+
return {
|
|
18567
|
+
versionOf: (sessionId) => versions.get(sessionId),
|
|
18568
|
+
sweep: (isTracked) => {
|
|
18569
|
+
for (const sessionId of [...versions.keys()]) {
|
|
18570
|
+
if (!isTracked(sessionId)) {
|
|
18571
|
+
versions.delete(sessionId);
|
|
18572
|
+
}
|
|
18573
|
+
}
|
|
18574
|
+
}
|
|
18575
|
+
};
|
|
18576
|
+
}
|
|
18577
|
+
|
|
18578
|
+
// src/frontdoor/rcSessionCommands.ts
|
|
18579
|
+
var RC_SESSION_COMMAND_VERIFIED_VERSIONS = ["2.1.319"];
|
|
18580
|
+
var RC_GOAL_CLEAR_WORDS = ["clear", "stop", "off", "reset", "none", "cancel"];
|
|
18581
|
+
var RC_GOAL_CONDITION_MAX_CHARS = 4e3;
|
|
18582
|
+
var MAX_JSON_BYTES_PER_CODE_UNIT = 6;
|
|
18583
|
+
var RC_COMPACT_INSTRUCTIONS_MAX_CHARS = Math.floor(CONTROL_BODY_CAP_BYTES / MAX_JSON_BYTES_PER_CODE_UNIT);
|
|
18584
|
+
var RC_SESSION_COMMAND_MAX_WAIT_MS = 2147483647;
|
|
18585
|
+
function unverifiedVersionMessage(sessionId, version, source) {
|
|
18586
|
+
const verified = RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ");
|
|
18587
|
+
return version === void 0 ? `session ${sessionId} has not reported its Claude Code version (${source}), and goal and compaction control is verified only on Claude Code ${verified}` : `session ${sessionId} runs Claude Code ${version}, and goal and compaction control is verified only on Claude Code ${verified}: the door will not act on a version whose behaviour it has not verified`;
|
|
18588
|
+
}
|
|
18589
|
+
function unsupportedMessage(sessionId) {
|
|
18590
|
+
return `session ${sessionId} was not launched under an agent-shim supervisor, so the door has no in-process channel into it, and it is not on the door's own self-hosted surface. Over the real Remote Control service, Claude Code ${RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ")} runs a slash command only when a person's app wrote it and treats any other writer as a peer, whose message the model reads as text, and the door does not claim to be a person's app on a service it does not run. Launch the session under a pool with resumeOnLimit (which supervises it), or run it against the door's self-hosted surface.`;
|
|
18591
|
+
}
|
|
18592
|
+
function createRcSessionCommands(deps) {
|
|
18593
|
+
const queues = /* @__PURE__ */ new Map();
|
|
18594
|
+
const serialised = async (sessionId, work) => {
|
|
18595
|
+
const before = queues.get(sessionId) ?? Promise.resolve();
|
|
18596
|
+
const run = before.then(work, work);
|
|
18597
|
+
const settled = run.then(() => void 0, () => void 0);
|
|
18598
|
+
queues.set(sessionId, settled);
|
|
18599
|
+
try {
|
|
18600
|
+
return await run;
|
|
18601
|
+
} finally {
|
|
18602
|
+
if (queues.get(sessionId) === settled) {
|
|
18603
|
+
queues.delete(sessionId);
|
|
18604
|
+
}
|
|
18605
|
+
}
|
|
18606
|
+
};
|
|
18607
|
+
const onRoute = async (sessionId, options, actions) => await serialised(sessionId, async () => {
|
|
18608
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
18609
|
+
if (signal.aborted) {
|
|
18610
|
+
return { ok: false, message: `the request for session ${sessionId} was aborted before it ran` };
|
|
18611
|
+
}
|
|
18612
|
+
const target = await deps.supervisedOf(sessionId);
|
|
18613
|
+
if (target !== void 0 && "refused" in target) {
|
|
18614
|
+
return { ok: false, message: target.refused };
|
|
18615
|
+
}
|
|
18616
|
+
if (target !== void 0) {
|
|
18617
|
+
if (target.version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(target.version)) {
|
|
18618
|
+
return { ok: false, message: unverifiedVersionMessage(sessionId, target.version, "its supervisor's control plugin has not loaded") };
|
|
18619
|
+
}
|
|
18620
|
+
const waitMs = options.waitMs ?? COMPACT_TIMEOUT_MS;
|
|
18621
|
+
const timeout = AbortSignal.timeout(waitMs);
|
|
18622
|
+
const bounded3 = AbortSignal.any([signal, timeout]);
|
|
18623
|
+
try {
|
|
18624
|
+
return await actions.supervised(target, bounded3, waitMs);
|
|
18625
|
+
} catch (error) {
|
|
18626
|
+
if (timeout.aborted) {
|
|
18627
|
+
return { ok: false, message: `session ${sessionId}'s control plugin did not answer within ${String(waitMs)} ms. A request the plugin had not started is withdrawn; one it had started runs once the session is idle (a turn waiting on a permission prompt holds it), so read the session's goal or transcript before asking again` };
|
|
18628
|
+
}
|
|
18629
|
+
return { ok: false, message: `session ${sessionId}'s control plugin did not complete the request: ${error instanceof Error ? error.message : String(error)}` };
|
|
18630
|
+
}
|
|
18631
|
+
}
|
|
18632
|
+
if (!deps.isObserved(sessionId)) {
|
|
18633
|
+
return { ok: false, message: `the front door has not observed Remote Control session ${sessionId}` };
|
|
18634
|
+
}
|
|
18635
|
+
if (deps.selfHost !== void 0) {
|
|
18636
|
+
const unavailable = deps.selfHost.unavailable();
|
|
18637
|
+
if (unavailable !== void 0) {
|
|
18638
|
+
return { ok: false, message: `session ${sessionId} was not launched under an agent-shim supervisor, and the door's self-hosted surface cannot take a command: ${unavailable}` };
|
|
18639
|
+
}
|
|
18640
|
+
const version = deps.selfHost.versionOf(sessionId);
|
|
18641
|
+
if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
|
|
18642
|
+
return { ok: false, message: unverifiedVersionMessage(sessionId, version, "no system/init from its worker has been observed on its stream; send it a prompt so it reports one") };
|
|
18643
|
+
}
|
|
18644
|
+
const waitMs = options.waitMs ?? deps.selfHost.defaultWaitMs;
|
|
18645
|
+
const timeout = AbortSignal.timeout(waitMs);
|
|
18646
|
+
const result = await actions.selfHosted(deps.selfHost, AbortSignal.any([signal, timeout]));
|
|
18647
|
+
if (!result.ok && timeout.aborted) {
|
|
18648
|
+
return { ok: false, message: `session ${sessionId}'s worker did not answer within ${String(waitMs)} ms in all; it may still be queued behind a running turn, so read the session's stream before asking again` };
|
|
18649
|
+
}
|
|
18650
|
+
return result;
|
|
18651
|
+
}
|
|
18652
|
+
return { ok: false, message: unsupportedMessage(sessionId) };
|
|
18653
|
+
});
|
|
18654
|
+
const transcriptGoal = async (sessionId, target) => {
|
|
18655
|
+
const goal = target.transcriptPath === void 0 ? void 0 : await deps.goalOf(target.transcriptPath);
|
|
18656
|
+
if (goal === void 0) {
|
|
18657
|
+
return { ok: false, message: `session ${sessionId}'s supervisor has not recorded its transcript yet, which is where its goal is read from; retry once it has finished a turn` };
|
|
18658
|
+
}
|
|
18659
|
+
return { ok: true, report: goal };
|
|
18660
|
+
};
|
|
18661
|
+
const settledGoal = async (sessionId, target, signal, holds) => {
|
|
18662
|
+
for (; ; ) {
|
|
18663
|
+
const read = await transcriptGoal(sessionId, target);
|
|
18664
|
+
if (!read.ok || holds(read.report) || signal.aborted) {
|
|
18665
|
+
return read;
|
|
18666
|
+
}
|
|
18667
|
+
await (0, import_promises.setTimeout)(RESULT_POLL_MS);
|
|
18668
|
+
}
|
|
18669
|
+
};
|
|
18670
|
+
const waitOf = (options) => options.waitMs;
|
|
18671
|
+
return {
|
|
18672
|
+
/** Reads the session's goal: from the transcript for a supervised session, with no effect on it; by running `/goal` on the self-hosted surface otherwise. */
|
|
18673
|
+
goalGet: async (sessionId, options = {}) => await onRoute(sessionId, options, {
|
|
18674
|
+
supervised: async (target) => {
|
|
18675
|
+
const read = await transcriptGoal(sessionId, target);
|
|
18676
|
+
return await Promise.resolve(read.ok ? { ok: true, report: { route: "supervised", goal: read.report } } : read);
|
|
18677
|
+
},
|
|
18678
|
+
selfHosted: async (selfHost, signal) => {
|
|
18679
|
+
const read = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
|
|
18680
|
+
return read.ok ? { ok: true, report: { route: "self-hosted", goal: read.report.goal } } : read;
|
|
18681
|
+
}
|
|
18682
|
+
}),
|
|
18683
|
+
/**
|
|
18684
|
+
* Sets the session's goal: the goal check then keeps the session working until the condition holds, and the condition reaches its model as a directive (`docs/rc-slash-commands.md`, the trust boundary). Refused unsent: an empty condition, one `/goal` reads as a clear, and one longer than it accepts. The answer names the goal it replaced.
|
|
18685
|
+
*/
|
|
18686
|
+
goalSet: async (sessionId, condition, options = {}) => {
|
|
18687
|
+
const trimmed = condition.trim();
|
|
18688
|
+
if (trimmed === "") {
|
|
18689
|
+
return { ok: false, message: "a goal set needs a non-empty condition" };
|
|
18690
|
+
}
|
|
18691
|
+
if (RC_GOAL_CLEAR_WORDS.includes(trimmed.toLowerCase())) {
|
|
18692
|
+
return { ok: false, message: `"${trimmed}" cannot be set as a goal condition: /goal reads ${RC_GOAL_CLEAR_WORDS.join(", ")} as a request to clear the goal, so use the clear verb for that` };
|
|
18693
|
+
}
|
|
18694
|
+
if (/[\r\n]/u.test(trimmed)) {
|
|
18695
|
+
return { ok: false, message: "a goal condition is one line: /goal reads its condition from the line it is typed on, and both routes confirm the goal by the exact condition, so a condition spanning lines is refused rather than set as something else" };
|
|
18696
|
+
}
|
|
18697
|
+
if (trimmed.length > RC_GOAL_CONDITION_MAX_CHARS) {
|
|
18698
|
+
return { ok: false, message: `a goal condition is limited to ${String(RC_GOAL_CONDITION_MAX_CHARS)} characters, and this one has ${String(trimmed.length)}` };
|
|
18699
|
+
}
|
|
18700
|
+
return await onRoute(sessionId, options, {
|
|
18701
|
+
supervised: async (target, signal, waitMs) => {
|
|
18702
|
+
const before = await transcriptGoal(sessionId, target);
|
|
18703
|
+
if (!before.ok) {
|
|
18704
|
+
return before;
|
|
18705
|
+
}
|
|
18706
|
+
await target.runGoal(trimmed, signal, waitMs);
|
|
18707
|
+
const after = await settledGoal(sessionId, target, signal, (goal) => goal?.condition === trimmed);
|
|
18708
|
+
if (!after.ok) {
|
|
18709
|
+
return after;
|
|
18710
|
+
}
|
|
18711
|
+
return after.report?.condition === trimmed ? { ok: true, report: { route: "supervised", condition: trimmed, superseded: before.report?.condition ?? null } } : { ok: false, message: `session ${sessionId} ran /goal but its transcript does not record the goal as set` };
|
|
18712
|
+
},
|
|
18713
|
+
selfHosted: async (selfHost, signal) => {
|
|
18714
|
+
const before = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
|
|
18715
|
+
if (!before.ok) {
|
|
18716
|
+
return before;
|
|
18717
|
+
}
|
|
18718
|
+
const set = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-set", condition: trimmed }, waitOf(options), signal);
|
|
18719
|
+
return set.ok ? { ok: true, report: { route: "self-hosted", condition: set.report.condition, superseded: before.report.goal?.condition ?? null } } : set;
|
|
18720
|
+
}
|
|
18721
|
+
});
|
|
18722
|
+
},
|
|
18723
|
+
/** Clears the session's goal and names the condition it cleared, or `null` when there was none, which is not a failure (clearing is idempotent). */
|
|
18724
|
+
goalClear: async (sessionId, options = {}) => await onRoute(sessionId, options, {
|
|
18725
|
+
supervised: async (target, signal, waitMs) => {
|
|
18726
|
+
const before = await transcriptGoal(sessionId, target);
|
|
18727
|
+
if (!before.ok) {
|
|
18728
|
+
return before;
|
|
18729
|
+
}
|
|
18730
|
+
if (before.report === null) {
|
|
18731
|
+
return { ok: true, report: { route: "supervised", cleared: null } };
|
|
18732
|
+
}
|
|
18733
|
+
await target.runGoal("clear", signal, waitMs);
|
|
18734
|
+
const after = await settledGoal(sessionId, target, signal, (goal) => goal === null);
|
|
18735
|
+
if (!after.ok) {
|
|
18736
|
+
return after;
|
|
18737
|
+
}
|
|
18738
|
+
return after.report === null ? { ok: true, report: { route: "supervised", cleared: before.report.condition } } : { ok: false, message: `session ${sessionId} ran /goal clear but its transcript still records the goal "${after.report.condition}"` };
|
|
18739
|
+
},
|
|
18740
|
+
selfHosted: async (selfHost, signal) => {
|
|
18741
|
+
const cleared = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-clear" }, waitOf(options), signal);
|
|
18742
|
+
return cleared.ok ? { ok: true, report: { route: "self-hosted", cleared: cleared.report.cleared } } : cleared;
|
|
18743
|
+
}
|
|
18744
|
+
}),
|
|
18745
|
+
/** Compacts the session's conversation, with custom summary instructions when given, and resolves with the outcome: the trigger and token counts, or the session's reason for not compacting. */
|
|
18746
|
+
compact: async (sessionId, options = {}) => {
|
|
18747
|
+
const instructions = options.instructions?.trim();
|
|
18748
|
+
const given = instructions === void 0 || instructions === "" ? void 0 : instructions;
|
|
18749
|
+
return await onRoute(sessionId, options, {
|
|
18750
|
+
supervised: async (target, signal, waitMs) => {
|
|
18751
|
+
const result = await target.compact(signal, given, waitMs);
|
|
18752
|
+
if (result.kind === "unchanged") {
|
|
18753
|
+
return { ok: false, message: `session ${sessionId} was not compacted: ${result.reason}` };
|
|
18754
|
+
}
|
|
18755
|
+
return { ok: true, report: { route: "supervised", trigger: "plugin", ...result.beforeTokens === void 0 ? {} : { preTokens: result.beforeTokens }, ...result.afterTokens === void 0 ? {} : { postTokens: result.afterTokens } } };
|
|
18756
|
+
},
|
|
18757
|
+
selfHosted: async (selfHost, signal) => {
|
|
18758
|
+
const compacted = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "compact", instructions: given }, waitOf(options), signal);
|
|
18759
|
+
return compacted.ok ? { ok: true, report: { route: "self-hosted", ...compacted.report } } : compacted;
|
|
18760
|
+
}
|
|
18761
|
+
});
|
|
18762
|
+
}
|
|
18763
|
+
};
|
|
18764
|
+
}
|
|
18765
|
+
|
|
18766
|
+
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
18767
|
+
var WaitMsSchema = import_zod23.z.int().positive().max(RC_SESSION_COMMAND_MAX_WAIT_MS).optional();
|
|
18768
|
+
var RcGoalSessionInputSchema = import_zod23.z.strictObject({
|
|
18769
|
+
session: import_zod23.z.string().min(1),
|
|
18770
|
+
waitMs: WaitMsSchema
|
|
18771
|
+
});
|
|
18772
|
+
var RcGoalSetInputSchema = import_zod23.z.strictObject({
|
|
18773
|
+
session: import_zod23.z.string().min(1),
|
|
18774
|
+
condition: import_zod23.z.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
|
|
18775
|
+
waitMs: WaitMsSchema
|
|
18776
|
+
});
|
|
18777
|
+
var RcCompactInputSchema = import_zod23.z.strictObject({
|
|
18778
|
+
session: import_zod23.z.string().min(1),
|
|
18779
|
+
waitMs: WaitMsSchema
|
|
18780
|
+
});
|
|
18781
|
+
var RcCompactWithInstructionsInputSchema = import_zod23.z.strictObject({
|
|
18782
|
+
session: import_zod23.z.string().min(1),
|
|
18783
|
+
instructions: import_zod23.z.string().trim().min(1).max(RC_COMPACT_INSTRUCTIONS_MAX_CHARS),
|
|
18784
|
+
waitMs: WaitMsSchema
|
|
18785
|
+
});
|
|
18786
|
+
var commandAnswerShape = {
|
|
18787
|
+
session: import_zod23.z.string(),
|
|
18788
|
+
route: import_zod23.z.enum(["supervised", "self-hosted"])
|
|
18789
|
+
};
|
|
18790
|
+
var RcGoalGetOutputSchema = import_zod23.z.strictObject({
|
|
18791
|
+
...commandAnswerShape,
|
|
18792
|
+
goal: import_zod23.z.strictObject({ condition: import_zod23.z.string(), iterations: import_zod23.z.int().nonnegative(), lastCheck: import_zod23.z.string().optional() }).nullable()
|
|
18793
|
+
});
|
|
18794
|
+
var RcGoalSetOutputSchema = import_zod23.z.strictObject({
|
|
18795
|
+
...commandAnswerShape,
|
|
18796
|
+
condition: import_zod23.z.string(),
|
|
18797
|
+
superseded: import_zod23.z.string().nullable()
|
|
18798
|
+
});
|
|
18799
|
+
var RcGoalClearOutputSchema = import_zod23.z.strictObject({
|
|
18800
|
+
...commandAnswerShape,
|
|
18801
|
+
cleared: import_zod23.z.string().nullable()
|
|
18802
|
+
});
|
|
18803
|
+
var RcCompactOutputSchema = import_zod23.z.strictObject({
|
|
18804
|
+
...commandAnswerShape,
|
|
18805
|
+
trigger: import_zod23.z.string(),
|
|
18806
|
+
preTokens: import_zod23.z.number().optional(),
|
|
18807
|
+
postTokens: import_zod23.z.number().optional()
|
|
18808
|
+
});
|
|
18809
|
+
|
|
18359
18810
|
// src/frontdoor/rcApi.ts
|
|
18360
18811
|
var RC_ORPC_PATH_PREFIX = "/__agent-shim/orpc";
|
|
18361
18812
|
var RC_OPENAPI_DOC_PATH = "/openapi.json";
|
|
@@ -18377,6 +18828,7 @@ function doorApiAuth(expectedToken) {
|
|
|
18377
18828
|
});
|
|
18378
18829
|
}
|
|
18379
18830
|
var RC_API_TAG = "remote-control";
|
|
18831
|
+
var RC_DIRECTIVE_TAG = "remote-control-directives";
|
|
18380
18832
|
function createRcApiRouter(deps) {
|
|
18381
18833
|
const authed = doorApiAuth(deps.expectedToken);
|
|
18382
18834
|
const delivered = (sessionId, result) => {
|
|
@@ -18394,6 +18846,13 @@ function createRcApiRouter(deps) {
|
|
|
18394
18846
|
}
|
|
18395
18847
|
return { request: result.requestId, sequenceNums: result.sequenceNums };
|
|
18396
18848
|
};
|
|
18849
|
+
const commanded = (sessionId, result) => {
|
|
18850
|
+
if (!result.ok) {
|
|
18851
|
+
throw new import_client.ORPCError("BAD_GATEWAY", { message: result.message });
|
|
18852
|
+
}
|
|
18853
|
+
return { session: sessionId, ...result.report };
|
|
18854
|
+
};
|
|
18855
|
+
const optionsOf = (waitMs, signal) => ({ ...waitMs === void 0 ? {} : { waitMs }, ...signal === void 0 ? {} : { signal } });
|
|
18397
18856
|
return {
|
|
18398
18857
|
rc: {
|
|
18399
18858
|
list: authed.meta((0, import_openapi.openapi)({ method: "GET", path: "/rest/rc/sessions", summary: "List the observed Remote Control sessions", tags: [RC_API_TAG] })).output(RcListOutputSchema).handler(() => ({ sessions: deps.list() })),
|
|
@@ -18430,6 +18889,11 @@ function createRcApiRouter(deps) {
|
|
|
18430
18889
|
mcpAuthenticate: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/mcp-authenticate", summary: "Start OAuth for one MCP server on a session", tags: [RC_API_TAG] })).input(RcMcpAuthenticateInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, ...deliveredControl(input.session, await deps.mcpAuthenticate(input.session, input.serverName, input.redirectUri)) })),
|
|
18431
18890
|
mcpOAuthCallbackUrl: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/mcp-oauth-callback-url", summary: "Hand a completed MCP OAuth callback to a session", tags: [RC_API_TAG] })).input(RcMcpOAuthCallbackUrlInputSchema).output(RcControlWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, ...deliveredControl(input.session, await deps.mcpOAuthCallbackUrl(input.session, input.serverName, input.callbackUrl)) })),
|
|
18432
18891
|
teleport: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/teleport", summary: "Teleport a session to a conversation marker", tags: [RC_API_TAG] })).input(RcTeleportInputSchema).output(RcWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, sequenceNums: delivered(input.session, await deps.teleport(input.session, input.marker)) })),
|
|
18892
|
+
goalGet: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/goal/get", summary: "Read a session's goal", tags: [RC_API_TAG] })).input(RcGoalSessionInputSchema).output(RcGoalGetOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.goalGet(input.session, optionsOf(input.waitMs, signal)))),
|
|
18893
|
+
goalSet: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/goal/set", summary: "Set a session's goal, a directive its model then works to", tags: [RC_DIRECTIVE_TAG] })).input(RcGoalSetInputSchema).output(RcGoalSetOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.goalSet(input.session, input.condition, optionsOf(input.waitMs, signal)))),
|
|
18894
|
+
goalClear: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/goal/clear", summary: "Clear a session's goal", tags: [RC_API_TAG] })).input(RcGoalSessionInputSchema).output(RcGoalClearOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.goalClear(input.session, optionsOf(input.waitMs, signal)))),
|
|
18895
|
+
compact: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/compact", summary: "Compact a session's conversation", tags: [RC_API_TAG] })).input(RcCompactInputSchema).output(RcCompactOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.compact(input.session, optionsOf(input.waitMs, signal)))),
|
|
18896
|
+
compactWithInstructions: authed.meta((0, import_openapi.openapi)({ method: "POST", path: "/rest/rc/compact-with-instructions", summary: "Compact a session's conversation under summary instructions, a directive to its model", tags: [RC_DIRECTIVE_TAG] })).input(RcCompactWithInstructionsInputSchema).output(RcCompactOutputSchema).handler(async ({ input, signal }) => commanded(input.session, await deps.compact(input.session, { ...optionsOf(input.waitMs, signal), instructions: input.instructions }))),
|
|
18433
18897
|
subscribe: authed.meta((0, import_openapi.openapi)({ method: "GET", path: "/rest/rc/events", summary: "Stream a session's Remote Control events (SSE)", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output((0, import_server2.eventIterator)(RcStreamEventSchema)).handler(async function* ({ input, signal }) {
|
|
18434
18898
|
const queue = [];
|
|
18435
18899
|
let wake;
|
|
@@ -18510,8 +18974,27 @@ function doorApiNodeHandlerOf(router, expectedToken) {
|
|
|
18510
18974
|
function createRcApiNodeHandler(deps) {
|
|
18511
18975
|
return doorApiNodeHandlerOf(createRcApiRouter(deps), deps.expectedToken);
|
|
18512
18976
|
}
|
|
18977
|
+
var DEFAULT_HEADERS_TIMEOUT_MS = 3e5;
|
|
18978
|
+
var SESSION_COMMAND_PROCEDURES = ["rc/goalGet", "rc/goalSet", "rc/goalClear", "rc/compact", "rc/compactWithInstructions"];
|
|
18979
|
+
function headersTimeoutOf(url, body) {
|
|
18980
|
+
if (!SESSION_COMMAND_PROCEDURES.some((procedure) => url.endsWith(`${RC_ORPC_PATH_PREFIX}/${procedure}`))) {
|
|
18981
|
+
return DEFAULT_HEADERS_TIMEOUT_MS;
|
|
18982
|
+
}
|
|
18983
|
+
const parsed = body === void 0 ? void 0 : JSON.parse(body.toString("utf8"));
|
|
18984
|
+
const waitMs = typeof parsed === "object" && parsed !== null && "json" in parsed && typeof parsed.json === "object" && parsed.json !== null && "waitMs" in parsed.json && typeof parsed.json.waitMs === "number" ? parsed.json.waitMs : COMPACT_TIMEOUT_MS;
|
|
18985
|
+
return Math.min(waitMs + DEFAULT_HEADERS_TIMEOUT_MS, RC_SESSION_COMMAND_MAX_WAIT_MS);
|
|
18986
|
+
}
|
|
18513
18987
|
function frontDoorApiLink(port, ca, token) {
|
|
18514
|
-
const
|
|
18988
|
+
const dispatchers = /* @__PURE__ */ new Map();
|
|
18989
|
+
const dispatcherFor = (headersTimeout) => {
|
|
18990
|
+
const existing = dispatchers.get(headersTimeout);
|
|
18991
|
+
if (existing !== void 0) {
|
|
18992
|
+
return existing;
|
|
18993
|
+
}
|
|
18994
|
+
const created = new import_undici.Agent({ connect: { ca }, headersTimeout });
|
|
18995
|
+
dispatchers.set(headersTimeout, created);
|
|
18996
|
+
return created;
|
|
18997
|
+
};
|
|
18515
18998
|
return new import_fetch.RPCLink({
|
|
18516
18999
|
origin: `https://127.0.0.1:${String(port)}`,
|
|
18517
19000
|
url: RC_ORPC_PATH_PREFIX,
|
|
@@ -18524,7 +19007,7 @@ function frontDoorApiLink(port, ca, token) {
|
|
|
18524
19007
|
method: request4.method,
|
|
18525
19008
|
headers: [...request4.headers],
|
|
18526
19009
|
...body === void 0 ? {} : { body },
|
|
18527
|
-
dispatcher,
|
|
19010
|
+
dispatcher: dispatcherFor(headersTimeoutOf(request4.url, body)),
|
|
18528
19011
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
18529
19012
|
});
|
|
18530
19013
|
return new Response(answered.body, { status: answered.status, statusText: answered.statusText, headers: [...answered.headers] });
|
|
@@ -18540,48 +19023,48 @@ init_cliError();
|
|
|
18540
19023
|
init_package();
|
|
18541
19024
|
|
|
18542
19025
|
// src/codex/appServerSchemas.ts
|
|
18543
|
-
var
|
|
19026
|
+
var import_zod24 = require("zod");
|
|
18544
19027
|
var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
|
|
18545
|
-
var RateLimitWindowSchema =
|
|
18546
|
-
usedPercent:
|
|
18547
|
-
resetsAt:
|
|
18548
|
-
windowDurationMins:
|
|
18549
|
-
});
|
|
18550
|
-
var RateLimitSnapshotSchema =
|
|
18551
|
-
limitId:
|
|
18552
|
-
limitName:
|
|
18553
|
-
planType:
|
|
19028
|
+
var RateLimitWindowSchema = import_zod24.z.object({
|
|
19029
|
+
usedPercent: import_zod24.z.number(),
|
|
19030
|
+
resetsAt: import_zod24.z.number().nullish(),
|
|
19031
|
+
windowDurationMins: import_zod24.z.number().nullish()
|
|
19032
|
+
});
|
|
19033
|
+
var RateLimitSnapshotSchema = import_zod24.z.object({
|
|
19034
|
+
limitId: import_zod24.z.string().nullish(),
|
|
19035
|
+
limitName: import_zod24.z.string().nullish(),
|
|
19036
|
+
planType: import_zod24.z.string().nullish(),
|
|
18554
19037
|
primary: RateLimitWindowSchema.nullish(),
|
|
18555
19038
|
secondary: RateLimitWindowSchema.nullish(),
|
|
18556
|
-
rateLimitReachedType:
|
|
18557
|
-
spendControlReached:
|
|
18558
|
-
});
|
|
18559
|
-
var RateLimitResetCreditSchema =
|
|
18560
|
-
id:
|
|
18561
|
-
grantedAt:
|
|
18562
|
-
expiresAt:
|
|
18563
|
-
resetType:
|
|
18564
|
-
status:
|
|
18565
|
-
title:
|
|
18566
|
-
description:
|
|
18567
|
-
});
|
|
18568
|
-
var CodexAccountSchema =
|
|
18569
|
-
|
|
18570
|
-
|
|
18571
|
-
|
|
19039
|
+
rateLimitReachedType: import_zod24.z.string().nullish(),
|
|
19040
|
+
spendControlReached: import_zod24.z.boolean().nullish()
|
|
19041
|
+
});
|
|
19042
|
+
var RateLimitResetCreditSchema = import_zod24.z.object({
|
|
19043
|
+
id: import_zod24.z.string(),
|
|
19044
|
+
grantedAt: import_zod24.z.number(),
|
|
19045
|
+
expiresAt: import_zod24.z.number().nullish(),
|
|
19046
|
+
resetType: import_zod24.z.string(),
|
|
19047
|
+
status: import_zod24.z.string(),
|
|
19048
|
+
title: import_zod24.z.string().nullish(),
|
|
19049
|
+
description: import_zod24.z.string().nullish()
|
|
19050
|
+
});
|
|
19051
|
+
var CodexAccountSchema = import_zod24.z.discriminatedUnion("type", [
|
|
19052
|
+
import_zod24.z.object({ type: import_zod24.z.literal("apiKey") }),
|
|
19053
|
+
import_zod24.z.object({ type: import_zod24.z.literal("chatgpt"), email: import_zod24.z.string().nullable(), planType: import_zod24.z.string() }),
|
|
19054
|
+
import_zod24.z.object({ type: import_zod24.z.literal("amazonBedrock"), usesCodexManagedCredentials: import_zod24.z.boolean().default(false) })
|
|
18572
19055
|
]);
|
|
18573
|
-
var CodexAccountReadSchema =
|
|
19056
|
+
var CodexAccountReadSchema = import_zod24.z.object({
|
|
18574
19057
|
account: CodexAccountSchema.nullable(),
|
|
18575
|
-
requiresOpenaiAuth:
|
|
19058
|
+
requiresOpenaiAuth: import_zod24.z.boolean()
|
|
18576
19059
|
});
|
|
18577
|
-
var CodexRateLimitsReadSchema =
|
|
19060
|
+
var CodexRateLimitsReadSchema = import_zod24.z.object({
|
|
18578
19061
|
rateLimits: RateLimitSnapshotSchema,
|
|
18579
|
-
rateLimitsByLimitId:
|
|
18580
|
-
rateLimitResetCredits:
|
|
18581
|
-
accountId:
|
|
18582
|
-
ordinaryUsageAllowed:
|
|
19062
|
+
rateLimitsByLimitId: import_zod24.z.record(import_zod24.z.string(), RateLimitSnapshotSchema).nullish(),
|
|
19063
|
+
rateLimitResetCredits: import_zod24.z.object({ availableCount: import_zod24.z.number(), credits: import_zod24.z.array(RateLimitResetCreditSchema).nullish() }).nullish(),
|
|
19064
|
+
accountId: import_zod24.z.string().nullish(),
|
|
19065
|
+
ordinaryUsageAllowed: import_zod24.z.boolean().nullish()
|
|
18583
19066
|
});
|
|
18584
|
-
var CodexInitializeResultSchema =
|
|
19067
|
+
var CodexInitializeResultSchema = import_zod24.z.object({ userAgent: import_zod24.z.string() });
|
|
18585
19068
|
|
|
18586
19069
|
// src/codex/appServer.ts
|
|
18587
19070
|
var CodexAppServerUnavailableError = class extends CliError {
|
|
@@ -18908,7 +19391,7 @@ init_providersStore();
|
|
|
18908
19391
|
init_signIn();
|
|
18909
19392
|
init_realPorts();
|
|
18910
19393
|
var import_node_path37 = __toESM(require("node:path"), 1);
|
|
18911
|
-
var
|
|
19394
|
+
var import_zod27 = require("zod");
|
|
18912
19395
|
init_envBool();
|
|
18913
19396
|
init_load();
|
|
18914
19397
|
init_schema();
|
|
@@ -18990,9 +19473,9 @@ function lookupKeychainService(run, farmRoot) {
|
|
|
18990
19473
|
}
|
|
18991
19474
|
return { checked: true, found: true, serviceName, note: `Keychain service name for this identity: "${serviceName}".` };
|
|
18992
19475
|
}
|
|
18993
|
-
var SettingsSecretsShapeSchema =
|
|
18994
|
-
env:
|
|
18995
|
-
hooks:
|
|
19476
|
+
var SettingsSecretsShapeSchema = import_zod27.z.looseObject({
|
|
19477
|
+
env: import_zod27.z.record(import_zod27.z.string(), import_zod27.z.unknown()).optional(),
|
|
19478
|
+
hooks: import_zod27.z.record(import_zod27.z.string(), import_zod27.z.array(import_zod27.z.unknown())).optional()
|
|
18996
19479
|
});
|
|
18997
19480
|
function hookCommandCountOf(group) {
|
|
18998
19481
|
if (typeof group !== "object" || group === null) {
|
|
@@ -19293,7 +19776,7 @@ function collectCheckReport(params) {
|
|
|
19293
19776
|
}
|
|
19294
19777
|
|
|
19295
19778
|
// src/checkReportSchema.ts
|
|
19296
|
-
var
|
|
19779
|
+
var import_zod29 = require("zod");
|
|
19297
19780
|
init_schema();
|
|
19298
19781
|
init_claudeVersion();
|
|
19299
19782
|
init_identity();
|
|
@@ -19357,124 +19840,124 @@ var DIAGNOSTIC_CODES = [
|
|
|
19357
19840
|
var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
|
|
19358
19841
|
|
|
19359
19842
|
// src/usage/pickReportSchema.ts
|
|
19360
|
-
var
|
|
19843
|
+
var import_zod28 = require("zod");
|
|
19361
19844
|
init_plan2();
|
|
19362
|
-
var PoolPickCandidateViewSchema =
|
|
19363
|
-
identity:
|
|
19364
|
-
/** In pick order: `scored` has usable quota data, `unknown` has none, `pay-per-use` bills by use, `ineligible` is refused right now. */
|
|
19365
|
-
class:
|
|
19845
|
+
var PoolPickCandidateViewSchema = import_zod28.z.strictObject({
|
|
19846
|
+
identity: import_zod28.z.string(),
|
|
19847
|
+
/** In pick order: `scored` has usable quota data, `unknown` has none and no plan known to bill by use, `pay-per-use` bills by use whether or not usage is recorded, `ineligible` is refused right now. */
|
|
19848
|
+
class: import_zod28.z.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
|
|
19366
19849
|
/** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
|
|
19367
|
-
score:
|
|
19850
|
+
score: import_zod28.z.number().optional(),
|
|
19368
19851
|
/** Which window's reset divides the score: the seven-day window, or the five-hour one when the member reports no seven-day utilisation or its measured-ratio five-hour term outranks the weekly one; present with `score`. */
|
|
19369
|
-
scoreWindow:
|
|
19852
|
+
scoreWindow: import_zod28.z.enum(["sevenDay", "fiveHour"]).optional(),
|
|
19370
19853
|
/** False when the five-hour window would run dry, at the observed pace, before it resets. */
|
|
19371
|
-
feasible:
|
|
19854
|
+
feasible: import_zod28.z.boolean(),
|
|
19372
19855
|
/** When an `ineligible` member can be used again, as an ISO instant. */
|
|
19373
|
-
blockedUntil:
|
|
19856
|
+
blockedUntil: import_zod28.z.iso.datetime().optional(),
|
|
19374
19857
|
plan: PlanClassSchema,
|
|
19375
19858
|
/** The facts behind the class and score, in the order they matter. */
|
|
19376
|
-
reasons:
|
|
19859
|
+
reasons: import_zod28.z.array(import_zod28.z.string())
|
|
19377
19860
|
});
|
|
19378
|
-
var PoolPickReportSchema =
|
|
19379
|
-
pool:
|
|
19380
|
-
directory:
|
|
19861
|
+
var PoolPickReportSchema = import_zod28.z.strictObject({
|
|
19862
|
+
pool: import_zod28.z.string(),
|
|
19863
|
+
directory: import_zod28.z.string(),
|
|
19381
19864
|
/** The member a launch would run as, absent when every member is refused. */
|
|
19382
|
-
pick:
|
|
19383
|
-
candidates:
|
|
19865
|
+
pick: import_zod28.z.string().optional(),
|
|
19866
|
+
candidates: import_zod28.z.array(PoolPickCandidateViewSchema),
|
|
19384
19867
|
/** Identity members anywhere in the pool's graph that do not exist; a launch skips them. */
|
|
19385
|
-
missing:
|
|
19868
|
+
missing: import_zod28.z.array(import_zod28.z.string()),
|
|
19386
19869
|
/** When nothing can be picked, the soonest any member returns. */
|
|
19387
|
-
earliestReturn:
|
|
19870
|
+
earliestReturn: import_zod28.z.strictObject({ identity: import_zod28.z.string(), at: import_zod28.z.iso.datetime() }).optional(),
|
|
19388
19871
|
/** The member a resumed conversation started on but moved off, and why, when the ranking could not keep it. */
|
|
19389
|
-
movedOff:
|
|
19872
|
+
movedOff: import_zod28.z.strictObject({ identity: import_zod28.z.string(), reason: import_zod28.z.string() }).optional(),
|
|
19390
19873
|
/** Why the last-pick record could not be read, when that is the case. */
|
|
19391
|
-
stickyProblem:
|
|
19874
|
+
stickyProblem: import_zod28.z.string().optional()
|
|
19392
19875
|
});
|
|
19393
19876
|
|
|
19394
19877
|
// src/checkReportSchema.ts
|
|
19395
19878
|
var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
|
|
19396
|
-
var CheckLayerViewSchema =
|
|
19397
|
-
id:
|
|
19398
|
-
kind:
|
|
19399
|
-
source:
|
|
19400
|
-
});
|
|
19401
|
-
var CheckEntryViewSchema =
|
|
19402
|
-
path:
|
|
19403
|
-
shared:
|
|
19404
|
-
via:
|
|
19879
|
+
var CheckLayerViewSchema = import_zod29.z.strictObject({
|
|
19880
|
+
id: import_zod29.z.int(),
|
|
19881
|
+
kind: import_zod29.z.enum(LAYER_KINDS),
|
|
19882
|
+
source: import_zod29.z.string()
|
|
19883
|
+
});
|
|
19884
|
+
var CheckEntryViewSchema = import_zod29.z.strictObject({
|
|
19885
|
+
path: import_zod29.z.string(),
|
|
19886
|
+
shared: import_zod29.z.boolean(),
|
|
19887
|
+
via: import_zod29.z.enum(DECISION_VIAS),
|
|
19405
19888
|
/** The entry's real category, or null when nothing classifies it. */
|
|
19406
|
-
category:
|
|
19407
|
-
rule:
|
|
19889
|
+
category: import_zod29.z.enum(CATEGORY_NAMES).nullable(),
|
|
19890
|
+
rule: import_zod29.z.strictObject({ key: import_zod29.z.string(), layer: import_zod29.z.int() }).optional(),
|
|
19408
19891
|
/** Rules that matched but whose `when` condition failed, each with the conditions that failed. */
|
|
19409
|
-
eliminated:
|
|
19410
|
-
});
|
|
19411
|
-
var CheckDiagnosticSchema =
|
|
19412
|
-
code:
|
|
19413
|
-
severity:
|
|
19414
|
-
message:
|
|
19415
|
-
subject:
|
|
19416
|
-
layer:
|
|
19417
|
-
});
|
|
19418
|
-
var CheckAmbientCredentialSchema =
|
|
19419
|
-
var CheckKeychainSchema =
|
|
19420
|
-
checked:
|
|
19421
|
-
found:
|
|
19422
|
-
serviceName:
|
|
19423
|
-
note:
|
|
19424
|
-
});
|
|
19425
|
-
var CheckSettingsExposureSchema =
|
|
19426
|
-
file:
|
|
19427
|
-
envKeyNames:
|
|
19428
|
-
hookEventNames:
|
|
19429
|
-
hookCommandCount:
|
|
19430
|
-
});
|
|
19431
|
-
var CredentialSourceSummarySchema =
|
|
19432
|
-
|
|
19433
|
-
|
|
19434
|
-
|
|
19435
|
-
|
|
19436
|
-
|
|
19437
|
-
|
|
19892
|
+
eliminated: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.strictObject({ key: import_zod29.z.string(), failed: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.string())) }))).optional()
|
|
19893
|
+
});
|
|
19894
|
+
var CheckDiagnosticSchema = import_zod29.z.strictObject({
|
|
19895
|
+
code: import_zod29.z.enum(DIAGNOSTIC_CODES),
|
|
19896
|
+
severity: import_zod29.z.enum(DIAGNOSTIC_SEVERITIES),
|
|
19897
|
+
message: import_zod29.z.string(),
|
|
19898
|
+
subject: import_zod29.z.string().optional(),
|
|
19899
|
+
layer: import_zod29.z.int().optional()
|
|
19900
|
+
});
|
|
19901
|
+
var CheckAmbientCredentialSchema = import_zod29.z.union([import_zod29.z.strictObject({ ok: import_zod29.z.literal(true) }), import_zod29.z.strictObject({ ok: import_zod29.z.literal(false), variable: import_zod29.z.string(), message: import_zod29.z.string() })]);
|
|
19902
|
+
var CheckKeychainSchema = import_zod29.z.strictObject({
|
|
19903
|
+
checked: import_zod29.z.literal(true),
|
|
19904
|
+
found: import_zod29.z.boolean(),
|
|
19905
|
+
serviceName: import_zod29.z.string().optional(),
|
|
19906
|
+
note: import_zod29.z.string()
|
|
19907
|
+
});
|
|
19908
|
+
var CheckSettingsExposureSchema = import_zod29.z.strictObject({
|
|
19909
|
+
file: import_zod29.z.string(),
|
|
19910
|
+
envKeyNames: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.string())),
|
|
19911
|
+
hookEventNames: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.string())),
|
|
19912
|
+
hookCommandCount: import_zod29.z.int().nonnegative()
|
|
19913
|
+
});
|
|
19914
|
+
var CredentialSourceSummarySchema = import_zod29.z.union([
|
|
19915
|
+
import_zod29.z.strictObject({ kind: import_zod29.z.literal("env"), variable: import_zod29.z.string() }),
|
|
19916
|
+
import_zod29.z.strictObject({ kind: import_zod29.z.literal("file"), path: import_zod29.z.string() }),
|
|
19917
|
+
import_zod29.z.strictObject({ kind: import_zod29.z.literal("command"), program: import_zod29.z.string() }),
|
|
19918
|
+
import_zod29.z.strictObject({ kind: import_zod29.z.literal("op"), reference: import_zod29.z.string() }),
|
|
19919
|
+
import_zod29.z.strictObject({ kind: import_zod29.z.literal("keychain"), service: import_zod29.z.string(), account: import_zod29.z.string().optional() }),
|
|
19920
|
+
import_zod29.z.strictObject({ kind: import_zod29.z.literal("literal") })
|
|
19438
19921
|
]);
|
|
19439
|
-
var CredentialSummarySchema =
|
|
19440
|
-
target:
|
|
19441
|
-
sources:
|
|
19922
|
+
var CredentialSummarySchema = import_zod29.z.strictObject({
|
|
19923
|
+
target: import_zod29.z.enum(CREDENTIAL_TARGETS),
|
|
19924
|
+
sources: import_zod29.z.readonly(import_zod29.z.array(CredentialSourceSummarySchema)),
|
|
19442
19925
|
cache: CredentialCacheSchema.optional()
|
|
19443
19926
|
});
|
|
19444
|
-
var CachedCredentialStateSchema =
|
|
19445
|
-
|
|
19446
|
-
|
|
19447
|
-
|
|
19927
|
+
var CachedCredentialStateSchema = import_zod29.z.union([
|
|
19928
|
+
import_zod29.z.strictObject({ store: import_zod29.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod29.z.literal("empty") }),
|
|
19929
|
+
import_zod29.z.strictObject({ store: import_zod29.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod29.z.literal("unreadable"), reason: import_zod29.z.string() }),
|
|
19930
|
+
import_zod29.z.strictObject({ store: import_zod29.z.enum(CREDENTIAL_CACHE_STORES), status: import_zod29.z.enum(["fresh", "expired"]), ageMs: import_zod29.z.number(), expiresInMs: import_zod29.z.number().optional() })
|
|
19448
19931
|
]);
|
|
19449
|
-
var CheckCredentialProviderSchema =
|
|
19450
|
-
|
|
19451
|
-
|
|
19932
|
+
var CheckCredentialProviderSchema = import_zod29.z.union([
|
|
19933
|
+
import_zod29.z.strictObject({ name: import_zod29.z.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
|
|
19934
|
+
import_zod29.z.strictObject({ name: import_zod29.z.string(), problem: import_zod29.z.string() })
|
|
19452
19935
|
]);
|
|
19453
|
-
var CheckCredentialSchema =
|
|
19454
|
-
applies:
|
|
19936
|
+
var CheckCredentialSchema = import_zod29.z.strictObject({
|
|
19937
|
+
applies: import_zod29.z.enum(CHECK_CREDENTIAL_APPLIES),
|
|
19455
19938
|
provider: CheckCredentialProviderSchema.optional(),
|
|
19456
19939
|
identity: CredentialSummarySchema.optional(),
|
|
19457
19940
|
identityCached: CachedCredentialStateSchema.optional()
|
|
19458
19941
|
});
|
|
19459
|
-
var CheckClaudeVersionSchema =
|
|
19460
|
-
pinned:
|
|
19461
|
-
highestInstalled:
|
|
19462
|
-
installed:
|
|
19942
|
+
var CheckClaudeVersionSchema = import_zod29.z.strictObject({
|
|
19943
|
+
pinned: import_zod29.z.strictObject({ version: import_zod29.z.string(), source: import_zod29.z.enum(CLAUDE_VERSION_SOURCES), installed: import_zod29.z.boolean() }).optional(),
|
|
19944
|
+
highestInstalled: import_zod29.z.string().optional(),
|
|
19945
|
+
installed: import_zod29.z.readonly(import_zod29.z.array(import_zod29.z.string()))
|
|
19463
19946
|
});
|
|
19464
|
-
var CheckReportJsonSchema =
|
|
19465
|
-
identity:
|
|
19947
|
+
var CheckReportJsonSchema = import_zod29.z.strictObject({
|
|
19948
|
+
identity: import_zod29.z.strictObject({ name: import_zod29.z.string().nullable(), source: import_zod29.z.enum(IDENTITY_DECISION_SOURCES) }),
|
|
19466
19949
|
/** The pool ranking, when the launch named a pool instead of an identity. */
|
|
19467
19950
|
pool: PoolPickReportSchema.optional(),
|
|
19468
|
-
configProfile:
|
|
19469
|
-
layers:
|
|
19470
|
-
entries:
|
|
19471
|
-
projectEncodingAmbiguities:
|
|
19472
|
-
|
|
19951
|
+
configProfile: import_zod29.z.strictObject({ name: import_zod29.z.string().nullable(), source: import_zod29.z.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
|
|
19952
|
+
layers: import_zod29.z.readonly(import_zod29.z.array(CheckLayerViewSchema)),
|
|
19953
|
+
entries: import_zod29.z.readonly(import_zod29.z.array(CheckEntryViewSchema)),
|
|
19954
|
+
projectEncodingAmbiguities: import_zod29.z.readonly(
|
|
19955
|
+
import_zod29.z.array(import_zod29.z.strictObject({ fragment: import_zod29.z.string(), encoded: import_zod29.z.string(), reason: import_zod29.z.enum(ENCODING_AMBIGUITY_REASONS), detail: import_zod29.z.string() }))
|
|
19473
19956
|
),
|
|
19474
|
-
diagnostics:
|
|
19957
|
+
diagnostics: import_zod29.z.readonly(import_zod29.z.array(CheckDiagnosticSchema)),
|
|
19475
19958
|
ambientCredential: CheckAmbientCredentialSchema,
|
|
19476
19959
|
keychain: CheckKeychainSchema.optional(),
|
|
19477
|
-
settingsExposure:
|
|
19960
|
+
settingsExposure: import_zod29.z.readonly(import_zod29.z.array(CheckSettingsExposureSchema)),
|
|
19478
19961
|
credential: CheckCredentialSchema,
|
|
19479
19962
|
claudeVersion: CheckClaudeVersionSchema.optional()
|
|
19480
19963
|
});
|
|
@@ -19485,28 +19968,28 @@ init_preflight();
|
|
|
19485
19968
|
init_resets();
|
|
19486
19969
|
|
|
19487
19970
|
// src/usage/resetsSchema.ts
|
|
19488
|
-
var
|
|
19489
|
-
var ResetRowSchema =
|
|
19490
|
-
identity:
|
|
19491
|
-
provider:
|
|
19971
|
+
var import_zod30 = require("zod");
|
|
19972
|
+
var ResetRowSchema = import_zod30.z.strictObject({
|
|
19973
|
+
identity: import_zod30.z.string(),
|
|
19974
|
+
provider: import_zod30.z.string(),
|
|
19492
19975
|
/** What the window is: `5h`, `7d` or `extra usage` for an Anthropic account, or the provider's own measure and period (`tokens 5h`). */
|
|
19493
|
-
window:
|
|
19976
|
+
window: import_zod30.z.string(),
|
|
19494
19977
|
/** When the state the window comes from was observed, as an ISO instant. */
|
|
19495
|
-
observedAt:
|
|
19978
|
+
observedAt: import_zod30.z.iso.datetime(),
|
|
19496
19979
|
/** When the window resets, as an ISO instant; absent when the upstream reported none. */
|
|
19497
|
-
resetsAt:
|
|
19980
|
+
resetsAt: import_zod30.z.iso.datetime().optional(),
|
|
19498
19981
|
/** True when the reset time has passed, so the recorded observation describes a window that no longer exists and its utilisation reads as 0. */
|
|
19499
|
-
reset:
|
|
19982
|
+
reset: import_zod30.z.boolean(),
|
|
19500
19983
|
/** The fraction used, as `effectiveWindow` reads it at the report's own clock. */
|
|
19501
|
-
utilization:
|
|
19984
|
+
utilization: import_zod30.z.number().optional(),
|
|
19502
19985
|
/** The window's own status, for a window that has not reset yet. */
|
|
19503
|
-
status:
|
|
19986
|
+
status: import_zod30.z.string().optional()
|
|
19504
19987
|
});
|
|
19505
|
-
var ResetScheduleSchema =
|
|
19988
|
+
var ResetScheduleSchema = import_zod30.z.strictObject({ resets: import_zod30.z.readonly(import_zod30.z.array(ResetRowSchema)) });
|
|
19506
19989
|
|
|
19507
19990
|
// src/frontdoor/controlSchemas.ts
|
|
19508
19991
|
var import_node_path43 = __toESM(require("node:path"), 1);
|
|
19509
|
-
var
|
|
19992
|
+
var import_zod37 = require("zod");
|
|
19510
19993
|
|
|
19511
19994
|
// src/codex/doctor.ts
|
|
19512
19995
|
function codexIdentityFindings(entry, identity) {
|
|
@@ -20733,92 +21216,92 @@ function collectDoctorReport(params) {
|
|
|
20733
21216
|
// src/frontdoor/controlSchemas.ts
|
|
20734
21217
|
init_schema2();
|
|
20735
21218
|
init_state();
|
|
20736
|
-
var UsageListOutputSchema =
|
|
20737
|
-
var UsageWindowsInputSchema =
|
|
20738
|
-
identity:
|
|
20739
|
-
provider:
|
|
21219
|
+
var UsageListOutputSchema = import_zod37.z.strictObject({ snapshots: import_zod37.z.readonly(import_zod37.z.array(UsageSnapshotSchema)) });
|
|
21220
|
+
var UsageWindowsInputSchema = import_zod37.z.strictObject({
|
|
21221
|
+
identity: import_zod37.z.string().min(1),
|
|
21222
|
+
provider: import_zod37.z.string().min(1).optional()
|
|
20740
21223
|
});
|
|
20741
|
-
var EffectiveWindowSchema =
|
|
21224
|
+
var EffectiveWindowSchema = import_zod37.z.strictObject({
|
|
20742
21225
|
/** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
|
|
20743
|
-
reset:
|
|
21226
|
+
reset: import_zod37.z.boolean(),
|
|
20744
21227
|
/** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
|
|
20745
|
-
utilization:
|
|
21228
|
+
utilization: import_zod37.z.number().optional(),
|
|
20746
21229
|
/** The reset instant, for a window that has not reset yet and reported one. */
|
|
20747
|
-
resetsAtMs:
|
|
21230
|
+
resetsAtMs: import_zod37.z.number().optional(),
|
|
20748
21231
|
/** The window's own status, for a window that has not reset yet. */
|
|
20749
|
-
status:
|
|
21232
|
+
status: import_zod37.z.string().optional()
|
|
20750
21233
|
});
|
|
20751
|
-
var UsageWindowsOutputSchema =
|
|
20752
|
-
identity:
|
|
20753
|
-
provider:
|
|
21234
|
+
var UsageWindowsOutputSchema = import_zod37.z.strictObject({
|
|
21235
|
+
identity: import_zod37.z.string(),
|
|
21236
|
+
provider: import_zod37.z.string(),
|
|
20754
21237
|
/** When the rate-limit state the windows come from was observed. */
|
|
20755
|
-
observedAt:
|
|
21238
|
+
observedAt: import_zod37.z.iso.datetime().optional(),
|
|
20756
21239
|
fiveHour: EffectiveWindowSchema.optional(),
|
|
20757
21240
|
sevenDay: EffectiveWindowSchema.optional()
|
|
20758
21241
|
});
|
|
20759
|
-
var UsageLiveOutputSchema =
|
|
21242
|
+
var UsageLiveOutputSchema = import_zod37.z.strictObject({
|
|
20760
21243
|
/** The freshest observation the door holds, never narrowed by the read's session filter because it is the door's single latest statement of the account's quota; absent while no rate_limit_event has been filed at all. */
|
|
20761
21244
|
latest: RcLiveRateLimitSchema.optional(),
|
|
20762
21245
|
/** One observation per session whose stream has filed a rate_limit_event this door generation. */
|
|
20763
|
-
sessions:
|
|
21246
|
+
sessions: import_zod37.z.readonly(import_zod37.z.array(RcLiveRateLimitSchema))
|
|
20764
21247
|
});
|
|
20765
|
-
var FrontDoorSessionStatusSchema =
|
|
20766
|
-
pid:
|
|
20767
|
-
startedAt:
|
|
20768
|
-
alive:
|
|
21248
|
+
var FrontDoorSessionStatusSchema = import_zod37.z.strictObject({
|
|
21249
|
+
pid: import_zod37.z.int().positive(),
|
|
21250
|
+
startedAt: import_zod37.z.number(),
|
|
21251
|
+
alive: import_zod37.z.boolean()
|
|
20769
21252
|
});
|
|
20770
|
-
var HeadroomSocketTargetSchema =
|
|
20771
|
-
var FrontDoorStatusOutputSchema =
|
|
21253
|
+
var HeadroomSocketTargetSchema = import_zod37.z.union([import_zod37.z.strictObject({ socketPath: import_zod37.z.string() }), import_zod37.z.strictObject({ refused: import_zod37.z.string() })]);
|
|
21254
|
+
var FrontDoorStatusOutputSchema = import_zod37.z.strictObject({
|
|
20772
21255
|
state: FrontDoorStateSchema,
|
|
20773
|
-
supervisorAlive:
|
|
21256
|
+
supervisorAlive: import_zod37.z.boolean(),
|
|
20774
21257
|
/** The pids of earlier doors that released their addresses and are finishing the connections they carried: running, but not serving anything new. */
|
|
20775
|
-
draining:
|
|
20776
|
-
sessions:
|
|
21258
|
+
draining: import_zod37.z.readonly(import_zod37.z.array(import_zod37.z.number().int().positive())),
|
|
21259
|
+
sessions: import_zod37.z.readonly(import_zod37.z.array(FrontDoorSessionStatusSchema)),
|
|
20777
21260
|
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
20778
|
-
logPath:
|
|
20779
|
-
logExists:
|
|
21261
|
+
logPath: import_zod37.z.string(),
|
|
21262
|
+
logExists: import_zod37.z.boolean()
|
|
20780
21263
|
});
|
|
20781
|
-
var FrontDoorSessionsOutputSchema =
|
|
20782
|
-
var CheckRunInputSchema =
|
|
20783
|
-
path:
|
|
20784
|
-
identity:
|
|
21264
|
+
var FrontDoorSessionsOutputSchema = import_zod37.z.strictObject({ sessions: import_zod37.z.readonly(import_zod37.z.array(FrontDoorSessionStatusSchema)) });
|
|
21265
|
+
var CheckRunInputSchema = import_zod37.z.strictObject({
|
|
21266
|
+
path: import_zod37.z.string().min(1),
|
|
21267
|
+
identity: import_zod37.z.string().min(1).optional()
|
|
20785
21268
|
}).refine((input) => import_node_path43.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
20786
|
-
var PoolPickInputSchema =
|
|
20787
|
-
pool:
|
|
20788
|
-
path:
|
|
21269
|
+
var PoolPickInputSchema = import_zod37.z.strictObject({
|
|
21270
|
+
pool: import_zod37.z.string().min(1),
|
|
21271
|
+
path: import_zod37.z.string().min(1)
|
|
20789
21272
|
}).refine((input) => import_node_path43.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
20790
|
-
var DoctorFindingSchema =
|
|
20791
|
-
section:
|
|
20792
|
-
subject:
|
|
20793
|
-
severity:
|
|
20794
|
-
message:
|
|
21273
|
+
var DoctorFindingSchema = import_zod37.z.strictObject({
|
|
21274
|
+
section: import_zod37.z.enum(DOCTOR_SECTIONS),
|
|
21275
|
+
subject: import_zod37.z.string().optional(),
|
|
21276
|
+
severity: import_zod37.z.enum(DOCTOR_SEVERITIES),
|
|
21277
|
+
message: import_zod37.z.string()
|
|
20795
21278
|
});
|
|
20796
|
-
var DoctorRunOutputSchema =
|
|
21279
|
+
var DoctorRunOutputSchema = import_zod37.z.strictObject({
|
|
20797
21280
|
/** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
|
|
20798
|
-
ok:
|
|
20799
|
-
findings:
|
|
20800
|
-
});
|
|
20801
|
-
var FrontDoorRestartOutputSchema =
|
|
20802
|
-
action:
|
|
20803
|
-
previousPid:
|
|
20804
|
-
});
|
|
20805
|
-
var UpdateCheckOutputSchema =
|
|
20806
|
-
current:
|
|
20807
|
-
latest:
|
|
20808
|
-
action:
|
|
20809
|
-
});
|
|
20810
|
-
var CodexSignInSchema =
|
|
20811
|
-
|
|
20812
|
-
|
|
20813
|
-
|
|
21281
|
+
ok: import_zod37.z.boolean(),
|
|
21282
|
+
findings: import_zod37.z.readonly(import_zod37.z.array(DoctorFindingSchema))
|
|
21283
|
+
});
|
|
21284
|
+
var FrontDoorRestartOutputSchema = import_zod37.z.strictObject({
|
|
21285
|
+
action: import_zod37.z.literal("restarting"),
|
|
21286
|
+
previousPid: import_zod37.z.int().positive()
|
|
21287
|
+
});
|
|
21288
|
+
var UpdateCheckOutputSchema = import_zod37.z.strictObject({
|
|
21289
|
+
current: import_zod37.z.string(),
|
|
21290
|
+
latest: import_zod37.z.string(),
|
|
21291
|
+
action: import_zod37.z.enum(["current", "available", "updated"])
|
|
21292
|
+
});
|
|
21293
|
+
var CodexSignInSchema = import_zod37.z.discriminatedUnion("state", [
|
|
21294
|
+
import_zod37.z.strictObject({ state: import_zod37.z.literal("none") }),
|
|
21295
|
+
import_zod37.z.strictObject({ state: import_zod37.z.literal("signed-in"), email: import_zod37.z.string().optional(), planScope: import_zod37.z.boolean(), accessTokenExpiresAt: import_zod37.z.number() }),
|
|
21296
|
+
import_zod37.z.strictObject({ state: import_zod37.z.literal("unreadable"), message: import_zod37.z.string() })
|
|
20814
21297
|
]);
|
|
20815
|
-
var CodexStatusOutputSchema =
|
|
21298
|
+
var CodexStatusOutputSchema = import_zod37.z.strictObject({
|
|
20816
21299
|
signIn: CodexSignInSchema,
|
|
20817
|
-
codexProviders:
|
|
21300
|
+
codexProviders: import_zod37.z.readonly(import_zod37.z.array(import_zod37.z.string()))
|
|
20818
21301
|
});
|
|
20819
|
-
var CodexLogoutOutputSchema =
|
|
20820
|
-
hadGrant:
|
|
20821
|
-
revoked:
|
|
21302
|
+
var CodexLogoutOutputSchema = import_zod37.z.strictObject({
|
|
21303
|
+
hadGrant: import_zod37.z.boolean(),
|
|
21304
|
+
revoked: import_zod37.z.boolean()
|
|
20822
21305
|
});
|
|
20823
21306
|
|
|
20824
21307
|
// src/frontdoor/codexApi.ts
|
|
@@ -20882,71 +21365,71 @@ init_poolStore();
|
|
|
20882
21365
|
init_providersStore();
|
|
20883
21366
|
|
|
20884
21367
|
// src/frontdoor/configSchemas.ts
|
|
20885
|
-
var
|
|
21368
|
+
var import_zod38 = require("zod");
|
|
20886
21369
|
init_schema();
|
|
20887
21370
|
init_names();
|
|
20888
21371
|
init_keychainLogin();
|
|
20889
21372
|
init_statusline();
|
|
20890
|
-
var RemovalConfirmationSchema =
|
|
20891
|
-
var CredentialWriteSchema = (targets) =>
|
|
20892
|
-
sources:
|
|
20893
|
-
target:
|
|
20894
|
-
cache:
|
|
20895
|
-
});
|
|
20896
|
-
var CredentialSummarySchema2 =
|
|
20897
|
-
target:
|
|
20898
|
-
sources:
|
|
20899
|
-
|
|
20900
|
-
|
|
20901
|
-
|
|
20902
|
-
|
|
20903
|
-
|
|
20904
|
-
|
|
20905
|
-
|
|
21373
|
+
var RemovalConfirmationSchema = import_zod38.z.boolean();
|
|
21374
|
+
var CredentialWriteSchema = (targets) => import_zod38.z.strictObject({
|
|
21375
|
+
sources: import_zod38.z.array(RemoteCredentialSourceSchema).min(1).optional(),
|
|
21376
|
+
target: import_zod38.z.enum(targets).optional(),
|
|
21377
|
+
cache: import_zod38.z.union([import_zod38.z.literal(false), CredentialCacheSchema]).optional()
|
|
21378
|
+
});
|
|
21379
|
+
var CredentialSummarySchema2 = import_zod38.z.strictObject({
|
|
21380
|
+
target: import_zod38.z.enum(CREDENTIAL_TARGETS),
|
|
21381
|
+
sources: import_zod38.z.readonly(import_zod38.z.array(
|
|
21382
|
+
import_zod38.z.discriminatedUnion("kind", [
|
|
21383
|
+
import_zod38.z.strictObject({ kind: import_zod38.z.literal("env"), variable: import_zod38.z.string() }),
|
|
21384
|
+
import_zod38.z.strictObject({ kind: import_zod38.z.literal("file"), path: import_zod38.z.string() }),
|
|
21385
|
+
import_zod38.z.strictObject({ kind: import_zod38.z.literal("command"), program: import_zod38.z.string() }),
|
|
21386
|
+
import_zod38.z.strictObject({ kind: import_zod38.z.literal("op"), reference: import_zod38.z.string() }),
|
|
21387
|
+
import_zod38.z.strictObject({ kind: import_zod38.z.literal("keychain"), service: import_zod38.z.string(), account: import_zod38.z.string().optional() }),
|
|
21388
|
+
import_zod38.z.strictObject({ kind: import_zod38.z.literal("literal") })
|
|
20906
21389
|
])
|
|
20907
21390
|
)),
|
|
20908
21391
|
cache: CredentialCacheSchema.optional()
|
|
20909
21392
|
});
|
|
20910
|
-
var mutationOutput = (kind, action) =>
|
|
20911
|
-
var storedMutationOutput = (kind, action, value) =>
|
|
20912
|
-
var IdentityValueSchema =
|
|
20913
|
-
name:
|
|
20914
|
-
label:
|
|
20915
|
-
defaultConfigProfile:
|
|
20916
|
-
provider:
|
|
20917
|
-
allowAmbientCredential:
|
|
21393
|
+
var mutationOutput = (kind, action) => import_zod38.z.strictObject({ action: import_zod38.z.literal(action), kind: import_zod38.z.literal(kind), name: import_zod38.z.string() });
|
|
21394
|
+
var storedMutationOutput = (kind, action, value) => import_zod38.z.strictObject({ action: import_zod38.z.literal(action), kind: import_zod38.z.literal(kind), name: import_zod38.z.string(), value });
|
|
21395
|
+
var IdentityValueSchema = import_zod38.z.strictObject({
|
|
21396
|
+
name: import_zod38.z.string(),
|
|
21397
|
+
label: import_zod38.z.string().optional(),
|
|
21398
|
+
defaultConfigProfile: import_zod38.z.string().optional(),
|
|
21399
|
+
provider: import_zod38.z.string().optional(),
|
|
21400
|
+
allowAmbientCredential: import_zod38.z.boolean(),
|
|
20918
21401
|
credential: CredentialSummarySchema2.optional(),
|
|
20919
|
-
anchors:
|
|
21402
|
+
anchors: import_zod38.z.array(AnchorSchema).optional()
|
|
20920
21403
|
});
|
|
20921
21404
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
20922
|
-
var ProviderValueSchema =
|
|
20923
|
-
name:
|
|
20924
|
-
kind:
|
|
20925
|
-
displayName:
|
|
20926
|
-
baseUrl:
|
|
21405
|
+
var ProviderValueSchema = import_zod38.z.strictObject({
|
|
21406
|
+
name: import_zod38.z.string(),
|
|
21407
|
+
kind: import_zod38.z.enum(PROVIDER_KINDS),
|
|
21408
|
+
displayName: import_zod38.z.string(),
|
|
21409
|
+
baseUrl: import_zod38.z.string().optional(),
|
|
20927
21410
|
codex: CodexProviderConfigSchema.optional(),
|
|
20928
21411
|
credential: CredentialSummarySchema2.optional(),
|
|
20929
|
-
env:
|
|
21412
|
+
env: import_zod38.z.record(import_zod38.z.string(), import_zod38.z.string()).optional()
|
|
20930
21413
|
});
|
|
20931
|
-
var ConfigNameInputSchema =
|
|
20932
|
-
var ConfigIdentityAddInputSchema =
|
|
21414
|
+
var ConfigNameInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1) });
|
|
21415
|
+
var ConfigIdentityAddInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), keepKeychainLogin: import_zod38.z.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
|
|
20933
21416
|
var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
|
|
20934
|
-
var ConfigIdentitySetInputSchema =
|
|
20935
|
-
name:
|
|
21417
|
+
var ConfigIdentitySetInputSchema = import_zod38.z.strictObject({
|
|
21418
|
+
name: import_zod38.z.string().min(1),
|
|
20936
21419
|
/** The identity's display label; `false` clears it. */
|
|
20937
|
-
label:
|
|
20938
|
-
defaultConfigProfile:
|
|
21420
|
+
label: import_zod38.z.union([IdentityLabelSchema, import_zod38.z.literal(false)]).optional(),
|
|
21421
|
+
defaultConfigProfile: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
|
|
20939
21422
|
/** The provider the identity exists for; `false` clears it. */
|
|
20940
|
-
provider:
|
|
20941
|
-
allowAmbientCredential:
|
|
20942
|
-
credential:
|
|
21423
|
+
provider: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
|
|
21424
|
+
allowAmbientCredential: import_zod38.z.boolean().optional(),
|
|
21425
|
+
credential: import_zod38.z.union([import_zod38.z.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
|
|
20943
21426
|
/** `false` removes the anchors; a list replaces them. */
|
|
20944
|
-
anchors:
|
|
21427
|
+
anchors: import_zod38.z.union([import_zod38.z.literal(false), import_zod38.z.array(AnchorSchema).min(1)]).optional()
|
|
20945
21428
|
});
|
|
20946
21429
|
var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
|
|
20947
|
-
var ConfigIdentityRemoveInputSchema =
|
|
21430
|
+
var ConfigIdentityRemoveInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
20948
21431
|
var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
|
|
20949
|
-
var ConfigStatuslineSetSchema =
|
|
21432
|
+
var ConfigStatuslineSetSchema = import_zod38.z.record(import_zod38.z.string(), import_zod38.z.unknown()).superRefine((settings, context) => {
|
|
20950
21433
|
for (const key of Object.keys(settings)) {
|
|
20951
21434
|
if (key === STATUSLINE_EXTRA_GROUP || key.startsWith(`${STATUSLINE_EXTRA_GROUP}.`)) {
|
|
20952
21435
|
context.addIssue({ code: "custom", path: [key], message: `a config write through the API cannot set "${key}": the extra segment's command runs a program, so only your own configuration (the global config, a profile you edit yourself, a directory rule or a command-line assignment) may set it` });
|
|
@@ -20954,93 +21437,93 @@ var ConfigStatuslineSetSchema = import_zod37.z.record(import_zod37.z.string(), i
|
|
|
20954
21437
|
}
|
|
20955
21438
|
});
|
|
20956
21439
|
var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
|
|
20957
|
-
var ConfigProfileAddInputSchema =
|
|
20958
|
-
name:
|
|
20959
|
-
extends:
|
|
20960
|
-
description:
|
|
21440
|
+
var ConfigProfileAddInputSchema = import_zod38.z.strictObject({
|
|
21441
|
+
name: import_zod38.z.string().min(1),
|
|
21442
|
+
extends: import_zod38.z.array(import_zod38.z.string().min(1)).optional(),
|
|
21443
|
+
description: import_zod38.z.string().optional()
|
|
20961
21444
|
});
|
|
20962
21445
|
var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
|
|
20963
|
-
var ConfigProfileSetInputSchema =
|
|
20964
|
-
name:
|
|
20965
|
-
category:
|
|
20966
|
-
entry:
|
|
20967
|
-
extends:
|
|
20968
|
-
description:
|
|
20969
|
-
launch:
|
|
20970
|
-
skipPermissions:
|
|
20971
|
-
remoteControl:
|
|
20972
|
-
headroom:
|
|
20973
|
-
trackUsage:
|
|
20974
|
-
provider:
|
|
20975
|
-
claudeVersion:
|
|
20976
|
-
delay:
|
|
20977
|
-
pause:
|
|
20978
|
-
explain:
|
|
20979
|
-
proxyBypass:
|
|
20980
|
-
statusline:
|
|
21446
|
+
var ConfigProfileSetInputSchema = import_zod38.z.strictObject({
|
|
21447
|
+
name: import_zod38.z.string().min(1),
|
|
21448
|
+
category: import_zod38.z.record(import_zod38.z.string(), import_zod38.z.boolean()).optional(),
|
|
21449
|
+
entry: import_zod38.z.record(import_zod38.z.string(), import_zod38.z.boolean()).optional(),
|
|
21450
|
+
extends: import_zod38.z.union([import_zod38.z.array(import_zod38.z.string().min(1)), import_zod38.z.literal(false)]).optional(),
|
|
21451
|
+
description: import_zod38.z.union([import_zod38.z.string(), import_zod38.z.literal(false)]).optional(),
|
|
21452
|
+
launch: import_zod38.z.strictObject({
|
|
21453
|
+
skipPermissions: import_zod38.z.boolean().optional(),
|
|
21454
|
+
remoteControl: import_zod38.z.boolean().optional(),
|
|
21455
|
+
headroom: import_zod38.z.boolean().optional(),
|
|
21456
|
+
trackUsage: import_zod38.z.boolean().optional(),
|
|
21457
|
+
provider: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
|
|
21458
|
+
claudeVersion: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
|
|
21459
|
+
delay: import_zod38.z.union([import_zod38.z.string().regex(DURATION_RE), import_zod38.z.literal(false)]).optional(),
|
|
21460
|
+
pause: import_zod38.z.boolean().optional(),
|
|
21461
|
+
explain: import_zod38.z.boolean().optional(),
|
|
21462
|
+
proxyBypass: import_zod38.z.union([import_zod38.z.array(import_zod38.z.string().min(1)), import_zod38.z.literal(false)]).optional(),
|
|
21463
|
+
statusline: import_zod38.z.strictObject({
|
|
20981
21464
|
set: ConfigStatuslineSetSchema.optional(),
|
|
20982
|
-
unset:
|
|
21465
|
+
unset: import_zod38.z.array(import_zod38.z.string()).optional()
|
|
20983
21466
|
}).optional()
|
|
20984
21467
|
}).optional()
|
|
20985
21468
|
});
|
|
20986
21469
|
var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
|
|
20987
|
-
var ConfigProfileRemoveInputSchema =
|
|
21470
|
+
var ConfigProfileRemoveInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
20988
21471
|
var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
|
|
20989
21472
|
var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
|
|
20990
|
-
var PoolMembersInputSchema =
|
|
20991
|
-
var ConfigPoolAddInputSchema =
|
|
20992
|
-
name:
|
|
21473
|
+
var PoolMembersInputSchema = import_zod38.z.array(import_zod38.z.string().min(1)).min(1);
|
|
21474
|
+
var ConfigPoolAddInputSchema = import_zod38.z.strictObject({
|
|
21475
|
+
name: import_zod38.z.string().min(1),
|
|
20993
21476
|
identities: PoolMembersInputSchema,
|
|
20994
|
-
preference:
|
|
20995
|
-
resumeOnLimit:
|
|
20996
|
-
compactBeforeLimit:
|
|
21477
|
+
preference: import_zod38.z.enum(POOL_PREFERENCES).optional(),
|
|
21478
|
+
resumeOnLimit: import_zod38.z.boolean().optional(),
|
|
21479
|
+
compactBeforeLimit: import_zod38.z.boolean().optional(),
|
|
20997
21480
|
compactAtUtilisation: CompactAtUtilisationSchema.optional()
|
|
20998
21481
|
});
|
|
20999
21482
|
var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
|
|
21000
|
-
var ConfigPoolSetInputSchema =
|
|
21001
|
-
name:
|
|
21483
|
+
var ConfigPoolSetInputSchema = import_zod38.z.strictObject({
|
|
21484
|
+
name: import_zod38.z.string().min(1),
|
|
21002
21485
|
identities: PoolMembersInputSchema.optional(),
|
|
21003
|
-
preference:
|
|
21004
|
-
resumeOnLimit:
|
|
21005
|
-
compactBeforeLimit:
|
|
21006
|
-
compactAtUtilisation:
|
|
21486
|
+
preference: import_zod38.z.union([import_zod38.z.enum(POOL_PREFERENCES), import_zod38.z.literal(false)]).optional(),
|
|
21487
|
+
resumeOnLimit: import_zod38.z.boolean().optional(),
|
|
21488
|
+
compactBeforeLimit: import_zod38.z.boolean().optional(),
|
|
21489
|
+
compactAtUtilisation: import_zod38.z.union([CompactAtUtilisationSchema, import_zod38.z.literal(false)]).optional()
|
|
21007
21490
|
});
|
|
21008
21491
|
var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
|
|
21009
|
-
var ConfigPoolRemoveInputSchema =
|
|
21492
|
+
var ConfigPoolRemoveInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
21010
21493
|
var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
|
|
21011
21494
|
var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
|
|
21012
|
-
var ConfigProviderAddInputSchema =
|
|
21013
|
-
name:
|
|
21014
|
-
kind:
|
|
21015
|
-
displayName:
|
|
21016
|
-
baseUrl:
|
|
21495
|
+
var ConfigProviderAddInputSchema = import_zod38.z.strictObject({
|
|
21496
|
+
name: import_zod38.z.string().min(1),
|
|
21497
|
+
kind: import_zod38.z.enum(PROVIDER_KINDS).optional(),
|
|
21498
|
+
displayName: import_zod38.z.string().min(1),
|
|
21499
|
+
baseUrl: import_zod38.z.string().min(1).optional(),
|
|
21017
21500
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
|
|
21018
21501
|
codex: CodexProviderConfigSchema.optional()
|
|
21019
21502
|
});
|
|
21020
21503
|
var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
|
|
21021
|
-
var ConfigProviderSetInputSchema =
|
|
21022
|
-
name:
|
|
21023
|
-
displayName:
|
|
21024
|
-
baseUrl:
|
|
21504
|
+
var ConfigProviderSetInputSchema = import_zod38.z.strictObject({
|
|
21505
|
+
name: import_zod38.z.string().min(1),
|
|
21506
|
+
displayName: import_zod38.z.string().min(1).optional(),
|
|
21507
|
+
baseUrl: import_zod38.z.string().min(1).optional(),
|
|
21025
21508
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
|
|
21026
21509
|
codex: CodexProviderConfigSchema.optional()
|
|
21027
21510
|
});
|
|
21028
21511
|
var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
|
|
21029
|
-
var ConfigProviderRemoveInputSchema =
|
|
21512
|
+
var ConfigProviderRemoveInputSchema = import_zod38.z.strictObject({ name: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
21030
21513
|
var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
|
|
21031
|
-
var ConfigRuleAddInputSchema =
|
|
21032
|
-
path:
|
|
21033
|
-
configProfile:
|
|
21034
|
-
identity:
|
|
21514
|
+
var ConfigRuleAddInputSchema = import_zod38.z.strictObject({
|
|
21515
|
+
path: import_zod38.z.string().min(1),
|
|
21516
|
+
configProfile: import_zod38.z.string().min(1).optional(),
|
|
21517
|
+
identity: import_zod38.z.string().min(1).optional()
|
|
21035
21518
|
});
|
|
21036
21519
|
var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
|
|
21037
|
-
var ConfigRuleSetInputSchema =
|
|
21038
|
-
path:
|
|
21039
|
-
configProfile:
|
|
21040
|
-
identity:
|
|
21520
|
+
var ConfigRuleSetInputSchema = import_zod38.z.strictObject({
|
|
21521
|
+
path: import_zod38.z.string().min(1),
|
|
21522
|
+
configProfile: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional(),
|
|
21523
|
+
identity: import_zod38.z.union([import_zod38.z.string().min(1), import_zod38.z.literal(false)]).optional()
|
|
21041
21524
|
});
|
|
21042
21525
|
var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
|
|
21043
|
-
var ConfigRuleRemoveInputSchema =
|
|
21526
|
+
var ConfigRuleRemoveInputSchema = import_zod38.z.strictObject({ path: import_zod38.z.string().min(1), confirm: RemovalConfirmationSchema });
|
|
21044
21527
|
var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
|
|
21045
21528
|
|
|
21046
21529
|
// src/frontdoor/configApi.ts
|
|
@@ -21392,51 +21875,51 @@ var import_openapi4 = require("@orpc/openapi");
|
|
|
21392
21875
|
var import_server3 = require("@orpc/server");
|
|
21393
21876
|
|
|
21394
21877
|
// src/frontdoor/eventSchemas.ts
|
|
21395
|
-
var
|
|
21878
|
+
var import_zod39 = require("zod");
|
|
21396
21879
|
init_schema2();
|
|
21397
21880
|
var DOOR_EVENT_SOURCE_RC = "rc";
|
|
21398
21881
|
var LAUNCH_EVENT_SOURCE = "launch";
|
|
21399
21882
|
var USAGE_EVENT_SOURCE = "usage";
|
|
21400
21883
|
var DOOR_HEALTH_EVENT_SOURCE = "door";
|
|
21401
21884
|
var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
|
|
21402
|
-
var DoorEventSchema =
|
|
21403
|
-
source:
|
|
21885
|
+
var DoorEventSchema = import_zod39.z.strictObject({
|
|
21886
|
+
source: import_zod39.z.string().min(1),
|
|
21404
21887
|
/** A positive integer because the backbone's counters start at one and only ever increase. */
|
|
21405
|
-
sequence:
|
|
21406
|
-
payload:
|
|
21407
|
-
});
|
|
21408
|
-
var DoorEventSourceQuerySchema =
|
|
21409
|
-
sources:
|
|
21410
|
-
});
|
|
21411
|
-
var LaunchLifecycleEventSchema =
|
|
21412
|
-
kind:
|
|
21413
|
-
pid:
|
|
21414
|
-
startedAt:
|
|
21415
|
-
observedAt:
|
|
21416
|
-
});
|
|
21417
|
-
var DoorHealthEventSchema =
|
|
21418
|
-
|
|
21419
|
-
|
|
21420
|
-
|
|
21421
|
-
|
|
21422
|
-
|
|
21423
|
-
|
|
21888
|
+
sequence: import_zod39.z.number().int().positive(),
|
|
21889
|
+
payload: import_zod39.z.unknown()
|
|
21890
|
+
});
|
|
21891
|
+
var DoorEventSourceQuerySchema = import_zod39.z.strictObject({
|
|
21892
|
+
sources: import_zod39.z.array(import_zod39.z.string().min(1)).min(1).optional()
|
|
21893
|
+
});
|
|
21894
|
+
var LaunchLifecycleEventSchema = import_zod39.z.strictObject({
|
|
21895
|
+
kind: import_zod39.z.enum(["registered", "pruned", "ended"]),
|
|
21896
|
+
pid: import_zod39.z.number().int().positive(),
|
|
21897
|
+
startedAt: import_zod39.z.number(),
|
|
21898
|
+
observedAt: import_zod39.z.number()
|
|
21899
|
+
});
|
|
21900
|
+
var DoorHealthEventSchema = import_zod39.z.discriminatedUnion("kind", [
|
|
21901
|
+
import_zod39.z.strictObject({ kind: import_zod39.z.literal("generation"), pid: import_zod39.z.number().int().positive(), providerPort: import_zod39.z.number().int().positive(), connectPort: import_zod39.z.number().int().positive(), directPort: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() }),
|
|
21902
|
+
import_zod39.z.strictObject({ kind: import_zod39.z.literal("listenerFailed"), pid: import_zod39.z.number().int().positive(), listener: import_zod39.z.enum(["provider", "connect", "direct"]), message: import_zod39.z.string(), observedAt: import_zod39.z.number() }),
|
|
21903
|
+
import_zod39.z.strictObject({ kind: import_zod39.z.literal("binaryTurnover"), pid: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() }),
|
|
21904
|
+
import_zod39.z.strictObject({ kind: import_zod39.z.literal("idleShutdown"), pid: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() }),
|
|
21905
|
+
import_zod39.z.strictObject({ kind: import_zod39.z.literal("superseded"), pid: import_zod39.z.number().int().positive(), ownerPid: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() }),
|
|
21906
|
+
import_zod39.z.strictObject({ kind: import_zod39.z.literal("drained"), pid: import_zod39.z.number().int().positive(), observedAt: import_zod39.z.number() })
|
|
21424
21907
|
]);
|
|
21425
|
-
var QuotaExpiringEventSchema =
|
|
21908
|
+
var QuotaExpiringEventSchema = import_zod39.z.strictObject({
|
|
21426
21909
|
/** The id of the identity whose window it is: what its usage is filed under, which a rename keeps. */
|
|
21427
|
-
id:
|
|
21910
|
+
id: import_zod39.z.string().min(1),
|
|
21428
21911
|
/** The identity's name when the event was published, absent for an identity no longer stored under the id. */
|
|
21429
|
-
name:
|
|
21430
|
-
provider:
|
|
21431
|
-
window:
|
|
21912
|
+
name: import_zod39.z.string().min(1).optional(),
|
|
21913
|
+
provider: import_zod39.z.string().min(1),
|
|
21914
|
+
window: import_zod39.z.enum(["fiveHour", "sevenDay"]),
|
|
21432
21915
|
/** The fraction of the window already used when it was seen expiring, always below one because a fully used window has nothing left to spend. */
|
|
21433
|
-
utilization:
|
|
21434
|
-
resetsAt:
|
|
21435
|
-
observedAt:
|
|
21916
|
+
utilization: import_zod39.z.number().min(0).max(1),
|
|
21917
|
+
resetsAt: import_zod39.z.iso.datetime(),
|
|
21918
|
+
observedAt: import_zod39.z.number()
|
|
21436
21919
|
});
|
|
21437
21920
|
var UsageChangeEventSchema = UsageSnapshotSchema.extend({
|
|
21438
|
-
id:
|
|
21439
|
-
name:
|
|
21921
|
+
id: import_zod39.z.string().min(1),
|
|
21922
|
+
name: import_zod39.z.string().min(1).optional()
|
|
21440
21923
|
});
|
|
21441
21924
|
|
|
21442
21925
|
// src/frontdoor/eventsApi.ts
|
|
@@ -21480,7 +21963,7 @@ function createEventsApiRouter(deps) {
|
|
|
21480
21963
|
// src/frontdoor/lifecycleApi.ts
|
|
21481
21964
|
var import_client4 = require("@orpc/client");
|
|
21482
21965
|
var import_openapi5 = require("@orpc/openapi");
|
|
21483
|
-
var
|
|
21966
|
+
var import_zod40 = require("zod");
|
|
21484
21967
|
init_update();
|
|
21485
21968
|
var FRONTDOOR_API_TAG = "frontdoor";
|
|
21486
21969
|
var UPDATE_API_TAG = "update";
|
|
@@ -21488,7 +21971,7 @@ function createLifecycleApiRouter(deps) {
|
|
|
21488
21971
|
const authed = doorApiAuth(deps.expectedToken);
|
|
21489
21972
|
return {
|
|
21490
21973
|
frontdoor: {
|
|
21491
|
-
refreshCatalogues: authed.meta((0, import_openapi5.openapi)({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(
|
|
21974
|
+
refreshCatalogues: authed.meta((0, import_openapi5.openapi)({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(import_zod40.z.strictObject({ requested: import_zod40.z.literal(true) })).handler(() => {
|
|
21492
21975
|
deps.refreshCatalogues();
|
|
21493
21976
|
return { requested: true };
|
|
21494
21977
|
}),
|
|
@@ -21525,62 +22008,62 @@ init_cliError();
|
|
|
21525
22008
|
|
|
21526
22009
|
// src/frontdoor/launchSchemas.ts
|
|
21527
22010
|
var import_node_path44 = __toESM(require("node:path"), 1);
|
|
21528
|
-
var
|
|
22011
|
+
var import_zod41 = require("zod");
|
|
21529
22012
|
init_statusline();
|
|
21530
22013
|
init_claudeVersion();
|
|
21531
22014
|
init_identity();
|
|
21532
|
-
var LaunchResolveInputSchema =
|
|
21533
|
-
path:
|
|
22015
|
+
var LaunchResolveInputSchema = import_zod41.z.strictObject({
|
|
22016
|
+
path: import_zod41.z.string().min(1),
|
|
21534
22017
|
/** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
|
|
21535
|
-
argv:
|
|
22018
|
+
argv: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string())).optional(),
|
|
21536
22019
|
/** The launch's inherited environment. Absent means an empty one: the door's own environment is never a substitute for the caller's, so a caller that wants `AGENT_SHIM_*` switches or a `CLAUDE_CONFIG_DIR` considered names them here. Values are read, never reported. */
|
|
21537
|
-
env:
|
|
22020
|
+
env: import_zod41.z.record(import_zod41.z.string(), import_zod41.z.string()).optional()
|
|
21538
22021
|
}).refine((input) => import_node_path44.default.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
21539
|
-
var LaunchPoolDecisionSchema =
|
|
21540
|
-
name:
|
|
21541
|
-
reasons:
|
|
21542
|
-
movedOff:
|
|
21543
|
-
});
|
|
21544
|
-
var LaunchDecisionSchema =
|
|
21545
|
-
identity:
|
|
21546
|
-
identityId:
|
|
21547
|
-
identitySource:
|
|
22022
|
+
var LaunchPoolDecisionSchema = import_zod41.z.strictObject({
|
|
22023
|
+
name: import_zod41.z.string(),
|
|
22024
|
+
reasons: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string())),
|
|
22025
|
+
movedOff: import_zod41.z.strictObject({ identity: import_zod41.z.string(), reason: import_zod41.z.string() }).optional()
|
|
22026
|
+
});
|
|
22027
|
+
var LaunchDecisionSchema = import_zod41.z.strictObject({
|
|
22028
|
+
identity: import_zod41.z.string().optional(),
|
|
22029
|
+
identityId: import_zod41.z.string().optional(),
|
|
22030
|
+
identitySource: import_zod41.z.enum(IDENTITY_DECISION_SOURCES),
|
|
21548
22031
|
pool: LaunchPoolDecisionSchema.optional(),
|
|
21549
22032
|
/** True when `CLAUDE_CONFIG_DIR` was already set and nothing on the command line named an identity; an identity named there outranks the variable and leaves it false. */
|
|
21550
|
-
configDirEscapeHatch:
|
|
21551
|
-
configDir:
|
|
21552
|
-
configProfile:
|
|
21553
|
-
configProfileSource:
|
|
21554
|
-
provider:
|
|
21555
|
-
});
|
|
21556
|
-
var LaunchFlagsSchema =
|
|
21557
|
-
skipPermissions:
|
|
21558
|
-
remoteControl:
|
|
21559
|
-
headroom:
|
|
21560
|
-
trackUsage:
|
|
21561
|
-
pause:
|
|
21562
|
-
explain:
|
|
22033
|
+
configDirEscapeHatch: import_zod41.z.boolean(),
|
|
22034
|
+
configDir: import_zod41.z.string().optional(),
|
|
22035
|
+
configProfile: import_zod41.z.string().optional(),
|
|
22036
|
+
configProfileSource: import_zod41.z.enum(CONFIG_PROFILE_DECISION_SOURCES),
|
|
22037
|
+
provider: import_zod41.z.string().optional()
|
|
22038
|
+
});
|
|
22039
|
+
var LaunchFlagsSchema = import_zod41.z.strictObject({
|
|
22040
|
+
skipPermissions: import_zod41.z.boolean(),
|
|
22041
|
+
remoteControl: import_zod41.z.boolean(),
|
|
22042
|
+
headroom: import_zod41.z.boolean(),
|
|
22043
|
+
trackUsage: import_zod41.z.boolean(),
|
|
22044
|
+
pause: import_zod41.z.boolean(),
|
|
22045
|
+
explain: import_zod41.z.boolean(),
|
|
21563
22046
|
/** How long the launch waits after its own output before it starts claude, in milliseconds. */
|
|
21564
|
-
delayMs:
|
|
22047
|
+
delayMs: import_zod41.z.number(),
|
|
21565
22048
|
/** The hosts the launch keeps off the front door by adding them to the child's `NO_PROXY`. */
|
|
21566
|
-
proxyBypass:
|
|
22049
|
+
proxyBypass: import_zod41.z.array(import_zod41.z.string()).readonly(),
|
|
21567
22050
|
/** How the session's built-in statusline looks, when the launch configures any of it. */
|
|
21568
22051
|
statusline: StatuslineSchema.optional()
|
|
21569
22052
|
});
|
|
21570
|
-
var LaunchResolveOutputSchema =
|
|
22053
|
+
var LaunchResolveOutputSchema = import_zod41.z.strictObject({
|
|
21571
22054
|
decision: LaunchDecisionSchema,
|
|
21572
22055
|
flags: LaunchFlagsSchema,
|
|
21573
|
-
claudeVersion:
|
|
22056
|
+
claudeVersion: import_zod41.z.strictObject({ version: import_zod41.z.string(), source: import_zod41.z.enum(CLAUDE_VERSION_SOURCES) }).optional(),
|
|
21574
22057
|
/** The real `claude` binary the launch would spawn, on the door's host. */
|
|
21575
|
-
bin:
|
|
22058
|
+
bin: import_zod41.z.string(),
|
|
21576
22059
|
/** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
|
|
21577
|
-
args:
|
|
22060
|
+
args: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string())),
|
|
21578
22061
|
/** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
|
|
21579
|
-
credential:
|
|
21580
|
-
routing:
|
|
22062
|
+
credential: import_zod41.z.strictObject({ subject: import_zod41.z.enum(["provider", "identity"]), name: import_zod41.z.string(), summary: CredentialSummarySchema }).optional(),
|
|
22063
|
+
routing: import_zod41.z.strictObject({ frontDoor: import_zod41.z.boolean(), headroom: import_zod41.z.boolean() }),
|
|
21581
22064
|
/** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
|
|
21582
|
-
environment:
|
|
21583
|
-
warnings:
|
|
22065
|
+
environment: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string())),
|
|
22066
|
+
warnings: import_zod41.z.readonly(import_zod41.z.array(import_zod41.z.string()))
|
|
21584
22067
|
});
|
|
21585
22068
|
|
|
21586
22069
|
// src/frontdoor/launchApi.ts
|
|
@@ -21616,22 +22099,22 @@ function createLaunchApiRouter(deps) {
|
|
|
21616
22099
|
// src/frontdoor/agentTreesApi.ts
|
|
21617
22100
|
var import_client6 = require("@orpc/client");
|
|
21618
22101
|
var import_openapi7 = require("@orpc/openapi");
|
|
21619
|
-
var
|
|
22102
|
+
var import_zod42 = require("zod");
|
|
21620
22103
|
init_cliError();
|
|
21621
|
-
var AgentTreesListInputSchema =
|
|
22104
|
+
var AgentTreesListInputSchema = import_zod42.z.strictObject({
|
|
21622
22105
|
/** Only this identity's sessions. */
|
|
21623
|
-
identity:
|
|
22106
|
+
identity: import_zod42.z.string().optional(),
|
|
21624
22107
|
/** Include sessions that spawned no agent and ran no workflow. */
|
|
21625
|
-
all:
|
|
22108
|
+
all: import_zod42.z.boolean().optional()
|
|
21626
22109
|
});
|
|
21627
|
-
var AgentTreesListOutputSchema =
|
|
21628
|
-
var AgentTreesShowInputSchema =
|
|
22110
|
+
var AgentTreesListOutputSchema = import_zod42.z.array(SessionSummarySchema);
|
|
22111
|
+
var AgentTreesShowInputSchema = import_zod42.z.strictObject({
|
|
21629
22112
|
/** A session id, or an unambiguous prefix of one. */
|
|
21630
|
-
session:
|
|
22113
|
+
session: import_zod42.z.string().min(1),
|
|
21631
22114
|
/** Look only in this identity. */
|
|
21632
|
-
identity:
|
|
22115
|
+
identity: import_zod42.z.string().optional()
|
|
21633
22116
|
});
|
|
21634
|
-
var AgentTreesShowOutputSchema =
|
|
22117
|
+
var AgentTreesShowOutputSchema = import_zod42.z.strictObject({ identities: import_zod42.z.array(import_zod42.z.string()), ...MergedAgentTreeSchema.shape });
|
|
21635
22118
|
function asBadRequest(error) {
|
|
21636
22119
|
if (error instanceof CliError) {
|
|
21637
22120
|
throw new import_client6.ORPCError("BAD_REQUEST", { message: error.message });
|
|
@@ -21684,7 +22167,7 @@ var import_openapi8 = require("@orpc/openapi");
|
|
|
21684
22167
|
var import_server4 = require("@orpc/server");
|
|
21685
22168
|
|
|
21686
22169
|
// src/frontdoor/rcEventLog.ts
|
|
21687
|
-
var
|
|
22170
|
+
var import_zod43 = require("zod");
|
|
21688
22171
|
|
|
21689
22172
|
// src/frontdoor/eventHub.ts
|
|
21690
22173
|
var DOOR_EVENT_BUFFER_EVENTS = 100;
|
|
@@ -21807,46 +22290,46 @@ var NUMBER_FIELDS = ["at", "sequence"].length;
|
|
|
21807
22290
|
var BYTES_PER_CODE_UNIT = Uint16Array.BYTES_PER_ELEMENT;
|
|
21808
22291
|
var RC_SESSION_END_REASONS = ["expired", "archived", "conflict"];
|
|
21809
22292
|
var RC_PENDING_RETIRE_REASONS = ["answered", "expired", "session-ended"];
|
|
21810
|
-
var transitionBase = { session:
|
|
21811
|
-
var cursorFields = { cursor:
|
|
21812
|
-
var sessionAppearedShape = { kind:
|
|
21813
|
-
var sessionEndedShape = { kind:
|
|
21814
|
-
var workerStateShape = { kind:
|
|
21815
|
-
var pendingBornShape = { kind:
|
|
21816
|
-
var pendingRetiredShape = { kind:
|
|
21817
|
-
var RcSessionTransitionSchema =
|
|
21818
|
-
|
|
21819
|
-
|
|
21820
|
-
|
|
21821
|
-
|
|
21822
|
-
|
|
22293
|
+
var transitionBase = { session: import_zod43.z.string(), at: import_zod43.z.number() };
|
|
22294
|
+
var cursorFields = { cursor: import_zod43.z.string(), sequence: import_zod43.z.int().positive() };
|
|
22295
|
+
var sessionAppearedShape = { kind: import_zod43.z.literal("session-appeared"), ...transitionBase };
|
|
22296
|
+
var sessionEndedShape = { kind: import_zod43.z.literal("session-ended"), reason: import_zod43.z.enum(RC_SESSION_END_REASONS), ...transitionBase };
|
|
22297
|
+
var workerStateShape = { kind: import_zod43.z.literal("worker-state"), state: import_zod43.z.string(), previous: import_zod43.z.string().optional(), ...transitionBase };
|
|
22298
|
+
var pendingBornShape = { kind: import_zod43.z.literal("pending-born"), requestId: import_zod43.z.string(), type: import_zod43.z.string(), summary: import_zod43.z.string(), ...transitionBase };
|
|
22299
|
+
var pendingRetiredShape = { kind: import_zod43.z.literal("pending-retired"), requestId: import_zod43.z.string(), reason: import_zod43.z.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
|
|
22300
|
+
var RcSessionTransitionSchema = import_zod43.z.discriminatedUnion("kind", [
|
|
22301
|
+
import_zod43.z.strictObject(sessionAppearedShape),
|
|
22302
|
+
import_zod43.z.strictObject(sessionEndedShape),
|
|
22303
|
+
import_zod43.z.strictObject(workerStateShape),
|
|
22304
|
+
import_zod43.z.strictObject(pendingBornShape),
|
|
22305
|
+
import_zod43.z.strictObject(pendingRetiredShape)
|
|
21823
22306
|
]);
|
|
21824
22307
|
var KIND_MAX_CHARS = Math.max(...RcSessionTransitionSchema.options.map((option) => option.shape.kind.value.length));
|
|
21825
22308
|
var RC_SESSION_EVENT_MAX_BYTES = (RC_SESSION_EVENT_GENERATION_MAX_CHARS + ".".length + SEQUENCE_MAX_DIGITS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + KIND_MAX_CHARS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + RC_SESSION_EVENT_TOKEN_MAX_CHARS + RC_SESSION_EVENT_SUMMARY_MAX_CHARS) * BYTES_PER_CODE_UNIT + NUMBER_FIELDS * NUMBER_BYTES;
|
|
21826
22309
|
var RC_SESSION_EVENT_LOG_CAPACITY = Math.floor(CONTROL_BODY_CAP_BYTES / RC_SESSION_EVENT_MAX_BYTES);
|
|
21827
|
-
var RcSessionEventSchema =
|
|
21828
|
-
|
|
21829
|
-
|
|
21830
|
-
|
|
21831
|
-
|
|
21832
|
-
|
|
22310
|
+
var RcSessionEventSchema = import_zod43.z.discriminatedUnion("kind", [
|
|
22311
|
+
import_zod43.z.strictObject({ ...cursorFields, ...sessionAppearedShape }),
|
|
22312
|
+
import_zod43.z.strictObject({ ...cursorFields, ...sessionEndedShape }),
|
|
22313
|
+
import_zod43.z.strictObject({ ...cursorFields, ...workerStateShape }),
|
|
22314
|
+
import_zod43.z.strictObject({ ...cursorFields, ...pendingBornShape }),
|
|
22315
|
+
import_zod43.z.strictObject({ ...cursorFields, ...pendingRetiredShape })
|
|
21833
22316
|
]);
|
|
21834
|
-
var RcSessionEventsReadInputSchema =
|
|
22317
|
+
var RcSessionEventsReadInputSchema = import_zod43.z.strictObject({
|
|
21835
22318
|
/** The cursor of the last event the caller saw; every retained event when omitted. */
|
|
21836
|
-
since:
|
|
22319
|
+
since: import_zod43.z.string().min(1).optional(),
|
|
21837
22320
|
/** One `cse_` session id; every session when omitted. */
|
|
21838
|
-
session:
|
|
22321
|
+
session: import_zod43.z.string().min(1).optional(),
|
|
21839
22322
|
/** The most events one answer carries; every event after `since` when omitted. */
|
|
21840
|
-
limit:
|
|
22323
|
+
limit: import_zod43.z.int().positive().optional()
|
|
21841
22324
|
});
|
|
21842
22325
|
var RcSessionEventsPageInputSchema = RcSessionEventsReadInputSchema.extend({
|
|
21843
22326
|
/** The most events this page carries: by default and at most, the bound the door's event backbone already holds per slow consumer (`DOOR_EVENT_BUFFER_EVENTS`, oRPC's own documented default for that case). A page lands whole in its reader, so a reader receives at most one consumer buffer's worth at a time (at worst `DOOR_EVENT_BUFFER_EVENTS` times `RC_SESSION_EVENT_MAX_BYTES`) and pages on with the cursor for more; a maximum of the whole window would let one page carry the log's entire memory budget into an agent's context. */
|
|
21844
|
-
limit:
|
|
22327
|
+
limit: import_zod43.z.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
|
|
21845
22328
|
});
|
|
21846
22329
|
var RcSessionEventsStreamInputSchema = RcSessionEventsReadInputSchema.omit({ limit: true });
|
|
21847
|
-
var RcSessionEventsReadOutputSchema =
|
|
21848
|
-
|
|
21849
|
-
|
|
22330
|
+
var RcSessionEventsReadOutputSchema = import_zod43.z.discriminatedUnion("status", [
|
|
22331
|
+
import_zod43.z.strictObject({ status: import_zod43.z.literal("ok"), events: import_zod43.z.readonly(import_zod43.z.array(RcSessionEventSchema)), cursor: import_zod43.z.string(), more: import_zod43.z.boolean(), head: import_zod43.z.string() }),
|
|
22332
|
+
import_zod43.z.strictObject({ status: import_zod43.z.literal("expired"), message: import_zod43.z.string(), head: import_zod43.z.string() })
|
|
21850
22333
|
]);
|
|
21851
22334
|
var CURSOR_SEPARATOR = ".";
|
|
21852
22335
|
var RESYNC_ADVICE = "cursor expired, resync from status: read `rc status` for every session's present state, then resume after the head this answer names";
|
|
@@ -22345,15 +22828,15 @@ function createQuotaExpiringPublisher(hub, deps) {
|
|
|
22345
22828
|
|
|
22346
22829
|
// src/frontdoor/rcLiveUsage.ts
|
|
22347
22830
|
var RC_RATE_LIMIT_EVENT_TYPE = "rate_limit_event";
|
|
22348
|
-
function
|
|
22831
|
+
function isRecord9(value) {
|
|
22349
22832
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22350
22833
|
}
|
|
22351
22834
|
function rcRateLimitInfoOf(event) {
|
|
22352
22835
|
const payload = event.envelope.payload;
|
|
22353
|
-
if (!
|
|
22836
|
+
if (!isRecord9(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
|
|
22354
22837
|
return void 0;
|
|
22355
22838
|
}
|
|
22356
|
-
if (!
|
|
22839
|
+
if (!isRecord9(payload.rate_limit_info)) {
|
|
22357
22840
|
return void 0;
|
|
22358
22841
|
}
|
|
22359
22842
|
const parsed = RcRateLimitInfoSchema.safeParse(payload.rate_limit_info);
|
|
@@ -22441,7 +22924,7 @@ function createSseParser() {
|
|
|
22441
22924
|
}
|
|
22442
22925
|
};
|
|
22443
22926
|
}
|
|
22444
|
-
function
|
|
22927
|
+
function isRecord10(value) {
|
|
22445
22928
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22446
22929
|
}
|
|
22447
22930
|
function sequenceNumOf(value) {
|
|
@@ -22463,7 +22946,7 @@ function parseRcStreamEnvelope(parsed) {
|
|
|
22463
22946
|
} catch {
|
|
22464
22947
|
return void 0;
|
|
22465
22948
|
}
|
|
22466
|
-
if (!
|
|
22949
|
+
if (!isRecord10(data)) {
|
|
22467
22950
|
return void 0;
|
|
22468
22951
|
}
|
|
22469
22952
|
const eventType = data.event_type;
|
|
@@ -22710,7 +23193,13 @@ init_capability();
|
|
|
22710
23193
|
// src/frontdoor/rcSelfHostEndpoints.ts
|
|
22711
23194
|
var RC_SOURCE_WORKER = "worker";
|
|
22712
23195
|
var RC_SOURCE_CLIENT = "client";
|
|
22713
|
-
|
|
23196
|
+
var CLIENT_PLATFORM_HEADER = "anthropic-client-platform";
|
|
23197
|
+
function withClientPlatform(payload, headers) {
|
|
23198
|
+
const rest = Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "client_platform"));
|
|
23199
|
+
const platform = headers[CLIENT_PLATFORM_HEADER];
|
|
23200
|
+
return typeof platform === "string" && platform !== "" ? { ...rest, client_platform: platform } : rest;
|
|
23201
|
+
}
|
|
23202
|
+
function isRecord11(value) {
|
|
22714
23203
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22715
23204
|
}
|
|
22716
23205
|
function parseJsonObject2(body) {
|
|
@@ -22720,7 +23209,7 @@ function parseJsonObject2(body) {
|
|
|
22720
23209
|
} catch {
|
|
22721
23210
|
return void 0;
|
|
22722
23211
|
}
|
|
22723
|
-
return
|
|
23212
|
+
return isRecord11(parsed) ? parsed : void 0;
|
|
22724
23213
|
}
|
|
22725
23214
|
function nonEmptyString2(record, field) {
|
|
22726
23215
|
const value = record === void 0 ? void 0 : record[field];
|
|
@@ -22794,11 +23283,11 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
|
22794
23283
|
}
|
|
22795
23284
|
const results = [];
|
|
22796
23285
|
for (const event of events) {
|
|
22797
|
-
if (!
|
|
23286
|
+
if (!isRecord11(event) || !isRecord11(event.payload)) {
|
|
22798
23287
|
await ctx.answerJson(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a teleport write is an object carrying one payload object" } });
|
|
22799
23288
|
return true;
|
|
22800
23289
|
}
|
|
22801
|
-
const published = ctx.publish(host.conversation, host.writer, RC_SOURCE_CLIENT, event.payload);
|
|
23290
|
+
const published = ctx.publish(host.conversation, host.writer, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
|
|
22802
23291
|
results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
|
|
22803
23292
|
}
|
|
22804
23293
|
ctx.sweep();
|
|
@@ -22894,7 +23383,7 @@ async function serveRcCompatSessions(ctx, pathname, compatPath) {
|
|
|
22894
23383
|
// src/frontdoor/rcSelfHostConversations.ts
|
|
22895
23384
|
var RC_CONVERSATIONS_PATH_PREFIX = "/v1/code/conversations";
|
|
22896
23385
|
var RC_CONVERSATION_ID_PREFIX = "conv_";
|
|
22897
|
-
function
|
|
23386
|
+
function isRecord12(value) {
|
|
22898
23387
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22899
23388
|
}
|
|
22900
23389
|
function parseJsonObject3(body) {
|
|
@@ -22904,7 +23393,7 @@ function parseJsonObject3(body) {
|
|
|
22904
23393
|
} catch {
|
|
22905
23394
|
return void 0;
|
|
22906
23395
|
}
|
|
22907
|
-
return
|
|
23396
|
+
return isRecord12(parsed) ? parsed : void 0;
|
|
22908
23397
|
}
|
|
22909
23398
|
function nonEmptyString3(record, field) {
|
|
22910
23399
|
const value = record === void 0 ? void 0 : record[field];
|
|
@@ -22958,11 +23447,11 @@ async function serveRcConversations(ctx, pathname, method) {
|
|
|
22958
23447
|
}
|
|
22959
23448
|
const results = [];
|
|
22960
23449
|
for (const event of events) {
|
|
22961
|
-
if (!
|
|
23450
|
+
if (!isRecord12(event) || !isRecord12(event.payload)) {
|
|
22962
23451
|
await ctx.answerJson(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a write is an object carrying one payload object" } });
|
|
22963
23452
|
return;
|
|
22964
23453
|
}
|
|
22965
|
-
const published = ctx.publish(conversation, { session: void 0, half: "client" }, RC_SOURCE_CLIENT, event.payload);
|
|
23454
|
+
const published = ctx.publish(conversation, { session: void 0, half: "client" }, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
|
|
22966
23455
|
results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
|
|
22967
23456
|
}
|
|
22968
23457
|
ctx.sweep();
|
|
@@ -22990,7 +23479,7 @@ var RC_SELF_HOST_SCOPE_LIST = ["user:profile", "user:inference", "user:sessions:
|
|
|
22990
23479
|
var RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS = 3600;
|
|
22991
23480
|
var MS_PER_SECOND6 = 1e3;
|
|
22992
23481
|
var HTTP_SERVICE_UNAVAILABLE = 503;
|
|
22993
|
-
function
|
|
23482
|
+
function isRecord13(value) {
|
|
22994
23483
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22995
23484
|
}
|
|
22996
23485
|
function parseJsonObject4(body) {
|
|
@@ -23000,7 +23489,7 @@ function parseJsonObject4(body) {
|
|
|
23000
23489
|
} catch {
|
|
23001
23490
|
return void 0;
|
|
23002
23491
|
}
|
|
23003
|
-
return
|
|
23492
|
+
return isRecord13(parsed) ? parsed : void 0;
|
|
23004
23493
|
}
|
|
23005
23494
|
function growthBookFeatures() {
|
|
23006
23495
|
return {
|
|
@@ -23354,7 +23843,7 @@ var RC_SELF_HOST_WORKER_EPOCH = 1;
|
|
|
23354
23843
|
var RC_STREAM_EVENT_NAME2 = "client_event";
|
|
23355
23844
|
var CONFLICT_REASON_HEADER2 = "x-ccr-conflict-reason";
|
|
23356
23845
|
var CONFLICT_REASON_EPOCH_STALE = "epoch_stale";
|
|
23357
|
-
function
|
|
23846
|
+
function isRecord14(value) {
|
|
23358
23847
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23359
23848
|
}
|
|
23360
23849
|
function isWebSearchRefusal(value) {
|
|
@@ -23438,7 +23927,7 @@ function parseJsonObject5(body) {
|
|
|
23438
23927
|
} catch {
|
|
23439
23928
|
return void 0;
|
|
23440
23929
|
}
|
|
23441
|
-
return
|
|
23930
|
+
return isRecord14(parsed) ? parsed : void 0;
|
|
23442
23931
|
}
|
|
23443
23932
|
function mintWorkerJwt(randomToken, issuedAt) {
|
|
23444
23933
|
const encode = (value) => Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
|
|
@@ -23698,7 +24187,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
23698
24187
|
if (status !== void 0) {
|
|
23699
24188
|
session.workerStatus = status;
|
|
23700
24189
|
}
|
|
23701
|
-
if (
|
|
24190
|
+
if (isRecord14(body?.external_metadata)) {
|
|
23702
24191
|
session.externalMetadata = body.external_metadata;
|
|
23703
24192
|
}
|
|
23704
24193
|
await answerJson2(response, HTTP_STATUS.ok, {});
|
|
@@ -23728,7 +24217,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
23728
24217
|
}
|
|
23729
24218
|
const results = [];
|
|
23730
24219
|
for (const event of events) {
|
|
23731
|
-
if (!
|
|
24220
|
+
if (!isRecord14(event) || !isRecord14(event.payload)) {
|
|
23732
24221
|
await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a batch is an object carrying one payload object" } });
|
|
23733
24222
|
return;
|
|
23734
24223
|
}
|
|
@@ -23761,7 +24250,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
23761
24250
|
return;
|
|
23762
24251
|
}
|
|
23763
24252
|
for (const event of events) {
|
|
23764
|
-
if (
|
|
24253
|
+
if (isRecord14(event)) {
|
|
23765
24254
|
session.internalEvents.push({ eventId: deps.newUuid(), body: event });
|
|
23766
24255
|
}
|
|
23767
24256
|
}
|
|
@@ -23857,11 +24346,11 @@ data: ${JSON.stringify(envelope)}
|
|
|
23857
24346
|
}
|
|
23858
24347
|
const results = [];
|
|
23859
24348
|
for (const event of events) {
|
|
23860
|
-
if (!
|
|
24349
|
+
if (!isRecord14(event) || !isRecord14(event.payload)) {
|
|
23861
24350
|
await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a write is an object carrying one payload object" } });
|
|
23862
24351
|
return;
|
|
23863
24352
|
}
|
|
23864
|
-
const published = publish(session.conversation, { session: session.id, half: "client" }, RC_SOURCE_CLIENT, event.payload);
|
|
24353
|
+
const published = publish(session.conversation, { session: session.id, half: "client" }, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
|
|
23865
24354
|
results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
|
|
23866
24355
|
}
|
|
23867
24356
|
sweep();
|
|
@@ -23995,7 +24484,7 @@ var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
|
|
|
23995
24484
|
var RC_SELF_HOST_RECORD_FILE = "credential.json";
|
|
23996
24485
|
var SELF_HOST_EMAIL = "selfhost@agent-shim.invalid";
|
|
23997
24486
|
var SELF_HOST_SUBSCRIPTION_TYPE = "max";
|
|
23998
|
-
function
|
|
24487
|
+
function isRecord15(value) {
|
|
23999
24488
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24000
24489
|
}
|
|
24001
24490
|
function readJsonObject(fs17, file) {
|
|
@@ -24009,7 +24498,7 @@ function readJsonObject(fs17, file) {
|
|
|
24009
24498
|
} catch {
|
|
24010
24499
|
return void 0;
|
|
24011
24500
|
}
|
|
24012
|
-
return
|
|
24501
|
+
return isRecord15(parsed) ? parsed : void 0;
|
|
24013
24502
|
}
|
|
24014
24503
|
function readRcSelfHostRecord(fs17, frontdoorDir) {
|
|
24015
24504
|
const parsed = readJsonObject(fs17, import_node_path45.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
@@ -24037,7 +24526,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
24037
24526
|
const recordFile2 = import_node_path45.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
24038
24527
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
24039
24528
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
24040
|
-
const existingOauth =
|
|
24529
|
+
const existingOauth = isRecord15(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
24041
24530
|
const existingToken = typeof existingOauth?.accessToken === "string" && existingOauth.accessToken !== "" ? existingOauth.accessToken : void 0;
|
|
24042
24531
|
const existingIsOwn = existingToken !== void 0 && previousRecord?.accessToken === existingToken;
|
|
24043
24532
|
if (existingToken !== void 0 && !existingIsOwn && !deps.force) {
|
|
@@ -24054,7 +24543,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
24054
24543
|
deps.fs.writeFilePrivate(credentialsFile, `${JSON.stringify({ ...existingCredentials, claudeAiOauth: { accessToken, refreshToken, expiresAt: null, scopes: [...RC_SELF_HOST_SCOPE_LIST], subscriptionType: SELF_HOST_SUBSCRIPTION_TYPE, rateLimitTier: null } }, null, 2)}
|
|
24055
24544
|
`);
|
|
24056
24545
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
24057
|
-
const existingBlock = (value) =>
|
|
24546
|
+
const existingBlock = (value) => isRecord15(value) ? value : {};
|
|
24058
24547
|
deps.fs.writeFilePrivate(claudeJsonFile, `${JSON.stringify({
|
|
24059
24548
|
...claudeJson,
|
|
24060
24549
|
oauthAccount: {
|
|
@@ -24177,7 +24666,7 @@ init_poolPick();
|
|
|
24177
24666
|
|
|
24178
24667
|
// src/agents/read.ts
|
|
24179
24668
|
var import_node_path47 = __toESM(require("node:path"), 1);
|
|
24180
|
-
var
|
|
24669
|
+
var import_zod44 = require("zod");
|
|
24181
24670
|
var PROJECTS_DIR = "projects";
|
|
24182
24671
|
var TASKS_DIR = "tasks";
|
|
24183
24672
|
var SUBAGENTS_DIR = "subagents";
|
|
@@ -24296,14 +24785,14 @@ function parseJson2(text) {
|
|
|
24296
24785
|
return void 0;
|
|
24297
24786
|
}
|
|
24298
24787
|
}
|
|
24299
|
-
var TaskFileSchema =
|
|
24300
|
-
var WorkflowRunFileSchema =
|
|
24301
|
-
runId:
|
|
24302
|
-
workflowName:
|
|
24303
|
-
status:
|
|
24304
|
-
startTime:
|
|
24305
|
-
phases:
|
|
24306
|
-
summary:
|
|
24788
|
+
var TaskFileSchema = import_zod44.z.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: import_zod44.z.array(import_zod44.z.string()).default([]), blockedBy: import_zod44.z.array(import_zod44.z.string()).default([]) });
|
|
24789
|
+
var WorkflowRunFileSchema = import_zod44.z.object({
|
|
24790
|
+
runId: import_zod44.z.string(),
|
|
24791
|
+
workflowName: import_zod44.z.string().optional(),
|
|
24792
|
+
status: import_zod44.z.string().optional(),
|
|
24793
|
+
startTime: import_zod44.z.number().optional(),
|
|
24794
|
+
phases: import_zod44.z.array(import_zod44.z.object({ title: import_zod44.z.string() })).default([]),
|
|
24795
|
+
summary: import_zod44.z.string().optional()
|
|
24307
24796
|
});
|
|
24308
24797
|
function summariseSession(fs17, configDir, ref) {
|
|
24309
24798
|
const sessionRelative = import_node_path47.default.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
@@ -24808,6 +25297,8 @@ init_ownCli();
|
|
|
24808
25297
|
QUOTA_EXPIRING_EVENT_SOURCE,
|
|
24809
25298
|
QuotaExpiringEventSchema,
|
|
24810
25299
|
RC_CONTEXT_USAGE_DETAILS,
|
|
25300
|
+
RC_GOAL_CLEAR_WORDS,
|
|
25301
|
+
RC_GOAL_CONDITION_MAX_CHARS,
|
|
24811
25302
|
RC_IDLE_EXPIRY_MS,
|
|
24812
25303
|
RC_ORPC_PATH_PREFIX,
|
|
24813
25304
|
RC_PENDING_DEADLINE_MS,
|
|
@@ -24823,6 +25314,8 @@ init_ownCli();
|
|
|
24823
25314
|
RC_SELF_HOST_SCOPE_LIST,
|
|
24824
25315
|
RC_SELF_HOST_WORKER_JWT_TTL_SECONDS,
|
|
24825
25316
|
RC_SESSIONS_PATH_PREFIX,
|
|
25317
|
+
RC_SESSION_COMMAND_MAX_WAIT_MS,
|
|
25318
|
+
RC_SESSION_COMMAND_VERIFIED_VERSIONS,
|
|
24826
25319
|
RC_SESSION_END_REASONS,
|
|
24827
25320
|
RC_SESSION_EVENT_LOG_CAPACITY,
|
|
24828
25321
|
RC_STREAM_BACKOFF_MS,
|
|
@@ -24918,11 +25411,13 @@ init_ownCli();
|
|
|
24918
25411
|
createQuotaExpiringPublisher,
|
|
24919
25412
|
createRcApiNodeHandler,
|
|
24920
25413
|
createRcApiRouter,
|
|
25414
|
+
createRcClaudeCodeVersions,
|
|
24921
25415
|
createRcControlHandler,
|
|
24922
25416
|
createRcCredentialStore,
|
|
24923
25417
|
createRcEventFanout,
|
|
24924
25418
|
createRcLiveUsage,
|
|
24925
25419
|
createRcSelfHostSurface,
|
|
25420
|
+
createRcSessionCommands,
|
|
24926
25421
|
createRcSessionEventLog,
|
|
24927
25422
|
createRcSessionEventsApiRouter,
|
|
24928
25423
|
createRcSessionRegistryReader,
|
|
@@ -24985,6 +25480,7 @@ init_ownCli();
|
|
|
24985
25480
|
mintRcSelfHostCredential,
|
|
24986
25481
|
observingRoutedRoute,
|
|
24987
25482
|
parseConnectTarget,
|
|
25483
|
+
parseRcGoalOutput,
|
|
24988
25484
|
parseRcStreamEnvelope,
|
|
24989
25485
|
planOf,
|
|
24990
25486
|
poolIdentities,
|
|
@@ -24996,6 +25492,8 @@ init_ownCli();
|
|
|
24996
25492
|
rankPool,
|
|
24997
25493
|
rcEventWriteResultFromAnswer,
|
|
24998
25494
|
rcFanoutOnDoorHub,
|
|
25495
|
+
rcLocalCommandAnswerOf,
|
|
25496
|
+
rcManualCompactBoundaryOf,
|
|
24999
25497
|
rcObserverAsPassthrough,
|
|
25000
25498
|
rcRateLimitInfoOf,
|
|
25001
25499
|
rcSelfHostFromEnv,
|