brass-runtime 1.16.1 → 1.18.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 (123) hide show
  1. package/README.md +40 -8
  2. package/dist/agent/cli/main.cjs +31 -32
  3. package/dist/agent/cli/main.js +3 -4
  4. package/dist/agent/cli/main.mjs +3 -4
  5. package/dist/agent/index.cjs +4 -5
  6. package/dist/agent/index.d.ts +1 -1
  7. package/dist/agent/index.js +3 -4
  8. package/dist/agent/index.mjs +3 -4
  9. package/dist/{chunk-GYM3LLGS.mjs → chunk-2QNREG6K.mjs} +188 -5
  10. package/dist/{chunk-4ROBZFL6.cjs → chunk-2SLT3X6G.cjs} +6 -8
  11. package/dist/{chunk-KZJQ723N.cjs → chunk-3PFZGP23.cjs} +13 -15
  12. package/dist/{chunk-AVNQLJ5V.js → chunk-3PHU7FWS.js} +528 -23
  13. package/dist/{chunk-CIZFIMK5.js → chunk-4YQHPIWJ.js} +60 -11
  14. package/dist/chunk-5XADBMSU.cjs +33 -0
  15. package/dist/{chunk-DNFJLJMW.mjs → chunk-6MLAZPBL.mjs} +48 -24
  16. package/dist/chunk-7TKI527D.cjs +123 -0
  17. package/dist/{chunk-AGR5B2BC.cjs → chunk-7TXQJFZX.cjs} +564 -12
  18. package/dist/{chunk-RKGKFN2A.js → chunk-AADFFVYS.js} +1 -1
  19. package/dist/{chunk-52PPNNI4.cjs → chunk-AJMKZXRB.cjs} +2 -2
  20. package/dist/{chunk-3AYM6WPJ.js → chunk-BG5RNEA2.js} +20 -299
  21. package/dist/{chunk-2HQTDLHF.mjs → chunk-ELLF55ER.mjs} +555 -3
  22. package/dist/{chunk-EOC4UHBS.mjs → chunk-G5JTCFMI.mjs} +2 -2
  23. package/dist/chunk-H5GYX7RZ.js +6126 -0
  24. package/dist/{chunk-C3MDXTRZ.js → chunk-HCJ4S3YB.js} +48 -24
  25. package/dist/{chunk-6IXXWIUM.js → chunk-IBRHSH5H.js} +555 -3
  26. package/dist/{chunk-Q2I37RP3.cjs → chunk-IFRBVMWJ.cjs} +44 -323
  27. package/dist/{chunk-52OB2ROS.js → chunk-ITG6I7ZS.js} +2 -4
  28. package/dist/chunk-ITZQ526U.mjs +33 -0
  29. package/dist/{chunk-7JIJOVCT.js → chunk-JH4GI3DW.js} +2 -4
  30. package/dist/{chunk-76YMRMH2.cjs → chunk-KHACHFBQ.cjs} +583 -78
  31. package/dist/{chunk-MT3OWDPC.mjs → chunk-KRYP6CAE.mjs} +60 -11
  32. package/dist/chunk-KTGDLBLD.mjs +123 -0
  33. package/dist/{chunk-ENKODRU3.cjs → chunk-LXBU5E77.cjs} +143 -94
  34. package/dist/{chunk-PD4EJTQC.cjs → chunk-N6QNSTWD.cjs} +5 -5
  35. package/dist/{chunk-HLWLMW2F.mjs → chunk-OI4ESUMC.mjs} +9 -11
  36. package/dist/{chunk-EJ6BPYVR.mjs → chunk-OT2TESZU.mjs} +1 -1
  37. package/dist/{chunk-BABBZK4Y.js → chunk-PSEU65ND.js} +9 -11
  38. package/dist/{chunk-DNFO2EIZ.mjs → chunk-QCOLAHU3.mjs} +528 -23
  39. package/dist/{chunk-KH4SYAOS.mjs → chunk-QZ6QFJNM.mjs} +20 -299
  40. package/dist/{chunk-MBEJI5HF.mjs → chunk-R6WDSZA6.mjs} +2 -4
  41. package/dist/{chunk-FHQGHPMO.mjs → chunk-RREBJX2S.mjs} +2 -4
  42. package/dist/{chunk-5QC7LRZ3.js → chunk-S4HHFUYP.js} +2 -2
  43. package/dist/{chunk-GLE2WY7Z.cjs → chunk-SSQJKDN3.cjs} +194 -11
  44. package/dist/{chunk-CZIVE6NT.cjs → chunk-UUMKZJRJ.cjs} +48 -24
  45. package/dist/chunk-VIFA4DPN.cjs +6126 -0
  46. package/dist/chunk-W6WR37HN.js +33 -0
  47. package/dist/{chunk-FH2X7BVP.js → chunk-XSAHV5HQ.js} +188 -5
  48. package/dist/chunk-YM3EDNYD.js +123 -0
  49. package/dist/{chunk-VN44DYYT.cjs → chunk-YTX2JYYP.cjs} +18 -20
  50. package/dist/chunk-Z3PSSXP3.mjs +6126 -0
  51. package/dist/core/index.cjs +31 -9
  52. package/dist/core/index.d.ts +19 -152
  53. package/dist/core/index.js +80 -58
  54. package/dist/core/index.mjs +80 -58
  55. package/dist/defaultClient-DhpCQW9m.d.ts +1623 -0
  56. package/dist/{effect-DIUHZ9IN.d.ts → effect-CtUDl5M5.d.ts} +1 -1
  57. package/dist/http/index.cjs +202 -59
  58. package/dist/http/index.d.ts +55 -819
  59. package/dist/http/index.js +216 -73
  60. package/dist/http/index.mjs +216 -73
  61. package/dist/http/testing.cjs +31 -10
  62. package/dist/http/testing.d.ts +16 -5
  63. package/dist/http/testing.js +29 -8
  64. package/dist/http/testing.mjs +29 -8
  65. package/dist/index.cjs +110 -88
  66. package/dist/index.d.ts +9 -8
  67. package/dist/index.js +81 -59
  68. package/dist/index.mjs +81 -59
  69. package/dist/{schedule-CK3Ml_7p.d.ts → layer-BalPI6cN.d.ts} +176 -2
  70. package/dist/observability/index.cjs +22 -7
  71. package/dist/observability/index.d.ts +32 -8
  72. package/dist/observability/index.js +21 -6
  73. package/dist/observability/index.mjs +21 -6
  74. package/dist/perf/cli.cjs +26 -28
  75. package/dist/perf/cli.js +11 -13
  76. package/dist/perf/cli.mjs +11 -13
  77. package/dist/perf/index.cjs +13 -15
  78. package/dist/perf/index.js +11 -13
  79. package/dist/perf/index.mjs +11 -13
  80. package/dist/schema/index.cjs +2 -2
  81. package/dist/schema/index.js +1 -1
  82. package/dist/schema/index.mjs +1 -1
  83. package/dist/{server-GJPg8ZSG.d.ts → server-C1zVmqE6.d.ts} +16 -5
  84. package/dist/{stream-B4oK9JFP.d.ts → stream-Bb4FTejt.d.ts} +1 -1
  85. package/dist/{tracer-Hwt1cl7h.d.ts → tracer-DzfuE6um.d.ts} +2 -2
  86. package/dist/{tracing-DqbTKGcf.d.ts → tracing-BABA5arE.d.ts} +1 -1
  87. package/docs/README.md +4 -0
  88. package/docs/ai/PUBLIC_API.md +31 -7
  89. package/docs/articles/brass-runtime-http-observability.md +467 -0
  90. package/docs/framework-integrations.md +38 -0
  91. package/docs/frameworks/angular.md +204 -0
  92. package/docs/frameworks/express.md +183 -0
  93. package/docs/frameworks/fastify.md +173 -0
  94. package/docs/frameworks/nestjs.md +335 -0
  95. package/docs/frameworks/nextjs.md +202 -0
  96. package/docs/frameworks/react.md +183 -0
  97. package/docs/frameworks/vanilla.md +280 -0
  98. package/docs/guides/layers.md +130 -0
  99. package/docs/http-recipes.md +31 -1
  100. package/docs/http.md +50 -1
  101. package/docs/nestjs.md +6 -0
  102. package/docs/observability-framework-examples.md +12 -0
  103. package/docs/observability.md +239 -0
  104. package/docs/performance-profiler.md +6 -2
  105. package/docs/recipes/layers.md +46 -2
  106. package/docs/recipes/testing.md +25 -0
  107. package/package.json +4 -1
  108. package/dist/chunk-3LOYJFRR.cjs +0 -300
  109. package/dist/chunk-3Y2RIUMM.js +0 -300
  110. package/dist/chunk-5EC274J5.cjs +0 -2874
  111. package/dist/chunk-5VRJNBLZ.mjs +0 -2874
  112. package/dist/chunk-62AZW6UT.cjs +0 -313
  113. package/dist/chunk-74ZTY6CP.js +0 -2871
  114. package/dist/chunk-7CMJS3QE.mjs +0 -2871
  115. package/dist/chunk-A2OM6NEH.mjs +0 -194
  116. package/dist/chunk-B33ICAKP.js +0 -313
  117. package/dist/chunk-JF5WGYJJ.cjs +0 -194
  118. package/dist/chunk-KN32XNTH.mjs +0 -313
  119. package/dist/chunk-KQLYONSE.cjs +0 -2871
  120. package/dist/chunk-L2SYFEBS.js +0 -194
  121. package/dist/chunk-MIIYDLGM.js +0 -2874
  122. package/dist/chunk-PWC3RBQE.mjs +0 -300
  123. package/dist/client-CZHU674n.d.ts +0 -820
package/README.md CHANGED
@@ -9,6 +9,10 @@ Built without `Promise`/`async`/`await` as the primary semantic primitive. Effec
9
9
  npm i brass-runtime
10
10
  ```
11
11
 
12
+ Runnable framework examples live in the
13
+ [repository examples](https://github.com/BaldrVivaldelli/brass-runtime/tree/main/examples).
14
+ They are kept out of the npm package so installs stay small.
15
+
12
16
  ---
13
17
 
14
18
  ## What it does
@@ -159,9 +163,30 @@ console.log(http.compression?.stats());
159
163
  deduplication, priority scheduling, retry, adaptive concurrency, safe-method
160
164
  response cache, decompression, stats, `cancelAll`, and JSON/text helpers. Use
161
165
  `preset: "production"` when you want that production-ready shape explicitly,
162
- `preset: "balanced"` to skip the default cache, or `preset: "minimal"` for a
163
- cheap wire client with the same helper API. `preset: "default"` remains the
164
- same full preset for compatibility.
166
+ `preset: "balanced"` to skip the default cache, `preset: "highThroughputProxy"`
167
+ for hot BFF/proxy paths without lifecycle queues or Brass timers by default,
168
+ `preset: "proxy"` as the shorter compatibility alias, or `preset: "minimal"`
169
+ for a cheap wire client with the same helper API. `preset: "default"` remains
170
+ the same full preset for compatibility.
171
+
172
+ On Node BFF/proxy services, pair the proxy preset with the first-party
173
+ `node:http` transport when the default `fetch` backend is the bottleneck.
174
+ The Node-only factory below wires that recommended shape directly:
175
+
176
+ ```ts
177
+ import { toPromise } from "brass-runtime";
178
+ import { makeNodeHttpProxyClient } from "brass-runtime/http";
179
+
180
+ const http = makeNodeHttpProxyClient({
181
+ baseUrl: "https://api.example.com",
182
+ nodeTransport: {
183
+ maxSockets: 512,
184
+ maxFreeSockets: 512,
185
+ },
186
+ });
187
+
188
+ await toPromise(http.shutdown(), {}); // also destroys owned Node agents
189
+ ```
165
190
 
166
191
  The HTTP stack is meant to replace the usual `fetch` wrapper plus Zod/Valibot
167
192
  glue: schemas are dependency-free, responses and request bodies are validated in
@@ -420,6 +445,7 @@ const client = baseClient.with(middleware);
420
445
  import { Runtime, asyncSucceed } from "brass-runtime/core";
421
446
  import {
422
447
  makeObservability,
448
+ makeOtlpOptions,
423
449
  runObservedHttpServerEffect,
424
450
  withHttpObservability,
425
451
  } from "brass-runtime/observability";
@@ -431,11 +457,7 @@ const obs = makeObservability({
431
457
  sampling: { ratio: 0.25, respectRemoteSampled: true, forceSampleOnError: true },
432
458
  redaction: {},
433
459
  cardinality: { maxValuesPerLabel: 100 },
434
- otlp: {
435
- metricsUrl: "http://collector:4318/v1/metrics",
436
- tracesUrl: "http://collector:4318/v1/traces",
437
- logsUrl: "http://collector:4318/v1/logs",
438
- },
460
+ otlp: makeOtlpOptions({ endpoint: "http://collector:4318" }),
439
461
  flushIntervalMs: 10_000,
440
462
  });
441
463
 
@@ -463,6 +485,14 @@ It also reads `req.policy` automatically: logs and span attributes include
463
485
  Metric labels stay conservative by default; opt into stable labels with
464
486
  `withHttpObservability({ policy: { labelKeys: ["preset", "lane", "poolKey"] } })`.
465
487
 
488
+ For hot proxy paths, keep HTTP metrics separate from runtime hooks:
489
+ `makeObservability({ metrics: false, logs: false, traces: false })`,
490
+ `preset: "proxy"`, `withHttpObservability({ spans: false, logs: false,
491
+ injectTraceHeaders: false, includeHostLabel: false })`. For sampled spans on
492
+ the same path, avoid global runtime hooks and use
493
+ `withHttpObservability({ spans: { events: false, sampleRate: 0.001 },
494
+ spanSink: observability.tracer, injectTraceHeaders: false })`.
495
+
466
496
  ### Performance profiler
467
497
 
468
498
  ```bash
@@ -666,6 +696,8 @@ Property-based tests use `fast-check` with 100+ iterations per property. Each HT
666
696
  - [Cancellation & Interruption](./docs/cancellation.md)
667
697
  - [Observability: Hooks & Tracing](./docs/observability.md)
668
698
  - [Observability framework examples](./docs/observability-framework-examples.md)
699
+ - [Framework integrations](./docs/framework-integrations.md)
700
+ - [NestJS integration](./docs/frameworks/nestjs.md)
669
701
  - [Observability collector smoke](./docs/observability-collector-smoke.md)
670
702
  - [HTTP module](./docs/http.md)
671
703
  - [Production readiness](./docs/production-readiness.md)
@@ -17,18 +17,17 @@
17
17
 
18
18
 
19
19
 
20
- var _chunk4ROBZFL6cjs = require('../../chunk-4ROBZFL6.cjs');
20
+ var _chunk2SLT3X6Gcjs = require('../../chunk-2SLT3X6G.cjs');
21
21
  require('../../chunk-SA6HUJVI.cjs');
22
- require('../../chunk-JF5WGYJJ.cjs');
23
22
 
24
23
 
25
- var _chunkGLE2WY7Zcjs = require('../../chunk-GLE2WY7Z.cjs');
24
+ var _chunkSSQJKDN3cjs = require('../../chunk-SSQJKDN3.cjs');
26
25
 
27
26
 
28
27
 
29
28
 
30
29
  var _chunkMVGUEJ5Zcjs = require('../../chunk-MVGUEJ5Z.cjs');
31
- require('../../chunk-CZIVE6NT.cjs');
30
+ require('../../chunk-UUMKZJRJ.cjs');
32
31
  require('../../chunk-OBGZSXTJ.cjs');
33
32
 
34
33
  // src/agent/cli/approvals.ts
@@ -57,7 +56,7 @@ var makeCliApprovalService = (options = {}) => ({
57
56
  _optionalChain([output, 'optionalAccess', _ => _.write, 'optionalCall', _2 => _2(`
58
57
  Approval required (${request.risk})
59
58
  `)]);
60
- _optionalChain([output, 'optionalAccess', _3 => _3.write, 'optionalCall', _4 => _4(`Action: ${_chunk4ROBZFL6cjs.summarizeAgentAction.call(void 0, request.action)}
59
+ _optionalChain([output, 'optionalAccess', _3 => _3.write, 'optionalCall', _4 => _4(`Action: ${_chunk2SLT3X6Gcjs.summarizeAgentAction.call(void 0, request.action)}
61
60
  `)]);
62
61
  _optionalChain([output, 'optionalAccess', _5 => _5.write, 'optionalCall', _6 => _6(`Reason: ${request.reason}
63
62
  `)]);
@@ -1104,7 +1103,7 @@ var parseCliArgs = (argv) => {
1104
1103
  }
1105
1104
  if (arg === "--preset" || arg.startsWith("--preset=")) {
1106
1105
  const [value, nextIndex] = readFlagValue(argv, index, "--preset");
1107
- if (!_chunk4ROBZFL6cjs.isAgentPreset.call(void 0, value)) {
1106
+ if (!_chunk2SLT3X6Gcjs.isAgentPreset.call(void 0, value)) {
1108
1107
  throw new Error("--preset requires one of: fix-tests, inspect, typecheck, lint");
1109
1108
  }
1110
1109
  preset = value;
@@ -1280,7 +1279,7 @@ var parseBatchGoal = (value, path) => {
1280
1279
  if (cwd !== void 0 && typeof cwd !== "string") throw new Error(`${path}.cwd must be a string.`);
1281
1280
  if (patchFile !== void 0 && typeof patchFile !== "string") throw new Error(`${path}.patchFile must be a string.`);
1282
1281
  if (saveRunDir !== void 0 && typeof saveRunDir !== "string") throw new Error(`${path}.saveRunDir must be a string.`);
1283
- if (preset !== void 0 && (typeof preset !== "string" || !_chunk4ROBZFL6cjs.isAgentPreset.call(void 0, preset))) {
1282
+ if (preset !== void 0 && (typeof preset !== "string" || !_chunk2SLT3X6Gcjs.isAgentPreset.call(void 0, preset))) {
1284
1283
  throw new Error(`${path}.preset must be one of: fix-tests, inspect, typecheck, lint.`);
1285
1284
  }
1286
1285
  if (mode !== void 0 && (typeof mode !== "string" || !isAgentMode(mode))) {
@@ -1324,7 +1323,7 @@ var readBatchFile = async (cwd, batchFile) => {
1324
1323
  var resolveBatchGoalText = (item, fallbackPatchFile) => {
1325
1324
  if (typeof item === "string") return item;
1326
1325
  if (item.goal) return item.goal;
1327
- if (item.preset) return _chunk4ROBZFL6cjs.goalForAgentPreset.call(void 0, item.preset);
1326
+ if (item.preset) return _chunk2SLT3X6Gcjs.goalForAgentPreset.call(void 0, item.preset);
1328
1327
  if (_nullishCoalesce(item.patchFile, () => ( fallbackPatchFile))) return "apply supplied patch";
1329
1328
  return "";
1330
1329
  };
@@ -1351,7 +1350,7 @@ var resolveBatchRuns = (items, parsed, config) => items.map((item, index) => {
1351
1350
  };
1352
1351
  });
1353
1352
  var resolveParsedConfig = async (parsed) => {
1354
- const workspaceDiscovery = _chunk4ROBZFL6cjs.discoverNodeWorkspaceRoot.call(void 0, parsed.cwd, {
1353
+ const workspaceDiscovery = _chunk2SLT3X6Gcjs.discoverNodeWorkspaceRoot.call(void 0, parsed.cwd, {
1355
1354
  enabled: parsed.discoverWorkspace
1356
1355
  });
1357
1356
  const cwdResolved = workspaceDiscovery.cwd;
@@ -1359,7 +1358,7 @@ var resolveParsedConfig = async (parsed) => {
1359
1358
  ...parsed,
1360
1359
  cwd: cwdResolved
1361
1360
  };
1362
- const loaded = await _chunk4ROBZFL6cjs.loadNodeAgentConfig.call(void 0, {
1361
+ const loaded = await _chunk2SLT3X6Gcjs.loadNodeAgentConfig.call(void 0, {
1363
1362
  cwd: cwdResolved,
1364
1363
  configPath: parsed.configPath,
1365
1364
  noConfig: parsed.noConfig
@@ -1375,7 +1374,7 @@ var resolveParsedConfig = async (parsed) => {
1375
1374
  const batchRuns = resolveBatchRuns(batchItems, parsedAtWorkspace, loaded.config);
1376
1375
  return {
1377
1376
  ...parsedAtWorkspace,
1378
- goalText: parsed.goalText || (parsed.preset ? _chunk4ROBZFL6cjs.goalForAgentPreset.call(void 0, parsed.preset) : parsed.patchFile ? "apply supplied patch" : parsed.goalText),
1377
+ goalText: parsed.goalText || (parsed.preset ? _chunk2SLT3X6Gcjs.goalForAgentPreset.call(void 0, parsed.preset) : parsed.patchFile ? "apply supplied patch" : parsed.goalText),
1379
1378
  mode: parsed.modeSpecified ? parsed.mode : parsed.preset === "inspect" ? "read-only" : _nullishCoalesce(loaded.config.mode, () => ( parsed.mode)),
1380
1379
  approval: parsed.approvalSpecified ? parsed.approval : _nullishCoalesce(loaded.config.approval, () => ( parsed.approval)),
1381
1380
  config: loaded.config,
@@ -1499,7 +1498,7 @@ var envByName = (name) => name ? process.env[name] : void 0;
1499
1498
  var makeGoogleLLMFromEnv = (config) => {
1500
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));
1501
1500
  if (!apiKey) return void 0;
1502
- return _chunk4ROBZFL6cjs.makeGoogleGenerativeAILLM.call(void 0, {
1501
+ return _chunk2SLT3X6Gcjs.makeGoogleGenerativeAILLM.call(void 0, {
1503
1502
  apiKey,
1504
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")),
1505
1504
  apiVersion: _nullishCoalesce(_nullishCoalesce(process.env.BRASS_GOOGLE_API_VERSION, () => ( _optionalChain([config, 'optionalAccess', _41 => _41.apiVersion]))), () => ( "v1beta")),
@@ -1517,12 +1516,12 @@ var makeOpenAICompatibleLLMFromEnv = (config) => {
1517
1516
  const apiKey = _nullishCoalesce(envByName(_optionalChain([config, 'optionalAccess', _50 => _50.apiKeyEnv])), () => ( process.env.BRASS_LLM_API_KEY));
1518
1517
  const model = _nullishCoalesce(_nullishCoalesce(process.env.BRASS_LLM_MODEL, () => ( _optionalChain([config, 'optionalAccess', _51 => _51.model]))), () => ( "gpt-4.1"));
1519
1518
  if (!endpoint || !apiKey) return void 0;
1520
- return _chunk4ROBZFL6cjs.makeOpenAICompatibleLLM.call(void 0, { endpoint, apiKey, model });
1519
+ return _chunk2SLT3X6Gcjs.makeOpenAICompatibleLLM.call(void 0, { endpoint, apiKey, model });
1521
1520
  };
1522
1521
  var makeLLMFromEnv = (config) => {
1523
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()]);
1524
1523
  const fakeResponse = _nullishCoalesce(process.env.BRASS_FAKE_LLM_RESPONSE, () => ( _optionalChain([config, 'optionalAccess', _57 => _57.fakeResponse])));
1525
- if (provider === "fake") return _chunk4ROBZFL6cjs.makeFakeLLM.call(void 0, { content: fakeResponse });
1524
+ if (provider === "fake") return _chunk2SLT3X6Gcjs.makeFakeLLM.call(void 0, { content: fakeResponse });
1526
1525
  if (provider === "google" || provider === "gemini") {
1527
1526
  const google = makeGoogleLLMFromEnv(config);
1528
1527
  if (!google) {
@@ -1544,7 +1543,7 @@ var makeLLMFromEnv = (config) => {
1544
1543
  if (provider) {
1545
1544
  throw new Error(`Unsupported LLM provider: ${provider}`);
1546
1545
  }
1547
- return _nullishCoalesce(_nullishCoalesce(makeGoogleLLMFromEnv(config), () => ( makeOpenAICompatibleLLMFromEnv(config))), () => ( _chunk4ROBZFL6cjs.makeFakeLLM.call(void 0, { content: fakeResponse })));
1546
+ return _nullishCoalesce(_nullishCoalesce(makeGoogleLLMFromEnv(config), () => ( makeOpenAICompatibleLLMFromEnv(config))), () => ( _chunk2SLT3X6Gcjs.makeFakeLLM.call(void 0, { content: fakeResponse })));
1548
1547
  };
1549
1548
  var parseApprovalModeFromEnv = () => {
1550
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()]);
@@ -1567,9 +1566,9 @@ var makeApprovalServiceFromCli = (parsed) => {
1567
1566
  const mode = resolveApprovalMode(parsed);
1568
1567
  switch (mode) {
1569
1568
  case "approve":
1570
- return _chunk4ROBZFL6cjs.autoApproveApprovals;
1569
+ return _chunk2SLT3X6Gcjs.autoApproveApprovals;
1571
1570
  case "deny":
1572
- return _chunk4ROBZFL6cjs.makeAutoDenyApprovals.call(void 0, "Approval rejected because the CLI is running without interactive input. Use --yes to auto-approve.");
1571
+ return _chunk2SLT3X6Gcjs.makeAutoDenyApprovals.call(void 0, "Approval rejected because the CLI is running without interactive input. Use --yes to auto-approve.");
1573
1572
  case "interactive":
1574
1573
  return makeCliApprovalService();
1575
1574
  }
@@ -1701,32 +1700,32 @@ var createHumanEventSink = (configPath) => ({
1701
1700
  console.log("");
1702
1701
  break;
1703
1702
  case "agent.action.started":
1704
- console.log(`\u2192 ${_chunk4ROBZFL6cjs.summarizeAgentAction.call(void 0, event.action)}`);
1703
+ console.log(`\u2192 ${_chunk2SLT3X6Gcjs.summarizeAgentAction.call(void 0, event.action)}`);
1705
1704
  break;
1706
1705
  case "agent.action.completed": {
1707
- const status = _chunk4ROBZFL6cjs.observationStatus.call(void 0, event.observation);
1708
- console.log(`${statusIcon2(status)} ${_chunk4ROBZFL6cjs.summarizeAgentObservation.call(void 0, event.observation)} ${formatDuration(event.durationMs)}`);
1706
+ const status = _chunk2SLT3X6Gcjs.observationStatus.call(void 0, event.observation);
1707
+ console.log(`${statusIcon2(status)} ${_chunk2SLT3X6Gcjs.summarizeAgentObservation.call(void 0, event.observation)} ${formatDuration(event.durationMs)}`);
1709
1708
  break;
1710
1709
  }
1711
1710
  case "agent.action.failed":
1712
1711
  if (event.error._tag !== "ToolTimeout" && event.error._tag !== "PermissionDenied" && event.error._tag !== "ApprovalRejected") {
1713
- console.log(`\u2717 ${_chunk4ROBZFL6cjs.summarizeAgentAction.call(void 0, event.action)} failed with ${event.error._tag} ${formatDuration(event.durationMs)}`);
1712
+ console.log(`\u2717 ${_chunk2SLT3X6Gcjs.summarizeAgentAction.call(void 0, event.action)} failed with ${event.error._tag} ${formatDuration(event.durationMs)}`);
1714
1713
  }
1715
1714
  break;
1716
1715
  case "agent.tool.timeout":
1717
- console.log(`! ${_chunk4ROBZFL6cjs.summarizeAgentAction.call(void 0, event.action)} timed out after ${event.timeoutMs}ms`);
1716
+ console.log(`! ${_chunk2SLT3X6Gcjs.summarizeAgentAction.call(void 0, event.action)} timed out after ${event.timeoutMs}ms`);
1718
1717
  break;
1719
1718
  case "agent.permission.denied":
1720
- console.log(`\u2717 ${_chunk4ROBZFL6cjs.summarizeAgentAction.call(void 0, event.action)} denied: ${event.reason}`);
1719
+ console.log(`\u2717 ${_chunk2SLT3X6Gcjs.summarizeAgentAction.call(void 0, event.action)} denied: ${event.reason}`);
1721
1720
  break;
1722
1721
  case "agent.approval.requested":
1723
- console.log(`? approval required for ${_chunk4ROBZFL6cjs.summarizeAgentAction.call(void 0, event.action)} (${event.risk})`);
1722
+ console.log(`? approval required for ${_chunk2SLT3X6Gcjs.summarizeAgentAction.call(void 0, event.action)} (${event.risk})`);
1724
1723
  break;
1725
1724
  case "agent.approval.resolved":
1726
1725
  if (event.approved) {
1727
- console.log(`\u2713 approval granted for ${_chunk4ROBZFL6cjs.summarizeAgentAction.call(void 0, event.action)}`);
1726
+ console.log(`\u2713 approval granted for ${_chunk2SLT3X6Gcjs.summarizeAgentAction.call(void 0, event.action)}`);
1728
1727
  } else {
1729
- console.log(`\u2717 approval rejected for ${_chunk4ROBZFL6cjs.summarizeAgentAction.call(void 0, event.action)}${event.reason ? `: ${event.reason}` : ""}`);
1728
+ console.log(`\u2717 approval rejected for ${_chunk2SLT3X6Gcjs.summarizeAgentAction.call(void 0, event.action)}${event.reason ? `: ${event.reason}` : ""}`);
1730
1729
  }
1731
1730
  break;
1732
1731
  case "agent.patch.applied":
@@ -1831,13 +1830,13 @@ var printHumanFinalSummary = (state) => {
1831
1830
  };
1832
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;
1833
1832
  var makeAgentEnv = (parsed, events) => {
1834
- const shell = _chunk4ROBZFL6cjs.NodeShell;
1833
+ const shell = _chunk2SLT3X6Gcjs.NodeShell;
1835
1834
  return {
1836
1835
  shell,
1837
- fs: _chunk4ROBZFL6cjs.makeNodeFileSystem.call(void 0, shell),
1838
- patch: _chunk4ROBZFL6cjs.makeNodePatchService.call(void 0, shell),
1836
+ fs: _chunk2SLT3X6Gcjs.makeNodeFileSystem.call(void 0, shell),
1837
+ patch: _chunk2SLT3X6Gcjs.makeNodePatchService.call(void 0, shell),
1839
1838
  llm: makeLLMFromEnv(parsed.config.llm),
1840
- permissions: _chunk4ROBZFL6cjs.makeConfiguredPermissions.call(void 0, parsed.config.permissions),
1839
+ permissions: _chunk2SLT3X6Gcjs.makeConfiguredPermissions.call(void 0, parsed.config.permissions),
1841
1840
  approvals: makeApprovalServiceFromCli(parsed),
1842
1841
  ...events ? { events } : {},
1843
1842
  ...parsed.config.tools ? { toolPolicies: parsed.config.tools } : {}
@@ -1854,10 +1853,10 @@ var singleRunFromParsed = (parsed) => ({
1854
1853
  });
1855
1854
  var runCliAgent = async (parsed, run, compactOptions, events) => {
1856
1855
  const env = makeAgentEnv(parsed, events);
1857
- const runtime = new (0, _chunkGLE2WY7Zcjs.Runtime)({ env });
1856
+ const runtime = new (0, _chunkSSQJKDN3cjs.Runtime)({ env });
1858
1857
  const initialPatch = run.patchFile ? await readPatchFile(run.cwd, run.patchFile) : void 0;
1859
1858
  const state = await runtime.toPromise(
1860
- _chunk4ROBZFL6cjs.runAgent.call(void 0, runtime, {
1859
+ _chunk2SLT3X6Gcjs.runAgent.call(void 0, runtime, {
1861
1860
  id: `agent-${Date.now()}-${run.index + 1}`,
1862
1861
  cwd: run.cwd,
1863
1862
  text: run.goalText,
@@ -17,18 +17,17 @@ import {
17
17
  runAgent,
18
18
  summarizeAgentAction,
19
19
  summarizeAgentObservation
20
- } from "../../chunk-52OB2ROS.js";
20
+ } from "../../chunk-ITG6I7ZS.js";
21
21
  import "../../chunk-UCUBNWM2.js";
22
- import "../../chunk-L2SYFEBS.js";
23
22
  import {
24
23
  Runtime
25
- } from "../../chunk-FH2X7BVP.js";
24
+ } from "../../chunk-XSAHV5HQ.js";
26
25
  import {
27
26
  Cause,
28
27
  Exit,
29
28
  asyncEffect
30
29
  } from "../../chunk-UB4B6OFY.js";
31
- import "../../chunk-C3MDXTRZ.js";
30
+ import "../../chunk-HCJ4S3YB.js";
32
31
  import "../../chunk-3RG5ZIWI.js";
33
32
 
34
33
  // src/agent/cli/approvals.ts
@@ -17,18 +17,17 @@ import {
17
17
  runAgent,
18
18
  summarizeAgentAction,
19
19
  summarizeAgentObservation
20
- } from "../../chunk-MBEJI5HF.mjs";
20
+ } from "../../chunk-R6WDSZA6.mjs";
21
21
  import "../../chunk-B5JD23U7.mjs";
22
- import "../../chunk-A2OM6NEH.mjs";
23
22
  import {
24
23
  Runtime
25
- } from "../../chunk-GYM3LLGS.mjs";
24
+ } from "../../chunk-2QNREG6K.mjs";
26
25
  import {
27
26
  Cause,
28
27
  Exit,
29
28
  asyncEffect
30
29
  } from "../../chunk-36I3M4UC.mjs";
31
- import "../../chunk-DNFJLJMW.mjs";
30
+ import "../../chunk-6MLAZPBL.mjs";
32
31
  import "../../chunk-Y6FXYEAI.mjs";
33
32
 
34
33
  // src/agent/cli/approvals.ts
@@ -73,12 +73,11 @@
73
73
 
74
74
 
75
75
 
76
- var _chunk4ROBZFL6cjs = require('../chunk-4ROBZFL6.cjs');
76
+ var _chunk2SLT3X6Gcjs = require('../chunk-2SLT3X6G.cjs');
77
77
  require('../chunk-SA6HUJVI.cjs');
78
- require('../chunk-JF5WGYJJ.cjs');
79
- require('../chunk-GLE2WY7Z.cjs');
78
+ require('../chunk-SSQJKDN3.cjs');
80
79
  require('../chunk-MVGUEJ5Z.cjs');
81
- require('../chunk-CZIVE6NT.cjs');
80
+ require('../chunk-UUMKZJRJ.cjs');
82
81
  require('../chunk-OBGZSXTJ.cjs');
83
82
 
84
83
 
@@ -155,4 +154,4 @@ require('../chunk-OBGZSXTJ.cjs');
155
154
 
156
155
 
157
156
 
158
- exports.AGENT_CONFIG_FILE_NAMES = _chunk4ROBZFL6cjs.AGENT_CONFIG_FILE_NAMES; exports.NodeShell = _chunk4ROBZFL6cjs.NodeShell; exports.PROJECT_LOCKFILE_PROBES = _chunk4ROBZFL6cjs.PROJECT_LOCKFILE_PROBES; exports.PROJECT_PROFILE_PROBES = _chunk4ROBZFL6cjs.PROJECT_PROFILE_PROBES; exports.autoApproveApprovals = _chunk4ROBZFL6cjs.autoApproveApprovals; exports.canAutoRollback = _chunk4ROBZFL6cjs.canAutoRollback; exports.canRequestPatchRepair = _chunk4ROBZFL6cjs.canRequestPatchRepair; exports.commandForScript = _chunk4ROBZFL6cjs.commandForScript; exports.decideNextAction = _chunk4ROBZFL6cjs.decideNextAction; exports.defaultPermissions = _chunk4ROBZFL6cjs.defaultPermissions; exports.deriveContextSearchQueries = _chunk4ROBZFL6cjs.deriveContextSearchQueries; exports.describeCommandDiscovery = _chunk4ROBZFL6cjs.describeCommandDiscovery; exports.describeContextDiscovery = _chunk4ROBZFL6cjs.describeContextDiscovery; exports.describeLanguagePolicy = _chunk4ROBZFL6cjs.describeLanguagePolicy; exports.describePatchQuality = _chunk4ROBZFL6cjs.describePatchQuality; exports.describeProjectProfile = _chunk4ROBZFL6cjs.describeProjectProfile; exports.describeRollbackSafety = _chunk4ROBZFL6cjs.describeRollbackSafety; exports.discoverNodeWorkspaceRoot = _chunk4ROBZFL6cjs.discoverNodeWorkspaceRoot; exports.discoverPackageManager = _chunk4ROBZFL6cjs.discoverPackageManager; exports.discoverProjectProfile = _chunk4ROBZFL6cjs.discoverProjectProfile; exports.discoverValidationCommands = _chunk4ROBZFL6cjs.discoverValidationCommands; exports.emitAgentEvent = _chunk4ROBZFL6cjs.emitAgentEvent; exports.emitAgentEvents = _chunk4ROBZFL6cjs.emitAgentEvents; exports.errorEventFor = _chunk4ROBZFL6cjs.errorEventFor; exports.extractLikelyFilePaths = _chunk4ROBZFL6cjs.extractLikelyFilePaths; exports.extractPatchPaths = _chunk4ROBZFL6cjs.extractPatchPaths; exports.extractUnifiedDiff = _chunk4ROBZFL6cjs.extractUnifiedDiff; exports.goalForAgentPreset = _chunk4ROBZFL6cjs.goalForAgentPreset; exports.inferUserLanguage = _chunk4ROBZFL6cjs.inferUserLanguage; exports.initialAgentState = _chunk4ROBZFL6cjs.initialAgentState; exports.invokeAction = _chunk4ROBZFL6cjs.invokeAction; exports.isAgentConfigApprovalMode = _chunk4ROBZFL6cjs.isAgentConfigApprovalMode; exports.isAgentConfigLLMProvider = _chunk4ROBZFL6cjs.isAgentConfigLLMProvider; exports.isAgentConfigMode = _chunk4ROBZFL6cjs.isAgentConfigMode; exports.isAgentPreset = _chunk4ROBZFL6cjs.isAgentPreset; exports.isRedactionEnabled = _chunk4ROBZFL6cjs.isRedactionEnabled; exports.isTerminal = _chunk4ROBZFL6cjs.isTerminal; exports.latestUnappliedPatch = _chunk4ROBZFL6cjs.latestUnappliedPatch; exports.loadNodeAgentConfig = _chunk4ROBZFL6cjs.loadNodeAgentConfig; exports.makeAutoDenyApprovals = _chunk4ROBZFL6cjs.makeAutoDenyApprovals; exports.makeConfiguredPermissions = _chunk4ROBZFL6cjs.makeConfiguredPermissions; exports.makeFakeLLM = _chunk4ROBZFL6cjs.makeFakeLLM; exports.makeGoogleGenerativeAILLM = _chunk4ROBZFL6cjs.makeGoogleGenerativeAILLM; exports.makeNodeFileSystem = _chunk4ROBZFL6cjs.makeNodeFileSystem; exports.makeNodePatchService = _chunk4ROBZFL6cjs.makeNodePatchService; exports.makeOpenAICompatibleLLM = _chunk4ROBZFL6cjs.makeOpenAICompatibleLLM; exports.nextContextDiscoveryAction = _chunk4ROBZFL6cjs.nextContextDiscoveryAction; exports.nextProjectProbeAction = _chunk4ROBZFL6cjs.nextProjectProbeAction; exports.nextUnrunValidationCommand = _chunk4ROBZFL6cjs.nextUnrunValidationCommand; exports.nowMillis = _chunk4ROBZFL6cjs.nowMillis; exports.observationEventFor = _chunk4ROBZFL6cjs.observationEventFor; exports.observationStatus = _chunk4ROBZFL6cjs.observationStatus; exports.parseProjectPackageJson = _chunk4ROBZFL6cjs.parseProjectPackageJson; exports.patchQualitySummary = _chunk4ROBZFL6cjs.patchQualitySummary; exports.patchRepairAttemptsUsed = _chunk4ROBZFL6cjs.patchRepairAttemptsUsed; exports.patchValidationStatus = _chunk4ROBZFL6cjs.patchValidationStatus; exports.projectProfileProbePending = _chunk4ROBZFL6cjs.projectProfileProbePending; exports.redactText = _chunk4ROBZFL6cjs.redactText; exports.reduceAgentState = _chunk4ROBZFL6cjs.reduceAgentState; exports.responseLanguageName = _chunk4ROBZFL6cjs.responseLanguageName; exports.retry = _chunk4ROBZFL6cjs.retry; exports.rollbackSafetySummary = _chunk4ROBZFL6cjs.rollbackSafetySummary; exports.runAgent = _chunk4ROBZFL6cjs.runAgent; exports.runStatusFor = _chunk4ROBZFL6cjs.runStatusFor; exports.shouldContinueRollbackStack = _chunk4ROBZFL6cjs.shouldContinueRollbackStack; exports.sleep = _chunk4ROBZFL6cjs.sleep; exports.spanishLike = _chunk4ROBZFL6cjs.spanishLike; exports.splitCommand = _chunk4ROBZFL6cjs.splitCommand; exports.summarizeAgentAction = _chunk4ROBZFL6cjs.summarizeAgentAction; exports.summarizeAgentObservation = _chunk4ROBZFL6cjs.summarizeAgentObservation; exports.summarizeContextDiscovery = _chunk4ROBZFL6cjs.summarizeContextDiscovery; exports.timeout = _chunk4ROBZFL6cjs.timeout; exports.unappliedPatchStack = _chunk4ROBZFL6cjs.unappliedPatchStack; exports.workspaceValidationStatus = _chunk4ROBZFL6cjs.workspaceValidationStatus;
157
+ exports.AGENT_CONFIG_FILE_NAMES = _chunk2SLT3X6Gcjs.AGENT_CONFIG_FILE_NAMES; exports.NodeShell = _chunk2SLT3X6Gcjs.NodeShell; exports.PROJECT_LOCKFILE_PROBES = _chunk2SLT3X6Gcjs.PROJECT_LOCKFILE_PROBES; exports.PROJECT_PROFILE_PROBES = _chunk2SLT3X6Gcjs.PROJECT_PROFILE_PROBES; exports.autoApproveApprovals = _chunk2SLT3X6Gcjs.autoApproveApprovals; exports.canAutoRollback = _chunk2SLT3X6Gcjs.canAutoRollback; exports.canRequestPatchRepair = _chunk2SLT3X6Gcjs.canRequestPatchRepair; exports.commandForScript = _chunk2SLT3X6Gcjs.commandForScript; exports.decideNextAction = _chunk2SLT3X6Gcjs.decideNextAction; exports.defaultPermissions = _chunk2SLT3X6Gcjs.defaultPermissions; exports.deriveContextSearchQueries = _chunk2SLT3X6Gcjs.deriveContextSearchQueries; exports.describeCommandDiscovery = _chunk2SLT3X6Gcjs.describeCommandDiscovery; exports.describeContextDiscovery = _chunk2SLT3X6Gcjs.describeContextDiscovery; exports.describeLanguagePolicy = _chunk2SLT3X6Gcjs.describeLanguagePolicy; exports.describePatchQuality = _chunk2SLT3X6Gcjs.describePatchQuality; exports.describeProjectProfile = _chunk2SLT3X6Gcjs.describeProjectProfile; exports.describeRollbackSafety = _chunk2SLT3X6Gcjs.describeRollbackSafety; exports.discoverNodeWorkspaceRoot = _chunk2SLT3X6Gcjs.discoverNodeWorkspaceRoot; exports.discoverPackageManager = _chunk2SLT3X6Gcjs.discoverPackageManager; exports.discoverProjectProfile = _chunk2SLT3X6Gcjs.discoverProjectProfile; exports.discoverValidationCommands = _chunk2SLT3X6Gcjs.discoverValidationCommands; exports.emitAgentEvent = _chunk2SLT3X6Gcjs.emitAgentEvent; exports.emitAgentEvents = _chunk2SLT3X6Gcjs.emitAgentEvents; exports.errorEventFor = _chunk2SLT3X6Gcjs.errorEventFor; exports.extractLikelyFilePaths = _chunk2SLT3X6Gcjs.extractLikelyFilePaths; exports.extractPatchPaths = _chunk2SLT3X6Gcjs.extractPatchPaths; exports.extractUnifiedDiff = _chunk2SLT3X6Gcjs.extractUnifiedDiff; exports.goalForAgentPreset = _chunk2SLT3X6Gcjs.goalForAgentPreset; exports.inferUserLanguage = _chunk2SLT3X6Gcjs.inferUserLanguage; exports.initialAgentState = _chunk2SLT3X6Gcjs.initialAgentState; exports.invokeAction = _chunk2SLT3X6Gcjs.invokeAction; exports.isAgentConfigApprovalMode = _chunk2SLT3X6Gcjs.isAgentConfigApprovalMode; exports.isAgentConfigLLMProvider = _chunk2SLT3X6Gcjs.isAgentConfigLLMProvider; exports.isAgentConfigMode = _chunk2SLT3X6Gcjs.isAgentConfigMode; exports.isAgentPreset = _chunk2SLT3X6Gcjs.isAgentPreset; exports.isRedactionEnabled = _chunk2SLT3X6Gcjs.isRedactionEnabled; exports.isTerminal = _chunk2SLT3X6Gcjs.isTerminal; exports.latestUnappliedPatch = _chunk2SLT3X6Gcjs.latestUnappliedPatch; exports.loadNodeAgentConfig = _chunk2SLT3X6Gcjs.loadNodeAgentConfig; exports.makeAutoDenyApprovals = _chunk2SLT3X6Gcjs.makeAutoDenyApprovals; exports.makeConfiguredPermissions = _chunk2SLT3X6Gcjs.makeConfiguredPermissions; exports.makeFakeLLM = _chunk2SLT3X6Gcjs.makeFakeLLM; exports.makeGoogleGenerativeAILLM = _chunk2SLT3X6Gcjs.makeGoogleGenerativeAILLM; exports.makeNodeFileSystem = _chunk2SLT3X6Gcjs.makeNodeFileSystem; exports.makeNodePatchService = _chunk2SLT3X6Gcjs.makeNodePatchService; exports.makeOpenAICompatibleLLM = _chunk2SLT3X6Gcjs.makeOpenAICompatibleLLM; exports.nextContextDiscoveryAction = _chunk2SLT3X6Gcjs.nextContextDiscoveryAction; exports.nextProjectProbeAction = _chunk2SLT3X6Gcjs.nextProjectProbeAction; exports.nextUnrunValidationCommand = _chunk2SLT3X6Gcjs.nextUnrunValidationCommand; exports.nowMillis = _chunk2SLT3X6Gcjs.nowMillis; exports.observationEventFor = _chunk2SLT3X6Gcjs.observationEventFor; exports.observationStatus = _chunk2SLT3X6Gcjs.observationStatus; exports.parseProjectPackageJson = _chunk2SLT3X6Gcjs.parseProjectPackageJson; exports.patchQualitySummary = _chunk2SLT3X6Gcjs.patchQualitySummary; exports.patchRepairAttemptsUsed = _chunk2SLT3X6Gcjs.patchRepairAttemptsUsed; exports.patchValidationStatus = _chunk2SLT3X6Gcjs.patchValidationStatus; exports.projectProfileProbePending = _chunk2SLT3X6Gcjs.projectProfileProbePending; exports.redactText = _chunk2SLT3X6Gcjs.redactText; exports.reduceAgentState = _chunk2SLT3X6Gcjs.reduceAgentState; exports.responseLanguageName = _chunk2SLT3X6Gcjs.responseLanguageName; exports.retry = _chunk2SLT3X6Gcjs.retry; exports.rollbackSafetySummary = _chunk2SLT3X6Gcjs.rollbackSafetySummary; exports.runAgent = _chunk2SLT3X6Gcjs.runAgent; exports.runStatusFor = _chunk2SLT3X6Gcjs.runStatusFor; exports.shouldContinueRollbackStack = _chunk2SLT3X6Gcjs.shouldContinueRollbackStack; exports.sleep = _chunk2SLT3X6Gcjs.sleep; exports.spanishLike = _chunk2SLT3X6Gcjs.spanishLike; exports.splitCommand = _chunk2SLT3X6Gcjs.splitCommand; exports.summarizeAgentAction = _chunk2SLT3X6Gcjs.summarizeAgentAction; exports.summarizeAgentObservation = _chunk2SLT3X6Gcjs.summarizeAgentObservation; exports.summarizeContextDiscovery = _chunk2SLT3X6Gcjs.summarizeContextDiscovery; exports.timeout = _chunk2SLT3X6Gcjs.timeout; exports.unappliedPatchStack = _chunk2SLT3X6Gcjs.unappliedPatchStack; exports.workspaceValidationStatus = _chunk2SLT3X6Gcjs.workspaceValidationStatus;
@@ -1,4 +1,4 @@
1
- import { A as Async, f as Runtime, S as Scope } from '../effect-DIUHZ9IN.js';
1
+ import { A as Async, b as Runtime, S as Scope } from '../effect-CtUDl5M5.js';
2
2
 
3
3
  type AgentMode = "read-only" | "propose" | "write" | "autonomous";
4
4
  type AgentPackageManager = "npm" | "pnpm" | "yarn" | "bun";
@@ -73,12 +73,11 @@ import {
73
73
  timeout,
74
74
  unappliedPatchStack,
75
75
  workspaceValidationStatus
76
- } from "../chunk-52OB2ROS.js";
76
+ } from "../chunk-ITG6I7ZS.js";
77
77
  import "../chunk-UCUBNWM2.js";
78
- import "../chunk-L2SYFEBS.js";
79
- import "../chunk-FH2X7BVP.js";
78
+ import "../chunk-XSAHV5HQ.js";
80
79
  import "../chunk-UB4B6OFY.js";
81
- import "../chunk-C3MDXTRZ.js";
80
+ import "../chunk-HCJ4S3YB.js";
82
81
  import "../chunk-3RG5ZIWI.js";
83
82
  export {
84
83
  AGENT_CONFIG_FILE_NAMES,
@@ -73,12 +73,11 @@ import {
73
73
  timeout,
74
74
  unappliedPatchStack,
75
75
  workspaceValidationStatus
76
- } from "../chunk-MBEJI5HF.mjs";
76
+ } from "../chunk-R6WDSZA6.mjs";
77
77
  import "../chunk-B5JD23U7.mjs";
78
- import "../chunk-A2OM6NEH.mjs";
79
- import "../chunk-GYM3LLGS.mjs";
78
+ import "../chunk-2QNREG6K.mjs";
80
79
  import "../chunk-36I3M4UC.mjs";
81
- import "../chunk-DNFJLJMW.mjs";
80
+ import "../chunk-6MLAZPBL.mjs";
82
81
  import "../chunk-Y6FXYEAI.mjs";
83
82
  export {
84
83
  AGENT_CONFIG_FILE_NAMES,
@@ -2,12 +2,15 @@ import {
2
2
  Async,
3
3
  Cause,
4
4
  Exit,
5
- asyncEffect
5
+ asyncEffect,
6
+ asyncFlatMap,
7
+ asyncFold,
8
+ unit
6
9
  } from "./chunk-36I3M4UC.mjs";
7
10
  import {
8
11
  Schema,
9
12
  parseConfig
10
- } from "./chunk-DNFJLJMW.mjs";
13
+ } from "./chunk-6MLAZPBL.mjs";
11
14
 
12
15
  // src/core/runtime/ringBuffer.ts
13
16
  var PushStatus = /* @__PURE__ */ ((PushStatus3) => {
@@ -2978,7 +2981,7 @@ var Runtime = class _Runtime {
2978
2981
  if (this.hooks !== NoopHooks) return false;
2979
2982
  if (getCurrentFiber() !== null) return false;
2980
2983
  if (this.scheduler !== globalScheduler) return false;
2981
- if (this.lane !== void 0 || this.inferLane) return false;
2984
+ if (this.inferLane) return false;
2982
2985
  if (this.engineMode !== "ts") return false;
2983
2986
  new NativeTopLevelRunner(this, effect, cb).start();
2984
2987
  return true;
@@ -3137,7 +3140,7 @@ var NativeTopLevelRunner = class {
3137
3140
  syncExit = exit;
3138
3141
  return;
3139
3142
  }
3140
- queueMicrotask(() => this.resumeAsync(exit));
3143
+ this.resumeAsync(exit);
3141
3144
  };
3142
3145
  try {
3143
3146
  current.register(this.runtime.env, resume);
@@ -4035,6 +4038,183 @@ var JsFiberEngine = class {
4035
4038
  }
4036
4039
  };
4037
4040
 
4041
+ // src/core/runtime/scope.ts
4042
+ var nextScopeId = 1;
4043
+ function awaitAll(fibers) {
4044
+ return asyncEffect((_env, cb) => {
4045
+ let remaining = fibers.length;
4046
+ if (remaining === 0) {
4047
+ cb({ _tag: "Success", value: void 0 });
4048
+ return;
4049
+ }
4050
+ for (const f of fibers) {
4051
+ f.join(() => {
4052
+ remaining -= 1;
4053
+ if (remaining === 0) cb({ _tag: "Success", value: void 0 });
4054
+ });
4055
+ }
4056
+ });
4057
+ }
4058
+ var Scope = class _Scope {
4059
+ constructor(runtime, parentScopeId) {
4060
+ this.runtime = runtime;
4061
+ this.parentScopeId = parentScopeId;
4062
+ this.id = nextScopeId++;
4063
+ const inferredParent = this.parentScopeId ?? getCurrentFiber()?.scopeId;
4064
+ if (this.runtime.hasActiveHooks()) {
4065
+ this.runtime.emit({
4066
+ type: "scope.open",
4067
+ scopeId: this.id,
4068
+ parentScopeId: inferredParent
4069
+ });
4070
+ }
4071
+ }
4072
+ runtime;
4073
+ parentScopeId;
4074
+ id;
4075
+ closed = false;
4076
+ children = /* @__PURE__ */ new Set();
4077
+ subScopes = /* @__PURE__ */ new Set();
4078
+ finalizers = [];
4079
+ /** registra un finalizer (LIFO) */
4080
+ addFinalizer(f) {
4081
+ if (this.closed) {
4082
+ throw new Error("Trying to add finalizer to closed scope");
4083
+ }
4084
+ this.finalizers.push(f);
4085
+ }
4086
+ /** crea un sub scope (mismo runtime) */
4087
+ subScope() {
4088
+ if (this.closed) throw new Error("Scope closed");
4089
+ const s = new _Scope(this.runtime, this.id);
4090
+ this.subScopes.add(s);
4091
+ return s;
4092
+ }
4093
+ /** ✅ fork en este scope */
4094
+ fork(eff) {
4095
+ if (this.closed) throw new Error("Scope closed");
4096
+ const f = this.runtime.fork(eff, this.id);
4097
+ this.children.add(f);
4098
+ f.join(() => this.children.delete(f));
4099
+ return f;
4100
+ }
4101
+ /** close fire-and-forget (no bloquea) */
4102
+ close(exit = { _tag: "Success", value: void 0 }) {
4103
+ this.runtime.fork(this.closeAsync(exit));
4104
+ }
4105
+ /** Emit the scope.close event if hooks are active. */
4106
+ emitCloseEvent(exit) {
4107
+ if (this.runtime.hasActiveHooks()) {
4108
+ const status = exit._tag === "Success" ? "success" : Cause.isInterruptedOnly(exit.cause) ? "interrupted" : "failure";
4109
+ const failure = exit._tag === "Failure" ? Cause.firstFailure(exit.cause) : void 0;
4110
+ this.runtime.emit({
4111
+ type: "scope.close",
4112
+ scopeId: this.id,
4113
+ status,
4114
+ error: failure?._tag === "Some" ? failure.value : exit._tag === "Failure" ? exit.cause : void 0
4115
+ });
4116
+ }
4117
+ }
4118
+ /**
4119
+ * Build an effect that executes finalizers in LIFO order.
4120
+ *
4121
+ * Optimization over the original: instead of wrapping every finalizer in
4122
+ * `asyncFold(fin(exit), () => unit(), () => unit())` which creates 3 effect
4123
+ * nodes per finalizer (Fold + 2 Succeed), we use a single Sync thunk per
4124
+ * finalizer that catches errors inline. When the finalizer returns a
4125
+ * Succeed effect (like `unit()`), the Sync thunk completes without creating
4126
+ * additional effect nodes.
4127
+ */
4128
+ buildFinalizerEffect(exit) {
4129
+ const fins = this.finalizers;
4130
+ if (fins.length === 0) return unit();
4131
+ let chain = unit();
4132
+ for (let i = fins.length - 1; i >= 0; i--) {
4133
+ const fin = fins[i];
4134
+ chain = asyncFlatMap(chain, () => {
4135
+ let result;
4136
+ try {
4137
+ result = fin(exit);
4138
+ } catch {
4139
+ return unit();
4140
+ }
4141
+ if (result._tag === "Succeed") {
4142
+ return unit();
4143
+ }
4144
+ return asyncFold(
4145
+ result,
4146
+ () => unit(),
4147
+ () => unit()
4148
+ );
4149
+ });
4150
+ }
4151
+ return chain;
4152
+ }
4153
+ closeAsync(exit = { _tag: "Success", value: void 0 }, opts = { awaitChildren: true }) {
4154
+ return asyncFlatMap(
4155
+ unit(),
4156
+ () => asyncEffect((env, cb) => {
4157
+ if (this.closed) {
4158
+ cb({ _tag: "Success", value: void 0 });
4159
+ return;
4160
+ }
4161
+ this.closed = true;
4162
+ const children = Array.from(this.children);
4163
+ const subScopes = Array.from(this.subScopes);
4164
+ for (const child of children) {
4165
+ child.interrupt();
4166
+ }
4167
+ const closeSubs = subScopes.reduceRight(
4168
+ (acc, s) => asyncFlatMap(acc, () => s.closeAsync(exit, opts)),
4169
+ unit()
4170
+ );
4171
+ const runFinalizers = this.buildFinalizerEffect(exit);
4172
+ const needsAwait = opts.awaitChildren && children.length > 0;
4173
+ const awaitChildrenEff = needsAwait ? awaitAll(children) : unit();
4174
+ const hasSubScopes = subScopes.length > 0;
4175
+ const hasNoFinalizers = this.finalizers.length === 0;
4176
+ if (!hasSubScopes && !needsAwait && hasNoFinalizers) {
4177
+ this.emitCloseEvent(exit);
4178
+ cb({ _tag: "Success", value: void 0 });
4179
+ return;
4180
+ }
4181
+ const all = asyncFlatMap(closeSubs, () => asyncFlatMap(awaitChildrenEff, () => runFinalizers));
4182
+ this.runtime.fork(all).join(() => {
4183
+ this.emitCloseEvent(exit);
4184
+ cb({ _tag: "Success", value: void 0 });
4185
+ });
4186
+ })
4187
+ );
4188
+ }
4189
+ };
4190
+ function withScopeAsync(runtime, f) {
4191
+ return asyncEffect((_env, cb) => {
4192
+ const scope = new Scope(runtime);
4193
+ let done = false;
4194
+ const completeAfterClose = (exit) => {
4195
+ runtime.fork(scope.closeAsync(exit)).join(() => {
4196
+ if (done) return;
4197
+ done = true;
4198
+ cb(exit);
4199
+ });
4200
+ };
4201
+ const fiber = runtime.fork(f(scope));
4202
+ fiber.join(completeAfterClose);
4203
+ return () => {
4204
+ if (done) return;
4205
+ fiber.interrupt();
4206
+ runtime.fork(scope.closeAsync(Exit.failCause(Cause.interrupt())));
4207
+ };
4208
+ });
4209
+ }
4210
+ function withScope(runtime, f) {
4211
+ return withScopeAsync(runtime, (scope) => {
4212
+ const out = f(scope);
4213
+ if (out && typeof out === "object" && "_tag" in out) return out;
4214
+ return unit();
4215
+ });
4216
+ }
4217
+
4038
4218
  export {
4039
4219
  PushStatus,
4040
4220
  RingBuffer,
@@ -4085,5 +4265,8 @@ export {
4085
4265
  RuntimeFiber,
4086
4266
  getCurrentFiber,
4087
4267
  unsafeGetCurrentRuntime,
4088
- withCurrentFiber
4268
+ withCurrentFiber,
4269
+ Scope,
4270
+ withScopeAsync,
4271
+ withScope
4089
4272
  };