claude-use 12.1.0 → 12.2.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 +351 -171
- package/dist/index.cjs +256 -156
- package/dist/index.mjs +256 -156
- package/dist/types/index.d.ts +947 -890
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1012,6 +1012,8 @@ var init_schema = __esm({
|
|
|
1012
1012
|
kind: import_zod3.z.literal("http").optional(),
|
|
1013
1013
|
displayName: import_zod3.z.string().min(1),
|
|
1014
1014
|
baseUrl: import_zod3.z.url(),
|
|
1015
|
+
/** How long opening a TCP connection to `baseUrl` may take before the provider counts as unreachable: the door's forwarding gives up and answers naming the provider, and `doctor`, `check` and a launch's probe are bounded by it. Defaults to `DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS`. Bounds the connect only, never the wait for the answer. */
|
|
1016
|
+
connectTimeoutMs: import_zod3.z.int().positive().optional(),
|
|
1015
1017
|
credential: ProviderCredentialSchema,
|
|
1016
1018
|
env: ProviderEnvSchema.optional(),
|
|
1017
1019
|
/** Extra models `/model` lists beside the ones the tier settings name. */
|
|
@@ -10865,7 +10867,7 @@ var init_package = __esm({
|
|
|
10865
10867
|
"package.json"() {
|
|
10866
10868
|
package_default = {
|
|
10867
10869
|
name: "claude-use",
|
|
10868
|
-
version: "12.
|
|
10870
|
+
version: "12.2.0",
|
|
10869
10871
|
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.",
|
|
10870
10872
|
license: "MIT",
|
|
10871
10873
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -11528,6 +11530,9 @@ function addProvider(paths, name, input) {
|
|
|
11528
11530
|
if (kind !== "http" && kind !== "router" && input.catalogue !== void 0) {
|
|
11529
11531
|
throw new ProviderKindMismatchError("A model catalogue applies only to an http provider.");
|
|
11530
11532
|
}
|
|
11533
|
+
if (kind !== "http" && input.connectTimeoutMs !== void 0) {
|
|
11534
|
+
throw new ProviderKindMismatchError("A connect timeout applies only to an http provider, the one kind that dials a base URL.");
|
|
11535
|
+
}
|
|
11531
11536
|
if (kind !== "codex" && !isEmptyCodexConfig(input.codex)) {
|
|
11532
11537
|
throw new ProviderKindMismatchError("Codex settings apply only to a codex provider (--kind codex).");
|
|
11533
11538
|
}
|
|
@@ -11541,7 +11546,7 @@ function addProvider(paths, name, input) {
|
|
|
11541
11546
|
...input.pickerModels === void 0 || input.pickerModels.length === 0 ? {} : { pickerModels: input.pickerModels }
|
|
11542
11547
|
};
|
|
11543
11548
|
const parsed = ProviderSchema.safeParse(
|
|
11544
|
-
kind === "router" ? { kind, displayName: input.displayName } : kind === "codex" ? { kind, ...shared, ...isEmptyCodexConfig(input.codex) ? {} : { codex: input.codex } } : kind === "antigravity" ? { kind, ...shared, ...isEmptyAntigravityConfig(input.antigravity) ? {} : { antigravity: input.antigravity } } : { ...shared, baseUrl: input.baseUrl, ...input.catalogue === void 0 ? {} : { catalogue: input.catalogue } }
|
|
11549
|
+
kind === "router" ? { kind, displayName: input.displayName } : kind === "codex" ? { kind, ...shared, ...isEmptyCodexConfig(input.codex) ? {} : { codex: input.codex } } : kind === "antigravity" ? { kind, ...shared, ...isEmptyAntigravityConfig(input.antigravity) ? {} : { antigravity: input.antigravity } } : { ...shared, baseUrl: input.baseUrl, ...input.connectTimeoutMs === void 0 ? {} : { connectTimeoutMs: input.connectTimeoutMs }, ...input.catalogue === void 0 ? {} : { catalogue: input.catalogue } }
|
|
11545
11550
|
);
|
|
11546
11551
|
if (!parsed.success) {
|
|
11547
11552
|
throw new ConfigValidationError(providerJsonPath(paths, name), parsed.error.issues);
|
|
@@ -11573,6 +11578,9 @@ function updateProvider(paths, name, input) {
|
|
|
11573
11578
|
if (isAntigravityProvider(existing) && input.baseUrl !== void 0) {
|
|
11574
11579
|
throw new ProviderKindMismatchError(`Provider "${name}" is an antigravity provider, which has no base URL.`);
|
|
11575
11580
|
}
|
|
11581
|
+
if (!isHttpProvider(existing) && input.connectTimeoutMs !== void 0) {
|
|
11582
|
+
throw new ProviderKindMismatchError(`Provider "${name}" is not an http provider; a connect timeout applies only to an http provider, the one kind that dials a base URL.`);
|
|
11583
|
+
}
|
|
11576
11584
|
if ((isCodexProvider(existing) || isAntigravityProvider(existing)) && input.catalogue !== void 0 && input.catalogue !== false) {
|
|
11577
11585
|
throw new ProviderKindMismatchError(`Provider "${name}" is not an http provider; a model catalogue applies only to an http provider.`);
|
|
11578
11586
|
}
|
|
@@ -11613,7 +11621,8 @@ function updateProvider(paths, name, input) {
|
|
|
11613
11621
|
candidate = { kind: "router", ...shared };
|
|
11614
11622
|
} else {
|
|
11615
11623
|
const catalogue = input.catalogue === void 0 ? existing.catalogue : input.catalogue === false ? void 0 : input.catalogue;
|
|
11616
|
-
|
|
11624
|
+
const connectTimeoutMs = input.connectTimeoutMs === void 0 ? existing.connectTimeoutMs : input.connectTimeoutMs === false ? void 0 : input.connectTimeoutMs;
|
|
11625
|
+
candidate = { ...existing, ...shared, catalogue, connectTimeoutMs, ...input.baseUrl === void 0 ? {} : { baseUrl: input.baseUrl } };
|
|
11617
11626
|
}
|
|
11618
11627
|
const parsed = ProviderSchema.safeParse(candidate);
|
|
11619
11628
|
if (!parsed.success) {
|
|
@@ -11958,6 +11967,185 @@ var init_paths = __esm({
|
|
|
11958
11967
|
}
|
|
11959
11968
|
});
|
|
11960
11969
|
|
|
11970
|
+
// src/frontdoor/probe.ts
|
|
11971
|
+
function requestCatalogueRefreshSync(port, caPem, token, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
11972
|
+
refuseToBlockInRole("a synchronous catalogue refresh request");
|
|
11973
|
+
return runProbeWorker(CATALOGUE_REQUEST_SOURCE, { port, ca: caPem, token }, timeoutMs);
|
|
11974
|
+
}
|
|
11975
|
+
function probeFrontDoorSync(port, caPem, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
11976
|
+
refuseToBlockInRole("a synchronous probe of the front door");
|
|
11977
|
+
return runProbeWorker(PROBE_SOURCE, { port, ca: caPem }, timeoutMs);
|
|
11978
|
+
}
|
|
11979
|
+
function probeListenerAcceptSync(port, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
11980
|
+
refuseToBlockInRole("a synchronous probe of a front door listener");
|
|
11981
|
+
return runProbeWorker(ACCEPT_PROBE_SOURCE, { host: "127.0.0.1", port }, timeoutMs);
|
|
11982
|
+
}
|
|
11983
|
+
function probeAddressAcceptSync(host, port, timeoutMs) {
|
|
11984
|
+
refuseToBlockInRole("a synchronous probe of a provider's address");
|
|
11985
|
+
return runProbeWorker(ACCEPT_PROBE_SOURCE, { host, port }, timeoutMs);
|
|
11986
|
+
}
|
|
11987
|
+
function runProbeWorker(source, data, timeoutMs) {
|
|
11988
|
+
const shared = new SharedArrayBuffer(HEADER_SLOTS * INT32_BYTES + REASON_BYTES);
|
|
11989
|
+
const header = new Int32Array(shared, 0, HEADER_SLOTS);
|
|
11990
|
+
const worker = new import_node_worker_threads.Worker(source, {
|
|
11991
|
+
eval: true,
|
|
11992
|
+
workerData: { ...data, timeoutMs, shared, ok: VERDICT_OK, failed: VERDICT_FAILED, headerSlots: HEADER_SLOTS }
|
|
11993
|
+
});
|
|
11994
|
+
worker.unref();
|
|
11995
|
+
try {
|
|
11996
|
+
const waited = Atomics.wait(header, 0, VERDICT_PENDING, timeoutMs + PROBE_WAIT_MARGIN_MS);
|
|
11997
|
+
const verdict = Atomics.load(header, 0);
|
|
11998
|
+
if (waited === "timed-out" || verdict === VERDICT_PENDING) {
|
|
11999
|
+
return { ok: false, reason: `the probe did not finish within ${String(timeoutMs + PROBE_WAIT_MARGIN_MS)}ms` };
|
|
12000
|
+
}
|
|
12001
|
+
if (verdict === VERDICT_OK) {
|
|
12002
|
+
return { ok: true };
|
|
12003
|
+
}
|
|
12004
|
+
const length = Atomics.load(header, 1);
|
|
12005
|
+
return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
|
|
12006
|
+
} finally {
|
|
12007
|
+
void worker.terminate();
|
|
12008
|
+
}
|
|
12009
|
+
}
|
|
12010
|
+
var import_node_worker_threads, PROBE_TIMEOUT_MS, PROBE_WAIT_MARGIN_MS, REASON_BYTES, HEADER_SLOTS, INT32_BYTES, VERDICT_PENDING, VERDICT_OK, VERDICT_FAILED, PROBE_SOURCE, CATALOGUE_REQUEST_SOURCE, ACCEPT_PROBE_SOURCE;
|
|
12011
|
+
var init_probe = __esm({
|
|
12012
|
+
"src/frontdoor/probe.ts"() {
|
|
12013
|
+
"use strict";
|
|
12014
|
+
init_processRole();
|
|
12015
|
+
import_node_worker_threads = require("node:worker_threads");
|
|
12016
|
+
PROBE_TIMEOUT_MS = 2e3;
|
|
12017
|
+
PROBE_WAIT_MARGIN_MS = 1e3;
|
|
12018
|
+
REASON_BYTES = 1024;
|
|
12019
|
+
HEADER_SLOTS = 2;
|
|
12020
|
+
INT32_BYTES = 4;
|
|
12021
|
+
VERDICT_PENDING = 0;
|
|
12022
|
+
VERDICT_OK = 1;
|
|
12023
|
+
VERDICT_FAILED = 2;
|
|
12024
|
+
PROBE_SOURCE = `
|
|
12025
|
+
const { workerData } = require("node:worker_threads");
|
|
12026
|
+
const https = require("node:https");
|
|
12027
|
+
const { port, ca, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
12028
|
+
const header = new Int32Array(shared, 0, headerSlots);
|
|
12029
|
+
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
12030
|
+
let done = false;
|
|
12031
|
+
const finish = (verdict, message) => {
|
|
12032
|
+
if (done) return;
|
|
12033
|
+
done = true;
|
|
12034
|
+
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
12035
|
+
reason.set(bytes);
|
|
12036
|
+
Atomics.store(header, 1, bytes.length);
|
|
12037
|
+
Atomics.store(header, 0, verdict);
|
|
12038
|
+
Atomics.notify(header, 0);
|
|
12039
|
+
};
|
|
12040
|
+
const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
|
|
12041
|
+
let body = "";
|
|
12042
|
+
response.setEncoding("utf8");
|
|
12043
|
+
response.on("data", (chunk) => { body += chunk; });
|
|
12044
|
+
response.on("end", () => {
|
|
12045
|
+
if (response.statusCode === 200 && body === "ok") finish(ok, "");
|
|
12046
|
+
else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
|
|
12047
|
+
});
|
|
12048
|
+
response.on("error", (error) => finish(failed, error.message));
|
|
12049
|
+
});
|
|
12050
|
+
// A hard deadline over the whole exchange, handshake included: a listener that accepts the connection and then says nothing must still fail the probe.
|
|
12051
|
+
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
12052
|
+
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
12053
|
+
`;
|
|
12054
|
+
CATALOGUE_REQUEST_SOURCE = `
|
|
12055
|
+
const { workerData } = require("node:worker_threads");
|
|
12056
|
+
const https = require("node:https");
|
|
12057
|
+
const { port, ca, token, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
12058
|
+
const header = new Int32Array(shared, 0, headerSlots);
|
|
12059
|
+
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
12060
|
+
let done = false;
|
|
12061
|
+
const finish = (verdict, message) => {
|
|
12062
|
+
if (done) return;
|
|
12063
|
+
done = true;
|
|
12064
|
+
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
12065
|
+
reason.set(bytes);
|
|
12066
|
+
Atomics.store(header, 1, bytes.length);
|
|
12067
|
+
Atomics.store(header, 0, verdict);
|
|
12068
|
+
Atomics.notify(header, 0);
|
|
12069
|
+
};
|
|
12070
|
+
const request = https.request({ host: "127.0.0.1", port, path: "/__agent-shim/orpc/rest/frontdoor/catalogues/refresh", method: "POST", headers: { authorization: "Bearer " + token }, ca: [ca], agent: false }, (response) => {
|
|
12071
|
+
response.resume();
|
|
12072
|
+
response.on("end", () => response.statusCode === 200 ? finish(ok, "") : finish(failed, "catalogue refresh request returned HTTP " + String(response.statusCode)));
|
|
12073
|
+
response.on("error", (error) => finish(failed, error.message));
|
|
12074
|
+
});
|
|
12075
|
+
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
12076
|
+
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
12077
|
+
request.end();
|
|
12078
|
+
`;
|
|
12079
|
+
ACCEPT_PROBE_SOURCE = `
|
|
12080
|
+
const { workerData } = require("node:worker_threads");
|
|
12081
|
+
const net = require("node:net");
|
|
12082
|
+
const { host, port, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
12083
|
+
const header = new Int32Array(shared, 0, headerSlots);
|
|
12084
|
+
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
12085
|
+
let done = false;
|
|
12086
|
+
const finish = (verdict, message) => {
|
|
12087
|
+
if (done) return;
|
|
12088
|
+
done = true;
|
|
12089
|
+
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
12090
|
+
reason.set(bytes);
|
|
12091
|
+
Atomics.store(header, 1, bytes.length);
|
|
12092
|
+
Atomics.store(header, 0, verdict);
|
|
12093
|
+
Atomics.notify(header, 0);
|
|
12094
|
+
};
|
|
12095
|
+
const socket = net.connect({ host, port });
|
|
12096
|
+
socket.once("connect", () => { socket.destroy(); finish(ok, ""); });
|
|
12097
|
+
socket.once("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
12098
|
+
setTimeout(() => { socket.destroy(); finish(failed, "no connection accepted within " + String(timeoutMs) + "ms"); }, timeoutMs);
|
|
12099
|
+
`;
|
|
12100
|
+
}
|
|
12101
|
+
});
|
|
12102
|
+
|
|
12103
|
+
// src/providerReachability.ts
|
|
12104
|
+
function providerConnectTimeoutMs(provider) {
|
|
12105
|
+
return provider.connectTimeoutMs ?? DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS;
|
|
12106
|
+
}
|
|
12107
|
+
function dialTargetOf(baseUrl) {
|
|
12108
|
+
const url = new URL(baseUrl);
|
|
12109
|
+
const defaultPort = DEFAULT_PORTS[url.protocol];
|
|
12110
|
+
if (defaultPort === void 0) {
|
|
12111
|
+
return void 0;
|
|
12112
|
+
}
|
|
12113
|
+
return { host: url.hostname.replace(/^\[(.*)\]$/, "$1"), port: url.port === "" ? defaultPort : Number(url.port) };
|
|
12114
|
+
}
|
|
12115
|
+
function couldNotConnectMessage(subject, baseUrl, reason) {
|
|
12116
|
+
return `${subject} could not connect to ${baseUrl}: ${reason}`;
|
|
12117
|
+
}
|
|
12118
|
+
function probeProviderReachability(name, provider, probe) {
|
|
12119
|
+
const verdict = probe(provider.baseUrl, providerConnectTimeoutMs(provider));
|
|
12120
|
+
return verdict.ok ? { ok: true } : { ok: false, message: couldNotConnectMessage(`provider ${name}`, provider.baseUrl, verdict.reason) };
|
|
12121
|
+
}
|
|
12122
|
+
function unreachableProviderLine(name, provider, probe) {
|
|
12123
|
+
if (probe === void 0 || !isHttpProvider(provider)) {
|
|
12124
|
+
return void 0;
|
|
12125
|
+
}
|
|
12126
|
+
const reachability = probeProviderReachability(name, provider, probe);
|
|
12127
|
+
return reachability.ok ? void 0 : reachability.message;
|
|
12128
|
+
}
|
|
12129
|
+
var TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS, CONNECT_SYN_RETRANSMISSIONS_TOLERATED, DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS, DEFAULT_PORTS, realBaseUrlProbe;
|
|
12130
|
+
var init_providerReachability = __esm({
|
|
12131
|
+
"src/providerReachability.ts"() {
|
|
12132
|
+
"use strict";
|
|
12133
|
+
init_schema();
|
|
12134
|
+
init_probe();
|
|
12135
|
+
TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS = 1e3;
|
|
12136
|
+
CONNECT_SYN_RETRANSMISSIONS_TOLERATED = 2;
|
|
12137
|
+
DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS = TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS * (2 ** (CONNECT_SYN_RETRANSMISSIONS_TOLERATED + 1) - 1);
|
|
12138
|
+
DEFAULT_PORTS = { "http:": 80, "https:": 443 };
|
|
12139
|
+
realBaseUrlProbe = (baseUrl, timeoutMs) => {
|
|
12140
|
+
const target = dialTargetOf(baseUrl);
|
|
12141
|
+
if (target === void 0) {
|
|
12142
|
+
return { ok: false, reason: "the base URL is neither http nor https" };
|
|
12143
|
+
}
|
|
12144
|
+
return probeAddressAcceptSync(target.host, target.port, timeoutMs);
|
|
12145
|
+
};
|
|
12146
|
+
}
|
|
12147
|
+
});
|
|
12148
|
+
|
|
11961
12149
|
// src/launcher/claudeVersion.ts
|
|
11962
12150
|
function validated2(value, origin) {
|
|
11963
12151
|
if (!NUMERIC_DOTTED_VERSION_RE.test(value)) {
|
|
@@ -12683,135 +12871,6 @@ var init_targets = __esm({
|
|
|
12683
12871
|
}
|
|
12684
12872
|
});
|
|
12685
12873
|
|
|
12686
|
-
// src/frontdoor/probe.ts
|
|
12687
|
-
function requestCatalogueRefreshSync(port, caPem, token, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
12688
|
-
refuseToBlockInRole("a synchronous catalogue refresh request");
|
|
12689
|
-
return runProbeWorker(CATALOGUE_REQUEST_SOURCE, { port, ca: caPem, token }, timeoutMs);
|
|
12690
|
-
}
|
|
12691
|
-
function probeFrontDoorSync(port, caPem, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
12692
|
-
refuseToBlockInRole("a synchronous probe of the front door");
|
|
12693
|
-
return runProbeWorker(PROBE_SOURCE, { port, ca: caPem }, timeoutMs);
|
|
12694
|
-
}
|
|
12695
|
-
function probeListenerAcceptSync(port, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
12696
|
-
refuseToBlockInRole("a synchronous probe of a front door listener");
|
|
12697
|
-
return runProbeWorker(ACCEPT_PROBE_SOURCE, { port }, timeoutMs);
|
|
12698
|
-
}
|
|
12699
|
-
function runProbeWorker(source, data, timeoutMs) {
|
|
12700
|
-
const shared = new SharedArrayBuffer(HEADER_SLOTS * INT32_BYTES + REASON_BYTES);
|
|
12701
|
-
const header = new Int32Array(shared, 0, HEADER_SLOTS);
|
|
12702
|
-
const worker = new import_node_worker_threads.Worker(source, {
|
|
12703
|
-
eval: true,
|
|
12704
|
-
workerData: { ...data, timeoutMs, shared, ok: VERDICT_OK, failed: VERDICT_FAILED, headerSlots: HEADER_SLOTS }
|
|
12705
|
-
});
|
|
12706
|
-
worker.unref();
|
|
12707
|
-
try {
|
|
12708
|
-
const waited = Atomics.wait(header, 0, VERDICT_PENDING, timeoutMs + PROBE_WAIT_MARGIN_MS);
|
|
12709
|
-
const verdict = Atomics.load(header, 0);
|
|
12710
|
-
if (waited === "timed-out" || verdict === VERDICT_PENDING) {
|
|
12711
|
-
return { ok: false, reason: `the probe did not finish within ${String(timeoutMs + PROBE_WAIT_MARGIN_MS)}ms` };
|
|
12712
|
-
}
|
|
12713
|
-
if (verdict === VERDICT_OK) {
|
|
12714
|
-
return { ok: true };
|
|
12715
|
-
}
|
|
12716
|
-
const length = Atomics.load(header, 1);
|
|
12717
|
-
return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
|
|
12718
|
-
} finally {
|
|
12719
|
-
void worker.terminate();
|
|
12720
|
-
}
|
|
12721
|
-
}
|
|
12722
|
-
var import_node_worker_threads, PROBE_TIMEOUT_MS, PROBE_WAIT_MARGIN_MS, REASON_BYTES, HEADER_SLOTS, INT32_BYTES, VERDICT_PENDING, VERDICT_OK, VERDICT_FAILED, PROBE_SOURCE, CATALOGUE_REQUEST_SOURCE, ACCEPT_PROBE_SOURCE;
|
|
12723
|
-
var init_probe = __esm({
|
|
12724
|
-
"src/frontdoor/probe.ts"() {
|
|
12725
|
-
"use strict";
|
|
12726
|
-
init_processRole();
|
|
12727
|
-
import_node_worker_threads = require("node:worker_threads");
|
|
12728
|
-
PROBE_TIMEOUT_MS = 2e3;
|
|
12729
|
-
PROBE_WAIT_MARGIN_MS = 1e3;
|
|
12730
|
-
REASON_BYTES = 1024;
|
|
12731
|
-
HEADER_SLOTS = 2;
|
|
12732
|
-
INT32_BYTES = 4;
|
|
12733
|
-
VERDICT_PENDING = 0;
|
|
12734
|
-
VERDICT_OK = 1;
|
|
12735
|
-
VERDICT_FAILED = 2;
|
|
12736
|
-
PROBE_SOURCE = `
|
|
12737
|
-
const { workerData } = require("node:worker_threads");
|
|
12738
|
-
const https = require("node:https");
|
|
12739
|
-
const { port, ca, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
12740
|
-
const header = new Int32Array(shared, 0, headerSlots);
|
|
12741
|
-
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
12742
|
-
let done = false;
|
|
12743
|
-
const finish = (verdict, message) => {
|
|
12744
|
-
if (done) return;
|
|
12745
|
-
done = true;
|
|
12746
|
-
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
12747
|
-
reason.set(bytes);
|
|
12748
|
-
Atomics.store(header, 1, bytes.length);
|
|
12749
|
-
Atomics.store(header, 0, verdict);
|
|
12750
|
-
Atomics.notify(header, 0);
|
|
12751
|
-
};
|
|
12752
|
-
const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
|
|
12753
|
-
let body = "";
|
|
12754
|
-
response.setEncoding("utf8");
|
|
12755
|
-
response.on("data", (chunk) => { body += chunk; });
|
|
12756
|
-
response.on("end", () => {
|
|
12757
|
-
if (response.statusCode === 200 && body === "ok") finish(ok, "");
|
|
12758
|
-
else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
|
|
12759
|
-
});
|
|
12760
|
-
response.on("error", (error) => finish(failed, error.message));
|
|
12761
|
-
});
|
|
12762
|
-
// A hard deadline over the whole exchange, handshake included: a listener that accepts the connection and then says nothing must still fail the probe.
|
|
12763
|
-
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
12764
|
-
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
12765
|
-
`;
|
|
12766
|
-
CATALOGUE_REQUEST_SOURCE = `
|
|
12767
|
-
const { workerData } = require("node:worker_threads");
|
|
12768
|
-
const https = require("node:https");
|
|
12769
|
-
const { port, ca, token, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
12770
|
-
const header = new Int32Array(shared, 0, headerSlots);
|
|
12771
|
-
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
12772
|
-
let done = false;
|
|
12773
|
-
const finish = (verdict, message) => {
|
|
12774
|
-
if (done) return;
|
|
12775
|
-
done = true;
|
|
12776
|
-
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
12777
|
-
reason.set(bytes);
|
|
12778
|
-
Atomics.store(header, 1, bytes.length);
|
|
12779
|
-
Atomics.store(header, 0, verdict);
|
|
12780
|
-
Atomics.notify(header, 0);
|
|
12781
|
-
};
|
|
12782
|
-
const request = https.request({ host: "127.0.0.1", port, path: "/__agent-shim/orpc/rest/frontdoor/catalogues/refresh", method: "POST", headers: { authorization: "Bearer " + token }, ca: [ca], agent: false }, (response) => {
|
|
12783
|
-
response.resume();
|
|
12784
|
-
response.on("end", () => response.statusCode === 200 ? finish(ok, "") : finish(failed, "catalogue refresh request returned HTTP " + String(response.statusCode)));
|
|
12785
|
-
response.on("error", (error) => finish(failed, error.message));
|
|
12786
|
-
});
|
|
12787
|
-
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
12788
|
-
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
12789
|
-
request.end();
|
|
12790
|
-
`;
|
|
12791
|
-
ACCEPT_PROBE_SOURCE = `
|
|
12792
|
-
const { workerData } = require("node:worker_threads");
|
|
12793
|
-
const net = require("node:net");
|
|
12794
|
-
const { port, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
12795
|
-
const header = new Int32Array(shared, 0, headerSlots);
|
|
12796
|
-
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
12797
|
-
let done = false;
|
|
12798
|
-
const finish = (verdict, message) => {
|
|
12799
|
-
if (done) return;
|
|
12800
|
-
done = true;
|
|
12801
|
-
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
12802
|
-
reason.set(bytes);
|
|
12803
|
-
Atomics.store(header, 1, bytes.length);
|
|
12804
|
-
Atomics.store(header, 0, verdict);
|
|
12805
|
-
Atomics.notify(header, 0);
|
|
12806
|
-
};
|
|
12807
|
-
const socket = net.connect({ host: "127.0.0.1", port });
|
|
12808
|
-
socket.once("connect", () => { socket.destroy(); finish(ok, ""); });
|
|
12809
|
-
socket.once("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
12810
|
-
setTimeout(() => { socket.destroy(); finish(failed, "no connection accepted within " + String(timeoutMs) + "ms"); }, timeoutMs);
|
|
12811
|
-
`;
|
|
12812
|
-
}
|
|
12813
|
-
});
|
|
12814
|
-
|
|
12815
12874
|
// src/launcher/proxyBypass.ts
|
|
12816
12875
|
function checkedProxyBypass(entries, source) {
|
|
12817
12876
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -14761,6 +14820,11 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
14761
14820
|
proc.exit(check.status);
|
|
14762
14821
|
}
|
|
14763
14822
|
}
|
|
14823
|
+
const unreachable = resolvedProvider === void 0 ? void 0 : unreachableProviderLine(resolvedProvider.name, resolvedProvider.definition, params.probeBaseUrl);
|
|
14824
|
+
if (unreachable !== void 0) {
|
|
14825
|
+
log.error(`agent-shim: ${unreachable}`);
|
|
14826
|
+
proc.exit(1);
|
|
14827
|
+
}
|
|
14764
14828
|
const frontDoorPort = params.frontdoor;
|
|
14765
14829
|
const frontDoorEngaged = resolvedProvider !== void 0 || resolvedFlags.headroom || resolvedFlags.trackUsage;
|
|
14766
14830
|
if (frontDoorEngaged && frontDoorPort === void 0) {
|
|
@@ -14916,6 +14980,7 @@ var init_launcher = __esm({
|
|
|
14916
14980
|
init_flatten();
|
|
14917
14981
|
init_walk();
|
|
14918
14982
|
init_schema();
|
|
14983
|
+
init_providerReachability();
|
|
14919
14984
|
init_schema();
|
|
14920
14985
|
init_credential();
|
|
14921
14986
|
init_middleware();
|
|
@@ -15209,6 +15274,7 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
15209
15274
|
headroom: realHeadroomPort(paths, { spawnDaemon: options.spawnDaemon, cwd: farm.runtime.cwd }),
|
|
15210
15275
|
frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
|
|
15211
15276
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
15277
|
+
probeBaseUrl: realBaseUrlProbe,
|
|
15212
15278
|
hold: realHoldPort,
|
|
15213
15279
|
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: import_node_path54.default.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
|
|
15214
15280
|
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin, import_node_path54.default.join(paths.identitiesDir, identity), options.proc.env),
|
|
@@ -15292,6 +15358,7 @@ var init_launchWiring = __esm({
|
|
|
15292
15358
|
init_replayRun();
|
|
15293
15359
|
init_paths();
|
|
15294
15360
|
init_signIn();
|
|
15361
|
+
init_providerReachability();
|
|
15295
15362
|
init_realPorts();
|
|
15296
15363
|
LaunchRefusedError = class extends CliError {
|
|
15297
15364
|
exitCode;
|
|
@@ -19935,6 +20002,7 @@ var import_zod27 = require("zod");
|
|
|
19935
20002
|
init_envBool();
|
|
19936
20003
|
init_load();
|
|
19937
20004
|
init_schema();
|
|
20005
|
+
init_providerReachability();
|
|
19938
20006
|
init_identityStore();
|
|
19939
20007
|
init_credential();
|
|
19940
20008
|
init_claudeVersion();
|
|
@@ -20127,6 +20195,7 @@ function runCheck(params) {
|
|
|
20127
20195
|
const settingsExposure = inspectSettingsExposure({ settingsShared, files: params.settingsFiles });
|
|
20128
20196
|
const keychain = !isCodex && params.platform === "darwin" && params.run !== void 0 && params.farmRoot !== void 0 ? lookupKeychainService(params.run, params.farmRoot) : void 0;
|
|
20129
20197
|
const claudeVersion = isCodex ? void 0 : buildClaudeVersionReport(params, resolved.flattened.launch.claudeVersion);
|
|
20198
|
+
const providerReachability = buildProviderReachability(params.provider, params.probeBaseUrl);
|
|
20130
20199
|
return {
|
|
20131
20200
|
...params.identityName === void 0 ? {} : { identityName: params.identityName },
|
|
20132
20201
|
identitySource: params.identitySource,
|
|
@@ -20140,9 +20209,18 @@ function runCheck(params) {
|
|
|
20140
20209
|
...keychain === void 0 ? {} : { keychain },
|
|
20141
20210
|
settingsExposure,
|
|
20142
20211
|
credential: buildCredentialReport(params.provider, params.identity, params.identityId, params.credentialCache),
|
|
20143
|
-
...claudeVersion === void 0 ? {} : { claudeVersion }
|
|
20212
|
+
...claudeVersion === void 0 ? {} : { claudeVersion },
|
|
20213
|
+
...providerReachability === void 0 ? {} : { providerReachability }
|
|
20144
20214
|
};
|
|
20145
20215
|
}
|
|
20216
|
+
function buildProviderReachability(provider, probe) {
|
|
20217
|
+
if (provider?.definition === void 0 || probe === void 0 || !isHttpProvider(provider.definition)) {
|
|
20218
|
+
return void 0;
|
|
20219
|
+
}
|
|
20220
|
+
const { baseUrl } = provider.definition;
|
|
20221
|
+
const reachability = probeProviderReachability(provider.name, provider.definition, probe);
|
|
20222
|
+
return reachability.ok ? { name: provider.name, baseUrl, ok: true } : { name: provider.name, baseUrl, ok: false, message: reachability.message };
|
|
20223
|
+
}
|
|
20146
20224
|
function formatCheckReport(report) {
|
|
20147
20225
|
const lines = [];
|
|
20148
20226
|
lines.push(`Identity: ${report.identityName ?? "(none)"} (${report.identitySource})`);
|
|
@@ -20189,6 +20267,11 @@ function formatCheckReport(report) {
|
|
|
20189
20267
|
if (credential.applies === "stored-login") {
|
|
20190
20268
|
lines.push(" The identity's stored login (no credential block applies).");
|
|
20191
20269
|
}
|
|
20270
|
+
if (report.providerReachability !== void 0) {
|
|
20271
|
+
lines.push("", "Provider reachability:");
|
|
20272
|
+
const reachability = report.providerReachability;
|
|
20273
|
+
lines.push(reachability.ok ? ` Provider ${reachability.name}: ${reachability.baseUrl} accepts connections` : ` [FAIL] ${reachability.message}`);
|
|
20274
|
+
}
|
|
20192
20275
|
if (report.claudeVersion !== void 0) {
|
|
20193
20276
|
lines.push("", "Claude Code version:");
|
|
20194
20277
|
const { pinned, highestInstalled, installed } = report.claudeVersion;
|
|
@@ -20239,11 +20322,12 @@ function checkReportToJson(report) {
|
|
|
20239
20322
|
...report.keychain === void 0 ? {} : { keychain: report.keychain },
|
|
20240
20323
|
settingsExposure: report.settingsExposure,
|
|
20241
20324
|
credential: report.credential,
|
|
20242
|
-
...report.claudeVersion === void 0 ? {} : { claudeVersion: report.claudeVersion }
|
|
20325
|
+
...report.claudeVersion === void 0 ? {} : { claudeVersion: report.claudeVersion },
|
|
20326
|
+
...report.providerReachability === void 0 ? {} : { providerReachability: report.providerReachability }
|
|
20243
20327
|
};
|
|
20244
20328
|
}
|
|
20245
20329
|
function checkReportHasWarnings(report) {
|
|
20246
|
-
return report.resolved.diagnostics.some((diagnostic) => diagnostic.severity !== "info") || report.projectEncodingAmbiguities.length > 0 || !report.ambientCredential.ok || report.credential.provider?.problem !== void 0 || report.claudeVersion?.pinned?.installed === false;
|
|
20330
|
+
return report.resolved.diagnostics.some((diagnostic) => diagnostic.severity !== "info") || report.projectEncodingAmbiguities.length > 0 || !report.ambientCredential.ok || report.credential.provider?.problem !== void 0 || report.providerReachability?.ok === false || report.claudeVersion?.pinned?.installed === false;
|
|
20247
20331
|
}
|
|
20248
20332
|
function loadCheckProvider(paths, name) {
|
|
20249
20333
|
let definition;
|
|
@@ -20310,7 +20394,8 @@ function collectCheckReport(params) {
|
|
|
20310
20394
|
...isCodex ? {} : { installedClaudeVersions: realInstalledClaudeVersions() },
|
|
20311
20395
|
...farmRoot === void 0 ? {} : { farmRoot },
|
|
20312
20396
|
platform: process.platform,
|
|
20313
|
-
...provider === void 0 ? {} : { provider }
|
|
20397
|
+
...provider === void 0 ? {} : { provider },
|
|
20398
|
+
probeBaseUrl: realBaseUrlProbe
|
|
20314
20399
|
});
|
|
20315
20400
|
return report;
|
|
20316
20401
|
}
|
|
@@ -20475,6 +20560,10 @@ var CheckCredentialProviderSchema = import_zod29.z.union([
|
|
|
20475
20560
|
import_zod29.z.strictObject({ name: import_zod29.z.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
|
|
20476
20561
|
import_zod29.z.strictObject({ name: import_zod29.z.string(), problem: import_zod29.z.string() })
|
|
20477
20562
|
]);
|
|
20563
|
+
var CheckProviderReachabilitySchema = import_zod29.z.union([
|
|
20564
|
+
import_zod29.z.strictObject({ name: import_zod29.z.string(), baseUrl: import_zod29.z.string(), ok: import_zod29.z.literal(true) }),
|
|
20565
|
+
import_zod29.z.strictObject({ name: import_zod29.z.string(), baseUrl: import_zod29.z.string(), ok: import_zod29.z.literal(false), message: import_zod29.z.string() })
|
|
20566
|
+
]);
|
|
20478
20567
|
var CheckCredentialSchema = import_zod29.z.strictObject({
|
|
20479
20568
|
applies: import_zod29.z.enum(CHECK_CREDENTIAL_APPLIES),
|
|
20480
20569
|
provider: CheckCredentialProviderSchema.optional(),
|
|
@@ -20501,7 +20590,8 @@ var CheckReportJsonSchema = import_zod29.z.strictObject({
|
|
|
20501
20590
|
keychain: CheckKeychainSchema.optional(),
|
|
20502
20591
|
settingsExposure: import_zod29.z.readonly(import_zod29.z.array(CheckSettingsExposureSchema)),
|
|
20503
20592
|
credential: CheckCredentialSchema,
|
|
20504
|
-
claudeVersion: CheckClaudeVersionSchema.optional()
|
|
20593
|
+
claudeVersion: CheckClaudeVersionSchema.optional(),
|
|
20594
|
+
providerReachability: CheckProviderReachabilitySchema.optional()
|
|
20505
20595
|
});
|
|
20506
20596
|
|
|
20507
20597
|
// src/frontdoor/controlApi.ts
|
|
@@ -20545,7 +20635,6 @@ function codexIdentityFindings(entry, identity) {
|
|
|
20545
20635
|
// src/doctorReport.ts
|
|
20546
20636
|
init_claudeShim();
|
|
20547
20637
|
init_readableConfig();
|
|
20548
|
-
init_names();
|
|
20549
20638
|
init_store();
|
|
20550
20639
|
init_identityStore();
|
|
20551
20640
|
init_identityRecords();
|
|
@@ -20620,6 +20709,28 @@ var import_node_path42 = __toESM(require("node:path"), 1);
|
|
|
20620
20709
|
init_signIn();
|
|
20621
20710
|
init_identityAccounts();
|
|
20622
20711
|
init_read();
|
|
20712
|
+
init_providerReachability();
|
|
20713
|
+
|
|
20714
|
+
// src/doctorNameFinding.ts
|
|
20715
|
+
init_names();
|
|
20716
|
+
function pushNameFinding(push, section, kind, entry) {
|
|
20717
|
+
if (isFileName(entry.name)) {
|
|
20718
|
+
return true;
|
|
20719
|
+
}
|
|
20720
|
+
if (!isStoredName(entry.name)) {
|
|
20721
|
+
push(section, "fail", `${entry.path} cannot be used as a ${kind}: its name is ${JSON.stringify(entry.name)}, and a name ${FILE_NAME_RULE}. Rename or remove the file.`, entry.name);
|
|
20722
|
+
return false;
|
|
20723
|
+
}
|
|
20724
|
+
push(
|
|
20725
|
+
section,
|
|
20726
|
+
"warn",
|
|
20727
|
+
`The ${kind} ${JSON.stringify(entry.name)} is stored under a name that does not fit the shape names are given now (a name ${FILE_NAME_RULE}). It still works from your own configuration, but a project file cannot name it. Rename ${entry.path} to a name that fits, and change what names it.`,
|
|
20728
|
+
entry.name
|
|
20729
|
+
);
|
|
20730
|
+
return true;
|
|
20731
|
+
}
|
|
20732
|
+
|
|
20733
|
+
// src/doctorReport.ts
|
|
20623
20734
|
init_siwcStore();
|
|
20624
20735
|
init_siwc();
|
|
20625
20736
|
init_load();
|
|
@@ -21114,23 +21225,7 @@ function signInProblem(signIn) {
|
|
|
21114
21225
|
return error instanceof Error ? error.message : String(error);
|
|
21115
21226
|
}
|
|
21116
21227
|
}
|
|
21117
|
-
function
|
|
21118
|
-
if (isFileName(entry.name)) {
|
|
21119
|
-
return true;
|
|
21120
|
-
}
|
|
21121
|
-
if (!isStoredName(entry.name)) {
|
|
21122
|
-
push(section, "fail", `${entry.path} cannot be used as a ${kind}: its name is ${JSON.stringify(entry.name)}, and a name ${FILE_NAME_RULE}. Rename or remove the file.`, entry.name);
|
|
21123
|
-
return false;
|
|
21124
|
-
}
|
|
21125
|
-
push(
|
|
21126
|
-
section,
|
|
21127
|
-
"warn",
|
|
21128
|
-
`The ${kind} ${JSON.stringify(entry.name)} is stored under a name that does not fit the shape names are given now (a name ${FILE_NAME_RULE}). It still works from your own configuration, but a project file cannot name it. Rename ${entry.path} to a name that fits, and change what names it.`,
|
|
21129
|
-
entry.name
|
|
21130
|
-
);
|
|
21131
|
-
return true;
|
|
21132
|
-
}
|
|
21133
|
-
function pushProvider(push, entry, cacheEnv, signIn) {
|
|
21228
|
+
function pushProvider(push, entry, cacheEnv, signIn, probeBaseUrl) {
|
|
21134
21229
|
if (entry.raw === void 0) {
|
|
21135
21230
|
push("provider", "fail", `${entry.path} is missing.`, entry.name);
|
|
21136
21231
|
return;
|
|
@@ -21162,6 +21257,10 @@ function pushProvider(push, entry, cacheEnv, signIn) {
|
|
|
21162
21257
|
if (!router && validated3.data.env?.ENABLE_TOOL_SEARCH === void 0) {
|
|
21163
21258
|
push("provider", "warn", `${entry.name} does not set ENABLE_TOOL_SEARCH: a session on this provider keeps Claude Code's own API as its base URL, so it defers MCP tool loading and sends tool_reference payloads the upstream backend must understand. Set ENABLE_TOOL_SEARCH=false in the provider's env block to load tools upfront instead, when the backend does not support them.`, entry.name);
|
|
21164
21259
|
}
|
|
21260
|
+
const unreachable = unreachableProviderLine(entry.name, validated3.data, probeBaseUrl);
|
|
21261
|
+
if (unreachable !== void 0) {
|
|
21262
|
+
push("provider", "fail", unreachable, entry.name);
|
|
21263
|
+
}
|
|
21165
21264
|
if (signIn !== void 0 && isCodexProvider(validated3.data) && validated3.data.codex?.login === "chatgpt-sign-in") {
|
|
21166
21265
|
const problem = signInProblem(signIn);
|
|
21167
21266
|
if (problem !== void 0) {
|
|
@@ -21392,7 +21491,7 @@ function runDoctor(params) {
|
|
|
21392
21491
|
if (!pushNameFinding(push, "provider", "provider", entry)) {
|
|
21393
21492
|
continue;
|
|
21394
21493
|
}
|
|
21395
|
-
pushProvider(push, entry, params.credentialCache, params.chatgptSignIn);
|
|
21494
|
+
pushProvider(push, entry, params.credentialCache, params.chatgptSignIn, params.probeBaseUrl);
|
|
21396
21495
|
}
|
|
21397
21496
|
const providerNames = new Set(params.providers.map((entry) => entry.name));
|
|
21398
21497
|
for (const finding of aliasFindings(params.providerAliases ?? {}, providerNames)) {
|
|
@@ -21699,6 +21798,7 @@ function collectDoctorReport(params) {
|
|
|
21699
21798
|
configProfiles,
|
|
21700
21799
|
providers,
|
|
21701
21800
|
providerAliases: readProviderAliases(paths),
|
|
21801
|
+
probeBaseUrl: realBaseUrlProbe,
|
|
21702
21802
|
renameJournals: listRenameJournals(realFarmFs, paths.identityRenamesDir),
|
|
21703
21803
|
unreachableIdentities,
|
|
21704
21804
|
identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: import_node_fs14.default.existsSync(import_node_path42.default.join(paths.identitiesDir, record.id)) })), nameRenames: unfinishedNameRenames(paths).map((record) => ({ from: record.from, description: describeInterruptedNameRename(paths, record) })), strayNameRenameFiles: strayNameRenameRecordFiles(paths) },
|