orkestrator 2.36.5-beta → 2.36.6-beta

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.
@@ -1,3 +1,75 @@
1
+ // ../protocol/src/node/bridge-launch-environment.ts
2
+ import { closeSync, fstatSync, openSync, readSync, rmSync, constants } from "node:fs";
3
+ var BRIDGE_LAUNCH_ENVIRONMENT_ENV = "ORKESTRATOR_BRIDGE_LAUNCH_ENVIRONMENT";
4
+ var BRIDGE_LAUNCH_KEYS_ENV = "ORKESTRATOR_BRIDGE_LAUNCH_KEYS";
5
+ var BRIDGE_LAUNCH_WORKDIR_ENV = "ORKESTRATOR_BRIDGE_LAUNCH_WORKDIR";
6
+ var MAX_SNAPSHOT_BYTES = 1024 * 1024;
7
+ var MAX_SNAPSHOT_ENTRIES = 4096;
8
+ var NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_%.-]*$/;
9
+ var LAUNCH_ONLY = /(?:_BRIDGE_TOKEN|_TOKEN_SHA256|_AUTHORITY_KEY)$|^ORKESTRATOR_BRIDGE_(?:LAUNCH_|EXECUTION_POLICY$)|^ORKESTRATOR_COORDINATOR_/;
10
+ var NOT_APPLIED = new Set(["PWD", "OLDPWD", "SHLVL", "_", "NODE_PATH"]);
11
+ function readSnapshot(file) {
12
+ let fd;
13
+ try {
14
+ fd = openSync(file, constants.O_RDONLY | constants.O_NOFOLLOW);
15
+ } catch {
16
+ return null;
17
+ }
18
+ try {
19
+ const stat = fstatSync(fd);
20
+ if (!stat.isFile() || stat.size > MAX_SNAPSHOT_BYTES)
21
+ return null;
22
+ const buffer = Buffer.alloc(stat.size);
23
+ let offset = 0;
24
+ while (offset < buffer.length) {
25
+ const read = readSync(fd, buffer, offset, buffer.length - offset, offset);
26
+ if (read === 0)
27
+ break;
28
+ offset += read;
29
+ }
30
+ return buffer.subarray(0, offset);
31
+ } finally {
32
+ closeSync(fd);
33
+ }
34
+ }
35
+ function applyBridgeLaunchEnvironment(env = process.env, chdir = (directory) => process.chdir(directory)) {
36
+ const file = env[BRIDGE_LAUNCH_ENVIRONMENT_ENV];
37
+ if (!file)
38
+ return null;
39
+ const trusted = new Set((env[BRIDGE_LAUNCH_KEYS_ENV] ?? "").split(",").map((name) => name.trim()).filter(Boolean));
40
+ const workdir = env[BRIDGE_LAUNCH_WORKDIR_ENV];
41
+ delete env[BRIDGE_LAUNCH_ENVIRONMENT_ENV];
42
+ delete env[BRIDGE_LAUNCH_KEYS_ENV];
43
+ delete env[BRIDGE_LAUNCH_WORKDIR_ENV];
44
+ const result = { applied: 0, refused: 0 };
45
+ const snapshot = readSnapshot(file);
46
+ rmSync(file, { force: true });
47
+ if (snapshot) {
48
+ const entries = snapshot.toString("utf8").split("\x00").slice(0, MAX_SNAPSHOT_ENTRIES);
49
+ for (const entry of entries) {
50
+ const separator = entry.indexOf("=");
51
+ if (separator <= 0)
52
+ continue;
53
+ const name = entry.slice(0, separator);
54
+ if (!NAME_PATTERN.test(name) || NOT_APPLIED.has(name))
55
+ continue;
56
+ if (trusted.has(name) || LAUNCH_ONLY.test(name)) {
57
+ result.refused += 1;
58
+ continue;
59
+ }
60
+ env[name] = entry.slice(separator + 1);
61
+ result.applied += 1;
62
+ }
63
+ }
64
+ if (workdir) {
65
+ try {
66
+ chdir(workdir);
67
+ } catch {}
68
+ }
69
+ return result;
70
+ }
71
+ applyBridgeLaunchEnvironment();
72
+
1
73
  // ../protocol/src/node/bridge-diagnostics.ts
2
74
  import { createHash } from "node:crypto";
3
75
 
@@ -44,7 +116,7 @@ var MAX_FRAME_CHARS = 240;
44
116
  var MAX_RAW_FRAME_CHARS = 1024;
45
117
  var MAX_CAUSE_DEPTH = 2;
46
118
  var TRUNCATED_MARKER = "...[truncated]";
47
- var NAME_PATTERN = /^[A-Za-z_$][\w$.-]{0,63}$/;
119
+ var NAME_PATTERN2 = /^[A-Za-z_$][\w$.-]{0,63}$/;
48
120
  var CODE_PATTERN = /^[\w.:-]{1,64}$/;
49
121
  var SYSCALL_PATTERN = /^[\w./ -]{1,128}$/;
50
122
  var COMMAND_OUTPUT_FIELDS = ["stdout", "stderr", "cmd", "spawnargs"];
@@ -122,7 +194,7 @@ function describe(error, includeStack, includeMessage, depth) {
122
194
  if (!(error instanceof Error) && typeof rawMessage !== "string") {
123
195
  return { name: "NonError", message: "[object]" };
124
196
  }
125
- const name = matching(read(error, "name"), NAME_PATTERN) ?? "Error";
197
+ const name = matching(read(error, "name"), NAME_PATTERN2) ?? "Error";
126
198
  const message = typeof rawMessage === "string" ? rawMessage : undefined;
127
199
  const commandFailure = isCommandFailure(error, name, message);
128
200
  const stackHoldsMessage = message !== undefined && String(read(error, "stack") ?? "").includes(message);
@@ -177,7 +249,7 @@ function logErrorKind(error) {
177
249
  const safeCode = finite(code) ?? matching(code, CODE_PATTERN);
178
250
  if (safeCode !== undefined)
179
251
  return String(safeCode);
180
- return matching(read(error, "name"), NAME_PATTERN) ?? "Error";
252
+ return matching(read(error, "name"), NAME_PATTERN2) ?? "Error";
181
253
  }
182
254
 
183
255
  // ../protocol/src/log-vocabulary/define.ts
@@ -598,6 +670,7 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
598
670
  events: {
599
671
  "attention-failed": "A dialog could not ask for the user's attention.",
600
672
  closed: "A native dialog closed.",
673
+ "hidden-cancelled": "A hidden profile cancelled a dialog without opening native UI.",
601
674
  "open-failed": "A dialog could not open; it was answered as cancelled.",
602
675
  opening: "A native dialog is opening.",
603
676
  "preview-beforeunload-ignored": "A browser preview's beforeunload handler was ignored.",
@@ -683,6 +756,7 @@ var ENVIRONMENT_LOG_AREAS = defineLogAreas({
683
756
  "orphan-session.reaped": "A native session no tab references was torn down.",
684
757
  "handoff-sweep.failed": "Sweeping transferred transcripts no tab references failed.",
685
758
  "delete.terminals-survived": "Terminal process trees outlived termination, so the deletion stops.",
759
+ "delete.step-deadline": "A deletion step that runs child processes passed its deadline; they are stopped and the deletion fails once they have.",
686
760
  "delete.artifacts-left": "Graph run artifact directories were not removed.",
687
761
  "delete.worktrees-kept": "Graph runs kept branch worktrees.",
688
762
  "delete.step-failed": "One best-effort part of deleting an environment failed; `step` says which, and the rest goes on.",
@@ -717,6 +791,7 @@ var GATEWAY_LOG_AREAS = defineLogAreas({
717
791
  "host.refused": "A request named a host this gateway does not answer to. Logged once per name, up to a limit.",
718
792
  "port.fallback": "The preferred port was taken, so a nearby one is used.",
719
793
  "port.fallback-distant": "The preferred port and those nearby were taken, so another is used.",
794
+ "request-auth.fallback": "A desktop request-auth hook failed closed. Phase only; no request or error content.",
720
795
  "request.failed": "A gateway request failed. Throttled: repeats are counted, not written.",
721
796
  "websocket.upgrade-failed": "A WebSocket upgrade failed.",
722
797
  "events.client-dropped": "An event-stream client buffered too much and was dropped; it reconnects and refetches.",
@@ -775,6 +850,11 @@ var LOCAL_SERVER_LOG_AREAS = defineLogAreas({
775
850
  requested: "boolean"
776
851
  }
777
852
  },
853
+ "bridge.orphans-reaped": {
854
+ description: "Processes a bridge left in its process group after exiting on its own (its agent CLI, mid-turn) were stopped. `warn` when they left; `error` when one survived SIGKILL.",
855
+ essential: true,
856
+ fields: { key: "label", pid: "number", result: "label" }
857
+ },
778
858
  "reaper.tmux-list-failed": "Orphaned claude-tmux sessions could not be listed.",
779
859
  "reaper.tmux-kill-failed": "An orphaned tmux session could not be killed.",
780
860
  "reaper.tmux-reaped": "Orphaned claude-tmux sessions of a deleted environment were killed.",
@@ -1608,7 +1688,11 @@ var DOCKER_LOG_AREAS = defineLogAreas({
1608
1688
  "network.list-failed": "Docker networks could not be listed.",
1609
1689
  "network.inspect-failed": "A Docker network could not be inspected.",
1610
1690
  "stale-containers.removing": "Stale probe containers are being removed.",
1611
- "stale-networks.removing": "Stale probe networks are being removed."
1691
+ "stale-networks.removing": "Stale probe networks are being removed.",
1692
+ "peers.refused": "The agent tools server closed connections from addresses outside loopback and this backend's Docker networks (at most one entry a minute, with a count).",
1693
+ "peers.subnets-loaded": "The Docker subnets the agent tools server admits were reloaded.",
1694
+ "port.loopback-taken": "The agent tools server gave up a port because another process holds it on 127.0.0.1, where host agents call; it moves to a free port.",
1695
+ "peers.subnets-load-failed": "The Docker subnets the agent tools server admits could not be read; cached permissions are cleared and only loopback is admitted until a successful retry."
1612
1696
  }
1613
1697
  }
1614
1698
  });
@@ -3351,34 +3435,201 @@ function createBridgeDiagnostics(bridge, state, metrics) {
3351
3435
  var bufferedFlushes = new Set;
3352
3436
 
3353
3437
  // ../protocol/src/node/bridge-credential.ts
3354
- import { createHash as createHash2, randomBytes, timingSafeEqual } from "node:crypto";
3438
+ import { createHash as createHash3, randomBytes as randomBytes2, timingSafeEqual } from "node:crypto";
3355
3439
  import { createRequire } from "node:module";
3440
+
3441
+ // ../protocol/src/node/bridge-authority.ts
3442
+ import {
3443
+ createHash as createHash2,
3444
+ createPrivateKey,
3445
+ createPublicKey,
3446
+ generateKeyPairSync,
3447
+ randomBytes,
3448
+ sign,
3449
+ verify
3450
+ } from "node:crypto";
3451
+ var BRIDGE_AUTHORITY_HEADER = "x-orkestrator-authority";
3452
+ var BRIDGE_AUTHORITY_REFUSED_CODE = "authority-signature-required";
3453
+ var BRIDGE_AUTHORITY_WINDOW_MS = 5 * 60000;
3454
+ var BRIDGE_AUTHORITY_MAX_NONCES = 8192;
3455
+ var BRIDGE_AUTHORITY_MAX_BODY_BYTES = 64 * 1024 * 1024;
3456
+ var SCHEME = "orkestrator-bridge-authority-v1";
3457
+ var KEY_PATTERN = /^[A-Za-z0-9_-]{40,200}$/;
3458
+ var HEADER_PATTERN = /^v1 t=(\d{1,16}) n=([A-Za-z0-9_-]{22}) s=([A-Za-z0-9_-]{86})$/;
3459
+ var READ_METHODS = new Set(["GET", "HEAD", "OPTIONS"]);
3460
+ var UNSIGNED_ROUTES = [
3461
+ /^\/session\/[^/]+\/close$/,
3462
+ /^\/sessions\/activity$/,
3463
+ /^\/debug\/log-policy$/
3464
+ ];
3465
+ function bridgeAuthorityKeyEnv(tokenEnv) {
3466
+ return `${tokenEnv}_AUTHORITY_KEY`;
3467
+ }
3468
+ function isBridgeAuthorityKey(value) {
3469
+ return typeof value === "string" && KEY_PATTERN.test(value);
3470
+ }
3471
+ function publicKeyFrom(encoded) {
3472
+ if (!isBridgeAuthorityKey(encoded))
3473
+ return null;
3474
+ try {
3475
+ const key = createPublicKey({
3476
+ key: Buffer.from(encoded, "base64url"),
3477
+ format: "der",
3478
+ type: "spki"
3479
+ });
3480
+ return key.asymmetricKeyType === "ed25519" ? key : null;
3481
+ } catch {
3482
+ return null;
3483
+ }
3484
+ }
3485
+ function bridgeAuthorityTarget(url) {
3486
+ const parsed = new URL(url, "http://bridge.invalid");
3487
+ return `${parsed.pathname}${parsed.search}`;
3488
+ }
3489
+ function bridgeRequestNeedsAuthority(method, target) {
3490
+ if (READ_METHODS.has(method.toUpperCase()))
3491
+ return false;
3492
+ const pathname = bridgeAuthorityTarget(target).split("?", 1)[0];
3493
+ return !UNSIGNED_ROUTES.some((pattern) => pattern.test(pathname));
3494
+ }
3495
+ function bodyDigest(body) {
3496
+ return createHash2("sha256").update(body ?? "").digest("hex");
3497
+ }
3498
+ function signedMessage(method, target, issuedAt, nonce, digest) {
3499
+ return Buffer.from([SCHEME, method.toUpperCase(), target, String(issuedAt), nonce, digest].join(`
3500
+ `));
3501
+ }
3502
+ var UNENFORCED = {
3503
+ enforced: false,
3504
+ requires: () => false,
3505
+ check: () => ({ ok: true })
3506
+ };
3507
+ function bridgeAuthorityFromPublicKey(publicKey, options = {}) {
3508
+ if (publicKey === undefined)
3509
+ return UNENFORCED;
3510
+ const key = publicKeyFrom(publicKey);
3511
+ const now = options.now ?? Date.now;
3512
+ const maxNonces = options.maxNonces ?? BRIDGE_AUTHORITY_MAX_NONCES;
3513
+ const seen = new Map;
3514
+ let floor = -Infinity;
3515
+ const remember = (nonce, issuedAt, current) => {
3516
+ for (const [oldNonce, oldIssuedAt] of seen) {
3517
+ if (seen.size < maxNonces && oldIssuedAt >= current - BRIDGE_AUTHORITY_WINDOW_MS)
3518
+ break;
3519
+ seen.delete(oldNonce);
3520
+ floor = Math.max(floor, oldIssuedAt);
3521
+ }
3522
+ seen.set(nonce, issuedAt);
3523
+ };
3524
+ return {
3525
+ enforced: true,
3526
+ requires: bridgeRequestNeedsAuthority,
3527
+ check(request) {
3528
+ if (!request.header)
3529
+ return { ok: false, reason: "missing" };
3530
+ const match = HEADER_PATTERN.exec(request.header.trim());
3531
+ if (!match)
3532
+ return { ok: false, reason: "malformed" };
3533
+ const issuedAt = Number(match[1]);
3534
+ const nonce = match[2];
3535
+ const current = now();
3536
+ if (Math.abs(current - issuedAt) > BRIDGE_AUTHORITY_WINDOW_MS || issuedAt <= floor) {
3537
+ return { ok: false, reason: "stale" };
3538
+ }
3539
+ if (!key)
3540
+ return { ok: false, reason: "invalid" };
3541
+ const valid = verify(null, signedMessage(request.method, bridgeAuthorityTarget(request.url), issuedAt, nonce, bodyDigest(request.body)), key, Buffer.from(match[3], "base64url"));
3542
+ if (!valid)
3543
+ return { ok: false, reason: "invalid" };
3544
+ if (seen.has(nonce))
3545
+ return { ok: false, reason: "replayed" };
3546
+ remember(nonce, issuedAt, current);
3547
+ return { ok: true };
3548
+ }
3549
+ };
3550
+ }
3551
+ function loadBridgeAuthority(tokenEnv, options = {}) {
3552
+ const env = options.env ?? process.env;
3553
+ const name = bridgeAuthorityKeyEnv(tokenEnv);
3554
+ const value = env[name]?.trim();
3555
+ delete env[name];
3556
+ return bridgeAuthorityFromPublicKey(value || undefined, { now: options.now });
3557
+ }
3558
+ function refusal(reason) {
3559
+ return {
3560
+ status: 403,
3561
+ body: {
3562
+ error: "This request changes an agent's authority and needs the backend's signature",
3563
+ code: BRIDGE_AUTHORITY_REFUSED_CODE,
3564
+ reason
3565
+ }
3566
+ };
3567
+ }
3568
+ var TOO_LARGE = {
3569
+ status: 413,
3570
+ body: { error: "Request body is too large" }
3571
+ };
3572
+ var admittedBodies = new WeakMap;
3573
+ async function admitNodeBridgeRequest(authority, request, maxBodyBytes) {
3574
+ const method = request.method ?? "GET";
3575
+ const url = request.url ?? "/";
3576
+ if (!authority.requires(method, url))
3577
+ return null;
3578
+ const header = request.headers[BRIDGE_AUTHORITY_HEADER];
3579
+ const value = Array.isArray(header) ? header[0] : header;
3580
+ if (!value)
3581
+ return refusal("missing");
3582
+ const chunks = [];
3583
+ let total = 0;
3584
+ for await (const chunk of request) {
3585
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
3586
+ total += buffer.length;
3587
+ if (total > maxBodyBytes)
3588
+ return TOO_LARGE;
3589
+ chunks.push(buffer);
3590
+ }
3591
+ const body = Buffer.concat(chunks);
3592
+ const result = authority.check({ method, url, header: value, body });
3593
+ if (!result.ok)
3594
+ return refusal(result.reason);
3595
+ admittedBodies.set(request, body);
3596
+ return null;
3597
+ }
3598
+ function takeAdmittedBody(request) {
3599
+ const body = admittedBodies.get(request);
3600
+ admittedBodies.delete(request);
3601
+ return body;
3602
+ }
3603
+
3604
+ // ../protocol/src/node/bridge-credential.ts
3356
3605
  var BRIDGE_TOKEN_PREFIX = "okb_";
3357
3606
  var PR_SET_DUMPABLE = 4;
3358
3607
  var VERIFIER_PATTERN = /^[0-9a-f]{64}$/;
3359
3608
  var log3 = createLogger("bridge.lifecycle");
3360
3609
  function mintBridgeToken() {
3361
- return `${BRIDGE_TOKEN_PREFIX}${randomBytes(32).toString("base64url")}`;
3610
+ return `${BRIDGE_TOKEN_PREFIX}${randomBytes2(32).toString("base64url")}`;
3362
3611
  }
3363
3612
  function bridgeTokenVerifier(token) {
3364
- return createHash2("sha256").update(token).digest("hex");
3613
+ return createHash3("sha256").update(token).digest("hex");
3365
3614
  }
3366
3615
  function bridgeTokenVerifierEnv(tokenEnv) {
3367
3616
  return `${tokenEnv}_SHA256`;
3368
3617
  }
3369
- function credentialFromVerifier(verifier, plainToken) {
3618
+ function credentialFromVerifier(verifier, plainToken, authority = UNENFORCED_AUTHORITY) {
3370
3619
  const expected = Buffer.from(verifier, "hex");
3371
3620
  return {
3372
3621
  plainToken,
3622
+ authority,
3373
3623
  matches(candidate) {
3374
3624
  if (!candidate)
3375
3625
  return false;
3376
- return timingSafeEqual(expected, createHash2("sha256").update(candidate).digest());
3626
+ return timingSafeEqual(expected, createHash3("sha256").update(candidate).digest());
3377
3627
  }
3378
3628
  };
3379
3629
  }
3380
- function bridgeCredentialFromToken(token) {
3381
- return credentialFromVerifier(bridgeTokenVerifier(token), token);
3630
+ var UNENFORCED_AUTHORITY = loadBridgeAuthority("", { env: {} });
3631
+ function bridgeCredentialFromToken(token, authority = UNENFORCED_AUTHORITY) {
3632
+ return credentialFromVerifier(bridgeTokenVerifier(token), token, authority);
3382
3633
  }
3383
3634
  function markProcessNonDumpable(loadFfi = () => createRequire(import.meta.url)("bun:ffi")) {
3384
3635
  if (process.platform !== "linux" || !process.versions.bun)
@@ -3410,16 +3661,17 @@ function loadBridgeCredential(tokenEnv, options = {}) {
3410
3661
  const token = env[tokenEnv]?.trim();
3411
3662
  delete env[verifierEnv];
3412
3663
  delete env[tokenEnv];
3664
+ const authority = loadBridgeAuthority(tokenEnv, { env });
3413
3665
  if (verifier) {
3414
3666
  (options.harden ?? markProcessNonDumpable)();
3415
- return VERIFIER_PATTERN.test(verifier) ? credentialFromVerifier(verifier, undefined) : bridgeCredentialFromToken(mintBridgeToken());
3667
+ return VERIFIER_PATTERN.test(verifier) ? credentialFromVerifier(verifier, undefined, authority) : bridgeCredentialFromToken(mintBridgeToken(), authority);
3416
3668
  }
3417
- return bridgeCredentialFromToken(token || mintBridgeToken());
3669
+ return bridgeCredentialFromToken(token || mintBridgeToken(), authority);
3418
3670
  }
3419
3671
 
3420
3672
  // ../../bridges/acp-bridge/src/acp-context.ts
3421
3673
  import { spawn as spawn2 } from "node:child_process";
3422
- import { createHmac, randomBytes as randomBytes3, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
3674
+ import { createHmac, randomBytes as randomBytes4, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
3423
3675
  import { resolve as resolve3 } from "node:path";
3424
3676
 
3425
3677
  // ../protocol/src/capacity-retry.ts
@@ -12241,10 +12493,10 @@ async function acpReadiness(provider, authMethodEnv, env = process.env) {
12241
12493
 
12242
12494
  // ../../bridges/acp-bridge/src/acp-client-methods.ts
12243
12495
  import { spawn } from "node:child_process";
12244
- import { constants } from "node:fs";
12496
+ import { constants as constants2 } from "node:fs";
12245
12497
  import { lstat, open as open2, realpath } from "node:fs/promises";
12246
12498
  import { dirname, isAbsolute, join as join2, relative, resolve, sep } from "node:path";
12247
- import { randomBytes as randomBytes2 } from "node:crypto";
12499
+ import { randomBytes as randomBytes3 } from "node:crypto";
12248
12500
 
12249
12501
  // ../protocol/src/coordinator-web-research.ts
12250
12502
  var DEFAULT_COORDINATOR_RESEARCH_MCP_SERVERS = Object.freeze([{ name: "context7", url: "https://mcp.context7.com/mcp" }]);
@@ -12611,7 +12863,7 @@ class AcpClientMethods {
12611
12863
  }
12612
12864
  async readTextFile(request) {
12613
12865
  const target = await secureExistingFile(request.path, this.workspaceRoot);
12614
- const handle = await open2(target.path, constants.O_RDONLY | constants.O_NOFOLLOW);
12866
+ const handle = await open2(target.path, constants2.O_RDONLY | constants2.O_NOFOLLOW);
12615
12867
  try {
12616
12868
  const stats = await handle.stat();
12617
12869
  assertSameFile(stats, target.stats);
@@ -12634,7 +12886,7 @@ class AcpClientMethods {
12634
12886
  throw new Error("ACP file write exceeds the 2 MiB limit");
12635
12887
  }
12636
12888
  const target = await secureWritableFile(request.path, this.workspaceRoot);
12637
- const handle = await open2(target.path, constants.O_WRONLY | constants.O_CREAT | constants.O_TRUNC | constants.O_NOFOLLOW, 384);
12889
+ const handle = await open2(target.path, constants2.O_WRONLY | constants2.O_CREAT | constants2.O_TRUNC | constants2.O_NOFOLLOW, 384);
12638
12890
  try {
12639
12891
  const stats = await handle.stat();
12640
12892
  if (!stats.isFile())
@@ -12660,7 +12912,7 @@ class AcpClientMethods {
12660
12912
  }
12661
12913
  const cwd = await secureTerminalCwd(request.cwd, this.workspaceRoot);
12662
12914
  const outputLimit = Math.min(MAX_TERMINAL_OUTPUT_BYTES, Number.isSafeInteger(request.outputByteLimit) && (request.outputByteLimit ?? 0) > 0 ? request.outputByteLimit : DEFAULT_TERMINAL_OUTPUT_BYTES);
12663
- const terminalId = randomBytes2(16).toString("hex");
12915
+ const terminalId = randomBytes3(16).toString("hex");
12664
12916
  const child = this.spawnTerminalImpl(request.command, request.args ?? [], {
12665
12917
  cwd,
12666
12918
  env: withoutBridgeControlEnvironment({
@@ -12949,7 +13201,7 @@ function isString(value) {
12949
13201
  }
12950
13202
 
12951
13203
  // ../../bridges/acp-bridge/src/acp-readonly-profile.ts
12952
- import { mkdtempSync as mkdtempSync2, writeFileSync, rmSync } from "node:fs";
13204
+ import { mkdtempSync as mkdtempSync2, writeFileSync, rmSync as rmSync2 } from "node:fs";
12953
13205
  import { tmpdir as tmpdir2 } from "node:os";
12954
13206
  import { join as join3 } from "node:path";
12955
13207
  var GROK_READ_ONLY_PROFILE = `---
@@ -12966,7 +13218,7 @@ disallowedTools:
12966
13218
  `;
12967
13219
  function createReadOnlyProfile() {
12968
13220
  const directory = mkdtempSync2(join3(tmpdir2(), "orkestrator-grok-profile-"));
12969
- const dispose = () => rmSync(directory, { recursive: true, force: true });
13221
+ const dispose = () => rmSync2(directory, { recursive: true, force: true });
12970
13222
  try {
12971
13223
  const path = join3(directory, "read-only.md");
12972
13224
  writeFileSync(path, GROK_READ_ONLY_PROFILE, { mode: 384 });
@@ -13058,7 +13310,7 @@ function grokQuestionTimeoutFromEnv(env) {
13058
13310
  }
13059
13311
 
13060
13312
  // ../../bridges/acp-bridge/src/acp-mcp-inventory.ts
13061
- import { createHash as createHash3 } from "node:crypto";
13313
+ import { createHash as createHash4 } from "node:crypto";
13062
13314
  import { readFile, stat } from "node:fs/promises";
13063
13315
  import { homedir as homedir2 } from "node:os";
13064
13316
  import { join as join4, resolve as resolve2 } from "node:path";
@@ -13149,7 +13401,7 @@ function grokMcpConfigFiles(options = { cwd: process.cwd() }) {
13149
13401
  }
13150
13402
  async function fileDigest(file) {
13151
13403
  try {
13152
- return `sha256:${createHash3("sha256").update(await readFile(file)).digest("base64url")}`;
13404
+ return `sha256:${createHash4("sha256").update(await readFile(file)).digest("base64url")}`;
13153
13405
  } catch {
13154
13406
  return "absent";
13155
13407
  }
@@ -13157,7 +13409,7 @@ async function fileDigest(file) {
13157
13409
  async function grokMcpConfigFingerprint(files) {
13158
13410
  const [user, project] = await Promise.all([fileDigest(files.user), fileDigest(files.project)]);
13159
13411
  return {
13160
- fingerprint: createHash3("sha256").update(`user=${user}\x00project=${project}`).digest("base64url"),
13412
+ fingerprint: createHash4("sha256").update(`user=${user}\x00project=${project}`).digest("base64url"),
13161
13413
  sources: { user, project }
13162
13414
  };
13163
13415
  }
@@ -13225,7 +13477,7 @@ var hostname = process.env.HOSTNAME?.trim() || "127.0.0.1";
13225
13477
  var workingDirectory = resolve3(process.env.CWD?.trim() || process.cwd());
13226
13478
  var bridgeCredential = loadBridgeCredential("ACP_BRIDGE_TOKEN");
13227
13479
  var authToken = bridgeCredential.plainToken ?? "";
13228
- var externalSessionKey = randomBytes3(32);
13480
+ var externalSessionKey = randomBytes4(32);
13229
13481
  var executable = providerConfig.executable;
13230
13482
  var stateDirectory = process.env.ACP_STATE_DIR?.trim();
13231
13483
  var stateFile = stateDirectory ? resolve3(stateDirectory, "state.json") : null;
@@ -14542,7 +14794,7 @@ function encodedStringBytes(value, previous) {
14542
14794
  // ../../bridges/acp-bridge/src/acp-persist-writer.ts
14543
14795
  import { promises as fs2 } from "node:fs";
14544
14796
  import { dirname as dirname2 } from "node:path";
14545
- import { randomBytes as randomBytes4 } from "node:crypto";
14797
+ import { randomBytes as randomBytes5 } from "node:crypto";
14546
14798
 
14547
14799
  // ../protocol/src/node/transcript-window.ts
14548
14800
  import { Buffer as Buffer4 } from "node:buffer";
@@ -14846,16 +15098,16 @@ async function writePersistedState() {
14846
15098
  throw new Error("ACP persisted state exceeds its byte limit");
14847
15099
  }
14848
15100
  await fs2.mkdir(dirname2(file), { recursive: true, mode: 448 });
14849
- const temporary = `${file}.${process.pid}.${randomBytes4(6).toString("hex")}.tmp`;
15101
+ const temporary = `${file}.${process.pid}.${randomBytes5(6).toString("hex")}.tmp`;
14850
15102
  await fs2.writeFile(temporary, payload, { mode: 384 });
14851
15103
  await fs2.rename(temporary, file);
14852
15104
  }
14853
15105
 
14854
15106
  // ../../bridges/acp-bridge/src/acp-rows.ts
14855
- import { randomBytes as randomBytes5 } from "node:crypto";
15107
+ import { randomBytes as randomBytes6 } from "node:crypto";
14856
15108
 
14857
15109
  // ../protocol/src/node/revised-rows.ts
14858
- import { createHash as createHash4 } from "node:crypto";
15110
+ import { createHash as createHash5 } from "node:crypto";
14859
15111
  var RECENTLY_REVISED_ROWS_MAX = 128;
14860
15112
 
14861
15113
  class RecentlyRevisedRows {
@@ -14893,7 +15145,7 @@ class RecentlyRevisedRows {
14893
15145
  function revisedRowsReconciliationToken(overflowVersion, omitted) {
14894
15146
  if (overflowVersion === 0 && omitted.length === 0)
14895
15147
  return;
14896
- const digest = createHash4("sha256").update(String(overflowVersion));
15148
+ const digest = createHash5("sha256").update(String(overflowVersion));
14897
15149
  for (const row of omitted)
14898
15150
  digest.update(JSON.stringify(row) ?? "null");
14899
15151
  return digest.digest("hex");
@@ -14942,7 +15194,7 @@ function currentAssistantMessage(state) {
14942
15194
  if (!message || message.role !== "assistant" || rowIsFull(message) || state.status !== "running" && state.historyReplay !== "hydrate") {
14943
15195
  const modelId = boundedModelId(state.sessionConfig.composer.selectedModelId);
14944
15196
  message = {
14945
- id: randomBytes5(12).toString("hex"),
15197
+ id: randomBytes6(12).toString("hex"),
14946
15198
  role: "assistant",
14947
15199
  content: "",
14948
15200
  parts: [],
@@ -16777,7 +17029,7 @@ var DEFAULT_WORKFLOW_RESULT_TOOLS_SETTINGS = {
16777
17029
  };
16778
17030
 
16779
17031
  // ../../bridges/acp-bridge/src/acp-session.ts
16780
- import { randomBytes as randomBytes8 } from "node:crypto";
17032
+ import { randomBytes as randomBytes9 } from "node:crypto";
16781
17033
  import { resolve as resolve7 } from "node:path";
16782
17034
 
16783
17035
  // ../../bridges/acp-bridge/src/session-config.ts
@@ -18005,18 +18257,18 @@ async function readJournal(path, maxEntries) {
18005
18257
  }
18006
18258
 
18007
18259
  // ../../bridges/acp-bridge/src/grok-interjection.ts
18008
- import { createHash as createHash5, randomBytes as randomBytes6 } from "node:crypto";
18260
+ import { createHash as createHash6, randomBytes as randomBytes7 } from "node:crypto";
18009
18261
  var GROK_INTERJECT_METHOD = "_x.ai/interject";
18010
18262
  var GROK_INTERJECTION_NOTIFICATION = "_x.ai/session/interjection";
18011
18263
  var MAX_GROK_INTERJECTION_JOURNAL = 256;
18012
18264
  var MAX_GROK_INTERJECTION_ID_BYTES = 512;
18013
18265
  var MAX_GROK_INTERJECTION_TEXT_BYTES = 64 * 1024;
18014
- var grokBridgeGeneration = randomBytes6(12).toString("base64url");
18266
+ var grokBridgeGeneration = randomBytes7(12).toString("base64url");
18015
18267
  function grokRunId(promptSequence) {
18016
18268
  return `grok:${grokBridgeGeneration}:${promptSequence}`;
18017
18269
  }
18018
18270
  function grokInterjectionDigest(text) {
18019
- return createHash5("sha256").update(text).digest("hex");
18271
+ return createHash6("sha256").update(text).digest("hex");
18020
18272
  }
18021
18273
  function parseGrokInterjectResult(value) {
18022
18274
  if (!isObject6(value) || value.status !== "queued")
@@ -18108,7 +18360,7 @@ function applyGrokInterjectionBroadcast(journal, acpSessionId, method, params, n
18108
18360
  return broadcast;
18109
18361
  }
18110
18362
  async function probeGrokInterjectionExtension(requester) {
18111
- const probeId = `orkestrator-qualification-${randomBytes6(12).toString("base64url")}`;
18363
+ const probeId = `orkestrator-qualification-${randomBytes7(12).toString("base64url")}`;
18112
18364
  try {
18113
18365
  await requestGrokInterjection(requester, {
18114
18366
  sessionId: probeId,
@@ -18144,7 +18396,7 @@ function isObject6(value) {
18144
18396
  }
18145
18397
 
18146
18398
  // ../../bridges/acp-bridge/src/acp-commands.ts
18147
- import { randomBytes as randomBytes7 } from "node:crypto";
18399
+ import { randomBytes as randomBytes8 } from "node:crypto";
18148
18400
 
18149
18401
  // ../protocol/src/agent-command-catalogue.ts
18150
18402
  var NATIVE_AGENT_COMMAND_CATALOGUE_VERSION = 1;
@@ -18275,7 +18527,7 @@ function commandUnavailableResponse(message) {
18275
18527
  }
18276
18528
 
18277
18529
  // ../../bridges/acp-bridge/src/acp-commands.ts
18278
- var COMMAND_CATALOGUE_GENERATION = `${provider}:${randomBytes7(8).toString("hex")}`;
18530
+ var COMMAND_CATALOGUE_GENERATION = `${provider}:${randomBytes8(8).toString("hex")}`;
18279
18531
  var COMMAND_ROWS_BYTE_BUDGET = COMMAND_CATALOGUE_LIMITS.maxWireBytes - 16 * 1024;
18280
18532
  var PROVIDER_LABEL = `${provider.charAt(0).toUpperCase()}${provider.slice(1)}`;
18281
18533
  function commandId(name) {
@@ -19278,12 +19530,12 @@ class InteractionDeadline {
19278
19530
  }
19279
19531
 
19280
19532
  // ../../bridges/acp-bridge/src/acp-command-changes.ts
19281
- import { createHash as createHash7 } from "node:crypto";
19533
+ import { createHash as createHash8 } from "node:crypto";
19282
19534
  import { resolve as resolve6 } from "node:path";
19283
19535
 
19284
19536
  // ../protocol/src/node/workspace-change-probe.ts
19285
19537
  import { randomUUID as randomUUID2 } from "node:crypto";
19286
- import { rmSync as rmSync2 } from "node:fs";
19538
+ import { rmSync as rmSync3 } from "node:fs";
19287
19539
  import { copyFile, lstat as lstat2, mkdtemp, rm as rm2 } from "node:fs/promises";
19288
19540
  import { tmpdir as tmpdir3 } from "node:os";
19289
19541
  import { delimiter, isAbsolute as isAbsolute3, join as join6, resolve as resolve4 } from "node:path";
@@ -19496,6 +19748,7 @@ function classifyCommandFailure(error, options = {}) {
19496
19748
  import { createRequire as createRequire2 } from "node:module";
19497
19749
 
19498
19750
  // ../protocol/src/node/shell-process-state.ts
19751
+ import { spawnSync } from "node:child_process";
19499
19752
  import { readdirSync, readFileSync as readFileSync2 } from "node:fs";
19500
19753
  import { constants as osConstants } from "node:os";
19501
19754
  var PROCESS_INSPECTION_OPTIONS = {
@@ -19565,8 +19818,11 @@ function linuxGroupHasLiveMember(pgid) {
19565
19818
  return false;
19566
19819
  }
19567
19820
  function psGroupHasLiveMember(pgid) {
19568
- const result = bunRuntime()?.spawnSync(["/bin/ps", "-A", "-o", "pgid=,stat="], PROCESS_INSPECTION_OPTIONS);
19569
- if (!result?.success)
19821
+ const argv = ["-A", "-o", "pgid=,stat="];
19822
+ const bun = bunRuntime();
19823
+ const result = bun ? bun.spawnSync(["/bin/ps", ...argv], PROCESS_INSPECTION_OPTIONS) : spawnSync("/bin/ps", argv, PROCESS_INSPECTION_OPTIONS);
19824
+ const succeeded = "success" in result ? result.success : result.status === 0 && !result.error;
19825
+ if (!succeeded)
19570
19826
  return true;
19571
19827
  return result.stdout.toString().split(`
19572
19828
  `).some((line) => {
@@ -19928,6 +20184,7 @@ function executeCommandBytes(command, args, options, timeoutMs, outputLimit, std
19928
20184
  let limitTimer;
19929
20185
  let stopExitWatch = () => {};
19930
20186
  let commandExit;
20187
+ let pendingFailure;
19931
20188
  const finishCapture = () => {
19932
20189
  settled = true;
19933
20190
  clearTimeout(timeoutTimer);
@@ -19949,13 +20206,33 @@ function executeCommandBytes(command, args, options, timeoutMs, outputLimit, std
19949
20206
  releaseCaptureFds();
19950
20207
  }
19951
20208
  };
19952
- const fail = (error) => {
19953
- if (settled)
19954
- return;
20209
+ const rejectFailure = (error) => {
19955
20210
  const output = finishCapture();
19956
20211
  if (output)
19957
20212
  reject(Object.assign(error, { ...output, killed: timedOut }));
19958
20213
  };
20214
+ const awaitTermination = (delayMs) => {
20215
+ clearTimeout(groupTimer);
20216
+ if (settled)
20217
+ return;
20218
+ if ((commandExit || exitReported(child)) && !commandGroupAlive(child)) {
20219
+ rejectFailure(pendingFailure);
20220
+ return;
20221
+ }
20222
+ groupTimer = setTimeout(awaitTermination, delayMs, Math.min(delayMs * 2, COMMAND_GROUP_POLL_MAX_MS));
20223
+ };
20224
+ const fail = (error) => {
20225
+ if (settled || pendingFailure)
20226
+ return;
20227
+ if (options.waitForTermination && child.pid !== undefined) {
20228
+ pendingFailure = error;
20229
+ signalCommand(child, "SIGKILL");
20230
+ clearTimeout(timeoutTimer);
20231
+ clearInterval(limitTimer);
20232
+ awaitTermination(COMMAND_GROUP_POLL_MS);
20233
+ } else
20234
+ rejectFailure(error);
20235
+ };
19959
20236
  const abort = () => {
19960
20237
  timedOut = true;
19961
20238
  signalCommand(child, "SIGKILL");
@@ -19982,11 +20259,11 @@ function executeCommandBytes(command, args, options, timeoutMs, outputLimit, std
19982
20259
  }
19983
20260
  };
19984
20261
  limitTimer = setInterval(() => {
19985
- if (!settled && !timedOut)
20262
+ if (!settled && !timedOut && !pendingFailure)
19986
20263
  failIfOverLimit();
19987
20264
  }, COMMAND_OUTPUT_CHECK_MS);
19988
20265
  const settleOnExit = () => {
19989
- if (settled || timedOut || failIfOverLimit())
20266
+ if (settled || timedOut || pendingFailure || failIfOverLimit())
19990
20267
  return;
19991
20268
  if (commandExit?.code !== 0 || commandExit.signal !== null) {
19992
20269
  fail(Object.assign(new Error(`Command failed: ${[command, ...args].join(" ")}`), {
@@ -20000,7 +20277,7 @@ function executeCommandBytes(command, args, options, timeoutMs, outputLimit, std
20000
20277
  resolve(output);
20001
20278
  };
20002
20279
  const awaitGroupExit = (delayMs) => {
20003
- if (settled || timedOut)
20280
+ if (settled || timedOut || pendingFailure)
20004
20281
  return;
20005
20282
  if (commandGroupAlive(child)) {
20006
20283
  groupTimer = setTimeout(awaitGroupExit, delayMs, Math.min(delayMs * 2, COMMAND_GROUP_POLL_MAX_MS));
@@ -20013,14 +20290,16 @@ function executeCommandBytes(command, args, options, timeoutMs, outputLimit, std
20013
20290
  return;
20014
20291
  commandExit = exit;
20015
20292
  stopExitWatch();
20016
- if (options.waitForDescendants)
20293
+ if (pendingFailure)
20294
+ awaitTermination(COMMAND_GROUP_POLL_MS);
20295
+ else if (options.waitForDescendants)
20017
20296
  awaitGroupExit(COMMAND_GROUP_POLL_MS);
20018
20297
  else
20019
20298
  settleOnExit();
20020
20299
  };
20021
20300
  child.exited.then(onCommandExit, (error) => fail(error instanceof Error ? error : new Error(String(error))));
20022
20301
  stopExitWatch = watchForLostExit(child.pid, (exit) => {
20023
- if (!settled && !timedOut)
20302
+ if (!settled)
20024
20303
  onCommandExit(exit);
20025
20304
  });
20026
20305
  if (timeoutMs > 0) {
@@ -20112,7 +20391,7 @@ var temporaryObjectDirectories = new Set;
20112
20391
  process.once("exit", () => {
20113
20392
  for (const directory of temporaryObjectDirectories) {
20114
20393
  try {
20115
- rmSync2(directory, { recursive: true, force: true });
20394
+ rmSync3(directory, { recursive: true, force: true });
20116
20395
  } catch {}
20117
20396
  }
20118
20397
  });
@@ -21080,7 +21359,7 @@ function workspaceObservationReportIssues(value) {
21080
21359
  }
21081
21360
 
21082
21361
  // ../protocol/src/node/change-tracking/evidence-spool.ts
21083
- import { createHash as createHash6, randomUUID as randomUUID3 } from "node:crypto";
21362
+ import { createHash as createHash7, randomUUID as randomUUID3 } from "node:crypto";
21084
21363
  import { readdirSync as readdirSync2, readFileSync as readFileSync3 } from "node:fs";
21085
21364
  import { appendFile as appendFile2, mkdir as mkdir2, rename as rename2, rm as rm3, writeFile as writeFile2 } from "node:fs/promises";
21086
21365
  import { join as join7 } from "node:path";
@@ -21096,10 +21375,10 @@ var DEFAULT_EVIDENCE_SPOOL_LIMITS = {
21096
21375
  var ENTRIES_FILE = "entries.jsonl";
21097
21376
  var BODY_DIRECTORY = "bodies";
21098
21377
  function evidenceBodyId(bytes) {
21099
- return `sha256:${createHash6("sha256").update(bytes).digest("hex")}`;
21378
+ return `sha256:${createHash7("sha256").update(bytes).digest("hex")}`;
21100
21379
  }
21101
21380
  function stableEvidenceId(...parts) {
21102
- const hash = createHash6("sha256");
21381
+ const hash = createHash7("sha256");
21103
21382
  for (const part of parts)
21104
21383
  hash.update(`${part ?? ""}\x00`);
21105
21384
  return hash.digest("hex").slice(0, 40);
@@ -22297,7 +22576,7 @@ async function applyJournaledCommandChanges(state) {
22297
22576
  function journalFor(acpSessionId) {
22298
22577
  if (!journalDirectory || !acpSessionId)
22299
22578
  return;
22300
- const name = createHash7("sha256").update(acpSessionId).digest("hex").slice(0, 40);
22579
+ const name = createHash8("sha256").update(acpSessionId).digest("hex").slice(0, 40);
22301
22580
  const path = resolve6(journalDirectory, `${name}.jsonl`);
22302
22581
  let journal = journals.get(path);
22303
22582
  if (journal) {
@@ -22455,7 +22734,7 @@ async function resumeSessionReserved(acpSessionId, signal, patch, policy, agentM
22455
22734
  throw new HttpError(410, `${provider} cannot reload persisted ACP sessions`);
22456
22735
  }
22457
22736
  state = {
22458
- id: randomBytes8(16).toString("hex"),
22737
+ id: randomBytes9(16).toString("hex"),
22459
22738
  acpSessionId,
22460
22739
  status: "idle",
22461
22740
  messages: [],
@@ -22612,7 +22891,7 @@ async function createSessionReserved(clientSessionKey, signal, spawnOptions = {}
22612
22891
  if (!isObject3(created) || typeof created.sessionId !== "string") {
22613
22892
  throw new Error(`${provider} returned an invalid ACP session`);
22614
22893
  }
22615
- const id = randomBytes8(16).toString("hex");
22894
+ const id = randomBytes9(16).toString("hex");
22616
22895
  const sessionConfig = normalizeAcpSessionConfig(provider, created);
22617
22896
  rememberCatalog(sessionConfig.composer);
22618
22897
  const state = newSessionState(id, clientSessionKey, created.sessionId, child, sessionConfig, spawnOptions);
@@ -22681,7 +22960,7 @@ function newSessionState(id, clientSessionKey, acpSessionId, child, sessionConfi
22681
22960
  };
22682
22961
  }
22683
22962
  async function createDeferredSession(clientSessionKey, spawnOptions) {
22684
- const id = randomBytes8(16).toString("hex");
22963
+ const id = randomBytes9(16).toString("hex");
22685
22964
  const empty = normalizeAcpSessionConfig(provider, {});
22686
22965
  const sessionConfig = withRequestedSelection({ ...empty, composer: { ...empty.composer, models: catalogCache?.models ?? [] } }, composerPatchFromSpawn(spawnOptions));
22687
22966
  const state = newSessionState(id, clientSessionKey, "", null, sessionConfig, spawnOptions);
@@ -23393,7 +23672,7 @@ function parkPermission(state, child, requestId, params) {
23393
23672
  }
23394
23673
  ];
23395
23674
  }).slice(0, 20) : [];
23396
- const id = randomBytes8(12).toString("hex");
23675
+ const id = randomBytes9(12).toString("hex");
23397
23676
  const requestedAt = Date.now();
23398
23677
  const promptSequence = state.promptSequence;
23399
23678
  const toolCallId = isObject3(params.toolCall) ? params.toolCall.toolCallId : undefined;
@@ -23450,7 +23729,7 @@ function permissionTitle(params) {
23450
23729
  return title.slice(0, 500);
23451
23730
  }
23452
23731
  function appendNonTextContent(state, update, role) {
23453
- const messageId = randomBytes8(12).toString("hex");
23732
+ const messageId = randomBytes9(12).toString("hex");
23454
23733
  const parts = contentBlockParts(update.content, messageId, 0);
23455
23734
  if (parts.length === 0)
23456
23735
  return;
@@ -23590,7 +23869,7 @@ function applySessionUpdate(state, params) {
23590
23869
  if (!message) {
23591
23870
  const modelId = role === "assistant" ? boundedModelId(state.sessionConfig.composer.selectedModelId) : undefined;
23592
23871
  message = {
23593
- id: randomBytes8(12).toString("hex"),
23872
+ id: randomBytes9(12).toString("hex"),
23594
23873
  role,
23595
23874
  content: "",
23596
23875
  parts: [],
@@ -24017,7 +24296,7 @@ function setPromptJournal(state, entry) {
24017
24296
  state.promptJournal.set(entry.requestId, entry);
24018
24297
  }
24019
24298
  // ../../bridges/acp-bridge/src/acp-prompt.ts
24020
- import { randomBytes as randomBytes9 } from "node:crypto";
24299
+ import { randomBytes as randomBytes10 } from "node:crypto";
24021
24300
 
24022
24301
  // ../../bridges/acp-bridge/src/structured-prompt-marker.ts
24023
24302
  var STRUCTURED_PROMPT_INSTRUCTION_PREFIX = "End your turn with exactly one JSON value";
@@ -24094,7 +24373,7 @@ function openRetryCard(state, text) {
24094
24373
  type: "retry",
24095
24374
  content: text,
24096
24375
  toolState: "pending",
24097
- sourcePartId: randomBytes9(12).toString("hex"),
24376
+ sourcePartId: randomBytes10(12).toString("hex"),
24098
24377
  sourceMessageId: message.id,
24099
24378
  createdAt: new Date().toISOString()
24100
24379
  };
@@ -24561,7 +24840,7 @@ function humanPromptObservation(messages, tasks) {
24561
24840
  }
24562
24841
 
24563
24842
  // ../../bridges/acp-bridge/src/acp-http.ts
24564
- import { randomBytes as randomBytes10 } from "node:crypto";
24843
+ import { randomBytes as randomBytes11 } from "node:crypto";
24565
24844
  import { pathToFileURL } from "node:url";
24566
24845
  import { gzip } from "node:zlib";
24567
24846
 
@@ -24742,7 +25021,7 @@ var STRUCTURED_OUTPUT_FAILURE_CODES = new Set([
24742
25021
  ]);
24743
25022
 
24744
25023
  // ../../bridges/acp-bridge/src/prompt-attachments.ts
24745
- import { constants as constants2 } from "node:fs";
25024
+ import { constants as constants3 } from "node:fs";
24746
25025
  import { lstat as lstat3, open as open4, realpath as realpath3 } from "node:fs/promises";
24747
25026
  import { isAbsolute as isAbsolute4, join as join8, relative as relative3, resolve as resolve8, sep as sep2 } from "node:path";
24748
25027
 
@@ -24907,8 +25186,8 @@ async function readWorkspaceImage(filePath, workspaceRoot) {
24907
25186
  if (!isPathWithin(canonicalRoot, canonicalTarget)) {
24908
25187
  throw new PromptAttachmentError("attachment_outside_workspace", "Image attachment must be contained in the current workspace");
24909
25188
  }
24910
- const noFollow = constants2.O_NOFOLLOW ?? 0;
24911
- const handle = await open4(targetPath, constants2.O_RDONLY | noFollow).catch((error) => {
25189
+ const noFollow = constants3.O_NOFOLLOW ?? 0;
25190
+ const handle = await open4(targetPath, constants3.O_RDONLY | noFollow).catch((error) => {
24912
25191
  throw attachmentErrorForFsFailure(error);
24913
25192
  });
24914
25193
  try {
@@ -25000,7 +25279,7 @@ var DEFAULT_MCP_MANAGEMENT_ROLLOUT = Object.freeze({
25000
25279
 
25001
25280
  // ../protocol/src/node/bridge-transcript-summary.ts
25002
25281
  import { Buffer as Buffer5 } from "node:buffer";
25003
- import { createHash as createHash8 } from "node:crypto";
25282
+ import { createHash as createHash9 } from "node:crypto";
25004
25283
 
25005
25284
  // ../protocol/src/node/progressive-transcript.ts
25006
25285
  var BRIDGE_TRANSCRIPT_MAX_MESSAGES = 100;
@@ -25166,7 +25445,7 @@ function digestPayload(payload) {
25166
25445
  const serialized = JSON.stringify(payload);
25167
25446
  return {
25168
25447
  bytes: Buffer5.byteLength(serialized),
25169
- digest: createHash8("sha256").update(serialized).digest("base64url").slice(0, 32)
25448
+ digest: createHash9("sha256").update(serialized).digest("base64url").slice(0, 32)
25170
25449
  };
25171
25450
  }
25172
25451
  function topLevelKey(part, index) {
@@ -25879,7 +26158,7 @@ function holdParkedRequest(state, family, id, held) {
25879
26158
  }
25880
26159
 
25881
26160
  // ../../bridges/acp-bridge/src/acp-http.ts
25882
- var TRANSCRIPT_GENERATION = randomBytes10(16).toString("hex");
26161
+ var TRANSCRIPT_GENERATION = randomBytes11(16).toString("hex");
25883
26162
  var log10 = createLogger("bridge.acp");
25884
26163
 
25885
26164
  class CommandUnavailableError extends Error {
@@ -25891,6 +26170,9 @@ async function route(request, response, clientSignal) {
25891
26170
  }
25892
26171
  if (!authenticated(request))
25893
26172
  return json(response, 401, { error: "Unauthorized" });
26173
+ const refused = await admitNodeBridgeRequest(bridgeCredential.authority, request, MAX_BODY_BYTES);
26174
+ if (refused)
26175
+ return json(response, refused.status, refused.body);
25894
26176
  if (url.pathname === "/global/auth-check" && request.method === "GET") {
25895
26177
  return json(response, 200, { ok: true });
25896
26178
  }
@@ -26327,7 +26609,7 @@ async function route(request, response, clientSignal) {
26327
26609
  }
26328
26610
  throw error;
26329
26611
  }
26330
- const userMessageId = randomBytes10(12).toString("hex");
26612
+ const userMessageId = randomBytes11(12).toString("hex");
26331
26613
  const userVisiblePrompt = selectedCommand ? displayPrompt || prompt : prompt;
26332
26614
  state.messages.push({
26333
26615
  id: userMessageId,
@@ -26611,13 +26893,18 @@ function storeAgentMcp(state, value) {
26611
26893
  }
26612
26894
  async function readJson(request) {
26613
26895
  const chunks = [];
26614
- let bytes = 0;
26615
- for await (const chunk of request) {
26616
- const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
26617
- bytes += buffer.length;
26618
- if (bytes > MAX_BODY_BYTES)
26619
- throw new HttpError(413, "Request body is too large");
26620
- chunks.push(buffer);
26896
+ const admitted = takeAdmittedBody(request);
26897
+ if (admitted) {
26898
+ chunks.push(admitted);
26899
+ } else {
26900
+ let bytes = 0;
26901
+ for await (const chunk of request) {
26902
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
26903
+ bytes += buffer.length;
26904
+ if (bytes > MAX_BODY_BYTES)
26905
+ throw new HttpError(413, "Request body is too large");
26906
+ chunks.push(buffer);
26907
+ }
26621
26908
  }
26622
26909
  let parsed;
26623
26910
  try {