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/cli.cjs
CHANGED
|
@@ -28293,6 +28293,8 @@ var init_schema = __esm({
|
|
|
28293
28293
|
kind: external_exports.literal("http").optional(),
|
|
28294
28294
|
displayName: external_exports.string().min(1),
|
|
28295
28295
|
baseUrl: external_exports.url(),
|
|
28296
|
+
/** 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. */
|
|
28297
|
+
connectTimeoutMs: external_exports.int().positive().optional(),
|
|
28296
28298
|
credential: ProviderCredentialSchema,
|
|
28297
28299
|
env: ProviderEnvSchema.optional(),
|
|
28298
28300
|
/** Extra models `/model` lists beside the ones the tier settings name. */
|
|
@@ -42067,6 +42069,9 @@ function addProvider(paths, name, input2) {
|
|
|
42067
42069
|
if (kind !== "http" && kind !== "router" && input2.catalogue !== void 0) {
|
|
42068
42070
|
throw new ProviderKindMismatchError("A model catalogue applies only to an http provider.");
|
|
42069
42071
|
}
|
|
42072
|
+
if (kind !== "http" && input2.connectTimeoutMs !== void 0) {
|
|
42073
|
+
throw new ProviderKindMismatchError("A connect timeout applies only to an http provider, the one kind that dials a base URL.");
|
|
42074
|
+
}
|
|
42070
42075
|
if (kind !== "codex" && !isEmptyCodexConfig(input2.codex)) {
|
|
42071
42076
|
throw new ProviderKindMismatchError("Codex settings apply only to a codex provider (--kind codex).");
|
|
42072
42077
|
}
|
|
@@ -42080,7 +42085,7 @@ function addProvider(paths, name, input2) {
|
|
|
42080
42085
|
...input2.pickerModels === void 0 || input2.pickerModels.length === 0 ? {} : { pickerModels: input2.pickerModels }
|
|
42081
42086
|
};
|
|
42082
42087
|
const parsed = ProviderSchema.safeParse(
|
|
42083
|
-
kind === "router" ? { kind, displayName: input2.displayName } : kind === "codex" ? { kind, ...shared, ...isEmptyCodexConfig(input2.codex) ? {} : { codex: input2.codex } } : kind === "antigravity" ? { kind, ...shared, ...isEmptyAntigravityConfig(input2.antigravity) ? {} : { antigravity: input2.antigravity } } : { ...shared, baseUrl: input2.baseUrl, ...input2.catalogue === void 0 ? {} : { catalogue: input2.catalogue } }
|
|
42088
|
+
kind === "router" ? { kind, displayName: input2.displayName } : kind === "codex" ? { kind, ...shared, ...isEmptyCodexConfig(input2.codex) ? {} : { codex: input2.codex } } : kind === "antigravity" ? { kind, ...shared, ...isEmptyAntigravityConfig(input2.antigravity) ? {} : { antigravity: input2.antigravity } } : { ...shared, baseUrl: input2.baseUrl, ...input2.connectTimeoutMs === void 0 ? {} : { connectTimeoutMs: input2.connectTimeoutMs }, ...input2.catalogue === void 0 ? {} : { catalogue: input2.catalogue } }
|
|
42084
42089
|
);
|
|
42085
42090
|
if (!parsed.success) {
|
|
42086
42091
|
throw new ConfigValidationError(providerJsonPath(paths, name), parsed.error.issues);
|
|
@@ -42112,6 +42117,9 @@ function updateProvider(paths, name, input2) {
|
|
|
42112
42117
|
if (isAntigravityProvider(existing) && input2.baseUrl !== void 0) {
|
|
42113
42118
|
throw new ProviderKindMismatchError(`Provider "${name}" is an antigravity provider, which has no base URL.`);
|
|
42114
42119
|
}
|
|
42120
|
+
if (!isHttpProvider(existing) && input2.connectTimeoutMs !== void 0) {
|
|
42121
|
+
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.`);
|
|
42122
|
+
}
|
|
42115
42123
|
if ((isCodexProvider(existing) || isAntigravityProvider(existing)) && input2.catalogue !== void 0 && input2.catalogue !== false) {
|
|
42116
42124
|
throw new ProviderKindMismatchError(`Provider "${name}" is not an http provider; a model catalogue applies only to an http provider.`);
|
|
42117
42125
|
}
|
|
@@ -42152,7 +42160,8 @@ function updateProvider(paths, name, input2) {
|
|
|
42152
42160
|
candidate = { kind: "router", ...shared };
|
|
42153
42161
|
} else {
|
|
42154
42162
|
const catalogue = input2.catalogue === void 0 ? existing.catalogue : input2.catalogue === false ? void 0 : input2.catalogue;
|
|
42155
|
-
|
|
42163
|
+
const connectTimeoutMs = input2.connectTimeoutMs === void 0 ? existing.connectTimeoutMs : input2.connectTimeoutMs === false ? void 0 : input2.connectTimeoutMs;
|
|
42164
|
+
candidate = { ...existing, ...shared, catalogue, connectTimeoutMs, ...input2.baseUrl === void 0 ? {} : { baseUrl: input2.baseUrl } };
|
|
42156
42165
|
}
|
|
42157
42166
|
const parsed = ProviderSchema.safeParse(candidate);
|
|
42158
42167
|
if (!parsed.success) {
|
|
@@ -42341,7 +42350,7 @@ var init_package = __esm({
|
|
|
42341
42350
|
"package.json"() {
|
|
42342
42351
|
package_default = {
|
|
42343
42352
|
name: "claude-use",
|
|
42344
|
-
version: "12.
|
|
42353
|
+
version: "12.2.0",
|
|
42345
42354
|
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.",
|
|
42346
42355
|
license: "MIT",
|
|
42347
42356
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -42552,6 +42561,185 @@ var init_memberProvider = __esm({
|
|
|
42552
42561
|
}
|
|
42553
42562
|
});
|
|
42554
42563
|
|
|
42564
|
+
// src/frontdoor/probe.ts
|
|
42565
|
+
function requestCatalogueRefreshSync(port, caPem, token, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
42566
|
+
refuseToBlockInRole("a synchronous catalogue refresh request");
|
|
42567
|
+
return runProbeWorker(CATALOGUE_REQUEST_SOURCE, { port, ca: caPem, token }, timeoutMs);
|
|
42568
|
+
}
|
|
42569
|
+
function probeFrontDoorSync(port, caPem, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
42570
|
+
refuseToBlockInRole("a synchronous probe of the front door");
|
|
42571
|
+
return runProbeWorker(PROBE_SOURCE, { port, ca: caPem }, timeoutMs);
|
|
42572
|
+
}
|
|
42573
|
+
function probeListenerAcceptSync(port, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
42574
|
+
refuseToBlockInRole("a synchronous probe of a front door listener");
|
|
42575
|
+
return runProbeWorker(ACCEPT_PROBE_SOURCE, { host: "127.0.0.1", port }, timeoutMs);
|
|
42576
|
+
}
|
|
42577
|
+
function probeAddressAcceptSync(host, port, timeoutMs) {
|
|
42578
|
+
refuseToBlockInRole("a synchronous probe of a provider's address");
|
|
42579
|
+
return runProbeWorker(ACCEPT_PROBE_SOURCE, { host, port }, timeoutMs);
|
|
42580
|
+
}
|
|
42581
|
+
function runProbeWorker(source, data, timeoutMs) {
|
|
42582
|
+
const shared = new SharedArrayBuffer(HEADER_SLOTS * INT32_BYTES + REASON_BYTES);
|
|
42583
|
+
const header = new Int32Array(shared, 0, HEADER_SLOTS);
|
|
42584
|
+
const worker = new import_node_worker_threads.Worker(source, {
|
|
42585
|
+
eval: true,
|
|
42586
|
+
workerData: { ...data, timeoutMs, shared, ok: VERDICT_OK, failed: VERDICT_FAILED, headerSlots: HEADER_SLOTS }
|
|
42587
|
+
});
|
|
42588
|
+
worker.unref();
|
|
42589
|
+
try {
|
|
42590
|
+
const waited = Atomics.wait(header, 0, VERDICT_PENDING, timeoutMs + PROBE_WAIT_MARGIN_MS);
|
|
42591
|
+
const verdict = Atomics.load(header, 0);
|
|
42592
|
+
if (waited === "timed-out" || verdict === VERDICT_PENDING) {
|
|
42593
|
+
return { ok: false, reason: `the probe did not finish within ${String(timeoutMs + PROBE_WAIT_MARGIN_MS)}ms` };
|
|
42594
|
+
}
|
|
42595
|
+
if (verdict === VERDICT_OK) {
|
|
42596
|
+
return { ok: true };
|
|
42597
|
+
}
|
|
42598
|
+
const length = Atomics.load(header, 1);
|
|
42599
|
+
return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
|
|
42600
|
+
} finally {
|
|
42601
|
+
void worker.terminate();
|
|
42602
|
+
}
|
|
42603
|
+
}
|
|
42604
|
+
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;
|
|
42605
|
+
var init_probe = __esm({
|
|
42606
|
+
"src/frontdoor/probe.ts"() {
|
|
42607
|
+
"use strict";
|
|
42608
|
+
init_processRole();
|
|
42609
|
+
import_node_worker_threads = require("node:worker_threads");
|
|
42610
|
+
PROBE_TIMEOUT_MS = 2e3;
|
|
42611
|
+
PROBE_WAIT_MARGIN_MS = 1e3;
|
|
42612
|
+
REASON_BYTES = 1024;
|
|
42613
|
+
HEADER_SLOTS = 2;
|
|
42614
|
+
INT32_BYTES = 4;
|
|
42615
|
+
VERDICT_PENDING = 0;
|
|
42616
|
+
VERDICT_OK = 1;
|
|
42617
|
+
VERDICT_FAILED = 2;
|
|
42618
|
+
PROBE_SOURCE = `
|
|
42619
|
+
const { workerData } = require("node:worker_threads");
|
|
42620
|
+
const https = require("node:https");
|
|
42621
|
+
const { port, ca, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
42622
|
+
const header = new Int32Array(shared, 0, headerSlots);
|
|
42623
|
+
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
42624
|
+
let done = false;
|
|
42625
|
+
const finish = (verdict, message) => {
|
|
42626
|
+
if (done) return;
|
|
42627
|
+
done = true;
|
|
42628
|
+
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
42629
|
+
reason.set(bytes);
|
|
42630
|
+
Atomics.store(header, 1, bytes.length);
|
|
42631
|
+
Atomics.store(header, 0, verdict);
|
|
42632
|
+
Atomics.notify(header, 0);
|
|
42633
|
+
};
|
|
42634
|
+
const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
|
|
42635
|
+
let body = "";
|
|
42636
|
+
response.setEncoding("utf8");
|
|
42637
|
+
response.on("data", (chunk) => { body += chunk; });
|
|
42638
|
+
response.on("end", () => {
|
|
42639
|
+
if (response.statusCode === 200 && body === "ok") finish(ok, "");
|
|
42640
|
+
else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
|
|
42641
|
+
});
|
|
42642
|
+
response.on("error", (error) => finish(failed, error.message));
|
|
42643
|
+
});
|
|
42644
|
+
// A hard deadline over the whole exchange, handshake included: a listener that accepts the connection and then says nothing must still fail the probe.
|
|
42645
|
+
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
42646
|
+
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
42647
|
+
`;
|
|
42648
|
+
CATALOGUE_REQUEST_SOURCE = `
|
|
42649
|
+
const { workerData } = require("node:worker_threads");
|
|
42650
|
+
const https = require("node:https");
|
|
42651
|
+
const { port, ca, token, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
42652
|
+
const header = new Int32Array(shared, 0, headerSlots);
|
|
42653
|
+
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
42654
|
+
let done = false;
|
|
42655
|
+
const finish = (verdict, message) => {
|
|
42656
|
+
if (done) return;
|
|
42657
|
+
done = true;
|
|
42658
|
+
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
42659
|
+
reason.set(bytes);
|
|
42660
|
+
Atomics.store(header, 1, bytes.length);
|
|
42661
|
+
Atomics.store(header, 0, verdict);
|
|
42662
|
+
Atomics.notify(header, 0);
|
|
42663
|
+
};
|
|
42664
|
+
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) => {
|
|
42665
|
+
response.resume();
|
|
42666
|
+
response.on("end", () => response.statusCode === 200 ? finish(ok, "") : finish(failed, "catalogue refresh request returned HTTP " + String(response.statusCode)));
|
|
42667
|
+
response.on("error", (error) => finish(failed, error.message));
|
|
42668
|
+
});
|
|
42669
|
+
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
42670
|
+
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
42671
|
+
request.end();
|
|
42672
|
+
`;
|
|
42673
|
+
ACCEPT_PROBE_SOURCE = `
|
|
42674
|
+
const { workerData } = require("node:worker_threads");
|
|
42675
|
+
const net = require("node:net");
|
|
42676
|
+
const { host, port, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
42677
|
+
const header = new Int32Array(shared, 0, headerSlots);
|
|
42678
|
+
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
42679
|
+
let done = false;
|
|
42680
|
+
const finish = (verdict, message) => {
|
|
42681
|
+
if (done) return;
|
|
42682
|
+
done = true;
|
|
42683
|
+
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
42684
|
+
reason.set(bytes);
|
|
42685
|
+
Atomics.store(header, 1, bytes.length);
|
|
42686
|
+
Atomics.store(header, 0, verdict);
|
|
42687
|
+
Atomics.notify(header, 0);
|
|
42688
|
+
};
|
|
42689
|
+
const socket = net.connect({ host, port });
|
|
42690
|
+
socket.once("connect", () => { socket.destroy(); finish(ok, ""); });
|
|
42691
|
+
socket.once("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
42692
|
+
setTimeout(() => { socket.destroy(); finish(failed, "no connection accepted within " + String(timeoutMs) + "ms"); }, timeoutMs);
|
|
42693
|
+
`;
|
|
42694
|
+
}
|
|
42695
|
+
});
|
|
42696
|
+
|
|
42697
|
+
// src/providerReachability.ts
|
|
42698
|
+
function providerConnectTimeoutMs(provider) {
|
|
42699
|
+
return provider.connectTimeoutMs ?? DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS;
|
|
42700
|
+
}
|
|
42701
|
+
function dialTargetOf(baseUrl) {
|
|
42702
|
+
const url2 = new URL(baseUrl);
|
|
42703
|
+
const defaultPort = DEFAULT_PORTS[url2.protocol];
|
|
42704
|
+
if (defaultPort === void 0) {
|
|
42705
|
+
return void 0;
|
|
42706
|
+
}
|
|
42707
|
+
return { host: url2.hostname.replace(/^\[(.*)\]$/, "$1"), port: url2.port === "" ? defaultPort : Number(url2.port) };
|
|
42708
|
+
}
|
|
42709
|
+
function couldNotConnectMessage(subject, baseUrl, reason) {
|
|
42710
|
+
return `${subject} could not connect to ${baseUrl}: ${reason}`;
|
|
42711
|
+
}
|
|
42712
|
+
function probeProviderReachability(name, provider, probe) {
|
|
42713
|
+
const verdict = probe(provider.baseUrl, providerConnectTimeoutMs(provider));
|
|
42714
|
+
return verdict.ok ? { ok: true } : { ok: false, message: couldNotConnectMessage(`provider ${name}`, provider.baseUrl, verdict.reason) };
|
|
42715
|
+
}
|
|
42716
|
+
function unreachableProviderLine(name, provider, probe) {
|
|
42717
|
+
if (probe === void 0 || !isHttpProvider(provider)) {
|
|
42718
|
+
return void 0;
|
|
42719
|
+
}
|
|
42720
|
+
const reachability = probeProviderReachability(name, provider, probe);
|
|
42721
|
+
return reachability.ok ? void 0 : reachability.message;
|
|
42722
|
+
}
|
|
42723
|
+
var TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS, CONNECT_SYN_RETRANSMISSIONS_TOLERATED, DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS, DEFAULT_PORTS, realBaseUrlProbe;
|
|
42724
|
+
var init_providerReachability = __esm({
|
|
42725
|
+
"src/providerReachability.ts"() {
|
|
42726
|
+
"use strict";
|
|
42727
|
+
init_schema();
|
|
42728
|
+
init_probe();
|
|
42729
|
+
TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS = 1e3;
|
|
42730
|
+
CONNECT_SYN_RETRANSMISSIONS_TOLERATED = 2;
|
|
42731
|
+
DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS = TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS * (2 ** (CONNECT_SYN_RETRANSMISSIONS_TOLERATED + 1) - 1);
|
|
42732
|
+
DEFAULT_PORTS = { "http:": 80, "https:": 443 };
|
|
42733
|
+
realBaseUrlProbe = (baseUrl, timeoutMs) => {
|
|
42734
|
+
const target = dialTargetOf(baseUrl);
|
|
42735
|
+
if (target === void 0) {
|
|
42736
|
+
return { ok: false, reason: "the base URL is neither http nor https" };
|
|
42737
|
+
}
|
|
42738
|
+
return probeAddressAcceptSync(target.host, target.port, timeoutMs);
|
|
42739
|
+
};
|
|
42740
|
+
}
|
|
42741
|
+
});
|
|
42742
|
+
|
|
42555
42743
|
// src/launcher/claudeVersion.ts
|
|
42556
42744
|
function validated2(value3, origin) {
|
|
42557
42745
|
if (!NUMERIC_DOTTED_VERSION_RE.test(value3)) {
|
|
@@ -53450,7 +53638,7 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
53450
53638
|
var { kClose, kDestroy, kClosed, kDestroyed, kDispatch, kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent } = require_symbols();
|
|
53451
53639
|
var ProxyAgent = require_proxy_agent();
|
|
53452
53640
|
var Agent6 = require_agent();
|
|
53453
|
-
var
|
|
53641
|
+
var DEFAULT_PORTS2 = {
|
|
53454
53642
|
"http:": 80,
|
|
53455
53643
|
"https:": 443
|
|
53456
53644
|
};
|
|
@@ -53499,7 +53687,7 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
53499
53687
|
#getProxyAgentForUrl(url2) {
|
|
53500
53688
|
let { protocol, host: hostname3, port } = url2;
|
|
53501
53689
|
hostname3 = hostname3.replace(/:\d*$/, "").toLowerCase();
|
|
53502
|
-
port = Number.parseInt(port, 10) ||
|
|
53690
|
+
port = Number.parseInt(port, 10) || DEFAULT_PORTS2[protocol] || 0;
|
|
53503
53691
|
if (!this.#shouldProxy(hostname3, port)) {
|
|
53504
53692
|
return this[kNoProxyAgent];
|
|
53505
53693
|
}
|
|
@@ -69613,135 +69801,6 @@ var init_ensure2 = __esm({
|
|
|
69613
69801
|
}
|
|
69614
69802
|
});
|
|
69615
69803
|
|
|
69616
|
-
// src/frontdoor/probe.ts
|
|
69617
|
-
function requestCatalogueRefreshSync(port, caPem, token, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
69618
|
-
refuseToBlockInRole("a synchronous catalogue refresh request");
|
|
69619
|
-
return runProbeWorker(CATALOGUE_REQUEST_SOURCE, { port, ca: caPem, token }, timeoutMs);
|
|
69620
|
-
}
|
|
69621
|
-
function probeFrontDoorSync(port, caPem, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
69622
|
-
refuseToBlockInRole("a synchronous probe of the front door");
|
|
69623
|
-
return runProbeWorker(PROBE_SOURCE, { port, ca: caPem }, timeoutMs);
|
|
69624
|
-
}
|
|
69625
|
-
function probeListenerAcceptSync(port, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
69626
|
-
refuseToBlockInRole("a synchronous probe of a front door listener");
|
|
69627
|
-
return runProbeWorker(ACCEPT_PROBE_SOURCE, { port }, timeoutMs);
|
|
69628
|
-
}
|
|
69629
|
-
function runProbeWorker(source, data, timeoutMs) {
|
|
69630
|
-
const shared = new SharedArrayBuffer(HEADER_SLOTS * INT32_BYTES + REASON_BYTES);
|
|
69631
|
-
const header = new Int32Array(shared, 0, HEADER_SLOTS);
|
|
69632
|
-
const worker = new import_node_worker_threads.Worker(source, {
|
|
69633
|
-
eval: true,
|
|
69634
|
-
workerData: { ...data, timeoutMs, shared, ok: VERDICT_OK, failed: VERDICT_FAILED, headerSlots: HEADER_SLOTS }
|
|
69635
|
-
});
|
|
69636
|
-
worker.unref();
|
|
69637
|
-
try {
|
|
69638
|
-
const waited = Atomics.wait(header, 0, VERDICT_PENDING, timeoutMs + PROBE_WAIT_MARGIN_MS);
|
|
69639
|
-
const verdict = Atomics.load(header, 0);
|
|
69640
|
-
if (waited === "timed-out" || verdict === VERDICT_PENDING) {
|
|
69641
|
-
return { ok: false, reason: `the probe did not finish within ${String(timeoutMs + PROBE_WAIT_MARGIN_MS)}ms` };
|
|
69642
|
-
}
|
|
69643
|
-
if (verdict === VERDICT_OK) {
|
|
69644
|
-
return { ok: true };
|
|
69645
|
-
}
|
|
69646
|
-
const length = Atomics.load(header, 1);
|
|
69647
|
-
return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
|
|
69648
|
-
} finally {
|
|
69649
|
-
void worker.terminate();
|
|
69650
|
-
}
|
|
69651
|
-
}
|
|
69652
|
-
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;
|
|
69653
|
-
var init_probe = __esm({
|
|
69654
|
-
"src/frontdoor/probe.ts"() {
|
|
69655
|
-
"use strict";
|
|
69656
|
-
init_processRole();
|
|
69657
|
-
import_node_worker_threads = require("node:worker_threads");
|
|
69658
|
-
PROBE_TIMEOUT_MS = 2e3;
|
|
69659
|
-
PROBE_WAIT_MARGIN_MS = 1e3;
|
|
69660
|
-
REASON_BYTES = 1024;
|
|
69661
|
-
HEADER_SLOTS = 2;
|
|
69662
|
-
INT32_BYTES = 4;
|
|
69663
|
-
VERDICT_PENDING = 0;
|
|
69664
|
-
VERDICT_OK = 1;
|
|
69665
|
-
VERDICT_FAILED = 2;
|
|
69666
|
-
PROBE_SOURCE = `
|
|
69667
|
-
const { workerData } = require("node:worker_threads");
|
|
69668
|
-
const https = require("node:https");
|
|
69669
|
-
const { port, ca, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
69670
|
-
const header = new Int32Array(shared, 0, headerSlots);
|
|
69671
|
-
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
69672
|
-
let done = false;
|
|
69673
|
-
const finish = (verdict, message) => {
|
|
69674
|
-
if (done) return;
|
|
69675
|
-
done = true;
|
|
69676
|
-
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
69677
|
-
reason.set(bytes);
|
|
69678
|
-
Atomics.store(header, 1, bytes.length);
|
|
69679
|
-
Atomics.store(header, 0, verdict);
|
|
69680
|
-
Atomics.notify(header, 0);
|
|
69681
|
-
};
|
|
69682
|
-
const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
|
|
69683
|
-
let body = "";
|
|
69684
|
-
response.setEncoding("utf8");
|
|
69685
|
-
response.on("data", (chunk) => { body += chunk; });
|
|
69686
|
-
response.on("end", () => {
|
|
69687
|
-
if (response.statusCode === 200 && body === "ok") finish(ok, "");
|
|
69688
|
-
else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
|
|
69689
|
-
});
|
|
69690
|
-
response.on("error", (error) => finish(failed, error.message));
|
|
69691
|
-
});
|
|
69692
|
-
// A hard deadline over the whole exchange, handshake included: a listener that accepts the connection and then says nothing must still fail the probe.
|
|
69693
|
-
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
69694
|
-
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
69695
|
-
`;
|
|
69696
|
-
CATALOGUE_REQUEST_SOURCE = `
|
|
69697
|
-
const { workerData } = require("node:worker_threads");
|
|
69698
|
-
const https = require("node:https");
|
|
69699
|
-
const { port, ca, token, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
69700
|
-
const header = new Int32Array(shared, 0, headerSlots);
|
|
69701
|
-
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
69702
|
-
let done = false;
|
|
69703
|
-
const finish = (verdict, message) => {
|
|
69704
|
-
if (done) return;
|
|
69705
|
-
done = true;
|
|
69706
|
-
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
69707
|
-
reason.set(bytes);
|
|
69708
|
-
Atomics.store(header, 1, bytes.length);
|
|
69709
|
-
Atomics.store(header, 0, verdict);
|
|
69710
|
-
Atomics.notify(header, 0);
|
|
69711
|
-
};
|
|
69712
|
-
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) => {
|
|
69713
|
-
response.resume();
|
|
69714
|
-
response.on("end", () => response.statusCode === 200 ? finish(ok, "") : finish(failed, "catalogue refresh request returned HTTP " + String(response.statusCode)));
|
|
69715
|
-
response.on("error", (error) => finish(failed, error.message));
|
|
69716
|
-
});
|
|
69717
|
-
setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
|
|
69718
|
-
request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
69719
|
-
request.end();
|
|
69720
|
-
`;
|
|
69721
|
-
ACCEPT_PROBE_SOURCE = `
|
|
69722
|
-
const { workerData } = require("node:worker_threads");
|
|
69723
|
-
const net = require("node:net");
|
|
69724
|
-
const { port, timeoutMs, shared, ok, failed, headerSlots } = workerData;
|
|
69725
|
-
const header = new Int32Array(shared, 0, headerSlots);
|
|
69726
|
-
const reason = new Uint8Array(shared, headerSlots * 4);
|
|
69727
|
-
let done = false;
|
|
69728
|
-
const finish = (verdict, message) => {
|
|
69729
|
-
if (done) return;
|
|
69730
|
-
done = true;
|
|
69731
|
-
const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
|
|
69732
|
-
reason.set(bytes);
|
|
69733
|
-
Atomics.store(header, 1, bytes.length);
|
|
69734
|
-
Atomics.store(header, 0, verdict);
|
|
69735
|
-
Atomics.notify(header, 0);
|
|
69736
|
-
};
|
|
69737
|
-
const socket = net.connect({ host: "127.0.0.1", port });
|
|
69738
|
-
socket.once("connect", () => { socket.destroy(); finish(ok, ""); });
|
|
69739
|
-
socket.once("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
|
|
69740
|
-
setTimeout(() => { socket.destroy(); finish(failed, "no connection accepted within " + String(timeoutMs) + "ms"); }, timeoutMs);
|
|
69741
|
-
`;
|
|
69742
|
-
}
|
|
69743
|
-
});
|
|
69744
|
-
|
|
69745
69804
|
// src/frontdoor/selfIdentity.ts
|
|
69746
69805
|
function declareThisProcessTheFrontDoor() {
|
|
69747
69806
|
declaredPid = process.pid;
|
|
@@ -73664,6 +73723,11 @@ function prepareRegisteredLaunch(params, onRecorded) {
|
|
|
73664
73723
|
proc.exit(check2.status);
|
|
73665
73724
|
}
|
|
73666
73725
|
}
|
|
73726
|
+
const unreachable = resolvedProvider === void 0 ? void 0 : unreachableProviderLine(resolvedProvider.name, resolvedProvider.definition, params.probeBaseUrl);
|
|
73727
|
+
if (unreachable !== void 0) {
|
|
73728
|
+
log.error(`agent-shim: ${unreachable}`);
|
|
73729
|
+
proc.exit(1);
|
|
73730
|
+
}
|
|
73667
73731
|
const frontDoorPort = params.frontdoor;
|
|
73668
73732
|
const frontDoorEngaged = resolvedProvider !== void 0 || resolvedFlags.headroom || resolvedFlags.trackUsage;
|
|
73669
73733
|
if (frontDoorEngaged && frontDoorPort === void 0) {
|
|
@@ -73819,6 +73883,7 @@ var init_launcher = __esm({
|
|
|
73819
73883
|
init_flatten();
|
|
73820
73884
|
init_walk();
|
|
73821
73885
|
init_schema();
|
|
73886
|
+
init_providerReachability();
|
|
73822
73887
|
init_schema();
|
|
73823
73888
|
init_credential();
|
|
73824
73889
|
init_middleware();
|
|
@@ -73940,6 +74005,7 @@ function realPrepareLaunchParams(paths, options) {
|
|
|
73940
74005
|
headroom: realHeadroomPort(paths, { spawnDaemon: options.spawnDaemon, cwd: farm.runtime.cwd }),
|
|
73941
74006
|
frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
|
|
73942
74007
|
credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
|
|
74008
|
+
probeBaseUrl: realBaseUrlProbe,
|
|
73943
74009
|
hold: realHoldPort,
|
|
73944
74010
|
hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: import_node_path59.default.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
|
|
73945
74011
|
hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin, import_node_path59.default.join(paths.identitiesDir, identity), options.proc.env),
|
|
@@ -74004,6 +74070,7 @@ var init_launchWiring = __esm({
|
|
|
74004
74070
|
init_replayRun();
|
|
74005
74071
|
init_paths();
|
|
74006
74072
|
init_signIn();
|
|
74073
|
+
init_providerReachability();
|
|
74007
74074
|
init_realPorts();
|
|
74008
74075
|
LaunchRefusedError = class extends CliError {
|
|
74009
74076
|
exitCode;
|
|
@@ -124924,6 +124991,7 @@ init_zod();
|
|
|
124924
124991
|
init_envBool();
|
|
124925
124992
|
init_load();
|
|
124926
124993
|
init_schema();
|
|
124994
|
+
init_providerReachability();
|
|
124927
124995
|
init_identityStore();
|
|
124928
124996
|
init_credential();
|
|
124929
124997
|
init_claudeVersion();
|
|
@@ -125116,6 +125184,7 @@ function runCheck(params) {
|
|
|
125116
125184
|
const settingsExposure = inspectSettingsExposure({ settingsShared, files: params.settingsFiles });
|
|
125117
125185
|
const keychain = !isCodex && params.platform === "darwin" && params.run !== void 0 && params.farmRoot !== void 0 ? lookupKeychainService(params.run, params.farmRoot) : void 0;
|
|
125118
125186
|
const claudeVersion = isCodex ? void 0 : buildClaudeVersionReport(params, resolved.flattened.launch.claudeVersion);
|
|
125187
|
+
const providerReachability = buildProviderReachability(params.provider, params.probeBaseUrl);
|
|
125119
125188
|
return {
|
|
125120
125189
|
...params.identityName === void 0 ? {} : { identityName: params.identityName },
|
|
125121
125190
|
identitySource: params.identitySource,
|
|
@@ -125129,9 +125198,18 @@ function runCheck(params) {
|
|
|
125129
125198
|
...keychain === void 0 ? {} : { keychain },
|
|
125130
125199
|
settingsExposure,
|
|
125131
125200
|
credential: buildCredentialReport(params.provider, params.identity, params.identityId, params.credentialCache),
|
|
125132
|
-
...claudeVersion === void 0 ? {} : { claudeVersion }
|
|
125201
|
+
...claudeVersion === void 0 ? {} : { claudeVersion },
|
|
125202
|
+
...providerReachability === void 0 ? {} : { providerReachability }
|
|
125133
125203
|
};
|
|
125134
125204
|
}
|
|
125205
|
+
function buildProviderReachability(provider, probe) {
|
|
125206
|
+
if (provider?.definition === void 0 || probe === void 0 || !isHttpProvider(provider.definition)) {
|
|
125207
|
+
return void 0;
|
|
125208
|
+
}
|
|
125209
|
+
const { baseUrl } = provider.definition;
|
|
125210
|
+
const reachability = probeProviderReachability(provider.name, provider.definition, probe);
|
|
125211
|
+
return reachability.ok ? { name: provider.name, baseUrl, ok: true } : { name: provider.name, baseUrl, ok: false, message: reachability.message };
|
|
125212
|
+
}
|
|
125135
125213
|
function formatCheckReport(report) {
|
|
125136
125214
|
const lines = [];
|
|
125137
125215
|
lines.push(`Identity: ${report.identityName ?? "(none)"} (${report.identitySource})`);
|
|
@@ -125178,6 +125256,11 @@ function formatCheckReport(report) {
|
|
|
125178
125256
|
if (credential.applies === "stored-login") {
|
|
125179
125257
|
lines.push(" The identity's stored login (no credential block applies).");
|
|
125180
125258
|
}
|
|
125259
|
+
if (report.providerReachability !== void 0) {
|
|
125260
|
+
lines.push("", "Provider reachability:");
|
|
125261
|
+
const reachability = report.providerReachability;
|
|
125262
|
+
lines.push(reachability.ok ? ` Provider ${reachability.name}: ${reachability.baseUrl} accepts connections` : ` [FAIL] ${reachability.message}`);
|
|
125263
|
+
}
|
|
125181
125264
|
if (report.claudeVersion !== void 0) {
|
|
125182
125265
|
lines.push("", "Claude Code version:");
|
|
125183
125266
|
const { pinned, highestInstalled, installed } = report.claudeVersion;
|
|
@@ -125228,11 +125311,12 @@ function checkReportToJson(report) {
|
|
|
125228
125311
|
...report.keychain === void 0 ? {} : { keychain: report.keychain },
|
|
125229
125312
|
settingsExposure: report.settingsExposure,
|
|
125230
125313
|
credential: report.credential,
|
|
125231
|
-
...report.claudeVersion === void 0 ? {} : { claudeVersion: report.claudeVersion }
|
|
125314
|
+
...report.claudeVersion === void 0 ? {} : { claudeVersion: report.claudeVersion },
|
|
125315
|
+
...report.providerReachability === void 0 ? {} : { providerReachability: report.providerReachability }
|
|
125232
125316
|
};
|
|
125233
125317
|
}
|
|
125234
125318
|
function checkReportHasWarnings(report) {
|
|
125235
|
-
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;
|
|
125319
|
+
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;
|
|
125236
125320
|
}
|
|
125237
125321
|
function loadCheckProvider(paths, name) {
|
|
125238
125322
|
let definition;
|
|
@@ -125299,7 +125383,8 @@ function collectCheckReport(params) {
|
|
|
125299
125383
|
...isCodex ? {} : { installedClaudeVersions: realInstalledClaudeVersions() },
|
|
125300
125384
|
...farmRoot === void 0 ? {} : { farmRoot },
|
|
125301
125385
|
platform: process.platform,
|
|
125302
|
-
...provider === void 0 ? {} : { provider }
|
|
125386
|
+
...provider === void 0 ? {} : { provider },
|
|
125387
|
+
probeBaseUrl: realBaseUrlProbe
|
|
125303
125388
|
});
|
|
125304
125389
|
return report;
|
|
125305
125390
|
}
|
|
@@ -130111,7 +130196,6 @@ function codexIdentityFindings(entry, identity) {
|
|
|
130111
130196
|
// src/doctorReport.ts
|
|
130112
130197
|
init_claudeShim();
|
|
130113
130198
|
init_readableConfig();
|
|
130114
|
-
init_names();
|
|
130115
130199
|
init_store();
|
|
130116
130200
|
init_identityStore();
|
|
130117
130201
|
init_identityRecords();
|
|
@@ -130186,6 +130270,28 @@ var import_node_path63 = __toESM(require("node:path"), 1);
|
|
|
130186
130270
|
init_signIn();
|
|
130187
130271
|
init_identityAccounts();
|
|
130188
130272
|
init_read();
|
|
130273
|
+
init_providerReachability();
|
|
130274
|
+
|
|
130275
|
+
// src/doctorNameFinding.ts
|
|
130276
|
+
init_names();
|
|
130277
|
+
function pushNameFinding(push, section, kind, entry) {
|
|
130278
|
+
if (isFileName(entry.name)) {
|
|
130279
|
+
return true;
|
|
130280
|
+
}
|
|
130281
|
+
if (!isStoredName(entry.name)) {
|
|
130282
|
+
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);
|
|
130283
|
+
return false;
|
|
130284
|
+
}
|
|
130285
|
+
push(
|
|
130286
|
+
section,
|
|
130287
|
+
"warn",
|
|
130288
|
+
`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.`,
|
|
130289
|
+
entry.name
|
|
130290
|
+
);
|
|
130291
|
+
return true;
|
|
130292
|
+
}
|
|
130293
|
+
|
|
130294
|
+
// src/doctorReport.ts
|
|
130189
130295
|
init_siwcStore();
|
|
130190
130296
|
init_siwc();
|
|
130191
130297
|
init_load();
|
|
@@ -130680,23 +130786,7 @@ function signInProblem(signIn) {
|
|
|
130680
130786
|
return error63 instanceof Error ? error63.message : String(error63);
|
|
130681
130787
|
}
|
|
130682
130788
|
}
|
|
130683
|
-
function
|
|
130684
|
-
if (isFileName(entry.name)) {
|
|
130685
|
-
return true;
|
|
130686
|
-
}
|
|
130687
|
-
if (!isStoredName(entry.name)) {
|
|
130688
|
-
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);
|
|
130689
|
-
return false;
|
|
130690
|
-
}
|
|
130691
|
-
push(
|
|
130692
|
-
section,
|
|
130693
|
-
"warn",
|
|
130694
|
-
`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.`,
|
|
130695
|
-
entry.name
|
|
130696
|
-
);
|
|
130697
|
-
return true;
|
|
130698
|
-
}
|
|
130699
|
-
function pushProvider(push, entry, cacheEnv, signIn) {
|
|
130789
|
+
function pushProvider(push, entry, cacheEnv, signIn, probeBaseUrl) {
|
|
130700
130790
|
if (entry.raw === void 0) {
|
|
130701
130791
|
push("provider", "fail", `${entry.path} is missing.`, entry.name);
|
|
130702
130792
|
return;
|
|
@@ -130728,6 +130818,10 @@ function pushProvider(push, entry, cacheEnv, signIn) {
|
|
|
130728
130818
|
if (!router && validated3.data.env?.ENABLE_TOOL_SEARCH === void 0) {
|
|
130729
130819
|
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);
|
|
130730
130820
|
}
|
|
130821
|
+
const unreachable = unreachableProviderLine(entry.name, validated3.data, probeBaseUrl);
|
|
130822
|
+
if (unreachable !== void 0) {
|
|
130823
|
+
push("provider", "fail", unreachable, entry.name);
|
|
130824
|
+
}
|
|
130731
130825
|
if (signIn !== void 0 && isCodexProvider(validated3.data) && validated3.data.codex?.login === "chatgpt-sign-in") {
|
|
130732
130826
|
const problem = signInProblem(signIn);
|
|
130733
130827
|
if (problem !== void 0) {
|
|
@@ -130958,7 +131052,7 @@ function runDoctor(params) {
|
|
|
130958
131052
|
if (!pushNameFinding(push, "provider", "provider", entry)) {
|
|
130959
131053
|
continue;
|
|
130960
131054
|
}
|
|
130961
|
-
pushProvider(push, entry, params.credentialCache, params.chatgptSignIn);
|
|
131055
|
+
pushProvider(push, entry, params.credentialCache, params.chatgptSignIn, params.probeBaseUrl);
|
|
130962
131056
|
}
|
|
130963
131057
|
const providerNames = new Set(params.providers.map((entry) => entry.name));
|
|
130964
131058
|
for (const finding of aliasFindings(params.providerAliases ?? {}, providerNames)) {
|
|
@@ -131265,6 +131359,7 @@ function collectDoctorReport(params) {
|
|
|
131265
131359
|
configProfiles,
|
|
131266
131360
|
providers,
|
|
131267
131361
|
providerAliases: readProviderAliases(paths),
|
|
131362
|
+
probeBaseUrl: realBaseUrlProbe,
|
|
131268
131363
|
renameJournals: listRenameJournals(realFarmFs, paths.identityRenamesDir),
|
|
131269
131364
|
unreachableIdentities,
|
|
131270
131365
|
identityRecords: { all: records, displaced: displacedIdentities.map((record3) => ({ ...record3, directoryPresent: import_node_fs26.default.existsSync(import_node_path63.default.join(paths.identitiesDir, record3.id)) })), nameRenames: unfinishedNameRenames(paths).map((record3) => ({ from: record3.from, description: describeInterruptedNameRename(paths, record3) })), strayNameRenameFiles: strayNameRenameRecordFiles(paths) },
|
|
@@ -138230,6 +138325,10 @@ var CheckCredentialProviderSchema = external_exports.union([
|
|
|
138230
138325
|
external_exports.strictObject({ name: external_exports.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
|
|
138231
138326
|
external_exports.strictObject({ name: external_exports.string(), problem: external_exports.string() })
|
|
138232
138327
|
]);
|
|
138328
|
+
var CheckProviderReachabilitySchema = external_exports.union([
|
|
138329
|
+
external_exports.strictObject({ name: external_exports.string(), baseUrl: external_exports.string(), ok: external_exports.literal(true) }),
|
|
138330
|
+
external_exports.strictObject({ name: external_exports.string(), baseUrl: external_exports.string(), ok: external_exports.literal(false), message: external_exports.string() })
|
|
138331
|
+
]);
|
|
138233
138332
|
var CheckCredentialSchema = external_exports.strictObject({
|
|
138234
138333
|
applies: external_exports.enum(CHECK_CREDENTIAL_APPLIES),
|
|
138235
138334
|
provider: CheckCredentialProviderSchema.optional(),
|
|
@@ -138256,7 +138355,8 @@ var CheckReportJsonSchema = external_exports.strictObject({
|
|
|
138256
138355
|
keychain: CheckKeychainSchema.optional(),
|
|
138257
138356
|
settingsExposure: external_exports.readonly(external_exports.array(CheckSettingsExposureSchema)),
|
|
138258
138357
|
credential: CheckCredentialSchema,
|
|
138259
|
-
claudeVersion: CheckClaudeVersionSchema.optional()
|
|
138358
|
+
claudeVersion: CheckClaudeVersionSchema.optional(),
|
|
138359
|
+
providerReachability: CheckProviderReachabilitySchema.optional()
|
|
138260
138360
|
});
|
|
138261
138361
|
|
|
138262
138362
|
// src/frontdoor/controlApi.ts
|
|
@@ -144437,6 +144537,7 @@ init_translate();
|
|
|
144437
144537
|
init_quota();
|
|
144438
144538
|
init_credential();
|
|
144439
144539
|
init_providersStore();
|
|
144540
|
+
init_providerReachability();
|
|
144440
144541
|
|
|
144441
144542
|
// src/codex/route.ts
|
|
144442
144543
|
init_route();
|
|
@@ -145843,8 +145944,32 @@ init_connect();
|
|
|
145843
145944
|
// src/frontdoor/passthrough.ts
|
|
145844
145945
|
var http5 = __toESM(require("node:http"), 1);
|
|
145845
145946
|
var https4 = __toESM(require("node:https"), 1);
|
|
145947
|
+
init_providerReachability();
|
|
145846
145948
|
init_connect();
|
|
145847
145949
|
init_unifiedRefusal();
|
|
145950
|
+
function armConnectDeadline(forward, timeoutMs, giveUp) {
|
|
145951
|
+
let connected = false;
|
|
145952
|
+
const deadline = setTimeout(() => {
|
|
145953
|
+
const error63 = new Error(`no connection within ${String(timeoutMs)}ms`);
|
|
145954
|
+
forward.destroy(error63);
|
|
145955
|
+
giveUp(error63);
|
|
145956
|
+
}, timeoutMs);
|
|
145957
|
+
const opened = () => {
|
|
145958
|
+
connected = true;
|
|
145959
|
+
clearTimeout(deadline);
|
|
145960
|
+
};
|
|
145961
|
+
forward.once("socket", (socket) => {
|
|
145962
|
+
if (socket.connecting) {
|
|
145963
|
+
socket.once("connect", opened);
|
|
145964
|
+
} else {
|
|
145965
|
+
opened();
|
|
145966
|
+
}
|
|
145967
|
+
});
|
|
145968
|
+
forward.once("close", () => {
|
|
145969
|
+
clearTimeout(deadline);
|
|
145970
|
+
});
|
|
145971
|
+
return { connected: () => connected };
|
|
145972
|
+
}
|
|
145848
145973
|
var TOO_MANY_REQUESTS3 = 429;
|
|
145849
145974
|
var REFUSAL_BODY_LIMIT_BYTES = 16384;
|
|
145850
145975
|
function responseHeaders2(headers) {
|
|
@@ -145920,7 +146045,7 @@ function createPassthroughRoute(name, target) {
|
|
|
145920
146045
|
response.destroy();
|
|
145921
146046
|
} else {
|
|
145922
146047
|
response.start(HTTP_STATUS.badGateway, { "Content-Type": "application/json" });
|
|
145923
|
-
await response.write(JSON.stringify({ type: "error", error: { type: "api_error", message:
|
|
146048
|
+
await response.write(JSON.stringify({ type: "error", error: { type: "api_error", message: `${target.subject} at ${target.baseUrl} dropped the connection` } }));
|
|
145924
146049
|
response.end();
|
|
145925
146050
|
}
|
|
145926
146051
|
}
|
|
@@ -145929,16 +146054,31 @@ function createPassthroughRoute(name, target) {
|
|
|
145929
146054
|
void stream();
|
|
145930
146055
|
};
|
|
145931
146056
|
const forward = tls2 ? https4.request(options, onUpstreamResponse) : http5.request(options, onUpstreamResponse);
|
|
145932
|
-
|
|
146057
|
+
let failed = false;
|
|
146058
|
+
const fail = (error63, connected) => {
|
|
146059
|
+
if (failed) {
|
|
146060
|
+
return;
|
|
146061
|
+
}
|
|
146062
|
+
failed = true;
|
|
145933
146063
|
if (!response.headersSent) {
|
|
146064
|
+
const message = connected ? `${target.subject} at ${target.baseUrl} dropped the connection before answering: ${error63.message}` : couldNotConnectMessage(target.subject, target.baseUrl, error63.message);
|
|
146065
|
+
if (!connected) {
|
|
146066
|
+
target.couldNotConnect(message);
|
|
146067
|
+
}
|
|
145934
146068
|
response.start(HTTP_STATUS.badGateway, { "Content-Type": "application/json" });
|
|
145935
|
-
void response.write(JSON.stringify({ type: "error", error: { type: "api_error", message
|
|
146069
|
+
void response.write(JSON.stringify({ type: "error", error: { type: "api_error", message } })).then(() => {
|
|
145936
146070
|
response.end();
|
|
145937
146071
|
});
|
|
145938
146072
|
} else {
|
|
145939
146073
|
response.destroy();
|
|
145940
146074
|
}
|
|
145941
146075
|
resolve3(void 0);
|
|
146076
|
+
};
|
|
146077
|
+
const connection = armConnectDeadline(forward, target.connectTimeoutMs, (error63) => {
|
|
146078
|
+
fail(error63, false);
|
|
146079
|
+
});
|
|
146080
|
+
forward.on("error", (error63) => {
|
|
146081
|
+
fail(error63, connection.connected());
|
|
145942
146082
|
});
|
|
145943
146083
|
request7.signal.addEventListener("abort", () => {
|
|
145944
146084
|
forward.destroy();
|
|
@@ -146082,6 +146222,7 @@ async function scanRequestHead(request7, wholeBody = false) {
|
|
|
146082
146222
|
}
|
|
146083
146223
|
|
|
146084
146224
|
// src/frontdoor/providerRoute.ts
|
|
146225
|
+
var COULD_NOT_CONNECT_LOG_INTERVAL_MS = 6e4;
|
|
146085
146226
|
var isRcSelfHostPath = (path101) => path101 === "/v1/code/sessions" || path101.startsWith("/v1/code/sessions/") || path101 === "/v1/sessions" || path101.startsWith("/v1/sessions/");
|
|
146086
146227
|
function scopeSessionProviderPath(request7) {
|
|
146087
146228
|
if (request7.session.provider === void 0) {
|
|
@@ -146155,7 +146296,24 @@ function resolveAccountTarget(model, models) {
|
|
|
146155
146296
|
return first === void 0 ? void 0 : resolveAccountTarget(first, void 0);
|
|
146156
146297
|
}
|
|
146157
146298
|
function createProviderRouteResolver(deps) {
|
|
146158
|
-
const
|
|
146299
|
+
const couldNotConnectLoggedAt = /* @__PURE__ */ new Map();
|
|
146300
|
+
const couldNotConnectFor = (subject) => (line) => {
|
|
146301
|
+
const now = deps.now();
|
|
146302
|
+
const last = couldNotConnectLoggedAt.get(subject);
|
|
146303
|
+
if (last !== void 0 && now - last < COULD_NOT_CONNECT_LOG_INTERVAL_MS) {
|
|
146304
|
+
return;
|
|
146305
|
+
}
|
|
146306
|
+
couldNotConnectLoggedAt.set(subject, now);
|
|
146307
|
+
deps.log(`front door: ${line}`);
|
|
146308
|
+
};
|
|
146309
|
+
const oauthRoute = createPassthroughRoute("anthropic", {
|
|
146310
|
+
baseUrl: `https://${CONNECT_INTERCEPT_HOST}:${String(HTTPS_PORT)}`,
|
|
146311
|
+
stripPrefix: void 0,
|
|
146312
|
+
headroomUpstream: void 0,
|
|
146313
|
+
subject: "the Anthropic API",
|
|
146314
|
+
connectTimeoutMs: DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS,
|
|
146315
|
+
couldNotConnect: couldNotConnectFor("the Anthropic API")
|
|
146316
|
+
});
|
|
146159
146317
|
const resolveCredential2 = shareInFlightResolutions(resolveCredentialAsync);
|
|
146160
146318
|
const resolveAgyCredential = createAgyCredentialResolver(deps.credentials);
|
|
146161
146319
|
const antigravityQuotaSources = /* @__PURE__ */ new Map();
|
|
@@ -146213,12 +146371,12 @@ function createProviderRouteResolver(deps) {
|
|
|
146213
146371
|
};
|
|
146214
146372
|
const passthroughByTarget = /* @__PURE__ */ new Map();
|
|
146215
146373
|
const passthroughFor = (name, target) => {
|
|
146216
|
-
const key = `${name}\0${target.baseUrl}\0${target.stripPrefix ?? ""}\0${target.headroomUpstream ?? ""}`;
|
|
146374
|
+
const key = `${name}\0${target.baseUrl}\0${target.stripPrefix ?? ""}\0${target.headroomUpstream ?? ""}\0${String(target.connectTimeoutMs)}`;
|
|
146217
146375
|
const existing = passthroughByTarget.get(key);
|
|
146218
146376
|
if (existing !== void 0) {
|
|
146219
146377
|
return existing;
|
|
146220
146378
|
}
|
|
146221
|
-
const route = createPassthroughRoute(name, target);
|
|
146379
|
+
const route = createPassthroughRoute(name, { ...target, couldNotConnect: couldNotConnectFor(target.subject) });
|
|
146222
146380
|
passthroughByTarget.set(key, route);
|
|
146223
146381
|
return route;
|
|
146224
146382
|
};
|
|
@@ -146292,7 +146450,16 @@ function createProviderRouteResolver(deps) {
|
|
|
146292
146450
|
};
|
|
146293
146451
|
}
|
|
146294
146452
|
if (isRouterProvider(definition)) {
|
|
146295
|
-
return {
|
|
146453
|
+
return {
|
|
146454
|
+
ok: true,
|
|
146455
|
+
route: passthroughFor(`router:${provider}`, {
|
|
146456
|
+
baseUrl: `http://127.0.0.1:${String(deps.directPort())}`,
|
|
146457
|
+
stripPrefix: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(provider)}`,
|
|
146458
|
+
headroomUpstream: directOrigin2(deps.directPort()),
|
|
146459
|
+
subject: `router ${provider}'s own door listener`,
|
|
146460
|
+
connectTimeoutMs: DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS
|
|
146461
|
+
})
|
|
146462
|
+
};
|
|
146296
146463
|
}
|
|
146297
146464
|
const httpProvider = definition;
|
|
146298
146465
|
return {
|
|
@@ -146301,7 +146468,9 @@ function createProviderRouteResolver(deps) {
|
|
|
146301
146468
|
passthroughFor(`http:${provider}`, {
|
|
146302
146469
|
baseUrl: httpProvider.baseUrl,
|
|
146303
146470
|
stripPrefix: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(provider)}`,
|
|
146304
|
-
headroomUpstream: directOrigin2(deps.directPort())
|
|
146471
|
+
headroomUpstream: directOrigin2(deps.directPort()),
|
|
146472
|
+
subject: `provider ${provider}`,
|
|
146473
|
+
connectTimeoutMs: providerConnectTimeoutMs(httpProvider)
|
|
146305
146474
|
}),
|
|
146306
146475
|
{ provider, credential: httpProvider.credential, env: deps.env, port: deps.credentials, resolve: resolveCredential2 }
|
|
146307
146476
|
)
|
|
@@ -150681,7 +150850,9 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, lifecycle, track
|
|
|
150681
150850
|
// An `acct:` model member is served by relaunch: the door leaves a move request for the session's supervisor (found across every pool's registry, since the door does not know which pool launched the session) and answers the request with what is happening. A session nothing supervises gets the message naming the command to run instead.
|
|
150682
150851
|
observations: (target) => observations.observation(target),
|
|
150683
150852
|
accountMoves: async (sessionId, to2, model) => await requestAccountMove({ fs: realFarmFs, paths, runningAmong: realRunningAmong, idOf: (name) => identityIdOf(paths, name), now: () => Date.now() }, sessionId, to2, model),
|
|
150684
|
-
...rcSelfHostSurface === void 0 ? {} : { rcSelfHostRoute: rcSelfHostSurface.route }
|
|
150853
|
+
...rcSelfHostSurface === void 0 ? {} : { rcSelfHostRoute: rcSelfHostSurface.route },
|
|
150854
|
+
log,
|
|
150855
|
+
now: () => Date.now()
|
|
150685
150856
|
}),
|
|
150686
150857
|
rcTracker,
|
|
150687
150858
|
rcHub
|
|
@@ -167452,6 +167623,7 @@ function registerPoolCommand(program2, deps) {
|
|
|
167452
167623
|
|
|
167453
167624
|
// src/providers.ts
|
|
167454
167625
|
init_commandDeps();
|
|
167626
|
+
init_providerReachability();
|
|
167455
167627
|
init_translate2();
|
|
167456
167628
|
init_catalogueCredential();
|
|
167457
167629
|
init_translate();
|
|
@@ -167635,13 +167807,14 @@ function rewriteReferences(paths, from, to2) {
|
|
|
167635
167807
|
init_realCredentialCache();
|
|
167636
167808
|
init_realPorts();
|
|
167637
167809
|
init_providersStore();
|
|
167810
|
+
var CONNECT_TIMEOUT_DEFAULT_HINT = `a duration such as 3s or 500ms; default ${String(DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS)}ms, the first SYN and two retransmissions`;
|
|
167638
167811
|
function toProviderView(name, provider, formerNames) {
|
|
167639
167812
|
return {
|
|
167640
167813
|
name,
|
|
167641
167814
|
...formerNames.length === 0 ? {} : { formerNames },
|
|
167642
167815
|
kind: provider.kind ?? "http",
|
|
167643
167816
|
displayName: provider.displayName,
|
|
167644
|
-
...isCodexProvider(provider) ? provider.codex === void 0 ? {} : { codex: provider.codex } : isAntigravityProvider(provider) ? provider.antigravity === void 0 ? {} : { antigravity: provider.antigravity } : isRouterProvider(provider) ? {} : { baseUrl: provider.baseUrl },
|
|
167817
|
+
...isCodexProvider(provider) ? provider.codex === void 0 ? {} : { codex: provider.codex } : isAntigravityProvider(provider) ? provider.antigravity === void 0 ? {} : { antigravity: provider.antigravity } : isRouterProvider(provider) ? {} : { baseUrl: provider.baseUrl, ...provider.connectTimeoutMs === void 0 ? {} : { connectTimeoutMs: provider.connectTimeoutMs } },
|
|
167645
167818
|
...isRouterProvider(provider) ? {} : { credential: summariseCredential(provider.credential) },
|
|
167646
167819
|
...!isRouterProvider(provider) && provider.env !== void 0 ? { env: provider.env } : {},
|
|
167647
167820
|
...!isRouterProvider(provider) && provider.pickerModels !== void 0 ? { pickerModels: provider.pickerModels } : {},
|
|
@@ -167728,7 +167901,7 @@ function registerProviderCommand(program2, deps) {
|
|
|
167728
167901
|
["agent-shim provider add z --display-name z.ai --base-url https://api.z.ai/api/anthropic --credential env:Z_API_TOKEN", "agent-shim provider list"]
|
|
167729
167902
|
);
|
|
167730
167903
|
withExamples(
|
|
167731
|
-
provider.command("add <name>").description("Create a new API provider definition. Fails if one with this name already exists.").addOption(new Option("--kind <kind>", "http (default): an Anthropic-compatible endpoint at --base-url; codex: ChatGPT's Codex backend through the front-door daemon.").choices(PROVIDER_KINDS)).requiredOption("--display-name <name>", "Human-readable name, exported to the child as AGENT_SHIM_PROVIDER.").option("--base-url <url>", "Anthropic-compatible base URL the child's requests are sent to (http providers only, and required for them).").requiredOption(
|
|
167904
|
+
provider.command("add <name>").description("Create a new API provider definition. Fails if one with this name already exists.").addOption(new Option("--kind <kind>", "http (default): an Anthropic-compatible endpoint at --base-url; codex: ChatGPT's Codex backend through the front-door daemon.").choices(PROVIDER_KINDS)).requiredOption("--display-name <name>", "Human-readable name, exported to the child as AGENT_SHIM_PROVIDER.").option("--base-url <url>", "Anthropic-compatible base URL the child's requests are sent to (http providers only, and required for them).").option("--connect-timeout <duration>", `http providers: how long opening a connection to the base URL may take before the provider counts as unreachable (${CONNECT_TIMEOUT_DEFAULT_HINT}). Bounds the connect only, never the wait for the answer.`, parseDurationOption).requiredOption(
|
|
167732
167905
|
"--credential <source>",
|
|
167733
167906
|
`Where the provider's token comes from (repeatable; tried in the order given until one yields a token): ${CREDENTIAL_SOURCE_SYNTAX}. Never the token itself.`,
|
|
167734
167907
|
collectCredentialSource
|
|
@@ -167744,6 +167917,7 @@ function registerProviderCommand(program2, deps) {
|
|
|
167744
167917
|
...options.kind === void 0 ? {} : { kind: options.kind },
|
|
167745
167918
|
displayName: options.displayName,
|
|
167746
167919
|
...options.baseUrl === void 0 ? {} : { baseUrl: options.baseUrl },
|
|
167920
|
+
...options.connectTimeout === void 0 ? {} : { connectTimeoutMs: options.connectTimeout },
|
|
167747
167921
|
sources: options.credential,
|
|
167748
167922
|
...options.credentialTarget === void 0 ? {} : { target: options.credentialTarget },
|
|
167749
167923
|
...options.env === void 0 ? {} : { env: options.env },
|
|
@@ -167767,7 +167941,7 @@ function registerProviderCommand(program2, deps) {
|
|
|
167767
167941
|
"agent-shim provider add agy-local --kind antigravity --display-name Antigravity --antigravity-mode local --credential literal:placeholder"
|
|
167768
167942
|
]
|
|
167769
167943
|
);
|
|
167770
|
-
const providerSet = provider.command("set <name>").description("Update an existing API provider definition.").option("--display-name <name>", "Replace the human-readable name.").option("--base-url <url>", "Replace the base URL (http providers only).").option(
|
|
167944
|
+
const providerSet = provider.command("set <name>").description("Update an existing API provider definition.").option("--display-name <name>", "Replace the human-readable name.").option("--base-url <url>", "Replace the base URL (http providers only).").option("--connect-timeout <duration>", `http providers: replace how long opening a connection to the base URL may take before the provider counts as unreachable (${CONNECT_TIMEOUT_DEFAULT_HINT}).`, parseDurationOption).option("--unset-connect-timeout", "http providers: go back to the default connect timeout.").option(
|
|
167771
167945
|
"--credential <source>",
|
|
167772
167946
|
`Replace the credential's sources with these (repeatable, in the order tried): ${CREDENTIAL_SOURCE_SYNTAX}.`,
|
|
167773
167947
|
collectCredentialSource
|
|
@@ -167782,13 +167956,16 @@ function registerProviderCommand(program2, deps) {
|
|
|
167782
167956
|
const { json: json2, ...options } = allOptions;
|
|
167783
167957
|
if (Object.entries(allOptions).every(([key, value3]) => key === "json" || value3 === void 0)) {
|
|
167784
167958
|
throw new UsageError(
|
|
167785
|
-
"Nothing to change: pass --display-name, --base-url, --credential, --credential-target, a --credential-cache option, --env, --unset-env, --picker-model, --unset-picker-model, a --catalogue option, --unset-catalogue, or codex/antigravity settings."
|
|
167959
|
+
"Nothing to change: pass --display-name, --base-url, --connect-timeout, --unset-connect-timeout, --credential, --credential-target, a --credential-cache option, --env, --unset-env, --picker-model, --unset-picker-model, a --catalogue option, --unset-catalogue, or codex/antigravity settings."
|
|
167786
167960
|
);
|
|
167787
167961
|
}
|
|
167788
167962
|
const codex = codexConfigFromOptions(options);
|
|
167789
167963
|
const antigravity = antigravityConfigFromOptions(options);
|
|
167790
167964
|
const existingForCache = readProvider(paths, name);
|
|
167791
167965
|
const cache = cacheChange(options, existingForCache !== void 0 && !isRouterProvider(existingForCache) ? existingForCache.credential.cache : void 0);
|
|
167966
|
+
if (options.unsetConnectTimeout === true && options.connectTimeout !== void 0) {
|
|
167967
|
+
throw new UsageError("--unset-connect-timeout cannot be combined with --connect-timeout.");
|
|
167968
|
+
}
|
|
167792
167969
|
if (options.unsetCatalogue === true && hasCatalogueOptions(options)) {
|
|
167793
167970
|
throw new UsageError("--unset-catalogue cannot be combined with another --catalogue option.");
|
|
167794
167971
|
}
|
|
@@ -167800,6 +167977,7 @@ function registerProviderCommand(program2, deps) {
|
|
|
167800
167977
|
...cache === void 0 ? {} : { cache },
|
|
167801
167978
|
...options.displayName === void 0 ? {} : { displayName: options.displayName },
|
|
167802
167979
|
...options.baseUrl === void 0 ? {} : { baseUrl: options.baseUrl },
|
|
167980
|
+
...options.unsetConnectTimeout === true ? { connectTimeoutMs: false } : options.connectTimeout === void 0 ? {} : { connectTimeoutMs: options.connectTimeout },
|
|
167803
167981
|
...options.credential === void 0 ? {} : { sources: options.credential },
|
|
167804
167982
|
...options.credentialTarget === void 0 ? {} : { target: options.credentialTarget },
|
|
167805
167983
|
...options.env === void 0 ? {} : { env: options.env },
|
|
@@ -167814,6 +167992,7 @@ function registerProviderCommand(program2, deps) {
|
|
|
167814
167992
|
}),
|
|
167815
167993
|
[
|
|
167816
167994
|
"agent-shim provider set z --base-url https://api.z.ai/api/anthropic",
|
|
167995
|
+
"agent-shim provider set local --connect-timeout 3s",
|
|
167817
167996
|
"agent-shim provider set z --env API_TIMEOUT_MS=600000",
|
|
167818
167997
|
"agent-shim provider set z --credential op:op://vault/z/credential --credential-cache-ttl 12h",
|
|
167819
167998
|
"agent-shim provider set anthropic-api --credential-target apiKey",
|
|
@@ -167875,6 +168054,7 @@ function registerProviderCommand(program2, deps) {
|
|
|
167875
168054
|
console.log(`Endpoint: ${describeProviderEndpoint(found)}`);
|
|
167876
168055
|
} else if (!isRouterProvider(found)) {
|
|
167877
168056
|
console.log(`Base URL: ${found.baseUrl}`);
|
|
168057
|
+
console.log(`Connect timeout: ${String(providerConnectTimeoutMs(found))}ms${found.connectTimeoutMs === void 0 ? " (the default)" : ""}`);
|
|
167878
168058
|
}
|
|
167879
168059
|
if (!isRouterProvider(found)) {
|
|
167880
168060
|
console.log(`Credential: ${describeCredential(found.credential)}`);
|