@effect-uai/core 0.9.0 → 0.11.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-CrdR1EQi.d.mts → AiError-Bf1pq4BB.d.mts} +8 -3
- package/dist/{AiError-CrdR1EQi.d.mts.map → AiError-Bf1pq4BB.d.mts.map} +1 -1
- package/dist/{Audio-DDSKCkSe.d.mts → Audio-CR7CSljJ.d.mts} +2 -2
- package/dist/{Audio-DDSKCkSe.d.mts.map → Audio-CR7CSljJ.d.mts.map} +1 -1
- package/dist/{Image-C_Zjpwhc.d.mts → Image-C4vuBmu0.d.mts} +12 -12
- package/dist/{Image-C_Zjpwhc.d.mts.map → Image-C4vuBmu0.d.mts.map} +1 -1
- package/dist/{Items-CgKD6Npw.d.mts → Items-BWNu6VGp.d.mts} +118 -92
- package/dist/Items-BWNu6VGp.d.mts.map +1 -0
- package/dist/{Loop-B5_cqumi.d.mts → Loop-D8nWpowc.d.mts} +2 -2
- package/dist/{Loop-B5_cqumi.d.mts.map → Loop-D8nWpowc.d.mts.map} +1 -1
- package/dist/{Media-DOLyaygI.d.mts → Media-D_CpcM1Z.d.mts} +1 -1
- package/dist/{Media-DOLyaygI.d.mts.map → Media-D_CpcM1Z.d.mts.map} +1 -1
- package/dist/{StructuredFormat-CMJFD3sn.d.mts → StructuredFormat-DHaUJBdd.d.mts} +1 -1
- package/dist/{StructuredFormat-CMJFD3sn.d.mts.map → StructuredFormat-DHaUJBdd.d.mts.map} +1 -1
- package/dist/{Tool-0XUIT2A2.d.mts → Tool-CXFHCQrT.d.mts} +101 -16
- package/dist/Tool-CXFHCQrT.d.mts.map +1 -0
- package/dist/{ToolEvent-DYrAUJGs.d.mts → ToolEvent-nVijCrvm.d.mts} +2 -2
- package/dist/ToolEvent-nVijCrvm.d.mts.map +1 -0
- package/dist/{ToolResult-BZd-cEWW.d.mts → ToolResult-CQqKkcDa.d.mts} +10 -4
- package/dist/ToolResult-CQqKkcDa.d.mts.map +1 -0
- package/dist/{Toolkit-BKC8b8Xo.d.mts → Toolkit-BYPwwu-j.d.mts} +65 -24
- package/dist/Toolkit-BYPwwu-j.d.mts.map +1 -0
- package/dist/browser/Browser.d.mts +190 -0
- package/dist/browser/Browser.d.mts.map +1 -0
- package/dist/browser/Browser.mjs +34 -0
- package/dist/browser/Browser.mjs.map +1 -0
- package/dist/browser/BrowserError.d.mts +141 -0
- package/dist/browser/BrowserError.d.mts.map +1 -0
- package/dist/browser/BrowserError.mjs +89 -0
- package/dist/browser/BrowserError.mjs.map +1 -0
- package/dist/browser/BrowserTool.d.mts +59 -0
- package/dist/browser/BrowserTool.d.mts.map +1 -0
- package/dist/browser/BrowserTool.mjs +86 -0
- package/dist/browser/BrowserTool.mjs.map +1 -0
- package/dist/{dist-DWgRbDN3.mjs → dist-C0m0QnUP.mjs} +71 -30
- package/dist/dist-C0m0QnUP.mjs.map +1 -0
- package/dist/{dist-B04dlFHg.mjs → dist-CcRV3-A5.mjs} +8 -8
- package/dist/{dist-B04dlFHg.mjs.map → dist-CcRV3-A5.mjs.map} +1 -1
- package/dist/domain/AiError.d.mts +2 -2
- package/dist/domain/AiError.mjs +22 -3
- package/dist/domain/AiError.mjs.map +1 -1
- package/dist/domain/Audio.d.mts +1 -1
- package/dist/domain/Citation.d.mts +60 -0
- package/dist/domain/Citation.d.mts.map +1 -0
- package/dist/domain/Citation.mjs +7 -0
- package/dist/domain/Citation.mjs.map +1 -0
- package/dist/domain/Image.d.mts +1 -1
- package/dist/domain/Items.d.mts +1 -1
- package/dist/domain/Items.mjs +13 -3
- package/dist/domain/Items.mjs.map +1 -1
- package/dist/domain/Media.d.mts +1 -1
- package/dist/domain/Music.d.mts +1 -1
- package/dist/domain/Research.d.mts +37 -0
- package/dist/domain/Research.d.mts.map +1 -0
- package/dist/domain/Research.mjs +7 -0
- package/dist/domain/Research.mjs.map +1 -0
- package/dist/domain/Turn.d.mts +92 -10
- package/dist/domain/Turn.d.mts.map +1 -1
- package/dist/domain/Turn.mjs +8 -1
- package/dist/domain/Turn.mjs.map +1 -1
- 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.mjs +2 -2
- package/dist/embedding-model/EmbeddingModel.mjs.map +1 -1
- package/dist/embedding-model/EmbeddingModel.test.mjs +1 -1
- package/dist/index.d.mts +22 -13
- package/dist/index.mjs +18 -9
- package/dist/job/Job.d.mts +80 -0
- package/dist/job/Job.d.mts.map +1 -0
- package/dist/job/Job.mjs +49 -0
- package/dist/job/Job.mjs.map +1 -0
- package/dist/language-model/LanguageModel.d.mts +4 -4
- package/dist/language-model/LanguageModel.mjs +2 -2
- package/dist/language-model/LanguageModel.mjs.map +1 -1
- package/dist/language-model/LanguageModel.test.mjs +1 -1
- package/dist/loop/Loop.d.mts +1 -1
- package/dist/loop/Loop.test.mjs +1 -1
- package/dist/music-generator/MusicGenerator.d.mts +2 -2
- package/dist/music-generator/MusicGenerator.mjs +4 -4
- package/dist/music-generator/MusicGenerator.mjs.map +1 -1
- package/dist/music-generator/MusicGenerator.test.mjs +1 -1
- package/dist/observability/Metrics.d.mts +1 -1
- package/dist/observability/Metrics.test.mjs +2 -2
- package/dist/observability/Telemetry.test.mjs +2 -2
- package/dist/research/DeepResearch.d.mts +71 -0
- package/dist/research/DeepResearch.d.mts.map +1 -0
- package/dist/research/DeepResearch.mjs +61 -0
- package/dist/research/DeepResearch.mjs.map +1 -0
- package/dist/retry/Retry.d.mts +1 -1
- package/dist/retry/Retry.test.mjs +1 -1
- package/dist/sandbox/Sandbox.mjs +18 -18
- package/dist/sandbox/Sandbox.mjs.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +2 -2
- package/dist/speech-synthesizer/SpeechSynthesizer.mjs +8 -8
- package/dist/speech-synthesizer/SpeechSynthesizer.mjs.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +1 -1
- package/dist/streaming/JSONL.d.mts +3 -1
- package/dist/streaming/JSONL.d.mts.map +1 -1
- package/dist/streaming/JSONL.mjs +5 -11
- package/dist/streaming/JSONL.mjs.map +1 -1
- package/dist/streaming/JSONL.test.mjs +10 -1
- package/dist/streaming/JSONL.test.mjs.map +1 -1
- package/dist/streaming/SSE.d.mts +5 -3
- package/dist/streaming/SSE.d.mts.map +1 -1
- package/dist/streaming/SSE.mjs +28 -38
- package/dist/streaming/SSE.mjs.map +1 -1
- package/dist/streaming/SSE.test.mjs +54 -4
- package/dist/streaming/SSE.test.mjs.map +1 -1
- package/dist/structured-format/StructuredFormat.d.mts +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 +19 -7
- package/dist/tool/Approval.d.mts.map +1 -1
- package/dist/tool/Approval.mjs +18 -11
- package/dist/tool/Approval.mjs.map +1 -1
- package/dist/tool/Approval.test.mjs +47 -8
- 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 -28
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/Tool.test.mjs +127 -3
- package/dist/tool/Tool.test.mjs.map +1 -1
- package/dist/tool/ToolEvent.d.mts +1 -1
- package/dist/tool/ToolEvent.mjs +5 -0
- package/dist/tool/ToolEvent.mjs.map +1 -1
- package/dist/tool/ToolResult.d.mts +2 -2
- package/dist/tool/ToolResult.mjs +15 -6
- package/dist/tool/ToolResult.mjs.map +1 -1
- package/dist/tool/Toolkit.d.mts +2 -2
- package/dist/tool/Toolkit.mjs +62 -22
- package/dist/tool/Toolkit.mjs.map +1 -1
- package/dist/tool/Toolkit.test.mjs +207 -9
- package/dist/tool/Toolkit.test.mjs.map +1 -1
- package/dist/transcriber/Transcriber.d.mts +2 -2
- package/dist/transcriber/Transcriber.mjs +3 -3
- package/dist/transcriber/Transcriber.mjs.map +1 -1
- package/dist/transcriber/Transcriber.test.mjs +1 -1
- package/dist/web-read/WebRead.d.mts +44 -0
- package/dist/web-read/WebRead.d.mts.map +1 -0
- package/dist/web-read/WebRead.mjs +18 -0
- package/dist/web-read/WebRead.mjs.map +1 -0
- package/dist/web-read/WebReadTool.d.mts +57 -0
- package/dist/web-read/WebReadTool.d.mts.map +1 -0
- package/dist/web-read/WebReadTool.mjs +59 -0
- package/dist/web-read/WebReadTool.mjs.map +1 -0
- package/dist/web-search/WebSearch.d.mts +1 -1
- package/dist/web-search/WebSearch.mjs +1 -1
- package/dist/web-search/WebSearch.mjs.map +1 -1
- package/dist/web-search/WebSearchTool.d.mts +12 -6
- package/dist/web-search/WebSearchTool.d.mts.map +1 -1
- package/dist/web-search/WebSearchTool.mjs +10 -5
- package/dist/web-search/WebSearchTool.mjs.map +1 -1
- package/package.json +39 -3
- package/src/browser/Browser.ts +268 -0
- package/src/browser/BrowserError.ts +145 -0
- package/src/browser/BrowserTool.ts +161 -0
- package/src/domain/AiError.ts +27 -1
- package/src/domain/Citation.ts +64 -0
- package/src/domain/Items.ts +14 -4
- package/src/domain/Research.ts +42 -0
- package/src/domain/Turn.ts +26 -0
- package/src/embedding-model/EmbeddingModel.ts +2 -2
- package/src/index.ts +9 -0
- package/src/job/Job.ts +125 -0
- package/src/language-model/LanguageModel.ts +2 -2
- package/src/music-generator/MusicGenerator.ts +4 -4
- package/src/research/DeepResearch.ts +137 -0
- package/src/sandbox/Sandbox.ts +18 -18
- package/src/speech-synthesizer/SpeechSynthesizer.ts +8 -8
- package/src/streaming/JSONL.test.ts +19 -0
- package/src/streaming/JSONL.ts +6 -38
- package/src/streaming/SSE.test.ts +86 -3
- package/src/streaming/SSE.ts +36 -80
- package/src/tool/Approval.test.ts +55 -5
- package/src/tool/Approval.ts +72 -27
- package/src/tool/Tool.test.ts +151 -1
- package/src/tool/Tool.ts +263 -66
- package/src/tool/ToolEvent.ts +5 -0
- package/src/tool/ToolResult.ts +14 -8
- package/src/tool/Toolkit.test.ts +231 -2
- package/src/tool/Toolkit.ts +175 -62
- package/src/transcriber/Transcriber.ts +3 -3
- package/src/web-read/WebRead.ts +70 -0
- package/src/web-read/WebReadTool.ts +96 -0
- package/src/web-search/WebSearch.ts +1 -1
- package/src/web-search/WebSearchTool.ts +11 -5
- package/dist/Items-CgKD6Npw.d.mts.map +0 -1
- package/dist/Tool-0XUIT2A2.d.mts.map +0 -1
- package/dist/ToolEvent-DYrAUJGs.d.mts.map +0 -1
- package/dist/ToolResult-BZd-cEWW.d.mts.map +0 -1
- package/dist/Toolkit-BKC8b8Xo.d.mts.map +0 -1
- package/dist/dist-DWgRbDN3.mjs.map +0 -1
|
@@ -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-
|
|
2
|
-
export { AiError, AuthFailed, AuthSubtype, Cancelled, ContentFiltered, ContextLengthExceeded, GenerationFailed, IncompleteTurn, InvalidRequest, RateLimited, Scope, Timeout, Unavailable, Unsupported };
|
|
1
|
+
import { a as Cancelled, c as GenerationFailed, d as RateLimited, f as Scope, g as describe, 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-Bf1pq4BB.mjs";
|
|
2
|
+
export { AiError, AuthFailed, AuthSubtype, Cancelled, ContentFiltered, ContextLengthExceeded, GenerationFailed, IncompleteTurn, InvalidRequest, RateLimited, Scope, Timeout, Unavailable, Unsupported, describe };
|
package/dist/domain/AiError.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
|
|
2
|
-
import { Data } from "effect";
|
|
2
|
+
import { Data, Match } from "effect";
|
|
3
3
|
//#region src/domain/AiError.ts
|
|
4
4
|
var AiError_exports = /* @__PURE__ */ __exportAll({
|
|
5
5
|
AuthFailed: () => AuthFailed,
|
|
@@ -12,7 +12,8 @@ var AiError_exports = /* @__PURE__ */ __exportAll({
|
|
|
12
12
|
RateLimited: () => RateLimited,
|
|
13
13
|
Timeout: () => Timeout,
|
|
14
14
|
Unavailable: () => Unavailable,
|
|
15
|
-
Unsupported: () => Unsupported
|
|
15
|
+
Unsupported: () => Unsupported,
|
|
16
|
+
describe: () => describe
|
|
16
17
|
});
|
|
17
18
|
var RateLimited = class extends Data.TaggedError("RateLimited") {};
|
|
18
19
|
var Unavailable = class extends Data.TaggedError("Unavailable") {};
|
|
@@ -50,7 +51,25 @@ var IncompleteTurn = class extends Data.TaggedError("IncompleteTurn") {};
|
|
|
50
51
|
* (`TtsIncrementalText`, `SttStreaming`) on the R channel instead.
|
|
51
52
|
*/
|
|
52
53
|
var Unsupported = class extends Data.TaggedError("Unsupported") {};
|
|
54
|
+
const withReason = (base, reason) => reason === void 0 ? base : `${base}: ${reason}`;
|
|
55
|
+
/**
|
|
56
|
+
* Short human-readable description of an error, for logs and model-facing
|
|
57
|
+
* failure messages. Prose, not a contract; branch on `_tag` instead.
|
|
58
|
+
*/
|
|
59
|
+
const describe = Match.type().pipe(Match.discriminatorsExhaustive("_tag")({
|
|
60
|
+
RateLimited: (e) => `rate limited by ${e.provider}; try again later`,
|
|
61
|
+
Unavailable: (e) => `${e.provider} is temporarily unavailable`,
|
|
62
|
+
Timeout: (e) => `the ${e.provider} request timed out`,
|
|
63
|
+
ContentFiltered: (e) => withReason(`blocked by ${e.provider}'s content filter`, e.reason),
|
|
64
|
+
ContextLengthExceeded: (e) => `the request exceeded ${e.provider}'s context limit`,
|
|
65
|
+
InvalidRequest: (e) => e.param === void 0 ? `${e.provider} rejected the request` : `${e.provider} rejected the request (param: ${e.param})`,
|
|
66
|
+
AuthFailed: (e) => `authentication against ${e.provider} failed (${e.subtype})`,
|
|
67
|
+
Cancelled: (e) => `the ${e.provider} request was cancelled`,
|
|
68
|
+
IncompleteTurn: () => "the provider stream ended without completing",
|
|
69
|
+
GenerationFailed: (e) => e.message ?? `${e.provider} failed mid-generation`,
|
|
70
|
+
Unsupported: (e) => withReason(`${e.provider} does not support ${e.capability}`, e.reason)
|
|
71
|
+
}));
|
|
53
72
|
//#endregion
|
|
54
|
-
export { AuthFailed, Cancelled, ContentFiltered, ContextLengthExceeded, GenerationFailed, IncompleteTurn, InvalidRequest, RateLimited, Timeout, Unavailable, Unsupported, AiError_exports as t };
|
|
73
|
+
export { AuthFailed, Cancelled, ContentFiltered, ContextLengthExceeded, GenerationFailed, IncompleteTurn, InvalidRequest, RateLimited, Timeout, Unavailable, Unsupported, describe, AiError_exports as t };
|
|
55
74
|
|
|
56
75
|
//# sourceMappingURL=AiError.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiError.mjs","names":[],"sources":["../../src/domain/AiError.ts"],"sourcesContent":["import { Data, Duration } from \"effect\"\n\nexport type Scope = \"rpm\" | \"tpm\" | \"rpd\" | \"tpd\"\n\nexport class RateLimited extends Data.TaggedError(\"RateLimited\")<{\n provider: string\n retryAfter?: Duration.Duration\n scope?: Scope\n requestId?: string\n raw: unknown\n}> {}\n\nexport class Unavailable extends Data.TaggedError(\"Unavailable\")<{\n provider: string\n retryAfter?: Duration.Duration\n status?: number\n requestId?: string\n raw: unknown\n}> {}\n\nexport class Timeout extends Data.TaggedError(\"Timeout\")<{\n provider: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport class ContentFiltered extends Data.TaggedError(\"ContentFiltered\")<{\n provider: string\n reason?: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport class ContextLengthExceeded extends Data.TaggedError(\"ContextLengthExceeded\")<{\n provider: string\n modelLimit?: number\n requested?: number\n raw: unknown\n}> {}\n\nexport class InvalidRequest extends Data.TaggedError(\"InvalidRequest\")<{\n provider: string\n param?: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport type AuthSubtype = \"auth\" | \"permission\" | \"billing\" | \"quota\"\n\nexport class AuthFailed extends Data.TaggedError(\"AuthFailed\")<{\n provider: string\n subtype: AuthSubtype\n raw: unknown\n}> {}\n\nexport class Cancelled extends Data.TaggedError(\"Cancelled\")<{\n provider: string\n}> {}\n\n/**\n * The model errored mid-generation. Distinct from `Unavailable` (transport\n * problem before generation started) and from `IncompleteTurn` (provider\n * stream ended without a terminal event). The provider's own error message,\n * if any, is on `message`.\n */\nexport class GenerationFailed extends Data.TaggedError(\"GenerationFailed\")<{\n provider: string\n code?: string\n message?: string\n requestId?: string\n raw: unknown\n}> {}\n\n/**\n * The provider's delta stream ended without a terminal `TurnComplete`.\n * Indicates a misbehaving provider or a connection that dropped mid-flight.\n * Non-terminal deltas seen so far have already been emitted downstream.\n */\nexport class IncompleteTurn extends Data.TaggedError(\"IncompleteTurn\")<{\n raw?: unknown\n}> {}\n\n/**\n * The provider does not implement the requested capability for this\n * specific request. Distinct from `InvalidRequest` (the request shape is\n * malformed) and `AuthFailed` (the request was rejected).\n *\n * Reserved for request-data-dependent gaps where the provider supports\n * the method in general but not for these inputs — e.g. Google's\n * `streamSynthesisFrom` works only for Chirp 3 HD voices; calling it\n * with a Neural2 voice ID fails `Unsupported`.\n *\n * Blanket provider-level gaps (e.g. OpenAI has no incremental-text-in\n * TTS at all) are gated at compile time via capability marker tags\n * (`TtsIncrementalText`, `SttStreaming`) on the R channel instead.\n */\nexport class Unsupported extends Data.TaggedError(\"Unsupported\")<{\n provider: string\n capability: string\n reason?: string\n}> {}\n\nexport type AiError =\n | RateLimited\n | Unavailable\n | Timeout\n | ContentFiltered\n | ContextLengthExceeded\n | InvalidRequest\n | AuthFailed\n | Cancelled\n | IncompleteTurn\n | GenerationFailed\n | Unsupported\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AiError.mjs","names":[],"sources":["../../src/domain/AiError.ts"],"sourcesContent":["import { Data, Duration, Match } from \"effect\"\n\nexport type Scope = \"rpm\" | \"tpm\" | \"rpd\" | \"tpd\"\n\nexport class RateLimited extends Data.TaggedError(\"RateLimited\")<{\n provider: string\n retryAfter?: Duration.Duration\n scope?: Scope\n requestId?: string\n raw: unknown\n}> {}\n\nexport class Unavailable extends Data.TaggedError(\"Unavailable\")<{\n provider: string\n retryAfter?: Duration.Duration\n status?: number\n requestId?: string\n raw: unknown\n}> {}\n\nexport class Timeout extends Data.TaggedError(\"Timeout\")<{\n provider: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport class ContentFiltered extends Data.TaggedError(\"ContentFiltered\")<{\n provider: string\n reason?: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport class ContextLengthExceeded extends Data.TaggedError(\"ContextLengthExceeded\")<{\n provider: string\n modelLimit?: number\n requested?: number\n raw: unknown\n}> {}\n\nexport class InvalidRequest extends Data.TaggedError(\"InvalidRequest\")<{\n provider: string\n param?: string\n requestId?: string\n raw: unknown\n}> {}\n\nexport type AuthSubtype = \"auth\" | \"permission\" | \"billing\" | \"quota\"\n\nexport class AuthFailed extends Data.TaggedError(\"AuthFailed\")<{\n provider: string\n subtype: AuthSubtype\n raw: unknown\n}> {}\n\nexport class Cancelled extends Data.TaggedError(\"Cancelled\")<{\n provider: string\n}> {}\n\n/**\n * The model errored mid-generation. Distinct from `Unavailable` (transport\n * problem before generation started) and from `IncompleteTurn` (provider\n * stream ended without a terminal event). The provider's own error message,\n * if any, is on `message`.\n */\nexport class GenerationFailed extends Data.TaggedError(\"GenerationFailed\")<{\n provider: string\n code?: string\n message?: string\n requestId?: string\n raw: unknown\n}> {}\n\n/**\n * The provider's delta stream ended without a terminal `TurnComplete`.\n * Indicates a misbehaving provider or a connection that dropped mid-flight.\n * Non-terminal deltas seen so far have already been emitted downstream.\n */\nexport class IncompleteTurn extends Data.TaggedError(\"IncompleteTurn\")<{\n raw?: unknown\n}> {}\n\n/**\n * The provider does not implement the requested capability for this\n * specific request. Distinct from `InvalidRequest` (the request shape is\n * malformed) and `AuthFailed` (the request was rejected).\n *\n * Reserved for request-data-dependent gaps where the provider supports\n * the method in general but not for these inputs — e.g. Google's\n * `streamSynthesisFrom` works only for Chirp 3 HD voices; calling it\n * with a Neural2 voice ID fails `Unsupported`.\n *\n * Blanket provider-level gaps (e.g. OpenAI has no incremental-text-in\n * TTS at all) are gated at compile time via capability marker tags\n * (`TtsIncrementalText`, `SttStreaming`) on the R channel instead.\n */\nexport class Unsupported extends Data.TaggedError(\"Unsupported\")<{\n provider: string\n capability: string\n reason?: string\n}> {}\n\nexport type AiError =\n | RateLimited\n | Unavailable\n | Timeout\n | ContentFiltered\n | ContextLengthExceeded\n | InvalidRequest\n | AuthFailed\n | Cancelled\n | IncompleteTurn\n | GenerationFailed\n | Unsupported\n\nconst withReason = (base: string, reason: string | undefined): string =>\n reason === undefined ? base : `${base}: ${reason}`\n\n/**\n * Short human-readable description of an error, for logs and model-facing\n * failure messages. Prose, not a contract; branch on `_tag` instead.\n */\nexport const describe: (e: AiError) => string = Match.type<AiError>().pipe(\n Match.discriminatorsExhaustive(\"_tag\")({\n RateLimited: (e) => `rate limited by ${e.provider}; try again later`,\n Unavailable: (e) => `${e.provider} is temporarily unavailable`,\n Timeout: (e) => `the ${e.provider} request timed out`,\n ContentFiltered: (e) => withReason(`blocked by ${e.provider}'s content filter`, e.reason),\n ContextLengthExceeded: (e) => `the request exceeded ${e.provider}'s context limit`,\n InvalidRequest: (e) =>\n e.param === undefined\n ? `${e.provider} rejected the request`\n : `${e.provider} rejected the request (param: ${e.param})`,\n AuthFailed: (e) => `authentication against ${e.provider} failed (${e.subtype})`,\n Cancelled: (e) => `the ${e.provider} request was cancelled`,\n IncompleteTurn: () => \"the provider stream ended without completing\",\n GenerationFailed: (e) => e.message ?? `${e.provider} failed mid-generation`,\n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MAAM,OAAO,EAAE,SAAS;CACpC,sBAAsB;CACtB,mBAAmB,MAAM,EAAE,WAAW,GAAG,EAAE,SAAS;CACpD,cAAc,MAAM,WAAW,GAAG,EAAE,SAAS,oBAAoB,EAAE,cAAc,EAAE,OAAO;CAC3F,CAAC,CACH"}
|
package/dist/domain/Audio.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as AudioSource, c as isAudioBytes, i as AudioMimeType, l as isAudioUrl, n as AudioChunk, r as AudioFormat, s as isAudioBase64, t as AudioBlob } from "../Audio-
|
|
1
|
+
import { a as AudioSource, c as isAudioBytes, i as AudioMimeType, l as isAudioUrl, n as AudioChunk, r as AudioFormat, s as isAudioBase64, t as AudioBlob } from "../Audio-CR7CSljJ.mjs";
|
|
2
2
|
export { AudioBlob, AudioChunk, AudioFormat, AudioMimeType, AudioSource, isAudioBase64, isAudioBytes, isAudioUrl };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { DateTime } from "effect";
|
|
2
|
+
|
|
3
|
+
//#region src/domain/Citation.d.ts
|
|
4
|
+
declare namespace Citation_d_exports {
|
|
5
|
+
export { CitationSpan, Citations, Source };
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A document the model consulted. `url` and `title` are the only
|
|
9
|
+
* near-universal fields; the rest is best-effort. `raw` round-trips
|
|
10
|
+
* provider-opaque tokens (encrypted indices, chunk handles, document ids) so
|
|
11
|
+
* nothing is lost.
|
|
12
|
+
*/
|
|
13
|
+
type Source = {
|
|
14
|
+
readonly url: string;
|
|
15
|
+
readonly title?: string;
|
|
16
|
+
readonly snippet?: string;
|
|
17
|
+
readonly publishedDate?: DateTime.DateTime;
|
|
18
|
+
readonly sourceType?: "web" | "x" | "news" | "file" | "document" | (string & {});
|
|
19
|
+
readonly raw?: unknown;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Where in the answer a claim is grounded, and which sources ground it.
|
|
23
|
+
* `sourceRefs` indexes into the sibling {@link Citations.sources} array
|
|
24
|
+
* (many-to-one). The four kinds normalize how providers link answer text to
|
|
25
|
+
* sources: a character / byte offset range, an exact source quote, a
|
|
26
|
+
* positional `[n]` marker, or `none` for a bare source with no anchor.
|
|
27
|
+
*/
|
|
28
|
+
type CitationSpan = {
|
|
29
|
+
readonly kind: "char";
|
|
30
|
+
readonly start: number;
|
|
31
|
+
readonly end: number;
|
|
32
|
+
readonly unit: "char" | "byte";
|
|
33
|
+
readonly sourceRefs: ReadonlyArray<number>;
|
|
34
|
+
readonly confidence?: number;
|
|
35
|
+
} | {
|
|
36
|
+
readonly kind: "quote";
|
|
37
|
+
readonly text: string;
|
|
38
|
+
readonly sourceRefs: ReadonlyArray<number>;
|
|
39
|
+
} | {
|
|
40
|
+
readonly kind: "marker";
|
|
41
|
+
readonly ordinal: number;
|
|
42
|
+
readonly sourceRefs: ReadonlyArray<number>;
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: "none";
|
|
45
|
+
readonly sourceRefs: ReadonlyArray<number>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* The grounding for a piece of generated text: the sources consulted, and the
|
|
49
|
+
* spans that reference them. This is the canonical, provider-agnostic form.
|
|
50
|
+
* The flat `Items.Annotation` array is its degenerate view (one `char` span
|
|
51
|
+
* with one inlined source), used where a wire-attached, per-`output_text`
|
|
52
|
+
* shape is enough.
|
|
53
|
+
*/
|
|
54
|
+
type Citations = {
|
|
55
|
+
readonly sources: ReadonlyArray<Source>;
|
|
56
|
+
readonly spans: ReadonlyArray<CitationSpan>;
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
export { CitationSpan, Citations, Source, Citation_d_exports as t };
|
|
60
|
+
//# sourceMappingURL=Citation.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Citation.d.mts","names":[],"sources":["../../src/domain/Citation.ts"],"mappings":";;;;;;;;;;;;KAYY,MAAA;EAAA,SACD,GAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,aAAA,GAAgB,QAAA,CAAS,QAAA;EAAA,SACzB,UAAA;EAAA,SACA,GAAA;AAAA;;;;;;;;KAcC,YAAA;EAAA,SAEG,IAAA;EAAA,SACA,KAAA;EAAA,SACA,GAAA;EAAA,SACA,IAAA;EAAA,SACA,UAAA,EAAY,aAAA;EAAA,SACZ,UAAA;AAAA;EAAA,SAEA,IAAA;EAAA,SAAwB,IAAA;EAAA,SAAuB,UAAA,EAAY,aAAA;AAAA;EAAA,SAE3D,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA,EAAY,aAAA;AAAA;EAAA,SAEZ,IAAA;EAAA,SAAuB,UAAA,EAAY,aAAA;AAAA;;;;;;;;KAatC,SAAA;EAAA,SACD,OAAA,EAAS,aAAA,CAAc,MAAA;EAAA,SACvB,KAAA,EAAO,aAAA,CAAc,YAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Citation.mjs","names":[],"sources":["../../src/domain/Citation.ts"],"sourcesContent":["import type { DateTime } from \"effect\"\n\n// ---------------------------------------------------------------------------\n// Source\n// ---------------------------------------------------------------------------\n\n/**\n * A document the model consulted. `url` and `title` are the only\n * near-universal fields; the rest is best-effort. `raw` round-trips\n * provider-opaque tokens (encrypted indices, chunk handles, document ids) so\n * nothing is lost.\n */\nexport type Source = {\n readonly url: string\n readonly title?: string\n readonly snippet?: string\n readonly publishedDate?: DateTime.DateTime\n readonly sourceType?: \"web\" | \"x\" | \"news\" | \"file\" | \"document\" | (string & {})\n readonly raw?: unknown\n}\n\n// ---------------------------------------------------------------------------\n// Span\n// ---------------------------------------------------------------------------\n\n/**\n * Where in the answer a claim is grounded, and which sources ground it.\n * `sourceRefs` indexes into the sibling {@link Citations.sources} array\n * (many-to-one). The four kinds normalize how providers link answer text to\n * sources: a character / byte offset range, an exact source quote, a\n * positional `[n]` marker, or `none` for a bare source with no anchor.\n */\nexport type CitationSpan =\n | {\n readonly kind: \"char\"\n readonly start: number\n readonly end: number\n readonly unit: \"char\" | \"byte\"\n readonly sourceRefs: ReadonlyArray<number>\n readonly confidence?: number\n }\n | { readonly kind: \"quote\"; readonly text: string; readonly sourceRefs: ReadonlyArray<number> }\n | {\n readonly kind: \"marker\"\n readonly ordinal: number\n readonly sourceRefs: ReadonlyArray<number>\n }\n | { readonly kind: \"none\"; readonly sourceRefs: ReadonlyArray<number> }\n\n// ---------------------------------------------------------------------------\n// Citations\n// ---------------------------------------------------------------------------\n\n/**\n * The grounding for a piece of generated text: the sources consulted, and the\n * spans that reference them. This is the canonical, provider-agnostic form.\n * The flat `Items.Annotation` array is its degenerate view (one `char` span\n * with one inlined source), used where a wire-attached, per-`output_text`\n * shape is enough.\n */\nexport type Citations = {\n readonly sources: ReadonlyArray<Source>\n readonly spans: ReadonlyArray<CitationSpan>\n}\n"],"mappings":""}
|
package/dist/domain/Image.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ImageUrlSource, c as imageBytes, d as isImageBytes, f as isImageUrl, i as ImageSource, l as imageUrl, n as ImageBytesSource, r as ImageMimeType, s as imageBase64, t as ImageBase64Source, u as isImageBase64 } from "../Image-
|
|
1
|
+
import { a as ImageUrlSource, c as imageBytes, d as isImageBytes, f as isImageUrl, i as ImageSource, l as imageUrl, n as ImageBytesSource, r as ImageMimeType, s as imageBase64, t as ImageBase64Source, u as isImageBase64 } from "../Image-C4vuBmu0.mjs";
|
|
2
2
|
export { ImageBase64Source, ImageBytesSource, ImageMimeType, ImageSource, ImageUrlSource, imageBase64, imageBytes, imageUrl, isImageBase64, isImageBytes, isImageUrl };
|
package/dist/domain/Items.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as isReasoning, C as isContainerFileCitation, D as isInputText, E as isInputImage, F as systemText, I as toolCallOutput, L as userText, M as isToolCall, N as isToolCallOutput, O as isMessage, P as isUrlCitation, S as assistantText, T as isFilePath, _ as StopReason, a as FilePath, b as UrlCitation, c as InputText, d as Message, f as OutputText, g as Role, h as Refusal, i as FileCitation, j as isRefusal, k as isOutputText, l as InputTokensDetails, m as Reasoning, n as ContainerFileCitation, o as HistoryItem, p as OutputTokensDetails, r as ContentBlock, s as InputImage, t as Annotation, v as ToolCall, w as isFileCitation, x as Usage, y as ToolCallOutput } from "../Items-
|
|
1
|
+
import { A as isReasoning, C as isContainerFileCitation, D as isInputText, E as isInputImage, F as systemText, I as toolCallOutput, L as userText, M as isToolCall, N as isToolCallOutput, O as isMessage, P as isUrlCitation, S as assistantText, T as isFilePath, _ as StopReason, a as FilePath, b as UrlCitation, c as InputText, d as Message, f as OutputText, g as Role, h as Refusal, i as FileCitation, j as isRefusal, k as isOutputText, l as InputTokensDetails, m as Reasoning, n as ContainerFileCitation, o as HistoryItem, p as OutputTokensDetails, r as ContentBlock, s as InputImage, t as Annotation, v as ToolCall, w as isFileCitation, x as Usage, y as ToolCallOutput } from "../Items-BWNu6VGp.mjs";
|
|
2
2
|
export { Annotation, ContainerFileCitation, ContentBlock, FileCitation, FilePath, HistoryItem, InputImage, InputText, InputTokensDetails, Message, OutputText, OutputTokensDetails, Reasoning, Refusal, Role, StopReason, ToolCall, ToolCallOutput, UrlCitation, Usage, assistantText, isContainerFileCitation, isFileCitation, isFilePath, isInputImage, isInputText, isMessage, isOutputText, isReasoning, isRefusal, isToolCall, isToolCallOutput, isUrlCitation, systemText, toolCallOutput, userText };
|
package/dist/domain/Items.mjs
CHANGED
|
@@ -56,12 +56,22 @@ const InputImage = Schema.Struct({
|
|
|
56
56
|
type: Schema.Literal("input_image"),
|
|
57
57
|
source: ImageSource
|
|
58
58
|
});
|
|
59
|
+
/**
|
|
60
|
+
* A cited source. `url` + `title` are the only near-universal fields; the
|
|
61
|
+
* link from a source to the answer text varies by provider, so it is optional
|
|
62
|
+
* and expressed three ways: `start_index`/`end_index` (a character span into
|
|
63
|
+
* the answer), `cited_text` (an exact quote of the source, when no offsets are
|
|
64
|
+
* given), or `marker` (a positional `[n]` reference into an ordered list). A
|
|
65
|
+
* provider populates whichever it has; a bare source list sets none.
|
|
66
|
+
*/
|
|
59
67
|
const UrlCitation = Schema.Struct({
|
|
60
68
|
type: Schema.Literal("url_citation"),
|
|
61
69
|
url: Schema.String,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
title: Schema.String,
|
|
71
|
+
start_index: Schema.optional(Schema.Number),
|
|
72
|
+
end_index: Schema.optional(Schema.Number),
|
|
73
|
+
cited_text: Schema.optional(Schema.String),
|
|
74
|
+
marker: Schema.optional(Schema.Number)
|
|
65
75
|
});
|
|
66
76
|
const FileCitation = Schema.Struct({
|
|
67
77
|
type: Schema.Literal("file_citation"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Items.mjs","names":[],"sources":["../../src/domain/Items.ts"],"sourcesContent":["import { Schema } from \"effect\"\nimport { ImageSource } from \"./Image.js\"\n\n// ---------------------------------------------------------------------------\n// Content blocks (inside Message.content)\n// ---------------------------------------------------------------------------\n\nexport const InputText = Schema.Struct({\n type: Schema.Literal(\"input_text\"),\n text: Schema.String,\n})\nexport type InputText = typeof InputText.Type\n\n/**\n * User-provided image content block. Pair with `InputText` inside a\n * `Message.content` array to ask \"what's in this image?\" style questions.\n *\n * `source` is the cross-modality `ImageSource` from `domain/Image.ts` -\n * url, base64, or raw bytes. Provider codecs encode bytes to whatever\n * wire format the provider wants.\n */\nexport const InputImage = Schema.Struct({\n type: Schema.Literal(\"input_image\"),\n source: ImageSource,\n})\nexport type InputImage = typeof InputImage.Type\n\n// ---------------------------------------------------------------------------\n// Annotations - source / citation pointers attached to `output_text` blocks.\n// Mirrors OpenAI Responses API; other providers can omit or map onto these\n// shapes.\n// ---------------------------------------------------------------------------\n\nexport const UrlCitation = Schema.Struct({\n type: Schema.Literal(\"url_citation\"),\n url: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n title: Schema.String,\n})\nexport type UrlCitation = typeof UrlCitation.Type\n\nexport const FileCitation = Schema.Struct({\n type: Schema.Literal(\"file_citation\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FileCitation = typeof FileCitation.Type\n\nexport const ContainerFileCitation = Schema.Struct({\n type: Schema.Literal(\"container_file_citation\"),\n container_id: Schema.String,\n file_id: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n})\nexport type ContainerFileCitation = typeof ContainerFileCitation.Type\n\nexport const FilePath = Schema.Struct({\n type: Schema.Literal(\"file_path\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FilePath = typeof FilePath.Type\n\nexport const Annotation = Schema.Union([UrlCitation, FileCitation, ContainerFileCitation, FilePath])\nexport type Annotation = typeof Annotation.Type\n\nexport const isUrlCitation = Schema.is(UrlCitation)\nexport const isFileCitation = Schema.is(FileCitation)\nexport const isContainerFileCitation = Schema.is(ContainerFileCitation)\nexport const isFilePath = Schema.is(FilePath)\n\nexport const OutputText = Schema.Struct({\n type: Schema.Literal(\"output_text\"),\n text: Schema.String,\n annotations: Schema.optional(Schema.Array(Annotation)),\n})\nexport type OutputText = typeof OutputText.Type\n\n/**\n * Model-emitted refusal. Distinct from `output_text`: the model declined\n * to answer rather than producing normal output. Pair with\n * `stop_reason: \"refusal\"` on the surrounding `Turn`. Streamed via the\n * `RefusalDelta` `TurnEvent`.\n */\nexport const Refusal = Schema.Struct({\n type: Schema.Literal(\"refusal\"),\n text: Schema.String,\n})\nexport type Refusal = typeof Refusal.Type\n\nexport const ContentBlock = Schema.Union([InputText, InputImage, OutputText, Refusal])\nexport type ContentBlock = typeof ContentBlock.Type\n\nexport const Role = Schema.Literals([\"user\", \"assistant\", \"system\"])\nexport type Role = typeof Role.Type\n\n// ---------------------------------------------------------------------------\n// Provider passthrough - every Item type carries this opaque slot.\n// The framework never reads or interprets it; provider modules decode\n// their own data via their own typed readers (see e.g.\n// the `@effect-uai/responses` package).\n// ---------------------------------------------------------------------------\n\nconst ProviderData = Schema.optional(Schema.Unknown)\n\n// ---------------------------------------------------------------------------\n// Items\n// ---------------------------------------------------------------------------\n\nexport const Message = Schema.Struct({\n type: Schema.Literal(\"message\"),\n role: Role,\n content: Schema.Array(ContentBlock),\n providerData: ProviderData,\n})\nexport type Message = typeof Message.Type\n\nexport const ToolCall = Schema.Struct({\n type: Schema.Literal(\"function_call\"),\n call_id: Schema.String,\n name: Schema.String,\n // JSON-encoded arguments string, mirroring OpenAI Responses API\n arguments: Schema.String,\n providerData: ProviderData,\n})\nexport type ToolCall = typeof ToolCall.Type\n\nexport const ToolCallOutput = Schema.Struct({\n type: Schema.Literal(\"function_call_output\"),\n call_id: Schema.String,\n output: Schema.String,\n providerData: ProviderData,\n})\nexport type ToolCallOutput = typeof ToolCallOutput.Type\n\n/**\n * Reasoning item - top-level, mirrors OpenAI Responses API. Common shape\n * across providers covers `summary` (human-readable text) and `signature`\n * (opaque round-trip blob - Anthropic's signed thinking, OpenAI's\n * encrypted_content, etc.). Provider-specific fields go in `providerData`.\n */\nexport const Reasoning = Schema.Struct({\n type: Schema.Literal(\"reasoning\"),\n id: Schema.optional(Schema.String),\n summary: Schema.optional(Schema.String),\n signature: Schema.optional(Schema.String),\n providerData: ProviderData,\n})\nexport type Reasoning = typeof Reasoning.Type\n\nexport const HistoryItem = Schema.Union([Message, ToolCall, ToolCallOutput, Reasoning])\nexport type HistoryItem = typeof HistoryItem.Type\n\n// ---------------------------------------------------------------------------\n// Type guards\n// ---------------------------------------------------------------------------\n\nexport const isInputText = Schema.is(InputText)\nexport const isInputImage = Schema.is(InputImage)\nexport const isOutputText = Schema.is(OutputText)\nexport const isRefusal = Schema.is(Refusal)\n\nexport const isMessage = Schema.is(Message)\nexport const isToolCall = Schema.is(ToolCall)\nexport const isToolCallOutput = Schema.is(ToolCallOutput)\nexport const isReasoning = Schema.is(Reasoning)\n\n// ---------------------------------------------------------------------------\n// Usage and stop reason\n// ---------------------------------------------------------------------------\n\nexport const InputTokensDetails = Schema.Struct({\n cached_tokens: Schema.optional(Schema.Number),\n})\nexport type InputTokensDetails = typeof InputTokensDetails.Type\n\nexport const OutputTokensDetails = Schema.Struct({\n reasoning_tokens: Schema.optional(Schema.Number),\n})\nexport type OutputTokensDetails = typeof OutputTokensDetails.Type\n\nexport const Usage = Schema.Struct({\n input_tokens: Schema.optional(Schema.Number),\n output_tokens: Schema.optional(Schema.Number),\n total_tokens: Schema.optional(Schema.Number),\n input_tokens_details: Schema.optional(InputTokensDetails),\n output_tokens_details: Schema.optional(OutputTokensDetails),\n})\nexport type Usage = typeof Usage.Type\n\nexport const StopReason = Schema.Literals([\n \"stop\",\n \"tool_calls\",\n \"max_tokens\",\n \"refusal\",\n /** Provider-side safety classifier flagged the output. */\n \"content_filter\",\n /** Server-enforced cap on tool calls per turn was hit. */\n \"max_tool_calls\",\n])\nexport type StopReason = typeof StopReason.Type\n\n// ---------------------------------------------------------------------------\n// Helper constructors\n// ---------------------------------------------------------------------------\n\nexport const userText = (text: string): Message => ({\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const systemText = (text: string): Message => ({\n type: \"message\",\n role: \"system\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const assistantText = (text: string): Message => ({\n type: \"message\",\n role: \"assistant\",\n content: [{ type: \"output_text\", text }],\n})\n\nexport const toolCallOutput = (call_id: string, output: string): ToolCallOutput => ({\n type: \"function_call_output\",\n call_id,\n output,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,YAAY,OAAO,OAAO;CACrC,MAAM,OAAO,QAAQ,aAAa;CAClC,MAAM,OAAO;CACd,CAAC;;;;;;;;;AAWF,MAAa,aAAa,OAAO,OAAO;CACtC,MAAM,OAAO,QAAQ,cAAc;CACnC,QAAQ;CACT,CAAC;AASF,MAAa,cAAc,OAAO,OAAO;CACvC,MAAM,OAAO,QAAQ,eAAe;CACpC,KAAK,OAAO;CACZ,aAAa,OAAO;CACpB,WAAW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CAAC;AAOF,MAAa,YAAY,UAA2B;CAClD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAc;EAAM,CAAC;CACxC;AAED,MAAa,cAAc,UAA2B;CACpD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAc;EAAM,CAAC;CACxC;AAED,MAAa,iBAAiB,UAA2B;CACvD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAe;EAAM,CAAC;CACzC;AAED,MAAa,kBAAkB,SAAiB,YAAoC;CAClF,MAAM;CACN;CACA;CACD"}
|
|
1
|
+
{"version":3,"file":"Items.mjs","names":[],"sources":["../../src/domain/Items.ts"],"sourcesContent":["import { Schema } from \"effect\"\nimport { ImageSource } from \"./Image.js\"\n\n// ---------------------------------------------------------------------------\n// Content blocks (inside Message.content)\n// ---------------------------------------------------------------------------\n\nexport const InputText = Schema.Struct({\n type: Schema.Literal(\"input_text\"),\n text: Schema.String,\n})\nexport type InputText = typeof InputText.Type\n\n/**\n * User-provided image content block. Pair with `InputText` inside a\n * `Message.content` array to ask \"what's in this image?\" style questions.\n *\n * `source` is the cross-modality `ImageSource` from `domain/Image.ts` -\n * url, base64, or raw bytes. Provider codecs encode bytes to whatever\n * wire format the provider wants.\n */\nexport const InputImage = Schema.Struct({\n type: Schema.Literal(\"input_image\"),\n source: ImageSource,\n})\nexport type InputImage = typeof InputImage.Type\n\n// ---------------------------------------------------------------------------\n// Annotations - source / citation pointers attached to `output_text` blocks.\n// Provider-agnostic: each provider populates the fields it has (character\n// span, quote, or positional marker) and omits the rest.\n// ---------------------------------------------------------------------------\n\n/**\n * A cited source. `url` + `title` are the only near-universal fields; the\n * link from a source to the answer text varies by provider, so it is optional\n * and expressed three ways: `start_index`/`end_index` (a character span into\n * the answer), `cited_text` (an exact quote of the source, when no offsets are\n * given), or `marker` (a positional `[n]` reference into an ordered list). A\n * provider populates whichever it has; a bare source list sets none.\n */\nexport const UrlCitation = Schema.Struct({\n type: Schema.Literal(\"url_citation\"),\n url: Schema.String,\n title: Schema.String,\n start_index: Schema.optional(Schema.Number),\n end_index: Schema.optional(Schema.Number),\n cited_text: Schema.optional(Schema.String),\n marker: Schema.optional(Schema.Number),\n})\nexport type UrlCitation = typeof UrlCitation.Type\n\nexport const FileCitation = Schema.Struct({\n type: Schema.Literal(\"file_citation\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FileCitation = typeof FileCitation.Type\n\nexport const ContainerFileCitation = Schema.Struct({\n type: Schema.Literal(\"container_file_citation\"),\n container_id: Schema.String,\n file_id: Schema.String,\n start_index: Schema.Number,\n end_index: Schema.Number,\n})\nexport type ContainerFileCitation = typeof ContainerFileCitation.Type\n\nexport const FilePath = Schema.Struct({\n type: Schema.Literal(\"file_path\"),\n file_id: Schema.String,\n index: Schema.Number,\n})\nexport type FilePath = typeof FilePath.Type\n\nexport const Annotation = Schema.Union([UrlCitation, FileCitation, ContainerFileCitation, FilePath])\nexport type Annotation = typeof Annotation.Type\n\nexport const isUrlCitation = Schema.is(UrlCitation)\nexport const isFileCitation = Schema.is(FileCitation)\nexport const isContainerFileCitation = Schema.is(ContainerFileCitation)\nexport const isFilePath = Schema.is(FilePath)\n\nexport const OutputText = Schema.Struct({\n type: Schema.Literal(\"output_text\"),\n text: Schema.String,\n annotations: Schema.optional(Schema.Array(Annotation)),\n})\nexport type OutputText = typeof OutputText.Type\n\n/**\n * Model-emitted refusal. Distinct from `output_text`: the model declined\n * to answer rather than producing normal output. Pair with\n * `stop_reason: \"refusal\"` on the surrounding `Turn`. Streamed via the\n * `RefusalDelta` `TurnEvent`.\n */\nexport const Refusal = Schema.Struct({\n type: Schema.Literal(\"refusal\"),\n text: Schema.String,\n})\nexport type Refusal = typeof Refusal.Type\n\nexport const ContentBlock = Schema.Union([InputText, InputImage, OutputText, Refusal])\nexport type ContentBlock = typeof ContentBlock.Type\n\nexport const Role = Schema.Literals([\"user\", \"assistant\", \"system\"])\nexport type Role = typeof Role.Type\n\n// ---------------------------------------------------------------------------\n// Provider passthrough - every Item type carries this opaque slot.\n// The framework never reads or interprets it; provider modules decode\n// their own data via their own typed readers (see e.g.\n// the `@effect-uai/responses` package).\n// ---------------------------------------------------------------------------\n\nconst ProviderData = Schema.optional(Schema.Unknown)\n\n// ---------------------------------------------------------------------------\n// Items\n// ---------------------------------------------------------------------------\n\nexport const Message = Schema.Struct({\n type: Schema.Literal(\"message\"),\n role: Role,\n content: Schema.Array(ContentBlock),\n providerData: ProviderData,\n})\nexport type Message = typeof Message.Type\n\nexport const ToolCall = Schema.Struct({\n type: Schema.Literal(\"function_call\"),\n call_id: Schema.String,\n name: Schema.String,\n // JSON-encoded arguments string, mirroring OpenAI Responses API\n arguments: Schema.String,\n providerData: ProviderData,\n})\nexport type ToolCall = typeof ToolCall.Type\n\nexport const ToolCallOutput = Schema.Struct({\n type: Schema.Literal(\"function_call_output\"),\n call_id: Schema.String,\n output: Schema.String,\n providerData: ProviderData,\n})\nexport type ToolCallOutput = typeof ToolCallOutput.Type\n\n/**\n * Reasoning item - top-level, mirrors OpenAI Responses API. Common shape\n * across providers covers `summary` (human-readable text) and `signature`\n * (opaque round-trip blob - Anthropic's signed thinking, OpenAI's\n * encrypted_content, etc.). Provider-specific fields go in `providerData`.\n */\nexport const Reasoning = Schema.Struct({\n type: Schema.Literal(\"reasoning\"),\n id: Schema.optional(Schema.String),\n summary: Schema.optional(Schema.String),\n signature: Schema.optional(Schema.String),\n providerData: ProviderData,\n})\nexport type Reasoning = typeof Reasoning.Type\n\nexport const HistoryItem = Schema.Union([Message, ToolCall, ToolCallOutput, Reasoning])\nexport type HistoryItem = typeof HistoryItem.Type\n\n// ---------------------------------------------------------------------------\n// Type guards\n// ---------------------------------------------------------------------------\n\nexport const isInputText = Schema.is(InputText)\nexport const isInputImage = Schema.is(InputImage)\nexport const isOutputText = Schema.is(OutputText)\nexport const isRefusal = Schema.is(Refusal)\n\nexport const isMessage = Schema.is(Message)\nexport const isToolCall = Schema.is(ToolCall)\nexport const isToolCallOutput = Schema.is(ToolCallOutput)\nexport const isReasoning = Schema.is(Reasoning)\n\n// ---------------------------------------------------------------------------\n// Usage and stop reason\n// ---------------------------------------------------------------------------\n\nexport const InputTokensDetails = Schema.Struct({\n cached_tokens: Schema.optional(Schema.Number),\n})\nexport type InputTokensDetails = typeof InputTokensDetails.Type\n\nexport const OutputTokensDetails = Schema.Struct({\n reasoning_tokens: Schema.optional(Schema.Number),\n})\nexport type OutputTokensDetails = typeof OutputTokensDetails.Type\n\nexport const Usage = Schema.Struct({\n input_tokens: Schema.optional(Schema.Number),\n output_tokens: Schema.optional(Schema.Number),\n total_tokens: Schema.optional(Schema.Number),\n input_tokens_details: Schema.optional(InputTokensDetails),\n output_tokens_details: Schema.optional(OutputTokensDetails),\n})\nexport type Usage = typeof Usage.Type\n\nexport const StopReason = Schema.Literals([\n \"stop\",\n \"tool_calls\",\n \"max_tokens\",\n \"refusal\",\n /** Provider-side safety classifier flagged the output. */\n \"content_filter\",\n /** Server-enforced cap on tool calls per turn was hit. */\n \"max_tool_calls\",\n])\nexport type StopReason = typeof StopReason.Type\n\n// ---------------------------------------------------------------------------\n// Helper constructors\n// ---------------------------------------------------------------------------\n\nexport const userText = (text: string): Message => ({\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const systemText = (text: string): Message => ({\n type: \"message\",\n role: \"system\",\n content: [{ type: \"input_text\", text }],\n})\n\nexport const assistantText = (text: string): Message => ({\n type: \"message\",\n role: \"assistant\",\n content: [{ type: \"output_text\", text }],\n})\n\nexport const toolCallOutput = (call_id: string, output: string): ToolCallOutput => ({\n type: \"function_call_output\",\n call_id,\n output,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,YAAY,OAAO,OAAO;CACrC,MAAM,OAAO,QAAQ,aAAa;CAClC,MAAM,OAAO;CACd,CAAC;;;;;;;;;AAWF,MAAa,aAAa,OAAO,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AGF,MAAa,QAAQ,OAAO,OAAO;CACjC,cAAc,OAAO,SAAS,OAAO,OAAO;CAC5C,eAAe,OAAO,SAAS,OAAO,OAAO;CAC7C,cAAc,OAAO,SAAS,OAAO,OAAO;CAC5C,sBAAsB,OAAO,SAAS,mBAAmB;CACzD,uBAAuB,OAAO,SAAS,oBAAoB;CAC5D,CAAC;AAGF,MAAa,aAAa,OAAO,SAAS;CACxC;CACA;CACA;CACA;CAEA;CAEA;CACD,CAAC;AAOF,MAAa,YAAY,UAA2B;CAClD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAc;EAAM,CAAC;CACxC;AAED,MAAa,cAAc,UAA2B;CACpD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAc;EAAM,CAAC;CACxC;AAED,MAAa,iBAAiB,UAA2B;CACvD,MAAM;CACN,MAAM;CACN,SAAS,CAAC;EAAE,MAAM;EAAe;EAAM,CAAC;CACzC;AAED,MAAa,kBAAkB,SAAiB,YAAoC;CAClF,MAAM;CACN;CACA;CACD"}
|
package/dist/domain/Media.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as isMediaUrl, i as MediaUrl, n as MediaBytes, o as isMediaBase64, r as MediaSource, s as isMediaBytes, t as MediaBase64 } from "../Media-
|
|
1
|
+
import { c as isMediaUrl, i as MediaUrl, n as MediaBytes, o as isMediaBase64, r as MediaSource, s as isMediaBytes, t as MediaBase64 } from "../Media-D_CpcM1Z.mjs";
|
|
2
2
|
export { MediaBase64, MediaBytes, MediaSource, MediaUrl, isMediaBase64, isMediaBytes, isMediaUrl };
|
package/dist/domain/Music.d.mts
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { o as HistoryItem } from "../Items-BWNu6VGp.mjs";
|
|
2
|
+
import { JobRef, JobState } from "../job/Job.mjs";
|
|
3
|
+
import { Turn } from "./Turn.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/domain/Research.d.ts
|
|
6
|
+
declare namespace Research_d_exports {
|
|
7
|
+
export { ResearchJobRef, ResearchRequest, ResearchState };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Cross-provider deep-research request: a question in, a cited report out.
|
|
11
|
+
* Deliberately minimal, only the input every provider shares. Depth, search
|
|
12
|
+
* caps, and structured-output knobs vary too much to unify, so they live on
|
|
13
|
+
* each provider's typed request, which extends this and narrows `model`.
|
|
14
|
+
*
|
|
15
|
+
* `history` reuses the `LanguageModel` input primitive: the common case is a
|
|
16
|
+
* single user message with the question. There is no history threading. A
|
|
17
|
+
* research call is one background job, not a conversation, but the input
|
|
18
|
+
* encoding is shared.
|
|
19
|
+
*/
|
|
20
|
+
type ResearchRequest = {
|
|
21
|
+
readonly history: ReadonlyArray<HistoryItem>; /** Model / agent id. Provider default if omitted; each provider narrows. */
|
|
22
|
+
readonly model?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A completed research result is a `Turn`: one assistant message with the
|
|
26
|
+
* report text and its citations on `OutputText.annotations`, plus usage.
|
|
27
|
+
* Project it with `Turn.assistantText` / `Turn.citations` /
|
|
28
|
+
* `Turn.decodeStructured`. There is no bespoke report type; the streaming
|
|
29
|
+
* terminal (`TurnComplete.turn`) and the collected result are the same shape.
|
|
30
|
+
*/
|
|
31
|
+
/** Provider-tagged handle to a running research job, branded to `Turn`. */
|
|
32
|
+
type ResearchJobRef = JobRef<Turn>;
|
|
33
|
+
/** Current state of a research job. See {@link Job.JobState}. */
|
|
34
|
+
type ResearchState = JobState<Turn>;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { ResearchJobRef, ResearchRequest, ResearchState, Research_d_exports as t };
|
|
37
|
+
//# sourceMappingURL=Research.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Research.d.mts","names":[],"sources":["../../src/domain/Research.ts"],"mappings":";;;;;;;;;;;;;;;;AAmBA;;;KAAY,eAAA;EAAA,SACD,OAAA,EAAS,aAAA,CAAc,WAAA,GAAd;EAAA,SAET,KAAA;AAAA;;;;AAgBX;;;;;KAAY,cAAA,GAAiB,MAAA,CAAW,IAAA;;KAG5B,aAAA,GAAgB,QAAA,CAAa,IAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Research.mjs","names":[],"sources":["../../src/domain/Research.ts"],"sourcesContent":["import type * as Job from \"../job/Job.js\"\nimport type * as Items from \"./Items.js\"\nimport type { Turn } from \"./Turn.js\"\n\n// ---------------------------------------------------------------------------\n// Request\n// ---------------------------------------------------------------------------\n\n/**\n * Cross-provider deep-research request: a question in, a cited report out.\n * Deliberately minimal, only the input every provider shares. Depth, search\n * caps, and structured-output knobs vary too much to unify, so they live on\n * each provider's typed request, which extends this and narrows `model`.\n *\n * `history` reuses the `LanguageModel` input primitive: the common case is a\n * single user message with the question. There is no history threading. A\n * research call is one background job, not a conversation, but the input\n * encoding is shared.\n */\nexport type ResearchRequest = {\n readonly history: ReadonlyArray<Items.HistoryItem>\n /** Model / agent id. Provider default if omitted; each provider narrows. */\n readonly model?: string\n}\n\n// ---------------------------------------------------------------------------\n// Result + job handle\n// ---------------------------------------------------------------------------\n\n/**\n * A completed research result is a `Turn`: one assistant message with the\n * report text and its citations on `OutputText.annotations`, plus usage.\n * Project it with `Turn.assistantText` / `Turn.citations` /\n * `Turn.decodeStructured`. There is no bespoke report type; the streaming\n * terminal (`TurnComplete.turn`) and the collected result are the same shape.\n */\n\n/** Provider-tagged handle to a running research job, branded to `Turn`. */\nexport type ResearchJobRef = Job.JobRef<Turn>\n\n/** Current state of a research job. See {@link Job.JobState}. */\nexport type ResearchState = Job.JobState<Turn>\n"],"mappings":""}
|
package/dist/domain/Turn.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as ImageSource } from "../Image-
|
|
2
|
-
import { d as Message, m as Reasoning, o as HistoryItem, v as ToolCall, x as Usage, y as ToolCallOutput } from "../Items-
|
|
3
|
-
import { i as StructuredFormat, n as JsonParseError, r as StructuredDecodeError } from "../StructuredFormat-
|
|
1
|
+
import { i as ImageSource } from "../Image-C4vuBmu0.mjs";
|
|
2
|
+
import { d as Message, m as Reasoning, o as HistoryItem, t as Annotation, v as ToolCall, x as Usage, y as ToolCallOutput } from "../Items-BWNu6VGp.mjs";
|
|
3
|
+
import { i as StructuredFormat, n as JsonParseError, r as StructuredDecodeError } from "../StructuredFormat-DHaUJBdd.mjs";
|
|
4
4
|
import { Data, Effect, Schema, Stream } from "effect";
|
|
5
5
|
import * as _$effect_Cause0 from "effect/Cause";
|
|
6
6
|
import * as _$effect_Types0 from "effect/Types";
|
|
@@ -8,7 +8,7 @@ import * as _$effect_Unify0 from "effect/Unify";
|
|
|
8
8
|
|
|
9
9
|
//#region src/domain/Turn.d.ts
|
|
10
10
|
declare namespace Turn_d_exports {
|
|
11
|
-
export { InteractionEvent, RefusalRejected, Turn, TurnEvent, appendToHistory, assistantMessages, assistantText, assistantTexts, decodeStructured, getToolCalls, isTurnComplete, reasonings, textDeltas };
|
|
11
|
+
export { InteractionEvent, RefusalRejected, Turn, TurnEvent, appendToHistory, assistantMessages, assistantText, assistantTexts, citations, decodeStructured, getToolCalls, isTurnComplete, reasonings, textDeltas };
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* The result of a single LLM generation. A turn produces zero or more items
|
|
@@ -31,9 +31,11 @@ declare const Turn: Schema.Struct<{
|
|
|
31
31
|
readonly annotations: Schema.optional<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
32
32
|
readonly type: Schema.Literal<"url_citation">;
|
|
33
33
|
readonly url: Schema.String;
|
|
34
|
-
readonly start_index: Schema.Number;
|
|
35
|
-
readonly end_index: Schema.Number;
|
|
36
34
|
readonly title: Schema.String;
|
|
35
|
+
readonly start_index: Schema.optional<Schema.Number>;
|
|
36
|
+
readonly end_index: Schema.optional<Schema.Number>;
|
|
37
|
+
readonly cited_text: Schema.optional<Schema.String>;
|
|
38
|
+
readonly marker: Schema.optional<Schema.Number>;
|
|
37
39
|
}>, Schema.Struct<{
|
|
38
40
|
readonly type: Schema.Literal<"file_citation">;
|
|
39
41
|
readonly file_id: Schema.String;
|
|
@@ -104,6 +106,14 @@ type Turn = typeof Turn.Type;
|
|
|
104
106
|
* `UsageUpdate`: mid-stream cumulative usage. Anthropic emits this on
|
|
105
107
|
* `message_start` and `message_delta`; other providers may only deliver
|
|
106
108
|
* usage via `TurnComplete.turn.usage`.
|
|
109
|
+
*
|
|
110
|
+
* `WebSearchCall`: lifecycle of a provider-executed web search within the
|
|
111
|
+
* turn. Fires only when the turn grounds against search; absent otherwise.
|
|
112
|
+
*
|
|
113
|
+
* `CitationAdded`: a citation attached to the answer, emitted incrementally
|
|
114
|
+
* where the provider streams citations. Providers that bundle citations emit
|
|
115
|
+
* none of these; their citations still arrive on `TurnComplete.turn`
|
|
116
|
+
* (`OutputText.annotations`). Either way the final set is on the assembled turn.
|
|
107
117
|
*/
|
|
108
118
|
type TurnEvent = Data.TaggedEnum<{
|
|
109
119
|
TextDelta: {
|
|
@@ -127,6 +137,14 @@ type TurnEvent = Data.TaggedEnum<{
|
|
|
127
137
|
UsageUpdate: {
|
|
128
138
|
readonly usage: Usage;
|
|
129
139
|
};
|
|
140
|
+
WebSearchCall: {
|
|
141
|
+
readonly status: "started" | "searching" | "completed";
|
|
142
|
+
readonly query?: string;
|
|
143
|
+
readonly action?: "search" | "open_page" | "find_in_page";
|
|
144
|
+
};
|
|
145
|
+
CitationAdded: {
|
|
146
|
+
readonly annotation: Annotation;
|
|
147
|
+
};
|
|
130
148
|
TurnComplete: {
|
|
131
149
|
readonly turn: Turn;
|
|
132
150
|
};
|
|
@@ -159,11 +177,21 @@ declare const TurnEvent: {
|
|
|
159
177
|
readonly _tag: "UsageUpdate";
|
|
160
178
|
readonly usage: Usage;
|
|
161
179
|
}, "_tag">;
|
|
180
|
+
readonly WebSearchCall: Data.TaggedEnum.ConstructorFrom<{
|
|
181
|
+
readonly _tag: "WebSearchCall";
|
|
182
|
+
readonly status: "started" | "searching" | "completed";
|
|
183
|
+
readonly query?: string;
|
|
184
|
+
readonly action?: "search" | "open_page" | "find_in_page";
|
|
185
|
+
}, "_tag">;
|
|
186
|
+
readonly CitationAdded: Data.TaggedEnum.ConstructorFrom<{
|
|
187
|
+
readonly _tag: "CitationAdded";
|
|
188
|
+
readonly annotation: Annotation;
|
|
189
|
+
}, "_tag">;
|
|
162
190
|
readonly TurnComplete: Data.TaggedEnum.ConstructorFrom<{
|
|
163
191
|
readonly _tag: "TurnComplete";
|
|
164
192
|
readonly turn: Turn;
|
|
165
193
|
}, "_tag">;
|
|
166
|
-
readonly $is: <Tag extends "TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallStart" | "ToolCallArgsDelta" | "UsageUpdate" | "TurnComplete">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
194
|
+
readonly $is: <Tag extends "TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallStart" | "ToolCallArgsDelta" | "UsageUpdate" | "WebSearchCall" | "CitationAdded" | "TurnComplete">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
167
195
|
readonly _tag: "TextDelta";
|
|
168
196
|
readonly text: string;
|
|
169
197
|
}, {
|
|
@@ -196,6 +224,18 @@ declare const TurnEvent: {
|
|
|
196
224
|
readonly usage: Usage;
|
|
197
225
|
}, {
|
|
198
226
|
readonly _tag: Tag;
|
|
227
|
+
}> | Extract<{
|
|
228
|
+
readonly _tag: "WebSearchCall";
|
|
229
|
+
readonly status: "started" | "searching" | "completed";
|
|
230
|
+
readonly query?: string;
|
|
231
|
+
readonly action?: "search" | "open_page" | "find_in_page";
|
|
232
|
+
}, {
|
|
233
|
+
readonly _tag: Tag;
|
|
234
|
+
}> | Extract<{
|
|
235
|
+
readonly _tag: "CitationAdded";
|
|
236
|
+
readonly annotation: Annotation;
|
|
237
|
+
}, {
|
|
238
|
+
readonly _tag: Tag;
|
|
199
239
|
}> | Extract<{
|
|
200
240
|
readonly _tag: "TurnComplete";
|
|
201
241
|
readonly turn: Turn;
|
|
@@ -231,6 +271,16 @@ declare const TurnEvent: {
|
|
|
231
271
|
readonly _tag: "UsageUpdate";
|
|
232
272
|
readonly usage: Usage;
|
|
233
273
|
}) => any;
|
|
274
|
+
readonly WebSearchCall: (args: {
|
|
275
|
+
readonly _tag: "WebSearchCall";
|
|
276
|
+
readonly status: "started" | "searching" | "completed";
|
|
277
|
+
readonly query?: string;
|
|
278
|
+
readonly action?: "search" | "open_page" | "find_in_page";
|
|
279
|
+
}) => any;
|
|
280
|
+
readonly CitationAdded: (args: {
|
|
281
|
+
readonly _tag: "CitationAdded";
|
|
282
|
+
readonly annotation: Annotation;
|
|
283
|
+
}) => any;
|
|
234
284
|
readonly TurnComplete: (args: {
|
|
235
285
|
readonly _tag: "TurnComplete";
|
|
236
286
|
readonly turn: Turn;
|
|
@@ -256,10 +306,18 @@ declare const TurnEvent: {
|
|
|
256
306
|
} | {
|
|
257
307
|
readonly _tag: "UsageUpdate";
|
|
258
308
|
readonly usage: Usage;
|
|
309
|
+
} | {
|
|
310
|
+
readonly _tag: "WebSearchCall";
|
|
311
|
+
readonly status: "started" | "searching" | "completed";
|
|
312
|
+
readonly query?: string;
|
|
313
|
+
readonly action?: "search" | "open_page" | "find_in_page";
|
|
314
|
+
} | {
|
|
315
|
+
readonly _tag: "CitationAdded";
|
|
316
|
+
readonly annotation: Annotation;
|
|
259
317
|
} | {
|
|
260
318
|
readonly _tag: "TurnComplete";
|
|
261
319
|
readonly turn: Turn;
|
|
262
|
-
}) => _$effect_Unify0.Unify<ReturnType<Cases["TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallStart" | "ToolCallArgsDelta" | "UsageUpdate" | "TurnComplete"]>>;
|
|
320
|
+
}) => _$effect_Unify0.Unify<ReturnType<Cases["TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallStart" | "ToolCallArgsDelta" | "UsageUpdate" | "WebSearchCall" | "CitationAdded" | "TurnComplete"]>>;
|
|
263
321
|
<Cases extends {
|
|
264
322
|
readonly TextDelta: (args: {
|
|
265
323
|
readonly _tag: "TextDelta";
|
|
@@ -288,6 +346,16 @@ declare const TurnEvent: {
|
|
|
288
346
|
readonly _tag: "UsageUpdate";
|
|
289
347
|
readonly usage: Usage;
|
|
290
348
|
}) => any;
|
|
349
|
+
readonly WebSearchCall: (args: {
|
|
350
|
+
readonly _tag: "WebSearchCall";
|
|
351
|
+
readonly status: "started" | "searching" | "completed";
|
|
352
|
+
readonly query?: string;
|
|
353
|
+
readonly action?: "search" | "open_page" | "find_in_page";
|
|
354
|
+
}) => any;
|
|
355
|
+
readonly CitationAdded: (args: {
|
|
356
|
+
readonly _tag: "CitationAdded";
|
|
357
|
+
readonly annotation: Annotation;
|
|
358
|
+
}) => any;
|
|
291
359
|
readonly TurnComplete: (args: {
|
|
292
360
|
readonly _tag: "TurnComplete";
|
|
293
361
|
readonly turn: Turn;
|
|
@@ -313,10 +381,18 @@ declare const TurnEvent: {
|
|
|
313
381
|
} | {
|
|
314
382
|
readonly _tag: "UsageUpdate";
|
|
315
383
|
readonly usage: Usage;
|
|
384
|
+
} | {
|
|
385
|
+
readonly _tag: "WebSearchCall";
|
|
386
|
+
readonly status: "started" | "searching" | "completed";
|
|
387
|
+
readonly query?: string;
|
|
388
|
+
readonly action?: "search" | "open_page" | "find_in_page";
|
|
389
|
+
} | {
|
|
390
|
+
readonly _tag: "CitationAdded";
|
|
391
|
+
readonly annotation: Annotation;
|
|
316
392
|
} | {
|
|
317
393
|
readonly _tag: "TurnComplete";
|
|
318
394
|
readonly turn: Turn;
|
|
319
|
-
}, cases: Cases): _$effect_Unify0.Unify<ReturnType<Cases["TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallStart" | "ToolCallArgsDelta" | "UsageUpdate" | "TurnComplete"]>>;
|
|
395
|
+
}, cases: Cases): _$effect_Unify0.Unify<ReturnType<Cases["TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallStart" | "ToolCallArgsDelta" | "UsageUpdate" | "WebSearchCall" | "CitationAdded" | "TurnComplete"]>>;
|
|
320
396
|
};
|
|
321
397
|
};
|
|
322
398
|
/**
|
|
@@ -347,6 +423,12 @@ declare const assistantTexts: (turn: Turn) => ReadonlyArray<string>;
|
|
|
347
423
|
* that want one concatenated string.
|
|
348
424
|
*/
|
|
349
425
|
declare const assistantText: (turn: Turn) => string;
|
|
426
|
+
/**
|
|
427
|
+
* Every citation annotation attached to the turn's assistant `output_text`
|
|
428
|
+
* blocks, in order. The flat view of a grounded turn's sources, whether the
|
|
429
|
+
* turn came from a normal generation with native search or a deep-research job.
|
|
430
|
+
*/
|
|
431
|
+
declare const citations: (turn: Turn) => ReadonlyArray<Annotation>;
|
|
350
432
|
/**
|
|
351
433
|
* Append a completed turn and optional follow-up items to a state record's
|
|
352
434
|
* history. Recipes use this at the point where structured tool results are
|
|
@@ -384,5 +466,5 @@ declare class RefusalRejected extends RefusalRejected_base<{
|
|
|
384
466
|
*/
|
|
385
467
|
declare const decodeStructured: <A>(turn: Turn, format: StructuredFormat<A>) => Effect.Effect<A, RefusalRejected | JsonParseError | StructuredDecodeError>;
|
|
386
468
|
//#endregion
|
|
387
|
-
export { InteractionEvent, RefusalRejected, Turn, TurnEvent, appendToHistory, assistantMessages, assistantText, assistantTexts, decodeStructured, getToolCalls, isTurnComplete, reasonings, Turn_d_exports as t, textDeltas };
|
|
469
|
+
export { InteractionEvent, RefusalRejected, Turn, TurnEvent, appendToHistory, assistantMessages, assistantText, assistantTexts, citations, decodeStructured, getToolCalls, isTurnComplete, reasonings, Turn_d_exports as t, textDeltas };
|
|
388
470
|
//# sourceMappingURL=Turn.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Turn.d.mts","names":[],"sources":["../../src/domain/Turn.ts"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Turn.d.mts","names":[],"sources":["../../src/domain/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AkB,cAAA,GAAkC,qBAAA"}
|
package/dist/domain/Turn.mjs
CHANGED
|
@@ -11,6 +11,7 @@ var Turn_exports = /* @__PURE__ */ __exportAll({
|
|
|
11
11
|
assistantMessages: () => assistantMessages,
|
|
12
12
|
assistantText: () => assistantText,
|
|
13
13
|
assistantTexts: () => assistantTexts,
|
|
14
|
+
citations: () => citations,
|
|
14
15
|
decodeStructured: () => decodeStructured,
|
|
15
16
|
getToolCalls: () => getToolCalls,
|
|
16
17
|
isTurnComplete: () => isTurnComplete,
|
|
@@ -47,6 +48,12 @@ const assistantTexts = (turn) => assistantMessages(turn).flatMap((m) => m.conten
|
|
|
47
48
|
*/
|
|
48
49
|
const assistantText = (turn) => assistantTexts(turn).join("");
|
|
49
50
|
/**
|
|
51
|
+
* Every citation annotation attached to the turn's assistant `output_text`
|
|
52
|
+
* blocks, in order. The flat view of a grounded turn's sources, whether the
|
|
53
|
+
* turn came from a normal generation with native search or a deep-research job.
|
|
54
|
+
*/
|
|
55
|
+
const citations = (turn) => assistantMessages(turn).flatMap((m) => m.content).filter(isOutputText).flatMap((b) => b.annotations ?? []);
|
|
56
|
+
/**
|
|
50
57
|
* Append a completed turn and optional follow-up items to a state record's
|
|
51
58
|
* history. Recipes use this at the point where structured tool results are
|
|
52
59
|
* converted to model-facing `ToolCallOutput`s.
|
|
@@ -99,6 +106,6 @@ const lastAssistantContent = (turn) => {
|
|
|
99
106
|
*/
|
|
100
107
|
const decodeStructured = (turn, format) => pipe(lastAssistantContent(turn), ({ text, refused }) => refused ? Effect.fail(new RefusalRejected({ turn })) : parseJson(format)(text));
|
|
101
108
|
//#endregion
|
|
102
|
-
export { RefusalRejected, Turn, TurnEvent, appendToHistory, assistantMessages, assistantText, assistantTexts, decodeStructured, getToolCalls, isTurnComplete, reasonings, Turn_exports as t, textDeltas };
|
|
109
|
+
export { RefusalRejected, Turn, TurnEvent, appendToHistory, assistantMessages, assistantText, assistantTexts, citations, decodeStructured, getToolCalls, isTurnComplete, reasonings, Turn_exports as t, textDeltas };
|
|
103
110
|
|
|
104
111
|
//# sourceMappingURL=Turn.mjs.map
|
package/dist/domain/Turn.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Turn.mjs","names":["StructuredFormat.parseJson"],"sources":["../../src/domain/Turn.ts"],"sourcesContent":["import { Data, Effect, Result, Schema, Stream, pipe } from \"effect\"\nimport * as StructuredFormat from \"../structured-format/StructuredFormat.js\"\nimport {\n HistoryItem,\n Message,\n Reasoning,\n StopReason,\n ToolCall,\n ToolCallOutput,\n Usage,\n isOutputText,\n isReasoning,\n isRefusal,\n isToolCall,\n} from \"./Items.js\"\n\n/**\n * The result of a single LLM generation. A turn produces zero or more items\n * (typically one assistant message and zero or more function_call items)\n * and reports usage + a stop reason.\n */\nexport const Turn = Schema.Struct({\n items: Schema.Array(HistoryItem),\n usage: Usage,\n stop_reason: StopReason,\n})\nexport type Turn = typeof Turn.Type\n\n/**\n * Canonical events emitted while a single turn is being generated. Most\n * variants are streaming deltas (text, reasoning, tool-call args); the\n * terminal `TurnComplete` carries the assembled `Turn`. Lifecycle members\n * aren't deltas, hence the union name.\n *\n * `ReasoningDelta.kind`: `trace` is the model's raw chain-of-thought;\n * `summary` is a model-written summary intended for display. OpenAI\n * Responses emits both; Anthropic and Gemini only emit `trace`.\n *\n * `RefusalDelta`: the model declined to answer. OpenAI Responses emits\n * this as its own event; Anthropic surfaces refusals via `stop_reason`\n * and Gemini collapses them into `finishReason: SAFETY` — both go\n * without a `RefusalDelta`.\n *\n * `UsageUpdate`: mid-stream cumulative usage. Anthropic emits this on\n * `message_start` and `message_delta`; other providers may only deliver\n * usage via `TurnComplete.turn.usage`.\n */\nexport type TurnEvent = Data.TaggedEnum<{\n TextDelta: { readonly text: string }\n ReasoningDelta: { readonly text: string; readonly kind: \"trace\" | \"summary\" }\n RefusalDelta: { readonly text: string }\n ToolCallStart: { readonly call_id: string; readonly name: string }\n ToolCallArgsDelta: { readonly call_id: string; readonly delta: string }\n UsageUpdate: { readonly usage: Usage }\n TurnComplete: { readonly turn: Turn }\n}>\n\nexport const TurnEvent = Data.taggedEnum<TurnEvent>()\n\n/**\n * What flows out of an agent loop body to its consumer per turn: every\n * `TurnEvent` the provider emits (including the terminal `TurnComplete`\n * carrying the assembled `Turn`), plus the output of any tool the loop ran.\n * Both variants carry a `_tag` discriminator.\n */\nexport type InteractionEvent = TurnEvent | ToolCallOutput\n\nexport const isTurnComplete = TurnEvent.$is(\"TurnComplete\")\n\nexport const getToolCalls = (turn: Turn): ReadonlyArray<ToolCall> => turn.items.filter(isToolCall)\n\nexport const reasonings = (turn: Turn): ReadonlyArray<Reasoning> => turn.items.filter(isReasoning)\n\nexport const assistantMessages = (turn: Turn): ReadonlyArray<Message> =>\n turn.items.filter((i): i is Message => i.type === \"message\" && i.role === \"assistant\")\n\n/**\n * Every `output_text` payload across every assistant message in the turn,\n * preserving order. Refusals and other content blocks are dropped — use\n * `assistantMessages` if you need to inspect them. The primitive for\n * \"give me the assistant's text\"; callers decide how to combine\n * (typically `.join(\"\")` for prose or `.join(\" \")` for log strings).\n */\nexport const assistantTexts = (turn: Turn): ReadonlyArray<string> =>\n assistantMessages(turn)\n .flatMap((m) => m.content)\n .filter(isOutputText)\n .map((b) => b.text)\n\n/**\n * Sugar over `assistantTexts(turn).join(\"\")` — the common case for\n * summarizers, classifiers, judge calls, and structured-output backstops\n * that want one concatenated string.\n */\nexport const assistantText = (turn: Turn): string => assistantTexts(turn).join(\"\")\n\n/**\n * Append a completed turn and optional follow-up items to a state record's\n * history. Recipes use this at the point where structured tool results are\n * converted to model-facing `ToolCallOutput`s.\n */\nexport const appendToHistory = <S extends { readonly history: ReadonlyArray<HistoryItem> }>(\n state: S,\n turn: Turn,\n items: ReadonlyArray<HistoryItem> = [],\n): S => ({\n ...state,\n history: [...state.history, ...turn.items, ...items],\n})\n\n// ---------------------------------------------------------------------------\n// Stream operators\n// ---------------------------------------------------------------------------\n\n/**\n * Project a `TurnEvent` stream onto its `TextDelta` payloads. Other\n * variants are dropped. Composes with `Lines.lines` +\n * `decodeJsonLines` for prompted-JSONL streaming.\n */\nexport const textDeltas = <E, R>(\n self: Stream.Stream<TurnEvent, E, R>,\n): Stream.Stream<string, E, R> =>\n self.pipe(\n Stream.filterMap((ev) => (ev._tag === \"TextDelta\" ? Result.succeed(ev.text) : Result.failVoid)),\n )\n\n// ---------------------------------------------------------------------------\n// Structured-output integration\n// ---------------------------------------------------------------------------\n\n/**\n * The assistant message on the just-completed turn was a refusal block,\n * not an `output_text` payload. Returned by `decodeStructured` to short-circuit\n * decoding before `JSON.parse` / schema validation runs.\n */\nexport class RefusalRejected extends Data.TaggedError(\"RefusalRejected\")<{\n readonly turn: Turn\n}> {}\n\nconst lastAssistantContent = (turn: Turn): { readonly text: string; readonly refused: boolean } => {\n const assistants = assistantMessages(turn)\n const last = assistants[assistants.length - 1]\n if (last === undefined) return { text: \"\", refused: false }\n if (last.content.some(isRefusal)) return { text: \"\", refused: true }\n const text = last.content\n .filter(isOutputText)\n .map((b) => b.text)\n .join(\"\")\n return { text, refused: false }\n}\n\n/**\n * Validate a completed `Turn` against a `StructuredFormat`. Concatenates\n * `output_text` blocks on the last assistant message, then runs\n * `JSON.parse` + the format's schema validation.\n *\n * Three failure modes:\n * - `RefusalRejected` — the assistant emitted a refusal block.\n * - `JsonParseError` — the assembled text wasn't valid JSON.\n * - `StructuredDecodeError` — the JSON didn't match the schema.\n */\nexport const decodeStructured = <A>(\n turn: Turn,\n format: StructuredFormat.StructuredFormat<A>,\n): Effect.Effect<\n A,\n RefusalRejected | StructuredFormat.JsonParseError | StructuredFormat.StructuredDecodeError\n> =>\n pipe(lastAssistantContent(turn), ({ text, refused }) =>\n refused ? Effect.fail(new RefusalRejected({ turn })) : StructuredFormat.parseJson(format)(text),\n )\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Turn.mjs","names":["StructuredFormat.parseJson"],"sources":["../../src/domain/Turn.ts"],"sourcesContent":["import { Data, Effect, Result, Schema, Stream, pipe } from \"effect\"\nimport * as StructuredFormat from \"../structured-format/StructuredFormat.js\"\nimport {\n type Annotation,\n HistoryItem,\n Message,\n Reasoning,\n StopReason,\n ToolCall,\n ToolCallOutput,\n Usage,\n isOutputText,\n isReasoning,\n isRefusal,\n isToolCall,\n} from \"./Items.js\"\n\n/**\n * The result of a single LLM generation. A turn produces zero or more items\n * (typically one assistant message and zero or more function_call items)\n * and reports usage + a stop reason.\n */\nexport const Turn = Schema.Struct({\n items: Schema.Array(HistoryItem),\n usage: Usage,\n stop_reason: StopReason,\n})\nexport type Turn = typeof Turn.Type\n\n/**\n * Canonical events emitted while a single turn is being generated. Most\n * variants are streaming deltas (text, reasoning, tool-call args); the\n * terminal `TurnComplete` carries the assembled `Turn`. Lifecycle members\n * aren't deltas, hence the union name.\n *\n * `ReasoningDelta.kind`: `trace` is the model's raw chain-of-thought;\n * `summary` is a model-written summary intended for display. OpenAI\n * Responses emits both; Anthropic and Gemini only emit `trace`.\n *\n * `RefusalDelta`: the model declined to answer. OpenAI Responses emits\n * this as its own event; Anthropic surfaces refusals via `stop_reason`\n * and Gemini collapses them into `finishReason: SAFETY` — both go\n * without a `RefusalDelta`.\n *\n * `UsageUpdate`: mid-stream cumulative usage. Anthropic emits this on\n * `message_start` and `message_delta`; other providers may only deliver\n * usage via `TurnComplete.turn.usage`.\n *\n * `WebSearchCall`: lifecycle of a provider-executed web search within the\n * turn. Fires only when the turn grounds against search; absent otherwise.\n *\n * `CitationAdded`: a citation attached to the answer, emitted incrementally\n * where the provider streams citations. Providers that bundle citations emit\n * none of these; their citations still arrive on `TurnComplete.turn`\n * (`OutputText.annotations`). Either way the final set is on the assembled turn.\n */\nexport type TurnEvent = Data.TaggedEnum<{\n TextDelta: { readonly text: string }\n ReasoningDelta: { readonly text: string; readonly kind: \"trace\" | \"summary\" }\n RefusalDelta: { readonly text: string }\n ToolCallStart: { readonly call_id: string; readonly name: string }\n ToolCallArgsDelta: { readonly call_id: string; readonly delta: string }\n UsageUpdate: { readonly usage: Usage }\n WebSearchCall: {\n readonly status: \"started\" | \"searching\" | \"completed\"\n readonly query?: string\n readonly action?: \"search\" | \"open_page\" | \"find_in_page\"\n }\n CitationAdded: { readonly annotation: Annotation }\n TurnComplete: { readonly turn: Turn }\n}>\n\nexport const TurnEvent = Data.taggedEnum<TurnEvent>()\n\n/**\n * What flows out of an agent loop body to its consumer per turn: every\n * `TurnEvent` the provider emits (including the terminal `TurnComplete`\n * carrying the assembled `Turn`), plus the output of any tool the loop ran.\n * Both variants carry a `_tag` discriminator.\n */\nexport type InteractionEvent = TurnEvent | ToolCallOutput\n\nexport const isTurnComplete = TurnEvent.$is(\"TurnComplete\")\n\nexport const getToolCalls = (turn: Turn): ReadonlyArray<ToolCall> => turn.items.filter(isToolCall)\n\nexport const reasonings = (turn: Turn): ReadonlyArray<Reasoning> => turn.items.filter(isReasoning)\n\nexport const assistantMessages = (turn: Turn): ReadonlyArray<Message> =>\n turn.items.filter((i): i is Message => i.type === \"message\" && i.role === \"assistant\")\n\n/**\n * Every `output_text` payload across every assistant message in the turn,\n * preserving order. Refusals and other content blocks are dropped — use\n * `assistantMessages` if you need to inspect them. The primitive for\n * \"give me the assistant's text\"; callers decide how to combine\n * (typically `.join(\"\")` for prose or `.join(\" \")` for log strings).\n */\nexport const assistantTexts = (turn: Turn): ReadonlyArray<string> =>\n assistantMessages(turn)\n .flatMap((m) => m.content)\n .filter(isOutputText)\n .map((b) => b.text)\n\n/**\n * Sugar over `assistantTexts(turn).join(\"\")` — the common case for\n * summarizers, classifiers, judge calls, and structured-output backstops\n * that want one concatenated string.\n */\nexport const assistantText = (turn: Turn): string => assistantTexts(turn).join(\"\")\n\n/**\n * Every citation annotation attached to the turn's assistant `output_text`\n * blocks, in order. The flat view of a grounded turn's sources, whether the\n * turn came from a normal generation with native search or a deep-research job.\n */\nexport const citations = (turn: Turn): ReadonlyArray<Annotation> =>\n assistantMessages(turn)\n .flatMap((m) => m.content)\n .filter(isOutputText)\n .flatMap((b) => b.annotations ?? [])\n\n/**\n * Append a completed turn and optional follow-up items to a state record's\n * history. Recipes use this at the point where structured tool results are\n * converted to model-facing `ToolCallOutput`s.\n */\nexport const appendToHistory = <S extends { readonly history: ReadonlyArray<HistoryItem> }>(\n state: S,\n turn: Turn,\n items: ReadonlyArray<HistoryItem> = [],\n): S => ({\n ...state,\n history: [...state.history, ...turn.items, ...items],\n})\n\n// ---------------------------------------------------------------------------\n// Stream operators\n// ---------------------------------------------------------------------------\n\n/**\n * Project a `TurnEvent` stream onto its `TextDelta` payloads. Other\n * variants are dropped. Composes with `Lines.lines` +\n * `decodeJsonLines` for prompted-JSONL streaming.\n */\nexport const textDeltas = <E, R>(\n self: Stream.Stream<TurnEvent, E, R>,\n): Stream.Stream<string, E, R> =>\n self.pipe(\n Stream.filterMap((ev) => (ev._tag === \"TextDelta\" ? Result.succeed(ev.text) : Result.failVoid)),\n )\n\n// ---------------------------------------------------------------------------\n// Structured-output integration\n// ---------------------------------------------------------------------------\n\n/**\n * The assistant message on the just-completed turn was a refusal block,\n * not an `output_text` payload. Returned by `decodeStructured` to short-circuit\n * decoding before `JSON.parse` / schema validation runs.\n */\nexport class RefusalRejected extends Data.TaggedError(\"RefusalRejected\")<{\n readonly turn: Turn\n}> {}\n\nconst lastAssistantContent = (turn: Turn): { readonly text: string; readonly refused: boolean } => {\n const assistants = assistantMessages(turn)\n const last = assistants[assistants.length - 1]\n if (last === undefined) return { text: \"\", refused: false }\n if (last.content.some(isRefusal)) return { text: \"\", refused: true }\n const text = last.content\n .filter(isOutputText)\n .map((b) => b.text)\n .join(\"\")\n return { text, refused: false }\n}\n\n/**\n * Validate a completed `Turn` against a `StructuredFormat`. Concatenates\n * `output_text` blocks on the last assistant message, then runs\n * `JSON.parse` + the format's schema validation.\n *\n * Three failure modes:\n * - `RefusalRejected` — the assistant emitted a refusal block.\n * - `JsonParseError` — the assembled text wasn't valid JSON.\n * - `StructuredDecodeError` — the JSON didn't match the schema.\n */\nexport const decodeStructured = <A>(\n turn: Turn,\n format: StructuredFormat.StructuredFormat<A>,\n): Effect.Effect<\n A,\n RefusalRejected | StructuredFormat.JsonParseError | StructuredFormat.StructuredDecodeError\n> =>\n pipe(lastAssistantContent(turn), ({ text, refused }) =>\n refused ? Effect.fail(new RefusalRejected({ turn })) : StructuredFormat.parseJson(format)(text),\n )\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,OAAO,OAAO,OAAO;CAChC,OAAO,OAAO,MAAM,YAAY;CAChC,OAAO;CACP,aAAa;CACd,CAAC;AA8CF,MAAa,YAAY,KAAK,YAAuB;AAUrD,MAAa,iBAAiB,UAAU,IAAI,eAAe;AAE3D,MAAa,gBAAgB,SAAwC,KAAK,MAAM,OAAO,WAAW;AAElG,MAAa,cAAc,SAAyC,KAAK,MAAM,OAAO,YAAY;AAElG,MAAa,qBAAqB,SAChC,KAAK,MAAM,QAAQ,MAAoB,EAAE,SAAS,aAAa,EAAE,SAAS,YAAY;;;;;;;;AASxF,MAAa,kBAAkB,SAC7B,kBAAkB,KAAK,CACpB,SAAS,MAAM,EAAE,QAAQ,CACzB,OAAO,aAAa,CACpB,KAAK,MAAM,EAAE,KAAK;;;;;;AAOvB,MAAa,iBAAiB,SAAuB,eAAe,KAAK,CAAC,KAAK,GAAG;;;;;;AAOlF,MAAa,aAAa,SACxB,kBAAkB,KAAK,CACpB,SAAS,MAAM,EAAE,QAAQ,CACzB,OAAO,aAAa,CACpB,SAAS,MAAM,EAAE,eAAe,EAAE,CAAC;;;;;;AAOxC,MAAa,mBACX,OACA,MACA,QAAoC,EAAE,MAC/B;CACP,GAAG;CACH,SAAS;EAAC,GAAG,MAAM;EAAS,GAAG,KAAK;EAAO,GAAG;EAAM;CACrD;;;;;;AAWD,MAAa,cACX,SAEA,KAAK,KACH,OAAO,WAAW,OAAQ,GAAG,SAAS,cAAc,OAAO,QAAQ,GAAG,KAAK,GAAG,OAAO,SAAU,CAChG;;;;;;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