@effect-uai/core 0.12.0 → 0.13.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-Bf1pq4BB.d.mts → AiError-eLV9t1lU.d.mts} +12 -16
- package/dist/AiError-eLV9t1lU.d.mts.map +1 -0
- package/dist/{Audio-CR7CSljJ.d.mts → Audio-60lKKHxS.d.mts} +4 -5
- package/dist/Audio-60lKKHxS.d.mts.map +1 -0
- package/dist/{Image-C4vuBmu0.d.mts → Image-BK8-4H6s.d.mts} +12 -14
- package/dist/Image-BK8-4H6s.d.mts.map +1 -0
- package/dist/{Items-BKQgqJ8A.d.mts → Items-SfUabNuB.d.mts} +74 -76
- package/dist/Items-SfUabNuB.d.mts.map +1 -0
- package/dist/{Loop-D8nWpowc.d.mts → Loop-B54AB1ME.d.mts} +19 -21
- package/dist/Loop-B54AB1ME.d.mts.map +1 -0
- package/dist/{Media-D_CpcM1Z.d.mts → Media-DwgpifPD.d.mts} +1 -1
- package/dist/Media-DwgpifPD.d.mts.map +1 -0
- package/dist/{SandboxError-CIrVDOMV.d.mts → SandboxError-BN8b28Bh.d.mts} +11 -15
- package/dist/SandboxError-BN8b28Bh.d.mts.map +1 -0
- package/dist/{StructuredFormat-DHaUJBdd.d.mts → StructuredFormat-BlZhyOsi.d.mts} +3 -7
- package/dist/StructuredFormat-BlZhyOsi.d.mts.map +1 -0
- package/dist/{Tool-u5bag8SO.d.mts → Tool-DE-rnvkw.d.mts} +5 -8
- package/dist/Tool-DE-rnvkw.d.mts.map +1 -0
- package/dist/{ToolEvent-BBfOdhF_.d.mts → ToolEvent-D99MGQYH.d.mts} +56 -63
- package/dist/ToolEvent-D99MGQYH.d.mts.map +1 -0
- package/dist/{ToolResult-CRpmkBXR.d.mts → ToolResult-Cj8ChodL.d.mts} +49 -54
- package/dist/ToolResult-Cj8ChodL.d.mts.map +1 -0
- package/dist/{Toolkit-D4mQvhjq.d.mts → Toolkit-BEZrNPTI.d.mts} +13 -16
- package/dist/Toolkit-BEZrNPTI.d.mts.map +1 -0
- package/dist/browser/Browser.d.mts +11 -7
- package/dist/browser/Browser.d.mts.map +1 -1
- package/dist/browser/Browser.mjs +1 -1
- package/dist/browser/Browser.mjs.map +1 -1
- package/dist/browser/BrowserError.d.mts +9 -13
- package/dist/browser/BrowserError.d.mts.map +1 -1
- package/dist/browser/BrowserError.mjs +1 -1
- package/dist/browser/BrowserError.mjs.map +1 -1
- package/dist/browser/BrowserTool.d.mts +33 -36
- package/dist/browser/BrowserTool.d.mts.map +1 -1
- package/dist/browser/BrowserTool.mjs +1 -1
- package/dist/browser/BrowserTool.mjs.map +1 -1
- package/dist/capabilities/Capabilities.d.mts +8 -6
- package/dist/capabilities/Capabilities.d.mts.map +1 -1
- package/dist/capabilities/Capabilities.mjs +1 -1
- package/dist/capabilities/Capabilities.mjs.map +1 -1
- package/dist/chunker/Chunker.d.mts +32 -0
- package/dist/chunker/Chunker.d.mts.map +1 -0
- package/dist/chunker/Chunker.mjs +14 -0
- package/dist/chunker/Chunker.mjs.map +1 -0
- package/dist/dist-BaenoU1A.mjs +145 -0
- package/dist/dist-BaenoU1A.mjs.map +1 -0
- package/dist/{dist-C0m0QnUP.mjs → dist-nohcnkD6.mjs} +16 -15
- package/dist/dist-nohcnkD6.mjs.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/Audio.d.mts +1 -1
- package/dist/domain/Audio.mjs +1 -1
- package/dist/domain/Citation.d.mts +0 -2
- package/dist/domain/Citation.d.mts.map +1 -1
- package/dist/domain/Citation.mjs +1 -1
- package/dist/domain/Image.d.mts +1 -1
- package/dist/domain/Image.mjs +1 -1
- package/dist/domain/Image.mjs.map +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/Media.d.mts +1 -1
- package/dist/domain/Media.mjs +1 -1
- package/dist/domain/Music.d.mts +18 -11
- package/dist/domain/Music.d.mts.map +1 -1
- package/dist/domain/Music.mjs +1 -1
- package/dist/domain/Music.mjs.map +1 -1
- package/dist/domain/Research.d.mts +3 -4
- package/dist/domain/Research.d.mts.map +1 -1
- package/dist/domain/Research.mjs +1 -1
- package/dist/domain/Transcript.d.mts +2 -3
- package/dist/domain/Transcript.d.mts.map +1 -1
- package/dist/domain/Transcript.mjs +1 -1
- package/dist/domain/Turn.d.mts +143 -164
- package/dist/domain/Turn.d.mts.map +1 -1
- package/dist/domain/Turn.mjs +1 -1
- package/dist/domain/Turn.mjs.map +1 -1
- package/dist/domain/Turn.test.d.mts +1 -1
- package/dist/domain/Turn.test.mjs +28 -18
- package/dist/domain/Turn.test.mjs.map +1 -1
- package/dist/embedding-model/Embedding.d.mts +1 -3
- package/dist/embedding-model/Embedding.d.mts.map +1 -1
- package/dist/embedding-model/Embedding.mjs +1 -1
- package/dist/embedding-model/EmbeddingModel.d.mts +1 -3
- package/dist/embedding-model/EmbeddingModel.d.mts.map +1 -1
- package/dist/embedding-model/EmbeddingModel.mjs +1 -1
- package/dist/embedding-model/EmbeddingModel.mjs.map +1 -1
- package/dist/embedding-model/EmbeddingModel.test.d.mts +1 -1
- package/dist/embedding-model/EmbeddingModel.test.mjs +14 -9
- package/dist/embedding-model/EmbeddingModel.test.mjs.map +1 -1
- package/dist/index.d.mts +16 -13
- package/dist/index.mjs +4 -1
- package/dist/job/Job.d.mts +4 -4
- package/dist/job/Job.d.mts.map +1 -1
- package/dist/job/Job.mjs +1 -1
- package/dist/job/Job.mjs.map +1 -1
- package/dist/language-model/LanguageModel.d.mts +4 -6
- package/dist/language-model/LanguageModel.d.mts.map +1 -1
- package/dist/language-model/LanguageModel.mjs +1 -1
- package/dist/language-model/LanguageModel.mjs.map +1 -1
- package/dist/language-model/LanguageModel.test.d.mts +1 -1
- package/dist/language-model/LanguageModel.test.mjs +6 -3
- package/dist/language-model/LanguageModel.test.mjs.map +1 -1
- package/dist/loop/Loop.d.mts +1 -1
- package/dist/loop/Loop.mjs +1 -1
- package/dist/loop/Loop.mjs.map +1 -1
- package/dist/loop/Loop.test.d.mts +1 -1
- package/dist/loop/Loop.test.mjs +60 -34
- package/dist/loop/Loop.test.mjs.map +1 -1
- package/dist/{magic-string.es-Dk-MMA0F.mjs → magic-string.es-CB2hOw9v.mjs} +14 -13
- package/dist/{magic-string.es-Dk-MMA0F.mjs.map → magic-string.es-CB2hOw9v.mjs.map} +1 -1
- package/dist/math/Vector.d.mts +0 -2
- package/dist/math/Vector.d.mts.map +1 -1
- package/dist/math/Vector.mjs +1 -1
- package/dist/math/Vector.mjs.map +1 -1
- package/dist/music-generator/MusicGenerator.d.mts +2 -4
- package/dist/music-generator/MusicGenerator.d.mts.map +1 -1
- package/dist/music-generator/MusicGenerator.mjs +1 -1
- package/dist/music-generator/MusicGenerator.mjs.map +1 -1
- package/dist/music-generator/MusicGenerator.test.d.mts +1 -1
- package/dist/music-generator/MusicGenerator.test.mjs +19 -10
- package/dist/music-generator/MusicGenerator.test.mjs.map +1 -1
- package/dist/observability/Metrics.d.mts +10 -7
- package/dist/observability/Metrics.d.mts.map +1 -1
- package/dist/observability/Metrics.mjs +1 -1
- package/dist/observability/Metrics.mjs.map +1 -1
- package/dist/observability/Metrics.test.d.mts +1 -1
- package/dist/observability/Metrics.test.mjs +50 -28
- package/dist/observability/Metrics.test.mjs.map +1 -1
- package/dist/observability/Telemetry.d.mts +2 -3
- package/dist/observability/Telemetry.d.mts.map +1 -1
- package/dist/observability/Telemetry.mjs +1 -1
- package/dist/observability/Telemetry.mjs.map +1 -1
- package/dist/observability/Telemetry.test.d.mts +1 -1
- package/dist/observability/Telemetry.test.mjs +15 -7
- package/dist/observability/Telemetry.test.mjs.map +1 -1
- package/dist/reranker/Reranker.d.mts +46 -0
- package/dist/reranker/Reranker.d.mts.map +1 -0
- package/dist/reranker/Reranker.mjs +14 -0
- package/dist/reranker/Reranker.mjs.map +1 -0
- package/dist/research/DeepResearch.d.mts +1 -3
- package/dist/research/DeepResearch.d.mts.map +1 -1
- package/dist/research/DeepResearch.mjs +1 -1
- package/dist/research/DeepResearch.mjs.map +1 -1
- package/dist/retry/Retry.d.mts +2 -6
- package/dist/retry/Retry.d.mts.map +1 -1
- package/dist/retry/Retry.mjs +1 -1
- package/dist/retry/Retry.mjs.map +1 -1
- package/dist/retry/Retry.test.d.mts +1 -1
- package/dist/retry/Retry.test.mjs +6 -3
- package/dist/retry/Retry.test.mjs.map +1 -1
- package/dist/sandbox/Memory.d.mts +0 -2
- package/dist/sandbox/Memory.d.mts.map +1 -1
- package/dist/sandbox/Memory.mjs +4 -4
- package/dist/sandbox/Memory.mjs.map +1 -1
- package/dist/sandbox/Sandbox.d.mts +144 -156
- package/dist/sandbox/Sandbox.d.mts.map +1 -1
- package/dist/sandbox/Sandbox.mjs +1 -1
- package/dist/sandbox/Sandbox.mjs.map +1 -1
- package/dist/sandbox/SandboxError.d.mts +1 -1
- package/dist/sandbox/SandboxError.mjs +1 -1
- package/dist/sandbox/SandboxError.mjs.map +1 -1
- package/dist/sandbox/SandboxImage.d.mts +0 -2
- package/dist/sandbox/SandboxImage.d.mts.map +1 -1
- package/dist/sandbox/SandboxImage.mjs +1 -1
- package/dist/sandbox/SandboxImage.mjs.map +1 -1
- package/dist/sandbox/SandboxNetwork.d.mts +0 -2
- package/dist/sandbox/SandboxNetwork.d.mts.map +1 -1
- package/dist/sandbox/SandboxNetwork.mjs +1 -1
- package/dist/sandbox/SandboxNetwork.mjs.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +8 -7
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.mjs +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.mjs.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.test.d.mts +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +31 -16
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs.map +1 -1
- package/dist/streaming/JSONL.d.mts +1 -5
- package/dist/streaming/JSONL.d.mts.map +1 -1
- package/dist/streaming/JSONL.mjs +1 -1
- package/dist/streaming/JSONL.mjs.map +1 -1
- package/dist/streaming/JSONL.test.d.mts +1 -1
- package/dist/streaming/JSONL.test.mjs +16 -8
- package/dist/streaming/JSONL.test.mjs.map +1 -1
- package/dist/streaming/Lines.d.mts +0 -2
- package/dist/streaming/Lines.d.mts.map +1 -1
- package/dist/streaming/Lines.mjs +1 -1
- package/dist/streaming/Lines.mjs.map +1 -1
- package/dist/streaming/SSE.d.mts +0 -2
- package/dist/streaming/SSE.d.mts.map +1 -1
- package/dist/streaming/SSE.mjs +1 -1
- package/dist/streaming/SSE.mjs.map +1 -1
- package/dist/streaming/SSE.test.d.mts +1 -1
- package/dist/streaming/SSE.test.mjs +34 -17
- package/dist/streaming/SSE.test.mjs.map +1 -1
- package/dist/structured-format/StructuredFormat.d.mts +1 -1
- package/dist/structured-format/StructuredFormat.mjs +1 -1
- package/dist/structured-format/StructuredFormat.mjs.map +1 -1
- package/dist/structured-format/StructuredFormat.test.d.mts +1 -1
- package/dist/structured-format/StructuredFormat.test.mjs +7 -4
- package/dist/structured-format/StructuredFormat.test.mjs.map +1 -1
- package/dist/{dist-CcRV3-A5.mjs → test.DNmyFkvJ-YPzDR0Co.mjs} +1644 -5172
- package/dist/test.DNmyFkvJ-YPzDR0Co.mjs.map +1 -0
- package/dist/testing/MockMusicGenerator.d.mts +4 -3
- package/dist/testing/MockMusicGenerator.d.mts.map +1 -1
- package/dist/testing/MockMusicGenerator.mjs.map +1 -1
- package/dist/testing/MockProvider.d.mts +1 -2
- package/dist/testing/MockProvider.d.mts.map +1 -1
- package/dist/testing/MockProvider.mjs.map +1 -1
- package/dist/testing/MockSandbox.d.mts +256 -290
- package/dist/testing/MockSandbox.d.mts.map +1 -1
- package/dist/testing/MockSandbox.mjs.map +1 -1
- package/dist/testing/MockSpeechSynthesizer.d.mts +10 -6
- package/dist/testing/MockSpeechSynthesizer.d.mts.map +1 -1
- package/dist/testing/MockSpeechSynthesizer.mjs.map +1 -1
- package/dist/testing/MockTranscriber.d.mts +3 -2
- package/dist/testing/MockTranscriber.d.mts.map +1 -1
- package/dist/testing/MockTranscriber.mjs.map +1 -1
- package/dist/tokenizer/Tokenizer.d.mts +22 -0
- package/dist/tokenizer/Tokenizer.d.mts.map +1 -0
- package/dist/tokenizer/Tokenizer.mjs +9 -0
- package/dist/tokenizer/Tokenizer.mjs.map +1 -0
- package/dist/tool/Approval.d.mts +31 -36
- package/dist/tool/Approval.d.mts.map +1 -1
- package/dist/tool/Approval.mjs +1 -1
- package/dist/tool/Approval.mjs.map +1 -1
- package/dist/tool/Approval.test.d.mts +1 -1
- package/dist/tool/Approval.test.mjs +37 -24
- package/dist/tool/Approval.test.mjs.map +1 -1
- package/dist/tool/HistoryCheck.d.mts +2 -4
- package/dist/tool/HistoryCheck.d.mts.map +1 -1
- package/dist/tool/HistoryCheck.mjs +1 -1
- package/dist/tool/HistoryCheck.mjs.map +1 -1
- package/dist/tool/Tool.d.mts +1 -1
- package/dist/tool/Tool.mjs +4 -4
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/Tool.test.d.mts +1 -1
- package/dist/tool/Tool.test.mjs +23 -11
- package/dist/tool/Tool.test.mjs.map +1 -1
- package/dist/tool/ToolEvent.d.mts +1 -1
- package/dist/tool/ToolEvent.mjs +1 -1
- package/dist/tool/ToolEvent.mjs.map +1 -1
- package/dist/tool/ToolResult.d.mts +1 -1
- package/dist/tool/ToolResult.mjs +1 -1
- package/dist/tool/ToolResult.mjs.map +1 -1
- package/dist/tool/Toolkit.d.mts +1 -1
- package/dist/tool/Toolkit.mjs +4 -3
- package/dist/tool/Toolkit.mjs.map +1 -1
- package/dist/tool/Toolkit.test.d.mts +1 -1
- package/dist/tool/Toolkit.test.mjs +40 -21
- package/dist/tool/Toolkit.test.mjs.map +1 -1
- package/dist/transcriber/Transcriber.d.mts +6 -6
- package/dist/transcriber/Transcriber.d.mts.map +1 -1
- package/dist/transcriber/Transcriber.mjs +1 -1
- package/dist/transcriber/Transcriber.mjs.map +1 -1
- package/dist/transcriber/Transcriber.test.d.mts +1 -1
- package/dist/transcriber/Transcriber.test.mjs +20 -10
- package/dist/transcriber/Transcriber.test.mjs.map +1 -1
- package/dist/utils-CiH_DjFW.mjs +3918 -0
- package/dist/utils-CiH_DjFW.mjs.map +1 -0
- package/dist/web-read/WebRead.d.mts +15 -9
- package/dist/web-read/WebRead.d.mts.map +1 -1
- package/dist/web-read/WebRead.mjs +1 -1
- package/dist/web-read/WebRead.mjs.map +1 -1
- package/dist/web-read/WebReadTool.d.mts +4 -5
- package/dist/web-read/WebReadTool.d.mts.map +1 -1
- package/dist/web-read/WebReadTool.mjs +1 -1
- package/dist/web-read/WebReadTool.mjs.map +1 -1
- package/dist/web-search/WebSearch.d.mts +22 -13
- package/dist/web-search/WebSearch.d.mts.map +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 +6 -6
- package/dist/web-search/WebSearchTool.d.mts.map +1 -1
- package/dist/web-search/WebSearchTool.mjs +1 -1
- package/dist/web-search/WebSearchTool.mjs.map +1 -1
- package/package.json +16 -4
- package/src/chunker/Chunker.ts +34 -0
- package/src/index.ts +3 -0
- package/src/loop/Loop.test.ts +13 -14
- package/src/loop/Loop.ts +74 -76
- package/src/reranker/Reranker.ts +51 -0
- package/src/testing/MockProvider.ts +8 -9
- package/src/tokenizer/Tokenizer.ts +19 -0
- package/src/tool/Tool.ts +13 -13
- package/dist/AiError-Bf1pq4BB.d.mts.map +0 -1
- package/dist/Audio-CR7CSljJ.d.mts.map +0 -1
- package/dist/Image-C4vuBmu0.d.mts.map +0 -1
- package/dist/Items-BKQgqJ8A.d.mts.map +0 -1
- package/dist/Loop-D8nWpowc.d.mts.map +0 -1
- package/dist/Media-D_CpcM1Z.d.mts.map +0 -1
- package/dist/SandboxError-CIrVDOMV.d.mts.map +0 -1
- package/dist/StructuredFormat-DHaUJBdd.d.mts.map +0 -1
- package/dist/Tool-u5bag8SO.d.mts.map +0 -1
- package/dist/ToolEvent-BBfOdhF_.d.mts.map +0 -1
- package/dist/ToolResult-CRpmkBXR.d.mts.map +0 -1
- package/dist/Toolkit-D4mQvhjq.d.mts.map +0 -1
- package/dist/dist-C0m0QnUP.mjs.map +0 -1
- package/dist/dist-CcRV3-A5.mjs.map +0 -1
- /package/dist/{chunk-uyGKjUfl.mjs → rolldown-runtime-EAsCxrDo.mjs} +0 -0
package/dist/domain/Music.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Music.mjs","names":[],"sources":["../../src/domain/Music.ts"],"sourcesContent":["import type { Duration } from \"effect\"\nimport type { AudioBlob, AudioChunk, AudioFormat } from \"./Audio.js\"\n\n/**\n * Prompt fragment with a relative weight. Native to Lyria RealTime\n * (`{ text, weight }` pairs blended in the model) and Riffusion compose.\n * Single-prompt providers (the majority) treat a 1-element array with\n * `weight: 1` as a plain prompt.\n */\nexport type WeightedPrompt = {\n readonly text: string\n /** Default `1.0`. Range typically `[0, 1]`; provider-dependent. */\n readonly weight?: number\n}\n\n/**\n * Cross-provider music-generation request. Trimmed to fields the\n * majority of music providers honor structurally; provider-specific\n * extras (Lyria `bpm` / `scale`, ElevenLabs `compositionPlan` /\n * `signWithC2pa`, Suno `style` / `personaId`, MiniMax `lyricsOptimizer`,\n * `instrumental` on providers that ship a wire toggle) live on each\n * provider's typed request which extends this and narrows `model`.\n *\n * Music providers are one-shot text-to-audio, not conversational. No\n * `messages[]` shape applies.\n */\nexport type CommonGenerateMusicRequest = {\n /** Model identifier. Each provider narrows. */\n readonly model: string\n /** Single prompt string. Weighted blends are provider-typed extras. */\n readonly prompt: string\n /**\n * Lyrics text, optionally with section tags like `[Verse]` /\n * `[Chorus]` / `[Bridge]` / `[Outro]`. Routed to a structured wire\n * field on providers that have one (ElevenLabs `lines`, MiniMax\n * `lyrics`, Mureka `lyrics`, Suno custom-mode `prompt`); embedded in\n * the prompt with a warning on providers without one (Lyria 3,\n * Riffusion).\n */\n readonly lyrics?: string\n /** Target duration. Provider may treat as a hint or hard limit. */\n readonly duration?: Duration.Duration\n /**\n * Reproducibility seed. Tuning hint (bucket 3): honored where the\n * provider takes one (Lyria 2 Vertex, Lyria RealTime, ElevenLabs\n * with `compositionPlan`, Stable Audio, MusicGen); silently ignored\n * elsewhere.\n */\n readonly seed?: number\n /** Preferred output format. Provider may override. */\n readonly outputFormat?: AudioFormat\n}\n\n/**\n * Streamed-output request. Same shape as the sync request: the\n * streaming variant only differs in how the response is delivered.\n */\nexport type CommonStreamGenerateMusicRequest = CommonGenerateMusicRequest\n\n/**\n * Playback-control vocabulary that converges across interactive-media\n * protocols (Web Audio, MIDI sequencer control, music SDK surfaces).\n * Provider-specific control actions (Lyria's `reset_context` and any\n * future provider's extras) live on the provider-typed session-input\n * union.\n */\nexport type MusicSessionControl = \"play\" | \"pause\" | \"stop\" | \"reset\"\n\n/**\n * Bidirectional-session input on the cross-provider surface. Two\n * load-bearing actions every interactive music session needs:\n *\n * - `prompts` — steer the active generation with a (single or\n * weighted) prompt blend.\n * - `control` — play / pause / stop / reset.\n *\n * Provider-typed services extend this union with their own `config`\n * variant for model-specific knobs (Lyria RealTime exposes density /\n * brightness / mute-stems / BPM / scale / etc. via its own\n * `LyriaRealtimeSessionInput`).\n */\nexport type MusicSessionInput =\n | { readonly _tag: \"prompts\"; readonly prompts: ReadonlyArray<WeightedPrompt> }\n | { readonly _tag: \"control\"; readonly action: MusicSessionControl }\n\nexport const promptsInput = (prompts: ReadonlyArray<WeightedPrompt>): MusicSessionInput => ({\n _tag: \"prompts\",\n prompts,\n})\n\nexport const controlInput = (action: MusicSessionControl): MusicSessionInput => ({\n _tag: \"control\",\n action,\n})\n\n/**\n * Watermark kind on the response. SynthID is mandatory on Lyria; C2PA\n * is opt-in on ElevenLabs. No provider exposes additional metadata\n * about the watermark itself, so a bare literal-union is enough.\n */\nexport type Watermark = \"synthid\" | \"c2pa\" | (string & {})\n\n/**\n * Labelled section with absolute timing. Populated when the provider\n * returns structured section metadata (Lyria text part, ElevenLabs\n * `/v1/music/detailed` with `with_timestamps`).\n */\nexport type MusicSection = {\n readonly label: string\n readonly startSeconds: number\n readonly endSeconds: number\n}\n\n/**\n * Single generated track. Composes `AudioBlob` rather than extending\n * it — `result.audio` is the raw blob, `result.songId` / `lyrics` /\n * `sections` / `watermark` are provider-side metadata when returned.\n */\nexport type MusicResult = {\n readonly audio: AudioBlob\n /**\n * Provider identifier, useful when routing through multiple\n * providers in a single pipeline (`\"lyria\"`, `\"elevenlabs-music\"`,\n * etc.).\n */\n readonly provider?: string\n /** Provider-side ID for back-reference (re-download, extension, stems). */\n readonly songId?: string\n /** Generated or transcribed lyrics when the provider returned them. */\n readonly lyrics?: string\n /** Structured section markers when the provider returned them. */\n readonly sections?: ReadonlyArray<MusicSection>\n /** Watermark presence indicator when the provider applied one. */\n readonly watermark?: Watermark\n}\n\n/**\n * Result of a `generate` call. Suno and Mureka always return 2 tracks\n * per request; every other provider returns 1. `primary` is the\n * caller-friendly convenience; `variants` carries every track the\n * provider produced (length ≥ 1; `primary === variants[0]`).\n */\nexport type GenerateResult = {\n readonly primary: MusicResult\n readonly variants: ReadonlyArray<MusicResult>\n}\n\n/**\n * In-band event on the bidirectional `streamGenerationFrom` output\n * stream. Audio chunks flow as `audio`; server-side warnings\n * (`warning`) and prompt-filter rejections (`filteredPrompt`) flow\n * alongside rather than going to a side-channel log.\n */\nexport type MusicStreamEvent =\n | { readonly _tag: \"audio\"; readonly chunk: AudioChunk }\n | { readonly _tag: \"warning\"; readonly message: string }\n | { readonly _tag: \"filteredPrompt\"; readonly prompt: string; readonly reason: string }\n\nexport const isPromptsInput = (\n i: MusicSessionInput,\n): i is MusicSessionInput & { _tag: \"prompts\" } => i._tag === \"prompts\"\nexport const isControlInput = (\n i: MusicSessionInput,\n): i is MusicSessionInput & { _tag: \"control\" } => i._tag === \"control\"\n\nexport const audioEvent = (chunk: AudioChunk): MusicStreamEvent => ({ _tag: \"audio\", chunk })\nexport const warningEvent = (message: string): MusicStreamEvent => ({\n _tag: \"warning\",\n message,\n})\nexport const filteredPromptEvent = (prompt: string, reason: string): MusicStreamEvent => ({\n _tag: \"filteredPrompt\",\n prompt,\n reason,\n})\n\nexport const isAudioEvent = (e: MusicStreamEvent): e is MusicStreamEvent & { _tag: \"audio\" } =>\n e._tag === \"audio\"\nexport const isWarningEvent = (e: MusicStreamEvent): e is MusicStreamEvent & { _tag: \"warning\" } =>\n e._tag === \"warning\"\nexport const isFilteredPromptEvent = (\n e: MusicStreamEvent,\n): e is MusicStreamEvent & { _tag: \"filteredPrompt\" } => e._tag === \"filteredPrompt\"\n\n/**\n * Build a single-variant `GenerateResult` from a `MusicResult`.\n * Convenience for providers that always return exactly one track\n * (Lyria, ElevenLabs, MiniMax, Stable Audio, MusicGen, Riffusion,\n * Tencent). Providers that return multiple tracks (Suno, Mureka)\n * construct the `GenerateResult` directly.\n */\nexport const singleVariant = (result: MusicResult): GenerateResult => ({\n primary: result,\n variants: [result],\n})\n"],"mappings":";;;;;;;;;;;;;;;AAqFA,MAAa,gBAAgB,aAA+D;CAC1F,MAAM;CACN;
|
|
1
|
+
{"version":3,"file":"Music.mjs","names":[],"sources":["../../src/domain/Music.ts"],"sourcesContent":["import type { Duration } from \"effect\"\nimport type { AudioBlob, AudioChunk, AudioFormat } from \"./Audio.js\"\n\n/**\n * Prompt fragment with a relative weight. Native to Lyria RealTime\n * (`{ text, weight }` pairs blended in the model) and Riffusion compose.\n * Single-prompt providers (the majority) treat a 1-element array with\n * `weight: 1` as a plain prompt.\n */\nexport type WeightedPrompt = {\n readonly text: string\n /** Default `1.0`. Range typically `[0, 1]`; provider-dependent. */\n readonly weight?: number\n}\n\n/**\n * Cross-provider music-generation request. Trimmed to fields the\n * majority of music providers honor structurally; provider-specific\n * extras (Lyria `bpm` / `scale`, ElevenLabs `compositionPlan` /\n * `signWithC2pa`, Suno `style` / `personaId`, MiniMax `lyricsOptimizer`,\n * `instrumental` on providers that ship a wire toggle) live on each\n * provider's typed request which extends this and narrows `model`.\n *\n * Music providers are one-shot text-to-audio, not conversational. No\n * `messages[]` shape applies.\n */\nexport type CommonGenerateMusicRequest = {\n /** Model identifier. Each provider narrows. */\n readonly model: string\n /** Single prompt string. Weighted blends are provider-typed extras. */\n readonly prompt: string\n /**\n * Lyrics text, optionally with section tags like `[Verse]` /\n * `[Chorus]` / `[Bridge]` / `[Outro]`. Routed to a structured wire\n * field on providers that have one (ElevenLabs `lines`, MiniMax\n * `lyrics`, Mureka `lyrics`, Suno custom-mode `prompt`); embedded in\n * the prompt with a warning on providers without one (Lyria 3,\n * Riffusion).\n */\n readonly lyrics?: string\n /** Target duration. Provider may treat as a hint or hard limit. */\n readonly duration?: Duration.Duration\n /**\n * Reproducibility seed. Tuning hint (bucket 3): honored where the\n * provider takes one (Lyria 2 Vertex, Lyria RealTime, ElevenLabs\n * with `compositionPlan`, Stable Audio, MusicGen); silently ignored\n * elsewhere.\n */\n readonly seed?: number\n /** Preferred output format. Provider may override. */\n readonly outputFormat?: AudioFormat\n}\n\n/**\n * Streamed-output request. Same shape as the sync request: the\n * streaming variant only differs in how the response is delivered.\n */\nexport type CommonStreamGenerateMusicRequest = CommonGenerateMusicRequest\n\n/**\n * Playback-control vocabulary that converges across interactive-media\n * protocols (Web Audio, MIDI sequencer control, music SDK surfaces).\n * Provider-specific control actions (Lyria's `reset_context` and any\n * future provider's extras) live on the provider-typed session-input\n * union.\n */\nexport type MusicSessionControl = \"play\" | \"pause\" | \"stop\" | \"reset\"\n\n/**\n * Bidirectional-session input on the cross-provider surface. Two\n * load-bearing actions every interactive music session needs:\n *\n * - `prompts` — steer the active generation with a (single or\n * weighted) prompt blend.\n * - `control` — play / pause / stop / reset.\n *\n * Provider-typed services extend this union with their own `config`\n * variant for model-specific knobs (Lyria RealTime exposes density /\n * brightness / mute-stems / BPM / scale / etc. via its own\n * `LyriaRealtimeSessionInput`).\n */\nexport type MusicSessionInput =\n | { readonly _tag: \"prompts\"; readonly prompts: ReadonlyArray<WeightedPrompt> }\n | { readonly _tag: \"control\"; readonly action: MusicSessionControl }\n\nexport const promptsInput = (prompts: ReadonlyArray<WeightedPrompt>): MusicSessionInput => ({\n _tag: \"prompts\",\n prompts,\n})\n\nexport const controlInput = (action: MusicSessionControl): MusicSessionInput => ({\n _tag: \"control\",\n action,\n})\n\n/**\n * Watermark kind on the response. SynthID is mandatory on Lyria; C2PA\n * is opt-in on ElevenLabs. No provider exposes additional metadata\n * about the watermark itself, so a bare literal-union is enough.\n */\nexport type Watermark = \"synthid\" | \"c2pa\" | (string & {})\n\n/**\n * Labelled section with absolute timing. Populated when the provider\n * returns structured section metadata (Lyria text part, ElevenLabs\n * `/v1/music/detailed` with `with_timestamps`).\n */\nexport type MusicSection = {\n readonly label: string\n readonly startSeconds: number\n readonly endSeconds: number\n}\n\n/**\n * Single generated track. Composes `AudioBlob` rather than extending\n * it — `result.audio` is the raw blob, `result.songId` / `lyrics` /\n * `sections` / `watermark` are provider-side metadata when returned.\n */\nexport type MusicResult = {\n readonly audio: AudioBlob\n /**\n * Provider identifier, useful when routing through multiple\n * providers in a single pipeline (`\"lyria\"`, `\"elevenlabs-music\"`,\n * etc.).\n */\n readonly provider?: string\n /** Provider-side ID for back-reference (re-download, extension, stems). */\n readonly songId?: string\n /** Generated or transcribed lyrics when the provider returned them. */\n readonly lyrics?: string\n /** Structured section markers when the provider returned them. */\n readonly sections?: ReadonlyArray<MusicSection>\n /** Watermark presence indicator when the provider applied one. */\n readonly watermark?: Watermark\n}\n\n/**\n * Result of a `generate` call. Suno and Mureka always return 2 tracks\n * per request; every other provider returns 1. `primary` is the\n * caller-friendly convenience; `variants` carries every track the\n * provider produced (length ≥ 1; `primary === variants[0]`).\n */\nexport type GenerateResult = {\n readonly primary: MusicResult\n readonly variants: ReadonlyArray<MusicResult>\n}\n\n/**\n * In-band event on the bidirectional `streamGenerationFrom` output\n * stream. Audio chunks flow as `audio`; server-side warnings\n * (`warning`) and prompt-filter rejections (`filteredPrompt`) flow\n * alongside rather than going to a side-channel log.\n */\nexport type MusicStreamEvent =\n | { readonly _tag: \"audio\"; readonly chunk: AudioChunk }\n | { readonly _tag: \"warning\"; readonly message: string }\n | { readonly _tag: \"filteredPrompt\"; readonly prompt: string; readonly reason: string }\n\nexport const isPromptsInput = (\n i: MusicSessionInput,\n): i is MusicSessionInput & { _tag: \"prompts\" } => i._tag === \"prompts\"\nexport const isControlInput = (\n i: MusicSessionInput,\n): i is MusicSessionInput & { _tag: \"control\" } => i._tag === \"control\"\n\nexport const audioEvent = (chunk: AudioChunk): MusicStreamEvent => ({ _tag: \"audio\", chunk })\nexport const warningEvent = (message: string): MusicStreamEvent => ({\n _tag: \"warning\",\n message,\n})\nexport const filteredPromptEvent = (prompt: string, reason: string): MusicStreamEvent => ({\n _tag: \"filteredPrompt\",\n prompt,\n reason,\n})\n\nexport const isAudioEvent = (e: MusicStreamEvent): e is MusicStreamEvent & { _tag: \"audio\" } =>\n e._tag === \"audio\"\nexport const isWarningEvent = (e: MusicStreamEvent): e is MusicStreamEvent & { _tag: \"warning\" } =>\n e._tag === \"warning\"\nexport const isFilteredPromptEvent = (\n e: MusicStreamEvent,\n): e is MusicStreamEvent & { _tag: \"filteredPrompt\" } => e._tag === \"filteredPrompt\"\n\n/**\n * Build a single-variant `GenerateResult` from a `MusicResult`.\n * Convenience for providers that always return exactly one track\n * (Lyria, ElevenLabs, MiniMax, Stable Audio, MusicGen, Riffusion,\n * Tencent). Providers that return multiple tracks (Suno, Mureka)\n * construct the `GenerateResult` directly.\n */\nexport const singleVariant = (result: MusicResult): GenerateResult => ({\n primary: result,\n variants: [result],\n})\n"],"mappings":";;;;;;;;;;;;;;;AAqFA,MAAa,gBAAgB,aAA+D;CAC1F,MAAM;CACN;AACF;AAEA,MAAa,gBAAgB,YAAoD;CAC/E,MAAM;CACN;AACF;AAiEA,MAAa,kBACX,MACiD,EAAE,SAAS;AAC9D,MAAa,kBACX,MACiD,EAAE,SAAS;AAE9D,MAAa,cAAc,WAAyC;CAAE,MAAM;CAAS;AAAM;AAC3F,MAAa,gBAAgB,aAAuC;CAClE,MAAM;CACN;AACF;AACA,MAAa,uBAAuB,QAAgB,YAAsC;CACxF,MAAM;CACN;CACA;AACF;AAEA,MAAa,gBAAgB,MAC3B,EAAE,SAAS;AACb,MAAa,kBAAkB,MAC7B,EAAE,SAAS;AACb,MAAa,yBACX,MACuD,EAAE,SAAS;;;;;;;;AASpE,MAAa,iBAAiB,YAAyC;CACrE,SAAS;CACT,UAAU,CAAC,MAAM;AACnB"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { o as HistoryItem } from "../Items-
|
|
1
|
+
import { o as HistoryItem } from "../Items-SfUabNuB.mjs";
|
|
2
2
|
import { JobRef, JobState } from "../job/Job.mjs";
|
|
3
3
|
import { Turn } from "./Turn.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/domain/Research.d.ts
|
|
6
4
|
declare namespace Research_d_exports {
|
|
7
5
|
export { ResearchJobRef, ResearchRequest, ResearchState };
|
|
8
6
|
}
|
|
@@ -18,7 +16,8 @@ declare namespace Research_d_exports {
|
|
|
18
16
|
* encoding is shared.
|
|
19
17
|
*/
|
|
20
18
|
type ResearchRequest = {
|
|
21
|
-
readonly history: ReadonlyArray<HistoryItem>;
|
|
19
|
+
readonly history: ReadonlyArray<HistoryItem>;
|
|
20
|
+
/** Model / agent id. Provider default if omitted; each provider narrows. */
|
|
22
21
|
readonly model?: string;
|
|
23
22
|
};
|
|
24
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Research.d.mts","names":[],"sources":["../../src/domain/Research.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Research.d.mts","names":[],"sources":["../../src/domain/Research.ts"],"mappings":";;;;;;;;;;;;;;;;;KAmBY;WACD,SAAS,cAAc;;WAEvB;;;;;;;;;;KAgBC,iBAAiB,OAAW;;KAG5B,gBAAgB,SAAa"}
|
package/dist/domain/Research.mjs
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Duration } from "effect";
|
|
2
|
-
|
|
3
|
-
//#region src/domain/Transcript.d.ts
|
|
4
2
|
declare namespace Transcript_d_exports {
|
|
5
3
|
export { TranscriptEvent, TranscriptResult, WordTimestamp, isAudioEvent, isError, isFinal, isMetadata, isPartial, isSpeechStarted, isUtteranceEnded };
|
|
6
4
|
}
|
|
@@ -27,7 +25,8 @@ type WordTimestamp = {
|
|
|
27
25
|
*/
|
|
28
26
|
type TranscriptResult = {
|
|
29
27
|
readonly text: string;
|
|
30
|
-
readonly languageCode?: string;
|
|
28
|
+
readonly languageCode?: string;
|
|
29
|
+
/** Total audio duration. (Word offsets stay raw seconds on `WordTimestamp`.) */
|
|
31
30
|
readonly duration?: Duration.Duration;
|
|
32
31
|
readonly words?: ReadonlyArray<WordTimestamp>;
|
|
33
32
|
readonly raw?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transcript.d.mts","names":[],"sources":["../../src/domain/Transcript.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Transcript.d.mts","names":[],"sources":["../../src/domain/Transcript.ts"],"mappings":";;;;;;;;;;;;KAUY;WACD;WACA;WACA;WACA;WACA;WACA;;;;;;;KAQC;WACD;WACA;;WAEA,WAAW,SAAS;WACpB,QAAQ,cAAc;WACtB;;;;;;;;;;;;;;;;KAiBC;WAEG;WACA;WACA,QAAQ,cAAc;WACtB;;WAGA;WACA;WACA,QAAQ,cAAc;WACtB;;WAEA;WAAiC;;WACjC;WAAkC;;WAElC;WACA;WACA;WACA;;WAEA;WAA2B;;WAC3B;WAAwB;WAAwB;;cAElD,YAAS,GAAO,oBAAkB,KAAK,QAAQ;EAAmB;;cAElE,UAAO,GAAO,oBAAkB,KAAK,QAAQ;EAAmB;;cAEhE,kBAAe,GACvB,oBACF,KAAK,QAAQ;EAAmB;;cACtB,mBAAgB,GACxB,oBACF,KAAK,QAAQ;EAAmB;;cACtB,eAAY,GACpB,oBACF,KAAK,QAAQ;EAAmB;;cACtB,aAAU,GAClB,oBACF,KAAK,QAAQ;EAAmB;;cACtB,UAAO,GAAO,oBAAkB,KAAK,QAAQ;EAAmB"}
|
package/dist/domain/Turn.d.mts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { i as ImageSource } from "../Image-
|
|
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-
|
|
3
|
-
import { i as StructuredFormat, n as JsonParseError, r as StructuredDecodeError } from "../StructuredFormat-
|
|
1
|
+
import { i as ImageSource } from "../Image-BK8-4H6s.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-SfUabNuB.mjs";
|
|
3
|
+
import { i as StructuredFormat, n as JsonParseError, r as StructuredDecodeError } from "../StructuredFormat-BlZhyOsi.mjs";
|
|
4
4
|
import { Data, Effect, Schema, Stream } from "effect";
|
|
5
|
-
import * as _$effect_Cause0 from "effect/Cause";
|
|
6
|
-
import * as _$effect_Types0 from "effect/Types";
|
|
7
|
-
import * as _$effect_Unify0 from "effect/Unify";
|
|
8
|
-
|
|
9
|
-
//#region src/domain/Turn.d.ts
|
|
10
5
|
declare namespace Turn_d_exports {
|
|
11
6
|
export { InteractionEvent, RefusalRejected, Turn, TurnEvent, appendToHistory, assistantMessages, assistantText, assistantTexts, citations, decodeStructured, getToolCalls, isTurnComplete, reasonings, textDeltas };
|
|
12
7
|
}
|
|
@@ -151,50 +146,9 @@ type TurnEvent = Data.TaggedEnum<{
|
|
|
151
146
|
};
|
|
152
147
|
}>;
|
|
153
148
|
declare const TurnEvent: {
|
|
154
|
-
readonly TextDelta:
|
|
155
|
-
readonly _tag: "TextDelta";
|
|
156
|
-
readonly text: string;
|
|
157
|
-
}, "_tag">;
|
|
158
|
-
readonly ReasoningDelta: Data.TaggedEnum.ConstructorFrom<{
|
|
159
|
-
readonly _tag: "ReasoningDelta";
|
|
160
|
-
readonly text: string;
|
|
161
|
-
readonly kind: "trace" | "summary";
|
|
162
|
-
}, "_tag">;
|
|
163
|
-
readonly RefusalDelta: Data.TaggedEnum.ConstructorFrom<{
|
|
164
|
-
readonly _tag: "RefusalDelta";
|
|
165
|
-
readonly text: string;
|
|
166
|
-
}, "_tag">;
|
|
167
|
-
readonly ToolCallStart: Data.TaggedEnum.ConstructorFrom<{
|
|
168
|
-
readonly _tag: "ToolCallStart";
|
|
169
|
-
readonly call_id: string;
|
|
170
|
-
readonly name: string;
|
|
171
|
-
}, "_tag">;
|
|
172
|
-
readonly ToolCallArgsDelta: Data.TaggedEnum.ConstructorFrom<{
|
|
173
|
-
readonly _tag: "ToolCallArgsDelta";
|
|
174
|
-
readonly call_id: string;
|
|
175
|
-
readonly delta: string;
|
|
176
|
-
}, "_tag">;
|
|
177
|
-
readonly UsageUpdate: Data.TaggedEnum.ConstructorFrom<{
|
|
178
|
-
readonly _tag: "UsageUpdate";
|
|
179
|
-
readonly usage: Usage;
|
|
180
|
-
}, "_tag">;
|
|
181
|
-
readonly WebSearchCall: Data.TaggedEnum.ConstructorFrom<{
|
|
182
|
-
readonly _tag: "WebSearchCall";
|
|
183
|
-
readonly status: "started" | "searching" | "completed";
|
|
184
|
-
readonly query?: string;
|
|
185
|
-
readonly action?: "search" | "open_page" | "find_in_page";
|
|
186
|
-
}, "_tag">;
|
|
187
|
-
readonly CitationAdded: Data.TaggedEnum.ConstructorFrom<{
|
|
149
|
+
readonly $is: <Tag extends "CitationAdded" | "ReasoningDelta" | "RefusalDelta" | "TextDelta" | "ToolCallArgsDelta" | "ToolCallStart" | "TurnComplete" | "UsageUpdate" | "WebSearchCall">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
188
150
|
readonly _tag: "CitationAdded";
|
|
189
151
|
readonly annotation: Annotation;
|
|
190
|
-
}, "_tag">;
|
|
191
|
-
readonly TurnComplete: Data.TaggedEnum.ConstructorFrom<{
|
|
192
|
-
readonly _tag: "TurnComplete";
|
|
193
|
-
readonly turn: Turn;
|
|
194
|
-
}, "_tag">;
|
|
195
|
-
readonly $is: <Tag extends "TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallStart" | "ToolCallArgsDelta" | "UsageUpdate" | "WebSearchCall" | "CitationAdded" | "TurnComplete">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
196
|
-
readonly _tag: "TextDelta";
|
|
197
|
-
readonly text: string;
|
|
198
152
|
}, {
|
|
199
153
|
readonly _tag: Tag;
|
|
200
154
|
}> | Extract<{
|
|
@@ -209,9 +163,8 @@ declare const TurnEvent: {
|
|
|
209
163
|
}, {
|
|
210
164
|
readonly _tag: Tag;
|
|
211
165
|
}> | Extract<{
|
|
212
|
-
readonly _tag: "
|
|
213
|
-
readonly
|
|
214
|
-
readonly name: string;
|
|
166
|
+
readonly _tag: "TextDelta";
|
|
167
|
+
readonly text: string;
|
|
215
168
|
}, {
|
|
216
169
|
readonly _tag: Tag;
|
|
217
170
|
}> | Extract<{
|
|
@@ -221,74 +174,33 @@ declare const TurnEvent: {
|
|
|
221
174
|
}, {
|
|
222
175
|
readonly _tag: Tag;
|
|
223
176
|
}> | Extract<{
|
|
224
|
-
readonly _tag: "
|
|
225
|
-
readonly
|
|
177
|
+
readonly _tag: "ToolCallStart";
|
|
178
|
+
readonly call_id: string;
|
|
179
|
+
readonly name: string;
|
|
226
180
|
}, {
|
|
227
181
|
readonly _tag: Tag;
|
|
228
182
|
}> | Extract<{
|
|
229
|
-
readonly _tag: "
|
|
230
|
-
readonly
|
|
231
|
-
readonly query?: string;
|
|
232
|
-
readonly action?: "search" | "open_page" | "find_in_page";
|
|
183
|
+
readonly _tag: "TurnComplete";
|
|
184
|
+
readonly turn: Turn;
|
|
233
185
|
}, {
|
|
234
186
|
readonly _tag: Tag;
|
|
235
187
|
}> | Extract<{
|
|
236
|
-
readonly _tag: "
|
|
237
|
-
readonly
|
|
188
|
+
readonly _tag: "UsageUpdate";
|
|
189
|
+
readonly usage: Usage;
|
|
238
190
|
}, {
|
|
239
191
|
readonly _tag: Tag;
|
|
240
192
|
}> | Extract<{
|
|
241
|
-
readonly _tag: "
|
|
242
|
-
readonly
|
|
193
|
+
readonly _tag: "WebSearchCall";
|
|
194
|
+
readonly status: "started" | "searching" | "completed";
|
|
195
|
+
readonly query?: string;
|
|
196
|
+
readonly action?: "search" | "open_page" | "find_in_page";
|
|
243
197
|
}, {
|
|
244
198
|
readonly _tag: Tag;
|
|
245
199
|
}>;
|
|
246
200
|
readonly $match: {
|
|
247
|
-
<Cases extends {
|
|
248
|
-
readonly
|
|
249
|
-
|
|
250
|
-
readonly text: string;
|
|
251
|
-
}) => any;
|
|
252
|
-
readonly ReasoningDelta: (args: {
|
|
253
|
-
readonly _tag: "ReasoningDelta";
|
|
254
|
-
readonly text: string;
|
|
255
|
-
readonly kind: "trace" | "summary";
|
|
256
|
-
}) => any;
|
|
257
|
-
readonly RefusalDelta: (args: {
|
|
258
|
-
readonly _tag: "RefusalDelta";
|
|
259
|
-
readonly text: string;
|
|
260
|
-
}) => any;
|
|
261
|
-
readonly ToolCallStart: (args: {
|
|
262
|
-
readonly _tag: "ToolCallStart";
|
|
263
|
-
readonly call_id: string;
|
|
264
|
-
readonly name: string;
|
|
265
|
-
}) => any;
|
|
266
|
-
readonly ToolCallArgsDelta: (args: {
|
|
267
|
-
readonly _tag: "ToolCallArgsDelta";
|
|
268
|
-
readonly call_id: string;
|
|
269
|
-
readonly delta: string;
|
|
270
|
-
}) => any;
|
|
271
|
-
readonly UsageUpdate: (args: {
|
|
272
|
-
readonly _tag: "UsageUpdate";
|
|
273
|
-
readonly usage: Usage;
|
|
274
|
-
}) => any;
|
|
275
|
-
readonly WebSearchCall: (args: {
|
|
276
|
-
readonly _tag: "WebSearchCall";
|
|
277
|
-
readonly status: "started" | "searching" | "completed";
|
|
278
|
-
readonly query?: string;
|
|
279
|
-
readonly action?: "search" | "open_page" | "find_in_page";
|
|
280
|
-
}) => any;
|
|
281
|
-
readonly CitationAdded: (args: {
|
|
282
|
-
readonly _tag: "CitationAdded";
|
|
283
|
-
readonly annotation: Annotation;
|
|
284
|
-
}) => any;
|
|
285
|
-
readonly TurnComplete: (args: {
|
|
286
|
-
readonly _tag: "TurnComplete";
|
|
287
|
-
readonly turn: Turn;
|
|
288
|
-
}) => any;
|
|
289
|
-
}>(cases: Cases): (value: {
|
|
290
|
-
readonly _tag: "TextDelta";
|
|
291
|
-
readonly text: string;
|
|
201
|
+
<Cases extends { readonly [Tag in "CitationAdded" | "ReasoningDelta" | "RefusalDelta" | "TextDelta" | "ToolCallArgsDelta" | "ToolCallStart" | "TurnComplete" | "UsageUpdate" | "WebSearchCall"]: (args: Extract<{
|
|
202
|
+
readonly _tag: "CitationAdded";
|
|
203
|
+
readonly annotation: Annotation;
|
|
292
204
|
} | {
|
|
293
205
|
readonly _tag: "ReasoningDelta";
|
|
294
206
|
readonly text: string;
|
|
@@ -297,13 +209,19 @@ declare const TurnEvent: {
|
|
|
297
209
|
readonly _tag: "RefusalDelta";
|
|
298
210
|
readonly text: string;
|
|
299
211
|
} | {
|
|
300
|
-
readonly _tag: "
|
|
301
|
-
readonly
|
|
302
|
-
readonly name: string;
|
|
212
|
+
readonly _tag: "TextDelta";
|
|
213
|
+
readonly text: string;
|
|
303
214
|
} | {
|
|
304
215
|
readonly _tag: "ToolCallArgsDelta";
|
|
305
216
|
readonly call_id: string;
|
|
306
217
|
readonly delta: string;
|
|
218
|
+
} | {
|
|
219
|
+
readonly _tag: "ToolCallStart";
|
|
220
|
+
readonly call_id: string;
|
|
221
|
+
readonly name: string;
|
|
222
|
+
} | {
|
|
223
|
+
readonly _tag: "TurnComplete";
|
|
224
|
+
readonly turn: Turn;
|
|
307
225
|
} | {
|
|
308
226
|
readonly _tag: "UsageUpdate";
|
|
309
227
|
readonly usage: Usage;
|
|
@@ -312,58 +230,11 @@ declare const TurnEvent: {
|
|
|
312
230
|
readonly status: "started" | "searching" | "completed";
|
|
313
231
|
readonly query?: string;
|
|
314
232
|
readonly action?: "search" | "open_page" | "find_in_page";
|
|
315
|
-
}
|
|
233
|
+
}, {
|
|
234
|
+
readonly _tag: Tag;
|
|
235
|
+
}>) => any; }>(cases: Cases): (value: {
|
|
316
236
|
readonly _tag: "CitationAdded";
|
|
317
237
|
readonly annotation: Annotation;
|
|
318
|
-
} | {
|
|
319
|
-
readonly _tag: "TurnComplete";
|
|
320
|
-
readonly turn: Turn;
|
|
321
|
-
}) => _$effect_Unify0.Unify<ReturnType<Cases["TextDelta" | "ReasoningDelta" | "RefusalDelta" | "ToolCallStart" | "ToolCallArgsDelta" | "UsageUpdate" | "WebSearchCall" | "CitationAdded" | "TurnComplete"]>>;
|
|
322
|
-
<Cases extends {
|
|
323
|
-
readonly TextDelta: (args: {
|
|
324
|
-
readonly _tag: "TextDelta";
|
|
325
|
-
readonly text: string;
|
|
326
|
-
}) => any;
|
|
327
|
-
readonly ReasoningDelta: (args: {
|
|
328
|
-
readonly _tag: "ReasoningDelta";
|
|
329
|
-
readonly text: string;
|
|
330
|
-
readonly kind: "trace" | "summary";
|
|
331
|
-
}) => any;
|
|
332
|
-
readonly RefusalDelta: (args: {
|
|
333
|
-
readonly _tag: "RefusalDelta";
|
|
334
|
-
readonly text: string;
|
|
335
|
-
}) => any;
|
|
336
|
-
readonly ToolCallStart: (args: {
|
|
337
|
-
readonly _tag: "ToolCallStart";
|
|
338
|
-
readonly call_id: string;
|
|
339
|
-
readonly name: string;
|
|
340
|
-
}) => any;
|
|
341
|
-
readonly ToolCallArgsDelta: (args: {
|
|
342
|
-
readonly _tag: "ToolCallArgsDelta";
|
|
343
|
-
readonly call_id: string;
|
|
344
|
-
readonly delta: string;
|
|
345
|
-
}) => any;
|
|
346
|
-
readonly UsageUpdate: (args: {
|
|
347
|
-
readonly _tag: "UsageUpdate";
|
|
348
|
-
readonly usage: Usage;
|
|
349
|
-
}) => any;
|
|
350
|
-
readonly WebSearchCall: (args: {
|
|
351
|
-
readonly _tag: "WebSearchCall";
|
|
352
|
-
readonly status: "started" | "searching" | "completed";
|
|
353
|
-
readonly query?: string;
|
|
354
|
-
readonly action?: "search" | "open_page" | "find_in_page";
|
|
355
|
-
}) => any;
|
|
356
|
-
readonly CitationAdded: (args: {
|
|
357
|
-
readonly _tag: "CitationAdded";
|
|
358
|
-
readonly annotation: Annotation;
|
|
359
|
-
}) => any;
|
|
360
|
-
readonly TurnComplete: (args: {
|
|
361
|
-
readonly _tag: "TurnComplete";
|
|
362
|
-
readonly turn: Turn;
|
|
363
|
-
}) => any;
|
|
364
|
-
}>(value: {
|
|
365
|
-
readonly _tag: "TextDelta";
|
|
366
|
-
readonly text: string;
|
|
367
238
|
} | {
|
|
368
239
|
readonly _tag: "ReasoningDelta";
|
|
369
240
|
readonly text: string;
|
|
@@ -371,14 +242,53 @@ declare const TurnEvent: {
|
|
|
371
242
|
} | {
|
|
372
243
|
readonly _tag: "RefusalDelta";
|
|
373
244
|
readonly text: string;
|
|
245
|
+
} | {
|
|
246
|
+
readonly _tag: "TextDelta";
|
|
247
|
+
readonly text: string;
|
|
248
|
+
} | {
|
|
249
|
+
readonly _tag: "ToolCallArgsDelta";
|
|
250
|
+
readonly call_id: string;
|
|
251
|
+
readonly delta: string;
|
|
374
252
|
} | {
|
|
375
253
|
readonly _tag: "ToolCallStart";
|
|
376
254
|
readonly call_id: string;
|
|
377
255
|
readonly name: string;
|
|
256
|
+
} | {
|
|
257
|
+
readonly _tag: "TurnComplete";
|
|
258
|
+
readonly turn: Turn;
|
|
259
|
+
} | {
|
|
260
|
+
readonly _tag: "UsageUpdate";
|
|
261
|
+
readonly usage: Usage;
|
|
262
|
+
} | {
|
|
263
|
+
readonly _tag: "WebSearchCall";
|
|
264
|
+
readonly status: "started" | "searching" | "completed";
|
|
265
|
+
readonly query?: string;
|
|
266
|
+
readonly action?: "search" | "open_page" | "find_in_page";
|
|
267
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["CitationAdded" | "ReasoningDelta" | "RefusalDelta" | "TextDelta" | "ToolCallArgsDelta" | "ToolCallStart" | "TurnComplete" | "UsageUpdate" | "WebSearchCall"]>>;
|
|
268
|
+
<Cases extends { readonly [Tag in "CitationAdded" | "ReasoningDelta" | "RefusalDelta" | "TextDelta" | "ToolCallArgsDelta" | "ToolCallStart" | "TurnComplete" | "UsageUpdate" | "WebSearchCall"]: (args: Extract<{
|
|
269
|
+
readonly _tag: "CitationAdded";
|
|
270
|
+
readonly annotation: Annotation;
|
|
271
|
+
} | {
|
|
272
|
+
readonly _tag: "ReasoningDelta";
|
|
273
|
+
readonly text: string;
|
|
274
|
+
readonly kind: "trace" | "summary";
|
|
275
|
+
} | {
|
|
276
|
+
readonly _tag: "RefusalDelta";
|
|
277
|
+
readonly text: string;
|
|
278
|
+
} | {
|
|
279
|
+
readonly _tag: "TextDelta";
|
|
280
|
+
readonly text: string;
|
|
378
281
|
} | {
|
|
379
282
|
readonly _tag: "ToolCallArgsDelta";
|
|
380
283
|
readonly call_id: string;
|
|
381
284
|
readonly delta: string;
|
|
285
|
+
} | {
|
|
286
|
+
readonly _tag: "ToolCallStart";
|
|
287
|
+
readonly call_id: string;
|
|
288
|
+
readonly name: string;
|
|
289
|
+
} | {
|
|
290
|
+
readonly _tag: "TurnComplete";
|
|
291
|
+
readonly turn: Turn;
|
|
382
292
|
} | {
|
|
383
293
|
readonly _tag: "UsageUpdate";
|
|
384
294
|
readonly usage: Usage;
|
|
@@ -387,14 +297,83 @@ declare const TurnEvent: {
|
|
|
387
297
|
readonly status: "started" | "searching" | "completed";
|
|
388
298
|
readonly query?: string;
|
|
389
299
|
readonly action?: "search" | "open_page" | "find_in_page";
|
|
390
|
-
}
|
|
300
|
+
}, {
|
|
301
|
+
readonly _tag: Tag;
|
|
302
|
+
}>) => any; }>(value: {
|
|
391
303
|
readonly _tag: "CitationAdded";
|
|
392
304
|
readonly annotation: Annotation;
|
|
305
|
+
} | {
|
|
306
|
+
readonly _tag: "ReasoningDelta";
|
|
307
|
+
readonly text: string;
|
|
308
|
+
readonly kind: "trace" | "summary";
|
|
309
|
+
} | {
|
|
310
|
+
readonly _tag: "RefusalDelta";
|
|
311
|
+
readonly text: string;
|
|
312
|
+
} | {
|
|
313
|
+
readonly _tag: "TextDelta";
|
|
314
|
+
readonly text: string;
|
|
315
|
+
} | {
|
|
316
|
+
readonly _tag: "ToolCallArgsDelta";
|
|
317
|
+
readonly call_id: string;
|
|
318
|
+
readonly delta: string;
|
|
319
|
+
} | {
|
|
320
|
+
readonly _tag: "ToolCallStart";
|
|
321
|
+
readonly call_id: string;
|
|
322
|
+
readonly name: string;
|
|
393
323
|
} | {
|
|
394
324
|
readonly _tag: "TurnComplete";
|
|
395
325
|
readonly turn: Turn;
|
|
396
|
-
}
|
|
326
|
+
} | {
|
|
327
|
+
readonly _tag: "UsageUpdate";
|
|
328
|
+
readonly usage: Usage;
|
|
329
|
+
} | {
|
|
330
|
+
readonly _tag: "WebSearchCall";
|
|
331
|
+
readonly status: "started" | "searching" | "completed";
|
|
332
|
+
readonly query?: string;
|
|
333
|
+
readonly action?: "search" | "open_page" | "find_in_page";
|
|
334
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["CitationAdded" | "ReasoningDelta" | "RefusalDelta" | "TextDelta" | "ToolCallArgsDelta" | "ToolCallStart" | "TurnComplete" | "UsageUpdate" | "WebSearchCall"]>>;
|
|
397
335
|
};
|
|
336
|
+
readonly CitationAdded: Data.TaggedEnum.ConstructorFrom<{
|
|
337
|
+
readonly _tag: "CitationAdded";
|
|
338
|
+
readonly annotation: Annotation;
|
|
339
|
+
}, "_tag">;
|
|
340
|
+
readonly ReasoningDelta: Data.TaggedEnum.ConstructorFrom<{
|
|
341
|
+
readonly _tag: "ReasoningDelta";
|
|
342
|
+
readonly text: string;
|
|
343
|
+
readonly kind: "trace" | "summary";
|
|
344
|
+
}, "_tag">;
|
|
345
|
+
readonly RefusalDelta: Data.TaggedEnum.ConstructorFrom<{
|
|
346
|
+
readonly _tag: "RefusalDelta";
|
|
347
|
+
readonly text: string;
|
|
348
|
+
}, "_tag">;
|
|
349
|
+
readonly TextDelta: Data.TaggedEnum.ConstructorFrom<{
|
|
350
|
+
readonly _tag: "TextDelta";
|
|
351
|
+
readonly text: string;
|
|
352
|
+
}, "_tag">;
|
|
353
|
+
readonly ToolCallArgsDelta: Data.TaggedEnum.ConstructorFrom<{
|
|
354
|
+
readonly _tag: "ToolCallArgsDelta";
|
|
355
|
+
readonly call_id: string;
|
|
356
|
+
readonly delta: string;
|
|
357
|
+
}, "_tag">;
|
|
358
|
+
readonly ToolCallStart: Data.TaggedEnum.ConstructorFrom<{
|
|
359
|
+
readonly _tag: "ToolCallStart";
|
|
360
|
+
readonly call_id: string;
|
|
361
|
+
readonly name: string;
|
|
362
|
+
}, "_tag">;
|
|
363
|
+
readonly TurnComplete: Data.TaggedEnum.ConstructorFrom<{
|
|
364
|
+
readonly _tag: "TurnComplete";
|
|
365
|
+
readonly turn: Turn;
|
|
366
|
+
}, "_tag">;
|
|
367
|
+
readonly UsageUpdate: Data.TaggedEnum.ConstructorFrom<{
|
|
368
|
+
readonly _tag: "UsageUpdate";
|
|
369
|
+
readonly usage: Usage;
|
|
370
|
+
}, "_tag">;
|
|
371
|
+
readonly WebSearchCall: Data.TaggedEnum.ConstructorFrom<{
|
|
372
|
+
readonly _tag: "WebSearchCall";
|
|
373
|
+
readonly status: "started" | "searching" | "completed";
|
|
374
|
+
readonly query?: string;
|
|
375
|
+
readonly action?: "search" | "open_page" | "find_in_page";
|
|
376
|
+
}, "_tag">;
|
|
398
377
|
};
|
|
399
378
|
/**
|
|
400
379
|
* What flows out of an agent loop body to its consumer per turn: every
|
|
@@ -444,7 +423,7 @@ declare const appendToHistory: <S extends {
|
|
|
444
423
|
* `decodeJsonLines` for prompted-JSONL streaming.
|
|
445
424
|
*/
|
|
446
425
|
declare const textDeltas: <E, R>(self: Stream.Stream<TurnEvent, E, R>) => Stream.Stream<string, E, R>;
|
|
447
|
-
declare const RefusalRejected_base: new <A extends Record<string, any> = {}>(args:
|
|
426
|
+
declare const RefusalRejected_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
448
427
|
readonly _tag: "RefusalRejected";
|
|
449
428
|
} & Readonly<A>;
|
|
450
429
|
/**
|
|
@@ -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/Turn.ts"],"mappings":";;;;;;;;;;;;cAsBa,MAAI,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKL,cAAc,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6BnB,YAAY,KAAK;EAC3B;aAAsB;;EACtB;aAA2B;aAAuB;;EAClD;aAAyB;;EACzB;aAA0B;aAA0B;;EACpD;aAA8B;aAA0B;;EACxD;aAAwB,OAAO;;EAC/B;aACW;aACA;aACA;;EAEX;aAA0B,YAAY;;EACtC;aAAyB,MAAM;;;cAGpB;;;aAJ2B,YAAA;;;;;aAVL;aAAuB;;;;;aACzB;;;;;aAFH;;;;;aAIW;aAAwB;;;;;aAD5B;aAAuB;;;;;aAS3B,MAAA;;;;;aAPA,OAAA;;;;;aAEZ;aACA;aACC;;;;;;;eAEkB,YAAA;;;eAVL;eAAuB;;;eACzB;;;eAFH;;;eAIW;eAAwB;;;eAD5B;eAAuB;;;eAS3B,MAAA;;;eAPA,OAAA;;;eAEZ;eACA;eACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAEkB,YAAA;;;eAVL;eAAuB;;;eACzB;;;eAFH;;;eAIW;eAAwB;;;eAD5B;eAAuB;;;eAS3B,MAAA;;;eAPA,OAAA;;;eAEZ;eACA;eACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAEkB,YAAA;;;;aAVL;aAAuB;;;;aACzB;;;;aAFH;;;;aAIW;aAAwB;;;;aAD5B;aAAuB;;;;aAS3B,MAAA;;;;aAPA,OAAA;;;;aAEZ;aACA;aACC;;;;;;;;;KAcV,mBAAmB,YAAY;cAE9B,iBAAc,eAAA;;WAbM,MAAA;;cAepB,eAAY,MAAU,SAAO,cAAc;cAE3C,aAAU,MAAU,SAAO,cAAc;cAEzC,oBAAiB,MAAU,SAAO,cAAc;;;;;;;;cAUhD,iBAAc,MAAU,SAAO;;;;;;cAW/B,gBAAa,MAAU;;;;;;cAOvB,YAAS,MAAU,SAAO,cAAc;;;;;;cAWxC,kBAAmB;WAAqB,SAAS,cAAc;GAAc,OACjF,GAAC,MACF,MAAI,QACH,cAAc,iBACpB;;;;;;cAcU,aAAc,GAAG,GAAC,MACvB,OAAO,OAAO,WAAW,GAAG,OACjC,OAAO,eAAe,GAAG;;;;;;;;;cAcf,wBAAwB;WAC1B,MAAM;;;;;;;;;;;;cAyBJ,mBAAoB,GAAC,MAC1B,MAAI,QACF,iBAAkC,OACzC,OAAO,OACR,GACA,kBAAkB,iBAAkC"}
|
package/dist/domain/Turn.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as __exportAll } from "../
|
|
1
|
+
import { n as __exportAll } from "../rolldown-runtime-EAsCxrDo.mjs";
|
|
2
2
|
import { HistoryItem, StopReason, Usage, isOutputText, isReasoning, isRefusal, isToolCall } from "./Items.mjs";
|
|
3
3
|
import { parseJson } from "../structured-format/StructuredFormat.mjs";
|
|
4
4
|
import { Data, Effect, Result, Schema, Stream, pipe } from "effect";
|
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 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,
|
|
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,WAAW;CAC/B,OAAO;CACP,aAAa;AACf,CAAC;AA8CD,MAAa,YAAY,KAAK,WAAsB;AAUpD,MAAa,iBAAiB,UAAU,IAAI,cAAc;AAE1D,MAAa,gBAAgB,SAAwC,KAAK,MAAM,OAAO,UAAU;AAEjG,MAAa,cAAc,SAAyC,KAAK,MAAM,OAAO,WAAW;AAEjG,MAAa,qBAAqB,SAChC,KAAK,MAAM,QAAQ,MAAoB,EAAE,SAAS,aAAa,EAAE,SAAS,WAAW;;;;;;;;AASvF,MAAa,kBAAkB,SAC7B,kBAAkB,IAAI,CAAC,CACpB,SAAS,MAAM,EAAE,OAAO,CAAC,CACzB,OAAO,YAAY,CAAC,CACpB,KAAK,MAAM,EAAE,IAAI;;;;;;AAOtB,MAAa,iBAAiB,SAAuB,eAAe,IAAI,CAAC,CAAC,KAAK,EAAE;;;;;;AAOjF,MAAa,aAAa,SACxB,kBAAkB,IAAI,CAAC,CACpB,SAAS,MAAM,EAAE,OAAO,CAAC,CACzB,OAAO,YAAY,CAAC,CACpB,SAAS,MAAM,EAAE,eAAe,CAAC,CAAC;;;;;;AAOvC,MAAa,mBACX,OACA,MACA,QAAoC,CAAC,OAC9B;CACP,GAAG;CACH,SAAS;EAAC,GAAG,MAAM;EAAS,GAAG,KAAK;EAAO,GAAG;CAAK;AACrD;;;;;;AAWA,MAAa,cACX,SAEA,KAAK,KACH,OAAO,WAAW,OAAQ,GAAG,SAAS,cAAc,OAAO,QAAQ,GAAG,IAAI,IAAI,OAAO,QAAS,CAChG;;;;;;AAWF,IAAa,kBAAb,cAAqC,KAAK,YAAY,iBAAiB,CAAC,CAErE,CAAC;AAEJ,MAAM,wBAAwB,SAAqE;CACjG,MAAM,aAAa,kBAAkB,IAAI;CACzC,MAAM,OAAO,WAAW,WAAW,SAAS;CAC5C,IAAI,SAAS,KAAA,GAAW,OAAO;EAAE,MAAM;EAAI,SAAS;CAAM;CAC1D,IAAI,KAAK,QAAQ,KAAK,SAAS,GAAG,OAAO;EAAE,MAAM;EAAI,SAAS;CAAK;CAKnE,OAAO;EAAE,MAJI,KAAK,QACf,OAAO,YAAY,CAAC,CACpB,KAAK,MAAM,EAAE,IAAI,CAAC,CAClB,KAAK,EACI;EAAG,SAAS;CAAM;AAChC;;;;;;;;;;;AAYA,MAAa,oBACX,MACA,WAKA,KAAK,qBAAqB,IAAI,IAAI,EAAE,MAAM,cACxC,UAAU,OAAO,KAAK,IAAI,gBAAgB,EAAE,KAAK,CAAC,CAAC,IAAIA,UAA2B,MAAM,CAAC,CAAC,IAAI,CAChG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|