@effect-uai/core 0.4.0 → 0.5.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-csR8Bhxx.d.mts → AiError-CAX_48RU.d.mts} +2 -2
- package/dist/{AiError-csR8Bhxx.d.mts.map → AiError-CAX_48RU.d.mts.map} +1 -1
- package/dist/{Image-DxyXqzAM.d.mts → Image-HNmMpMTh.d.mts} +4 -4
- package/dist/{Image-DxyXqzAM.d.mts.map → Image-HNmMpMTh.d.mts.map} +1 -1
- package/dist/{Items-Hg5AsYxl.d.mts → Items-DqbaJoz7.d.mts} +8 -8
- package/dist/{Items-Hg5AsYxl.d.mts.map → Items-DqbaJoz7.d.mts.map} +1 -1
- package/dist/{StructuredFormat-Cl41C56K.d.mts → StructuredFormat-BbN4dosH.d.mts} +11 -4
- package/dist/StructuredFormat-BbN4dosH.d.mts.map +1 -0
- package/dist/{Tool-B8B5qVEy.d.mts → Tool-Y0__Py1H.d.mts} +20 -4
- package/dist/Tool-Y0__Py1H.d.mts.map +1 -0
- package/dist/Turn-ChbL2foc.d.mts +388 -0
- package/dist/Turn-ChbL2foc.d.mts.map +1 -0
- package/dist/domain/AiError.d.mts +1 -1
- package/dist/domain/AiError.mjs +1 -1
- package/dist/domain/AiError.mjs.map +1 -1
- package/dist/domain/Image.d.mts +1 -1
- package/dist/domain/Items.d.mts +1 -1
- package/dist/domain/Items.mjs +1 -1
- package/dist/domain/Items.mjs.map +1 -1
- package/dist/domain/Turn.d.mts +2 -2
- package/dist/domain/Turn.mjs +22 -4
- package/dist/domain/Turn.mjs.map +1 -1
- package/dist/domain/Turn.test.d.mts +1 -0
- package/dist/domain/Turn.test.mjs +136 -0
- package/dist/domain/Turn.test.mjs.map +1 -0
- package/dist/embedding-model/Embedding.d.mts +15 -3
- package/dist/embedding-model/Embedding.d.mts.map +1 -1
- package/dist/embedding-model/Embedding.mjs.map +1 -1
- package/dist/embedding-model/EmbeddingModel.d.mts +33 -17
- package/dist/embedding-model/EmbeddingModel.d.mts.map +1 -1
- package/dist/embedding-model/EmbeddingModel.mjs.map +1 -1
- package/dist/embedding-model/EmbeddingModel.test.d.mts +1 -0
- package/dist/embedding-model/EmbeddingModel.test.mjs +59 -0
- package/dist/embedding-model/EmbeddingModel.test.mjs.map +1 -0
- package/dist/index.d.mts +6 -6
- package/dist/language-model/LanguageModel.d.mts +30 -8
- package/dist/language-model/LanguageModel.d.mts.map +1 -1
- package/dist/language-model/LanguageModel.mjs +33 -3
- package/dist/language-model/LanguageModel.mjs.map +1 -1
- package/dist/language-model/LanguageModel.test.d.mts +1 -0
- package/dist/language-model/LanguageModel.test.mjs +143 -0
- package/dist/language-model/LanguageModel.test.mjs.map +1 -0
- package/dist/loop/Loop.d.mts +94 -11
- package/dist/loop/Loop.d.mts.map +1 -1
- package/dist/loop/Loop.mjs +92 -26
- package/dist/loop/Loop.mjs.map +1 -1
- package/dist/loop/Loop.test.mjs +171 -3
- package/dist/loop/Loop.test.mjs.map +1 -1
- package/dist/music-generator/MusicGenerator.d.mts +1 -1
- package/dist/observability/Metrics.d.mts +1 -1
- package/dist/observability/Metrics.mjs +1 -1
- package/dist/observability/Metrics.mjs.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +1 -1
- package/dist/streaming/JSONL.d.mts +1 -1
- package/dist/streaming/JSONL.d.mts.map +1 -1
- package/dist/streaming/JSONL.mjs +7 -12
- package/dist/streaming/JSONL.mjs.map +1 -1
- package/dist/structured-format/StructuredFormat.d.mts +2 -2
- package/dist/structured-format/StructuredFormat.mjs +9 -1
- package/dist/structured-format/StructuredFormat.mjs.map +1 -1
- package/dist/structured-format/StructuredFormat.test.d.mts +1 -0
- package/dist/structured-format/StructuredFormat.test.mjs +70 -0
- package/dist/structured-format/StructuredFormat.test.mjs.map +1 -0
- package/dist/testing/MockMusicGenerator.d.mts.map +1 -1
- package/dist/testing/MockMusicGenerator.mjs +2 -2
- package/dist/testing/MockMusicGenerator.mjs.map +1 -1
- package/dist/testing/MockProvider.d.mts +23 -18
- package/dist/testing/MockProvider.d.mts.map +1 -1
- package/dist/testing/MockProvider.mjs +56 -72
- package/dist/testing/MockProvider.mjs.map +1 -1
- package/dist/testing/MockSpeechSynthesizer.d.mts.map +1 -1
- package/dist/testing/MockSpeechSynthesizer.mjs +2 -2
- package/dist/testing/MockSpeechSynthesizer.mjs.map +1 -1
- package/dist/testing/MockTranscriber.d.mts.map +1 -1
- package/dist/testing/MockTranscriber.mjs +2 -2
- package/dist/testing/MockTranscriber.mjs.map +1 -1
- package/dist/tool/HistoryCheck.d.mts +1 -1
- package/dist/tool/Outcome.d.mts +1 -1
- package/dist/tool/Resolvers.d.mts +65 -8
- package/dist/tool/Resolvers.d.mts.map +1 -1
- package/dist/tool/Resolvers.mjs +8 -12
- package/dist/tool/Resolvers.mjs.map +1 -1
- package/dist/tool/Resolvers.test.mjs +6 -5
- package/dist/tool/Resolvers.test.mjs.map +1 -1
- package/dist/tool/Tool.d.mts +2 -2
- package/dist/tool/Tool.mjs +18 -1
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/Tool.test.d.mts +1 -0
- package/dist/tool/Tool.test.mjs +66 -0
- package/dist/tool/Tool.test.mjs.map +1 -0
- package/dist/tool/Toolkit.d.mts +4 -6
- package/dist/tool/Toolkit.d.mts.map +1 -1
- package/dist/tool/Toolkit.mjs +14 -43
- package/dist/tool/Toolkit.mjs.map +1 -1
- package/dist/transcriber/Transcriber.d.mts +1 -1
- package/package.json +1 -1
- package/src/domain/AiError.ts +1 -1
- package/src/domain/Items.ts +1 -1
- package/src/domain/Turn.test.ts +141 -0
- package/src/domain/Turn.ts +50 -43
- package/src/embedding-model/Embedding.ts +23 -0
- package/src/embedding-model/EmbeddingModel.test.ts +92 -0
- package/src/embedding-model/EmbeddingModel.ts +30 -20
- package/src/language-model/LanguageModel.test.ts +170 -0
- package/src/language-model/LanguageModel.ts +64 -1
- package/src/loop/Loop.test.ts +256 -3
- package/src/loop/Loop.ts +225 -49
- package/src/observability/Metrics.ts +1 -1
- package/src/streaming/JSONL.ts +9 -18
- package/src/structured-format/StructuredFormat.test.ts +105 -0
- package/src/structured-format/StructuredFormat.ts +14 -1
- package/src/testing/MockMusicGenerator.ts +4 -6
- package/src/testing/MockProvider.ts +126 -105
- package/src/testing/MockSpeechSynthesizer.ts +4 -6
- package/src/testing/MockTranscriber.ts +4 -6
- package/src/tool/Resolvers.test.ts +8 -5
- package/src/tool/Resolvers.ts +17 -19
- package/src/tool/Tool.test.ts +105 -0
- package/src/tool/Tool.ts +20 -0
- package/src/tool/Toolkit.ts +49 -50
- package/dist/StructuredFormat-Cl41C56K.d.mts.map +0 -1
- package/dist/Tool-B8B5qVEy.d.mts.map +0 -1
- package/dist/Turn-7geUcKsf.d.mts +0 -194
- package/dist/Turn-7geUcKsf.d.mts.map +0 -1
|
@@ -97,7 +97,7 @@ declare const IncompleteTurn_base: new <A extends Record<string, any> = {}>(args
|
|
|
97
97
|
readonly _tag: "IncompleteTurn";
|
|
98
98
|
} & Readonly<A>;
|
|
99
99
|
/**
|
|
100
|
-
* The provider's delta stream ended without a terminal `
|
|
100
|
+
* The provider's delta stream ended without a terminal `TurnComplete`.
|
|
101
101
|
* Indicates a misbehaving provider or a connection that dropped mid-flight.
|
|
102
102
|
* Non-terminal deltas seen so far have already been emitted downstream.
|
|
103
103
|
*/
|
|
@@ -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-CAX_48RU.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiError-
|
|
1
|
+
{"version":3,"file":"AiError-CAX_48RU.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"}
|
|
@@ -42,20 +42,20 @@ declare const imageUrl: (url: string, mimeType?: ImageMimeType) => ImageUrlSourc
|
|
|
42
42
|
declare const imageBase64: (base64: string, mimeType: ImageMimeType) => ImageBase64Source;
|
|
43
43
|
declare const imageBytes: (bytes: Uint8Array, mimeType: ImageMimeType) => ImageBytesSource;
|
|
44
44
|
declare const isImageUrl: <I>(input: I) => input is I & {
|
|
45
|
-
readonly url: string;
|
|
46
45
|
readonly _tag: "url";
|
|
46
|
+
readonly url: string;
|
|
47
47
|
readonly mimeType?: ImageMimeType | undefined;
|
|
48
48
|
};
|
|
49
49
|
declare const isImageBase64: <I>(input: I) => input is I & {
|
|
50
|
+
readonly _tag: "base64";
|
|
50
51
|
readonly mimeType: ImageMimeType;
|
|
51
52
|
readonly base64: string;
|
|
52
|
-
readonly _tag: "base64";
|
|
53
53
|
};
|
|
54
54
|
declare const isImageBytes: <I>(input: I) => input is I & {
|
|
55
|
+
readonly _tag: "bytes";
|
|
55
56
|
readonly mimeType: ImageMimeType;
|
|
56
57
|
readonly bytes: Uint8Array<ArrayBufferLike>;
|
|
57
|
-
readonly _tag: "bytes";
|
|
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-HNmMpMTh.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image-
|
|
1
|
+
{"version":3,"file":"Image-HNmMpMTh.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-HNmMpMTh.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 url: string;
|
|
78
77
|
readonly type: "url_citation";
|
|
78
|
+
readonly url: string;
|
|
79
79
|
readonly start_index: number;
|
|
80
80
|
readonly end_index: number;
|
|
81
81
|
readonly title: string;
|
|
@@ -127,7 +127,7 @@ type OutputText = typeof OutputText.Type;
|
|
|
127
127
|
* Model-emitted refusal. Distinct from `output_text`: the model declined
|
|
128
128
|
* to answer rather than producing normal output. Pair with
|
|
129
129
|
* `stop_reason: "refusal"` on the surrounding `Turn`. Streamed via the
|
|
130
|
-
* `
|
|
130
|
+
* `RefusalDelta` `TurnEvent`.
|
|
131
131
|
*/
|
|
132
132
|
declare const Refusal: Schema.Struct<{
|
|
133
133
|
readonly type: Schema.Literal<"refusal">;
|
|
@@ -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 url: string;
|
|
313
312
|
readonly type: "url_citation";
|
|
313
|
+
readonly url: string;
|
|
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 url: string;
|
|
350
349
|
readonly type: "url_citation";
|
|
350
|
+
readonly url: string;
|
|
351
351
|
readonly start_index: number;
|
|
352
352
|
readonly end_index: number;
|
|
353
353
|
readonly title: string;
|
|
@@ -374,15 +374,15 @@ declare const isMessage: <I>(input: I) => input is I & {
|
|
|
374
374
|
readonly providerData?: unknown;
|
|
375
375
|
};
|
|
376
376
|
declare const isFunctionCall: <I>(input: I) => input is I & {
|
|
377
|
-
readonly type: "function_call";
|
|
378
377
|
readonly call_id: string;
|
|
378
|
+
readonly type: "function_call";
|
|
379
379
|
readonly name: string;
|
|
380
380
|
readonly arguments: string;
|
|
381
381
|
readonly providerData?: unknown;
|
|
382
382
|
};
|
|
383
383
|
declare const isFunctionCallOutput: <I>(input: I) => input is I & {
|
|
384
|
-
readonly type: "function_call_output";
|
|
385
384
|
readonly call_id: string;
|
|
385
|
+
readonly type: "function_call_output";
|
|
386
386
|
readonly output: string;
|
|
387
387
|
readonly providerData?: unknown;
|
|
388
388
|
};
|
|
@@ -421,4 +421,4 @@ declare const assistantText: (text: string) => Message;
|
|
|
421
421
|
declare const functionCallOutput: (call_id: string, output: string) => FunctionCallOutput;
|
|
422
422
|
//#endregion
|
|
423
423
|
export { isInputText as A, functionCallOutput as C, isFunctionCall as D, isFilePath as E, isUrlCitation as F, systemText as I, userText as L, isOutputText as M, isReasoning as N, isFunctionCallOutput as O, isRefusal as P, assistantText as S, isFileCitation as T, Refusal as _, FilePath as a, UrlCitation as b, InputImage as c, Item as d, Items_d_exports as f, Reasoning as g, OutputTokensDetails as h, FileCitation as i, isMessage as j, isInputImage as k, InputText as l, OutputText as m, ContainerFileCitation as n, FunctionCall as o, Message as p, ContentBlock as r, FunctionCallOutput as s, Annotation as t, InputTokensDetails as u, Role as v, isContainerFileCitation as w, Usage as x, StopReason as y };
|
|
424
|
-
//# sourceMappingURL=Items-
|
|
424
|
+
//# sourceMappingURL=Items-DqbaJoz7.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Items-
|
|
1
|
+
{"version":3,"file":"Items-DqbaJoz7.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,UAAo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AAA;;;;;;cAMX,kBAAA,EAAkB,MAAA,CAAA,MAAA;EAAA;;KAGnB,kBAAA,UAA4B,kBAAA,CAAmB,IAAA;AAAA,cAE9C,mBAAA,EAAmB,MAAA,CAAA,MAAA;EAAA;;KAGpB,mBAAA,UAA6B,mBAAA,CAAoB,IAAA;AAAA,cAEhD,KAAA,EAAK,MAAA,CAAA,MAAA;EAAA;;;;;;;;;;KAON,KAAA,UAAe,KAAA,CAAM,IAAA;AAAA,cAEpB,UAAA,EAAU,MAAA,CAAA,QAAA;AAAA,KAUX,UAAA,UAAoB,UAAA,CAAW,IAAA;AAAA,cAM9B,QAAA,GAAY,IAAA,aAAe,OAAA;AAAA,cAM3B,UAAA,GAAc,IAAA,aAAe,OAAA;AAAA,cAM7B,aAAA,GAAiB,IAAA,aAAe,OAAA;AAAA,cAMhC,kBAAA,GAAsB,OAAA,UAAiB,MAAA,aAAiB,kBAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Effect, Schema, Stream } from "effect";
|
|
1
|
+
import { Effect, Result, Schema, Stream } from "effect";
|
|
2
2
|
import * as _$effect_Types0 from "effect/Types";
|
|
3
3
|
import * as _$effect_Cause0 from "effect/Cause";
|
|
4
4
|
import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
5
|
|
|
6
6
|
//#region src/structured-format/StructuredFormat.d.ts
|
|
7
7
|
declare namespace StructuredFormat_d_exports {
|
|
8
|
-
export { DecodeIssue, JsonParseError, StructuredDecodeError, StructuredFormat, StructuredSchema, decode, decodeJsonLines, fromEffectSchema, parseJson };
|
|
8
|
+
export { DecodeIssue, JsonParseError, StructuredDecodeError, StructuredFormat, StructuredSchema, decode, decodeJsonLines, decodeJsonLinesRecoverable, fromEffectSchema, parseJson };
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Cross-validator schema constraint for structured outputs. Any schema
|
|
@@ -83,6 +83,13 @@ declare const parseJson: <A>(format: StructuredFormat<A>) => (raw: string) => Ef
|
|
|
83
83
|
* Failures surface in the stream's failure channel, distinguished by tag.
|
|
84
84
|
*/
|
|
85
85
|
declare const decodeJsonLines: <A>(format: StructuredFormat<A>) => <E, R>(self: Stream.Stream<string, E, R>) => Stream.Stream<A, E | JsonParseError | StructuredDecodeError, R>;
|
|
86
|
+
/**
|
|
87
|
+
* Like {@link decodeJsonLines}, but each line yields a `Result` instead of
|
|
88
|
+
* failing the stream. Use when one bad line shouldn't abort the rest —
|
|
89
|
+
* log-and-continue, or partial-recovery with a corrective re-prompt.
|
|
90
|
+
* Upstream errors (the input stream's own `E`) still propagate normally.
|
|
91
|
+
*/
|
|
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>;
|
|
86
93
|
//#endregion
|
|
87
|
-
export { StructuredFormat_d_exports as a, decodeJsonLines as c, StructuredFormat as i,
|
|
88
|
-
//# sourceMappingURL=StructuredFormat-
|
|
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-BbN4dosH.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StructuredFormat-BbN4dosH.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;EAA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baJoz7.mjs";
|
|
2
2
|
import { Effect, Schema, Stream } from "effect";
|
|
3
3
|
import * as _$effect_Cause0 from "effect/Cause";
|
|
4
4
|
import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
5
|
|
|
6
6
|
//#region src/tool/Tool.d.ts
|
|
7
7
|
declare namespace Tool_d_exports {
|
|
8
|
-
export { AnyKindTool, AnyPlainTool, AnyStreamingTool, StreamingTool, Tool, ToolDescriptor, ToolError, ToolInputSchema, execute, fromEffectSchema, isStreamingTool, make, streaming, toDescriptors };
|
|
8
|
+
export { AnyKindTool, AnyPlainTool, AnyStreamingTool, StreamingTool, Tool, ToolDescriptor, ToolError, ToolInputSchema, execute, fromEffectSchema, fromStandardSchema, isStreamingTool, make, streaming, toDescriptors };
|
|
9
9
|
}
|
|
10
10
|
declare const ToolError_base: Schema.Class<ToolError, Schema.TaggedStruct<"ToolError", {
|
|
11
11
|
readonly call_id: Schema.String;
|
|
@@ -30,6 +30,22 @@ type ToolInputSchema<Input = unknown> = StandardSchemaV1<unknown, Input> & Stand
|
|
|
30
30
|
* can be used as a `Tool.inputSchema`.
|
|
31
31
|
*/
|
|
32
32
|
declare const fromEffectSchema: <S extends Schema.Codec<any, any, never, any>>(schema: S) => S & ToolInputSchema<S["Type"]>;
|
|
33
|
+
/**
|
|
34
|
+
* Use any schema library that implements both Standard Schema (validation)
|
|
35
|
+
* and Standard JSON Schema (JSON Schema generation) as a `Tool.inputSchema`.
|
|
36
|
+
* Covers Zod 4.2+, Valibot 1.2+, and ArkType 2.1.28+ in one helper.
|
|
37
|
+
*
|
|
38
|
+
* Effect Schema doesn't implement Standard JSON Schema natively — use
|
|
39
|
+
* `fromEffectSchema` for those.
|
|
40
|
+
*
|
|
41
|
+
* The intersection constraint catches missing interfaces at compile time:
|
|
42
|
+
* a Zod v3 schema (no Standard JSON Schema) produces a precise type error
|
|
43
|
+
* pointing at the missing interface rather than a runtime surprise. The
|
|
44
|
+
* helper itself is a thin type-narrowing identity — schemas that satisfy
|
|
45
|
+
* both standards already structurally satisfy `ToolInputSchema`; the
|
|
46
|
+
* helper makes the input type inference explicit at the call site.
|
|
47
|
+
*/
|
|
48
|
+
declare const fromStandardSchema: <S extends StandardSchemaV1 & StandardJSONSchemaV1>(schema: S) => S & ToolInputSchema<StandardSchemaV1.InferOutput<S>>;
|
|
33
49
|
type Tool<Name extends string, Input, Output, R = never> = {
|
|
34
50
|
readonly name: Name;
|
|
35
51
|
readonly description: string;
|
|
@@ -82,5 +98,5 @@ declare const toDescriptors: <R>(tools: ReadonlyArray<AnyKindTool<R>>) => Readon
|
|
|
82
98
|
*/
|
|
83
99
|
declare const execute: <Name extends string, Input, Output, R>(tool: Tool<Name, Input, Output, R>, call: FunctionCall) => Effect.Effect<FunctionCallOutput, ToolError, R>;
|
|
84
100
|
//#endregion
|
|
85
|
-
export { Tool as a, ToolInputSchema as c, fromEffectSchema as d,
|
|
86
|
-
//# sourceMappingURL=Tool-
|
|
101
|
+
export { Tool as a, ToolInputSchema as c, fromEffectSchema as d, fromStandardSchema as f, toDescriptors as g, streaming as h, StreamingTool as i, Tool_d_exports as l, make as m, AnyPlainTool as n, ToolDescriptor as o, isStreamingTool as p, AnyStreamingTool as r, ToolError as s, AnyKindTool as t, execute as u };
|
|
102
|
+
//# sourceMappingURL=Tool-Y0__Py1H.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tool-Y0__Py1H.d.mts","names":[],"sources":["../src/tool/Tool.ts"],"mappings":";;;;;;;;;cAE0E,cAAA;;;;;;cAG7D,SAAA,SAAkB,cAAA;;;;;;;;;;KAmBnB,eAAA,oBAAmC,gBAAA,UAA0B,KAAA,IACvE,oBAAA,UAA8B,KAAA;;;;AAvB0C;;cA8B7D,gBAAA,aAA8B,MAAA,CAAO,KAAA,wBAChD,MAAA,EAAQ,CAAA,KACP,CAAA,GAAI,eAAA,CAAgB,CAAA;;;;;;;;;;;;;;;;cAmBV,kBAA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BAAA,CAAiB,CAAA,IAAK,YAAA,CAAa,CAAA;AAAA,cAEzD,eAAA,MAAsB,CAAA,EAAG,WAAA,CAAY,CAAA,MAAK,CAAA,IAAK,gBAAA,CAAiB,CAAA;;;;;;cAQhE,aAAA,MACX,KAAA,EAAO,aAAA,CAAc,WAAA,CAAY,CAAA,OAChC,aAAA,CAAc,cAAA;;;;;;cAkBJ,OAAA,0CACX,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,KAAA,EAAO,MAAA,EAAQ,CAAA,GAChC,IAAA,EAAM,YAAA,KACL,MAAA,CAAO,MAAA,CAAO,kBAAA,EAAoB,SAAA,EAAW,CAAA"}
|
|
@@ -0,0 +1,388 @@
|
|
|
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-DqbaJoz7.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-ChbL2foc.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Turn-ChbL2foc.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBADA,KAAA;EAAA;IAAA;;;mBACA,IAAA;EAAA;IAAA;;;;;;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,CACR,CAAA,EACA,eAAA,GAAkB,cAAA,GAAkC,qBAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as Cancelled, c as GenerationFailed, d as RateLimited, f as Scope, h as Unsupported, i as AuthSubtype, l as IncompleteTurn, m as Unavailable, o as ContentFiltered, p as Timeout, r as AuthFailed, s as ContextLengthExceeded, t as AiError, u as InvalidRequest } from "../AiError-
|
|
1
|
+
import { a as Cancelled, c as GenerationFailed, d as RateLimited, f as Scope, h as Unsupported, i as AuthSubtype, l as IncompleteTurn, m as Unavailable, o as ContentFiltered, p as Timeout, r as AuthFailed, s as ContextLengthExceeded, t as AiError, u as InvalidRequest } from "../AiError-CAX_48RU.mjs";
|
|
2
2
|
export { AiError, AuthFailed, AuthSubtype, Cancelled, ContentFiltered, ContextLengthExceeded, GenerationFailed, IncompleteTurn, InvalidRequest, RateLimited, Scope, Timeout, Unavailable, Unsupported };
|
package/dist/domain/AiError.mjs
CHANGED
|
@@ -30,7 +30,7 @@ var Cancelled = class extends Data.TaggedError("Cancelled") {};
|
|
|
30
30
|
*/
|
|
31
31
|
var GenerationFailed = class extends Data.TaggedError("GenerationFailed") {};
|
|
32
32
|
/**
|
|
33
|
-
* The provider's delta stream ended without a terminal `
|
|
33
|
+
* The provider's delta stream ended without a terminal `TurnComplete`.
|
|
34
34
|
* Indicates a misbehaving provider or a connection that dropped mid-flight.
|
|
35
35
|
* Non-terminal deltas seen so far have already been emitted downstream.
|
|
36
36
|
*/
|