@effect-uai/inworld 0.18.0 → 0.19.0-dev-20261109183959

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.
@@ -4,6 +4,7 @@ import * as Cause from "effect/Cause";
4
4
  import * as Duration from "effect/Duration";
5
5
  import * as Effect from "effect/Effect";
6
6
  import * as Exit from "effect/Exit";
7
+ import "effect/Fiber";
7
8
  import { constVoid, flow, pipe } from "effect/Function";
8
9
  import * as Layer from "effect/Layer";
9
10
  import * as Schedule from "effect/Schedule";
@@ -17292,30 +17293,31 @@ function clearModuleMocks(config) {
17292
17293
  if (unstubGlobals) vi.unstubAllGlobals();
17293
17294
  }
17294
17295
  //#endregion
17295
- //#region ../../../node_modules/.pnpm/@effect+vitest@4.0.1_effect@4.0.1_vitest@5.0.3_@types+node@26.2.0_vite@7.3.2_@types+nod_65816e3353e20bfeb9b2e1494bdddeef/node_modules/@effect/vitest/dist/internal/internal.js
17296
+ //#region ../../../node_modules/.pnpm/@effect+vitest@4.1.2_effect@4.1.2_vitest@5.0.3_@types+node@26.2.0_vite@7.3.2_@types+nod_a2fffe0deec250ef9d6207b86a9a1ab8/node_modules/@effect/vitest/dist/internal/internal.js
17296
17297
  /**
17297
17298
  * @since 4.0.0
17298
17299
  */
17299
17300
  const getCurrentSuite = TestRunner.getCurrentSuite;
17300
- const runPromise = /*#__PURE__*/ Effect.fnUntraced(function* (effect, _ctx) {
17301
- const exit = yield* Effect.exit(effect);
17301
+ const runPromise = (effect, ctx) => Effect.runPromise(Effect.uninterruptibleMask((restore) => Effect.gen(function* () {
17302
+ const exit = yield* Effect.exit(restore(effect));
17302
17303
  if (Exit.isFailure(exit)) {
17303
17304
  const errors = Cause.prettyErrors(exit.cause);
17304
17305
  for (let i = 0; i < errors.length; i++) yield* Effect.logError(errors[i]);
17305
17306
  }
17306
17307
  return yield* exit;
17307
- }, (effect, _, ctx) => Effect.runPromise(effect, { signal: ctx?.signal }));
17308
+ })), { signal: ctx?.signal });
17309
+ const settleOnAbort = (ctx, promise) => {
17310
+ const onAbort = () => ctx.onTestFinished(() => promise.then(constVoid, constVoid));
17311
+ ctx.signal.addEventListener("abort", onAbort, { once: true });
17312
+ const cleanup = () => ctx.signal.removeEventListener("abort", onAbort);
17313
+ promise.then(cleanup, cleanup);
17314
+ if (ctx.signal.aborted) onAbort();
17315
+ return promise;
17316
+ };
17308
17317
  /** @internal */
17309
17318
  const runTest = (ctx) => (effect) => {
17310
17319
  const promise = runPromise(effect, ctx);
17311
- if (ctx) {
17312
- const onAbort = () => ctx.onTestFinished(() => promise.then(constVoid, constVoid));
17313
- ctx.signal.addEventListener("abort", onAbort, { once: true });
17314
- const cleanup = () => ctx.signal.removeEventListener("abort", onAbort);
17315
- promise.then(cleanup, cleanup);
17316
- if (ctx.signal.aborted) onAbort();
17317
- }
17318
- return promise;
17320
+ return ctx ? settleOnAbort(ctx, promise) : promise;
17319
17321
  };
17320
17322
  const TestEnv = /*#__PURE__*/ Layer.mergeAll(TestConsole.layer, /*#__PURE__*/ TestClock.layer());
17321
17323
  /** @internal */
@@ -17351,6 +17353,9 @@ const collectTasks = (tasks, acc = []) => {
17351
17353
  }
17352
17354
  return acc;
17353
17355
  };
17356
+ const runsMoreThanOnce = (task) => {
17357
+ return ((typeof task.retry === "number" ? task.retry : task.retry?.count) ?? 0) > 0 || (task.repeats ?? 0) > 0;
17358
+ };
17354
17359
  const registerProp = (it, name, arbitraries, property, timeout) => {
17355
17360
  const arbitrary = makeArbitrary(arbitraries);
17356
17361
  it(name, testOptions(timeout), withFixturesOf(() => {}, (ctx) => runCheck(ctx, arbitrary, (values) => property(values, ctx), checkOptions(timeout))));
@@ -17370,11 +17375,35 @@ const makeTester = (mapEffect, it) => {
17370
17375
  prop
17371
17376
  });
17372
17377
  };
17373
- const makeProp = (it) => (name, arbitraries, self, timeout) => registerProp(it, name, arbitraries, (values, ctx) => self(values, ctx) !== false, timeout);
17378
+ const makeProp = (it) => (name, arbitraries, self, timeout) => registerProp(it, name, arbitraries, (values, ctx) => {
17379
+ const result = self(values, ctx);
17380
+ if (result !== void 0 && typeof result !== "boolean") throw new TypeError("it.prop callbacks must return boolean or void. Use it.effect.prop for Effect callbacks.");
17381
+ return result !== false;
17382
+ }, timeout);
17374
17383
  const makeLayer = (it) => (layer_, options) => (...args) => {
17375
17384
  const excludeTestServices = options?.excludeTestServices ?? false;
17376
17385
  const withTestEnv = excludeTestServices ? layer_ : Layer.provideMerge(layer_, TestEnv);
17377
17386
  const memoMap = options?.memoMap ?? Effect.runSync(Layer.makeMemoMap);
17387
+ const buildPerTest = options?.buildPerTest ?? false;
17388
+ const suiteOptions = options?.concurrent === void 0 ? {} : { concurrent: options.concurrent };
17389
+ const makeBlockMethods = (provide) => makeItProxy(it, {
17390
+ effect: makeTester((effect) => provide(Effect.scoped(effect)), it),
17391
+ prop: makeProp(it),
17392
+ flakyTest,
17393
+ layer(nestedLayer, nestedOptions) {
17394
+ return makeLayer(it)(Layer.provideMerge(nestedLayer, withTestEnv), {
17395
+ ...nestedOptions,
17396
+ memoMap: Layer.forkMemoMapUnsafe(memoMap),
17397
+ excludeTestServices,
17398
+ buildPerTest: buildPerTest || nestedOptions?.buildPerTest === true
17399
+ });
17400
+ }
17401
+ });
17402
+ if (buildPerTest) {
17403
+ const methods = makeBlockMethods((effect) => Effect.scopedWith((scope) => Layer.buildWithMemoMap(withTestEnv, Layer.forkMemoMapUnsafe(memoMap), scope).pipe(Effect.orDie, Effect.flatMap((context) => Effect.provide(effect, context)))));
17404
+ if (args.length === 1) return args[0](methods);
17405
+ return describe(args[0], suiteOptions, () => args[1](methods));
17406
+ }
17378
17407
  const scope = Effect.runSync(Scope.make());
17379
17408
  const contextEffect = Layer.buildWithMemoMap(withTestEnv, memoMap, scope).pipe(Effect.orDie, Effect.cached, Effect.runSync);
17380
17409
  let closed = false;
@@ -17383,18 +17412,7 @@ const makeLayer = (it) => (layer_, options) => (...args) => {
17383
17412
  closed = true;
17384
17413
  return runPromise(Scope.close(scope, Exit.void));
17385
17414
  };
17386
- const methods = makeItProxy(it, {
17387
- effect: makeTester((effect) => Effect.flatMap(contextEffect, (context) => effect.pipe(Effect.scoped, Effect.provide(context))), it),
17388
- prop: makeProp(it),
17389
- flakyTest,
17390
- layer(nestedLayer, options) {
17391
- return makeLayer(it)(Layer.provideMerge(nestedLayer, withTestEnv), {
17392
- ...options,
17393
- memoMap: Layer.forkMemoMapUnsafe(memoMap),
17394
- excludeTestServices
17395
- });
17396
- }
17397
- });
17415
+ const methods = makeBlockMethods((effect) => Effect.flatMap(contextEffect, (context) => Effect.provide(effect, context)));
17398
17416
  if (args.length === 1) {
17399
17417
  const currentSuite = getCurrentSuite();
17400
17418
  const previousTasks = new Set(currentSuite.tasks);
@@ -17405,10 +17423,11 @@ const makeLayer = (it) => (layer_, options) => (...args) => {
17405
17423
  return;
17406
17424
  }
17407
17425
  const blockTaskSet = new Set(blockTasks);
17426
+ const releaseAfterLastTest = !blockTasks.some(runsMoreThanOnce);
17408
17427
  let remaining = blockTasks.length;
17409
17428
  beforeEach(({ onTestFinished, signal, task }) => {
17410
17429
  if (!blockTaskSet.has(task)) return;
17411
- onTestFinished(() => {
17430
+ if (releaseAfterLastTest) onTestFinished(() => {
17412
17431
  remaining--;
17413
17432
  if (remaining === 0) return closeScope();
17414
17433
  });
@@ -17417,7 +17436,6 @@ const makeLayer = (it) => (layer_, options) => (...args) => {
17417
17436
  afterAll(() => closeScope(), hookTimeout(options?.timeout));
17418
17437
  return;
17419
17438
  }
17420
- const suiteOptions = options?.concurrent === void 0 ? {} : { concurrent: options.concurrent };
17421
17439
  return describe(args[0], suiteOptions, () => {
17422
17440
  beforeAll(() => runPromise(Effect.asVoid(contextEffect)), hookTimeout(options?.timeout));
17423
17441
  afterAll(() => closeScope(), hookTimeout(options?.timeout));
@@ -17439,15 +17457,16 @@ const it$1 = /*#__PURE__*/ makeMethods(it$2);
17439
17457
  /** @internal */
17440
17458
  const { effect, layer, live, prop } = it$1;
17441
17459
  //#endregion
17442
- //#region ../../../node_modules/.pnpm/@effect+vitest@4.0.1_effect@4.0.1_vitest@5.0.3_@types+node@26.2.0_vite@7.3.2_@types+nod_65816e3353e20bfeb9b2e1494bdddeef/node_modules/@effect/vitest/dist/index.js
17443
- /**
17444
- * @since 4.0.0
17445
- */
17460
+ //#region ../../../node_modules/.pnpm/@effect+vitest@4.1.2_effect@4.1.2_vitest@5.0.3_@types+node@26.2.0_vite@7.3.2_@types+nod_a2fffe0deec250ef9d6207b86a9a1ab8/node_modules/@effect/vitest/dist/index.js
17446
17461
  /**
17462
+ * Vitest test API extended with Effect test helpers.
17463
+ *
17464
+ * @stability unstable
17465
+ * @category testing
17447
17466
  * @since 4.0.0
17448
17467
  */
17449
17468
  const it = it$1;
17450
17469
  //#endregion
17451
17470
  export { globalExpect as n, describe as r, it as t };
17452
17471
 
17453
- //# sourceMappingURL=dist-Cu2gIMHV.mjs.map
17472
+ //# sourceMappingURL=dist-DvYz71Uo.mjs.map