@effect-uai/core 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AiError-CAX_48RU.d.mts → AiError-CrdR1EQi.d.mts} +2 -2
- package/dist/{AiError-CAX_48RU.d.mts.map → AiError-CrdR1EQi.d.mts.map} +1 -1
- package/dist/{Audio-DPlTsNdz.d.mts → Audio-DDSKCkSe.d.mts} +2 -2
- package/dist/{Audio-DPlTsNdz.d.mts.map → Audio-DDSKCkSe.d.mts.map} +1 -1
- package/dist/{Image-HNmMpMTh.d.mts → Image-C_Zjpwhc.d.mts} +2 -2
- package/dist/{Image-HNmMpMTh.d.mts.map → Image-C_Zjpwhc.d.mts.map} +1 -1
- package/dist/{Items-D8UaXQx_.d.mts → Items-CgKD6Npw.d.mts} +5 -5
- package/dist/{Items-D8UaXQx_.d.mts.map → Items-CgKD6Npw.d.mts.map} +1 -1
- package/dist/Loop-B5_cqumi.d.mts +173 -0
- package/dist/Loop-B5_cqumi.d.mts.map +1 -0
- package/dist/{Media-D_CpcM1Z.d.mts → Media-DOLyaygI.d.mts} +1 -1
- package/dist/{Media-D_CpcM1Z.d.mts.map → Media-DOLyaygI.d.mts.map} +1 -1
- package/dist/{SandboxError-BvKypkJm.d.mts → SandboxError-CIrVDOMV.d.mts} +2 -2
- package/dist/{SandboxError-BvKypkJm.d.mts.map → SandboxError-CIrVDOMV.d.mts.map} +1 -1
- package/dist/{StructuredFormat-BbN4dosH.d.mts → StructuredFormat-CMJFD3sn.d.mts} +2 -2
- package/dist/{StructuredFormat-BbN4dosH.d.mts.map → StructuredFormat-CMJFD3sn.d.mts.map} +1 -1
- package/dist/Tool-0XUIT2A2.d.mts +232 -0
- package/dist/Tool-0XUIT2A2.d.mts.map +1 -0
- package/dist/ToolEvent-DYrAUJGs.d.mts +151 -0
- package/dist/ToolEvent-DYrAUJGs.d.mts.map +1 -0
- package/dist/ToolResult-BZd-cEWW.d.mts +151 -0
- package/dist/ToolResult-BZd-cEWW.d.mts.map +1 -0
- package/dist/Toolkit-BKC8b8Xo.d.mts +155 -0
- package/dist/Toolkit-BKC8b8Xo.d.mts.map +1 -0
- package/dist/{dist-DV5ISja1.mjs → dist-B04dlFHg.mjs} +3 -3
- package/dist/{dist-DV5ISja1.mjs.map → dist-B04dlFHg.mjs.map} +1 -1
- package/dist/dist-DWgRbDN3.mjs +140 -0
- package/dist/dist-DWgRbDN3.mjs.map +1 -0
- package/dist/domain/AiError.d.mts +1 -1
- package/dist/domain/Audio.d.mts +1 -1
- package/dist/domain/Image.d.mts +1 -1
- package/dist/domain/Items.d.mts +1 -1
- package/dist/domain/Media.d.mts +1 -1
- package/dist/domain/Music.d.mts +1 -1
- package/dist/domain/Turn.d.mts +4 -4
- package/dist/domain/Turn.test.mjs +1 -1
- package/dist/embedding-model/Embedding.d.mts +1 -1
- package/dist/embedding-model/EmbeddingModel.d.mts +1 -1
- package/dist/embedding-model/EmbeddingModel.test.mjs +1 -1
- package/dist/embedding-model/EmbeddingModel.test.mjs.map +1 -1
- package/dist/index.d.mts +16 -13
- package/dist/index.mjs +5 -2
- package/dist/language-model/LanguageModel.d.mts +10 -5
- package/dist/language-model/LanguageModel.d.mts.map +1 -1
- package/dist/language-model/LanguageModel.mjs.map +1 -1
- package/dist/language-model/LanguageModel.test.mjs +1 -1
- package/dist/loop/Loop.d.mts +2 -141
- package/dist/loop/Loop.mjs +16 -20
- package/dist/loop/Loop.mjs.map +1 -1
- package/dist/loop/Loop.test.mjs +18 -1
- package/dist/loop/Loop.test.mjs.map +1 -1
- package/dist/{magic-string.es-BgIV5Mu3.mjs → magic-string.es-Dk-MMA0F.mjs} +1 -1
- package/dist/{magic-string.es-BgIV5Mu3.mjs.map → magic-string.es-Dk-MMA0F.mjs.map} +1 -1
- package/dist/music-generator/MusicGenerator.d.mts +2 -2
- package/dist/music-generator/MusicGenerator.test.mjs +1 -1
- package/dist/observability/Metrics.d.mts +116 -28
- package/dist/observability/Metrics.d.mts.map +1 -1
- package/dist/observability/Metrics.mjs +250 -38
- package/dist/observability/Metrics.mjs.map +1 -1
- package/dist/observability/Metrics.test.d.mts +1 -0
- package/dist/observability/Metrics.test.mjs +187 -0
- package/dist/observability/Metrics.test.mjs.map +1 -0
- package/dist/observability/Telemetry.d.mts +37 -0
- package/dist/observability/Telemetry.d.mts.map +1 -0
- package/dist/observability/Telemetry.mjs +57 -0
- package/dist/observability/Telemetry.mjs.map +1 -0
- package/dist/observability/Telemetry.test.d.mts +1 -0
- package/dist/observability/Telemetry.test.mjs +92 -0
- package/dist/observability/Telemetry.test.mjs.map +1 -0
- package/dist/retry/Retry.d.mts +2 -2
- package/dist/retry/Retry.test.mjs +1 -1
- package/dist/sandbox/Sandbox.d.mts +1 -1
- package/dist/sandbox/SandboxError.d.mts +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +2 -2
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +1 -1
- package/dist/streaming/JSONL.d.mts +1 -1
- package/dist/streaming/JSONL.test.mjs +1 -1
- package/dist/streaming/SSE.test.mjs +1 -1
- package/dist/structured-format/StructuredFormat.d.mts +1 -1
- package/dist/structured-format/StructuredFormat.mjs.map +1 -1
- package/dist/structured-format/StructuredFormat.test.mjs +1 -1
- package/dist/testing/MockMusicGenerator.d.mts +1 -1
- package/dist/testing/MockProvider.d.mts +1 -1
- package/dist/testing/MockSpeechSynthesizer.d.mts +1 -1
- package/dist/tool/Approval.d.mts +3 -3
- package/dist/tool/Approval.test.mjs +35 -34
- package/dist/tool/Approval.test.mjs.map +1 -1
- package/dist/tool/HistoryCheck.d.mts +2 -2
- package/dist/tool/Tool.d.mts +2 -2
- package/dist/tool/Tool.mjs +112 -22
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/Tool.test.mjs +41 -3
- package/dist/tool/Tool.test.mjs.map +1 -1
- package/dist/tool/ToolEvent.d.mts +2 -151
- package/dist/tool/ToolResult.d.mts +2 -138
- package/dist/tool/ToolResult.mjs +18 -3
- package/dist/tool/ToolResult.mjs.map +1 -1
- package/dist/tool/Toolkit.d.mts +2 -73
- package/dist/tool/Toolkit.mjs +106 -28
- package/dist/tool/Toolkit.mjs.map +1 -1
- package/dist/tool/Toolkit.test.mjs +113 -7
- package/dist/tool/Toolkit.test.mjs.map +1 -1
- package/dist/transcriber/Transcriber.d.mts +2 -2
- package/dist/transcriber/Transcriber.test.mjs +1 -1
- package/dist/web-search/WebSearch.d.mts +119 -0
- package/dist/web-search/WebSearch.d.mts.map +1 -0
- package/dist/web-search/WebSearch.mjs +42 -0
- package/dist/web-search/WebSearch.mjs.map +1 -0
- package/dist/web-search/WebSearchTool.d.mts +58 -0
- package/dist/web-search/WebSearchTool.d.mts.map +1 -0
- package/dist/web-search/WebSearchTool.mjs +69 -0
- package/dist/web-search/WebSearchTool.mjs.map +1 -0
- package/package.json +9 -1
- package/src/embedding-model/EmbeddingModel.test.ts +4 -0
- package/src/index.ts +3 -0
- package/src/language-model/LanguageModel.ts +7 -2
- package/src/loop/Loop.test.ts +22 -0
- package/src/loop/Loop.ts +27 -4
- package/src/observability/Metrics.test.ts +266 -0
- package/src/observability/Metrics.ts +505 -65
- package/src/observability/Telemetry.test.ts +123 -0
- package/src/observability/Telemetry.ts +96 -0
- package/src/structured-format/StructuredFormat.ts +4 -0
- package/src/tool/Approval.test.ts +22 -21
- package/src/tool/Tool.test.ts +55 -2
- package/src/tool/Tool.ts +221 -55
- package/src/tool/ToolResult.ts +22 -1
- package/src/tool/Toolkit.test.ts +168 -7
- package/src/tool/Toolkit.ts +336 -99
- package/src/web-search/WebSearch.ts +150 -0
- package/src/web-search/WebSearchTool.ts +106 -0
- package/dist/Tool-CiFXYjmR.d.mts +0 -102
- package/dist/Tool-CiFXYjmR.d.mts.map +0 -1
- package/dist/loop/Loop.d.mts.map +0 -1
- package/dist/tool/ToolEvent.d.mts.map +0 -1
- package/dist/tool/ToolResult.d.mts.map +0 -1
- package/dist/tool/Toolkit.d.mts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Duration } from "effect";
|
|
2
|
-
import * as _$effect_Types0 from "effect/Types";
|
|
3
2
|
import * as _$effect_Cause0 from "effect/Cause";
|
|
3
|
+
import * as _$effect_Types0 from "effect/Types";
|
|
4
4
|
|
|
5
5
|
//#region src/domain/AiError.d.ts
|
|
6
6
|
declare namespace AiError_d_exports {
|
|
@@ -129,4 +129,4 @@ declare class Unsupported extends Unsupported_base<{
|
|
|
129
129
|
type AiError = RateLimited | Unavailable | Timeout | ContentFiltered | ContextLengthExceeded | InvalidRequest | AuthFailed | Cancelled | IncompleteTurn | GenerationFailed | Unsupported;
|
|
130
130
|
//#endregion
|
|
131
131
|
export { Cancelled as a, GenerationFailed as c, RateLimited as d, Scope$1 as f, Unsupported as h, AuthSubtype as i, IncompleteTurn as l, Unavailable as m, AiError_d_exports as n, ContentFiltered as o, Timeout as p, AuthFailed as r, ContextLengthExceeded as s, AiError as t, InvalidRequest as u };
|
|
132
|
-
//# sourceMappingURL=AiError-
|
|
132
|
+
//# sourceMappingURL=AiError-CrdR1EQi.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiError-
|
|
1
|
+
{"version":3,"file":"AiError-CrdR1EQi.d.mts","names":[],"sources":["../src/domain/AiError.ts"],"mappings":";;;;;;;;KAEY,OAAA;AAAA,cAAqC,gBAAA;;;cAEpC,WAAA,SAAoB,gBAAA;EAC/B,QAAA;EACA,UAAA,GAAa,QAAA,CAAS,QAAA;EACtB,KAAA,GAAQ,OAAA;EACR,SAAA;EACA,GAAA;AAAA;AAAA,cACG,gBAAA;;;cAEQ,WAAA,SAAoB,gBAAA;EAC/B,QAAA;EACA,UAAA,GAAa,QAAA,CAAS,QAAA;EACtB,MAAA;EACA,SAAA;EACA,GAAA;AAAA;AAAA,cACG,YAAA;;;cAEQ,OAAA,SAAgB,YAAA;EAC3B,QAAA;EACA,SAAA;EACA,GAAA;AAAA;AAAA,cACG,oBAAA;;;cAEQ,eAAA,SAAwB,oBAAA;EACnC,QAAA;EACA,MAAA;EACA,SAAA;EACA,GAAA;AAAA;AAAA,cACG,0BAAA;;;cAEQ,qBAAA,SAA8B,0BAAA;EACzC,QAAA;EACA,UAAA;EACA,SAAA;EACA,GAAA;AAAA;AAAA,cACG,mBAAA;;;cAEQ,cAAA,SAAuB,mBAAA;EAClC,QAAA;EACA,KAAA;EACA,SAAA;EACA,GAAA;AAAA;AAAA,KAGU,WAAA;AAAA,cAAyD,eAAA;;;cAExD,UAAA,SAAmB,eAAA;EAC9B,QAAA;EACA,OAAA,EAAS,WAAA;EACT,GAAA;AAAA;AAAA,cACG,cAAA;;;cAEQ,SAAA,SAAkB,cAAA;EAC7B,QAAA;AAAA;AAAA,cACG,qBAAA;;;;;;;;;cAQQ,gBAAA,SAAyB,qBAAA;EACpC,QAAA;EACA,IAAA;EACA,OAAA;EACA,SAAA;EACA,GAAA;AAAA;AAAA,cACG,mBAAA;;;;;;;;cAOQ,cAAA,SAAuB,mBAAA;EAClC,GAAA;AAAA;AAAA,cACG,gBAAA;;;;;;;;;;;;;AA9DA;;;;cA8EQ,WAAA,SAAoB,gBAAA;EAC/B,QAAA;EACA,UAAA;EACA,MAAA;AAAA;AAAA,KAGU,OAAA,GACR,WAAA,GACA,WAAA,GACA,OAAA,GACA,eAAA,GACA,qBAAA,GACA,cAAA,GACA,UAAA,GACA,SAAA,GACA,cAAA,GACA,gBAAA,GACA,WAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as MediaUrl, n as MediaBytes, t as MediaBase64 } from "./Media-
|
|
1
|
+
import { i as MediaUrl, n as MediaBytes, t as MediaBase64 } from "./Media-DOLyaygI.mjs";
|
|
2
2
|
import { Duration } from "effect";
|
|
3
3
|
|
|
4
4
|
//#region src/domain/Audio.d.ts
|
|
@@ -59,4 +59,4 @@ type AudioBlob = {
|
|
|
59
59
|
};
|
|
60
60
|
//#endregion
|
|
61
61
|
export { AudioSource as a, isAudioBytes as c, AudioMimeType as i, isAudioUrl as l, AudioChunk as n, Audio_d_exports as o, AudioFormat as r, isAudioBase64 as s, AudioBlob as t };
|
|
62
|
-
//# sourceMappingURL=Audio-
|
|
62
|
+
//# sourceMappingURL=Audio-DDSKCkSe.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Audio-
|
|
1
|
+
{"version":3,"file":"Audio-DDSKCkSe.d.mts","names":[],"sources":["../src/domain/Audio.ts"],"mappings":";;;;;;;;;;;;;;;KAWY,aAAA;;;;;AAAZ;;;;;KA0BY,WAAA,GACR,QAAA,CAAS,aAAA,IACT,WAAA,CAAY,aAAA,IACZ,UAAA,CAAW,aAAA;AAAA,cAEF,UAAA,GAAc,CAAA,EAAG,WAAA,KAAc,CAAA,IAAK,QAAA,CAAS,aAAA;AAAA,cAC7C,aAAA,GAAiB,CAAA,EAAG,WAAA,KAAc,CAAA,IAAK,WAAA,CAAY,aAAA;AAAA,cAEnD,YAAA,GAAgB,CAAA,EAAG,WAAA,KAAc,CAAA,IAAK,UAAA,CAAW,aAAA;;;;;;;KAQlD,WAAA;EAAA,SACD,SAAA;EAAA,SACA,QAAA;EAAA,SAUA,UAAA,wDA1BK;EAAA,SA4BL,OAAA;EAAA,SACA,QAAA;AAAA;;AA1BX;;;;KAkCY,UAAA;EAAA,SACD,KAAA,EAAO,UAAA;AAAA;;;;;KAON,SAAA;EAAA,SACD,MAAA,EAAQ,WAAA;EAAA,SACR,KAAA,EAAO,UAAA;EAAA,SACP,QAAA,GAAW,QAAA,CAAS,QAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as MediaUrl, n as MediaBytes, r as MediaSource, t as MediaBase64 } from "./Media-
|
|
1
|
+
import { i as MediaUrl, n as MediaBytes, r as MediaSource, t as MediaBase64 } from "./Media-DOLyaygI.mjs";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
3
|
|
|
4
4
|
//#region src/domain/Image.d.ts
|
|
@@ -58,4 +58,4 @@ declare const isImageBytes: <I>(input: I) => input is I & {
|
|
|
58
58
|
};
|
|
59
59
|
//#endregion
|
|
60
60
|
export { ImageUrlSource as a, imageBytes as c, isImageBytes as d, isImageUrl as f, ImageSource as i, imageUrl as l, ImageBytesSource as n, Image_d_exports as o, ImageMimeType as r, imageBase64 as s, ImageBase64Source as t, isImageBase64 as u };
|
|
61
|
-
//# sourceMappingURL=Image-
|
|
61
|
+
//# sourceMappingURL=Image-C_Zjpwhc.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image-
|
|
1
|
+
{"version":3,"file":"Image-C_Zjpwhc.d.mts","names":[],"sources":["../src/domain/Image.ts"],"mappings":";;;;;;;;;;;;;;;KAWY,aAAA;AAAA,KAYA,cAAA,GAAiB,QAAA,CAAS,aAAA;AAAA,KAC1B,iBAAA,GAAoB,WAAA,CAAY,aAAA;AAAA,KAChC,gBAAA,GAAmB,UAAA,CAAW,aAAA;;;;;AAd1C;;;KAuBY,WAAA,GAAc,WAAA,CAAY,aAAA;AAAA,cAEzB,cAAA,EAAc,MAAA,CAAA,YAAA;EAAA;;;cAKd,iBAAA,EAAiB,MAAA,CAAA,YAAA;EAAA;;;cAKjB,gBAAA,EAAgB,MAAA,CAAA,YAAA;EAAA;;;cAKhB,WAAA,EAAa,MAAA,CAAO,MAAA,CAAO,WAAA;AAAA,cAM3B,QAAA,GAAY,GAAA,UAAa,QAAA,GAAW,aAAA,KAAgB,cAAA;AAAA,cAGpD,WAAA,GAAe,MAAA,UAAgB,QAAA,EAAU,aAAA,KAAgB,iBAAA;AAAA,cAMzD,UAAA,GAAc,KAAA,EAAO,UAAA,EAAY,QAAA,EAAU,aAAA,KAAgB,gBAAA;AAAA,cAM3D,UAAA,MAAU,KAAA,EAAA,CAAA,KAAA,KAAA,IAAA,CAAA;EAAA;;;;cACV,aAAA,MAAa,KAAA,EAAA,CAAA,KAAA,KAAA,IAAA,CAAA;EAAA;;;;cACb,YAAA,MAAY,KAAA,EAAA,CAAA,KAAA,KAAA,IAAA,CAAA;EAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as ImageSource } from "./Image-
|
|
1
|
+
import { i as ImageSource } from "./Image-C_Zjpwhc.mjs";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
3
|
|
|
4
4
|
//#region src/domain/Items.d.ts
|
|
@@ -74,8 +74,8 @@ declare const Annotation: Schema.Union<readonly [Schema.Struct<{
|
|
|
74
74
|
}>]>;
|
|
75
75
|
type Annotation = typeof Annotation.Type;
|
|
76
76
|
declare const isUrlCitation: <I>(input: I) => input is I & {
|
|
77
|
-
readonly type: "url_citation";
|
|
78
77
|
readonly url: string;
|
|
78
|
+
readonly type: "url_citation";
|
|
79
79
|
readonly start_index: number;
|
|
80
80
|
readonly end_index: number;
|
|
81
81
|
readonly title: string;
|
|
@@ -309,8 +309,8 @@ declare const isOutputText: <I>(input: I) => input is I & {
|
|
|
309
309
|
readonly type: "output_text";
|
|
310
310
|
readonly text: string;
|
|
311
311
|
readonly annotations?: readonly ({
|
|
312
|
-
readonly type: "url_citation";
|
|
313
312
|
readonly url: string;
|
|
313
|
+
readonly type: "url_citation";
|
|
314
314
|
readonly start_index: number;
|
|
315
315
|
readonly end_index: number;
|
|
316
316
|
readonly title: string;
|
|
@@ -346,8 +346,8 @@ declare const isMessage: <I>(input: I) => input is I & {
|
|
|
346
346
|
readonly type: "output_text";
|
|
347
347
|
readonly text: string;
|
|
348
348
|
readonly annotations?: readonly ({
|
|
349
|
-
readonly type: "url_citation";
|
|
350
349
|
readonly url: string;
|
|
350
|
+
readonly type: "url_citation";
|
|
351
351
|
readonly start_index: number;
|
|
352
352
|
readonly end_index: number;
|
|
353
353
|
readonly title: string;
|
|
@@ -421,4 +421,4 @@ declare const assistantText: (text: string) => Message;
|
|
|
421
421
|
declare const toolCallOutput: (call_id: string, output: string) => ToolCallOutput;
|
|
422
422
|
//#endregion
|
|
423
423
|
export { isReasoning as A, isContainerFileCitation as C, isInputText as D, isInputImage as E, systemText as F, toolCallOutput as I, userText as L, isToolCall as M, isToolCallOutput as N, isMessage as O, isUrlCitation as P, assistantText as S, isFilePath as T, StopReason as _, FilePath as a, UrlCitation as b, InputText as c, Message as d, OutputText as f, Role as g, Refusal as h, FileCitation as i, isRefusal as j, isOutputText as k, InputTokensDetails as l, Reasoning as m, ContainerFileCitation as n, HistoryItem as o, OutputTokensDetails as p, ContentBlock as r, InputImage as s, Annotation as t, Items_d_exports as u, ToolCall as v, isFileCitation as w, Usage as x, ToolCallOutput as y };
|
|
424
|
-
//# sourceMappingURL=Items-
|
|
424
|
+
//# sourceMappingURL=Items-CgKD6Npw.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Items-
|
|
1
|
+
{"version":3,"file":"Items-CgKD6Npw.d.mts","names":[],"sources":["../src/domain/Items.ts"],"mappings":";;;;;;;cAOa,SAAA,EAAS,MAAA,CAAA,MAAA;EAAA;;;KAIV,SAAA,UAAmB,SAAA,CAAU,IAAA;;;;;;;;;cAU5B,UAAA,EAAU,MAAA,CAAA,MAAA;EAAA;;;KAIX,UAAA,UAAoB,UAAA,CAAW,IAAA;AAAA,cAQ9B,WAAA,EAAW,MAAA,CAAA,MAAA;EAAA;;;;;;KAOZ,WAAA,UAAqB,WAAA,CAAY,IAAA;AAAA,cAEhC,YAAA,EAAY,MAAA,CAAA,MAAA;EAAA;;;;KAKb,YAAA,UAAsB,YAAA,CAAa,IAAA;AAAA,cAElC,qBAAA,EAAqB,MAAA,CAAA,MAAA;EAAA;;;;;;KAOtB,qBAAA,UAA+B,qBAAA,CAAsB,IAAA;AAAA,cAEpD,QAAA,EAAQ,MAAA,CAAA,MAAA;EAAA;;;;KAKT,QAAA,UAAkB,QAAA,CAAS,IAAA;AAAA,cAE1B,UAAA,EAAU,MAAA,CAAA,KAAA,WAAA,MAAA,CAAA,MAAA;EAAA;;;;;;;;;;;;;;;;;;;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aAAe,OAAA;AAAA,cAMhC,cAAA,GAAkB,OAAA,UAAiB,MAAA,aAAiB,cAAA"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { l as IncompleteTurn } from "./AiError-CrdR1EQi.mjs";
|
|
2
|
+
import { Turn, TurnEvent } from "./domain/Turn.mjs";
|
|
3
|
+
import { Data, Effect, Stream, SubscriptionRef } from "effect";
|
|
4
|
+
|
|
5
|
+
//#region src/loop/Loop.d.ts
|
|
6
|
+
declare namespace Loop_d_exports {
|
|
7
|
+
export { Next, Step, Stop, StopWith, Value, loop, loopOver, loopWithState, next, onTurnComplete, stop, value };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The tagged union a body emits per pull. `Value` carries a payload that
|
|
11
|
+
* flows downstream. `Next` ends the current iteration and continues with a
|
|
12
|
+
* new state. `Stop` ends the loop entirely with no carried state.
|
|
13
|
+
* `StopWith` also ends the loop but carries a final state that `loopOver`
|
|
14
|
+
* will thread to the next input and `loopWithState` will write to its
|
|
15
|
+
* `SubscriptionRef` before the loop ends. Plain `loop` has no next
|
|
16
|
+
* iteration to apply it to and treats `StopWith` like `Stop`.
|
|
17
|
+
*
|
|
18
|
+
* `Stop` is intentionally `{}` so the bare `stop()` helper doesn't
|
|
19
|
+
* constrain `S` from a body's stream type — every body has a `Stop`
|
|
20
|
+
* variant in its union, and forcing `S` to flow through it would break
|
|
21
|
+
* inference whenever the body never uses `next` / `stop(state)`.
|
|
22
|
+
*/
|
|
23
|
+
type Step<A, S> = Data.TaggedEnum<{
|
|
24
|
+
Value: {
|
|
25
|
+
readonly value: A;
|
|
26
|
+
};
|
|
27
|
+
Next: {
|
|
28
|
+
readonly state: S;
|
|
29
|
+
};
|
|
30
|
+
Stop: {};
|
|
31
|
+
StopWith: {
|
|
32
|
+
readonly state: S;
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Bare step constructors, so a loop body can emit `Value(...)`, `Next(...)`,
|
|
37
|
+
* `Stop()`, `StopWith(...)` directly inside a `Stream.make(...)` without the
|
|
38
|
+
* `Step.` prefix. (The `Step` object itself can't be exported under that name
|
|
39
|
+
* because it collides with the exported `Step` type.) For the common cases
|
|
40
|
+
* prefer the `value` / `next` / `stop` helpers, which also handle the
|
|
41
|
+
* single-element-stream wrapping for `next` / `stop`.
|
|
42
|
+
*/
|
|
43
|
+
declare const Value: <A, B>(args: {
|
|
44
|
+
readonly value: A;
|
|
45
|
+
}) => {
|
|
46
|
+
readonly _tag: "Value";
|
|
47
|
+
readonly value: A;
|
|
48
|
+
}, Next: <A, B>(args: {
|
|
49
|
+
readonly state: B;
|
|
50
|
+
}) => {
|
|
51
|
+
readonly _tag: "Next";
|
|
52
|
+
readonly state: B;
|
|
53
|
+
}, Stop: <A, B>(args: void) => {
|
|
54
|
+
readonly _tag: "Stop";
|
|
55
|
+
}, StopWith: <A, B>(args: {
|
|
56
|
+
readonly state: B;
|
|
57
|
+
}) => {
|
|
58
|
+
readonly _tag: "StopWith";
|
|
59
|
+
readonly state: B;
|
|
60
|
+
};
|
|
61
|
+
/** Wrap a value so it flows through the loop to downstream consumers. */
|
|
62
|
+
declare const value: <A>(a: A) => Step<A, never>;
|
|
63
|
+
/**
|
|
64
|
+
* End the current iteration and continue with a new state. Emits a single
|
|
65
|
+
* terminal `Next` step as a one-element stream, so it slots directly into a
|
|
66
|
+
* loop body or after a run of values: `values.pipe(Stream.concat(next(s)))`.
|
|
67
|
+
*/
|
|
68
|
+
declare const next: <S>(state: S) => Stream.Stream<Step<never, S>>;
|
|
69
|
+
/**
|
|
70
|
+
* End the loop. Called with no argument it emits a bare `Stop`; called with
|
|
71
|
+
* a state it emits `StopWith(state)` — `loopOver` threads that final state
|
|
72
|
+
* to the next input and `loopWithState` writes it to its `SubscriptionRef`
|
|
73
|
+
* before the loop ends. Either way it returns a single-element stream, so
|
|
74
|
+
* return it directly from a loop body.
|
|
75
|
+
*/
|
|
76
|
+
declare const stop: <S = never>(state?: S) => Stream.Stream<Step<never, S>>;
|
|
77
|
+
/**
|
|
78
|
+
* Lift a provider's `Stream<TurnEvent>` into a loop body's `Stream<Step<TurnEvent | A, S>>`.
|
|
79
|
+
* Each delta passes through as `value(delta)` (including the terminal
|
|
80
|
+
* `TurnComplete`, so the consumer sees turn boundaries naturally). Once
|
|
81
|
+
* the terminal arrives, `then(turn)` runs and its returned stream of loop
|
|
82
|
+
* steps (typically tool outputs followed by `next(state)` or `stop()`) is
|
|
83
|
+
* concatenated.
|
|
84
|
+
*
|
|
85
|
+
* Pre-pipe transforms (`Stream.tap` / `Stream.map` / `Stream.filter`) on
|
|
86
|
+
* the raw delta stream cover anything an `emit`-style callback would do.
|
|
87
|
+
*
|
|
88
|
+
* `then` may return the step stream directly, or an `Effect` that produces
|
|
89
|
+
* it (for branches that need to read a `Ref`, decode tool args, log, etc.).
|
|
90
|
+
* Mirrors `loop`'s body: return a bare `stop()` / `next(s)` where no effect
|
|
91
|
+
* is needed, lift to `Effect` only where one is.
|
|
92
|
+
*
|
|
93
|
+
* If the upstream ends without a `TurnComplete`, the resulting stream
|
|
94
|
+
* fails with `AiError.IncompleteTurn`. Catch it via `Stream.catchTag` if
|
|
95
|
+
* you want to recover.
|
|
96
|
+
*
|
|
97
|
+
* Dual: data-first `onTurnComplete(deltas, then)` and data-last
|
|
98
|
+
* `deltas.pipe(onTurnComplete(then))` both work.
|
|
99
|
+
*/
|
|
100
|
+
type TurnContinuation<S, A, E2, R2> = Stream.Stream<Step<A, S>, E2, R2> | Effect.Effect<Stream.Stream<Step<A, S>, E2, R2>, E2, R2>;
|
|
101
|
+
declare const onTurnComplete: {
|
|
102
|
+
<S, A, E2 = never, R2 = never>(then: (turn: Turn) => TurnContinuation<S, A, E2, R2>): <E, R>(deltas: Stream.Stream<TurnEvent, E, R>) => Stream.Stream<Step<TurnEvent | A, S>, E | E2 | IncompleteTurn, R | R2>;
|
|
103
|
+
<S, A, E, R, E2 = never, R2 = never>(deltas: Stream.Stream<TurnEvent, E, R>, then: (turn: Turn) => TurnContinuation<S, A, E2, R2>): Stream.Stream<Step<TurnEvent | A, S>, E | E2 | IncompleteTurn, R | R2>;
|
|
104
|
+
};
|
|
105
|
+
type LoopBody<S, A, E, R> = (state: S) => Stream.Stream<Step<A, S>, E, R> | Effect.Effect<Stream.Stream<Step<A, S>, E, R>, E, R>;
|
|
106
|
+
/**
|
|
107
|
+
* Drive a state-threaded loop body. Each iteration runs `body(state)` to get
|
|
108
|
+
* a `Stream<Step<A, S>>`; values flow downstream, `next(s)` continues with
|
|
109
|
+
* a new state, `stop()` ends the loop. See the file header for the full
|
|
110
|
+
* pull-based execution model.
|
|
111
|
+
*
|
|
112
|
+
* Dual: data-first `loop(initial, body)` and data-last `loop(body)(initial)`
|
|
113
|
+
* (or `pipe(initial, loop(body))`) both work.
|
|
114
|
+
*/
|
|
115
|
+
declare const loop: {
|
|
116
|
+
<S, A, E, R>(body: LoopBody<S, A, E, R>): (initial: S) => Stream.Stream<A, E, R>;
|
|
117
|
+
<S, A, E, R>(initial: S, body: LoopBody<S, A, E, R>): Stream.Stream<A, E, R>;
|
|
118
|
+
};
|
|
119
|
+
type LoopOverBody<S, I, A, E, R> = (state: S, input: I) => Stream.Stream<Step<A, S>, E, R> | Effect.Effect<Stream.Stream<Step<A, S>, E, R>, E, R>;
|
|
120
|
+
/**
|
|
121
|
+
* Input-driven sibling of `loop`. For each item pulled from the input
|
|
122
|
+
* stream, runs an inner seed-driven `loop` whose body is
|
|
123
|
+
* `(s) => body(s, item)`. State is threaded across input items.
|
|
124
|
+
*
|
|
125
|
+
* **Per-input semantics — the body emits standard `Step<A, S>`:**
|
|
126
|
+
* - `value(a)`: emit `a` downstream
|
|
127
|
+
* - `next(s)`: re-run the body with the SAME input and new state `s`
|
|
128
|
+
* (multi-turn within one input — e.g. multiple model turns + tool
|
|
129
|
+
* calls for one document)
|
|
130
|
+
* - `stop()`: end this input's inner loop, advance to the next input
|
|
131
|
+
* (state preserved)
|
|
132
|
+
* - body stream ending without a decision: same as `stop()` (advance)
|
|
133
|
+
*
|
|
134
|
+
* **Outer termination:** the input stream ending. To halt programmatically
|
|
135
|
+
* from within, end the input stream upstream (`Stream.takeWhile`, a
|
|
136
|
+
* `SubscriptionRef` gate, etc.). Reserving `stop()` for per-item
|
|
137
|
+
* advancement is what makes the common "stream of documents, multi-turn
|
|
138
|
+
* conversation per document" shape readable.
|
|
139
|
+
*
|
|
140
|
+
* Dual: data-first `loopOver(input, initial, body)` and data-last
|
|
141
|
+
* `input.pipe(loopOver(initial, body))` both work.
|
|
142
|
+
*/
|
|
143
|
+
declare const loopOver: {
|
|
144
|
+
<S, I, A, E, R>(initial: S, body: LoopOverBody<S, I, A, E, R>): <EI, RI>(input: Stream.Stream<I, EI, RI>) => Stream.Stream<A, E | EI, R | RI>;
|
|
145
|
+
<S, I, A, E, R, EI, RI>(input: Stream.Stream<I, EI, RI>, initial: S, body: LoopOverBody<S, I, A, E, R>): Stream.Stream<A, E | EI, R | RI>;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Like `loop`, but exposes the current loop state as a `SubscriptionRef`
|
|
149
|
+
* alongside the value stream.
|
|
150
|
+
*
|
|
151
|
+
* Allocates one `SubscriptionRef<S>` seeded with `initial`, then runs the
|
|
152
|
+
* loop with a wrapped body that taps every `Next(s)` step into the ref
|
|
153
|
+
* before forwarding it. The caller decides how to consume both channels:
|
|
154
|
+
*
|
|
155
|
+
* - **Final state**: drain the stream, then `SubscriptionRef.get(state)`
|
|
156
|
+
* - the ref holds the state from the last `Next` (or `initial` if the
|
|
157
|
+
* loop ended without advancing).
|
|
158
|
+
* - **Live transitions**: `SubscriptionRef.changes(state)` is a
|
|
159
|
+
* `Stream<S>` of every state observed; subscribe alongside the value
|
|
160
|
+
* stream.
|
|
161
|
+
* - **Mid-iteration peek**: `SubscriptionRef.get(state)` at any time.
|
|
162
|
+
*
|
|
163
|
+
* The returned stream and ref are independent of each other - the ref
|
|
164
|
+
* lives outside the stream's scope, so reading it after the stream
|
|
165
|
+
* completes is safe.
|
|
166
|
+
*/
|
|
167
|
+
declare const loopWithState: <S, A, E, R>(initial: S, body: LoopBody<S, A, E, R>) => Effect.Effect<{
|
|
168
|
+
readonly stream: Stream.Stream<A, E, R>;
|
|
169
|
+
readonly state: SubscriptionRef.SubscriptionRef<S>;
|
|
170
|
+
}>;
|
|
171
|
+
//#endregion
|
|
172
|
+
export { StopWith as a, loopOver as c, onTurnComplete as d, stop as f, Stop as i, loopWithState as l, Next as n, Value as o, value as p, Step as r, loop as s, Loop_d_exports as t, next as u };
|
|
173
|
+
//# sourceMappingURL=Loop-B5_cqumi.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Loop-B5_cqumi.d.mts","names":[],"sources":["../src/loop/Loop.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;KAwDY,IAAA,SAAa,IAAA,CAAK,UAAA;EAC5B,KAAA;IAAA,SAAkB,KAAA,EAAO,CAAA;EAAA;EACzB,IAAA;IAAA,SAAiB,KAAA,EAAO,CAAA;EAAA;EACxB,IAAA;EACA,QAAA;IAAA,SAAqB,KAAA,EAAO,CAAA;EAAA;AAAA;;;;;;;;;cAiBf,KAAA,SAAK,IAAA;IAAA;;;;kBAAM,IAAA;IAAA;;;;kBAAM,IAAA;IAAA;sBAAU,IAAA;IAAA;;;;;;cAG7B,KAAA,MAAY,CAAA,EAAG,CAAA,KAAI,IAAA,CAAK,CAAA;;;;;;cAOxB,IAAA,MAAW,KAAA,EAAO,CAAA,KAAI,MAAA,CAAO,MAAA,CAAO,IAAA,QAAY,CAAA;;;;;;;AAP7D;cAiBa,IAAA,cAAmB,KAAA,GAAQ,CAAA,KAAI,MAAA,CAAO,MAAA,CAAO,IAAA,QAAY,CAAA;;;;;;;;;;;;;;AAVtE;;;;;;;;;;KAwCK,gBAAA,iBACD,MAAA,CAAO,MAAA,CAAO,IAAA,CAAK,CAAA,EAAG,CAAA,GAAI,EAAA,EA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,MAAA,EAAQ,MAAA,CAAO,MAAA,CAAO,CAAA,EAAG,CAAA,EAAG,CAAA;EAAA,SAC5B,KAAA,EAAO,eAAA,CAAgB,eAAA,CAAgB,CAAA;AAAA"}
|
|
@@ -54,4 +54,4 @@ declare const isMediaBase64: <M extends string>(s: MediaSource<M>) => s is Media
|
|
|
54
54
|
declare const isMediaBytes: <M extends string>(s: MediaSource<M>) => s is MediaBytes<M>;
|
|
55
55
|
//#endregion
|
|
56
56
|
export { Media_d_exports as a, isMediaUrl as c, MediaUrl as i, MediaBytes as n, isMediaBase64 as o, MediaSource as r, isMediaBytes as s, MediaBase64 as t };
|
|
57
|
-
//# sourceMappingURL=Media-
|
|
57
|
+
//# sourceMappingURL=Media-DOLyaygI.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Media-
|
|
1
|
+
{"version":3,"file":"Media-DOLyaygI.d.mts","names":[],"sources":["../src/domain/Media.ts"],"mappings":";;;;;;;;;;;;;;;AAiCA;;;;;;;;;;;AAMA;;;;;;;;;KANY,QAAA;EAAA,SACD,IAAA;EAAA,SACA,GAAA;EAAA,SACA,QAAA,GAAW,CAAA;AAAA;AAAA,KAGV,WAAA;EAAA,SACD,IAAA;EAAA,SACA,MAAA;EAAA,SACA,QAAA,EAAU,CAAA;AAAA;AAAA,KAGT,UAAA;EAAA,SACD,IAAA;EAAA,SACA,KAAA,EAAO,UAAA;EAAA,SACP,QAAA,EAAU,CAAA;AAAA;AAAA,KAGT,WAAA,8BAAyC,QAAA,CAAS,CAAA,IAAK,WAAA,CAAY,CAAA,IAAK,UAAA,CAAW,CAAA;AAAA,cAElF,UAAA,qBAAgC,CAAA,EAAG,WAAA,CAAY,CAAA,MAAK,CAAA,IAAK,QAAA,CAAS,CAAA;AAAA,cAGlE,aAAA,qBAAmC,CAAA,EAAG,WAAA,CAAY,CAAA,MAAK,CAAA,IAAK,WAAA,CAAY,CAAA;AAAA,cAGxE,YAAA,qBAAkC,CAAA,EAAG,WAAA,CAAY,CAAA,MAAK,CAAA,IAAK,UAAA,CAAW,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Duration } from "effect";
|
|
2
|
-
import * as _$effect_Types0 from "effect/Types";
|
|
3
2
|
import * as _$effect_Cause0 from "effect/Cause";
|
|
3
|
+
import * as _$effect_Types0 from "effect/Types";
|
|
4
4
|
|
|
5
5
|
//#region src/sandbox/SandboxError.d.ts
|
|
6
6
|
declare namespace SandboxError_d_exports {
|
|
@@ -155,4 +155,4 @@ declare class SandboxUnsupported extends SandboxUnsupported_base<{
|
|
|
155
155
|
type SandboxError = SandboxCreateFailed | SandboxNotFound | SandboxAlreadyExists | SandboxExecFailed | SandboxTimeout | SandboxNetworkPolicyDenied | SandboxQuotaExceeded | SandboxInvalidRequest | SandboxAuthFailed | SandboxUnsupported;
|
|
156
156
|
//#endregion
|
|
157
157
|
export { SandboxError as a, SandboxInvalidRequest as c, SandboxQuotaExceeded as d, SandboxTimeout as f, SandboxCreateFailed as i, SandboxNetworkPolicyDenied as l, SandboxAuthFailed as n, SandboxError_d_exports as o, SandboxUnsupported as p, SandboxAuthSubtype as r, SandboxExecFailed as s, SandboxAlreadyExists as t, SandboxNotFound as u };
|
|
158
|
-
//# sourceMappingURL=SandboxError-
|
|
158
|
+
//# sourceMappingURL=SandboxError-CIrVDOMV.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SandboxError-
|
|
1
|
+
{"version":3,"file":"SandboxError-CIrVDOMV.d.mts","names":[],"sources":["../src/sandbox/SandboxError.ts"],"mappings":";;;;;;;;cAAuC,wBAAA;;;;;;;;;cAQ1B,mBAAA,SAA4B,wBAAA;EACvC,QAAA;EACA,MAAA;EACA,GAAA;AAAA;AAAA,cACG,oBAAA;;;;AAZkC;;;;cAmB1B,eAAA,SAAwB,oBAAA;EACnC,QAAA;EACA,EAAA;AAAA;AAAA,cACG,yBAAA;;;;;;;;;cAQQ,oBAAA,SAA6B,yBAAA;EACxC,QAAA;EACA,EAAA;AAAA;AAAA,cACG,sBAAA;;;;;;;;AAzBL;cAiCa,iBAAA,SAA0B,sBAAA;EACrC,QAAA;EACA,MAAA;EACA,GAAA;AAAA;AAAA,cACG,mBAAA;;;AAjCA;;;;AAAA,cAuCQ,cAAA,SAAuB,mBAAA;EAClC,QAAA;EACA,SAAA;EACA,MAAA,GAAS,QAAA,CAAS,QAAA;EAClB,GAAA;AAAA;AAAA,cACG,+BAAA;;;;;;;;;;;cAUQ,0BAAA,SAAmC,+BAAA;EAC9C,QAAA;EACA,IAAA;EACA,MAAA;EACA,GAAA;AAAA;AAAA,cACG,yBAAA;;;;;;;;cAOQ,oBAAA,SAA6B,yBAAA;EACxC,QAAA;EACA,MAAA;EACA,GAAA;AAAA;AAAA,cACG,0BAAA;;;;;;;;;;cASQ,qBAAA,SAA8B,0BAAA;EACzC,QAAA;EACA,KAAA;EACA,MAAA;EACA,GAAA;AAAA;;;;;KAOU,kBAAA;AAAA,cAAgE,sBAAA;;;cAE/D,iBAAA,SAA0B,sBAAA;EACrC,QAAA;EACA,OAAA,EAAS,kBAAA;EACT,GAAA;AAAA;AAAA,cACG,uBAAA;;;;;;AA3EA;;;;;;;;;;cA0FQ,kBAAA,SAA2B,uBAAA;EACtC,QAAA;EACA,UAAA;EACA,MAAA;AAAA;AAAA,KAGU,YAAA,GACR,mBAAA,GACA,eAAA,GACA,oBAAA,GACA,iBAAA,GACA,cAAA,GACA,0BAAA,GACA,oBAAA,GACA,qBAAA,GACA,iBAAA,GACA,kBAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect, Result, Schema, Stream } from "effect";
|
|
2
|
-
import * as _$effect_Types0 from "effect/Types";
|
|
3
2
|
import * as _$effect_Cause0 from "effect/Cause";
|
|
3
|
+
import * as _$effect_Types0 from "effect/Types";
|
|
4
4
|
import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
5
|
|
|
6
6
|
//#region src/structured-format/StructuredFormat.d.ts
|
|
@@ -92,4 +92,4 @@ declare const decodeJsonLines: <A>(format: StructuredFormat<A>) => <E, R>(self:
|
|
|
92
92
|
declare const decodeJsonLinesRecoverable: <A>(format: StructuredFormat<A>) => <E, R>(self: Stream.Stream<string, E, R>) => Stream.Stream<Result.Result<A, JsonParseError | StructuredDecodeError>, E, R>;
|
|
93
93
|
//#endregion
|
|
94
94
|
export { StructuredFormat_d_exports as a, decodeJsonLines as c, parseJson as d, StructuredFormat as i, decodeJsonLinesRecoverable as l, JsonParseError as n, StructuredSchema as o, StructuredDecodeError as r, decode as s, DecodeIssue as t, fromEffectSchema as u };
|
|
95
|
-
//# sourceMappingURL=StructuredFormat-
|
|
95
|
+
//# sourceMappingURL=StructuredFormat-CMJFD3sn.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructuredFormat-
|
|
1
|
+
{"version":3,"file":"StructuredFormat-CMJFD3sn.d.mts","names":[],"sources":["../src/structured-format/StructuredFormat.ts"],"mappings":";;;;;;;;;;;;;;;KAaY,gBAAA,qBAAqC,gBAAA,UAA0B,MAAA,IACzE,oBAAA,UAA8B,MAAA;;;;;;KAOpB,gBAAA;EAAA,SACD,IAAA;EAAA,SACA,WAAA;EAAA,SACA,MAAA,EAAQ,gBAAA,CAAiB,CAAA;;AAXpC;;;WAgBW,MAAA;AAAA;;KAIC,WAAA;EAAA,SACD,IAAA,EAAM,aAAA;EAAA,SACN,OAAA;AAAA;AAAA,cACV,0BAAA;;;;;;AAfD;cAyBa,qBAAA,SAA8B,0BAAA;EAAA,SAChC,GAAA;EAAA,SACA,MAAA,EAAQ,aAAA,CAAc,WAAA;AAAA;AAAA,cAC5B,mBAAA;;;;;;;cAMQ,cAAA,SAAuB,mBAAA;EAAA,SACzB,GAAA;EAAA,SACA,KAAA;AAAA;;;;;AArBV;cAiCY,gBAAA,aAA8B,MAAA,CAAO,KAAA,wBAChD,MAAA,EAAQ,CAAA,EACR,OAAA;EAAA,SACW,IAAA;EAAA,SACA,WAAA;EAAA,SACA,MAAA;AAAA,MAEV,gBAAA,CAAiB,CAAA;;;;;;cAyCP,MAAA,MACP,MAAA,EAAQ,gBAAA,CAAiB,CAAA,OAC5B,GAAA,cAAe,MAAA,CAAO,MAAA,CAAO,CAAA,EAAG,qBAAA;;;;;;cAoBtB,SAAA,MACP,MAAA,EAAQ,gBAAA,CAAiB,CAAA,OAC5B,GAAA,aAAc,MAAA,CAAO,MAAA,CAAO,CAAA,EAAG,cAAA,GAAiB,qBAAA;;;;;cAiBtC,eAAA,MACP,MAAA,EAAQ,gBAAA,CAAiB,CAAA,aAE3B,IAAA,EAAM,MAAA,CAAO,MAAA,SAAe,CAAA,EAAG,CAAA,MAC9B,MAAA,CAAO,MAAA,CAAO,CAAA,EAAG,CAAA,GAAI,cAAA,GAAiB,qBAAA,EAAuB,CAAA;;;;;;;cASrD,0BAAA,MACP,MAAA,EAAQ,gBAAA,CAAiB,CAAA,aAE3B,IAAA,EAAM,MAAA,CAAO,MAAA,SAAe,CAAA,EAAG,CAAA,MAC9B,MAAA,CAAO,MAAA,CAAO,MAAA,CAAO,MAAA,CAAO,CAAA,EAAG,cAAA,GAAiB,qBAAA,GAAwB,CAAA,EAAG,CAAA"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { v as ToolCall, y as ToolCallOutput } from "./Items-CgKD6Npw.mjs";
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
|
+
import * as _$effect_Cause0 from "effect/Cause";
|
|
4
|
+
import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
|
+
|
|
6
|
+
//#region src/tool/Tool.d.ts
|
|
7
|
+
declare namespace Tool_d_exports {
|
|
8
|
+
export { AnyLocalTool, AnyTool, DecodableTool, Emit, InteractionTool, ProviderTool, SignalTool, Tool, ToolDescriptor, ToolError, ToolInputSchema, ToolR, ToolValidationError, decodeArgs, descriptorsOf, execute, fromEffectSchema, fromStandardSchema, interaction, make, provider, signal, toDescriptors, withName, withRun };
|
|
9
|
+
}
|
|
10
|
+
declare const ToolError_base: Schema.Class<ToolError, Schema.TaggedStruct<"ToolError", {
|
|
11
|
+
readonly call_id: Schema.String;
|
|
12
|
+
readonly tool: Schema.String;
|
|
13
|
+
readonly message: Schema.String;
|
|
14
|
+
readonly cause: Schema.optional<Schema.Unknown>;
|
|
15
|
+
}>, _$effect_Cause0.YieldableError>;
|
|
16
|
+
declare class ToolError extends ToolError_base {}
|
|
17
|
+
declare const ToolValidationError_base: Schema.Class<ToolValidationError, Schema.TaggedStruct<"ToolValidationError", {
|
|
18
|
+
readonly call_id: Schema.String;
|
|
19
|
+
readonly tool: Schema.String;
|
|
20
|
+
readonly issues: Schema.$Array<Schema.Struct<{
|
|
21
|
+
readonly message: Schema.String;
|
|
22
|
+
readonly path: Schema.optional<Schema.$Array<Schema.Unknown>>;
|
|
23
|
+
}>>;
|
|
24
|
+
}>, _$effect_Cause0.YieldableError>;
|
|
25
|
+
/**
|
|
26
|
+
* The model's `arguments` for a call failed the tool's `inputSchema`. Distinct
|
|
27
|
+
* from `ToolError` (malformed JSON, runtime crash) so callers can tell a
|
|
28
|
+
* contract violation apart from a parse or execution failure, and so the
|
|
29
|
+
* structured `issues` survive instead of being flattened into a message string.
|
|
30
|
+
*/
|
|
31
|
+
declare class ToolValidationError extends ToolValidationError_base {}
|
|
32
|
+
/**
|
|
33
|
+
* Schemas accepted on `Tool.inputSchema`. Must implement both Standard
|
|
34
|
+
* Schema validation and JSON Schema conversion (for rendering tool
|
|
35
|
+
* descriptors to provider request bodies).
|
|
36
|
+
*
|
|
37
|
+
* Any Standard-Schema-compliant library that exposes both interfaces
|
|
38
|
+
* works directly: Zod 4+, Valibot, ArkType, Effect Schema (after
|
|
39
|
+
* `fromEffectSchema`), etc.
|
|
40
|
+
*/
|
|
41
|
+
type ToolInputSchema<Input = unknown> = StandardSchemaV1<unknown, Input> & StandardJSONSchemaV1<unknown, Input>;
|
|
42
|
+
/**
|
|
43
|
+
* Convenience wrapper for Effect Schema users - adds both the
|
|
44
|
+
* `validate` and `jsonSchema` extensions to a plain Effect Schema so it
|
|
45
|
+
* can be used as a `Tool.inputSchema`.
|
|
46
|
+
*/
|
|
47
|
+
declare const fromEffectSchema: <S extends Schema.Codec<any, any, never, any>>(schema: S) => S & ToolInputSchema<S["Type"]>;
|
|
48
|
+
/**
|
|
49
|
+
* Use any schema library that implements both Standard Schema (validation)
|
|
50
|
+
* and Standard JSON Schema (JSON Schema generation) as a `Tool.inputSchema`.
|
|
51
|
+
* Covers Zod 4.2+, Valibot 1.2+, and ArkType 2.1.28+ in one helper.
|
|
52
|
+
*
|
|
53
|
+
* Effect Schema doesn't implement Standard JSON Schema natively — use
|
|
54
|
+
* `fromEffectSchema` for those.
|
|
55
|
+
*
|
|
56
|
+
* The intersection constraint catches missing interfaces at compile time:
|
|
57
|
+
* a Zod v3 schema (no Standard JSON Schema) produces a precise type error
|
|
58
|
+
* pointing at the missing interface rather than a runtime surprise. The
|
|
59
|
+
* helper itself is a thin type-narrowing identity — schemas that satisfy
|
|
60
|
+
* both standards already structurally satisfy `ToolInputSchema`; the
|
|
61
|
+
* helper makes the input type inference explicit at the call site.
|
|
62
|
+
*/
|
|
63
|
+
declare const fromStandardSchema: <S extends StandardSchemaV1 & StandardJSONSchemaV1>(schema: S) => S & ToolInputSchema<StandardSchemaV1.InferOutput<S>>;
|
|
64
|
+
/**
|
|
65
|
+
* Emit one intermediate `Event` from inside a tool's `run`. Backed by the
|
|
66
|
+
* executor's per-call queue, so it returns an `Effect` (backpressure) and
|
|
67
|
+
* composes with `Stream.runForEach(emit)`.
|
|
68
|
+
*/
|
|
69
|
+
type Emit<Event> = (event: Event) => Effect.Effect<void>;
|
|
70
|
+
/**
|
|
71
|
+
* A model-visible tool with a local `Effect` executor. `run` computes the
|
|
72
|
+
* model-facing `Output`; emitting progress is a side channel via `emit`. A
|
|
73
|
+
* plain tool never calls `emit` (its `Event` is irrelevant); a streaming tool
|
|
74
|
+
* emits intermediate `Event`s that flow to the consumer as
|
|
75
|
+
* `ToolEvent.Progress` in real time.
|
|
76
|
+
*
|
|
77
|
+
* This is one of four tool *kinds*, discriminated by `_tag`. The other three
|
|
78
|
+
* (`ProviderTool`, `SignalTool`, `InteractionTool`) are model-visible but have
|
|
79
|
+
* no local executor — see their constructors below. `Tool` keeps its name (and
|
|
80
|
+
* the `Tool.make` constructor) because the local kind is by far the common one.
|
|
81
|
+
*/
|
|
82
|
+
type Tool<Name extends string, Input, Event, Output, R = never> = {
|
|
83
|
+
readonly _tag: "LocalTool";
|
|
84
|
+
readonly name: Name;
|
|
85
|
+
readonly description: string;
|
|
86
|
+
readonly inputSchema: ToolInputSchema<Input>;
|
|
87
|
+
readonly run: (input: Input, emit: Emit<Event>) => Effect.Effect<Output, unknown, R>;
|
|
88
|
+
/**
|
|
89
|
+
* Bound on this tool's emit queue. Unbounded when omitted. Per-tool because
|
|
90
|
+
* backpressure depends on how a given tool emits, unlike `concurrency`
|
|
91
|
+
* (cross-tool, on `Toolkit.run`'s options).
|
|
92
|
+
*/
|
|
93
|
+
readonly emitBufferSize?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Whether the provider should render this tool with its strict-mode
|
|
96
|
+
* flag (OpenAI's `strict: true`, etc). Default: true. The framework
|
|
97
|
+
* never rewrites the schema; if the rendered JSON Schema isn't
|
|
98
|
+
* compatible, the provider returns an error.
|
|
99
|
+
*/
|
|
100
|
+
readonly strict?: boolean;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* A provider-hosted tool: visible to the model and executed by the *provider*
|
|
104
|
+
* (native web search, code execution, RAG grounding), never by this process.
|
|
105
|
+
* It has no local `run`; `provider`/`config` tell the provider adapter how to
|
|
106
|
+
* render it. Passing it to `Toolkit.run` yields a `non_local_tool` result.
|
|
107
|
+
*/
|
|
108
|
+
type ProviderTool<Name extends string, Input, Provider extends string, Config> = {
|
|
109
|
+
readonly _tag: "ProviderTool";
|
|
110
|
+
readonly name: Name;
|
|
111
|
+
readonly description: string;
|
|
112
|
+
readonly inputSchema: ToolInputSchema<Input>;
|
|
113
|
+
readonly provider: Provider;
|
|
114
|
+
readonly config: Config;
|
|
115
|
+
readonly strict?: boolean;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* A typed request for the agent loop to change control flow (escalate, pause,
|
|
119
|
+
* schedule, hand off). Model-visible and decodable (`decodeArgs`) but never
|
|
120
|
+
* locally executed — the loop intercepts the call in `onTurnComplete` and acts
|
|
121
|
+
* on it, so there is no fake `run`. `Toolkit.run` reports it as `non_local_tool`.
|
|
122
|
+
*/
|
|
123
|
+
type SignalTool<Name extends string, Input> = {
|
|
124
|
+
readonly _tag: "SignalTool";
|
|
125
|
+
readonly name: Name;
|
|
126
|
+
readonly description: string;
|
|
127
|
+
readonly inputSchema: ToolInputSchema<Input>;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* A typed request for an external actor (user, channel, frontend) to respond
|
|
131
|
+
* before the loop resumes. Like `SignalTool` it is decode-only, but its
|
|
132
|
+
* lifecycle differs: the loop usually stops/pauses and resumes later by
|
|
133
|
+
* appending a `function_call_output` once the actor replies.
|
|
134
|
+
*/
|
|
135
|
+
type InteractionTool<Name extends string, Input> = {
|
|
136
|
+
readonly _tag: "InteractionTool";
|
|
137
|
+
readonly name: Name;
|
|
138
|
+
readonly description: string;
|
|
139
|
+
readonly inputSchema: ToolInputSchema<Input>;
|
|
140
|
+
};
|
|
141
|
+
/** A local (executable) tool of any shape. Readability alias. */
|
|
142
|
+
type AnyLocalTool<R = any> = Tool<string, any, any, any, R>;
|
|
143
|
+
/** Any of the four model-visible tool kinds. */
|
|
144
|
+
type AnyTool<R = any> = Tool<string, any, any, any, R> | ProviderTool<string, any, string, any> | SignalTool<string, any> | InteractionTool<string, any>;
|
|
145
|
+
/** A model-visible tool that carries a decodable input schema (every kind). */
|
|
146
|
+
type DecodableTool<Input> = {
|
|
147
|
+
readonly name: string;
|
|
148
|
+
readonly inputSchema: ToolInputSchema<Input>;
|
|
149
|
+
};
|
|
150
|
+
/** Extract the `R` of a local tool; non-local kinds contribute `never`. */
|
|
151
|
+
type ToolR<T> = T extends Tool<string, any, any, any, infer R> ? R : never;
|
|
152
|
+
/**
|
|
153
|
+
* Provider-agnostic tool descriptor. Each provider maps `inputSchema`
|
|
154
|
+
* to its own wire field (OpenAI → `parameters`, Anthropic →
|
|
155
|
+
* `input_schema`). Built from a `Tool` by `Tool.toDescriptors`.
|
|
156
|
+
*/
|
|
157
|
+
type ToolDescriptor = {
|
|
158
|
+
readonly name: string;
|
|
159
|
+
readonly description: string;
|
|
160
|
+
readonly inputSchema: Record<string, unknown>;
|
|
161
|
+
readonly strict?: boolean;
|
|
162
|
+
};
|
|
163
|
+
/** A model-visible tool with a local `Effect` executor. */
|
|
164
|
+
declare const make: <Name extends string, Input, Event, Output, R = never>(spec: Omit<Tool<Name, Input, Event, Output, R>, "_tag">) => Tool<Name, Input, Event, Output, R>;
|
|
165
|
+
/**
|
|
166
|
+
* A provider-hosted tool (native web search, code execution, RAG grounding).
|
|
167
|
+
* No local executor — `provider`/`config` drive the provider adapter's
|
|
168
|
+
* rendering. The model sees it; `Toolkit.run` reports it as `non_local_tool`.
|
|
169
|
+
*/
|
|
170
|
+
declare const provider: <Name extends string, Input, Provider extends string, Config>(spec: Omit<ProviderTool<Name, Input, Provider, Config>, "_tag">) => ProviderTool<Name, Input, Provider, Config>;
|
|
171
|
+
/**
|
|
172
|
+
* A typed control-flow signal to the agent loop (escalate, pause, schedule,
|
|
173
|
+
* hand off). Decode-only: the loop interprets the call rather than executing a
|
|
174
|
+
* handler, so there is no `run`.
|
|
175
|
+
*/
|
|
176
|
+
declare const signal: <Name extends string, Input>(spec: Omit<SignalTool<Name, Input>, "_tag">) => SignalTool<Name, Input>;
|
|
177
|
+
/**
|
|
178
|
+
* A typed request for an external actor to respond before the loop resumes
|
|
179
|
+
* (frontend, Telegram, CLI prompt). Decode-only; the loop stops/pauses and
|
|
180
|
+
* resumes by appending the actor's `function_call_output`.
|
|
181
|
+
*/
|
|
182
|
+
declare const interaction: <Name extends string, Input>(spec: Omit<InteractionTool<Name, Input>, "_tag">) => InteractionTool<Name, Input>;
|
|
183
|
+
/**
|
|
184
|
+
* Return a copy of a tool under a new `name`. Useful for resolving a name
|
|
185
|
+
* clash before combining tools into one `Toolkit`. Literal-preserving, so the
|
|
186
|
+
* renamed tool keys the toolkit record under the new name statically.
|
|
187
|
+
*/
|
|
188
|
+
declare const withName: <N extends string, T extends AnyTool>(tool: T, name: N) => Omit<T, "name"> & {
|
|
189
|
+
readonly name: N;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Replace a local tool's `run`, keeping its model-facing definition (name,
|
|
193
|
+
* description, schema, `_tag`) identical. The new `run`'s `input` is typed from
|
|
194
|
+
* the original tool, so override/mock need no annotation:
|
|
195
|
+
*
|
|
196
|
+
* const safe = { ...toolkit, send_email: Tool.withRun(toolkit.send_email,
|
|
197
|
+
* ({ to }) => Effect.succeed({ status: "dry-run", to })) }
|
|
198
|
+
*
|
|
199
|
+
* Descriptors stay identical to production, so a mocked toolkit can't drift
|
|
200
|
+
* from the contract the model sees.
|
|
201
|
+
*/
|
|
202
|
+
declare const withRun: <Name extends string, Input, Event, Output, R, Output2, R2 = never>(tool: Tool<Name, Input, Event, Output, R>, run: (input: Input, emit: Emit<Event>) => Effect.Effect<Output2, unknown, R2>) => Tool<Name, Input, Event, Output2, R2>;
|
|
203
|
+
/** Render tools to provider-agnostic descriptors. Every kind is model-visible. */
|
|
204
|
+
declare const toDescriptors: (tools: ReadonlyArray<AnyTool>) => ReadonlyArray<ToolDescriptor>;
|
|
205
|
+
/**
|
|
206
|
+
* Render a `Toolkit` (a name-indexed record of tools) to descriptors, treating
|
|
207
|
+
* an absent toolkit as no tools. The normalization point the `LanguageModel`
|
|
208
|
+
* boundary uses so a request can carry the toolkit itself instead of a
|
|
209
|
+
* pre-rendered descriptor array. Lives here (not on `Toolkit`) to keep providers
|
|
210
|
+
* free of a dependency on the toolkit module — it only needs the tool values.
|
|
211
|
+
*/
|
|
212
|
+
declare const descriptorsOf: (toolkit?: Readonly<Record<string, AnyTool>>) => ReadonlyArray<ToolDescriptor>;
|
|
213
|
+
/**
|
|
214
|
+
* Decode and validate a function_call's JSON `arguments` against the tool's
|
|
215
|
+
* own `inputSchema`, yielding the typed input. The decode-only half of
|
|
216
|
+
* `execute` - reach for it when you intercept a call to translate it into a
|
|
217
|
+
* control-flow decision rather than running the tool's `run`.
|
|
218
|
+
*
|
|
219
|
+
* Malformed JSON fails with `ToolError`; a parsed body that violates
|
|
220
|
+
* `inputSchema` fails with `ToolValidationError` carrying the issues.
|
|
221
|
+
*/
|
|
222
|
+
declare const decodeArgs: <Input>(tool: DecodableTool<Input>, call: ToolCall) => Effect.Effect<Input, ToolError | ToolValidationError>;
|
|
223
|
+
/**
|
|
224
|
+
* Decode and validate the JSON arguments of a function_call against the
|
|
225
|
+
* tool's input schema, run the tool, and serialize the output into a
|
|
226
|
+
* function_call_output item. Single-shot: intermediate events emitted by
|
|
227
|
+
* `run` are discarded (use `Toolkit.run` to stream them).
|
|
228
|
+
*/
|
|
229
|
+
declare const execute: <Name extends string, Input, Event, Output, R>(tool: Tool<Name, Input, Event, Output, R>, call: ToolCall) => Effect.Effect<ToolCallOutput, ToolError | ToolValidationError, R>;
|
|
230
|
+
//#endregion
|
|
231
|
+
export { signal as C, withRun as E, provider as S, withName as T, execute as _, InteractionTool as a, interaction as b, Tool as c, ToolInputSchema as d, ToolR as f, descriptorsOf as g, decodeArgs as h, Emit as i, ToolDescriptor as l, Tool_d_exports as m, AnyTool as n, ProviderTool as o, ToolValidationError as p, DecodableTool as r, SignalTool as s, AnyLocalTool as t, ToolError as u, fromEffectSchema as v, toDescriptors as w, make as x, fromStandardSchema as y };
|
|
232
|
+
//# sourceMappingURL=Tool-0XUIT2A2.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|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