@effect-uai/core 0.5.2 → 0.6.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/{Items-BH8xUkoR.d.mts → Items-pXR5BAgW.d.mts} +12 -12
- package/dist/Items-pXR5BAgW.d.mts.map +1 -0
- package/dist/SandboxError-BvKypkJm.d.mts +158 -0
- package/dist/SandboxError-BvKypkJm.d.mts.map +1 -0
- package/dist/{Tool-87ViKCCO.d.mts → Tool-DP-AwKOf.d.mts} +11 -11
- package/dist/{Tool-87ViKCCO.d.mts.map → Tool-DP-AwKOf.d.mts.map} +1 -1
- package/dist/domain/Items.d.mts +2 -2
- package/dist/domain/Items.mjs +15 -15
- package/dist/domain/Items.mjs.map +1 -1
- package/dist/domain/Turn.d.mts +388 -2
- package/dist/domain/Turn.d.mts.map +1 -0
- package/dist/domain/Turn.mjs +13 -13
- package/dist/domain/Turn.mjs.map +1 -1
- package/dist/index.d.mts +11 -6
- package/dist/index.mjs +8 -3
- package/dist/language-model/LanguageModel.d.mts +5 -5
- package/dist/language-model/LanguageModel.d.mts.map +1 -1
- package/dist/language-model/LanguageModel.mjs.map +1 -1
- package/dist/loop/Loop.d.mts +37 -90
- package/dist/loop/Loop.d.mts.map +1 -1
- package/dist/loop/Loop.mjs +39 -93
- package/dist/loop/Loop.mjs.map +1 -1
- package/dist/loop/Loop.test.mjs +46 -54
- package/dist/loop/Loop.test.mjs.map +1 -1
- package/dist/sandbox/Memory.d.mts +53 -0
- package/dist/sandbox/Memory.d.mts.map +1 -0
- package/dist/sandbox/Memory.mjs +68 -0
- package/dist/sandbox/Memory.mjs.map +1 -0
- package/dist/sandbox/Sandbox.d.mts +717 -0
- package/dist/sandbox/Sandbox.d.mts.map +1 -0
- package/dist/sandbox/Sandbox.mjs +192 -0
- package/dist/sandbox/Sandbox.mjs.map +1 -0
- package/dist/sandbox/SandboxError.d.mts +2 -0
- package/dist/sandbox/SandboxError.mjs +89 -0
- package/dist/sandbox/SandboxError.mjs.map +1 -0
- package/dist/sandbox/SandboxImage.d.mts +28 -0
- package/dist/sandbox/SandboxImage.d.mts.map +1 -0
- package/dist/sandbox/SandboxImage.mjs +32 -0
- package/dist/sandbox/SandboxImage.mjs.map +1 -0
- package/dist/sandbox/SandboxNetwork.d.mts +34 -0
- package/dist/sandbox/SandboxNetwork.d.mts.map +1 -0
- package/dist/sandbox/SandboxNetwork.mjs +36 -0
- package/dist/sandbox/SandboxNetwork.mjs.map +1 -0
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +98 -2
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.mjs +32 -2
- package/dist/speech-synthesizer/SpeechSynthesizer.mjs.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +56 -2
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs.map +1 -1
- package/dist/testing/MockProvider.d.mts +3 -3
- package/dist/testing/MockProvider.d.mts.map +1 -1
- package/dist/testing/MockProvider.mjs.map +1 -1
- package/dist/testing/MockSandbox.d.mts +604 -0
- package/dist/testing/MockSandbox.d.mts.map +1 -0
- package/dist/testing/MockSandbox.mjs +160 -0
- package/dist/testing/MockSandbox.mjs.map +1 -0
- package/dist/testing/MockSpeechSynthesizer.d.mts +26 -11
- package/dist/testing/MockSpeechSynthesizer.d.mts.map +1 -1
- package/dist/testing/MockSpeechSynthesizer.mjs +75 -51
- package/dist/testing/MockSpeechSynthesizer.mjs.map +1 -1
- package/dist/tool/{Resolvers.d.mts → Approval.d.mts} +27 -27
- package/dist/tool/Approval.d.mts.map +1 -0
- package/dist/tool/{Resolvers.mjs → Approval.mjs} +18 -18
- package/dist/tool/Approval.mjs.map +1 -0
- package/dist/tool/{Resolvers.test.mjs → Approval.test.mjs} +40 -40
- package/dist/tool/Approval.test.mjs.map +1 -0
- package/dist/tool/HistoryCheck.d.mts +6 -6
- package/dist/tool/HistoryCheck.d.mts.map +1 -1
- package/dist/tool/HistoryCheck.mjs +5 -5
- package/dist/tool/HistoryCheck.mjs.map +1 -1
- package/dist/tool/Tool.d.mts +2 -2
- package/dist/tool/Tool.mjs +4 -4
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/ToolEvent.d.mts +19 -19
- package/dist/tool/ToolEvent.d.mts.map +1 -1
- package/dist/tool/ToolEvent.mjs +8 -8
- package/dist/tool/ToolEvent.mjs.map +1 -1
- package/dist/tool/{Outcome.d.mts → ToolResult.d.mts} +29 -29
- package/dist/tool/ToolResult.d.mts.map +1 -0
- package/dist/tool/ToolResult.mjs +61 -0
- package/dist/tool/ToolResult.mjs.map +1 -0
- package/dist/tool/Toolkit.d.mts +58 -26
- package/dist/tool/Toolkit.d.mts.map +1 -1
- package/dist/tool/Toolkit.mjs +62 -34
- package/dist/tool/Toolkit.mjs.map +1 -1
- package/dist/tool/Toolkit.test.mjs +13 -13
- package/dist/tool/Toolkit.test.mjs.map +1 -1
- package/package.json +31 -7
- package/src/domain/Items.ts +9 -9
- package/src/domain/Turn.ts +16 -16
- package/src/index.ts +7 -2
- package/src/language-model/LanguageModel.ts +3 -3
- package/src/loop/Loop.test.ts +93 -91
- package/src/loop/Loop.ts +72 -170
- package/src/sandbox/Memory.ts +128 -0
- package/src/sandbox/Sandbox.ts +639 -0
- package/src/sandbox/SandboxError.ts +140 -0
- package/src/sandbox/SandboxImage.ts +26 -0
- package/src/sandbox/SandboxNetwork.ts +34 -0
- package/src/speech-synthesizer/SpeechSynthesizer.test.ts +89 -0
- package/src/speech-synthesizer/SpeechSynthesizer.ts +124 -0
- package/src/testing/MockProvider.ts +21 -20
- package/src/testing/MockSandbox.ts +342 -0
- package/src/testing/MockSpeechSynthesizer.ts +137 -77
- package/src/tool/{Resolvers.test.ts → Approval.test.ts} +45 -54
- package/src/tool/{Resolvers.ts → Approval.ts} +25 -25
- package/src/tool/HistoryCheck.ts +10 -13
- package/src/tool/Tool.ts +13 -15
- package/src/tool/ToolEvent.ts +7 -7
- package/src/tool/{Outcome.ts → ToolResult.ts} +20 -20
- package/src/tool/Toolkit.test.ts +13 -13
- package/src/tool/Toolkit.ts +97 -73
- package/dist/Items-BH8xUkoR.d.mts.map +0 -1
- package/dist/Turn-0CwCAyVe.d.mts +0 -388
- package/dist/Turn-0CwCAyVe.d.mts.map +0 -1
- package/dist/tool/Outcome.d.mts.map +0 -1
- package/dist/tool/Outcome.mjs +0 -61
- package/dist/tool/Outcome.mjs.map +0 -1
- package/dist/tool/Resolvers.d.mts.map +0 -1
- package/dist/tool/Resolvers.mjs.map +0 -1
- package/dist/tool/Resolvers.test.mjs.map +0 -1
- /package/dist/tool/{Resolvers.test.d.mts → Approval.test.d.mts} +0 -0
package/dist/Turn-0CwCAyVe.d.mts
DELETED
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
import { i as ImageSource } from "./Image-HNmMpMTh.mjs";
|
|
2
|
-
import { d as Item, g as Reasoning, o as FunctionCall, p as Message, s as FunctionCallOutput, x as Usage } from "./Items-BH8xUkoR.mjs";
|
|
3
|
-
import { i as StructuredFormat, n as JsonParseError, r as StructuredDecodeError } from "./StructuredFormat-BbN4dosH.mjs";
|
|
4
|
-
import { Data, Effect, Schema, Stream } from "effect";
|
|
5
|
-
import * as _$effect_Types0 from "effect/Types";
|
|
6
|
-
import * as _$effect_Cause0 from "effect/Cause";
|
|
7
|
-
import * as _$effect_Unify0 from "effect/Unify";
|
|
8
|
-
|
|
9
|
-
//#region src/domain/Turn.d.ts
|
|
10
|
-
declare namespace Turn_d_exports {
|
|
11
|
-
export { InteractionEvent, RefusalRejected, Turn, TurnEvent, appendTurn, assistantMessages, assistantText, assistantTexts, functionCalls, isTurnComplete, reasonings, textDeltas, toStructured };
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* The result of a single LLM generation. A turn produces zero or more items
|
|
15
|
-
* (typically one assistant message and zero or more function_call items)
|
|
16
|
-
* and reports usage + a stop reason.
|
|
17
|
-
*/
|
|
18
|
-
declare const Turn: Schema.Struct<{
|
|
19
|
-
readonly items: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
20
|
-
readonly type: Schema.Literal<"message">;
|
|
21
|
-
readonly role: Schema.Literals<readonly ["user", "assistant", "system"]>;
|
|
22
|
-
readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
23
|
-
readonly type: Schema.Literal<"input_text">;
|
|
24
|
-
readonly text: Schema.String;
|
|
25
|
-
}>, Schema.Struct<{
|
|
26
|
-
readonly type: Schema.Literal<"input_image">;
|
|
27
|
-
readonly source: Schema.Schema<ImageSource>;
|
|
28
|
-
}>, Schema.Struct<{
|
|
29
|
-
readonly type: Schema.Literal<"output_text">;
|
|
30
|
-
readonly text: Schema.String;
|
|
31
|
-
readonly annotations: Schema.optional<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
32
|
-
readonly type: Schema.Literal<"url_citation">;
|
|
33
|
-
readonly url: Schema.String;
|
|
34
|
-
readonly start_index: Schema.Number;
|
|
35
|
-
readonly end_index: Schema.Number;
|
|
36
|
-
readonly title: Schema.String;
|
|
37
|
-
}>, Schema.Struct<{
|
|
38
|
-
readonly type: Schema.Literal<"file_citation">;
|
|
39
|
-
readonly file_id: Schema.String;
|
|
40
|
-
readonly index: Schema.Number;
|
|
41
|
-
}>, Schema.Struct<{
|
|
42
|
-
readonly type: Schema.Literal<"container_file_citation">;
|
|
43
|
-
readonly container_id: Schema.String;
|
|
44
|
-
readonly file_id: Schema.String;
|
|
45
|
-
readonly start_index: Schema.Number;
|
|
46
|
-
readonly end_index: Schema.Number;
|
|
47
|
-
}>, Schema.Struct<{
|
|
48
|
-
readonly type: Schema.Literal<"file_path">;
|
|
49
|
-
readonly file_id: Schema.String;
|
|
50
|
-
readonly index: Schema.Number;
|
|
51
|
-
}>]>>>;
|
|
52
|
-
}>, Schema.Struct<{
|
|
53
|
-
readonly type: Schema.Literal<"refusal">;
|
|
54
|
-
readonly text: Schema.String;
|
|
55
|
-
}>]>>;
|
|
56
|
-
readonly providerData: Schema.optional<Schema.Unknown>;
|
|
57
|
-
}>, Schema.Struct<{
|
|
58
|
-
readonly type: Schema.Literal<"function_call">;
|
|
59
|
-
readonly call_id: Schema.String;
|
|
60
|
-
readonly name: Schema.String;
|
|
61
|
-
readonly arguments: Schema.String;
|
|
62
|
-
readonly providerData: Schema.optional<Schema.Unknown>;
|
|
63
|
-
}>, Schema.Struct<{
|
|
64
|
-
readonly type: Schema.Literal<"function_call_output">;
|
|
65
|
-
readonly call_id: Schema.String;
|
|
66
|
-
readonly output: Schema.String;
|
|
67
|
-
readonly providerData: Schema.optional<Schema.Unknown>;
|
|
68
|
-
}>, Schema.Struct<{
|
|
69
|
-
readonly type: Schema.Literal<"reasoning">;
|
|
70
|
-
readonly id: Schema.optional<Schema.String>;
|
|
71
|
-
readonly summary: Schema.optional<Schema.String>;
|
|
72
|
-
readonly signature: Schema.optional<Schema.String>;
|
|
73
|
-
readonly providerData: Schema.optional<Schema.Unknown>;
|
|
74
|
-
}>]>>;
|
|
75
|
-
readonly usage: Schema.Struct<{
|
|
76
|
-
readonly input_tokens: Schema.optional<Schema.Number>;
|
|
77
|
-
readonly output_tokens: Schema.optional<Schema.Number>;
|
|
78
|
-
readonly total_tokens: Schema.optional<Schema.Number>;
|
|
79
|
-
readonly input_tokens_details: Schema.optional<Schema.Struct<{
|
|
80
|
-
readonly cached_tokens: Schema.optional<Schema.Number>;
|
|
81
|
-
}>>;
|
|
82
|
-
readonly output_tokens_details: Schema.optional<Schema.Struct<{
|
|
83
|
-
readonly reasoning_tokens: Schema.optional<Schema.Number>;
|
|
84
|
-
}>>;
|
|
85
|
-
}>;
|
|
86
|
-
readonly stop_reason: Schema.Literals<readonly ["stop", "tool_calls", "max_tokens", "refusal", "content_filter", "max_tool_calls"]>;
|
|
87
|
-
}>;
|
|
88
|
-
type Turn = typeof Turn.Type;
|
|
89
|
-
/**
|
|
90
|
-
* Canonical events emitted while a single turn is being generated. Most
|
|
91
|
-
* variants are streaming deltas (text, reasoning, tool-call args); the
|
|
92
|
-
* terminal `TurnComplete` carries the assembled `Turn`. Lifecycle members
|
|
93
|
-
* aren't deltas, hence the union name.
|
|
94
|
-
*
|
|
95
|
-
* `ReasoningDelta.kind`: `trace` is the model's raw chain-of-thought;
|
|
96
|
-
* `summary` is a model-written summary intended for display. OpenAI
|
|
97
|
-
* Responses emits both; Anthropic and Gemini only emit `trace`.
|
|
98
|
-
*
|
|
99
|
-
* `RefusalDelta`: the model declined to answer. OpenAI Responses emits
|
|
100
|
-
* this as its own event; Anthropic surfaces refusals via `stop_reason`
|
|
101
|
-
* and Gemini collapses them into `finishReason: SAFETY` — both go
|
|
102
|
-
* without a `RefusalDelta`.
|
|
103
|
-
*
|
|
104
|
-
* `UsageUpdate`: mid-stream cumulative usage. Anthropic emits this on
|
|
105
|
-
* `message_start` and `message_delta`; other providers may only deliver
|
|
106
|
-
* usage via `TurnComplete.turn.usage`.
|
|
107
|
-
*/
|
|
108
|
-
type TurnEvent = Data.TaggedEnum<{
|
|
109
|
-
TextDelta: {
|
|
110
|
-
readonly text: string;
|
|
111
|
-
};
|
|
112
|
-
ReasoningDelta: {
|
|
113
|
-
readonly text: string;
|
|
114
|
-
readonly kind: "trace" | "summary";
|
|
115
|
-
};
|
|
116
|
-
RefusalDelta: {
|
|
117
|
-
readonly text: string;
|
|
118
|
-
};
|
|
119
|
-
ToolCallStart: {
|
|
120
|
-
readonly call_id: string;
|
|
121
|
-
readonly name: string;
|
|
122
|
-
};
|
|
123
|
-
ToolCallArgsDelta: {
|
|
124
|
-
readonly call_id: string;
|
|
125
|
-
readonly delta: string;
|
|
126
|
-
};
|
|
127
|
-
UsageUpdate: {
|
|
128
|
-
readonly usage: Usage;
|
|
129
|
-
};
|
|
130
|
-
TurnComplete: {
|
|
131
|
-
readonly turn: Turn;
|
|
132
|
-
};
|
|
133
|
-
}>;
|
|
134
|
-
declare const TurnEvent: {
|
|
135
|
-
readonly TextDelta: Data.TaggedEnum.ConstructorFrom<{
|
|
136
|
-
readonly _tag: "TextDelta";
|
|
137
|
-
readonly text: string;
|
|
138
|
-
}, "_tag">;
|
|
139
|
-
readonly ReasoningDelta: Data.TaggedEnum.ConstructorFrom<{
|
|
140
|
-
readonly _tag: "ReasoningDelta";
|
|
141
|
-
readonly text: string;
|
|
142
|
-
readonly kind: "trace" | "summary";
|
|
143
|
-
}, "_tag">;
|
|
144
|
-
readonly RefusalDelta: Data.TaggedEnum.ConstructorFrom<{
|
|
145
|
-
readonly _tag: "RefusalDelta";
|
|
146
|
-
readonly text: string;
|
|
147
|
-
}, "_tag">;
|
|
148
|
-
readonly ToolCallStart: Data.TaggedEnum.ConstructorFrom<{
|
|
149
|
-
readonly _tag: "ToolCallStart";
|
|
150
|
-
readonly call_id: string;
|
|
151
|
-
readonly name: string;
|
|
152
|
-
}, "_tag">;
|
|
153
|
-
readonly ToolCallArgsDelta: Data.TaggedEnum.ConstructorFrom<{
|
|
154
|
-
readonly _tag: "ToolCallArgsDelta";
|
|
155
|
-
readonly call_id: string;
|
|
156
|
-
readonly delta: string;
|
|
157
|
-
}, "_tag">;
|
|
158
|
-
readonly UsageUpdate: Data.TaggedEnum.ConstructorFrom<{
|
|
159
|
-
readonly _tag: "UsageUpdate";
|
|
160
|
-
readonly usage: Usage;
|
|
161
|
-
}, "_tag">;
|
|
162
|
-
readonly TurnComplete: Data.TaggedEnum.ConstructorFrom<{
|
|
163
|
-
readonly _tag: "TurnComplete";
|
|
164
|
-
readonly turn: Turn;
|
|
165
|
-
}, "_tag">;
|
|
166
|
-
readonly $is: <Tag extends "TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallStart" | "ToolCallArgsDelta" | "UsageUpdate" | "TurnComplete">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
167
|
-
readonly _tag: "TextDelta";
|
|
168
|
-
readonly text: string;
|
|
169
|
-
}, {
|
|
170
|
-
readonly _tag: Tag;
|
|
171
|
-
}> | Extract<{
|
|
172
|
-
readonly _tag: "ReasoningDelta";
|
|
173
|
-
readonly text: string;
|
|
174
|
-
readonly kind: "trace" | "summary";
|
|
175
|
-
}, {
|
|
176
|
-
readonly _tag: Tag;
|
|
177
|
-
}> | Extract<{
|
|
178
|
-
readonly _tag: "RefusalDelta";
|
|
179
|
-
readonly text: string;
|
|
180
|
-
}, {
|
|
181
|
-
readonly _tag: Tag;
|
|
182
|
-
}> | Extract<{
|
|
183
|
-
readonly _tag: "ToolCallStart";
|
|
184
|
-
readonly call_id: string;
|
|
185
|
-
readonly name: string;
|
|
186
|
-
}, {
|
|
187
|
-
readonly _tag: Tag;
|
|
188
|
-
}> | Extract<{
|
|
189
|
-
readonly _tag: "ToolCallArgsDelta";
|
|
190
|
-
readonly call_id: string;
|
|
191
|
-
readonly delta: string;
|
|
192
|
-
}, {
|
|
193
|
-
readonly _tag: Tag;
|
|
194
|
-
}> | Extract<{
|
|
195
|
-
readonly _tag: "UsageUpdate";
|
|
196
|
-
readonly usage: Usage;
|
|
197
|
-
}, {
|
|
198
|
-
readonly _tag: Tag;
|
|
199
|
-
}> | Extract<{
|
|
200
|
-
readonly _tag: "TurnComplete";
|
|
201
|
-
readonly turn: Turn;
|
|
202
|
-
}, {
|
|
203
|
-
readonly _tag: Tag;
|
|
204
|
-
}>;
|
|
205
|
-
readonly $match: {
|
|
206
|
-
<Cases extends {
|
|
207
|
-
readonly TextDelta: (args: {
|
|
208
|
-
readonly _tag: "TextDelta";
|
|
209
|
-
readonly text: string;
|
|
210
|
-
}) => any;
|
|
211
|
-
readonly ReasoningDelta: (args: {
|
|
212
|
-
readonly _tag: "ReasoningDelta";
|
|
213
|
-
readonly text: string;
|
|
214
|
-
readonly kind: "trace" | "summary";
|
|
215
|
-
}) => any;
|
|
216
|
-
readonly RefusalDelta: (args: {
|
|
217
|
-
readonly _tag: "RefusalDelta";
|
|
218
|
-
readonly text: string;
|
|
219
|
-
}) => any;
|
|
220
|
-
readonly ToolCallStart: (args: {
|
|
221
|
-
readonly _tag: "ToolCallStart";
|
|
222
|
-
readonly call_id: string;
|
|
223
|
-
readonly name: string;
|
|
224
|
-
}) => any;
|
|
225
|
-
readonly ToolCallArgsDelta: (args: {
|
|
226
|
-
readonly _tag: "ToolCallArgsDelta";
|
|
227
|
-
readonly call_id: string;
|
|
228
|
-
readonly delta: string;
|
|
229
|
-
}) => any;
|
|
230
|
-
readonly UsageUpdate: (args: {
|
|
231
|
-
readonly _tag: "UsageUpdate";
|
|
232
|
-
readonly usage: Usage;
|
|
233
|
-
}) => any;
|
|
234
|
-
readonly TurnComplete: (args: {
|
|
235
|
-
readonly _tag: "TurnComplete";
|
|
236
|
-
readonly turn: Turn;
|
|
237
|
-
}) => any;
|
|
238
|
-
}>(cases: Cases): (value: {
|
|
239
|
-
readonly _tag: "TextDelta";
|
|
240
|
-
readonly text: string;
|
|
241
|
-
} | {
|
|
242
|
-
readonly _tag: "ReasoningDelta";
|
|
243
|
-
readonly text: string;
|
|
244
|
-
readonly kind: "trace" | "summary";
|
|
245
|
-
} | {
|
|
246
|
-
readonly _tag: "RefusalDelta";
|
|
247
|
-
readonly text: string;
|
|
248
|
-
} | {
|
|
249
|
-
readonly _tag: "ToolCallStart";
|
|
250
|
-
readonly call_id: string;
|
|
251
|
-
readonly name: string;
|
|
252
|
-
} | {
|
|
253
|
-
readonly _tag: "ToolCallArgsDelta";
|
|
254
|
-
readonly call_id: string;
|
|
255
|
-
readonly delta: string;
|
|
256
|
-
} | {
|
|
257
|
-
readonly _tag: "UsageUpdate";
|
|
258
|
-
readonly usage: Usage;
|
|
259
|
-
} | {
|
|
260
|
-
readonly _tag: "TurnComplete";
|
|
261
|
-
readonly turn: Turn;
|
|
262
|
-
}) => _$effect_Unify0.Unify<ReturnType<Cases["TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallStart" | "ToolCallArgsDelta" | "UsageUpdate" | "TurnComplete"]>>;
|
|
263
|
-
<Cases extends {
|
|
264
|
-
readonly TextDelta: (args: {
|
|
265
|
-
readonly _tag: "TextDelta";
|
|
266
|
-
readonly text: string;
|
|
267
|
-
}) => any;
|
|
268
|
-
readonly ReasoningDelta: (args: {
|
|
269
|
-
readonly _tag: "ReasoningDelta";
|
|
270
|
-
readonly text: string;
|
|
271
|
-
readonly kind: "trace" | "summary";
|
|
272
|
-
}) => any;
|
|
273
|
-
readonly RefusalDelta: (args: {
|
|
274
|
-
readonly _tag: "RefusalDelta";
|
|
275
|
-
readonly text: string;
|
|
276
|
-
}) => any;
|
|
277
|
-
readonly ToolCallStart: (args: {
|
|
278
|
-
readonly _tag: "ToolCallStart";
|
|
279
|
-
readonly call_id: string;
|
|
280
|
-
readonly name: string;
|
|
281
|
-
}) => any;
|
|
282
|
-
readonly ToolCallArgsDelta: (args: {
|
|
283
|
-
readonly _tag: "ToolCallArgsDelta";
|
|
284
|
-
readonly call_id: string;
|
|
285
|
-
readonly delta: string;
|
|
286
|
-
}) => any;
|
|
287
|
-
readonly UsageUpdate: (args: {
|
|
288
|
-
readonly _tag: "UsageUpdate";
|
|
289
|
-
readonly usage: Usage;
|
|
290
|
-
}) => any;
|
|
291
|
-
readonly TurnComplete: (args: {
|
|
292
|
-
readonly _tag: "TurnComplete";
|
|
293
|
-
readonly turn: Turn;
|
|
294
|
-
}) => any;
|
|
295
|
-
}>(value: {
|
|
296
|
-
readonly _tag: "TextDelta";
|
|
297
|
-
readonly text: string;
|
|
298
|
-
} | {
|
|
299
|
-
readonly _tag: "ReasoningDelta";
|
|
300
|
-
readonly text: string;
|
|
301
|
-
readonly kind: "trace" | "summary";
|
|
302
|
-
} | {
|
|
303
|
-
readonly _tag: "RefusalDelta";
|
|
304
|
-
readonly text: string;
|
|
305
|
-
} | {
|
|
306
|
-
readonly _tag: "ToolCallStart";
|
|
307
|
-
readonly call_id: string;
|
|
308
|
-
readonly name: string;
|
|
309
|
-
} | {
|
|
310
|
-
readonly _tag: "ToolCallArgsDelta";
|
|
311
|
-
readonly call_id: string;
|
|
312
|
-
readonly delta: string;
|
|
313
|
-
} | {
|
|
314
|
-
readonly _tag: "UsageUpdate";
|
|
315
|
-
readonly usage: Usage;
|
|
316
|
-
} | {
|
|
317
|
-
readonly _tag: "TurnComplete";
|
|
318
|
-
readonly turn: Turn;
|
|
319
|
-
}, cases: Cases): _$effect_Unify0.Unify<ReturnType<Cases["TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallStart" | "ToolCallArgsDelta" | "UsageUpdate" | "TurnComplete"]>>;
|
|
320
|
-
};
|
|
321
|
-
};
|
|
322
|
-
/**
|
|
323
|
-
* What flows out of an agent loop body to its consumer per turn: every
|
|
324
|
-
* `TurnEvent` the provider emits (including the terminal `TurnComplete`
|
|
325
|
-
* carrying the assembled `Turn`), plus the output of any tool the loop ran.
|
|
326
|
-
* Both variants carry a `_tag` discriminator.
|
|
327
|
-
*/
|
|
328
|
-
type InteractionEvent = TurnEvent | FunctionCallOutput;
|
|
329
|
-
declare const isTurnComplete: (u: unknown) => u is {
|
|
330
|
-
readonly _tag: "TurnComplete";
|
|
331
|
-
readonly turn: Turn;
|
|
332
|
-
};
|
|
333
|
-
declare const functionCalls: (turn: Turn) => ReadonlyArray<FunctionCall>;
|
|
334
|
-
declare const reasonings: (turn: Turn) => ReadonlyArray<Reasoning>;
|
|
335
|
-
declare const assistantMessages: (turn: Turn) => ReadonlyArray<Message>;
|
|
336
|
-
/**
|
|
337
|
-
* Every `output_text` payload across every assistant message in the turn,
|
|
338
|
-
* preserving order. Refusals and other content blocks are dropped — use
|
|
339
|
-
* `assistantMessages` if you need to inspect them. The primitive for
|
|
340
|
-
* "give me the assistant's text"; callers decide how to combine
|
|
341
|
-
* (typically `.join("")` for prose or `.join(" ")` for log strings).
|
|
342
|
-
*/
|
|
343
|
-
declare const assistantTexts: (turn: Turn) => ReadonlyArray<string>;
|
|
344
|
-
/**
|
|
345
|
-
* Sugar over `assistantTexts(turn).join("")` — the common case for
|
|
346
|
-
* summarizers, classifiers, judge calls, and structured-output backstops
|
|
347
|
-
* that want one concatenated string.
|
|
348
|
-
*/
|
|
349
|
-
declare const assistantText: (turn: Turn) => string;
|
|
350
|
-
/**
|
|
351
|
-
* Append a completed turn and optional follow-up items to a state record's
|
|
352
|
-
* history. Recipes use this at the point where structured tool results are
|
|
353
|
-
* converted to model-facing `FunctionCallOutput`s.
|
|
354
|
-
*/
|
|
355
|
-
declare const appendTurn: <S extends {
|
|
356
|
-
readonly history: ReadonlyArray<Item>;
|
|
357
|
-
}>(state: S, turn: Turn, items?: ReadonlyArray<Item>) => S;
|
|
358
|
-
/**
|
|
359
|
-
* Project a `TurnEvent` stream onto its `TextDelta` payloads. Other
|
|
360
|
-
* variants are dropped. Composes with `Lines.lines` +
|
|
361
|
-
* `decodeJsonLines` for prompted-JSONL streaming.
|
|
362
|
-
*/
|
|
363
|
-
declare const textDeltas: <E, R>(self: Stream.Stream<TurnEvent, E, R>) => Stream.Stream<string, E, R>;
|
|
364
|
-
declare const RefusalRejected_base: new <A extends Record<string, any> = {}>(args: _$effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => _$effect_Cause0.YieldableError & {
|
|
365
|
-
readonly _tag: "RefusalRejected";
|
|
366
|
-
} & Readonly<A>;
|
|
367
|
-
/**
|
|
368
|
-
* The assistant message on the just-completed turn was a refusal block,
|
|
369
|
-
* not an `output_text` payload. Returned by `toStructured` to short-circuit
|
|
370
|
-
* decoding before `JSON.parse` / schema validation runs.
|
|
371
|
-
*/
|
|
372
|
-
declare class RefusalRejected extends RefusalRejected_base<{
|
|
373
|
-
readonly turn: Turn;
|
|
374
|
-
}> {}
|
|
375
|
-
/**
|
|
376
|
-
* Validate a completed `Turn` against a `StructuredFormat`. Concatenates
|
|
377
|
-
* `output_text` blocks on the last assistant message, then runs
|
|
378
|
-
* `JSON.parse` + the format's schema validation.
|
|
379
|
-
*
|
|
380
|
-
* Three failure modes:
|
|
381
|
-
* - `RefusalRejected` — the assistant emitted a refusal block.
|
|
382
|
-
* - `JsonParseError` — the assembled text wasn't valid JSON.
|
|
383
|
-
* - `StructuredDecodeError` — the JSON didn't match the schema.
|
|
384
|
-
*/
|
|
385
|
-
declare const toStructured: <A>(turn: Turn, format: StructuredFormat<A>) => Effect.Effect<A, RefusalRejected | JsonParseError | StructuredDecodeError>;
|
|
386
|
-
//#endregion
|
|
387
|
-
export { Turn_d_exports as a, assistantText as c, isTurnComplete as d, reasonings as f, TurnEvent as i, assistantTexts as l, toStructured as m, RefusalRejected as n, appendTurn as o, textDeltas as p, Turn as r, assistantMessages as s, InteractionEvent as t, functionCalls as u };
|
|
388
|
-
//# sourceMappingURL=Turn-0CwCAyVe.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Turn-0CwCAyVe.d.mts","names":[],"sources":["../src/domain/Turn.ts"],"mappings":";;;;;;;;;;;;;;;;;cAmBa,IAAA,EAAI,MAAA,CAAA,MAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKL,IAAA,UAAc,IAAA,CAAK,IAAA;;;;;;;;;;;;;;;;;;;;KAqBnB,SAAA,GAAY,IAAA,CAAK,UAAA;EAC3B,SAAA;IAAA,SAAsB,IAAA;EAAA;EACtB,cAAA;IAAA,SAA2B,IAAA;IAAA,SAAuB,IAAA;EAAA;EAClD,YAAA;IAAA,SAAyB,IAAA;EAAA;EACzB,aAAA;IAAA,SAA0B,OAAA;IAAA,SAA0B,IAAA;EAAA;EACpD,iBAAA;IAAA,SAA8B,OAAA;IAAA,SAA0B,KAAA;EAAA;EACxD,WAAA;IAAA,SAAwB,KAAA,EAAO,KAAA;EAAA;EAC/B,YAAA;IAAA,SAAyB,IAAA,EAAM,IAAA;EAAA;AAAA;AAAA,cAGpB,SAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;oBAJoB,KAAA;EAAA;EAAA;;mBACA,IAAA;EAAA;EAAA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ga,YAAA,MACX,IAAA,EAAM,IAAA,EACN,MAAA,EAAQ,gBAAA,CAAkC,CAAA,MACzC,MAAA,CAAO,MAAA,CACR,CAAA,EACA,eAAA,GAAkB,cAAA,GAAkC,qBAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
|
|
2
|
-
import { functionCallOutput } from "../domain/Items.mjs";
|
|
3
|
-
import { Data } from "effect";
|
|
4
|
-
//#region src/tool/Outcome.ts
|
|
5
|
-
/**
|
|
6
|
-
* Post-execution and synthetic tool results.
|
|
7
|
-
*
|
|
8
|
-
* - Executed tools emit ToolResult.Value.
|
|
9
|
-
* - Approval/cancellation policy emits synthetic ToolResult.Failure.
|
|
10
|
-
*
|
|
11
|
-
* Wire conversion stays at the recipe boundary via `toFunctionCallOutput`
|
|
12
|
-
* so recipes can inspect, redact, or audit values before serialization.
|
|
13
|
-
*
|
|
14
|
-
* `output` and `reason` are `string`, not `unknown`: the wire wants strings,
|
|
15
|
-
* and `unknown` would invite non-serializable values (Date, Map, BigInt,
|
|
16
|
-
* fn). Recipes that want structured detail JSON.stringify themselves.
|
|
17
|
-
*/
|
|
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({
|
|
40
|
-
call_id: call.call_id,
|
|
41
|
-
tool: call.name,
|
|
42
|
-
kind,
|
|
43
|
-
...reason !== void 0 ? { reason } : {}
|
|
44
|
-
});
|
|
45
|
-
/** Explicit user/policy rejection. */
|
|
46
|
-
const denied = (call, reason) => rejected(call, "denied", reason);
|
|
47
|
-
/** Implicit non-answer (follow-up, inactivity, abort). */
|
|
48
|
-
const cancelled = (call, reason) => rejected(call, "cancelled", reason);
|
|
49
|
-
/** Tool's own execution failed (parse error, schema, runtime crash). */
|
|
50
|
-
const executionError = (call, reason) => rejected(call, "execution_error", reason);
|
|
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
|
-
});
|
|
58
|
-
//#endregion
|
|
59
|
-
export { ToolResult, cancelled, denied, executionError, isFailure, isValue, rejected, Outcome_exports as t, toFunctionCallOutput };
|
|
60
|
-
|
|
61
|
-
//# sourceMappingURL=Outcome.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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,MA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AA;MAAA;MAAA;;yBACE,UAAA;MAAA;IAAA;;qBADF,YAAA;IAAA;MAAA;uBACE,UAAA;IAAA;;;;uBADF,YAAA;MAAA;MAAA;;yBACE,UAAA;MAAA;IAAA;;qBADF,YAAA;IAAA;MAAA;uBACE,UAAA;IAAA;;;cAKlB,OAAA,GAAW,IAAA,EAAM,YAAA,KAAe,gBAAA;AAAA,cAEhC,MAAA,GAAU,MAAA,EAAQ,UAAA,KAAa,gBAAA;AAAA,cAG/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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Resolvers.mjs","names":[],"sources":["../../src/tool/Resolvers.ts"],"sourcesContent":["/**\n * Approval helpers for the two transport flavors.\n *\n * These helpers only decide which calls are approved and which synthetic\n * results must be returned to the model. Tool execution stays explicit at\n * the recipe boundary via `Toolkit.executeAll`.\n */\nimport { Data, Deferred, Effect, Queue, Scope, Stream } from \"effect\"\nimport type { FunctionCall } from \"../domain/Items.js\"\nimport { type ToolResult, cancelled, denied } from \"./Outcome.js\"\nimport { ToolEvent } from \"./ToolEvent.js\"\n\nexport type ToolCallPlan = {\n readonly approved: ReadonlyArray<FunctionCall>\n readonly rejected: ReadonlyArray<ToolResult>\n}\n\nexport type ToolCallDecision = Data.TaggedEnum<{\n Approved: { readonly call: FunctionCall }\n Rejected: { readonly result: ToolResult }\n}>\n\nexport const ToolCallDecision = Data.taggedEnum<ToolCallDecision>()\n\nexport const approve = (call: FunctionCall): ToolCallDecision => ToolCallDecision.Approved({ call })\n\nexport const reject = (result: ToolResult): ToolCallDecision =>\n ToolCallDecision.Rejected({ result })\n\nexport const splitToolCallDecisions = (decisions: ReadonlyArray<ToolCallDecision>): ToolCallPlan =>\n decisions.reduce<ToolCallPlan>(\n (acc, decision) =>\n decision._tag === \"Approved\"\n ? { ...acc, approved: [...acc.approved, decision.call] }\n : { ...acc, rejected: [...acc.rejected, decision.result] },\n { approved: [], rejected: [] },\n )\n\nexport const approvalRequested = (call: FunctionCall): ToolEvent =>\n ToolEvent.ApprovalRequested({\n call_id: call.call_id,\n tool: call.name,\n arguments: call.arguments,\n })\n\n// ---------------------------------------------------------------------------\n// Verdict queue (WebSocket-style transport).\n// ---------------------------------------------------------------------------\n\nexport type Verdict = {\n readonly call_id: string\n readonly decision: \"approve\" | \"deny\"\n readonly reason?: string\n}\n\n/**\n * Queue-backed approval planner. Safe calls are returned immediately in\n * `approved`; gated calls emit `ApprovalRequested` events and later produce\n * one `ToolCallDecision` when their matching verdict arrives.\n */\nexport const fromVerdictQueue =\n (predicate: (call: FunctionCall) => boolean, verdicts: Queue.Dequeue<Verdict>) =>\n (\n calls: ReadonlyArray<FunctionCall>,\n ): Effect.Effect<\n {\n readonly approved: ReadonlyArray<FunctionCall>\n readonly decisions: Stream.Stream<ToolCallDecision>\n readonly announce: Stream.Stream<ToolEvent>\n },\n never,\n Scope.Scope\n > =>\n Effect.gen(function* () {\n const gated = calls.filter(predicate)\n const approved = calls.filter((call) => !predicate(call))\n\n const entries = yield* Effect.forEach(gated, (call) =>\n Deferred.make<Verdict>().pipe(Effect.map((d) => [call.call_id, d] as const)),\n )\n const deferreds: ReadonlyMap<string, Deferred.Deferred<Verdict>> = new Map(entries)\n\n // Router is forked into the surrounding Scope so it lives as long\n // as the consumer is pulling events. Recipes typically supply the\n // scope by wrapping the events construction in `Stream.unwrap`.\n yield* Effect.forkScoped(\n Effect.forever(\n Effect.gen(function* () {\n const v = yield* Queue.take(verdicts)\n const d = deferreds.get(v.call_id)\n if (d !== undefined) yield* Deferred.succeed(d, v)\n }),\n ),\n )\n\n const decisions = Stream.fromIterable(gated).pipe(\n Stream.flatMap(\n (call) => {\n const d = deferreds.get(call.call_id)!\n return Stream.fromEffect(\n Deferred.await(d).pipe(\n Effect.map((v) =>\n v.decision === \"approve\" ? approve(call) : reject(denied(call, v.reason)),\n ),\n ),\n )\n },\n { concurrency: \"unbounded\" },\n ),\n )\n\n const announce = Stream.fromIterable<ToolEvent>(gated.map(approvalRequested))\n\n return { approved, decisions, announce }\n })\n\n// ---------------------------------------------------------------------------\n// Approval map (HTTP-style transport). Verdicts arrive synchronously\n// bundled in the request payload. Missing entries → cancelled.\n// ---------------------------------------------------------------------------\n\nexport type ApprovalMapEntry =\n | { readonly decision: \"approve\" }\n | { readonly decision: \"deny\"; readonly reason?: string }\n\nexport const fromApprovalMap =\n (predicate: (call: FunctionCall) => boolean, approvals: ReadonlyMap<string, ApprovalMapEntry>) =>\n (calls: ReadonlyArray<FunctionCall>): ToolCallPlan =>\n splitToolCallDecisions(\n calls.map((call) => {\n if (!predicate(call)) return approve(call)\n const v = approvals.get(call.call_id)\n if (v === undefined) return reject(cancelled(call))\n return v.decision === \"approve\" ? approve(call) : reject(denied(call, v.reason))\n }),\n )\n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;AACrC,UAAO,OAAO,WACZ,SAAS,MAAM,EAAE,CAAC,KAChB,OAAO,KAAK,MACV,EAAE,aAAa,YAAY,QAAQ,KAAK,GAAG,OAAO,OAAO,MAAM,EAAE,OAAO,CAAC,CAC1E,CACF,CACF;KAEH,EAAE,aAAa,aAAa,CAC7B,CAKyB;EAAE,UAFb,OAAO,aAAwB,MAAM,IAAI,kBAAkB,CAEtC;EAAE;EACxC;AAWN,MAAa,mBACV,WAA4C,eAC5C,UACC,uBACE,MAAM,KAAK,SAAS;AAClB,KAAI,CAAC,UAAU,KAAK,CAAE,QAAO,QAAQ,KAAK;CAC1C,MAAM,IAAI,UAAU,IAAI,KAAK,QAAQ;AACrC,KAAI,MAAM,KAAA,EAAW,QAAO,OAAO,UAAU,KAAK,CAAC;AACnD,QAAO,EAAE,aAAa,YAAY,QAAQ,KAAK,GAAG,OAAO,OAAO,MAAM,EAAE,OAAO,CAAC;EAChF,CACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Resolvers.test.mjs","names":["makeTool","Items.functionCallOutput","Items.userText"],"sources":["../../src/tool/Resolvers.test.ts"],"sourcesContent":["/**\n * Tests for approval planners + history-reconciliation primitives. Exercises\n * the full HITL + streaming-tool stack end-to-end by composing approval plans\n * with `executeAll`, with the four wire-shaped scenarios:\n *\n * 1. Approval : gated calls approved → tools execute, structured Values\n * 2. Denial : gated calls denied → Failure(denied) results\n * 3. Cancellation : missing verdicts → Failure(cancelled) results\n * 4. Mixed + history : reconciliation via cancelAllPending\n *\n * Plus: hallucinated tool name (graceful Failure), unknown_tool kind.\n */\nimport { Effect, Queue, Schema, Stream } from \"effect\"\nimport { describe, expect, it } from \"vitest\"\nimport * as Items from \"../domain/Items.js\"\nimport { findUnansweredCalls, cancelAllPending, isReconciled } from \"./HistoryCheck.js\"\nimport { type ToolResult, isFailure, isValue, toFunctionCallOutput } from \"./Outcome.js\"\nimport {\n type ApprovalMapEntry,\n type ToolCallDecision,\n fromApprovalMap,\n fromVerdictQueue,\n} from \"./Resolvers.js\"\nimport { fromEffectSchema, make as makeTool, streaming } from \"./Tool.js\"\nimport { executeAll } from \"./Toolkit.js\"\nimport { ToolEvent, isApprovalRequested, isIntermediate, isOutput } from \"./ToolEvent.js\"\n\n// ---------------------------------------------------------------------------\n// Three demo tools covering the matrix:\n// - web_search : streaming, no approval\n// - bulk_email : streaming, requires approval\n// - delete_database : non-streaming, requires approval\n// ---------------------------------------------------------------------------\n\nconst webSearch = streaming({\n name: \"web_search\",\n description: \"search\",\n inputSchema: fromEffectSchema(Schema.Struct({ query: Schema.String })),\n run: ({ query }) =>\n Stream.fromIterable([\n { url: \"a\", title: `${query} 1` },\n { url: \"b\", title: `${query} 2` },\n { url: \"c\", title: `${query} 3` },\n ]),\n finalize: (hits) => ({ count: hits.length }),\n})\n\nconst bulkEmail = streaming({\n name: \"bulk_email\",\n description: \"send\",\n inputSchema: fromEffectSchema(\n Schema.Struct({ recipients: Schema.Array(Schema.String), subject: Schema.String }),\n ),\n run: ({ recipients }) =>\n Stream.fromIterable(\n recipients.map((_, i) => ({\n type: \"progress\" as const,\n sent: i + 1,\n total: recipients.length,\n })),\n ),\n finalize: (events) => ({ status: \"sent\" as const, delivered: events.length }),\n})\n\nconst deleteDatabase = makeTool({\n name: \"delete_database\",\n description: \"drop\",\n inputSchema: fromEffectSchema(Schema.Struct({ name: Schema.String })),\n run: ({ name }) => Effect.succeed({ status: \"dropped\", name }),\n})\n\nconst allTools = [webSearch, bulkEmail, deleteDatabase]\nconst SENSITIVE = new Set([\"bulk_email\", \"delete_database\"])\nconst isSensitive = (call: Items.FunctionCall) => SENSITIVE.has(call.name)\n\nconst fc = (call_id: string, name: string, args: unknown): Items.FunctionCall => ({\n type: \"function_call\",\n call_id,\n name,\n arguments: JSON.stringify(args),\n})\n\nconst calls = [\n fc(\"c1\", \"web_search\", { query: \"effect\" }),\n fc(\"c2\", \"bulk_email\", { recipients: [\"a@x\", \"b@x\"], subject: \"Hi\" }),\n fc(\"c3\", \"delete_database\", { name: \"prod\" }),\n]\n\nconst resultsFrom = (collected: ReadonlyArray<ToolEvent>): ReadonlyArray<ToolResult> =>\n collected.filter(isOutput).map((e) => e.result)\n\nconst byCallId = (results: ReadonlyArray<ToolResult>) => new Map(results.map((r) => [r.call_id, r]))\n\nconst rejectedStream = (rejected: ReadonlyArray<ToolResult>) =>\n Stream.fromIterable(rejected.map((result) => ToolEvent.Output({ result })))\n\nconst eventsFromApprovalMap = (approvals: ReadonlyMap<string, ApprovalMapEntry>) => {\n const plan = fromApprovalMap(isSensitive, approvals)(calls)\n return Stream.merge(executeAll(allTools, plan.approved), rejectedStream(plan.rejected))\n}\n\nconst eventsFromDecision = (decision: ToolCallDecision): Stream.Stream<ToolEvent> =>\n decision._tag === \"Approved\"\n ? executeAll(allTools, [decision.call])\n : Stream.succeed(ToolEvent.Output({ result: decision.result }))\n\n// ---------------------------------------------------------------------------\n// fromApprovalMap: HTTP-style scenarios\n// ---------------------------------------------------------------------------\n\ndescribe(\"fromApprovalMap + executeAll\", () => {\n it(\"approval: all gated approved → tools execute, structured Values\", async () => {\n const approvals = new Map<string, ApprovalMapEntry>([\n [\"c2\", { decision: \"approve\" }],\n [\"c3\", { decision: \"approve\" }],\n ])\n const collected = await Effect.runPromise(Stream.runCollect(eventsFromApprovalMap(approvals)))\n const by = byCallId(resultsFrom(collected))\n expect(by.get(\"c1\")).toMatchObject({ _tag: \"Value\", value: { count: 3 } })\n expect(by.get(\"c2\")).toMatchObject({\n _tag: \"Value\",\n value: { status: \"sent\", delivered: 2 },\n })\n expect(by.get(\"c3\")).toMatchObject({\n _tag: \"Value\",\n value: { status: \"dropped\", name: \"prod\" },\n })\n\n // No ApprovalRequested events from the pure HTTP flow.\n expect(collected.filter(isApprovalRequested)).toHaveLength(0)\n })\n\n it(\"denial: gated denied → Failure(denied), no execution\", async () => {\n const approvals = new Map<string, ApprovalMapEntry>([\n [\"c2\", { decision: \"deny\", reason: \"spam concern\" }],\n [\"c3\", { decision: \"deny\", reason: \"prod is sacred\" }],\n ])\n const collected = await Effect.runPromise(Stream.runCollect(eventsFromApprovalMap(approvals)))\n\n // bulk_email never ran.\n expect(collected.filter(isIntermediate).filter((e) => e.tool === \"bulk_email\")).toHaveLength(0)\n\n const by = byCallId(resultsFrom(collected))\n expect(by.get(\"c2\")).toMatchObject({\n _tag: \"Failure\",\n kind: \"denied\",\n reason: \"spam concern\",\n })\n expect(by.get(\"c3\")).toMatchObject({\n _tag: \"Failure\",\n kind: \"denied\",\n reason: \"prod is sacred\",\n })\n })\n\n it(\"cancellation: missing verdicts → Failure(cancelled)\", async () => {\n const collected = await Effect.runPromise(Stream.runCollect(eventsFromApprovalMap(new Map())))\n const by = byCallId(resultsFrom(collected))\n expect(by.get(\"c1\")).toMatchObject({ _tag: \"Value\", value: { count: 3 } })\n expect(by.get(\"c2\")).toMatchObject({ _tag: \"Failure\", kind: \"cancelled\" })\n expect(by.get(\"c3\")).toMatchObject({ _tag: \"Failure\", kind: \"cancelled\" })\n })\n\n it(\"mixed: approve + deny + omit → all three kinds\", async () => {\n const approvals = new Map<string, ApprovalMapEntry>([\n [\"c2\", { decision: \"approve\" }],\n // c3 omitted → cancelled\n ])\n const collected = await Effect.runPromise(Stream.runCollect(eventsFromApprovalMap(approvals)))\n const by = byCallId(resultsFrom(collected))\n expect(by.get(\"c1\")).toMatchObject({ _tag: \"Value\", value: { count: 3 } })\n expect(by.get(\"c2\")).toMatchObject({ _tag: \"Value\", value: { status: \"sent\" } })\n expect(by.get(\"c3\")).toMatchObject({ _tag: \"Failure\", kind: \"cancelled\" })\n })\n})\n\n// ---------------------------------------------------------------------------\n// Graceful degradation: hallucinated tool name doesn't kill the turn.\n// ---------------------------------------------------------------------------\n\ndescribe(\"executeAll: graceful degradation\", () => {\n it(\"unknown tool name → Failure(unknown_tool); other calls still execute\", async () => {\n const callsWithBogus = [\n fc(\"c1\", \"web_search\", { query: \"x\" }),\n fc(\"c2\", \"does_not_exist\", {}),\n fc(\"c3\", \"delete_database\", { name: \"prod\" }),\n ]\n const collected = await Effect.runPromise(\n Stream.runCollect(\n (() => {\n const plan = fromApprovalMap(\n isSensitive,\n new Map([[\"c3\", { decision: \"approve\" }]]),\n )(callsWithBogus)\n return Stream.merge(executeAll(allTools, plan.approved), rejectedStream(plan.rejected))\n })(),\n ),\n )\n const by = byCallId(resultsFrom(collected))\n expect(by.get(\"c1\")).toMatchObject({ _tag: \"Value\" })\n expect(by.get(\"c2\")).toMatchObject({ _tag: \"Failure\", kind: \"unknown_tool\" })\n expect(by.get(\"c3\")).toMatchObject({ _tag: \"Value\", value: { status: \"dropped\" } })\n })\n})\n\n// ---------------------------------------------------------------------------\n// fromVerdictQueue: WebSocket-style scenarios\n// ---------------------------------------------------------------------------\n\ndescribe(\"fromVerdictQueue + executeAll\", () => {\n it(\"queue-driven: approve + deny resolve correctly with ApprovalRequested events\", async () => {\n const collected = await Effect.runPromise(\n Effect.gen(function* () {\n const verdicts = yield* Queue.unbounded<{\n readonly call_id: string\n readonly decision: \"approve\" | \"deny\"\n readonly reason?: string\n }>()\n yield* Queue.offer(verdicts, { call_id: \"c2\", decision: \"approve\" })\n yield* Queue.offer(verdicts, {\n call_id: \"c3\",\n decision: \"deny\",\n reason: \"too risky\",\n })\n\n // Stream.unwrap supplies the Scope for fromVerdictQueue's router.\n const events = Stream.unwrap(\n Effect.gen(function* () {\n const { approved, decisions, announce } = yield* fromVerdictQueue(\n isSensitive,\n verdicts,\n )(calls)\n return Stream.merge(\n announce,\n Stream.merge(\n executeAll(allTools, approved),\n decisions.pipe(Stream.flatMap(eventsFromDecision)),\n ),\n )\n }),\n )\n return yield* Stream.runCollect(events)\n }),\n )\n\n expect(collected.filter(isApprovalRequested)).toHaveLength(2)\n\n const by = byCallId(resultsFrom(collected))\n expect(by.get(\"c2\")).toMatchObject({ _tag: \"Value\", value: { status: \"sent\" } })\n expect(by.get(\"c3\")).toMatchObject({\n _tag: \"Failure\",\n kind: \"denied\",\n reason: \"too risky\",\n })\n })\n})\n\n// ---------------------------------------------------------------------------\n// History reconciliation\n// ---------------------------------------------------------------------------\n\ndescribe(\"findUnansweredCalls / cancelAllPending / isReconciled\", () => {\n const orphan = fc(\"c99\", \"delete_database\", { name: \"prod\" })\n const answered = fc(\"c98\", \"web_search\", { query: \"x\" })\n const answeredOutput = Items.functionCallOutput(\"c98\", JSON.stringify({ count: 0 }))\n\n it(\"findUnansweredCalls returns only orphans\", () => {\n const history = [Items.userText(\"hi\"), answered, orphan, answeredOutput]\n const unanswered = findUnansweredCalls(history)\n expect(unanswered).toHaveLength(1)\n expect(unanswered[0]!.call_id).toBe(\"c99\")\n })\n\n it(\"isReconciled is false when orphans exist, true otherwise\", () => {\n const stale = [Items.userText(\"hi\"), orphan]\n expect(isReconciled(stale)).toBe(false)\n const reconciled = [...stale, ...cancelAllPending(stale).map(toFunctionCallOutput)]\n expect(isReconciled(reconciled)).toBe(true)\n })\n\n it(\"cancelAllPending synthesizes one Failure(cancelled) per orphan\", () => {\n const history = [Items.userText(\"hi\"), answered, orphan, answeredOutput]\n const closures = cancelAllPending(history, \"user moved on\")\n expect(closures).toHaveLength(1)\n const c = closures[0]!\n expect(isFailure(c)).toBe(true)\n expect(c).toMatchObject({\n _tag: \"Failure\",\n call_id: \"c99\",\n kind: \"cancelled\",\n reason: \"user moved on\",\n })\n })\n\n it(\"follow-up: map closures to FunctionCallOutput before appending new user message\", () => {\n const stale = [Items.userText(\"first request\"), orphan]\n const closures = cancelAllPending(stale, \"user redirected\")\n const reconciled = [\n ...stale,\n ...closures.map(toFunctionCallOutput),\n Items.userText(\"never mind\"),\n ]\n expect(findUnansweredCalls(reconciled)).toHaveLength(0)\n })\n})\n\n// ---------------------------------------------------------------------------\n// Wire conversion\n// ---------------------------------------------------------------------------\n\ndescribe(\"toFunctionCallOutput\", () => {\n it(\"round-trips a Value result\", () => {\n const r: ToolResult = {\n _tag: \"Value\",\n call_id: \"c1\",\n tool: \"web_search\",\n value: { count: 3 },\n }\n const out = toFunctionCallOutput(r)\n expect(out.call_id).toBe(\"c1\")\n expect(JSON.parse(out.output)).toEqual({ count: 3 })\n })\n\n it(\"round-trips a Failure result with reason\", () => {\n const r: ToolResult = {\n _tag: \"Failure\",\n call_id: \"c2\",\n tool: \"bulk_email\",\n kind: \"denied\",\n reason: \"spam concern\",\n }\n const out = toFunctionCallOutput(r)\n expect(JSON.parse(out.output)).toEqual({ kind: \"denied\", reason: \"spam concern\" })\n })\n\n it(\"round-trips a Failure result without reason (omits the field)\", () => {\n const r: ToolResult = {\n _tag: \"Failure\",\n call_id: \"c3\",\n tool: \"delete_database\",\n kind: \"cancelled\",\n }\n const out = toFunctionCallOutput(r)\n expect(JSON.parse(out.output)).toEqual({ kind: \"cancelled\" })\n })\n})\n\n// ---------------------------------------------------------------------------\n// executeAll\n// ---------------------------------------------------------------------------\n\ndescribe(\"executeAll\", () => {\n it(\"runs all calls passed to it\", async () => {\n const collected = await Effect.runPromise(Stream.runCollect(executeAll(allTools, calls)))\n expect(collected.filter(isOutput)).toHaveLength(3)\n expect(collected.filter(isOutput).every((e) => isValue(e.result))).toBe(true)\n })\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAM,WAAW;CArCC,UAAU;EAC1B,MAAM;EACN,aAAa;EACb,aAAa,iBAAiB,OAAO,OAAO,EAAE,OAAO,OAAO,QAAQ,CAAC,CAAC;EACtE,MAAM,EAAE,YACN,OAAO,aAAa;GAClB;IAAE,KAAK;IAAK,OAAO,GAAG,MAAM;IAAK;GACjC;IAAE,KAAK;IAAK,OAAO,GAAG,MAAM;IAAK;GACjC;IAAE,KAAK;IAAK,OAAO,GAAG,MAAM;IAAK;GAClC,CAAC;EACJ,WAAW,UAAU,EAAE,OAAO,KAAK,QAAQ;EAC5C,CA0B0B;CAxBT,UAAU;EAC1B,MAAM;EACN,aAAa;EACb,aAAa,iBACX,OAAO,OAAO;GAAE,YAAY,OAAO,MAAM,OAAO,OAAO;GAAE,SAA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