agent-shim 11.17.1 → 11.19.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/dist/cli.cjs +242 -117
- package/dist/index.cjs +169 -73
- package/dist/index.mjs +169 -73
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -324,10 +324,10 @@ var init_schema = __esm({
|
|
|
324
324
|
ANTIGRAVITY_EFFORTS = ["none", "low", "medium", "high", "xhigh", "max"];
|
|
325
325
|
ANTIGRAVITY_DEFAULT_MODE = "cloud";
|
|
326
326
|
ANTIGRAVITY_DEFAULT_TIER_MODELS = Object.freeze({
|
|
327
|
-
fable: ["
|
|
327
|
+
fable: ["gemini-4-argon-high", "claude-opus-5-5-high", "gemini-3.8-flash-high"],
|
|
328
328
|
opus: ["claude-opus-5-5-high", "gemini-4-argon-high", "gemini-3.8-flash-high"],
|
|
329
329
|
sonnet: ["claude-sonnet-5-5-medium", "gemini-4-argon-medium", "gemini-3.8-flash-medium"],
|
|
330
|
-
haiku: ["gemini-3.8-flash-low", "gemini-4-argon-low", "
|
|
330
|
+
haiku: ["gemini-3.8-flash-low", "gemini-4-argon-low", "claude-sonnet-5-5-low"]
|
|
331
331
|
});
|
|
332
332
|
AntigravityModelTargetSchema = z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]);
|
|
333
333
|
AntigravityProviderConfigSchema = z.strictObject({
|
|
@@ -337,6 +337,8 @@ var init_schema = __esm({
|
|
|
337
337
|
defaultModel: z.string().min(1).optional(),
|
|
338
338
|
/** Model name mapping. A key naming a tier (`fable`, `opus`, `sonnet`, `haiku`) overrides that tier's shipped model and is matched by substring of the requested name in `ANTIGRAVITY_TIERS` order; any other key is an alias, matched against the whole requested name case-insensitively, so `/model <alias>` selects its backend model. An alias outranks every other rule, including the pass-through of backend names. A value is one model or an ordered list of candidates: the request goes to the first whose quota windows are not spent, and when every candidate is spent, to the one whose binding window lifts soonest. */
|
|
339
339
|
models: z.record(z.string().min(1), AntigravityModelTargetSchema).optional(),
|
|
340
|
+
/** When every candidate of the tier a request names has no quota left, serve it from the next tier down, and onward through the lower tiers, instead of failing with the quota limit. Applies to a name that selects a tier (`/model fable`), not to an alias or a backend model name. Defaults to false. */
|
|
341
|
+
degradeDownTiers: z.boolean().optional(),
|
|
340
342
|
/** The reasoning effort used when the request's own effort is not one the backend accepts. */
|
|
341
343
|
effort: z.enum(ANTIGRAVITY_EFFORTS).optional(),
|
|
342
344
|
/** Cloud-specific settings (for `mode: "cloud"`). */
|
|
@@ -559,26 +561,103 @@ var init_schema = __esm({
|
|
|
559
561
|
}
|
|
560
562
|
});
|
|
561
563
|
|
|
564
|
+
// src/config/unrecognisedKeys.ts
|
|
565
|
+
function isRecord(value) {
|
|
566
|
+
return typeof value === "object" && value !== null;
|
|
567
|
+
}
|
|
568
|
+
function parseIgnoringUnrecognisedKeys(schema, raw) {
|
|
569
|
+
const first = schema.safeParse(raw);
|
|
570
|
+
if (first.success) {
|
|
571
|
+
return { success: true, data: first.data, ignored: [] };
|
|
572
|
+
}
|
|
573
|
+
const unrecognised = first.error.issues.filter((issue) => issue.code === "unrecognized_keys");
|
|
574
|
+
const others = first.error.issues.filter((issue) => issue.code !== "unrecognized_keys");
|
|
575
|
+
if (others.length > 0) {
|
|
576
|
+
return { success: false, issues: others };
|
|
577
|
+
}
|
|
578
|
+
const stripped = structuredClone(raw);
|
|
579
|
+
const ignored = [];
|
|
580
|
+
for (const issue of unrecognised) {
|
|
581
|
+
let holder = stripped;
|
|
582
|
+
for (const step of issue.path) {
|
|
583
|
+
holder = isRecord(holder) ? holder[step] : void 0;
|
|
584
|
+
}
|
|
585
|
+
if (isRecord(holder)) {
|
|
586
|
+
const values = Object.fromEntries(issue.keys.map((key) => [key, holder[key]]));
|
|
587
|
+
for (const key of issue.keys) {
|
|
588
|
+
Reflect.deleteProperty(holder, key);
|
|
589
|
+
}
|
|
590
|
+
ignored.push({ path: issue.path, keys: issue.keys, values });
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
const second = schema.safeParse(stripped);
|
|
594
|
+
return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
|
|
595
|
+
}
|
|
596
|
+
function describeIgnoredKeys(filePath, ignored) {
|
|
597
|
+
const places = ignored.map(({ path: path41, keys }) => `${path41.length === 0 ? "" : `${path41.map(String).join(".")}.`}${keys.join(", ")}`);
|
|
598
|
+
return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
|
|
599
|
+
}
|
|
600
|
+
function noteIgnoredKeys(filePath, ignored) {
|
|
601
|
+
if (ignored.length === 0) {
|
|
602
|
+
ignoredByFile.delete(filePath);
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
ignoredByFile.set(filePath, ignored);
|
|
606
|
+
const message = `agent-shim: warning: ${describeIgnoredKeys(filePath, ignored)}
|
|
607
|
+
`;
|
|
608
|
+
if (!warned.has(message)) {
|
|
609
|
+
warned.add(message);
|
|
610
|
+
process.stderr.write(message);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
function restoreIgnoredKeys(filePath, value) {
|
|
614
|
+
const ignored = ignoredByFile.get(filePath);
|
|
615
|
+
if (ignored === void 0) {
|
|
616
|
+
return value;
|
|
617
|
+
}
|
|
618
|
+
const restored = structuredClone(value);
|
|
619
|
+
for (const { path: path41, values } of ignored) {
|
|
620
|
+
let holder = restored;
|
|
621
|
+
for (const step of path41) {
|
|
622
|
+
holder = isRecord(holder) ? holder[step] : void 0;
|
|
623
|
+
}
|
|
624
|
+
if (isRecord(holder)) {
|
|
625
|
+
for (const [key, held] of Object.entries(values)) {
|
|
626
|
+
holder[key] = held;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return restored;
|
|
631
|
+
}
|
|
632
|
+
var warned, ignoredByFile;
|
|
633
|
+
var init_unrecognisedKeys = __esm({
|
|
634
|
+
"src/config/unrecognisedKeys.ts"() {
|
|
635
|
+
"use strict";
|
|
636
|
+
warned = /* @__PURE__ */ new Set();
|
|
637
|
+
ignoredByFile = /* @__PURE__ */ new Map();
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
|
|
562
641
|
// src/config/load.ts
|
|
563
642
|
import { cosmiconfigSync } from "cosmiconfig";
|
|
564
643
|
function createExplorer(moduleName = "agent-shim") {
|
|
565
644
|
return cosmiconfigSync(moduleName, { searchPlaces: [] });
|
|
566
645
|
}
|
|
567
|
-
function
|
|
646
|
+
function isRecord2(value) {
|
|
568
647
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
569
648
|
}
|
|
570
649
|
function captureEntryOrder(value) {
|
|
571
|
-
if (!
|
|
650
|
+
if (!isRecord2(value)) {
|
|
572
651
|
return [];
|
|
573
652
|
}
|
|
574
653
|
const entries = value.entries;
|
|
575
|
-
if (!
|
|
654
|
+
if (!isRecord2(entries)) {
|
|
576
655
|
return [];
|
|
577
656
|
}
|
|
578
657
|
return Object.keys(entries);
|
|
579
658
|
}
|
|
580
659
|
function captureRuleEntryOrders(value) {
|
|
581
|
-
if (!
|
|
660
|
+
if (!isRecord2(value)) {
|
|
582
661
|
return [];
|
|
583
662
|
}
|
|
584
663
|
const rules = value.rules;
|
|
@@ -593,7 +672,7 @@ function cosmiconfigReader(explorer = createExplorer()) {
|
|
|
593
672
|
try {
|
|
594
673
|
result = explorer.load(filepath);
|
|
595
674
|
} catch (error) {
|
|
596
|
-
const code =
|
|
675
|
+
const code = isRecord2(error) ? error.code : void 0;
|
|
597
676
|
if (code === "ENOENT") {
|
|
598
677
|
return void 0;
|
|
599
678
|
}
|
|
@@ -610,10 +689,11 @@ function loadConfigFile(filepath, schema, read = cosmiconfigReader()) {
|
|
|
610
689
|
if (raw === void 0) {
|
|
611
690
|
return void 0;
|
|
612
691
|
}
|
|
613
|
-
const parsed = schema
|
|
692
|
+
const parsed = parseIgnoringUnrecognisedKeys(schema, raw);
|
|
614
693
|
if (!parsed.success) {
|
|
615
|
-
throw new ConfigValidationError(filepath, parsed.
|
|
694
|
+
throw new ConfigValidationError(filepath, parsed.issues);
|
|
616
695
|
}
|
|
696
|
+
noteIgnoredKeys(filepath, parsed.ignored);
|
|
617
697
|
return {
|
|
618
698
|
filepath,
|
|
619
699
|
config: parsed.data,
|
|
@@ -626,6 +706,7 @@ var init_load = __esm({
|
|
|
626
706
|
"src/config/load.ts"() {
|
|
627
707
|
"use strict";
|
|
628
708
|
init_cliError();
|
|
709
|
+
init_unrecognisedKeys();
|
|
629
710
|
ConfigValidationError = class extends CliError {
|
|
630
711
|
constructor(filepath, issues) {
|
|
631
712
|
const detail = issues.map((issue) => ` ${issue.path.join(".") || "(root)"}: ${issue.message}`).join("\n");
|
|
@@ -654,10 +735,11 @@ function readJson(filePath, schema, storeFs = nodeStoreFs) {
|
|
|
654
735
|
return void 0;
|
|
655
736
|
}
|
|
656
737
|
const parsed = JSON.parse(raw);
|
|
657
|
-
const result = schema
|
|
738
|
+
const result = parseIgnoringUnrecognisedKeys(schema, parsed);
|
|
658
739
|
if (!result.success) {
|
|
659
|
-
throw new ConfigValidationError(filePath, result.
|
|
740
|
+
throw new ConfigValidationError(filePath, result.issues);
|
|
660
741
|
}
|
|
742
|
+
noteIgnoredKeys(filePath, result.ignored);
|
|
661
743
|
return result.data;
|
|
662
744
|
}
|
|
663
745
|
function writeTextAtomic(filePath, contents, storeFs = nodeStoreFs) {
|
|
@@ -673,7 +755,7 @@ function writeTextAtomic(filePath, contents, storeFs = nodeStoreFs) {
|
|
|
673
755
|
}
|
|
674
756
|
}
|
|
675
757
|
function writeJsonAtomic(filePath, data, storeFs = nodeStoreFs) {
|
|
676
|
-
writeTextAtomic(filePath, `${JSON.stringify(data, null, 2)}
|
|
758
|
+
writeTextAtomic(filePath, `${JSON.stringify(restoreIgnoredKeys(filePath, data), null, 2)}
|
|
677
759
|
`, storeFs);
|
|
678
760
|
}
|
|
679
761
|
function applyPatch(filePath, schema, patch, options = {}) {
|
|
@@ -696,6 +778,7 @@ var init_store = __esm({
|
|
|
696
778
|
"src/config/store.ts"() {
|
|
697
779
|
"use strict";
|
|
698
780
|
init_load();
|
|
781
|
+
init_unrecognisedKeys();
|
|
699
782
|
nodeStoreFs = {
|
|
700
783
|
readFileUtf8(filePath) {
|
|
701
784
|
try {
|
|
@@ -2813,7 +2896,7 @@ var init_package = __esm({
|
|
|
2813
2896
|
"package.json"() {
|
|
2814
2897
|
package_default = {
|
|
2815
2898
|
name: "agent-shim",
|
|
2816
|
-
version: "11.
|
|
2899
|
+
version: "11.19.0",
|
|
2817
2900
|
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.",
|
|
2818
2901
|
license: "MIT",
|
|
2819
2902
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -6174,7 +6257,7 @@ function formatCredentialSummary(summary) {
|
|
|
6174
6257
|
function describeCredential(credential) {
|
|
6175
6258
|
return formatCredentialSummary(summariseCredential(credential));
|
|
6176
6259
|
}
|
|
6177
|
-
function
|
|
6260
|
+
function isRecord6(value) {
|
|
6178
6261
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6179
6262
|
}
|
|
6180
6263
|
function unpackKeyringToken(raw) {
|
|
@@ -6186,7 +6269,7 @@ function unpackKeyringToken(raw) {
|
|
|
6186
6269
|
const base64Str = trimmed.slice(GO_KEYRING_BASE64_PREFIX.length);
|
|
6187
6270
|
const decoded = Buffer.from(base64Str, "base64").toString("utf8");
|
|
6188
6271
|
const parsed = JSON.parse(decoded);
|
|
6189
|
-
if (
|
|
6272
|
+
if (isRecord6(parsed) && isRecord6(parsed.token)) {
|
|
6190
6273
|
const accessToken = parsed.token.access_token;
|
|
6191
6274
|
if (typeof accessToken === "string" && accessToken.trim() !== "") {
|
|
6192
6275
|
return accessToken.trim();
|
|
@@ -6302,14 +6385,14 @@ function providerJsonPath(paths, name) {
|
|
|
6302
6385
|
function providerExists(paths, name) {
|
|
6303
6386
|
return fs7.existsSync(providerJsonPath(paths, name));
|
|
6304
6387
|
}
|
|
6305
|
-
function
|
|
6388
|
+
function isRecord7(value) {
|
|
6306
6389
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6307
6390
|
}
|
|
6308
6391
|
function legacyProviderConversion(raw) {
|
|
6309
|
-
if (!
|
|
6392
|
+
if (!isRecord7(raw) || "credential" in raw) {
|
|
6310
6393
|
return void 0;
|
|
6311
6394
|
}
|
|
6312
|
-
const env =
|
|
6395
|
+
const env = isRecord7(raw.env) ? raw.env : void 0;
|
|
6313
6396
|
const legacyEnvKeys = env === void 0 ? [] : Object.keys(env).filter((key) => LEGACY_ENV_CREDENTIAL_KEYS.includes(key));
|
|
6314
6397
|
const fields = [...LEGACY_PROVIDER_FIELDS.filter((field) => field in raw), ...legacyEnvKeys.map((key) => `env.${key}`)];
|
|
6315
6398
|
if (fields.length === 0) {
|
|
@@ -6342,10 +6425,11 @@ function parseProviderFile(filePath, raw) {
|
|
|
6342
6425
|
if (conversion !== void 0) {
|
|
6343
6426
|
throw new LegacyProviderFileError(filePath, conversion);
|
|
6344
6427
|
}
|
|
6345
|
-
const parsed = ProviderSchema
|
|
6428
|
+
const parsed = parseIgnoringUnrecognisedKeys(ProviderSchema, raw);
|
|
6346
6429
|
if (!parsed.success) {
|
|
6347
|
-
throw new ConfigValidationError(filePath, parsed.
|
|
6430
|
+
throw new ConfigValidationError(filePath, parsed.issues);
|
|
6348
6431
|
}
|
|
6432
|
+
noteIgnoredKeys(filePath, parsed.ignored);
|
|
6349
6433
|
return parsed.data;
|
|
6350
6434
|
}
|
|
6351
6435
|
function readProvider(paths, name) {
|
|
@@ -6406,7 +6490,7 @@ function isEmptyCodexConfig(config) {
|
|
|
6406
6490
|
return config === void 0 || config.defaultModel === void 0 && config.effort === void 0 && config.login === void 0 && (config.models === void 0 || Object.keys(config.models).length === 0);
|
|
6407
6491
|
}
|
|
6408
6492
|
function isEmptyAntigravityConfig(config) {
|
|
6409
|
-
return config === void 0 || config.mode === void 0 && config.defaultModel === void 0 && config.effort === void 0 && config.cloud === void 0 && config.local === void 0 && (config.models === void 0 || Object.keys(config.models).length === 0);
|
|
6493
|
+
return config === void 0 || config.mode === void 0 && config.defaultModel === void 0 && config.effort === void 0 && config.degradeDownTiers === void 0 && config.cloud === void 0 && config.local === void 0 && (config.models === void 0 || Object.keys(config.models).length === 0);
|
|
6410
6494
|
}
|
|
6411
6495
|
function addProvider(paths, name, input) {
|
|
6412
6496
|
if (providerExists(paths, name)) {
|
|
@@ -6553,6 +6637,7 @@ var init_providersStore = __esm({
|
|
|
6553
6637
|
"use strict";
|
|
6554
6638
|
init_load();
|
|
6555
6639
|
init_store();
|
|
6640
|
+
init_unrecognisedKeys();
|
|
6556
6641
|
init_schema();
|
|
6557
6642
|
init_cliError();
|
|
6558
6643
|
init_credential();
|
|
@@ -7535,7 +7620,7 @@ function resolvePoolLaunch(params) {
|
|
|
7535
7620
|
if (stickyRead.problem !== void 0) {
|
|
7536
7621
|
log.warn(`agent-shim: ${stickyRead.problem}; ignoring the last-pick record`);
|
|
7537
7622
|
}
|
|
7538
|
-
const
|
|
7623
|
+
const warned2 = /* @__PURE__ */ new Set();
|
|
7539
7624
|
for (; ; ) {
|
|
7540
7625
|
const nowMs = params.now();
|
|
7541
7626
|
let graph;
|
|
@@ -7559,8 +7644,8 @@ function resolvePoolLaunch(params) {
|
|
|
7559
7644
|
}
|
|
7560
7645
|
for (const gone of graph.missing) {
|
|
7561
7646
|
const key = `${gone.pool}:${gone.identity}`;
|
|
7562
|
-
if (!
|
|
7563
|
-
|
|
7647
|
+
if (!warned2.has(key)) {
|
|
7648
|
+
warned2.add(key);
|
|
7564
7649
|
log.warn(`agent-shim: pool "${gone.pool}" names identity "${gone.identity}", which does not exist; skipping it`);
|
|
7565
7650
|
}
|
|
7566
7651
|
}
|
|
@@ -9889,7 +9974,7 @@ var LiveTaskSchema = z5.strictObject({
|
|
|
9889
9974
|
observedAt: z5.number()
|
|
9890
9975
|
});
|
|
9891
9976
|
var SYSTEM_SUBTYPES = ["task_started", "task_progress", "task_updated", "task_notification", "background_tasks_changed"];
|
|
9892
|
-
function
|
|
9977
|
+
function isRecord3(value) {
|
|
9893
9978
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9894
9979
|
}
|
|
9895
9980
|
function stringField(record, field) {
|
|
@@ -9906,7 +9991,7 @@ function booleanField(record, field) {
|
|
|
9906
9991
|
}
|
|
9907
9992
|
function usageOf(record) {
|
|
9908
9993
|
const raw = record.usage;
|
|
9909
|
-
if (!
|
|
9994
|
+
if (!isRecord3(raw)) {
|
|
9910
9995
|
return void 0;
|
|
9911
9996
|
}
|
|
9912
9997
|
const totalTokens = numberField(raw, "total_tokens");
|
|
@@ -9938,7 +10023,7 @@ function bounded(book) {
|
|
|
9938
10023
|
return book;
|
|
9939
10024
|
}
|
|
9940
10025
|
function applyAgentTaskEvent(book, sessionId, payload, observedAt2) {
|
|
9941
|
-
if (!
|
|
10026
|
+
if (!isRecord3(payload) || payload.type !== "system") {
|
|
9942
10027
|
return book;
|
|
9943
10028
|
}
|
|
9944
10029
|
const subtype = payload.subtype;
|
|
@@ -9954,8 +10039,8 @@ function applyAgentTaskEvent(book, sessionId, payload, observedAt2) {
|
|
|
9954
10039
|
if (subtype === "background_tasks_changed") {
|
|
9955
10040
|
const tasks = Array.isArray(payload.tasks) ? payload.tasks : [];
|
|
9956
10041
|
for (const raw of tasks) {
|
|
9957
|
-
const taskId2 =
|
|
9958
|
-
if (
|
|
10042
|
+
const taskId2 = isRecord3(raw) ? stringField(raw, "task_id") : void 0;
|
|
10043
|
+
if (isRecord3(raw) && taskId2 !== void 0) {
|
|
9959
10044
|
upsert(taskId2, { runId: stringField(raw, "run_id"), taskType: stringField(raw, "task_type"), description: stringField(raw, "description") });
|
|
9960
10045
|
}
|
|
9961
10046
|
}
|
|
@@ -9978,7 +10063,7 @@ function applyAgentTaskEvent(book, sessionId, payload, observedAt2) {
|
|
|
9978
10063
|
} else if (subtype === "task_progress") {
|
|
9979
10064
|
upsert(taskId, { ...common, subagentType: stringField(payload, "subagent_type"), lastToolName: stringField(payload, "last_tool_name"), usage: usageOf(payload) });
|
|
9980
10065
|
} else if (subtype === "task_updated") {
|
|
9981
|
-
const patch =
|
|
10066
|
+
const patch = isRecord3(payload.patch) ? payload.patch : {};
|
|
9982
10067
|
upsert(taskId, { runId: stringField(payload, "run_id"), status: stringField(patch, "status") });
|
|
9983
10068
|
} else {
|
|
9984
10069
|
upsert(taskId, { ...common, status: stringField(payload, "status"), outputFile: stringField(payload, "output_file"), summary: stringField(payload, "summary"), usage: usageOf(payload) });
|
|
@@ -10060,7 +10145,7 @@ function sessionCreateId(body) {
|
|
|
10060
10145
|
const id = session.id;
|
|
10061
10146
|
return typeof id === "string" && id.startsWith(RC_SESSION_ID_PREFIX) ? id : void 0;
|
|
10062
10147
|
}
|
|
10063
|
-
function
|
|
10148
|
+
function isRecord4(value) {
|
|
10064
10149
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10065
10150
|
}
|
|
10066
10151
|
function parseJsonObject(body) {
|
|
@@ -10070,7 +10155,7 @@ function parseJsonObject(body) {
|
|
|
10070
10155
|
} catch {
|
|
10071
10156
|
return void 0;
|
|
10072
10157
|
}
|
|
10073
|
-
return
|
|
10158
|
+
return isRecord4(parsed) ? parsed : void 0;
|
|
10074
10159
|
}
|
|
10075
10160
|
function nonEmptyString(record, field) {
|
|
10076
10161
|
const value = record === void 0 ? void 0 : record[field];
|
|
@@ -10091,11 +10176,11 @@ function payloadEventsOf(body) {
|
|
|
10091
10176
|
}
|
|
10092
10177
|
const payloads = [];
|
|
10093
10178
|
for (const event of events) {
|
|
10094
|
-
if (!
|
|
10179
|
+
if (!isRecord4(event)) {
|
|
10095
10180
|
continue;
|
|
10096
10181
|
}
|
|
10097
10182
|
const payload = event.payload;
|
|
10098
|
-
if (!
|
|
10183
|
+
if (!isRecord4(payload)) {
|
|
10099
10184
|
continue;
|
|
10100
10185
|
}
|
|
10101
10186
|
payloads.push(payload);
|
|
@@ -10110,7 +10195,7 @@ function pendingOfControlRequestPayload(payload) {
|
|
|
10110
10195
|
if (requestId === void 0) {
|
|
10111
10196
|
return void 0;
|
|
10112
10197
|
}
|
|
10113
|
-
const request4 =
|
|
10198
|
+
const request4 = isRecord4(payload.request) ? payload.request : void 0;
|
|
10114
10199
|
const subtype = nonEmptyString(request4, "subtype");
|
|
10115
10200
|
const type = subtype ?? "control_request";
|
|
10116
10201
|
let summary = "";
|
|
@@ -10127,7 +10212,7 @@ function answeredRequestIdsOfControlResponsePayload(payload) {
|
|
|
10127
10212
|
if (payload.type !== "control_response") {
|
|
10128
10213
|
return [];
|
|
10129
10214
|
}
|
|
10130
|
-
const response =
|
|
10215
|
+
const response = isRecord4(payload.response) ? payload.response : void 0;
|
|
10131
10216
|
const id = nonEmptyString(response, "request_id") ?? nonEmptyString(payload, "request_id") ?? nonEmptyString(payload, "uuid");
|
|
10132
10217
|
return id === void 0 ? [] : [id];
|
|
10133
10218
|
}
|
|
@@ -10356,7 +10441,7 @@ function createRcSessionTracker(deps) {
|
|
|
10356
10441
|
return;
|
|
10357
10442
|
}
|
|
10358
10443
|
entry.sequenceNum = entry.sequenceNum === void 0 || event.sequence_num > entry.sequenceNum ? event.sequence_num : entry.sequenceNum;
|
|
10359
|
-
if (!
|
|
10444
|
+
if (!isRecord4(event.payload)) {
|
|
10360
10445
|
return;
|
|
10361
10446
|
}
|
|
10362
10447
|
entry.liveTasks = applyAgentTaskEvent(entry.liveTasks, sessionId, event.payload, deps.now());
|
|
@@ -11779,11 +11864,11 @@ import path10 from "node:path";
|
|
|
11779
11864
|
function isSafeSessionId(sessionId) {
|
|
11780
11865
|
return /^[A-Za-z0-9_-]+$/.test(sessionId);
|
|
11781
11866
|
}
|
|
11782
|
-
function
|
|
11867
|
+
function isRecord5(value) {
|
|
11783
11868
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11784
11869
|
}
|
|
11785
11870
|
function credentialOfJson(parsed) {
|
|
11786
|
-
if (!
|
|
11871
|
+
if (!isRecord5(parsed)) {
|
|
11787
11872
|
return void 0;
|
|
11788
11873
|
}
|
|
11789
11874
|
const { authorization, anthropicVersion, anthropicClientPlatform } = parsed;
|
|
@@ -11813,7 +11898,7 @@ function createRcCredentialStore(fs13, dir) {
|
|
|
11813
11898
|
} catch {
|
|
11814
11899
|
return void 0;
|
|
11815
11900
|
}
|
|
11816
|
-
return
|
|
11901
|
+
return isRecord5(parsed) ? parsed : void 0;
|
|
11817
11902
|
};
|
|
11818
11903
|
return {
|
|
11819
11904
|
read: (sessionId) => {
|
|
@@ -13750,6 +13835,7 @@ function parseSiwcFile(raw, filePath) {
|
|
|
13750
13835
|
|
|
13751
13836
|
// src/doctorReport.ts
|
|
13752
13837
|
init_load();
|
|
13838
|
+
init_unrecognisedKeys();
|
|
13753
13839
|
init_schema();
|
|
13754
13840
|
init_credential();
|
|
13755
13841
|
init_credentialCache();
|
|
@@ -13960,11 +14046,11 @@ function validateJson(schema, input) {
|
|
|
13960
14046
|
} catch (error) {
|
|
13961
14047
|
return { ok: false, message: `${input.path} is not valid JSON: ${error instanceof Error ? error.message : String(error)}` };
|
|
13962
14048
|
}
|
|
13963
|
-
const result = schema
|
|
14049
|
+
const result = parseIgnoringUnrecognisedKeys(schema, parsed);
|
|
13964
14050
|
if (!result.success) {
|
|
13965
|
-
return { ok: false, message: new ConfigValidationError(input.path, result.
|
|
14051
|
+
return { ok: false, message: new ConfigValidationError(input.path, result.issues).message };
|
|
13966
14052
|
}
|
|
13967
|
-
return { ok: true, data: result.data };
|
|
14053
|
+
return { ok: true, data: result.data, ...result.ignored.length === 0 ? {} : { warning: describeIgnoredKeys(input.path, result.ignored) } };
|
|
13968
14054
|
}
|
|
13969
14055
|
function tcpPortEraRecord(raw) {
|
|
13970
14056
|
let parsed;
|
|
@@ -14057,11 +14143,14 @@ function pushProvider(push, entry, cacheEnv, signIn) {
|
|
|
14057
14143
|
push("provider", "fail", new LegacyProviderFileError(entry.path, conversion).message, entry.name);
|
|
14058
14144
|
return;
|
|
14059
14145
|
}
|
|
14060
|
-
const validated3 = ProviderSchema
|
|
14146
|
+
const validated3 = parseIgnoringUnrecognisedKeys(ProviderSchema, parsed);
|
|
14061
14147
|
if (!validated3.success) {
|
|
14062
|
-
push("provider", "fail", new ConfigValidationError(entry.path, validated3.
|
|
14148
|
+
push("provider", "fail", new ConfigValidationError(entry.path, validated3.issues).message, entry.name);
|
|
14063
14149
|
return;
|
|
14064
14150
|
}
|
|
14151
|
+
if (validated3.ignored.length > 0) {
|
|
14152
|
+
push("provider", "warn", describeIgnoredKeys(entry.path, validated3.ignored), entry.name);
|
|
14153
|
+
}
|
|
14065
14154
|
const cache = cacheClause(cacheEnv, `provider ${entry.name}`, validated3.data.credential);
|
|
14066
14155
|
push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(validated3.data)}, credential ${describeCredential(validated3.data.credential)})${cache.text}.`, entry.name);
|
|
14067
14156
|
if (validated3.data.env?.ENABLE_TOOL_SEARCH === void 0) {
|
|
@@ -14096,6 +14185,13 @@ function runDoctor(params) {
|
|
|
14096
14185
|
const push = (section, severity, message, subject) => {
|
|
14097
14186
|
findings.push({ section, severity, message, ...subject === void 0 ? {} : { subject } });
|
|
14098
14187
|
};
|
|
14188
|
+
const validate = (schema, input, section, subject) => {
|
|
14189
|
+
const validated3 = validateJson(schema, input);
|
|
14190
|
+
if (validated3.ok && validated3.warning !== void 0) {
|
|
14191
|
+
push(section, "warn", validated3.warning, subject);
|
|
14192
|
+
}
|
|
14193
|
+
return validated3;
|
|
14194
|
+
};
|
|
14099
14195
|
const checkPin = (section, subject, where, version) => {
|
|
14100
14196
|
const installed = params.installedClaudeVersions;
|
|
14101
14197
|
if (version === void 0 || installed === void 0 || installed.includes(version)) {
|
|
@@ -14135,7 +14231,7 @@ function runDoctor(params) {
|
|
|
14135
14231
|
pushLegacyName(push, params);
|
|
14136
14232
|
const profileSources = /* @__PURE__ */ new Map();
|
|
14137
14233
|
for (const entry of params.configProfiles) {
|
|
14138
|
-
const validated3 =
|
|
14234
|
+
const validated3 = validate(ConfigProfileSchema, entry, "config-profile", entry.name);
|
|
14139
14235
|
if (!validated3.ok) {
|
|
14140
14236
|
push("config-profile", "fail", validated3.message, entry.name);
|
|
14141
14237
|
continue;
|
|
@@ -14157,7 +14253,7 @@ function runDoctor(params) {
|
|
|
14157
14253
|
const validProfileNames = new Set(profileSources.keys());
|
|
14158
14254
|
const validIdentityNames = /* @__PURE__ */ new Set();
|
|
14159
14255
|
for (const entry of params.identities) {
|
|
14160
|
-
const validated3 =
|
|
14256
|
+
const validated3 = validate(IdentitySchema, entry, "identity", entry.name);
|
|
14161
14257
|
if (!validated3.ok) {
|
|
14162
14258
|
push("identity", "fail", validated3.message, entry.name);
|
|
14163
14259
|
continue;
|
|
@@ -14243,7 +14339,7 @@ function runDoctor(params) {
|
|
|
14243
14339
|
if (params.directoryRules.raw === void 0) {
|
|
14244
14340
|
push("directory-rules", "pass", "No directory-rules.json configured.");
|
|
14245
14341
|
} else {
|
|
14246
|
-
const validated3 =
|
|
14342
|
+
const validated3 = validate(DirectoryRulesSchema, params.directoryRules, "directory-rules");
|
|
14247
14343
|
if (!validated3.ok) {
|
|
14248
14344
|
push("directory-rules", "fail", validated3.message);
|
|
14249
14345
|
} else {
|
|
@@ -14268,7 +14364,7 @@ function runDoctor(params) {
|
|
|
14268
14364
|
if (params.globalConfig.raw === void 0) {
|
|
14269
14365
|
push("global-config", "pass", "No config.json configured.");
|
|
14270
14366
|
} else {
|
|
14271
|
-
const validated3 =
|
|
14367
|
+
const validated3 = validate(GlobalConfigSchema, params.globalConfig, "global-config");
|
|
14272
14368
|
if (!validated3.ok) {
|
|
14273
14369
|
push("global-config", "fail", validated3.message);
|
|
14274
14370
|
} else {
|
|
@@ -14288,7 +14384,7 @@ function runDoctor(params) {
|
|
|
14288
14384
|
if (params.categoriesLocal.raw === void 0) {
|
|
14289
14385
|
push("categories-local", "pass", "No categories.local.json configured.");
|
|
14290
14386
|
} else {
|
|
14291
|
-
const validated3 =
|
|
14387
|
+
const validated3 = validate(CategoryClassificationOverlaySchema, params.categoriesLocal, "categories-local");
|
|
14292
14388
|
push(
|
|
14293
14389
|
"categories-local",
|
|
14294
14390
|
validated3.ok ? "pass" : "fail",
|
|
@@ -15899,15 +15995,15 @@ function createQuotaExpiringPublisher(hub, deps) {
|
|
|
15899
15995
|
|
|
15900
15996
|
// src/frontdoor/rcLiveUsage.ts
|
|
15901
15997
|
var RC_RATE_LIMIT_EVENT_TYPE = "rate_limit_event";
|
|
15902
|
-
function
|
|
15998
|
+
function isRecord8(value) {
|
|
15903
15999
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15904
16000
|
}
|
|
15905
16001
|
function rcRateLimitInfoOf(event) {
|
|
15906
16002
|
const payload = event.envelope.payload;
|
|
15907
|
-
if (!
|
|
16003
|
+
if (!isRecord8(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
|
|
15908
16004
|
return void 0;
|
|
15909
16005
|
}
|
|
15910
|
-
if (!
|
|
16006
|
+
if (!isRecord8(payload.rate_limit_info)) {
|
|
15911
16007
|
return void 0;
|
|
15912
16008
|
}
|
|
15913
16009
|
const parsed = RcRateLimitInfoSchema.safeParse(payload.rate_limit_info);
|
|
@@ -15995,7 +16091,7 @@ function createSseParser() {
|
|
|
15995
16091
|
}
|
|
15996
16092
|
};
|
|
15997
16093
|
}
|
|
15998
|
-
function
|
|
16094
|
+
function isRecord9(value) {
|
|
15999
16095
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16000
16096
|
}
|
|
16001
16097
|
function sequenceNumOf(value) {
|
|
@@ -16017,7 +16113,7 @@ function parseRcStreamEnvelope(parsed) {
|
|
|
16017
16113
|
} catch {
|
|
16018
16114
|
return void 0;
|
|
16019
16115
|
}
|
|
16020
|
-
if (!
|
|
16116
|
+
if (!isRecord9(data)) {
|
|
16021
16117
|
return void 0;
|
|
16022
16118
|
}
|
|
16023
16119
|
const eventType = data.event_type;
|
|
@@ -16258,7 +16354,7 @@ init_capability();
|
|
|
16258
16354
|
// src/frontdoor/rcSelfHostEndpoints.ts
|
|
16259
16355
|
var RC_SOURCE_WORKER = "worker";
|
|
16260
16356
|
var RC_SOURCE_CLIENT = "client";
|
|
16261
|
-
function
|
|
16357
|
+
function isRecord10(value) {
|
|
16262
16358
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16263
16359
|
}
|
|
16264
16360
|
function parseJsonObject2(body) {
|
|
@@ -16268,7 +16364,7 @@ function parseJsonObject2(body) {
|
|
|
16268
16364
|
} catch {
|
|
16269
16365
|
return void 0;
|
|
16270
16366
|
}
|
|
16271
|
-
return
|
|
16367
|
+
return isRecord10(parsed) ? parsed : void 0;
|
|
16272
16368
|
}
|
|
16273
16369
|
function nonEmptyString2(record, field) {
|
|
16274
16370
|
const value = record === void 0 ? void 0 : record[field];
|
|
@@ -16342,7 +16438,7 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
|
16342
16438
|
}
|
|
16343
16439
|
const results = [];
|
|
16344
16440
|
for (const event of events) {
|
|
16345
|
-
if (!
|
|
16441
|
+
if (!isRecord10(event) || !isRecord10(event.payload)) {
|
|
16346
16442
|
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" } });
|
|
16347
16443
|
return true;
|
|
16348
16444
|
}
|
|
@@ -16442,7 +16538,7 @@ async function serveRcCompatSessions(ctx, pathname, compatPath) {
|
|
|
16442
16538
|
// src/frontdoor/rcSelfHostConversations.ts
|
|
16443
16539
|
var RC_CONVERSATIONS_PATH_PREFIX = "/v1/code/conversations";
|
|
16444
16540
|
var RC_CONVERSATION_ID_PREFIX = "conv_";
|
|
16445
|
-
function
|
|
16541
|
+
function isRecord11(value) {
|
|
16446
16542
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16447
16543
|
}
|
|
16448
16544
|
function parseJsonObject3(body) {
|
|
@@ -16452,7 +16548,7 @@ function parseJsonObject3(body) {
|
|
|
16452
16548
|
} catch {
|
|
16453
16549
|
return void 0;
|
|
16454
16550
|
}
|
|
16455
|
-
return
|
|
16551
|
+
return isRecord11(parsed) ? parsed : void 0;
|
|
16456
16552
|
}
|
|
16457
16553
|
function nonEmptyString3(record, field) {
|
|
16458
16554
|
const value = record === void 0 ? void 0 : record[field];
|
|
@@ -16506,7 +16602,7 @@ async function serveRcConversations(ctx, pathname, method) {
|
|
|
16506
16602
|
}
|
|
16507
16603
|
const results = [];
|
|
16508
16604
|
for (const event of events) {
|
|
16509
|
-
if (!
|
|
16605
|
+
if (!isRecord11(event) || !isRecord11(event.payload)) {
|
|
16510
16606
|
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" } });
|
|
16511
16607
|
return;
|
|
16512
16608
|
}
|
|
@@ -16538,7 +16634,7 @@ var RC_SELF_HOST_SCOPE_LIST = ["user:profile", "user:inference", "user:sessions:
|
|
|
16538
16634
|
var RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS = 3600;
|
|
16539
16635
|
var MS_PER_SECOND5 = 1e3;
|
|
16540
16636
|
var HTTP_SERVICE_UNAVAILABLE = 503;
|
|
16541
|
-
function
|
|
16637
|
+
function isRecord12(value) {
|
|
16542
16638
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16543
16639
|
}
|
|
16544
16640
|
function parseJsonObject4(body) {
|
|
@@ -16548,7 +16644,7 @@ function parseJsonObject4(body) {
|
|
|
16548
16644
|
} catch {
|
|
16549
16645
|
return void 0;
|
|
16550
16646
|
}
|
|
16551
|
-
return
|
|
16647
|
+
return isRecord12(parsed) ? parsed : void 0;
|
|
16552
16648
|
}
|
|
16553
16649
|
function growthBookFeatures() {
|
|
16554
16650
|
return {
|
|
@@ -16902,7 +16998,7 @@ var RC_SELF_HOST_WORKER_EPOCH = 1;
|
|
|
16902
16998
|
var RC_STREAM_EVENT_NAME2 = "client_event";
|
|
16903
16999
|
var CONFLICT_REASON_HEADER2 = "x-ccr-conflict-reason";
|
|
16904
17000
|
var CONFLICT_REASON_EPOCH_STALE = "epoch_stale";
|
|
16905
|
-
function
|
|
17001
|
+
function isRecord13(value) {
|
|
16906
17002
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16907
17003
|
}
|
|
16908
17004
|
function isWebSearchRefusal(value) {
|
|
@@ -16986,7 +17082,7 @@ function parseJsonObject5(body) {
|
|
|
16986
17082
|
} catch {
|
|
16987
17083
|
return void 0;
|
|
16988
17084
|
}
|
|
16989
|
-
return
|
|
17085
|
+
return isRecord13(parsed) ? parsed : void 0;
|
|
16990
17086
|
}
|
|
16991
17087
|
function mintWorkerJwt(randomToken, issuedAt) {
|
|
16992
17088
|
const encode = (value) => Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
|
|
@@ -17246,7 +17342,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
17246
17342
|
if (status !== void 0) {
|
|
17247
17343
|
session.workerStatus = status;
|
|
17248
17344
|
}
|
|
17249
|
-
if (
|
|
17345
|
+
if (isRecord13(body?.external_metadata)) {
|
|
17250
17346
|
session.externalMetadata = body.external_metadata;
|
|
17251
17347
|
}
|
|
17252
17348
|
await answerJson2(response, HTTP_STATUS.ok, {});
|
|
@@ -17276,7 +17372,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
17276
17372
|
}
|
|
17277
17373
|
const results = [];
|
|
17278
17374
|
for (const event of events) {
|
|
17279
|
-
if (!
|
|
17375
|
+
if (!isRecord13(event) || !isRecord13(event.payload)) {
|
|
17280
17376
|
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" } });
|
|
17281
17377
|
return;
|
|
17282
17378
|
}
|
|
@@ -17309,7 +17405,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
17309
17405
|
return;
|
|
17310
17406
|
}
|
|
17311
17407
|
for (const event of events) {
|
|
17312
|
-
if (
|
|
17408
|
+
if (isRecord13(event)) {
|
|
17313
17409
|
session.internalEvents.push({ eventId: deps.newUuid(), body: event });
|
|
17314
17410
|
}
|
|
17315
17411
|
}
|
|
@@ -17405,7 +17501,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
17405
17501
|
}
|
|
17406
17502
|
const results = [];
|
|
17407
17503
|
for (const event of events) {
|
|
17408
|
-
if (!
|
|
17504
|
+
if (!isRecord13(event) || !isRecord13(event.payload)) {
|
|
17409
17505
|
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" } });
|
|
17410
17506
|
return;
|
|
17411
17507
|
}
|
|
@@ -17542,7 +17638,7 @@ var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
|
|
|
17542
17638
|
var RC_SELF_HOST_RECORD_FILE = "credential.json";
|
|
17543
17639
|
var SELF_HOST_EMAIL = "selfhost@agent-shim.invalid";
|
|
17544
17640
|
var SELF_HOST_SUBSCRIPTION_TYPE = "max";
|
|
17545
|
-
function
|
|
17641
|
+
function isRecord14(value) {
|
|
17546
17642
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17547
17643
|
}
|
|
17548
17644
|
function readJsonObject(fs13, file) {
|
|
@@ -17556,7 +17652,7 @@ function readJsonObject(fs13, file) {
|
|
|
17556
17652
|
} catch {
|
|
17557
17653
|
return void 0;
|
|
17558
17654
|
}
|
|
17559
|
-
return
|
|
17655
|
+
return isRecord14(parsed) ? parsed : void 0;
|
|
17560
17656
|
}
|
|
17561
17657
|
function readRcSelfHostRecord(fs13, frontdoorDir) {
|
|
17562
17658
|
const parsed = readJsonObject(fs13, path33.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
@@ -17580,7 +17676,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
17580
17676
|
const recordFile = path33.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
17581
17677
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
17582
17678
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
17583
|
-
const existingOauth =
|
|
17679
|
+
const existingOauth = isRecord14(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
17584
17680
|
const existingToken = typeof existingOauth?.accessToken === "string" && existingOauth.accessToken !== "" ? existingOauth.accessToken : void 0;
|
|
17585
17681
|
const existingIsOwn = existingToken !== void 0 && previousRecord?.accessToken === existingToken;
|
|
17586
17682
|
if (existingToken !== void 0 && !existingIsOwn && !deps.force) {
|
|
@@ -17597,7 +17693,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
17597
17693
|
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)}
|
|
17598
17694
|
`);
|
|
17599
17695
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
17600
|
-
const existingBlock = (value) =>
|
|
17696
|
+
const existingBlock = (value) => isRecord14(value) ? value : {};
|
|
17601
17697
|
deps.fs.writeFilePrivate(claudeJsonFile, `${JSON.stringify({
|
|
17602
17698
|
...claudeJson,
|
|
17603
17699
|
oauthAccount: {
|