claude-use 11.18.0 → 11.19.1
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 +227 -127
- package/dist/index.cjs +184 -83
- package/dist/index.mjs +183 -82
- package/dist/types/index.d.ts +14 -5
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -24527,25 +24527,102 @@ var require_dist = __commonJS({
|
|
|
24527
24527
|
}
|
|
24528
24528
|
});
|
|
24529
24529
|
|
|
24530
|
+
// src/config/unrecognisedKeys.ts
|
|
24531
|
+
function isRecord(value2) {
|
|
24532
|
+
return typeof value2 === "object" && value2 !== null;
|
|
24533
|
+
}
|
|
24534
|
+
function parseIgnoringUnrecognisedKeys(schema, raw) {
|
|
24535
|
+
const first = schema.safeParse(raw);
|
|
24536
|
+
if (first.success) {
|
|
24537
|
+
return { success: true, data: first.data, ignored: [] };
|
|
24538
|
+
}
|
|
24539
|
+
const unrecognised = first.error.issues.filter((issue2) => issue2.code === "unrecognized_keys");
|
|
24540
|
+
const others = first.error.issues.filter((issue2) => issue2.code !== "unrecognized_keys");
|
|
24541
|
+
if (others.length > 0) {
|
|
24542
|
+
return { success: false, issues: others };
|
|
24543
|
+
}
|
|
24544
|
+
const stripped = structuredClone(raw);
|
|
24545
|
+
const ignored = [];
|
|
24546
|
+
for (const issue2 of unrecognised) {
|
|
24547
|
+
let holder = stripped;
|
|
24548
|
+
for (const step2 of issue2.path) {
|
|
24549
|
+
holder = isRecord(holder) ? holder[step2] : void 0;
|
|
24550
|
+
}
|
|
24551
|
+
if (isRecord(holder)) {
|
|
24552
|
+
const values = Object.fromEntries(issue2.keys.map((key) => [key, holder[key]]));
|
|
24553
|
+
for (const key of issue2.keys) {
|
|
24554
|
+
Reflect.deleteProperty(holder, key);
|
|
24555
|
+
}
|
|
24556
|
+
ignored.push({ path: issue2.path, keys: issue2.keys, values });
|
|
24557
|
+
}
|
|
24558
|
+
}
|
|
24559
|
+
const second = schema.safeParse(stripped);
|
|
24560
|
+
return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
|
|
24561
|
+
}
|
|
24562
|
+
function describeIgnoredKeys(filePath, ignored) {
|
|
24563
|
+
const places = ignored.map(({ path: path61, keys }) => `${path61.length === 0 ? "" : `${path61.map(String).join(".")}.`}${keys.join(", ")}`);
|
|
24564
|
+
return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
|
|
24565
|
+
}
|
|
24566
|
+
function noteIgnoredKeys(filePath, ignored) {
|
|
24567
|
+
if (ignored.length === 0) {
|
|
24568
|
+
ignoredByFile.delete(filePath);
|
|
24569
|
+
return;
|
|
24570
|
+
}
|
|
24571
|
+
ignoredByFile.set(filePath, ignored);
|
|
24572
|
+
const message = `agent-shim: warning: ${describeIgnoredKeys(filePath, ignored)}
|
|
24573
|
+
`;
|
|
24574
|
+
if (!warned.has(message)) {
|
|
24575
|
+
warned.add(message);
|
|
24576
|
+
process.stderr.write(message);
|
|
24577
|
+
}
|
|
24578
|
+
}
|
|
24579
|
+
function restoreIgnoredKeys(filePath, value2) {
|
|
24580
|
+
const ignored = ignoredByFile.get(filePath);
|
|
24581
|
+
if (ignored === void 0) {
|
|
24582
|
+
return value2;
|
|
24583
|
+
}
|
|
24584
|
+
const restored = structuredClone(value2);
|
|
24585
|
+
for (const { path: path61, values } of ignored) {
|
|
24586
|
+
let holder = restored;
|
|
24587
|
+
for (const step2 of path61) {
|
|
24588
|
+
holder = isRecord(holder) ? holder[step2] : void 0;
|
|
24589
|
+
}
|
|
24590
|
+
if (isRecord(holder)) {
|
|
24591
|
+
for (const [key, held] of Object.entries(values)) {
|
|
24592
|
+
holder[key] = held;
|
|
24593
|
+
}
|
|
24594
|
+
}
|
|
24595
|
+
}
|
|
24596
|
+
return restored;
|
|
24597
|
+
}
|
|
24598
|
+
var warned, ignoredByFile;
|
|
24599
|
+
var init_unrecognisedKeys = __esm({
|
|
24600
|
+
"src/config/unrecognisedKeys.ts"() {
|
|
24601
|
+
"use strict";
|
|
24602
|
+
warned = /* @__PURE__ */ new Set();
|
|
24603
|
+
ignoredByFile = /* @__PURE__ */ new Map();
|
|
24604
|
+
}
|
|
24605
|
+
});
|
|
24606
|
+
|
|
24530
24607
|
// src/config/load.ts
|
|
24531
24608
|
function createExplorer(moduleName = "agent-shim") {
|
|
24532
24609
|
return (0, import_cosmiconfig.cosmiconfigSync)(moduleName, { searchPlaces: [] });
|
|
24533
24610
|
}
|
|
24534
|
-
function
|
|
24611
|
+
function isRecord2(value2) {
|
|
24535
24612
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
24536
24613
|
}
|
|
24537
24614
|
function captureEntryOrder(value2) {
|
|
24538
|
-
if (!
|
|
24615
|
+
if (!isRecord2(value2)) {
|
|
24539
24616
|
return [];
|
|
24540
24617
|
}
|
|
24541
24618
|
const entries = value2.entries;
|
|
24542
|
-
if (!
|
|
24619
|
+
if (!isRecord2(entries)) {
|
|
24543
24620
|
return [];
|
|
24544
24621
|
}
|
|
24545
24622
|
return Object.keys(entries);
|
|
24546
24623
|
}
|
|
24547
24624
|
function captureRuleEntryOrders(value2) {
|
|
24548
|
-
if (!
|
|
24625
|
+
if (!isRecord2(value2)) {
|
|
24549
24626
|
return [];
|
|
24550
24627
|
}
|
|
24551
24628
|
const rules = value2.rules;
|
|
@@ -24560,7 +24637,7 @@ function cosmiconfigReader(explorer = createExplorer()) {
|
|
|
24560
24637
|
try {
|
|
24561
24638
|
result = explorer.load(filepath);
|
|
24562
24639
|
} catch (error63) {
|
|
24563
|
-
const code =
|
|
24640
|
+
const code = isRecord2(error63) ? error63.code : void 0;
|
|
24564
24641
|
if (code === "ENOENT") {
|
|
24565
24642
|
return void 0;
|
|
24566
24643
|
}
|
|
@@ -24577,10 +24654,11 @@ function loadConfigFile(filepath, schema, read = cosmiconfigReader()) {
|
|
|
24577
24654
|
if (raw === void 0) {
|
|
24578
24655
|
return void 0;
|
|
24579
24656
|
}
|
|
24580
|
-
const parsed = schema
|
|
24657
|
+
const parsed = parseIgnoringUnrecognisedKeys(schema, raw);
|
|
24581
24658
|
if (!parsed.success) {
|
|
24582
|
-
throw new ConfigValidationError(filepath, parsed.
|
|
24659
|
+
throw new ConfigValidationError(filepath, parsed.issues);
|
|
24583
24660
|
}
|
|
24661
|
+
noteIgnoredKeys(filepath, parsed.ignored);
|
|
24584
24662
|
return {
|
|
24585
24663
|
filepath,
|
|
24586
24664
|
config: parsed.data,
|
|
@@ -24594,6 +24672,7 @@ var init_load = __esm({
|
|
|
24594
24672
|
"use strict";
|
|
24595
24673
|
import_cosmiconfig = __toESM(require_dist(), 1);
|
|
24596
24674
|
init_cliError();
|
|
24675
|
+
init_unrecognisedKeys();
|
|
24597
24676
|
ConfigValidationError = class extends CliError {
|
|
24598
24677
|
constructor(filepath, issues) {
|
|
24599
24678
|
const detail = issues.map((issue2) => ` ${issue2.path.join(".") || "(root)"}: ${issue2.message}`).join("\n");
|
|
@@ -24619,10 +24698,11 @@ function readJson(filePath, schema, storeFs = nodeStoreFs) {
|
|
|
24619
24698
|
return void 0;
|
|
24620
24699
|
}
|
|
24621
24700
|
const parsed = JSON.parse(raw);
|
|
24622
|
-
const result = schema
|
|
24701
|
+
const result = parseIgnoringUnrecognisedKeys(schema, parsed);
|
|
24623
24702
|
if (!result.success) {
|
|
24624
|
-
throw new ConfigValidationError(filePath, result.
|
|
24703
|
+
throw new ConfigValidationError(filePath, result.issues);
|
|
24625
24704
|
}
|
|
24705
|
+
noteIgnoredKeys(filePath, result.ignored);
|
|
24626
24706
|
return result.data;
|
|
24627
24707
|
}
|
|
24628
24708
|
function writeTextAtomic(filePath, contents, storeFs = nodeStoreFs) {
|
|
@@ -24638,7 +24718,7 @@ function writeTextAtomic(filePath, contents, storeFs = nodeStoreFs) {
|
|
|
24638
24718
|
}
|
|
24639
24719
|
}
|
|
24640
24720
|
function writeJsonAtomic(filePath, data, storeFs = nodeStoreFs) {
|
|
24641
|
-
writeTextAtomic(filePath, `${JSON.stringify(data, null, 2)}
|
|
24721
|
+
writeTextAtomic(filePath, `${JSON.stringify(restoreIgnoredKeys(filePath, data), null, 2)}
|
|
24642
24722
|
`, storeFs);
|
|
24643
24723
|
}
|
|
24644
24724
|
function applyPatch(filePath, schema, patch, options = {}) {
|
|
@@ -24664,6 +24744,7 @@ var init_store = __esm({
|
|
|
24664
24744
|
import_node_path2 = __toESM(require("node:path"), 1);
|
|
24665
24745
|
import_node_crypto = require("node:crypto");
|
|
24666
24746
|
init_load();
|
|
24747
|
+
init_unrecognisedKeys();
|
|
24667
24748
|
nodeStoreFs = {
|
|
24668
24749
|
readFileUtf8(filePath) {
|
|
24669
24750
|
try {
|
|
@@ -33966,7 +34047,7 @@ function formatCredentialSummary(summary) {
|
|
|
33966
34047
|
function describeCredential(credential) {
|
|
33967
34048
|
return formatCredentialSummary(summariseCredential(credential));
|
|
33968
34049
|
}
|
|
33969
|
-
function
|
|
34050
|
+
function isRecord3(value2) {
|
|
33970
34051
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
33971
34052
|
}
|
|
33972
34053
|
function unpackKeyringToken(raw) {
|
|
@@ -33978,7 +34059,7 @@ function unpackKeyringToken(raw) {
|
|
|
33978
34059
|
const base64Str = trimmed.slice(GO_KEYRING_BASE64_PREFIX.length);
|
|
33979
34060
|
const decoded = Buffer.from(base64Str, "base64").toString("utf8");
|
|
33980
34061
|
const parsed = JSON.parse(decoded);
|
|
33981
|
-
if (
|
|
34062
|
+
if (isRecord3(parsed) && isRecord3(parsed.token)) {
|
|
33982
34063
|
const accessToken = parsed.token.access_token;
|
|
33983
34064
|
if (typeof accessToken === "string" && accessToken.trim() !== "") {
|
|
33984
34065
|
return accessToken.trim();
|
|
@@ -34091,7 +34172,7 @@ var init_package = __esm({
|
|
|
34091
34172
|
"package.json"() {
|
|
34092
34173
|
package_default = {
|
|
34093
34174
|
name: "claude-use",
|
|
34094
|
-
version: "11.
|
|
34175
|
+
version: "11.19.1",
|
|
34095
34176
|
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.",
|
|
34096
34177
|
license: "MIT",
|
|
34097
34178
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -35666,14 +35747,14 @@ function providerJsonPath(paths, name) {
|
|
|
35666
35747
|
function providerExists(paths, name) {
|
|
35667
35748
|
return import_node_fs10.default.existsSync(providerJsonPath(paths, name));
|
|
35668
35749
|
}
|
|
35669
|
-
function
|
|
35750
|
+
function isRecord4(value2) {
|
|
35670
35751
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
35671
35752
|
}
|
|
35672
35753
|
function legacyProviderConversion(raw) {
|
|
35673
|
-
if (!
|
|
35754
|
+
if (!isRecord4(raw) || "credential" in raw) {
|
|
35674
35755
|
return void 0;
|
|
35675
35756
|
}
|
|
35676
|
-
const env =
|
|
35757
|
+
const env = isRecord4(raw.env) ? raw.env : void 0;
|
|
35677
35758
|
const legacyEnvKeys = env === void 0 ? [] : Object.keys(env).filter((key) => LEGACY_ENV_CREDENTIAL_KEYS.includes(key));
|
|
35678
35759
|
const fields = [...LEGACY_PROVIDER_FIELDS.filter((field) => field in raw), ...legacyEnvKeys.map((key) => `env.${key}`)];
|
|
35679
35760
|
if (fields.length === 0) {
|
|
@@ -35706,10 +35787,11 @@ function parseProviderFile(filePath, raw) {
|
|
|
35706
35787
|
if (conversion !== void 0) {
|
|
35707
35788
|
throw new LegacyProviderFileError(filePath, conversion);
|
|
35708
35789
|
}
|
|
35709
|
-
const parsed = ProviderSchema
|
|
35790
|
+
const parsed = parseIgnoringUnrecognisedKeys(ProviderSchema, raw);
|
|
35710
35791
|
if (!parsed.success) {
|
|
35711
|
-
throw new ConfigValidationError(filePath, parsed.
|
|
35792
|
+
throw new ConfigValidationError(filePath, parsed.issues);
|
|
35712
35793
|
}
|
|
35794
|
+
noteIgnoredKeys(filePath, parsed.ignored);
|
|
35713
35795
|
return parsed.data;
|
|
35714
35796
|
}
|
|
35715
35797
|
function readProvider(paths, name) {
|
|
@@ -35919,6 +36001,7 @@ var init_providersStore = __esm({
|
|
|
35919
36001
|
import_node_path29 = __toESM(require("node:path"), 1);
|
|
35920
36002
|
init_load();
|
|
35921
36003
|
init_store();
|
|
36004
|
+
init_unrecognisedKeys();
|
|
35922
36005
|
init_schema();
|
|
35923
36006
|
init_cliError();
|
|
35924
36007
|
init_credential();
|
|
@@ -63129,7 +63212,7 @@ function resolvePoolLaunch(params) {
|
|
|
63129
63212
|
if (stickyRead.problem !== void 0) {
|
|
63130
63213
|
log.warn(`agent-shim: ${stickyRead.problem}; ignoring the last-pick record`);
|
|
63131
63214
|
}
|
|
63132
|
-
const
|
|
63215
|
+
const warned2 = /* @__PURE__ */ new Set();
|
|
63133
63216
|
for (; ; ) {
|
|
63134
63217
|
const nowMs = params.now();
|
|
63135
63218
|
let graph;
|
|
@@ -63153,8 +63236,8 @@ function resolvePoolLaunch(params) {
|
|
|
63153
63236
|
}
|
|
63154
63237
|
for (const gone of graph.missing) {
|
|
63155
63238
|
const key = `${gone.pool}:${gone.identity}`;
|
|
63156
|
-
if (!
|
|
63157
|
-
|
|
63239
|
+
if (!warned2.has(key)) {
|
|
63240
|
+
warned2.add(key);
|
|
63158
63241
|
log.warn(`agent-shim: pool "${gone.pool}" names identity "${gone.identity}", which does not exist; skipping it`);
|
|
63159
63242
|
}
|
|
63160
63243
|
}
|
|
@@ -64036,11 +64119,11 @@ function buildCloudRequestBody(params) {
|
|
|
64036
64119
|
}
|
|
64037
64120
|
return JSON.stringify(params.request);
|
|
64038
64121
|
}
|
|
64039
|
-
function
|
|
64122
|
+
function isRecord5(value2) {
|
|
64040
64123
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
64041
64124
|
}
|
|
64042
64125
|
function isGeminiChunk(value2) {
|
|
64043
|
-
return
|
|
64126
|
+
return isRecord5(value2);
|
|
64044
64127
|
}
|
|
64045
64128
|
async function* callCloudAntigravity(params, fetchFn = fetch) {
|
|
64046
64129
|
const url2 = buildCloudUrl(params.config, params.model);
|
|
@@ -64075,8 +64158,8 @@ async function* callCloudAntigravity(params, fetchFn = fetch) {
|
|
|
64075
64158
|
if (jsonStr.length > 0) {
|
|
64076
64159
|
try {
|
|
64077
64160
|
const parsed = JSON.parse(jsonStr);
|
|
64078
|
-
if (
|
|
64079
|
-
const unwrapped =
|
|
64161
|
+
if (isRecord5(parsed)) {
|
|
64162
|
+
const unwrapped = isRecord5(parsed.response) ? parsed.response : parsed;
|
|
64080
64163
|
if (isGeminiChunk(unwrapped)) {
|
|
64081
64164
|
yield unwrapped;
|
|
64082
64165
|
}
|
|
@@ -109963,7 +110046,13 @@ function validateMembers(pools, name, members2) {
|
|
|
109963
110046
|
throw new UsageError(`Member "pool:${cycle[1] ?? name}" would make pool "${name}" reach itself: ${cycle.join(" -> ")}. A pool cannot nest itself, directly or through another pool.`);
|
|
109964
110047
|
}
|
|
109965
110048
|
}
|
|
109966
|
-
function
|
|
110049
|
+
function poolPolicyOf(policy) {
|
|
110050
|
+
return { ...policy.preference === void 0 ? {} : { preference: policy.preference } };
|
|
110051
|
+
}
|
|
110052
|
+
function isPoolChange(change) {
|
|
110053
|
+
return change.identities !== void 0 || change.preference !== void 0;
|
|
110054
|
+
}
|
|
110055
|
+
function addPool(paths, name, identities, policy = {}) {
|
|
109967
110056
|
if (!PoolNameSchema.safeParse(name).success) {
|
|
109968
110057
|
throw new InvalidPoolNameError(name);
|
|
109969
110058
|
}
|
|
@@ -109972,14 +110061,16 @@ function addPool(paths, name, identities, preference) {
|
|
|
109972
110061
|
throw new PoolAlreadyExistsError(name);
|
|
109973
110062
|
}
|
|
109974
110063
|
validateMembers(pools, name, identities);
|
|
109975
|
-
const pool = { identities: [...identities], ...
|
|
110064
|
+
const pool = { identities: [...identities], ...poolPolicyOf(policy) };
|
|
109976
110065
|
writePools(paths, { ...pools, [name]: pool });
|
|
109977
110066
|
return pool;
|
|
109978
110067
|
}
|
|
109979
|
-
function
|
|
109980
|
-
requirePool(paths, name);
|
|
110068
|
+
function changePool(paths, name, change) {
|
|
110069
|
+
const existing = requirePool(paths, name);
|
|
110070
|
+
const identities = change.identities ?? existing.identities;
|
|
109981
110071
|
validateMembers(readPools(paths), name, identities);
|
|
109982
|
-
const
|
|
110072
|
+
const preference = change.preference === void 0 ? existing.preference : change.preference === false ? void 0 : change.preference;
|
|
110073
|
+
const pool = { identities: [...identities], ...poolPolicyOf({ preference }) };
|
|
109983
110074
|
writePools(paths, { ...readPools(paths), [name]: pool });
|
|
109984
110075
|
return pool;
|
|
109985
110076
|
}
|
|
@@ -115102,7 +115193,7 @@ var LiveTaskSchema = external_exports.strictObject({
|
|
|
115102
115193
|
observedAt: external_exports.number()
|
|
115103
115194
|
});
|
|
115104
115195
|
var SYSTEM_SUBTYPES = ["task_started", "task_progress", "task_updated", "task_notification", "background_tasks_changed"];
|
|
115105
|
-
function
|
|
115196
|
+
function isRecord6(value2) {
|
|
115106
115197
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
115107
115198
|
}
|
|
115108
115199
|
function stringField(record2, field) {
|
|
@@ -115119,7 +115210,7 @@ function booleanField(record2, field) {
|
|
|
115119
115210
|
}
|
|
115120
115211
|
function usageOf(record2) {
|
|
115121
115212
|
const raw = record2.usage;
|
|
115122
|
-
if (!
|
|
115213
|
+
if (!isRecord6(raw)) {
|
|
115123
115214
|
return void 0;
|
|
115124
115215
|
}
|
|
115125
115216
|
const totalTokens = numberField(raw, "total_tokens");
|
|
@@ -115151,7 +115242,7 @@ function bounded(book) {
|
|
|
115151
115242
|
return book;
|
|
115152
115243
|
}
|
|
115153
115244
|
function applyAgentTaskEvent(book, sessionId, payload, observedAt2) {
|
|
115154
|
-
if (!
|
|
115245
|
+
if (!isRecord6(payload) || payload.type !== "system") {
|
|
115155
115246
|
return book;
|
|
115156
115247
|
}
|
|
115157
115248
|
const subtype = payload.subtype;
|
|
@@ -115167,8 +115258,8 @@ function applyAgentTaskEvent(book, sessionId, payload, observedAt2) {
|
|
|
115167
115258
|
if (subtype === "background_tasks_changed") {
|
|
115168
115259
|
const tasks = Array.isArray(payload.tasks) ? payload.tasks : [];
|
|
115169
115260
|
for (const raw of tasks) {
|
|
115170
|
-
const taskId2 =
|
|
115171
|
-
if (
|
|
115261
|
+
const taskId2 = isRecord6(raw) ? stringField(raw, "task_id") : void 0;
|
|
115262
|
+
if (isRecord6(raw) && taskId2 !== void 0) {
|
|
115172
115263
|
upsert(taskId2, { runId: stringField(raw, "run_id"), taskType: stringField(raw, "task_type"), description: stringField(raw, "description") });
|
|
115173
115264
|
}
|
|
115174
115265
|
}
|
|
@@ -115191,7 +115282,7 @@ function applyAgentTaskEvent(book, sessionId, payload, observedAt2) {
|
|
|
115191
115282
|
} else if (subtype === "task_progress") {
|
|
115192
115283
|
upsert(taskId, { ...common, subagentType: stringField(payload, "subagent_type"), lastToolName: stringField(payload, "last_tool_name"), usage: usageOf(payload) });
|
|
115193
115284
|
} else if (subtype === "task_updated") {
|
|
115194
|
-
const patch =
|
|
115285
|
+
const patch = isRecord6(payload.patch) ? payload.patch : {};
|
|
115195
115286
|
upsert(taskId, { runId: stringField(payload, "run_id"), status: stringField(patch, "status") });
|
|
115196
115287
|
} else {
|
|
115197
115288
|
upsert(taskId, { ...common, status: stringField(payload, "status"), outputFile: stringField(payload, "output_file"), summary: stringField(payload, "summary"), usage: usageOf(payload) });
|
|
@@ -115273,7 +115364,7 @@ function sessionCreateId(body) {
|
|
|
115273
115364
|
const id2 = session.id;
|
|
115274
115365
|
return typeof id2 === "string" && id2.startsWith(RC_SESSION_ID_PREFIX) ? id2 : void 0;
|
|
115275
115366
|
}
|
|
115276
|
-
function
|
|
115367
|
+
function isRecord7(value2) {
|
|
115277
115368
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
115278
115369
|
}
|
|
115279
115370
|
function parseJsonObject(body) {
|
|
@@ -115283,7 +115374,7 @@ function parseJsonObject(body) {
|
|
|
115283
115374
|
} catch {
|
|
115284
115375
|
return void 0;
|
|
115285
115376
|
}
|
|
115286
|
-
return
|
|
115377
|
+
return isRecord7(parsed) ? parsed : void 0;
|
|
115287
115378
|
}
|
|
115288
115379
|
function nonEmptyString(record2, field) {
|
|
115289
115380
|
const value2 = record2 === void 0 ? void 0 : record2[field];
|
|
@@ -115304,11 +115395,11 @@ function payloadEventsOf(body) {
|
|
|
115304
115395
|
}
|
|
115305
115396
|
const payloads = [];
|
|
115306
115397
|
for (const event of events) {
|
|
115307
|
-
if (!
|
|
115398
|
+
if (!isRecord7(event)) {
|
|
115308
115399
|
continue;
|
|
115309
115400
|
}
|
|
115310
115401
|
const payload = event.payload;
|
|
115311
|
-
if (!
|
|
115402
|
+
if (!isRecord7(payload)) {
|
|
115312
115403
|
continue;
|
|
115313
115404
|
}
|
|
115314
115405
|
payloads.push(payload);
|
|
@@ -115323,7 +115414,7 @@ function pendingOfControlRequestPayload(payload) {
|
|
|
115323
115414
|
if (requestId === void 0) {
|
|
115324
115415
|
return void 0;
|
|
115325
115416
|
}
|
|
115326
|
-
const request7 =
|
|
115417
|
+
const request7 = isRecord7(payload.request) ? payload.request : void 0;
|
|
115327
115418
|
const subtype = nonEmptyString(request7, "subtype");
|
|
115328
115419
|
const type2 = subtype ?? "control_request";
|
|
115329
115420
|
let summary = "";
|
|
@@ -115340,7 +115431,7 @@ function answeredRequestIdsOfControlResponsePayload(payload) {
|
|
|
115340
115431
|
if (payload.type !== "control_response") {
|
|
115341
115432
|
return [];
|
|
115342
115433
|
}
|
|
115343
|
-
const response =
|
|
115434
|
+
const response = isRecord7(payload.response) ? payload.response : void 0;
|
|
115344
115435
|
const id2 = nonEmptyString(response, "request_id") ?? nonEmptyString(payload, "request_id") ?? nonEmptyString(payload, "uuid");
|
|
115345
115436
|
return id2 === void 0 ? [] : [id2];
|
|
115346
115437
|
}
|
|
@@ -115569,7 +115660,7 @@ function createRcSessionTracker(deps) {
|
|
|
115569
115660
|
return;
|
|
115570
115661
|
}
|
|
115571
115662
|
entry.sequenceNum = entry.sequenceNum === void 0 || event.sequence_num > entry.sequenceNum ? event.sequence_num : entry.sequenceNum;
|
|
115572
|
-
if (!
|
|
115663
|
+
if (!isRecord7(event.payload)) {
|
|
115573
115664
|
return;
|
|
115574
115665
|
}
|
|
115575
115666
|
entry.liveTasks = applyAgentTaskEvent(entry.liveTasks, sessionId, event.payload, deps.now());
|
|
@@ -117143,6 +117234,7 @@ function identitySignIn(fs24, probe, identity) {
|
|
|
117143
117234
|
|
|
117144
117235
|
// src/doctorReport.ts
|
|
117145
117236
|
init_load();
|
|
117237
|
+
init_unrecognisedKeys();
|
|
117146
117238
|
init_schema();
|
|
117147
117239
|
init_credential();
|
|
117148
117240
|
init_credentialCache();
|
|
@@ -117353,11 +117445,11 @@ function validateJson(schema, input2) {
|
|
|
117353
117445
|
} catch (error63) {
|
|
117354
117446
|
return { ok: false, message: `${input2.path} is not valid JSON: ${error63 instanceof Error ? error63.message : String(error63)}` };
|
|
117355
117447
|
}
|
|
117356
|
-
const result = schema
|
|
117448
|
+
const result = parseIgnoringUnrecognisedKeys(schema, parsed);
|
|
117357
117449
|
if (!result.success) {
|
|
117358
|
-
return { ok: false, message: new ConfigValidationError(input2.path, result.
|
|
117450
|
+
return { ok: false, message: new ConfigValidationError(input2.path, result.issues).message };
|
|
117359
117451
|
}
|
|
117360
|
-
return { ok: true, data: result.data };
|
|
117452
|
+
return { ok: true, data: result.data, ...result.ignored.length === 0 ? {} : { warning: describeIgnoredKeys(input2.path, result.ignored) } };
|
|
117361
117453
|
}
|
|
117362
117454
|
function tcpPortEraRecord(raw) {
|
|
117363
117455
|
let parsed;
|
|
@@ -117450,11 +117542,14 @@ function pushProvider(push, entry, cacheEnv, signIn) {
|
|
|
117450
117542
|
push("provider", "fail", new LegacyProviderFileError(entry.path, conversion).message, entry.name);
|
|
117451
117543
|
return;
|
|
117452
117544
|
}
|
|
117453
|
-
const validated2 = ProviderSchema
|
|
117545
|
+
const validated2 = parseIgnoringUnrecognisedKeys(ProviderSchema, parsed);
|
|
117454
117546
|
if (!validated2.success) {
|
|
117455
|
-
push("provider", "fail", new ConfigValidationError(entry.path, validated2.
|
|
117547
|
+
push("provider", "fail", new ConfigValidationError(entry.path, validated2.issues).message, entry.name);
|
|
117456
117548
|
return;
|
|
117457
117549
|
}
|
|
117550
|
+
if (validated2.ignored.length > 0) {
|
|
117551
|
+
push("provider", "warn", describeIgnoredKeys(entry.path, validated2.ignored), entry.name);
|
|
117552
|
+
}
|
|
117458
117553
|
const cache = cacheClause(cacheEnv, `provider ${entry.name}`, validated2.data.credential);
|
|
117459
117554
|
push("provider", cache.unreadable ? "fail" : "pass", `${entry.name} is valid (${describeProviderEndpoint(validated2.data)}, credential ${describeCredential(validated2.data.credential)})${cache.text}.`, entry.name);
|
|
117460
117555
|
if (validated2.data.env?.ENABLE_TOOL_SEARCH === void 0) {
|
|
@@ -117489,6 +117584,13 @@ function runDoctor(params) {
|
|
|
117489
117584
|
const push = (section, severity, message, subject) => {
|
|
117490
117585
|
findings.push({ section, severity, message, ...subject === void 0 ? {} : { subject } });
|
|
117491
117586
|
};
|
|
117587
|
+
const validate2 = (schema, input2, section, subject) => {
|
|
117588
|
+
const validated2 = validateJson(schema, input2);
|
|
117589
|
+
if (validated2.ok && validated2.warning !== void 0) {
|
|
117590
|
+
push(section, "warn", validated2.warning, subject);
|
|
117591
|
+
}
|
|
117592
|
+
return validated2;
|
|
117593
|
+
};
|
|
117492
117594
|
const checkPin = (section, subject, where, version2) => {
|
|
117493
117595
|
const installed = params.installedClaudeVersions;
|
|
117494
117596
|
if (version2 === void 0 || installed === void 0 || installed.includes(version2)) {
|
|
@@ -117528,7 +117630,7 @@ function runDoctor(params) {
|
|
|
117528
117630
|
pushLegacyName(push, params);
|
|
117529
117631
|
const profileSources = /* @__PURE__ */ new Map();
|
|
117530
117632
|
for (const entry of params.configProfiles) {
|
|
117531
|
-
const validated2 =
|
|
117633
|
+
const validated2 = validate2(ConfigProfileSchema, entry, "config-profile", entry.name);
|
|
117532
117634
|
if (!validated2.ok) {
|
|
117533
117635
|
push("config-profile", "fail", validated2.message, entry.name);
|
|
117534
117636
|
continue;
|
|
@@ -117550,7 +117652,7 @@ function runDoctor(params) {
|
|
|
117550
117652
|
const validProfileNames = new Set(profileSources.keys());
|
|
117551
117653
|
const validIdentityNames = /* @__PURE__ */ new Set();
|
|
117552
117654
|
for (const entry of params.identities) {
|
|
117553
|
-
const validated2 =
|
|
117655
|
+
const validated2 = validate2(IdentitySchema, entry, "identity", entry.name);
|
|
117554
117656
|
if (!validated2.ok) {
|
|
117555
117657
|
push("identity", "fail", validated2.message, entry.name);
|
|
117556
117658
|
continue;
|
|
@@ -117636,7 +117738,7 @@ function runDoctor(params) {
|
|
|
117636
117738
|
if (params.directoryRules.raw === void 0) {
|
|
117637
117739
|
push("directory-rules", "pass", "No directory-rules.json configured.");
|
|
117638
117740
|
} else {
|
|
117639
|
-
const validated2 =
|
|
117741
|
+
const validated2 = validate2(DirectoryRulesSchema, params.directoryRules, "directory-rules");
|
|
117640
117742
|
if (!validated2.ok) {
|
|
117641
117743
|
push("directory-rules", "fail", validated2.message);
|
|
117642
117744
|
} else {
|
|
@@ -117661,7 +117763,7 @@ function runDoctor(params) {
|
|
|
117661
117763
|
if (params.globalConfig.raw === void 0) {
|
|
117662
117764
|
push("global-config", "pass", "No config.json configured.");
|
|
117663
117765
|
} else {
|
|
117664
|
-
const validated2 =
|
|
117766
|
+
const validated2 = validate2(GlobalConfigSchema, params.globalConfig, "global-config");
|
|
117665
117767
|
if (!validated2.ok) {
|
|
117666
117768
|
push("global-config", "fail", validated2.message);
|
|
117667
117769
|
} else {
|
|
@@ -117681,7 +117783,7 @@ function runDoctor(params) {
|
|
|
117681
117783
|
if (params.categoriesLocal.raw === void 0) {
|
|
117682
117784
|
push("categories-local", "pass", "No categories.local.json configured.");
|
|
117683
117785
|
} else {
|
|
117684
|
-
const validated2 =
|
|
117786
|
+
const validated2 = validate2(CategoryClassificationOverlaySchema, params.categoriesLocal, "categories-local");
|
|
117685
117787
|
push(
|
|
117686
117788
|
"categories-local",
|
|
117687
117789
|
validated2.ok ? "pass" : "fail",
|
|
@@ -120447,7 +120549,7 @@ var HTTP_METHODS_UP_TO_V31 = [
|
|
|
120447
120549
|
function operationFields(convert) {
|
|
120448
120550
|
return Object.fromEntries(HTTP_METHODS_UP_TO_V31.map((method) => [method, convert]));
|
|
120449
120551
|
}
|
|
120450
|
-
function
|
|
120552
|
+
function isRecord8(value2) {
|
|
120451
120553
|
if (typeof value2 !== "object" || value2 === null) {
|
|
120452
120554
|
return false;
|
|
120453
120555
|
}
|
|
@@ -120467,7 +120569,7 @@ function setOwn2(object3, key, value2) {
|
|
|
120467
120569
|
}
|
|
120468
120570
|
}
|
|
120469
120571
|
function cloneValue(value2, seen) {
|
|
120470
|
-
if (!(Array.isArray(value2) ||
|
|
120572
|
+
if (!(Array.isArray(value2) || isRecord8(value2))) {
|
|
120471
120573
|
return value2;
|
|
120472
120574
|
}
|
|
120473
120575
|
const existing = seen.get(value2);
|
|
@@ -120490,14 +120592,14 @@ function cloneValue(value2, seen) {
|
|
|
120490
120592
|
return out;
|
|
120491
120593
|
}
|
|
120492
120594
|
function deepClone(value2) {
|
|
120493
|
-
if (!(Array.isArray(value2) ||
|
|
120595
|
+
if (!(Array.isArray(value2) || isRecord8(value2))) {
|
|
120494
120596
|
return value2;
|
|
120495
120597
|
}
|
|
120496
120598
|
return cloneValue(value2, /* @__PURE__ */ new WeakMap());
|
|
120497
120599
|
}
|
|
120498
120600
|
var converting = /* @__PURE__ */ new WeakMap();
|
|
120499
120601
|
function convertRecord(value2, fields, finish) {
|
|
120500
|
-
if (!
|
|
120602
|
+
if (!isRecord8(value2)) {
|
|
120501
120603
|
return deepClone(value2);
|
|
120502
120604
|
}
|
|
120503
120605
|
const inProgress = converting.get(value2);
|
|
@@ -120523,7 +120625,7 @@ function convertRecord(value2, fields, finish) {
|
|
|
120523
120625
|
}
|
|
120524
120626
|
}
|
|
120525
120627
|
function mapRecord(value2, convert) {
|
|
120526
|
-
if (!
|
|
120628
|
+
if (!isRecord8(value2)) {
|
|
120527
120629
|
return deepClone(value2);
|
|
120528
120630
|
}
|
|
120529
120631
|
const out = {};
|
|
@@ -120542,7 +120644,7 @@ function mapArray(value2, convert) {
|
|
|
120542
120644
|
return value2.map((item) => convert(item)).filter((item) => item !== DROP);
|
|
120543
120645
|
}
|
|
120544
120646
|
function getRef(value2) {
|
|
120545
|
-
if (
|
|
120647
|
+
if (isRecord8(value2) && typeof value2.$ref === "string") {
|
|
120546
120648
|
return value2.$ref;
|
|
120547
120649
|
}
|
|
120548
120650
|
return void 0;
|
|
@@ -120748,7 +120850,7 @@ function convertSchema2(schema) {
|
|
|
120748
120850
|
if (schema === false) {
|
|
120749
120851
|
return { not: {} };
|
|
120750
120852
|
}
|
|
120751
|
-
if (
|
|
120853
|
+
if (isRecord8(schema) && typeof schema.$ref === "string" && Object.keys(schema).length === 1) {
|
|
120752
120854
|
return { $ref: schema.$ref };
|
|
120753
120855
|
}
|
|
120754
120856
|
return convertRecord(schema, SCHEMA_FIELDS, finishSchema);
|
|
@@ -120760,7 +120862,7 @@ function resolveSchemeType(name, schemes, seen) {
|
|
|
120760
120862
|
return void 0;
|
|
120761
120863
|
}
|
|
120762
120864
|
const scheme = schemes[name];
|
|
120763
|
-
if (!
|
|
120865
|
+
if (!isRecord8(scheme)) {
|
|
120764
120866
|
return void 0;
|
|
120765
120867
|
}
|
|
120766
120868
|
if (typeof scheme.type === "string") {
|
|
@@ -120777,11 +120879,11 @@ function resolveSchemeType(name, schemes, seen) {
|
|
|
120777
120879
|
return void 0;
|
|
120778
120880
|
}
|
|
120779
120881
|
function createContext(spec) {
|
|
120780
|
-
const components =
|
|
120781
|
-
const pathItems =
|
|
120782
|
-
const schemes =
|
|
120882
|
+
const components = isRecord8(spec) ? spec.components : void 0;
|
|
120883
|
+
const pathItems = isRecord8(components) ? components.pathItems : void 0;
|
|
120884
|
+
const schemes = isRecord8(components) ? components.securitySchemes : void 0;
|
|
120783
120885
|
const schemeTypes = /* @__PURE__ */ new Map();
|
|
120784
|
-
if (
|
|
120886
|
+
if (isRecord8(schemes)) {
|
|
120785
120887
|
for (const name of Object.keys(schemes)) {
|
|
120786
120888
|
const type2 = resolveSchemeType(name, schemes, /* @__PURE__ */ new Set());
|
|
120787
120889
|
if (type2 !== void 0) {
|
|
@@ -120791,7 +120893,7 @@ function createContext(spec) {
|
|
|
120791
120893
|
}
|
|
120792
120894
|
return {
|
|
120793
120895
|
inlining: /* @__PURE__ */ new Set(),
|
|
120794
|
-
pathItems:
|
|
120896
|
+
pathItems: isRecord8(pathItems) ? pathItems : void 0,
|
|
120795
120897
|
schemeTypes
|
|
120796
120898
|
};
|
|
120797
120899
|
}
|
|
@@ -120799,7 +120901,7 @@ function isMutualTls(name, context) {
|
|
|
120799
120901
|
return context.schemeTypes.get(name) === "mutualTLS";
|
|
120800
120902
|
}
|
|
120801
120903
|
function convertRequirement(value2, context) {
|
|
120802
|
-
if (!
|
|
120904
|
+
if (!isRecord8(value2)) {
|
|
120803
120905
|
return deepClone(value2);
|
|
120804
120906
|
}
|
|
120805
120907
|
const entries = Object.entries(value2);
|
|
@@ -120899,10 +121001,10 @@ function resolvePathItemRef(value2, context) {
|
|
|
120899
121001
|
return void 0;
|
|
120900
121002
|
}
|
|
120901
121003
|
const target = context.pathItems[name];
|
|
120902
|
-
return
|
|
121004
|
+
return isRecord8(target) ? [name, target] : void 0;
|
|
120903
121005
|
}
|
|
120904
121006
|
function convertPathItem(value2, context) {
|
|
120905
|
-
if (!
|
|
121007
|
+
if (!isRecord8(value2)) {
|
|
120906
121008
|
return deepClone(value2);
|
|
120907
121009
|
}
|
|
120908
121010
|
const resolved = resolvePathItemRef(value2, context);
|
|
@@ -121002,7 +121104,7 @@ function convertExample(value2) {
|
|
|
121002
121104
|
});
|
|
121003
121105
|
}
|
|
121004
121106
|
function isQuerystringParameter(value2) {
|
|
121005
|
-
return
|
|
121107
|
+
return isRecord8(value2) && value2.in === "querystring";
|
|
121006
121108
|
}
|
|
121007
121109
|
function isRemovedRef(value2, removed) {
|
|
121008
121110
|
const ref = getRef(value2);
|
|
@@ -121018,7 +121120,7 @@ function convertParameterOrHeader2(value2, context) {
|
|
|
121018
121120
|
style: (item) => item === "cookie" ? DROP : deepClone(item)
|
|
121019
121121
|
},
|
|
121020
121122
|
(out, parameter) => {
|
|
121021
|
-
const lostContent =
|
|
121123
|
+
const lostContent = isRecord8(parameter.content) && Object.keys(parameter.content).length > 0 && isRecord8(out.content) && Object.keys(out.content).length === 0;
|
|
121022
121124
|
return lostContent ? DROP : out;
|
|
121023
121125
|
}
|
|
121024
121126
|
);
|
|
@@ -121139,7 +121241,7 @@ function convertComponents2(value2, context) {
|
|
|
121139
121241
|
});
|
|
121140
121242
|
}
|
|
121141
121243
|
function losesEntireContent(value2, mediaTypes) {
|
|
121142
|
-
if (!(
|
|
121244
|
+
if (!(isRecord8(value2) && isRecord8(value2.content))) {
|
|
121143
121245
|
return false;
|
|
121144
121246
|
}
|
|
121145
121247
|
const entries = Object.values(value2.content);
|
|
@@ -121147,7 +121249,7 @@ function losesEntireContent(value2, mediaTypes) {
|
|
|
121147
121249
|
}
|
|
121148
121250
|
function indexRemovedComponentRefs(map2, prefix, mediaTypes, isDirectlyRemoved) {
|
|
121149
121251
|
const removed = /* @__PURE__ */ new Set();
|
|
121150
|
-
if (!
|
|
121252
|
+
if (!isRecord8(map2)) {
|
|
121151
121253
|
return removed;
|
|
121152
121254
|
}
|
|
121153
121255
|
const entries = Object.entries(map2);
|
|
@@ -121169,12 +121271,12 @@ function indexRemovedComponentRefs(map2, prefix, mediaTypes, isDirectlyRemoved)
|
|
|
121169
121271
|
return removed;
|
|
121170
121272
|
}
|
|
121171
121273
|
function createContext2(spec) {
|
|
121172
|
-
const components =
|
|
121173
|
-
const mediaTypes =
|
|
121274
|
+
const components = isRecord8(spec) ? spec.components : void 0;
|
|
121275
|
+
const mediaTypes = isRecord8(components) && isRecord8(components.mediaTypes) ? components.mediaTypes : void 0;
|
|
121174
121276
|
return {
|
|
121175
121277
|
mediaTypes,
|
|
121176
|
-
removedHeaderRefs: indexRemovedComponentRefs(
|
|
121177
|
-
removedParameterRefs: indexRemovedComponentRefs(
|
|
121278
|
+
removedHeaderRefs: indexRemovedComponentRefs(isRecord8(components) ? components.headers : void 0, HEADERS_REF_PREFIX, mediaTypes, () => false),
|
|
121279
|
+
removedParameterRefs: indexRemovedComponentRefs(isRecord8(components) ? components.parameters : void 0, PARAMETERS_REF_PREFIX, mediaTypes, isQuerystringParameter)
|
|
121178
121280
|
};
|
|
121179
121281
|
}
|
|
121180
121282
|
function convertJsonSchemaDialect(value2) {
|
|
@@ -126249,20 +126351,19 @@ function createConfigApiRouter(deps) {
|
|
|
126249
126351
|
add: route("/rest/config/pool/add", "Define a pool").input(ConfigPoolAddInputSchema).output(ConfigPoolAddOutputSchema).handler(
|
|
126250
126352
|
({ input: input2 }) => guarded(() => {
|
|
126251
126353
|
requireIdentityNames(paths, input2.identities);
|
|
126252
|
-
const created = addPool(paths, input2.name, input2.identities, input2.preference);
|
|
126354
|
+
const created = addPool(paths, input2.name, input2.identities, { preference: input2.preference });
|
|
126253
126355
|
return { action: "created", kind: "pool", name: input2.name, value: created };
|
|
126254
126356
|
})
|
|
126255
126357
|
),
|
|
126256
126358
|
set: route("/rest/config/pool/set", "Replace a pool's members, its preference or both").input(ConfigPoolSetInputSchema).output(ConfigPoolSetOutputSchema).handler(
|
|
126257
126359
|
({ input: input2 }) => guarded(() => {
|
|
126258
|
-
|
|
126259
|
-
|
|
126360
|
+
const change = { identities: input2.identities, preference: input2.preference };
|
|
126361
|
+
requireChange(isPoolChange(change), "identities or preference");
|
|
126362
|
+
requirePool(paths, input2.name);
|
|
126260
126363
|
if (input2.identities !== void 0) {
|
|
126261
126364
|
requireIdentityNames(paths, input2.identities);
|
|
126262
126365
|
}
|
|
126263
|
-
|
|
126264
|
-
const preference = input2.preference === void 0 ? existing.preference : input2.preference === false ? void 0 : input2.preference;
|
|
126265
|
-
return { action: "updated", kind: "pool", name: input2.name, value: setPool(paths, input2.name, members2, preference) };
|
|
126366
|
+
return { action: "updated", kind: "pool", name: input2.name, value: changePool(paths, input2.name, change) };
|
|
126266
126367
|
})
|
|
126267
126368
|
),
|
|
126268
126369
|
remove: route("/rest/config/pool/remove", "Delete a pool").input(ConfigPoolRemoveInputSchema).output(ConfigPoolRemoveOutputSchema).handler(({ input: input2 }) => {
|
|
@@ -127923,11 +128024,11 @@ function antigravityQuotaExhaustion(quota, model, nowMs) {
|
|
|
127923
128024
|
const binding = spent.reduce((latest, next) => latest === void 0 || next.resetSec > latest.resetSec ? next : latest, void 0);
|
|
127924
128025
|
return binding === void 0 ? void 0 : { window: binding.window, resetSec: binding.resetSec, exhaustedWindows: spent.map((entry) => entry.window) };
|
|
127925
128026
|
}
|
|
127926
|
-
function
|
|
128027
|
+
function isRecord9(value2) {
|
|
127927
128028
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
127928
128029
|
}
|
|
127929
128030
|
function bucketToEntry(bucket, nowMs) {
|
|
127930
|
-
if (!
|
|
128031
|
+
if (!isRecord9(bucket) || typeof bucket.bucketId !== "string") {
|
|
127931
128032
|
return void 0;
|
|
127932
128033
|
}
|
|
127933
128034
|
const remainingFraction = typeof bucket.remainingFraction === "number" && Number.isFinite(bucket.remainingFraction) ? bucket.remainingFraction : void 0;
|
|
@@ -127969,12 +128070,12 @@ async function fetchAntigravityQuotaSummary(params) {
|
|
|
127969
128070
|
} catch {
|
|
127970
128071
|
return void 0;
|
|
127971
128072
|
}
|
|
127972
|
-
if (!
|
|
128073
|
+
if (!isRecord9(parsed) || !Array.isArray(parsed.groups)) {
|
|
127973
128074
|
return void 0;
|
|
127974
128075
|
}
|
|
127975
128076
|
const map2 = {};
|
|
127976
128077
|
for (const group of parsed.groups) {
|
|
127977
|
-
if (!
|
|
128078
|
+
if (!isRecord9(group) || !Array.isArray(group.buckets)) {
|
|
127978
128079
|
continue;
|
|
127979
128080
|
}
|
|
127980
128081
|
for (const bucket of group.buckets) {
|
|
@@ -128198,7 +128299,7 @@ function turnBlocks2(message) {
|
|
|
128198
128299
|
}
|
|
128199
128300
|
return blocks.map((block2) => isTextBlock(block2) ? { ...block2, text: systemReminder2(block2.text) } : block2);
|
|
128200
128301
|
}
|
|
128201
|
-
function
|
|
128302
|
+
function isRecord10(value2) {
|
|
128202
128303
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
128203
128304
|
}
|
|
128204
128305
|
function messagesToGeminiContents(messages, names, toolIdToName) {
|
|
@@ -128244,7 +128345,7 @@ function messagesToGeminiContents(messages, names, toolIdToName) {
|
|
|
128244
128345
|
ensureRole("model").push({
|
|
128245
128346
|
functionCall: {
|
|
128246
128347
|
name: sanitizedName,
|
|
128247
|
-
args:
|
|
128348
|
+
args: isRecord10(block2.input) ? block2.input : {}
|
|
128248
128349
|
},
|
|
128249
128350
|
// The relay remembered the signature the backend attached to this exact call; echoing it back is what the backend requires of a repeated function call. A call with none remembered (made before a door restart, evicted from the bounded store, or produced by another model in a resumed session) gets the backend's documented bypass, since history is resent whole on every request and a single unsigned call would otherwise fail the whole conversation for good.
|
|
128250
128351
|
thoughtSignature: signature ?? UNVERIFIED_THOUGHT_SIGNATURE
|
|
@@ -129183,7 +129284,7 @@ var AcpStreamMessageSchema = external_exports.looseObject({
|
|
|
129183
129284
|
chunk: external_exports.looseObject({}).optional()
|
|
129184
129285
|
}).optional()
|
|
129185
129286
|
});
|
|
129186
|
-
function
|
|
129287
|
+
function isRecord11(value2) {
|
|
129187
129288
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
129188
129289
|
}
|
|
129189
129290
|
function normalizeFinishReason(reason) {
|
|
@@ -129208,7 +129309,7 @@ function parseJsonRecord(raw) {
|
|
|
129208
129309
|
}
|
|
129209
129310
|
try {
|
|
129210
129311
|
const parsed = JSON.parse(raw);
|
|
129211
|
-
if (
|
|
129312
|
+
if (isRecord11(parsed)) {
|
|
129212
129313
|
return parsed;
|
|
129213
129314
|
}
|
|
129214
129315
|
} catch {
|
|
@@ -129983,15 +130084,15 @@ function readFrontDoorControlMaterial(fsPort, paths, purpose) {
|
|
|
129983
130084
|
|
|
129984
130085
|
// src/frontdoor/rcLiveUsage.ts
|
|
129985
130086
|
var RC_RATE_LIMIT_EVENT_TYPE = "rate_limit_event";
|
|
129986
|
-
function
|
|
130087
|
+
function isRecord12(value2) {
|
|
129987
130088
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
129988
130089
|
}
|
|
129989
130090
|
function rcRateLimitInfoOf(event) {
|
|
129990
130091
|
const payload = event.envelope.payload;
|
|
129991
|
-
if (!
|
|
130092
|
+
if (!isRecord12(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
|
|
129992
130093
|
return void 0;
|
|
129993
130094
|
}
|
|
129994
|
-
if (!
|
|
130095
|
+
if (!isRecord12(payload.rate_limit_info)) {
|
|
129995
130096
|
return void 0;
|
|
129996
130097
|
}
|
|
129997
130098
|
const parsed = RcRateLimitInfoSchema.safeParse(payload.rate_limit_info);
|
|
@@ -130027,7 +130128,7 @@ var RC_SELF_HOST_SCOPE_LIST = ["user:profile", "user:inference", "user:sessions:
|
|
|
130027
130128
|
var RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS = 3600;
|
|
130028
130129
|
var MS_PER_SECOND11 = 1e3;
|
|
130029
130130
|
var HTTP_SERVICE_UNAVAILABLE = 503;
|
|
130030
|
-
function
|
|
130131
|
+
function isRecord13(value2) {
|
|
130031
130132
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
130032
130133
|
}
|
|
130033
130134
|
function parseJsonObject2(body) {
|
|
@@ -130037,7 +130138,7 @@ function parseJsonObject2(body) {
|
|
|
130037
130138
|
} catch {
|
|
130038
130139
|
return void 0;
|
|
130039
130140
|
}
|
|
130040
|
-
return
|
|
130141
|
+
return isRecord13(parsed) ? parsed : void 0;
|
|
130041
130142
|
}
|
|
130042
130143
|
function growthBookFeatures() {
|
|
130043
130144
|
return {
|
|
@@ -130131,7 +130232,7 @@ var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
|
|
|
130131
130232
|
var RC_SELF_HOST_RECORD_FILE = "credential.json";
|
|
130132
130233
|
var SELF_HOST_EMAIL = "selfhost@agent-shim.invalid";
|
|
130133
130234
|
var SELF_HOST_SUBSCRIPTION_TYPE = "max";
|
|
130134
|
-
function
|
|
130235
|
+
function isRecord14(value2) {
|
|
130135
130236
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
130136
130237
|
}
|
|
130137
130238
|
function readJsonObject(fs24, file2) {
|
|
@@ -130145,7 +130246,7 @@ function readJsonObject(fs24, file2) {
|
|
|
130145
130246
|
} catch {
|
|
130146
130247
|
return void 0;
|
|
130147
130248
|
}
|
|
130148
|
-
return
|
|
130249
|
+
return isRecord14(parsed) ? parsed : void 0;
|
|
130149
130250
|
}
|
|
130150
130251
|
function readRcSelfHostRecord(fs24, frontdoorDir) {
|
|
130151
130252
|
const parsed = readJsonObject(fs24, import_node_path49.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
|
|
@@ -130169,7 +130270,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
130169
130270
|
const recordFile = import_node_path49.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
|
|
130170
130271
|
const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
|
|
130171
130272
|
const existingCredentials = readJsonObject(deps.fs, credentialsFile);
|
|
130172
|
-
const existingOauth =
|
|
130273
|
+
const existingOauth = isRecord14(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
|
|
130173
130274
|
const existingToken = typeof existingOauth?.accessToken === "string" && existingOauth.accessToken !== "" ? existingOauth.accessToken : void 0;
|
|
130174
130275
|
const existingIsOwn = existingToken !== void 0 && previousRecord?.accessToken === existingToken;
|
|
130175
130276
|
if (existingToken !== void 0 && !existingIsOwn && !deps.force) {
|
|
@@ -130186,7 +130287,7 @@ function mintRcSelfHostCredential(deps) {
|
|
|
130186
130287
|
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)}
|
|
130187
130288
|
`);
|
|
130188
130289
|
const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
|
|
130189
|
-
const existingBlock = (value2) =>
|
|
130290
|
+
const existingBlock = (value2) => isRecord14(value2) ? value2 : {};
|
|
130190
130291
|
deps.fs.writeFilePrivate(claudeJsonFile, `${JSON.stringify({
|
|
130191
130292
|
...claudeJson,
|
|
130192
130293
|
oauthAccount: {
|
|
@@ -130573,11 +130674,11 @@ var import_node_path50 = __toESM(require("node:path"), 1);
|
|
|
130573
130674
|
function isSafeSessionId(sessionId) {
|
|
130574
130675
|
return /^[A-Za-z0-9_-]+$/.test(sessionId);
|
|
130575
130676
|
}
|
|
130576
|
-
function
|
|
130677
|
+
function isRecord15(value2) {
|
|
130577
130678
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
130578
130679
|
}
|
|
130579
130680
|
function credentialOfJson(parsed) {
|
|
130580
|
-
if (!
|
|
130681
|
+
if (!isRecord15(parsed)) {
|
|
130581
130682
|
return void 0;
|
|
130582
130683
|
}
|
|
130583
130684
|
const { authorization, anthropicVersion, anthropicClientPlatform } = parsed;
|
|
@@ -130607,7 +130708,7 @@ function createRcCredentialStore(fs24, dir) {
|
|
|
130607
130708
|
} catch {
|
|
130608
130709
|
return void 0;
|
|
130609
130710
|
}
|
|
130610
|
-
return
|
|
130711
|
+
return isRecord15(parsed) ? parsed : void 0;
|
|
130611
130712
|
};
|
|
130612
130713
|
return {
|
|
130613
130714
|
read: (sessionId) => {
|
|
@@ -131175,7 +131276,7 @@ init_capability();
|
|
|
131175
131276
|
// src/frontdoor/rcSelfHostEndpoints.ts
|
|
131176
131277
|
var RC_SOURCE_WORKER = "worker";
|
|
131177
131278
|
var RC_SOURCE_CLIENT = "client";
|
|
131178
|
-
function
|
|
131279
|
+
function isRecord16(value2) {
|
|
131179
131280
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
131180
131281
|
}
|
|
131181
131282
|
function parseJsonObject3(body) {
|
|
@@ -131185,7 +131286,7 @@ function parseJsonObject3(body) {
|
|
|
131185
131286
|
} catch {
|
|
131186
131287
|
return void 0;
|
|
131187
131288
|
}
|
|
131188
|
-
return
|
|
131289
|
+
return isRecord16(parsed) ? parsed : void 0;
|
|
131189
131290
|
}
|
|
131190
131291
|
function nonEmptyString2(record2, field) {
|
|
131191
131292
|
const value2 = record2 === void 0 ? void 0 : record2[field];
|
|
@@ -131259,7 +131360,7 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
|
|
|
131259
131360
|
}
|
|
131260
131361
|
const results = [];
|
|
131261
131362
|
for (const event of events) {
|
|
131262
|
-
if (!
|
|
131363
|
+
if (!isRecord16(event) || !isRecord16(event.payload)) {
|
|
131263
131364
|
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" } });
|
|
131264
131365
|
return true;
|
|
131265
131366
|
}
|
|
@@ -131359,7 +131460,7 @@ async function serveRcCompatSessions(ctx, pathname, compatPath) {
|
|
|
131359
131460
|
// src/frontdoor/rcSelfHostConversations.ts
|
|
131360
131461
|
var RC_CONVERSATIONS_PATH_PREFIX = "/v1/code/conversations";
|
|
131361
131462
|
var RC_CONVERSATION_ID_PREFIX = "conv_";
|
|
131362
|
-
function
|
|
131463
|
+
function isRecord17(value2) {
|
|
131363
131464
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
131364
131465
|
}
|
|
131365
131466
|
function parseJsonObject4(body) {
|
|
@@ -131369,7 +131470,7 @@ function parseJsonObject4(body) {
|
|
|
131369
131470
|
} catch {
|
|
131370
131471
|
return void 0;
|
|
131371
131472
|
}
|
|
131372
|
-
return
|
|
131473
|
+
return isRecord17(parsed) ? parsed : void 0;
|
|
131373
131474
|
}
|
|
131374
131475
|
function nonEmptyString3(record2, field) {
|
|
131375
131476
|
const value2 = record2 === void 0 ? void 0 : record2[field];
|
|
@@ -131423,7 +131524,7 @@ async function serveRcConversations(ctx, pathname, method) {
|
|
|
131423
131524
|
}
|
|
131424
131525
|
const results = [];
|
|
131425
131526
|
for (const event of events) {
|
|
131426
|
-
if (!
|
|
131527
|
+
if (!isRecord17(event) || !isRecord17(event.payload)) {
|
|
131427
131528
|
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" } });
|
|
131428
131529
|
return;
|
|
131429
131530
|
}
|
|
@@ -131716,7 +131817,7 @@ var RC_SELF_HOST_WORKER_EPOCH = 1;
|
|
|
131716
131817
|
var RC_STREAM_EVENT_NAME = "client_event";
|
|
131717
131818
|
var CONFLICT_REASON_HEADER2 = "x-ccr-conflict-reason";
|
|
131718
131819
|
var CONFLICT_REASON_EPOCH_STALE = "epoch_stale";
|
|
131719
|
-
function
|
|
131820
|
+
function isRecord18(value2) {
|
|
131720
131821
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
131721
131822
|
}
|
|
131722
131823
|
function isWebSearchRefusal(value2) {
|
|
@@ -131800,7 +131901,7 @@ function parseJsonObject5(body) {
|
|
|
131800
131901
|
} catch {
|
|
131801
131902
|
return void 0;
|
|
131802
131903
|
}
|
|
131803
|
-
return
|
|
131904
|
+
return isRecord18(parsed) ? parsed : void 0;
|
|
131804
131905
|
}
|
|
131805
131906
|
function mintWorkerJwt(randomToken, issuedAt) {
|
|
131806
131907
|
const encode3 = (value2) => Buffer.from(JSON.stringify(value2), "utf8").toString("base64url");
|
|
@@ -132060,7 +132161,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
132060
132161
|
if (status !== void 0) {
|
|
132061
132162
|
session.workerStatus = status;
|
|
132062
132163
|
}
|
|
132063
|
-
if (
|
|
132164
|
+
if (isRecord18(body?.external_metadata)) {
|
|
132064
132165
|
session.externalMetadata = body.external_metadata;
|
|
132065
132166
|
}
|
|
132066
132167
|
await answerJson2(response, HTTP_STATUS.ok, {});
|
|
@@ -132090,7 +132191,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
132090
132191
|
}
|
|
132091
132192
|
const results = [];
|
|
132092
132193
|
for (const event of events) {
|
|
132093
|
-
if (!
|
|
132194
|
+
if (!isRecord18(event) || !isRecord18(event.payload)) {
|
|
132094
132195
|
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" } });
|
|
132095
132196
|
return;
|
|
132096
132197
|
}
|
|
@@ -132123,7 +132224,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
132123
132224
|
return;
|
|
132124
132225
|
}
|
|
132125
132226
|
for (const event of events) {
|
|
132126
|
-
if (
|
|
132227
|
+
if (isRecord18(event)) {
|
|
132127
132228
|
session.internalEvents.push({ eventId: deps.newUuid(), body: event });
|
|
132128
132229
|
}
|
|
132129
132230
|
}
|
|
@@ -132219,7 +132320,7 @@ data: ${JSON.stringify(envelope)}
|
|
|
132219
132320
|
}
|
|
132220
132321
|
const results = [];
|
|
132221
132322
|
for (const event of events) {
|
|
132222
|
-
if (!
|
|
132323
|
+
if (!isRecord18(event) || !isRecord18(event.payload)) {
|
|
132223
132324
|
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" } });
|
|
132224
132325
|
return;
|
|
132225
132326
|
}
|
|
@@ -132409,7 +132510,7 @@ function createSseParser() {
|
|
|
132409
132510
|
}
|
|
132410
132511
|
};
|
|
132411
132512
|
}
|
|
132412
|
-
function
|
|
132513
|
+
function isRecord19(value2) {
|
|
132413
132514
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
132414
132515
|
}
|
|
132415
132516
|
function sequenceNumOf(value2) {
|
|
@@ -132431,7 +132532,7 @@ function parseRcStreamEnvelope(parsed) {
|
|
|
132431
132532
|
} catch {
|
|
132432
132533
|
return void 0;
|
|
132433
132534
|
}
|
|
132434
|
-
if (!
|
|
132535
|
+
if (!isRecord19(data)) {
|
|
132435
132536
|
return void 0;
|
|
132436
132537
|
}
|
|
132437
132538
|
const eventType = data.event_type;
|
|
@@ -144980,7 +145081,7 @@ function registerPoolCommand(program2, deps) {
|
|
|
144980
145081
|
pool.command("add <name>").description("Define a pool. Fails if one with this name already exists.").option("--identity <name>", "A member: an identity name, or pool:<name> to nest another pool with its own policy (repeatable).", collectRepeated).addOption(new Option("--preference <mode>", PREFERENCE_DESCRIPTION).choices(POOL_PREFERENCES)).option("--json", "Print the result as JSON.").action((name, options) => {
|
|
144981
145082
|
const members2 = membersOf(options);
|
|
144982
145083
|
requireIdentityNames(paths, members2);
|
|
144983
|
-
const created = addPool(paths, name, members2, options.preference);
|
|
145084
|
+
const created = addPool(paths, name, members2, { preference: options.preference });
|
|
144984
145085
|
reportMutation(options.json, { action: "created", kind: "pool", name, value: created }, () => {
|
|
144985
145086
|
console.log(`Created pool "${name}" with ${members2.join(", ")}.`);
|
|
144986
145087
|
});
|
|
@@ -144989,18 +145090,17 @@ function registerPoolCommand(program2, deps) {
|
|
|
144989
145090
|
);
|
|
144990
145091
|
withExamples(
|
|
144991
145092
|
pool.command("set <name>").description("Replace a pool's members, its preference, or both.").option("--identity <name>", "A member: an identity name, or pool:<name> to nest another pool with its own policy (repeatable); the full new list. Kept as-is when this option is absent.", collectRepeated).addOption(new Option("--preference <mode>", PREFERENCE_DESCRIPTION).choices(POOL_PREFERENCES)).option("--no-preference", "Clear the preference back to the default, score.").option("--json", "Print the result as JSON.").action((name, options) => {
|
|
144992
|
-
|
|
144993
|
-
|
|
145093
|
+
requirePool(paths, name);
|
|
145094
|
+
const change = { identities: options.identity, preference: options.preference };
|
|
145095
|
+
if (!isPoolChange(change)) {
|
|
144994
145096
|
throw new UsageError("Nothing to change: pass --identity, --preference or --no-preference.");
|
|
144995
145097
|
}
|
|
144996
|
-
const members2 = options.identity === void 0 ? existing.identities : membersOf(options);
|
|
144997
145098
|
if (options.identity !== void 0) {
|
|
144998
145099
|
requireIdentityNames(paths, membersOf(options));
|
|
144999
145100
|
}
|
|
145000
|
-
const
|
|
145001
|
-
const updated = setPool(paths, name, members2, preference);
|
|
145101
|
+
const updated = changePool(paths, name, change);
|
|
145002
145102
|
reportMutation(options.json, { action: "updated", kind: "pool", name, value: updated }, () => {
|
|
145003
|
-
console.log(`Pool "${name}" now has ${
|
|
145103
|
+
console.log(`Pool "${name}" now has ${updated.identities.map(poolMemberIdentity).join(", ")}.`);
|
|
145004
145104
|
});
|
|
145005
145105
|
}),
|
|
145006
145106
|
["agent-shim pool set subs --identity work --identity personal --identity spare", "agent-shim pool set subs --preference listed"]
|
|
@@ -145010,7 +145110,7 @@ function registerPoolCommand(program2, deps) {
|
|
|
145010
145110
|
const pools = readPools(paths);
|
|
145011
145111
|
const active = readActiveIdentity2(paths);
|
|
145012
145112
|
if (options.json === true) {
|
|
145013
|
-
printJson(Object.entries(pools).map(([name, entry]) => ({ name, identities: entry.identities, ...entry
|
|
145113
|
+
printJson(Object.entries(pools).map(([name, entry]) => ({ name, identities: entry.identities, ...poolPolicyOf(entry), active: active === `${POOL_SELECTOR_PREFIX}${name}` })));
|
|
145014
145114
|
return;
|
|
145015
145115
|
}
|
|
145016
145116
|
const names = Object.keys(pools).sort();
|
|
@@ -145020,7 +145120,7 @@ function registerPoolCommand(program2, deps) {
|
|
|
145020
145120
|
}
|
|
145021
145121
|
for (const name of names) {
|
|
145022
145122
|
const entry = pools[name];
|
|
145023
|
-
console.log(`${active === `${POOL_SELECTOR_PREFIX}${name}` ? "*" : " "} ${name}: ${(entry?.identities ?? []).map(poolMemberIdentity).join(", ")}${entry?.preference === void 0 ? "" :
|
|
145123
|
+
console.log(`${active === `${POOL_SELECTOR_PREFIX}${name}` ? "*" : " "} ${name}: ${(entry?.identities ?? []).map(poolMemberIdentity).join(", ")}${entry?.preference === void 0 ? "" : ` (preference: ${entry.preference})`}`);
|
|
145024
145124
|
}
|
|
145025
145125
|
}),
|
|
145026
145126
|
["agent-shim pool list", "agent-shim pool list --json"]
|
|
@@ -145029,7 +145129,7 @@ function registerPoolCommand(program2, deps) {
|
|
|
145029
145129
|
pool.command("show <name>").description("Show one pool's members.").option("--json", "Print the pool as JSON.").action((name, options) => {
|
|
145030
145130
|
const entry = requirePool(paths, name);
|
|
145031
145131
|
if (options.json === true) {
|
|
145032
|
-
printJson({ name, identities: entry.identities, ...entry
|
|
145132
|
+
printJson({ name, identities: entry.identities, ...poolPolicyOf(entry) });
|
|
145033
145133
|
return;
|
|
145034
145134
|
}
|
|
145035
145135
|
console.log(`Pool: ${name}`);
|