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.mjs
CHANGED
|
@@ -7268,30 +7268,30 @@ var init_state2 = __esm({
|
|
|
7268
7268
|
});
|
|
7269
7269
|
|
|
7270
7270
|
// src/headroom/earlierRelease.ts
|
|
7271
|
-
function withoutOurSocket(
|
|
7271
|
+
function withoutOurSocket(commandLine2, socketPath) {
|
|
7272
7272
|
for (const argument of [`--uds ${socketPath}`, `--uds=${socketPath}`]) {
|
|
7273
7273
|
let from = 0;
|
|
7274
7274
|
for (; ; ) {
|
|
7275
|
-
const index =
|
|
7275
|
+
const index = commandLine2.indexOf(argument, from);
|
|
7276
7276
|
if (index === -1) {
|
|
7277
7277
|
break;
|
|
7278
7278
|
}
|
|
7279
7279
|
const end = index + argument.length;
|
|
7280
|
-
const startsArgument = index === 0 || /\s/.test(
|
|
7281
|
-
const endsArgument = end ===
|
|
7280
|
+
const startsArgument = index === 0 || /\s/.test(commandLine2.charAt(index - 1));
|
|
7281
|
+
const endsArgument = end === commandLine2.length || /\s/.test(commandLine2.charAt(end));
|
|
7282
7282
|
if (startsArgument && endsArgument) {
|
|
7283
|
-
return `${
|
|
7283
|
+
return `${commandLine2.slice(0, index)} ${commandLine2.slice(end)}`;
|
|
7284
7284
|
}
|
|
7285
7285
|
from = index + 1;
|
|
7286
7286
|
}
|
|
7287
7287
|
}
|
|
7288
7288
|
return void 0;
|
|
7289
7289
|
}
|
|
7290
|
-
function daemonIdentity(
|
|
7291
|
-
if (
|
|
7290
|
+
function daemonIdentity(commandLine2, socketPath) {
|
|
7291
|
+
if (commandLine2 === void 0) {
|
|
7292
7292
|
return "unreadable";
|
|
7293
7293
|
}
|
|
7294
|
-
const rest = withoutOurSocket(
|
|
7294
|
+
const rest = withoutOurSocket(commandLine2, socketPath);
|
|
7295
7295
|
const argumentsList = rest === void 0 ? [] : rest.trim().split(/\s+/);
|
|
7296
7296
|
if (rest === void 0 || !argumentsList.includes("proxy")) {
|
|
7297
7297
|
return "not-headroom";
|
|
@@ -7390,8 +7390,8 @@ function ensureHeadroom(params) {
|
|
|
7390
7390
|
writeSession(ports.fs, paths.headroomSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), supervisorPid: state.supervisorPid });
|
|
7391
7391
|
return { socketPath: state.socketPath };
|
|
7392
7392
|
}
|
|
7393
|
-
const
|
|
7394
|
-
const earlierRelease = earlierReleaseDaemon(ports.fs, paths, { commandLine, socketPath: state.socketPath, recordedHash: state.allowlistHash });
|
|
7393
|
+
const commandLine2 = commandLineOf(state.headroomPid);
|
|
7394
|
+
const earlierRelease = earlierReleaseDaemon(ports.fs, paths, { commandLine: commandLine2, socketPath: state.socketPath, recordedHash: state.allowlistHash });
|
|
7395
7395
|
if (earlierRelease !== void 0) {
|
|
7396
7396
|
if (earlierRelease.admitsServingDoor) {
|
|
7397
7397
|
writeSession(ports.fs, paths.headroomSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), supervisorPid: state.supervisorPid });
|
|
@@ -7401,7 +7401,7 @@ function ensureHeadroom(params) {
|
|
|
7401
7401
|
`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}`
|
|
7402
7402
|
);
|
|
7403
7403
|
}
|
|
7404
|
-
awaiting = { daemonPid: state.headroomPid, identity: daemonIdentity(
|
|
7404
|
+
awaiting = { daemonPid: state.headroomPid, identity: daemonIdentity(commandLine2, state.socketPath) };
|
|
7405
7405
|
}
|
|
7406
7406
|
if (state.lastError !== void 0) {
|
|
7407
7407
|
throw new HeadroomStartError(
|
|
@@ -9211,6 +9211,9 @@ function assessIdentity(member, nowMs) {
|
|
|
9211
9211
|
const state = member.snapshot?.providers[ANTHROPIC_PROVIDER];
|
|
9212
9212
|
const unified = unifiedOf(state);
|
|
9213
9213
|
if (member.snapshot === void 0 || state === void 0 || unified === void 0) {
|
|
9214
|
+
if (plan.kind === "pay-per-use") {
|
|
9215
|
+
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)"] } };
|
|
9216
|
+
}
|
|
9214
9217
|
return { candidate: { ...base, class: "unknown", reasons: ["no usage recorded yet, so its quota is unknown (turn on trackUsage for it)", ...planReasons] } };
|
|
9215
9218
|
}
|
|
9216
9219
|
const observedAgo = state.rateLimit === void 0 ? "" : ` (last seen ${formatAge(nowMs - Date.parse(state.rateLimit.observedAt))} ago)`;
|
|
@@ -9342,7 +9345,7 @@ function rankPool(input) {
|
|
|
9342
9345
|
return { ...candidate, feasible: false, runsDryAtMs: nowMs + Math.min(...dryAfterMs), reasons: [...drySpots, ...candidate.reasons] };
|
|
9343
9346
|
});
|
|
9344
9347
|
const ordered = input.preference === "listed" ? [...candidates] : [...candidates].sort(
|
|
9345
|
-
(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)
|
|
9348
|
+
(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)
|
|
9346
9349
|
);
|
|
9347
9350
|
const sticky = input.sticky;
|
|
9348
9351
|
const stickyIndex = sticky === void 0 ? -1 : ordered.findIndex((candidate) => candidate.identity === sticky.identity);
|
|
@@ -10489,7 +10492,7 @@ var init_package = __esm({
|
|
|
10489
10492
|
"package.json"() {
|
|
10490
10493
|
package_default = {
|
|
10491
10494
|
name: "claude-use",
|
|
10492
|
-
version: "11.
|
|
10495
|
+
version: "11.90.0",
|
|
10493
10496
|
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.",
|
|
10494
10497
|
license: "MIT",
|
|
10495
10498
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -10835,7 +10838,7 @@ var init_paths = __esm({
|
|
|
10835
10838
|
});
|
|
10836
10839
|
|
|
10837
10840
|
// src/providerAliases.ts
|
|
10838
|
-
import { z as
|
|
10841
|
+
import { z as z25 } from "zod";
|
|
10839
10842
|
function parseAliases(file, raw) {
|
|
10840
10843
|
const parsed = ProviderAliasesSchema.safeParse(raw);
|
|
10841
10844
|
if (!parsed.success) {
|
|
@@ -10874,7 +10877,7 @@ var init_providerAliases = __esm({
|
|
|
10874
10877
|
init_cliError();
|
|
10875
10878
|
init_load();
|
|
10876
10879
|
init_store();
|
|
10877
|
-
ProviderAliasesSchema =
|
|
10880
|
+
ProviderAliasesSchema = z25.record(z25.string().min(1), z25.string().min(1));
|
|
10878
10881
|
}
|
|
10879
10882
|
});
|
|
10880
10883
|
|
|
@@ -11099,14 +11102,14 @@ function requireProviderExists(paths, name) {
|
|
|
11099
11102
|
throw new ProviderNotFoundError(name);
|
|
11100
11103
|
}
|
|
11101
11104
|
}
|
|
11102
|
-
function
|
|
11105
|
+
function isRecord8(value) {
|
|
11103
11106
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11104
11107
|
}
|
|
11105
11108
|
function legacyProviderConversion(raw) {
|
|
11106
|
-
if (!
|
|
11109
|
+
if (!isRecord8(raw) || "credential" in raw) {
|
|
11107
11110
|
return void 0;
|
|
11108
11111
|
}
|
|
11109
|
-
const env =
|
|
11112
|
+
const env = isRecord8(raw.env) ? raw.env : void 0;
|
|
11110
11113
|
const legacyEnvKeys = env === void 0 ? [] : Object.keys(env).filter((key) => LEGACY_ENV_CREDENTIAL_KEYS.includes(key));
|
|
11111
11114
|
const fields = [...LEGACY_PROVIDER_FIELDS.filter((field) => field in raw), ...legacyEnvKeys.map((key) => `env.${key}`)];
|
|
11112
11115
|
if (fields.length === 0) {
|
|
@@ -11589,7 +11592,7 @@ var init_headers = __esm({
|
|
|
11589
11592
|
|
|
11590
11593
|
// src/launcher/injected.ts
|
|
11591
11594
|
import { createHash as createHash8 } from "node:crypto";
|
|
11592
|
-
import { z as
|
|
11595
|
+
import { z as z26 } from "zod";
|
|
11593
11596
|
function listKey(list) {
|
|
11594
11597
|
return `${list},appended`;
|
|
11595
11598
|
}
|
|
@@ -11682,7 +11685,7 @@ var init_injected = __esm({
|
|
|
11682
11685
|
INJECTED_ENV = "AGENT_SHIM_INJECTED";
|
|
11683
11686
|
CUSTOM_HEADERS_ENV = "ANTHROPIC_CUSTOM_HEADERS";
|
|
11684
11687
|
HEADER_KEY_PREFIX = `${CUSTOM_HEADERS_ENV}:`;
|
|
11685
|
-
InjectedSchema =
|
|
11688
|
+
InjectedSchema = z26.record(z26.string(), z26.string());
|
|
11686
11689
|
}
|
|
11687
11690
|
});
|
|
11688
11691
|
|
|
@@ -11818,7 +11821,7 @@ var init_commandDeps = __esm({
|
|
|
11818
11821
|
// src/claudeShim.ts
|
|
11819
11822
|
import fs11 from "node:fs";
|
|
11820
11823
|
import path38 from "node:path";
|
|
11821
|
-
import { z as
|
|
11824
|
+
import { z as z31 } from "zod";
|
|
11822
11825
|
function commandFilename(ownExecutablePath, commandName) {
|
|
11823
11826
|
return ownExecutablePath.toLowerCase().endsWith(".exe") ? `${commandName}.exe` : commandName;
|
|
11824
11827
|
}
|
|
@@ -11868,35 +11871,35 @@ var init_claudeShim = __esm({
|
|
|
11868
11871
|
init_store();
|
|
11869
11872
|
init_realPorts();
|
|
11870
11873
|
init_cliError();
|
|
11871
|
-
ClaudeShimStateSchema =
|
|
11872
|
-
targetPath:
|
|
11873
|
-
method:
|
|
11874
|
-
installedAtMs:
|
|
11874
|
+
ClaudeShimStateSchema = z31.strictObject({
|
|
11875
|
+
targetPath: z31.string().min(1),
|
|
11876
|
+
method: z31.enum(["hardlink", "copy"]),
|
|
11877
|
+
installedAtMs: z31.number()
|
|
11875
11878
|
});
|
|
11876
11879
|
nodeLinkFs = { link: fs11.linkSync, copyFile: fs11.copyFileSync, chmod: fs11.chmodSync };
|
|
11877
11880
|
}
|
|
11878
11881
|
});
|
|
11879
11882
|
|
|
11880
11883
|
// src/codex/auth.ts
|
|
11881
|
-
import { z as
|
|
11884
|
+
import { z as z32 } from "zod";
|
|
11882
11885
|
var AuthFileSchema, TokenGrantSchema, CodexAuthError;
|
|
11883
11886
|
var init_auth = __esm({
|
|
11884
11887
|
"src/codex/auth.ts"() {
|
|
11885
11888
|
"use strict";
|
|
11886
|
-
AuthFileSchema =
|
|
11887
|
-
tokens:
|
|
11888
|
-
access_token:
|
|
11889
|
-
refresh_token:
|
|
11890
|
-
id_token:
|
|
11891
|
-
account_id:
|
|
11889
|
+
AuthFileSchema = z32.looseObject({
|
|
11890
|
+
tokens: z32.looseObject({
|
|
11891
|
+
access_token: z32.string().optional(),
|
|
11892
|
+
refresh_token: z32.string().optional(),
|
|
11893
|
+
id_token: z32.string().optional(),
|
|
11894
|
+
account_id: z32.string().optional()
|
|
11892
11895
|
}).nullish(),
|
|
11893
|
-
last_refresh:
|
|
11896
|
+
last_refresh: z32.string().optional()
|
|
11894
11897
|
});
|
|
11895
|
-
TokenGrantSchema =
|
|
11896
|
-
access_token:
|
|
11897
|
-
refresh_token:
|
|
11898
|
-
id_token:
|
|
11899
|
-
account_id:
|
|
11898
|
+
TokenGrantSchema = z32.looseObject({
|
|
11899
|
+
access_token: z32.string().min(1).optional(),
|
|
11900
|
+
refresh_token: z32.string().min(1).optional(),
|
|
11901
|
+
id_token: z32.string().min(1).optional(),
|
|
11902
|
+
account_id: z32.string().min(1).optional()
|
|
11900
11903
|
});
|
|
11901
11904
|
CodexAuthError = class extends Error {
|
|
11902
11905
|
constructor(message) {
|
|
@@ -11908,7 +11911,7 @@ var init_auth = __esm({
|
|
|
11908
11911
|
});
|
|
11909
11912
|
|
|
11910
11913
|
// src/codex/siwc.ts
|
|
11911
|
-
import { z as
|
|
11914
|
+
import { z as z33 } from "zod";
|
|
11912
11915
|
var SIWC_RESOURCE, SIWC_RESPONSES_URL, SIWC_PLAN_SCOPE, TokenResponseSchema, JwtHeaderSchema, IdTokenClaimsSchema, JwksSchema;
|
|
11913
11916
|
var init_siwc = __esm({
|
|
11914
11917
|
"src/codex/siwc.ts"() {
|
|
@@ -11916,28 +11919,28 @@ var init_siwc = __esm({
|
|
|
11916
11919
|
SIWC_RESOURCE = "https://api.openai.com/v1";
|
|
11917
11920
|
SIWC_RESPONSES_URL = `${SIWC_RESOURCE}/responses`;
|
|
11918
11921
|
SIWC_PLAN_SCOPE = "chatgpt.tokens.use.direct";
|
|
11919
|
-
TokenResponseSchema =
|
|
11920
|
-
access_token:
|
|
11921
|
-
refresh_token:
|
|
11922
|
-
id_token:
|
|
11923
|
-
expires_in:
|
|
11924
|
-
scope:
|
|
11922
|
+
TokenResponseSchema = z33.looseObject({
|
|
11923
|
+
access_token: z33.string().min(1),
|
|
11924
|
+
refresh_token: z33.string().min(1).optional(),
|
|
11925
|
+
id_token: z33.string().min(1).optional(),
|
|
11926
|
+
expires_in: z33.number().positive(),
|
|
11927
|
+
scope: z33.string().optional()
|
|
11925
11928
|
});
|
|
11926
|
-
JwtHeaderSchema =
|
|
11927
|
-
IdTokenClaimsSchema =
|
|
11928
|
-
iss:
|
|
11929
|
-
sub:
|
|
11930
|
-
aud:
|
|
11931
|
-
exp:
|
|
11932
|
-
nonce:
|
|
11933
|
-
email:
|
|
11929
|
+
JwtHeaderSchema = z33.looseObject({ alg: z33.string(), kid: z33.string().optional() });
|
|
11930
|
+
IdTokenClaimsSchema = z33.looseObject({
|
|
11931
|
+
iss: z33.string(),
|
|
11932
|
+
sub: z33.string().min(1),
|
|
11933
|
+
aud: z33.union([z33.string(), z33.array(z33.string())]),
|
|
11934
|
+
exp: z33.number(),
|
|
11935
|
+
nonce: z33.string().optional(),
|
|
11936
|
+
email: z33.string().optional()
|
|
11934
11937
|
});
|
|
11935
|
-
JwksSchema =
|
|
11938
|
+
JwksSchema = z33.object({ keys: z33.array(z33.looseObject({ kid: z33.string().optional(), kty: z33.string() })) });
|
|
11936
11939
|
}
|
|
11937
11940
|
});
|
|
11938
11941
|
|
|
11939
11942
|
// src/codex/siwcStore.ts
|
|
11940
|
-
import { z as
|
|
11943
|
+
import { z as z34 } from "zod";
|
|
11941
11944
|
function parseSiwcFile(raw, filePath) {
|
|
11942
11945
|
let json;
|
|
11943
11946
|
try {
|
|
@@ -11957,18 +11960,18 @@ var init_siwcStore = __esm({
|
|
|
11957
11960
|
"use strict";
|
|
11958
11961
|
init_auth();
|
|
11959
11962
|
init_siwc();
|
|
11960
|
-
SiwcGrantSchema =
|
|
11961
|
-
clientId:
|
|
11962
|
-
sub:
|
|
11963
|
-
email:
|
|
11964
|
-
idToken:
|
|
11965
|
-
accessToken:
|
|
11966
|
-
refreshToken:
|
|
11967
|
-
scopes:
|
|
11963
|
+
SiwcGrantSchema = z34.strictObject({
|
|
11964
|
+
clientId: z34.string().min(1),
|
|
11965
|
+
sub: z34.string().min(1),
|
|
11966
|
+
email: z34.string().optional(),
|
|
11967
|
+
idToken: z34.string().min(1),
|
|
11968
|
+
accessToken: z34.string().min(1),
|
|
11969
|
+
refreshToken: z34.string().min(1),
|
|
11970
|
+
scopes: z34.array(z34.string()).readonly(),
|
|
11968
11971
|
/** When the access token stops working, in milliseconds since the epoch. */
|
|
11969
|
-
expiresAt:
|
|
11972
|
+
expiresAt: z34.number()
|
|
11970
11973
|
});
|
|
11971
|
-
SiwcFileSchema =
|
|
11974
|
+
SiwcFileSchema = z34.strictObject({ registeredClientId: z34.string().min(1).optional(), grant: SiwcGrantSchema.optional() });
|
|
11972
11975
|
}
|
|
11973
11976
|
});
|
|
11974
11977
|
|
|
@@ -12028,7 +12031,7 @@ var init_modelsStore = __esm({
|
|
|
12028
12031
|
// src/codex/catalogueCredential.ts
|
|
12029
12032
|
import { createHash as createHash9 } from "node:crypto";
|
|
12030
12033
|
import path41 from "node:path";
|
|
12031
|
-
import { z as
|
|
12034
|
+
import { z as z35 } from "zod";
|
|
12032
12035
|
function parseCatalogueBinding(raw) {
|
|
12033
12036
|
if (raw === void 0) return void 0;
|
|
12034
12037
|
try {
|
|
@@ -12069,7 +12072,7 @@ var init_catalogueCredential = __esm({
|
|
|
12069
12072
|
"src/codex/catalogueCredential.ts"() {
|
|
12070
12073
|
"use strict";
|
|
12071
12074
|
init_siwcStore();
|
|
12072
|
-
CatalogueBindingSchema =
|
|
12075
|
+
CatalogueBindingSchema = z35.strictObject({ fingerprint: z35.string().min(1), source: z35.string().min(1), revision: z35.string().min(1) });
|
|
12073
12076
|
}
|
|
12074
12077
|
});
|
|
12075
12078
|
|
|
@@ -12120,64 +12123,64 @@ var init_signatures = __esm({
|
|
|
12120
12123
|
});
|
|
12121
12124
|
|
|
12122
12125
|
// src/codex/anthropic.ts
|
|
12123
|
-
import { z as
|
|
12126
|
+
import { z as z36 } from "zod";
|
|
12124
12127
|
var TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
|
|
12125
12128
|
var init_anthropic = __esm({
|
|
12126
12129
|
"src/codex/anthropic.ts"() {
|
|
12127
12130
|
"use strict";
|
|
12128
|
-
TextBlockSchema =
|
|
12129
|
-
Base64ImageSourceSchema =
|
|
12130
|
-
UrlImageSourceSchema =
|
|
12131
|
-
ImageBlockSchema =
|
|
12132
|
-
type:
|
|
12133
|
-
source:
|
|
12131
|
+
TextBlockSchema = z36.looseObject({ type: z36.literal("text"), text: z36.string() });
|
|
12132
|
+
Base64ImageSourceSchema = z36.looseObject({ type: z36.literal("base64"), media_type: z36.string().min(1), data: z36.string() });
|
|
12133
|
+
UrlImageSourceSchema = z36.looseObject({ type: z36.literal("url"), url: z36.string().min(1) });
|
|
12134
|
+
ImageBlockSchema = z36.looseObject({
|
|
12135
|
+
type: z36.literal("image"),
|
|
12136
|
+
source: z36.union([Base64ImageSourceSchema, UrlImageSourceSchema])
|
|
12134
12137
|
});
|
|
12135
|
-
ToolUseBlockSchema =
|
|
12136
|
-
type:
|
|
12137
|
-
id:
|
|
12138
|
-
name:
|
|
12139
|
-
input:
|
|
12138
|
+
ToolUseBlockSchema = z36.looseObject({
|
|
12139
|
+
type: z36.literal("tool_use"),
|
|
12140
|
+
id: z36.string().min(1),
|
|
12141
|
+
name: z36.string().min(1),
|
|
12142
|
+
input: z36.unknown()
|
|
12140
12143
|
});
|
|
12141
|
-
ToolResultContentBlockSchema =
|
|
12142
|
-
ToolResultBlockSchema =
|
|
12143
|
-
type:
|
|
12144
|
-
tool_use_id:
|
|
12145
|
-
content:
|
|
12144
|
+
ToolResultContentBlockSchema = z36.union([TextBlockSchema, z36.looseObject({ type: z36.string() })]);
|
|
12145
|
+
ToolResultBlockSchema = z36.looseObject({
|
|
12146
|
+
type: z36.literal("tool_result"),
|
|
12147
|
+
tool_use_id: z36.string().min(1),
|
|
12148
|
+
content: z36.union([z36.string(), z36.array(ToolResultContentBlockSchema)]).optional()
|
|
12146
12149
|
});
|
|
12147
|
-
OtherBlockSchema =
|
|
12148
|
-
ContentBlockSchema =
|
|
12149
|
-
MessageSchema =
|
|
12150
|
-
role:
|
|
12151
|
-
content:
|
|
12150
|
+
OtherBlockSchema = z36.looseObject({ type: z36.string() });
|
|
12151
|
+
ContentBlockSchema = z36.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
|
|
12152
|
+
MessageSchema = z36.looseObject({
|
|
12153
|
+
role: z36.enum(["user", "assistant", "system"]),
|
|
12154
|
+
content: z36.union([z36.string(), z36.array(ContentBlockSchema)])
|
|
12152
12155
|
});
|
|
12153
|
-
ToolSchema =
|
|
12154
|
-
name:
|
|
12155
|
-
description:
|
|
12156
|
-
input_schema:
|
|
12157
|
-
allowed_domains:
|
|
12158
|
-
blocked_domains:
|
|
12156
|
+
ToolSchema = z36.looseObject({
|
|
12157
|
+
name: z36.string().min(1),
|
|
12158
|
+
description: z36.string().optional(),
|
|
12159
|
+
input_schema: z36.record(z36.string(), z36.unknown()).optional(),
|
|
12160
|
+
allowed_domains: z36.array(z36.string()).optional(),
|
|
12161
|
+
blocked_domains: z36.array(z36.string()).optional()
|
|
12159
12162
|
});
|
|
12160
|
-
ToolChoiceSchema =
|
|
12161
|
-
|
|
12162
|
-
|
|
12163
|
+
ToolChoiceSchema = z36.union([
|
|
12164
|
+
z36.looseObject({ type: z36.enum(["auto", "none", "any"]) }),
|
|
12165
|
+
z36.looseObject({ type: z36.literal("tool"), name: z36.string().min(1) })
|
|
12163
12166
|
]);
|
|
12164
|
-
SystemSchema =
|
|
12165
|
-
MessagesRequestSchema =
|
|
12166
|
-
model:
|
|
12167
|
+
SystemSchema = z36.union([z36.string(), z36.array(z36.union([TextBlockSchema, OtherBlockSchema]))]);
|
|
12168
|
+
MessagesRequestSchema = z36.looseObject({
|
|
12169
|
+
model: z36.string().optional(),
|
|
12167
12170
|
system: SystemSchema.optional(),
|
|
12168
|
-
messages:
|
|
12169
|
-
tools:
|
|
12171
|
+
messages: z36.array(MessageSchema),
|
|
12172
|
+
tools: z36.array(ToolSchema).optional(),
|
|
12170
12173
|
tool_choice: ToolChoiceSchema.optional(),
|
|
12171
|
-
stream:
|
|
12174
|
+
stream: z36.boolean().optional(),
|
|
12172
12175
|
/** `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. */
|
|
12173
|
-
metadata:
|
|
12176
|
+
metadata: z36.looseObject({ user_id: z36.string().optional() }).optional(),
|
|
12174
12177
|
/** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
|
|
12175
|
-
output_config:
|
|
12178
|
+
output_config: z36.looseObject({ effort: z36.string().optional(), format: z36.object({ type: z36.literal("json_schema"), schema: z36.record(z36.string(), z36.unknown()) }).optional() }).optional()
|
|
12176
12179
|
});
|
|
12177
|
-
CountTokensRequestSchema =
|
|
12178
|
-
system:
|
|
12179
|
-
messages:
|
|
12180
|
-
tools:
|
|
12180
|
+
CountTokensRequestSchema = z36.looseObject({
|
|
12181
|
+
system: z36.unknown().optional(),
|
|
12182
|
+
messages: z36.unknown().optional(),
|
|
12183
|
+
tools: z36.unknown().optional()
|
|
12181
12184
|
});
|
|
12182
12185
|
}
|
|
12183
12186
|
});
|
|
@@ -13531,7 +13534,7 @@ function withLauncherSettings(passthrough, settings) {
|
|
|
13531
13534
|
}
|
|
13532
13535
|
return [...kept, "--settings", settings, ...tail];
|
|
13533
13536
|
}
|
|
13534
|
-
function
|
|
13537
|
+
function isRecord16(value) {
|
|
13535
13538
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13536
13539
|
}
|
|
13537
13540
|
function mergeSettings(parts) {
|
|
@@ -13542,7 +13545,7 @@ function mergeSettings(parts) {
|
|
|
13542
13545
|
continue;
|
|
13543
13546
|
}
|
|
13544
13547
|
const parsed = JSON.parse(part);
|
|
13545
|
-
if (!
|
|
13548
|
+
if (!isRecord16(parsed)) {
|
|
13546
13549
|
throw new Error("a launch's settings part is not a JSON object");
|
|
13547
13550
|
}
|
|
13548
13551
|
for (const [key, value] of Object.entries(parsed)) {
|
|
@@ -15224,7 +15227,7 @@ var init_identityClaude = __esm({
|
|
|
15224
15227
|
});
|
|
15225
15228
|
|
|
15226
15229
|
// src/usage/providerQuota.ts
|
|
15227
|
-
import { z as
|
|
15230
|
+
import { z as z45 } from "zod";
|
|
15228
15231
|
var 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;
|
|
15229
15232
|
var init_providerQuota = __esm({
|
|
15230
15233
|
"src/usage/providerQuota.ts"() {
|
|
@@ -15243,35 +15246,35 @@ var init_providerQuota = __esm({
|
|
|
15243
15246
|
[ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND9],
|
|
15244
15247
|
[ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9]
|
|
15245
15248
|
]);
|
|
15246
|
-
ZaiLimitSchema =
|
|
15247
|
-
type:
|
|
15248
|
-
unit:
|
|
15249
|
-
number:
|
|
15250
|
-
percentage:
|
|
15251
|
-
nextResetTime:
|
|
15252
|
-
usage:
|
|
15253
|
-
currentValue:
|
|
15254
|
-
remaining:
|
|
15249
|
+
ZaiLimitSchema = z45.object({
|
|
15250
|
+
type: z45.string(),
|
|
15251
|
+
unit: z45.number().int(),
|
|
15252
|
+
number: z45.number().int().positive(),
|
|
15253
|
+
percentage: z45.number().nonnegative(),
|
|
15254
|
+
nextResetTime: z45.number().positive().optional(),
|
|
15255
|
+
usage: z45.number().nonnegative().optional(),
|
|
15256
|
+
currentValue: z45.number().nonnegative().optional(),
|
|
15257
|
+
remaining: z45.number().nonnegative().optional()
|
|
15255
15258
|
});
|
|
15256
|
-
ZaiResponseSchema =
|
|
15257
|
-
success:
|
|
15258
|
-
msg:
|
|
15259
|
-
data:
|
|
15259
|
+
ZaiResponseSchema = z45.object({
|
|
15260
|
+
success: z45.boolean(),
|
|
15261
|
+
msg: z45.string().optional(),
|
|
15262
|
+
data: z45.object({ level: z45.string().optional(), limits: z45.array(ZaiLimitSchema) })
|
|
15260
15263
|
});
|
|
15261
15264
|
OPENROUTER_HOST = "openrouter.ai";
|
|
15262
15265
|
OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
|
|
15263
15266
|
OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
|
|
15264
15267
|
MS_PER_DAY2 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
15265
|
-
OpenRouterKeySchema =
|
|
15266
|
-
data:
|
|
15267
|
-
limit:
|
|
15268
|
-
limit_remaining:
|
|
15269
|
-
limit_reset:
|
|
15270
|
-
is_free_tier:
|
|
15271
|
-
free_model_daily_requests:
|
|
15268
|
+
OpenRouterKeySchema = z45.object({
|
|
15269
|
+
data: z45.object({
|
|
15270
|
+
limit: z45.number().nonnegative().nullable(),
|
|
15271
|
+
limit_remaining: z45.number().nullable(),
|
|
15272
|
+
limit_reset: z45.string().nullable(),
|
|
15273
|
+
is_free_tier: z45.boolean().optional(),
|
|
15274
|
+
free_model_daily_requests: z45.object({ used: z45.number().nonnegative(), limit: z45.number().nonnegative(), remaining: z45.number() }).optional()
|
|
15272
15275
|
})
|
|
15273
15276
|
});
|
|
15274
|
-
OpenRouterCreditsSchema =
|
|
15277
|
+
OpenRouterCreditsSchema = z45.object({ data: z45.object({ total_credits: z45.number().nonnegative(), total_usage: z45.number().nonnegative() }) });
|
|
15275
15278
|
ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
|
|
15276
15279
|
ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
|
|
15277
15280
|
ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
|
|
@@ -15279,21 +15282,21 @@ var init_providerQuota = __esm({
|
|
|
15279
15282
|
DAYS_PER_WEEK2 = 7;
|
|
15280
15283
|
FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
15281
15284
|
WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND9;
|
|
15282
|
-
AntigravityBucketSchema =
|
|
15283
|
-
bucketId:
|
|
15284
|
-
remainingFraction:
|
|
15285
|
-
resetTime:
|
|
15285
|
+
AntigravityBucketSchema = z45.object({
|
|
15286
|
+
bucketId: z45.string(),
|
|
15287
|
+
remainingFraction: z45.number().optional(),
|
|
15288
|
+
resetTime: z45.string().optional()
|
|
15286
15289
|
});
|
|
15287
|
-
AntigravitySummarySchema =
|
|
15288
|
-
GoogleTokenInfoSchema =
|
|
15289
|
-
email:
|
|
15290
|
-
sub:
|
|
15290
|
+
AntigravitySummarySchema = z45.object({ groups: z45.array(z45.object({ buckets: z45.array(AntigravityBucketSchema) })) });
|
|
15291
|
+
GoogleTokenInfoSchema = z45.object({
|
|
15292
|
+
email: z45.string().optional(),
|
|
15293
|
+
sub: z45.string().optional()
|
|
15291
15294
|
});
|
|
15292
|
-
AntigravityUserSchema =
|
|
15295
|
+
AntigravityUserSchema = z45.object({
|
|
15293
15296
|
/** The code-assist tier context, which defaults to the free tier for every account. */
|
|
15294
|
-
currentTier:
|
|
15297
|
+
currentTier: z45.object({ name: z45.string().optional(), id: z45.string().optional() }).optional(),
|
|
15295
15298
|
/** The account's paid subscription; absent when the account has none. */
|
|
15296
|
-
paidTier:
|
|
15299
|
+
paidTier: z45.object({ name: z45.string().optional(), id: z45.string().optional() }).optional()
|
|
15297
15300
|
});
|
|
15298
15301
|
}
|
|
15299
15302
|
});
|
|
@@ -15946,9 +15949,11 @@ function createRcSessionTracker(deps) {
|
|
|
15946
15949
|
if (id?.startsWith(RC_SESSION_ID_PREFIX) !== true) {
|
|
15947
15950
|
return void 0;
|
|
15948
15951
|
}
|
|
15952
|
+
const isClientWrite = method === "POST" && (rest === `${id}/events` || rest === `${id}/teleport-events`);
|
|
15953
|
+
const sessionFacts = isClientWrite ? { ...facts, anthropicClientPlatform: void 0 } : facts;
|
|
15949
15954
|
const tracked = entries.get(id);
|
|
15950
15955
|
if (tracked !== void 0) {
|
|
15951
|
-
refresh(tracked,
|
|
15956
|
+
refresh(tracked, sessionFacts);
|
|
15952
15957
|
}
|
|
15953
15958
|
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;
|
|
15954
15959
|
let chunks = [];
|
|
@@ -16018,7 +16023,7 @@ function createRcSessionTracker(deps) {
|
|
|
16018
16023
|
}
|
|
16019
16024
|
accepted = isSuccessful(status);
|
|
16020
16025
|
if (accepted && !entries.has(id)) {
|
|
16021
|
-
persistCredential(birth(id,
|
|
16026
|
+
persistCredential(birth(id, sessionFacts));
|
|
16022
16027
|
}
|
|
16023
16028
|
file();
|
|
16024
16029
|
},
|
|
@@ -17743,6 +17748,11 @@ import { OpenAPIHandler } from "@orpc/openapi/node";
|
|
|
17743
17748
|
import { eventIterator, os as os3, withEventMeta } from "@orpc/server";
|
|
17744
17749
|
import { BodyLimitPlugin, RPCHandler } from "@orpc/server/node";
|
|
17745
17750
|
import { Agent as Agent3, fetch as undiciFetch } from "undici";
|
|
17751
|
+
|
|
17752
|
+
// src/supervise/compactTimeout.ts
|
|
17753
|
+
var COMPACT_TIMEOUT_MS = 9e5;
|
|
17754
|
+
|
|
17755
|
+
// src/frontdoor/rcApi.ts
|
|
17746
17756
|
init_capability();
|
|
17747
17757
|
|
|
17748
17758
|
// src/frontdoor/rcSchemas.ts
|
|
@@ -17914,6 +17924,438 @@ var RcAnswerOutputSchema = z22.strictObject({
|
|
|
17914
17924
|
sequenceNums: z22.readonly(z22.array(z22.number()))
|
|
17915
17925
|
});
|
|
17916
17926
|
|
|
17927
|
+
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
17928
|
+
import { z as z23 } from "zod";
|
|
17929
|
+
|
|
17930
|
+
// src/frontdoor/rcSessionCommands.ts
|
|
17931
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
17932
|
+
|
|
17933
|
+
// src/supervise/sessionControl.ts
|
|
17934
|
+
var RESULT_POLL_MS = 250;
|
|
17935
|
+
var REQUEST_INSTANT_DIGITS = String(Number.MAX_SAFE_INTEGER).length;
|
|
17936
|
+
|
|
17937
|
+
// src/frontdoor/rcSelfHostCommands.ts
|
|
17938
|
+
var RC_PERSON_CLIENT_PLATFORM = "web_claude_ai";
|
|
17939
|
+
async function writeRcPersonMessage(deps, sessionId, text) {
|
|
17940
|
+
const credential = deps.credentialOf(sessionId);
|
|
17941
|
+
if (credential === void 0) {
|
|
17942
|
+
return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
|
|
17943
|
+
}
|
|
17944
|
+
if (credential.authorization === void 0) {
|
|
17945
|
+
return noOAuthCredentialResult(sessionId);
|
|
17946
|
+
}
|
|
17947
|
+
const body = JSON.stringify(buildRcEventWriteBody(buildRcUserMessagePayload(deps.newUuid(), sessionId, text)));
|
|
17948
|
+
const bytes = Buffer.byteLength(body, "utf8");
|
|
17949
|
+
if (bytes > CONTROL_BODY_CAP_BYTES) {
|
|
17950
|
+
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` };
|
|
17951
|
+
}
|
|
17952
|
+
let answer;
|
|
17953
|
+
try {
|
|
17954
|
+
answer = await deps.dial.writeEvents(sessionId, rcWriteHeaders({ ...credential, anthropicClientPlatform: RC_PERSON_CLIENT_PLATFORM }), body);
|
|
17955
|
+
} catch (error) {
|
|
17956
|
+
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)}` };
|
|
17957
|
+
}
|
|
17958
|
+
const result = rcEventWriteResultFromAnswer(answer);
|
|
17959
|
+
if (result.ok) {
|
|
17960
|
+
deps.noteSequenceNums(sessionId, result.sequenceNums);
|
|
17961
|
+
}
|
|
17962
|
+
return result;
|
|
17963
|
+
}
|
|
17964
|
+
function isRecord7(value) {
|
|
17965
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17966
|
+
}
|
|
17967
|
+
function rcLocalCommandAnswerOf(event, command, args) {
|
|
17968
|
+
const payload = event.envelope.payload;
|
|
17969
|
+
if (!isRecord7(payload) || payload.type !== "assistant" || !isRecord7(payload.local_command_run) || payload.local_command_run.command !== command || payload.local_command_run.args !== args) {
|
|
17970
|
+
return void 0;
|
|
17971
|
+
}
|
|
17972
|
+
const message = payload.message;
|
|
17973
|
+
if (!isRecord7(message) || !Array.isArray(message.content)) {
|
|
17974
|
+
return void 0;
|
|
17975
|
+
}
|
|
17976
|
+
const blocks = message.content;
|
|
17977
|
+
const text = blocks.flatMap((block) => isRecord7(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
|
|
17978
|
+
const outcome = isRecord7(payload.local_command_outcome) && typeof payload.local_command_outcome.kind === "string" ? payload.local_command_outcome.kind : void 0;
|
|
17979
|
+
return { text, outcome };
|
|
17980
|
+
}
|
|
17981
|
+
function rcManualCompactBoundaryOf(event) {
|
|
17982
|
+
const payload = event.envelope.payload;
|
|
17983
|
+
if (!isRecord7(payload) || payload.type !== "system" || payload.subtype !== "compact_boundary" || !isRecord7(payload.compact_metadata)) {
|
|
17984
|
+
return void 0;
|
|
17985
|
+
}
|
|
17986
|
+
const metadata = payload.compact_metadata;
|
|
17987
|
+
if (metadata.trigger !== "manual" || typeof metadata.pre_tokens !== "number" || typeof metadata.post_tokens !== "number") {
|
|
17988
|
+
return void 0;
|
|
17989
|
+
}
|
|
17990
|
+
return { trigger: metadata.trigger, preTokens: metadata.pre_tokens, postTokens: metadata.post_tokens };
|
|
17991
|
+
}
|
|
17992
|
+
function isPeerDelivery(event, text) {
|
|
17993
|
+
const payload = event.envelope.payload;
|
|
17994
|
+
if (!isRecord7(payload) || payload.type !== "user" || !isRecord7(payload.origin) || payload.origin.kind !== "peer" || !isRecord7(payload.message)) {
|
|
17995
|
+
return false;
|
|
17996
|
+
}
|
|
17997
|
+
return typeof payload.message.content === "string" && payload.message.content.includes(text);
|
|
17998
|
+
}
|
|
17999
|
+
var NO_GOAL_PREFIX = "No goal set";
|
|
18000
|
+
var ACTIVE_GOAL_PATTERN = /^Goal active: (?<condition>[\s\S]*?) \((?:not yet evaluated|(?<iterations>\d+) turns?)\)(?:\nLast check: (?<lastCheck>[\s\S]*))?$/u;
|
|
18001
|
+
function parseRcGoalOutput(output) {
|
|
18002
|
+
if (output.startsWith(NO_GOAL_PREFIX)) {
|
|
18003
|
+
return { goal: null };
|
|
18004
|
+
}
|
|
18005
|
+
const groups = ACTIVE_GOAL_PATTERN.exec(output)?.groups;
|
|
18006
|
+
const condition = groups?.condition;
|
|
18007
|
+
if (condition === void 0) {
|
|
18008
|
+
return void 0;
|
|
18009
|
+
}
|
|
18010
|
+
return { goal: { condition, iterations: groups?.iterations === void 0 ? 0 : Number(groups.iterations), ...groups?.lastCheck === void 0 ? {} : { lastCheck: groups.lastCheck } } };
|
|
18011
|
+
}
|
|
18012
|
+
var GOAL_CLEARED_PREFIX = "Goal cleared: ";
|
|
18013
|
+
var GOAL_SET_PREFIX = "Goal set: ";
|
|
18014
|
+
function commandLine(command) {
|
|
18015
|
+
if (command.kind === "goal-set") {
|
|
18016
|
+
return { name: "goal", args: command.condition };
|
|
18017
|
+
}
|
|
18018
|
+
if (command.kind === "compact") {
|
|
18019
|
+
return { name: "compact", args: command.instructions ?? "" };
|
|
18020
|
+
}
|
|
18021
|
+
return { name: "goal", args: command.kind === "goal-clear" ? "clear" : "" };
|
|
18022
|
+
}
|
|
18023
|
+
function recognise(command, event, name, args) {
|
|
18024
|
+
if (command.kind === "compact") {
|
|
18025
|
+
const boundary = rcManualCompactBoundaryOf(event);
|
|
18026
|
+
if (boundary !== void 0) {
|
|
18027
|
+
return { ok: true, report: boundary };
|
|
18028
|
+
}
|
|
18029
|
+
}
|
|
18030
|
+
const answer = rcLocalCommandAnswerOf(event, name, args);
|
|
18031
|
+
if (answer === void 0) {
|
|
18032
|
+
return void 0;
|
|
18033
|
+
}
|
|
18034
|
+
if (answer.outcome === "failed") {
|
|
18035
|
+
return { ok: false, message: `the worker reported /${name} failed: ${answer.text}` };
|
|
18036
|
+
}
|
|
18037
|
+
if (command.kind === "goal-get") {
|
|
18038
|
+
const report = parseRcGoalOutput(answer.text);
|
|
18039
|
+
return report === void 0 ? { ok: false, message: `the worker answered /goal with text the verified versions never produce: ${answer.text}` } : { ok: true, report };
|
|
18040
|
+
}
|
|
18041
|
+
if (command.kind === "goal-set") {
|
|
18042
|
+
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}` };
|
|
18043
|
+
}
|
|
18044
|
+
if (command.kind === "goal-clear") {
|
|
18045
|
+
if (answer.text.startsWith(GOAL_CLEARED_PREFIX)) {
|
|
18046
|
+
return { ok: true, report: { cleared: answer.text.slice(GOAL_CLEARED_PREFIX.length) } };
|
|
18047
|
+
}
|
|
18048
|
+
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}` };
|
|
18049
|
+
}
|
|
18050
|
+
return { ok: false, message: `the worker did not compact the session: ${answer.text}` };
|
|
18051
|
+
}
|
|
18052
|
+
async function runSelfHostedSlashCommand(deps, sessionId, command, waitMs, signal) {
|
|
18053
|
+
const { name, args } = commandLine(command);
|
|
18054
|
+
const text = args === "" ? `/${name}` : `/${name} ${args}`;
|
|
18055
|
+
const early = [];
|
|
18056
|
+
let after;
|
|
18057
|
+
let settle;
|
|
18058
|
+
const judge = (event) => {
|
|
18059
|
+
if (after === void 0) {
|
|
18060
|
+
early.push(event);
|
|
18061
|
+
return;
|
|
18062
|
+
}
|
|
18063
|
+
if (event.envelope.sequence_num <= after || event.envelope.source !== "worker") {
|
|
18064
|
+
return;
|
|
18065
|
+
}
|
|
18066
|
+
if (isPeerDelivery(event, text)) {
|
|
18067
|
+
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` });
|
|
18068
|
+
return;
|
|
18069
|
+
}
|
|
18070
|
+
const outcome = recognise(command, event, name, args);
|
|
18071
|
+
if (outcome !== void 0) {
|
|
18072
|
+
settle?.(outcome);
|
|
18073
|
+
}
|
|
18074
|
+
};
|
|
18075
|
+
const detach = deps.fanout.subscribe(sessionId, judge);
|
|
18076
|
+
let cancelTimer;
|
|
18077
|
+
const onAbort = () => {
|
|
18078
|
+
settle?.({ ok: false, message: `the request for ${text} on session ${sessionId} was aborted before the worker answered` });
|
|
18079
|
+
};
|
|
18080
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
18081
|
+
try {
|
|
18082
|
+
const answered = new Promise((resolve) => {
|
|
18083
|
+
settle = resolve;
|
|
18084
|
+
});
|
|
18085
|
+
const written = await writeRcPersonMessage(deps.personWrite, sessionId, text);
|
|
18086
|
+
if (!written.ok) {
|
|
18087
|
+
return written;
|
|
18088
|
+
}
|
|
18089
|
+
if (signal.aborted) {
|
|
18090
|
+
return { ok: false, message: `the request for ${text} on session ${sessionId} was aborted after it was written (sequence_num ${written.sequenceNums.join(", ")})` };
|
|
18091
|
+
}
|
|
18092
|
+
after = Math.max(...written.sequenceNums);
|
|
18093
|
+
const bound = waitMs ?? deps.defaultWaitMs;
|
|
18094
|
+
cancelTimer = deps.setTimer(() => {
|
|
18095
|
+
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` });
|
|
18096
|
+
}, bound);
|
|
18097
|
+
for (const event of early.splice(0)) {
|
|
18098
|
+
judge(event);
|
|
18099
|
+
}
|
|
18100
|
+
return await answered;
|
|
18101
|
+
} finally {
|
|
18102
|
+
signal.removeEventListener("abort", onAbort);
|
|
18103
|
+
cancelTimer?.();
|
|
18104
|
+
detach();
|
|
18105
|
+
}
|
|
18106
|
+
}
|
|
18107
|
+
function createRcClaudeCodeVersions(fanout) {
|
|
18108
|
+
const versions = /* @__PURE__ */ new Map();
|
|
18109
|
+
fanout.subscribe(void 0, (event) => {
|
|
18110
|
+
const payload = event.envelope.payload;
|
|
18111
|
+
if (event.envelope.source === "worker" && isRecord7(payload) && payload.type === "system" && payload.subtype === "init" && typeof payload.claude_code_version === "string") {
|
|
18112
|
+
versions.set(event.session, payload.claude_code_version);
|
|
18113
|
+
}
|
|
18114
|
+
});
|
|
18115
|
+
return {
|
|
18116
|
+
versionOf: (sessionId) => versions.get(sessionId),
|
|
18117
|
+
sweep: (isTracked) => {
|
|
18118
|
+
for (const sessionId of [...versions.keys()]) {
|
|
18119
|
+
if (!isTracked(sessionId)) {
|
|
18120
|
+
versions.delete(sessionId);
|
|
18121
|
+
}
|
|
18122
|
+
}
|
|
18123
|
+
}
|
|
18124
|
+
};
|
|
18125
|
+
}
|
|
18126
|
+
|
|
18127
|
+
// src/frontdoor/rcSessionCommands.ts
|
|
18128
|
+
var RC_SESSION_COMMAND_VERIFIED_VERSIONS = ["2.1.319"];
|
|
18129
|
+
var RC_GOAL_CLEAR_WORDS = ["clear", "stop", "off", "reset", "none", "cancel"];
|
|
18130
|
+
var RC_GOAL_CONDITION_MAX_CHARS = 4e3;
|
|
18131
|
+
var MAX_JSON_BYTES_PER_CODE_UNIT = 6;
|
|
18132
|
+
var RC_COMPACT_INSTRUCTIONS_MAX_CHARS = Math.floor(CONTROL_BODY_CAP_BYTES / MAX_JSON_BYTES_PER_CODE_UNIT);
|
|
18133
|
+
var RC_SESSION_COMMAND_MAX_WAIT_MS = 2147483647;
|
|
18134
|
+
function unverifiedVersionMessage(sessionId, version, source) {
|
|
18135
|
+
const verified = RC_SESSION_COMMAND_VERIFIED_VERSIONS.join(", ");
|
|
18136
|
+
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`;
|
|
18137
|
+
}
|
|
18138
|
+
function unsupportedMessage(sessionId) {
|
|
18139
|
+
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.`;
|
|
18140
|
+
}
|
|
18141
|
+
function createRcSessionCommands(deps) {
|
|
18142
|
+
const queues = /* @__PURE__ */ new Map();
|
|
18143
|
+
const serialised = async (sessionId, work) => {
|
|
18144
|
+
const before = queues.get(sessionId) ?? Promise.resolve();
|
|
18145
|
+
const run = before.then(work, work);
|
|
18146
|
+
const settled = run.then(() => void 0, () => void 0);
|
|
18147
|
+
queues.set(sessionId, settled);
|
|
18148
|
+
try {
|
|
18149
|
+
return await run;
|
|
18150
|
+
} finally {
|
|
18151
|
+
if (queues.get(sessionId) === settled) {
|
|
18152
|
+
queues.delete(sessionId);
|
|
18153
|
+
}
|
|
18154
|
+
}
|
|
18155
|
+
};
|
|
18156
|
+
const onRoute = async (sessionId, options, actions) => await serialised(sessionId, async () => {
|
|
18157
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
18158
|
+
if (signal.aborted) {
|
|
18159
|
+
return { ok: false, message: `the request for session ${sessionId} was aborted before it ran` };
|
|
18160
|
+
}
|
|
18161
|
+
const target = await deps.supervisedOf(sessionId);
|
|
18162
|
+
if (target !== void 0 && "refused" in target) {
|
|
18163
|
+
return { ok: false, message: target.refused };
|
|
18164
|
+
}
|
|
18165
|
+
if (target !== void 0) {
|
|
18166
|
+
if (target.version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(target.version)) {
|
|
18167
|
+
return { ok: false, message: unverifiedVersionMessage(sessionId, target.version, "its supervisor's control plugin has not loaded") };
|
|
18168
|
+
}
|
|
18169
|
+
const waitMs = options.waitMs ?? COMPACT_TIMEOUT_MS;
|
|
18170
|
+
const timeout = AbortSignal.timeout(waitMs);
|
|
18171
|
+
const bounded3 = AbortSignal.any([signal, timeout]);
|
|
18172
|
+
try {
|
|
18173
|
+
return await actions.supervised(target, bounded3, waitMs);
|
|
18174
|
+
} catch (error) {
|
|
18175
|
+
if (timeout.aborted) {
|
|
18176
|
+
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` };
|
|
18177
|
+
}
|
|
18178
|
+
return { ok: false, message: `session ${sessionId}'s control plugin did not complete the request: ${error instanceof Error ? error.message : String(error)}` };
|
|
18179
|
+
}
|
|
18180
|
+
}
|
|
18181
|
+
if (!deps.isObserved(sessionId)) {
|
|
18182
|
+
return { ok: false, message: `the front door has not observed Remote Control session ${sessionId}` };
|
|
18183
|
+
}
|
|
18184
|
+
if (deps.selfHost !== void 0) {
|
|
18185
|
+
const unavailable = deps.selfHost.unavailable();
|
|
18186
|
+
if (unavailable !== void 0) {
|
|
18187
|
+
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}` };
|
|
18188
|
+
}
|
|
18189
|
+
const version = deps.selfHost.versionOf(sessionId);
|
|
18190
|
+
if (version === void 0 || !RC_SESSION_COMMAND_VERIFIED_VERSIONS.includes(version)) {
|
|
18191
|
+
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") };
|
|
18192
|
+
}
|
|
18193
|
+
const waitMs = options.waitMs ?? deps.selfHost.defaultWaitMs;
|
|
18194
|
+
const timeout = AbortSignal.timeout(waitMs);
|
|
18195
|
+
const result = await actions.selfHosted(deps.selfHost, AbortSignal.any([signal, timeout]));
|
|
18196
|
+
if (!result.ok && timeout.aborted) {
|
|
18197
|
+
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` };
|
|
18198
|
+
}
|
|
18199
|
+
return result;
|
|
18200
|
+
}
|
|
18201
|
+
return { ok: false, message: unsupportedMessage(sessionId) };
|
|
18202
|
+
});
|
|
18203
|
+
const transcriptGoal = async (sessionId, target) => {
|
|
18204
|
+
const goal = target.transcriptPath === void 0 ? void 0 : await deps.goalOf(target.transcriptPath);
|
|
18205
|
+
if (goal === void 0) {
|
|
18206
|
+
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` };
|
|
18207
|
+
}
|
|
18208
|
+
return { ok: true, report: goal };
|
|
18209
|
+
};
|
|
18210
|
+
const settledGoal = async (sessionId, target, signal, holds) => {
|
|
18211
|
+
for (; ; ) {
|
|
18212
|
+
const read = await transcriptGoal(sessionId, target);
|
|
18213
|
+
if (!read.ok || holds(read.report) || signal.aborted) {
|
|
18214
|
+
return read;
|
|
18215
|
+
}
|
|
18216
|
+
await sleep(RESULT_POLL_MS);
|
|
18217
|
+
}
|
|
18218
|
+
};
|
|
18219
|
+
const waitOf = (options) => options.waitMs;
|
|
18220
|
+
return {
|
|
18221
|
+
/** 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. */
|
|
18222
|
+
goalGet: async (sessionId, options = {}) => await onRoute(sessionId, options, {
|
|
18223
|
+
supervised: async (target) => {
|
|
18224
|
+
const read = await transcriptGoal(sessionId, target);
|
|
18225
|
+
return await Promise.resolve(read.ok ? { ok: true, report: { route: "supervised", goal: read.report } } : read);
|
|
18226
|
+
},
|
|
18227
|
+
selfHosted: async (selfHost, signal) => {
|
|
18228
|
+
const read = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
|
|
18229
|
+
return read.ok ? { ok: true, report: { route: "self-hosted", goal: read.report.goal } } : read;
|
|
18230
|
+
}
|
|
18231
|
+
}),
|
|
18232
|
+
/**
|
|
18233
|
+
* 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.
|
|
18234
|
+
*/
|
|
18235
|
+
goalSet: async (sessionId, condition, options = {}) => {
|
|
18236
|
+
const trimmed = condition.trim();
|
|
18237
|
+
if (trimmed === "") {
|
|
18238
|
+
return { ok: false, message: "a goal set needs a non-empty condition" };
|
|
18239
|
+
}
|
|
18240
|
+
if (RC_GOAL_CLEAR_WORDS.includes(trimmed.toLowerCase())) {
|
|
18241
|
+
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` };
|
|
18242
|
+
}
|
|
18243
|
+
if (/[\r\n]/u.test(trimmed)) {
|
|
18244
|
+
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" };
|
|
18245
|
+
}
|
|
18246
|
+
if (trimmed.length > RC_GOAL_CONDITION_MAX_CHARS) {
|
|
18247
|
+
return { ok: false, message: `a goal condition is limited to ${String(RC_GOAL_CONDITION_MAX_CHARS)} characters, and this one has ${String(trimmed.length)}` };
|
|
18248
|
+
}
|
|
18249
|
+
return await onRoute(sessionId, options, {
|
|
18250
|
+
supervised: async (target, signal, waitMs) => {
|
|
18251
|
+
const before = await transcriptGoal(sessionId, target);
|
|
18252
|
+
if (!before.ok) {
|
|
18253
|
+
return before;
|
|
18254
|
+
}
|
|
18255
|
+
await target.runGoal(trimmed, signal, waitMs);
|
|
18256
|
+
const after = await settledGoal(sessionId, target, signal, (goal) => goal?.condition === trimmed);
|
|
18257
|
+
if (!after.ok) {
|
|
18258
|
+
return after;
|
|
18259
|
+
}
|
|
18260
|
+
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` };
|
|
18261
|
+
},
|
|
18262
|
+
selfHosted: async (selfHost, signal) => {
|
|
18263
|
+
const before = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-get" }, waitOf(options), signal);
|
|
18264
|
+
if (!before.ok) {
|
|
18265
|
+
return before;
|
|
18266
|
+
}
|
|
18267
|
+
const set = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-set", condition: trimmed }, waitOf(options), signal);
|
|
18268
|
+
return set.ok ? { ok: true, report: { route: "self-hosted", condition: set.report.condition, superseded: before.report.goal?.condition ?? null } } : set;
|
|
18269
|
+
}
|
|
18270
|
+
});
|
|
18271
|
+
},
|
|
18272
|
+
/** 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). */
|
|
18273
|
+
goalClear: async (sessionId, options = {}) => await onRoute(sessionId, options, {
|
|
18274
|
+
supervised: async (target, signal, waitMs) => {
|
|
18275
|
+
const before = await transcriptGoal(sessionId, target);
|
|
18276
|
+
if (!before.ok) {
|
|
18277
|
+
return before;
|
|
18278
|
+
}
|
|
18279
|
+
if (before.report === null) {
|
|
18280
|
+
return { ok: true, report: { route: "supervised", cleared: null } };
|
|
18281
|
+
}
|
|
18282
|
+
await target.runGoal("clear", signal, waitMs);
|
|
18283
|
+
const after = await settledGoal(sessionId, target, signal, (goal) => goal === null);
|
|
18284
|
+
if (!after.ok) {
|
|
18285
|
+
return after;
|
|
18286
|
+
}
|
|
18287
|
+
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}"` };
|
|
18288
|
+
},
|
|
18289
|
+
selfHosted: async (selfHost, signal) => {
|
|
18290
|
+
const cleared = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "goal-clear" }, waitOf(options), signal);
|
|
18291
|
+
return cleared.ok ? { ok: true, report: { route: "self-hosted", cleared: cleared.report.cleared } } : cleared;
|
|
18292
|
+
}
|
|
18293
|
+
}),
|
|
18294
|
+
/** 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. */
|
|
18295
|
+
compact: async (sessionId, options = {}) => {
|
|
18296
|
+
const instructions = options.instructions?.trim();
|
|
18297
|
+
const given = instructions === void 0 || instructions === "" ? void 0 : instructions;
|
|
18298
|
+
return await onRoute(sessionId, options, {
|
|
18299
|
+
supervised: async (target, signal, waitMs) => {
|
|
18300
|
+
const result = await target.compact(signal, given, waitMs);
|
|
18301
|
+
if (result.kind === "unchanged") {
|
|
18302
|
+
return { ok: false, message: `session ${sessionId} was not compacted: ${result.reason}` };
|
|
18303
|
+
}
|
|
18304
|
+
return { ok: true, report: { route: "supervised", trigger: "plugin", ...result.beforeTokens === void 0 ? {} : { preTokens: result.beforeTokens }, ...result.afterTokens === void 0 ? {} : { postTokens: result.afterTokens } } };
|
|
18305
|
+
},
|
|
18306
|
+
selfHosted: async (selfHost, signal) => {
|
|
18307
|
+
const compacted = await runSelfHostedSlashCommand(selfHost, sessionId, { kind: "compact", instructions: given }, waitOf(options), signal);
|
|
18308
|
+
return compacted.ok ? { ok: true, report: { route: "self-hosted", ...compacted.report } } : compacted;
|
|
18309
|
+
}
|
|
18310
|
+
});
|
|
18311
|
+
}
|
|
18312
|
+
};
|
|
18313
|
+
}
|
|
18314
|
+
|
|
18315
|
+
// src/frontdoor/rcSlashCommandSchemas.ts
|
|
18316
|
+
var WaitMsSchema = z23.int().positive().max(RC_SESSION_COMMAND_MAX_WAIT_MS).optional();
|
|
18317
|
+
var RcGoalSessionInputSchema = z23.strictObject({
|
|
18318
|
+
session: z23.string().min(1),
|
|
18319
|
+
waitMs: WaitMsSchema
|
|
18320
|
+
});
|
|
18321
|
+
var RcGoalSetInputSchema = z23.strictObject({
|
|
18322
|
+
session: z23.string().min(1),
|
|
18323
|
+
condition: z23.string().trim().min(1).max(RC_GOAL_CONDITION_MAX_CHARS).regex(/^[^\r\n]*$/u, "a goal condition is one line"),
|
|
18324
|
+
waitMs: WaitMsSchema
|
|
18325
|
+
});
|
|
18326
|
+
var RcCompactInputSchema = z23.strictObject({
|
|
18327
|
+
session: z23.string().min(1),
|
|
18328
|
+
waitMs: WaitMsSchema
|
|
18329
|
+
});
|
|
18330
|
+
var RcCompactWithInstructionsInputSchema = z23.strictObject({
|
|
18331
|
+
session: z23.string().min(1),
|
|
18332
|
+
instructions: z23.string().trim().min(1).max(RC_COMPACT_INSTRUCTIONS_MAX_CHARS),
|
|
18333
|
+
waitMs: WaitMsSchema
|
|
18334
|
+
});
|
|
18335
|
+
var commandAnswerShape = {
|
|
18336
|
+
session: z23.string(),
|
|
18337
|
+
route: z23.enum(["supervised", "self-hosted"])
|
|
18338
|
+
};
|
|
18339
|
+
var RcGoalGetOutputSchema = z23.strictObject({
|
|
18340
|
+
...commandAnswerShape,
|
|
18341
|
+
goal: z23.strictObject({ condition: z23.string(), iterations: z23.int().nonnegative(), lastCheck: z23.string().optional() }).nullable()
|
|
18342
|
+
});
|
|
18343
|
+
var RcGoalSetOutputSchema = z23.strictObject({
|
|
18344
|
+
...commandAnswerShape,
|
|
18345
|
+
condition: z23.string(),
|
|
18346
|
+
superseded: z23.string().nullable()
|
|
18347
|
+
});
|
|
18348
|
+
var RcGoalClearOutputSchema = z23.strictObject({
|
|
18349
|
+
...commandAnswerShape,
|
|
18350
|
+
cleared: z23.string().nullable()
|
|
18351
|
+
});
|
|
18352
|
+
var RcCompactOutputSchema = z23.strictObject({
|
|
18353
|
+
...commandAnswerShape,
|
|
18354
|
+
trigger: z23.string(),
|
|
18355
|
+
preTokens: z23.number().optional(),
|
|
18356
|
+
postTokens: z23.number().optional()
|
|
18357
|
+
});
|
|
18358
|
+
|
|
17917
18359
|
// src/frontdoor/rcApi.ts
|
|
17918
18360
|
var RC_ORPC_PATH_PREFIX = "/__agent-shim/orpc";
|
|
17919
18361
|
var RC_OPENAPI_DOC_PATH = "/openapi.json";
|
|
@@ -17935,6 +18377,7 @@ function doorApiAuth(expectedToken) {
|
|
|
17935
18377
|
});
|
|
17936
18378
|
}
|
|
17937
18379
|
var RC_API_TAG = "remote-control";
|
|
18380
|
+
var RC_DIRECTIVE_TAG = "remote-control-directives";
|
|
17938
18381
|
function createRcApiRouter(deps) {
|
|
17939
18382
|
const authed = doorApiAuth(deps.expectedToken);
|
|
17940
18383
|
const delivered = (sessionId, result) => {
|
|
@@ -17952,6 +18395,13 @@ function createRcApiRouter(deps) {
|
|
|
17952
18395
|
}
|
|
17953
18396
|
return { request: result.requestId, sequenceNums: result.sequenceNums };
|
|
17954
18397
|
};
|
|
18398
|
+
const commanded = (sessionId, result) => {
|
|
18399
|
+
if (!result.ok) {
|
|
18400
|
+
throw new ORPCError("BAD_GATEWAY", { message: result.message });
|
|
18401
|
+
}
|
|
18402
|
+
return { session: sessionId, ...result.report };
|
|
18403
|
+
};
|
|
18404
|
+
const optionsOf = (waitMs, signal) => ({ ...waitMs === void 0 ? {} : { waitMs }, ...signal === void 0 ? {} : { signal } });
|
|
17955
18405
|
return {
|
|
17956
18406
|
rc: {
|
|
17957
18407
|
list: authed.meta(openapi({ method: "GET", path: "/rest/rc/sessions", summary: "List the observed Remote Control sessions", tags: [RC_API_TAG] })).output(RcListOutputSchema).handler(() => ({ sessions: deps.list() })),
|
|
@@ -17988,6 +18438,11 @@ function createRcApiRouter(deps) {
|
|
|
17988
18438
|
mcpAuthenticate: authed.meta(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)) })),
|
|
17989
18439
|
mcpOAuthCallbackUrl: authed.meta(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)) })),
|
|
17990
18440
|
teleport: authed.meta(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)) })),
|
|
18441
|
+
goalGet: authed.meta(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)))),
|
|
18442
|
+
goalSet: authed.meta(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)))),
|
|
18443
|
+
goalClear: authed.meta(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)))),
|
|
18444
|
+
compact: authed.meta(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)))),
|
|
18445
|
+
compactWithInstructions: authed.meta(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 }))),
|
|
17991
18446
|
subscribe: authed.meta(openapi({ method: "GET", path: "/rest/rc/events", summary: "Stream a session's Remote Control events (SSE)", tags: [RC_API_TAG] })).input(RcSessionQuerySchema).output(eventIterator(RcStreamEventSchema)).handler(async function* ({ input, signal }) {
|
|
17992
18447
|
const queue = [];
|
|
17993
18448
|
let wake;
|
|
@@ -18068,8 +18523,27 @@ function doorApiNodeHandlerOf(router, expectedToken) {
|
|
|
18068
18523
|
function createRcApiNodeHandler(deps) {
|
|
18069
18524
|
return doorApiNodeHandlerOf(createRcApiRouter(deps), deps.expectedToken);
|
|
18070
18525
|
}
|
|
18526
|
+
var DEFAULT_HEADERS_TIMEOUT_MS = 3e5;
|
|
18527
|
+
var SESSION_COMMAND_PROCEDURES = ["rc/goalGet", "rc/goalSet", "rc/goalClear", "rc/compact", "rc/compactWithInstructions"];
|
|
18528
|
+
function headersTimeoutOf(url, body) {
|
|
18529
|
+
if (!SESSION_COMMAND_PROCEDURES.some((procedure) => url.endsWith(`${RC_ORPC_PATH_PREFIX}/${procedure}`))) {
|
|
18530
|
+
return DEFAULT_HEADERS_TIMEOUT_MS;
|
|
18531
|
+
}
|
|
18532
|
+
const parsed = body === void 0 ? void 0 : JSON.parse(body.toString("utf8"));
|
|
18533
|
+
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;
|
|
18534
|
+
return Math.min(waitMs + DEFAULT_HEADERS_TIMEOUT_MS, RC_SESSION_COMMAND_MAX_WAIT_MS);
|
|
18535
|
+
}
|
|
18071
18536
|
function frontDoorApiLink(port, ca, token) {
|
|
18072
|
-
const
|
|
18537
|
+
const dispatchers = /* @__PURE__ */ new Map();
|
|
18538
|
+
const dispatcherFor = (headersTimeout) => {
|
|
18539
|
+
const existing = dispatchers.get(headersTimeout);
|
|
18540
|
+
if (existing !== void 0) {
|
|
18541
|
+
return existing;
|
|
18542
|
+
}
|
|
18543
|
+
const created = new Agent3({ connect: { ca }, headersTimeout });
|
|
18544
|
+
dispatchers.set(headersTimeout, created);
|
|
18545
|
+
return created;
|
|
18546
|
+
};
|
|
18073
18547
|
return new RPCLink({
|
|
18074
18548
|
origin: `https://127.0.0.1:${String(port)}`,
|
|
18075
18549
|
url: RC_ORPC_PATH_PREFIX,
|
|
@@ -18082,7 +18556,7 @@ function frontDoorApiLink(port, ca, token) {
|
|
|
18082
18556
|
method: request4.method,
|
|
18083
18557
|
headers: [...request4.headers],
|
|
18084
18558
|
...body === void 0 ? {} : { body },
|
|
18085
|
-
dispatcher,
|
|
18559
|
+
dispatcher: dispatcherFor(headersTimeoutOf(request4.url, body)),
|
|
18086
18560
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
18087
18561
|
});
|
|
18088
18562
|
return new Response(answered.body, { status: answered.status, statusText: answered.statusText, headers: [...answered.headers] });
|
|
@@ -18098,48 +18572,48 @@ init_cliError();
|
|
|
18098
18572
|
init_package();
|
|
18099
18573
|
|
|
18100
18574
|
// src/codex/appServerSchemas.ts
|
|
18101
|
-
import { z as
|
|
18575
|
+
import { z as z24 } from "zod";
|
|
18102
18576
|
var CODEX_APP_SERVER_GENERATED_AGAINST = "0.160.0";
|
|
18103
|
-
var RateLimitWindowSchema =
|
|
18104
|
-
usedPercent:
|
|
18105
|
-
resetsAt:
|
|
18106
|
-
windowDurationMins:
|
|
18107
|
-
});
|
|
18108
|
-
var RateLimitSnapshotSchema =
|
|
18109
|
-
limitId:
|
|
18110
|
-
limitName:
|
|
18111
|
-
planType:
|
|
18577
|
+
var RateLimitWindowSchema = z24.object({
|
|
18578
|
+
usedPercent: z24.number(),
|
|
18579
|
+
resetsAt: z24.number().nullish(),
|
|
18580
|
+
windowDurationMins: z24.number().nullish()
|
|
18581
|
+
});
|
|
18582
|
+
var RateLimitSnapshotSchema = z24.object({
|
|
18583
|
+
limitId: z24.string().nullish(),
|
|
18584
|
+
limitName: z24.string().nullish(),
|
|
18585
|
+
planType: z24.string().nullish(),
|
|
18112
18586
|
primary: RateLimitWindowSchema.nullish(),
|
|
18113
18587
|
secondary: RateLimitWindowSchema.nullish(),
|
|
18114
|
-
rateLimitReachedType:
|
|
18115
|
-
spendControlReached:
|
|
18116
|
-
});
|
|
18117
|
-
var RateLimitResetCreditSchema =
|
|
18118
|
-
id:
|
|
18119
|
-
grantedAt:
|
|
18120
|
-
expiresAt:
|
|
18121
|
-
resetType:
|
|
18122
|
-
status:
|
|
18123
|
-
title:
|
|
18124
|
-
description:
|
|
18125
|
-
});
|
|
18126
|
-
var CodexAccountSchema =
|
|
18127
|
-
|
|
18128
|
-
|
|
18129
|
-
|
|
18588
|
+
rateLimitReachedType: z24.string().nullish(),
|
|
18589
|
+
spendControlReached: z24.boolean().nullish()
|
|
18590
|
+
});
|
|
18591
|
+
var RateLimitResetCreditSchema = z24.object({
|
|
18592
|
+
id: z24.string(),
|
|
18593
|
+
grantedAt: z24.number(),
|
|
18594
|
+
expiresAt: z24.number().nullish(),
|
|
18595
|
+
resetType: z24.string(),
|
|
18596
|
+
status: z24.string(),
|
|
18597
|
+
title: z24.string().nullish(),
|
|
18598
|
+
description: z24.string().nullish()
|
|
18599
|
+
});
|
|
18600
|
+
var CodexAccountSchema = z24.discriminatedUnion("type", [
|
|
18601
|
+
z24.object({ type: z24.literal("apiKey") }),
|
|
18602
|
+
z24.object({ type: z24.literal("chatgpt"), email: z24.string().nullable(), planType: z24.string() }),
|
|
18603
|
+
z24.object({ type: z24.literal("amazonBedrock"), usesCodexManagedCredentials: z24.boolean().default(false) })
|
|
18130
18604
|
]);
|
|
18131
|
-
var CodexAccountReadSchema =
|
|
18605
|
+
var CodexAccountReadSchema = z24.object({
|
|
18132
18606
|
account: CodexAccountSchema.nullable(),
|
|
18133
|
-
requiresOpenaiAuth:
|
|
18607
|
+
requiresOpenaiAuth: z24.boolean()
|
|
18134
18608
|
});
|
|
18135
|
-
var CodexRateLimitsReadSchema =
|
|
18609
|
+
var CodexRateLimitsReadSchema = z24.object({
|
|
18136
18610
|
rateLimits: RateLimitSnapshotSchema,
|
|
18137
|
-
rateLimitsByLimitId:
|
|
18138
|
-
rateLimitResetCredits:
|
|
18139
|
-
accountId:
|
|
18140
|
-
ordinaryUsageAllowed:
|
|
18611
|
+
rateLimitsByLimitId: z24.record(z24.string(), RateLimitSnapshotSchema).nullish(),
|
|
18612
|
+
rateLimitResetCredits: z24.object({ availableCount: z24.number(), credits: z24.array(RateLimitResetCreditSchema).nullish() }).nullish(),
|
|
18613
|
+
accountId: z24.string().nullish(),
|
|
18614
|
+
ordinaryUsageAllowed: z24.boolean().nullish()
|
|
18141
18615
|
});
|
|
18142
|
-
var CodexInitializeResultSchema =
|
|
18616
|
+
var CodexInitializeResultSchema = z24.object({ userAgent: z24.string() });
|
|
18143
18617
|
|
|
18144
18618
|
// src/codex/appServer.ts
|
|
18145
18619
|
var CodexAppServerUnavailableError = class extends CliError {
|
|
@@ -18479,7 +18953,7 @@ init_projects();
|
|
|
18479
18953
|
init_injected();
|
|
18480
18954
|
init_pipeline();
|
|
18481
18955
|
import path37 from "node:path";
|
|
18482
|
-
import { z as
|
|
18956
|
+
import { z as z27 } from "zod";
|
|
18483
18957
|
var HISTORY_PROJECTS_KEY_PREFIX = "history/projects/";
|
|
18484
18958
|
function projectFragmentOf(rawKey) {
|
|
18485
18959
|
return rawKey.startsWith(HISTORY_PROJECTS_KEY_PREFIX) ? rawKey.slice(HISTORY_PROJECTS_KEY_PREFIX.length) : void 0;
|
|
@@ -18548,9 +19022,9 @@ function lookupKeychainService(run, farmRoot) {
|
|
|
18548
19022
|
}
|
|
18549
19023
|
return { checked: true, found: true, serviceName, note: `Keychain service name for this identity: "${serviceName}".` };
|
|
18550
19024
|
}
|
|
18551
|
-
var SettingsSecretsShapeSchema =
|
|
18552
|
-
env:
|
|
18553
|
-
hooks:
|
|
19025
|
+
var SettingsSecretsShapeSchema = z27.looseObject({
|
|
19026
|
+
env: z27.record(z27.string(), z27.unknown()).optional(),
|
|
19027
|
+
hooks: z27.record(z27.string(), z27.array(z27.unknown())).optional()
|
|
18554
19028
|
});
|
|
18555
19029
|
function hookCommandCountOf(group) {
|
|
18556
19030
|
if (typeof group !== "object" || group === null) {
|
|
@@ -18855,7 +19329,7 @@ init_schema();
|
|
|
18855
19329
|
init_claudeVersion();
|
|
18856
19330
|
init_identity();
|
|
18857
19331
|
init_projects();
|
|
18858
|
-
import { z as
|
|
19332
|
+
import { z as z29 } from "zod";
|
|
18859
19333
|
|
|
18860
19334
|
// src/resolve/types.ts
|
|
18861
19335
|
var LAYER_KINDS = [
|
|
@@ -18916,123 +19390,123 @@ var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
|
|
|
18916
19390
|
|
|
18917
19391
|
// src/usage/pickReportSchema.ts
|
|
18918
19392
|
init_plan2();
|
|
18919
|
-
import { z as
|
|
18920
|
-
var PoolPickCandidateViewSchema =
|
|
18921
|
-
identity:
|
|
18922
|
-
/** In pick order: `scored` has usable quota data, `unknown` has none, `pay-per-use` bills by use, `ineligible` is refused right now. */
|
|
18923
|
-
class:
|
|
19393
|
+
import { z as z28 } from "zod";
|
|
19394
|
+
var PoolPickCandidateViewSchema = z28.strictObject({
|
|
19395
|
+
identity: z28.string(),
|
|
19396
|
+
/** 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. */
|
|
19397
|
+
class: z28.enum(["scored", "unknown", "pay-per-use", "ineligible"]),
|
|
18924
19398
|
/** Plan-size-weighted remaining quota per hour until its reset; present for `scored` only. */
|
|
18925
|
-
score:
|
|
19399
|
+
score: z28.number().optional(),
|
|
18926
19400
|
/** 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`. */
|
|
18927
|
-
scoreWindow:
|
|
19401
|
+
scoreWindow: z28.enum(["sevenDay", "fiveHour"]).optional(),
|
|
18928
19402
|
/** False when the five-hour window would run dry, at the observed pace, before it resets. */
|
|
18929
|
-
feasible:
|
|
19403
|
+
feasible: z28.boolean(),
|
|
18930
19404
|
/** When an `ineligible` member can be used again, as an ISO instant. */
|
|
18931
|
-
blockedUntil:
|
|
19405
|
+
blockedUntil: z28.iso.datetime().optional(),
|
|
18932
19406
|
plan: PlanClassSchema,
|
|
18933
19407
|
/** The facts behind the class and score, in the order they matter. */
|
|
18934
|
-
reasons:
|
|
19408
|
+
reasons: z28.array(z28.string())
|
|
18935
19409
|
});
|
|
18936
|
-
var PoolPickReportSchema =
|
|
18937
|
-
pool:
|
|
18938
|
-
directory:
|
|
19410
|
+
var PoolPickReportSchema = z28.strictObject({
|
|
19411
|
+
pool: z28.string(),
|
|
19412
|
+
directory: z28.string(),
|
|
18939
19413
|
/** The member a launch would run as, absent when every member is refused. */
|
|
18940
|
-
pick:
|
|
18941
|
-
candidates:
|
|
19414
|
+
pick: z28.string().optional(),
|
|
19415
|
+
candidates: z28.array(PoolPickCandidateViewSchema),
|
|
18942
19416
|
/** Identity members anywhere in the pool's graph that do not exist; a launch skips them. */
|
|
18943
|
-
missing:
|
|
19417
|
+
missing: z28.array(z28.string()),
|
|
18944
19418
|
/** When nothing can be picked, the soonest any member returns. */
|
|
18945
|
-
earliestReturn:
|
|
19419
|
+
earliestReturn: z28.strictObject({ identity: z28.string(), at: z28.iso.datetime() }).optional(),
|
|
18946
19420
|
/** The member a resumed conversation started on but moved off, and why, when the ranking could not keep it. */
|
|
18947
|
-
movedOff:
|
|
19421
|
+
movedOff: z28.strictObject({ identity: z28.string(), reason: z28.string() }).optional(),
|
|
18948
19422
|
/** Why the last-pick record could not be read, when that is the case. */
|
|
18949
|
-
stickyProblem:
|
|
19423
|
+
stickyProblem: z28.string().optional()
|
|
18950
19424
|
});
|
|
18951
19425
|
|
|
18952
19426
|
// src/checkReportSchema.ts
|
|
18953
19427
|
var CHECK_CREDENTIAL_APPLIES = ["provider", "identity", "stored-login"];
|
|
18954
|
-
var CheckLayerViewSchema =
|
|
18955
|
-
id:
|
|
18956
|
-
kind:
|
|
18957
|
-
source:
|
|
18958
|
-
});
|
|
18959
|
-
var CheckEntryViewSchema =
|
|
18960
|
-
path:
|
|
18961
|
-
shared:
|
|
18962
|
-
via:
|
|
19428
|
+
var CheckLayerViewSchema = z29.strictObject({
|
|
19429
|
+
id: z29.int(),
|
|
19430
|
+
kind: z29.enum(LAYER_KINDS),
|
|
19431
|
+
source: z29.string()
|
|
19432
|
+
});
|
|
19433
|
+
var CheckEntryViewSchema = z29.strictObject({
|
|
19434
|
+
path: z29.string(),
|
|
19435
|
+
shared: z29.boolean(),
|
|
19436
|
+
via: z29.enum(DECISION_VIAS),
|
|
18963
19437
|
/** The entry's real category, or null when nothing classifies it. */
|
|
18964
|
-
category:
|
|
18965
|
-
rule:
|
|
19438
|
+
category: z29.enum(CATEGORY_NAMES).nullable(),
|
|
19439
|
+
rule: z29.strictObject({ key: z29.string(), layer: z29.int() }).optional(),
|
|
18966
19440
|
/** Rules that matched but whose `when` condition failed, each with the conditions that failed. */
|
|
18967
|
-
eliminated:
|
|
18968
|
-
});
|
|
18969
|
-
var CheckDiagnosticSchema =
|
|
18970
|
-
code:
|
|
18971
|
-
severity:
|
|
18972
|
-
message:
|
|
18973
|
-
subject:
|
|
18974
|
-
layer:
|
|
18975
|
-
});
|
|
18976
|
-
var CheckAmbientCredentialSchema =
|
|
18977
|
-
var CheckKeychainSchema =
|
|
18978
|
-
checked:
|
|
18979
|
-
found:
|
|
18980
|
-
serviceName:
|
|
18981
|
-
note:
|
|
18982
|
-
});
|
|
18983
|
-
var CheckSettingsExposureSchema =
|
|
18984
|
-
file:
|
|
18985
|
-
envKeyNames:
|
|
18986
|
-
hookEventNames:
|
|
18987
|
-
hookCommandCount:
|
|
18988
|
-
});
|
|
18989
|
-
var CredentialSourceSummarySchema =
|
|
18990
|
-
|
|
18991
|
-
|
|
18992
|
-
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
|
|
19441
|
+
eliminated: z29.readonly(z29.array(z29.strictObject({ key: z29.string(), failed: z29.readonly(z29.array(z29.string())) }))).optional()
|
|
19442
|
+
});
|
|
19443
|
+
var CheckDiagnosticSchema = z29.strictObject({
|
|
19444
|
+
code: z29.enum(DIAGNOSTIC_CODES),
|
|
19445
|
+
severity: z29.enum(DIAGNOSTIC_SEVERITIES),
|
|
19446
|
+
message: z29.string(),
|
|
19447
|
+
subject: z29.string().optional(),
|
|
19448
|
+
layer: z29.int().optional()
|
|
19449
|
+
});
|
|
19450
|
+
var CheckAmbientCredentialSchema = z29.union([z29.strictObject({ ok: z29.literal(true) }), z29.strictObject({ ok: z29.literal(false), variable: z29.string(), message: z29.string() })]);
|
|
19451
|
+
var CheckKeychainSchema = z29.strictObject({
|
|
19452
|
+
checked: z29.literal(true),
|
|
19453
|
+
found: z29.boolean(),
|
|
19454
|
+
serviceName: z29.string().optional(),
|
|
19455
|
+
note: z29.string()
|
|
19456
|
+
});
|
|
19457
|
+
var CheckSettingsExposureSchema = z29.strictObject({
|
|
19458
|
+
file: z29.string(),
|
|
19459
|
+
envKeyNames: z29.readonly(z29.array(z29.string())),
|
|
19460
|
+
hookEventNames: z29.readonly(z29.array(z29.string())),
|
|
19461
|
+
hookCommandCount: z29.int().nonnegative()
|
|
19462
|
+
});
|
|
19463
|
+
var CredentialSourceSummarySchema = z29.union([
|
|
19464
|
+
z29.strictObject({ kind: z29.literal("env"), variable: z29.string() }),
|
|
19465
|
+
z29.strictObject({ kind: z29.literal("file"), path: z29.string() }),
|
|
19466
|
+
z29.strictObject({ kind: z29.literal("command"), program: z29.string() }),
|
|
19467
|
+
z29.strictObject({ kind: z29.literal("op"), reference: z29.string() }),
|
|
19468
|
+
z29.strictObject({ kind: z29.literal("keychain"), service: z29.string(), account: z29.string().optional() }),
|
|
19469
|
+
z29.strictObject({ kind: z29.literal("literal") })
|
|
18996
19470
|
]);
|
|
18997
|
-
var CredentialSummarySchema =
|
|
18998
|
-
target:
|
|
18999
|
-
sources:
|
|
19471
|
+
var CredentialSummarySchema = z29.strictObject({
|
|
19472
|
+
target: z29.enum(CREDENTIAL_TARGETS),
|
|
19473
|
+
sources: z29.readonly(z29.array(CredentialSourceSummarySchema)),
|
|
19000
19474
|
cache: CredentialCacheSchema.optional()
|
|
19001
19475
|
});
|
|
19002
|
-
var CachedCredentialStateSchema =
|
|
19003
|
-
|
|
19004
|
-
|
|
19005
|
-
|
|
19476
|
+
var CachedCredentialStateSchema = z29.union([
|
|
19477
|
+
z29.strictObject({ store: z29.enum(CREDENTIAL_CACHE_STORES), status: z29.literal("empty") }),
|
|
19478
|
+
z29.strictObject({ store: z29.enum(CREDENTIAL_CACHE_STORES), status: z29.literal("unreadable"), reason: z29.string() }),
|
|
19479
|
+
z29.strictObject({ store: z29.enum(CREDENTIAL_CACHE_STORES), status: z29.enum(["fresh", "expired"]), ageMs: z29.number(), expiresInMs: z29.number().optional() })
|
|
19006
19480
|
]);
|
|
19007
|
-
var CheckCredentialProviderSchema =
|
|
19008
|
-
|
|
19009
|
-
|
|
19481
|
+
var CheckCredentialProviderSchema = z29.union([
|
|
19482
|
+
z29.strictObject({ name: z29.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
|
|
19483
|
+
z29.strictObject({ name: z29.string(), problem: z29.string() })
|
|
19010
19484
|
]);
|
|
19011
|
-
var CheckCredentialSchema =
|
|
19012
|
-
applies:
|
|
19485
|
+
var CheckCredentialSchema = z29.strictObject({
|
|
19486
|
+
applies: z29.enum(CHECK_CREDENTIAL_APPLIES),
|
|
19013
19487
|
provider: CheckCredentialProviderSchema.optional(),
|
|
19014
19488
|
identity: CredentialSummarySchema.optional(),
|
|
19015
19489
|
identityCached: CachedCredentialStateSchema.optional()
|
|
19016
19490
|
});
|
|
19017
|
-
var CheckClaudeVersionSchema =
|
|
19018
|
-
pinned:
|
|
19019
|
-
highestInstalled:
|
|
19020
|
-
installed:
|
|
19491
|
+
var CheckClaudeVersionSchema = z29.strictObject({
|
|
19492
|
+
pinned: z29.strictObject({ version: z29.string(), source: z29.enum(CLAUDE_VERSION_SOURCES), installed: z29.boolean() }).optional(),
|
|
19493
|
+
highestInstalled: z29.string().optional(),
|
|
19494
|
+
installed: z29.readonly(z29.array(z29.string()))
|
|
19021
19495
|
});
|
|
19022
|
-
var CheckReportJsonSchema =
|
|
19023
|
-
identity:
|
|
19496
|
+
var CheckReportJsonSchema = z29.strictObject({
|
|
19497
|
+
identity: z29.strictObject({ name: z29.string().nullable(), source: z29.enum(IDENTITY_DECISION_SOURCES) }),
|
|
19024
19498
|
/** The pool ranking, when the launch named a pool instead of an identity. */
|
|
19025
19499
|
pool: PoolPickReportSchema.optional(),
|
|
19026
|
-
configProfile:
|
|
19027
|
-
layers:
|
|
19028
|
-
entries:
|
|
19029
|
-
projectEncodingAmbiguities:
|
|
19030
|
-
|
|
19500
|
+
configProfile: z29.strictObject({ name: z29.string().nullable(), source: z29.enum(CONFIG_PROFILE_DECISION_SOURCES) }),
|
|
19501
|
+
layers: z29.readonly(z29.array(CheckLayerViewSchema)),
|
|
19502
|
+
entries: z29.readonly(z29.array(CheckEntryViewSchema)),
|
|
19503
|
+
projectEncodingAmbiguities: z29.readonly(
|
|
19504
|
+
z29.array(z29.strictObject({ fragment: z29.string(), encoded: z29.string(), reason: z29.enum(ENCODING_AMBIGUITY_REASONS), detail: z29.string() }))
|
|
19031
19505
|
),
|
|
19032
|
-
diagnostics:
|
|
19506
|
+
diagnostics: z29.readonly(z29.array(CheckDiagnosticSchema)),
|
|
19033
19507
|
ambientCredential: CheckAmbientCredentialSchema,
|
|
19034
19508
|
keychain: CheckKeychainSchema.optional(),
|
|
19035
|
-
settingsExposure:
|
|
19509
|
+
settingsExposure: z29.readonly(z29.array(CheckSettingsExposureSchema)),
|
|
19036
19510
|
credential: CheckCredentialSchema,
|
|
19037
19511
|
claudeVersion: CheckClaudeVersionSchema.optional()
|
|
19038
19512
|
});
|
|
@@ -19043,28 +19517,28 @@ init_preflight();
|
|
|
19043
19517
|
init_resets();
|
|
19044
19518
|
|
|
19045
19519
|
// src/usage/resetsSchema.ts
|
|
19046
|
-
import { z as
|
|
19047
|
-
var ResetRowSchema =
|
|
19048
|
-
identity:
|
|
19049
|
-
provider:
|
|
19520
|
+
import { z as z30 } from "zod";
|
|
19521
|
+
var ResetRowSchema = z30.strictObject({
|
|
19522
|
+
identity: z30.string(),
|
|
19523
|
+
provider: z30.string(),
|
|
19050
19524
|
/** What the window is: `5h`, `7d` or `extra usage` for an Anthropic account, or the provider's own measure and period (`tokens 5h`). */
|
|
19051
|
-
window:
|
|
19525
|
+
window: z30.string(),
|
|
19052
19526
|
/** When the state the window comes from was observed, as an ISO instant. */
|
|
19053
|
-
observedAt:
|
|
19527
|
+
observedAt: z30.iso.datetime(),
|
|
19054
19528
|
/** When the window resets, as an ISO instant; absent when the upstream reported none. */
|
|
19055
|
-
resetsAt:
|
|
19529
|
+
resetsAt: z30.iso.datetime().optional(),
|
|
19056
19530
|
/** True when the reset time has passed, so the recorded observation describes a window that no longer exists and its utilisation reads as 0. */
|
|
19057
|
-
reset:
|
|
19531
|
+
reset: z30.boolean(),
|
|
19058
19532
|
/** The fraction used, as `effectiveWindow` reads it at the report's own clock. */
|
|
19059
|
-
utilization:
|
|
19533
|
+
utilization: z30.number().optional(),
|
|
19060
19534
|
/** The window's own status, for a window that has not reset yet. */
|
|
19061
|
-
status:
|
|
19535
|
+
status: z30.string().optional()
|
|
19062
19536
|
});
|
|
19063
|
-
var ResetScheduleSchema =
|
|
19537
|
+
var ResetScheduleSchema = z30.strictObject({ resets: z30.readonly(z30.array(ResetRowSchema)) });
|
|
19064
19538
|
|
|
19065
19539
|
// src/frontdoor/controlSchemas.ts
|
|
19066
19540
|
import path43 from "node:path";
|
|
19067
|
-
import { z as
|
|
19541
|
+
import { z as z37 } from "zod";
|
|
19068
19542
|
|
|
19069
19543
|
// src/codex/doctor.ts
|
|
19070
19544
|
function codexIdentityFindings(entry, identity) {
|
|
@@ -20291,92 +20765,92 @@ function collectDoctorReport(params) {
|
|
|
20291
20765
|
// src/frontdoor/controlSchemas.ts
|
|
20292
20766
|
init_schema2();
|
|
20293
20767
|
init_state();
|
|
20294
|
-
var UsageListOutputSchema =
|
|
20295
|
-
var UsageWindowsInputSchema =
|
|
20296
|
-
identity:
|
|
20297
|
-
provider:
|
|
20768
|
+
var UsageListOutputSchema = z37.strictObject({ snapshots: z37.readonly(z37.array(UsageSnapshotSchema)) });
|
|
20769
|
+
var UsageWindowsInputSchema = z37.strictObject({
|
|
20770
|
+
identity: z37.string().min(1),
|
|
20771
|
+
provider: z37.string().min(1).optional()
|
|
20298
20772
|
});
|
|
20299
|
-
var EffectiveWindowSchema =
|
|
20773
|
+
var EffectiveWindowSchema = z37.strictObject({
|
|
20300
20774
|
/** True when the window's reset time has passed, so the recorded observation describes a window that no longer exists. */
|
|
20301
|
-
reset:
|
|
20775
|
+
reset: z37.boolean(),
|
|
20302
20776
|
/** The fraction used: 0 for a reset window, otherwise what was last observed, absent when none was reported. */
|
|
20303
|
-
utilization:
|
|
20777
|
+
utilization: z37.number().optional(),
|
|
20304
20778
|
/** The reset instant, for a window that has not reset yet and reported one. */
|
|
20305
|
-
resetsAtMs:
|
|
20779
|
+
resetsAtMs: z37.number().optional(),
|
|
20306
20780
|
/** The window's own status, for a window that has not reset yet. */
|
|
20307
|
-
status:
|
|
20781
|
+
status: z37.string().optional()
|
|
20308
20782
|
});
|
|
20309
|
-
var UsageWindowsOutputSchema =
|
|
20310
|
-
identity:
|
|
20311
|
-
provider:
|
|
20783
|
+
var UsageWindowsOutputSchema = z37.strictObject({
|
|
20784
|
+
identity: z37.string(),
|
|
20785
|
+
provider: z37.string(),
|
|
20312
20786
|
/** When the rate-limit state the windows come from was observed. */
|
|
20313
|
-
observedAt:
|
|
20787
|
+
observedAt: z37.iso.datetime().optional(),
|
|
20314
20788
|
fiveHour: EffectiveWindowSchema.optional(),
|
|
20315
20789
|
sevenDay: EffectiveWindowSchema.optional()
|
|
20316
20790
|
});
|
|
20317
|
-
var UsageLiveOutputSchema =
|
|
20791
|
+
var UsageLiveOutputSchema = z37.strictObject({
|
|
20318
20792
|
/** 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. */
|
|
20319
20793
|
latest: RcLiveRateLimitSchema.optional(),
|
|
20320
20794
|
/** One observation per session whose stream has filed a rate_limit_event this door generation. */
|
|
20321
|
-
sessions:
|
|
20795
|
+
sessions: z37.readonly(z37.array(RcLiveRateLimitSchema))
|
|
20322
20796
|
});
|
|
20323
|
-
var FrontDoorSessionStatusSchema =
|
|
20324
|
-
pid:
|
|
20325
|
-
startedAt:
|
|
20326
|
-
alive:
|
|
20797
|
+
var FrontDoorSessionStatusSchema = z37.strictObject({
|
|
20798
|
+
pid: z37.int().positive(),
|
|
20799
|
+
startedAt: z37.number(),
|
|
20800
|
+
alive: z37.boolean()
|
|
20327
20801
|
});
|
|
20328
|
-
var HeadroomSocketTargetSchema =
|
|
20329
|
-
var FrontDoorStatusOutputSchema =
|
|
20802
|
+
var HeadroomSocketTargetSchema = z37.union([z37.strictObject({ socketPath: z37.string() }), z37.strictObject({ refused: z37.string() })]);
|
|
20803
|
+
var FrontDoorStatusOutputSchema = z37.strictObject({
|
|
20330
20804
|
state: FrontDoorStateSchema,
|
|
20331
|
-
supervisorAlive:
|
|
20805
|
+
supervisorAlive: z37.boolean(),
|
|
20332
20806
|
/** The pids of earlier doors that released their addresses and are finishing the connections they carried: running, but not serving anything new. */
|
|
20333
|
-
draining:
|
|
20334
|
-
sessions:
|
|
20807
|
+
draining: z37.readonly(z37.array(z37.number().int().positive())),
|
|
20808
|
+
sessions: z37.readonly(z37.array(FrontDoorSessionStatusSchema)),
|
|
20335
20809
|
headroomSocket: HeadroomSocketTargetSchema.optional(),
|
|
20336
|
-
logPath:
|
|
20337
|
-
logExists:
|
|
20810
|
+
logPath: z37.string(),
|
|
20811
|
+
logExists: z37.boolean()
|
|
20338
20812
|
});
|
|
20339
|
-
var FrontDoorSessionsOutputSchema =
|
|
20340
|
-
var CheckRunInputSchema =
|
|
20341
|
-
path:
|
|
20342
|
-
identity:
|
|
20813
|
+
var FrontDoorSessionsOutputSchema = z37.strictObject({ sessions: z37.readonly(z37.array(FrontDoorSessionStatusSchema)) });
|
|
20814
|
+
var CheckRunInputSchema = z37.strictObject({
|
|
20815
|
+
path: z37.string().min(1),
|
|
20816
|
+
identity: z37.string().min(1).optional()
|
|
20343
20817
|
}).refine((input) => path43.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
20344
|
-
var PoolPickInputSchema =
|
|
20345
|
-
pool:
|
|
20346
|
-
path:
|
|
20818
|
+
var PoolPickInputSchema = z37.strictObject({
|
|
20819
|
+
pool: z37.string().min(1),
|
|
20820
|
+
path: z37.string().min(1)
|
|
20347
20821
|
}).refine((input) => path43.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
20348
|
-
var DoctorFindingSchema =
|
|
20349
|
-
section:
|
|
20350
|
-
subject:
|
|
20351
|
-
severity:
|
|
20352
|
-
message:
|
|
20822
|
+
var DoctorFindingSchema = z37.strictObject({
|
|
20823
|
+
section: z37.enum(DOCTOR_SECTIONS),
|
|
20824
|
+
subject: z37.string().optional(),
|
|
20825
|
+
severity: z37.enum(DOCTOR_SEVERITIES),
|
|
20826
|
+
message: z37.string()
|
|
20353
20827
|
});
|
|
20354
|
-
var DoctorRunOutputSchema =
|
|
20828
|
+
var DoctorRunOutputSchema = z37.strictObject({
|
|
20355
20829
|
/** False exactly when any finding is a `fail`; a `warn` never fails the report on its own. */
|
|
20356
|
-
ok:
|
|
20357
|
-
findings:
|
|
20358
|
-
});
|
|
20359
|
-
var FrontDoorRestartOutputSchema =
|
|
20360
|
-
action:
|
|
20361
|
-
previousPid:
|
|
20362
|
-
});
|
|
20363
|
-
var UpdateCheckOutputSchema =
|
|
20364
|
-
current:
|
|
20365
|
-
latest:
|
|
20366
|
-
action:
|
|
20367
|
-
});
|
|
20368
|
-
var CodexSignInSchema =
|
|
20369
|
-
|
|
20370
|
-
|
|
20371
|
-
|
|
20830
|
+
ok: z37.boolean(),
|
|
20831
|
+
findings: z37.readonly(z37.array(DoctorFindingSchema))
|
|
20832
|
+
});
|
|
20833
|
+
var FrontDoorRestartOutputSchema = z37.strictObject({
|
|
20834
|
+
action: z37.literal("restarting"),
|
|
20835
|
+
previousPid: z37.int().positive()
|
|
20836
|
+
});
|
|
20837
|
+
var UpdateCheckOutputSchema = z37.strictObject({
|
|
20838
|
+
current: z37.string(),
|
|
20839
|
+
latest: z37.string(),
|
|
20840
|
+
action: z37.enum(["current", "available", "updated"])
|
|
20841
|
+
});
|
|
20842
|
+
var CodexSignInSchema = z37.discriminatedUnion("state", [
|
|
20843
|
+
z37.strictObject({ state: z37.literal("none") }),
|
|
20844
|
+
z37.strictObject({ state: z37.literal("signed-in"), email: z37.string().optional(), planScope: z37.boolean(), accessTokenExpiresAt: z37.number() }),
|
|
20845
|
+
z37.strictObject({ state: z37.literal("unreadable"), message: z37.string() })
|
|
20372
20846
|
]);
|
|
20373
|
-
var CodexStatusOutputSchema =
|
|
20847
|
+
var CodexStatusOutputSchema = z37.strictObject({
|
|
20374
20848
|
signIn: CodexSignInSchema,
|
|
20375
|
-
codexProviders:
|
|
20849
|
+
codexProviders: z37.readonly(z37.array(z37.string()))
|
|
20376
20850
|
});
|
|
20377
|
-
var CodexLogoutOutputSchema =
|
|
20378
|
-
hadGrant:
|
|
20379
|
-
revoked:
|
|
20851
|
+
var CodexLogoutOutputSchema = z37.strictObject({
|
|
20852
|
+
hadGrant: z37.boolean(),
|
|
20853
|
+
revoked: z37.boolean()
|
|
20380
20854
|
});
|
|
20381
20855
|
|
|
20382
20856
|
// src/frontdoor/codexApi.ts
|
|
@@ -20444,67 +20918,67 @@ init_schema();
|
|
|
20444
20918
|
init_names();
|
|
20445
20919
|
init_keychainLogin();
|
|
20446
20920
|
init_statusline();
|
|
20447
|
-
import { z as
|
|
20448
|
-
var RemovalConfirmationSchema =
|
|
20449
|
-
var CredentialWriteSchema = (targets) =>
|
|
20450
|
-
sources:
|
|
20451
|
-
target:
|
|
20452
|
-
cache:
|
|
20453
|
-
});
|
|
20454
|
-
var CredentialSummarySchema2 =
|
|
20455
|
-
target:
|
|
20456
|
-
sources:
|
|
20457
|
-
|
|
20458
|
-
|
|
20459
|
-
|
|
20460
|
-
|
|
20461
|
-
|
|
20462
|
-
|
|
20463
|
-
|
|
20921
|
+
import { z as z38 } from "zod";
|
|
20922
|
+
var RemovalConfirmationSchema = z38.boolean();
|
|
20923
|
+
var CredentialWriteSchema = (targets) => z38.strictObject({
|
|
20924
|
+
sources: z38.array(RemoteCredentialSourceSchema).min(1).optional(),
|
|
20925
|
+
target: z38.enum(targets).optional(),
|
|
20926
|
+
cache: z38.union([z38.literal(false), CredentialCacheSchema]).optional()
|
|
20927
|
+
});
|
|
20928
|
+
var CredentialSummarySchema2 = z38.strictObject({
|
|
20929
|
+
target: z38.enum(CREDENTIAL_TARGETS),
|
|
20930
|
+
sources: z38.readonly(z38.array(
|
|
20931
|
+
z38.discriminatedUnion("kind", [
|
|
20932
|
+
z38.strictObject({ kind: z38.literal("env"), variable: z38.string() }),
|
|
20933
|
+
z38.strictObject({ kind: z38.literal("file"), path: z38.string() }),
|
|
20934
|
+
z38.strictObject({ kind: z38.literal("command"), program: z38.string() }),
|
|
20935
|
+
z38.strictObject({ kind: z38.literal("op"), reference: z38.string() }),
|
|
20936
|
+
z38.strictObject({ kind: z38.literal("keychain"), service: z38.string(), account: z38.string().optional() }),
|
|
20937
|
+
z38.strictObject({ kind: z38.literal("literal") })
|
|
20464
20938
|
])
|
|
20465
20939
|
)),
|
|
20466
20940
|
cache: CredentialCacheSchema.optional()
|
|
20467
20941
|
});
|
|
20468
|
-
var mutationOutput = (kind, action) =>
|
|
20469
|
-
var storedMutationOutput = (kind, action, value) =>
|
|
20470
|
-
var IdentityValueSchema =
|
|
20471
|
-
name:
|
|
20472
|
-
label:
|
|
20473
|
-
defaultConfigProfile:
|
|
20474
|
-
provider:
|
|
20475
|
-
allowAmbientCredential:
|
|
20942
|
+
var mutationOutput = (kind, action) => z38.strictObject({ action: z38.literal(action), kind: z38.literal(kind), name: z38.string() });
|
|
20943
|
+
var storedMutationOutput = (kind, action, value) => z38.strictObject({ action: z38.literal(action), kind: z38.literal(kind), name: z38.string(), value });
|
|
20944
|
+
var IdentityValueSchema = z38.strictObject({
|
|
20945
|
+
name: z38.string(),
|
|
20946
|
+
label: z38.string().optional(),
|
|
20947
|
+
defaultConfigProfile: z38.string().optional(),
|
|
20948
|
+
provider: z38.string().optional(),
|
|
20949
|
+
allowAmbientCredential: z38.boolean(),
|
|
20476
20950
|
credential: CredentialSummarySchema2.optional(),
|
|
20477
|
-
anchors:
|
|
20951
|
+
anchors: z38.array(AnchorSchema).optional()
|
|
20478
20952
|
});
|
|
20479
20953
|
var ProfileValueSchema = ConfigProfileSchema.omit({ $schema: true });
|
|
20480
|
-
var ProviderValueSchema =
|
|
20481
|
-
name:
|
|
20482
|
-
kind:
|
|
20483
|
-
displayName:
|
|
20484
|
-
baseUrl:
|
|
20954
|
+
var ProviderValueSchema = z38.strictObject({
|
|
20955
|
+
name: z38.string(),
|
|
20956
|
+
kind: z38.enum(PROVIDER_KINDS),
|
|
20957
|
+
displayName: z38.string(),
|
|
20958
|
+
baseUrl: z38.string().optional(),
|
|
20485
20959
|
codex: CodexProviderConfigSchema.optional(),
|
|
20486
20960
|
credential: CredentialSummarySchema2.optional(),
|
|
20487
|
-
env:
|
|
20961
|
+
env: z38.record(z38.string(), z38.string()).optional()
|
|
20488
20962
|
});
|
|
20489
|
-
var ConfigNameInputSchema =
|
|
20490
|
-
var ConfigIdentityAddInputSchema =
|
|
20963
|
+
var ConfigNameInputSchema = z38.strictObject({ name: z38.string().min(1) });
|
|
20964
|
+
var ConfigIdentityAddInputSchema = z38.strictObject({ name: z38.string().min(1), keepKeychainLogin: z38.boolean().optional().describe(KEEP_KEYCHAIN_LOGIN_DESCRIPTION) });
|
|
20491
20965
|
var ConfigIdentityAddOutputSchema = storedMutationOutput("identity", "created", IdentityValueSchema);
|
|
20492
|
-
var ConfigIdentitySetInputSchema =
|
|
20493
|
-
name:
|
|
20966
|
+
var ConfigIdentitySetInputSchema = z38.strictObject({
|
|
20967
|
+
name: z38.string().min(1),
|
|
20494
20968
|
/** The identity's display label; `false` clears it. */
|
|
20495
|
-
label:
|
|
20496
|
-
defaultConfigProfile:
|
|
20969
|
+
label: z38.union([IdentityLabelSchema, z38.literal(false)]).optional(),
|
|
20970
|
+
defaultConfigProfile: z38.union([z38.string().min(1), z38.literal(false)]).optional(),
|
|
20497
20971
|
/** The provider the identity exists for; `false` clears it. */
|
|
20498
|
-
provider:
|
|
20499
|
-
allowAmbientCredential:
|
|
20500
|
-
credential:
|
|
20972
|
+
provider: z38.union([z38.string().min(1), z38.literal(false)]).optional(),
|
|
20973
|
+
allowAmbientCredential: z38.boolean().optional(),
|
|
20974
|
+
credential: z38.union([z38.literal(false), CredentialWriteSchema(CREDENTIAL_TARGETS)]).optional(),
|
|
20501
20975
|
/** `false` removes the anchors; a list replaces them. */
|
|
20502
|
-
anchors:
|
|
20976
|
+
anchors: z38.union([z38.literal(false), z38.array(AnchorSchema).min(1)]).optional()
|
|
20503
20977
|
});
|
|
20504
20978
|
var ConfigIdentitySetOutputSchema = storedMutationOutput("identity", "updated", IdentityValueSchema);
|
|
20505
|
-
var ConfigIdentityRemoveInputSchema =
|
|
20979
|
+
var ConfigIdentityRemoveInputSchema = z38.strictObject({ name: z38.string().min(1), confirm: RemovalConfirmationSchema });
|
|
20506
20980
|
var ConfigIdentityRemoveOutputSchema = mutationOutput("identity", "removed");
|
|
20507
|
-
var ConfigStatuslineSetSchema =
|
|
20981
|
+
var ConfigStatuslineSetSchema = z38.record(z38.string(), z38.unknown()).superRefine((settings, context) => {
|
|
20508
20982
|
for (const key of Object.keys(settings)) {
|
|
20509
20983
|
if (key === STATUSLINE_EXTRA_GROUP || key.startsWith(`${STATUSLINE_EXTRA_GROUP}.`)) {
|
|
20510
20984
|
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` });
|
|
@@ -20512,93 +20986,93 @@ var ConfigStatuslineSetSchema = z37.record(z37.string(), z37.unknown()).superRef
|
|
|
20512
20986
|
}
|
|
20513
20987
|
});
|
|
20514
20988
|
var ConfigIdentityUseOutputSchema = mutationOutput("identity", "selected");
|
|
20515
|
-
var ConfigProfileAddInputSchema =
|
|
20516
|
-
name:
|
|
20517
|
-
extends:
|
|
20518
|
-
description:
|
|
20989
|
+
var ConfigProfileAddInputSchema = z38.strictObject({
|
|
20990
|
+
name: z38.string().min(1),
|
|
20991
|
+
extends: z38.array(z38.string().min(1)).optional(),
|
|
20992
|
+
description: z38.string().optional()
|
|
20519
20993
|
});
|
|
20520
20994
|
var ConfigProfileAddOutputSchema = storedMutationOutput("profile", "created", ProfileValueSchema);
|
|
20521
|
-
var ConfigProfileSetInputSchema =
|
|
20522
|
-
name:
|
|
20523
|
-
category:
|
|
20524
|
-
entry:
|
|
20525
|
-
extends:
|
|
20526
|
-
description:
|
|
20527
|
-
launch:
|
|
20528
|
-
skipPermissions:
|
|
20529
|
-
remoteControl:
|
|
20530
|
-
headroom:
|
|
20531
|
-
trackUsage:
|
|
20532
|
-
provider:
|
|
20533
|
-
claudeVersion:
|
|
20534
|
-
delay:
|
|
20535
|
-
pause:
|
|
20536
|
-
explain:
|
|
20537
|
-
proxyBypass:
|
|
20538
|
-
statusline:
|
|
20995
|
+
var ConfigProfileSetInputSchema = z38.strictObject({
|
|
20996
|
+
name: z38.string().min(1),
|
|
20997
|
+
category: z38.record(z38.string(), z38.boolean()).optional(),
|
|
20998
|
+
entry: z38.record(z38.string(), z38.boolean()).optional(),
|
|
20999
|
+
extends: z38.union([z38.array(z38.string().min(1)), z38.literal(false)]).optional(),
|
|
21000
|
+
description: z38.union([z38.string(), z38.literal(false)]).optional(),
|
|
21001
|
+
launch: z38.strictObject({
|
|
21002
|
+
skipPermissions: z38.boolean().optional(),
|
|
21003
|
+
remoteControl: z38.boolean().optional(),
|
|
21004
|
+
headroom: z38.boolean().optional(),
|
|
21005
|
+
trackUsage: z38.boolean().optional(),
|
|
21006
|
+
provider: z38.union([z38.string().min(1), z38.literal(false)]).optional(),
|
|
21007
|
+
claudeVersion: z38.union([z38.string().min(1), z38.literal(false)]).optional(),
|
|
21008
|
+
delay: z38.union([z38.string().regex(DURATION_RE), z38.literal(false)]).optional(),
|
|
21009
|
+
pause: z38.boolean().optional(),
|
|
21010
|
+
explain: z38.boolean().optional(),
|
|
21011
|
+
proxyBypass: z38.union([z38.array(z38.string().min(1)), z38.literal(false)]).optional(),
|
|
21012
|
+
statusline: z38.strictObject({
|
|
20539
21013
|
set: ConfigStatuslineSetSchema.optional(),
|
|
20540
|
-
unset:
|
|
21014
|
+
unset: z38.array(z38.string()).optional()
|
|
20541
21015
|
}).optional()
|
|
20542
21016
|
}).optional()
|
|
20543
21017
|
});
|
|
20544
21018
|
var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
|
|
20545
|
-
var ConfigProfileRemoveInputSchema =
|
|
21019
|
+
var ConfigProfileRemoveInputSchema = z38.strictObject({ name: z38.string().min(1), confirm: RemovalConfirmationSchema });
|
|
20546
21020
|
var ConfigProfileRemoveOutputSchema = mutationOutput("profile", "removed");
|
|
20547
21021
|
var ConfigProfileUseOutputSchema = mutationOutput("profile", "selected");
|
|
20548
|
-
var PoolMembersInputSchema =
|
|
20549
|
-
var ConfigPoolAddInputSchema =
|
|
20550
|
-
name:
|
|
21022
|
+
var PoolMembersInputSchema = z38.array(z38.string().min(1)).min(1);
|
|
21023
|
+
var ConfigPoolAddInputSchema = z38.strictObject({
|
|
21024
|
+
name: z38.string().min(1),
|
|
20551
21025
|
identities: PoolMembersInputSchema,
|
|
20552
|
-
preference:
|
|
20553
|
-
resumeOnLimit:
|
|
20554
|
-
compactBeforeLimit:
|
|
21026
|
+
preference: z38.enum(POOL_PREFERENCES).optional(),
|
|
21027
|
+
resumeOnLimit: z38.boolean().optional(),
|
|
21028
|
+
compactBeforeLimit: z38.boolean().optional(),
|
|
20555
21029
|
compactAtUtilisation: CompactAtUtilisationSchema.optional()
|
|
20556
21030
|
});
|
|
20557
21031
|
var ConfigPoolAddOutputSchema = storedMutationOutput("pool", "created", PoolSchema);
|
|
20558
|
-
var ConfigPoolSetInputSchema =
|
|
20559
|
-
name:
|
|
21032
|
+
var ConfigPoolSetInputSchema = z38.strictObject({
|
|
21033
|
+
name: z38.string().min(1),
|
|
20560
21034
|
identities: PoolMembersInputSchema.optional(),
|
|
20561
|
-
preference:
|
|
20562
|
-
resumeOnLimit:
|
|
20563
|
-
compactBeforeLimit:
|
|
20564
|
-
compactAtUtilisation:
|
|
21035
|
+
preference: z38.union([z38.enum(POOL_PREFERENCES), z38.literal(false)]).optional(),
|
|
21036
|
+
resumeOnLimit: z38.boolean().optional(),
|
|
21037
|
+
compactBeforeLimit: z38.boolean().optional(),
|
|
21038
|
+
compactAtUtilisation: z38.union([CompactAtUtilisationSchema, z38.literal(false)]).optional()
|
|
20565
21039
|
});
|
|
20566
21040
|
var ConfigPoolSetOutputSchema = storedMutationOutput("pool", "updated", PoolSchema);
|
|
20567
|
-
var ConfigPoolRemoveInputSchema =
|
|
21041
|
+
var ConfigPoolRemoveInputSchema = z38.strictObject({ name: z38.string().min(1), confirm: RemovalConfirmationSchema });
|
|
20568
21042
|
var ConfigPoolRemoveOutputSchema = mutationOutput("pool", "removed");
|
|
20569
21043
|
var ConfigPoolUseOutputSchema = mutationOutput("pool", "selected");
|
|
20570
|
-
var ConfigProviderAddInputSchema =
|
|
20571
|
-
name:
|
|
20572
|
-
kind:
|
|
20573
|
-
displayName:
|
|
20574
|
-
baseUrl:
|
|
21044
|
+
var ConfigProviderAddInputSchema = z38.strictObject({
|
|
21045
|
+
name: z38.string().min(1),
|
|
21046
|
+
kind: z38.enum(PROVIDER_KINDS).optional(),
|
|
21047
|
+
displayName: z38.string().min(1),
|
|
21048
|
+
baseUrl: z38.string().min(1).optional(),
|
|
20575
21049
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).required({ sources: true }),
|
|
20576
21050
|
codex: CodexProviderConfigSchema.optional()
|
|
20577
21051
|
});
|
|
20578
21052
|
var ConfigProviderAddOutputSchema = storedMutationOutput("provider", "created", ProviderValueSchema);
|
|
20579
|
-
var ConfigProviderSetInputSchema =
|
|
20580
|
-
name:
|
|
20581
|
-
displayName:
|
|
20582
|
-
baseUrl:
|
|
21053
|
+
var ConfigProviderSetInputSchema = z38.strictObject({
|
|
21054
|
+
name: z38.string().min(1),
|
|
21055
|
+
displayName: z38.string().min(1).optional(),
|
|
21056
|
+
baseUrl: z38.string().min(1).optional(),
|
|
20583
21057
|
credential: CredentialWriteSchema(PROVIDER_CREDENTIAL_TARGETS).optional(),
|
|
20584
21058
|
codex: CodexProviderConfigSchema.optional()
|
|
20585
21059
|
});
|
|
20586
21060
|
var ConfigProviderSetOutputSchema = storedMutationOutput("provider", "updated", ProviderValueSchema);
|
|
20587
|
-
var ConfigProviderRemoveInputSchema =
|
|
21061
|
+
var ConfigProviderRemoveInputSchema = z38.strictObject({ name: z38.string().min(1), confirm: RemovalConfirmationSchema });
|
|
20588
21062
|
var ConfigProviderRemoveOutputSchema = mutationOutput("provider", "removed");
|
|
20589
|
-
var ConfigRuleAddInputSchema =
|
|
20590
|
-
path:
|
|
20591
|
-
configProfile:
|
|
20592
|
-
identity:
|
|
21063
|
+
var ConfigRuleAddInputSchema = z38.strictObject({
|
|
21064
|
+
path: z38.string().min(1),
|
|
21065
|
+
configProfile: z38.string().min(1).optional(),
|
|
21066
|
+
identity: z38.string().min(1).optional()
|
|
20593
21067
|
});
|
|
20594
21068
|
var ConfigRuleAddOutputSchema = storedMutationOutput("rule", "created", DirectoryRuleSchema);
|
|
20595
|
-
var ConfigRuleSetInputSchema =
|
|
20596
|
-
path:
|
|
20597
|
-
configProfile:
|
|
20598
|
-
identity:
|
|
21069
|
+
var ConfigRuleSetInputSchema = z38.strictObject({
|
|
21070
|
+
path: z38.string().min(1),
|
|
21071
|
+
configProfile: z38.union([z38.string().min(1), z38.literal(false)]).optional(),
|
|
21072
|
+
identity: z38.union([z38.string().min(1), z38.literal(false)]).optional()
|
|
20599
21073
|
});
|
|
20600
21074
|
var ConfigRuleSetOutputSchema = storedMutationOutput("rule", "updated", DirectoryRuleSchema);
|
|
20601
|
-
var ConfigRuleRemoveInputSchema =
|
|
21075
|
+
var ConfigRuleRemoveInputSchema = z38.strictObject({ path: z38.string().min(1), confirm: RemovalConfirmationSchema });
|
|
20602
21076
|
var ConfigRuleRemoveOutputSchema = mutationOutput("rule", "removed");
|
|
20603
21077
|
|
|
20604
21078
|
// src/frontdoor/configApi.ts
|
|
@@ -20951,50 +21425,50 @@ import { eventIterator as eventIterator2, withEventMeta as withEventMeta2 } from
|
|
|
20951
21425
|
|
|
20952
21426
|
// src/frontdoor/eventSchemas.ts
|
|
20953
21427
|
init_schema2();
|
|
20954
|
-
import { z as
|
|
21428
|
+
import { z as z39 } from "zod";
|
|
20955
21429
|
var DOOR_EVENT_SOURCE_RC = "rc";
|
|
20956
21430
|
var LAUNCH_EVENT_SOURCE = "launch";
|
|
20957
21431
|
var USAGE_EVENT_SOURCE = "usage";
|
|
20958
21432
|
var DOOR_HEALTH_EVENT_SOURCE = "door";
|
|
20959
21433
|
var QUOTA_EXPIRING_EVENT_SOURCE = "quota-expiring";
|
|
20960
|
-
var DoorEventSchema =
|
|
20961
|
-
source:
|
|
21434
|
+
var DoorEventSchema = z39.strictObject({
|
|
21435
|
+
source: z39.string().min(1),
|
|
20962
21436
|
/** A positive integer because the backbone's counters start at one and only ever increase. */
|
|
20963
|
-
sequence:
|
|
20964
|
-
payload:
|
|
20965
|
-
});
|
|
20966
|
-
var DoorEventSourceQuerySchema =
|
|
20967
|
-
sources:
|
|
20968
|
-
});
|
|
20969
|
-
var LaunchLifecycleEventSchema =
|
|
20970
|
-
kind:
|
|
20971
|
-
pid:
|
|
20972
|
-
startedAt:
|
|
20973
|
-
observedAt:
|
|
20974
|
-
});
|
|
20975
|
-
var DoorHealthEventSchema =
|
|
20976
|
-
|
|
20977
|
-
|
|
20978
|
-
|
|
20979
|
-
|
|
20980
|
-
|
|
20981
|
-
|
|
21437
|
+
sequence: z39.number().int().positive(),
|
|
21438
|
+
payload: z39.unknown()
|
|
21439
|
+
});
|
|
21440
|
+
var DoorEventSourceQuerySchema = z39.strictObject({
|
|
21441
|
+
sources: z39.array(z39.string().min(1)).min(1).optional()
|
|
21442
|
+
});
|
|
21443
|
+
var LaunchLifecycleEventSchema = z39.strictObject({
|
|
21444
|
+
kind: z39.enum(["registered", "pruned", "ended"]),
|
|
21445
|
+
pid: z39.number().int().positive(),
|
|
21446
|
+
startedAt: z39.number(),
|
|
21447
|
+
observedAt: z39.number()
|
|
21448
|
+
});
|
|
21449
|
+
var DoorHealthEventSchema = z39.discriminatedUnion("kind", [
|
|
21450
|
+
z39.strictObject({ kind: z39.literal("generation"), pid: z39.number().int().positive(), providerPort: z39.number().int().positive(), connectPort: z39.number().int().positive(), directPort: z39.number().int().positive(), observedAt: z39.number() }),
|
|
21451
|
+
z39.strictObject({ kind: z39.literal("listenerFailed"), pid: z39.number().int().positive(), listener: z39.enum(["provider", "connect", "direct"]), message: z39.string(), observedAt: z39.number() }),
|
|
21452
|
+
z39.strictObject({ kind: z39.literal("binaryTurnover"), pid: z39.number().int().positive(), observedAt: z39.number() }),
|
|
21453
|
+
z39.strictObject({ kind: z39.literal("idleShutdown"), pid: z39.number().int().positive(), observedAt: z39.number() }),
|
|
21454
|
+
z39.strictObject({ kind: z39.literal("superseded"), pid: z39.number().int().positive(), ownerPid: z39.number().int().positive(), observedAt: z39.number() }),
|
|
21455
|
+
z39.strictObject({ kind: z39.literal("drained"), pid: z39.number().int().positive(), observedAt: z39.number() })
|
|
20982
21456
|
]);
|
|
20983
|
-
var QuotaExpiringEventSchema =
|
|
21457
|
+
var QuotaExpiringEventSchema = z39.strictObject({
|
|
20984
21458
|
/** The id of the identity whose window it is: what its usage is filed under, which a rename keeps. */
|
|
20985
|
-
id:
|
|
21459
|
+
id: z39.string().min(1),
|
|
20986
21460
|
/** The identity's name when the event was published, absent for an identity no longer stored under the id. */
|
|
20987
|
-
name:
|
|
20988
|
-
provider:
|
|
20989
|
-
window:
|
|
21461
|
+
name: z39.string().min(1).optional(),
|
|
21462
|
+
provider: z39.string().min(1),
|
|
21463
|
+
window: z39.enum(["fiveHour", "sevenDay"]),
|
|
20990
21464
|
/** 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. */
|
|
20991
|
-
utilization:
|
|
20992
|
-
resetsAt:
|
|
20993
|
-
observedAt:
|
|
21465
|
+
utilization: z39.number().min(0).max(1),
|
|
21466
|
+
resetsAt: z39.iso.datetime(),
|
|
21467
|
+
observedAt: z39.number()
|
|
20994
21468
|
});
|
|
20995
21469
|
var UsageChangeEventSchema = UsageSnapshotSchema.extend({
|
|
20996
|
-
id:
|
|
20997
|
-
name:
|
|
21470
|
+
id: z39.string().min(1),
|
|
21471
|
+
name: z39.string().min(1).optional()
|
|
20998
21472
|
});
|
|
20999
21473
|
|
|
21000
21474
|
// src/frontdoor/eventsApi.ts
|
|
@@ -21039,14 +21513,14 @@ function createEventsApiRouter(deps) {
|
|
|
21039
21513
|
init_update();
|
|
21040
21514
|
import { ORPCError as ORPCError4 } from "@orpc/client";
|
|
21041
21515
|
import { openapi as openapi5 } from "@orpc/openapi";
|
|
21042
|
-
import { z as
|
|
21516
|
+
import { z as z40 } from "zod";
|
|
21043
21517
|
var FRONTDOOR_API_TAG = "frontdoor";
|
|
21044
21518
|
var UPDATE_API_TAG = "update";
|
|
21045
21519
|
function createLifecycleApiRouter(deps) {
|
|
21046
21520
|
const authed = doorApiAuth(deps.expectedToken);
|
|
21047
21521
|
return {
|
|
21048
21522
|
frontdoor: {
|
|
21049
|
-
refreshCatalogues: authed.meta(openapi5({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(
|
|
21523
|
+
refreshCatalogues: authed.meta(openapi5({ method: "POST", path: "/rest/frontdoor/catalogues/refresh", summary: "Request a catalogue refresh tick", tags: [FRONTDOOR_API_TAG] })).output(z40.strictObject({ requested: z40.literal(true) })).handler(() => {
|
|
21050
21524
|
deps.refreshCatalogues();
|
|
21051
21525
|
return { requested: true };
|
|
21052
21526
|
}),
|
|
@@ -21083,62 +21557,62 @@ import { openapi as openapi6 } from "@orpc/openapi";
|
|
|
21083
21557
|
|
|
21084
21558
|
// src/frontdoor/launchSchemas.ts
|
|
21085
21559
|
import path44 from "node:path";
|
|
21086
|
-
import { z as
|
|
21560
|
+
import { z as z41 } from "zod";
|
|
21087
21561
|
init_statusline();
|
|
21088
21562
|
init_claudeVersion();
|
|
21089
21563
|
init_identity();
|
|
21090
|
-
var LaunchResolveInputSchema =
|
|
21091
|
-
path:
|
|
21564
|
+
var LaunchResolveInputSchema = z41.strictObject({
|
|
21565
|
+
path: z41.string().min(1),
|
|
21092
21566
|
/** `@name`, launch flags, then the arguments for `claude`; empty for a bare launch. */
|
|
21093
|
-
argv:
|
|
21567
|
+
argv: z41.readonly(z41.array(z41.string())).optional(),
|
|
21094
21568
|
/** 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. */
|
|
21095
|
-
env:
|
|
21569
|
+
env: z41.record(z41.string(), z41.string()).optional()
|
|
21096
21570
|
}).refine((input) => path44.isAbsolute(input.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
|
|
21097
|
-
var LaunchPoolDecisionSchema =
|
|
21098
|
-
name:
|
|
21099
|
-
reasons:
|
|
21100
|
-
movedOff:
|
|
21101
|
-
});
|
|
21102
|
-
var LaunchDecisionSchema =
|
|
21103
|
-
identity:
|
|
21104
|
-
identityId:
|
|
21105
|
-
identitySource:
|
|
21571
|
+
var LaunchPoolDecisionSchema = z41.strictObject({
|
|
21572
|
+
name: z41.string(),
|
|
21573
|
+
reasons: z41.readonly(z41.array(z41.string())),
|
|
21574
|
+
movedOff: z41.strictObject({ identity: z41.string(), reason: z41.string() }).optional()
|
|
21575
|
+
});
|
|
21576
|
+
var LaunchDecisionSchema = z41.strictObject({
|
|
21577
|
+
identity: z41.string().optional(),
|
|
21578
|
+
identityId: z41.string().optional(),
|
|
21579
|
+
identitySource: z41.enum(IDENTITY_DECISION_SOURCES),
|
|
21106
21580
|
pool: LaunchPoolDecisionSchema.optional(),
|
|
21107
21581
|
/** 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. */
|
|
21108
|
-
configDirEscapeHatch:
|
|
21109
|
-
configDir:
|
|
21110
|
-
configProfile:
|
|
21111
|
-
configProfileSource:
|
|
21112
|
-
provider:
|
|
21113
|
-
});
|
|
21114
|
-
var LaunchFlagsSchema =
|
|
21115
|
-
skipPermissions:
|
|
21116
|
-
remoteControl:
|
|
21117
|
-
headroom:
|
|
21118
|
-
trackUsage:
|
|
21119
|
-
pause:
|
|
21120
|
-
explain:
|
|
21582
|
+
configDirEscapeHatch: z41.boolean(),
|
|
21583
|
+
configDir: z41.string().optional(),
|
|
21584
|
+
configProfile: z41.string().optional(),
|
|
21585
|
+
configProfileSource: z41.enum(CONFIG_PROFILE_DECISION_SOURCES),
|
|
21586
|
+
provider: z41.string().optional()
|
|
21587
|
+
});
|
|
21588
|
+
var LaunchFlagsSchema = z41.strictObject({
|
|
21589
|
+
skipPermissions: z41.boolean(),
|
|
21590
|
+
remoteControl: z41.boolean(),
|
|
21591
|
+
headroom: z41.boolean(),
|
|
21592
|
+
trackUsage: z41.boolean(),
|
|
21593
|
+
pause: z41.boolean(),
|
|
21594
|
+
explain: z41.boolean(),
|
|
21121
21595
|
/** How long the launch waits after its own output before it starts claude, in milliseconds. */
|
|
21122
|
-
delayMs:
|
|
21596
|
+
delayMs: z41.number(),
|
|
21123
21597
|
/** The hosts the launch keeps off the front door by adding them to the child's `NO_PROXY`. */
|
|
21124
|
-
proxyBypass:
|
|
21598
|
+
proxyBypass: z41.array(z41.string()).readonly(),
|
|
21125
21599
|
/** How the session's built-in statusline looks, when the launch configures any of it. */
|
|
21126
21600
|
statusline: StatuslineSchema.optional()
|
|
21127
21601
|
});
|
|
21128
|
-
var LaunchResolveOutputSchema =
|
|
21602
|
+
var LaunchResolveOutputSchema = z41.strictObject({
|
|
21129
21603
|
decision: LaunchDecisionSchema,
|
|
21130
21604
|
flags: LaunchFlagsSchema,
|
|
21131
|
-
claudeVersion:
|
|
21605
|
+
claudeVersion: z41.strictObject({ version: z41.string(), source: z41.enum(CLAUDE_VERSION_SOURCES) }).optional(),
|
|
21132
21606
|
/** The real `claude` binary the launch would spawn, on the door's host. */
|
|
21133
|
-
bin:
|
|
21607
|
+
bin: z41.string(),
|
|
21134
21608
|
/** The arguments the launch would pass it: the tool's own flags, then `CLAUDE_EXTRA_FLAGS`, then the caller's own. */
|
|
21135
|
-
args:
|
|
21609
|
+
args: z41.readonly(z41.array(z41.string())),
|
|
21136
21610
|
/** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
|
|
21137
|
-
credential:
|
|
21138
|
-
routing:
|
|
21611
|
+
credential: z41.strictObject({ subject: z41.enum(["provider", "identity"]), name: z41.string(), summary: CredentialSummarySchema }).optional(),
|
|
21612
|
+
routing: z41.strictObject({ frontDoor: z41.boolean(), headroom: z41.boolean() }),
|
|
21139
21613
|
/** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
|
|
21140
|
-
environment:
|
|
21141
|
-
warnings:
|
|
21614
|
+
environment: z41.readonly(z41.array(z41.string())),
|
|
21615
|
+
warnings: z41.readonly(z41.array(z41.string()))
|
|
21142
21616
|
});
|
|
21143
21617
|
|
|
21144
21618
|
// src/frontdoor/launchApi.ts
|
|
@@ -21174,22 +21648,22 @@ function createLaunchApiRouter(deps) {
|
|
|
21174
21648
|
// src/frontdoor/agentTreesApi.ts
|
|
21175
21649
|
import { ORPCError as ORPCError6 } from "@orpc/client";
|
|
21176
21650
|
import { openapi as openapi7 } from "@orpc/openapi";
|
|
21177
|
-
import { z as
|
|
21651
|
+
import { z as z42 } from "zod";
|
|
21178
21652
|
init_cliError();
|
|
21179
|
-
var AgentTreesListInputSchema =
|
|
21653
|
+
var AgentTreesListInputSchema = z42.strictObject({
|
|
21180
21654
|
/** Only this identity's sessions. */
|
|
21181
|
-
identity:
|
|
21655
|
+
identity: z42.string().optional(),
|
|
21182
21656
|
/** Include sessions that spawned no agent and ran no workflow. */
|
|
21183
|
-
all:
|
|
21657
|
+
all: z42.boolean().optional()
|
|
21184
21658
|
});
|
|
21185
|
-
var AgentTreesListOutputSchema =
|
|
21186
|
-
var AgentTreesShowInputSchema =
|
|
21659
|
+
var AgentTreesListOutputSchema = z42.array(SessionSummarySchema);
|
|
21660
|
+
var AgentTreesShowInputSchema = z42.strictObject({
|
|
21187
21661
|
/** A session id, or an unambiguous prefix of one. */
|
|
21188
|
-
session:
|
|
21662
|
+
session: z42.string().min(1),
|
|
21189
21663
|
/** Look only in this identity. */
|
|
21190
|
-
identity:
|
|
21664
|
+
identity: z42.string().optional()
|
|
21191
21665
|
});
|
|
21192
|
-
var AgentTreesShowOutputSchema =
|
|
21666
|
+
var AgentTreesShowOutputSchema = z42.strictObject({ identities: z42.array(z42.string()), ...MergedAgentTreeSchema.shape });
|
|
21193
21667
|
function asBadRequest(error) {
|
|
21194
21668
|
if (error instanceof CliError) {
|
|
21195
21669
|
throw new ORPCError6("BAD_REQUEST", { message: error.message });
|
|
@@ -21242,7 +21716,7 @@ import { openapi as openapi8 } from "@orpc/openapi";
|
|
|
21242
21716
|
import { eventIterator as eventIterator3, withEventMeta as withEventMeta3 } from "@orpc/server";
|
|
21243
21717
|
|
|
21244
21718
|
// src/frontdoor/rcEventLog.ts
|
|
21245
|
-
import { z as
|
|
21719
|
+
import { z as z43 } from "zod";
|
|
21246
21720
|
|
|
21247
21721
|
// src/frontdoor/eventHub.ts
|
|
21248
21722
|
var DOOR_EVENT_BUFFER_EVENTS = 100;
|
|
@@ -21365,46 +21839,46 @@ var NUMBER_FIELDS = ["at", "sequence"].length;
|
|
|
21365
21839
|
var BYTES_PER_CODE_UNIT = Uint16Array.BYTES_PER_ELEMENT;
|
|
21366
21840
|
var RC_SESSION_END_REASONS = ["expired", "archived", "conflict"];
|
|
21367
21841
|
var RC_PENDING_RETIRE_REASONS = ["answered", "expired", "session-ended"];
|
|
21368
|
-
var transitionBase = { session:
|
|
21369
|
-
var cursorFields = { cursor:
|
|
21370
|
-
var sessionAppearedShape = { kind:
|
|
21371
|
-
var sessionEndedShape = { kind:
|
|
21372
|
-
var workerStateShape = { kind:
|
|
21373
|
-
var pendingBornShape = { kind:
|
|
21374
|
-
var pendingRetiredShape = { kind:
|
|
21375
|
-
var RcSessionTransitionSchema =
|
|
21376
|
-
|
|
21377
|
-
|
|
21378
|
-
|
|
21379
|
-
|
|
21380
|
-
|
|
21842
|
+
var transitionBase = { session: z43.string(), at: z43.number() };
|
|
21843
|
+
var cursorFields = { cursor: z43.string(), sequence: z43.int().positive() };
|
|
21844
|
+
var sessionAppearedShape = { kind: z43.literal("session-appeared"), ...transitionBase };
|
|
21845
|
+
var sessionEndedShape = { kind: z43.literal("session-ended"), reason: z43.enum(RC_SESSION_END_REASONS), ...transitionBase };
|
|
21846
|
+
var workerStateShape = { kind: z43.literal("worker-state"), state: z43.string(), previous: z43.string().optional(), ...transitionBase };
|
|
21847
|
+
var pendingBornShape = { kind: z43.literal("pending-born"), requestId: z43.string(), type: z43.string(), summary: z43.string(), ...transitionBase };
|
|
21848
|
+
var pendingRetiredShape = { kind: z43.literal("pending-retired"), requestId: z43.string(), reason: z43.enum(RC_PENDING_RETIRE_REASONS), ...transitionBase };
|
|
21849
|
+
var RcSessionTransitionSchema = z43.discriminatedUnion("kind", [
|
|
21850
|
+
z43.strictObject(sessionAppearedShape),
|
|
21851
|
+
z43.strictObject(sessionEndedShape),
|
|
21852
|
+
z43.strictObject(workerStateShape),
|
|
21853
|
+
z43.strictObject(pendingBornShape),
|
|
21854
|
+
z43.strictObject(pendingRetiredShape)
|
|
21381
21855
|
]);
|
|
21382
21856
|
var KIND_MAX_CHARS = Math.max(...RcSessionTransitionSchema.options.map((option) => option.shape.kind.value.length));
|
|
21383
21857
|
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;
|
|
21384
21858
|
var RC_SESSION_EVENT_LOG_CAPACITY = Math.floor(CONTROL_BODY_CAP_BYTES / RC_SESSION_EVENT_MAX_BYTES);
|
|
21385
|
-
var RcSessionEventSchema =
|
|
21386
|
-
|
|
21387
|
-
|
|
21388
|
-
|
|
21389
|
-
|
|
21390
|
-
|
|
21859
|
+
var RcSessionEventSchema = z43.discriminatedUnion("kind", [
|
|
21860
|
+
z43.strictObject({ ...cursorFields, ...sessionAppearedShape }),
|
|
21861
|
+
z43.strictObject({ ...cursorFields, ...sessionEndedShape }),
|
|
21862
|
+
z43.strictObject({ ...cursorFields, ...workerStateShape }),
|
|
21863
|
+
z43.strictObject({ ...cursorFields, ...pendingBornShape }),
|
|
21864
|
+
z43.strictObject({ ...cursorFields, ...pendingRetiredShape })
|
|
21391
21865
|
]);
|
|
21392
|
-
var RcSessionEventsReadInputSchema =
|
|
21866
|
+
var RcSessionEventsReadInputSchema = z43.strictObject({
|
|
21393
21867
|
/** The cursor of the last event the caller saw; every retained event when omitted. */
|
|
21394
|
-
since:
|
|
21868
|
+
since: z43.string().min(1).optional(),
|
|
21395
21869
|
/** One `cse_` session id; every session when omitted. */
|
|
21396
|
-
session:
|
|
21870
|
+
session: z43.string().min(1).optional(),
|
|
21397
21871
|
/** The most events one answer carries; every event after `since` when omitted. */
|
|
21398
|
-
limit:
|
|
21872
|
+
limit: z43.int().positive().optional()
|
|
21399
21873
|
});
|
|
21400
21874
|
var RcSessionEventsPageInputSchema = RcSessionEventsReadInputSchema.extend({
|
|
21401
21875
|
/** 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. */
|
|
21402
|
-
limit:
|
|
21876
|
+
limit: z43.int().positive().max(DOOR_EVENT_BUFFER_EVENTS).default(DOOR_EVENT_BUFFER_EVENTS)
|
|
21403
21877
|
});
|
|
21404
21878
|
var RcSessionEventsStreamInputSchema = RcSessionEventsReadInputSchema.omit({ limit: true });
|
|
21405
|
-
var RcSessionEventsReadOutputSchema =
|
|
21406
|
-
|
|
21407
|
-
|
|
21879
|
+
var RcSessionEventsReadOutputSchema = z43.discriminatedUnion("status", [
|
|
21880
|
+
z43.strictObject({ status: z43.literal("ok"), events: z43.readonly(z43.array(RcSessionEventSchema)), cursor: z43.string(), more: z43.boolean(), head: z43.string() }),
|
|
21881
|
+
z43.strictObject({ status: z43.literal("expired"), message: z43.string(), head: z43.string() })
|
|
21408
21882
|
]);
|
|
21409
21883
|
var CURSOR_SEPARATOR = ".";
|
|
21410
21884
|
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";
|
|
@@ -21903,15 +22377,15 @@ function createQuotaExpiringPublisher(hub, deps) {
|
|
|
21903
22377
|
|
|
21904
22378
|
// src/frontdoor/rcLiveUsage.ts
|
|
21905
22379
|
var RC_RATE_LIMIT_EVENT_TYPE = "rate_limit_event";
|
|
21906
|
-
function
|
|
22380
|
+
function isRecord9(value) {
|
|
21907
22381
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21908
22382
|
}
|
|
21909
22383
|
function rcRateLimitInfoOf(event) {
|
|
21910
22384
|
const payload = event.envelope.payload;
|
|
21911
|
-
if (!
|
|
22385
|
+
if (!isRecord9(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
|
|
21912
22386
|
return void 0;
|
|
21913
22387
|
}
|
|
21914
|
-
if (!
|
|
22388
|
+
if (!isRecord9(payload.rate_limit_info)) {
|
|
21915
22389
|
return void 0;
|
|
21916
22390
|
}
|
|
21917
22391
|
const parsed = RcRateLimitInfoSchema.safeParse(payload.rate_limit_info);
|
|
@@ -21999,7 +22473,7 @@ function createSseParser() {
|
|
|
21999
22473
|
}
|
|
22000
22474
|
};
|
|
22001
22475
|
}
|
|
22002
|
-
function
|
|
22476
|
+
function isRecord10(value) {
|
|
22003
22477
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22004
22478
|
}
|
|
22005
22479
|
function sequenceNumOf(value) {
|
|
@@ -22021,7 +22495,7 @@ function parseRcStreamEnvelope(parsed) {
|
|
|
22021
22495
|
} catch {
|
|
22022
22496
|
return void 0;
|
|
22023
22497
|
}
|
|
22024
|
-
if (!
|
|
22498
|
+
if (!isRecord10(data)) {
|
|
22025
22499
|
return void 0;
|
|
22026
22500
|
}
|
|
22027
22501
|
const eventType = data.event_type;
|
|
@@ -22268,7 +22742,13 @@ init_capability();
|
|
|
22268
22742
|
// src/frontdoor/rcSelfHostEndpoints.ts
|
|
22269
22743
|
var RC_SOURCE_WORKER = "worker";
|
|
22270
22744
|
var RC_SOURCE_CLIENT = "client";
|
|
22271
|
-
|
|
22745
|
+
var CLIENT_PLATFORM_HEADER = "anthropic-client-platform";
|
|
22746
|
+
function withClientPlatform(payload, headers) {
|
|
22747
|
+
const rest = Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "client_platform"));
|
|
22748
|
+
const platform = headers[CLIENT_PLATFORM_HEADER];
|
|
22749
|
+
return typeof platform === "string" && platform !== "" ? { ...rest, client_platform: platform } : rest;
|
|
22750
|
+
}
|
|
22751
|
+
function isRecord11(value) {
|
|
22272
22752
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22273
22753
|
}
|
|
22274
22754
|
function parseJsonObject2(body) {
|
|
@@ -22278,7 +22758,7 @@ function parseJsonObject2(body) {
|
|
|
22278
22758
|
} catch {
|
|
22279
22759
|
return void 0;
|
|
22280
22760
|
}
|
|
22281
|
-
return
|
|
22761
|
+
return isRecord11(parsed) ? parsed : void 0;
|
|
22282
22762
|
}
|
|
22283
22763
|
function nonEmptyString2(record, field) {
|
|
22284
22764
|
const value = record === void 0 ? void 0 : record[field];
|
|
@@ -22352,11 +22832,11 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
|
22352
22832
|
}
|
|
22353
22833
|
const results = [];
|
|
22354
22834
|
for (const event of events) {
|
|
22355
|
-
if (!
|
|
22835
|
+
if (!isRecord11(event) || !isRecord11(event.payload)) {
|
|
22356
22836
|
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" } });
|
|
22357
22837
|
return true;
|
|
22358
22838
|
}
|
|
22359
|
-
const published = ctx.publish(host.conversation, host.writer, RC_SOURCE_CLIENT, event.payload);
|
|
22839
|
+
const published = ctx.publish(host.conversation, host.writer, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
|
|
22360
22840
|
results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
|
|
22361
22841
|
}
|
|
22362
22842
|
ctx.sweep();
|
|
@@ -22452,7 +22932,7 @@ async function serveRcCompatSessions(ctx, pathname, compatPath) {
|
|
|
22452
22932
|
// src/frontdoor/rcSelfHostConversations.ts
|
|
22453
22933
|
var RC_CONVERSATIONS_PATH_PREFIX = "/v1/code/conversations";
|
|
22454
22934
|
var RC_CONVERSATION_ID_PREFIX = "conv_";
|
|
22455
|
-
function
|
|
22935
|
+
function isRecord12(value) {
|
|
22456
22936
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22457
22937
|
}
|
|
22458
22938
|
function parseJsonObject3(body) {
|
|
@@ -22462,7 +22942,7 @@ function parseJsonObject3(body) {
|
|
|
22462
22942
|
} catch {
|
|
22463
22943
|
return void 0;
|
|
22464
22944
|
}
|
|
22465
|
-
return
|
|
22945
|
+
return isRecord12(parsed) ? parsed : void 0;
|
|
22466
22946
|
}
|
|
22467
22947
|
function nonEmptyString3(record, field) {
|
|
22468
22948
|
const value = record === void 0 ? void 0 : record[field];
|
|
@@ -22516,11 +22996,11 @@ async function serveRcConversations(ctx, pathname, method) {
|
|
|
22516
22996
|
}
|
|
22517
22997
|
const results = [];
|
|
22518
22998
|
for (const event of events) {
|
|
22519
|
-
if (!
|
|
22999
|
+
if (!isRecord12(event) || !isRecord12(event.payload)) {
|
|
22520
23000
|
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" } });
|
|
22521
23001
|
return;
|
|
22522
23002
|
}
|
|
22523
|
-
const published = ctx.publish(conversation, { session: void 0, half: "client" }, RC_SOURCE_CLIENT, event.payload);
|
|
23003
|
+
const published = ctx.publish(conversation, { session: void 0, half: "client" }, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
|
|
22524
23004
|
results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
|
|
22525
23005
|
}
|
|
22526
23006
|
ctx.sweep();
|
|
@@ -22548,7 +23028,7 @@ var RC_SELF_HOST_SCOPE_LIST = ["user:profile", "user:inference", "user:sessions:
|
|
|
22548
23028
|
var RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS = 3600;
|
|
22549
23029
|
var MS_PER_SECOND6 = 1e3;
|
|
22550
23030
|
var HTTP_SERVICE_UNAVAILABLE = 503;
|
|
22551
|
-
function
|
|
23031
|
+
function isRecord13(value) {
|
|
22552
23032
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22553
23033
|
}
|
|
22554
23034
|
function parseJsonObject4(body) {
|
|
@@ -22558,7 +23038,7 @@ function parseJsonObject4(body) {
|
|
|
22558
23038
|
} catch {
|
|
22559
23039
|
return void 0;
|
|
22560
23040
|
}
|
|
22561
|
-
return
|
|
23041
|
+
return isRecord13(parsed) ? parsed : void 0;
|
|
22562
23042
|
}
|
|
22563
23043
|
function growthBookFeatures() {
|
|
22564
23044
|
return {
|
|
@@ -22912,7 +23392,7 @@ var RC_SELF_HOST_WORKER_EPOCH = 1;
|
|
|
22912
23392
|
var RC_STREAM_EVENT_NAME2 = "client_event";
|
|
22913
23393
|
var CONFLICT_REASON_HEADER2 = "x-ccr-conflict-reason";
|
|
22914
23394
|
var CONFLICT_REASON_EPOCH_STALE = "epoch_stale";
|
|
22915
|
-
function
|
|
23395
|
+
function isRecord14(value) {
|
|
22916
23396
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22917
23397
|
}
|
|
22918
23398
|
function isWebSearchRefusal(value) {
|
|
@@ -22996,7 +23476,7 @@ function parseJsonObject5(body) {
|
|
|
22996
23476
|
} catch {
|
|
22997
23477
|
return void 0;
|
|
22998
23478
|
}
|
|
22999
|
-
return
|
|
23479
|
+
return isRecord14(parsed) ? parsed : void 0;
|
|
23000
23480
|
}
|
|
23001
23481
|
function mintWorkerJwt(randomToken, issuedAt) {
|
|
23002
23482
|
const encode = (value) => Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
|
|
@@ -23256,7 +23736,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
23256
23736
|
if (status !== void 0) {
|
|
23257
23737
|
session.workerStatus = status;
|
|
23258
23738
|
}
|
|
23259
|
-
if (
|
|
23739
|
+
if (isRecord14(body?.external_metadata)) {
|
|
23260
23740
|
session.externalMetadata = body.external_metadata;
|
|
23261
23741
|
}
|
|
23262
23742
|
await answerJson2(response, HTTP_STATUS.ok, {});
|
|
@@ -23286,7 +23766,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
23286
23766
|
}
|
|
23287
23767
|
const results = [];
|
|
23288
23768
|
for (const event of events) {
|
|
23289
|
-
if (!
|
|
23769
|
+
if (!isRecord14(event) || !isRecord14(event.payload)) {
|
|
23290
23770
|
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" } });
|
|
23291
23771
|
return;
|
|
23292
23772
|
}
|
|
@@ -23319,7 +23799,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
23319
23799
|
return;
|
|
23320
23800
|
}
|
|
23321
23801
|
for (const event of events) {
|
|
23322
|
-
if (
|
|
23802
|
+
if (isRecord14(event)) {
|
|
23323
23803
|
session.internalEvents.push({ eventId: deps.newUuid(), body: event });
|
|
23324
23804
|
}
|
|
23325
23805
|
}
|
|
@@ -23415,11 +23895,11 @@ data: ${JSON.stringify(envelope)}
|
|
|
23415
23895
|
}
|
|
23416
23896
|
const results = [];
|
|
23417
23897
|
for (const event of events) {
|
|
23418
|
-
if (!
|
|
23898
|
+
if (!isRecord14(event) || !isRecord14(event.payload)) {
|
|
23419
23899
|
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" } });
|
|
23420
23900
|
return;
|
|
23421
23901
|
}
|
|
23422
|
-
const published = publish(session.conversation, { session: session.id, half: "client" }, RC_SOURCE_CLIENT, event.payload);
|
|
23902
|
+
const published = publish(session.conversation, { session: session.id, half: "client" }, RC_SOURCE_CLIENT, withClientPlatform(event.payload, request4.headers));
|
|
23423
23903
|
results.push({ sequence_num: String(published.sequenceNum), duplicate: published.duplicate });
|
|
23424
23904
|
}
|
|
23425
23905
|
sweep();
|
|
@@ -23553,7 +24033,7 @@ var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
|
|
|
23553
24033
|
var RC_SELF_HOST_RECORD_FILE = "credential.json";
|
|
23554
24034
|
var SELF_HOST_EMAIL = "selfhost@agent-shim.invalid";
|
|
23555
24035
|
var SELF_HOST_SUBSCRIPTION_TYPE = "max";
|
|
23556
|
-
function
|
|
24036
|
+
function isRecord15(value) {
|
|
23557
24037
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23558
24038
|
}
|
|
23559
24039
|
function readJsonObject(fs17, file) {
|
|
@@ -23567,7 +24047,7 @@ function readJsonObject(fs17, file) {
|
|
|
23567
24047
|
} catch {
|
|
23568
24048
|
return void 0;
|
|
23569
24049
|
}
|
|
23570
|
-
return
|
|
24050
|
+
return isRecord15(parsed) ? parsed : void 0;
|
|
23571
24051
|
}
|
|
23572
24052
|
function readRcSelfHostRecord(fs17, frontdoorDir) {
|
|
23573
24053
|
const parsed = readJsonObject(fs17, path45.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
@@ -23595,7 +24075,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
23595
24075
|
const recordFile2 = path45.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
23596
24076
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
23597
24077
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
23598
|
-
const existingOauth =
|
|
24078
|
+
const existingOauth = isRecord15(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
23599
24079
|
const existingToken = typeof existingOauth?.accessToken === "string" && existingOauth.accessToken !== "" ? existingOauth.accessToken : void 0;
|
|
23600
24080
|
const existingIsOwn = existingToken !== void 0 && previousRecord?.accessToken === existingToken;
|
|
23601
24081
|
if (existingToken !== void 0 && !existingIsOwn && !deps.force) {
|
|
@@ -23612,7 +24092,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
23612
24092
|
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)}
|
|
23613
24093
|
`);
|
|
23614
24094
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
23615
|
-
const existingBlock = (value) =>
|
|
24095
|
+
const existingBlock = (value) => isRecord15(value) ? value : {};
|
|
23616
24096
|
deps.fs.writeFilePrivate(claudeJsonFile, `${JSON.stringify({
|
|
23617
24097
|
...claudeJson,
|
|
23618
24098
|
oauthAccount: {
|
|
@@ -23735,7 +24215,7 @@ init_poolPick();
|
|
|
23735
24215
|
|
|
23736
24216
|
// src/agents/read.ts
|
|
23737
24217
|
import path47 from "node:path";
|
|
23738
|
-
import { z as
|
|
24218
|
+
import { z as z44 } from "zod";
|
|
23739
24219
|
var PROJECTS_DIR = "projects";
|
|
23740
24220
|
var TASKS_DIR = "tasks";
|
|
23741
24221
|
var SUBAGENTS_DIR = "subagents";
|
|
@@ -23854,14 +24334,14 @@ function parseJson2(text) {
|
|
|
23854
24334
|
return void 0;
|
|
23855
24335
|
}
|
|
23856
24336
|
}
|
|
23857
|
-
var TaskFileSchema =
|
|
23858
|
-
var WorkflowRunFileSchema =
|
|
23859
|
-
runId:
|
|
23860
|
-
workflowName:
|
|
23861
|
-
status:
|
|
23862
|
-
startTime:
|
|
23863
|
-
phases:
|
|
23864
|
-
summary:
|
|
24337
|
+
var TaskFileSchema = z44.object({ ...TaskItemSchema.omit({ taskList: true }).shape, blocks: z44.array(z44.string()).default([]), blockedBy: z44.array(z44.string()).default([]) });
|
|
24338
|
+
var WorkflowRunFileSchema = z44.object({
|
|
24339
|
+
runId: z44.string(),
|
|
24340
|
+
workflowName: z44.string().optional(),
|
|
24341
|
+
status: z44.string().optional(),
|
|
24342
|
+
startTime: z44.number().optional(),
|
|
24343
|
+
phases: z44.array(z44.object({ title: z44.string() })).default([]),
|
|
24344
|
+
summary: z44.string().optional()
|
|
23865
24345
|
});
|
|
23866
24346
|
function summariseSession(fs17, configDir, ref) {
|
|
23867
24347
|
const sessionRelative = path47.join(PROJECTS_DIR, ref.project, ref.entry);
|
|
@@ -24365,6 +24845,8 @@ export {
|
|
|
24365
24845
|
QUOTA_EXPIRING_EVENT_SOURCE,
|
|
24366
24846
|
QuotaExpiringEventSchema,
|
|
24367
24847
|
RC_CONTEXT_USAGE_DETAILS,
|
|
24848
|
+
RC_GOAL_CLEAR_WORDS,
|
|
24849
|
+
RC_GOAL_CONDITION_MAX_CHARS,
|
|
24368
24850
|
RC_IDLE_EXPIRY_MS,
|
|
24369
24851
|
RC_ORPC_PATH_PREFIX,
|
|
24370
24852
|
RC_PENDING_DEADLINE_MS,
|
|
@@ -24380,6 +24862,8 @@ export {
|
|
|
24380
24862
|
RC_SELF_HOST_SCOPE_LIST,
|
|
24381
24863
|
RC_SELF_HOST_WORKER_JWT_TTL_SECONDS,
|
|
24382
24864
|
RC_SESSIONS_PATH_PREFIX,
|
|
24865
|
+
RC_SESSION_COMMAND_MAX_WAIT_MS,
|
|
24866
|
+
RC_SESSION_COMMAND_VERIFIED_VERSIONS,
|
|
24383
24867
|
RC_SESSION_END_REASONS,
|
|
24384
24868
|
RC_SESSION_EVENT_LOG_CAPACITY,
|
|
24385
24869
|
RC_STREAM_BACKOFF_MS,
|
|
@@ -24475,11 +24959,13 @@ export {
|
|
|
24475
24959
|
createQuotaExpiringPublisher,
|
|
24476
24960
|
createRcApiNodeHandler,
|
|
24477
24961
|
createRcApiRouter,
|
|
24962
|
+
createRcClaudeCodeVersions,
|
|
24478
24963
|
createRcControlHandler,
|
|
24479
24964
|
createRcCredentialStore,
|
|
24480
24965
|
createRcEventFanout,
|
|
24481
24966
|
createRcLiveUsage,
|
|
24482
24967
|
createRcSelfHostSurface,
|
|
24968
|
+
createRcSessionCommands,
|
|
24483
24969
|
createRcSessionEventLog,
|
|
24484
24970
|
createRcSessionEventsApiRouter,
|
|
24485
24971
|
createRcSessionRegistryReader,
|
|
@@ -24542,6 +25028,7 @@ export {
|
|
|
24542
25028
|
mintRcSelfHostCredential,
|
|
24543
25029
|
observingRoutedRoute,
|
|
24544
25030
|
parseConnectTarget,
|
|
25031
|
+
parseRcGoalOutput,
|
|
24545
25032
|
parseRcStreamEnvelope,
|
|
24546
25033
|
planOf,
|
|
24547
25034
|
poolIdentities,
|
|
@@ -24553,6 +25040,8 @@ export {
|
|
|
24553
25040
|
rankPool,
|
|
24554
25041
|
rcEventWriteResultFromAnswer,
|
|
24555
25042
|
rcFanoutOnDoorHub,
|
|
25043
|
+
rcLocalCommandAnswerOf,
|
|
25044
|
+
rcManualCompactBoundaryOf,
|
|
24556
25045
|
rcObserverAsPassthrough,
|
|
24557
25046
|
rcRateLimitInfoOf,
|
|
24558
25047
|
rcSelfHostFromEnv,
|