claude-use 7.4.0 → 7.6.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/README.md +3 -2
- package/dist/cli.cjs +198 -90
- package/dist/index.cjs +316 -126
- package/dist/index.mjs +291 -126
- package/dist/types/config/schema.d.ts +1 -1
- 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/tap.d.ts +8 -0
- package/dist/types/index.d.ts +7 -2
- 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` |
|
|
@@ -226,6 +226,7 @@ Issues and pull requests are welcome. Please keep the tool itself free of assump
|
|
|
226
226
|
- [docs/architecture.md](docs/architecture.md): the source layout file by file, error reporting design, schema rationale, and resolver mechanics.
|
|
227
227
|
- [docs/release-process.md](docs/release-process.md): the semantic-release pipeline, the Node SEA build, its macOS x64 limitation, and npm/GitHub Packages publishing.
|
|
228
228
|
- [docs/testing.md](docs/testing.md): the full list of cases the test suites cover.
|
|
229
|
+
- [docs/library.md](docs/library.md): using agent-shim in process: what the library exposes, and what stays CLI-only.
|
|
229
230
|
- [docs/installation.md](docs/installation.md): every install channel in full, with the platform support matrix.
|
|
230
231
|
- [docs/development.md](docs/development.md): test isolation, commit hooks, and the secret-redaction filter rationale.
|
|
231
232
|
|
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.0",
|
|
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>",
|
|
@@ -64450,6 +64452,39 @@ function createFileCapture(file2, now = () => /* @__PURE__ */ new Date()) {
|
|
|
64450
64452
|
upgrade: (request6) => {
|
|
64451
64453
|
append({ kind: "upgrade", method: request6.method ?? "?", url: request6.url ?? "?", headers: redactHeaders(request6.headers) });
|
|
64452
64454
|
},
|
|
64455
|
+
tapStream: (host) => {
|
|
64456
|
+
nextId += 1;
|
|
64457
|
+
const id = nextId;
|
|
64458
|
+
append({ kind: "stream", id, host });
|
|
64459
|
+
const stored = { "client-to-server": 0, "server-to-client": 0 };
|
|
64460
|
+
const sequences = { "client-to-server": 0, "server-to-client": 0 };
|
|
64461
|
+
return {
|
|
64462
|
+
onChunk: (direction, chunk) => {
|
|
64463
|
+
sequences[direction] += 1;
|
|
64464
|
+
const budget = STREAM_LOG_CAP_BYTES - stored[direction];
|
|
64465
|
+
if (budget <= 0) {
|
|
64466
|
+
return;
|
|
64467
|
+
}
|
|
64468
|
+
const excerpt = chunk.subarray(0, Math.min(CHUNK_LOG_CAP_BYTES, budget));
|
|
64469
|
+
stored[direction] += excerpt.length;
|
|
64470
|
+
const text2 = excerpt.toString("utf8");
|
|
64471
|
+
const faithful = Buffer.from(text2, "utf8").equals(excerpt);
|
|
64472
|
+
append({
|
|
64473
|
+
kind: "stream-chunk",
|
|
64474
|
+
id,
|
|
64475
|
+
dir: direction,
|
|
64476
|
+
seq: sequences[direction],
|
|
64477
|
+
bytes: chunk.length,
|
|
64478
|
+
stored: excerpt.length,
|
|
64479
|
+
truncated: excerpt.length < chunk.length,
|
|
64480
|
+
...faithful ? { body: redactText(text2) } : { b64: excerpt.toString("base64") }
|
|
64481
|
+
});
|
|
64482
|
+
},
|
|
64483
|
+
onEnd: () => {
|
|
64484
|
+
append({ kind: "stream-end", id, clientToServerCapped: stored["client-to-server"] >= STREAM_LOG_CAP_BYTES, serverToClientCapped: stored["server-to-client"] >= STREAM_LOG_CAP_BYTES });
|
|
64485
|
+
}
|
|
64486
|
+
};
|
|
64487
|
+
},
|
|
64453
64488
|
observePassthrough: (request6) => {
|
|
64454
64489
|
nextId += 1;
|
|
64455
64490
|
const id = nextId;
|
|
@@ -64495,10 +64530,6 @@ function createFileCapture(file2, now = () => /* @__PURE__ */ new Date()) {
|
|
|
64495
64530
|
// src/frontdoor/connect.ts
|
|
64496
64531
|
var import_node_crypto10 = require("node:crypto");
|
|
64497
64532
|
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
64533
|
|
|
64503
64534
|
// src/frontdoor/x509.ts
|
|
64504
64535
|
var import_node_crypto9 = require("node:crypto");
|
|
@@ -64771,6 +64802,54 @@ function issueLeafCertificate(ca, names, notBefore, notAfter) {
|
|
|
64771
64802
|
return { certPem: toPem("CERTIFICATE", der), keyPem: keyPem(privateKey) };
|
|
64772
64803
|
}
|
|
64773
64804
|
|
|
64805
|
+
// src/frontdoor/tap.ts
|
|
64806
|
+
function pumpTapSession(secure, openUpstream, tap) {
|
|
64807
|
+
let upstream;
|
|
64808
|
+
let ended = false;
|
|
64809
|
+
const end = () => {
|
|
64810
|
+
if (!ended) {
|
|
64811
|
+
ended = true;
|
|
64812
|
+
tap?.onEnd();
|
|
64813
|
+
}
|
|
64814
|
+
};
|
|
64815
|
+
const drop = () => {
|
|
64816
|
+
end();
|
|
64817
|
+
secure.destroy();
|
|
64818
|
+
upstream?.destroy();
|
|
64819
|
+
};
|
|
64820
|
+
secure.once("close", () => {
|
|
64821
|
+
end();
|
|
64822
|
+
upstream?.destroy();
|
|
64823
|
+
});
|
|
64824
|
+
secure.once("error", drop);
|
|
64825
|
+
const clientAlpn = "alpnProtocol" in secure && typeof secure.alpnProtocol === "string" ? secure.alpnProtocol : void 0;
|
|
64826
|
+
void (async () => {
|
|
64827
|
+
try {
|
|
64828
|
+
upstream = await openUpstream(clientAlpn);
|
|
64829
|
+
} catch {
|
|
64830
|
+
drop();
|
|
64831
|
+
return;
|
|
64832
|
+
}
|
|
64833
|
+
if (secure.destroyed) {
|
|
64834
|
+
end();
|
|
64835
|
+
upstream.destroy();
|
|
64836
|
+
return;
|
|
64837
|
+
}
|
|
64838
|
+
if (tap !== void 0) {
|
|
64839
|
+
secure.on("data", (chunk) => {
|
|
64840
|
+
tap.onChunk("client-to-server", chunk);
|
|
64841
|
+
});
|
|
64842
|
+
upstream.on("data", (chunk) => {
|
|
64843
|
+
tap.onChunk("server-to-client", chunk);
|
|
64844
|
+
});
|
|
64845
|
+
}
|
|
64846
|
+
secure.pipe(upstream);
|
|
64847
|
+
upstream.pipe(secure);
|
|
64848
|
+
upstream.once("close", drop);
|
|
64849
|
+
upstream.once("error", drop);
|
|
64850
|
+
})();
|
|
64851
|
+
}
|
|
64852
|
+
|
|
64774
64853
|
// src/frontdoor/supervisor.ts
|
|
64775
64854
|
var FRONTDOOR_SUPERVISOR_STILL_RUNNING = -1;
|
|
64776
64855
|
var FRONTDOOR_POLL_MS = 1e3;
|
|
@@ -64805,23 +64884,23 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
64805
64884
|
}
|
|
64806
64885
|
lastPort = http5.port;
|
|
64807
64886
|
const previousStickyConnect = lastConnectPort;
|
|
64808
|
-
let
|
|
64887
|
+
let connect3;
|
|
64809
64888
|
try {
|
|
64810
|
-
|
|
64889
|
+
connect3 = await ports.startConnectListener(lastConnectPort);
|
|
64811
64890
|
} catch (error62) {
|
|
64812
64891
|
await http5.close();
|
|
64813
64892
|
return fail(`could not start the CONNECT surface: ${error62 instanceof Error ? error62.message : String(error62)}`);
|
|
64814
64893
|
}
|
|
64815
|
-
if (previousStickyConnect !== void 0 &&
|
|
64816
|
-
ports.log(`agent-shim frontdoor supervisor: sticky CONNECT port ${String(previousStickyConnect)} was occupied; moving to ${String(
|
|
64894
|
+
if (previousStickyConnect !== void 0 && connect3.port !== previousStickyConnect) {
|
|
64895
|
+
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
64896
|
}
|
|
64818
|
-
lastConnectPort =
|
|
64897
|
+
lastConnectPort = connect3.port;
|
|
64819
64898
|
const previousStickyDirect = lastDirectPort;
|
|
64820
64899
|
let direct;
|
|
64821
64900
|
try {
|
|
64822
64901
|
direct = await ports.startDirectListener(lastDirectPort);
|
|
64823
64902
|
} catch (error62) {
|
|
64824
|
-
await
|
|
64903
|
+
await connect3.close();
|
|
64825
64904
|
await http5.close();
|
|
64826
64905
|
return fail(`could not start the direct listener: ${error62 instanceof Error ? error62.message : String(error62)}`);
|
|
64827
64906
|
}
|
|
@@ -64829,9 +64908,9 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
64829
64908
|
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
64909
|
}
|
|
64831
64910
|
lastDirectPort = direct.port;
|
|
64832
|
-
writeFrontDoorState(fs18, paths.frontdoorStateFile, { supervisorPid: ports.ownPid, port: http5.port, connectPort:
|
|
64911
|
+
writeFrontDoorState(fs18, paths.frontdoorStateFile, { supervisorPid: ports.ownPid, port: http5.port, connectPort: connect3.port, directPort: direct.port, ...sticky() });
|
|
64833
64912
|
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(
|
|
64913
|
+
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
64914
|
let idleSince;
|
|
64836
64915
|
let ticks = 0;
|
|
64837
64916
|
for (; ; ) {
|
|
@@ -64845,7 +64924,7 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
64845
64924
|
if (ports.now() - idleSince >= idleShutdownMinutes * MS_PER_MINUTE) {
|
|
64846
64925
|
ports.log(`agent-shim frontdoor supervisor: no sessions for ${String(idleShutdownMinutes)} minute(s); closing the front door and exiting`);
|
|
64847
64926
|
await direct.close();
|
|
64848
|
-
await
|
|
64927
|
+
await connect3.close();
|
|
64849
64928
|
await http5.close();
|
|
64850
64929
|
writeFrontDoorState(fs18, paths.frontdoorStateFile, sticky());
|
|
64851
64930
|
return 0;
|
|
@@ -64860,6 +64939,7 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
|
|
|
64860
64939
|
// src/frontdoor/connect.ts
|
|
64861
64940
|
var CONNECT_INTERCEPT_HOST = "api.anthropic.com";
|
|
64862
64941
|
var CONNECT_INTERCEPT_HOSTS = [CONNECT_INTERCEPT_HOST, "platform.claude.com"];
|
|
64942
|
+
var CONNECT_TAP_HOSTS = ["platform.claude.com"];
|
|
64863
64943
|
var ROUTED_PATH_PREFIX = "/v1/";
|
|
64864
64944
|
var HTTPS_PORT = 443;
|
|
64865
64945
|
var MAX_PORT = 65535;
|
|
@@ -64967,9 +65047,20 @@ function caParses(ca) {
|
|
|
64967
65047
|
return false;
|
|
64968
65048
|
}
|
|
64969
65049
|
}
|
|
65050
|
+
var TAP_ALPN_PROTOCOLS = ["h2", "http/1.1"];
|
|
64970
65051
|
async function startConnectServer(config2, effects, preferredPort) {
|
|
64971
65052
|
const onUpgrade = config2.capture === void 0 ? void 0 : (request6) => config2.capture?.upgrade(request6);
|
|
64972
65053
|
const sessions = config2.interceptHosts.map((host) => {
|
|
65054
|
+
if (config2.tapHosts.includes(host)) {
|
|
65055
|
+
const tlsAcceptor2 = effects.createTlsAcceptor(
|
|
65056
|
+
config2.leafFor(host),
|
|
65057
|
+
(secure) => {
|
|
65058
|
+
pumpTapSession(secure, async (clientAlpn) => await effects.connectTlsUpstream(host, HTTPS_PORT, clientAlpn), config2.capture?.tapStream?.(host));
|
|
65059
|
+
},
|
|
65060
|
+
TAP_ALPN_PROTOCOLS
|
|
65061
|
+
);
|
|
65062
|
+
return { host, tlsAcceptor: tlsAcceptor2 };
|
|
65063
|
+
}
|
|
64973
65064
|
const handler = (request6, response) => {
|
|
64974
65065
|
if (host === config2.routedHost && servedByPipeline(request6.url)) {
|
|
64975
65066
|
config2.serveRouted(request6, response);
|
|
@@ -64994,7 +65085,7 @@ async function startConnectServer(config2, effects, preferredPort) {
|
|
|
64994
65085
|
await listener.close();
|
|
64995
65086
|
for (const { httpSession, tlsAcceptor } of sessions) {
|
|
64996
65087
|
tlsAcceptor.close();
|
|
64997
|
-
httpSession
|
|
65088
|
+
httpSession?.close();
|
|
64998
65089
|
}
|
|
64999
65090
|
}
|
|
65000
65091
|
};
|
|
@@ -65170,6 +65261,40 @@ async function blindTunnel(socket, target, effects) {
|
|
|
65170
65261
|
socket.destroy();
|
|
65171
65262
|
});
|
|
65172
65263
|
}
|
|
65264
|
+
function isEnoent5(error62) {
|
|
65265
|
+
return typeof error62 === "object" && error62 !== null && "code" in error62 && error62.code === "ENOENT";
|
|
65266
|
+
}
|
|
65267
|
+
function realConnectCertStore(paths) {
|
|
65268
|
+
const read = (file2) => {
|
|
65269
|
+
try {
|
|
65270
|
+
return fs12.readFileSync(file2, "utf8");
|
|
65271
|
+
} catch (error62) {
|
|
65272
|
+
if (isEnoent5(error62)) {
|
|
65273
|
+
return void 0;
|
|
65274
|
+
}
|
|
65275
|
+
throw error62;
|
|
65276
|
+
}
|
|
65277
|
+
};
|
|
65278
|
+
return {
|
|
65279
|
+
loadCa: () => {
|
|
65280
|
+
const certPem = read(paths.frontdoorCaCertFile);
|
|
65281
|
+
const keyPem2 = read(paths.frontdoorCaKeyFile);
|
|
65282
|
+
return certPem === void 0 || keyPem2 === void 0 ? void 0 : { certPem, keyPem: keyPem2 };
|
|
65283
|
+
},
|
|
65284
|
+
writeCa: (ca) => {
|
|
65285
|
+
fs12.mkdirSync(paths.frontdoorCaDir, { recursive: true });
|
|
65286
|
+
fs12.writeFileSync(paths.frontdoorCaCertFile, ca.certPem, "utf8");
|
|
65287
|
+
fs12.writeFileSync(paths.frontdoorCaKeyFile, ca.keyPem, { encoding: "utf8", mode: CA_KEY_FILE_MODE });
|
|
65288
|
+
fs12.chmodSync(paths.frontdoorCaKeyFile, CA_KEY_FILE_MODE);
|
|
65289
|
+
}
|
|
65290
|
+
};
|
|
65291
|
+
}
|
|
65292
|
+
|
|
65293
|
+
// src/frontdoor/connectEffects.ts
|
|
65294
|
+
var http = __toESM(require("node:http"), 1);
|
|
65295
|
+
var https = __toESM(require("node:https"), 1);
|
|
65296
|
+
var net3 = __toESM(require("node:net"), 1);
|
|
65297
|
+
var tls = __toESM(require("node:tls"), 1);
|
|
65173
65298
|
function realConnectEffects() {
|
|
65174
65299
|
const plainAgent = new http.Agent({ keepAlive: true });
|
|
65175
65300
|
const tlsAgent = new https.Agent({ keepAlive: true });
|
|
@@ -65215,10 +65340,13 @@ function realConnectEffects() {
|
|
|
65215
65340
|
}
|
|
65216
65341
|
return await listenOnce(0, onSocket);
|
|
65217
65342
|
},
|
|
65218
|
-
createTlsAcceptor: (leaf, onSecure) => {
|
|
65219
|
-
const server = tls.createServer(
|
|
65220
|
-
|
|
65221
|
-
|
|
65343
|
+
createTlsAcceptor: (leaf, onSecure, alpnProtocols) => {
|
|
65344
|
+
const server = tls.createServer(
|
|
65345
|
+
{ key: leaf.keyPem, cert: leaf.certPem, ...alpnProtocols === void 0 ? {} : { ALPNProtocols: [...alpnProtocols] } },
|
|
65346
|
+
(secure) => {
|
|
65347
|
+
onSecure(secure);
|
|
65348
|
+
}
|
|
65349
|
+
);
|
|
65222
65350
|
server.on("clientError", (_error, socket) => {
|
|
65223
65351
|
socket.destroy();
|
|
65224
65352
|
});
|
|
@@ -65253,6 +65381,13 @@ function realConnectEffects() {
|
|
|
65253
65381
|
}
|
|
65254
65382
|
};
|
|
65255
65383
|
},
|
|
65384
|
+
connectTlsUpstream: async (host, port, clientAlpn) => await new Promise((resolve, reject) => {
|
|
65385
|
+
const socket = tls.connect({ host, port, servername: host, ...clientAlpn === void 0 ? {} : { ALPNProtocols: [clientAlpn] } });
|
|
65386
|
+
socket.once("secureConnect", () => {
|
|
65387
|
+
resolve(socket);
|
|
65388
|
+
});
|
|
65389
|
+
socket.once("error", reject);
|
|
65390
|
+
}),
|
|
65256
65391
|
connectTcp: async (host, port) => await new Promise((resolve, reject) => {
|
|
65257
65392
|
const socket = net3.connect({ host, port });
|
|
65258
65393
|
socket.once("connect", () => {
|
|
@@ -65316,34 +65451,6 @@ function realConnectEffects() {
|
|
|
65316
65451
|
}
|
|
65317
65452
|
};
|
|
65318
65453
|
}
|
|
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
65454
|
|
|
65348
65455
|
// src/frontdoor/ensure.ts
|
|
65349
65456
|
var import_node_crypto11 = require("node:crypto");
|
|
@@ -66973,6 +67080,7 @@ function realFrontDoorSupervisorPorts(paths) {
|
|
|
66973
67080
|
const server = await startConnectServer(
|
|
66974
67081
|
{
|
|
66975
67082
|
interceptHosts: CONNECT_INTERCEPT_HOSTS,
|
|
67083
|
+
tapHosts: CONNECT_TAP_HOSTS,
|
|
66976
67084
|
routedHost: CONNECT_INTERCEPT_HOST,
|
|
66977
67085
|
serveRouted: (request6, response) => {
|
|
66978
67086
|
const abort = new AbortController();
|