@effect-uai/core 0.12.1 → 0.14.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/{Audio-60lKKHxS.d.mts → Audio-_nGR4V0X.d.mts} +2 -2
- package/dist/{Audio-60lKKHxS.d.mts.map → Audio-_nGR4V0X.d.mts.map} +1 -1
- package/dist/Image-Cv6iBLTy.d.mts +99 -0
- package/dist/Image-Cv6iBLTy.d.mts.map +1 -0
- package/dist/{Items-SfUabNuB.d.mts → Items-C7MyrYPX.d.mts} +35 -4
- package/dist/Items-C7MyrYPX.d.mts.map +1 -0
- package/dist/Media-BbX7BAaO.d.mts +60 -0
- package/dist/Media-BbX7BAaO.d.mts.map +1 -0
- package/dist/{Tool-DE-rnvkw.d.mts → Tool-BF78QWtn.d.mts} +2 -2
- package/dist/{Tool-DE-rnvkw.d.mts.map → Tool-BF78QWtn.d.mts.map} +1 -1
- package/dist/{ToolEvent-D99MGQYH.d.mts → ToolEvent-Di4a723B.d.mts} +2 -2
- package/dist/{ToolEvent-D99MGQYH.d.mts.map → ToolEvent-Di4a723B.d.mts.map} +1 -1
- package/dist/{ToolResult-Cj8ChodL.d.mts → ToolResult-BsYQRjmW.d.mts} +2 -2
- package/dist/{ToolResult-Cj8ChodL.d.mts.map → ToolResult-BsYQRjmW.d.mts.map} +1 -1
- package/dist/{Toolkit-BEZrNPTI.d.mts → Toolkit-DAjJ9Tvl.d.mts} +5 -5
- package/dist/{Toolkit-BEZrNPTI.d.mts.map → Toolkit-DAjJ9Tvl.d.mts.map} +1 -1
- package/dist/browser/BrowserTool.d.mts +1 -1
- package/dist/capabilities/Capabilities.d.mts +26 -2
- package/dist/capabilities/Capabilities.d.mts.map +1 -1
- package/dist/capabilities/Capabilities.mjs +32 -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/domain/Audio.d.mts +1 -1
- package/dist/domain/Image.d.mts +3 -2
- package/dist/domain/Image.mjs +29 -3
- package/dist/domain/Image.mjs.map +1 -1
- package/dist/domain/Items.d.mts +2 -2
- package/dist/domain/Items.mjs +19 -1
- package/dist/domain/Items.mjs.map +1 -1
- package/dist/domain/Media.d.mts +2 -2
- package/dist/domain/Media.mjs +51 -2
- package/dist/domain/Media.mjs.map +1 -1
- package/dist/domain/Music.d.mts +3 -8
- package/dist/domain/Music.d.mts.map +1 -1
- package/dist/domain/Music.mjs.map +1 -1
- package/dist/domain/Research.d.mts +1 -1
- package/dist/domain/Turn.d.mts +73 -9
- package/dist/domain/Turn.d.mts.map +1 -1
- package/dist/domain/Turn.mjs +38 -2
- package/dist/domain/Turn.mjs.map +1 -1
- package/dist/embedding-model/Embedding.d.mts +1 -1
- package/dist/image-generator/ImageGenerator.d.mts +188 -0
- package/dist/image-generator/ImageGenerator.d.mts.map +1 -0
- package/dist/image-generator/ImageGenerator.mjs +50 -0
- package/dist/image-generator/ImageGenerator.mjs.map +1 -0
- package/dist/index.d.mts +14 -9
- package/dist/index.mjs +7 -2
- package/dist/language-model/LanguageModel.d.mts +2 -2
- package/dist/music-generator/MusicGenerator.d.mts +3 -2
- package/dist/music-generator/MusicGenerator.d.mts.map +1 -1
- package/dist/observability/Metrics.d.mts +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/speech-synthesizer/SpeechSynthesizer.d.mts +1 -1
- package/dist/streaming/Multipart.d.mts +21 -0
- package/dist/streaming/Multipart.d.mts.map +1 -0
- package/dist/streaming/Multipart.mjs +26 -0
- package/dist/streaming/Multipart.mjs.map +1 -0
- 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/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 +3 -3
- package/dist/tool/HistoryCheck.d.mts +2 -2
- package/dist/tool/Tool.d.mts +1 -1
- package/dist/tool/ToolEvent.d.mts +1 -1
- package/dist/tool/ToolResult.d.mts +1 -1
- package/dist/tool/Toolkit.d.mts +1 -1
- package/dist/transcriber/Transcriber.d.mts +1 -1
- package/dist/web-read/WebReadTool.d.mts +1 -1
- package/dist/web-search/WebSearchTool.d.mts +1 -1
- package/package.json +21 -1
- package/src/capabilities/Capabilities.ts +38 -0
- package/src/chunker/Chunker.ts +34 -0
- package/src/domain/Image.ts +68 -2
- package/src/domain/Items.ts +18 -1
- package/src/domain/Media.ts +66 -0
- package/src/domain/Music.ts +4 -3
- package/src/domain/Turn.ts +56 -0
- package/src/image-generator/ImageGenerator.ts +165 -0
- package/src/index.ts +5 -0
- package/src/reranker/Reranker.ts +51 -0
- package/src/streaming/Multipart.ts +29 -0
- package/src/tokenizer/Tokenizer.ts +19 -0
- package/dist/Image-BK8-4H6s.d.mts +0 -59
- package/dist/Image-BK8-4H6s.d.mts.map +0 -1
- package/dist/Items-SfUabNuB.d.mts.map +0 -1
- package/dist/Media-DwgpifPD.d.mts +0 -57
- package/dist/Media-DwgpifPD.d.mts.map +0 -1
package/dist/domain/Turn.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as __exportAll } from "../rolldown-runtime-EAsCxrDo.mjs";
|
|
2
|
-
import { HistoryItem, StopReason, Usage, isOutputText, isReasoning, isRefusal, isToolCall } from "./Items.mjs";
|
|
2
|
+
import { HistoryItem, StopReason, Usage, isOutputImage, 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";
|
|
5
5
|
//#region src/domain/Turn.ts
|
|
@@ -8,12 +8,14 @@ var Turn_exports = /* @__PURE__ */ __exportAll({
|
|
|
8
8
|
Turn: () => Turn,
|
|
9
9
|
TurnEvent: () => TurnEvent,
|
|
10
10
|
appendToHistory: () => appendToHistory,
|
|
11
|
+
assistantImages: () => assistantImages,
|
|
11
12
|
assistantMessages: () => assistantMessages,
|
|
12
13
|
assistantText: () => assistantText,
|
|
13
14
|
assistantTexts: () => assistantTexts,
|
|
14
15
|
citations: () => citations,
|
|
15
16
|
decodeStructured: () => decodeStructured,
|
|
16
17
|
getToolCalls: () => getToolCalls,
|
|
18
|
+
imagesAsInput: () => imagesAsInput,
|
|
17
19
|
isTurnComplete: () => isTurnComplete,
|
|
18
20
|
reasonings: () => reasonings,
|
|
19
21
|
textDeltas: () => textDeltas
|
|
@@ -48,6 +50,40 @@ const assistantTexts = (turn) => assistantMessages(turn).flatMap((m) => m.conten
|
|
|
48
50
|
*/
|
|
49
51
|
const assistantText = (turn) => assistantTexts(turn).join("");
|
|
50
52
|
/**
|
|
53
|
+
* Every image the model produced this turn, in order. The counterpart to
|
|
54
|
+
* {@link assistantTexts}: each is an `ImageSource`, so it can be written
|
|
55
|
+
* to disk or passed straight back as an `input_image` on the next turn.
|
|
56
|
+
*/
|
|
57
|
+
const assistantImages = (turn) => assistantMessages(turn).flatMap((m) => m.content).filter(isOutputImage).map((b) => b.source);
|
|
58
|
+
/**
|
|
59
|
+
* Rewrite assistant `output_image` blocks into a user message carrying
|
|
60
|
+
* the same pictures as `input_image`, so another provider can look at
|
|
61
|
+
* what this one drew.
|
|
62
|
+
*
|
|
63
|
+
* Only Gemini's wire has an assistant-role image part; every other
|
|
64
|
+
* adapter omits an `output_image` on replay and says so. Moving it to a
|
|
65
|
+
* user message is the conversion that makes it portable, and it is
|
|
66
|
+
* yours to make rather than the adapter's: "the assistant drew this" and
|
|
67
|
+
* "here is an image, look at it" are different claims, and silently
|
|
68
|
+
* swapping one for the other behind your back would be the wrong kind of
|
|
69
|
+
* helpful.
|
|
70
|
+
*
|
|
71
|
+
* Items with no images pass through untouched, and the new user message
|
|
72
|
+
* follows the assistant message it came from.
|
|
73
|
+
*/
|
|
74
|
+
const imagesAsInput = (history) => history.flatMap((item) => {
|
|
75
|
+
if (item.type !== "message" || item.role !== "assistant") return [item];
|
|
76
|
+
const images = item.content.filter(isOutputImage);
|
|
77
|
+
return images.length === 0 ? [item] : [item, {
|
|
78
|
+
type: "message",
|
|
79
|
+
role: "user",
|
|
80
|
+
content: images.map((b) => ({
|
|
81
|
+
type: "input_image",
|
|
82
|
+
source: b.source
|
|
83
|
+
}))
|
|
84
|
+
}];
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
51
87
|
* Every citation annotation attached to the turn's assistant `output_text`
|
|
52
88
|
* blocks, in order. The flat view of a grounded turn's sources, whether the
|
|
53
89
|
* turn came from a normal generation with native search or a deep-research job.
|
|
@@ -106,6 +142,6 @@ const lastAssistantContent = (turn) => {
|
|
|
106
142
|
*/
|
|
107
143
|
const decodeStructured = (turn, format) => pipe(lastAssistantContent(turn), ({ text, refused }) => refused ? Effect.fail(new RefusalRejected({ turn })) : parseJson(format)(text));
|
|
108
144
|
//#endregion
|
|
109
|
-
export { RefusalRejected, Turn, TurnEvent, appendToHistory, assistantMessages, assistantText, assistantTexts, citations, decodeStructured, getToolCalls, isTurnComplete, reasonings, Turn_exports as t, textDeltas };
|
|
145
|
+
export { RefusalRejected, Turn, TurnEvent, appendToHistory, assistantImages, assistantMessages, assistantText, assistantTexts, citations, decodeStructured, getToolCalls, imagesAsInput, isTurnComplete, reasonings, Turn_exports as t, textDeltas };
|
|
110
146
|
|
|
111
147
|
//# 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 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
|
+
{"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 type { ImageSource } from \"./Image.js\"\nimport {\n type Annotation,\n HistoryItem,\n Message,\n Reasoning,\n StopReason,\n ToolCall,\n ToolCallOutput,\n Usage,\n isOutputImage,\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 * `ImageOutput`: an image the model produced, whether it drew it as part\n * of its turn or reached a hosted tool for it. `partialIndex` marks a\n * preview frame from providers that stream them; the finished image\n * arrives without one and is also on `TurnComplete.turn` as an\n * `OutputImage` block.\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 ImageOutput: {\n readonly image: ImageSource\n /** Set only on a preview frame, counting from 0. Absent means finished. */\n readonly partialIndex?: number\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 image the model produced this turn, in order. The counterpart to\n * {@link assistantTexts}: each is an `ImageSource`, so it can be written\n * to disk or passed straight back as an `input_image` on the next turn.\n */\nexport const assistantImages = (turn: Turn): ReadonlyArray<ImageSource> =>\n assistantMessages(turn)\n .flatMap((m) => m.content)\n .filter(isOutputImage)\n .map((b) => b.source)\n\n/**\n * Rewrite assistant `output_image` blocks into a user message carrying\n * the same pictures as `input_image`, so another provider can look at\n * what this one drew.\n *\n * Only Gemini's wire has an assistant-role image part; every other\n * adapter omits an `output_image` on replay and says so. Moving it to a\n * user message is the conversion that makes it portable, and it is\n * yours to make rather than the adapter's: \"the assistant drew this\" and\n * \"here is an image, look at it\" are different claims, and silently\n * swapping one for the other behind your back would be the wrong kind of\n * helpful.\n *\n * Items with no images pass through untouched, and the new user message\n * follows the assistant message it came from.\n */\nexport const imagesAsInput = (history: ReadonlyArray<HistoryItem>): ReadonlyArray<HistoryItem> =>\n history.flatMap((item) => {\n if (item.type !== \"message\" || item.role !== \"assistant\") return [item]\n const images = item.content.filter(isOutputImage)\n return images.length === 0\n ? [item]\n : [\n item,\n {\n type: \"message\" as const,\n role: \"user\" as const,\n content: images.map((b) => ({ type: \"input_image\" as const, source: b.source })),\n },\n ]\n })\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,OAAO,OAAO,OAAO;CAChC,OAAO,OAAO,MAAM,WAAW;CAC/B,OAAO;CACP,aAAa;AACf,CAAC;AAyDD,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,mBAAmB,SAC9B,kBAAkB,IAAI,CAAC,CACpB,SAAS,MAAM,EAAE,OAAO,CAAC,CACzB,OAAO,aAAa,CAAC,CACrB,KAAK,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;AAkBxB,MAAa,iBAAiB,YAC5B,QAAQ,SAAS,SAAS;CACxB,IAAI,KAAK,SAAS,aAAa,KAAK,SAAS,aAAa,OAAO,CAAC,IAAI;CACtE,MAAM,SAAS,KAAK,QAAQ,OAAO,aAAa;CAChD,OAAO,OAAO,WAAW,IACrB,CAAC,IAAI,IACL,CACE,MACA;EACE,MAAM;EACN,MAAM;EACN,SAAS,OAAO,KAAK,OAAO;GAAE,MAAM;GAAwB,QAAQ,EAAE;EAAO,EAAE;CACjF,CACF;AACN,CAAC;;;;;;AAOH,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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as ImageSource } from "../Image-Cv6iBLTy.mjs";
|
|
2
2
|
declare namespace Embedding_d_exports {
|
|
3
3
|
export { BinaryEmbedding, EmbedContentPart, EmbedInput, Embedding, EmbeddingFor, Float32Embedding, Int8Embedding, MultivectorEmbedding, ResponseEncoding, SparseEmbedding, Usage, isBinary, isFloat32, isInt8, isMultivector, isSparse };
|
|
4
4
|
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { t as AspectRatio } from "../Media-BbX7BAaO.mjs";
|
|
2
|
+
import { a as ImageResolution, l as ProviderData, o as ImageSource, t as GeneratedImage } from "../Image-Cv6iBLTy.mjs";
|
|
3
|
+
import { t as AiError } from "../AiError-eLV9t1lU.mjs";
|
|
4
|
+
import { Context, Data, Effect, Stream } from "effect";
|
|
5
|
+
declare namespace ImageGenerator_d_exports {
|
|
6
|
+
export { AspectRatio, CommonImageEditRequest, CommonImageGenerateRequest, CommonStreamImageEditRequest, CommonStreamImageRequest, GeneratedImage, ImageGenerator, ImageGeneratorService, ImageResolution, ImageResponse, ImageStreamEvent, ImageStreaming, ImageUsage, ProviderData, edit, generate, isComplete, isPartialImage, streamEdit, streamGeneration };
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Cross-provider text-to-image request. Shape and resolution are given
|
|
10
|
+
* as a ratio plus a tier rather than exact pixels: every provider takes
|
|
11
|
+
* one or derives the other. Exact dimensions, quality tiers, output
|
|
12
|
+
* encodings, and moderation knobs are vendor-specific and live on each
|
|
13
|
+
* provider's typed request.
|
|
14
|
+
*/
|
|
15
|
+
type CommonImageGenerateRequest = {
|
|
16
|
+
readonly prompt: string;
|
|
17
|
+
/** Each provider narrows this to its typed literal union. */
|
|
18
|
+
readonly model: string;
|
|
19
|
+
readonly aspectRatio?: AspectRatio;
|
|
20
|
+
readonly resolution?: ImageResolution;
|
|
21
|
+
/** Default 1. Implementors without multi-image output fail `Unsupported` for more. */
|
|
22
|
+
readonly n?: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Edit request: the same prompt-driven generation, conditioned on
|
|
26
|
+
* reference images. Separate from `generate` because the reference set
|
|
27
|
+
* is required here and absent there, and providers expose the two as
|
|
28
|
+
* distinct wire shapes. Per-provider caps on the array length apply.
|
|
29
|
+
*/
|
|
30
|
+
type CommonImageEditRequest = CommonImageGenerateRequest & {
|
|
31
|
+
readonly images: ReadonlyArray<ImageSource>;
|
|
32
|
+
};
|
|
33
|
+
/** Gated by {@link ImageStreaming}; `partialImages` is the preview-frame count. */
|
|
34
|
+
type CommonStreamImageRequest = CommonImageGenerateRequest & {
|
|
35
|
+
readonly partialImages: 1 | 2 | 3;
|
|
36
|
+
};
|
|
37
|
+
/** The same previews, for an edit. Gated by {@link ImageStreaming}. */
|
|
38
|
+
type CommonStreamImageEditRequest = CommonImageEditRequest & {
|
|
39
|
+
readonly partialImages: 1 | 2 | 3;
|
|
40
|
+
};
|
|
41
|
+
/** Optional throughout: not every provider bills or reports per token. */
|
|
42
|
+
type ImageUsage = {
|
|
43
|
+
readonly inputTokens?: number;
|
|
44
|
+
readonly outputTokens?: number;
|
|
45
|
+
readonly totalTokens?: number;
|
|
46
|
+
};
|
|
47
|
+
type ImageResponse = {
|
|
48
|
+
readonly images: ReadonlyArray<GeneratedImage>;
|
|
49
|
+
readonly usage: ImageUsage;
|
|
50
|
+
/**
|
|
51
|
+
* Response-level extras, keyed by provider name: the seed a request
|
|
52
|
+
* resolved to, timings, safety flags. Per-image extras live on each
|
|
53
|
+
* {@link GeneratedImage} instead. See `Image.ProviderData`.
|
|
54
|
+
*/
|
|
55
|
+
readonly providerData?: ProviderData;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Zero or more `PartialImage` previews, then exactly one `Complete`.
|
|
59
|
+
* `Complete` carries the `ImageResponse` fields flat, so it is
|
|
60
|
+
* assignable to `ImageResponse` and needs no unwrapping.
|
|
61
|
+
*/
|
|
62
|
+
type ImageStreamEvent = Data.TaggedEnum<{
|
|
63
|
+
PartialImage: {
|
|
64
|
+
readonly image: ImageSource;
|
|
65
|
+
/** Counts from 0 in emission order. */
|
|
66
|
+
readonly index: number;
|
|
67
|
+
};
|
|
68
|
+
Complete: {
|
|
69
|
+
readonly images: ReadonlyArray<GeneratedImage>;
|
|
70
|
+
readonly usage: ImageUsage;
|
|
71
|
+
};
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Namespace of constructors, type guards, and matchers for
|
|
75
|
+
* `ImageStreamEvent`, provided by `Data.taggedEnum`.
|
|
76
|
+
*/
|
|
77
|
+
declare const ImageStreamEvent: {
|
|
78
|
+
readonly $is: <Tag extends "Complete" | "PartialImage">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
79
|
+
readonly _tag: "Complete";
|
|
80
|
+
readonly images: ReadonlyArray<GeneratedImage>;
|
|
81
|
+
readonly usage: ImageUsage;
|
|
82
|
+
}, {
|
|
83
|
+
readonly _tag: Tag;
|
|
84
|
+
}> | Extract<{
|
|
85
|
+
readonly _tag: "PartialImage";
|
|
86
|
+
readonly image: ImageSource;
|
|
87
|
+
readonly index: number;
|
|
88
|
+
}, {
|
|
89
|
+
readonly _tag: Tag;
|
|
90
|
+
}>;
|
|
91
|
+
readonly $match: {
|
|
92
|
+
<Cases extends { readonly [Tag in "Complete" | "PartialImage"]: (args: Extract<{
|
|
93
|
+
readonly _tag: "Complete";
|
|
94
|
+
readonly images: ReadonlyArray<GeneratedImage>;
|
|
95
|
+
readonly usage: ImageUsage;
|
|
96
|
+
} | {
|
|
97
|
+
readonly _tag: "PartialImage";
|
|
98
|
+
readonly image: ImageSource;
|
|
99
|
+
readonly index: number;
|
|
100
|
+
}, {
|
|
101
|
+
readonly _tag: Tag;
|
|
102
|
+
}>) => any; }>(cases: Cases): (value: {
|
|
103
|
+
readonly _tag: "Complete";
|
|
104
|
+
readonly images: ReadonlyArray<GeneratedImage>;
|
|
105
|
+
readonly usage: ImageUsage;
|
|
106
|
+
} | {
|
|
107
|
+
readonly _tag: "PartialImage";
|
|
108
|
+
readonly image: ImageSource;
|
|
109
|
+
readonly index: number;
|
|
110
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["Complete" | "PartialImage"]>>;
|
|
111
|
+
<Cases extends { readonly [Tag in "Complete" | "PartialImage"]: (args: Extract<{
|
|
112
|
+
readonly _tag: "Complete";
|
|
113
|
+
readonly images: ReadonlyArray<GeneratedImage>;
|
|
114
|
+
readonly usage: ImageUsage;
|
|
115
|
+
} | {
|
|
116
|
+
readonly _tag: "PartialImage";
|
|
117
|
+
readonly image: ImageSource;
|
|
118
|
+
readonly index: number;
|
|
119
|
+
}, {
|
|
120
|
+
readonly _tag: Tag;
|
|
121
|
+
}>) => any; }>(value: {
|
|
122
|
+
readonly _tag: "Complete";
|
|
123
|
+
readonly images: ReadonlyArray<GeneratedImage>;
|
|
124
|
+
readonly usage: ImageUsage;
|
|
125
|
+
} | {
|
|
126
|
+
readonly _tag: "PartialImage";
|
|
127
|
+
readonly image: ImageSource;
|
|
128
|
+
readonly index: number;
|
|
129
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Complete" | "PartialImage"]>>;
|
|
130
|
+
};
|
|
131
|
+
readonly Complete: Data.TaggedEnum.ConstructorFrom<{
|
|
132
|
+
readonly _tag: "Complete";
|
|
133
|
+
readonly images: ReadonlyArray<GeneratedImage>;
|
|
134
|
+
readonly usage: ImageUsage;
|
|
135
|
+
}, "_tag">;
|
|
136
|
+
readonly PartialImage: Data.TaggedEnum.ConstructorFrom<{
|
|
137
|
+
readonly _tag: "PartialImage";
|
|
138
|
+
readonly image: ImageSource;
|
|
139
|
+
readonly index: number;
|
|
140
|
+
}, "_tag">;
|
|
141
|
+
};
|
|
142
|
+
declare const isPartialImage: (u: unknown) => u is {
|
|
143
|
+
readonly _tag: "PartialImage";
|
|
144
|
+
readonly image: ImageSource;
|
|
145
|
+
readonly index: number;
|
|
146
|
+
};
|
|
147
|
+
declare const isComplete: (u: unknown) => u is {
|
|
148
|
+
readonly _tag: "Complete";
|
|
149
|
+
readonly images: ReadonlyArray<GeneratedImage>;
|
|
150
|
+
readonly usage: ImageUsage;
|
|
151
|
+
};
|
|
152
|
+
type ImageGeneratorService = {
|
|
153
|
+
/** Prompt in, images out. Universally supported. */
|
|
154
|
+
readonly generate: (request: CommonImageGenerateRequest) => Effect.Effect<ImageResponse, AiError>;
|
|
155
|
+
/** Prompt plus reference images in, images out. Universally supported. */
|
|
156
|
+
readonly edit: (request: CommonImageEditRequest) => Effect.Effect<ImageResponse, AiError>;
|
|
157
|
+
/**
|
|
158
|
+
* Preview frames as the image resolves, then the final response.
|
|
159
|
+
* Implementors without a partial-image wire return `Unsupported` and
|
|
160
|
+
* do NOT register {@link ImageStreaming}, so the top-level helper is
|
|
161
|
+
* a compile-time error against their Layer.
|
|
162
|
+
*/
|
|
163
|
+
readonly streamGeneration: (request: CommonStreamImageRequest) => Stream.Stream<ImageStreamEvent, AiError>;
|
|
164
|
+
/** {@link streamGeneration} conditioned on reference images. */
|
|
165
|
+
readonly streamEdit: (request: CommonStreamImageEditRequest) => Stream.Stream<ImageStreamEvent, AiError>;
|
|
166
|
+
};
|
|
167
|
+
declare const ImageGenerator_base: Context.ServiceClass<ImageGenerator, "@betalyra/effect-uai/ImageGenerator", ImageGeneratorService>;
|
|
168
|
+
declare class ImageGenerator extends ImageGenerator_base {}
|
|
169
|
+
declare const ImageStreaming_base: Context.ServiceClass<ImageStreaming, "@betalyra/effect-uai/capability/ImageStreaming", void>;
|
|
170
|
+
/**
|
|
171
|
+
* Capability marker for partial-image streaming. Phantom: the value is
|
|
172
|
+
* `void`, providers register with
|
|
173
|
+
* `Layer.succeed(ImageStreaming, undefined)`. Calling
|
|
174
|
+
* {@link streamGeneration} while only a non-streaming Layer is in scope
|
|
175
|
+
* fails at `Effect.provide` with a type error.
|
|
176
|
+
*/
|
|
177
|
+
declare class ImageStreaming extends ImageStreaming_base {}
|
|
178
|
+
/** Text to image. */
|
|
179
|
+
declare const generate: (request: CommonImageGenerateRequest) => Effect.Effect<ImageResponse, AiError, ImageGenerator>;
|
|
180
|
+
/** Text plus reference images to image. */
|
|
181
|
+
declare const edit: (request: CommonImageEditRequest) => Effect.Effect<ImageResponse, AiError, ImageGenerator>;
|
|
182
|
+
/** Preview frames then the final response. Requires {@link ImageStreaming} in R. */
|
|
183
|
+
declare const streamGeneration: (request: CommonStreamImageRequest) => Stream.Stream<ImageStreamEvent, AiError, ImageGenerator | ImageStreaming>;
|
|
184
|
+
/** The same, conditioned on reference images. Requires {@link ImageStreaming} in R. */
|
|
185
|
+
declare const streamEdit: (request: CommonStreamImageEditRequest) => Stream.Stream<ImageStreamEvent, AiError, ImageGenerator | ImageStreaming>;
|
|
186
|
+
//#endregion
|
|
187
|
+
export { type AspectRatio, CommonImageEditRequest, CommonImageGenerateRequest, CommonStreamImageEditRequest, CommonStreamImageRequest, type GeneratedImage, ImageGenerator, ImageGeneratorService, type ImageResolution, ImageResponse, ImageStreamEvent, ImageStreaming, ImageUsage, type ProviderData, edit, generate, isComplete, isPartialImage, streamEdit, streamGeneration, ImageGenerator_d_exports as t };
|
|
188
|
+
//# sourceMappingURL=ImageGenerator.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageGenerator.d.mts","names":[],"sources":["../../src/image-generator/ImageGenerator.ts"],"mappings":";;;;;;;;;;;;;;KAmBY;WACD;;WAEA;WACA,cAAc;WACd,aAAa;;WAEb;;;;;;;;KASC,yBAAyB;WAC1B,QAAQ,cAAc;;;KAIrB,2BAA2B;WAC5B;;;KAIC,+BAA+B;WAChC;;;KAIC;WACD;WACA;WACA;;KAGC;WACD,QAAQ,cAAc;WACtB,OAAO;;;;;;WAMP,eAAe;;;;;;;KAQd,mBAAmB,KAAK;EAClC;aACW,OAAO;;aAEP;;EAEX;aACW,QAAQ,cAAc;aACtB,OAAO;;;;;;;cAQP;;;aATQ,QAAA,cAAc;aACf,OAAA;;;;;aANA,OAAA;aAEA;;;;;;;eAGC,QAAA,cAAc;eACf,OAAA;;;eANA,OAAA;eAEA;;;;;;;;;;;;;;eAGC,QAAA,cAAc;eACf,OAAA;;;eANA,OAAA;eAEA;;;;;;;;;;;;;;;aAGC,QAAA,cAAc;aACf,OAAA;;;;aANA,OAAA;aAEA;;;cAcP,iBAAc,eAAA;;WAhBP,OAAA;WAEA;;cAeP,aAAU,eAAA;;WAZF,QAAA,cAAc;WACf,OAAA;;KAaR;;WAED,WACP,SAAS,+BACN,OAAO,OAAO,eAAe;;WAEzB,OAAO,SAAS,2BAA2B,OAAO,OAAO,eAAe;;;;;;;WAOxE,mBACP,SAAS,6BACN,OAAO,OAAO,kBAAkB;;WAE5B,aACP,SAAS,iCACN,OAAO,OAAO,kBAAkB;;;cAG1B,uBAAuB;;;;;;;;;cAWvB,uBAAuB;;cAKvB,WAAQ,SACV,+BACR,OAAO,OAAO,eAAe,SAAiB;;cAIpC,OAAI,SACN,2BACR,OAAO,OAAO,eAAe,SAAiB;;cAIpC,mBAAgB,SAClB,6BACR,OAAO,OAAO,kBAAkB,SAAiB,iBAAiB;;cAUxD,aAAU,SACZ,iCACR,OAAO,OAAO,kBAAkB,SAAiB,iBAAiB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { n as __exportAll } from "../rolldown-runtime-EAsCxrDo.mjs";
|
|
2
|
+
import { Context, Data, Effect, Stream } from "effect";
|
|
3
|
+
//#region src/image-generator/ImageGenerator.ts
|
|
4
|
+
var ImageGenerator_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
ImageGenerator: () => ImageGenerator,
|
|
6
|
+
ImageStreamEvent: () => ImageStreamEvent,
|
|
7
|
+
ImageStreaming: () => ImageStreaming,
|
|
8
|
+
edit: () => edit,
|
|
9
|
+
generate: () => generate,
|
|
10
|
+
isComplete: () => isComplete,
|
|
11
|
+
isPartialImage: () => isPartialImage,
|
|
12
|
+
streamEdit: () => streamEdit,
|
|
13
|
+
streamGeneration: () => streamGeneration
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Namespace of constructors, type guards, and matchers for
|
|
17
|
+
* `ImageStreamEvent`, provided by `Data.taggedEnum`.
|
|
18
|
+
*/
|
|
19
|
+
const ImageStreamEvent = Data.taggedEnum();
|
|
20
|
+
const isPartialImage = ImageStreamEvent.$is("PartialImage");
|
|
21
|
+
const isComplete = ImageStreamEvent.$is("Complete");
|
|
22
|
+
var ImageGenerator = class extends Context.Service()("@betalyra/effect-uai/ImageGenerator") {};
|
|
23
|
+
/**
|
|
24
|
+
* Capability marker for partial-image streaming. Phantom: the value is
|
|
25
|
+
* `void`, providers register with
|
|
26
|
+
* `Layer.succeed(ImageStreaming, undefined)`. Calling
|
|
27
|
+
* {@link streamGeneration} while only a non-streaming Layer is in scope
|
|
28
|
+
* fails at `Effect.provide` with a type error.
|
|
29
|
+
*/
|
|
30
|
+
var ImageStreaming = class extends Context.Service()("@betalyra/effect-uai/capability/ImageStreaming") {};
|
|
31
|
+
/** Text to image. */
|
|
32
|
+
const generate = (request) => Effect.flatMap(ImageGenerator, (g) => g.generate(request));
|
|
33
|
+
/** Text plus reference images to image. */
|
|
34
|
+
const edit = (request) => Effect.flatMap(ImageGenerator, (g) => g.edit(request));
|
|
35
|
+
/** Preview frames then the final response. Requires {@link ImageStreaming} in R. */
|
|
36
|
+
const streamGeneration = (request) => Stream.unwrap(Effect.gen(function* () {
|
|
37
|
+
const g = yield* ImageGenerator;
|
|
38
|
+
yield* ImageStreaming;
|
|
39
|
+
return g.streamGeneration(request);
|
|
40
|
+
}));
|
|
41
|
+
/** The same, conditioned on reference images. Requires {@link ImageStreaming} in R. */
|
|
42
|
+
const streamEdit = (request) => Stream.unwrap(Effect.gen(function* () {
|
|
43
|
+
const g = yield* ImageGenerator;
|
|
44
|
+
yield* ImageStreaming;
|
|
45
|
+
return g.streamEdit(request);
|
|
46
|
+
}));
|
|
47
|
+
//#endregion
|
|
48
|
+
export { ImageGenerator, ImageStreamEvent, ImageStreaming, edit, generate, isComplete, isPartialImage, streamEdit, streamGeneration, ImageGenerator_exports as t };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=ImageGenerator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageGenerator.mjs","names":[],"sources":["../../src/image-generator/ImageGenerator.ts"],"sourcesContent":["import { Context, Data, Effect, Stream } from \"effect\"\nimport type * as AiError from \"../domain/AiError.js\"\nimport type {\n AspectRatio,\n GeneratedImage,\n ImageResolution,\n ImageSource,\n ProviderData,\n} from \"../domain/Image.js\"\n\nexport type { AspectRatio, GeneratedImage, ImageResolution, ProviderData } from \"../domain/Image.js\"\n\n/**\n * Cross-provider text-to-image request. Shape and resolution are given\n * as a ratio plus a tier rather than exact pixels: every provider takes\n * one or derives the other. Exact dimensions, quality tiers, output\n * encodings, and moderation knobs are vendor-specific and live on each\n * provider's typed request.\n */\nexport type CommonImageGenerateRequest = {\n readonly prompt: string\n /** Each provider narrows this to its typed literal union. */\n readonly model: string\n readonly aspectRatio?: AspectRatio\n readonly resolution?: ImageResolution\n /** Default 1. Implementors without multi-image output fail `Unsupported` for more. */\n readonly n?: number\n}\n\n/**\n * Edit request: the same prompt-driven generation, conditioned on\n * reference images. Separate from `generate` because the reference set\n * is required here and absent there, and providers expose the two as\n * distinct wire shapes. Per-provider caps on the array length apply.\n */\nexport type CommonImageEditRequest = CommonImageGenerateRequest & {\n readonly images: ReadonlyArray<ImageSource>\n}\n\n/** Gated by {@link ImageStreaming}; `partialImages` is the preview-frame count. */\nexport type CommonStreamImageRequest = CommonImageGenerateRequest & {\n readonly partialImages: 1 | 2 | 3\n}\n\n/** The same previews, for an edit. Gated by {@link ImageStreaming}. */\nexport type CommonStreamImageEditRequest = CommonImageEditRequest & {\n readonly partialImages: 1 | 2 | 3\n}\n\n/** Optional throughout: not every provider bills or reports per token. */\nexport type ImageUsage = {\n readonly inputTokens?: number\n readonly outputTokens?: number\n readonly totalTokens?: number\n}\n\nexport type ImageResponse = {\n readonly images: ReadonlyArray<GeneratedImage>\n readonly usage: ImageUsage\n /**\n * Response-level extras, keyed by provider name: the seed a request\n * resolved to, timings, safety flags. Per-image extras live on each\n * {@link GeneratedImage} instead. See `Image.ProviderData`.\n */\n readonly providerData?: ProviderData\n}\n\n/**\n * Zero or more `PartialImage` previews, then exactly one `Complete`.\n * `Complete` carries the `ImageResponse` fields flat, so it is\n * assignable to `ImageResponse` and needs no unwrapping.\n */\nexport type ImageStreamEvent = Data.TaggedEnum<{\n PartialImage: {\n readonly image: ImageSource\n /** Counts from 0 in emission order. */\n readonly index: number\n }\n Complete: {\n readonly images: ReadonlyArray<GeneratedImage>\n readonly usage: ImageUsage\n }\n}>\n\n/**\n * Namespace of constructors, type guards, and matchers for\n * `ImageStreamEvent`, provided by `Data.taggedEnum`.\n */\nexport const ImageStreamEvent = Data.taggedEnum<ImageStreamEvent>()\n\nexport const isPartialImage = ImageStreamEvent.$is(\"PartialImage\")\nexport const isComplete = ImageStreamEvent.$is(\"Complete\")\n\nexport type ImageGeneratorService = {\n /** Prompt in, images out. Universally supported. */\n readonly generate: (\n request: CommonImageGenerateRequest,\n ) => Effect.Effect<ImageResponse, AiError.AiError>\n /** Prompt plus reference images in, images out. Universally supported. */\n readonly edit: (request: CommonImageEditRequest) => Effect.Effect<ImageResponse, AiError.AiError>\n /**\n * Preview frames as the image resolves, then the final response.\n * Implementors without a partial-image wire return `Unsupported` and\n * do NOT register {@link ImageStreaming}, so the top-level helper is\n * a compile-time error against their Layer.\n */\n readonly streamGeneration: (\n request: CommonStreamImageRequest,\n ) => Stream.Stream<ImageStreamEvent, AiError.AiError>\n /** {@link streamGeneration} conditioned on reference images. */\n readonly streamEdit: (\n request: CommonStreamImageEditRequest,\n ) => Stream.Stream<ImageStreamEvent, AiError.AiError>\n}\n\nexport class ImageGenerator extends Context.Service<ImageGenerator, ImageGeneratorService>()(\n \"@betalyra/effect-uai/ImageGenerator\",\n) {}\n\n/**\n * Capability marker for partial-image streaming. Phantom: the value is\n * `void`, providers register with\n * `Layer.succeed(ImageStreaming, undefined)`. Calling\n * {@link streamGeneration} while only a non-streaming Layer is in scope\n * fails at `Effect.provide` with a type error.\n */\nexport class ImageStreaming extends Context.Service<ImageStreaming, void>()(\n \"@betalyra/effect-uai/capability/ImageStreaming\",\n) {}\n\n/** Text to image. */\nexport const generate = (\n request: CommonImageGenerateRequest,\n): Effect.Effect<ImageResponse, AiError.AiError, ImageGenerator> =>\n Effect.flatMap(ImageGenerator, (g) => g.generate(request))\n\n/** Text plus reference images to image. */\nexport const edit = (\n request: CommonImageEditRequest,\n): Effect.Effect<ImageResponse, AiError.AiError, ImageGenerator> =>\n Effect.flatMap(ImageGenerator, (g) => g.edit(request))\n\n/** Preview frames then the final response. Requires {@link ImageStreaming} in R. */\nexport const streamGeneration = (\n request: CommonStreamImageRequest,\n): Stream.Stream<ImageStreamEvent, AiError.AiError, ImageGenerator | ImageStreaming> =>\n Stream.unwrap(\n Effect.gen(function* () {\n const g = yield* ImageGenerator\n yield* ImageStreaming\n return g.streamGeneration(request)\n }),\n )\n\n/** The same, conditioned on reference images. Requires {@link ImageStreaming} in R. */\nexport const streamEdit = (\n request: CommonStreamImageEditRequest,\n): Stream.Stream<ImageStreamEvent, AiError.AiError, ImageGenerator | ImageStreaming> =>\n Stream.unwrap(\n Effect.gen(function* () {\n const g = yield* ImageGenerator\n yield* ImageStreaming\n return g.streamEdit(request)\n }),\n )\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwFA,MAAa,mBAAmB,KAAK,WAA6B;AAElE,MAAa,iBAAiB,iBAAiB,IAAI,cAAc;AACjE,MAAa,aAAa,iBAAiB,IAAI,UAAU;AAwBzD,IAAa,iBAAb,cAAoC,QAAQ,QAA+C,CAAC,CAC1F,qCACF,CAAC,CAAC,CAAC;;;;;;;;AASH,IAAa,iBAAb,cAAoC,QAAQ,QAA8B,CAAC,CACzE,gDACF,CAAC,CAAC,CAAC;;AAGH,MAAa,YACX,YAEA,OAAO,QAAQ,iBAAiB,MAAM,EAAE,SAAS,OAAO,CAAC;;AAG3D,MAAa,QACX,YAEA,OAAO,QAAQ,iBAAiB,MAAM,EAAE,KAAK,OAAO,CAAC;;AAGvD,MAAa,oBACX,YAEA,OAAO,OACL,OAAO,IAAI,aAAa;CACtB,MAAM,IAAI,OAAO;CACjB,OAAO;CACP,OAAO,EAAE,iBAAiB,OAAO;AACnC,CAAC,CACH;;AAGF,MAAa,cACX,YAEA,OAAO,OACL,OAAO,IAAI,aAAa;CACtB,MAAM,IAAI,OAAO;CACjB,OAAO;CACP,OAAO,EAAE,WAAW,OAAO;AAC7B,CAAC,CACH"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { t as BrowserError_d_exports } from "./browser/BrowserError.mjs";
|
|
2
2
|
import { t as Browser_d_exports } from "./browser/Browser.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { u as Items_d_exports } from "./Items-
|
|
6
|
-
import { _ as Tool_d_exports } from "./Tool-
|
|
3
|
+
import { s as Media_d_exports } from "./Media-BbX7BAaO.mjs";
|
|
4
|
+
import { c as Image_d_exports } from "./Image-Cv6iBLTy.mjs";
|
|
5
|
+
import { u as Items_d_exports } from "./Items-C7MyrYPX.mjs";
|
|
6
|
+
import { _ as Tool_d_exports } from "./Tool-BF78QWtn.mjs";
|
|
7
7
|
import { t as BrowserTool_d_exports } from "./browser/BrowserTool.mjs";
|
|
8
8
|
import { t as Capabilities_d_exports } from "./capabilities/Capabilities.mjs";
|
|
9
9
|
import { n as AiError_d_exports } from "./AiError-eLV9t1lU.mjs";
|
|
10
|
-
import {
|
|
10
|
+
import { t as Chunker_d_exports } from "./chunker/Chunker.mjs";
|
|
11
|
+
import { o as Audio_d_exports } from "./Audio-_nGR4V0X.mjs";
|
|
11
12
|
import { t as Citation_d_exports } from "./domain/Citation.mjs";
|
|
12
13
|
import { t as Music_d_exports } from "./domain/Music.mjs";
|
|
13
14
|
import { t as Job_d_exports } from "./job/Job.mjs";
|
|
@@ -17,13 +18,15 @@ import { t as Research_d_exports } from "./domain/Research.mjs";
|
|
|
17
18
|
import { t as Transcript_d_exports } from "./domain/Transcript.mjs";
|
|
18
19
|
import { t as Embedding_d_exports } from "./embedding-model/Embedding.mjs";
|
|
19
20
|
import { t as EmbeddingModel_d_exports } from "./embedding-model/EmbeddingModel.mjs";
|
|
21
|
+
import { t as ImageGenerator_d_exports } from "./image-generator/ImageGenerator.mjs";
|
|
20
22
|
import { t as DeepResearch_d_exports } from "./research/DeepResearch.mjs";
|
|
21
23
|
import { t as Loop_d_exports } from "./Loop-B54AB1ME.mjs";
|
|
22
|
-
import { n as ToolResult_d_exports } from "./ToolResult-
|
|
23
|
-
import { n as ToolEvent_d_exports } from "./ToolEvent-
|
|
24
|
-
import { l as Toolkit_d_exports } from "./Toolkit-
|
|
24
|
+
import { n as ToolResult_d_exports } from "./ToolResult-BsYQRjmW.mjs";
|
|
25
|
+
import { n as ToolEvent_d_exports } from "./ToolEvent-Di4a723B.mjs";
|
|
26
|
+
import { l as Toolkit_d_exports } from "./Toolkit-DAjJ9Tvl.mjs";
|
|
25
27
|
import { t as LanguageModel_d_exports } from "./language-model/LanguageModel.mjs";
|
|
26
28
|
import { t as MusicGenerator_d_exports } from "./music-generator/MusicGenerator.mjs";
|
|
29
|
+
import { t as Reranker_d_exports } from "./reranker/Reranker.mjs";
|
|
27
30
|
import { t as Memory_d_exports } from "./sandbox/Memory.mjs";
|
|
28
31
|
import { o as SandboxError_d_exports } from "./SandboxError-BN8b28Bh.mjs";
|
|
29
32
|
import { t as Sandbox_d_exports } from "./sandbox/Sandbox.mjs";
|
|
@@ -36,12 +39,14 @@ import { t as WebReadTool_d_exports } from "./web-read/WebReadTool.mjs";
|
|
|
36
39
|
import { t as WebSearch_d_exports } from "./web-search/WebSearch.mjs";
|
|
37
40
|
import { t as WebSearchTool_d_exports } from "./web-search/WebSearchTool.mjs";
|
|
38
41
|
import { t as Vector_d_exports } from "./math/Vector.mjs";
|
|
42
|
+
import { t as Tokenizer_d_exports } from "./tokenizer/Tokenizer.mjs";
|
|
39
43
|
import { t as Retry_d_exports } from "./retry/Retry.mjs";
|
|
40
44
|
import { t as Approval_d_exports } from "./tool/Approval.mjs";
|
|
41
45
|
import { t as HistoryCheck_d_exports } from "./tool/HistoryCheck.mjs";
|
|
42
46
|
import { t as JSONL_d_exports } from "./streaming/JSONL.mjs";
|
|
43
47
|
import { t as Lines_d_exports } from "./streaming/Lines.mjs";
|
|
48
|
+
import { t as Multipart_d_exports } from "./streaming/Multipart.mjs";
|
|
44
49
|
import { t as SSE_d_exports } from "./streaming/SSE.mjs";
|
|
45
50
|
import { t as Metrics_d_exports } from "./observability/Metrics.mjs";
|
|
46
51
|
import { t as Telemetry_d_exports } from "./observability/Telemetry.mjs";
|
|
47
|
-
export { AiError_d_exports as AiError, Approval_d_exports as Approval, Audio_d_exports as Audio, Browser_d_exports as Browser, BrowserError_d_exports as BrowserError, BrowserTool_d_exports as BrowserTool, Capabilities_d_exports as Capabilities, Citation_d_exports as Citation, DeepResearch_d_exports as DeepResearch, Embedding_d_exports as Embedding, EmbeddingModel_d_exports as EmbeddingModel, HistoryCheck_d_exports as HistoryCheck, Image_d_exports as Image, Items_d_exports as Items, JSONL_d_exports as JSONL, Job_d_exports as Job, LanguageModel_d_exports as LanguageModel, Lines_d_exports as Lines, Loop_d_exports as Loop, Media_d_exports as Media, Memory_d_exports as Memory, Metrics_d_exports as Metrics, Music_d_exports as Music, MusicGenerator_d_exports as MusicGenerator, Research_d_exports as Research, Retry_d_exports as Retry, SSE_d_exports as SSE, Sandbox_d_exports as Sandbox, SandboxError_d_exports as SandboxError, SandboxImage_d_exports as SandboxImage, SandboxNetwork_d_exports as SandboxNetwork, SpeechSynthesizer_d_exports as SpeechSynthesizer, StructuredFormat_d_exports as StructuredFormat, Telemetry_d_exports as Telemetry, Tool_d_exports as Tool, ToolEvent_d_exports as ToolEvent, ToolResult_d_exports as ToolResult, Toolkit_d_exports as Toolkit, Transcriber_d_exports as Transcriber, Transcript_d_exports as Transcript, Turn_d_exports as Turn, Vector_d_exports as Vector, WebRead_d_exports as WebRead, WebReadTool_d_exports as WebReadTool, WebSearch_d_exports as WebSearch, WebSearchTool_d_exports as WebSearchTool };
|
|
52
|
+
export { AiError_d_exports as AiError, Approval_d_exports as Approval, Audio_d_exports as Audio, Browser_d_exports as Browser, BrowserError_d_exports as BrowserError, BrowserTool_d_exports as BrowserTool, Capabilities_d_exports as Capabilities, Chunker_d_exports as Chunker, Citation_d_exports as Citation, DeepResearch_d_exports as DeepResearch, Embedding_d_exports as Embedding, EmbeddingModel_d_exports as EmbeddingModel, HistoryCheck_d_exports as HistoryCheck, Image_d_exports as Image, ImageGenerator_d_exports as ImageGenerator, Items_d_exports as Items, JSONL_d_exports as JSONL, Job_d_exports as Job, LanguageModel_d_exports as LanguageModel, Lines_d_exports as Lines, Loop_d_exports as Loop, Media_d_exports as Media, Memory_d_exports as Memory, Metrics_d_exports as Metrics, Multipart_d_exports as Multipart, Music_d_exports as Music, MusicGenerator_d_exports as MusicGenerator, Reranker_d_exports as Reranker, Research_d_exports as Research, Retry_d_exports as Retry, SSE_d_exports as SSE, Sandbox_d_exports as Sandbox, SandboxError_d_exports as SandboxError, SandboxImage_d_exports as SandboxImage, SandboxNetwork_d_exports as SandboxNetwork, SpeechSynthesizer_d_exports as SpeechSynthesizer, StructuredFormat_d_exports as StructuredFormat, Telemetry_d_exports as Telemetry, Tokenizer_d_exports as Tokenizer, Tool_d_exports as Tool, ToolEvent_d_exports as ToolEvent, ToolResult_d_exports as ToolResult, Toolkit_d_exports as Toolkit, Transcriber_d_exports as Transcriber, Transcript_d_exports as Transcript, Turn_d_exports as Turn, Vector_d_exports as Vector, WebRead_d_exports as WebRead, WebReadTool_d_exports as WebReadTool, WebSearch_d_exports as WebSearch, WebSearchTool_d_exports as WebSearchTool };
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { t as AiError_exports } from "./domain/AiError.mjs";
|
|
|
2
2
|
import { t as Audio_exports } from "./domain/Audio.mjs";
|
|
3
3
|
import { t as Browser_exports } from "./browser/Browser.mjs";
|
|
4
4
|
import { t as BrowserError_exports } from "./browser/BrowserError.mjs";
|
|
5
|
+
import { t as Media_exports } from "./domain/Media.mjs";
|
|
5
6
|
import { t as Image_exports } from "./domain/Image.mjs";
|
|
6
7
|
import { t as Items_exports } from "./domain/Items.mjs";
|
|
7
8
|
import { t as ToolResult_exports } from "./tool/ToolResult.mjs";
|
|
@@ -13,17 +14,19 @@ import { t as ToolEvent_exports } from "./tool/ToolEvent.mjs";
|
|
|
13
14
|
import { t as Toolkit_exports } from "./tool/Toolkit.mjs";
|
|
14
15
|
import { t as BrowserTool_exports } from "./browser/BrowserTool.mjs";
|
|
15
16
|
import { t as Capabilities_exports } from "./capabilities/Capabilities.mjs";
|
|
17
|
+
import { t as Chunker_exports } from "./chunker/Chunker.mjs";
|
|
16
18
|
import { t as Citation_exports } from "./domain/Citation.mjs";
|
|
17
19
|
import { t as Job_exports } from "./job/Job.mjs";
|
|
18
20
|
import { t as DeepResearch_exports } from "./research/DeepResearch.mjs";
|
|
19
|
-
import { t as Media_exports } from "./domain/Media.mjs";
|
|
20
21
|
import { t as Music_exports } from "./domain/Music.mjs";
|
|
21
22
|
import { t as Research_exports } from "./domain/Research.mjs";
|
|
22
23
|
import { t as Transcript_exports } from "./domain/Transcript.mjs";
|
|
23
24
|
import { t as Embedding_exports } from "./embedding-model/Embedding.mjs";
|
|
24
25
|
import { t as EmbeddingModel_exports } from "./embedding-model/EmbeddingModel.mjs";
|
|
26
|
+
import { t as ImageGenerator_exports } from "./image-generator/ImageGenerator.mjs";
|
|
25
27
|
import { t as LanguageModel_exports } from "./language-model/LanguageModel.mjs";
|
|
26
28
|
import { t as MusicGenerator_exports } from "./music-generator/MusicGenerator.mjs";
|
|
29
|
+
import { t as Reranker_exports } from "./reranker/Reranker.mjs";
|
|
27
30
|
import { t as Memory_exports } from "./sandbox/Memory.mjs";
|
|
28
31
|
import { t as Sandbox_exports } from "./sandbox/Sandbox.mjs";
|
|
29
32
|
import { t as SandboxError_exports } from "./sandbox/SandboxError.mjs";
|
|
@@ -36,12 +39,14 @@ import { t as WebReadTool_exports } from "./web-read/WebReadTool.mjs";
|
|
|
36
39
|
import { t as WebSearch_exports } from "./web-search/WebSearch.mjs";
|
|
37
40
|
import { t as WebSearchTool_exports } from "./web-search/WebSearchTool.mjs";
|
|
38
41
|
import { t as Vector_exports } from "./math/Vector.mjs";
|
|
42
|
+
import { t as Tokenizer_exports } from "./tokenizer/Tokenizer.mjs";
|
|
39
43
|
import { t as Retry_exports } from "./retry/Retry.mjs";
|
|
40
44
|
import { t as Approval_exports } from "./tool/Approval.mjs";
|
|
41
45
|
import { t as HistoryCheck_exports } from "./tool/HistoryCheck.mjs";
|
|
42
46
|
import { t as JSONL_exports } from "./streaming/JSONL.mjs";
|
|
43
47
|
import { t as Lines_exports } from "./streaming/Lines.mjs";
|
|
48
|
+
import { t as Multipart_exports } from "./streaming/Multipart.mjs";
|
|
44
49
|
import { t as SSE_exports } from "./streaming/SSE.mjs";
|
|
45
50
|
import { t as Metrics_exports } from "./observability/Metrics.mjs";
|
|
46
51
|
import { t as Telemetry_exports } from "./observability/Telemetry.mjs";
|
|
47
|
-
export { AiError_exports as AiError, Approval_exports as Approval, Audio_exports as Audio, Browser_exports as Browser, BrowserError_exports as BrowserError, BrowserTool_exports as BrowserTool, Capabilities_exports as Capabilities, Citation_exports as Citation, DeepResearch_exports as DeepResearch, Embedding_exports as Embedding, EmbeddingModel_exports as EmbeddingModel, HistoryCheck_exports as HistoryCheck, Image_exports as Image, Items_exports as Items, JSONL_exports as JSONL, Job_exports as Job, LanguageModel_exports as LanguageModel, Lines_exports as Lines, Loop_exports as Loop, Media_exports as Media, Memory_exports as Memory, Metrics_exports as Metrics, Music_exports as Music, MusicGenerator_exports as MusicGenerator, Research_exports as Research, Retry_exports as Retry, SSE_exports as SSE, Sandbox_exports as Sandbox, SandboxError_exports as SandboxError, SandboxImage_exports as SandboxImage, SandboxNetwork_exports as SandboxNetwork, SpeechSynthesizer_exports as SpeechSynthesizer, StructuredFormat_exports as StructuredFormat, Telemetry_exports as Telemetry, Tool_exports as Tool, ToolEvent_exports as ToolEvent, ToolResult_exports as ToolResult, Toolkit_exports as Toolkit, Transcriber_exports as Transcriber, Transcript_exports as Transcript, Turn_exports as Turn, Vector_exports as Vector, WebRead_exports as WebRead, WebReadTool_exports as WebReadTool, WebSearch_exports as WebSearch, WebSearchTool_exports as WebSearchTool };
|
|
52
|
+
export { AiError_exports as AiError, Approval_exports as Approval, Audio_exports as Audio, Browser_exports as Browser, BrowserError_exports as BrowserError, BrowserTool_exports as BrowserTool, Capabilities_exports as Capabilities, Chunker_exports as Chunker, Citation_exports as Citation, DeepResearch_exports as DeepResearch, Embedding_exports as Embedding, EmbeddingModel_exports as EmbeddingModel, HistoryCheck_exports as HistoryCheck, Image_exports as Image, ImageGenerator_exports as ImageGenerator, Items_exports as Items, JSONL_exports as JSONL, Job_exports as Job, LanguageModel_exports as LanguageModel, Lines_exports as Lines, Loop_exports as Loop, Media_exports as Media, Memory_exports as Memory, Metrics_exports as Metrics, Multipart_exports as Multipart, Music_exports as Music, MusicGenerator_exports as MusicGenerator, Reranker_exports as Reranker, Research_exports as Research, Retry_exports as Retry, SSE_exports as SSE, Sandbox_exports as Sandbox, SandboxError_exports as SandboxError, SandboxImage_exports as SandboxImage, SandboxNetwork_exports as SandboxNetwork, SpeechSynthesizer_exports as SpeechSynthesizer, StructuredFormat_exports as StructuredFormat, Telemetry_exports as Telemetry, Tokenizer_exports as Tokenizer, Tool_exports as Tool, ToolEvent_exports as ToolEvent, ToolResult_exports as ToolResult, Toolkit_exports as Toolkit, Transcriber_exports as Transcriber, Transcript_exports as Transcript, Turn_exports as Turn, Vector_exports as Vector, WebRead_exports as WebRead, WebReadTool_exports as WebReadTool, WebSearch_exports as WebSearch, WebSearchTool_exports as WebSearchTool };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { o as HistoryItem } from "../Items-
|
|
1
|
+
import { o as HistoryItem } from "../Items-C7MyrYPX.mjs";
|
|
2
2
|
import { t as AiError } from "../AiError-eLV9t1lU.mjs";
|
|
3
3
|
import { i as StructuredFormat } from "../StructuredFormat-BlZhyOsi.mjs";
|
|
4
4
|
import { Turn, TurnEvent } from "../domain/Turn.mjs";
|
|
5
|
-
import { o as Toolkit } from "../Toolkit-
|
|
5
|
+
import { o as Toolkit } from "../Toolkit-DAjJ9Tvl.mjs";
|
|
6
6
|
import { Context, Effect, Stream } from "effect";
|
|
7
7
|
declare namespace LanguageModel_d_exports {
|
|
8
8
|
export { CommonRequest, LanguageModel, LanguageModelService, streamTurn, turn, turnFromStream };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { c as Watermark } from "../Media-BbX7BAaO.mjs";
|
|
1
2
|
import { t as AiError } from "../AiError-eLV9t1lU.mjs";
|
|
2
|
-
import { n as AudioChunk } from "../Audio-
|
|
3
|
-
import { CommonGenerateMusicRequest, CommonStreamGenerateMusicRequest, GenerateResult, MusicResult, MusicSection, MusicSessionControl, MusicSessionInput, MusicStreamEvent,
|
|
3
|
+
import { n as AudioChunk } from "../Audio-_nGR4V0X.mjs";
|
|
4
|
+
import { CommonGenerateMusicRequest, CommonStreamGenerateMusicRequest, GenerateResult, MusicResult, MusicSection, MusicSessionControl, MusicSessionInput, MusicStreamEvent, WeightedPrompt } from "../domain/Music.mjs";
|
|
4
5
|
import { Context, Effect, Stream } from "effect";
|
|
5
6
|
declare namespace MusicGenerator_d_exports {
|
|
6
7
|
export { CommonGenerateMusicRequest, CommonStreamGenerateMusicRequest, GenerateResult, MusicGenerator, MusicGeneratorService, MusicInteractiveSession, MusicResult, MusicSection, MusicSessionControl, MusicSessionInput, MusicStreamEvent, Watermark, WeightedPrompt, generate, streamGeneration, streamGenerationFrom };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MusicGenerator.d.mts","names":[],"sources":["../../src/music-generator/MusicGenerator.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MusicGenerator.d.mts","names":[],"sources":["../../src/music-generator/MusicGenerator.ts"],"mappings":";;;;;;;;KAwBY;;;;;;;;;;WAUD,WACP,SAAS,+BACN,OAAO,OAAO,gBAAgB;;;;;;;WAO1B,mBACP,SAAS,qCACN,OAAO,OAAO,YAAY;;;;;;;;;;;;;;;;;;;;;;;WAuBtB,uBAAuB,GAAG,GACjC,OAAO,OAAO,OAAO,mBAAmB,GAAG,IAC3C,SAAS,qCACN,OAAO,OAAO,kBAAkB,UAAkB,GAAG;;;cAG/C,uBAAuB;;;;;;;;;;;;cAcvB,gCAAgC;;cAKhC,WAAQ,SACV,+BACR,OAAO,OAAO,gBAAgB,SAAiB;;cAIrC,mBAAgB,SAClB,qCACR,OAAO,OAAO,YAAY,SAAiB;;;;;;;;;;;;;;;;;;;;;;;;;cA2BjC;GAET,SAAS,oCACP,GAAG,GACL,OAAO,OAAO,OAAO,mBAAmB,GAAG,OACxC,OAAO,OACV,kBACA,UAAkB,GAClB,IAAI,iBAAiB;GAEtB,GAAG,GACF,OAAO,OAAO,OAAO,mBAAmB,GAAG,IAC3C,SAAS,mCACR,OAAO,OACR,kBACA,UAAkB,GAClB,IAAI,iBAAiB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { t as AiError } from "../AiError-eLV9t1lU.mjs";
|
|
2
|
+
import { Context, Effect } from "effect";
|
|
3
|
+
declare namespace Reranker_d_exports {
|
|
4
|
+
export { CommonRerankRequest, RerankResponse, RerankResult, RerankUsage, Reranker, RerankerService, rerank };
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Cross-provider rerank request. Vendor knobs (multimodal documents,
|
|
8
|
+
* instruction fields, truncation) live on the provider's typed request.
|
|
9
|
+
*/
|
|
10
|
+
type CommonRerankRequest = {
|
|
11
|
+
readonly query: string;
|
|
12
|
+
readonly documents: ReadonlyArray<string>;
|
|
13
|
+
/** Each provider narrows this to its typed literal union. */
|
|
14
|
+
readonly model: string;
|
|
15
|
+
/** Keep only the top N results. Default: all documents. */
|
|
16
|
+
readonly topN?: number;
|
|
17
|
+
};
|
|
18
|
+
type RerankResult = {
|
|
19
|
+
/** Position in the request's `documents`. */
|
|
20
|
+
readonly index: number;
|
|
21
|
+
readonly score: number;
|
|
22
|
+
};
|
|
23
|
+
/** Optional throughout: some providers bill per search unit, not per token. */
|
|
24
|
+
type RerankUsage = {
|
|
25
|
+
readonly totalTokens?: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Score contract: `results` is sorted descending, higher is better. Scores
|
|
29
|
+
* order candidates within one call; no range or calibration is promised and
|
|
30
|
+
* they are not comparable across requests. Implementors must sort descending
|
|
31
|
+
* if the wire does not.
|
|
32
|
+
*/
|
|
33
|
+
type RerankResponse = {
|
|
34
|
+
readonly results: ReadonlyArray<RerankResult>;
|
|
35
|
+
readonly usage: RerankUsage;
|
|
36
|
+
};
|
|
37
|
+
type RerankerService = {
|
|
38
|
+
readonly rerank: (request: CommonRerankRequest) => Effect.Effect<RerankResponse, AiError>;
|
|
39
|
+
};
|
|
40
|
+
declare const Reranker_base: Context.ServiceClass<Reranker, "@betalyra/effect-uai/Reranker", RerankerService>;
|
|
41
|
+
declare class Reranker extends Reranker_base {}
|
|
42
|
+
/** Score a candidate set against a query, best first. */
|
|
43
|
+
declare const rerank: (request: CommonRerankRequest) => Effect.Effect<RerankResponse, AiError, Reranker>;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { CommonRerankRequest, RerankResponse, RerankResult, RerankUsage, Reranker, RerankerService, rerank, Reranker_d_exports as t };
|
|
46
|
+
//# sourceMappingURL=Reranker.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Reranker.d.mts","names":[],"sources":["../../src/reranker/Reranker.ts"],"mappings":";;;;;;;;;KAOY;WACD;WACA,WAAW;;WAEX;;WAEA;;KAGC;;WAED;WACA;;;KAIC;WACD;;;;;;;;KASC;WACD,SAAS,cAAc;WACvB,OAAO;;KAGN;WACD,SAAS,SAAS,wBAAwB,OAAO,OAAO,gBAAgB;;;cAGtE,iBAAiB;;cAKjB,SAAM,SACR,wBACR,OAAO,OAAO,gBAAgB,SAAiB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { n as __exportAll } from "../rolldown-runtime-EAsCxrDo.mjs";
|
|
2
|
+
import { Context, Effect } from "effect";
|
|
3
|
+
//#region src/reranker/Reranker.ts
|
|
4
|
+
var Reranker_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
Reranker: () => Reranker,
|
|
6
|
+
rerank: () => rerank
|
|
7
|
+
});
|
|
8
|
+
var Reranker = class extends Context.Service()("@betalyra/effect-uai/Reranker") {};
|
|
9
|
+
/** Score a candidate set against a query, best first. */
|
|
10
|
+
const rerank = (request) => Effect.flatMap(Reranker, (r) => r.rerank(request));
|
|
11
|
+
//#endregion
|
|
12
|
+
export { Reranker, rerank, Reranker_exports as t };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=Reranker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Reranker.mjs","names":[],"sources":["../../src/reranker/Reranker.ts"],"sourcesContent":["import { Context, Effect } from \"effect\"\nimport type * as AiError from \"../domain/AiError.js\"\n\n/**\n * Cross-provider rerank request. Vendor knobs (multimodal documents,\n * instruction fields, truncation) live on the provider's typed request.\n */\nexport type CommonRerankRequest = {\n readonly query: string\n readonly documents: ReadonlyArray<string>\n /** Each provider narrows this to its typed literal union. */\n readonly model: string\n /** Keep only the top N results. Default: all documents. */\n readonly topN?: number\n}\n\nexport type RerankResult = {\n /** Position in the request's `documents`. */\n readonly index: number\n readonly score: number\n}\n\n/** Optional throughout: some providers bill per search unit, not per token. */\nexport type RerankUsage = {\n readonly totalTokens?: number\n}\n\n/**\n * Score contract: `results` is sorted descending, higher is better. Scores\n * order candidates within one call; no range or calibration is promised and\n * they are not comparable across requests. Implementors must sort descending\n * if the wire does not.\n */\nexport type RerankResponse = {\n readonly results: ReadonlyArray<RerankResult>\n readonly usage: RerankUsage\n}\n\nexport type RerankerService = {\n readonly rerank: (request: CommonRerankRequest) => Effect.Effect<RerankResponse, AiError.AiError>\n}\n\nexport class Reranker extends Context.Service<Reranker, RerankerService>()(\n \"@betalyra/effect-uai/Reranker\",\n) {}\n\n/** Score a candidate set against a query, best first. */\nexport const rerank = (\n request: CommonRerankRequest,\n): Effect.Effect<RerankResponse, AiError.AiError, Reranker> =>\n Effect.flatMap(Reranker, (r) => r.rerank(request))\n"],"mappings":";;;;;;;AA0CA,IAAa,WAAb,cAA8B,QAAQ,QAAmC,CAAC,CACxE,+BACF,CAAC,CAAC,CAAC;;AAGH,MAAa,UACX,YAEA,OAAO,QAAQ,WAAW,MAAM,EAAE,OAAO,OAAO,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as AiError } from "../AiError-eLV9t1lU.mjs";
|
|
2
|
-
import { n as AudioChunk, r as AudioFormat, t as AudioBlob } from "../Audio-
|
|
2
|
+
import { n as AudioChunk, r as AudioFormat, t as AudioBlob } from "../Audio-_nGR4V0X.mjs";
|
|
3
3
|
import { Context, Effect, Stream } from "effect";
|
|
4
4
|
declare namespace SpeechSynthesizer_d_exports {
|
|
5
5
|
export { CommonStreamSynthesizeRequest, CommonSynthesizeDialogueRequest, CommonSynthesizeRequest, CustomPronunciation, DialogueTurn, MultiSpeakerTts, SpeechSynthesizer, SpeechSynthesizerService, TtsIncrementalText, streamSynthesis, streamSynthesisFrom, streamSynthesizeDialogue, synthesize, synthesizeDialogue };
|