@effect-uai/core 0.17.0 → 0.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.
- package/README.md +1 -1
- package/dist/decision-model/Decision.test.mjs +4 -4
- package/dist/dist-C8RmtoR8.mjs +172 -0
- package/dist/dist-C8RmtoR8.mjs.map +1 -0
- package/dist/dist-CorQTQL-.mjs +1533 -0
- package/dist/dist-CorQTQL-.mjs.map +1 -0
- package/dist/dist-DNeuh84d.mjs +7 -0
- package/dist/dist-DNeuh84d.mjs.map +1 -0
- package/dist/dist-DzeSyeYF.mjs +10253 -0
- package/dist/dist-DzeSyeYF.mjs.map +1 -0
- package/dist/domain/Transcript.test.mjs +3 -3
- package/dist/domain/Turn.test.mjs +2 -2
- package/dist/embedding-model/EmbeddingModel.test.mjs +2 -2
- package/dist/embedding-model/EmbeddingModel.test.mjs.map +1 -1
- package/dist/index.C4tKZ0yW-LuFnBtmu.mjs +7042 -0
- package/dist/index.C4tKZ0yW-LuFnBtmu.mjs.map +1 -0
- package/dist/language-model/LanguageModel.test.mjs +2 -2
- package/dist/loop/Loop.mjs.map +1 -1
- package/dist/loop/Loop.test.mjs +3 -3
- package/dist/math/Probability.test.mjs +2 -2
- package/dist/messenger/MessengerAdapter.test.mjs +3 -3
- package/dist/music-generator/MusicGenerator.test.mjs +3 -3
- package/dist/observability/Metrics.test.mjs +3 -3
- package/dist/observability/Telemetry.d.mts +1 -1
- package/dist/observability/Telemetry.mjs +1 -1
- package/dist/observability/Telemetry.mjs.map +1 -1
- package/dist/observability/Telemetry.test.mjs +4 -4
- package/dist/observability/Telemetry.test.mjs.map +1 -1
- package/dist/realtime/RealtimeSession.test.mjs +4 -4
- package/dist/retry/Retry.test.mjs +2 -2
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +3 -3
- package/dist/streaming/JSONL.test.mjs +2 -2
- package/dist/streaming/Multipart.d.mts +1 -1
- package/dist/streaming/Multipart.mjs +1 -1
- package/dist/streaming/Multipart.mjs.map +1 -1
- package/dist/streaming/SSE.d.mts +1 -1
- package/dist/streaming/SSE.mjs +2 -2
- package/dist/streaming/SSE.mjs.map +1 -1
- package/dist/streaming/SSE.test.mjs +2 -2
- package/dist/streaming/Settle.test.mjs +3 -3
- package/dist/streaming/WebSocketSession.d.mts +5 -3
- package/dist/streaming/WebSocketSession.d.mts.map +1 -1
- package/dist/streaming/WebSocketSession.mjs +22 -10
- package/dist/streaming/WebSocketSession.mjs.map +1 -1
- package/dist/streaming/WebSocketSession.test.mjs +41 -5
- package/dist/streaming/WebSocketSession.test.mjs.map +1 -1
- package/dist/structured-format/StructuredFormat.mjs.map +1 -1
- package/dist/structured-format/StructuredFormat.test.mjs +2 -2
- package/dist/testing/FakeWebSocket.d.mts +5 -1
- package/dist/testing/FakeWebSocket.d.mts.map +1 -1
- package/dist/testing/FakeWebSocket.mjs +12 -6
- package/dist/testing/FakeWebSocket.mjs.map +1 -1
- package/dist/tool/Approval.test.mjs +2 -2
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/Tool.test.mjs +3 -3
- package/dist/tool/Toolkit.test.mjs +3 -3
- package/dist/transcriber/Transcriber.test.mjs +3 -3
- package/package.json +3 -3
- package/src/embedding-model/EmbeddingModel.test.ts +2 -2
- package/src/loop/Loop.ts +1 -1
- package/src/observability/Telemetry.test.ts +1 -1
- package/src/observability/Telemetry.ts +2 -2
- package/src/streaming/Multipart.ts +1 -1
- package/src/streaming/SSE.ts +2 -2
- package/src/streaming/WebSocketSession.test.ts +54 -2
- package/src/streaming/WebSocketSession.ts +27 -6
- package/src/structured-format/StructuredFormat.ts +1 -1
- package/src/testing/FakeWebSocket.ts +21 -6
- package/src/tool/Tool.ts +1 -1
- package/dist/dist-BaenoU1A.mjs +0 -145
- package/dist/dist-BaenoU1A.mjs.map +0 -1
- package/dist/dist-nohcnkD6.mjs +0 -182
- package/dist/dist-nohcnkD6.mjs.map +0 -1
- package/dist/magic-string.es-CB2hOw9v.mjs +0 -1014
- package/dist/magic-string.es-CB2hOw9v.mjs.map +0 -1
- package/dist/test.DNmyFkvJ-YPzDR0Co.mjs +0 -10254
- package/dist/test.DNmyFkvJ-YPzDR0Co.mjs.map +0 -1
- package/dist/utils-CiH_DjFW.mjs +0 -3918
- package/dist/utils-CiH_DjFW.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Unsupported } from "../domain/AiError.mjs";
|
|
2
2
|
import { assertKinds, classify, confidence, expectedLevel, make, margin, probabilitiesOf, probability, ranked, rate, topLevel, winner } from "./Decision.mjs";
|
|
3
3
|
import { DecisionModel, decide } from "./DecisionModel.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { n as globalExpect } from "../
|
|
6
|
-
import { t as import_dist } from "../dist-
|
|
7
|
-
import { t as it } from "../dist-
|
|
4
|
+
import { m as describe } from "../dist-DzeSyeYF.mjs";
|
|
5
|
+
import { n as globalExpect } from "../index.C4tKZ0yW-LuFnBtmu.mjs";
|
|
6
|
+
import { t as import_dist } from "../dist-DNeuh84d.mjs";
|
|
7
|
+
import { t as it } from "../dist-C8RmtoR8.mjs";
|
|
8
8
|
import { Effect, Layer, Option, Ref, Schema } from "effect";
|
|
9
9
|
//#region src/decision-model/Decision.test.ts
|
|
10
10
|
const triage = make({
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { b as it$2, d as beforeEach, l as afterAll, m as describe, u as beforeAll } from "./dist-DzeSyeYF.mjs";
|
|
2
|
+
import { t as TestRunner } from "./index.C4tKZ0yW-LuFnBtmu.mjs";
|
|
3
|
+
import * as Arbitrary from "effect/Arbitrary";
|
|
4
|
+
import * as Cause from "effect/Cause";
|
|
5
|
+
import * as Duration from "effect/Duration";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Exit from "effect/Exit";
|
|
8
|
+
import { constVoid, flow, pipe } from "effect/Function";
|
|
9
|
+
import * as Layer from "effect/Layer";
|
|
10
|
+
import * as Schedule from "effect/Schedule";
|
|
11
|
+
import * as Scope from "effect/Scope";
|
|
12
|
+
import * as TestClock from "effect/testing/TestClock";
|
|
13
|
+
import * as TestConsole from "effect/testing/TestConsole";
|
|
14
|
+
//#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
|
|
15
|
+
/**
|
|
16
|
+
* @since 4.0.0
|
|
17
|
+
*/
|
|
18
|
+
const getCurrentSuite = TestRunner.getCurrentSuite;
|
|
19
|
+
const runPromise = /*#__PURE__*/ Effect.fnUntraced(function* (effect, _ctx) {
|
|
20
|
+
const exit = yield* Effect.exit(effect);
|
|
21
|
+
if (Exit.isFailure(exit)) {
|
|
22
|
+
const errors = Cause.prettyErrors(exit.cause);
|
|
23
|
+
for (let i = 0; i < errors.length; i++) yield* Effect.logError(errors[i]);
|
|
24
|
+
}
|
|
25
|
+
return yield* exit;
|
|
26
|
+
}, (effect, _, ctx) => Effect.runPromise(effect, { signal: ctx?.signal }));
|
|
27
|
+
/** @internal */
|
|
28
|
+
const runTest = (ctx) => (effect) => {
|
|
29
|
+
const promise = runPromise(effect, ctx);
|
|
30
|
+
if (ctx) {
|
|
31
|
+
const onAbort = () => ctx.onTestFinished(() => promise.then(constVoid, constVoid));
|
|
32
|
+
ctx.signal.addEventListener("abort", onAbort, { once: true });
|
|
33
|
+
const cleanup = () => ctx.signal.removeEventListener("abort", onAbort);
|
|
34
|
+
promise.then(cleanup, cleanup);
|
|
35
|
+
if (ctx.signal.aborted) onAbort();
|
|
36
|
+
}
|
|
37
|
+
return promise;
|
|
38
|
+
};
|
|
39
|
+
const TestEnv = /*#__PURE__*/ Layer.mergeAll(TestConsole.layer, /*#__PURE__*/ TestClock.layer());
|
|
40
|
+
/** @internal */
|
|
41
|
+
const testOptions = (timeout) => typeof timeout === "number" ? { timeout } : timeout ?? {};
|
|
42
|
+
const hookTimeout = (timeout) => timeout === void 0 ? void 0 : Duration.toMillis(Duration.fromInputUnsafe(timeout));
|
|
43
|
+
const propertyTestOptions = (timeout) => typeof timeout === "number" ? void 0 : timeout;
|
|
44
|
+
const checkOptions = (timeout) => propertyTestOptions(timeout)?.arbitrary;
|
|
45
|
+
const compileArbitraryInput = (input) => Arbitrary.isArbitrary(input) ? input : Arbitrary.schema(input);
|
|
46
|
+
const makeArbitrary = (arbitraries) => Arbitrary.all(Array.isArray(arbitraries) ? arbitraries.map(compileArbitraryInput) : Object.fromEntries(Object.entries(arbitraries).map(([key, input]) => [key, compileArbitraryInput(input)])));
|
|
47
|
+
const normalizeProperty = (property, value) => Effect.catchCause(Effect.suspend(() => {
|
|
48
|
+
const output = property(value);
|
|
49
|
+
return Effect.isEffect(output) ? output : Effect.succeed(output);
|
|
50
|
+
}), (cause) => Cause.hasInterrupts(cause) ? Effect.failCause(cause) : Effect.fail(cause));
|
|
51
|
+
const runCheck = (ctx, arbitrary, property, options) => runTest(ctx)(Effect.flatMapEager(Arbitrary.checkEffect(arbitrary, (value) => normalizeProperty(property, value), options), (result) => {
|
|
52
|
+
const failure = Arbitrary.formatCheckFailure(result);
|
|
53
|
+
return failure === void 0 ? Effect.void : Effect.die(new Error(failure));
|
|
54
|
+
}));
|
|
55
|
+
const withFixturesOf = (source, f) => Object.defineProperty(f, "toString", { value: () => source.toString() });
|
|
56
|
+
const makeItProxy = (it, overrides) => new Proxy(it, {
|
|
57
|
+
apply(target, thisArg, argArray) {
|
|
58
|
+
return Reflect.apply(target, thisArg, argArray);
|
|
59
|
+
},
|
|
60
|
+
get(target, property, receiver) {
|
|
61
|
+
if (Object.hasOwn(overrides, property)) return Reflect.get(overrides, property);
|
|
62
|
+
return Reflect.get(target, property, receiver);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const collectTasks = (tasks, acc = []) => {
|
|
66
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
67
|
+
const task = tasks[i];
|
|
68
|
+
if (task.type === "test" && task.mode !== "skip" && task.mode !== "todo") acc.push(task);
|
|
69
|
+
else if (task.tasks !== void 0) collectTasks(task.tasks, acc);
|
|
70
|
+
}
|
|
71
|
+
return acc;
|
|
72
|
+
};
|
|
73
|
+
const registerProp = (it, name, arbitraries, property, timeout) => {
|
|
74
|
+
const arbitrary = makeArbitrary(arbitraries);
|
|
75
|
+
it(name, testOptions(timeout), withFixturesOf(() => {}, (ctx) => runCheck(ctx, arbitrary, (values) => property(values, ctx), checkOptions(timeout))));
|
|
76
|
+
};
|
|
77
|
+
const makeTester = (mapEffect, it) => {
|
|
78
|
+
const run = (ctx, args, self) => pipe(Effect.suspend(() => self(...args)), mapEffect, runTest(ctx));
|
|
79
|
+
const register = (test) => (name, self, timeout) => test(name, testOptions(timeout), withFixturesOf(self, (ctx) => run(ctx, [ctx], self)));
|
|
80
|
+
const each = (cases) => (name, self, timeout) => it.for(cases)(name, testOptions(timeout), withFixturesOf(self, (args, ctx) => run(ctx, [args, ctx], self).then(constVoid)));
|
|
81
|
+
const prop = (name, arbitraries, self, timeout) => registerProp(it, name, arbitraries, (values, ctx) => Effect.mapEager(mapEffect(Effect.suspend(() => self(values, ctx))), (value) => value !== false), timeout);
|
|
82
|
+
return Object.assign(register(it), {
|
|
83
|
+
skip: register(it.skip),
|
|
84
|
+
skipIf: (condition) => register(it.skipIf(condition)),
|
|
85
|
+
runIf: (condition) => register(it.runIf(condition)),
|
|
86
|
+
only: register(it.only),
|
|
87
|
+
each,
|
|
88
|
+
fails: register(it.fails),
|
|
89
|
+
prop
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
const makeProp = (it) => (name, arbitraries, self, timeout) => registerProp(it, name, arbitraries, (values, ctx) => self(values, ctx) !== false, timeout);
|
|
93
|
+
const makeLayer = (it) => (layer_, options) => (...args) => {
|
|
94
|
+
const excludeTestServices = options?.excludeTestServices ?? false;
|
|
95
|
+
const withTestEnv = excludeTestServices ? layer_ : Layer.provideMerge(layer_, TestEnv);
|
|
96
|
+
const memoMap = options?.memoMap ?? Effect.runSync(Layer.makeMemoMap);
|
|
97
|
+
const scope = Effect.runSync(Scope.make());
|
|
98
|
+
const contextEffect = Layer.buildWithMemoMap(withTestEnv, memoMap, scope).pipe(Effect.orDie, Effect.cached, Effect.runSync);
|
|
99
|
+
let closed = false;
|
|
100
|
+
const closeScope = () => {
|
|
101
|
+
if (closed) return Promise.resolve();
|
|
102
|
+
closed = true;
|
|
103
|
+
return runPromise(Scope.close(scope, Exit.void));
|
|
104
|
+
};
|
|
105
|
+
const methods = makeItProxy(it, {
|
|
106
|
+
effect: makeTester((effect) => Effect.flatMap(contextEffect, (context) => effect.pipe(Effect.scoped, Effect.provide(context))), it),
|
|
107
|
+
prop: makeProp(it),
|
|
108
|
+
flakyTest,
|
|
109
|
+
layer(nestedLayer, options) {
|
|
110
|
+
return makeLayer(it)(Layer.provideMerge(nestedLayer, withTestEnv), {
|
|
111
|
+
...options,
|
|
112
|
+
memoMap: Layer.forkMemoMapUnsafe(memoMap),
|
|
113
|
+
excludeTestServices
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
if (args.length === 1) {
|
|
118
|
+
const currentSuite = getCurrentSuite();
|
|
119
|
+
const previousTasks = new Set(currentSuite.tasks);
|
|
120
|
+
args[0](methods);
|
|
121
|
+
const blockTasks = collectTasks(currentSuite.tasks.filter((task) => !previousTasks.has(task)));
|
|
122
|
+
if (blockTasks.length === 0) {
|
|
123
|
+
afterAll(() => closeScope(), hookTimeout(options?.timeout));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const blockTaskSet = new Set(blockTasks);
|
|
127
|
+
let remaining = blockTasks.length;
|
|
128
|
+
beforeEach(({ onTestFinished, signal, task }) => {
|
|
129
|
+
if (!blockTaskSet.has(task)) return;
|
|
130
|
+
onTestFinished(() => {
|
|
131
|
+
remaining--;
|
|
132
|
+
if (remaining === 0) return closeScope();
|
|
133
|
+
});
|
|
134
|
+
return runPromise(Effect.asVoid(contextEffect), { signal });
|
|
135
|
+
}, hookTimeout(options?.timeout));
|
|
136
|
+
afterAll(() => closeScope(), hookTimeout(options?.timeout));
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const suiteOptions = options?.concurrent === void 0 ? {} : { concurrent: options.concurrent };
|
|
140
|
+
return describe(args[0], suiteOptions, () => {
|
|
141
|
+
beforeAll(() => runPromise(Effect.asVoid(contextEffect)), hookTimeout(options?.timeout));
|
|
142
|
+
afterAll(() => closeScope(), hookTimeout(options?.timeout));
|
|
143
|
+
return args[1](methods);
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
/** @internal */
|
|
147
|
+
const flakyTest = (self, timeout = Duration.seconds(30)) => pipe(self, Effect.scoped, Effect.sandbox, Effect.retry(pipe(Schedule.recurs(10), Schedule.while((_) => Effect.succeed(Duration.isLessThanOrEqualTo(Duration.fromInputUnsafe(_.elapsed), Duration.fromInputUnsafe(timeout)))))), Effect.orDie);
|
|
148
|
+
/** @internal */
|
|
149
|
+
const makeMethods = (it) => makeItProxy(it, {
|
|
150
|
+
effect: makeTester(flow(Effect.scoped, Effect.provide(TestEnv)), it),
|
|
151
|
+
live: makeTester(Effect.scoped, it),
|
|
152
|
+
flakyTest,
|
|
153
|
+
layer: makeLayer(it),
|
|
154
|
+
prop: makeProp(it)
|
|
155
|
+
});
|
|
156
|
+
/** @internal */
|
|
157
|
+
const it$1 = /*#__PURE__*/ makeMethods(it$2);
|
|
158
|
+
/** @internal */
|
|
159
|
+
const { effect, layer, live, prop } = it$1;
|
|
160
|
+
//#endregion
|
|
161
|
+
//#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
|
|
162
|
+
/**
|
|
163
|
+
* @since 4.0.0
|
|
164
|
+
*/
|
|
165
|
+
/**
|
|
166
|
+
* @since 4.0.0
|
|
167
|
+
*/
|
|
168
|
+
const it = it$1;
|
|
169
|
+
//#endregion
|
|
170
|
+
export { it as t };
|
|
171
|
+
|
|
172
|
+
//# sourceMappingURL=dist-C8RmtoR8.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-C8RmtoR8.mjs","names":["V.describe","it","V.it","internal.it"],"sources":["../../../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","../../../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"],"sourcesContent":["/**\n * @since 4.0.0\n */\nimport * as Arbitrary from \"effect/Arbitrary\";\nimport * as Cause from \"effect/Cause\";\nimport * as Duration from \"effect/Duration\";\nimport * as Effect from \"effect/Effect\";\nimport * as Exit from \"effect/Exit\";\nimport { constVoid, flow, pipe } from \"effect/Function\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schedule from \"effect/Schedule\";\nimport * as Scope from \"effect/Scope\";\nimport * as TestClock from \"effect/testing/TestClock\";\nimport * as TestConsole from \"effect/testing/TestConsole\";\nimport * as V from \"vitest\";\nconst getCurrentSuite = V.TestRunner.getCurrentSuite;\nconst runPromise = /*#__PURE__*/Effect.fnUntraced(function* (effect, _ctx) {\n const exit = yield* Effect.exit(effect);\n if (Exit.isFailure(exit)) {\n const errors = Cause.prettyErrors(exit.cause);\n for (let i = 0; i < errors.length; i++) {\n yield* Effect.logError(errors[i]);\n }\n }\n return yield* exit;\n}, (effect, _, ctx) => Effect.runPromise(effect, {\n signal: ctx?.signal\n}));\n/** @internal */\nconst runTest = ctx => effect => {\n const promise = runPromise(effect, ctx);\n if (ctx) {\n // Vitest stops awaiting the test promise once the signal aborts (timeout or\n // cancellation), so only then add a hook that waits for the finalizers.\n // Registering it unconditionally would change the teardown of every test.\n const onAbort = () => ctx.onTestFinished(() => promise.then(constVoid, constVoid));\n ctx.signal.addEventListener(\"abort\", onAbort, {\n once: true\n });\n const cleanup = () => ctx.signal.removeEventListener(\"abort\", onAbort);\n promise.then(cleanup, cleanup);\n // A retry after a timed-out attempt reuses the aborted signal, so no event fires.\n if (ctx.signal.aborted) onAbort();\n }\n return promise;\n};\nconst TestEnv = /*#__PURE__*/Layer.mergeAll(TestConsole.layer, /*#__PURE__*/TestClock.layer());\n/** @internal */\nexport const addEqualityTesters = () => {\n V.expect.addEqualityTesters([]);\n};\n/** @internal */\nconst testOptions = timeout => typeof timeout === \"number\" ? {\n timeout\n} : timeout ?? {};\nconst hookTimeout = timeout => timeout === undefined ? undefined : Duration.toMillis(Duration.fromInputUnsafe(timeout));\nconst propertyTestOptions = timeout => typeof timeout === \"number\" ? undefined : timeout;\nconst checkOptions = timeout => propertyTestOptions(timeout)?.arbitrary;\nconst compileArbitraryInput = input => Arbitrary.isArbitrary(input) ? input : Arbitrary.schema(input);\nconst makeArbitrary = arbitraries => Arbitrary.all(Array.isArray(arbitraries) ? arbitraries.map(compileArbitraryInput) : Object.fromEntries(Object.entries(arbitraries).map(([key, input]) => [key, compileArbitraryInput(input)])));\nconst normalizeProperty = (property, value) => Effect.catchCause(Effect.suspend(() => {\n const output = property(value);\n return Effect.isEffect(output) ? output : Effect.succeed(output);\n}), cause => Cause.hasInterrupts(cause) ? Effect.failCause(cause) : Effect.fail(cause));\nconst runCheck = (ctx, arbitrary, property, options) => runTest(ctx)(Effect.flatMapEager(Arbitrary.checkEffect(arbitrary, value => normalizeProperty(property, value), options), result => {\n const failure = Arbitrary.formatCheckFailure(result);\n return failure === undefined ? Effect.void : Effect.die(new Error(failure));\n}));\n// Vitest decides which fixtures to set up by parsing the source of a test\n// function's context parameter, and there is no public API to supply the names\n// for a wrapper, so wrappers expose the source of the function they call.\nconst withFixturesOf = (source, f) => Object.defineProperty(f, \"toString\", {\n value: () => source.toString()\n});\nconst makeItProxy = (it, overrides) => new Proxy(it, {\n apply(target, thisArg, argArray) {\n return Reflect.apply(target, thisArg, argArray);\n },\n get(target, property, receiver) {\n if (Object.hasOwn(overrides, property)) {\n return Reflect.get(overrides, property);\n }\n // do not bind: binding would strip vitest's static helpers (e.g. `describe.each`)\n return Reflect.get(target, property, receiver);\n }\n});\nconst collectTasks = (tasks, acc = []) => {\n for (let i = 0; i < tasks.length; i++) {\n const task = tasks[i];\n if (task.type === \"test\" && task.mode !== \"skip\" && task.mode !== \"todo\") {\n acc.push(task);\n } else if (task.tasks !== undefined) {\n collectTasks(task.tasks, acc);\n }\n }\n return acc;\n};\nconst registerProp = (it, name, arbitraries, property, timeout) => {\n const arbitrary = makeArbitrary(arbitraries);\n // Property callbacks receive only the base context; the empty source requests no fixtures.\n it(name, testOptions(timeout), withFixturesOf(() => {}, ctx => runCheck(ctx, arbitrary, values => property(values, ctx), checkOptions(timeout))));\n};\nconst makeTester = (mapEffect, it) => {\n const run = (ctx, args, self) => pipe(Effect.suspend(() => self(...args)), mapEffect, runTest(ctx));\n const register = test => (name, self, timeout) => test(name, testOptions(timeout), withFixturesOf(self, ctx => run(ctx, [ctx], self)));\n const each = cases => (name, self, timeout) => it.for(cases)(name, testOptions(timeout), withFixturesOf(self, (args, ctx) => run(ctx, [args, ctx], self).then(constVoid)));\n const prop = (name, arbitraries, self, timeout) => registerProp(it, name, arbitraries, (values, ctx) => Effect.mapEager(mapEffect(Effect.suspend(() => self(values, ctx))), value => value !== false), timeout);\n return Object.assign(register(it), {\n skip: register(it.skip),\n skipIf: condition => register(it.skipIf(condition)),\n runIf: condition => register(it.runIf(condition)),\n only: register(it.only),\n each,\n fails: register(it.fails),\n prop\n });\n};\nconst makeProp = it => (name, arbitraries, self, timeout) => registerProp(it, name, arbitraries, (values, ctx) => self(values, ctx) !== false, timeout);\nconst makeLayer = it => (layer_, options) => (...args) => {\n const excludeTestServices = options?.excludeTestServices ?? false;\n const withTestEnv = excludeTestServices ? layer_ : Layer.provideMerge(layer_, TestEnv);\n const memoMap = options?.memoMap ?? Effect.runSync(Layer.makeMemoMap);\n const scope = Effect.runSync(Scope.make());\n const contextEffect = Layer.buildWithMemoMap(withTestEnv, memoMap, scope).pipe(Effect.orDie, Effect.cached, Effect.runSync);\n let closed = false;\n const closeScope = () => {\n if (closed) {\n return Promise.resolve();\n }\n closed = true;\n // Layer cleanup must outlive the last test's already-aborted signal.\n return runPromise(Scope.close(scope, Exit.void));\n };\n const methods = makeItProxy(it, {\n effect: makeTester(effect => Effect.flatMap(contextEffect, context => effect.pipe(Effect.scoped, Effect.provide(context))), it),\n prop: makeProp(it),\n flakyTest,\n layer(nestedLayer, options) {\n return makeLayer(it)(Layer.provideMerge(nestedLayer, withTestEnv), {\n ...options,\n memoMap: Layer.forkMemoMapUnsafe(memoMap),\n excludeTestServices\n });\n }\n });\n if (args.length === 1) {\n const currentSuite = getCurrentSuite();\n const previousTasks = new Set(currentSuite.tasks);\n args[0](methods);\n const blockTasks = collectTasks(currentSuite.tasks.filter(task => !previousTasks.has(task)));\n if (blockTasks.length === 0) {\n V.afterAll(() => closeScope(), hookTimeout(options?.timeout));\n return;\n }\n const blockTaskSet = new Set(blockTasks);\n let remaining = blockTasks.length;\n V.beforeEach(\n // Destructured so Vitest can parse the hook once the suite defines fixtures.\n ({\n onTestFinished,\n signal,\n task\n }) => {\n if (!blockTaskSet.has(task)) {\n return;\n }\n onTestFinished(() => {\n remaining--;\n if (remaining === 0) {\n return closeScope();\n }\n });\n return runPromise(Effect.asVoid(contextEffect), {\n signal\n });\n }, hookTimeout(options?.timeout));\n V.afterAll(() => closeScope(), hookTimeout(options?.timeout));\n return;\n }\n const suiteOptions = options?.concurrent === undefined ? {} : {\n concurrent: options.concurrent\n };\n return V.describe(args[0], suiteOptions, () => {\n V.beforeAll(() => runPromise(Effect.asVoid(contextEffect)), hookTimeout(options?.timeout));\n V.afterAll(() => closeScope(), hookTimeout(options?.timeout));\n return args[1](methods);\n });\n};\n/** @internal */\nexport const flakyTest = (self, timeout = Duration.seconds(30)) => pipe(self, Effect.scoped, Effect.sandbox, Effect.retry(pipe(Schedule.recurs(10), Schedule.while(_ => Effect.succeed(Duration.isLessThanOrEqualTo(Duration.fromInputUnsafe(_.elapsed), Duration.fromInputUnsafe(timeout)))))), Effect.orDie);\n/** @internal */\nexport const makeMethods = it => makeItProxy(it, {\n effect: makeTester(flow(Effect.scoped, Effect.provide(TestEnv)), it),\n live: makeTester(Effect.scoped, it),\n flakyTest,\n layer: makeLayer(it),\n prop: makeProp(it)\n});\n/** @internal */\nexport const it = /*#__PURE__*/makeMethods(V.it);\n/** @internal */\nexport const {\n /** @internal */\n effect,\n /** @internal */\n layer,\n /** @internal */\n live,\n /** @internal */\n prop\n} = it;\n/** @internal */\nexport const describeWrapped = (name, f) => V.describe(name, () => f(it));\n//# sourceMappingURL=internal.js.map","import * as internal from \"./internal/internal.js\";\n/**\n * Re-exports the `vitest` API unchanged.\n *\n * @stability unstable\n * @since 4.0.0\n */\nexport * from \"vitest\";\n/**\n * @since 4.0.0\n */\nexport const addEqualityTesters = internal.addEqualityTesters;\n/**\n * @since 4.0.0\n */\nexport const effect = internal.effect;\n/**\n * @since 4.0.0\n */\nexport const live = internal.live;\n/**\n * Share a `Layer` between multiple tests, optionally wrapping\n * the tests in a `describe` block if a name is provided.\n *\n * Named layers accept `concurrent` to override inherited suite concurrency.\n * Anonymous layers always inherit the enclosing suite's concurrency.\n * Use `ctx.expect` in concurrent tests for test-local snapshots and assertion counts.\n *\n * @since 4.0.0\n *\n * ```ts\n * import { assert, layer } from \"@effect/vitest\"\n * import { Effect, Layer, Context } from \"effect\"\n *\n * class Foo extends Context.Service<Foo, \"foo\">()(\"Foo\") {\n * static layer = Layer.succeed(Foo, \"foo\")\n * }\n *\n * class Bar extends Context.Service<Bar, \"bar\">()(\"Bar\") {\n * static layer = Layer.effect(\n * Bar,\n * Effect.map(Foo, () => \"bar\" as const)\n * )\n * }\n *\n * layer(Foo.layer)(\"layer\", (it) => {\n * it.effect(\"adds context\", () =>\n * Effect.gen(function*() {\n * const foo = yield* Foo\n * assert.strictEqual(foo, \"foo\")\n * }))\n *\n * it.layer(Bar.layer)(\"nested\", (it) => {\n * it.effect(\"adds context\", () =>\n * Effect.gen(function*() {\n * const foo = yield* Foo\n * const bar = yield* Bar\n * assert.strictEqual(foo, \"foo\")\n * assert.strictEqual(bar, \"bar\")\n * }))\n * })\n * })\n * ```\n */\nexport const layer = internal.layer;\n/**\n * @since 4.0.0\n */\nexport const flakyTest = internal.flakyTest;\n/**\n * @since 4.0.0\n */\nexport const prop = internal.prop;\n/**\n * @since 4.0.0\n */\n/**\n * @since 4.0.0\n */\nexport const it = internal.it;\n/**\n * Creates the Effect test helpers for a Vitest test API, such as one extended with fixtures.\n *\n * **Details**\n *\n * Tests receive the fixtures they destructure from their context. Vitest sets them up before the test and tears\n * them down after the test's scope closes, as it does for its own tests. `it.effect.each` passes the context\n * after the test case, and named and anonymous `it.layer` blocks keep the fixtures.\n *\n * **Gotchas**\n *\n * Vitest reads the destructured names to decide which fixtures to set up. Once any fixture is defined, a test that\n * takes the whole context as a plain parameter, such as `(ctx) =>`, fails with a `FixtureParseError`. Property\n * tests receive only the base test context and cannot request fixtures; auto fixtures still run.\n *\n * **Example** (Using a Vitest fixture in an Effect test)\n *\n * ```ts\n * import { assert, makeMethods, test } from \"@effect/vitest\"\n * import { Effect } from \"effect\"\n *\n * const it = makeMethods(\n * test.extend(\"config\", { scope: \"file\" }, () => ({ port: 3000 }))\n * )\n *\n * it.effect(\"reads the config fixture\", ({ config }) =>\n * Effect.sync(() => {\n * assert.strictEqual(config.port, 3000)\n * }))\n * ```\n *\n * @since 4.0.0\n */\nexport const makeMethods = internal.makeMethods;\n/**\n * @since 4.0.0\n */\nexport const describeWrapped = internal.describeWrapped;\n//# sourceMappingURL=index.js.map"],"x_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