brass-runtime 1.18.1 → 1.19.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/dist/agent/cli/main.cjs +31 -31
  3. package/dist/agent/cli/main.js +3 -3
  4. package/dist/agent/cli/main.mjs +3 -3
  5. package/dist/agent/index.cjs +4 -4
  6. package/dist/agent/index.js +3 -3
  7. package/dist/agent/index.mjs +3 -3
  8. package/dist/{chunk-22HZQG5F.js → chunk-2R3RVNS2.js} +6 -6
  9. package/dist/{chunk-YWLLH27R.mjs → chunk-3NKXUX4T.mjs} +2 -2
  10. package/dist/{chunk-IPSMXUWA.js → chunk-4PKBNG2H.js} +38 -18
  11. package/dist/{chunk-Z3ZZMQUZ.mjs → chunk-5RVHSBJ6.mjs} +182 -34
  12. package/dist/{chunk-B5FKOLTB.mjs → chunk-5UBJT4RW.mjs} +4 -4
  13. package/dist/{chunk-5RZ7YITF.cjs → chunk-6STX4PS3.cjs} +13 -13
  14. package/dist/{chunk-XPIMJQYS.cjs → chunk-7FZUTJM3.cjs} +400 -252
  15. package/dist/{chunk-YZ5LQ32F.js → chunk-A6EG5WRL.js} +3 -3
  16. package/dist/{chunk-TTSPIU3U.js → chunk-APQBU7TM.js} +53 -32
  17. package/dist/{chunk-BC6Q6BCO.mjs → chunk-AQQQFNYD.mjs} +38 -18
  18. package/dist/{chunk-OW5VHAOE.js → chunk-B2VXVNIS.js} +1 -1
  19. package/dist/{chunk-WCBNXPN6.mjs → chunk-BLXBZ6RE.mjs} +1 -1
  20. package/dist/{chunk-7VQLEN37.js → chunk-C3CWI42G.js} +1 -1
  21. package/dist/{chunk-WI7GZF3B.cjs → chunk-DV644N7P.cjs} +85 -85
  22. package/dist/{chunk-RBHNOKH4.mjs → chunk-EKLEDIVJ.mjs} +2 -2
  23. package/dist/{chunk-S4HXADU4.js → chunk-EXBGIC66.js} +1 -1
  24. package/dist/{chunk-LSYQ3C2M.js → chunk-FC5N5QHJ.js} +2 -2
  25. package/dist/{chunk-6MLAZPBL.mjs → chunk-FNWOH2T2.js} +18 -6
  26. package/dist/{chunk-WGE2FEZE.cjs → chunk-FYWWU3Z7.cjs} +2 -2
  27. package/dist/{chunk-2OW6IFY2.cjs → chunk-GOEO763K.cjs} +21 -21
  28. package/dist/{chunk-UAKAF32U.js → chunk-GXOIUBKE.js} +2 -2
  29. package/dist/{chunk-7DU7IQHK.js → chunk-H4ZRUQZL.js} +4 -4
  30. package/dist/{chunk-JWIEMBE6.mjs → chunk-HW2CLRJ3.mjs} +6 -6
  31. package/dist/{chunk-YGR2IN4R.js → chunk-JWFOWPMB.js} +163 -155
  32. package/dist/{chunk-6V2AWT4R.mjs → chunk-KAPZHDO4.mjs} +1 -1
  33. package/dist/{chunk-EEN5OTCR.mjs → chunk-KDXNWGPB.mjs} +1 -1
  34. package/dist/{chunk-UUMKZJRJ.cjs → chunk-KPOL2YEO.cjs} +18 -6
  35. package/dist/{chunk-J6DUHITE.cjs → chunk-MA74OYCI.cjs} +6 -6
  36. package/dist/{chunk-H626ZTDZ.mjs → chunk-MUMBUXU6.mjs} +53 -32
  37. package/dist/{chunk-5LC7V2OZ.cjs → chunk-NQW3YUFN.cjs} +18 -18
  38. package/dist/{chunk-EICAJDNX.cjs → chunk-OO7BGCC3.cjs} +54 -34
  39. package/dist/{chunk-7GBJYOX7.mjs → chunk-OX6MF7SZ.mjs} +163 -155
  40. package/dist/{chunk-WVSZOPGQ.cjs → chunk-QBVS3UYN.cjs} +245 -237
  41. package/dist/{chunk-WUDHOZIH.js → chunk-RZGB3DXR.js} +182 -34
  42. package/dist/{chunk-COOW7BJX.mjs → chunk-URVS2OE2.mjs} +3 -3
  43. package/dist/{chunk-HCJ4S3YB.js → chunk-UZQ3BB6W.mjs} +18 -6
  44. package/dist/{chunk-KNTJ7FQB.cjs → chunk-YQWZ7FZX.cjs} +5 -5
  45. package/dist/{chunk-ELIECDYN.cjs → chunk-Z2YIDHRI.cjs} +5 -5
  46. package/dist/{chunk-2JHJ4YHS.cjs → chunk-ZDZNV6NA.cjs} +59 -38
  47. package/dist/core/index.cjs +8 -8
  48. package/dist/core/index.js +7 -7
  49. package/dist/core/index.mjs +7 -7
  50. package/dist/http/index.cjs +54 -54
  51. package/dist/http/index.js +7 -7
  52. package/dist/http/index.mjs +7 -7
  53. package/dist/http/testing.cjs +9 -9
  54. package/dist/http/testing.js +5 -5
  55. package/dist/http/testing.mjs +5 -5
  56. package/dist/index.cjs +86 -86
  57. package/dist/index.js +8 -8
  58. package/dist/index.mjs +8 -8
  59. package/dist/observability/index.cjs +10 -10
  60. package/dist/observability/index.js +9 -9
  61. package/dist/observability/index.mjs +9 -9
  62. package/dist/perf/cli.cjs +26 -26
  63. package/dist/perf/cli.js +11 -11
  64. package/dist/perf/cli.mjs +11 -11
  65. package/dist/perf/index.cjs +13 -13
  66. package/dist/perf/index.js +11 -11
  67. package/dist/perf/index.mjs +11 -11
  68. package/dist/schema/index.cjs +2 -2
  69. package/dist/schema/index.js +1 -1
  70. package/dist/schema/index.mjs +1 -1
  71. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,70 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.18.2 - Release Metadata Alignment
4
+
5
+ ### Fixed
6
+
7
+ - Aligned `package.json` and `package-lock.json` with the npm release line after
8
+ the `1.18.0`/`1.18.1` publishes were cut from commits whose checked-in
9
+ package metadata still referenced older versions.
10
+ - Kept the HTTP P99 consolidation and runtime performance changes from the
11
+ `1.17.0` entry as the functional release contents; this patch is for
12
+ traceable version metadata and tag hygiene.
13
+
14
+ ## 1.17.0 - HTTP P99 Consolidation & Runtime Performance
15
+
16
+ ### Performance
17
+
18
+ - **HTTP P99/P50 ratio reduced from 12.3x to 2.5–3.5x** across `default-proxy-effect-transport`,
19
+ `default-proxy-effect-timeout-pool`, and `axios-brass-promise-pool-timeout` benchmark variants.
20
+ - **Runtime overhead reduced by ~46%** (P50 0.072ms → 0.039ms): hoisted the per-request frame
21
+ object inside `NativeTopLevelRunner` (eliminated 4 closures per `unsafeRunAsync`), made
22
+ `stack`/`joiners`/`finalizers` lazy-allocated, and stored the first joiner directly to skip
23
+ the array iteration on the happy path.
24
+ - **Schema nested object validation reduced by ~52%** (1.07μs → 0.51μs/op): pre-computed
25
+ `fieldKeys`/`fieldSchemas` arrays at construction, replaced `for...of` with indexed loops,
26
+ removed `issues.push(...result.issues)` spread allocations.
27
+ - **Cache middleware key computation reduced by ~84%** (+0.069ms → +0.011ms per request):
28
+ introduced `makeCacheKeyContext` and `computeCacheKeyFast` that hoist the relevant headers
29
+ Set, base URL origin, and validation once at middleware construction.
30
+ - **Dedup middleware key computation** mirrors the cache fast path via `makeDedupKeyContext`
31
+ and `computeDedupKeyFast`.
32
+ - **HTTP direct/pool transport**: added fast-path bypass for bare `Async`, `Succeed`, and
33
+ `Fail` effects that resolves transports synchronously; conditional `AbortController`
34
+ allocation using a shared `noopSignal` singleton; restructured `runPoolTransport` to use a
35
+ per-request `PoolRequestState` class that hoists shared logic as methods (closure budget
36
+ ≤ 3 in the uncontended sync path).
37
+ - **Promise transport adapter**: removed the per-request `async () => {}` wrapper IIFE,
38
+ inlined sync vs async response mapping, skipped `addEventListener` registration when the
39
+ signal is the shared `noopSignal`.
40
+ - **Stream `readerStream`**: cached `ABORTED_ERROR` singleton (no per-chunk `DOMException`
41
+ allocation), conditional signal listener registration, eliminated the separate `cleanup`
42
+ closure (inlined into `finish`).
43
+ - **Timer wheel**: added fine-tick scheduling path with `fineTickMs` (default 4ms) for
44
+ deadlines ≤ `fineThresholdMs` (default 50ms), so short timeouts overshoot by ≤ 4ms instead
45
+ of one coarse tick.
46
+ - **Conditional diagnostics**: per-label tracking in `recordAbortablePromiseStart`/`Finish`
47
+ is now opt-in via `setAbortablePromisePerLabelTracking(enabled)` (default `false`), making
48
+ the hot path allocation-free.
49
+ - **Observability**: collapsed the full middleware path's `asyncFlatMap × 4` chain into a
50
+ single `Async` with direct callbacks, reducing microtask hops per request; added a
51
+ base-labels cache keyed by `(method, host, route, preset)`.
52
+
53
+ ### Tooling
54
+
55
+ - Added `scripts/measure-p50.ts`, `scripts/measure-obs.ts`, `scripts/measure-schema.ts`, and
56
+ `scripts/measure-lifecycle.ts` for component-level latency breakdowns.
57
+ - HTTP P99/P50 regression gate (`src/benchmarks/http-local-overhead-gate.ts`) now runs with
58
+ `node --expose-gc` for stable measurements: 2000 calls × 2000 warmup × concurrency 8.
59
+ Asserts P99/P50 ≤ 4.0x for each gated variant and exits non-zero on regression.
60
+
61
+ ### Backward compatibility
62
+
63
+ - All public type signatures preserved (`makeHttp`, `makeDefaultHttpClient`, `makeHttpStream`,
64
+ schema builders).
65
+ - New configuration options (`fineTickMs`, `fineThresholdMs`, per-label tracking toggle) are
66
+ optional and default to pre-optimization behavior.
67
+
3
68
  ## 1.14.0 - First Public Release Candidate
4
69
 
5
70
  - Added mature core runtime features: structured concurrency, `Cause`,
@@ -17,17 +17,17 @@
17
17
 
18
18
 
19
19
 
20
- var _chunkJ6DUHITEcjs = require('../../chunk-J6DUHITE.cjs');
20
+ var _chunkMA74OYCIcjs = require('../../chunk-MA74OYCI.cjs');
21
21
  require('../../chunk-SA6HUJVI.cjs');
22
22
 
23
23
 
24
- var _chunk2JHJ4YHScjs = require('../../chunk-2JHJ4YHS.cjs');
24
+ var _chunkZDZNV6NAcjs = require('../../chunk-ZDZNV6NA.cjs');
25
25
 
26
26
 
27
27
 
28
28
 
29
29
  var _chunkMVGUEJ5Zcjs = require('../../chunk-MVGUEJ5Z.cjs');
30
- require('../../chunk-UUMKZJRJ.cjs');
30
+ require('../../chunk-KPOL2YEO.cjs');
31
31
  require('../../chunk-OBGZSXTJ.cjs');
32
32
 
33
33
  // src/agent/cli/approvals.ts
@@ -56,7 +56,7 @@ var makeCliApprovalService = (options = {}) => ({
56
56
  _optionalChain([output, 'optionalAccess', _ => _.write, 'optionalCall', _2 => _2(`
57
57
  Approval required (${request.risk})
58
58
  `)]);
59
- _optionalChain([output, 'optionalAccess', _3 => _3.write, 'optionalCall', _4 => _4(`Action: ${_chunkJ6DUHITEcjs.summarizeAgentAction.call(void 0, request.action)}
59
+ _optionalChain([output, 'optionalAccess', _3 => _3.write, 'optionalCall', _4 => _4(`Action: ${_chunkMA74OYCIcjs.summarizeAgentAction.call(void 0, request.action)}
60
60
  `)]);
61
61
  _optionalChain([output, 'optionalAccess', _5 => _5.write, 'optionalCall', _6 => _6(`Reason: ${request.reason}
62
62
  `)]);
@@ -1103,7 +1103,7 @@ var parseCliArgs = (argv) => {
1103
1103
  }
1104
1104
  if (arg === "--preset" || arg.startsWith("--preset=")) {
1105
1105
  const [value, nextIndex] = readFlagValue(argv, index, "--preset");
1106
- if (!_chunkJ6DUHITEcjs.isAgentPreset.call(void 0, value)) {
1106
+ if (!_chunkMA74OYCIcjs.isAgentPreset.call(void 0, value)) {
1107
1107
  throw new Error("--preset requires one of: fix-tests, inspect, typecheck, lint");
1108
1108
  }
1109
1109
  preset = value;
@@ -1279,7 +1279,7 @@ var parseBatchGoal = (value, path) => {
1279
1279
  if (cwd !== void 0 && typeof cwd !== "string") throw new Error(`${path}.cwd must be a string.`);
1280
1280
  if (patchFile !== void 0 && typeof patchFile !== "string") throw new Error(`${path}.patchFile must be a string.`);
1281
1281
  if (saveRunDir !== void 0 && typeof saveRunDir !== "string") throw new Error(`${path}.saveRunDir must be a string.`);
1282
- if (preset !== void 0 && (typeof preset !== "string" || !_chunkJ6DUHITEcjs.isAgentPreset.call(void 0, preset))) {
1282
+ if (preset !== void 0 && (typeof preset !== "string" || !_chunkMA74OYCIcjs.isAgentPreset.call(void 0, preset))) {
1283
1283
  throw new Error(`${path}.preset must be one of: fix-tests, inspect, typecheck, lint.`);
1284
1284
  }
1285
1285
  if (mode !== void 0 && (typeof mode !== "string" || !isAgentMode(mode))) {
@@ -1323,7 +1323,7 @@ var readBatchFile = async (cwd, batchFile) => {
1323
1323
  var resolveBatchGoalText = (item, fallbackPatchFile) => {
1324
1324
  if (typeof item === "string") return item;
1325
1325
  if (item.goal) return item.goal;
1326
- if (item.preset) return _chunkJ6DUHITEcjs.goalForAgentPreset.call(void 0, item.preset);
1326
+ if (item.preset) return _chunkMA74OYCIcjs.goalForAgentPreset.call(void 0, item.preset);
1327
1327
  if (_nullishCoalesce(item.patchFile, () => ( fallbackPatchFile))) return "apply supplied patch";
1328
1328
  return "";
1329
1329
  };
@@ -1350,7 +1350,7 @@ var resolveBatchRuns = (items, parsed, config) => items.map((item, index) => {
1350
1350
  };
1351
1351
  });
1352
1352
  var resolveParsedConfig = async (parsed) => {
1353
- const workspaceDiscovery = _chunkJ6DUHITEcjs.discoverNodeWorkspaceRoot.call(void 0, parsed.cwd, {
1353
+ const workspaceDiscovery = _chunkMA74OYCIcjs.discoverNodeWorkspaceRoot.call(void 0, parsed.cwd, {
1354
1354
  enabled: parsed.discoverWorkspace
1355
1355
  });
1356
1356
  const cwdResolved = workspaceDiscovery.cwd;
@@ -1358,7 +1358,7 @@ var resolveParsedConfig = async (parsed) => {
1358
1358
  ...parsed,
1359
1359
  cwd: cwdResolved
1360
1360
  };
1361
- const loaded = await _chunkJ6DUHITEcjs.loadNodeAgentConfig.call(void 0, {
1361
+ const loaded = await _chunkMA74OYCIcjs.loadNodeAgentConfig.call(void 0, {
1362
1362
  cwd: cwdResolved,
1363
1363
  configPath: parsed.configPath,
1364
1364
  noConfig: parsed.noConfig
@@ -1374,7 +1374,7 @@ var resolveParsedConfig = async (parsed) => {
1374
1374
  const batchRuns = resolveBatchRuns(batchItems, parsedAtWorkspace, loaded.config);
1375
1375
  return {
1376
1376
  ...parsedAtWorkspace,
1377
- goalText: parsed.goalText || (parsed.preset ? _chunkJ6DUHITEcjs.goalForAgentPreset.call(void 0, parsed.preset) : parsed.patchFile ? "apply supplied patch" : parsed.goalText),
1377
+ goalText: parsed.goalText || (parsed.preset ? _chunkMA74OYCIcjs.goalForAgentPreset.call(void 0, parsed.preset) : parsed.patchFile ? "apply supplied patch" : parsed.goalText),
1378
1378
  mode: parsed.modeSpecified ? parsed.mode : parsed.preset === "inspect" ? "read-only" : _nullishCoalesce(loaded.config.mode, () => ( parsed.mode)),
1379
1379
  approval: parsed.approvalSpecified ? parsed.approval : _nullishCoalesce(loaded.config.approval, () => ( parsed.approval)),
1380
1380
  config: loaded.config,
@@ -1498,7 +1498,7 @@ var envByName = (name) => name ? process.env[name] : void 0;
1498
1498
  var makeGoogleLLMFromEnv = (config) => {
1499
1499
  const apiKey = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(envByName(_optionalChain([config, 'optionalAccess', _39 => _39.apiKeyEnv])), () => ( process.env.BRASS_GOOGLE_API_KEY)), () => ( process.env.GOOGLE_API_KEY)), () => ( process.env.GEMINI_API_KEY));
1500
1500
  if (!apiKey) return void 0;
1501
- return _chunkJ6DUHITEcjs.makeGoogleGenerativeAILLM.call(void 0, {
1501
+ return _chunkMA74OYCIcjs.makeGoogleGenerativeAILLM.call(void 0, {
1502
1502
  apiKey,
1503
1503
  model: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(process.env.BRASS_GOOGLE_MODEL, () => ( process.env.BRASS_LLM_MODEL)), () => ( _optionalChain([config, 'optionalAccess', _40 => _40.model]))), () => ( "gemini-2.5-flash")),
1504
1504
  apiVersion: _nullishCoalesce(_nullishCoalesce(process.env.BRASS_GOOGLE_API_VERSION, () => ( _optionalChain([config, 'optionalAccess', _41 => _41.apiVersion]))), () => ( "v1beta")),
@@ -1516,12 +1516,12 @@ var makeOpenAICompatibleLLMFromEnv = (config) => {
1516
1516
  const apiKey = _nullishCoalesce(envByName(_optionalChain([config, 'optionalAccess', _50 => _50.apiKeyEnv])), () => ( process.env.BRASS_LLM_API_KEY));
1517
1517
  const model = _nullishCoalesce(_nullishCoalesce(process.env.BRASS_LLM_MODEL, () => ( _optionalChain([config, 'optionalAccess', _51 => _51.model]))), () => ( "gpt-4.1"));
1518
1518
  if (!endpoint || !apiKey) return void 0;
1519
- return _chunkJ6DUHITEcjs.makeOpenAICompatibleLLM.call(void 0, { endpoint, apiKey, model });
1519
+ return _chunkMA74OYCIcjs.makeOpenAICompatibleLLM.call(void 0, { endpoint, apiKey, model });
1520
1520
  };
1521
1521
  var makeLLMFromEnv = (config) => {
1522
1522
  const provider = _optionalChain([(_nullishCoalesce(process.env.BRASS_LLM_PROVIDER, () => ( _optionalChain([config, 'optionalAccess', _52 => _52.provider])))), 'optionalAccess', _53 => _53.trim, 'call', _54 => _54(), 'access', _55 => _55.toLowerCase, 'call', _56 => _56()]);
1523
1523
  const fakeResponse = _nullishCoalesce(process.env.BRASS_FAKE_LLM_RESPONSE, () => ( _optionalChain([config, 'optionalAccess', _57 => _57.fakeResponse])));
1524
- if (provider === "fake") return _chunkJ6DUHITEcjs.makeFakeLLM.call(void 0, { content: fakeResponse });
1524
+ if (provider === "fake") return _chunkMA74OYCIcjs.makeFakeLLM.call(void 0, { content: fakeResponse });
1525
1525
  if (provider === "google" || provider === "gemini") {
1526
1526
  const google = makeGoogleLLMFromEnv(config);
1527
1527
  if (!google) {
@@ -1543,7 +1543,7 @@ var makeLLMFromEnv = (config) => {
1543
1543
  if (provider) {
1544
1544
  throw new Error(`Unsupported LLM provider: ${provider}`);
1545
1545
  }
1546
- return _nullishCoalesce(_nullishCoalesce(makeGoogleLLMFromEnv(config), () => ( makeOpenAICompatibleLLMFromEnv(config))), () => ( _chunkJ6DUHITEcjs.makeFakeLLM.call(void 0, { content: fakeResponse })));
1546
+ return _nullishCoalesce(_nullishCoalesce(makeGoogleLLMFromEnv(config), () => ( makeOpenAICompatibleLLMFromEnv(config))), () => ( _chunkMA74OYCIcjs.makeFakeLLM.call(void 0, { content: fakeResponse })));
1547
1547
  };
1548
1548
  var parseApprovalModeFromEnv = () => {
1549
1549
  const raw = _optionalChain([process, 'access', _58 => _58.env, 'access', _59 => _59.BRASS_AGENT_APPROVAL, 'optionalAccess', _60 => _60.trim, 'call', _61 => _61(), 'access', _62 => _62.toLowerCase, 'call', _63 => _63()]);
@@ -1566,9 +1566,9 @@ var makeApprovalServiceFromCli = (parsed) => {
1566
1566
  const mode = resolveApprovalMode(parsed);
1567
1567
  switch (mode) {
1568
1568
  case "approve":
1569
- return _chunkJ6DUHITEcjs.autoApproveApprovals;
1569
+ return _chunkMA74OYCIcjs.autoApproveApprovals;
1570
1570
  case "deny":
1571
- return _chunkJ6DUHITEcjs.makeAutoDenyApprovals.call(void 0, "Approval rejected because the CLI is running without interactive input. Use --yes to auto-approve.");
1571
+ return _chunkMA74OYCIcjs.makeAutoDenyApprovals.call(void 0, "Approval rejected because the CLI is running without interactive input. Use --yes to auto-approve.");
1572
1572
  case "interactive":
1573
1573
  return makeCliApprovalService();
1574
1574
  }
@@ -1700,32 +1700,32 @@ var createHumanEventSink = (configPath) => ({
1700
1700
  console.log("");
1701
1701
  break;
1702
1702
  case "agent.action.started":
1703
- console.log(`\u2192 ${_chunkJ6DUHITEcjs.summarizeAgentAction.call(void 0, event.action)}`);
1703
+ console.log(`\u2192 ${_chunkMA74OYCIcjs.summarizeAgentAction.call(void 0, event.action)}`);
1704
1704
  break;
1705
1705
  case "agent.action.completed": {
1706
- const status = _chunkJ6DUHITEcjs.observationStatus.call(void 0, event.observation);
1707
- console.log(`${statusIcon2(status)} ${_chunkJ6DUHITEcjs.summarizeAgentObservation.call(void 0, event.observation)} ${formatDuration(event.durationMs)}`);
1706
+ const status = _chunkMA74OYCIcjs.observationStatus.call(void 0, event.observation);
1707
+ console.log(`${statusIcon2(status)} ${_chunkMA74OYCIcjs.summarizeAgentObservation.call(void 0, event.observation)} ${formatDuration(event.durationMs)}`);
1708
1708
  break;
1709
1709
  }
1710
1710
  case "agent.action.failed":
1711
1711
  if (event.error._tag !== "ToolTimeout" && event.error._tag !== "PermissionDenied" && event.error._tag !== "ApprovalRejected") {
1712
- console.log(`\u2717 ${_chunkJ6DUHITEcjs.summarizeAgentAction.call(void 0, event.action)} failed with ${event.error._tag} ${formatDuration(event.durationMs)}`);
1712
+ console.log(`\u2717 ${_chunkMA74OYCIcjs.summarizeAgentAction.call(void 0, event.action)} failed with ${event.error._tag} ${formatDuration(event.durationMs)}`);
1713
1713
  }
1714
1714
  break;
1715
1715
  case "agent.tool.timeout":
1716
- console.log(`! ${_chunkJ6DUHITEcjs.summarizeAgentAction.call(void 0, event.action)} timed out after ${event.timeoutMs}ms`);
1716
+ console.log(`! ${_chunkMA74OYCIcjs.summarizeAgentAction.call(void 0, event.action)} timed out after ${event.timeoutMs}ms`);
1717
1717
  break;
1718
1718
  case "agent.permission.denied":
1719
- console.log(`\u2717 ${_chunkJ6DUHITEcjs.summarizeAgentAction.call(void 0, event.action)} denied: ${event.reason}`);
1719
+ console.log(`\u2717 ${_chunkMA74OYCIcjs.summarizeAgentAction.call(void 0, event.action)} denied: ${event.reason}`);
1720
1720
  break;
1721
1721
  case "agent.approval.requested":
1722
- console.log(`? approval required for ${_chunkJ6DUHITEcjs.summarizeAgentAction.call(void 0, event.action)} (${event.risk})`);
1722
+ console.log(`? approval required for ${_chunkMA74OYCIcjs.summarizeAgentAction.call(void 0, event.action)} (${event.risk})`);
1723
1723
  break;
1724
1724
  case "agent.approval.resolved":
1725
1725
  if (event.approved) {
1726
- console.log(`\u2713 approval granted for ${_chunkJ6DUHITEcjs.summarizeAgentAction.call(void 0, event.action)}`);
1726
+ console.log(`\u2713 approval granted for ${_chunkMA74OYCIcjs.summarizeAgentAction.call(void 0, event.action)}`);
1727
1727
  } else {
1728
- console.log(`\u2717 approval rejected for ${_chunkJ6DUHITEcjs.summarizeAgentAction.call(void 0, event.action)}${event.reason ? `: ${event.reason}` : ""}`);
1728
+ console.log(`\u2717 approval rejected for ${_chunkMA74OYCIcjs.summarizeAgentAction.call(void 0, event.action)}${event.reason ? `: ${event.reason}` : ""}`);
1729
1729
  }
1730
1730
  break;
1731
1731
  case "agent.patch.applied":
@@ -1830,13 +1830,13 @@ var printHumanFinalSummary = (state) => {
1830
1830
  };
1831
1831
  var makeEventsSink = (parsed, compactOptions) => parsed.output === "human" ? createHumanEventSink(parsed.resolvedConfigPath) : parsed.output === "events-json" ? createJsonEventSink(compactOptions) : parsed.output === "protocol-json" ? createProtocolEventSink(compactOptions) : void 0;
1832
1832
  var makeAgentEnv = (parsed, events) => {
1833
- const shell = _chunkJ6DUHITEcjs.NodeShell;
1833
+ const shell = _chunkMA74OYCIcjs.NodeShell;
1834
1834
  return {
1835
1835
  shell,
1836
- fs: _chunkJ6DUHITEcjs.makeNodeFileSystem.call(void 0, shell),
1837
- patch: _chunkJ6DUHITEcjs.makeNodePatchService.call(void 0, shell),
1836
+ fs: _chunkMA74OYCIcjs.makeNodeFileSystem.call(void 0, shell),
1837
+ patch: _chunkMA74OYCIcjs.makeNodePatchService.call(void 0, shell),
1838
1838
  llm: makeLLMFromEnv(parsed.config.llm),
1839
- permissions: _chunkJ6DUHITEcjs.makeConfiguredPermissions.call(void 0, parsed.config.permissions),
1839
+ permissions: _chunkMA74OYCIcjs.makeConfiguredPermissions.call(void 0, parsed.config.permissions),
1840
1840
  approvals: makeApprovalServiceFromCli(parsed),
1841
1841
  ...events ? { events } : {},
1842
1842
  ...parsed.config.tools ? { toolPolicies: parsed.config.tools } : {}
@@ -1853,10 +1853,10 @@ var singleRunFromParsed = (parsed) => ({
1853
1853
  });
1854
1854
  var runCliAgent = async (parsed, run, compactOptions, events) => {
1855
1855
  const env = makeAgentEnv(parsed, events);
1856
- const runtime = new (0, _chunk2JHJ4YHScjs.Runtime)({ env });
1856
+ const runtime = new (0, _chunkZDZNV6NAcjs.Runtime)({ env });
1857
1857
  const initialPatch = run.patchFile ? await readPatchFile(run.cwd, run.patchFile) : void 0;
1858
1858
  const state = await runtime.toPromise(
1859
- _chunkJ6DUHITEcjs.runAgent.call(void 0, runtime, {
1859
+ _chunkMA74OYCIcjs.runAgent.call(void 0, runtime, {
1860
1860
  id: `agent-${Date.now()}-${run.index + 1}`,
1861
1861
  cwd: run.cwd,
1862
1862
  text: run.goalText,
@@ -17,17 +17,17 @@ import {
17
17
  runAgent,
18
18
  summarizeAgentAction,
19
19
  summarizeAgentObservation
20
- } from "../../chunk-7VQLEN37.js";
20
+ } from "../../chunk-C3CWI42G.js";
21
21
  import "../../chunk-UCUBNWM2.js";
22
22
  import {
23
23
  Runtime
24
- } from "../../chunk-TTSPIU3U.js";
24
+ } from "../../chunk-APQBU7TM.js";
25
25
  import {
26
26
  Cause,
27
27
  Exit,
28
28
  asyncEffect
29
29
  } from "../../chunk-UB4B6OFY.js";
30
- import "../../chunk-HCJ4S3YB.js";
30
+ import "../../chunk-FNWOH2T2.js";
31
31
  import "../../chunk-3RG5ZIWI.js";
32
32
 
33
33
  // src/agent/cli/approvals.ts
@@ -17,17 +17,17 @@ import {
17
17
  runAgent,
18
18
  summarizeAgentAction,
19
19
  summarizeAgentObservation
20
- } from "../../chunk-WCBNXPN6.mjs";
20
+ } from "../../chunk-BLXBZ6RE.mjs";
21
21
  import "../../chunk-B5JD23U7.mjs";
22
22
  import {
23
23
  Runtime
24
- } from "../../chunk-H626ZTDZ.mjs";
24
+ } from "../../chunk-MUMBUXU6.mjs";
25
25
  import {
26
26
  Cause,
27
27
  Exit,
28
28
  asyncEffect
29
29
  } from "../../chunk-36I3M4UC.mjs";
30
- import "../../chunk-6MLAZPBL.mjs";
30
+ import "../../chunk-UZQ3BB6W.mjs";
31
31
  import "../../chunk-Y6FXYEAI.mjs";
32
32
 
33
33
  // src/agent/cli/approvals.ts
@@ -73,11 +73,11 @@
73
73
 
74
74
 
75
75
 
76
- var _chunkJ6DUHITEcjs = require('../chunk-J6DUHITE.cjs');
76
+ var _chunkMA74OYCIcjs = require('../chunk-MA74OYCI.cjs');
77
77
  require('../chunk-SA6HUJVI.cjs');
78
- require('../chunk-2JHJ4YHS.cjs');
78
+ require('../chunk-ZDZNV6NA.cjs');
79
79
  require('../chunk-MVGUEJ5Z.cjs');
80
- require('../chunk-UUMKZJRJ.cjs');
80
+ require('../chunk-KPOL2YEO.cjs');
81
81
  require('../chunk-OBGZSXTJ.cjs');
82
82
 
83
83
 
@@ -154,4 +154,4 @@ require('../chunk-OBGZSXTJ.cjs');
154
154
 
155
155
 
156
156
 
157
- exports.AGENT_CONFIG_FILE_NAMES = _chunkJ6DUHITEcjs.AGENT_CONFIG_FILE_NAMES; exports.NodeShell = _chunkJ6DUHITEcjs.NodeShell; exports.PROJECT_LOCKFILE_PROBES = _chunkJ6DUHITEcjs.PROJECT_LOCKFILE_PROBES; exports.PROJECT_PROFILE_PROBES = _chunkJ6DUHITEcjs.PROJECT_PROFILE_PROBES; exports.autoApproveApprovals = _chunkJ6DUHITEcjs.autoApproveApprovals; exports.canAutoRollback = _chunkJ6DUHITEcjs.canAutoRollback; exports.canRequestPatchRepair = _chunkJ6DUHITEcjs.canRequestPatchRepair; exports.commandForScript = _chunkJ6DUHITEcjs.commandForScript; exports.decideNextAction = _chunkJ6DUHITEcjs.decideNextAction; exports.defaultPermissions = _chunkJ6DUHITEcjs.defaultPermissions; exports.deriveContextSearchQueries = _chunkJ6DUHITEcjs.deriveContextSearchQueries; exports.describeCommandDiscovery = _chunkJ6DUHITEcjs.describeCommandDiscovery; exports.describeContextDiscovery = _chunkJ6DUHITEcjs.describeContextDiscovery; exports.describeLanguagePolicy = _chunkJ6DUHITEcjs.describeLanguagePolicy; exports.describePatchQuality = _chunkJ6DUHITEcjs.describePatchQuality; exports.describeProjectProfile = _chunkJ6DUHITEcjs.describeProjectProfile; exports.describeRollbackSafety = _chunkJ6DUHITEcjs.describeRollbackSafety; exports.discoverNodeWorkspaceRoot = _chunkJ6DUHITEcjs.discoverNodeWorkspaceRoot; exports.discoverPackageManager = _chunkJ6DUHITEcjs.discoverPackageManager; exports.discoverProjectProfile = _chunkJ6DUHITEcjs.discoverProjectProfile; exports.discoverValidationCommands = _chunkJ6DUHITEcjs.discoverValidationCommands; exports.emitAgentEvent = _chunkJ6DUHITEcjs.emitAgentEvent; exports.emitAgentEvents = _chunkJ6DUHITEcjs.emitAgentEvents; exports.errorEventFor = _chunkJ6DUHITEcjs.errorEventFor; exports.extractLikelyFilePaths = _chunkJ6DUHITEcjs.extractLikelyFilePaths; exports.extractPatchPaths = _chunkJ6DUHITEcjs.extractPatchPaths; exports.extractUnifiedDiff = _chunkJ6DUHITEcjs.extractUnifiedDiff; exports.goalForAgentPreset = _chunkJ6DUHITEcjs.goalForAgentPreset; exports.inferUserLanguage = _chunkJ6DUHITEcjs.inferUserLanguage; exports.initialAgentState = _chunkJ6DUHITEcjs.initialAgentState; exports.invokeAction = _chunkJ6DUHITEcjs.invokeAction; exports.isAgentConfigApprovalMode = _chunkJ6DUHITEcjs.isAgentConfigApprovalMode; exports.isAgentConfigLLMProvider = _chunkJ6DUHITEcjs.isAgentConfigLLMProvider; exports.isAgentConfigMode = _chunkJ6DUHITEcjs.isAgentConfigMode; exports.isAgentPreset = _chunkJ6DUHITEcjs.isAgentPreset; exports.isRedactionEnabled = _chunkJ6DUHITEcjs.isRedactionEnabled; exports.isTerminal = _chunkJ6DUHITEcjs.isTerminal; exports.latestUnappliedPatch = _chunkJ6DUHITEcjs.latestUnappliedPatch; exports.loadNodeAgentConfig = _chunkJ6DUHITEcjs.loadNodeAgentConfig; exports.makeAutoDenyApprovals = _chunkJ6DUHITEcjs.makeAutoDenyApprovals; exports.makeConfiguredPermissions = _chunkJ6DUHITEcjs.makeConfiguredPermissions; exports.makeFakeLLM = _chunkJ6DUHITEcjs.makeFakeLLM; exports.makeGoogleGenerativeAILLM = _chunkJ6DUHITEcjs.makeGoogleGenerativeAILLM; exports.makeNodeFileSystem = _chunkJ6DUHITEcjs.makeNodeFileSystem; exports.makeNodePatchService = _chunkJ6DUHITEcjs.makeNodePatchService; exports.makeOpenAICompatibleLLM = _chunkJ6DUHITEcjs.makeOpenAICompatibleLLM; exports.nextContextDiscoveryAction = _chunkJ6DUHITEcjs.nextContextDiscoveryAction; exports.nextProjectProbeAction = _chunkJ6DUHITEcjs.nextProjectProbeAction; exports.nextUnrunValidationCommand = _chunkJ6DUHITEcjs.nextUnrunValidationCommand; exports.nowMillis = _chunkJ6DUHITEcjs.nowMillis; exports.observationEventFor = _chunkJ6DUHITEcjs.observationEventFor; exports.observationStatus = _chunkJ6DUHITEcjs.observationStatus; exports.parseProjectPackageJson = _chunkJ6DUHITEcjs.parseProjectPackageJson; exports.patchQualitySummary = _chunkJ6DUHITEcjs.patchQualitySummary; exports.patchRepairAttemptsUsed = _chunkJ6DUHITEcjs.patchRepairAttemptsUsed; exports.patchValidationStatus = _chunkJ6DUHITEcjs.patchValidationStatus; exports.projectProfileProbePending = _chunkJ6DUHITEcjs.projectProfileProbePending; exports.redactText = _chunkJ6DUHITEcjs.redactText; exports.reduceAgentState = _chunkJ6DUHITEcjs.reduceAgentState; exports.responseLanguageName = _chunkJ6DUHITEcjs.responseLanguageName; exports.retry = _chunkJ6DUHITEcjs.retry; exports.rollbackSafetySummary = _chunkJ6DUHITEcjs.rollbackSafetySummary; exports.runAgent = _chunkJ6DUHITEcjs.runAgent; exports.runStatusFor = _chunkJ6DUHITEcjs.runStatusFor; exports.shouldContinueRollbackStack = _chunkJ6DUHITEcjs.shouldContinueRollbackStack; exports.sleep = _chunkJ6DUHITEcjs.sleep; exports.spanishLike = _chunkJ6DUHITEcjs.spanishLike; exports.splitCommand = _chunkJ6DUHITEcjs.splitCommand; exports.summarizeAgentAction = _chunkJ6DUHITEcjs.summarizeAgentAction; exports.summarizeAgentObservation = _chunkJ6DUHITEcjs.summarizeAgentObservation; exports.summarizeContextDiscovery = _chunkJ6DUHITEcjs.summarizeContextDiscovery; exports.timeout = _chunkJ6DUHITEcjs.timeout; exports.unappliedPatchStack = _chunkJ6DUHITEcjs.unappliedPatchStack; exports.workspaceValidationStatus = _chunkJ6DUHITEcjs.workspaceValidationStatus;
157
+ exports.AGENT_CONFIG_FILE_NAMES = _chunkMA74OYCIcjs.AGENT_CONFIG_FILE_NAMES; exports.NodeShell = _chunkMA74OYCIcjs.NodeShell; exports.PROJECT_LOCKFILE_PROBES = _chunkMA74OYCIcjs.PROJECT_LOCKFILE_PROBES; exports.PROJECT_PROFILE_PROBES = _chunkMA74OYCIcjs.PROJECT_PROFILE_PROBES; exports.autoApproveApprovals = _chunkMA74OYCIcjs.autoApproveApprovals; exports.canAutoRollback = _chunkMA74OYCIcjs.canAutoRollback; exports.canRequestPatchRepair = _chunkMA74OYCIcjs.canRequestPatchRepair; exports.commandForScript = _chunkMA74OYCIcjs.commandForScript; exports.decideNextAction = _chunkMA74OYCIcjs.decideNextAction; exports.defaultPermissions = _chunkMA74OYCIcjs.defaultPermissions; exports.deriveContextSearchQueries = _chunkMA74OYCIcjs.deriveContextSearchQueries; exports.describeCommandDiscovery = _chunkMA74OYCIcjs.describeCommandDiscovery; exports.describeContextDiscovery = _chunkMA74OYCIcjs.describeContextDiscovery; exports.describeLanguagePolicy = _chunkMA74OYCIcjs.describeLanguagePolicy; exports.describePatchQuality = _chunkMA74OYCIcjs.describePatchQuality; exports.describeProjectProfile = _chunkMA74OYCIcjs.describeProjectProfile; exports.describeRollbackSafety = _chunkMA74OYCIcjs.describeRollbackSafety; exports.discoverNodeWorkspaceRoot = _chunkMA74OYCIcjs.discoverNodeWorkspaceRoot; exports.discoverPackageManager = _chunkMA74OYCIcjs.discoverPackageManager; exports.discoverProjectProfile = _chunkMA74OYCIcjs.discoverProjectProfile; exports.discoverValidationCommands = _chunkMA74OYCIcjs.discoverValidationCommands; exports.emitAgentEvent = _chunkMA74OYCIcjs.emitAgentEvent; exports.emitAgentEvents = _chunkMA74OYCIcjs.emitAgentEvents; exports.errorEventFor = _chunkMA74OYCIcjs.errorEventFor; exports.extractLikelyFilePaths = _chunkMA74OYCIcjs.extractLikelyFilePaths; exports.extractPatchPaths = _chunkMA74OYCIcjs.extractPatchPaths; exports.extractUnifiedDiff = _chunkMA74OYCIcjs.extractUnifiedDiff; exports.goalForAgentPreset = _chunkMA74OYCIcjs.goalForAgentPreset; exports.inferUserLanguage = _chunkMA74OYCIcjs.inferUserLanguage; exports.initialAgentState = _chunkMA74OYCIcjs.initialAgentState; exports.invokeAction = _chunkMA74OYCIcjs.invokeAction; exports.isAgentConfigApprovalMode = _chunkMA74OYCIcjs.isAgentConfigApprovalMode; exports.isAgentConfigLLMProvider = _chunkMA74OYCIcjs.isAgentConfigLLMProvider; exports.isAgentConfigMode = _chunkMA74OYCIcjs.isAgentConfigMode; exports.isAgentPreset = _chunkMA74OYCIcjs.isAgentPreset; exports.isRedactionEnabled = _chunkMA74OYCIcjs.isRedactionEnabled; exports.isTerminal = _chunkMA74OYCIcjs.isTerminal; exports.latestUnappliedPatch = _chunkMA74OYCIcjs.latestUnappliedPatch; exports.loadNodeAgentConfig = _chunkMA74OYCIcjs.loadNodeAgentConfig; exports.makeAutoDenyApprovals = _chunkMA74OYCIcjs.makeAutoDenyApprovals; exports.makeConfiguredPermissions = _chunkMA74OYCIcjs.makeConfiguredPermissions; exports.makeFakeLLM = _chunkMA74OYCIcjs.makeFakeLLM; exports.makeGoogleGenerativeAILLM = _chunkMA74OYCIcjs.makeGoogleGenerativeAILLM; exports.makeNodeFileSystem = _chunkMA74OYCIcjs.makeNodeFileSystem; exports.makeNodePatchService = _chunkMA74OYCIcjs.makeNodePatchService; exports.makeOpenAICompatibleLLM = _chunkMA74OYCIcjs.makeOpenAICompatibleLLM; exports.nextContextDiscoveryAction = _chunkMA74OYCIcjs.nextContextDiscoveryAction; exports.nextProjectProbeAction = _chunkMA74OYCIcjs.nextProjectProbeAction; exports.nextUnrunValidationCommand = _chunkMA74OYCIcjs.nextUnrunValidationCommand; exports.nowMillis = _chunkMA74OYCIcjs.nowMillis; exports.observationEventFor = _chunkMA74OYCIcjs.observationEventFor; exports.observationStatus = _chunkMA74OYCIcjs.observationStatus; exports.parseProjectPackageJson = _chunkMA74OYCIcjs.parseProjectPackageJson; exports.patchQualitySummary = _chunkMA74OYCIcjs.patchQualitySummary; exports.patchRepairAttemptsUsed = _chunkMA74OYCIcjs.patchRepairAttemptsUsed; exports.patchValidationStatus = _chunkMA74OYCIcjs.patchValidationStatus; exports.projectProfileProbePending = _chunkMA74OYCIcjs.projectProfileProbePending; exports.redactText = _chunkMA74OYCIcjs.redactText; exports.reduceAgentState = _chunkMA74OYCIcjs.reduceAgentState; exports.responseLanguageName = _chunkMA74OYCIcjs.responseLanguageName; exports.retry = _chunkMA74OYCIcjs.retry; exports.rollbackSafetySummary = _chunkMA74OYCIcjs.rollbackSafetySummary; exports.runAgent = _chunkMA74OYCIcjs.runAgent; exports.runStatusFor = _chunkMA74OYCIcjs.runStatusFor; exports.shouldContinueRollbackStack = _chunkMA74OYCIcjs.shouldContinueRollbackStack; exports.sleep = _chunkMA74OYCIcjs.sleep; exports.spanishLike = _chunkMA74OYCIcjs.spanishLike; exports.splitCommand = _chunkMA74OYCIcjs.splitCommand; exports.summarizeAgentAction = _chunkMA74OYCIcjs.summarizeAgentAction; exports.summarizeAgentObservation = _chunkMA74OYCIcjs.summarizeAgentObservation; exports.summarizeContextDiscovery = _chunkMA74OYCIcjs.summarizeContextDiscovery; exports.timeout = _chunkMA74OYCIcjs.timeout; exports.unappliedPatchStack = _chunkMA74OYCIcjs.unappliedPatchStack; exports.workspaceValidationStatus = _chunkMA74OYCIcjs.workspaceValidationStatus;
@@ -73,11 +73,11 @@ import {
73
73
  timeout,
74
74
  unappliedPatchStack,
75
75
  workspaceValidationStatus
76
- } from "../chunk-7VQLEN37.js";
76
+ } from "../chunk-C3CWI42G.js";
77
77
  import "../chunk-UCUBNWM2.js";
78
- import "../chunk-TTSPIU3U.js";
78
+ import "../chunk-APQBU7TM.js";
79
79
  import "../chunk-UB4B6OFY.js";
80
- import "../chunk-HCJ4S3YB.js";
80
+ import "../chunk-FNWOH2T2.js";
81
81
  import "../chunk-3RG5ZIWI.js";
82
82
  export {
83
83
  AGENT_CONFIG_FILE_NAMES,
@@ -73,11 +73,11 @@ import {
73
73
  timeout,
74
74
  unappliedPatchStack,
75
75
  workspaceValidationStatus
76
- } from "../chunk-WCBNXPN6.mjs";
76
+ } from "../chunk-BLXBZ6RE.mjs";
77
77
  import "../chunk-B5JD23U7.mjs";
78
- import "../chunk-H626ZTDZ.mjs";
78
+ import "../chunk-MUMBUXU6.mjs";
79
79
  import "../chunk-36I3M4UC.mjs";
80
- import "../chunk-6MLAZPBL.mjs";
80
+ import "../chunk-UZQ3BB6W.mjs";
81
81
  import "../chunk-Y6FXYEAI.mjs";
82
82
  export {
83
83
  AGENT_CONFIG_FILE_NAMES,
@@ -1,24 +1,24 @@
1
1
  import {
2
2
  makeFiberRef,
3
3
  makeRuntimeRecorder
4
- } from "./chunk-UAKAF32U.js";
4
+ } from "./chunk-GXOIUBKE.js";
5
5
  import {
6
6
  withHttpObservability
7
- } from "./chunk-YGR2IN4R.js";
7
+ } from "./chunk-JWFOWPMB.js";
8
8
  import {
9
9
  makeObservability
10
- } from "./chunk-YZ5LQ32F.js";
10
+ } from "./chunk-A6EG5WRL.js";
11
11
  import {
12
12
  EventBus
13
- } from "./chunk-OW5VHAOE.js";
13
+ } from "./chunk-B2VXVNIS.js";
14
14
  import {
15
15
  makeDefaultHttpClient,
16
16
  makeHttp
17
- } from "./chunk-WUDHOZIH.js";
17
+ } from "./chunk-RZGB3DXR.js";
18
18
  import {
19
19
  Runtime,
20
20
  Scheduler
21
- } from "./chunk-TTSPIU3U.js";
21
+ } from "./chunk-APQBU7TM.js";
22
22
  import {
23
23
  asyncFlatMap,
24
24
  asyncSucceed,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  layerEffect,
3
3
  makeServiceTag
4
- } from "./chunk-EEN5OTCR.mjs";
4
+ } from "./chunk-KDXNWGPB.mjs";
5
5
  import {
6
6
  Runtime
7
- } from "./chunk-H626ZTDZ.mjs";
7
+ } from "./chunk-MUMBUXU6.mjs";
8
8
  import {
9
9
  asyncSync
10
10
  } from "./chunk-36I3M4UC.mjs";
@@ -6,7 +6,7 @@ import {
6
6
  getCurrentFiber,
7
7
  unsafeGetCurrentRuntime,
8
8
  unsafeRunFoldWithEnv
9
- } from "./chunk-TTSPIU3U.js";
9
+ } from "./chunk-APQBU7TM.js";
10
10
  import {
11
11
  Cause,
12
12
  Exit,
@@ -412,31 +412,49 @@ function drainStreamSyncFull(stream) {
412
412
  }
413
413
  }
414
414
  }
415
+ var ABORTED_ERROR = (() => {
416
+ if (typeof DOMException === "function") {
417
+ try {
418
+ return new DOMException("aborted", "AbortError");
419
+ } catch {
420
+ }
421
+ }
422
+ const e = new Error("aborted");
423
+ e.name = "AbortError";
424
+ return e;
425
+ })();
415
426
  function readerStream(reader, normalizeError, signal) {
427
+ const noopSignal = globalThis.__brassNoopSignal;
428
+ const needsSignalListener = signal !== void 0 && signal !== noopSignal;
416
429
  const pull = asyncEffect((_, cb) => {
417
430
  let done = false;
418
- const cleanup = () => signal?.removeEventListener("abort", abort);
431
+ let abortFn;
419
432
  const finish = (exit) => {
420
433
  if (done) return;
421
434
  done = true;
422
- cleanup();
435
+ if (needsSignalListener && abortFn) signal.removeEventListener("abort", abortFn);
423
436
  cb(exit);
424
437
  };
425
- const abort = () => {
426
- try {
427
- reader.cancel();
428
- } catch {
438
+ if (needsSignalListener) {
439
+ if (signal.aborted) {
440
+ try {
441
+ reader.cancel();
442
+ } catch {
443
+ }
444
+ finish({ _tag: "Failure", cause: { _tag: "Fail", error: some(normalizeError(ABORTED_ERROR)) } });
445
+ return;
429
446
  }
430
- const error = typeof DOMException === "function" ? new DOMException("aborted", "AbortError") : new Error("aborted");
431
- finish({ _tag: "Failure", cause: { _tag: "Fail", error: some(normalizeError(error)) } });
432
- };
433
- if (signal?.aborted) {
434
- abort();
435
- return;
447
+ abortFn = () => {
448
+ try {
449
+ reader.cancel();
450
+ } catch {
451
+ }
452
+ finish({ _tag: "Failure", cause: { _tag: "Fail", error: some(normalizeError(ABORTED_ERROR)) } });
453
+ };
454
+ signal.addEventListener("abort", abortFn, { once: true });
436
455
  }
437
- signal?.addEventListener("abort", abort, { once: true });
438
- reader.read().then(({ done: done2, value }) => {
439
- if (done2) {
456
+ reader.read().then(({ done: readDone, value }) => {
457
+ if (readDone) {
440
458
  finish({ _tag: "Failure", cause: { _tag: "Fail", error: none } });
441
459
  return;
442
460
  }
@@ -444,11 +462,13 @@ function readerStream(reader, normalizeError, signal) {
444
462
  _tag: "Success",
445
463
  value: [value, fromPull(pull)]
446
464
  });
447
- }).catch((e) => {
465
+ }, (e) => {
448
466
  finish({ _tag: "Failure", cause: { _tag: "Fail", error: some(normalizeError(e)) } });
449
467
  });
450
468
  return () => {
451
- cleanup();
469
+ if (done) return;
470
+ done = true;
471
+ if (needsSignalListener && abortFn) signal.removeEventListener("abort", abortFn);
452
472
  try {
453
473
  reader.cancel();
454
474
  } catch {