claude-use 14.0.0 → 14.0.2

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
@@ -74,14 +74,42 @@ var init_categories_default = __esm({
74
74
  }
75
75
  });
76
76
 
77
- // src/config/proxyBypass.ts
78
- function isDnsName(name) {
79
- const labels = name.split(".");
80
- return name.length <= MAX_NAME_LENGTH && labels.every((label) => label.length <= MAX_LABEL_LENGTH && LABEL_RE.test(label)) && !DIGITS_RE.test(labels.at(-1) ?? "");
77
+ // src/hostName.ts
78
+ function isDottedDecimalIpv4(host) {
79
+ const parts = host.split(".");
80
+ return parts.length === IPV4_PARTS && parts.every((part) => IPV4_PART.test(part) && Number(part) <= MAX_OCTET);
81
81
  }
82
- function isIpv4(host) {
83
- return IPV4_RE.test(host) && host.split(".").every((octet) => Number(octet) <= MAX_OCTET);
82
+ function dnsNameProblem(name) {
83
+ if (name.length > MAX_NAME_LENGTH) {
84
+ return `a host longer than ${String(MAX_NAME_LENGTH)} characters`;
85
+ }
86
+ const labels = name.split(".");
87
+ if (labels.some((label) => label.length > MAX_LABEL_LENGTH)) {
88
+ return `a host with a label longer than ${String(MAX_LABEL_LENGTH)} characters`;
89
+ }
90
+ if (!labels.every((label) => LABEL.test(label))) {
91
+ return "a host that is not letters, digits, underscores and interior hyphens in non-empty dot-separated labels";
92
+ }
93
+ if (NUMERIC_LAST_LABEL.test(labels[labels.length - 1] ?? "")) {
94
+ return "a numeric host that is not a dotted-decimal IPv4 address";
95
+ }
96
+ return void 0;
84
97
  }
98
+ var MAX_LABEL_LENGTH, MAX_NAME_LENGTH, IPV4_PARTS, MAX_OCTET, LABEL, NUMERIC_LAST_LABEL, IPV4_PART;
99
+ var init_hostName = __esm({
100
+ "src/hostName.ts"() {
101
+ "use strict";
102
+ MAX_LABEL_LENGTH = 63;
103
+ MAX_NAME_LENGTH = 253;
104
+ IPV4_PARTS = 4;
105
+ MAX_OCTET = 255;
106
+ LABEL = /^[a-z0-9_](?:[a-z0-9_-]*[a-z0-9_])?$/i;
107
+ NUMERIC_LAST_LABEL = /^(?:\d+|0x[0-9a-f]*)$/i;
108
+ IPV4_PART = /^(?:0|[1-9]\d{0,2})$/;
109
+ }
110
+ });
111
+
112
+ // src/config/proxyBypass.ts
85
113
  function proxyBypassSyntaxProblem(entry) {
86
114
  if (entry === "" || entry !== entry.trim()) {
87
115
  return "is empty or has surrounding whitespace";
@@ -98,21 +126,15 @@ function proxyBypassSyntaxProblem(entry) {
98
126
  if (entry.includes(":")) {
99
127
  return "has a port, which the proxy variable cannot express: list the host alone";
100
128
  }
101
- return isIpv4(entry) || isDnsName(entry.replace(/^\./, "")) ? void 0 : "is not a host name or an IPv4 address";
129
+ return isDottedDecimalIpv4(entry) || dnsNameProblem(entry.replace(/^\./, "")) === void 0 ? void 0 : "is not a host name or an IPv4 address";
102
130
  }
103
131
  function proxyBypassName(entry) {
104
- return isIpv4(entry) ? void 0 : entry.replace(/^\./, "").toLowerCase();
132
+ return isDottedDecimalIpv4(entry) ? void 0 : entry.replace(/^\./, "").toLowerCase();
105
133
  }
106
- var MAX_NAME_LENGTH, MAX_LABEL_LENGTH, MAX_OCTET, LABEL_RE, IPV4_RE, DIGITS_RE;
107
134
  var init_proxyBypass = __esm({
108
135
  "src/config/proxyBypass.ts"() {
109
136
  "use strict";
110
- MAX_NAME_LENGTH = 253;
111
- MAX_LABEL_LENGTH = 63;
112
- MAX_OCTET = 255;
113
- LABEL_RE = /^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/;
114
- IPV4_RE = /^\d{1,3}(?:\.\d{1,3}){3}$/;
115
- DIGITS_RE = /^\d+$/;
137
+ init_hostName();
116
138
  }
117
139
  });
118
140
 
@@ -308,7 +330,7 @@ function resolveStatusline(settings) {
308
330
  }
309
331
  return resolved;
310
332
  }
311
- var STATUSLINE_HEADER_SEGMENTS, STATUSLINE_ROWS, STATUSLINE_SESSION_TIME_PARTS, PROMPT_CACHE_TTL_SECONDS, ORANGE_PALETTE_INDEX, STATUSLINE_COLOUR_NAMES, DEFAULT_HEADER_SEGMENTS, DEFAULT_ROWS, CLAUDE_HUD_DEFAULTS, STATUSLINE_PRESETS, GIT_WITH_DIRTY_MARKER, JJ_OFF, PRESET_BUNDLES, STATUSLINE_PATH_LEVELS, STATUSLINE_USAGE_VALUES, STATUSLINE_BAR_GRADIENTS, STATUSLINE_TIME_FORMATS, STATUSLINE_HOUR_CYCLES, MAX_PERCENT, MAX_STATUSLINE_PALETTE_INDEX, MAX_STATUSLINE_LABEL_COLUMNS, MIN_STATUSLINE_COLUMNS, MAX_STATUSLINE_COLUMNS, MAX_BAR_CELLS, MAX_ACCOUNT_USER_CHARS, MAX_DISPLAY_TEXT_CHARS, MAX_EXTRA_COMMAND_ARGUMENTS, MAX_EXTRA_COMMAND_ARGUMENT_CHARS, STATUSLINE_EXTRA_GROUP, commandArgument, LABEL_RE2, OPTIONAL_LABEL_RE, mergeGroups, colourValue, barCharacter, STATUSLINE_CONTEXT_VALUES, STATUSLINE_CONTEXT_ESTIMATES, AUTOCOMPACT_RESERVE_FRACTION, AUTOCOMPACT_RESERVE_RAMP_START, AUTOCOMPACT_RESERVE_RAMP_END, labelWithinColumns, labelWithinColumnsMessage, labelShowsSomething, labelShowsSomethingMessage, labelIsPlainText, labelIsPlainTextMessage, windowLabel, overrideText, wholePercent, thresholdPercent, SHAPES, UNSET_NOTE, RESET_NOTE, LANGUAGE_DESCRIPTION, LANGUAGE_TAGS, LANGUAGE_ALIASES, TOP_LEVEL, StatuslineSchema, ResolvedStatuslineSchema, STATUSLINE_DEFAULTS, STATUSLINE_ENV;
333
+ var STATUSLINE_HEADER_SEGMENTS, STATUSLINE_ROWS, STATUSLINE_SESSION_TIME_PARTS, PROMPT_CACHE_TTL_SECONDS, ORANGE_PALETTE_INDEX, STATUSLINE_COLOUR_NAMES, DEFAULT_HEADER_SEGMENTS, DEFAULT_ROWS, CLAUDE_HUD_DEFAULTS, STATUSLINE_PRESETS, GIT_WITH_DIRTY_MARKER, JJ_OFF, PRESET_BUNDLES, STATUSLINE_PATH_LEVELS, STATUSLINE_USAGE_VALUES, STATUSLINE_BAR_GRADIENTS, STATUSLINE_TIME_FORMATS, STATUSLINE_HOUR_CYCLES, MAX_PERCENT, MAX_STATUSLINE_PALETTE_INDEX, MAX_STATUSLINE_LABEL_COLUMNS, MIN_STATUSLINE_COLUMNS, MAX_STATUSLINE_COLUMNS, MAX_BAR_CELLS, MAX_ACCOUNT_USER_CHARS, MAX_DISPLAY_TEXT_CHARS, MAX_EXTRA_COMMAND_ARGUMENTS, MAX_EXTRA_COMMAND_ARGUMENT_CHARS, STATUSLINE_EXTRA_GROUP, commandArgument, LABEL_RE, OPTIONAL_LABEL_RE, mergeGroups, colourValue, barCharacter, STATUSLINE_CONTEXT_VALUES, STATUSLINE_CONTEXT_ESTIMATES, AUTOCOMPACT_RESERVE_FRACTION, AUTOCOMPACT_RESERVE_RAMP_START, AUTOCOMPACT_RESERVE_RAMP_END, labelWithinColumns, labelWithinColumnsMessage, labelShowsSomething, labelShowsSomethingMessage, labelIsPlainText, labelIsPlainTextMessage, windowLabel, overrideText, wholePercent, thresholdPercent, SHAPES, UNSET_NOTE, RESET_NOTE, LANGUAGE_DESCRIPTION, LANGUAGE_TAGS, LANGUAGE_ALIASES, TOP_LEVEL, StatuslineSchema, ResolvedStatuslineSchema, STATUSLINE_DEFAULTS, STATUSLINE_ENV;
312
334
  var init_statusline = __esm({
313
335
  "src/config/statusline.ts"() {
314
336
  "use strict";
@@ -379,7 +401,7 @@ var init_statusline = __esm({
379
401
  MAX_EXTRA_COMMAND_ARGUMENT_CHARS = 1024;
380
402
  STATUSLINE_EXTRA_GROUP = "extra";
381
403
  commandArgument = z2.string().max(MAX_EXTRA_COMMAND_ARGUMENT_CHARS).refine((argument) => !argument.includes("\0"), "must not contain a NUL character");
382
- LABEL_RE2 = /^[^\p{C}\p{Z}]+(?: [^\p{C}\p{Z}]+)*$/u;
404
+ LABEL_RE = /^[^\p{C}\p{Z}]+(?: [^\p{C}\p{Z}]+)*$/u;
383
405
  OPTIONAL_LABEL_RE = /^(?:[^\p{C}\p{Z}]+(?: [^\p{C}\p{Z}]+)*)?$/u;
384
406
  mergeGroups = z2.array(distinctList(z2.enum(STATUSLINE_ROWS)).min(2)).refine((groups) => {
385
407
  const rows = groups.flat();
@@ -396,7 +418,7 @@ var init_statusline = __esm({
396
418
  labelWithinColumnsMessage = `must take no more than ${String(MAX_STATUSLINE_LABEL_COLUMNS)} terminal columns`;
397
419
  labelShowsSomething = (text) => !drawsNothing(text);
398
420
  labelShowsSomethingMessage = "must show something: a label of only combining marks or blank characters draws nothing";
399
- labelIsPlainText = (text) => LABEL_RE2.test(text);
421
+ labelIsPlainText = (text) => LABEL_RE.test(text);
400
422
  labelIsPlainTextMessage = "must be visible text without control characters";
401
423
  windowLabel = z2.string().refine((text) => text === "" || labelWithinColumns(text), labelWithinColumnsMessage).refine((text) => text === "" || labelShowsSomething(text), labelShowsSomethingMessage).refine((text) => text === "" || labelIsPlainText(text), labelIsPlainTextMessage);
402
424
  overrideText = z2.string().max(MAX_DISPLAY_TEXT_CHARS).regex(OPTIONAL_LABEL_RE, "must be visible text without control characters");
@@ -3747,6 +3769,120 @@ var init_farm = __esm({
3747
3769
  }
3748
3770
  });
3749
3771
 
3772
+ // src/baseUrlDial.ts
3773
+ import { isIPv6 } from "node:net";
3774
+ import { domainToASCII } from "node:url";
3775
+ function dialHostOf(url) {
3776
+ return withoutRootDot(url.hostname.replace(/^\[(.*)\]$/, "$1"));
3777
+ }
3778
+ function withoutRootDot(host) {
3779
+ return host.endsWith(".") ? host.slice(0, -1) : host;
3780
+ }
3781
+ function bareZone(literal) {
3782
+ return literal.replace("%25", "%");
3783
+ }
3784
+ function portOf(text) {
3785
+ if (text === "") {
3786
+ return "has no port after the colon";
3787
+ }
3788
+ if (!/^\d+$/.test(text)) {
3789
+ return "has a port that is not a number";
3790
+ }
3791
+ const port = Number(text);
3792
+ return port >= 1 && port <= MAX_TCP_PORT ? port : `has a port outside 1 to ${String(MAX_TCP_PORT)}`;
3793
+ }
3794
+ function isAscii(text) {
3795
+ return new RegExp("^\\p{ASCII}*$", "u").test(text);
3796
+ }
3797
+ function nameOf(host) {
3798
+ const rooted = withoutRootDot(host.toLowerCase());
3799
+ if (rooted === "") {
3800
+ return { refusal: "an authority that names no host" };
3801
+ }
3802
+ const lowered = isAscii(rooted) ? rooted : domainToASCII(rooted);
3803
+ if (lowered === "") {
3804
+ return { refusal: "a host that does not convert to an ASCII name" };
3805
+ }
3806
+ if (isDottedDecimalIpv4(lowered)) {
3807
+ return lowered;
3808
+ }
3809
+ const problem = dnsNameProblem(lowered);
3810
+ if (problem !== void 0) {
3811
+ return { refusal: problem };
3812
+ }
3813
+ return lowered;
3814
+ }
3815
+ function canonicalLiteral(literal) {
3816
+ return literal.includes("%") ? lowerHost(literal) : dialHostOf(new URL(`http://[${literal}]/`));
3817
+ }
3818
+ function lowerHost(host) {
3819
+ const zone = host.indexOf("%");
3820
+ return zone === -1 ? host.toLowerCase() : `${host.slice(0, zone).toLowerCase()}${host.slice(zone)}`;
3821
+ }
3822
+ function parseDialAuthority(authority, defaultPort) {
3823
+ if (authority.includes("@")) {
3824
+ return { refusal: "an authority with userinfo cannot be dialled" };
3825
+ }
3826
+ if (NOT_AUTHORITY.test(authority)) {
3827
+ return { refusal: "an authority holds whitespace, a path, a query or a fragment" };
3828
+ }
3829
+ if (authority.startsWith("[")) {
3830
+ const close = authority.indexOf("]");
3831
+ if (close === -1) {
3832
+ return { refusal: "an authority with an unterminated bracket" };
3833
+ }
3834
+ const literal = bareZone(authority.slice(1, close));
3835
+ const rest = authority.slice(close + 1);
3836
+ if (literal === "") {
3837
+ return { refusal: "an authority that names no host" };
3838
+ }
3839
+ if (!isIPv6(literal)) {
3840
+ return { refusal: "a bracketed host that is not an IPv6 literal" };
3841
+ }
3842
+ if (rest !== "" && !rest.startsWith(":")) {
3843
+ return { refusal: "an authority with text after the closing bracket other than a port" };
3844
+ }
3845
+ const port2 = rest === "" ? defaultPort : portOf(rest.slice(1));
3846
+ return typeof port2 === "string" ? { refusal: `an authority that ${port2}` } : { host: canonicalLiteral(literal), port: port2 };
3847
+ }
3848
+ const colons = authority.split(":").length - 1;
3849
+ if (colons > 1) {
3850
+ return { refusal: "an unbracketed IPv6 literal, which must be written in brackets" };
3851
+ }
3852
+ const colon = authority.indexOf(":");
3853
+ const host = colon === -1 ? authority : authority.slice(0, colon);
3854
+ if (host === "") {
3855
+ return { refusal: "an authority that names no host" };
3856
+ }
3857
+ if (/[[\]]/.test(host)) {
3858
+ return { refusal: "an authority with brackets round something other than an IPv6 literal" };
3859
+ }
3860
+ const name = nameOf(host);
3861
+ if (typeof name !== "string") {
3862
+ return name;
3863
+ }
3864
+ const port = colon === -1 ? defaultPort : portOf(authority.slice(colon + 1));
3865
+ return typeof port === "string" ? { refusal: `an authority that ${port}` } : { host: name, port };
3866
+ }
3867
+ function dialTargetOf(baseUrl) {
3868
+ const url = new URL(baseUrl);
3869
+ const defaultPort = DEFAULT_PORTS[url.protocol];
3870
+ if (defaultPort === void 0) {
3871
+ throw new Error(`${url.protocol} is not a scheme a provider's base URL can have`);
3872
+ }
3873
+ return { host: dialHostOf(url), port: url.port === "" ? defaultPort : Number(url.port) };
3874
+ }
3875
+ var MAX_TCP_PORT, NOT_AUTHORITY, DEFAULT_PORTS;
3876
+ var init_baseUrlDial = __esm({
3877
+ "src/baseUrlDial.ts"() {
3878
+ "use strict";
3879
+ init_hostName();
3880
+ MAX_TCP_PORT = 65535;
3881
+ NOT_AUTHORITY = /[\s/?#\\]/;
3882
+ DEFAULT_PORTS = { "http:": 80, "https:": 443 };
3883
+ }
3884
+ });
3885
+
3750
3886
  // src/frontdoor/x509.ts
3751
3887
  import { createHash, createPrivateKey, generateKeyPairSync, randomBytes, sign, X509Certificate } from "node:crypto";
3752
3888
  import net from "node:net";
@@ -4135,6 +4271,39 @@ var init_route = __esm({
4135
4271
  }
4136
4272
  });
4137
4273
 
4274
+ // src/processRole.ts
4275
+ function enterProcessRole(role) {
4276
+ const previous = currentRole;
4277
+ currentRole = role;
4278
+ return () => {
4279
+ currentRole = previous;
4280
+ };
4281
+ }
4282
+ function noteBlockingStep() {
4283
+ blockingStepObserver?.();
4284
+ }
4285
+ function refuseToBlockInRole(operation) {
4286
+ noteBlockingStep();
4287
+ if (currentRole !== void 0) {
4288
+ throw new BlockingInEventLoopError(operation, currentRole);
4289
+ }
4290
+ }
4291
+ var currentRole, BlockingInEventLoopError, blockingStepObserver;
4292
+ var init_processRole = __esm({
4293
+ "src/processRole.ts"() {
4294
+ "use strict";
4295
+ init_cliError();
4296
+ BlockingInEventLoopError = class extends CliError {
4297
+ constructor(operation, role) {
4298
+ super(
4299
+ `${operation} blocks the calling thread, which in the ${role} is the event loop that answers every session; it must not run there (a launch planned inside the door reaches it through its own addresses, never through the launcher's synchronous coordination)`
4300
+ );
4301
+ this.name = "BlockingInEventLoopError";
4302
+ }
4303
+ };
4304
+ }
4305
+ });
4306
+
4138
4307
  // src/baseUrlDisplay.ts
4139
4308
  function displayBaseUrl(baseUrl) {
4140
4309
  const url = new URL(baseUrl);
@@ -4885,38 +5054,63 @@ var init_providerCatalogue = __esm({
4885
5054
  }
4886
5055
  });
4887
5056
 
4888
- // src/frontdoor/state.ts
5057
+ // src/frontdoor/catalogueCleanup.ts
4889
5058
  import path12 from "node:path";
4890
5059
  import { z as z8 } from "zod";
5060
+ async function pruneAbandonedCatalogueGenerations(fs17, paths, ownPid, generation, runningAmong) {
5061
+ const root = path12.join(paths.catalogueDir, "supervisors");
5062
+ const owners = fs17.readdir(root).flatMap((entry) => {
5063
+ const pid = Number(entry);
5064
+ return Number.isSafeInteger(pid) && pid > 0 && String(pid) === entry && fs17.lstat(path12.join(root, entry))?.kind === "dir" ? [pid] : [];
5065
+ });
5066
+ const running = await runningAmong(owners);
5067
+ for (const pid of owners) {
5068
+ if (pid !== ownPid && running.has(pid)) continue;
5069
+ const directory = path12.join(root, String(pid));
5070
+ for (const entry of fs17.readdir(directory)) {
5071
+ const candidate = path12.join(directory, entry);
5072
+ if (z8.uuid().safeParse(entry).success && (pid !== ownPid || entry !== generation) && fs17.lstat(candidate)?.kind === "dir") fs17.removeRecursive(candidate);
5073
+ }
5074
+ }
5075
+ }
5076
+ var init_catalogueCleanup = __esm({
5077
+ "src/frontdoor/catalogueCleanup.ts"() {
5078
+ "use strict";
5079
+ }
5080
+ });
5081
+
5082
+ // src/frontdoor/state.ts
5083
+ import path13 from "node:path";
5084
+ import { z as z9 } from "zod";
4891
5085
  function readCatalogueStatus(fs17, paths, pid, generation, name) {
4892
- const file = path12.join(path12.dirname(catalogueCachePath(paths, name, pid, generation)), `${name}.status.json`);
5086
+ const file = path13.join(path13.dirname(catalogueCachePath(paths, name, pid, generation)), `${name}.status.json`);
4893
5087
  const raw = fs17.readFileUtf8(file);
4894
5088
  if (raw === void 0) return void 0;
4895
5089
  try {
4896
- const value = z8.strictObject({ status: z8.enum(["running", "ready", "failed"]), fingerprint: z8.string().min(1).optional(), recordedAt: z8.number().optional() }).safeParse(JSON.parse(raw));
5090
+ const value = z9.strictObject({ status: z9.enum(["running", "ready", "failed"]), fingerprint: z9.string().min(1).optional(), recordedAt: z9.number().optional() }).safeParse(JSON.parse(raw));
4897
5091
  return value.success ? value.data : void 0;
4898
5092
  } catch {
4899
5093
  return void 0;
4900
5094
  }
4901
5095
  }
4902
5096
  function writeFrontDoorCodexHome(fs17, frontdoorDir, pid, codexHome, generation) {
4903
- const directory = path12.join(frontdoorDir, "codex-homes");
5097
+ const directory = path13.join(frontdoorDir, "codex-homes");
4904
5098
  fs17.mkdirp(directory);
4905
- fs17.writeFilePrivate(path12.join(directory, `${String(pid)}.json`), `${JSON.stringify({ codexHome, generation })}
5099
+ fs17.writeFilePrivate(path13.join(directory, `${String(pid)}.json`), `${JSON.stringify({ codexHome, generation })}
4906
5100
  `);
4907
5101
  }
4908
5102
  function readFrontDoorCodexRecord(fs17, frontdoorDir, pid) {
4909
- const raw = fs17.readFileUtf8(path12.join(frontdoorDir, "codex-homes", `${String(pid)}.json`));
5103
+ const raw = fs17.readFileUtf8(path13.join(frontdoorDir, "codex-homes", `${String(pid)}.json`));
4910
5104
  if (raw === void 0) return void 0;
4911
5105
  try {
4912
- const parsed = z8.strictObject({ codexHome: z8.string().min(1), generation: z8.uuid() }).safeParse(JSON.parse(raw));
4913
- return parsed.success && path12.isAbsolute(parsed.data.codexHome) ? parsed.data : void 0;
5106
+ const parsed = z9.strictObject({ codexHome: z9.string().min(1), generation: z9.uuid() }).safeParse(JSON.parse(raw));
5107
+ return parsed.success && path13.isAbsolute(parsed.data.codexHome) ? parsed.data : void 0;
4914
5108
  } catch {
4915
5109
  return void 0;
4916
5110
  }
4917
5111
  }
4918
5112
  function removeFrontDoorCodexHome(fs17, frontdoorDir, pid) {
4919
- fs17.removeRecursive(path12.join(frontdoorDir, "codex-homes", `${String(pid)}.json`));
5113
+ fs17.removeRecursive(path13.join(frontdoorDir, "codex-homes", `${String(pid)}.json`));
4920
5114
  }
4921
5115
  function readFrontDoorState(fs17, stateFile) {
4922
5116
  let raw;
@@ -4936,7 +5130,7 @@ function readFrontDoorState(fs17, stateFile) {
4936
5130
  }
4937
5131
  }
4938
5132
  function writeFrontDoorState(fs17, stateFile, state) {
4939
- fs17.mkdirp(path12.dirname(stateFile));
5133
+ fs17.mkdirp(path13.dirname(stateFile));
4940
5134
  fs17.writeFilePrivate(stateFile, `${JSON.stringify(state, null, 2)}
4941
5135
  `);
4942
5136
  }
@@ -4949,18 +5143,18 @@ function frontDoorOrigin(state) {
4949
5143
  }
4950
5144
  function writeFrontDoorDirectRecord(fs17, recordsDir, record) {
4951
5145
  fs17.mkdirp(recordsDir);
4952
- fs17.writeFilePrivate(path12.join(recordsDir, `${String(record.pid)}.json`), `${JSON.stringify({ directPort: record.directPort })}
5146
+ fs17.writeFilePrivate(path13.join(recordsDir, `${String(record.pid)}.json`), `${JSON.stringify({ directPort: record.directPort })}
4953
5147
  `);
4954
5148
  }
4955
5149
  function removeFrontDoorDirectRecord(fs17, recordsDir, pid) {
4956
- fs17.removeRecursive(path12.join(recordsDir, `${String(pid)}.json`));
5150
+ fs17.removeRecursive(path13.join(recordsDir, `${String(pid)}.json`));
4957
5151
  }
4958
5152
  function markFrontDoorDraining(fs17, markersDir, pid) {
4959
5153
  fs17.mkdirp(markersDir);
4960
- fs17.writeFilePrivate(path12.join(markersDir, String(pid)), "\n");
5154
+ fs17.writeFilePrivate(path13.join(markersDir, String(pid)), "\n");
4961
5155
  }
4962
5156
  function unmarkFrontDoorDraining(fs17, markersDir, pid) {
4963
- fs17.removeRecursive(path12.join(markersDir, String(pid)));
5157
+ fs17.removeRecursive(path13.join(markersDir, String(pid)));
4964
5158
  }
4965
5159
  function listDrainingFrontDoors(fs17, markersDir, isRunning) {
4966
5160
  return fs17.readdir(markersDir).flatMap((file) => /^[1-9]\d*$/.test(file) && Number.isSafeInteger(Number(file)) ? [Number(file)] : []).filter(isRunning).sort((a, b) => a - b);
@@ -4977,7 +5171,7 @@ function readDirectRecordEntry(fs17, recordsDir, file) {
4977
5171
  }
4978
5172
  let raw;
4979
5173
  try {
4980
- raw = fs17.readFileUtf8(path12.join(recordsDir, file));
5174
+ raw = fs17.readFileUtf8(path13.join(recordsDir, file));
4981
5175
  } catch {
4982
5176
  return void 0;
4983
5177
  }
@@ -5002,7 +5196,7 @@ function pruneMalformedFrontDoorDirectFiles(fs17, recordsDir, isRunning) {
5002
5196
  const writer = RECORD_TEMPORARY_FILE.exec(file)?.[1];
5003
5197
  const stale = writer !== void 0 && !isRunning(Number(writer));
5004
5198
  if (stale || readDirectRecordEntry(fs17, recordsDir, file)?.malformed === true) {
5005
- fs17.removeRecursive(path12.join(recordsDir, file));
5199
+ fs17.removeRecursive(path13.join(recordsDir, file));
5006
5200
  }
5007
5201
  }
5008
5202
  }
@@ -5021,7 +5215,7 @@ function recordOf(details) {
5021
5215
  }
5022
5216
  function writeFrontDoorSession(fs17, sessionsDir, session) {
5023
5217
  fs17.mkdirPrivate(sessionsDir);
5024
- fs17.writeFilePrivate(path12.join(sessionsDir, sessionRecordName(session.pid)), `${JSON.stringify(session, null, 2)}
5218
+ fs17.writeFilePrivate(path13.join(sessionsDir, sessionRecordName(session.pid)), `${JSON.stringify(session, null, 2)}
5025
5219
  `);
5026
5220
  }
5027
5221
  function sessionRecordName(pid) {
@@ -5035,7 +5229,7 @@ function summaryOf(session) {
5035
5229
  }
5036
5230
  function readFrontDoorSessionRecord(fs17, sessionsDir, name) {
5037
5231
  try {
5038
- const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs17.readFileUtf8(path12.join(sessionsDir, name)) ?? ""));
5232
+ const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs17.readFileUtf8(path13.join(sessionsDir, name)) ?? ""));
5039
5233
  return parsed.success ? parsed.data : void 0;
5040
5234
  } catch {
5041
5235
  return void 0;
@@ -5052,7 +5246,7 @@ function listFrontDoorSessions(fs17, sessionsDir) {
5052
5246
  return sessions.sort((a, b) => a.pid - b.pid);
5053
5247
  }
5054
5248
  function removeFrontDoorSession(fs17, sessionsDir, pid) {
5055
- fs17.removeRecursive(path12.join(sessionsDir, sessionRecordName(pid)));
5249
+ fs17.removeRecursive(path13.join(sessionsDir, sessionRecordName(pid)));
5056
5250
  }
5057
5251
  function pruneDeadFrontDoorSessions(fs17, sessionsDir, listed, isRunning) {
5058
5252
  const removed = [];
@@ -5064,109 +5258,51 @@ function pruneDeadFrontDoorSessions(fs17, sessionsDir, listed, isRunning) {
5064
5258
  }
5065
5259
  return removed;
5066
5260
  }
5067
- var FRONT_DOOR_PROTOCOL, FRONT_DOOR_HANDOVER_PROTOCOL, FrontDoorSessionSchema, FrontDoorStateSchema, MAX_TCP_PORT, FrontDoorDirectRecordSchema, RECORD_TEMPORARY_FILE;
5261
+ var FRONT_DOOR_PROTOCOL, FRONT_DOOR_HANDOVER_PROTOCOL, FrontDoorSessionSchema, FrontDoorStateSchema, FrontDoorDirectRecordSchema, RECORD_TEMPORARY_FILE;
5068
5262
  var init_state = __esm({
5069
5263
  "src/frontdoor/state.ts"() {
5070
5264
  "use strict";
5071
5265
  init_schema();
5266
+ init_baseUrlDial();
5072
5267
  init_providerCatalogue();
5073
5268
  FRONT_DOOR_PROTOCOL = 8;
5074
5269
  FRONT_DOOR_HANDOVER_PROTOCOL = 6;
5075
- FrontDoorSessionSchema = z8.strictObject({ pid: z8.number().int().positive(), startedAt: z8.number(), token: z8.string().min(1), supervisorPid: z8.number().int().positive().optional(), sessionId: z8.string().min(1).optional(), identity: z8.string().min(1).optional(), models: ModelsConfigSchema.optional() });
5076
- FrontDoorStateSchema = z8.strictObject({
5270
+ FrontDoorSessionSchema = z9.strictObject({ pid: z9.number().int().positive(), startedAt: z9.number(), token: z9.string().min(1), supervisorPid: z9.number().int().positive().optional(), sessionId: z9.string().min(1).optional(), identity: z9.string().min(1).optional(), models: ModelsConfigSchema.optional() });
5271
+ FrontDoorStateSchema = z9.strictObject({
5077
5272
  /**
5078
5273
  * The launcher-to-door wire protocol this supervisor speaks, written once it is serving; absent in state written by a release that predates the field, which `ensureFrontDoor` reads as protocol 0. A launcher replaces a door whose protocol is lower than its own (see `FRONT_DOOR_PROTOCOL`).
5079
5274
  */
5080
- protocol: z8.number().int().nonnegative().optional(),
5275
+ protocol: z9.number().int().nonnegative().optional(),
5081
5276
  /** The supervisor process serving the front door. Alive means both listeners are up in that process. */
5082
- supervisorPid: z8.number().int().positive().optional(),
5277
+ supervisorPid: z9.number().int().positive().optional(),
5083
5278
  /** The loopback port the HTTPS provider listener serves on. Absent until the listener has bound and answered its health probe, so "port is set" is itself the ready signal a launcher polls for. */
5084
- port: z8.number().int().positive().optional(),
5279
+ port: z9.number().int().positive().optional(),
5085
5280
  /**
5086
5281
  * The sticky port preference for the provider listener: kept across crashes, restarts and idle shutdowns so every provider session, whose base URL was frozen at launch, keeps finding the front door at the same address.
5087
5282
  */
5088
- lastPort: z8.number().int().positive().optional(),
5283
+ lastPort: z9.number().int().positive().optional(),
5089
5284
  /**
5090
5285
  * The loopback port the CONNECT surface listens on. Absent whenever no supervisor is serving it, so "connectPort is set" is the ready signal an OAuth launch polls for alongside `port`.
5091
5286
  */
5092
- connectPort: z8.number().int().positive().optional(),
5287
+ connectPort: z9.number().int().positive().optional(),
5093
5288
  /**
5094
5289
  * The sticky port preference for the CONNECT surface, the exact analogue of `lastPort` for the second listener: it survives every shutdown, because every OAuth session's environment was frozen at launch with HTTPS_PROXY pointing at this address and a restart that moves strands them.
5095
5290
  */
5096
- lastConnectPort: z8.number().int().positive().optional(),
5291
+ lastConnectPort: z9.number().int().positive().optional(),
5097
5292
  /**
5098
5293
  * The loopback port the direct listener serves on: the listener a headroom hop tells the daemon to forward routed traffic back to. Sticky like the others, because headroom's allowlist admits its exact origin: the headroom supervisor rewrites the daemon's allowlist file when the origin moves, but a provider launch waits at its gate until it has, so an ephemeral port would hold launches up after every restart.
5099
5294
  */
5100
- directPort: z8.number().int().positive().optional(),
5295
+ directPort: z9.number().int().positive().optional(),
5101
5296
  /** The sticky port preference for the direct listener, for the reason `directPort` gives. */
5102
- lastDirectPort: z8.number().int().positive().optional(),
5297
+ lastDirectPort: z9.number().int().positive().optional(),
5103
5298
  /** The last fatal error, kept across shutdowns so `frontdoor status` can explain a front door that is not running. */
5104
- lastError: z8.string().optional()
5299
+ lastError: z9.string().optional()
5105
5300
  });
5106
- MAX_TCP_PORT = 65535;
5107
- FrontDoorDirectRecordSchema = z8.strictObject({ directPort: z8.number().int().positive().max(MAX_TCP_PORT) });
5301
+ FrontDoorDirectRecordSchema = z9.strictObject({ directPort: z9.number().int().positive().max(MAX_TCP_PORT) });
5108
5302
  RECORD_TEMPORARY_FILE = /^[1-9]\d*\.json\.([1-9]\d*)\.tmp$/;
5109
5303
  }
5110
5304
  });
5111
5305
 
5112
- // src/processRole.ts
5113
- function enterProcessRole(role) {
5114
- const previous = currentRole;
5115
- currentRole = role;
5116
- return () => {
5117
- currentRole = previous;
5118
- };
5119
- }
5120
- function noteBlockingStep() {
5121
- blockingStepObserver?.();
5122
- }
5123
- function refuseToBlockInRole(operation) {
5124
- noteBlockingStep();
5125
- if (currentRole !== void 0) {
5126
- throw new BlockingInEventLoopError(operation, currentRole);
5127
- }
5128
- }
5129
- var currentRole, BlockingInEventLoopError, blockingStepObserver;
5130
- var init_processRole = __esm({
5131
- "src/processRole.ts"() {
5132
- "use strict";
5133
- init_cliError();
5134
- BlockingInEventLoopError = class extends CliError {
5135
- constructor(operation, role) {
5136
- super(
5137
- `${operation} blocks the calling thread, which in the ${role} is the event loop that answers every session; it must not run there (a launch planned inside the door reaches it through its own addresses, never through the launcher's synchronous coordination)`
5138
- );
5139
- this.name = "BlockingInEventLoopError";
5140
- }
5141
- };
5142
- }
5143
- });
5144
-
5145
- // src/frontdoor/catalogueCleanup.ts
5146
- import path13 from "node:path";
5147
- import { z as z9 } from "zod";
5148
- async function pruneAbandonedCatalogueGenerations(fs17, paths, ownPid, generation, runningAmong) {
5149
- const root = path13.join(paths.catalogueDir, "supervisors");
5150
- const owners = fs17.readdir(root).flatMap((entry) => {
5151
- const pid = Number(entry);
5152
- return Number.isSafeInteger(pid) && pid > 0 && String(pid) === entry && fs17.lstat(path13.join(root, entry))?.kind === "dir" ? [pid] : [];
5153
- });
5154
- const running = await runningAmong(owners);
5155
- for (const pid of owners) {
5156
- if (pid !== ownPid && running.has(pid)) continue;
5157
- const directory = path13.join(root, String(pid));
5158
- for (const entry of fs17.readdir(directory)) {
5159
- const candidate = path13.join(directory, entry);
5160
- if (z9.uuid().safeParse(entry).success && (pid !== ownPid || entry !== generation) && fs17.lstat(candidate)?.kind === "dir") fs17.removeRecursive(candidate);
5161
- }
5162
- }
5163
- }
5164
- var init_catalogueCleanup = __esm({
5165
- "src/frontdoor/catalogueCleanup.ts"() {
5166
- "use strict";
5167
- }
5168
- });
5169
-
5170
5306
  // src/frontdoor/supervisor.ts
5171
5307
  import path14 from "node:path";
5172
5308
  function watchedInstallEntry(resolvedOwnExecutablePath, siblingExists) {
@@ -5417,17 +5553,8 @@ var init_supervisor = __esm({
5417
5553
  import { X509Certificate as X509Certificate2, createPrivateKey as createPrivateKey2 } from "node:crypto";
5418
5554
  import * as fs3 from "node:fs";
5419
5555
  function parseConnectTarget(authority) {
5420
- const colon = authority.lastIndexOf(":");
5421
- if (colon === -1) {
5422
- const host2 = authority.trim().toLowerCase();
5423
- return host2 === "" ? void 0 : { host: host2, port: HTTPS_PORT };
5424
- }
5425
- const host = authority.slice(0, colon).trim().toLowerCase();
5426
- const port = Number.parseInt(authority.slice(colon + 1), 10);
5427
- if (host === "" || !Number.isInteger(port) || port <= 0 || port > MAX_TCP_PORT) {
5428
- return void 0;
5429
- }
5430
- return { host, port };
5556
+ const parsed = parseDialAuthority(authority, HTTPS_PORT);
5557
+ return "refusal" in parsed ? void 0 : parsed;
5431
5558
  }
5432
5559
  function isInterceptedHost(host, interceptHosts) {
5433
5560
  return interceptHosts.includes(host);
@@ -5746,9 +5873,9 @@ function routeConnect(socket, head, context) {
5746
5873
  const requestLine = head.split("\r\n", 1)[0] ?? "";
5747
5874
  const parts = requestLine.split(" ");
5748
5875
  const authority = parts.length === CONNECT_LINE_TOKENS && parts[0]?.toUpperCase() === "CONNECT" ? parts[1] ?? "" : void 0;
5749
- const target = authority === void 0 ? void 0 : parseConnectTarget(authority);
5750
- if (target === void 0) {
5751
- refuse(socket, REFUSAL.badRequest);
5876
+ const target = authority === void 0 ? void 0 : parseDialAuthority(authority, HTTPS_PORT);
5877
+ if (target === void 0 || "refusal" in target) {
5878
+ refuse(socket, REFUSAL.badRequest, target === void 0 ? [] : [`${REFUSAL_HEADER}: ${target.refusal}`]);
5752
5879
  return;
5753
5880
  }
5754
5881
  const session = sessions.find((entry) => entry.host === target.host);
@@ -5819,15 +5946,15 @@ function realConnectCertStore(paths) {
5819
5946
  }
5820
5947
  };
5821
5948
  }
5822
- var CONNECT_INTERCEPT_HOST, CONNECT_INTERCEPT_HOSTS, ROUTED_PATH_PREFIX, HTTPS_PORT, HTTP_BAD_GATEWAY, CA_KEY_FILE_MODE, CONNECT_LINE_TOKENS, HEAD_TERMINATOR, MAX_CONNECT_HEAD_BYTES, CONNECT_ESTABLISHED, REFUSAL, CONNECT_LIMITS, CA_VALIDITY_DAYS, LEAF_VALIDITY_DAYS, CA_SUBJECT_COMMON_NAME, MS_PER_DAY, HOP_BY_HOP_HEADERS, TAP_ALPN_PROTOCOLS;
5949
+ var CONNECT_INTERCEPT_HOST, CONNECT_INTERCEPT_HOSTS, ROUTED_PATH_PREFIX, HTTPS_PORT, HTTP_BAD_GATEWAY, CA_KEY_FILE_MODE, CONNECT_LINE_TOKENS, HEAD_TERMINATOR, MAX_CONNECT_HEAD_BYTES, CONNECT_ESTABLISHED, REFUSAL_HEADER, REFUSAL, CONNECT_LIMITS, CA_VALIDITY_DAYS, LEAF_VALIDITY_DAYS, CA_SUBJECT_COMMON_NAME, MS_PER_DAY, HOP_BY_HOP_HEADERS, TAP_ALPN_PROTOCOLS;
5823
5950
  var init_connect = __esm({
5824
5951
  "src/frontdoor/connect.ts"() {
5825
5952
  "use strict";
5953
+ init_baseUrlDial();
5826
5954
  init_x509();
5827
5955
  init_tap();
5828
5956
  init_capability();
5829
5957
  init_route();
5830
- init_state();
5831
5958
  init_supervisor();
5832
5959
  CONNECT_INTERCEPT_HOST = "api.anthropic.com";
5833
5960
  CONNECT_INTERCEPT_HOSTS = [CONNECT_INTERCEPT_HOST, "platform.claude.com"];
@@ -5839,6 +5966,7 @@ var init_connect = __esm({
5839
5966
  HEAD_TERMINATOR = "\r\n\r\n";
5840
5967
  MAX_CONNECT_HEAD_BYTES = 8192;
5841
5968
  CONNECT_ESTABLISHED = "HTTP/1.1 200 Connection Established\r\n\r\n";
5969
+ REFUSAL_HEADER = "x-agent-shim-refusal";
5842
5970
  REFUSAL = {
5843
5971
  badRequest: "400 Bad Request",
5844
5972
  proxyAuthenticationRequired: "407 Proxy Authentication Required",
@@ -13659,7 +13787,7 @@ var init_package = __esm({
13659
13787
  "package.json"() {
13660
13788
  package_default = {
13661
13789
  name: "claude-use",
13662
- version: "14.0.0",
13790
+ version: "14.0.2",
13663
13791
  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.",
13664
13792
  license: "MIT",
13665
13793
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -13708,7 +13836,7 @@ var init_package = __esm({
13708
13836
  schema: "node scripts/gen-schema.mts"
13709
13837
  },
13710
13838
  dependencies: {
13711
- "@anthropic-ai/claude-agent-sdk": "0.3.311",
13839
+ "@anthropic-ai/claude-agent-sdk": "0.3.316",
13712
13840
  "@clack/prompts": "^1.8.0",
13713
13841
  "@modelcontextprotocol/sdk": "1.32.0",
13714
13842
  "@orpc/client": "2.0.0-beta.46",
@@ -14921,26 +15049,6 @@ var init_paths = __esm({
14921
15049
  }
14922
15050
  });
14923
15051
 
14924
- // src/baseUrlDial.ts
14925
- function dialHostOf(url) {
14926
- return url.hostname.replace(/^\[(.*)\]$/, "$1");
14927
- }
14928
- function dialTargetOf(baseUrl) {
14929
- const url = new URL(baseUrl);
14930
- const defaultPort = DEFAULT_PORTS[url.protocol];
14931
- if (defaultPort === void 0) {
14932
- throw new Error(`${url.protocol} is not a scheme a provider's base URL can have`);
14933
- }
14934
- return { host: dialHostOf(url), port: url.port === "" ? defaultPort : Number(url.port) };
14935
- }
14936
- var DEFAULT_PORTS;
14937
- var init_baseUrlDial = __esm({
14938
- "src/baseUrlDial.ts"() {
14939
- "use strict";
14940
- DEFAULT_PORTS = { "http:": 80, "https:": 443 };
14941
- }
14942
- });
14943
-
14944
15052
  // src/frontdoor/probe.ts
14945
15053
  import { Worker } from "node:worker_threads";
14946
15054
  function probeWorkerSource(body) {
@@ -18805,13 +18913,13 @@ function withRegisteredSessionFacts(statuses, registry) {
18805
18913
  };
18806
18914
  });
18807
18915
  }
18808
- function withIdentityNames(statuses, nameOf) {
18916
+ function withIdentityNames(statuses, nameOf2) {
18809
18917
  return statuses.map((status) => {
18810
18918
  if (status.identity === void 0) {
18811
18919
  return status;
18812
18920
  }
18813
18921
  const { identity: id, ...rest } = status;
18814
- const name = nameOf(id);
18922
+ const name = nameOf2(id);
18815
18923
  return name === void 0 ? rest : { ...rest, identity: name };
18816
18924
  });
18817
18925
  }