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/index.mjs CHANGED
@@ -990,6 +990,8 @@ var init_schema = __esm({
990
990
  kind: z3.literal("http").optional(),
991
991
  displayName: z3.string().min(1),
992
992
  baseUrl: z3.url(),
993
+ /** 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. */
994
+ connectTimeoutMs: z3.int().positive().optional(),
993
995
  credential: ProviderCredentialSchema,
994
996
  env: ProviderEnvSchema.optional(),
995
997
  /** Extra models `/model` lists beside the ones the tier settings name. */
@@ -10838,7 +10840,7 @@ var init_package = __esm({
10838
10840
  "package.json"() {
10839
10841
  package_default = {
10840
10842
  name: "claude-use",
10841
- version: "12.1.0",
10843
+ version: "12.2.0",
10842
10844
  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.",
10843
10845
  license: "MIT",
10844
10846
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -11501,6 +11503,9 @@ function addProvider(paths, name, input) {
11501
11503
  if (kind !== "http" && kind !== "router" && input.catalogue !== void 0) {
11502
11504
  throw new ProviderKindMismatchError("A model catalogue applies only to an http provider.");
11503
11505
  }
11506
+ if (kind !== "http" && input.connectTimeoutMs !== void 0) {
11507
+ throw new ProviderKindMismatchError("A connect timeout applies only to an http provider, the one kind that dials a base URL.");
11508
+ }
11504
11509
  if (kind !== "codex" && !isEmptyCodexConfig(input.codex)) {
11505
11510
  throw new ProviderKindMismatchError("Codex settings apply only to a codex provider (--kind codex).");
11506
11511
  }
@@ -11514,7 +11519,7 @@ function addProvider(paths, name, input) {
11514
11519
  ...input.pickerModels === void 0 || input.pickerModels.length === 0 ? {} : { pickerModels: input.pickerModels }
11515
11520
  };
11516
11521
  const parsed = ProviderSchema.safeParse(
11517
- 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 } }
11522
+ 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 } }
11518
11523
  );
11519
11524
  if (!parsed.success) {
11520
11525
  throw new ConfigValidationError(providerJsonPath(paths, name), parsed.error.issues);
@@ -11546,6 +11551,9 @@ function updateProvider(paths, name, input) {
11546
11551
  if (isAntigravityProvider(existing) && input.baseUrl !== void 0) {
11547
11552
  throw new ProviderKindMismatchError(`Provider "${name}" is an antigravity provider, which has no base URL.`);
11548
11553
  }
11554
+ if (!isHttpProvider(existing) && input.connectTimeoutMs !== void 0) {
11555
+ 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.`);
11556
+ }
11549
11557
  if ((isCodexProvider(existing) || isAntigravityProvider(existing)) && input.catalogue !== void 0 && input.catalogue !== false) {
11550
11558
  throw new ProviderKindMismatchError(`Provider "${name}" is not an http provider; a model catalogue applies only to an http provider.`);
11551
11559
  }
@@ -11586,7 +11594,8 @@ function updateProvider(paths, name, input) {
11586
11594
  candidate = { kind: "router", ...shared };
11587
11595
  } else {
11588
11596
  const catalogue = input.catalogue === void 0 ? existing.catalogue : input.catalogue === false ? void 0 : input.catalogue;
11589
- candidate = { ...existing, ...shared, catalogue, ...input.baseUrl === void 0 ? {} : { baseUrl: input.baseUrl } };
11597
+ const connectTimeoutMs = input.connectTimeoutMs === void 0 ? existing.connectTimeoutMs : input.connectTimeoutMs === false ? void 0 : input.connectTimeoutMs;
11598
+ candidate = { ...existing, ...shared, catalogue, connectTimeoutMs, ...input.baseUrl === void 0 ? {} : { baseUrl: input.baseUrl } };
11590
11599
  }
11591
11600
  const parsed = ProviderSchema.safeParse(candidate);
11592
11601
  if (!parsed.success) {
@@ -11929,6 +11938,185 @@ var init_paths = __esm({
11929
11938
  }
11930
11939
  });
11931
11940
 
11941
+ // src/frontdoor/probe.ts
11942
+ import { Worker } from "node:worker_threads";
11943
+ function requestCatalogueRefreshSync(port, caPem, token, timeoutMs = PROBE_TIMEOUT_MS) {
11944
+ refuseToBlockInRole("a synchronous catalogue refresh request");
11945
+ return runProbeWorker(CATALOGUE_REQUEST_SOURCE, { port, ca: caPem, token }, timeoutMs);
11946
+ }
11947
+ function probeFrontDoorSync(port, caPem, timeoutMs = PROBE_TIMEOUT_MS) {
11948
+ refuseToBlockInRole("a synchronous probe of the front door");
11949
+ return runProbeWorker(PROBE_SOURCE, { port, ca: caPem }, timeoutMs);
11950
+ }
11951
+ function probeListenerAcceptSync(port, timeoutMs = PROBE_TIMEOUT_MS) {
11952
+ refuseToBlockInRole("a synchronous probe of a front door listener");
11953
+ return runProbeWorker(ACCEPT_PROBE_SOURCE, { host: "127.0.0.1", port }, timeoutMs);
11954
+ }
11955
+ function probeAddressAcceptSync(host, port, timeoutMs) {
11956
+ refuseToBlockInRole("a synchronous probe of a provider's address");
11957
+ return runProbeWorker(ACCEPT_PROBE_SOURCE, { host, port }, timeoutMs);
11958
+ }
11959
+ function runProbeWorker(source, data, timeoutMs) {
11960
+ const shared = new SharedArrayBuffer(HEADER_SLOTS * INT32_BYTES + REASON_BYTES);
11961
+ const header = new Int32Array(shared, 0, HEADER_SLOTS);
11962
+ const worker = new Worker(source, {
11963
+ eval: true,
11964
+ workerData: { ...data, timeoutMs, shared, ok: VERDICT_OK, failed: VERDICT_FAILED, headerSlots: HEADER_SLOTS }
11965
+ });
11966
+ worker.unref();
11967
+ try {
11968
+ const waited = Atomics.wait(header, 0, VERDICT_PENDING, timeoutMs + PROBE_WAIT_MARGIN_MS);
11969
+ const verdict = Atomics.load(header, 0);
11970
+ if (waited === "timed-out" || verdict === VERDICT_PENDING) {
11971
+ return { ok: false, reason: `the probe did not finish within ${String(timeoutMs + PROBE_WAIT_MARGIN_MS)}ms` };
11972
+ }
11973
+ if (verdict === VERDICT_OK) {
11974
+ return { ok: true };
11975
+ }
11976
+ const length = Atomics.load(header, 1);
11977
+ return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
11978
+ } finally {
11979
+ void worker.terminate();
11980
+ }
11981
+ }
11982
+ var 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;
11983
+ var init_probe = __esm({
11984
+ "src/frontdoor/probe.ts"() {
11985
+ "use strict";
11986
+ init_processRole();
11987
+ PROBE_TIMEOUT_MS = 2e3;
11988
+ PROBE_WAIT_MARGIN_MS = 1e3;
11989
+ REASON_BYTES = 1024;
11990
+ HEADER_SLOTS = 2;
11991
+ INT32_BYTES = 4;
11992
+ VERDICT_PENDING = 0;
11993
+ VERDICT_OK = 1;
11994
+ VERDICT_FAILED = 2;
11995
+ PROBE_SOURCE = `
11996
+ const { workerData } = require("node:worker_threads");
11997
+ const https = require("node:https");
11998
+ const { port, ca, timeoutMs, shared, ok, failed, headerSlots } = workerData;
11999
+ const header = new Int32Array(shared, 0, headerSlots);
12000
+ const reason = new Uint8Array(shared, headerSlots * 4);
12001
+ let done = false;
12002
+ const finish = (verdict, message) => {
12003
+ if (done) return;
12004
+ done = true;
12005
+ const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
12006
+ reason.set(bytes);
12007
+ Atomics.store(header, 1, bytes.length);
12008
+ Atomics.store(header, 0, verdict);
12009
+ Atomics.notify(header, 0);
12010
+ };
12011
+ const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
12012
+ let body = "";
12013
+ response.setEncoding("utf8");
12014
+ response.on("data", (chunk) => { body += chunk; });
12015
+ response.on("end", () => {
12016
+ if (response.statusCode === 200 && body === "ok") finish(ok, "");
12017
+ else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
12018
+ });
12019
+ response.on("error", (error) => finish(failed, error.message));
12020
+ });
12021
+ // A hard deadline over the whole exchange, handshake included: a listener that accepts the connection and then says nothing must still fail the probe.
12022
+ setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
12023
+ request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
12024
+ `;
12025
+ CATALOGUE_REQUEST_SOURCE = `
12026
+ const { workerData } = require("node:worker_threads");
12027
+ const https = require("node:https");
12028
+ const { port, ca, token, timeoutMs, shared, ok, failed, headerSlots } = workerData;
12029
+ const header = new Int32Array(shared, 0, headerSlots);
12030
+ const reason = new Uint8Array(shared, headerSlots * 4);
12031
+ let done = false;
12032
+ const finish = (verdict, message) => {
12033
+ if (done) return;
12034
+ done = true;
12035
+ const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
12036
+ reason.set(bytes);
12037
+ Atomics.store(header, 1, bytes.length);
12038
+ Atomics.store(header, 0, verdict);
12039
+ Atomics.notify(header, 0);
12040
+ };
12041
+ 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) => {
12042
+ response.resume();
12043
+ response.on("end", () => response.statusCode === 200 ? finish(ok, "") : finish(failed, "catalogue refresh request returned HTTP " + String(response.statusCode)));
12044
+ response.on("error", (error) => finish(failed, error.message));
12045
+ });
12046
+ setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
12047
+ request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
12048
+ request.end();
12049
+ `;
12050
+ ACCEPT_PROBE_SOURCE = `
12051
+ const { workerData } = require("node:worker_threads");
12052
+ const net = require("node:net");
12053
+ const { host, port, timeoutMs, shared, ok, failed, headerSlots } = workerData;
12054
+ const header = new Int32Array(shared, 0, headerSlots);
12055
+ const reason = new Uint8Array(shared, headerSlots * 4);
12056
+ let done = false;
12057
+ const finish = (verdict, message) => {
12058
+ if (done) return;
12059
+ done = true;
12060
+ const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
12061
+ reason.set(bytes);
12062
+ Atomics.store(header, 1, bytes.length);
12063
+ Atomics.store(header, 0, verdict);
12064
+ Atomics.notify(header, 0);
12065
+ };
12066
+ const socket = net.connect({ host, port });
12067
+ socket.once("connect", () => { socket.destroy(); finish(ok, ""); });
12068
+ socket.once("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
12069
+ setTimeout(() => { socket.destroy(); finish(failed, "no connection accepted within " + String(timeoutMs) + "ms"); }, timeoutMs);
12070
+ `;
12071
+ }
12072
+ });
12073
+
12074
+ // src/providerReachability.ts
12075
+ function providerConnectTimeoutMs(provider) {
12076
+ return provider.connectTimeoutMs ?? DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS;
12077
+ }
12078
+ function dialTargetOf(baseUrl) {
12079
+ const url = new URL(baseUrl);
12080
+ const defaultPort = DEFAULT_PORTS[url.protocol];
12081
+ if (defaultPort === void 0) {
12082
+ return void 0;
12083
+ }
12084
+ return { host: url.hostname.replace(/^\[(.*)\]$/, "$1"), port: url.port === "" ? defaultPort : Number(url.port) };
12085
+ }
12086
+ function couldNotConnectMessage(subject, baseUrl, reason) {
12087
+ return `${subject} could not connect to ${baseUrl}: ${reason}`;
12088
+ }
12089
+ function probeProviderReachability(name, provider, probe) {
12090
+ const verdict = probe(provider.baseUrl, providerConnectTimeoutMs(provider));
12091
+ return verdict.ok ? { ok: true } : { ok: false, message: couldNotConnectMessage(`provider ${name}`, provider.baseUrl, verdict.reason) };
12092
+ }
12093
+ function unreachableProviderLine(name, provider, probe) {
12094
+ if (probe === void 0 || !isHttpProvider(provider)) {
12095
+ return void 0;
12096
+ }
12097
+ const reachability = probeProviderReachability(name, provider, probe);
12098
+ return reachability.ok ? void 0 : reachability.message;
12099
+ }
12100
+ var TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS, CONNECT_SYN_RETRANSMISSIONS_TOLERATED, DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS, DEFAULT_PORTS, realBaseUrlProbe;
12101
+ var init_providerReachability = __esm({
12102
+ "src/providerReachability.ts"() {
12103
+ "use strict";
12104
+ init_schema();
12105
+ init_probe();
12106
+ TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS = 1e3;
12107
+ CONNECT_SYN_RETRANSMISSIONS_TOLERATED = 2;
12108
+ DEFAULT_PROVIDER_CONNECT_TIMEOUT_MS = TCP_INITIAL_RETRANSMISSION_TIMEOUT_MS * (2 ** (CONNECT_SYN_RETRANSMISSIONS_TOLERATED + 1) - 1);
12109
+ DEFAULT_PORTS = { "http:": 80, "https:": 443 };
12110
+ realBaseUrlProbe = (baseUrl, timeoutMs) => {
12111
+ const target = dialTargetOf(baseUrl);
12112
+ if (target === void 0) {
12113
+ return { ok: false, reason: "the base URL is neither http nor https" };
12114
+ }
12115
+ return probeAddressAcceptSync(target.host, target.port, timeoutMs);
12116
+ };
12117
+ }
12118
+ });
12119
+
11932
12120
  // src/launcher/claudeVersion.ts
11933
12121
  function validated2(value, origin) {
11934
12122
  if (!NUMERIC_DOTTED_VERSION_RE.test(value)) {
@@ -12653,135 +12841,6 @@ var init_targets = __esm({
12653
12841
  }
12654
12842
  });
12655
12843
 
12656
- // src/frontdoor/probe.ts
12657
- import { Worker } from "node:worker_threads";
12658
- function requestCatalogueRefreshSync(port, caPem, token, timeoutMs = PROBE_TIMEOUT_MS) {
12659
- refuseToBlockInRole("a synchronous catalogue refresh request");
12660
- return runProbeWorker(CATALOGUE_REQUEST_SOURCE, { port, ca: caPem, token }, timeoutMs);
12661
- }
12662
- function probeFrontDoorSync(port, caPem, timeoutMs = PROBE_TIMEOUT_MS) {
12663
- refuseToBlockInRole("a synchronous probe of the front door");
12664
- return runProbeWorker(PROBE_SOURCE, { port, ca: caPem }, timeoutMs);
12665
- }
12666
- function probeListenerAcceptSync(port, timeoutMs = PROBE_TIMEOUT_MS) {
12667
- refuseToBlockInRole("a synchronous probe of a front door listener");
12668
- return runProbeWorker(ACCEPT_PROBE_SOURCE, { port }, timeoutMs);
12669
- }
12670
- function runProbeWorker(source, data, timeoutMs) {
12671
- const shared = new SharedArrayBuffer(HEADER_SLOTS * INT32_BYTES + REASON_BYTES);
12672
- const header = new Int32Array(shared, 0, HEADER_SLOTS);
12673
- const worker = new Worker(source, {
12674
- eval: true,
12675
- workerData: { ...data, timeoutMs, shared, ok: VERDICT_OK, failed: VERDICT_FAILED, headerSlots: HEADER_SLOTS }
12676
- });
12677
- worker.unref();
12678
- try {
12679
- const waited = Atomics.wait(header, 0, VERDICT_PENDING, timeoutMs + PROBE_WAIT_MARGIN_MS);
12680
- const verdict = Atomics.load(header, 0);
12681
- if (waited === "timed-out" || verdict === VERDICT_PENDING) {
12682
- return { ok: false, reason: `the probe did not finish within ${String(timeoutMs + PROBE_WAIT_MARGIN_MS)}ms` };
12683
- }
12684
- if (verdict === VERDICT_OK) {
12685
- return { ok: true };
12686
- }
12687
- const length = Atomics.load(header, 1);
12688
- return { ok: false, reason: Buffer.from(new Uint8Array(shared, HEADER_SLOTS * INT32_BYTES, length)).toString("utf8") };
12689
- } finally {
12690
- void worker.terminate();
12691
- }
12692
- }
12693
- var 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;
12694
- var init_probe = __esm({
12695
- "src/frontdoor/probe.ts"() {
12696
- "use strict";
12697
- init_processRole();
12698
- PROBE_TIMEOUT_MS = 2e3;
12699
- PROBE_WAIT_MARGIN_MS = 1e3;
12700
- REASON_BYTES = 1024;
12701
- HEADER_SLOTS = 2;
12702
- INT32_BYTES = 4;
12703
- VERDICT_PENDING = 0;
12704
- VERDICT_OK = 1;
12705
- VERDICT_FAILED = 2;
12706
- PROBE_SOURCE = `
12707
- const { workerData } = require("node:worker_threads");
12708
- const https = require("node:https");
12709
- const { port, ca, timeoutMs, shared, ok, failed, headerSlots } = workerData;
12710
- const header = new Int32Array(shared, 0, headerSlots);
12711
- const reason = new Uint8Array(shared, headerSlots * 4);
12712
- let done = false;
12713
- const finish = (verdict, message) => {
12714
- if (done) return;
12715
- done = true;
12716
- const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
12717
- reason.set(bytes);
12718
- Atomics.store(header, 1, bytes.length);
12719
- Atomics.store(header, 0, verdict);
12720
- Atomics.notify(header, 0);
12721
- };
12722
- const request = https.get({ host: "127.0.0.1", port, path: "/healthz", ca: [ca], agent: false }, (response) => {
12723
- let body = "";
12724
- response.setEncoding("utf8");
12725
- response.on("data", (chunk) => { body += chunk; });
12726
- response.on("end", () => {
12727
- if (response.statusCode === 200 && body === "ok") finish(ok, "");
12728
- else finish(failed, "the listener answered its health probe with HTTP " + String(response.statusCode));
12729
- });
12730
- response.on("error", (error) => finish(failed, error.message));
12731
- });
12732
- // A hard deadline over the whole exchange, handshake included: a listener that accepts the connection and then says nothing must still fail the probe.
12733
- setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
12734
- request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
12735
- `;
12736
- CATALOGUE_REQUEST_SOURCE = `
12737
- const { workerData } = require("node:worker_threads");
12738
- const https = require("node:https");
12739
- const { port, ca, token, 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.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) => {
12753
- response.resume();
12754
- response.on("end", () => response.statusCode === 200 ? finish(ok, "") : finish(failed, "catalogue refresh request returned HTTP " + String(response.statusCode)));
12755
- response.on("error", (error) => finish(failed, error.message));
12756
- });
12757
- setTimeout(() => { request.destroy(new Error("no answer within " + String(timeoutMs) + "ms")); }, timeoutMs);
12758
- request.on("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
12759
- request.end();
12760
- `;
12761
- ACCEPT_PROBE_SOURCE = `
12762
- const { workerData } = require("node:worker_threads");
12763
- const net = require("node:net");
12764
- const { port, timeoutMs, shared, ok, failed, headerSlots } = workerData;
12765
- const header = new Int32Array(shared, 0, headerSlots);
12766
- const reason = new Uint8Array(shared, headerSlots * 4);
12767
- let done = false;
12768
- const finish = (verdict, message) => {
12769
- if (done) return;
12770
- done = true;
12771
- const bytes = Buffer.from(String(message), "utf8").subarray(0, reason.length);
12772
- reason.set(bytes);
12773
- Atomics.store(header, 1, bytes.length);
12774
- Atomics.store(header, 0, verdict);
12775
- Atomics.notify(header, 0);
12776
- };
12777
- const socket = net.connect({ host: "127.0.0.1", port });
12778
- socket.once("connect", () => { socket.destroy(); finish(ok, ""); });
12779
- socket.once("error", (error) => finish(failed, (error.code ? error.code + ": " : "") + error.message));
12780
- setTimeout(() => { socket.destroy(); finish(failed, "no connection accepted within " + String(timeoutMs) + "ms"); }, timeoutMs);
12781
- `;
12782
- }
12783
- });
12784
-
12785
12844
  // src/launcher/proxyBypass.ts
12786
12845
  function checkedProxyBypass(entries, source) {
12787
12846
  const seen = /* @__PURE__ */ new Set();
@@ -14734,6 +14793,11 @@ function prepareRegisteredLaunch(params, onRecorded) {
14734
14793
  proc.exit(check.status);
14735
14794
  }
14736
14795
  }
14796
+ const unreachable = resolvedProvider === void 0 ? void 0 : unreachableProviderLine(resolvedProvider.name, resolvedProvider.definition, params.probeBaseUrl);
14797
+ if (unreachable !== void 0) {
14798
+ log.error(`agent-shim: ${unreachable}`);
14799
+ proc.exit(1);
14800
+ }
14737
14801
  const frontDoorPort = params.frontdoor;
14738
14802
  const frontDoorEngaged = resolvedProvider !== void 0 || resolvedFlags.headroom || resolvedFlags.trackUsage;
14739
14803
  if (frontDoorEngaged && frontDoorPort === void 0) {
@@ -14884,6 +14948,7 @@ var init_launcher = __esm({
14884
14948
  init_flatten();
14885
14949
  init_walk();
14886
14950
  init_schema();
14951
+ init_providerReachability();
14887
14952
  init_schema();
14888
14953
  init_credential();
14889
14954
  init_middleware();
@@ -15179,6 +15244,7 @@ function realPrepareLaunchParams(paths, options) {
15179
15244
  headroom: realHeadroomPort(paths, { spawnDaemon: options.spawnDaemon, cwd: farm.runtime.cwd }),
15180
15245
  frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
15181
15246
  credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
15247
+ probeBaseUrl: realBaseUrlProbe,
15182
15248
  hold: realHoldPort,
15183
15249
  hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: options.run ?? realRunPort }, { farmRoot: path54.join(paths.identitiesDir, identity), hasCredentialBlock: false, provider: void 0 }).state !== "signed-out",
15184
15250
  hasUsableLogin: (identity, claudeBin) => storedLoginUsable(options.run ?? realRunPort, claudeBin, path54.join(paths.identitiesDir, identity), options.proc.env),
@@ -15259,6 +15325,7 @@ var init_launchWiring = __esm({
15259
15325
  init_replayRun();
15260
15326
  init_paths();
15261
15327
  init_signIn();
15328
+ init_providerReachability();
15262
15329
  init_realPorts();
15263
15330
  LaunchRefusedError = class extends CliError {
15264
15331
  exitCode;
@@ -19482,6 +19549,7 @@ init_realPorts();
19482
19549
  init_envBool();
19483
19550
  init_load();
19484
19551
  init_schema();
19552
+ init_providerReachability();
19485
19553
  init_identityStore();
19486
19554
  init_credential();
19487
19555
  init_claudeVersion();
@@ -19676,6 +19744,7 @@ function runCheck(params) {
19676
19744
  const settingsExposure = inspectSettingsExposure({ settingsShared, files: params.settingsFiles });
19677
19745
  const keychain = !isCodex && params.platform === "darwin" && params.run !== void 0 && params.farmRoot !== void 0 ? lookupKeychainService(params.run, params.farmRoot) : void 0;
19678
19746
  const claudeVersion = isCodex ? void 0 : buildClaudeVersionReport(params, resolved.flattened.launch.claudeVersion);
19747
+ const providerReachability = buildProviderReachability(params.provider, params.probeBaseUrl);
19679
19748
  return {
19680
19749
  ...params.identityName === void 0 ? {} : { identityName: params.identityName },
19681
19750
  identitySource: params.identitySource,
@@ -19689,9 +19758,18 @@ function runCheck(params) {
19689
19758
  ...keychain === void 0 ? {} : { keychain },
19690
19759
  settingsExposure,
19691
19760
  credential: buildCredentialReport(params.provider, params.identity, params.identityId, params.credentialCache),
19692
- ...claudeVersion === void 0 ? {} : { claudeVersion }
19761
+ ...claudeVersion === void 0 ? {} : { claudeVersion },
19762
+ ...providerReachability === void 0 ? {} : { providerReachability }
19693
19763
  };
19694
19764
  }
19765
+ function buildProviderReachability(provider, probe) {
19766
+ if (provider?.definition === void 0 || probe === void 0 || !isHttpProvider(provider.definition)) {
19767
+ return void 0;
19768
+ }
19769
+ const { baseUrl } = provider.definition;
19770
+ const reachability = probeProviderReachability(provider.name, provider.definition, probe);
19771
+ return reachability.ok ? { name: provider.name, baseUrl, ok: true } : { name: provider.name, baseUrl, ok: false, message: reachability.message };
19772
+ }
19695
19773
  function formatCheckReport(report) {
19696
19774
  const lines = [];
19697
19775
  lines.push(`Identity: ${report.identityName ?? "(none)"} (${report.identitySource})`);
@@ -19738,6 +19816,11 @@ function formatCheckReport(report) {
19738
19816
  if (credential.applies === "stored-login") {
19739
19817
  lines.push(" The identity's stored login (no credential block applies).");
19740
19818
  }
19819
+ if (report.providerReachability !== void 0) {
19820
+ lines.push("", "Provider reachability:");
19821
+ const reachability = report.providerReachability;
19822
+ lines.push(reachability.ok ? ` Provider ${reachability.name}: ${reachability.baseUrl} accepts connections` : ` [FAIL] ${reachability.message}`);
19823
+ }
19741
19824
  if (report.claudeVersion !== void 0) {
19742
19825
  lines.push("", "Claude Code version:");
19743
19826
  const { pinned, highestInstalled, installed } = report.claudeVersion;
@@ -19788,11 +19871,12 @@ function checkReportToJson(report) {
19788
19871
  ...report.keychain === void 0 ? {} : { keychain: report.keychain },
19789
19872
  settingsExposure: report.settingsExposure,
19790
19873
  credential: report.credential,
19791
- ...report.claudeVersion === void 0 ? {} : { claudeVersion: report.claudeVersion }
19874
+ ...report.claudeVersion === void 0 ? {} : { claudeVersion: report.claudeVersion },
19875
+ ...report.providerReachability === void 0 ? {} : { providerReachability: report.providerReachability }
19792
19876
  };
19793
19877
  }
19794
19878
  function checkReportHasWarnings(report) {
19795
- 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;
19879
+ 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;
19796
19880
  }
19797
19881
  function loadCheckProvider(paths, name) {
19798
19882
  let definition;
@@ -19859,7 +19943,8 @@ function collectCheckReport(params) {
19859
19943
  ...isCodex ? {} : { installedClaudeVersions: realInstalledClaudeVersions() },
19860
19944
  ...farmRoot === void 0 ? {} : { farmRoot },
19861
19945
  platform: process.platform,
19862
- ...provider === void 0 ? {} : { provider }
19946
+ ...provider === void 0 ? {} : { provider },
19947
+ probeBaseUrl: realBaseUrlProbe
19863
19948
  });
19864
19949
  return report;
19865
19950
  }
@@ -20024,6 +20109,10 @@ var CheckCredentialProviderSchema = z29.union([
20024
20109
  z29.strictObject({ name: z29.string(), credential: CredentialSummarySchema.optional(), cached: CachedCredentialStateSchema.optional() }),
20025
20110
  z29.strictObject({ name: z29.string(), problem: z29.string() })
20026
20111
  ]);
20112
+ var CheckProviderReachabilitySchema = z29.union([
20113
+ z29.strictObject({ name: z29.string(), baseUrl: z29.string(), ok: z29.literal(true) }),
20114
+ z29.strictObject({ name: z29.string(), baseUrl: z29.string(), ok: z29.literal(false), message: z29.string() })
20115
+ ]);
20027
20116
  var CheckCredentialSchema = z29.strictObject({
20028
20117
  applies: z29.enum(CHECK_CREDENTIAL_APPLIES),
20029
20118
  provider: CheckCredentialProviderSchema.optional(),
@@ -20050,7 +20139,8 @@ var CheckReportJsonSchema = z29.strictObject({
20050
20139
  keychain: CheckKeychainSchema.optional(),
20051
20140
  settingsExposure: z29.readonly(z29.array(CheckSettingsExposureSchema)),
20052
20141
  credential: CheckCredentialSchema,
20053
- claudeVersion: CheckClaudeVersionSchema.optional()
20142
+ claudeVersion: CheckClaudeVersionSchema.optional(),
20143
+ providerReachability: CheckProviderReachabilitySchema.optional()
20054
20144
  });
20055
20145
 
20056
20146
  // src/frontdoor/controlApi.ts
@@ -20094,7 +20184,6 @@ function codexIdentityFindings(entry, identity) {
20094
20184
  // src/doctorReport.ts
20095
20185
  init_claudeShim();
20096
20186
  init_readableConfig();
20097
- init_names();
20098
20187
  init_store();
20099
20188
  init_identityStore();
20100
20189
  init_identityRecords();
@@ -20169,6 +20258,28 @@ import path42 from "node:path";
20169
20258
  init_signIn();
20170
20259
  init_identityAccounts();
20171
20260
  init_read();
20261
+ init_providerReachability();
20262
+
20263
+ // src/doctorNameFinding.ts
20264
+ init_names();
20265
+ function pushNameFinding(push, section, kind, entry) {
20266
+ if (isFileName(entry.name)) {
20267
+ return true;
20268
+ }
20269
+ if (!isStoredName(entry.name)) {
20270
+ 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);
20271
+ return false;
20272
+ }
20273
+ push(
20274
+ section,
20275
+ "warn",
20276
+ `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.`,
20277
+ entry.name
20278
+ );
20279
+ return true;
20280
+ }
20281
+
20282
+ // src/doctorReport.ts
20172
20283
  init_siwcStore();
20173
20284
  init_siwc();
20174
20285
  init_load();
@@ -20663,23 +20774,7 @@ function signInProblem(signIn) {
20663
20774
  return error instanceof Error ? error.message : String(error);
20664
20775
  }
20665
20776
  }
20666
- function pushNameFinding(push, section, kind, entry) {
20667
- if (isFileName(entry.name)) {
20668
- return true;
20669
- }
20670
- if (!isStoredName(entry.name)) {
20671
- 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);
20672
- return false;
20673
- }
20674
- push(
20675
- section,
20676
- "warn",
20677
- `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.`,
20678
- entry.name
20679
- );
20680
- return true;
20681
- }
20682
- function pushProvider(push, entry, cacheEnv, signIn) {
20777
+ function pushProvider(push, entry, cacheEnv, signIn, probeBaseUrl) {
20683
20778
  if (entry.raw === void 0) {
20684
20779
  push("provider", "fail", `${entry.path} is missing.`, entry.name);
20685
20780
  return;
@@ -20711,6 +20806,10 @@ function pushProvider(push, entry, cacheEnv, signIn) {
20711
20806
  if (!router && validated3.data.env?.ENABLE_TOOL_SEARCH === void 0) {
20712
20807
  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);
20713
20808
  }
20809
+ const unreachable = unreachableProviderLine(entry.name, validated3.data, probeBaseUrl);
20810
+ if (unreachable !== void 0) {
20811
+ push("provider", "fail", unreachable, entry.name);
20812
+ }
20714
20813
  if (signIn !== void 0 && isCodexProvider(validated3.data) && validated3.data.codex?.login === "chatgpt-sign-in") {
20715
20814
  const problem = signInProblem(signIn);
20716
20815
  if (problem !== void 0) {
@@ -20941,7 +21040,7 @@ function runDoctor(params) {
20941
21040
  if (!pushNameFinding(push, "provider", "provider", entry)) {
20942
21041
  continue;
20943
21042
  }
20944
- pushProvider(push, entry, params.credentialCache, params.chatgptSignIn);
21043
+ pushProvider(push, entry, params.credentialCache, params.chatgptSignIn, params.probeBaseUrl);
20945
21044
  }
20946
21045
  const providerNames = new Set(params.providers.map((entry) => entry.name));
20947
21046
  for (const finding of aliasFindings(params.providerAliases ?? {}, providerNames)) {
@@ -21248,6 +21347,7 @@ function collectDoctorReport(params) {
21248
21347
  configProfiles,
21249
21348
  providers,
21250
21349
  providerAliases: readProviderAliases(paths),
21350
+ probeBaseUrl: realBaseUrlProbe,
21251
21351
  renameJournals: listRenameJournals(realFarmFs, paths.identityRenamesDir),
21252
21352
  unreachableIdentities,
21253
21353
  identityRecords: { all: records, displaced: displacedIdentities.map((record) => ({ ...record, directoryPresent: fs14.existsSync(path42.join(paths.identitiesDir, record.id)) })), nameRenames: unfinishedNameRenames(paths).map((record) => ({ from: record.from, description: describeInterruptedNameRename(paths, record) })), strayNameRenameFiles: strayNameRenameRecordFiles(paths) },