claude-use 7.5.0 → 7.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cli.cjs +218 -90
- package/dist/index.cjs +134 -46
- package/dist/index.mjs +134 -46
- package/dist/types/frontdoor/capture.d.ts +9 -0
- package/dist/types/frontdoor/connect.d.ts +14 -6
- package/dist/types/frontdoor/connectEffects.d.ts +3 -0
- package/dist/types/frontdoor/ensure.d.ts +2 -0
- package/dist/types/frontdoor/state.d.ts +7 -0
- package/dist/types/frontdoor/tap.d.ts +8 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,8 +63,8 @@ Every top-level entry in `~/.claude` is classified into one of five categories,
|
|
|
63
63
|
|
|
64
64
|
| Category | Default shared? | Example entries |
|
|
65
65
|
|---|---|---|
|
|
66
|
-
| `secret` | **Never** — hardcoded, cannot be overridden by any configuration layer | `.credentials.json`, `backups` |
|
|
67
|
-
| `runtime` | No | `daemon*`, `.git*`, `.DS_Store`, `mcp-needs-auth-cache.json`, `shell-snapshots`, `statsig`, `telemetry`, `stats-cache.json`, `usage-data`, `ide`, `cache`, `scheduled_tasks.lock` |
|
|
66
|
+
| `secret` | **Never** — hardcoded, cannot be overridden by any configuration layer | `.credentials.json`, `backups`, `settings.json.bak*` |
|
|
67
|
+
| `runtime` | No | `daemon*`, `.git*`, `.DS_Store`, `mcp-needs-auth-cache.json`, `codex-quota.json`, `file-transfers`, `shell-snapshots`, `statsig`, `telemetry`, `stats-cache.json`, `usage-data`, `ide`, `cache`, `scheduled_tasks.lock` |
|
|
68
68
|
| `history` | Yes | `projects`, `sessions`, `session-env`, `teams`, `tasks`, `todos`, `history.jsonl`, `transcripts`, `paste-cache`, `file-history`, `plans`, `workflows`, `jobs`, `debug`, `downloads`, `chrome` |
|
|
69
69
|
| `knowledge` | Yes | `skills`, `agents`, `rules`, `memory`, `commands`, `plugins`, `hooks`, `AGENTS.md`, `CLAUDE.md`, `README.md` |
|
|
70
70
|
| `settings` | Yes | `settings.json`, `settings.local.json` |
|
package/dist/cli.cjs
CHANGED
|
@@ -8756,7 +8756,7 @@ var require_connect = __commonJS({
|
|
|
8756
8756
|
const sessionCache = new SessionCache(maxCachedSessions == null ? 100 : maxCachedSessions);
|
|
8757
8757
|
timeout = timeout == null ? 1e4 : timeout;
|
|
8758
8758
|
allowH2 = allowH2 != null ? allowH2 : false;
|
|
8759
|
-
return function
|
|
8759
|
+
return function connect3({ hostname: hostname3, host, protocol, port, servername, localAddress, httpSocket }, callback) {
|
|
8760
8760
|
let socket;
|
|
8761
8761
|
if (protocol === "https:") {
|
|
8762
8762
|
if (!tls2) {
|
|
@@ -14554,7 +14554,7 @@ var require_client = __commonJS({
|
|
|
14554
14554
|
tls: tls2,
|
|
14555
14555
|
strictContentLength,
|
|
14556
14556
|
maxCachedSessions,
|
|
14557
|
-
connect:
|
|
14557
|
+
connect: connect4,
|
|
14558
14558
|
maxRequestsPerClient,
|
|
14559
14559
|
localAddress,
|
|
14560
14560
|
maxResponseSize,
|
|
@@ -14612,7 +14612,7 @@ var require_client = __commonJS({
|
|
|
14612
14612
|
if (bodyTimeout != null && (!Number.isInteger(bodyTimeout) || bodyTimeout < 0)) {
|
|
14613
14613
|
throw new InvalidArgumentError2("bodyTimeout must be a positive integer or zero");
|
|
14614
14614
|
}
|
|
14615
|
-
if (
|
|
14615
|
+
if (connect4 != null && typeof connect4 !== "function" && typeof connect4 !== "object") {
|
|
14616
14616
|
throw new InvalidArgumentError2("connect must be a function or an object");
|
|
14617
14617
|
}
|
|
14618
14618
|
if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) {
|
|
@@ -14646,8 +14646,8 @@ var require_client = __commonJS({
|
|
|
14646
14646
|
throw new InvalidArgumentError2("pingInterval must be a positive integer, greater or equal to 0");
|
|
14647
14647
|
}
|
|
14648
14648
|
super({ webSocket });
|
|
14649
|
-
if (typeof
|
|
14650
|
-
|
|
14649
|
+
if (typeof connect4 !== "function") {
|
|
14650
|
+
connect4 = buildConnector({
|
|
14651
14651
|
...tls2,
|
|
14652
14652
|
maxCachedSessions,
|
|
14653
14653
|
allowH2,
|
|
@@ -14655,18 +14655,18 @@ var require_client = __commonJS({
|
|
|
14655
14655
|
socketPath,
|
|
14656
14656
|
timeout: connectTimeout,
|
|
14657
14657
|
...typeof autoSelectFamily === "boolean" ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
|
|
14658
|
-
...
|
|
14658
|
+
...connect4
|
|
14659
14659
|
});
|
|
14660
14660
|
} else {
|
|
14661
|
-
const customConnect =
|
|
14662
|
-
|
|
14661
|
+
const customConnect = connect4;
|
|
14662
|
+
connect4 = (opts, callback) => customConnect({
|
|
14663
14663
|
...opts,
|
|
14664
14664
|
...socketPath != null ? { socketPath } : null,
|
|
14665
14665
|
...allowH2 != null ? { allowH2 } : null
|
|
14666
14666
|
}, callback);
|
|
14667
14667
|
}
|
|
14668
14668
|
this[kUrl] = util.parseOrigin(url2);
|
|
14669
|
-
this[kConnector] =
|
|
14669
|
+
this[kConnector] = connect4;
|
|
14670
14670
|
this[kPipelining] = pipelining != null ? pipelining : 1;
|
|
14671
14671
|
this[kMaxHeadersSize] = maxHeaderSize;
|
|
14672
14672
|
this[kKeepAliveDefaultTimeout] = keepAliveTimeout == null ? 4e3 : keepAliveTimeout;
|
|
@@ -14724,7 +14724,7 @@ var require_client = __commonJS({
|
|
|
14724
14724
|
);
|
|
14725
14725
|
}
|
|
14726
14726
|
[kConnect](cb) {
|
|
14727
|
-
|
|
14727
|
+
connect3(this);
|
|
14728
14728
|
this.once("connect", cb);
|
|
14729
14729
|
}
|
|
14730
14730
|
[kDispatch](opts, handler) {
|
|
@@ -14790,7 +14790,7 @@ var require_client = __commonJS({
|
|
|
14790
14790
|
assert2(client[kSize] === 0);
|
|
14791
14791
|
}
|
|
14792
14792
|
}
|
|
14793
|
-
function
|
|
14793
|
+
function connect3(client) {
|
|
14794
14794
|
assert2(!client[kConnecting]);
|
|
14795
14795
|
assert2(!client[kHTTPContext]);
|
|
14796
14796
|
let { host, hostname: hostname3, protocol, port } = client[kUrl];
|
|
@@ -14969,7 +14969,7 @@ var require_client = __commonJS({
|
|
|
14969
14969
|
return;
|
|
14970
14970
|
}
|
|
14971
14971
|
if (!client[kHTTPContext]) {
|
|
14972
|
-
|
|
14972
|
+
connect3(client);
|
|
14973
14973
|
return;
|
|
14974
14974
|
}
|
|
14975
14975
|
if (client[kHTTPContext].destroyed) {
|
|
@@ -15265,7 +15265,7 @@ var require_pool = __commonJS({
|
|
|
15265
15265
|
constructor(origin, {
|
|
15266
15266
|
connections,
|
|
15267
15267
|
factory = defaultFactory,
|
|
15268
|
-
connect:
|
|
15268
|
+
connect: connect3,
|
|
15269
15269
|
connectTimeout,
|
|
15270
15270
|
tls: tls2,
|
|
15271
15271
|
maxCachedSessions,
|
|
@@ -15282,24 +15282,24 @@ var require_pool = __commonJS({
|
|
|
15282
15282
|
if (typeof factory !== "function") {
|
|
15283
15283
|
throw new InvalidArgumentError2("factory must be a function.");
|
|
15284
15284
|
}
|
|
15285
|
-
if (
|
|
15285
|
+
if (connect3 != null && typeof connect3 !== "function" && typeof connect3 !== "object") {
|
|
15286
15286
|
throw new InvalidArgumentError2("connect must be a function or an object");
|
|
15287
15287
|
}
|
|
15288
|
-
if (typeof
|
|
15289
|
-
|
|
15288
|
+
if (typeof connect3 !== "function") {
|
|
15289
|
+
connect3 = buildConnector({
|
|
15290
15290
|
...tls2,
|
|
15291
15291
|
maxCachedSessions,
|
|
15292
15292
|
allowH2,
|
|
15293
15293
|
socketPath,
|
|
15294
15294
|
timeout: connectTimeout,
|
|
15295
15295
|
...typeof autoSelectFamily === "boolean" ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
|
|
15296
|
-
...
|
|
15296
|
+
...connect3
|
|
15297
15297
|
});
|
|
15298
15298
|
}
|
|
15299
15299
|
super(options);
|
|
15300
15300
|
this[kConnections] = connections || null;
|
|
15301
15301
|
this[kUrl] = util.parseOrigin(origin);
|
|
15302
|
-
this[kOptions] = { ...util.deepClone(options), connect:
|
|
15302
|
+
this[kOptions] = { ...util.deepClone(options), connect: connect3, allowH2, clientTtl, socketPath };
|
|
15303
15303
|
this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0;
|
|
15304
15304
|
this[kFactory] = factory;
|
|
15305
15305
|
this.on("connect", (origin2, targets) => {
|
|
@@ -15378,14 +15378,14 @@ var require_balanced_pool = __commonJS({
|
|
|
15378
15378
|
return new Pool(origin, opts);
|
|
15379
15379
|
}
|
|
15380
15380
|
var BalancedPool = class extends PoolBase {
|
|
15381
|
-
constructor(upstreams = [], { factory = defaultFactory, connect:
|
|
15381
|
+
constructor(upstreams = [], { factory = defaultFactory, connect: connect3, tls: tls2, ...opts } = {}) {
|
|
15382
15382
|
if (typeof factory !== "function") {
|
|
15383
15383
|
throw new InvalidArgumentError2("factory must be a function.");
|
|
15384
15384
|
}
|
|
15385
15385
|
super(opts);
|
|
15386
|
-
if (
|
|
15386
|
+
if (connect3 && typeof connect3 !== "function") connect3 = { ...connect3 };
|
|
15387
15387
|
if (tls2 && typeof tls2 !== "function") tls2 = { ...tls2 };
|
|
15388
|
-
this[kOptions] = { ...util.deepClone(opts), connect:
|
|
15388
|
+
this[kOptions] = { ...util.deepClone(opts), connect: connect3, tls: tls2 };
|
|
15389
15389
|
this[kOptions].interceptors = opts.interceptors ? { ...opts.interceptors } : void 0;
|
|
15390
15390
|
this[kIndex] = -1;
|
|
15391
15391
|
this[kCurrentWeight] = 0;
|
|
@@ -15518,7 +15518,7 @@ var require_round_robin_pool = __commonJS({
|
|
|
15518
15518
|
constructor(origin, {
|
|
15519
15519
|
connections,
|
|
15520
15520
|
factory = defaultFactory,
|
|
15521
|
-
connect:
|
|
15521
|
+
connect: connect3,
|
|
15522
15522
|
connectTimeout,
|
|
15523
15523
|
tls: tls2,
|
|
15524
15524
|
maxCachedSessions,
|
|
@@ -15535,24 +15535,24 @@ var require_round_robin_pool = __commonJS({
|
|
|
15535
15535
|
if (typeof factory !== "function") {
|
|
15536
15536
|
throw new InvalidArgumentError2("factory must be a function.");
|
|
15537
15537
|
}
|
|
15538
|
-
if (
|
|
15538
|
+
if (connect3 != null && typeof connect3 !== "function" && typeof connect3 !== "object") {
|
|
15539
15539
|
throw new InvalidArgumentError2("connect must be a function or an object");
|
|
15540
15540
|
}
|
|
15541
|
-
if (typeof
|
|
15542
|
-
|
|
15541
|
+
if (typeof connect3 !== "function") {
|
|
15542
|
+
connect3 = buildConnector({
|
|
15543
15543
|
...tls2,
|
|
15544
15544
|
maxCachedSessions,
|
|
15545
15545
|
allowH2,
|
|
15546
15546
|
socketPath,
|
|
15547
15547
|
timeout: connectTimeout,
|
|
15548
15548
|
...typeof autoSelectFamily === "boolean" ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
|
|
15549
|
-
...
|
|
15549
|
+
...connect3
|
|
15550
15550
|
});
|
|
15551
15551
|
}
|
|
15552
15552
|
super();
|
|
15553
15553
|
this[kConnections] = connections || null;
|
|
15554
15554
|
this[kUrl] = util.parseOrigin(origin);
|
|
15555
|
-
this[kOptions] = { ...util.deepClone(options), connect:
|
|
15555
|
+
this[kOptions] = { ...util.deepClone(options), connect: connect3, allowH2, clientTtl, socketPath };
|
|
15556
15556
|
this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0;
|
|
15557
15557
|
this[kFactory] = factory;
|
|
15558
15558
|
this[kIndex] = -1;
|
|
@@ -15626,21 +15626,21 @@ var require_agent = __commonJS({
|
|
|
15626
15626
|
return opts && opts.connections === 1 ? new Client(origin, opts) : new Pool(origin, opts);
|
|
15627
15627
|
}
|
|
15628
15628
|
var Agent6 = class extends DispatcherBase {
|
|
15629
|
-
constructor({ factory = defaultFactory, maxOrigins = Infinity, connect:
|
|
15629
|
+
constructor({ factory = defaultFactory, maxOrigins = Infinity, connect: connect3, ...options } = {}) {
|
|
15630
15630
|
if (typeof factory !== "function") {
|
|
15631
15631
|
throw new InvalidArgumentError2("factory must be a function.");
|
|
15632
15632
|
}
|
|
15633
|
-
if (
|
|
15633
|
+
if (connect3 != null && typeof connect3 !== "function" && typeof connect3 !== "object") {
|
|
15634
15634
|
throw new InvalidArgumentError2("connect must be a function or an object");
|
|
15635
15635
|
}
|
|
15636
15636
|
if (typeof maxOrigins !== "number" || Number.isNaN(maxOrigins) || maxOrigins <= 0) {
|
|
15637
15637
|
throw new InvalidArgumentError2("maxOrigins must be a number greater than 0");
|
|
15638
15638
|
}
|
|
15639
15639
|
super(options);
|
|
15640
|
-
if (
|
|
15641
|
-
|
|
15640
|
+
if (connect3 && typeof connect3 !== "function") {
|
|
15641
|
+
connect3 = { ...connect3 };
|
|
15642
15642
|
}
|
|
15643
|
-
this[kOptions] = { ...util.deepClone(options), maxOrigins, connect:
|
|
15643
|
+
this[kOptions] = { ...util.deepClone(options), maxOrigins, connect: connect3 };
|
|
15644
15644
|
this[kFactory] = factory;
|
|
15645
15645
|
this[kClients] = /* @__PURE__ */ new Map();
|
|
15646
15646
|
this[kOrigins] = /* @__PURE__ */ new Set();
|
|
@@ -16471,16 +16471,16 @@ var require_proxy_agent = __commonJS({
|
|
|
16471
16471
|
}
|
|
16472
16472
|
var Http1ProxyWrapper = class extends DispatcherBase {
|
|
16473
16473
|
#client;
|
|
16474
|
-
constructor(proxyUrl, { headers = {}, connect:
|
|
16474
|
+
constructor(proxyUrl, { headers = {}, connect: connect3, factory }) {
|
|
16475
16475
|
if (!proxyUrl) {
|
|
16476
16476
|
throw new InvalidArgumentError2("Proxy URL is mandatory");
|
|
16477
16477
|
}
|
|
16478
16478
|
super();
|
|
16479
16479
|
this[kProxyHeaders] = headers;
|
|
16480
16480
|
if (factory) {
|
|
16481
|
-
this.#client = factory(proxyUrl, { connect:
|
|
16481
|
+
this.#client = factory(proxyUrl, { connect: connect3 });
|
|
16482
16482
|
} else {
|
|
16483
|
-
this.#client = new Client(proxyUrl, { connect:
|
|
16483
|
+
this.#client = new Client(proxyUrl, { connect: connect3 });
|
|
16484
16484
|
}
|
|
16485
16485
|
}
|
|
16486
16486
|
[kDispatch](opts, handler) {
|
|
@@ -16541,7 +16541,7 @@ var require_proxy_agent = __commonJS({
|
|
|
16541
16541
|
} else if (username && password) {
|
|
16542
16542
|
this[kProxyHeaders]["proxy-authorization"] = `Basic ${Buffer.from(`${decodeURIComponent(username)}:${decodeURIComponent(password)}`).toString("base64")}`;
|
|
16543
16543
|
}
|
|
16544
|
-
const
|
|
16544
|
+
const connect3 = buildConnector({ ...opts.proxyTls });
|
|
16545
16545
|
this[kConnectEndpoint] = buildConnector({ ...opts.requestTls });
|
|
16546
16546
|
const agentFactory = opts.factory || defaultAgentFactory;
|
|
16547
16547
|
const factory = (origin2, options) => {
|
|
@@ -16549,7 +16549,7 @@ var require_proxy_agent = __commonJS({
|
|
|
16549
16549
|
if (this[kProxy].protocol === "socks5:" || this[kProxy].protocol === "socks:") {
|
|
16550
16550
|
return new Socks5ProxyAgent(this[kProxy].uri, {
|
|
16551
16551
|
headers: this[kProxyHeaders],
|
|
16552
|
-
connect:
|
|
16552
|
+
connect: connect3,
|
|
16553
16553
|
factory: agentFactory,
|
|
16554
16554
|
username: opts.username || username,
|
|
16555
16555
|
password: opts.password || password,
|
|
@@ -16560,7 +16560,7 @@ var require_proxy_agent = __commonJS({
|
|
|
16560
16560
|
if (!this[kTunnelProxy] && protocol2 === "http:" && this[kProxy].protocol === "http:") {
|
|
16561
16561
|
return new Http1ProxyWrapper(this[kProxy].uri, {
|
|
16562
16562
|
headers: this[kProxyHeaders],
|
|
16563
|
-
connect:
|
|
16563
|
+
connect: connect3,
|
|
16564
16564
|
factory: agentFactory
|
|
16565
16565
|
});
|
|
16566
16566
|
}
|
|
@@ -16569,7 +16569,7 @@ var require_proxy_agent = __commonJS({
|
|
|
16569
16569
|
if (protocol === "socks5:" || protocol === "socks:") {
|
|
16570
16570
|
this[kClient] = null;
|
|
16571
16571
|
} else {
|
|
16572
|
-
this[kClient] = clientFactory(url2, { connect:
|
|
16572
|
+
this[kClient] = clientFactory(url2, { connect: connect3 });
|
|
16573
16573
|
}
|
|
16574
16574
|
this[kAgent] = new Agent6({
|
|
16575
16575
|
...opts,
|
|
@@ -18402,10 +18402,10 @@ var require_api_connect = __commonJS({
|
|
|
18402
18402
|
}
|
|
18403
18403
|
}
|
|
18404
18404
|
};
|
|
18405
|
-
function
|
|
18405
|
+
function connect3(opts, callback) {
|
|
18406
18406
|
if (callback === void 0) {
|
|
18407
18407
|
return new Promise((resolve, reject) => {
|
|
18408
|
-
|
|
18408
|
+
connect3.call(this, opts, (err, data) => {
|
|
18409
18409
|
return err ? reject(err) : resolve(data);
|
|
18410
18410
|
});
|
|
18411
18411
|
});
|
|
@@ -18422,7 +18422,7 @@ var require_api_connect = __commonJS({
|
|
|
18422
18422
|
queueMicrotask(() => callback(err, { opaque }));
|
|
18423
18423
|
}
|
|
18424
18424
|
}
|
|
18425
|
-
module2.exports =
|
|
18425
|
+
module2.exports = connect3;
|
|
18426
18426
|
}
|
|
18427
18427
|
});
|
|
18428
18428
|
|
|
@@ -57330,12 +57330,14 @@ var import_picomatch = __toESM(require_picomatch2(), 1);
|
|
|
57330
57330
|
|
|
57331
57331
|
// src/config/categories.default.json
|
|
57332
57332
|
var categories_default_default = {
|
|
57333
|
-
secret: [".credentials.json", "backups"],
|
|
57333
|
+
secret: [".credentials.json", "backups", "settings.json.bak*"],
|
|
57334
57334
|
runtime: [
|
|
57335
57335
|
"daemon*",
|
|
57336
57336
|
".git*",
|
|
57337
57337
|
".DS_Store",
|
|
57338
57338
|
"mcp-needs-auth-cache.json",
|
|
57339
|
+
"codex-quota.json",
|
|
57340
|
+
"file-transfers",
|
|
57339
57341
|
"shell-snapshots",
|
|
57340
57342
|
"statsig",
|
|
57341
57343
|
"telemetry",
|
|
@@ -61051,7 +61053,7 @@ function resolveLaunchIdentity(paths, cwd) {
|
|
|
61051
61053
|
// package.json
|
|
61052
61054
|
var package_default = {
|
|
61053
61055
|
name: "claude-use",
|
|
61054
|
-
version: "7.
|
|
61056
|
+
version: "7.6.1",
|
|
61055
61057
|
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.",
|
|
61056
61058
|
license: "MIT",
|
|
61057
61059
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -63789,8 +63791,13 @@ var import_node_path27 = __toESM(require("node:path"), 1);
|
|
|
63789
63791
|
|
|
63790
63792
|
// src/frontdoor/state.ts
|
|
63791
63793
|
var import_node_path26 = __toESM(require("node:path"), 1);
|
|
63794
|
+
var FRONT_DOOR_PROTOCOL = 1;
|
|
63792
63795
|
var FrontDoorSessionSchema = external_exports.strictObject({ pid: external_exports.number().int().positive(), startedAt: external_exports.number(), token: external_exports.string().min(1) });
|
|
63793
63796
|
var FrontDoorStateSchema = external_exports.strictObject({
|
|
63797
|
+
/**
|
|
63798
|
+
* 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`).
|
|
63799
|
+
*/
|
|
63800
|
+
protocol: external_exports.number().int().nonnegative().optional(),
|
|
63794
63801
|
/** The supervisor process serving the front door. Alive means both listeners are up in that process. */
|
|
63795
63802
|
supervisorPid: external_exports.number().int().positive().optional(),
|
|
63796
63803
|
/** 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. */
|
|
@@ -64450,6 +64457,39 @@ function createFileCapture(file2, now = () => /* @__PURE__ */ new Date()) {
|
|
|
64450
64457
|
upgrade: (request6) => {
|
|
64451
64458
|
append({ kind: "upgrade", method: request6.method ?? "?", url: request6.url ?? "?", headers: redactHeaders(request6.headers) });
|
|
64452
64459
|
},
|
|
64460
|
+
tapStream: (host) => {
|
|
64461
|
+
nextId += 1;
|
|
64462
|
+
const id = nextId;
|
|
64463
|
+
append({ kind: "stream", id, host });
|
|
64464
|
+
const stored = { "client-to-server": 0, "server-to-client": 0 };
|
|
64465
|
+
const sequences = { "client-to-server": 0, "server-to-client": 0 };
|
|
64466
|
+
return {
|
|
64467
|
+
onChunk: (direction, chunk) => {
|
|
64468
|
+
sequences[direction] += 1;
|
|
64469
|
+
const budget = STREAM_LOG_CAP_BYTES - stored[direction];
|
|
64470
|
+
if (budget <= 0) {
|
|
64471
|
+
return;
|
|
64472
|
+
}
|
|
64473
|
+
const excerpt = chunk.subarray(0, Math.min(CHUNK_LOG_CAP_BYTES, budget));
|
|
64474
|
+
stored[direction] += excerpt.length;
|
|
64475
|
+
const text2 = excerpt.toString("utf8");
|
|
64476
|
+
const faithful = Buffer.from(text2, "utf8").equals(excerpt);
|
|
64477
|
+
append({
|
|
64478
|
+
kind: "stream-chunk",
|
|
64479
|
+
id,
|
|
64480
|
+
dir: direction,
|
|
64481
|
+
seq: sequences[direction],
|
|
64482
|
+
bytes: chunk.length,
|
|
64483
|
+
stored: excerpt.length,
|
|
64484
|
+
truncated: excerpt.length < chunk.length,
|
|
64485
|
+
...faithful ? { body: redactText(text2) } : { b64: excerpt.toString("base64") }
|
|
64486
|
+
});
|
|
64487
|
+
},
|
|
64488
|
+
onEnd: () => {
|
|
64489
|
+
append({ kind: "stream-end", id, clientToServerCapped: stored["client-to-server"] >= STREAM_LOG_CAP_BYTES, serverToClientCapped: stored["server-to-client"] >= STREAM_LOG_CAP_BYTES });
|
|
64490
|
+
}
|
|
64491
|
+
};
|
|
64492
|
+
},
|
|
64453
64493
|
observePassthrough: (request6) => {
|
|
64454
64494
|
nextId += 1;
|
|
64455
64495
|
const id = nextId;
|
|
@@ -64495,10 +64535,6 @@ function createFileCapture(file2, now = () => /* @__PURE__ */ new Date()) {
|
|
|
64495
64535
|
// src/frontdoor/connect.ts
|
|
64496
64536
|
var import_node_crypto10 = require("node:crypto");
|
|
64497
64537
|
var fs12 = __toESM(require("node:fs"), 1);
|
|
64498
|
-
var http = __toESM(require("node:http"), 1);
|
|
64499
|
-
var https = __toESM(require("node:https"), 1);
|
|
64500
|
-
var net3 = __toESM(require("node:net"), 1);
|
|
64501
|
-
var tls = __toESM(require("node:tls"), 1);
|
|
64502
64538
|
|
|
64503
64539
|
// src/frontdoor/x509.ts
|
|
64504
64540
|
var import_node_crypto9 = require("node:crypto");
|
|
@@ -64771,6 +64807,54 @@ function issueLeafCertificate(ca, names, notBefore, notAfter) {
|
|
|
64771
64807
|
return { certPem: toPem("CERTIFICATE", der), keyPem: keyPem(privateKey) };
|
|
64772
64808
|
}
|
|
64773
64809
|
|
|
64810
|
+
// src/frontdoor/tap.ts
|
|
64811
|
+
function pumpTapSession(secure, openUpstream, tap) {
|
|
64812
|
+
let upstream;
|
|
64813
|
+
let ended = false;
|
|
64814
|
+
const end = () => {
|
|
64815
|
+
if (!ended) {
|
|
64816
|
+
ended = true;
|
|
64817
|
+
tap?.onEnd();
|
|
64818
|
+
}
|
|
64819
|
+
};
|
|
64820
|
+
const drop = () => {
|
|
64821
|
+
end();
|
|
64822
|
+
secure.destroy();
|
|
64823
|
+
upstream?.destroy();
|
|
64824
|
+
};
|
|
64825
|
+
secure.once("close", () => {
|
|
64826
|
+
end();
|
|
64827
|
+
upstream?.destroy();
|
|
64828
|
+
});
|
|
64829
|
+
secure.once("error", drop);
|
|
64830
|
+
const clientAlpn = "alpnProtocol" in secure && typeof secure.alpnProtocol === "string" ? secure.alpnProtocol : void 0;
|
|
64831
|
+
void (async () => {
|
|
64832
|
+
try {
|
|
64833
|
+
upstream = await openUpstream(clientAlpn);
|
|
64834
|
+
} catch {
|
|
64835
|
+
drop();
|
|
64836
|
+
return;
|
|
64837
|
+
}
|
|
64838
|
+
if (secure.destroyed) {
|
|
64839
|
+
end();
|
|
64840
|
+
upstream.destroy();
|
|
64841
|
+
return;
|
|
64842
|
+
}
|
|
64843
|
+
if (tap !== void 0) {
|
|
64844
|
+
secure.on("data", (chunk) => {
|
|
64845
|
+
tap.onChunk("client-to-server", chunk);
|
|
64846
|
+
});
|
|
64847
|
+
upstream.on("data", (chunk) => {
|
|
64848
|
+
tap.onChunk("server-to-client", chunk);
|
|
64849
|
+
});
|
|
64850
|
+
}
|
|
64851
|
+
secure.pipe(upstream);
|
|
64852
|
+
upstream.pipe(secure);
|
|
64853
|
+
upstream.once("close", drop);
|
|
64854
|
+
upstream.once("error", drop);
|
|
64855
|
+
})();
|
|
64856
|
+
}
|
|
64857
|
+
|
|
64774
64858
|
// src/frontdoor/supervisor.ts
|
|
64775
64859
|
var FRONTDOOR_SUPERVISOR_STILL_RUNNING = -1;
|
|
64776
64860
|
var FRONTDOOR_POLL_MS = 1e3;
|
|
@@ -64805,23 +64889,23 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
64805
64889
|
}
|
|
64806
64890
|
lastPort = http5.port;
|
|
64807
64891
|
const previousStickyConnect = lastConnectPort;
|
|
64808
|
-
let
|
|
64892
|
+
let connect3;
|
|
64809
64893
|
try {
|
|
64810
|
-
|
|
64894
|
+
connect3 = await ports.startConnectListener(lastConnectPort);
|
|
64811
64895
|
} catch (error62) {
|
|
64812
64896
|
await http5.close();
|
|
64813
64897
|
return fail(`could not start the CONNECT surface: ${error62 instanceof Error ? error62.message : String(error62)}`);
|
|
64814
64898
|
}
|
|
64815
|
-
if (previousStickyConnect !== void 0 &&
|
|
64816
|
-
ports.log(`agent-shim frontdoor supervisor: sticky CONNECT port ${String(previousStickyConnect)} was occupied; moving to ${String(
|
|
64899
|
+
if (previousStickyConnect !== void 0 && connect3.port !== previousStickyConnect) {
|
|
64900
|
+
ports.log(`agent-shim frontdoor supervisor: sticky CONNECT port ${String(previousStickyConnect)} was occupied; moving to ${String(connect3.port)} (OAuth sessions launched against the old port are stale until they relaunch)`);
|
|
64817
64901
|
}
|
|
64818
|
-
lastConnectPort =
|
|
64902
|
+
lastConnectPort = connect3.port;
|
|
64819
64903
|
const previousStickyDirect = lastDirectPort;
|
|
64820
64904
|
let direct;
|
|
64821
64905
|
try {
|
|
64822
64906
|
direct = await ports.startDirectListener(lastDirectPort);
|
|
64823
64907
|
} catch (error62) {
|
|
64824
|
-
await
|
|
64908
|
+
await connect3.close();
|
|
64825
64909
|
await http5.close();
|
|
64826
64910
|
return fail(`could not start the direct listener: ${error62 instanceof Error ? error62.message : String(error62)}`);
|
|
64827
64911
|
}
|
|
@@ -64829,9 +64913,9 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
64829
64913
|
ports.log(`agent-shim frontdoor supervisor: sticky direct port ${String(previousStickyDirect)} was occupied; moving to ${String(direct.port)} (headroom must be restarted to admit the new address)`);
|
|
64830
64914
|
}
|
|
64831
64915
|
lastDirectPort = direct.port;
|
|
64832
|
-
writeFrontDoorState(fs18, paths.frontdoorStateFile, { supervisorPid: ports.ownPid, port: http5.port, connectPort:
|
|
64916
|
+
writeFrontDoorState(fs18, paths.frontdoorStateFile, { protocol: FRONT_DOOR_PROTOCOL, supervisorPid: ports.ownPid, port: http5.port, connectPort: connect3.port, directPort: direct.port, ...sticky() });
|
|
64833
64917
|
fs18.removeRecursive(paths.frontdoorLockFile);
|
|
64834
|
-
ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: front door on 127.0.0.1:${String(http5.port)}, CONNECT surface on 127.0.0.1:${String(
|
|
64918
|
+
ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: front door on 127.0.0.1:${String(http5.port)}, CONNECT surface on 127.0.0.1:${String(connect3.port)}`);
|
|
64835
64919
|
let idleSince;
|
|
64836
64920
|
let ticks = 0;
|
|
64837
64921
|
for (; ; ) {
|
|
@@ -64845,7 +64929,7 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
64845
64929
|
if (ports.now() - idleSince >= idleShutdownMinutes * MS_PER_MINUTE) {
|
|
64846
64930
|
ports.log(`agent-shim frontdoor supervisor: no sessions for ${String(idleShutdownMinutes)} minute(s); closing the front door and exiting`);
|
|
64847
64931
|
await direct.close();
|
|
64848
|
-
await
|
|
64932
|
+
await connect3.close();
|
|
64849
64933
|
await http5.close();
|
|
64850
64934
|
writeFrontDoorState(fs18, paths.frontdoorStateFile, sticky());
|
|
64851
64935
|
return 0;
|
|
@@ -64860,6 +64944,7 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
64860
64944
|
// src/frontdoor/connect.ts
|
|
64861
64945
|
var CONNECT_INTERCEPT_HOST = "api.anthropic.com";
|
|
64862
64946
|
var CONNECT_INTERCEPT_HOSTS = [CONNECT_INTERCEPT_HOST, "platform.claude.com"];
|
|
64947
|
+
var CONNECT_TAP_HOSTS = ["platform.claude.com"];
|
|
64863
64948
|
var ROUTED_PATH_PREFIX = "/v1/";
|
|
64864
64949
|
var HTTPS_PORT = 443;
|
|
64865
64950
|
var MAX_PORT = 65535;
|
|
@@ -64967,9 +65052,20 @@ function caParses(ca) {
|
|
|
64967
65052
|
return false;
|
|
64968
65053
|
}
|
|
64969
65054
|
}
|
|
65055
|
+
var TAP_ALPN_PROTOCOLS = ["h2", "http/1.1"];
|
|
64970
65056
|
async function startConnectServer(config2, effects, preferredPort) {
|
|
64971
65057
|
const onUpgrade = config2.capture === void 0 ? void 0 : (request6) => config2.capture?.upgrade(request6);
|
|
64972
65058
|
const sessions = config2.interceptHosts.map((host) => {
|
|
65059
|
+
if (config2.tapHosts.includes(host)) {
|
|
65060
|
+
const tlsAcceptor2 = effects.createTlsAcceptor(
|
|
65061
|
+
config2.leafFor(host),
|
|
65062
|
+
(secure) => {
|
|
65063
|
+
pumpTapSession(secure, async (clientAlpn) => await effects.connectTlsUpstream(host, HTTPS_PORT, clientAlpn), config2.capture?.tapStream?.(host));
|
|
65064
|
+
},
|
|
65065
|
+
TAP_ALPN_PROTOCOLS
|
|
65066
|
+
);
|
|
65067
|
+
return { host, tlsAcceptor: tlsAcceptor2 };
|
|
65068
|
+
}
|
|
64973
65069
|
const handler = (request6, response) => {
|
|
64974
65070
|
if (host === config2.routedHost && servedByPipeline(request6.url)) {
|
|
64975
65071
|
config2.serveRouted(request6, response);
|
|
@@ -64994,7 +65090,7 @@ async function startConnectServer(config2, effects, preferredPort) {
|
|
|
64994
65090
|
await listener.close();
|
|
64995
65091
|
for (const { httpSession, tlsAcceptor } of sessions) {
|
|
64996
65092
|
tlsAcceptor.close();
|
|
64997
|
-
httpSession
|
|
65093
|
+
httpSession?.close();
|
|
64998
65094
|
}
|
|
64999
65095
|
}
|
|
65000
65096
|
};
|
|
@@ -65170,6 +65266,40 @@ async function blindTunnel(socket, target, effects) {
|
|
|
65170
65266
|
socket.destroy();
|
|
65171
65267
|
});
|
|
65172
65268
|
}
|
|
65269
|
+
function isEnoent5(error62) {
|
|
65270
|
+
return typeof error62 === "object" && error62 !== null && "code" in error62 && error62.code === "ENOENT";
|
|
65271
|
+
}
|
|
65272
|
+
function realConnectCertStore(paths) {
|
|
65273
|
+
const read = (file2) => {
|
|
65274
|
+
try {
|
|
65275
|
+
return fs12.readFileSync(file2, "utf8");
|
|
65276
|
+
} catch (error62) {
|
|
65277
|
+
if (isEnoent5(error62)) {
|
|
65278
|
+
return void 0;
|
|
65279
|
+
}
|
|
65280
|
+
throw error62;
|
|
65281
|
+
}
|
|
65282
|
+
};
|
|
65283
|
+
return {
|
|
65284
|
+
loadCa: () => {
|
|
65285
|
+
const certPem = read(paths.frontdoorCaCertFile);
|
|
65286
|
+
const keyPem2 = read(paths.frontdoorCaKeyFile);
|
|
65287
|
+
return certPem === void 0 || keyPem2 === void 0 ? void 0 : { certPem, keyPem: keyPem2 };
|
|
65288
|
+
},
|
|
65289
|
+
writeCa: (ca) => {
|
|
65290
|
+
fs12.mkdirSync(paths.frontdoorCaDir, { recursive: true });
|
|
65291
|
+
fs12.writeFileSync(paths.frontdoorCaCertFile, ca.certPem, "utf8");
|
|
65292
|
+
fs12.writeFileSync(paths.frontdoorCaKeyFile, ca.keyPem, { encoding: "utf8", mode: CA_KEY_FILE_MODE });
|
|
65293
|
+
fs12.chmodSync(paths.frontdoorCaKeyFile, CA_KEY_FILE_MODE);
|
|
65294
|
+
}
|
|
65295
|
+
};
|
|
65296
|
+
}
|
|
65297
|
+
|
|
65298
|
+
// src/frontdoor/connectEffects.ts
|
|
65299
|
+
var http = __toESM(require("node:http"), 1);
|
|
65300
|
+
var https = __toESM(require("node:https"), 1);
|
|
65301
|
+
var net3 = __toESM(require("node:net"), 1);
|
|
65302
|
+
var tls = __toESM(require("node:tls"), 1);
|
|
65173
65303
|
function realConnectEffects() {
|
|
65174
65304
|
const plainAgent = new http.Agent({ keepAlive: true });
|
|
65175
65305
|
const tlsAgent = new https.Agent({ keepAlive: true });
|
|
@@ -65215,10 +65345,13 @@ function realConnectEffects() {
|
|
|
65215
65345
|
}
|
|
65216
65346
|
return await listenOnce(0, onSocket);
|
|
65217
65347
|
},
|
|
65218
|
-
createTlsAcceptor: (leaf, onSecure) => {
|
|
65219
|
-
const server = tls.createServer(
|
|
65220
|
-
|
|
65221
|
-
|
|
65348
|
+
createTlsAcceptor: (leaf, onSecure, alpnProtocols) => {
|
|
65349
|
+
const server = tls.createServer(
|
|
65350
|
+
{ key: leaf.keyPem, cert: leaf.certPem, ...alpnProtocols === void 0 ? {} : { ALPNProtocols: [...alpnProtocols] } },
|
|
65351
|
+
(secure) => {
|
|
65352
|
+
onSecure(secure);
|
|
65353
|
+
}
|
|
65354
|
+
);
|
|
65222
65355
|
server.on("clientError", (_error, socket) => {
|
|
65223
65356
|
socket.destroy();
|
|
65224
65357
|
});
|
|
@@ -65253,6 +65386,13 @@ function realConnectEffects() {
|
|
|
65253
65386
|
}
|
|
65254
65387
|
};
|
|
65255
65388
|
},
|
|
65389
|
+
connectTlsUpstream: async (host, port, clientAlpn) => await new Promise((resolve, reject) => {
|
|
65390
|
+
const socket = tls.connect({ host, port, servername: host, ...clientAlpn === void 0 ? {} : { ALPNProtocols: [clientAlpn] } });
|
|
65391
|
+
socket.once("secureConnect", () => {
|
|
65392
|
+
resolve(socket);
|
|
65393
|
+
});
|
|
65394
|
+
socket.once("error", reject);
|
|
65395
|
+
}),
|
|
65256
65396
|
connectTcp: async (host, port) => await new Promise((resolve, reject) => {
|
|
65257
65397
|
const socket = net3.connect({ host, port });
|
|
65258
65398
|
socket.once("connect", () => {
|
|
@@ -65316,34 +65456,6 @@ function realConnectEffects() {
|
|
|
65316
65456
|
}
|
|
65317
65457
|
};
|
|
65318
65458
|
}
|
|
65319
|
-
function isEnoent5(error62) {
|
|
65320
|
-
return typeof error62 === "object" && error62 !== null && "code" in error62 && error62.code === "ENOENT";
|
|
65321
|
-
}
|
|
65322
|
-
function realConnectCertStore(paths) {
|
|
65323
|
-
const read = (file2) => {
|
|
65324
|
-
try {
|
|
65325
|
-
return fs12.readFileSync(file2, "utf8");
|
|
65326
|
-
} catch (error62) {
|
|
65327
|
-
if (isEnoent5(error62)) {
|
|
65328
|
-
return void 0;
|
|
65329
|
-
}
|
|
65330
|
-
throw error62;
|
|
65331
|
-
}
|
|
65332
|
-
};
|
|
65333
|
-
return {
|
|
65334
|
-
loadCa: () => {
|
|
65335
|
-
const certPem = read(paths.frontdoorCaCertFile);
|
|
65336
|
-
const keyPem2 = read(paths.frontdoorCaKeyFile);
|
|
65337
|
-
return certPem === void 0 || keyPem2 === void 0 ? void 0 : { certPem, keyPem: keyPem2 };
|
|
65338
|
-
},
|
|
65339
|
-
writeCa: (ca) => {
|
|
65340
|
-
fs12.mkdirSync(paths.frontdoorCaDir, { recursive: true });
|
|
65341
|
-
fs12.writeFileSync(paths.frontdoorCaCertFile, ca.certPem, "utf8");
|
|
65342
|
-
fs12.writeFileSync(paths.frontdoorCaKeyFile, ca.keyPem, { encoding: "utf8", mode: CA_KEY_FILE_MODE });
|
|
65343
|
-
fs12.chmodSync(paths.frontdoorCaKeyFile, CA_KEY_FILE_MODE);
|
|
65344
|
-
}
|
|
65345
|
-
};
|
|
65346
|
-
}
|
|
65347
65459
|
|
|
65348
65460
|
// src/frontdoor/ensure.ts
|
|
65349
65461
|
var import_node_crypto11 = require("node:crypto");
|
|
@@ -65359,6 +65471,7 @@ function ensureFrontDoor(params) {
|
|
|
65359
65471
|
const { paths, ports } = params;
|
|
65360
65472
|
const deadline = ports.now() + FRONTDOOR_START_TIMEOUT_MS;
|
|
65361
65473
|
let spawned = false;
|
|
65474
|
+
let replaced = false;
|
|
65362
65475
|
const distrusted = /* @__PURE__ */ new Set();
|
|
65363
65476
|
let lastRejection;
|
|
65364
65477
|
for (; ; ) {
|
|
@@ -65367,6 +65480,17 @@ function ensureFrontDoor(params) {
|
|
|
65367
65480
|
if (supervisorPid !== void 0 && !distrusted.has(supervisorPid) && ports.isRunning(supervisorPid)) {
|
|
65368
65481
|
if (state?.port !== void 0 && state.connectPort !== void 0) {
|
|
65369
65482
|
const verdict = ports.verifyListener(state.port);
|
|
65483
|
+
if (verdict.ok && (state.protocol ?? 0) < FRONT_DOOR_PROTOCOL && !replaced) {
|
|
65484
|
+
ports.stopSupervisor(supervisorPid);
|
|
65485
|
+
while (ports.isRunning(supervisorPid)) {
|
|
65486
|
+
if (ports.now() >= deadline) {
|
|
65487
|
+
throw new FrontDoorStartError(`agent-shim: the front door (pid ${String(supervisorPid)}, protocol ${String(state.protocol ?? 0)}) is older than this launcher (protocol ${String(FRONT_DOOR_PROTOCOL)}) and did not exit when asked. Daemon log: ${paths.frontdoorLogPath}`);
|
|
65488
|
+
}
|
|
65489
|
+
ports.sleep(FRONTDOOR_LAUNCHER_POLL_MS);
|
|
65490
|
+
}
|
|
65491
|
+
replaced = true;
|
|
65492
|
+
continue;
|
|
65493
|
+
}
|
|
65370
65494
|
if (verdict.ok) {
|
|
65371
65495
|
const token = (0, import_node_crypto11.randomUUID)();
|
|
65372
65496
|
writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token });
|
|
@@ -66973,6 +67097,7 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
66973
67097
|
const server = await startConnectServer(
|
|
66974
67098
|
{
|
|
66975
67099
|
interceptHosts: CONNECT_INTERCEPT_HOSTS,
|
|
67100
|
+
tapHosts: CONNECT_TAP_HOSTS,
|
|
66976
67101
|
routedHost: CONNECT_INTERCEPT_HOST,
|
|
66977
67102
|
serveRouted: (request6, response) => {
|
|
66978
67103
|
const abort = new AbortController();
|
|
@@ -67044,6 +67169,9 @@ function realFrontDoorPort(paths) {
|
|
|
67044
67169
|
now: () => Date.now(),
|
|
67045
67170
|
sleep: realSleepSync,
|
|
67046
67171
|
spawnSupervisor: (layout) => spawnDetachedSupervisor(layout, "__frontdoor-supervisor", layout.frontdoorLogPath),
|
|
67172
|
+
stopSupervisor: (pid) => {
|
|
67173
|
+
process.kill(pid, "SIGTERM");
|
|
67174
|
+
},
|
|
67047
67175
|
// Read fresh for each probe: a replacement supervisor may have regenerated an unparseable CA, and the probe must trust exactly what the serving door's leaf chains to.
|
|
67048
67176
|
verifyListener: (port) => probeFrontDoorSync(port, import_node_fs11.default.readFileSync(paths.frontdoorCaCertFile, "utf8"))
|
|
67049
67177
|
}
|