@effect-uai/core 0.2.0 → 0.3.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/{AiError-CqmYjXyx.d.mts → AiError-CBuPHVKA.d.mts} +1 -1
- package/dist/{AiError-CqmYjXyx.d.mts.map → AiError-CBuPHVKA.d.mts.map} +1 -1
- package/dist/Image-BZmKfIdq.d.mts +61 -0
- package/dist/Image-BZmKfIdq.d.mts.map +1 -0
- package/dist/{Items-D1C2686t.d.mts → Items-CB8Bo3FI.d.mts} +132 -80
- package/dist/Items-CB8Bo3FI.d.mts.map +1 -0
- package/dist/Media-D_CpcM1Z.d.mts +57 -0
- package/dist/Media-D_CpcM1Z.d.mts.map +1 -0
- package/dist/{StructuredFormat-B5ueioNr.d.mts → StructuredFormat-BWq5Hd1O.d.mts} +5 -5
- package/dist/StructuredFormat-BWq5Hd1O.d.mts.map +1 -0
- package/dist/{Tool-5wxOCuOh.d.mts → Tool-DjVufH7i.d.mts} +13 -13
- package/dist/Tool-DjVufH7i.d.mts.map +1 -0
- package/dist/{Turn-Bi83du4I.d.mts → Turn-OPaILVIB.d.mts} +5 -11
- package/dist/Turn-OPaILVIB.d.mts.map +1 -0
- package/dist/{chunk-CfYAbeIz.mjs → chunk-uyGKjUfl.mjs} +2 -1
- package/dist/dist-DV5ISja1.mjs +13782 -0
- package/dist/dist-DV5ISja1.mjs.map +1 -0
- package/dist/domain/AiError.d.mts +1 -1
- package/dist/domain/AiError.mjs +1 -1
- package/dist/domain/Image.d.mts +2 -0
- package/dist/domain/Image.mjs +58 -0
- package/dist/domain/Image.mjs.map +1 -0
- package/dist/domain/Items.d.mts +2 -2
- package/dist/domain/Items.mjs +19 -42
- package/dist/domain/Items.mjs.map +1 -1
- package/dist/domain/Media.d.mts +2 -0
- package/dist/domain/Media.mjs +14 -0
- package/dist/domain/Media.mjs.map +1 -0
- package/dist/domain/Turn.d.mts +1 -1
- package/dist/domain/Turn.mjs +1 -1
- package/dist/embedding-model/Embedding.d.mts +107 -0
- package/dist/embedding-model/Embedding.d.mts.map +1 -0
- package/dist/embedding-model/Embedding.mjs +18 -0
- package/dist/embedding-model/Embedding.mjs.map +1 -0
- package/dist/embedding-model/EmbeddingModel.d.mts +97 -0
- package/dist/embedding-model/EmbeddingModel.d.mts.map +1 -0
- package/dist/embedding-model/EmbeddingModel.mjs +17 -0
- package/dist/embedding-model/EmbeddingModel.mjs.map +1 -0
- package/dist/index.d.mts +15 -7
- package/dist/index.mjs +10 -2
- package/dist/language-model/LanguageModel.d.mts +12 -20
- package/dist/language-model/LanguageModel.d.mts.map +1 -1
- package/dist/language-model/LanguageModel.mjs +3 -20
- package/dist/language-model/LanguageModel.mjs.map +1 -1
- package/dist/loop/Loop.d.mts +31 -7
- package/dist/loop/Loop.d.mts.map +1 -1
- package/dist/loop/Loop.mjs +39 -6
- package/dist/loop/Loop.mjs.map +1 -1
- package/dist/loop/Loop.test.d.mts +1 -0
- package/dist/loop/Loop.test.mjs +411 -0
- package/dist/loop/Loop.test.mjs.map +1 -0
- package/dist/magic-string.es-BgIV5Mu3.mjs +1013 -0
- package/dist/magic-string.es-BgIV5Mu3.mjs.map +1 -0
- package/dist/math/Vector.d.mts +47 -0
- package/dist/math/Vector.d.mts.map +1 -0
- package/dist/math/Vector.mjs +117 -0
- package/dist/math/Vector.mjs.map +1 -0
- package/dist/observability/Metrics.d.mts +2 -2
- package/dist/observability/Metrics.d.mts.map +1 -1
- package/dist/observability/Metrics.mjs +1 -1
- package/dist/observability/Metrics.mjs.map +1 -1
- package/dist/streaming/JSONL.mjs +1 -1
- package/dist/streaming/JSONL.test.d.mts +1 -0
- package/dist/streaming/JSONL.test.mjs +70 -0
- package/dist/streaming/JSONL.test.mjs.map +1 -0
- package/dist/streaming/Lines.mjs +1 -1
- package/dist/streaming/SSE.d.mts +2 -2
- package/dist/streaming/SSE.d.mts.map +1 -1
- package/dist/streaming/SSE.mjs +1 -1
- package/dist/streaming/SSE.mjs.map +1 -1
- package/dist/streaming/SSE.test.d.mts +1 -0
- package/dist/streaming/SSE.test.mjs +72 -0
- package/dist/streaming/SSE.test.mjs.map +1 -0
- package/dist/structured-format/StructuredFormat.d.mts +1 -1
- package/dist/structured-format/StructuredFormat.mjs +1 -1
- package/dist/structured-format/StructuredFormat.mjs.map +1 -1
- package/dist/testing/MockProvider.d.mts +6 -6
- package/dist/testing/MockProvider.d.mts.map +1 -1
- package/dist/testing/MockProvider.mjs.map +1 -1
- package/dist/tool/HistoryCheck.d.mts +6 -3
- package/dist/tool/HistoryCheck.d.mts.map +1 -1
- package/dist/tool/HistoryCheck.mjs +7 -1
- package/dist/tool/HistoryCheck.mjs.map +1 -1
- package/dist/tool/Outcome.d.mts +138 -2
- package/dist/tool/Outcome.d.mts.map +1 -0
- package/dist/tool/Outcome.mjs +32 -10
- package/dist/tool/Outcome.mjs.map +1 -1
- package/dist/tool/Resolvers.d.mts +11 -8
- package/dist/tool/Resolvers.d.mts.map +1 -1
- package/dist/tool/Resolvers.mjs +10 -1
- package/dist/tool/Resolvers.mjs.map +1 -1
- package/dist/tool/Resolvers.test.d.mts +1 -0
- package/dist/tool/Resolvers.test.mjs +317 -0
- package/dist/tool/Resolvers.test.mjs.map +1 -0
- package/dist/tool/Tool.d.mts +1 -1
- package/dist/tool/Tool.mjs +1 -1
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/ToolEvent.d.mts +151 -2
- package/dist/tool/ToolEvent.d.mts.map +1 -0
- package/dist/tool/ToolEvent.mjs +30 -4
- package/dist/tool/ToolEvent.mjs.map +1 -1
- package/dist/tool/Toolkit.d.mts +19 -10
- package/dist/tool/Toolkit.d.mts.map +1 -1
- package/dist/tool/Toolkit.mjs +5 -5
- package/dist/tool/Toolkit.mjs.map +1 -1
- package/dist/tool/Toolkit.test.d.mts +1 -0
- package/dist/tool/Toolkit.test.mjs +113 -0
- package/dist/tool/Toolkit.test.mjs.map +1 -0
- package/package.json +29 -13
- package/src/domain/Image.ts +75 -0
- package/src/domain/Items.ts +18 -47
- package/src/domain/Media.ts +61 -0
- package/src/embedding-model/Embedding.ts +117 -0
- package/src/embedding-model/EmbeddingModel.ts +107 -0
- package/src/index.ts +9 -1
- package/src/language-model/LanguageModel.ts +2 -22
- package/src/loop/Loop.test.ts +114 -2
- package/src/loop/Loop.ts +69 -5
- package/src/math/Vector.ts +138 -0
- package/src/observability/Metrics.ts +1 -1
- package/src/streaming/SSE.ts +1 -1
- package/src/structured-format/StructuredFormat.ts +2 -2
- package/src/testing/MockProvider.ts +2 -2
- package/src/tool/HistoryCheck.ts +2 -5
- package/src/tool/Outcome.ts +36 -36
- package/src/tool/Resolvers.test.ts +11 -35
- package/src/tool/Resolvers.ts +5 -14
- package/src/tool/Tool.ts +9 -9
- package/src/tool/ToolEvent.ts +28 -24
- package/src/tool/Toolkit.test.ts +97 -2
- package/src/tool/Toolkit.ts +57 -33
- package/dist/Items-D1C2686t.d.mts.map +0 -1
- package/dist/Outcome-GiaNvt7i.d.mts +0 -32
- package/dist/Outcome-GiaNvt7i.d.mts.map +0 -1
- package/dist/StructuredFormat-B5ueioNr.d.mts.map +0 -1
- package/dist/Tool-5wxOCuOh.d.mts.map +0 -1
- package/dist/ToolEvent-wTMgb2GO.d.mts +0 -29
- package/dist/ToolEvent-wTMgb2GO.d.mts.map +0 -1
- package/dist/Turn-Bi83du4I.d.mts.map +0 -1
- package/dist/match/Match.d.mts +0 -16
- package/dist/match/Match.d.mts.map +0 -1
- package/dist/match/Match.mjs +0 -15
- package/dist/match/Match.mjs.map +0 -1
- package/src/match/Match.ts +0 -9
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { fromBytes, toBytes } from "./SSE.mjs";
|
|
2
|
+
import { i as it, n as globalExpect, r as describe } from "../dist-DV5ISja1.mjs";
|
|
3
|
+
import { Effect, Stream } from "effect";
|
|
4
|
+
//#region src/streaming/SSE.test.ts
|
|
5
|
+
const enc = new TextEncoder();
|
|
6
|
+
const bytesOf = (...chunks) => Stream.fromIterable(chunks.map((c) => enc.encode(c)));
|
|
7
|
+
const collect = (s) => Effect.runPromise(Stream.runCollect(s));
|
|
8
|
+
describe("SSE.fromBytes", () => {
|
|
9
|
+
it("parses a single complete event", async () => {
|
|
10
|
+
globalExpect(await collect(fromBytes(bytesOf("event: foo\ndata: hello\n\n")))).toEqual([{
|
|
11
|
+
event: "foo",
|
|
12
|
+
data: "hello"
|
|
13
|
+
}]);
|
|
14
|
+
});
|
|
15
|
+
it("joins multiple data lines with \\n", async () => {
|
|
16
|
+
globalExpect(await collect(fromBytes(bytesOf("data: line1\ndata: line2\ndata: line3\n\n")))).toEqual([{ data: "line1\nline2\nline3" }]);
|
|
17
|
+
});
|
|
18
|
+
it("handles events split across chunk boundaries", async () => {
|
|
19
|
+
globalExpect(await collect(fromBytes(bytesOf("event: split\nda", "ta: hi\n", "\nevent: next\ndata: x\n\n")))).toEqual([{
|
|
20
|
+
event: "split",
|
|
21
|
+
data: "hi"
|
|
22
|
+
}, {
|
|
23
|
+
event: "next",
|
|
24
|
+
data: "x"
|
|
25
|
+
}]);
|
|
26
|
+
});
|
|
27
|
+
it("handles CRLF line endings", async () => {
|
|
28
|
+
globalExpect(await collect(fromBytes(bytesOf("event: a\r\ndata: b\r\n\r\n")))).toEqual([{
|
|
29
|
+
event: "a",
|
|
30
|
+
data: "b"
|
|
31
|
+
}]);
|
|
32
|
+
});
|
|
33
|
+
it("preserves id and skips comment lines", async () => {
|
|
34
|
+
globalExpect(await collect(fromBytes(bytesOf(": ping\nid: 42\ndata: x\n\n")))).toEqual([{
|
|
35
|
+
id: "42",
|
|
36
|
+
data: "x"
|
|
37
|
+
}]);
|
|
38
|
+
});
|
|
39
|
+
it("flushes a trailing event without a closing blank line", async () => {
|
|
40
|
+
globalExpect(await collect(fromBytes(bytesOf("data: tail")))).toEqual([{ data: "tail" }]);
|
|
41
|
+
});
|
|
42
|
+
it("ignores empty blocks between events", async () => {
|
|
43
|
+
globalExpect(await collect(fromBytes(bytesOf("data: a\n\n\n\ndata: b\n\n")))).toEqual([{ data: "a" }, { data: "b" }]);
|
|
44
|
+
});
|
|
45
|
+
it("handles a UTF-8 multi-byte char split across chunks", async () => {
|
|
46
|
+
const squidBytes = enc.encode("data: 🦑\n\n");
|
|
47
|
+
const a = squidBytes.slice(0, 8);
|
|
48
|
+
const b = squidBytes.slice(8);
|
|
49
|
+
globalExpect(await collect(fromBytes(Stream.fromIterable([a, b])))).toEqual([{ data: "🦑" }]);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe("SSE.toBytes round-trip", () => {
|
|
53
|
+
it("re-parses what it serializes", async () => {
|
|
54
|
+
const events = [
|
|
55
|
+
{
|
|
56
|
+
event: "a",
|
|
57
|
+
data: "hello"
|
|
58
|
+
},
|
|
59
|
+
{ data: "multi\nline" },
|
|
60
|
+
{
|
|
61
|
+
event: "b",
|
|
62
|
+
id: "7",
|
|
63
|
+
data: "x"
|
|
64
|
+
}
|
|
65
|
+
];
|
|
66
|
+
globalExpect(await collect(Stream.fromIterable(events).pipe(toBytes, fromBytes))).toEqual(events);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
//#endregion
|
|
70
|
+
export {};
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=SSE.test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SSE.test.mjs","names":["SSE.fromBytes","SSE.toBytes"],"sources":["../../src/streaming/SSE.test.ts"],"sourcesContent":["import { Effect, Stream } from \"effect\"\nimport { describe, expect, it } from \"vitest\"\nimport * as SSE from \"./SSE.js\"\n\nconst enc = new TextEncoder()\nconst bytesOf = (...chunks: ReadonlyArray<string>) =>\n Stream.fromIterable(chunks.map((c) => enc.encode(c)))\n\nconst collect = <A, E>(s: Stream.Stream<A, E>) => Effect.runPromise(Stream.runCollect(s))\n\ndescribe(\"SSE.fromBytes\", () => {\n it(\"parses a single complete event\", async () => {\n const out = await collect(SSE.fromBytes(bytesOf(\"event: foo\\ndata: hello\\n\\n\")))\n expect(out).toEqual([{ event: \"foo\", data: \"hello\" }])\n })\n\n it(\"joins multiple data lines with \\\\n\", async () => {\n const out = await collect(SSE.fromBytes(bytesOf(\"data: line1\\ndata: line2\\ndata: line3\\n\\n\")))\n expect(out).toEqual([{ data: \"line1\\nline2\\nline3\" }])\n })\n\n it(\"handles events split across chunk boundaries\", async () => {\n const out = await collect(\n SSE.fromBytes(bytesOf(\"event: split\\nda\", \"ta: hi\\n\", \"\\nevent: next\\ndata: x\\n\\n\")),\n )\n expect(out).toEqual([\n { event: \"split\", data: \"hi\" },\n { event: \"next\", data: \"x\" },\n ])\n })\n\n it(\"handles CRLF line endings\", async () => {\n const out = await collect(SSE.fromBytes(bytesOf(\"event: a\\r\\ndata: b\\r\\n\\r\\n\")))\n expect(out).toEqual([{ event: \"a\", data: \"b\" }])\n })\n\n it(\"preserves id and skips comment lines\", async () => {\n const out = await collect(SSE.fromBytes(bytesOf(\": ping\\nid: 42\\ndata: x\\n\\n\")))\n expect(out).toEqual([{ id: \"42\", data: \"x\" }])\n })\n\n it(\"flushes a trailing event without a closing blank line\", async () => {\n const out = await collect(SSE.fromBytes(bytesOf(\"data: tail\")))\n expect(out).toEqual([{ data: \"tail\" }])\n })\n\n it(\"ignores empty blocks between events\", async () => {\n const out = await collect(SSE.fromBytes(bytesOf(\"data: a\\n\\n\\n\\ndata: b\\n\\n\")))\n expect(out).toEqual([{ data: \"a\" }, { data: \"b\" }])\n })\n\n it(\"handles a UTF-8 multi-byte char split across chunks\", async () => {\n // \"🦑\" is 0xF0 0x9F 0xA6 0x91. Split between bytes 2 and 3.\n const squidBytes = enc.encode(\"data: 🦑\\n\\n\")\n const a = squidBytes.slice(0, 8) // \"data: \" + first 2 bytes of squid\n const b = squidBytes.slice(8) // remaining squid bytes + \"\\n\\n\"\n const out = await collect(SSE.fromBytes(Stream.fromIterable([a, b])))\n expect(out).toEqual([{ data: \"🦑\" }])\n })\n})\n\ndescribe(\"SSE.toBytes round-trip\", () => {\n it(\"re-parses what it serializes\", async () => {\n const events: ReadonlyArray<SSE.Event> = [\n { event: \"a\", data: \"hello\" },\n { data: \"multi\\nline\" },\n { event: \"b\", id: \"7\", data: \"x\" },\n ]\n const reparsed = await collect(Stream.fromIterable(events).pipe(SSE.toBytes, SSE.fromBytes))\n expect(reparsed).toEqual(events)\n })\n})\n"],"mappings":";;;;AAIA,MAAM,MAAM,IAAI,aAAa;AAC7B,MAAM,WAAW,GAAG,WAClB,OAAO,aAAa,OAAO,KAAK,MAAM,IAAI,OAAO,EAAE,CAAC,CAAC;AAEvD,MAAM,WAAiB,MAA2B,OAAO,WAAW,OAAO,WAAW,EAAE,CAAC;AAEzF,SAAS,uBAAuB;AAC9B,IAAG,kCAAkC,YAAY;AAE/C,eAAO,MADW,QAAQA,UAAc,QAAQ,8BAA8B,CAAC,CAAC,CACrE,CAAC,QAAQ,CAAC;GAAE,OAAO;GAAO,MAAM;GAAS,CAAC,CAAC;GACtD;AAEF,IAAG,sCAAsC,YAAY;AAEnD,eAAO,MADW,QAAQA,UAAc,QAAQ,4CAA4C,CAAC,CAAC,CACnF,CAAC,QAAQ,CAAC,EAAE,MAAM,uBAAuB,CAAC,CAAC;GACtD;AAEF,IAAG,gDAAgD,YAAY;AAI7D,eAAO,MAHW,QAChBA,UAAc,QAAQ,oBAAoB,YAAY,6BAA6B,CAAC,CACrF,CACU,CAAC,QAAQ,CAClB;GAAE,OAAO;GAAS,MAAM;GAAM,EAC9B;GAAE,OAAO;GAAQ,MAAM;GAAK,CAC7B,CAAC;GACF;AAEF,IAAG,6BAA6B,YAAY;AAE1C,eAAO,MADW,QAAQA,UAAc,QAAQ,8BAA8B,CAAC,CAAC,CACrE,CAAC,QAAQ,CAAC;GAAE,OAAO;GAAK,MAAM;GAAK,CAAC,CAAC;GAChD;AAEF,IAAG,wCAAwC,YAAY;AAErD,eAAO,MADW,QAAQA,UAAc,QAAQ,8BAA8B,CAAC,CAAC,CACrE,CAAC,QAAQ,CAAC;GAAE,IAAI;GAAM,MAAM;GAAK,CAAC,CAAC;GAC9C;AAEF,IAAG,yDAAyD,YAAY;AAEtE,eAAO,MADW,QAAQA,UAAc,QAAQ,aAAa,CAAC,CAAC,CACpD,CAAC,QAAQ,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC;GACvC;AAEF,IAAG,uCAAuC,YAAY;AAEpD,eAAO,MADW,QAAQA,UAAc,QAAQ,6BAA6B,CAAC,CAAC,CACpE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,EAAE,EAAE,MAAM,KAAK,CAAC,CAAC;GACnD;AAEF,IAAG,uDAAuD,YAAY;EAEpE,MAAM,aAAa,IAAI,OAAO,eAAe;EAC7C,MAAM,IAAI,WAAW,MAAM,GAAG,EAAE;EAChC,MAAM,IAAI,WAAW,MAAM,EAAE;AAE7B,eAAO,MADW,QAAQA,UAAc,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAC1D,CAAC,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAC,CAAC;GACrC;EACF;AAEF,SAAS,gCAAgC;AACvC,IAAG,gCAAgC,YAAY;EAC7C,MAAM,SAAmC;GACvC;IAAE,OAAO;IAAK,MAAM;IAAS;GAC7B,EAAE,MAAM,eAAe;GACvB;IAAE,OAAO;IAAK,IAAI;IAAK,MAAM;IAAK;GACnC;AAED,eAAO,MADgB,QAAQ,OAAO,aAAa,OAAO,CAAC,KAAKC,SAAaD,UAAc,CAAC,CAC5E,CAAC,QAAQ,OAAO;GAChC;EACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as decodeJsonLines, i as StructuredFormat, l as fromEffectSchema, n as JsonParseError, o as StructuredSchema, r as StructuredDecodeError, s as decode, t as DecodeIssue, u as parseJson } from "../StructuredFormat-
|
|
1
|
+
import { c as decodeJsonLines, i as StructuredFormat, l as fromEffectSchema, n as JsonParseError, o as StructuredSchema, r as StructuredDecodeError, s as decode, t as DecodeIssue, u as parseJson } from "../StructuredFormat-BWq5Hd1O.mjs";
|
|
2
2
|
export { DecodeIssue, JsonParseError, StructuredDecodeError, StructuredFormat, StructuredSchema, decode, decodeJsonLines, fromEffectSchema, parseJson };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
|
|
2
2
|
import { Data, Effect, Match, Schema, Stream, pipe } from "effect";
|
|
3
3
|
//#region src/structured-format/StructuredFormat.ts
|
|
4
4
|
var StructuredFormat_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructuredFormat.mjs","names":[],"sources":["../../src/structured-format/StructuredFormat.ts"],"sourcesContent":["import type { StandardJSONSchemaV1, StandardSchemaV1 } from \"@standard-schema/spec\"\nimport { Data, Effect, Match, Schema, Stream, pipe } from \"effect\"\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Cross-validator schema constraint for structured outputs. Any schema\n * implementing both Standard Schema (runtime validation) and Standard\n * JSON Schema (wire encoding) works directly: Zod 4+, Valibot, ArkType,\n * and Effect Schema after `fromEffectSchema`.\n */\nexport type StructuredSchema<Output = unknown> = StandardSchemaV1<unknown, Output> &\n StandardJSONSchemaV1<unknown, Output>\n\n/**\n * A schema-bound output the user wants the model to produce. Pairs the\n * cross-validator schema with metadata providers need (name, description,\n * strict-mode flag).\n */\nexport
|
|
1
|
+
{"version":3,"file":"StructuredFormat.mjs","names":[],"sources":["../../src/structured-format/StructuredFormat.ts"],"sourcesContent":["import type { StandardJSONSchemaV1, StandardSchemaV1 } from \"@standard-schema/spec\"\nimport { Data, Effect, Match, Schema, Stream, pipe } from \"effect\"\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Cross-validator schema constraint for structured outputs. Any schema\n * implementing both Standard Schema (runtime validation) and Standard\n * JSON Schema (wire encoding) works directly: Zod 4+, Valibot, ArkType,\n * and Effect Schema after `fromEffectSchema`.\n */\nexport type StructuredSchema<Output = unknown> = StandardSchemaV1<unknown, Output> &\n StandardJSONSchemaV1<unknown, Output>\n\n/**\n * A schema-bound output the user wants the model to produce. Pairs the\n * cross-validator schema with metadata providers need (name, description,\n * strict-mode flag).\n */\nexport type StructuredFormat<A> = {\n readonly name: string\n readonly description?: string\n readonly schema: StructuredSchema<A>\n /**\n * Provider strict-mode flag. OpenAI, Anthropic, and Mistral honour it\n * (constrained decoding); other providers ignore.\n */\n readonly strict?: boolean\n}\n\n/** A single path-scoped validation problem. Library-agnostic shape. */\nexport type DecodeIssue = {\n readonly path: ReadonlyArray<string | number>\n readonly message: string\n}\n\n// ---------------------------------------------------------------------------\n// Errors\n// ---------------------------------------------------------------------------\n\n/**\n * Schema validation failed. `raw` is the original text (or stringified\n * value) that failed; `issues` is a flat list of per-field problems.\n */\nexport class StructuredDecodeError extends Data.TaggedError(\"StructuredDecodeError\")<{\n readonly raw: string\n readonly issues: ReadonlyArray<DecodeIssue>\n}> {}\n\n/**\n * `JSON.parse` threw on a string that was supposed to be JSON. Distinct\n * from `StructuredDecodeError`: the bytes weren't even JSON.\n */\nexport class JsonParseError extends Data.TaggedError(\"StructuredJsonParseError\")<{\n readonly raw: string\n readonly cause: unknown\n}> {}\n\n// ---------------------------------------------------------------------------\n// Constructors\n// ---------------------------------------------------------------------------\n\n/**\n * Wrap an Effect `Schema` as a `StructuredFormat`. Effect Schema doesn't\n * natively implement Standard Schema; this helper installs the\n * `~standard` and JSON Schema interfaces.\n */\nexport const fromEffectSchema = <S extends Schema.Codec<any, any, never, any>>(\n schema: S,\n options?: {\n readonly name?: string\n readonly description?: string\n readonly strict?: boolean\n },\n): StructuredFormat<S[\"Type\"]> => ({\n name: options?.name ?? \"output\",\n schema: Schema.toStandardJSONSchemaV1(Schema.toStandardSchemaV1(schema)),\n ...(options?.description !== undefined && {\n description: options.description,\n }),\n ...(options?.strict !== undefined && { strict: options.strict }),\n})\n\n// ---------------------------------------------------------------------------\n// Standard Schema → DecodeIssue\n// ---------------------------------------------------------------------------\n\nconst propertyKeyToScalar = Match.type<PropertyKey>().pipe(\n Match.when(Match.string, (s) => s),\n Match.when(Match.number, (n) => n),\n Match.when(Match.symbol, (s) => s.toString()),\n Match.exhaustive,\n)\n\nconst segmentToKey = Match.type<PropertyKey | StandardSchemaV1.PathSegment>().pipe(\n Match.when(Match.string, (s) => s),\n Match.when(Match.number, (n) => n),\n Match.when(Match.symbol, (s) => s.toString()),\n Match.orElse((segment) => propertyKeyToScalar(segment.key)),\n)\n\nconst issueToDecode = (issue: StandardSchemaV1.Issue): DecodeIssue => ({\n path: (issue.path ?? []).map(segmentToKey),\n message: issue.message,\n})\n\n// ---------------------------------------------------------------------------\n// Decoding\n// ---------------------------------------------------------------------------\n\n/**\n * Validate an `unknown` against the format's schema. Returns the typed\n * value or a `StructuredDecodeError`. Standard Schema's `validate` may\n * be async; this function handles both sync and async results.\n */\nexport const decode =\n <A>(format: StructuredFormat<A>) =>\n (raw: unknown): Effect.Effect<A, StructuredDecodeError> =>\n pipe(\n Effect.promise(async () => format.schema[\"~standard\"].validate(raw)),\n Effect.flatMap((result) =>\n result.issues === undefined\n ? Effect.succeed(result.value)\n : Effect.fail(\n new StructuredDecodeError({\n raw: typeof raw === \"string\" ? raw : JSON.stringify(raw),\n issues: result.issues.map(issueToDecode),\n }),\n ),\n ),\n )\n\n/**\n * Parse a JSON string then validate against the format's schema. Two\n * failure modes: `JsonParseError` (bytes weren't JSON) and\n * `StructuredDecodeError` (JSON didn't match the schema).\n */\nexport const parseJson =\n <A>(format: StructuredFormat<A>) =>\n (raw: string): Effect.Effect<A, JsonParseError | StructuredDecodeError> =>\n pipe(\n Effect.try({\n try: () => JSON.parse(raw),\n catch: (cause) => new JsonParseError({ raw, cause }),\n }),\n Effect.flatMap(decode(format)),\n )\n\n/**\n * Stream operator: each input string is JSON-parsed and validated.\n * Failures surface in the stream's failure channel, distinguished by tag.\n */\nexport const decodeJsonLines =\n <A>(format: StructuredFormat<A>) =>\n <E, R>(\n self: Stream.Stream<string, E, R>,\n ): Stream.Stream<A, E | JsonParseError | StructuredDecodeError, R> =>\n self.pipe(Stream.mapEffect(parseJson(format)))\n"],"mappings":";;;;;;;;;;;;;;;AA8CA,IAAa,wBAAb,cAA2C,KAAK,YAAY,wBAAwB,CAGjF;;;;;AAMH,IAAa,iBAAb,cAAoC,KAAK,YAAY,2BAA2B,CAG7E;;;;;;AAWH,MAAa,oBACX,QACA,aAKiC;CACjC,MAAM,SAAS,QAAQ;CACvB,QAAQ,OAAO,uBAAuB,OAAO,mBAAmB,OAAO,CAAC;CACxE,GAAI,SAAS,gBAAgB,KAAA,KAAa,EACxC,aAAa,QAAQ,aACtB;CACD,GAAI,SAAS,WAAW,KAAA,KAAa,EAAE,QAAQ,QAAQ,QAAQ;CAChE;AAMD,MAAM,sBAAsB,MAAM,MAAmB,CAAC,KACpD,MAAM,KAAK,MAAM,SAAS,MAAM,EAAE,EAClC,MAAM,KAAK,MAAM,SAAS,MAAM,EAAE,EAClC,MAAM,KAAK,MAAM,SAAS,MAAM,EAAE,UAAU,CAAC,EAC7C,MAAM,WACP;AAED,MAAM,eAAe,MAAM,MAAkD,CAAC,KAC5E,MAAM,KAAK,MAAM,SAAS,MAAM,EAAE,EAClC,MAAM,KAAK,MAAM,SAAS,MAAM,EAAE,EAClC,MAAM,KAAK,MAAM,SAAS,MAAM,EAAE,UAAU,CAAC,EAC7C,MAAM,QAAQ,YAAY,oBAAoB,QAAQ,IAAI,CAAC,CAC5D;AAED,MAAM,iBAAiB,WAAgD;CACrE,OAAO,MAAM,QAAQ,EAAE,EAAE,IAAI,aAAa;CAC1C,SAAS,MAAM;CAChB;;;;;;AAWD,MAAa,UACP,YACH,QACC,KACE,OAAO,QAAQ,YAAY,OAAO,OAAO,aAAa,SAAS,IAAI,CAAC,EACpE,OAAO,SAAS,WACd,OAAO,WAAW,KAAA,IACd,OAAO,QAAQ,OAAO,MAAM,GAC5B,OAAO,KACL,IAAI,sBAAsB;CACxB,KAAK,OAAO,QAAQ,WAAW,MAAM,KAAK,UAAU,IAAI;CACxD,QAAQ,OAAO,OAAO,IAAI,cAAc;CACzC,CAAC,CACH,CACN,CACF;;;;;;AAOL,MAAa,aACP,YACH,QACC,KACE,OAAO,IAAI;CACT,WAAW,KAAK,MAAM,IAAI;CAC1B,QAAQ,UAAU,IAAI,eAAe;EAAE;EAAK;EAAO,CAAC;CACrD,CAAC,EACF,OAAO,QAAQ,OAAO,OAAO,CAAC,CAC/B;;;;;AAML,MAAa,mBACP,YAEF,SAEA,KAAK,KAAK,OAAO,UAAU,UAAU,OAAO,CAAC,CAAC"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as Turn } from "../Turn-
|
|
1
|
+
import { d as Item } from "../Items-CB8Bo3FI.mjs";
|
|
2
|
+
import { r as Turn } from "../Turn-OPaILVIB.mjs";
|
|
3
3
|
import { LanguageModel, LanguageModelService } from "../language-model/LanguageModel.mjs";
|
|
4
4
|
import { Duration, Effect, Layer } from "effect";
|
|
5
5
|
|
|
6
6
|
//#region src/testing/MockProvider.d.ts
|
|
7
|
-
|
|
7
|
+
type MockOptions = {
|
|
8
8
|
/**
|
|
9
9
|
* If set, deltas of each scripted turn are spaced by this duration via
|
|
10
10
|
* `Schedule.spaced`. Combine with `TestClock.adjust` for deterministic
|
|
11
11
|
* timing in tests.
|
|
12
12
|
*/
|
|
13
13
|
readonly deltaInterval?: Duration.Input;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
/**
|
|
16
16
|
* A scripted mock provider. Pre-canned `Turn` outputs are returned in order,
|
|
17
17
|
* one per call to `streamTurn`. Each scripted turn is split into synthetic
|
|
18
18
|
* deltas (text → tool_call_start → tool_call_args_delta → ... → turn_complete)
|
|
19
19
|
* so streaming consumers can see realistic delta shapes.
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
type MockRecorder = {
|
|
22
22
|
readonly calls: ReadonlyArray<{
|
|
23
23
|
readonly history: ReadonlyArray<Item>;
|
|
24
24
|
readonly turn: Turn;
|
|
25
25
|
}>;
|
|
26
|
-
}
|
|
26
|
+
};
|
|
27
27
|
declare const layer: (scriptedTurns: ReadonlyArray<Turn>, options?: MockOptions) => Layer.Layer<LanguageModel>;
|
|
28
28
|
/**
|
|
29
29
|
* Synchronous constructor that returns the `LanguageModelService` value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MockProvider.d.mts","names":[],"sources":["../../src/testing/MockProvider.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"MockProvider.d.mts","names":[],"sources":["../../src/testing/MockProvider.ts"],"mappings":";;;;;;KAMY,WAAA;;AAAZ;;;;WAMW,aAAA,GAAgB,QAAA,CAAS,KAAA;AAAA;;;;AASpC;;;KAAY,YAAA;EAAA,SACD,KAAA,EAAO,aAAA;IAAA,SACL,OAAA,EAAS,aAAA,CAAc,IAAA;IAAA,SACvB,IAAA,EAAM,IAAA;EAAA;AAAA;AAAA,cAqEN,KAAA,GACX,aAAA,EAAe,aAAA,CAAc,IAAA,GAC7B,OAAA,GAAU,WAAA,KACT,KAAA,CAAM,KAAA,CAAM,aAAA;;;;;;;cAQF,IAAA,GACX,aAAA,EAAe,aAAA,CAAc,IAAA,GAC7B,OAAA,GAAU,WAAA;EAAA,SAED,OAAA,EAAS,oBAAA;EAAA,SACT,QAAA,EAAU,MAAA,CAAO,MAAA,CAAO,YAAA;AAAA;;;;;cAiCtB,iBAAA,GACX,aAAA,EAAe,aAAA,CAAc,IAAA,GAC7B,OAAA,GAAU,WAAA;EAAA,SAED,KAAA,EAAO,KAAA,CAAM,KAAA,CAAM,aAAA;EAAA,SACnB,QAAA,EAAU,MAAA,CAAO,MAAA,CAAO,YAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MockProvider.mjs","names":["AiError.InvalidRequest"],"sources":["../../src/testing/MockProvider.ts"],"sourcesContent":["import { Duration, Effect, Layer, Ref, Schedule, Stream } from \"effect\"\nimport * as AiError from \"../domain/AiError.js\"\nimport type { Item } from \"../domain/Items.js\"\nimport { LanguageModel, type LanguageModelService } from \"../language-model/LanguageModel.js\"\nimport type { Turn, TurnEvent } from \"../domain/Turn.js\"\n\nexport
|
|
1
|
+
{"version":3,"file":"MockProvider.mjs","names":["AiError.InvalidRequest"],"sources":["../../src/testing/MockProvider.ts"],"sourcesContent":["import { Duration, Effect, Layer, Ref, Schedule, Stream } from \"effect\"\nimport * as AiError from \"../domain/AiError.js\"\nimport type { Item } from \"../domain/Items.js\"\nimport { LanguageModel, type LanguageModelService } from \"../language-model/LanguageModel.js\"\nimport type { Turn, TurnEvent } from \"../domain/Turn.js\"\n\nexport type MockOptions = {\n /**\n * If set, deltas of each scripted turn are spaced by this duration via\n * `Schedule.spaced`. Combine with `TestClock.adjust` for deterministic\n * timing in tests.\n */\n readonly deltaInterval?: Duration.Input\n}\n\n/**\n * A scripted mock provider. Pre-canned `Turn` outputs are returned in order,\n * one per call to `streamTurn`. Each scripted turn is split into synthetic\n * deltas (text → tool_call_start → tool_call_args_delta → ... → turn_complete)\n * so streaming consumers can see realistic delta shapes.\n */\nexport type MockRecorder = {\n readonly calls: ReadonlyArray<{\n readonly history: ReadonlyArray<Item>\n readonly turn: Turn\n }>\n}\n\nconst turnToDeltas = (turn: Turn): ReadonlyArray<TurnEvent> => {\n const deltas: TurnEvent[] = []\n for (const item of turn.items) {\n if (item.type === \"message\" && item.role === \"assistant\") {\n for (const block of item.content) {\n if (block.type === \"output_text\") {\n deltas.push({ type: \"text_delta\", text: block.text })\n }\n }\n } else if (item.type === \"function_call\") {\n deltas.push({\n type: \"tool_call_start\",\n call_id: item.call_id,\n name: item.name,\n })\n deltas.push({\n type: \"tool_call_args_delta\",\n call_id: item.call_id,\n delta: item.arguments,\n })\n } else if (item.type === \"reasoning\" && item.summary !== undefined) {\n deltas.push({ type: \"reasoning_delta\", text: item.summary, kind: \"summary\" })\n }\n }\n deltas.push({ type: \"turn_complete\", turn })\n return deltas\n}\n\nconst pacedDeltas = (turn: Turn, options?: MockOptions): Stream.Stream<TurnEvent> => {\n const base = Stream.fromIterable(turnToDeltas(turn))\n return options?.deltaInterval === undefined\n ? base\n : base.pipe(Stream.schedule(Schedule.spaced(options.deltaInterval)))\n}\n\nconst makeService = (\n scriptedTurns: ReadonlyArray<Turn>,\n options?: MockOptions,\n recordCall?: (history: ReadonlyArray<Item>, turn: Turn) => Effect.Effect<void>,\n) =>\n Effect.gen(function* () {\n const cursor = yield* Ref.make(0)\n return LanguageModel.of({\n streamTurn: (request) =>\n Stream.unwrap(\n Effect.gen(function* () {\n const i = yield* Ref.getAndUpdate(cursor, (n) => n + 1)\n if (i >= scriptedTurns.length) {\n return Stream.fail(\n new AiError.InvalidRequest({\n provider: \"mock\",\n raw: `MockProvider exhausted: ${scriptedTurns.length} turns scripted, but call ${i + 1} was made`,\n }),\n )\n }\n const turn = scriptedTurns[i]!\n if (recordCall !== undefined) {\n yield* recordCall(request.history, turn)\n }\n return pacedDeltas(turn, options)\n }),\n ),\n })\n })\n\nexport const layer = (\n scriptedTurns: ReadonlyArray<Turn>,\n options?: MockOptions,\n): Layer.Layer<LanguageModel> => Layer.effect(LanguageModel, makeService(scriptedTurns, options))\n\n/**\n * Synchronous constructor that returns the `LanguageModelService` value\n * directly, plus a recorder. Use this when you want to swap models\n * mid-stream via `Effect.provideService` instead of providing one model\n * for the whole program via `Layer`.\n */\nexport const make = (\n scriptedTurns: ReadonlyArray<Turn>,\n options?: MockOptions,\n): {\n readonly service: LanguageModelService\n readonly recorder: Effect.Effect<MockRecorder>\n} => {\n const cursor = Ref.makeUnsafe(0)\n const callsRef = Ref.makeUnsafe<ReadonlyArray<{ history: ReadonlyArray<Item>; turn: Turn }>>([])\n const service: LanguageModelService = {\n streamTurn: (request) =>\n Stream.unwrap(\n Effect.gen(function* () {\n const i = yield* Ref.getAndUpdate(cursor, (n) => n + 1)\n if (i >= scriptedTurns.length) {\n return Stream.fail(\n new AiError.InvalidRequest({\n provider: \"mock\",\n raw: `MockProvider exhausted: ${scriptedTurns.length} turns scripted, but call ${i + 1} was made`,\n }),\n )\n }\n const turn = scriptedTurns[i]!\n yield* Ref.update(callsRef, (xs) => [...xs, { history: request.history, turn }])\n return pacedDeltas(turn, options)\n }),\n ),\n }\n return {\n service,\n recorder: Ref.get(callsRef).pipe(Effect.map((calls) => ({ calls }))),\n }\n}\n\n/**\n * Same as `layer`, but also exposes a recorder that captures every call\n * (history + returned turn).\n */\nexport const layerWithRecorder = (\n scriptedTurns: ReadonlyArray<Turn>,\n options?: MockOptions,\n): {\n readonly layer: Layer.Layer<LanguageModel>\n readonly recorder: Effect.Effect<MockRecorder>\n} => {\n const callsRef = Ref.makeUnsafe<ReadonlyArray<{ history: ReadonlyArray<Item>; turn: Turn }>>([])\n const live = Layer.effect(\n LanguageModel,\n makeService(scriptedTurns, options, (history, turn) =>\n Ref.update(callsRef, (xs) => [...xs, { history, turn }]),\n ),\n )\n return {\n layer: live,\n recorder: Ref.get(callsRef).pipe(Effect.map((calls) => ({ calls }))),\n }\n}\n"],"mappings":";;;;AA4BA,MAAM,gBAAgB,SAAyC;CAC7D,MAAM,SAAsB,EAAE;AAC9B,MAAK,MAAM,QAAQ,KAAK,MACtB,KAAI,KAAK,SAAS,aAAa,KAAK,SAAS;OACtC,MAAM,SAAS,KAAK,QACvB,KAAI,MAAM,SAAS,cACjB,QAAO,KAAK;GAAE,MAAM;GAAc,MAAM,MAAM;GAAM,CAAC;YAGhD,KAAK,SAAS,iBAAiB;AACxC,SAAO,KAAK;GACV,MAAM;GACN,SAAS,KAAK;GACd,MAAM,KAAK;GACZ,CAAC;AACF,SAAO,KAAK;GACV,MAAM;GACN,SAAS,KAAK;GACd,OAAO,KAAK;GACb,CAAC;YACO,KAAK,SAAS,eAAe,KAAK,YAAY,KAAA,EACvD,QAAO,KAAK;EAAE,MAAM;EAAmB,MAAM,KAAK;EAAS,MAAM;EAAW,CAAC;AAGjF,QAAO,KAAK;EAAE,MAAM;EAAiB;EAAM,CAAC;AAC5C,QAAO;;AAGT,MAAM,eAAe,MAAY,YAAoD;CACnF,MAAM,OAAO,OAAO,aAAa,aAAa,KAAK,CAAC;AACpD,QAAO,SAAS,kBAAkB,KAAA,IAC9B,OACA,KAAK,KAAK,OAAO,SAAS,SAAS,OAAO,QAAQ,cAAc,CAAC,CAAC;;AAGxE,MAAM,eACJ,eACA,SACA,eAEA,OAAO,IAAI,aAAa;CACtB,MAAM,SAAS,OAAO,IAAI,KAAK,EAAE;AACjC,QAAO,cAAc,GAAG,EACtB,aAAa,YACX,OAAO,OACL,OAAO,IAAI,aAAa;EACtB,MAAM,IAAI,OAAO,IAAI,aAAa,SAAS,MAAM,IAAI,EAAE;AACvD,MAAI,KAAK,cAAc,OACrB,QAAO,OAAO,KACZ,IAAIA,eAAuB;GACzB,UAAU;GACV,KAAK,2BAA2B,cAAc,OAAO,4BAA4B,IAAI,EAAE;GACxF,CAAC,CACH;EAEH,MAAM,OAAO,cAAc;AAC3B,MAAI,eAAe,KAAA,EACjB,QAAO,WAAW,QAAQ,SAAS,KAAK;AAE1C,SAAO,YAAY,MAAM,QAAQ;GACjC,CACH,EACJ,CAAC;EACF;AAEJ,MAAa,SACX,eACA,YAC+B,MAAM,OAAO,eAAe,YAAY,eAAe,QAAQ,CAAC;;;;;;;AAQjG,MAAa,QACX,eACA,YAIG;CACH,MAAM,SAAS,IAAI,WAAW,EAAE;CAChC,MAAM,WAAW,IAAI,WAAwE,EAAE,CAAC;AAoBhG,QAAO;EACL,SAAA,EAnBA,aAAa,YACX,OAAO,OACL,OAAO,IAAI,aAAa;GACtB,MAAM,IAAI,OAAO,IAAI,aAAa,SAAS,MAAM,IAAI,EAAE;AACvD,OAAI,KAAK,cAAc,OACrB,QAAO,OAAO,KACZ,IAAIA,eAAuB;IACzB,UAAU;IACV,KAAK,2BAA2B,cAAc,OAAO,4BAA4B,IAAI,EAAE;IACxF,CAAC,CACH;GAEH,MAAM,OAAO,cAAc;AAC3B,UAAO,IAAI,OAAO,WAAW,OAAO,CAAC,GAAG,IAAI;IAAE,SAAS,QAAQ;IAAS;IAAM,CAAC,CAAC;AAChF,UAAO,YAAY,MAAM,QAAQ;IACjC,CACH,EAGI;EACP,UAAU,IAAI,IAAI,SAAS,CAAC,KAAK,OAAO,KAAK,WAAW,EAAE,OAAO,EAAE,CAAC;EACrE;;;;;;AAOH,MAAa,qBACX,eACA,YAIG;CACH,MAAM,WAAW,IAAI,WAAwE,EAAE,CAAC;AAOhG,QAAO;EACL,OAPW,MAAM,OACjB,eACA,YAAY,eAAe,UAAU,SAAS,SAC5C,IAAI,OAAO,WAAW,OAAO,CAAC,GAAG,IAAI;GAAE;GAAS;GAAM,CAAC,CAAC,CACzD,CAGU;EACX,UAAU,IAAI,IAAI,SAAS,CAAC,KAAK,OAAO,KAAK,WAAW,EAAE,OAAO,EAAE,CAAC;EACrE"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { d as Item, o as FunctionCall } from "../Items-CB8Bo3FI.mjs";
|
|
2
|
+
import { ToolResult } from "./Outcome.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/tool/HistoryCheck.d.ts
|
|
5
|
+
declare namespace HistoryCheck_d_exports {
|
|
6
|
+
export { cancelAllPending, findUnansweredCalls, isReconciled };
|
|
7
|
+
}
|
|
5
8
|
/**
|
|
6
9
|
* Return every `function_call` in `history` that does not have a matching
|
|
7
10
|
* `function_call_output` later in `history` (correlated by `call_id`).
|
|
@@ -20,5 +23,5 @@ declare const isReconciled: (history: ReadonlyArray<Item>) => boolean;
|
|
|
20
23
|
*/
|
|
21
24
|
declare const cancelAllPending: (history: ReadonlyArray<Item>, reason?: string) => ReadonlyArray<ToolResult>;
|
|
22
25
|
//#endregion
|
|
23
|
-
export { cancelAllPending, findUnansweredCalls, isReconciled };
|
|
26
|
+
export { cancelAllPending, findUnansweredCalls, isReconciled, HistoryCheck_d_exports as t };
|
|
24
27
|
//# sourceMappingURL=HistoryCheck.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HistoryCheck.d.mts","names":[],"sources":["../../src/tool/HistoryCheck.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"HistoryCheck.d.mts","names":[],"sources":["../../src/tool/HistoryCheck.ts"],"mappings":";;;;;;;;;;;;cAyBa,mBAAA,GAAuB,OAAA,EAAS,aAAA,CAAc,IAAA,MAAQ,aAAA,CAAc,YAAA;;cAMpE,YAAA,GAAgB,OAAA,EAAS,aAAA,CAAc,IAAA;;;;;AAApD;;;;cAWa,gBAAA,GACX,OAAA,EAAS,aAAA,CAAc,IAAA,GACvB,MAAA,cACC,aAAA,CAAc,UAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
|
|
1
2
|
import { isFunctionCall, isFunctionCallOutput } from "../domain/Items.mjs";
|
|
2
3
|
import { cancelled } from "./Outcome.mjs";
|
|
3
4
|
//#region src/tool/HistoryCheck.ts
|
|
@@ -13,6 +14,11 @@ import { cancelled } from "./Outcome.mjs";
|
|
|
13
14
|
* Recipe author calls these at known transition points (right before the
|
|
14
15
|
* next provider request). Not invoked from inside the loop.
|
|
15
16
|
*/
|
|
17
|
+
var HistoryCheck_exports = /* @__PURE__ */ __exportAll({
|
|
18
|
+
cancelAllPending: () => cancelAllPending,
|
|
19
|
+
findUnansweredCalls: () => findUnansweredCalls,
|
|
20
|
+
isReconciled: () => isReconciled
|
|
21
|
+
});
|
|
16
22
|
/**
|
|
17
23
|
* Return every `function_call` in `history` that does not have a matching
|
|
18
24
|
* `function_call_output` later in `history` (correlated by `call_id`).
|
|
@@ -34,6 +40,6 @@ const isReconciled = (history) => findUnansweredCalls(history).length === 0;
|
|
|
34
40
|
*/
|
|
35
41
|
const cancelAllPending = (history, reason) => findUnansweredCalls(history).map((call) => cancelled(call, reason));
|
|
36
42
|
//#endregion
|
|
37
|
-
export { cancelAllPending, findUnansweredCalls, isReconciled };
|
|
43
|
+
export { cancelAllPending, findUnansweredCalls, isReconciled, HistoryCheck_exports as t };
|
|
38
44
|
|
|
39
45
|
//# sourceMappingURL=HistoryCheck.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HistoryCheck.mjs","names":[],"sources":["../../src/tool/HistoryCheck.ts"],"sourcesContent":["/**\n * History-consistency primitives. Useful even WITHOUT HITL.\n *\n * Every provider rejects a new request if any prior `function_call` lacks\n * a matching `function_call_output`. Multi-turn flows that can be\n * interrupted, restarted, or branched (HITL, mid-stream abort, persisted\n * checkpoints, stateless HTTP servers) need to detect orphans and\n * synthesize closing outputs before submitting.\n *\n * Recipe author calls these at known transition points (right before the\n * next provider request). Not invoked from inside the loop.\n */\nimport {\n type FunctionCall,\n type Item,\n isFunctionCall,\n isFunctionCallOutput,\n} from \"../domain/Items.js\"\nimport { type ToolResult, cancelled } from \"./Outcome.js\"\n\n/**\n * Return every `function_call` in `history` that does not have a matching\n * `function_call_output` later in `history` (correlated by `call_id`).\n * Empty result = history is provider-submittable from this invariant.\n */\nexport const findUnansweredCalls = (
|
|
1
|
+
{"version":3,"file":"HistoryCheck.mjs","names":[],"sources":["../../src/tool/HistoryCheck.ts"],"sourcesContent":["/**\n * History-consistency primitives. Useful even WITHOUT HITL.\n *\n * Every provider rejects a new request if any prior `function_call` lacks\n * a matching `function_call_output`. Multi-turn flows that can be\n * interrupted, restarted, or branched (HITL, mid-stream abort, persisted\n * checkpoints, stateless HTTP servers) need to detect orphans and\n * synthesize closing outputs before submitting.\n *\n * Recipe author calls these at known transition points (right before the\n * next provider request). Not invoked from inside the loop.\n */\nimport {\n type FunctionCall,\n type Item,\n isFunctionCall,\n isFunctionCallOutput,\n} from \"../domain/Items.js\"\nimport { type ToolResult, cancelled } from \"./Outcome.js\"\n\n/**\n * Return every `function_call` in `history` that does not have a matching\n * `function_call_output` later in `history` (correlated by `call_id`).\n * Empty result = history is provider-submittable from this invariant.\n */\nexport const findUnansweredCalls = (history: ReadonlyArray<Item>): ReadonlyArray<FunctionCall> => {\n const answered = new Set(history.filter(isFunctionCallOutput).map((o) => o.call_id))\n return history.filter(isFunctionCall).filter((c) => !answered.has(c.call_id))\n}\n\n/** Cheap predicate: is this history submittable to a provider? */\nexport const isReconciled = (history: ReadonlyArray<Item>): boolean =>\n findUnansweredCalls(history).length === 0\n\n/**\n * Synthesize cancellation results for every unanswered call. Caller maps\n * via `toFunctionCallOutput` and appends to history before submitting.\n *\n * Use when: a new user message arrives mid-approval; an approval timer\n * fires; a persisted checkpoint contains orphans (crash recovery); a\n * stateless HTTP server reconstructed history from a stale checkpoint.\n */\nexport const cancelAllPending = (\n history: ReadonlyArray<Item>,\n reason?: string,\n): ReadonlyArray<ToolResult> => findUnansweredCalls(history).map((call) => cancelled(call, reason))\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,uBAAuB,YAA8D;CAChG,MAAM,WAAW,IAAI,IAAI,QAAQ,OAAO,qBAAqB,CAAC,KAAK,MAAM,EAAE,QAAQ,CAAC;AACpF,QAAO,QAAQ,OAAO,eAAe,CAAC,QAAQ,MAAM,CAAC,SAAS,IAAI,EAAE,QAAQ,CAAC;;;AAI/E,MAAa,gBAAgB,YAC3B,oBAAoB,QAAQ,CAAC,WAAW;;;;;;;;;AAU1C,MAAa,oBACX,SACA,WAC8B,oBAAoB,QAAQ,CAAC,KAAK,SAAS,UAAU,MAAM,OAAO,CAAC"}
|
package/dist/tool/Outcome.d.mts
CHANGED
|
@@ -1,2 +1,138 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { o as FunctionCall, s as FunctionCallOutput } from "../Items-CB8Bo3FI.mjs";
|
|
2
|
+
import { Data } from "effect";
|
|
3
|
+
import * as _$effect_Unify0 from "effect/Unify";
|
|
4
|
+
|
|
5
|
+
//#region src/tool/Outcome.d.ts
|
|
6
|
+
declare namespace Outcome_d_exports {
|
|
7
|
+
export { ToolResult, cancelled, denied, executionError, isFailure, isValue, rejected, toFunctionCallOutput };
|
|
8
|
+
}
|
|
9
|
+
type ToolResult = Data.TaggedEnum<{
|
|
10
|
+
Value: {
|
|
11
|
+
readonly call_id: string;
|
|
12
|
+
readonly tool: string;
|
|
13
|
+
readonly value: unknown;
|
|
14
|
+
};
|
|
15
|
+
Failure: {
|
|
16
|
+
readonly call_id: string;
|
|
17
|
+
readonly tool: string;
|
|
18
|
+
readonly kind: string;
|
|
19
|
+
readonly reason?: string;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Namespace of constructors, type guards, and matchers for `ToolResult`,
|
|
24
|
+
* provided by `Data.taggedEnum`. Use `ToolResult.$is("Value")` for type
|
|
25
|
+
* narrowing and `ToolResult.$match({ Value, Failure })` for exhaustive
|
|
26
|
+
* pattern matching. Synthetic-result helpers (`denied`, `cancelled`,
|
|
27
|
+
* `executionError`, `rejected`) below are kinder constructors than the
|
|
28
|
+
* raw `ToolResult.Failure(...)`.
|
|
29
|
+
*/
|
|
30
|
+
declare const ToolResult: {
|
|
31
|
+
readonly Value: Data.TaggedEnum.ConstructorFrom<{
|
|
32
|
+
readonly _tag: "Value";
|
|
33
|
+
readonly call_id: string;
|
|
34
|
+
readonly tool: string;
|
|
35
|
+
readonly value: unknown;
|
|
36
|
+
}, "_tag">;
|
|
37
|
+
readonly Failure: Data.TaggedEnum.ConstructorFrom<{
|
|
38
|
+
readonly _tag: "Failure";
|
|
39
|
+
readonly call_id: string;
|
|
40
|
+
readonly tool: string;
|
|
41
|
+
readonly kind: string;
|
|
42
|
+
readonly reason?: string;
|
|
43
|
+
}, "_tag">;
|
|
44
|
+
readonly $is: <Tag extends "Value" | "Failure">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
45
|
+
readonly _tag: "Value";
|
|
46
|
+
readonly call_id: string;
|
|
47
|
+
readonly tool: string;
|
|
48
|
+
readonly value: unknown;
|
|
49
|
+
}, {
|
|
50
|
+
readonly _tag: Tag;
|
|
51
|
+
}> | Extract<{
|
|
52
|
+
readonly _tag: "Failure";
|
|
53
|
+
readonly call_id: string;
|
|
54
|
+
readonly tool: string;
|
|
55
|
+
readonly kind: string;
|
|
56
|
+
readonly reason?: string;
|
|
57
|
+
}, {
|
|
58
|
+
readonly _tag: Tag;
|
|
59
|
+
}>;
|
|
60
|
+
readonly $match: {
|
|
61
|
+
<Cases extends {
|
|
62
|
+
readonly Value: (args: {
|
|
63
|
+
readonly _tag: "Value";
|
|
64
|
+
readonly call_id: string;
|
|
65
|
+
readonly tool: string;
|
|
66
|
+
readonly value: unknown;
|
|
67
|
+
}) => any;
|
|
68
|
+
readonly Failure: (args: {
|
|
69
|
+
readonly _tag: "Failure";
|
|
70
|
+
readonly call_id: string;
|
|
71
|
+
readonly tool: string;
|
|
72
|
+
readonly kind: string;
|
|
73
|
+
readonly reason?: string;
|
|
74
|
+
}) => any;
|
|
75
|
+
}>(cases: Cases): (value: {
|
|
76
|
+
readonly _tag: "Value";
|
|
77
|
+
readonly call_id: string;
|
|
78
|
+
readonly tool: string;
|
|
79
|
+
readonly value: unknown;
|
|
80
|
+
} | {
|
|
81
|
+
readonly _tag: "Failure";
|
|
82
|
+
readonly call_id: string;
|
|
83
|
+
readonly tool: string;
|
|
84
|
+
readonly kind: string;
|
|
85
|
+
readonly reason?: string;
|
|
86
|
+
}) => _$effect_Unify0.Unify<ReturnType<Cases["Value" | "Failure"]>>;
|
|
87
|
+
<Cases extends {
|
|
88
|
+
readonly Value: (args: {
|
|
89
|
+
readonly _tag: "Value";
|
|
90
|
+
readonly call_id: string;
|
|
91
|
+
readonly tool: string;
|
|
92
|
+
readonly value: unknown;
|
|
93
|
+
}) => any;
|
|
94
|
+
readonly Failure: (args: {
|
|
95
|
+
readonly _tag: "Failure";
|
|
96
|
+
readonly call_id: string;
|
|
97
|
+
readonly tool: string;
|
|
98
|
+
readonly kind: string;
|
|
99
|
+
readonly reason?: string;
|
|
100
|
+
}) => any;
|
|
101
|
+
}>(value: {
|
|
102
|
+
readonly _tag: "Value";
|
|
103
|
+
readonly call_id: string;
|
|
104
|
+
readonly tool: string;
|
|
105
|
+
readonly value: unknown;
|
|
106
|
+
} | {
|
|
107
|
+
readonly _tag: "Failure";
|
|
108
|
+
readonly call_id: string;
|
|
109
|
+
readonly tool: string;
|
|
110
|
+
readonly kind: string;
|
|
111
|
+
readonly reason?: string;
|
|
112
|
+
}, cases: Cases): _$effect_Unify0.Unify<ReturnType<Cases["Value" | "Failure"]>>;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
declare const isValue: (u: unknown) => u is {
|
|
116
|
+
readonly _tag: "Value";
|
|
117
|
+
readonly call_id: string;
|
|
118
|
+
readonly tool: string;
|
|
119
|
+
readonly value: unknown;
|
|
120
|
+
};
|
|
121
|
+
declare const isFailure: (u: unknown) => u is {
|
|
122
|
+
readonly _tag: "Failure";
|
|
123
|
+
readonly call_id: string;
|
|
124
|
+
readonly tool: string;
|
|
125
|
+
readonly kind: string;
|
|
126
|
+
readonly reason?: string;
|
|
127
|
+
};
|
|
128
|
+
declare const rejected: (call: FunctionCall, kind: string, reason?: string) => ToolResult;
|
|
129
|
+
/** Explicit user/policy rejection. */
|
|
130
|
+
declare const denied: (call: FunctionCall, reason?: string) => ToolResult;
|
|
131
|
+
/** Implicit non-answer (follow-up, inactivity, abort). */
|
|
132
|
+
declare const cancelled: (call: FunctionCall, reason?: string) => ToolResult;
|
|
133
|
+
/** Tool's own execution failed (parse error, schema, runtime crash). */
|
|
134
|
+
declare const executionError: (call: FunctionCall, reason: string) => ToolResult;
|
|
135
|
+
declare const toFunctionCallOutput: (r: ToolResult) => FunctionCallOutput;
|
|
136
|
+
//#endregion
|
|
137
|
+
export { ToolResult, cancelled, denied, executionError, isFailure, isValue, rejected, Outcome_d_exports as t, toFunctionCallOutput };
|
|
138
|
+
//# sourceMappingURL=Outcome.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Outcome.d.mts","names":[],"sources":["../../src/tool/Outcome.ts"],"mappings":";;;;;;;;KAqBY,UAAA,GAAa,IAAA,CAAK,UAAA;EAC5B,KAAA;IAAA,SACW,OAAA;IAAA,SACA,IAAA;IAAA,SACA,KAAA;EAAA;EAEX,OAAA;IAAA,SACW,OAAA;IAAA,SACA,IAAA;IAAA,SACA,IAAA;IAAA,SACA,MAAA;EAAA;AAAA;;;;;;AAYb;;;cAAa,UAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEA,OAAA,GAAO,CAAA,cAAA,CAAA;EAAA;;;;;cACP,SAAA,GAAS,CAAA,cAAA,CAAA;EAAA;;;;;;cAMT,QAAA,GAAY,IAAA,EAAM,YAAA,EAAc,IAAA,UAAc,MAAA,cAAkB,UAAA;;cAShE,MAAA,GAAU,IAAA,EAAM,YAAA,EAAc,MAAA,cAAkB,UAAA;;cAIhD,SAAA,GAAa,IAAA,EAAM,YAAA,EAAc,MAAA,cAAkB,UAAA;;cAInD,cAAA,GAAkB,IAAA,EAAM,YAAA,EAAc,MAAA,aAAiB,UAAA;AAAA,cAOvD,oBAAA,GAAwB,CAAA,EAAG,UAAA,KAAa,kBAAA"}
|
package/dist/tool/Outcome.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
|
|
1
2
|
import { functionCallOutput } from "../domain/Items.mjs";
|
|
2
|
-
import {
|
|
3
|
+
import { Data } from "effect";
|
|
3
4
|
//#region src/tool/Outcome.ts
|
|
4
5
|
/**
|
|
5
6
|
* Post-execution and synthetic tool results.
|
|
@@ -14,10 +15,28 @@ import { Match } from "effect";
|
|
|
14
15
|
* and `unknown` would invite non-serializable values (Date, Map, BigInt,
|
|
15
16
|
* fn). Recipes that want structured detail JSON.stringify themselves.
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
var Outcome_exports = /* @__PURE__ */ __exportAll({
|
|
19
|
+
ToolResult: () => ToolResult,
|
|
20
|
+
cancelled: () => cancelled,
|
|
21
|
+
denied: () => denied,
|
|
22
|
+
executionError: () => executionError,
|
|
23
|
+
isFailure: () => isFailure,
|
|
24
|
+
isValue: () => isValue,
|
|
25
|
+
rejected: () => rejected,
|
|
26
|
+
toFunctionCallOutput: () => toFunctionCallOutput
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Namespace of constructors, type guards, and matchers for `ToolResult`,
|
|
30
|
+
* provided by `Data.taggedEnum`. Use `ToolResult.$is("Value")` for type
|
|
31
|
+
* narrowing and `ToolResult.$match({ Value, Failure })` for exhaustive
|
|
32
|
+
* pattern matching. Synthetic-result helpers (`denied`, `cancelled`,
|
|
33
|
+
* `executionError`, `rejected`) below are kinder constructors than the
|
|
34
|
+
* raw `ToolResult.Failure(...)`.
|
|
35
|
+
*/
|
|
36
|
+
const ToolResult = Data.taggedEnum();
|
|
37
|
+
const isValue = ToolResult.$is("Value");
|
|
38
|
+
const isFailure = ToolResult.$is("Failure");
|
|
39
|
+
const rejected = (call, kind, reason) => ToolResult.Failure({
|
|
21
40
|
call_id: call.call_id,
|
|
22
41
|
tool: call.name,
|
|
23
42
|
kind,
|
|
@@ -29,11 +48,14 @@ const denied = (call, reason) => rejected(call, "denied", reason);
|
|
|
29
48
|
const cancelled = (call, reason) => rejected(call, "cancelled", reason);
|
|
30
49
|
/** Tool's own execution failed (parse error, schema, runtime crash). */
|
|
31
50
|
const executionError = (call, reason) => rejected(call, "execution_error", reason);
|
|
32
|
-
const toFunctionCallOutput = (r) =>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
51
|
+
const toFunctionCallOutput = (r) => ToolResult.$match(r, {
|
|
52
|
+
Value: (v) => functionCallOutput(v.call_id, JSON.stringify(v.value)),
|
|
53
|
+
Failure: (f) => functionCallOutput(f.call_id, JSON.stringify(f.reason !== void 0 ? {
|
|
54
|
+
kind: f.kind,
|
|
55
|
+
reason: f.reason
|
|
56
|
+
} : { kind: f.kind }))
|
|
57
|
+
});
|
|
36
58
|
//#endregion
|
|
37
|
-
export { cancelled, denied, executionError, isFailure, isValue, rejected, toFunctionCallOutput };
|
|
59
|
+
export { ToolResult, cancelled, denied, executionError, isFailure, isValue, rejected, Outcome_exports as t, toFunctionCallOutput };
|
|
38
60
|
|
|
39
61
|
//# sourceMappingURL=Outcome.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Outcome.mjs","names":[],"sources":["../../src/tool/Outcome.ts"],"sourcesContent":["/**\n * Post-execution and synthetic tool results.\n *\n * - Executed tools emit ToolResult.Value.\n * - Approval/cancellation policy emits synthetic ToolResult.Failure.\n *\n * Wire conversion stays at the recipe boundary via `toFunctionCallOutput`\n * so recipes can inspect, redact, or audit values before serialization.\n *\n * `output` and `reason` are `string`, not `unknown`: the wire wants strings,\n * and `unknown` would invite non-serializable values (Date, Map, BigInt,\n * fn). Recipes that want structured detail JSON.stringify themselves.\n */\nimport {
|
|
1
|
+
{"version":3,"file":"Outcome.mjs","names":[],"sources":["../../src/tool/Outcome.ts"],"sourcesContent":["/**\n * Post-execution and synthetic tool results.\n *\n * - Executed tools emit ToolResult.Value.\n * - Approval/cancellation policy emits synthetic ToolResult.Failure.\n *\n * Wire conversion stays at the recipe boundary via `toFunctionCallOutput`\n * so recipes can inspect, redact, or audit values before serialization.\n *\n * `output` and `reason` are `string`, not `unknown`: the wire wants strings,\n * and `unknown` would invite non-serializable values (Date, Map, BigInt,\n * fn). Recipes that want structured detail JSON.stringify themselves.\n */\nimport { Data } from \"effect\"\nimport type { FunctionCall, FunctionCallOutput } from \"../domain/Items.js\"\nimport { functionCallOutput } from \"../domain/Items.js\"\n\n// ---------------------------------------------------------------------------\n// ToolResult\n// ---------------------------------------------------------------------------\n\nexport type ToolResult = Data.TaggedEnum<{\n Value: {\n readonly call_id: string\n readonly tool: string\n readonly value: unknown\n }\n Failure: {\n readonly call_id: string\n readonly tool: string\n readonly kind: string\n readonly reason?: string\n }\n}>\n\n/**\n * Namespace of constructors, type guards, and matchers for `ToolResult`,\n * provided by `Data.taggedEnum`. Use `ToolResult.$is(\"Value\")` for type\n * narrowing and `ToolResult.$match({ Value, Failure })` for exhaustive\n * pattern matching. Synthetic-result helpers (`denied`, `cancelled`,\n * `executionError`, `rejected`) below are kinder constructors than the\n * raw `ToolResult.Failure(...)`.\n */\nexport const ToolResult = Data.taggedEnum<ToolResult>()\n\nexport const isValue = ToolResult.$is(\"Value\")\nexport const isFailure = ToolResult.$is(\"Failure\")\n\n// Synthesizers. `denied` and `cancelled` are operationally distinct;\n// anything else is just a recipe-chosen `kind` via `rejected`.\n// ---------------------------------------------------------------------------\n\nexport const rejected = (call: FunctionCall, kind: string, reason?: string): ToolResult =>\n ToolResult.Failure({\n call_id: call.call_id,\n tool: call.name,\n kind,\n ...(reason !== undefined ? { reason } : {}),\n })\n\n/** Explicit user/policy rejection. */\nexport const denied = (call: FunctionCall, reason?: string): ToolResult =>\n rejected(call, \"denied\", reason)\n\n/** Implicit non-answer (follow-up, inactivity, abort). */\nexport const cancelled = (call: FunctionCall, reason?: string): ToolResult =>\n rejected(call, \"cancelled\", reason)\n\n/** Tool's own execution failed (parse error, schema, runtime crash). */\nexport const executionError = (call: FunctionCall, reason: string): ToolResult =>\n rejected(call, \"execution_error\", reason)\n\n// ---------------------------------------------------------------------------\n// Wire conversion - the one place structured → string happens.\n// ---------------------------------------------------------------------------\n\nexport const toFunctionCallOutput = (r: ToolResult): FunctionCallOutput =>\n ToolResult.$match(r, {\n Value: (v) => functionCallOutput(v.call_id, JSON.stringify(v.value)),\n Failure: (f) =>\n functionCallOutput(\n f.call_id,\n JSON.stringify(\n f.reason !== undefined ? { kind: f.kind, reason: f.reason } : { kind: f.kind },\n ),\n ),\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,aAAa,KAAK,YAAwB;AAEvD,MAAa,UAAU,WAAW,IAAI,QAAQ;AAC9C,MAAa,YAAY,WAAW,IAAI,UAAU;AAMlD,MAAa,YAAY,MAAoB,MAAc,WACzD,WAAW,QAAQ;CACjB,SAAS,KAAK;CACd,MAAM,KAAK;CACX;CACA,GAAI,WAAW,KAAA,IAAY,EAAE,QAAQ,GAAG,EAAE;CAC3C,CAAC;;AAGJ,MAAa,UAAU,MAAoB,WACzC,SAAS,MAAM,UAAU,OAAO;;AAGlC,MAAa,aAAa,MAAoB,WAC5C,SAAS,MAAM,aAAa,OAAO;;AAGrC,MAAa,kBAAkB,MAAoB,WACjD,SAAS,MAAM,mBAAmB,OAAO;AAM3C,MAAa,wBAAwB,MACnC,WAAW,OAAO,GAAG;CACnB,QAAQ,MAAM,mBAAmB,EAAE,SAAS,KAAK,UAAU,EAAE,MAAM,CAAC;CACpE,UAAU,MACR,mBACE,EAAE,SACF,KAAK,UACH,EAAE,WAAW,KAAA,IAAY;EAAE,MAAM,EAAE;EAAM,QAAQ,EAAE;EAAQ,GAAG,EAAE,MAAM,EAAE,MAAM,CAC/E,CACF;CACJ,CAAC"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { o as FunctionCall } from "../Items-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { o as FunctionCall } from "../Items-CB8Bo3FI.mjs";
|
|
2
|
+
import { ToolResult } from "./Outcome.mjs";
|
|
3
|
+
import { ToolEvent } from "./ToolEvent.mjs";
|
|
4
4
|
import { Effect, Queue, Scope, Stream } from "effect";
|
|
5
5
|
|
|
6
6
|
//#region src/tool/Resolvers.d.ts
|
|
7
|
-
|
|
7
|
+
declare namespace Resolvers_d_exports {
|
|
8
|
+
export { ApprovalMapEntry, ToolCallDecision, ToolCallPlan, Verdict, approvalRequested, approve, fromApprovalMap, fromVerdictQueue, reject, splitToolCallDecisions };
|
|
9
|
+
}
|
|
10
|
+
type ToolCallPlan = {
|
|
8
11
|
readonly approved: ReadonlyArray<FunctionCall>;
|
|
9
12
|
readonly rejected: ReadonlyArray<ToolResult>;
|
|
10
|
-
}
|
|
13
|
+
};
|
|
11
14
|
type ToolCallDecision = {
|
|
12
15
|
readonly _tag: "Approved";
|
|
13
16
|
readonly call: FunctionCall;
|
|
@@ -19,11 +22,11 @@ declare const approve: (call: FunctionCall) => ToolCallDecision;
|
|
|
19
22
|
declare const reject: (result: ToolResult) => ToolCallDecision;
|
|
20
23
|
declare const splitToolCallDecisions: (decisions: ReadonlyArray<ToolCallDecision>) => ToolCallPlan;
|
|
21
24
|
declare const approvalRequested: (call: FunctionCall) => ToolEvent;
|
|
22
|
-
|
|
25
|
+
type Verdict = {
|
|
23
26
|
readonly call_id: string;
|
|
24
27
|
readonly decision: "approve" | "deny";
|
|
25
28
|
readonly reason?: string;
|
|
26
|
-
}
|
|
29
|
+
};
|
|
27
30
|
/**
|
|
28
31
|
* Queue-backed approval planner. Safe calls are returned immediately in
|
|
29
32
|
* `approved`; gated calls emit `ApprovalRequested` events and later produce
|
|
@@ -42,5 +45,5 @@ type ApprovalMapEntry = {
|
|
|
42
45
|
};
|
|
43
46
|
declare const fromApprovalMap: (predicate: (call: FunctionCall) => boolean, approvals: ReadonlyMap<string, ApprovalMapEntry>) => (calls: ReadonlyArray<FunctionCall>) => ToolCallPlan;
|
|
44
47
|
//#endregion
|
|
45
|
-
export { ApprovalMapEntry, ToolCallDecision, ToolCallPlan, Verdict, approvalRequested, approve, fromApprovalMap, fromVerdictQueue, reject, splitToolCallDecisions };
|
|
48
|
+
export { ApprovalMapEntry, ToolCallDecision, ToolCallPlan, Verdict, approvalRequested, approve, fromApprovalMap, fromVerdictQueue, reject, splitToolCallDecisions, Resolvers_d_exports as t };
|
|
46
49
|
//# sourceMappingURL=Resolvers.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resolvers.d.mts","names":[],"sources":["../../src/tool/Resolvers.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Resolvers.d.mts","names":[],"sources":["../../src/tool/Resolvers.ts"],"mappings":";;;;;;;;;KAYY,YAAA;EAAA,SACD,QAAA,EAAU,aAAA,CAAc,YAAA;EAAA,SACxB,QAAA,EAAU,aAAA,CAAc,UAAA;AAAA;AAAA,KAGvB,gBAAA;EAAA,SACG,IAAA;EAAA,SAA2B,IAAA,EAAM,YAAA;AAAA;EAAA,SACjC,IAAA;EAAA,SAA2B,MAAA,EAAQ,UAAA;AAAA;AAAA,cAErC,OAAA,GAAW,IAAA,EAAM,YAAA,KAAe,gBAAA;AAAA,cAKhC,MAAA,GAAU,MAAA,EAAQ,UAAA,KAAa,gBAAA;AAAA,cAK/B,sBAAA,GAA0B,SAAA,EAAW,aAAA,CAAc,gBAAA,MAAoB,YAAA;AAAA,cASvE,iBAAA,GAAqB,IAAA,EAAM,YAAA,KAAe,SAAA;AAAA,KAW3C,OAAA;EAAA,SACD,OAAA;EAAA,SACA,QAAA;EAAA,SACA,MAAA;AAAA;;;;;;cAQE,gBAAA,GACV,SAAA,GAAY,IAAA,EAAM,YAAA,cAA0B,QAAA,EAAU,KAAA,CAAM,OAAA,CAAQ,OAAA,OAEnE,KAAA,EAAO,aAAA,CAAc,YAAA,MACpB,MAAA,CAAO,MAAA;EAAA,SAEG,QAAA,EAAU,aAAA,CAAc,YAAA;EAAA,SACxB,SAAA,EAAW,MAAA,CAAO,MAAA,CAAO,gBAAA;EAAA,SACzB,QAAA,EAAU,MAAA,CAAO,MAAA,CAAO,SAAA;AAAA,UAGnC,KAAA,CAAM,KAAA;AAAA,KAkDE,gBAAA;EAAA,SACG,QAAA;AAAA;EAAA,SACA,QAAA;EAAA,SAA2B,MAAA;AAAA;AAAA,cAE7B,eAAA,GACV,SAAA,GAAY,IAAA,EAAM,YAAA,cAA0B,SAAA,EAAW,WAAA,SAAoB,gBAAA,OAC3E,KAAA,EAAO,aAAA,CAAc,YAAA,MAAgB,YAAA"}
|
package/dist/tool/Resolvers.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
|
|
1
2
|
import { cancelled, denied } from "./Outcome.mjs";
|
|
2
3
|
import { Deferred, Effect, Queue, Stream } from "effect";
|
|
3
4
|
//#region src/tool/Resolvers.ts
|
|
@@ -8,6 +9,14 @@ import { Deferred, Effect, Queue, Stream } from "effect";
|
|
|
8
9
|
* results must be returned to the model. Tool execution stays explicit at
|
|
9
10
|
* the recipe boundary via `Toolkit.executeAll`.
|
|
10
11
|
*/
|
|
12
|
+
var Resolvers_exports = /* @__PURE__ */ __exportAll({
|
|
13
|
+
approvalRequested: () => approvalRequested,
|
|
14
|
+
approve: () => approve,
|
|
15
|
+
fromApprovalMap: () => fromApprovalMap,
|
|
16
|
+
fromVerdictQueue: () => fromVerdictQueue,
|
|
17
|
+
reject: () => reject,
|
|
18
|
+
splitToolCallDecisions: () => splitToolCallDecisions
|
|
19
|
+
});
|
|
11
20
|
const approve = (call) => ({
|
|
12
21
|
_tag: "Approved",
|
|
13
22
|
call
|
|
@@ -63,6 +72,6 @@ const fromApprovalMap = (predicate, approvals) => (calls) => splitToolCallDecisi
|
|
|
63
72
|
return v.decision === "approve" ? approve(call) : reject(denied(call, v.reason));
|
|
64
73
|
}));
|
|
65
74
|
//#endregion
|
|
66
|
-
export { approvalRequested, approve, fromApprovalMap, fromVerdictQueue, reject, splitToolCallDecisions };
|
|
75
|
+
export { approvalRequested, approve, fromApprovalMap, fromVerdictQueue, reject, splitToolCallDecisions, Resolvers_exports as t };
|
|
67
76
|
|
|
68
77
|
//# sourceMappingURL=Resolvers.mjs.map
|