brass-runtime 1.19.0 → 1.19.2

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 (78) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/agent/cli/main.cjs +30 -30
  3. package/dist/agent/cli/main.js +2 -2
  4. package/dist/agent/cli/main.mjs +2 -2
  5. package/dist/agent/index.cjs +3 -3
  6. package/dist/agent/index.d.ts +1 -1
  7. package/dist/agent/index.js +2 -2
  8. package/dist/agent/index.mjs +2 -2
  9. package/dist/{chunk-GOEO763K.cjs → chunk-2XXQ3NVT.cjs} +19 -19
  10. package/dist/{chunk-5RVHSBJ6.mjs → chunk-5X3MPWTR.mjs} +275 -39
  11. package/dist/{chunk-2R3RVNS2.js → chunk-6AGAZD32.js} +6 -6
  12. package/dist/{chunk-BLXBZ6RE.mjs → chunk-6BNZS2A4.mjs} +1 -1
  13. package/dist/{chunk-EXBGIC66.js → chunk-6W5DC3TX.js} +1 -1
  14. package/dist/{chunk-MUMBUXU6.mjs → chunk-BFNBU47C.mjs} +22 -6
  15. package/dist/{chunk-JWFOWPMB.js → chunk-BHX4MD35.js} +5 -5
  16. package/dist/{chunk-OO7BGCC3.cjs → chunk-CXWJII2N.cjs} +13 -13
  17. package/dist/{chunk-Z2YIDHRI.cjs → chunk-ENMKEX3N.cjs} +5 -5
  18. package/dist/{chunk-RZGB3DXR.js → chunk-HKLZJ5UK.js} +275 -39
  19. package/dist/{chunk-HW2CLRJ3.mjs → chunk-IA6BDGXW.mjs} +6 -6
  20. package/dist/{chunk-MA74OYCI.cjs → chunk-IHY2EJTT.cjs} +6 -6
  21. package/dist/{chunk-AQQQFNYD.mjs → chunk-IWAQQDYE.mjs} +1 -1
  22. package/dist/{chunk-C3CWI42G.js → chunk-J4F5KC3U.js} +1 -1
  23. package/dist/{chunk-ZDZNV6NA.cjs → chunk-JKHBEWQA.cjs} +23 -7
  24. package/dist/{chunk-5UBJT4RW.mjs → chunk-JM7WMSRR.mjs} +3 -3
  25. package/dist/{chunk-YQWZ7FZX.cjs → chunk-JQCQWO47.cjs} +5 -5
  26. package/dist/{chunk-B2VXVNIS.js → chunk-LI7WUVJN.js} +1 -1
  27. package/dist/{chunk-FC5N5QHJ.js → chunk-NWONRWBT.js} +2 -2
  28. package/dist/{chunk-H4ZRUQZL.js → chunk-PG6CHG34.js} +3 -3
  29. package/dist/{chunk-NQW3YUFN.cjs → chunk-QAHW7S3Q.cjs} +18 -18
  30. package/dist/{chunk-GXOIUBKE.js → chunk-RZQK32C6.js} +2 -2
  31. package/dist/{chunk-EKLEDIVJ.mjs → chunk-S6KSHYAT.mjs} +2 -2
  32. package/dist/{chunk-URVS2OE2.mjs → chunk-SCHM2MDA.mjs} +2 -2
  33. package/dist/{chunk-A6EG5WRL.js → chunk-TAPB4NN5.js} +2 -2
  34. package/dist/{chunk-APQBU7TM.js → chunk-TN2P7RNK.js} +22 -6
  35. package/dist/{chunk-QBVS3UYN.cjs → chunk-TWEHIAUE.cjs} +54 -54
  36. package/dist/{chunk-7FZUTJM3.cjs → chunk-UOKXJQAI.cjs} +380 -144
  37. package/dist/{chunk-FYWWU3Z7.cjs → chunk-VXNWVAIG.cjs} +2 -2
  38. package/dist/{chunk-KAPZHDO4.mjs → chunk-WA65XP2P.mjs} +1 -1
  39. package/dist/{chunk-4PKBNG2H.js → chunk-XO3TDAJE.js} +1 -1
  40. package/dist/{chunk-KDXNWGPB.mjs → chunk-XRRC5BBM.mjs} +1 -1
  41. package/dist/{chunk-DV644N7P.cjs → chunk-ZJC3JZIE.cjs} +16 -16
  42. package/dist/{chunk-3NKXUX4T.mjs → chunk-ZXLETUGQ.mjs} +2 -2
  43. package/dist/{chunk-OX6MF7SZ.mjs → chunk-ZXXOXB3T.mjs} +5 -5
  44. package/dist/{chunk-6STX4PS3.cjs → chunk-ZZ2CMYJL.cjs} +13 -13
  45. package/dist/core/index.cjs +9 -7
  46. package/dist/core/index.d.ts +6 -6
  47. package/dist/core/index.js +8 -6
  48. package/dist/core/index.mjs +8 -6
  49. package/dist/{defaultClient-Cid0JoUR.d.ts → defaultClient-hyVSNzSJ.d.ts} +3 -3
  50. package/dist/{effect-DnGUuhw6.d.ts → effect-DbEMiMvv.d.ts} +8 -1
  51. package/dist/http/index.cjs +48 -48
  52. package/dist/http/index.d.ts +8 -8
  53. package/dist/http/index.js +6 -6
  54. package/dist/http/index.mjs +6 -6
  55. package/dist/http/testing.cjs +8 -8
  56. package/dist/http/testing.d.ts +4 -4
  57. package/dist/http/testing.js +4 -4
  58. package/dist/http/testing.mjs +4 -4
  59. package/dist/index.cjs +87 -85
  60. package/dist/index.d.ts +7 -7
  61. package/dist/index.js +9 -7
  62. package/dist/index.mjs +9 -7
  63. package/dist/{layer-D2LFcBVx.d.ts → layer-CsNGeVee.d.ts} +1 -1
  64. package/dist/observability/index.cjs +9 -9
  65. package/dist/observability/index.d.ts +7 -7
  66. package/dist/observability/index.js +8 -8
  67. package/dist/observability/index.mjs +8 -8
  68. package/dist/perf/cli.cjs +25 -25
  69. package/dist/perf/cli.js +10 -10
  70. package/dist/perf/cli.mjs +10 -10
  71. package/dist/perf/index.cjs +12 -12
  72. package/dist/perf/index.js +10 -10
  73. package/dist/perf/index.mjs +10 -10
  74. package/dist/{server-Bf1zNYZk.d.ts → server-BKKuzAW9.d.ts} +4 -4
  75. package/dist/{stream-I7bkvF7a.d.ts → stream-B8c_UKZq.d.ts} +1 -1
  76. package/dist/{tracer-DF83nLn6.d.ts → tracer-CS3yOXZx.d.ts} +2 -2
  77. package/dist/{tracing-CWV4gT0u.d.ts → tracing-DIAUf2x8.d.ts} +1 -1
  78. package/package.json +1 -1
@@ -3,18 +3,20 @@ import {
3
3
  } from "./chunk-TRM4JUZQ.js";
4
4
  import {
5
5
  streamFromReadableStream
6
- } from "./chunk-4PKBNG2H.js";
6
+ } from "./chunk-XO3TDAJE.js";
7
7
  import {
8
8
  layerEffect,
9
9
  makeScheduleDriver,
10
10
  makeServiceTag,
11
11
  sleep
12
- } from "./chunk-EXBGIC66.js";
12
+ } from "./chunk-6W5DC3TX.js";
13
13
  import {
14
14
  fromPromiseAbortable,
15
+ recordAbortablePromiseFinish,
16
+ recordAbortablePromiseStart,
15
17
  resolveWasmModule,
16
18
  toPromise
17
- } from "./chunk-APQBU7TM.js";
19
+ } from "./chunk-TN2P7RNK.js";
18
20
  import {
19
21
  Cause,
20
22
  asyncEffect,
@@ -3182,6 +3184,275 @@ var noopSignal = (() => {
3182
3184
  globalThis.__brassNoopSignal = s;
3183
3185
  return s;
3184
3186
  })();
3187
+ var PoolRequestState = class {
3188
+ constructor(req, url, transport, metrics, pool, adaptiveLimiter, timerWheel, timeoutMs, env, cb, previousSignal, controller, signal, label, startedAt) {
3189
+ this.req = req;
3190
+ this.url = url;
3191
+ this.transport = transport;
3192
+ this.metrics = metrics;
3193
+ this.pool = pool;
3194
+ this.adaptiveLimiter = adaptiveLimiter;
3195
+ this.timerWheel = timerWheel;
3196
+ this.timeoutMs = timeoutMs;
3197
+ this.env = env;
3198
+ this.cb = cb;
3199
+ this.previousSignal = previousSignal;
3200
+ this.controller = controller;
3201
+ this.signal = signal;
3202
+ this.label = label;
3203
+ this.startedAt = startedAt;
3204
+ }
3205
+ req;
3206
+ url;
3207
+ transport;
3208
+ metrics;
3209
+ pool;
3210
+ adaptiveLimiter;
3211
+ timerWheel;
3212
+ timeoutMs;
3213
+ env;
3214
+ cb;
3215
+ previousSignal;
3216
+ controller;
3217
+ signal;
3218
+ label;
3219
+ startedAt;
3220
+ done = false;
3221
+ cancelInner = void 0;
3222
+ timerHandle = void 0;
3223
+ timeoutHandle = void 0;
3224
+ lease = void 0;
3225
+ finish(outcome, exit, error) {
3226
+ if (this.done) return;
3227
+ this.done = true;
3228
+ if (this.timerHandle) {
3229
+ this.timerHandle.cancel();
3230
+ this.timerHandle = void 0;
3231
+ }
3232
+ if (this.timeoutHandle !== void 0) {
3233
+ clearTimeout(this.timeoutHandle);
3234
+ this.timeoutHandle = void 0;
3235
+ }
3236
+ if (this.previousSignal) this.previousSignal.removeEventListener("abort", this.boundAbortFromPrevious);
3237
+ this.cancelInner = void 0;
3238
+ recordAbortablePromiseFinish(this.label, outcome);
3239
+ this.metrics.onFinish({
3240
+ label: this.label,
3241
+ outcome,
3242
+ durationMs: Math.round(performance.now() - this.startedAt),
3243
+ error
3244
+ });
3245
+ this.cb(exit);
3246
+ }
3247
+ finishFailure(error, outcome = "failure") {
3248
+ this.finish(outcome, { _tag: "Failure", cause: Cause.fail(error) }, error);
3249
+ }
3250
+ abortCurrent(reason) {
3251
+ if (!this.controller) return;
3252
+ try {
3253
+ this.controller.abort(reason);
3254
+ } catch {
3255
+ this.controller.abort();
3256
+ }
3257
+ }
3258
+ /**
3259
+ * Bound reference for addEventListener/removeEventListener.
3260
+ * Only allocated when previousSignal is present (not on the hot path).
3261
+ */
3262
+ boundAbortFromPrevious = void 0;
3263
+ abortFromPrevious() {
3264
+ const error = this.previousSignal ? abortErrorForSignal(this.previousSignal) : { _tag: "Abort" };
3265
+ this.abortCurrent(this.previousSignal?.reason);
3266
+ const cancel = this.cancelInner;
3267
+ this.cancelInner = void 0;
3268
+ if (this.lease) {
3269
+ releaseFailure(this.lease, this.adaptiveLimiter);
3270
+ this.lease = void 0;
3271
+ }
3272
+ queueMicrotask(() => {
3273
+ this.finishFailure(error);
3274
+ cancel?.();
3275
+ });
3276
+ }
3277
+ runTransportInner() {
3278
+ const { transport, req, url, signal, env } = this;
3279
+ try {
3280
+ const effect = transport({ request: req, url, signal });
3281
+ if (effect._tag === "Succeed") {
3282
+ if (this.lease) releaseSuccess(this.lease, this.adaptiveLimiter, effect.value);
3283
+ this.finish("success", { _tag: "Success", value: effect.value });
3284
+ } else if (effect._tag === "Fail") {
3285
+ if (this.lease) releaseFailure(this.lease, this.adaptiveLimiter);
3286
+ this.finishFailure(effect.error);
3287
+ } else if (effect._tag === "Async") {
3288
+ try {
3289
+ const cancel = effect.register(env, (exit) => {
3290
+ if (this.done) return;
3291
+ this.cancelInner = void 0;
3292
+ if (exit._tag === "Success") {
3293
+ if (this.lease) releaseSuccess(this.lease, this.adaptiveLimiter, exit.value);
3294
+ this.finish("success", exit);
3295
+ } else {
3296
+ if (this.lease) releaseFailure(this.lease, this.adaptiveLimiter);
3297
+ this.finish("failure", exit, exitError(exit));
3298
+ }
3299
+ });
3300
+ if (!this.done) this.cancelInner = typeof cancel === "function" ? cancel : void 0;
3301
+ } catch (error) {
3302
+ if (this.lease) releaseFailure(this.lease, this.adaptiveLimiter);
3303
+ this.finishFailure(normalizeHttpError(error));
3304
+ }
3305
+ } else {
3306
+ const innerCancel = registerHttpEffect(
3307
+ effect,
3308
+ env,
3309
+ (exit) => {
3310
+ if (this.done) return;
3311
+ this.cancelInner = void 0;
3312
+ if (exit._tag === "Success") {
3313
+ if (this.lease) releaseSuccess(this.lease, this.adaptiveLimiter, exit.value);
3314
+ this.finish("success", exit);
3315
+ } else {
3316
+ if (this.lease) releaseFailure(this.lease, this.adaptiveLimiter);
3317
+ this.finish("failure", exit, exitError(exit));
3318
+ }
3319
+ }
3320
+ );
3321
+ if (!this.done) this.cancelInner = innerCancel;
3322
+ }
3323
+ } catch (error) {
3324
+ if (this.lease) releaseFailure(this.lease, this.adaptiveLimiter);
3325
+ this.finishFailure(normalizeHttpError(error));
3326
+ }
3327
+ }
3328
+ };
3329
+ var runPoolTransport = (req, url, transport, metrics, pool, adaptiveLimiter, timerWheel, timeoutMs) => ({
3330
+ _tag: "Async",
3331
+ register: (env, cb) => {
3332
+ const previousSignal = req.init?.signal;
3333
+ const controller = new AbortController();
3334
+ const signal = controller.signal;
3335
+ const label = fetchLabel(req, url);
3336
+ const startedAt = performance.now();
3337
+ const state = new PoolRequestState(
3338
+ req,
3339
+ url,
3340
+ transport,
3341
+ metrics,
3342
+ pool,
3343
+ adaptiveLimiter,
3344
+ timerWheel,
3345
+ timeoutMs,
3346
+ env,
3347
+ cb,
3348
+ previousSignal,
3349
+ controller,
3350
+ signal,
3351
+ label,
3352
+ startedAt
3353
+ );
3354
+ recordAbortablePromiseStart(label);
3355
+ metrics.onStart();
3356
+ if (previousSignal) {
3357
+ state.boundAbortFromPrevious = () => state.abortFromPrevious();
3358
+ if (previousSignal.aborted) {
3359
+ state.abortFromPrevious();
3360
+ return () => void 0;
3361
+ }
3362
+ previousSignal.addEventListener("abort", state.boundAbortFromPrevious, ONCE_OPTIONS);
3363
+ }
3364
+ if (timeoutMs !== void 0 && timeoutMs > 0) {
3365
+ const onTimeout = () => {
3366
+ const reason = timeoutReason(req, url, timeoutMs);
3367
+ if (state.lease) {
3368
+ releaseFailure(state.lease, adaptiveLimiter);
3369
+ state.lease = void 0;
3370
+ }
3371
+ const cancel = state.cancelInner;
3372
+ state.cancelInner = void 0;
3373
+ state.finishFailure(reason, "timeout");
3374
+ state.abortCurrent(reason);
3375
+ cancel?.();
3376
+ };
3377
+ if (timerWheel) {
3378
+ state.timerHandle = timerWheel.schedule(timeoutMs, onTimeout, startedAt);
3379
+ } else {
3380
+ state.timeoutHandle = setTimeout(onTimeout, timeoutMs);
3381
+ }
3382
+ }
3383
+ if (adaptiveLimiter) {
3384
+ const key = resolveHttpPoolKey(adaptiveLimiter.keyResolver, req, url);
3385
+ const syncLease = adaptiveLimiter.tryAcquireSync(key, signal);
3386
+ if (syncLease) {
3387
+ state.lease = syncLease;
3388
+ } else {
3389
+ adaptiveLimiter.acquire(key, signal, { priority: requestPriority(req) }).then(
3390
+ (asyncLease) => {
3391
+ if (state.done) {
3392
+ asyncLease.release(0);
3393
+ return;
3394
+ }
3395
+ state.lease = asyncLease;
3396
+ state.runTransportInner();
3397
+ },
3398
+ (err) => {
3399
+ if (state.done) return;
3400
+ state.finishFailure(normalizeHttpError(err));
3401
+ }
3402
+ );
3403
+ return () => {
3404
+ if (state.done) return;
3405
+ const cancel = state.cancelInner;
3406
+ state.cancelInner = void 0;
3407
+ state.abortCurrent();
3408
+ if (state.lease) releaseFailure(state.lease, adaptiveLimiter);
3409
+ state.finish("interrupt", { _tag: "Failure", cause: Cause.interrupt() });
3410
+ cancel?.();
3411
+ };
3412
+ }
3413
+ } else if (pool) {
3414
+ const key = resolveHttpPoolKey(pool.keyResolver, req, url);
3415
+ const syncLease = pool.tryAcquireSync(key, signal);
3416
+ if (syncLease) {
3417
+ state.lease = syncLease;
3418
+ } else {
3419
+ pool.acquire(key, signal).then(
3420
+ (asyncLease) => {
3421
+ if (state.done) {
3422
+ asyncLease.release();
3423
+ return;
3424
+ }
3425
+ state.lease = asyncLease;
3426
+ state.runTransportInner();
3427
+ },
3428
+ (err) => {
3429
+ if (state.done) return;
3430
+ state.finishFailure(normalizeHttpError(err));
3431
+ }
3432
+ );
3433
+ return () => {
3434
+ if (state.done) return;
3435
+ const cancel = state.cancelInner;
3436
+ state.cancelInner = void 0;
3437
+ state.abortCurrent();
3438
+ if (state.lease) releaseFailure(state.lease, void 0);
3439
+ state.finish("interrupt", { _tag: "Failure", cause: Cause.interrupt() });
3440
+ cancel?.();
3441
+ };
3442
+ }
3443
+ }
3444
+ state.runTransportInner();
3445
+ return () => {
3446
+ if (state.done) return;
3447
+ const cancel = state.cancelInner;
3448
+ state.cancelInner = void 0;
3449
+ state.abortCurrent();
3450
+ if (state.lease) releaseFailure(state.lease, adaptiveLimiter);
3451
+ state.finish("interrupt", { _tag: "Failure", cause: Cause.interrupt() });
3452
+ cancel?.();
3453
+ };
3454
+ }
3455
+ });
3185
3456
  function makeHttp(cfg = {}) {
3186
3457
  validateMakeHttpConfig(cfg);
3187
3458
  const baseUrl = cfg.baseUrl ?? "";
@@ -3200,42 +3471,7 @@ function makeHttp(cfg = {}) {
3200
3471
  if (!adaptiveLimiter && !pool && timeoutMs === void 0) {
3201
3472
  return runDirectTransport(req, url, transport, metrics);
3202
3473
  }
3203
- return fromPromiseAbortable(
3204
- async (signal, env) => {
3205
- let lease;
3206
- const linkedSignal = linkAbortSignals(signal, req.init?.signal);
3207
- try {
3208
- if (linkedSignal.signal.aborted) throw abortErrorForSignal(linkedSignal.signal);
3209
- if (adaptiveLimiter) {
3210
- const key = resolveHttpPoolKey(adaptiveLimiter.keyResolver, req, url);
3211
- lease = await adaptiveLimiter.acquire(key, linkedSignal.signal, { priority: requestPriority(req) });
3212
- } else if (pool) {
3213
- const key = resolveHttpPoolKey(pool.keyResolver, req, url);
3214
- lease = await pool.acquire(key, linkedSignal.signal);
3215
- }
3216
- const response = await runTransportEffect(
3217
- transport({ request: req, url, signal: linkedSignal.signal }),
3218
- env,
3219
- linkedSignal.signal
3220
- );
3221
- lease = releaseSuccess(lease, adaptiveLimiter, response);
3222
- return response;
3223
- } finally {
3224
- linkedSignal.cleanup();
3225
- if (lease) {
3226
- releaseFailure(lease, adaptiveLimiter);
3227
- }
3228
- }
3229
- },
3230
- normalizeHttpError,
3231
- {
3232
- label: fetchLabel(req, url),
3233
- timeoutMs,
3234
- timeoutReason: timeoutMs ? () => timeoutReason(req, url, timeoutMs) : void 0,
3235
- onStart: metrics.onStart,
3236
- onFinish: metrics.onFinish
3237
- }
3238
- );
3474
+ return runPoolTransport(req, url, transport, metrics, pool, adaptiveLimiter, void 0, timeoutMs);
3239
3475
  };
3240
3476
  const metadata = {};
3241
3477
  if (adaptiveLimiter) metadata.adaptiveLimiter = adaptiveLimiter;
@@ -1,24 +1,24 @@
1
1
  import {
2
2
  makeFiberRef,
3
3
  makeRuntimeRecorder
4
- } from "./chunk-EKLEDIVJ.mjs";
4
+ } from "./chunk-S6KSHYAT.mjs";
5
5
  import {
6
6
  withHttpObservability
7
- } from "./chunk-OX6MF7SZ.mjs";
7
+ } from "./chunk-ZXXOXB3T.mjs";
8
8
  import {
9
9
  makeObservability
10
- } from "./chunk-URVS2OE2.mjs";
10
+ } from "./chunk-SCHM2MDA.mjs";
11
11
  import {
12
12
  EventBus
13
- } from "./chunk-KAPZHDO4.mjs";
13
+ } from "./chunk-WA65XP2P.mjs";
14
14
  import {
15
15
  makeDefaultHttpClient,
16
16
  makeHttp
17
- } from "./chunk-5RVHSBJ6.mjs";
17
+ } from "./chunk-5X3MPWTR.mjs";
18
18
  import {
19
19
  Runtime,
20
20
  Scheduler
21
- } from "./chunk-MUMBUXU6.mjs";
21
+ } from "./chunk-BFNBU47C.mjs";
22
22
  import {
23
23
  asyncFlatMap,
24
24
  asyncSucceed,
@@ -4,7 +4,7 @@ var _chunkSA6HUJVIcjs = require('./chunk-SA6HUJVI.cjs');
4
4
 
5
5
 
6
6
 
7
- var _chunkZDZNV6NAcjs = require('./chunk-ZDZNV6NA.cjs');
7
+ var _chunkJKHBEWQAcjs = require('./chunk-JKHBEWQA.cjs');
8
8
 
9
9
 
10
10
 
@@ -1914,7 +1914,7 @@ var runLoop = (state, scope, runStartedAt) => {
1914
1914
  })
1915
1915
  );
1916
1916
  };
1917
- var runAgent = (runtime, goal) => _chunkZDZNV6NAcjs.withScopeAsync.call(void 0,
1917
+ var runAgent = (runtime, goal) => _chunkJKHBEWQAcjs.withScopeAsync.call(void 0,
1918
1918
  runtime,
1919
1919
  (scope) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
1920
1920
  nowMillis(),
@@ -2219,14 +2219,14 @@ var parseRipgrep = (stdout) => stdout.split("\n").filter(Boolean).map((line) =>
2219
2219
  return { path, line: Number(lineNo), text: rest.join(":") };
2220
2220
  });
2221
2221
  var makeNodeFileSystem = (shell) => ({
2222
- readFile: (path) => _chunkZDZNV6NAcjs.fromPromiseAbortable.call(void 0,
2222
+ readFile: (path) => _chunkJKHBEWQAcjs.fromPromiseAbortable.call(void 0,
2223
2223
  async (signal) => {
2224
2224
  const { readFile } = await dynamicImport2("node:fs/promises");
2225
2225
  return readFile(path, { encoding: "utf8", signal });
2226
2226
  },
2227
2227
  (cause) => ({ _tag: "FsError", operation: "readFile", cause })
2228
2228
  ),
2229
- exists: (path) => _chunkZDZNV6NAcjs.fromPromiseAbortable.call(void 0,
2229
+ exists: (path) => _chunkJKHBEWQAcjs.fromPromiseAbortable.call(void 0,
2230
2230
  async (signal) => {
2231
2231
  if (signal.aborted) return false;
2232
2232
  const { stat } = await dynamicImport2("node:fs/promises");
@@ -2607,7 +2607,7 @@ var loadNodeAgentConfig = async (options) => {
2607
2607
  // src/agent/llm/openAICompatible.ts
2608
2608
  var extractText = (json) => _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([json, 'optionalAccess', _150 => _150.choices, 'optionalAccess', _151 => _151[0], 'optionalAccess', _152 => _152.message, 'optionalAccess', _153 => _153.content]), () => ( _optionalChain([json, 'optionalAccess', _154 => _154.output_text]))), () => ( _optionalChain([json, 'optionalAccess', _155 => _155.content, 'optionalAccess', _156 => _156[0], 'optionalAccess', _157 => _157.text]))), () => ( JSON.stringify(json)));
2609
2609
  var makeOpenAICompatibleLLM = (config) => ({
2610
- complete: (request) => _chunkZDZNV6NAcjs.fromPromiseAbortable.call(void 0,
2610
+ complete: (request) => _chunkJKHBEWQAcjs.fromPromiseAbortable.call(void 0,
2611
2611
  async (signal) => {
2612
2612
  const res = await fetch(config.endpoint, {
2613
2613
  method: "POST",
@@ -2699,7 +2699,7 @@ var responseErrorMessage = async (res) => {
2699
2699
  }
2700
2700
  };
2701
2701
  var makeGoogleGenerativeAILLM = (config) => ({
2702
- complete: (request) => _chunkZDZNV6NAcjs.fromPromiseAbortable.call(void 0,
2702
+ complete: (request) => _chunkJKHBEWQAcjs.fromPromiseAbortable.call(void 0,
2703
2703
  async (signal) => {
2704
2704
  const res = await fetch(makeGenerateContentEndpoint(config), {
2705
2705
  method: "POST",
@@ -6,7 +6,7 @@ import {
6
6
  getCurrentFiber,
7
7
  unsafeGetCurrentRuntime,
8
8
  unsafeRunFoldWithEnv
9
- } from "./chunk-MUMBUXU6.mjs";
9
+ } from "./chunk-BFNBU47C.mjs";
10
10
  import {
11
11
  Cause,
12
12
  Exit,
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  fromPromiseAbortable,
6
6
  withScopeAsync
7
- } from "./chunk-APQBU7TM.js";
7
+ } from "./chunk-TN2P7RNK.js";
8
8
  import {
9
9
  Cause,
10
10
  Exit,
@@ -2860,7 +2860,9 @@ var Runtime = class _Runtime {
2860
2860
  this.forkPolicy = makeForkPolicy(this.env, this.hooks);
2861
2861
  this.fiberEngine = this.makeFiberEngine(this.engineMode, args.wasm);
2862
2862
  this.fallbackUsed = false;
2863
+ this.staticFastPathOk = this.hooks === NoopHooks && this.scheduler === globalScheduler && !this.inferLane && this.engineMode === "ts";
2863
2864
  }
2865
+
2864
2866
  makeFiberEngine(mode, wasm) {
2865
2867
  if (mode === "ts") return new JsFiberEngine(this);
2866
2868
  if (mode === "wasm") return new WasmFiberEngine(this, wasm);
@@ -2990,11 +2992,8 @@ var Runtime = class _Runtime {
2990
2992
  });
2991
2993
  }
2992
2994
  tryRunNativeTopLevel(effect, cb) {
2993
- if (this.hooks !== NoopHooks) return false;
2995
+ if (!this.staticFastPathOk) return false;
2994
2996
  if (getCurrentFiber() !== null) return false;
2995
- if (this.scheduler !== globalScheduler) return false;
2996
- if (this.inferLane) return false;
2997
- if (this.engineMode !== "ts") return false;
2998
2997
  new NativeTopLevelRunner(this, effect, cb).start();
2999
2998
  return true;
3000
2999
  }
@@ -3070,16 +3069,25 @@ var NativeTopLevelRunner = (_class16 = class {
3070
3069
  this.runLoop();
3071
3070
  }
3072
3071
  runLoop() {
3073
- this.withFrame(() => {
3072
+ const prevFiber = setCurrentFiber(this);
3073
+ try {
3074
3074
  this.yielded = false;
3075
3075
  let budget = NATIVE_FAST_PATH_STEP_BUDGET;
3076
3076
  while (!this.result && budget-- > 0) {
3077
3077
  const current = this.current;
3078
3078
  switch (current._tag) {
3079
3079
  case "Succeed":
3080
+ if (!this.stack || this.stack.length === 0) {
3081
+ this.notify(_chunkMVGUEJ5Zcjs.Exit.succeed(current.value));
3082
+ return;
3083
+ }
3080
3084
  this.onSuccess(current.value);
3081
3085
  break;
3082
3086
  case "Fail":
3087
+ if (!this.stack || this.stack.length === 0) {
3088
+ this.notify(_chunkMVGUEJ5Zcjs.Exit.failCause(_chunkMVGUEJ5Zcjs.Cause.fail(current.error)));
3089
+ return;
3090
+ }
3083
3091
  this.onCause(_chunkMVGUEJ5Zcjs.Cause.fail(current.error));
3084
3092
  break;
3085
3093
  case "Sync":
@@ -3156,7 +3164,9 @@ var NativeTopLevelRunner = (_class16 = class {
3156
3164
  this.yielded = true;
3157
3165
  queueMicrotask(() => this.runLoop());
3158
3166
  }
3159
- });
3167
+ } finally {
3168
+ setCurrentFiber(prevFiber);
3169
+ }
3160
3170
  }
3161
3171
  runAsync(current) {
3162
3172
  let registered = false;
@@ -4136,6 +4146,11 @@ function withCurrentFiber(fiber, f) {
4136
4146
  _current = prev;
4137
4147
  }
4138
4148
  }
4149
+ function setCurrentFiber(fiber) {
4150
+ const prev = _current;
4151
+ _current = fiber;
4152
+ return prev;
4153
+ }
4139
4154
 
4140
4155
  // src/core/runtime/engine/JsFiberEngine.ts
4141
4156
  var JsFiberEngine = (_class18 = class {
@@ -4400,4 +4415,5 @@ function withScope(runtime, f) {
4400
4415
 
4401
4416
 
4402
4417
 
4403
- exports.PushStatus = PushStatus; exports.RingBuffer = RingBuffer; exports.resolveWasmModule = resolveWasmModule; exports.makeBoundedRingBuffer = makeBoundedRingBuffer; exports.sanitizeLaneKey = sanitizeLaneKey; exports.laneTag = laneTag; exports.inferCallerLaneFromStack = inferCallerLaneFromStack; exports.Scheduler = Scheduler; exports.globalScheduler = globalScheduler; exports.emptyContext = emptyContext; exports.ctxExtend = ctxExtend; exports.ctxToObject = ctxToObject; exports.DefaultHostExecutor = DefaultHostExecutor; exports.JsFiberEngine = JsFiberEngine; exports.HostRegistry = HostRegistry; exports.ProgramBuilder = ProgramBuilder; exports.EngineFiberHandle = EngineFiberHandle; exports.ABI_VERSION = ABI_VERSION; exports.EVENT_WORDS = EVENT_WORDS; exports.NONE_U32 = NONE_U32; exports.OpcodeTagCode = OpcodeTagCode; exports.EventKindCode = EventKindCode; exports.encodeOpcodeProgram = encodeOpcodeProgram; exports.encodeOpcodeNodes = encodeOpcodeNodes; exports.decodeEvent = decodeEvent; exports.decodeEventBatch = decodeEventBatch; exports.WasmPackFiberBridge = WasmPackFiberBridge; exports.WasmFiberRegistryBridge = WasmFiberRegistryBridge; exports.makeFiberReadyQueue = makeFiberReadyQueue; exports.WasmFiberEngine = WasmFiberEngine; exports.runtimeCapabilities = runtimeCapabilities; exports.liveClock = liveClock; exports.runtimeClockFromEnv = runtimeClockFromEnv; exports.NoopHooks = NoopHooks; exports.Runtime = Runtime; exports.fork = fork; exports.runtimeForCaller = runtimeForCaller; exports.toPromiseByCaller = toPromiseByCaller; exports.unsafeRunAsync = unsafeRunAsync; exports.toPromise = toPromise; exports.setAbortablePromisePerLabelTracking = setAbortablePromisePerLabelTracking; exports.recordAbortablePromiseStart = recordAbortablePromiseStart; exports.recordAbortablePromiseFinish = recordAbortablePromiseFinish; exports.abortablePromiseStats = abortablePromiseStats; exports.resetAbortablePromiseStats = resetAbortablePromiseStats; exports.fromPromiseAbortable = fromPromiseAbortable; exports.unsafeRunFoldWithEnv = unsafeRunFoldWithEnv; exports.setBenchmarkBudget = setBenchmarkBudget; exports.getBenchmarkBudget = getBenchmarkBudget; exports.RuntimeFiber = RuntimeFiber; exports.getCurrentFiber = getCurrentFiber; exports.unsafeGetCurrentRuntime = unsafeGetCurrentRuntime; exports.withCurrentFiber = withCurrentFiber; exports.Scope = Scope; exports.withScopeAsync = withScopeAsync; exports.withScope = withScope;
4418
+
4419
+ exports.PushStatus = PushStatus; exports.RingBuffer = RingBuffer; exports.resolveWasmModule = resolveWasmModule; exports.makeBoundedRingBuffer = makeBoundedRingBuffer; exports.sanitizeLaneKey = sanitizeLaneKey; exports.laneTag = laneTag; exports.inferCallerLaneFromStack = inferCallerLaneFromStack; exports.Scheduler = Scheduler; exports.globalScheduler = globalScheduler; exports.emptyContext = emptyContext; exports.ctxExtend = ctxExtend; exports.ctxToObject = ctxToObject; exports.DefaultHostExecutor = DefaultHostExecutor; exports.JsFiberEngine = JsFiberEngine; exports.HostRegistry = HostRegistry; exports.ProgramBuilder = ProgramBuilder; exports.EngineFiberHandle = EngineFiberHandle; exports.ABI_VERSION = ABI_VERSION; exports.EVENT_WORDS = EVENT_WORDS; exports.NONE_U32 = NONE_U32; exports.OpcodeTagCode = OpcodeTagCode; exports.EventKindCode = EventKindCode; exports.encodeOpcodeProgram = encodeOpcodeProgram; exports.encodeOpcodeNodes = encodeOpcodeNodes; exports.decodeEvent = decodeEvent; exports.decodeEventBatch = decodeEventBatch; exports.WasmPackFiberBridge = WasmPackFiberBridge; exports.WasmFiberRegistryBridge = WasmFiberRegistryBridge; exports.makeFiberReadyQueue = makeFiberReadyQueue; exports.WasmFiberEngine = WasmFiberEngine; exports.runtimeCapabilities = runtimeCapabilities; exports.liveClock = liveClock; exports.runtimeClockFromEnv = runtimeClockFromEnv; exports.NoopHooks = NoopHooks; exports.Runtime = Runtime; exports.fork = fork; exports.runtimeForCaller = runtimeForCaller; exports.toPromiseByCaller = toPromiseByCaller; exports.unsafeRunAsync = unsafeRunAsync; exports.toPromise = toPromise; exports.setAbortablePromisePerLabelTracking = setAbortablePromisePerLabelTracking; exports.recordAbortablePromiseStart = recordAbortablePromiseStart; exports.recordAbortablePromiseFinish = recordAbortablePromiseFinish; exports.abortablePromiseStats = abortablePromiseStats; exports.resetAbortablePromiseStats = resetAbortablePromiseStats; exports.fromPromiseAbortable = fromPromiseAbortable; exports.unsafeRunFoldWithEnv = unsafeRunFoldWithEnv; exports.setBenchmarkBudget = setBenchmarkBudget; exports.getBenchmarkBudget = getBenchmarkBudget; exports.RuntimeFiber = RuntimeFiber; exports.getCurrentFiber = getCurrentFiber; exports.unsafeGetCurrentRuntime = unsafeGetCurrentRuntime; exports.withCurrentFiber = withCurrentFiber; exports.setCurrentFiber = setCurrentFiber; exports.Scope = Scope; exports.withScopeAsync = withScopeAsync; exports.withScope = withScope;
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  makeRuntimeEventRecord
3
- } from "./chunk-KAPZHDO4.mjs";
3
+ } from "./chunk-WA65XP2P.mjs";
4
4
  import {
5
5
  layerEffect,
6
6
  makeScheduleDriver
7
- } from "./chunk-KDXNWGPB.mjs";
7
+ } from "./chunk-XRRC5BBM.mjs";
8
8
  import {
9
9
  Runtime,
10
10
  getCurrentFiber,
@@ -12,7 +12,7 @@ import {
12
12
  runtimeClockFromEnv,
13
13
  toPromise,
14
14
  unsafeRunAsync
15
- } from "./chunk-MUMBUXU6.mjs";
15
+ } from "./chunk-BFNBU47C.mjs";
16
16
  import {
17
17
  Cause,
18
18
  Exit,
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkFYWWU3Z7cjs = require('./chunk-FYWWU3Z7.cjs');
3
+ var _chunkVXNWVAIGcjs = require('./chunk-VXNWVAIG.cjs');
4
4
 
5
5
 
6
6
 
7
- var _chunkZDZNV6NAcjs = require('./chunk-ZDZNV6NA.cjs');
7
+ var _chunkJKHBEWQAcjs = require('./chunk-JKHBEWQA.cjs');
8
8
 
9
9
 
10
10
 
@@ -73,9 +73,9 @@ function fiberRefSnapshot() {
73
73
  return new Map(currentFiberRefs(false));
74
74
  }
75
75
  function currentFiberRefs(create) {
76
- const fiber = _chunkZDZNV6NAcjs.getCurrentFiber.call(void 0, );
76
+ const fiber = _chunkJKHBEWQAcjs.getCurrentFiber.call(void 0, );
77
77
  if (!fiber) return void 0;
78
- fiber.fiberContext ??= { log: _chunkZDZNV6NAcjs.emptyContext, trace: null };
78
+ fiber.fiberContext ??= { log: _chunkJKHBEWQAcjs.emptyContext, trace: null };
79
79
  if (!fiber.fiberContext.fiberRefs && create) fiber.fiberContext.fiberRefs = /* @__PURE__ */ new Map();
80
80
  return fiber.fiberContext.fiberRefs;
81
81
  }
@@ -98,7 +98,7 @@ function makeRuntimeRecorder(options = {}) {
98
98
  return out;
99
99
  };
100
100
  const emit = (ev, ctx) => {
101
- records[next] = _chunkFYWWU3Z7cjs.makeRuntimeEventRecord.call(void 0, ev, ctx, seq++);
101
+ records[next] = _chunkVXNWVAIGcjs.makeRuntimeEventRecord.call(void 0, ev, ctx, seq++);
102
102
  next = (next + 1) % capacity;
103
103
  if (size < capacity) size++;
104
104
  else dropped++;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  makeBoundedRingBuffer
3
- } from "./chunk-APQBU7TM.js";
3
+ } from "./chunk-TN2P7RNK.js";
4
4
  import {
5
5
  Cause
6
6
  } from "./chunk-UB4B6OFY.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  layerEffect,
3
3
  makeServiceTag
4
- } from "./chunk-EXBGIC66.js";
4
+ } from "./chunk-6W5DC3TX.js";
5
5
  import {
6
6
  Runtime
7
- } from "./chunk-APQBU7TM.js";
7
+ } from "./chunk-TN2P7RNK.js";
8
8
  import {
9
9
  asyncSync
10
10
  } from "./chunk-UB4B6OFY.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  makeRuntimeEventRecord
3
- } from "./chunk-B2VXVNIS.js";
3
+ } from "./chunk-LI7WUVJN.js";
4
4
  import {
5
5
  layerEffect,
6
6
  makeScheduleDriver
7
- } from "./chunk-EXBGIC66.js";
7
+ } from "./chunk-6W5DC3TX.js";
8
8
  import {
9
9
  Runtime,
10
10
  getCurrentFiber,
@@ -12,7 +12,7 @@ import {
12
12
  runtimeClockFromEnv,
13
13
  toPromise,
14
14
  unsafeRunAsync
15
- } from "./chunk-APQBU7TM.js";
15
+ } from "./chunk-TN2P7RNK.js";
16
16
  import {
17
17
  Cause,
18
18
  Exit,