@effect-uai/core 0.8.0 → 0.9.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/dist/{AiError-CAX_48RU.d.mts → AiError-CrdR1EQi.d.mts} +2 -2
- package/dist/{AiError-CAX_48RU.d.mts.map → AiError-CrdR1EQi.d.mts.map} +1 -1
- package/dist/{Audio-DPlTsNdz.d.mts → Audio-DDSKCkSe.d.mts} +2 -2
- package/dist/{Audio-DPlTsNdz.d.mts.map → Audio-DDSKCkSe.d.mts.map} +1 -1
- package/dist/{Image-HNmMpMTh.d.mts → Image-C_Zjpwhc.d.mts} +2 -2
- package/dist/{Image-HNmMpMTh.d.mts.map → Image-C_Zjpwhc.d.mts.map} +1 -1
- package/dist/{Items-7ljaVxH_.d.mts → Items-CgKD6Npw.d.mts} +13 -13
- package/dist/{Items-7ljaVxH_.d.mts.map → Items-CgKD6Npw.d.mts.map} +1 -1
- package/dist/Loop-B5_cqumi.d.mts +173 -0
- package/dist/Loop-B5_cqumi.d.mts.map +1 -0
- package/dist/{Media-D_CpcM1Z.d.mts → Media-DOLyaygI.d.mts} +1 -1
- package/dist/{Media-D_CpcM1Z.d.mts.map → Media-DOLyaygI.d.mts.map} +1 -1
- package/dist/{SandboxError-BvKypkJm.d.mts → SandboxError-CIrVDOMV.d.mts} +2 -2
- package/dist/{SandboxError-BvKypkJm.d.mts.map → SandboxError-CIrVDOMV.d.mts.map} +1 -1
- package/dist/{StructuredFormat-BbN4dosH.d.mts → StructuredFormat-CMJFD3sn.d.mts} +2 -2
- package/dist/{StructuredFormat-BbN4dosH.d.mts.map → StructuredFormat-CMJFD3sn.d.mts.map} +1 -1
- package/dist/Tool-0XUIT2A2.d.mts +232 -0
- package/dist/Tool-0XUIT2A2.d.mts.map +1 -0
- package/dist/ToolEvent-DYrAUJGs.d.mts +151 -0
- package/dist/ToolEvent-DYrAUJGs.d.mts.map +1 -0
- package/dist/ToolResult-BZd-cEWW.d.mts +151 -0
- package/dist/ToolResult-BZd-cEWW.d.mts.map +1 -0
- package/dist/Toolkit-BKC8b8Xo.d.mts +155 -0
- package/dist/Toolkit-BKC8b8Xo.d.mts.map +1 -0
- package/dist/{dist-DV5ISja1.mjs → dist-B04dlFHg.mjs} +3 -3
- package/dist/{dist-DV5ISja1.mjs.map → dist-B04dlFHg.mjs.map} +1 -1
- package/dist/dist-DWgRbDN3.mjs +140 -0
- package/dist/dist-DWgRbDN3.mjs.map +1 -0
- package/dist/domain/AiError.d.mts +1 -1
- package/dist/domain/Audio.d.mts +1 -1
- package/dist/domain/Image.d.mts +1 -1
- package/dist/domain/Items.d.mts +1 -1
- package/dist/domain/Media.d.mts +1 -1
- package/dist/domain/Music.d.mts +1 -1
- package/dist/domain/Turn.d.mts +4 -4
- package/dist/domain/Turn.test.mjs +1 -1
- package/dist/embedding-model/Embedding.d.mts +1 -1
- package/dist/embedding-model/EmbeddingModel.d.mts +1 -1
- package/dist/embedding-model/EmbeddingModel.test.mjs +1 -1
- package/dist/embedding-model/EmbeddingModel.test.mjs.map +1 -1
- package/dist/index.d.mts +14 -13
- package/dist/index.mjs +2 -1
- package/dist/language-model/LanguageModel.d.mts +10 -5
- package/dist/language-model/LanguageModel.d.mts.map +1 -1
- package/dist/language-model/LanguageModel.mjs.map +1 -1
- package/dist/language-model/LanguageModel.test.mjs +1 -1
- package/dist/loop/Loop.d.mts +2 -141
- package/dist/loop/Loop.mjs +16 -20
- package/dist/loop/Loop.mjs.map +1 -1
- package/dist/loop/Loop.test.mjs +18 -1
- package/dist/loop/Loop.test.mjs.map +1 -1
- package/dist/{magic-string.es-BgIV5Mu3.mjs → magic-string.es-Dk-MMA0F.mjs} +1 -1
- package/dist/{magic-string.es-BgIV5Mu3.mjs.map → magic-string.es-Dk-MMA0F.mjs.map} +1 -1
- package/dist/music-generator/MusicGenerator.d.mts +2 -2
- package/dist/music-generator/MusicGenerator.test.mjs +1 -1
- package/dist/observability/Metrics.d.mts +116 -28
- package/dist/observability/Metrics.d.mts.map +1 -1
- package/dist/observability/Metrics.mjs +250 -38
- package/dist/observability/Metrics.mjs.map +1 -1
- package/dist/observability/Metrics.test.d.mts +1 -0
- package/dist/observability/Metrics.test.mjs +187 -0
- package/dist/observability/Metrics.test.mjs.map +1 -0
- package/dist/observability/Telemetry.d.mts +37 -0
- package/dist/observability/Telemetry.d.mts.map +1 -0
- package/dist/observability/Telemetry.mjs +57 -0
- package/dist/observability/Telemetry.mjs.map +1 -0
- package/dist/observability/Telemetry.test.d.mts +1 -0
- package/dist/observability/Telemetry.test.mjs +92 -0
- package/dist/observability/Telemetry.test.mjs.map +1 -0
- package/dist/retry/Retry.d.mts +2 -2
- package/dist/retry/Retry.test.mjs +1 -1
- package/dist/sandbox/Sandbox.d.mts +1 -1
- package/dist/sandbox/SandboxError.d.mts +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +2 -2
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +1 -1
- package/dist/streaming/JSONL.d.mts +1 -1
- package/dist/streaming/JSONL.test.mjs +1 -1
- package/dist/streaming/SSE.test.mjs +1 -1
- package/dist/structured-format/StructuredFormat.d.mts +1 -1
- package/dist/structured-format/StructuredFormat.mjs.map +1 -1
- package/dist/structured-format/StructuredFormat.test.mjs +1 -1
- package/dist/testing/MockMusicGenerator.d.mts +1 -1
- package/dist/testing/MockProvider.d.mts +1 -1
- package/dist/testing/MockSpeechSynthesizer.d.mts +1 -1
- package/dist/tool/Approval.d.mts +3 -3
- package/dist/tool/Approval.test.mjs +35 -34
- package/dist/tool/Approval.test.mjs.map +1 -1
- package/dist/tool/HistoryCheck.d.mts +2 -2
- package/dist/tool/Tool.d.mts +2 -2
- package/dist/tool/Tool.mjs +112 -22
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/Tool.test.mjs +41 -3
- package/dist/tool/Tool.test.mjs.map +1 -1
- package/dist/tool/ToolEvent.d.mts +2 -151
- package/dist/tool/ToolResult.d.mts +2 -138
- package/dist/tool/ToolResult.mjs +18 -3
- package/dist/tool/ToolResult.mjs.map +1 -1
- package/dist/tool/Toolkit.d.mts +2 -73
- package/dist/tool/Toolkit.mjs +106 -28
- package/dist/tool/Toolkit.mjs.map +1 -1
- package/dist/tool/Toolkit.test.mjs +113 -7
- package/dist/tool/Toolkit.test.mjs.map +1 -1
- package/dist/transcriber/Transcriber.d.mts +2 -2
- package/dist/transcriber/Transcriber.test.mjs +1 -1
- package/dist/web-search/WebSearch.d.mts +1 -1
- package/dist/web-search/WebSearchTool.d.mts +2 -2
- package/dist/web-search/WebSearchTool.d.mts.map +1 -1
- package/dist/web-search/WebSearchTool.mjs.map +1 -1
- package/package.json +1 -1
- package/src/embedding-model/EmbeddingModel.test.ts +4 -0
- package/src/index.ts +1 -0
- package/src/language-model/LanguageModel.ts +7 -2
- package/src/loop/Loop.test.ts +22 -0
- package/src/loop/Loop.ts +27 -4
- package/src/observability/Metrics.test.ts +266 -0
- package/src/observability/Metrics.ts +505 -65
- package/src/observability/Telemetry.test.ts +123 -0
- package/src/observability/Telemetry.ts +96 -0
- package/src/structured-format/StructuredFormat.ts +4 -0
- package/src/tool/Approval.test.ts +22 -21
- package/src/tool/Tool.test.ts +55 -2
- package/src/tool/Tool.ts +221 -55
- package/src/tool/ToolResult.ts +22 -1
- package/src/tool/Toolkit.test.ts +168 -7
- package/src/tool/Toolkit.ts +336 -99
- package/src/web-search/WebSearchTool.ts +1 -1
- package/dist/Tool-BKiieFXk.d.mts +0 -102
- package/dist/Tool-BKiieFXk.d.mts.map +0 -1
- package/dist/loop/Loop.d.mts.map +0 -1
- package/dist/tool/ToolEvent.d.mts.map +0 -1
- package/dist/tool/ToolResult.d.mts.map +0 -1
- package/dist/tool/Toolkit.d.mts.map +0 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { a as describe, i as beforeAll, o as it$1, r as afterAll } from "./dist-B04dlFHg.mjs";
|
|
2
|
+
import * as Cause from "effect/Cause";
|
|
3
|
+
import * as Duration from "effect/Duration";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Exit from "effect/Exit";
|
|
6
|
+
import { flow, pipe } from "effect/Function";
|
|
7
|
+
import * as Layer from "effect/Layer";
|
|
8
|
+
import { isObject } from "effect/Predicate";
|
|
9
|
+
import * as Schedule from "effect/Schedule";
|
|
10
|
+
import * as Schema from "effect/Schema";
|
|
11
|
+
import * as Scope from "effect/Scope";
|
|
12
|
+
import * as fc from "effect/testing/FastCheck";
|
|
13
|
+
import * as TestClock from "effect/testing/TestClock";
|
|
14
|
+
import * as TestConsole from "effect/testing/TestConsole";
|
|
15
|
+
//#region ../../node_modules/.pnpm/@effect+vitest@4.0.0-beta.66_effect@4.0.0-beta.57_vitest@4.1.5_@types+node@25.6.0_vite@_d7d7dab69e8c36d4c2ec9ca466208ed9/node_modules/@effect/vitest/dist/internal/internal.js
|
|
16
|
+
/**
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
*/
|
|
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) => runPromise(effect, ctx);
|
|
29
|
+
const TestEnv = /* @__PURE__ */ Layer.mergeAll(TestConsole.layer, /* @__PURE__ */ TestClock.layer());
|
|
30
|
+
/** @internal */
|
|
31
|
+
const testOptions = (timeout) => typeof timeout === "number" ? { timeout } : timeout ?? {};
|
|
32
|
+
/** @internal */
|
|
33
|
+
const makeTester = (mapEffect, it = it$1) => {
|
|
34
|
+
const run = (ctx, args, self) => pipe(Effect.suspend(() => self(...args)), mapEffect, runTest(ctx));
|
|
35
|
+
const f = (name, self, timeout) => it(name, testOptions(timeout), (ctx) => run(ctx, [ctx], self));
|
|
36
|
+
const skip = (name, self, timeout) => it.skip(name, testOptions(timeout), (ctx) => run(ctx, [ctx], self));
|
|
37
|
+
const skipIf = (condition) => (name, self, timeout) => it.skipIf(condition)(name, testOptions(timeout), (ctx) => run(ctx, [ctx], self));
|
|
38
|
+
const runIf = (condition) => (name, self, timeout) => it.runIf(condition)(name, testOptions(timeout), (ctx) => run(ctx, [ctx], self));
|
|
39
|
+
const only = (name, self, timeout) => it.only(name, testOptions(timeout), (ctx) => run(ctx, [ctx], self));
|
|
40
|
+
const each = (cases) => (name, self, timeout) => it.for(cases)(name, testOptions(timeout), (args, ctx) => run(ctx, [args], self));
|
|
41
|
+
const fails = (name, self, timeout) => it$1.fails(name, testOptions(timeout), (ctx) => run(ctx, [ctx], self));
|
|
42
|
+
const prop = (name, arbitraries, self, timeout) => {
|
|
43
|
+
if (Array.isArray(arbitraries)) {
|
|
44
|
+
const arbs = arbitraries.map((arbitrary) => {
|
|
45
|
+
if (Schema.isSchema(arbitrary)) return Schema.toArbitrary(arbitrary);
|
|
46
|
+
return arbitrary;
|
|
47
|
+
});
|
|
48
|
+
return it(name, testOptions(timeout), (ctx) => fc.assert(fc.asyncProperty(...arbs, (...as) => run(ctx, [as, ctx], self)), isObject(timeout) ? timeout?.fastCheck : {}));
|
|
49
|
+
}
|
|
50
|
+
const arbs = fc.record(Object.keys(arbitraries).reduce(function(result, key) {
|
|
51
|
+
const arb = arbitraries[key];
|
|
52
|
+
if (Schema.isSchema(arb)) result[key] = Schema.toArbitrary(arb);
|
|
53
|
+
result[key] = arb;
|
|
54
|
+
return result;
|
|
55
|
+
}, {}));
|
|
56
|
+
return it(name, testOptions(timeout), (ctx) => fc.assert(fc.asyncProperty(arbs, (...as) => run(ctx, [as[0], ctx], self)), isObject(timeout) ? timeout?.fastCheck : {}));
|
|
57
|
+
};
|
|
58
|
+
return Object.assign(f, {
|
|
59
|
+
skip,
|
|
60
|
+
skipIf,
|
|
61
|
+
runIf,
|
|
62
|
+
only,
|
|
63
|
+
each,
|
|
64
|
+
fails,
|
|
65
|
+
prop
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
/** @internal */
|
|
69
|
+
const prop$1 = (name, arbitraries, self, timeout) => {
|
|
70
|
+
if (Array.isArray(arbitraries)) {
|
|
71
|
+
const arbs = arbitraries.map((arbitrary) => {
|
|
72
|
+
if (Schema.isSchema(arbitrary)) throw new Error("Schemas are not supported yet");
|
|
73
|
+
return arbitrary;
|
|
74
|
+
});
|
|
75
|
+
return it$1(name, testOptions(timeout), (ctx) => fc.assert(fc.property(...arbs, (...as) => self(as, ctx)), isObject(timeout) ? timeout?.fastCheck : {}));
|
|
76
|
+
}
|
|
77
|
+
const arbs = fc.record(Object.keys(arbitraries).reduce(function(result, key) {
|
|
78
|
+
const arb = arbitraries[key];
|
|
79
|
+
if (Schema.isSchema(arb)) throw new Error("Schemas are not supported yet");
|
|
80
|
+
result[key] = arb;
|
|
81
|
+
return result;
|
|
82
|
+
}, {}));
|
|
83
|
+
return it$1(name, testOptions(timeout), (ctx) => fc.assert(fc.property(arbs, (as) => self(as, ctx)), isObject(timeout) ? timeout?.fastCheck : {}));
|
|
84
|
+
};
|
|
85
|
+
/** @internal */
|
|
86
|
+
const layer$1 = (layer_, options) => (...args) => {
|
|
87
|
+
const excludeTestServices = options?.excludeTestServices ?? false;
|
|
88
|
+
const withTestEnv = excludeTestServices ? layer_ : Layer.provideMerge(layer_, TestEnv);
|
|
89
|
+
const memoMap = options?.memoMap ?? Effect.runSync(Layer.makeMemoMap);
|
|
90
|
+
const scope = Effect.runSync(Scope.make());
|
|
91
|
+
const contextEffect = Layer.buildWithMemoMap(withTestEnv, memoMap, scope).pipe(Effect.orDie, Effect.cached, Effect.runSync);
|
|
92
|
+
const makeIt = (it) => Object.assign(it, {
|
|
93
|
+
effect: makeTester((effect) => Effect.flatMap(contextEffect, (context) => effect.pipe(Effect.scoped, Effect.provide(context))), it),
|
|
94
|
+
prop: prop$1,
|
|
95
|
+
flakyTest: flakyTest$1,
|
|
96
|
+
layer(nestedLayer, options) {
|
|
97
|
+
return layer$1(Layer.provideMerge(nestedLayer, withTestEnv), {
|
|
98
|
+
...options,
|
|
99
|
+
memoMap,
|
|
100
|
+
excludeTestServices
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
if (args.length === 1) {
|
|
105
|
+
beforeAll(() => runPromise(Effect.asVoid(contextEffect)), options?.timeout ? Duration.toMillis(Duration.fromInputUnsafe(options.timeout)) : void 0);
|
|
106
|
+
afterAll(() => runPromise(Scope.close(scope, Exit.void)), options?.timeout ? Duration.toMillis(Duration.fromInputUnsafe(options.timeout)) : void 0);
|
|
107
|
+
return args[0](makeIt(it$1));
|
|
108
|
+
}
|
|
109
|
+
return describe(args[0], () => {
|
|
110
|
+
beforeAll(() => runPromise(Effect.asVoid(contextEffect)), options?.timeout ? Duration.toMillis(Duration.fromInputUnsafe(options.timeout)) : void 0);
|
|
111
|
+
afterAll(() => runPromise(Scope.close(scope, Exit.void)), options?.timeout ? Duration.toMillis(Duration.fromInputUnsafe(options.timeout)) : void 0);
|
|
112
|
+
return args[1](makeIt(it$1));
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
/** @internal */
|
|
116
|
+
const flakyTest$1 = (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);
|
|
117
|
+
/** @internal */
|
|
118
|
+
const makeMethods = (it) => Object.assign(it, {
|
|
119
|
+
effect: makeTester(flow(Effect.scoped, Effect.provide(TestEnv)), it),
|
|
120
|
+
live: makeTester(Effect.scoped, it),
|
|
121
|
+
flakyTest: flakyTest$1,
|
|
122
|
+
layer: layer$1,
|
|
123
|
+
prop: prop$1
|
|
124
|
+
});
|
|
125
|
+
/** @internal */
|
|
126
|
+
const { effect: effect$1, live: live$1 } = /* @__PURE__ */ makeMethods(it$1);
|
|
127
|
+
/**
|
|
128
|
+
* @since 1.0.0
|
|
129
|
+
*/
|
|
130
|
+
const it = /* @__PURE__ */ Object.assign(it$1, {
|
|
131
|
+
effect: effect$1,
|
|
132
|
+
live: live$1,
|
|
133
|
+
flakyTest: flakyTest$1,
|
|
134
|
+
layer: layer$1,
|
|
135
|
+
prop: prop$1
|
|
136
|
+
});
|
|
137
|
+
//#endregion
|
|
138
|
+
export { it as t };
|
|
139
|
+
|
|
140
|
+
//# sourceMappingURL=dist-DWgRbDN3.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-DWgRbDN3.mjs","names":["V.it","prop","layer","V.describe","flakyTest","internal.effect","internal.live","internal.layer","internal.flakyTest","internal.prop","V.it"],"sources":["../../../node_modules/.pnpm/@effect+vitest@4.0.0-beta.66_effect@4.0.0-beta.57_vitest@4.1.5_@types+node@25.6.0_vite@_d7d7dab69e8c36d4c2ec9ca466208ed9/node_modules/@effect/vitest/dist/internal/internal.js","../../../node_modules/.pnpm/@effect+vitest@4.0.0-beta.66_effect@4.0.0-beta.57_vitest@4.1.5_@types+node@25.6.0_vite@_d7d7dab69e8c36d4c2ec9ca466208ed9/node_modules/@effect/vitest/dist/index.js"],"sourcesContent":["/**\n * @since 1.0.0\n */\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 { flow, pipe } from \"effect/Function\";\nimport * as Layer from \"effect/Layer\";\nimport { isObject } from \"effect/Predicate\";\nimport * as Schedule from \"effect/Schedule\";\nimport * as Schema from \"effect/Schema\";\nimport * as Scope from \"effect/Scope\";\nimport * as fc from \"effect/testing/FastCheck\";\nimport * as TestClock from \"effect/testing/TestClock\";\nimport * as TestConsole from \"effect/testing/TestConsole\";\nimport * as V from \"vitest\";\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 => runPromise(effect, ctx);\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 ?? {};\n/** @internal */\nconst makeTester = (mapEffect, it = V.it) => {\n const run = (ctx, args, self) => pipe(Effect.suspend(() => self(...args)), mapEffect, runTest(ctx));\n const f = (name, self, timeout) => it(name, testOptions(timeout), ctx => run(ctx, [ctx], self));\n const skip = (name, self, timeout) => it.skip(name, testOptions(timeout), ctx => run(ctx, [ctx], self));\n const skipIf = condition => (name, self, timeout) => it.skipIf(condition)(name, testOptions(timeout), ctx => run(ctx, [ctx], self));\n const runIf = condition => (name, self, timeout) => it.runIf(condition)(name, testOptions(timeout), ctx => run(ctx, [ctx], self));\n const only = (name, self, timeout) => it.only(name, testOptions(timeout), ctx => run(ctx, [ctx], self));\n const each = cases => (name, self, timeout) => it.for(cases)(name, testOptions(timeout), (args, ctx) => run(ctx, [args], self));\n const fails = (name, self, timeout) => V.it.fails(name, testOptions(timeout), ctx => run(ctx, [ctx], self));\n const prop = (name, arbitraries, self, timeout) => {\n if (Array.isArray(arbitraries)) {\n const arbs = arbitraries.map(arbitrary => {\n if (Schema.isSchema(arbitrary)) {\n return Schema.toArbitrary(arbitrary);\n }\n return arbitrary;\n });\n return it(name, testOptions(timeout), ctx =>\n // @ts-ignore\n fc.assert(\n // @ts-ignore\n fc.asyncProperty(...arbs, (...as) => run(ctx, [as, ctx], self)),\n // @ts-ignore\n isObject(timeout) ? timeout?.fastCheck : {}));\n }\n const arbs = fc.record(Object.keys(arbitraries).reduce(function (result, key) {\n const arb = arbitraries[key];\n if (Schema.isSchema(arb)) {\n result[key] = Schema.toArbitrary(arb);\n }\n result[key] = arb;\n return result;\n }, {}));\n return it(name, testOptions(timeout), ctx =>\n // @ts-ignore\n fc.assert(fc.asyncProperty(arbs, (...as) =>\n // @ts-ignore\n run(ctx, [as[0], ctx], self)),\n // @ts-ignore\n isObject(timeout) ? timeout?.fastCheck : {}));\n };\n return Object.assign(f, {\n skip,\n skipIf,\n runIf,\n only,\n each,\n fails,\n prop\n });\n};\n/** @internal */\nexport const prop = (name, arbitraries, self, timeout) => {\n if (Array.isArray(arbitraries)) {\n const arbs = arbitraries.map(arbitrary => {\n if (Schema.isSchema(arbitrary)) {\n throw new Error(\"Schemas are not supported yet\");\n }\n return arbitrary;\n });\n return V.it(name, testOptions(timeout),\n // @ts-ignore\n ctx => fc.assert(fc.property(...arbs, (...as) => self(as, ctx)), isObject(timeout) ? timeout?.fastCheck : {}));\n }\n const arbs = fc.record(Object.keys(arbitraries).reduce(function (result, key) {\n const arb = arbitraries[key];\n if (Schema.isSchema(arb)) {\n throw new Error(\"Schemas are not supported yet\");\n }\n result[key] = arb;\n return result;\n }, {}));\n return V.it(name, testOptions(timeout),\n // @ts-ignore\n ctx => fc.assert(fc.property(arbs, as => self(as, ctx)), isObject(timeout) ? timeout?.fastCheck : {}));\n};\n/** @internal */\nexport const layer = (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 const makeIt = it => Object.assign(it, {\n effect: makeTester(effect => Effect.flatMap(contextEffect, context => effect.pipe(Effect.scoped, Effect.provide(context))), it),\n prop,\n flakyTest,\n layer(nestedLayer, options) {\n return layer(Layer.provideMerge(nestedLayer, withTestEnv), {\n ...options,\n memoMap,\n excludeTestServices\n });\n }\n });\n if (args.length === 1) {\n V.beforeAll(() => runPromise(Effect.asVoid(contextEffect)), options?.timeout ? Duration.toMillis(Duration.fromInputUnsafe(options.timeout)) : undefined);\n V.afterAll(() => runPromise(Scope.close(scope, Exit.void)), options?.timeout ? Duration.toMillis(Duration.fromInputUnsafe(options.timeout)) : undefined);\n return args[0](makeIt(V.it));\n }\n return V.describe(args[0], () => {\n V.beforeAll(() => runPromise(Effect.asVoid(contextEffect)), options?.timeout ? Duration.toMillis(Duration.fromInputUnsafe(options.timeout)) : undefined);\n V.afterAll(() => runPromise(Scope.close(scope, Exit.void)), options?.timeout ? Duration.toMillis(Duration.fromInputUnsafe(options.timeout)) : undefined);\n return args[1](makeIt(V.it));\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 => Object.assign(it, {\n effect: makeTester(flow(Effect.scoped, Effect.provide(TestEnv)), it),\n live: makeTester(Effect.scoped, it),\n flakyTest,\n layer,\n prop\n});\n/** @internal */\nexport const {\n /** @internal */\n effect,\n /** @internal */\n live\n} = /*#__PURE__*/makeMethods(V.it);\n/** @internal */\nexport const describeWrapped = (name, f) => V.describe(name, it => f(makeMethods(it)));\n//# sourceMappingURL=internal.js.map","import * as V from \"vitest\";\nimport * as internal from \"./internal/internal.js\";\n/**\n * @since 1.0.0\n */\nexport * from \"vitest\";\n/**\n * @since 1.0.0\n */\nexport const addEqualityTesters = internal.addEqualityTesters;\n/**\n * @since 1.0.0\n */\nexport const effect = internal.effect;\n/**\n * @since 1.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 * @since 1.0.0\n *\n * ```ts\n * import { expect, layer } from \"@effect/vitest\"\n * import { Effect, Layer, Context } from \"effect\"\n *\n * class Foo extends Context.Service(\"Foo\")<Foo, \"foo\">() {\n * static Live = Layer.succeed(Foo, \"foo\")\n * }\n *\n * class Bar extends Context.Service(\"Bar\")<Bar, \"bar\">() {\n * static Live = Layer.effect(\n * Bar,\n * Effect.map(Foo, () => \"bar\" as const)\n * )\n * }\n *\n * layer(Foo.Live)(\"layer\", (it) => {\n * it.effect(\"adds context\", () =>\n * Effect.gen(function*() {\n * const foo = yield* Foo\n * expect(foo).toEqual(\"foo\")\n * }))\n *\n * it.layer(Bar.Live)(\"nested\", (it) => {\n * it.effect(\"adds context\", () =>\n * Effect.gen(function*() {\n * const foo = yield* Foo\n * const bar = yield* Bar\n * expect(foo).toEqual(\"foo\")\n * expect(bar).toEqual(\"bar\")\n * }))\n * })\n * })\n * ```\n */\nexport const layer = internal.layer;\n/**\n * @since 1.0.0\n */\nexport const flakyTest = internal.flakyTest;\n/**\n * @since 1.0.0\n */\nexport const prop = internal.prop;\n/**\n * @since 1.0.0\n */\n/** @ignored */\nconst methods = {\n effect,\n live,\n flakyTest,\n layer,\n prop\n};\n/**\n * @since 1.0.0\n */\nexport const it = /*#__PURE__*/Object.assign(V.it, methods);\n/**\n * @since 1.0.0\n */\nexport const makeMethods = internal.makeMethods;\n/**\n * @since 1.0.0\n */\nexport const describeWrapped = internal.describeWrapped;\n//# sourceMappingURL=index.js.map"],"x_google_ignoreList":[0,1],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAM,aAA0B,uBAAO,WAAW,WAAW,QAAQ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AAO,IAAI;CACjD,QAAQ,WAAW,KAAK,OAAO,QAAQ,OAAO,QAAQ,QAAQ,CAAC,EAAE,GAAG;CACpE,MAAM,WAAW,OAAO,QAAQ,GAAG;CACnC,WAAA;CACA,OAAA;CACA,MAAA;CACD,CAAC;;AAEF,MAAa,EAEX,QAAA,UAEA,MAAA,WACe,4BAAYJ,KAAK;;;;AClFlC,MAAa,KAAkB,uBAAO,OAAOU,MAAM;CATjD;CACA;CACA;CACA;CACA;CAKiD,CAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as Cancelled, c as GenerationFailed, d as RateLimited, f as Scope, h as Unsupported, i as AuthSubtype, l as IncompleteTurn, m as Unavailable, o as ContentFiltered, p as Timeout, r as AuthFailed, s as ContextLengthExceeded, t as AiError, u as InvalidRequest } from "../AiError-
|
|
1
|
+
import { a as Cancelled, c as GenerationFailed, d as RateLimited, f as Scope, h as Unsupported, i as AuthSubtype, l as IncompleteTurn, m as Unavailable, o as ContentFiltered, p as Timeout, r as AuthFailed, s as ContextLengthExceeded, t as AiError, u as InvalidRequest } from "../AiError-CrdR1EQi.mjs";
|
|
2
2
|
export { AiError, AuthFailed, AuthSubtype, Cancelled, ContentFiltered, ContextLengthExceeded, GenerationFailed, IncompleteTurn, InvalidRequest, RateLimited, Scope, Timeout, Unavailable, Unsupported };
|
package/dist/domain/Audio.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as AudioSource, c as isAudioBytes, i as AudioMimeType, l as isAudioUrl, n as AudioChunk, r as AudioFormat, s as isAudioBase64, t as AudioBlob } from "../Audio-
|
|
1
|
+
import { a as AudioSource, c as isAudioBytes, i as AudioMimeType, l as isAudioUrl, n as AudioChunk, r as AudioFormat, s as isAudioBase64, t as AudioBlob } from "../Audio-DDSKCkSe.mjs";
|
|
2
2
|
export { AudioBlob, AudioChunk, AudioFormat, AudioMimeType, AudioSource, isAudioBase64, isAudioBytes, isAudioUrl };
|
package/dist/domain/Image.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ImageUrlSource, c as imageBytes, d as isImageBytes, f as isImageUrl, i as ImageSource, l as imageUrl, n as ImageBytesSource, r as ImageMimeType, s as imageBase64, t as ImageBase64Source, u as isImageBase64 } from "../Image-
|
|
1
|
+
import { a as ImageUrlSource, c as imageBytes, d as isImageBytes, f as isImageUrl, i as ImageSource, l as imageUrl, n as ImageBytesSource, r as ImageMimeType, s as imageBase64, t as ImageBase64Source, u as isImageBase64 } from "../Image-C_Zjpwhc.mjs";
|
|
2
2
|
export { ImageBase64Source, ImageBytesSource, ImageMimeType, ImageSource, ImageUrlSource, imageBase64, imageBytes, imageUrl, isImageBase64, isImageBytes, isImageUrl };
|
package/dist/domain/Items.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as isReasoning, C as isContainerFileCitation, D as isInputText, E as isInputImage, F as systemText, I as toolCallOutput, L as userText, M as isToolCall, N as isToolCallOutput, O as isMessage, P as isUrlCitation, S as assistantText, T as isFilePath, _ as StopReason, a as FilePath, b as UrlCitation, c as InputText, d as Message, f as OutputText, g as Role, h as Refusal, i as FileCitation, j as isRefusal, k as isOutputText, l as InputTokensDetails, m as Reasoning, n as ContainerFileCitation, o as HistoryItem, p as OutputTokensDetails, r as ContentBlock, s as InputImage, t as Annotation, v as ToolCall, w as isFileCitation, x as Usage, y as ToolCallOutput } from "../Items-
|
|
1
|
+
import { A as isReasoning, C as isContainerFileCitation, D as isInputText, E as isInputImage, F as systemText, I as toolCallOutput, L as userText, M as isToolCall, N as isToolCallOutput, O as isMessage, P as isUrlCitation, S as assistantText, T as isFilePath, _ as StopReason, a as FilePath, b as UrlCitation, c as InputText, d as Message, f as OutputText, g as Role, h as Refusal, i as FileCitation, j as isRefusal, k as isOutputText, l as InputTokensDetails, m as Reasoning, n as ContainerFileCitation, o as HistoryItem, p as OutputTokensDetails, r as ContentBlock, s as InputImage, t as Annotation, v as ToolCall, w as isFileCitation, x as Usage, y as ToolCallOutput } from "../Items-CgKD6Npw.mjs";
|
|
2
2
|
export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath, HistoryItem, InputImage, InputText, InputTokensDetails, Message, OutputText, OutputTokensDetails, Reasoning, Refusal, Role, StopReason, ToolCall, ToolCallOutput, UrlCitation, Usage, assistantText, isContainerFileCitation, isFileCitation, isFilePath, isInputImage, isInputText, isMessage, isOutputText, isReasoning, isRefusal, isToolCall, isToolCallOutput, isUrlCitation, systemText, toolCallOutput, userText };
|
package/dist/domain/Media.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as isMediaUrl, i as MediaUrl, n as MediaBytes, o as isMediaBase64, r as MediaSource, s as isMediaBytes, t as MediaBase64 } from "../Media-
|
|
1
|
+
import { c as isMediaUrl, i as MediaUrl, n as MediaBytes, o as isMediaBase64, r as MediaSource, s as isMediaBytes, t as MediaBase64 } from "../Media-DOLyaygI.mjs";
|
|
2
2
|
export { MediaBase64, MediaBytes, MediaSource, MediaUrl, isMediaBase64, isMediaBytes, isMediaUrl };
|
package/dist/domain/Music.d.mts
CHANGED
package/dist/domain/Turn.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { i as ImageSource } from "../Image-
|
|
2
|
-
import { d as Message, m as Reasoning, o as HistoryItem, v as ToolCall, x as Usage, y as ToolCallOutput } from "../Items-
|
|
3
|
-
import { i as StructuredFormat, n as JsonParseError, r as StructuredDecodeError } from "../StructuredFormat-
|
|
1
|
+
import { i as ImageSource } from "../Image-C_Zjpwhc.mjs";
|
|
2
|
+
import { d as Message, m as Reasoning, o as HistoryItem, v as ToolCall, x as Usage, y as ToolCallOutput } from "../Items-CgKD6Npw.mjs";
|
|
3
|
+
import { i as StructuredFormat, n as JsonParseError, r as StructuredDecodeError } from "../StructuredFormat-CMJFD3sn.mjs";
|
|
4
4
|
import { Data, Effect, Schema, Stream } from "effect";
|
|
5
|
-
import * as _$effect_Types0 from "effect/Types";
|
|
6
5
|
import * as _$effect_Cause0 from "effect/Cause";
|
|
6
|
+
import * as _$effect_Types0 from "effect/Types";
|
|
7
7
|
import * as _$effect_Unify0 from "effect/Unify";
|
|
8
8
|
|
|
9
9
|
//#region src/domain/Turn.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assistantText, systemText, userText } from "./Items.mjs";
|
|
2
2
|
import { assistantText as assistantText$1, assistantTexts } from "./Turn.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { a as describe, n as globalExpect, o as it } from "../dist-B04dlFHg.mjs";
|
|
4
4
|
//#region src/domain/Turn.test.ts
|
|
5
5
|
const turnOf = (items) => ({
|
|
6
6
|
items,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { embed, embedMany } from "./EmbeddingModel.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { a as describe, o as it, t as import_dist } from "../dist-B04dlFHg.mjs";
|
|
3
3
|
//#region src/embedding-model/EmbeddingModel.test.ts
|
|
4
4
|
describe("EmbedResponse<E> conditional narrowing", () => {
|
|
5
5
|
it("defaults to Float32Embedding when E is undefined", () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddingModel.test.mjs","names":[],"sources":["../../src/embedding-model/EmbeddingModel.test.ts"],"sourcesContent":["import { Effect } from \"effect\"\nimport { describe, expectTypeOf, it } from \"vitest\"\nimport type * as AiError from \"../domain/AiError.js\"\nimport type {\n BinaryEmbedding,\n Float32Embedding,\n Int8Embedding,\n MultivectorEmbedding,\n SparseEmbedding,\n} from \"./Embedding.js\"\nimport {\n type EmbedEncoding,\n embed,\n embedMany,\n type EmbedManyResponse,\n type EmbedResponse,\n EmbeddingModel,\n} from \"./EmbeddingModel.js\"\n\n// Type-level tests only. The actual narrowing happens at the type system\n// boundary — the runtime impl is exercised in provider-specific test files.\ndescribe(\"EmbedResponse<E> conditional narrowing\", () => {\n it(\"defaults to Float32Embedding when E is undefined\", () => {\n expectTypeOf<EmbedResponse>().toEqualTypeOf<{\n readonly embedding: Float32Embedding\n readonly usage: import(\"./Embedding.js\").Usage\n }>()\n })\n\n it(\"maps each encoding literal to the matching Embedding variant\", () => {\n expectTypeOf<EmbedResponse<\"float32\">[\"embedding\"]>().toEqualTypeOf<Float32Embedding>()\n expectTypeOf<EmbedResponse<\"int8\">[\"embedding\"]>().toEqualTypeOf<Int8Embedding>()\n expectTypeOf<EmbedResponse<\"binary\">[\"embedding\"]>().toEqualTypeOf<BinaryEmbedding>()\n expectTypeOf<EmbedResponse<\"sparse\">[\"embedding\"]>().toEqualTypeOf<SparseEmbedding>()\n expectTypeOf<EmbedResponse<\"multivector\">[\"embedding\"]>().toEqualTypeOf<MultivectorEmbedding>()\n })\n\n it(\"falls back to the open Embedding union when E is the full EmbedEncoding\", () => {\n expectTypeOf<EmbedResponse<EmbedEncoding>[\"embedding\"]>().toEqualTypeOf<\n Float32Embedding | Int8Embedding | BinaryEmbedding | SparseEmbedding | MultivectorEmbedding\n >()\n })\n})\n\ndescribe(\"EmbedManyResponse<E> mirrors EmbedResponse<E>\", () => {\n it(\"defaults to ReadonlyArray<Float32Embedding>\", () => {\n expectTypeOf<EmbedManyResponse[\"embeddings\"]>().toEqualTypeOf<ReadonlyArray<Float32Embedding>>()\n })\n\n it(\"narrows per encoding\", () => {\n expectTypeOf<EmbedManyResponse<\"int8\">[\"embeddings\"]>().toEqualTypeOf<\n ReadonlyArray<Int8Embedding>\n >()\n })\n})\n\ndescribe(\"embed / embedMany free exports preserve E in their return type\", () => {\n it(\"embed with no encoding returns EmbedResponse<undefined> = Float32\", () => {\n const result = embed({ input: \"x\", model: \"m\" })\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedResponse<undefined>, AiError.AiError, EmbeddingModel>\n >()\n })\n\n it(\"embed with encoding: int8 returns EmbedResponse<int8>\", () => {\n const result = embed({ input: \"x\", model: \"m\", encoding: \"int8\" })\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedResponse<\"int8\">, AiError.AiError, EmbeddingModel>\n >()\n })\n\n it(\"embedMany with encoding: binary returns EmbedManyResponse<binary>\", () => {\n const result = embedMany({ inputs: [\"x\"], model: \"m\", encoding: \"binary\" })\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedManyResponse<\"binary\">, AiError.AiError, EmbeddingModel>\n >()\n })\n\n it(\"rejects non-dense encodings on the generic path (trimmed EmbedEncoding)\", () => {\n // `sparse` / `multivector` are Jina-only representation kinds, not part\n // of the cross-provider request set. Requesting them on the generic\n // helper is a compile error; they're reachable only via the typed\n // `JinaEmbedding` tag.\n // @ts-expect-error \"multivector\" is not an EmbedEncoding\n embedMany({ inputs: [\"x\"], model: \"m\", encoding: \"multivector\" })\n // @ts-expect-error \"sparse\" is not an EmbedEncoding\n embed({ input: \"x\", model: \"m\", encoding: \"sparse\" })\n })\n\n it(\"when the request is widened to CommonEmbedRequest, the response is the open union\", () => {\n // Demonstrates the documented case: annotating the request type erases\n // the literal `encoding` and the response falls back to `Embedding`.\n const req: { input: string; model: string; encoding?: EmbedEncoding } = {\n input: \"x\",\n model: \"m\",\n encoding: \"int8\",\n }\n const result = embed(req)\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedResponse<EmbedEncoding>, AiError.AiError, EmbeddingModel>\n >()\n })\n})\n"],"mappings":";;;AAqBA,SAAS,gDAAgD;AACvD,IAAG,0DAA0D;AAC3D,GAAA,GAAA,YAAA,eAA6B,CAAC,eAG1B;GACJ;AAEF,IAAG,sEAAsE;AACvE,GAAA,GAAA,YAAA,eAAqD,CAAC,eAAiC;AACvF,GAAA,GAAA,YAAA,eAAkD,CAAC,eAA8B;AACjF,GAAA,GAAA,YAAA,eAAoD,CAAC,eAAgC;AACrF,GAAA,GAAA,YAAA,eAAoD,CAAC,eAAgC;AACrF,GAAA,GAAA,YAAA,eAAyD,CAAC,eAAqC;GAC/F;AAEF,IAAG,iFAAiF;AAClF,GAAA,GAAA,YAAA,eAAyD,CAAC,eAEvD;GACH;EACF;AAEF,SAAS,uDAAuD;AAC9D,IAAG,qDAAqD;AACtD,GAAA,GAAA,YAAA,eAA+C,CAAC,eAAgD;GAChG;AAEF,IAAG,8BAA8B;AAC/B,GAAA,GAAA,YAAA,eAAuD,CAAC,eAErD;GACH;EACF;AAEF,SAAS,wEAAwE;AAC/E,IAAG,2EAA2E;AAE5E,GAAA,GAAA,YAAA,cADe,MAAM;GAAE,OAAO;GAAK,OAAO;GAAK,CAC5B,CAAC,CAAC,eAElB;GACH;AAEF,IAAG,+DAA+D;AAEhE,GAAA,GAAA,YAAA,cADe,MAAM;GAAE,OAAO;GAAK,OAAO;GAAK,UAAU;GAAQ,CAC9C,CAAC,CAAC,eAElB;GACH;AAEF,IAAG,2EAA2E;AAE5E,GAAA,GAAA,YAAA,cADe,UAAU;GAAE,QAAQ,CAAC,IAAI;GAAE,OAAO;GAAK,UAAU;GAAU,CACvD,CAAC,CAAC,eAElB;GACH;AAEF,IAAG,iFAAiF;
|
|
1
|
+
{"version":3,"file":"EmbeddingModel.test.mjs","names":[],"sources":["../../src/embedding-model/EmbeddingModel.test.ts"],"sourcesContent":["import { Effect } from \"effect\"\nimport { describe, expectTypeOf, it } from \"vitest\"\nimport type * as AiError from \"../domain/AiError.js\"\nimport type {\n BinaryEmbedding,\n Float32Embedding,\n Int8Embedding,\n MultivectorEmbedding,\n SparseEmbedding,\n} from \"./Embedding.js\"\nimport {\n type EmbedEncoding,\n embed,\n embedMany,\n type EmbedManyResponse,\n type EmbedResponse,\n EmbeddingModel,\n} from \"./EmbeddingModel.js\"\n\n// Type-level tests only. The actual narrowing happens at the type system\n// boundary — the runtime impl is exercised in provider-specific test files.\ndescribe(\"EmbedResponse<E> conditional narrowing\", () => {\n it(\"defaults to Float32Embedding when E is undefined\", () => {\n expectTypeOf<EmbedResponse>().toEqualTypeOf<{\n readonly embedding: Float32Embedding\n readonly usage: import(\"./Embedding.js\").Usage\n }>()\n })\n\n it(\"maps each encoding literal to the matching Embedding variant\", () => {\n expectTypeOf<EmbedResponse<\"float32\">[\"embedding\"]>().toEqualTypeOf<Float32Embedding>()\n expectTypeOf<EmbedResponse<\"int8\">[\"embedding\"]>().toEqualTypeOf<Int8Embedding>()\n expectTypeOf<EmbedResponse<\"binary\">[\"embedding\"]>().toEqualTypeOf<BinaryEmbedding>()\n expectTypeOf<EmbedResponse<\"sparse\">[\"embedding\"]>().toEqualTypeOf<SparseEmbedding>()\n expectTypeOf<EmbedResponse<\"multivector\">[\"embedding\"]>().toEqualTypeOf<MultivectorEmbedding>()\n })\n\n it(\"falls back to the open Embedding union when E is the full EmbedEncoding\", () => {\n expectTypeOf<EmbedResponse<EmbedEncoding>[\"embedding\"]>().toEqualTypeOf<\n Float32Embedding | Int8Embedding | BinaryEmbedding | SparseEmbedding | MultivectorEmbedding\n >()\n })\n})\n\ndescribe(\"EmbedManyResponse<E> mirrors EmbedResponse<E>\", () => {\n it(\"defaults to ReadonlyArray<Float32Embedding>\", () => {\n expectTypeOf<EmbedManyResponse[\"embeddings\"]>().toEqualTypeOf<ReadonlyArray<Float32Embedding>>()\n })\n\n it(\"narrows per encoding\", () => {\n expectTypeOf<EmbedManyResponse<\"int8\">[\"embeddings\"]>().toEqualTypeOf<\n ReadonlyArray<Int8Embedding>\n >()\n })\n})\n\ndescribe(\"embed / embedMany free exports preserve E in their return type\", () => {\n it(\"embed with no encoding returns EmbedResponse<undefined> = Float32\", () => {\n const result = embed({ input: \"x\", model: \"m\" })\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedResponse<undefined>, AiError.AiError, EmbeddingModel>\n >()\n })\n\n it(\"embed with encoding: int8 returns EmbedResponse<int8>\", () => {\n const result = embed({ input: \"x\", model: \"m\", encoding: \"int8\" })\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedResponse<\"int8\">, AiError.AiError, EmbeddingModel>\n >()\n })\n\n it(\"embedMany with encoding: binary returns EmbedManyResponse<binary>\", () => {\n const result = embedMany({ inputs: [\"x\"], model: \"m\", encoding: \"binary\" })\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedManyResponse<\"binary\">, AiError.AiError, EmbeddingModel>\n >()\n })\n\n it(\"rejects non-dense encodings on the generic path (trimmed EmbedEncoding)\", () => {\n // `sparse` / `multivector` are Jina-only representation kinds, not part\n // of the cross-provider request set. Requesting them on the generic\n // helper is a compile error; they're reachable only via the typed\n // `JinaEmbedding` tag.\n // These calls exist only to assert the encoding is a compile error; they\n // are intentionally never run, so the floating-effect check is off here.\n // @effect-diagnostics effect/floatingEffect:off\n // @ts-expect-error \"multivector\" is not an EmbedEncoding\n embedMany({ inputs: [\"x\"], model: \"m\", encoding: \"multivector\" })\n // @ts-expect-error \"sparse\" is not an EmbedEncoding\n embed({ input: \"x\", model: \"m\", encoding: \"sparse\" })\n // @effect-diagnostics effect/floatingEffect:error\n })\n\n it(\"when the request is widened to CommonEmbedRequest, the response is the open union\", () => {\n // Demonstrates the documented case: annotating the request type erases\n // the literal `encoding` and the response falls back to `Embedding`.\n const req: { input: string; model: string; encoding?: EmbedEncoding } = {\n input: \"x\",\n model: \"m\",\n encoding: \"int8\",\n }\n const result = embed(req)\n expectTypeOf(result).toEqualTypeOf<\n Effect.Effect<EmbedResponse<EmbedEncoding>, AiError.AiError, EmbeddingModel>\n >()\n })\n})\n"],"mappings":";;;AAqBA,SAAS,gDAAgD;AACvD,IAAG,0DAA0D;AAC3D,GAAA,GAAA,YAAA,eAA6B,CAAC,eAG1B;GACJ;AAEF,IAAG,sEAAsE;AACvE,GAAA,GAAA,YAAA,eAAqD,CAAC,eAAiC;AACvF,GAAA,GAAA,YAAA,eAAkD,CAAC,eAA8B;AACjF,GAAA,GAAA,YAAA,eAAoD,CAAC,eAAgC;AACrF,GAAA,GAAA,YAAA,eAAoD,CAAC,eAAgC;AACrF,GAAA,GAAA,YAAA,eAAyD,CAAC,eAAqC;GAC/F;AAEF,IAAG,iFAAiF;AAClF,GAAA,GAAA,YAAA,eAAyD,CAAC,eAEvD;GACH;EACF;AAEF,SAAS,uDAAuD;AAC9D,IAAG,qDAAqD;AACtD,GAAA,GAAA,YAAA,eAA+C,CAAC,eAAgD;GAChG;AAEF,IAAG,8BAA8B;AAC/B,GAAA,GAAA,YAAA,eAAuD,CAAC,eAErD;GACH;EACF;AAEF,SAAS,wEAAwE;AAC/E,IAAG,2EAA2E;AAE5E,GAAA,GAAA,YAAA,cADe,MAAM;GAAE,OAAO;GAAK,OAAO;GAAK,CAC5B,CAAC,CAAC,eAElB;GACH;AAEF,IAAG,+DAA+D;AAEhE,GAAA,GAAA,YAAA,cADe,MAAM;GAAE,OAAO;GAAK,OAAO;GAAK,UAAU;GAAQ,CAC9C,CAAC,CAAC,eAElB;GACH;AAEF,IAAG,2EAA2E;AAE5E,GAAA,GAAA,YAAA,cADe,UAAU;GAAE,QAAQ,CAAC,IAAI;GAAE,OAAO;GAAK,UAAU;GAAU,CACvD,CAAC,CAAC,eAElB;GACH;AAEF,IAAG,iFAAiF;AASlF,YAAU;GAAE,QAAQ,CAAC,IAAI;GAAE,OAAO;GAAK,UAAU;GAAe,CAAC;AAEjE,QAAM;GAAE,OAAO;GAAK,OAAO;GAAK,UAAU;GAAU,CAAC;GAErD;AAEF,IAAG,2FAA2F;AAS5F,GAAA,GAAA,YAAA,cADe,MAAM;GAJnB,OAAO;GACP,OAAO;GACP,UAAU;GAEY,CACL,CAAC,CAAC,eAElB;GACH;EACF"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { t as Capabilities_d_exports } from "./capabilities/Capabilities.mjs";
|
|
2
|
-
import { n as AiError_d_exports } from "./AiError-
|
|
3
|
-
import { a as Media_d_exports } from "./Media-
|
|
4
|
-
import { o as Audio_d_exports } from "./Audio-
|
|
5
|
-
import { o as Image_d_exports } from "./Image-
|
|
6
|
-
import { u as Items_d_exports } from "./Items-
|
|
2
|
+
import { n as AiError_d_exports } from "./AiError-CrdR1EQi.mjs";
|
|
3
|
+
import { a as Media_d_exports } from "./Media-DOLyaygI.mjs";
|
|
4
|
+
import { o as Audio_d_exports } from "./Audio-DDSKCkSe.mjs";
|
|
5
|
+
import { o as Image_d_exports } from "./Image-C_Zjpwhc.mjs";
|
|
6
|
+
import { u as Items_d_exports } from "./Items-CgKD6Npw.mjs";
|
|
7
7
|
import { t as Music_d_exports } from "./domain/Music.mjs";
|
|
8
8
|
import { t as Transcript_d_exports } from "./domain/Transcript.mjs";
|
|
9
|
-
import { a as StructuredFormat_d_exports } from "./StructuredFormat-
|
|
9
|
+
import { a as StructuredFormat_d_exports } from "./StructuredFormat-CMJFD3sn.mjs";
|
|
10
10
|
import { t as Turn_d_exports } from "./domain/Turn.mjs";
|
|
11
11
|
import { t as Embedding_d_exports } from "./embedding-model/Embedding.mjs";
|
|
12
12
|
import { t as EmbeddingModel_d_exports } from "./embedding-model/EmbeddingModel.mjs";
|
|
13
|
-
import {
|
|
13
|
+
import { t as Loop_d_exports } from "./Loop-B5_cqumi.mjs";
|
|
14
|
+
import { m as Tool_d_exports } from "./Tool-0XUIT2A2.mjs";
|
|
15
|
+
import { n as ToolResult_d_exports } from "./ToolResult-BZd-cEWW.mjs";
|
|
16
|
+
import { n as ToolEvent_d_exports } from "./ToolEvent-DYrAUJGs.mjs";
|
|
17
|
+
import { c as Toolkit_d_exports } from "./Toolkit-BKC8b8Xo.mjs";
|
|
14
18
|
import { t as LanguageModel_d_exports } from "./language-model/LanguageModel.mjs";
|
|
15
19
|
import { t as MusicGenerator_d_exports } from "./music-generator/MusicGenerator.mjs";
|
|
16
20
|
import { t as Memory_d_exports } from "./sandbox/Memory.mjs";
|
|
17
|
-
import { o as SandboxError_d_exports } from "./SandboxError-
|
|
21
|
+
import { o as SandboxError_d_exports } from "./SandboxError-CIrVDOMV.mjs";
|
|
18
22
|
import { t as Sandbox_d_exports } from "./sandbox/Sandbox.mjs";
|
|
19
23
|
import { t as SandboxImage_d_exports } from "./sandbox/SandboxImage.mjs";
|
|
20
24
|
import { t as SandboxNetwork_d_exports } from "./sandbox/SandboxNetwork.mjs";
|
|
@@ -23,15 +27,12 @@ import { t as Transcriber_d_exports } from "./transcriber/Transcriber.mjs";
|
|
|
23
27
|
import { t as WebSearch_d_exports } from "./web-search/WebSearch.mjs";
|
|
24
28
|
import { t as WebSearchTool_d_exports } from "./web-search/WebSearchTool.mjs";
|
|
25
29
|
import { t as Vector_d_exports } from "./math/Vector.mjs";
|
|
26
|
-
import { t as Loop_d_exports } from "./loop/Loop.mjs";
|
|
27
30
|
import { t as Retry_d_exports } from "./retry/Retry.mjs";
|
|
28
|
-
import { t as ToolResult_d_exports } from "./tool/ToolResult.mjs";
|
|
29
|
-
import { t as ToolEvent_d_exports } from "./tool/ToolEvent.mjs";
|
|
30
|
-
import { t as Toolkit_d_exports } from "./tool/Toolkit.mjs";
|
|
31
31
|
import { t as Approval_d_exports } from "./tool/Approval.mjs";
|
|
32
32
|
import { t as HistoryCheck_d_exports } from "./tool/HistoryCheck.mjs";
|
|
33
33
|
import { t as JSONL_d_exports } from "./streaming/JSONL.mjs";
|
|
34
34
|
import { t as Lines_d_exports } from "./streaming/Lines.mjs";
|
|
35
35
|
import { t as SSE_d_exports } from "./streaming/SSE.mjs";
|
|
36
36
|
import { t as Metrics_d_exports } from "./observability/Metrics.mjs";
|
|
37
|
-
|
|
37
|
+
import { t as Telemetry_d_exports } from "./observability/Telemetry.mjs";
|
|
38
|
+
export { AiError_d_exports as AiError, Approval_d_exports as Approval, Audio_d_exports as Audio, Capabilities_d_exports as Capabilities, Embedding_d_exports as Embedding, EmbeddingModel_d_exports as EmbeddingModel, HistoryCheck_d_exports as HistoryCheck, Image_d_exports as Image, Items_d_exports as Items, JSONL_d_exports as JSONL, LanguageModel_d_exports as LanguageModel, Lines_d_exports as Lines, Loop_d_exports as Loop, Media_d_exports as Media, Memory_d_exports as Memory, Metrics_d_exports as Metrics, Music_d_exports as Music, MusicGenerator_d_exports as MusicGenerator, Retry_d_exports as Retry, SSE_d_exports as SSE, Sandbox_d_exports as Sandbox, SandboxError_d_exports as SandboxError, SandboxImage_d_exports as SandboxImage, SandboxNetwork_d_exports as SandboxNetwork, SpeechSynthesizer_d_exports as SpeechSynthesizer, StructuredFormat_d_exports as StructuredFormat, Telemetry_d_exports as Telemetry, Tool_d_exports as Tool, ToolEvent_d_exports as ToolEvent, ToolResult_d_exports as ToolResult, Toolkit_d_exports as Toolkit, Transcriber_d_exports as Transcriber, Transcript_d_exports as Transcript, Turn_d_exports as Turn, Vector_d_exports as Vector, WebSearch_d_exports as WebSearch, WebSearchTool_d_exports as WebSearchTool };
|
package/dist/index.mjs
CHANGED
|
@@ -34,4 +34,5 @@ import { t as JSONL_exports } from "./streaming/JSONL.mjs";
|
|
|
34
34
|
import { t as Lines_exports } from "./streaming/Lines.mjs";
|
|
35
35
|
import { t as SSE_exports } from "./streaming/SSE.mjs";
|
|
36
36
|
import { t as Metrics_exports } from "./observability/Metrics.mjs";
|
|
37
|
-
|
|
37
|
+
import { t as Telemetry_exports } from "./observability/Telemetry.mjs";
|
|
38
|
+
export { AiError_exports as AiError, Approval_exports as Approval, Audio_exports as Audio, Capabilities_exports as Capabilities, Embedding_exports as Embedding, EmbeddingModel_exports as EmbeddingModel, HistoryCheck_exports as HistoryCheck, Image_exports as Image, Items_exports as Items, JSONL_exports as JSONL, LanguageModel_exports as LanguageModel, Lines_exports as Lines, Loop_exports as Loop, Media_exports as Media, Memory_exports as Memory, Metrics_exports as Metrics, Music_exports as Music, MusicGenerator_exports as MusicGenerator, Retry_exports as Retry, SSE_exports as SSE, Sandbox_exports as Sandbox, SandboxError_exports as SandboxError, SandboxImage_exports as SandboxImage, SandboxNetwork_exports as SandboxNetwork, SpeechSynthesizer_exports as SpeechSynthesizer, StructuredFormat_exports as StructuredFormat, Telemetry_exports as Telemetry, Tool_exports as Tool, ToolEvent_exports as ToolEvent, ToolResult_exports as ToolResult, Toolkit_exports as Toolkit, Transcriber_exports as Transcriber, Transcript_exports as Transcript, Turn_exports as Turn, Vector_exports as Vector, WebSearch_exports as WebSearch, WebSearchTool_exports as WebSearchTool };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as AiError } from "../AiError-
|
|
2
|
-
import { o as HistoryItem } from "../Items-
|
|
3
|
-
import { i as StructuredFormat } from "../StructuredFormat-
|
|
1
|
+
import { t as AiError } from "../AiError-CrdR1EQi.mjs";
|
|
2
|
+
import { o as HistoryItem } from "../Items-CgKD6Npw.mjs";
|
|
3
|
+
import { i as StructuredFormat } from "../StructuredFormat-CMJFD3sn.mjs";
|
|
4
4
|
import { Turn, TurnEvent } from "../domain/Turn.mjs";
|
|
5
|
-
import { o as
|
|
5
|
+
import { o as Toolkit } from "../Toolkit-BKC8b8Xo.mjs";
|
|
6
6
|
import { Context, Effect, Stream } from "effect";
|
|
7
7
|
|
|
8
8
|
//#region src/language-model/LanguageModel.d.ts
|
|
@@ -22,7 +22,12 @@ type CommonRequest = {
|
|
|
22
22
|
* so code that yields a typed provider tag gets autocompletion.
|
|
23
23
|
*/
|
|
24
24
|
readonly model: string;
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The model-visible tools for this request, as a `Toolkit`. The provider
|
|
27
|
+
* renders it to wire descriptors (`Tool.descriptorsOf`); omit it for a turn
|
|
28
|
+
* with no tools.
|
|
29
|
+
*/
|
|
30
|
+
readonly tools?: Toolkit;
|
|
26
31
|
readonly toolChoice?: "auto" | "required" | "none" | {
|
|
27
32
|
readonly type: "function";
|
|
28
33
|
readonly name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LanguageModel.d.mts","names":[],"sources":["../../src/language-model/LanguageModel.ts"],"mappings":";;;;;;;;;;;;;;;;;KAaY,aAAA;EAAA,SACD,OAAA,EAAS,aAAA,CAAc,WAAA;;;;AADlC;WAMW,KAAA
|
|
1
|
+
{"version":3,"file":"LanguageModel.d.mts","names":[],"sources":["../../src/language-model/LanguageModel.ts"],"mappings":";;;;;;;;;;;;;;;;;KAaY,aAAA;EAAA,SACD,OAAA,EAAS,aAAA,CAAc,WAAA;;;;AADlC;WAMW,KAAA;;;;;;WAMA,KAAA,GAAQ,OAAA;EAAA,SACR,UAAA;IAAA,SAIM,IAAA;IAAA,SAA2B,IAAA;EAAA;EAAA,SACjC,WAAA;EAAA,SACA,IAAA;EAAA,SACA,eAAA;EAPA;;;;;;EAAA,SAcA,UAAA,GAAa,gBAAA;AAAA;AAAA,KAGZ,oBAAA;EAAA,SACD,UAAA,GAAa,OAAA,EAAS,aAAA,KAAkB,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,OAAA;EAJnB;AAGzD;;;;;;;;EAHyD,SAc9C,IAAA,GAAO,OAAA,EAAS,aAAA,KAAkB,MAAA,CAAO,MAAA,CAAO,IAAA,EAAM,OAAA;AAAA;AAAA,cAChE,kBAAA;cAEY,aAAA,SAAsB,kBAAA;;;;cAOtB,UAAA,GACX,OAAA,EAAS,aAAA,KACR,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,OAAA,EAAiB,aAAA;;;;;;;cAShC,IAAA,GAAQ,OAAA,EAAS,aAAA,KAAgB,MAAA,CAAO,MAAA,CAAO,IAAA,EAAM,OAAA,EAAiB,aAAA;;;;;;;cAStE,cAAA,QACL,UAAA,GAAa,OAAA,EAAS,GAAA,KAAQ,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,OAAA,OAC5D,OAAA,EAAS,GAAA,KAAM,MAAA,CAAO,MAAA,CAAO,IAAA,EAAM,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LanguageModel.mjs","names":["Arr","AiError.IncompleteTurn"],"sources":["../../src/language-model/LanguageModel.ts"],"sourcesContent":["import { Array as Arr, Context, Effect, Option, Stream } from \"effect\"\nimport * as AiError from \"../domain/AiError.js\"\nimport type { HistoryItem } from \"../domain/Items.js\"\nimport type * as StructuredFormat from \"../structured-format/StructuredFormat.js\"\nimport type {
|
|
1
|
+
{"version":3,"file":"LanguageModel.mjs","names":["Arr","AiError.IncompleteTurn"],"sources":["../../src/language-model/LanguageModel.ts"],"sourcesContent":["import { Array as Arr, Context, Effect, Option, Stream } from \"effect\"\nimport * as AiError from \"../domain/AiError.js\"\nimport type { HistoryItem } from \"../domain/Items.js\"\nimport type * as StructuredFormat from \"../structured-format/StructuredFormat.js\"\nimport type { Toolkit } from \"../tool/Toolkit.js\"\nimport { isTurnComplete, type Turn, type TurnEvent } from \"../domain/Turn.js\"\n\n/**\n * Cross-provider request shape. Every call carries its own `history` and\n * `model` - models are not bound at layer construction. Anything specific\n * to a single provider (reasoning effort, prompt caching, store flags,\n * ...) lives in that provider's own request interface, which extends this.\n */\nexport type CommonRequest = {\n readonly history: ReadonlyArray<HistoryItem>\n /**\n * Model identifier. Each provider narrows this to its typed literal union,\n * so code that yields a typed provider tag gets autocompletion.\n */\n readonly model: string\n /**\n * The model-visible tools for this request, as a `Toolkit`. The provider\n * renders it to wire descriptors (`Tool.descriptorsOf`); omit it for a turn\n * with no tools.\n */\n readonly tools?: Toolkit\n readonly toolChoice?:\n | \"auto\"\n | \"required\"\n | \"none\"\n | { readonly type: \"function\"; readonly name: string }\n readonly temperature?: number\n readonly topP?: number\n readonly maxOutputTokens?: number\n /**\n * Schema-bound JSON output. The provider constrains the wire to match the\n * schema; pair with `Turn.decodeStructured` for runtime validation. Supported\n * across all current providers (OpenAI Responses json_schema, Anthropic\n * `output_config`, Gemini `responseJsonSchema`).\n */\n readonly structured?: StructuredFormat.StructuredFormat<unknown>\n}\n\nexport type LanguageModelService = {\n readonly streamTurn: (request: CommonRequest) => Stream.Stream<TurnEvent, AiError.AiError>\n /**\n * Drain a single turn and return the assembled `Turn` from the\n * terminal `TurnComplete` event. Fails with `IncompleteTurn` if the\n * stream ends without one.\n *\n * Most providers derive this from `streamTurn` via\n * {@link turnFromStream}; providers with a native non-streaming\n * endpoint may override with a cheaper direct call.\n */\n readonly turn: (request: CommonRequest) => Effect.Effect<Turn, AiError.AiError>\n}\n\nexport class LanguageModel extends Context.Service<LanguageModel, LanguageModelService>()(\n \"@betalyra/effect-uai/LanguageModel\",\n) {}\n\n/**\n * Stream the deltas of a single turn.\n */\nexport const streamTurn = (\n request: CommonRequest,\n): Stream.Stream<TurnEvent, AiError.AiError, LanguageModel> =>\n Stream.unwrap(Effect.map(LanguageModel.asEffect(), (m) => m.streamTurn(request)))\n\n/**\n * Drain a single turn and return the assembled `Turn`. Delegates to the\n * service's `turn` method — providers with a native complete endpoint\n * can override; the rest get the default streamTurn-drain via\n * {@link turnFromStream}.\n */\nexport const turn = (request: CommonRequest): Effect.Effect<Turn, AiError.AiError, LanguageModel> =>\n Effect.flatMap(LanguageModel.asEffect(), (m) => m.turn(request))\n\n/**\n * Build a `turn` implementation from a `streamTurn` implementation.\n * Providers without a native non-streaming endpoint use this to\n * populate the service's `turn` field. Generic over the request type so\n * provider-typed services (with their narrowed request) can reuse it.\n */\nexport const turnFromStream =\n <Req>(streamTurn: (request: Req) => Stream.Stream<TurnEvent, AiError.AiError>) =>\n (request: Req): Effect.Effect<Turn, AiError.AiError> =>\n streamTurn(request).pipe(\n Stream.runCollect,\n Effect.flatMap((events) =>\n Arr.findLast(events, isTurnComplete).pipe(\n Option.match({\n onNone: () => Effect.fail(new AiError.IncompleteTurn({})),\n onSome: (e) => Effect.succeed(e.turn),\n }),\n ),\n ),\n )\n"],"mappings":";;;;;;;;;;;AAyDA,IAAa,gBAAb,cAAmC,QAAQ,SAA8C,CACvF,qCACD,CAAC;;;;AAKF,MAAa,cACX,YAEA,OAAO,OAAO,OAAO,IAAI,cAAc,UAAU,GAAG,MAAM,EAAE,WAAW,QAAQ,CAAC,CAAC;;;;;;;AAQnF,MAAa,QAAQ,YACnB,OAAO,QAAQ,cAAc,UAAU,GAAG,MAAM,EAAE,KAAK,QAAQ,CAAC;;;;;;;AAQlE,MAAa,kBACL,gBACL,YACC,WAAW,QAAQ,CAAC,KAClB,OAAO,YACP,OAAO,SAAS,WACdA,MAAI,SAAS,QAAQ,eAAe,CAAC,KACnC,OAAO,MAAM;CACX,cAAc,OAAO,KAAK,IAAIC,eAAuB,EAAE,CAAC,CAAC;CACzD,SAAS,MAAM,OAAO,QAAQ,EAAE,KAAK;CACtC,CAAC,CACH,CACF,CACF"}
|
|
@@ -2,7 +2,7 @@ import { IncompleteTurn, RateLimited } from "../domain/AiError.mjs";
|
|
|
2
2
|
import { assistantText, userText } from "../domain/Items.mjs";
|
|
3
3
|
import { TurnEvent } from "../domain/Turn.mjs";
|
|
4
4
|
import { LanguageModel, turn, turnFromStream } from "./LanguageModel.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { a as describe, n as globalExpect, o as it } from "../dist-B04dlFHg.mjs";
|
|
6
6
|
import { layer } from "../testing/MockProvider.mjs";
|
|
7
7
|
import { Cause, Effect, Exit, Layer, Option, Stream } from "effect";
|
|
8
8
|
//#region src/language-model/LanguageModel.test.ts
|
package/dist/loop/Loop.d.mts
CHANGED
|
@@ -1,141 +1,2 @@
|
|
|
1
|
-
import { l as
|
|
2
|
-
|
|
3
|
-
import { Data, Effect, Stream, SubscriptionRef } from "effect";
|
|
4
|
-
|
|
5
|
-
//#region src/loop/Loop.d.ts
|
|
6
|
-
declare namespace Loop_d_exports {
|
|
7
|
-
export { Step, loop, loopOver, loopWithState, next, onTurnComplete, stop, value };
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* The tagged union a body emits per pull. `Value` carries a payload that
|
|
11
|
-
* flows downstream. `Next` ends the current iteration and continues with a
|
|
12
|
-
* new state. `Stop` ends the loop entirely with no carried state.
|
|
13
|
-
* `StopWith` also ends the loop but carries a final state that `loopOver`
|
|
14
|
-
* will thread to the next input and `loopWithState` will write to its
|
|
15
|
-
* `SubscriptionRef` before the loop ends. Plain `loop` has no next
|
|
16
|
-
* iteration to apply it to and treats `StopWith` like `Stop`.
|
|
17
|
-
*
|
|
18
|
-
* `Stop` is intentionally `{}` so the bare `stop()` helper doesn't
|
|
19
|
-
* constrain `S` from a body's stream type — every body has a `Stop`
|
|
20
|
-
* variant in its union, and forcing `S` to flow through it would break
|
|
21
|
-
* inference whenever the body never uses `next` / `stop(state)`.
|
|
22
|
-
*/
|
|
23
|
-
type Step<A, S> = Data.TaggedEnum<{
|
|
24
|
-
Value: {
|
|
25
|
-
readonly value: A;
|
|
26
|
-
};
|
|
27
|
-
Next: {
|
|
28
|
-
readonly state: S;
|
|
29
|
-
};
|
|
30
|
-
Stop: {};
|
|
31
|
-
StopWith: {
|
|
32
|
-
readonly state: S;
|
|
33
|
-
};
|
|
34
|
-
}>;
|
|
35
|
-
/** Wrap a value so it flows through the loop to downstream consumers. */
|
|
36
|
-
declare const value: <A>(a: A) => Step<A, never>;
|
|
37
|
-
/**
|
|
38
|
-
* End the current iteration and continue with a new state. Emits a single
|
|
39
|
-
* terminal `Next` step as a one-element stream, so it slots directly into a
|
|
40
|
-
* loop body or after a run of values: `values.pipe(Stream.concat(next(s)))`.
|
|
41
|
-
*/
|
|
42
|
-
declare const next: <S>(state: S) => Stream.Stream<Step<never, S>>;
|
|
43
|
-
/**
|
|
44
|
-
* End the loop. Called with no argument it emits a bare `Stop`; called with
|
|
45
|
-
* a state it emits `StopWith(state)` — `loopOver` threads that final state
|
|
46
|
-
* to the next input and `loopWithState` writes it to its `SubscriptionRef`
|
|
47
|
-
* before the loop ends. Either way it returns a single-element stream, so
|
|
48
|
-
* return it directly from a loop body.
|
|
49
|
-
*/
|
|
50
|
-
declare const stop: <S = never>(state?: S) => Stream.Stream<Step<never, S>>;
|
|
51
|
-
/**
|
|
52
|
-
* Lift a provider's `Stream<TurnEvent>` into a loop body's `Stream<Step<TurnEvent | A, S>>`.
|
|
53
|
-
* Each delta passes through as `value(delta)` (including the terminal
|
|
54
|
-
* `TurnComplete`, so the consumer sees turn boundaries naturally). Once
|
|
55
|
-
* the terminal arrives, `then(turn)` runs and its returned stream of loop
|
|
56
|
-
* steps (typically tool outputs followed by `next(state)` or `stop()`) is
|
|
57
|
-
* concatenated.
|
|
58
|
-
*
|
|
59
|
-
* Pre-pipe transforms (`Stream.tap` / `Stream.map` / `Stream.filter`) on
|
|
60
|
-
* the raw delta stream cover anything an `emit`-style callback would do.
|
|
61
|
-
*
|
|
62
|
-
* If the upstream ends without a `TurnComplete`, the resulting stream
|
|
63
|
-
* fails with `AiError.IncompleteTurn`. Catch it via `Stream.catchTag` if
|
|
64
|
-
* you want to recover.
|
|
65
|
-
*
|
|
66
|
-
* Dual: data-first `onTurnComplete(deltas, then)` and data-last
|
|
67
|
-
* `deltas.pipe(onTurnComplete(then))` both work.
|
|
68
|
-
*/
|
|
69
|
-
declare const onTurnComplete: {
|
|
70
|
-
<S, A, E2 = never, R2 = never>(then: (turn: Turn) => Effect.Effect<Stream.Stream<Step<A, S>, E2, R2>, E2, R2>): <E, R>(deltas: Stream.Stream<TurnEvent, E, R>) => Stream.Stream<Step<TurnEvent | A, S>, E | E2 | IncompleteTurn, R | R2>;
|
|
71
|
-
<S, A, E, R, E2 = never, R2 = never>(deltas: Stream.Stream<TurnEvent, E, R>, then: (turn: Turn) => Effect.Effect<Stream.Stream<Step<A, S>, E2, R2>, E2, R2>): Stream.Stream<Step<TurnEvent | A, S>, E | E2 | IncompleteTurn, R | R2>;
|
|
72
|
-
};
|
|
73
|
-
type LoopBody<S, A, E, R> = (state: S) => Stream.Stream<Step<A, S>, E, R> | Effect.Effect<Stream.Stream<Step<A, S>, E, R>, E, R>;
|
|
74
|
-
/**
|
|
75
|
-
* Drive a state-threaded loop body. Each iteration runs `body(state)` to get
|
|
76
|
-
* a `Stream<Step<A, S>>`; values flow downstream, `next(s)` continues with
|
|
77
|
-
* a new state, `stop()` ends the loop. See the file header for the full
|
|
78
|
-
* pull-based execution model.
|
|
79
|
-
*
|
|
80
|
-
* Dual: data-first `loop(initial, body)` and data-last `loop(body)(initial)`
|
|
81
|
-
* (or `pipe(initial, loop(body))`) both work.
|
|
82
|
-
*/
|
|
83
|
-
declare const loop: {
|
|
84
|
-
<S, A, E, R>(body: LoopBody<S, A, E, R>): (initial: S) => Stream.Stream<A, E, R>;
|
|
85
|
-
<S, A, E, R>(initial: S, body: LoopBody<S, A, E, R>): Stream.Stream<A, E, R>;
|
|
86
|
-
};
|
|
87
|
-
type LoopOverBody<S, I, A, E, R> = (state: S, input: I) => Stream.Stream<Step<A, S>, E, R> | Effect.Effect<Stream.Stream<Step<A, S>, E, R>, E, R>;
|
|
88
|
-
/**
|
|
89
|
-
* Input-driven sibling of `loop`. For each item pulled from the input
|
|
90
|
-
* stream, runs an inner seed-driven `loop` whose body is
|
|
91
|
-
* `(s) => body(s, item)`. State is threaded across input items.
|
|
92
|
-
*
|
|
93
|
-
* **Per-input semantics — the body emits standard `Step<A, S>`:**
|
|
94
|
-
* - `value(a)`: emit `a` downstream
|
|
95
|
-
* - `next(s)`: re-run the body with the SAME input and new state `s`
|
|
96
|
-
* (multi-turn within one input — e.g. multiple model turns + tool
|
|
97
|
-
* calls for one document)
|
|
98
|
-
* - `stop()`: end this input's inner loop, advance to the next input
|
|
99
|
-
* (state preserved)
|
|
100
|
-
* - body stream ending without a decision: same as `stop()` (advance)
|
|
101
|
-
*
|
|
102
|
-
* **Outer termination:** the input stream ending. To halt programmatically
|
|
103
|
-
* from within, end the input stream upstream (`Stream.takeWhile`, a
|
|
104
|
-
* `SubscriptionRef` gate, etc.). Reserving `stop()` for per-item
|
|
105
|
-
* advancement is what makes the common "stream of documents, multi-turn
|
|
106
|
-
* conversation per document" shape readable.
|
|
107
|
-
*
|
|
108
|
-
* Dual: data-first `loopOver(input, initial, body)` and data-last
|
|
109
|
-
* `input.pipe(loopOver(initial, body))` both work.
|
|
110
|
-
*/
|
|
111
|
-
declare const loopOver: {
|
|
112
|
-
<S, I, A, E, R>(initial: S, body: LoopOverBody<S, I, A, E, R>): <EI, RI>(input: Stream.Stream<I, EI, RI>) => Stream.Stream<A, E | EI, R | RI>;
|
|
113
|
-
<S, I, A, E, R, EI, RI>(input: Stream.Stream<I, EI, RI>, initial: S, body: LoopOverBody<S, I, A, E, R>): Stream.Stream<A, E | EI, R | RI>;
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* Like `loop`, but exposes the current loop state as a `SubscriptionRef`
|
|
117
|
-
* alongside the value stream.
|
|
118
|
-
*
|
|
119
|
-
* Allocates one `SubscriptionRef<S>` seeded with `initial`, then runs the
|
|
120
|
-
* loop with a wrapped body that taps every `Next(s)` step into the ref
|
|
121
|
-
* before forwarding it. The caller decides how to consume both channels:
|
|
122
|
-
*
|
|
123
|
-
* - **Final state**: drain the stream, then `SubscriptionRef.get(state)`
|
|
124
|
-
* - the ref holds the state from the last `Next` (or `initial` if the
|
|
125
|
-
* loop ended without advancing).
|
|
126
|
-
* - **Live transitions**: `SubscriptionRef.changes(state)` is a
|
|
127
|
-
* `Stream<S>` of every state observed; subscribe alongside the value
|
|
128
|
-
* stream.
|
|
129
|
-
* - **Mid-iteration peek**: `SubscriptionRef.get(state)` at any time.
|
|
130
|
-
*
|
|
131
|
-
* The returned stream and ref are independent of each other - the ref
|
|
132
|
-
* lives outside the stream's scope, so reading it after the stream
|
|
133
|
-
* completes is safe.
|
|
134
|
-
*/
|
|
135
|
-
declare const loopWithState: <S, A, E, R>(initial: S, body: LoopBody<S, A, E, R>) => Effect.Effect<{
|
|
136
|
-
readonly stream: Stream.Stream<A, E, R>;
|
|
137
|
-
readonly state: SubscriptionRef.SubscriptionRef<S>;
|
|
138
|
-
}>;
|
|
139
|
-
//#endregion
|
|
140
|
-
export { Step, loop, loopOver, loopWithState, next, onTurnComplete, stop, Loop_d_exports as t, value };
|
|
141
|
-
//# sourceMappingURL=Loop.d.mts.map
|
|
1
|
+
import { a as StopWith, c as loopOver, d as onTurnComplete, f as stop, i as Stop, l as loopWithState, n as Next, o as Value, p as value, r as Step, s as loop, u as next } from "../Loop-B5_cqumi.mjs";
|
|
2
|
+
export { Next, Step, Stop, StopWith, Value, loop, loopOver, loopWithState, next, onTurnComplete, stop, value };
|