@tanstack/ai 0.55.0 → 0.58.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/README.md +42 -16
- package/dist/esm/activities/chat/index.js +8 -6
- package/dist/esm/activities/chat/index.js.map +1 -1
- package/dist/esm/activities/chat/middleware/types.d.ts +4 -3
- package/dist/esm/activities/chat/middleware/types.js.map +1 -1
- package/dist/esm/activities/chat/tools/tool-calls.d.ts +2 -2
- package/dist/esm/activities/chat/tools/tool-calls.js +3 -2
- package/dist/esm/activities/chat/tools/tool-calls.js.map +1 -1
- package/dist/esm/activities/evaluate/adapter.d.ts +160 -0
- package/dist/esm/activities/evaluate/adapter.js +23 -0
- package/dist/esm/activities/evaluate/adapter.js.map +1 -0
- package/dist/esm/activities/evaluate/index.d.ts +255 -0
- package/dist/esm/activities/evaluate/index.js +317 -0
- package/dist/esm/activities/evaluate/index.js.map +1 -0
- package/dist/esm/activities/generateSpeech/adapter.d.ts +39 -1
- package/dist/esm/activities/generateSpeech/adapter.js.map +1 -1
- package/dist/esm/activities/generateSpeech/index.d.ts +55 -5
- package/dist/esm/activities/generateSpeech/index.js +53 -3
- package/dist/esm/activities/generateSpeech/index.js.map +1 -1
- package/dist/esm/activities/generateVoice/adapter.d.ts +62 -0
- package/dist/esm/activities/generateVoice/adapter.js +23 -0
- package/dist/esm/activities/generateVoice/adapter.js.map +1 -0
- package/dist/esm/activities/generateVoice/index.d.ts +133 -0
- package/dist/esm/activities/generateVoice/index.js +184 -0
- package/dist/esm/activities/generateVoice/index.js.map +1 -0
- package/dist/esm/activities/index.d.ts +10 -4
- package/dist/esm/activities/index.js +14 -10
- package/dist/esm/activities/middleware/types.d.ts +1 -1
- package/dist/esm/client.d.ts +3 -2
- package/dist/esm/client.js +21 -3
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +6 -3
- package/dist/esm/middlewares/otel.js +2 -0
- package/dist/esm/middlewares/otel.js.map +1 -1
- package/dist/esm/realtime/index.d.ts +1 -1
- package/dist/esm/realtime/index.js +1 -1
- package/dist/esm/realtime/index.js.map +1 -1
- package/dist/esm/stream-to-response.js +12 -6
- package/dist/esm/stream-to-response.js.map +1 -1
- package/dist/esm/strip-to-spec-middleware.js +2 -1
- package/dist/esm/strip-to-spec-middleware.js.map +1 -1
- package/dist/esm/types.d.ts +243 -3
- package/dist/esm/utilities/durability-batch.d.ts +8 -0
- package/dist/esm/utilities/durability-batch.js +45 -0
- package/dist/esm/utilities/durability-batch.js.map +1 -0
- package/package.json +3 -3
- package/skills/ai-core/media-generation/SKILL.md +132 -6
- package/src/activities/chat/index.ts +11 -5
- package/src/activities/chat/middleware/types.ts +8 -2
- package/src/activities/chat/tools/tool-calls.ts +24 -5
- package/src/activities/evaluate/adapter.ts +212 -0
- package/src/activities/evaluate/index.ts +614 -0
- package/src/activities/generateSpeech/adapter.ts +47 -1
- package/src/activities/generateSpeech/index.ts +149 -8
- package/src/activities/generateVoice/adapter.ts +89 -0
- package/src/activities/generateVoice/index.ts +371 -0
- package/src/activities/index.ts +69 -0
- package/src/activities/middleware/types.ts +2 -0
- package/src/client.ts +35 -8
- package/src/index.ts +21 -0
- package/src/middlewares/otel.ts +2 -0
- package/src/realtime/index.ts +1 -1
- package/src/stream-to-response.ts +16 -6
- package/src/strip-to-spec-middleware.ts +2 -1
- package/src/types.ts +269 -3
- package/src/utilities/durability-batch.ts +48 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { resolveDebugOption } from "../../logger/resolve.js";
|
|
2
|
+
import { streamGenerationResult } from "../stream-generation-result.js";
|
|
3
|
+
import { applyGenerationResultTransforms, createGenerationContext, runGenerationAbort, runGenerationError, runGenerationFinish, runGenerationStart, runGenerationUsage } from "../middleware/run.js";
|
|
4
|
+
import { abortReasonMessage, createActivityAbortControls, isActivityAbortError, raceWithAbort } from "../../utilities/activity-abort.js";
|
|
5
|
+
import "./adapter.js";
|
|
6
|
+
import { aiEventClient } from "@tanstack/ai-event-client";
|
|
7
|
+
//#region src/activities/generateVoice/index.ts
|
|
8
|
+
/**
|
|
9
|
+
* Voice Activity
|
|
10
|
+
*
|
|
11
|
+
* Creates a reusable voice — either designed from a text description or cloned
|
|
12
|
+
* from reference audio — and returns voice ids that `generateSpeech()` accepts.
|
|
13
|
+
* This is a self-contained module with implementation, types, and JSDoc.
|
|
14
|
+
*/
|
|
15
|
+
/** The adapter kind this activity handles */
|
|
16
|
+
var kind = "voice";
|
|
17
|
+
function createId(prefix) {
|
|
18
|
+
return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Voice activity - creates a reusable voice.
|
|
22
|
+
*
|
|
23
|
+
* Providers create voices in one of two ways, and some support both: design a
|
|
24
|
+
* new voice from a text description, or clone one from reference audio. Either
|
|
25
|
+
* way the result carries voice ids you pass back to `generateSpeech()`.
|
|
26
|
+
*
|
|
27
|
+
* @example Design a voice from a description
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { generateVoice, generateSpeech } from '@tanstack/ai'
|
|
30
|
+
* import { elevenlabsVoiceDesign, elevenlabsSpeech } from '@tanstack/ai-elevenlabs'
|
|
31
|
+
*
|
|
32
|
+
* const designed = await generateVoice({
|
|
33
|
+
* adapter: elevenlabsVoiceDesign('eleven_ttv_v3'),
|
|
34
|
+
* prompt: 'A warm, gravelly narrator in his sixties with a slight Irish lilt',
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* const [preview] = designed.voices
|
|
38
|
+
* if (!preview) throw new Error('No voice candidates returned')
|
|
39
|
+
*
|
|
40
|
+
* const speech = await generateSpeech({
|
|
41
|
+
* adapter: elevenlabsSpeech('eleven_v3'),
|
|
42
|
+
* text: 'Once upon a time...',
|
|
43
|
+
* voice: preview.voiceId,
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example Save the voice to the provider's library
|
|
48
|
+
* ```ts
|
|
49
|
+
* const saved = await generateVoice({
|
|
50
|
+
* adapter: elevenlabsVoiceDesign('eleven_ttv_v3'),
|
|
51
|
+
* prompt: 'A bright, upbeat product demo host',
|
|
52
|
+
* name: 'Demo Host',
|
|
53
|
+
* description: 'Bright, upbeat, mid-30s',
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
function generateVoice(options) {
|
|
58
|
+
if (options.stream) return streamGenerationResult((resolved) => runGenerateVoice({
|
|
59
|
+
...options,
|
|
60
|
+
runId: resolved.runId
|
|
61
|
+
}), options);
|
|
62
|
+
return runGenerateVoice(options);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Run the core voice generation logic (non-streaming).
|
|
66
|
+
*/
|
|
67
|
+
async function runGenerateVoice(options) {
|
|
68
|
+
const { adapter, stream: _stream, debug: _debug, middleware, threadId, runId, timeout, abortSignal: callerAbortSignal, ...rest } = options;
|
|
69
|
+
if (rest.prompt == null && rest.referenceAudio == null) throw new Error("generateVoice() requires `prompt` (design a new voice) or `referenceAudio` (clone an existing one).");
|
|
70
|
+
const model = adapter.model;
|
|
71
|
+
const requestId = createId("voice");
|
|
72
|
+
const startTime = Date.now();
|
|
73
|
+
const logger = resolveDebugOption(options.debug);
|
|
74
|
+
const abortControls = createActivityAbortControls({
|
|
75
|
+
timeout,
|
|
76
|
+
abortSignal: callerAbortSignal
|
|
77
|
+
});
|
|
78
|
+
const mwCtx = createGenerationContext({
|
|
79
|
+
requestId,
|
|
80
|
+
activity: "voice",
|
|
81
|
+
provider: adapter.name,
|
|
82
|
+
model,
|
|
83
|
+
modelOptions: rest.modelOptions,
|
|
84
|
+
artifactInputs: {
|
|
85
|
+
prompt: rest.prompt,
|
|
86
|
+
name: rest.name,
|
|
87
|
+
description: rest.description
|
|
88
|
+
},
|
|
89
|
+
threadId,
|
|
90
|
+
runId,
|
|
91
|
+
createId
|
|
92
|
+
});
|
|
93
|
+
await runGenerationStart(middleware, mwCtx);
|
|
94
|
+
aiEventClient.emit("voice:request:started", {
|
|
95
|
+
requestId,
|
|
96
|
+
provider: adapter.name,
|
|
97
|
+
model,
|
|
98
|
+
prompt: rest.prompt,
|
|
99
|
+
name: rest.name,
|
|
100
|
+
description: rest.description,
|
|
101
|
+
hasReferenceAudio: rest.referenceAudio != null,
|
|
102
|
+
modelOptions: rest.modelOptions,
|
|
103
|
+
timestamp: startTime
|
|
104
|
+
});
|
|
105
|
+
logger.request(`activity=generateVoice provider=${adapter.name}`, {
|
|
106
|
+
provider: adapter.name,
|
|
107
|
+
model
|
|
108
|
+
});
|
|
109
|
+
try {
|
|
110
|
+
const rawResult = await raceWithAbort(adapter.generateVoice({
|
|
111
|
+
...rest,
|
|
112
|
+
model,
|
|
113
|
+
logger,
|
|
114
|
+
...abortControls.signal ? { abortSignal: abortControls.signal } : {}
|
|
115
|
+
}), abortControls.signal);
|
|
116
|
+
abortControls.clear();
|
|
117
|
+
const result = await applyGenerationResultTransforms(mwCtx, rawResult);
|
|
118
|
+
const duration = Date.now() - startTime;
|
|
119
|
+
aiEventClient.emit("voice:request:completed", {
|
|
120
|
+
requestId,
|
|
121
|
+
provider: adapter.name,
|
|
122
|
+
model,
|
|
123
|
+
voiceIds: result.voices.map((voice) => voice.voiceId),
|
|
124
|
+
voiceCount: result.voices.length,
|
|
125
|
+
previewText: result.previewText,
|
|
126
|
+
duration,
|
|
127
|
+
modelOptions: rest.modelOptions,
|
|
128
|
+
timestamp: Date.now()
|
|
129
|
+
});
|
|
130
|
+
if (result.usage) aiEventClient.emit("voice:usage", {
|
|
131
|
+
requestId,
|
|
132
|
+
model,
|
|
133
|
+
usage: result.usage,
|
|
134
|
+
modelOptions: rest.modelOptions,
|
|
135
|
+
timestamp: Date.now()
|
|
136
|
+
});
|
|
137
|
+
logger.output(`activity=generateVoice voices=${result.voices.length}`, { voices: result.voices.length });
|
|
138
|
+
if (result.usage) await runGenerationUsage(middleware, mwCtx, result.usage);
|
|
139
|
+
await runGenerationFinish(middleware, mwCtx, {
|
|
140
|
+
duration,
|
|
141
|
+
usage: result.usage
|
|
142
|
+
});
|
|
143
|
+
return result;
|
|
144
|
+
} catch (error) {
|
|
145
|
+
abortControls.clear();
|
|
146
|
+
const duration = Date.now() - startTime;
|
|
147
|
+
const err = error;
|
|
148
|
+
aiEventClient.emit("voice:request:error", {
|
|
149
|
+
requestId,
|
|
150
|
+
provider: adapter.name,
|
|
151
|
+
model,
|
|
152
|
+
error: {
|
|
153
|
+
message: err.message,
|
|
154
|
+
name: err.name
|
|
155
|
+
},
|
|
156
|
+
duration,
|
|
157
|
+
modelOptions: rest.modelOptions,
|
|
158
|
+
timestamp: Date.now()
|
|
159
|
+
});
|
|
160
|
+
if (isActivityAbortError(error, abortControls.signal)) await runGenerationAbort(middleware, mwCtx, {
|
|
161
|
+
reason: abortReasonMessage(error, abortControls.signal),
|
|
162
|
+
duration
|
|
163
|
+
});
|
|
164
|
+
else await runGenerationError(middleware, mwCtx, {
|
|
165
|
+
error,
|
|
166
|
+
duration
|
|
167
|
+
});
|
|
168
|
+
logger.errors("generateVoice activity failed", {
|
|
169
|
+
error,
|
|
170
|
+
source: "generateVoice"
|
|
171
|
+
});
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Create typed options for the generateVoice() function without executing.
|
|
177
|
+
*/
|
|
178
|
+
function createVoiceOptions(options) {
|
|
179
|
+
return options;
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
export { createVoiceOptions, generateVoice, kind };
|
|
183
|
+
|
|
184
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/activities/generateVoice/index.ts"],"sourcesContent":["/**\n * Voice Activity\n *\n * Creates a reusable voice — either designed from a text description or cloned\n * from reference audio — and returns voice ids that `generateSpeech()` accepts.\n * This is a self-contained module with implementation, types, and JSDoc.\n */\n\nimport { aiEventClient } from '@tanstack/ai-event-client'\nimport { streamGenerationResult } from '../stream-generation-result.js'\nimport { resolveDebugOption } from '../../logger/resolve'\nimport {\n applyGenerationResultTransforms,\n createGenerationContext,\n runGenerationAbort,\n runGenerationError,\n runGenerationFinish,\n runGenerationStart,\n runGenerationUsage,\n} from '../middleware/run'\nimport {\n abortReasonMessage,\n createActivityAbortControls,\n isActivityAbortError,\n raceWithAbort,\n} from '../../utilities/activity-abort'\nimport type { InternalLogger } from '../../logger/internal-logger'\nimport type { DebugOption } from '../../logger/types'\nimport type { GenerationMiddleware } from '../middleware/types'\nimport type { VoiceAdapter } from './adapter'\nimport type { StreamChunk, VoiceResult } from '../../types'\n\n// ===========================\n// Activity Kind\n// ===========================\n\n/** The adapter kind this activity handles */\nexport const kind = 'voice' as const\n\n// ===========================\n// Type Extraction Helpers\n// ===========================\n\n/**\n * Extract provider options from a VoiceAdapter via ~types.\n */\nexport type VoiceProviderOptions<TAdapter> = TAdapter extends {\n '~types': { providerOptions: infer P extends object }\n}\n ? P\n : object\n\n// ===========================\n// Activity Options Type\n// ===========================\n\n/**\n * Options for the voice activity.\n * The model is extracted from the adapter's model property.\n *\n * @template TAdapter - The voice adapter type\n * @template TStream - Whether to stream the output\n */\nexport interface VoiceActivityOptions<\n TAdapter extends VoiceAdapter<string, VoiceProviderOptions<TAdapter>>,\n TStream extends boolean = false,\n> {\n /** The voice adapter to use (must be created with a model) */\n adapter: TAdapter & { kind: typeof kind }\n /**\n * Text description of the voice to create, for design-capable models\n * (e.g. `'A warm, gravelly narrator in his sixties'`).\n */\n prompt?: string\n /**\n * Reference audio of the speaker to clone, for clone-capable models.\n * Accepts a base64 string, base64 data URL, File, Blob, or ArrayBuffer.\n * Remote URLs are not accepted; read the file and pass the bytes.\n */\n referenceAudio?: string | File | Blob | ArrayBuffer\n /**\n * Name to store the voice under in the provider's voice library. Check\n * `saved` on each returned voice to see whether it was actually persisted.\n */\n name?: string\n /** Human-readable description stored alongside the voice */\n description?: string\n /** Provider-specific options for voice creation */\n modelOptions?: VoiceProviderOptions<TAdapter>\n /**\n * Whether to stream the generation result.\n * When true, returns an AsyncIterable<StreamChunk> for streaming transport.\n * When false or not provided, returns a Promise<VoiceResult>.\n *\n * @default false\n */\n stream?: TStream\n /**\n * Enable debug logging. Pass `true` to enable all categories, `false` to\n * silence everything including errors, or a `DebugConfig` object for granular\n * control and/or a custom `Logger`.\n */\n debug?: DebugOption\n /**\n * Observe-only middleware notified on start, usage, success, and error. Pass\n * `otelMiddleware()` to emit OpenTelemetry spans, or implement the\n * `GenerationMiddleware` contract for a custom backend.\n */\n middleware?: Array<GenerationMiddleware>\n /** Stable conversation/thread id for correlating this run when persisted. */\n threadId?: string\n /** Stable run id for correlating this run when persisted. */\n runId?: string\n /**\n * Maximum duration of this activity invocation in milliseconds.\n * No SDK-wide default — choose a value suitable for the provider and job.\n * Composed with {@link abortSignal}; the first abort wins.\n */\n timeout?: number\n /**\n * Caller cancellation signal (request disconnects, job/runtime cancellation).\n * Composed with {@link timeout} into an effective signal forwarded to the\n * adapter. Request-specific — not stored on global provider client config.\n */\n abortSignal?: AbortSignal\n}\n\n// ===========================\n// Activity Result Type\n// ===========================\n\n/**\n * Result type for the voice activity.\n * - If stream is true: AsyncIterable<StreamChunk>\n * - Otherwise: Promise<VoiceResult>\n */\nexport type VoiceActivityResult<TStream extends boolean = false> =\n TStream extends true ? AsyncIterable<StreamChunk> : Promise<VoiceResult>\n\nfunction createId(prefix: string): string {\n return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`\n}\n\n// ===========================\n// Activity Implementation\n// ===========================\n\n/**\n * Voice activity - creates a reusable voice.\n *\n * Providers create voices in one of two ways, and some support both: design a\n * new voice from a text description, or clone one from reference audio. Either\n * way the result carries voice ids you pass back to `generateSpeech()`.\n *\n * @example Design a voice from a description\n * ```ts\n * import { generateVoice, generateSpeech } from '@tanstack/ai'\n * import { elevenlabsVoiceDesign, elevenlabsSpeech } from '@tanstack/ai-elevenlabs'\n *\n * const designed = await generateVoice({\n * adapter: elevenlabsVoiceDesign('eleven_ttv_v3'),\n * prompt: 'A warm, gravelly narrator in his sixties with a slight Irish lilt',\n * })\n *\n * const [preview] = designed.voices\n * if (!preview) throw new Error('No voice candidates returned')\n *\n * const speech = await generateSpeech({\n * adapter: elevenlabsSpeech('eleven_v3'),\n * text: 'Once upon a time...',\n * voice: preview.voiceId,\n * })\n * ```\n *\n * @example Save the voice to the provider's library\n * ```ts\n * const saved = await generateVoice({\n * adapter: elevenlabsVoiceDesign('eleven_ttv_v3'),\n * prompt: 'A bright, upbeat product demo host',\n * name: 'Demo Host',\n * description: 'Bright, upbeat, mid-30s',\n * })\n * ```\n */\nexport function generateVoice<\n TAdapter extends VoiceAdapter<string, VoiceProviderOptions<TAdapter>>,\n TStream extends boolean = false,\n>(\n options: VoiceActivityOptions<TAdapter, TStream>,\n): VoiceActivityResult<TStream> {\n if (options.stream) {\n return streamGenerationResult(\n // Only `runId` is taken from the resolved wire identity — see the\n // matching note in `generateSpeech`.\n (resolved) => runGenerateVoice({ ...options, runId: resolved.runId }),\n options,\n ) as VoiceActivityResult<TStream>\n }\n return runGenerateVoice(options) as VoiceActivityResult<TStream>\n}\n\n/**\n * Run the core voice generation logic (non-streaming).\n */\nasync function runGenerateVoice<\n TAdapter extends VoiceAdapter<string, VoiceProviderOptions<TAdapter>>,\n>(options: VoiceActivityOptions<TAdapter, boolean>): Promise<VoiceResult> {\n const {\n adapter,\n stream: _stream,\n debug: _debug,\n middleware,\n threadId,\n runId,\n timeout,\n abortSignal: callerAbortSignal,\n ...rest\n } = options\n\n if (rest.prompt == null && rest.referenceAudio == null) {\n throw new Error(\n 'generateVoice() requires `prompt` (design a new voice) or `referenceAudio` (clone an existing one).',\n )\n }\n\n const model = adapter.model\n const requestId = createId('voice')\n const startTime = Date.now()\n const logger: InternalLogger = resolveDebugOption(options.debug)\n const abortControls = createActivityAbortControls({\n timeout,\n abortSignal: callerAbortSignal,\n })\n\n const mwCtx = createGenerationContext({\n requestId,\n activity: 'voice',\n provider: adapter.name,\n model,\n modelOptions: rest.modelOptions,\n artifactInputs: {\n prompt: rest.prompt,\n name: rest.name,\n description: rest.description,\n },\n threadId,\n runId,\n createId,\n })\n\n await runGenerationStart(middleware, mwCtx)\n\n aiEventClient.emit('voice:request:started', {\n requestId,\n provider: adapter.name,\n model,\n prompt: rest.prompt,\n name: rest.name,\n description: rest.description,\n hasReferenceAudio: rest.referenceAudio != null,\n modelOptions: rest.modelOptions as Record<string, unknown> | undefined,\n timestamp: startTime,\n })\n\n logger.request(`activity=generateVoice provider=${adapter.name}`, {\n provider: adapter.name,\n model,\n })\n\n try {\n const rawResult = await raceWithAbort(\n adapter.generateVoice({\n ...rest,\n model,\n logger,\n ...(abortControls.signal ? { abortSignal: abortControls.signal } : {}),\n }),\n abortControls.signal,\n )\n abortControls.clear()\n const result = await applyGenerationResultTransforms(mwCtx, rawResult)\n const duration = Date.now() - startTime\n\n aiEventClient.emit('voice:request:completed', {\n requestId,\n provider: adapter.name,\n model,\n voiceIds: result.voices.map((voice) => voice.voiceId),\n voiceCount: result.voices.length,\n previewText: result.previewText,\n duration,\n modelOptions: rest.modelOptions as Record<string, unknown> | undefined,\n timestamp: Date.now(),\n })\n\n if (result.usage) {\n aiEventClient.emit('voice:usage', {\n requestId,\n model,\n usage: result.usage,\n modelOptions: rest.modelOptions as Record<string, unknown> | undefined,\n timestamp: Date.now(),\n })\n }\n\n logger.output(`activity=generateVoice voices=${result.voices.length}`, {\n voices: result.voices.length,\n })\n\n if (result.usage) await runGenerationUsage(middleware, mwCtx, result.usage)\n await runGenerationFinish(middleware, mwCtx, {\n duration,\n usage: result.usage,\n })\n\n return result\n } catch (error) {\n abortControls.clear()\n const duration = Date.now() - startTime\n const err = error as Error\n aiEventClient.emit('voice:request:error', {\n requestId,\n provider: adapter.name,\n model,\n error: { message: err.message, name: err.name },\n duration,\n modelOptions: rest.modelOptions as Record<string, unknown> | undefined,\n timestamp: Date.now(),\n })\n if (isActivityAbortError(error, abortControls.signal)) {\n await runGenerationAbort(middleware, mwCtx, {\n reason: abortReasonMessage(error, abortControls.signal),\n duration,\n })\n } else {\n await runGenerationError(middleware, mwCtx, {\n error,\n duration,\n })\n }\n logger.errors('generateVoice activity failed', {\n error,\n source: 'generateVoice',\n })\n throw error\n }\n}\n\n// ===========================\n// Options Factory\n// ===========================\n\n/**\n * Create typed options for the generateVoice() function without executing.\n */\nexport function createVoiceOptions<\n TAdapter extends VoiceAdapter<string, VoiceProviderOptions<TAdapter>>,\n TStream extends boolean = false,\n>(\n options: VoiceActivityOptions<TAdapter, TStream>,\n): VoiceActivityOptions<TAdapter, TStream> {\n return options\n}\n\n// Re-export adapter types\nexport type {\n VoiceAdapter,\n VoiceAdapterConfig,\n AnyVoiceAdapter,\n} from './adapter'\nexport { BaseVoiceAdapter } from './adapter'\n"],"mappings":";;;;;;;;;;;;;;;AAqCA,IAAa,OAAO;AAsGpB,SAAS,SAAS,QAAwB;CACxC,OAAO,GAAG,OAAO,GAAG,KAAK,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;AACzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,cAId,SAC8B;CAC9B,IAAI,QAAQ,QACV,OAAO,wBAGJ,aAAa,iBAAiB;EAAE,GAAG;EAAS,OAAO,SAAS;CAAM,CAAC,GACpE,OACF;CAEF,OAAO,iBAAiB,OAAO;AACjC;;;;AAKA,eAAe,iBAEb,SAAwE;CACxE,MAAM,EACJ,SACA,QAAQ,SACR,OAAO,QACP,YACA,UACA,OACA,SACA,aAAa,mBACb,GAAG,SACD;CAEJ,IAAI,KAAK,UAAU,QAAQ,KAAK,kBAAkB,MAChD,MAAM,IAAI,MACR,qGACF;CAGF,MAAM,QAAQ,QAAQ;CACtB,MAAM,YAAY,SAAS,OAAO;CAClC,MAA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AAQ,OAAO,OAAO,OACxB,CAAC;EAED,IAAI,OAAO,OAAO,MAAM,mBAAmB,YAAY,OAAO,OAAO,KAAK;EAC1E,MAAM,oBAAoB,YAAY,OAAO;GAC3C;GACA,OAAO,OAAO;EAChB,CAAC;EAED,OAAO;CACT,SAAS,OAAO;EACd,cAAc,MAAM;EACpB,MAAM,WAAW,KAAK,IAAI,IAAI;EAC9B,MAAM,MAAM;EACZ,cAAc,KAAK,uBAAuB;GACxC;GACA,UAAU,QAAQ;GAClB;GACA,OAAO;IAAE,SAAS,IAAI;IAAS,MAAM,IAAI;GAAK;GAC9C;GACA,cAAc,KAAK;GACnB,WAAW,KAAK,IAAI;EACtB,CAAC;EACD,IAAI,qBAAqB,OAAO,cAAc,MAAM,GAClD,MAAM,mBAAmB,YAAY,OAAO;GAC1C,QAAQ,mBAAmB,OAAO,cAAc,MAAM;GACtD;EACF,CAAC;OAED,MAAM,mBAAmB,YAAY,OAAO;GAC1C;GACA;EACF,CAAC;EAEH,OAAO,OAAO,iCAAiC;GAC7C;GACA,QAAQ;EACV,CAAC;EACD,MAAM;CACR;AACF;;;;AASA,SAAgB,mBAId,SACyC;CACzC,OAAO;AACT"}
|
|
@@ -4,9 +4,11 @@ import { AnyImageAdapter } from './generateImage/adapter.js';
|
|
|
4
4
|
import { AnyAudioAdapter } from './generateAudio/adapter.js';
|
|
5
5
|
import { AnyVideoAdapter } from './generateVideo/adapter.js';
|
|
6
6
|
import { AnyTTSAdapter } from './generateSpeech/adapter.js';
|
|
7
|
+
import { AnyVoiceAdapter } from './generateVoice/adapter.js';
|
|
7
8
|
import { AnyTranscriptionAdapter } from './generateTranscription/adapter.js';
|
|
8
9
|
import { AnyEmbeddingAdapter } from './embed/adapter.js';
|
|
9
10
|
import { AnyRerankAdapter } from './rerank/adapter.js';
|
|
11
|
+
import { AnyEvaluateAdapter } from './evaluate/adapter.js';
|
|
10
12
|
import { AnyWorldAdapter } from './generateWorld/adapter.js';
|
|
11
13
|
import { AnyLiveVideoAdapter } from './generateLiveVideo/adapter.js';
|
|
12
14
|
export { kind as textKind, chat, type TextActivityOptions, type TextActivityResult, } from './chat/index.js';
|
|
@@ -16,6 +18,8 @@ export { BaseSummarizeAdapter, type SummarizeAdapter, type SummarizeAdapterConfi
|
|
|
16
18
|
export { ChatStreamSummarizeAdapter, type ChatStreamCapable, type InferTextProviderOptions, } from './summarize/chat-stream-summarize.js';
|
|
17
19
|
export { kind as rerankKind, rerank, createRerankOptions, type RerankActivityOptions, type RerankProviderOptions, } from './rerank/index.js';
|
|
18
20
|
export { BaseRerankAdapter, type RerankAdapter, type RerankAdapterConfig, type AnyRerankAdapter, } from './rerank/adapter.js';
|
|
21
|
+
export { kind as evaluateKind, decide, choice, score, boolean, type EvaluateActivityOptions, type EvaluateResult, type EvaluateResultMeta, type EvaluateProviderOptions, type ChoiceAnswer, type ScoreAnswer, type BooleanAnswer, type InferEvaluateAnswer, } from './evaluate/index.js';
|
|
22
|
+
export { BaseEvaluateAdapter, type EvaluateAdapter, type EvaluateAdapterConfig, type AnyEvaluateAdapter, type EvaluateOptions, type EvaluateAdapterResult, type EvaluateState, type EvaluateInstructions, type EvaluateJsonValue, type WireQuestion, type WireAnswer, type WireChoiceQuestion, type WireScoreQuestion, type WireNoulQuestion, type WireChoiceAnswer, type WireScoreAnswer, type WireNoulAnswer, } from './evaluate/adapter.js';
|
|
19
23
|
export { kind as imageKind, generateImage, type ImageActivityOptions, type ImageActivityResult, type ImageProviderOptionsForModel, type ImageSizeForModel, } from './generateImage/index.js';
|
|
20
24
|
export { BaseImageAdapter, type ImageAdapter, type ImageAdapterConfig, type AnyImageAdapter, } from './generateImage/adapter.js';
|
|
21
25
|
export { kind as audioKind, generateAudio, type AudioActivityOptions, type AudioActivityResult, type AudioProviderOptions, } from './generateAudio/index.js';
|
|
@@ -23,8 +27,10 @@ export { BaseAudioAdapter, type AudioAdapter, type AudioAdapterConfig, type AnyA
|
|
|
23
27
|
export { kind as videoKind, generateVideo, getVideoJobStatus, type VideoActivityOptions, type VideoActivityResult, type VideoProviderOptions, type VideoCreateOptions, type VideoStatusOptions, type VideoUrlOptions, type VideoDurationForAdapter, } from './generateVideo/index.js';
|
|
24
28
|
export { BaseVideoAdapter, type VideoAdapter, type VideoAdapterConfig, type AnyVideoAdapter, type DurationOptions, } from './generateVideo/adapter.js';
|
|
25
29
|
export { snapToDurationOption } from './generateVideo/snap.js';
|
|
26
|
-
export { kind as ttsKind, generateSpeech, type TTSActivityOptions, type TTSActivityResult, type TTSProviderOptions, } from './generateSpeech/index.js';
|
|
27
|
-
export { BaseTTSAdapter, type TTSAdapter, type TTSAdapterConfig, type AnyTTSAdapter, } from './generateSpeech/adapter.js';
|
|
30
|
+
export { kind as ttsKind, generateSpeech, listVoices, type ListVoicesActivityOptions, type TTSActivityOptions, type TTSActivityResult, type TTSProviderOptions, } from './generateSpeech/index.js';
|
|
31
|
+
export { BaseTTSAdapter, type TTSAdapter, type TTSAdapterConfig, type TTSCapabilities, type AnyTTSAdapter, } from './generateSpeech/adapter.js';
|
|
32
|
+
export { kind as voiceKind, generateVoice, createVoiceOptions, type VoiceActivityOptions, type VoiceActivityResult, type VoiceProviderOptions, } from './generateVoice/index.js';
|
|
33
|
+
export { BaseVoiceAdapter, type VoiceAdapter, type VoiceAdapterConfig, type AnyVoiceAdapter, } from './generateVoice/adapter.js';
|
|
28
34
|
export { kind as transcriptionKind, generateTranscription, type TranscriptionActivityOptions, type TranscriptionActivityResult, type TranscriptionProviderOptions, } from './generateTranscription/index.js';
|
|
29
35
|
export { BaseTranscriptionAdapter, type TranscriptionAdapter, type TranscriptionAdapterConfig, type AnyTranscriptionAdapter, } from './generateTranscription/adapter.js';
|
|
30
36
|
export { kind as embeddingKind, embed, type EmbedOptions, type EmbedProviderOptionsForModel, type EmbeddingInputForModel, } from './embed/index.js';
|
|
@@ -34,6 +40,6 @@ export { BaseWorldAdapter, type WorldAdapter, type WorldAdapterConfig, type AnyW
|
|
|
34
40
|
export { kind as liveVideoKind, generateLiveVideo, type LiveVideoActivityOptions, type LiveVideoActivityResult, type LiveVideoProviderOptions, } from './generateLiveVideo/index.js';
|
|
35
41
|
export { BaseLiveVideoAdapter, type LiveVideoAdapter, type LiveVideoAdapterConfig, type AnyLiveVideoAdapter, } from './generateLiveVideo/adapter.js';
|
|
36
42
|
/** Union of all adapter types that can be passed to chat() */
|
|
37
|
-
export type AIAdapter = AnyTextAdapter | AnySummarizeAdapter | AnyImageAdapter | AnyAudioAdapter | AnyVideoAdapter | AnyTTSAdapter | AnyTranscriptionAdapter | AnyEmbeddingAdapter | AnyRerankAdapter | AnyWorldAdapter | AnyLiveVideoAdapter;
|
|
43
|
+
export type AIAdapter = AnyTextAdapter | AnySummarizeAdapter | AnyImageAdapter | AnyAudioAdapter | AnyVideoAdapter | AnyTTSAdapter | AnyVoiceAdapter | AnyTranscriptionAdapter | AnyEmbeddingAdapter | AnyRerankAdapter | AnyEvaluateAdapter | AnyWorldAdapter | AnyLiveVideoAdapter;
|
|
38
44
|
/** Union type of all adapter kinds */
|
|
39
|
-
export type AdapterKind = 'text' | 'summarize' | 'image' | 'audio' | 'video' | 'tts' | 'transcription' | 'embedding' | 'rerank' | 'world' | 'liveVideo';
|
|
45
|
+
export type AdapterKind = 'text' | 'summarize' | 'image' | 'audio' | 'video' | 'tts' | 'voice' | 'transcription' | 'embedding' | 'rerank' | 'evaluate' | 'world' | 'liveVideo';
|
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import { BaseTextAdapter } from "./chat/adapter.js";
|
|
2
|
-
import { chat, kind as kind$
|
|
2
|
+
import { chat, kind as kind$7 } from "./chat/index.js";
|
|
3
3
|
import { BaseSummarizeAdapter } from "./summarize/adapter.js";
|
|
4
4
|
import { ChatStreamSummarizeAdapter } from "./summarize/chat-stream-summarize.js";
|
|
5
|
-
import { kind as kind$
|
|
5
|
+
import { kind as kind$6, summarize } from "./summarize/index.js";
|
|
6
6
|
import { BaseRerankAdapter } from "./rerank/adapter.js";
|
|
7
|
-
import { createRerankOptions, kind as kind$
|
|
7
|
+
import { createRerankOptions, kind as kind$5, rerank } from "./rerank/index.js";
|
|
8
|
+
import { BaseEvaluateAdapter } from "./evaluate/adapter.js";
|
|
9
|
+
import { boolean, choice, decide, kind as kind$2, score } from "./evaluate/index.js";
|
|
8
10
|
import { BaseImageAdapter } from "./generateImage/adapter.js";
|
|
9
|
-
import { generateImage, kind as kind$
|
|
11
|
+
import { generateImage, kind as kind$3 } from "./generateImage/index.js";
|
|
10
12
|
import { BaseAudioAdapter } from "./generateAudio/adapter.js";
|
|
11
13
|
import { generateAudio, kind } from "./generateAudio/index.js";
|
|
12
14
|
import { BaseVideoAdapter } from "./generateVideo/adapter.js";
|
|
13
|
-
import { generateVideo, getVideoJobStatus, kind as kind$
|
|
15
|
+
import { generateVideo, getVideoJobStatus, kind as kind$10 } from "./generateVideo/index.js";
|
|
14
16
|
import { snapToDurationOption } from "./generateVideo/snap.js";
|
|
15
17
|
import { BaseTTSAdapter } from "./generateSpeech/adapter.js";
|
|
16
|
-
import { generateSpeech, kind as kind$
|
|
18
|
+
import { generateSpeech, kind as kind$9, listVoices } from "./generateSpeech/index.js";
|
|
19
|
+
import { BaseVoiceAdapter } from "./generateVoice/adapter.js";
|
|
20
|
+
import { createVoiceOptions, generateVoice, kind as kind$11 } from "./generateVoice/index.js";
|
|
17
21
|
import { BaseTranscriptionAdapter } from "./generateTranscription/adapter.js";
|
|
18
|
-
import { generateTranscription, kind as kind$
|
|
22
|
+
import { generateTranscription, kind as kind$8 } from "./generateTranscription/index.js";
|
|
19
23
|
import { BaseEmbeddingAdapter } from "./embed/adapter.js";
|
|
20
24
|
import { embed, kind as kind$1 } from "./embed/index.js";
|
|
21
25
|
import { BaseWorldAdapter } from "./generateWorld/adapter.js";
|
|
22
|
-
import { generateWorld, kind as kind$
|
|
26
|
+
import { generateWorld, kind as kind$12 } from "./generateWorld/index.js";
|
|
23
27
|
import { BaseLiveVideoAdapter } from "./generateLiveVideo/adapter.js";
|
|
24
|
-
import { generateLiveVideo, kind as kind$
|
|
25
|
-
export { BaseAudioAdapter, BaseEmbeddingAdapter, BaseImageAdapter, BaseLiveVideoAdapter, BaseRerankAdapter, BaseSummarizeAdapter, BaseTTSAdapter, BaseTextAdapter, BaseTranscriptionAdapter, BaseVideoAdapter, BaseWorldAdapter, ChatStreamSummarizeAdapter, kind as audioKind, chat, createRerankOptions, embed, kind$1 as embeddingKind, generateAudio, generateImage, generateLiveVideo, generateSpeech, generateTranscription, generateVideo, generateWorld, getVideoJobStatus, kind$
|
|
28
|
+
import { generateLiveVideo, kind as kind$4 } from "./generateLiveVideo/index.js";
|
|
29
|
+
export { BaseAudioAdapter, BaseEmbeddingAdapter, BaseEvaluateAdapter, BaseImageAdapter, BaseLiveVideoAdapter, BaseRerankAdapter, BaseSummarizeAdapter, BaseTTSAdapter, BaseTextAdapter, BaseTranscriptionAdapter, BaseVideoAdapter, BaseVoiceAdapter, BaseWorldAdapter, ChatStreamSummarizeAdapter, kind as audioKind, boolean, chat, choice, createRerankOptions, createVoiceOptions, decide, embed, kind$1 as embeddingKind, kind$2 as evaluateKind, generateAudio, generateImage, generateLiveVideo, generateSpeech, generateTranscription, generateVideo, generateVoice, generateWorld, getVideoJobStatus, kind$3 as imageKind, listVoices, kind$4 as liveVideoKind, rerank, kind$5 as rerankKind, score, snapToDurationOption, summarize, kind$6 as summarizeKind, kind$7 as textKind, kind$8 as transcriptionKind, kind$9 as ttsKind, kind$10 as videoKind, kind$11 as voiceKind, kind$12 as worldKind };
|
|
@@ -11,7 +11,7 @@ import { TokenUsage } from '../../types.js';
|
|
|
11
11
|
* `'summarize'` produces text, not media, so it has no artifacts — a
|
|
12
12
|
* persistence middleware stores its run record and result and nothing else.
|
|
13
13
|
*/
|
|
14
|
-
export type GenerationActivity = 'chat' | 'image' | 'video' | 'audio' | 'tts' | 'transcription' | 'embedding' | 'rerank' | 'summarize' | 'world' | 'liveVideo';
|
|
14
|
+
export type GenerationActivity = 'chat' | 'image' | 'video' | 'audio' | 'tts' | 'voice' | 'transcription' | 'embedding' | 'rerank' | 'evaluate' | 'summarize' | 'world' | 'liveVideo';
|
|
15
15
|
/**
|
|
16
16
|
* Stable context passed to every {@link GenerationMiddleware} hook. Created
|
|
17
17
|
* once per activity call and shared across the hooks of that call.
|
package/dist/esm/client.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { AudioGenerationOptions, ImageGenerationOptions, TTSOptions, TranscriptionOptions, VideoGenerationOptions, WorldGenerationOptions, LiveVideoGenerationOptions } from './types.js';
|
|
2
|
-
export type GenerationKind = 'image' | 'audio' | 'tts' | 'video' | 'transcription' | 'world' | 'liveVideo';
|
|
1
|
+
import { AudioGenerationOptions, ImageGenerationOptions, TTSOptions, TranscriptionOptions, VoiceGenerationOptions, VideoGenerationOptions, WorldGenerationOptions, LiveVideoGenerationOptions } from './types.js';
|
|
2
|
+
export type GenerationKind = 'image' | 'audio' | 'tts' | 'voice' | 'video' | 'transcription' | 'world' | 'liveVideo';
|
|
3
3
|
type GenerationInputByKind = {
|
|
4
4
|
image: Omit<ImageGenerationOptions, 'logger' | 'model'>;
|
|
5
5
|
audio: Omit<AudioGenerationOptions, 'logger' | 'model'>;
|
|
6
6
|
tts: Omit<TTSOptions, 'logger' | 'model'>;
|
|
7
|
+
voice: Omit<VoiceGenerationOptions, 'logger' | 'model'>;
|
|
7
8
|
video: Omit<VideoGenerationOptions, 'logger' | 'model'>;
|
|
8
9
|
transcription: Omit<TranscriptionOptions, 'logger' | 'model'>;
|
|
9
10
|
world: Omit<WorldGenerationOptions, 'logger' | 'model'>;
|
package/dist/esm/client.js
CHANGED
|
@@ -21,6 +21,7 @@ var generationKinds = [
|
|
|
21
21
|
"image",
|
|
22
22
|
"audio",
|
|
23
23
|
"tts",
|
|
24
|
+
"voice",
|
|
24
25
|
"video",
|
|
25
26
|
"transcription",
|
|
26
27
|
"world",
|
|
@@ -38,14 +39,31 @@ function isGenerationEnvelope(body) {
|
|
|
38
39
|
function assertGenerationKind(kind) {
|
|
39
40
|
if (!generationKinds.includes(kind)) throw new Error(`Unsupported generation kind: ${String(kind)}. Expected one of ${generationKinds.join(", ")}.`);
|
|
40
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* The input field(s) that identify a generation body for a kind. Most kinds
|
|
44
|
+
* have exactly one; `voice` accepts either of its two creation modes, so any
|
|
45
|
+
* one of its keys is enough.
|
|
46
|
+
*/
|
|
47
|
+
function requiredKeysForKind(kind) {
|
|
48
|
+
switch (kind) {
|
|
49
|
+
case "tts": return ["text"];
|
|
50
|
+
case "transcription": return ["audio"];
|
|
51
|
+
case "voice": return ["prompt", "referenceAudio"];
|
|
52
|
+
case "image":
|
|
53
|
+
case "audio":
|
|
54
|
+
case "video":
|
|
55
|
+
case "world":
|
|
56
|
+
case "liveVideo": return ["prompt"];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
41
59
|
function assertInputForKind(kind, input) {
|
|
42
60
|
if (!isRecord(input)) throw new Error(`Generation ${kind} input must be an object.`);
|
|
43
|
-
const
|
|
44
|
-
if (!hasOwnKey(input,
|
|
61
|
+
const requiredKeys = requiredKeysForKind(kind);
|
|
62
|
+
if (!requiredKeys.some((key) => hasOwnKey(input, key))) throw new Error(`Generation ${kind} input must include ${requiredKeys.join(" or ")}.`);
|
|
45
63
|
}
|
|
46
64
|
function isInputForKind(kind, input) {
|
|
47
65
|
if (!isRecord(input)) return false;
|
|
48
|
-
return hasOwnKey(input,
|
|
66
|
+
return requiredKeysForKind(kind).some((key) => hasOwnKey(input, key));
|
|
49
67
|
}
|
|
50
68
|
function forwardedPropsFromEnvelope(envelope) {
|
|
51
69
|
if (!hasOwnKey(envelope, "forwardedProps")) return {};
|
package/dist/esm/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":[],"sources":["../../src/client.ts"],"sourcesContent":["import type {\n AudioGenerationOptions,\n ImageGenerationOptions,\n TTSOptions,\n TranscriptionOptions,\n VideoGenerationOptions,\n WorldGenerationOptions,\n LiveVideoGenerationOptions,\n} from './types'\n\nexport type GenerationKind =\n | 'image'\n | 'audio'\n | 'tts'\n | 'video'\n | 'transcription'\n | 'world'\n | 'liveVideo'\n\ntype GenerationInputByKind = {\n image: Omit<ImageGenerationOptions, 'logger' | 'model'>\n audio: Omit<AudioGenerationOptions, 'logger' | 'model'>\n tts: Omit<TTSOptions, 'logger' | 'model'>\n video: Omit<VideoGenerationOptions, 'logger' | 'model'>\n transcription: Omit<TranscriptionOptions, 'logger' | 'model'>\n world: Omit<WorldGenerationOptions, 'logger' | 'model'>\n liveVideo: Omit<LiveVideoGenerationOptions, 'logger' | 'model'>\n}\n\nexport interface GenerationParams<TKind extends GenerationKind> {\n input: GenerationInputByKind[TKind]\n forwardedProps: Record<string, unknown>\n threadId?: string\n runId?: string\n}\n\nconst generationKinds = [\n 'image',\n 'audio',\n 'tts',\n 'video',\n 'transcription',\n 'world',\n 'liveVideo',\n] as const satisfies ReadonlyArray<GenerationKind>\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction hasOwnKey(value: Record<string, unknown>, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(value, key)\n}\n\nfunction isGenerationEnvelope(body: unknown): body is Record<string, unknown> {\n return (\n isRecord(body) &&\n (hasOwnKey(body, 'data') || hasOwnKey(body, 'forwardedProps'))\n )\n}\n\nfunction assertGenerationKind(kind: unknown): asserts kind is GenerationKind {\n if (!generationKinds.includes(kind as GenerationKind)) {\n throw new Error(\n `Unsupported generation kind: ${String(\n kind,\n )}. Expected one of ${generationKinds.join(', ')}.`,\n )\n }\n}\n\nfunction assertInputForKind(\n kind: GenerationKind,\n input: unknown,\n): asserts input is GenerationInputByKind[GenerationKind] {\n if (!isRecord(input)) {\n throw new Error(`Generation ${kind} input must be an object.`)\n }\n\n const requiredKey =\n kind === 'tts' ? 'text' : kind === 'transcription' ? 'audio' : 'prompt'\n\n if (!hasOwnKey(input, requiredKey)) {\n throw new Error(`Generation ${kind} input must include ${requiredKey}.`)\n }\n}\n\nfunction isInputForKind(kind: GenerationKind, input: unknown): boolean {\n if (!isRecord(input)) return false\n\n const requiredKey =\n kind === 'tts' ? 'text' : kind === 'transcription' ? 'audio' : 'prompt'\n\n return hasOwnKey(input, requiredKey)\n}\n\nfunction forwardedPropsFromEnvelope(\n envelope: Record<string, unknown>,\n): Record<string, unknown> {\n if (!hasOwnKey(envelope, 'forwardedProps')) {\n return {}\n }\n\n if (!isRecord(envelope.forwardedProps)) {\n throw new Error('Generation envelope forwardedProps must be an object.')\n }\n\n return envelope.forwardedProps\n}\n\nfunction optionalStringField(\n envelope: Record<string, unknown>,\n key: 'threadId' | 'runId',\n): string | undefined {\n if (!hasOwnKey(envelope, key)) {\n return undefined\n }\n\n const value = envelope[key]\n if (typeof value !== 'string') {\n throw new Error(`Generation envelope ${key} must be a string.`)\n }\n\n return value\n}\n\nfunction generationIdentityFields(envelope: Record<string, unknown>): {\n threadId?: string\n runId?: string\n} {\n const identity: {\n threadId?: string\n runId?: string\n } = {}\n const threadId = optionalStringField(envelope, 'threadId')\n const runId = optionalStringField(envelope, 'runId')\n\n if (threadId !== undefined) identity.threadId = threadId\n if (runId !== undefined) identity.runId = runId\n\n return identity\n}\n\nexport function generationParamsFromBody<TKind extends GenerationKind>(\n kind: TKind,\n body: unknown,\n): GenerationParams<TKind> {\n assertGenerationKind(kind)\n\n if (isInputForKind(kind, body)) {\n assertInputForKind(kind, body)\n return {\n input: body as GenerationInputByKind[TKind],\n forwardedProps: {},\n }\n }\n\n if (!isGenerationEnvelope(body)) {\n assertInputForKind(kind, body)\n return {\n input: body as GenerationInputByKind[TKind],\n forwardedProps: {},\n }\n }\n\n if (!hasOwnKey(body, 'data')) {\n throw new Error(`Generation ${kind} envelope must include data.`)\n }\n\n const input = body.data\n assertInputForKind(kind, input)\n\n const forwardedProps = forwardedPropsFromEnvelope(body)\n\n return {\n input: input as GenerationInputByKind[TKind],\n forwardedProps,\n ...generationIdentityFields(body),\n }\n}\n\nexport async function generationParamsFromRequest<TKind extends GenerationKind>(\n kind: TKind,\n request: Request,\n): Promise<GenerationParams<TKind>> {\n let body: unknown\n try {\n body = await request.json()\n } catch (error) {\n throw new Error('Invalid JSON request body.', { cause: error })\n }\n\n if (!isRecord(body)) {\n throw new Error('Generation request body must be a JSON object.')\n }\n\n return generationParamsFromBody(kind, body)\n}\n\nexport enum EventType {\n TEXT_MESSAGE_START = 'TEXT_MESSAGE_START',\n TEXT_MESSAGE_CONTENT = 'TEXT_MESSAGE_CONTENT',\n TEXT_MESSAGE_END = 'TEXT_MESSAGE_END',\n TEXT_MESSAGE_CHUNK = 'TEXT_MESSAGE_CHUNK',\n TOOL_CALL_START = 'TOOL_CALL_START',\n TOOL_CALL_ARGS = 'TOOL_CALL_ARGS',\n TOOL_CALL_END = 'TOOL_CALL_END',\n TOOL_CALL_CHUNK = 'TOOL_CALL_CHUNK',\n TOOL_CALL_RESULT = 'TOOL_CALL_RESULT',\n THINKING_START = 'THINKING_START',\n THINKING_END = 'THINKING_END',\n THINKING_TEXT_MESSAGE_START = 'THINKING_TEXT_MESSAGE_START',\n THINKING_TEXT_MESSAGE_CONTENT = 'THINKING_TEXT_MESSAGE_CONTENT',\n THINKING_TEXT_MESSAGE_END = 'THINKING_TEXT_MESSAGE_END',\n STATE_SNAPSHOT = 'STATE_SNAPSHOT',\n STATE_DELTA = 'STATE_DELTA',\n MESSAGES_SNAPSHOT = 'MESSAGES_SNAPSHOT',\n ACTIVITY_SNAPSHOT = 'ACTIVITY_SNAPSHOT',\n ACTIVITY_DELTA = 'ACTIVITY_DELTA',\n RAW = 'RAW',\n CUSTOM = 'CUSTOM',\n RUN_STARTED = 'RUN_STARTED',\n RUN_FINISHED = 'RUN_FINISHED',\n RUN_ERROR = 'RUN_ERROR',\n STEP_STARTED = 'STEP_STARTED',\n STEP_FINISHED = 'STEP_FINISHED',\n REASONING_START = 'REASONING_START',\n REASONING_MESSAGE_START = 'REASONING_MESSAGE_START',\n REASONING_MESSAGE_CONTENT = 'REASONING_MESSAGE_CONTENT',\n REASONING_MESSAGE_END = 'REASONING_MESSAGE_END',\n REASONING_MESSAGE_CHUNK = 'REASONING_MESSAGE_CHUNK',\n REASONING_END = 'REASONING_END',\n REASONING_ENCRYPTED_VALUE = 'REASONING_ENCRYPTED_VALUE',\n}\n\nexport {\n toolDefinition,\n type AnyClientTool,\n type ClientTool,\n type InferToolInput,\n type InferToolName,\n type InferToolOutput,\n type ApprovalCapabilityOf,\n type ApprovalSchemaConfig,\n type ApprovalSchemaOf,\n type InputSchemaOf,\n type OutputSchemaOf,\n type NoSchema,\n type ToolDefinition,\n type ToolDefinitionConfig,\n type ToolDefinitionInstance,\n} from './activities/chat/tools/tool-definition'\n\nexport {\n hashSchemaInput,\n normalizeApprovalSchema,\n type NormalizedApprovalSchema,\n type NormalizedSchemaInput,\n} from './activities/chat/tools/approval-schema'\n\nexport {\n canonicalInterruptJson,\n cloneAndDeepFreezeJson,\n digestInterruptJson,\n} from './interrupt-serialization'\n\nexport {\n convertSchemaToJsonSchema,\n isStandardSchema,\n parseWithStandardSchema,\n validateWithStandardSchema,\n} from './activities/chat/tools/schema-converter'\n\nexport {\n convertMessagesToModelMessages,\n generateMessageId,\n modelMessageToUIMessage,\n modelMessagesToUIMessages,\n normalizeToUIMessage,\n uiMessageToModelMessages,\n} from './activities/chat/messages'\n\nexport {\n BatchStrategy,\n CompositeStrategy,\n defaultJSONParser,\n ImmediateStrategy,\n parsePartialJSON,\n PartialJSONParser,\n PunctuationStrategy,\n StreamProcessor,\n WordBoundaryStrategy,\n} from './activities/chat/stream/index'\nexport type {\n ChunkRecording,\n ChunkStrategy,\n InternalToolCallState,\n JSONParser,\n ProcessorResult,\n ProcessorState,\n StreamProcessorEvents,\n StreamProcessorOptions,\n ToolCallState,\n ToolResultState,\n} from './activities/chat/stream/index'\n\nexport { uiMessagesToWire } from './utilities/ag-ui-wire'\nexport {\n mergeMetadata,\n tanstackMetadata,\n withTanstackMetadata,\n} from './utilities/merge-metadata'\nexport { fromSpecTokenUsage, toSpecTokenUsage } from './utilities/ag-ui-usage'\nexport type { SpecTokenUsage } from './utilities/ag-ui-usage'\nexport { normalizeStreamChunk } from './utilities/normalize-stream-chunk'\nexport { restoreInboundChunk } from './utilities/restore-inbound-chunk'\nexport type { AdapterYieldChunk } from './utilities/adapter-yield-chunk'\nexport { getChunkRunId, getChunkThreadId } from './utilities/chunk-ids'\nexport type { WireMessage } from './utilities/ag-ui-wire'\n\nexport type {\n AudioPart,\n ContentPart,\n ContentPartDataSource,\n ContentPartSource,\n ContentPartUrlSource,\n CustomEvent,\n DocumentPart,\n ImagePart,\n MediaInputMetadata,\n MediaInputRole,\n MediaPrompt,\n MediaPromptPart,\n MessagePart,\n ModelMessage,\n PersistedArtifactActivity,\n PersistedArtifactRef,\n PersistedArtifactRole,\n Interrupt,\n RunAgentResumeItem,\n RunErrorEvent,\n RunFinishedEvent,\n RunFinishedOutcome,\n SchemaInput,\n StreamChunk,\n StructuredOutputPart,\n TextPart,\n TanStackMessageMetadata,\n TanStackRunMetadata,\n ThinkingPart,\n ToolCall,\n ToolCallPart,\n ToolResultPart,\n UIMessage,\n UIResourcePart,\n VideoPart,\n InferSchemaType,\n} from './types'\n\n// Enumerated, not `export *` — see the matching note in `index.ts`. The\n// interrupt protocol surface is a commitment, so it is published field by\n// field.\nexport {\n INTERRUPT_BINDING_VERSION,\n canonicalizeInterruptResolutions,\n} from './interrupts'\nexport {\n defineInterrupt,\n hashInterruptDefinitionSchema,\n INTERRUPT_PAYLOAD_METADATA_KEY,\n} from './interrupt-definition'\nexport {\n INTERRUPT_CONTINUATION_METADATA_KEY,\n INTERRUPT_CONTINUATION_VERSION,\n genericInterruptContinuationFromDescriptor,\n readGenericInterruptContinuation,\n wrapGenericInterruptContinuation,\n} from './generic-interrupt-continuation'\nexport type {\n GenericInterruptContinuation,\n GenericInterruptContinuationReadResult,\n} from './generic-interrupt-continuation'\nexport type {\n GenericInterruptRequest,\n InterruptDefinition,\n} from './interrupt-definition'\nexport type {\n BatchInterruptError,\n BatchInterruptErrorCode,\n InterruptBinding,\n InterruptCorrelation,\n InterruptSubmissionError,\n ItemInterruptError,\n ItemInterruptErrorCode,\n ToolApprovalResolution,\n UnopenedInterruptBinding,\n} from './interrupts'\n\nexport {\n INTERRUPT_BINDING_METADATA_KEY,\n readInterruptBinding,\n readUnopenedInterruptBinding,\n withInterruptBinding,\n withoutInterruptBinding,\n} from './interrupt-resume'\n\nexport type {\n AudioVisualization,\n RealtimeAdapter,\n RealtimeConnection,\n RealtimeError,\n RealtimeErrorCode,\n RealtimeEvent,\n RealtimeEventHandler,\n RealtimeEventPayloads,\n RealtimeMessage,\n RealtimeMessagePart,\n RealtimeMode,\n RealtimeSessionConfig,\n RealtimeStatus,\n RealtimeToken,\n RealtimeAudioPart,\n RealtimeImagePart,\n RealtimeTextPart,\n RealtimeToolCallPart,\n RealtimeToolResultPart,\n VADConfig,\n} from './realtime/types'\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoCA,IAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,UAAU,OAAgC,KAAsB;CACvE,OAAO,OAAO,UAAU,eAAe,KAAK,OAAO,GAAG;AACxD;AAEA,SAAS,qBAAqB,MAAgD;CAC5E,OACE,SAAS,IAAI,MACZ,UAAU,MAAM,MAAM,KAAK,UAAU,MAAM,gBAAgB;AAEhE;AAEA,SAAS,qBAAqB,MAA+C;CAC3E,IAAI,CAAC,gBAAgB,SAAS,IAAsB,GAClD,MAAM,IAAI,MACR,gCAAgC,OAC9B,IACF,EAAE,oBAAoB,gBAAgB,KAAK,IAAI,EAAE,EACnD;AAEJ;AAEA,SAAS,mBACP,M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ts"],"sourcesContent":["import type {\n AudioGenerationOptions,\n ImageGenerationOptions,\n TTSOptions,\n TranscriptionOptions,\n VoiceGenerationOptions,\n VideoGenerationOptions,\n WorldGenerationOptions,\n LiveVideoGenerationOptions,\n} from './types'\n\nexport type GenerationKind =\n | 'image'\n | 'audio'\n | 'tts'\n | 'voice'\n | 'video'\n | 'transcription'\n | 'world'\n | 'liveVideo'\n\ntype GenerationInputByKind = {\n image: Omit<ImageGenerationOptions, 'logger' | 'model'>\n audio: Omit<AudioGenerationOptions, 'logger' | 'model'>\n tts: Omit<TTSOptions, 'logger' | 'model'>\n voice: Omit<VoiceGenerationOptions, 'logger' | 'model'>\n video: Omit<VideoGenerationOptions, 'logger' | 'model'>\n transcription: Omit<TranscriptionOptions, 'logger' | 'model'>\n world: Omit<WorldGenerationOptions, 'logger' | 'model'>\n liveVideo: Omit<LiveVideoGenerationOptions, 'logger' | 'model'>\n}\n\nexport interface GenerationParams<TKind extends GenerationKind> {\n input: GenerationInputByKind[TKind]\n forwardedProps: Record<string, unknown>\n threadId?: string\n runId?: string\n}\n\nconst generationKinds = [\n 'image',\n 'audio',\n 'tts',\n 'voice',\n 'video',\n 'transcription',\n 'world',\n 'liveVideo',\n] as const satisfies ReadonlyArray<GenerationKind>\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction hasOwnKey(value: Record<string, unknown>, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(value, key)\n}\n\nfunction isGenerationEnvelope(body: unknown): body is Record<string, unknown> {\n return (\n isRecord(body) &&\n (hasOwnKey(body, 'data') || hasOwnKey(body, 'forwardedProps'))\n )\n}\n\nfunction assertGenerationKind(kind: unknown): asserts kind is GenerationKind {\n if (!generationKinds.includes(kind as GenerationKind)) {\n throw new Error(\n `Unsupported generation kind: ${String(\n kind,\n )}. Expected one of ${generationKinds.join(', ')}.`,\n )\n }\n}\n\n/**\n * The input field(s) that identify a generation body for a kind. Most kinds\n * have exactly one; `voice` accepts either of its two creation modes, so any\n * one of its keys is enough.\n */\nfunction requiredKeysForKind(kind: GenerationKind): Array<string> {\n // Enumerated rather than defaulted so a new generation kind has to declare\n // the field that identifies its body instead of silently inheriting\n // `prompt`.\n switch (kind) {\n case 'tts':\n return ['text']\n case 'transcription':\n return ['audio']\n case 'voice':\n return ['prompt', 'referenceAudio']\n case 'image':\n case 'audio':\n case 'video':\n case 'world':\n case 'liveVideo':\n return ['prompt']\n }\n}\n\nfunction assertInputForKind(\n kind: GenerationKind,\n input: unknown,\n): asserts input is GenerationInputByKind[GenerationKind] {\n if (!isRecord(input)) {\n throw new Error(`Generation ${kind} input must be an object.`)\n }\n\n const requiredKeys = requiredKeysForKind(kind)\n\n if (!requiredKeys.some((key) => hasOwnKey(input, key))) {\n throw new Error(\n `Generation ${kind} input must include ${requiredKeys.join(' or ')}.`,\n )\n }\n}\n\nfunction isInputForKind(kind: GenerationKind, input: unknown): boolean {\n if (!isRecord(input)) return false\n\n return requiredKeysForKind(kind).some((key) => hasOwnKey(input, key))\n}\n\nfunction forwardedPropsFromEnvelope(\n envelope: Record<string, unknown>,\n): Record<string, unknown> {\n if (!hasOwnKey(envelope, 'forwardedProps')) {\n return {}\n }\n\n if (!isRecord(envelope.forwardedProps)) {\n throw new Error('Generation envelope forwardedProps must be an object.')\n }\n\n return envelope.forwardedProps\n}\n\nfunction optionalStringField(\n envelope: Record<string, unknown>,\n key: 'threadId' | 'runId',\n): string | undefined {\n if (!hasOwnKey(envelope, key)) {\n return undefined\n }\n\n const value = envelope[key]\n if (typeof value !== 'string') {\n throw new Error(`Generation envelope ${key} must be a string.`)\n }\n\n return value\n}\n\nfunction generationIdentityFields(envelope: Record<string, unknown>): {\n threadId?: string\n runId?: string\n} {\n const identity: {\n threadId?: string\n runId?: string\n } = {}\n const threadId = optionalStringField(envelope, 'threadId')\n const runId = optionalStringField(envelope, 'runId')\n\n if (threadId !== undefined) identity.threadId = threadId\n if (runId !== undefined) identity.runId = runId\n\n return identity\n}\n\nexport function generationParamsFromBody<TKind extends GenerationKind>(\n kind: TKind,\n body: unknown,\n): GenerationParams<TKind> {\n assertGenerationKind(kind)\n\n if (isInputForKind(kind, body)) {\n assertInputForKind(kind, body)\n return {\n input: body as GenerationInputByKind[TKind],\n forwardedProps: {},\n }\n }\n\n if (!isGenerationEnvelope(body)) {\n assertInputForKind(kind, body)\n return {\n input: body as GenerationInputByKind[TKind],\n forwardedProps: {},\n }\n }\n\n if (!hasOwnKey(body, 'data')) {\n throw new Error(`Generation ${kind} envelope must include data.`)\n }\n\n const input = body.data\n assertInputForKind(kind, input)\n\n const forwardedProps = forwardedPropsFromEnvelope(body)\n\n return {\n input: input as GenerationInputByKind[TKind],\n forwardedProps,\n ...generationIdentityFields(body),\n }\n}\n\nexport async function generationParamsFromRequest<TKind extends GenerationKind>(\n kind: TKind,\n request: Request,\n): Promise<GenerationParams<TKind>> {\n let body: unknown\n try {\n body = await request.json()\n } catch (error) {\n throw new Error('Invalid JSON request body.', { cause: error })\n }\n\n if (!isRecord(body)) {\n throw new Error('Generation request body must be a JSON object.')\n }\n\n return generationParamsFromBody(kind, body)\n}\n\nexport enum EventType {\n TEXT_MESSAGE_START = 'TEXT_MESSAGE_START',\n TEXT_MESSAGE_CONTENT = 'TEXT_MESSAGE_CONTENT',\n TEXT_MESSAGE_END = 'TEXT_MESSAGE_END',\n TEXT_MESSAGE_CHUNK = 'TEXT_MESSAGE_CHUNK',\n TOOL_CALL_START = 'TOOL_CALL_START',\n TOOL_CALL_ARGS = 'TOOL_CALL_ARGS',\n TOOL_CALL_END = 'TOOL_CALL_END',\n TOOL_CALL_CHUNK = 'TOOL_CALL_CHUNK',\n TOOL_CALL_RESULT = 'TOOL_CALL_RESULT',\n THINKING_START = 'THINKING_START',\n THINKING_END = 'THINKING_END',\n THINKING_TEXT_MESSAGE_START = 'THINKING_TEXT_MESSAGE_START',\n THINKING_TEXT_MESSAGE_CONTENT = 'THINKING_TEXT_MESSAGE_CONTENT',\n THINKING_TEXT_MESSAGE_END = 'THINKING_TEXT_MESSAGE_END',\n STATE_SNAPSHOT = 'STATE_SNAPSHOT',\n STATE_DELTA = 'STATE_DELTA',\n MESSAGES_SNAPSHOT = 'MESSAGES_SNAPSHOT',\n ACTIVITY_SNAPSHOT = 'ACTIVITY_SNAPSHOT',\n ACTIVITY_DELTA = 'ACTIVITY_DELTA',\n RAW = 'RAW',\n CUSTOM = 'CUSTOM',\n RUN_STARTED = 'RUN_STARTED',\n RUN_FINISHED = 'RUN_FINISHED',\n RUN_ERROR = 'RUN_ERROR',\n STEP_STARTED = 'STEP_STARTED',\n STEP_FINISHED = 'STEP_FINISHED',\n REASONING_START = 'REASONING_START',\n REASONING_MESSAGE_START = 'REASONING_MESSAGE_START',\n REASONING_MESSAGE_CONTENT = 'REASONING_MESSAGE_CONTENT',\n REASONING_MESSAGE_END = 'REASONING_MESSAGE_END',\n REASONING_MESSAGE_CHUNK = 'REASONING_MESSAGE_CHUNK',\n REASONING_END = 'REASONING_END',\n REASONING_ENCRYPTED_VALUE = 'REASONING_ENCRYPTED_VALUE',\n}\n\nexport {\n toolDefinition,\n type AnyClientTool,\n type ClientTool,\n type InferToolInput,\n type InferToolName,\n type InferToolOutput,\n type ApprovalCapabilityOf,\n type ApprovalSchemaConfig,\n type ApprovalSchemaOf,\n type InputSchemaOf,\n type OutputSchemaOf,\n type NoSchema,\n type ToolDefinition,\n type ToolDefinitionConfig,\n type ToolDefinitionInstance,\n} from './activities/chat/tools/tool-definition'\n\nexport {\n hashSchemaInput,\n normalizeApprovalSchema,\n type NormalizedApprovalSchema,\n type NormalizedSchemaInput,\n} from './activities/chat/tools/approval-schema'\n\nexport {\n canonicalInterruptJson,\n cloneAndDeepFreezeJson,\n digestInterruptJson,\n} from './interrupt-serialization'\n\nexport {\n convertSchemaToJsonSchema,\n isStandardSchema,\n parseWithStandardSchema,\n validateWithStandardSchema,\n} from './activities/chat/tools/schema-converter'\n\nexport {\n convertMessagesToModelMessages,\n generateMessageId,\n modelMessageToUIMessage,\n modelMessagesToUIMessages,\n normalizeToUIMessage,\n uiMessageToModelMessages,\n} from './activities/chat/messages'\n\nexport {\n BatchStrategy,\n CompositeStrategy,\n defaultJSONParser,\n ImmediateStrategy,\n parsePartialJSON,\n PartialJSONParser,\n PunctuationStrategy,\n StreamProcessor,\n WordBoundaryStrategy,\n} from './activities/chat/stream/index'\nexport type {\n ChunkRecording,\n ChunkStrategy,\n InternalToolCallState,\n JSONParser,\n ProcessorResult,\n ProcessorState,\n StreamProcessorEvents,\n StreamProcessorOptions,\n ToolCallState,\n ToolResultState,\n} from './activities/chat/stream/index'\n\nexport { uiMessagesToWire } from './utilities/ag-ui-wire'\nexport {\n mergeMetadata,\n tanstackMetadata,\n withTanstackMetadata,\n} from './utilities/merge-metadata'\nexport { fromSpecTokenUsage, toSpecTokenUsage } from './utilities/ag-ui-usage'\nexport type { SpecTokenUsage } from './utilities/ag-ui-usage'\nexport { normalizeStreamChunk } from './utilities/normalize-stream-chunk'\nexport { restoreInboundChunk } from './utilities/restore-inbound-chunk'\nexport type { AdapterYieldChunk } from './utilities/adapter-yield-chunk'\nexport { getChunkRunId, getChunkThreadId } from './utilities/chunk-ids'\nexport type { WireMessage } from './utilities/ag-ui-wire'\n\nexport type {\n AudioPart,\n ContentPart,\n ContentPartDataSource,\n ContentPartSource,\n ContentPartUrlSource,\n CustomEvent,\n DocumentPart,\n ImagePart,\n MediaInputMetadata,\n MediaInputRole,\n MediaPrompt,\n MediaPromptPart,\n MessagePart,\n ModelMessage,\n PersistedArtifactActivity,\n PersistedArtifactRef,\n PersistedArtifactRole,\n Interrupt,\n RunAgentResumeItem,\n RunErrorEvent,\n RunFinishedEvent,\n RunFinishedOutcome,\n SchemaInput,\n StreamChunk,\n StructuredOutputPart,\n TextPart,\n TanStackMessageMetadata,\n TanStackRunMetadata,\n ThinkingPart,\n ToolCall,\n ToolCallPart,\n ToolResultPart,\n UIMessage,\n UIResourcePart,\n VideoPart,\n InferSchemaType,\n} from './types'\n\n// Enumerated, not `export *` — see the matching note in `index.ts`. The\n// interrupt protocol surface is a commitment, so it is published field by\n// field.\nexport {\n INTERRUPT_BINDING_VERSION,\n canonicalizeInterruptResolutions,\n} from './interrupts'\nexport {\n defineInterrupt,\n hashInterruptDefinitionSchema,\n INTERRUPT_PAYLOAD_METADATA_KEY,\n} from './interrupt-definition'\nexport {\n INTERRUPT_CONTINUATION_METADATA_KEY,\n INTERRUPT_CONTINUATION_VERSION,\n genericInterruptContinuationFromDescriptor,\n readGenericInterruptContinuation,\n wrapGenericInterruptContinuation,\n} from './generic-interrupt-continuation'\nexport type {\n GenericInterruptContinuation,\n GenericInterruptContinuationReadResult,\n} from './generic-interrupt-continuation'\nexport type {\n GenericInterruptRequest,\n InterruptDefinition,\n} from './interrupt-definition'\nexport type {\n BatchInterruptError,\n BatchInterruptErrorCode,\n InterruptBinding,\n InterruptCorrelation,\n InterruptSubmissionError,\n ItemInterruptError,\n ItemInterruptErrorCode,\n ToolApprovalResolution,\n UnopenedInterruptBinding,\n} from './interrupts'\n\nexport {\n INTERRUPT_BINDING_METADATA_KEY,\n readInterruptBinding,\n readUnopenedInterruptBinding,\n withInterruptBinding,\n withoutInterruptBinding,\n} from './interrupt-resume'\n\nexport type {\n AudioVisualization,\n RealtimeAdapter,\n RealtimeConnection,\n RealtimeError,\n RealtimeErrorCode,\n RealtimeEvent,\n RealtimeEventHandler,\n RealtimeEventPayloads,\n RealtimeMessage,\n RealtimeMessagePart,\n RealtimeMode,\n RealtimeSessionConfig,\n RealtimeStatus,\n RealtimeToken,\n RealtimeAudioPart,\n RealtimeImagePart,\n RealtimeTextPart,\n RealtimeToolCallPart,\n RealtimeToolResultPart,\n VADConfig,\n} from './realtime/types'\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuCA,IAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO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B,MAAM,IAAI;AAC5C;AAEA,IAAY,YAAL,yBAAA,WAAA;CACL,UAAA,wBAAA;CACA,UAAA,0BAAA;CACA,UAAA,sBAAA;CACA,UAAA,wBAAA;CACA,UAAA,qBAAA;CACA,UAAA,oBAAA;CACA,UAAA,mBAAA;CACA,UAAA,qBAAA;CACA,UAAA,sBAAA;CACA,UAAA,oBAAA;CACA,UAAA,kBAAA;CACA,UAAA,iCAAA;CACA,UAAA,mCAAA;CACA,UAAA,+BAAA;CACA,UAAA,oBAAA;CACA,UAAA,iBAAA;CACA,UAAA,uBAAA;CACA,UAAA,uBAAA;CACA,UAAA,oBAAA;CACA,UAAA,SAAA;CACA,UAAA,YAAA;CACA,UAAA,iBAAA;CACA,UAAA,kBAAA;CACA,UAAA,eAAA;CACA,UAAA,kBAAA;CACA,UAAA,mBAAA;CACA,UAAA,qBAAA;CACA,UAAA,6BAAA;CACA,UAAA,+BAAA;CACA,UAAA,2BAAA;CACA,UAAA,6BAAA;CACA,UAAA,mBAAA;CACA,UAAA,+BAAA;;AACF,EAAA,CAAA,CAAA"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { chat, summarize, rerank, generateImage, generateAudio, generateVideo, getVideoJobStatus, generateSpeech, generateTranscription, embed, generateWorld, generateLiveVideo, } from './activities/index.js';
|
|
1
|
+
export { chat, summarize, rerank, decide, choice, score, boolean, generateImage, generateAudio, generateVideo, getVideoJobStatus, generateSpeech, listVoices, generateVoice, generateTranscription, embed, generateWorld, generateLiveVideo, } from './activities/index.js';
|
|
2
2
|
export { createChatOptions } from './activities/chat/index.js';
|
|
3
3
|
export { createSummarizeOptions } from './activities/summarize/index.js';
|
|
4
4
|
export { createRerankOptions } from './activities/rerank/index.js';
|
|
@@ -6,12 +6,14 @@ export { createImageOptions } from './activities/generateImage/index.js';
|
|
|
6
6
|
export { createAudioOptions } from './activities/generateAudio/index.js';
|
|
7
7
|
export { createVideoOptions } from './activities/generateVideo/index.js';
|
|
8
8
|
export { createSpeechOptions } from './activities/generateSpeech/index.js';
|
|
9
|
+
export { createVoiceOptions } from './activities/generateVoice/index.js';
|
|
9
10
|
export { createTranscriptionOptions } from './activities/generateTranscription/index.js';
|
|
10
11
|
export { createEmbedOptions } from './activities/embed/index.js';
|
|
11
12
|
export { createWorldOptions } from './activities/generateWorld/index.js';
|
|
12
13
|
export { createLiveVideoOptions } from './activities/generateLiveVideo/index.js';
|
|
13
|
-
export type { AIAdapter, ImageAdapter, AnyImageAdapter, TextAdapter, AnyTextAdapter, AnySummarizeAdapter, SummarizeAdapter, AnyAudioAdapter, AudioAdapter, AnyTTSAdapter, TTSAdapter, AnyTranscriptionAdapter, TranscriptionAdapter, AnyVideoAdapter, VideoAdapter, AnyEmbeddingAdapter, EmbeddingAdapter, AnyRerankAdapter, RerankAdapter, AnyWorldAdapter, WorldAdapter, AnyLiveVideoAdapter, LiveVideoAdapter, } from './activities/index.js';
|
|
14
|
+
export type { AIAdapter, ImageAdapter, AnyImageAdapter, TextAdapter, AnyTextAdapter, AnySummarizeAdapter, SummarizeAdapter, AnyAudioAdapter, AudioAdapter, AnyTTSAdapter, TTSAdapter, TTSCapabilities, AnyVoiceAdapter, VoiceAdapter, AnyTranscriptionAdapter, TranscriptionAdapter, AnyVideoAdapter, VideoAdapter, AnyEmbeddingAdapter, EmbeddingAdapter, AnyRerankAdapter, RerankAdapter, AnyEvaluateAdapter, EvaluateAdapter, ChoiceAnswer, ScoreAnswer, BooleanAnswer, EvaluateResult, WireQuestion, WireAnswer, AnyWorldAdapter, WorldAdapter, AnyLiveVideoAdapter, LiveVideoAdapter, } from './activities/index.js';
|
|
14
15
|
export { BaseRerankAdapter } from './activities/rerank/adapter.js';
|
|
16
|
+
export { BaseEvaluateAdapter } from './activities/evaluate/adapter.js';
|
|
15
17
|
export { toolDefinition, type ToolDefinition, type ToolDefinitionInstance, type ToolDefinitionConfig, type ServerTool, type AnyServerTool, type ClientTool, type AnyClientTool, type InferToolName, type InferToolInput, type InferToolOutput, type ApprovalCapabilityOf, type ApprovalSchemaConfig, type ApprovalSchemaOf, type InputSchemaOf, type OutputSchemaOf, type NoSchema, } from './activities/chat/tools/tool-definition.js';
|
|
16
18
|
export { hashSchemaInput, normalizeApprovalSchema, type NormalizedApprovalSchema, type NormalizedSchemaInput, } from './activities/chat/tools/approval-schema.js';
|
|
17
19
|
export { canonicalInterruptJson, cloneAndDeepFreezeJson, digestInterruptJson, } from './interrupt-serialization.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { memoryStream, replayRunStream, resolveResumeRunId } from "./stream-dura
|
|
|
5
5
|
import { EventType } from "./types.js";
|
|
6
6
|
import { fromSpecTokenUsage, toSpecTokenUsage } from "./utilities/ag-ui-usage.js";
|
|
7
7
|
import { mergeMetadata, withTanstackMetadata } from "./utilities/merge-metadata.js";
|
|
8
|
+
import { CUSTOM_EVENT, isCustomEvent } from "./custom-events.js";
|
|
8
9
|
import { normalizeStreamChunk } from "./utilities/normalize-stream-chunk.js";
|
|
9
10
|
import { ConsoleLogger } from "./logger/console-logger.js";
|
|
10
11
|
import { SkillLimitError } from "./utilities/errors.js";
|
|
@@ -30,11 +31,14 @@ import { chat, createChatOptions } from "./activities/chat/index.js";
|
|
|
30
31
|
import { createSummarizeOptions, summarize } from "./activities/summarize/index.js";
|
|
31
32
|
import { BaseRerankAdapter } from "./activities/rerank/adapter.js";
|
|
32
33
|
import { createRerankOptions, rerank } from "./activities/rerank/index.js";
|
|
34
|
+
import { BaseEvaluateAdapter } from "./activities/evaluate/adapter.js";
|
|
35
|
+
import { boolean, choice, decide, score } from "./activities/evaluate/index.js";
|
|
33
36
|
import { resolveMediaPrompt } from "./utilities/media-prompt.js";
|
|
34
37
|
import { createImageOptions, generateImage } from "./activities/generateImage/index.js";
|
|
35
38
|
import { createAudioOptions, generateAudio } from "./activities/generateAudio/index.js";
|
|
36
39
|
import { createVideoOptions, generateVideo, getVideoJobStatus } from "./activities/generateVideo/index.js";
|
|
37
|
-
import { createSpeechOptions, generateSpeech } from "./activities/generateSpeech/index.js";
|
|
40
|
+
import { createSpeechOptions, generateSpeech, listVoices } from "./activities/generateSpeech/index.js";
|
|
41
|
+
import { createVoiceOptions, generateVoice } from "./activities/generateVoice/index.js";
|
|
38
42
|
import { createTranscriptionOptions, generateTranscription } from "./activities/generateTranscription/index.js";
|
|
39
43
|
import { countEmbeddingInputModalities, requireTextOnlyEmbeddingInput, resolveEmbeddingInput } from "./utilities/embedding-input.js";
|
|
40
44
|
import { createEmbedOptions, embed } from "./activities/embed/index.js";
|
|
@@ -49,7 +53,6 @@ import { INTERRUPT_BOUNDARY_PHASES, INTERRUPT_TOOL_RESUMES } from "./activities/
|
|
|
49
53
|
import { defineChatMiddleware } from "./activities/chat/middleware/define.js";
|
|
50
54
|
import { createChatMiddleware } from "./activities/chat/middleware/builder.js";
|
|
51
55
|
import { MetadataCapability, getMetadata, provideMetadata } from "./activities/chat/middleware/metadata.js";
|
|
52
|
-
import { CUSTOM_EVENT, isCustomEvent } from "./custom-events.js";
|
|
53
56
|
import { buildBaseUsage } from "./utilities/usage.js";
|
|
54
57
|
import { normalizeSystemPrompts } from "./system-prompts.js";
|
|
55
58
|
import { detectImageMimeType } from "./utils.js";
|
|
@@ -61,4 +64,4 @@ import { BatchStrategy, CompositeStrategy, ImmediateStrategy, PunctuationStrateg
|
|
|
61
64
|
import { StreamProcessor, createReplayStream } from "./activities/chat/stream/processor.js";
|
|
62
65
|
import { generationParamsFromBody, generationParamsFromRequest } from "./client.js";
|
|
63
66
|
import { createModel, extendAdapter } from "./extend-adapter.js";
|
|
64
|
-
export { BaseRerankAdapter, BatchStrategy, CUSTOM_EVENT, CompositeStrategy, ConsoleLogger, DISCOVERY_TOOL_NAME, DetachableRunCapability, DuplicateToolNameError, EventType, INTERRUPT_BINDING_METADATA_KEY, INTERRUPT_BINDING_VERSION, INTERRUPT_BOUNDARY_PHASES, INTERRUPT_CONTINUATION_METADATA_KEY, INTERRUPT_CONTINUATION_VERSION, INTERRUPT_PAYLOAD_METADATA_KEY, INTERRUPT_TOOL_RESUMES, ImmediateStrategy, InMemoryRunStore, InterruptResumeValidationError, MCPDuplicateToolNameError, MetadataCapability, PartialJSONParser, PunctuationStrategy, RUN_ACCEPTED_EVENT, RUN_CANCEL_REASON, RunDetachedCapability, SkillLimitError, StandardSchemaValidationError, StreamProcessor, ToolCallManager, WordBoundaryStrategy, brandProviderTool, buildBaseUsage, canonicalInterruptJson, canonicalizeInterruptResolutions, chat, chatParamsFromRequest, chatParamsFromRequestBody, cloneAndDeepFreezeJson, combineStrategies, convertMessagesToModelMessages, convertSchemaToJsonSchema, countEmbeddingInputModalities, createAudioOptions, createCapability, createChatMiddleware, createChatOptions, createEmbedOptions, createFrozenRegistry, createImageOptions, createInterruptBinding, createLiveVideoOptions, createModel, createRealtimeEventEmitter, createReplayStream, createRerankOptions, createSpeechOptions, createSummarizeOptions, createToolRegistry, createTranscriptionOptions, createVideoOptions, createWorldOptions, decodeWsFrame, defaultJSONParser, defineChatMiddleware, defineInterrupt, defineRunStore, detectImageMimeType, digestInterruptJson, embed, encodeWsFrame, extendAdapter, firstSentence, fromSpecTokenUsage, generateAudio, generateImage, generateLiveVideo, generateMessageId, generateSpeech, generateTranscription, generateVideo, generateWorld, generationParamsFromBody, generationParamsFromRequest, genericInterruptContinuationFromDescriptor, getChunkRunId, getChunkThreadId, getDetachableRun, getMetadata, getProviderExecutedMetadata, getRunDetached, getVideoJobStatus, hashSchemaInput, interruptItemError, isCancelRequestedReason, isContentPart, isContentPartArray, isCustomEvent, isProviderExecutedToolCall, isRunStatus, isStandardSchema, isTerminalRunStatus, maxIterations, memoryStream, mergeAgentTools, mergeMetadata, modelMessageToUIMessage, modelMessagesToUIMessages, normalizeApprovalSchema, normalizeStreamChunk, normalizeSystemPrompts, normalizeToUIMessage, normalizeToolResult, parsePartialJSON, parseWithStandardSchema, provideDetachableRun, provideMetadata, provideRunDetached, readGenericInterruptContinuation, readInterruptBinding, readUnopenedInterruptBinding, realtimeToken, renderLazyCatalogEntry, replayRunStream, requestRunCancel, requireTextOnlyEmbeddingInput, rerank, resolveEmbeddingInput, resolveMediaPrompt, resolveResumeRunId, resumeHttpResponse, resumeServerSentEventsResponse, resumeWebSocketResponse, resumeWebSocketStream, streamToText, summarize, toHttpResponse, toHttpStream, toServerSentEventsResponse, toServerSentEventsStream, toSpecTokenUsage, toWebSocketResponse, toWebSocketStream, toolDefinition, uiMessageToModelMessages, uiMessagesToWire, untilFinishReason, validateInterruptResumeBatch, validateWithStandardSchema, wasCancelRequested, withInterruptBinding, withTanstackMetadata, withoutInterruptBinding, wrapGenericInterruptContinuation };
|
|
67
|
+
export { BaseEvaluateAdapter, BaseRerankAdapter, BatchStrategy, CUSTOM_EVENT, CompositeStrategy, ConsoleLogger, DISCOVERY_TOOL_NAME, DetachableRunCapability, DuplicateToolNameError, EventType, INTERRUPT_BINDING_METADATA_KEY, INTERRUPT_BINDING_VERSION, INTERRUPT_BOUNDARY_PHASES, INTERRUPT_CONTINUATION_METADATA_KEY, INTERRUPT_CONTINUATION_VERSION, INTERRUPT_PAYLOAD_METADATA_KEY, INTERRUPT_TOOL_RESUMES, ImmediateStrategy, InMemoryRunStore, InterruptResumeValidationError, MCPDuplicateToolNameError, MetadataCapability, PartialJSONParser, PunctuationStrategy, RUN_ACCEPTED_EVENT, RUN_CANCEL_REASON, RunDetachedCapability, SkillLimitError, StandardSchemaValidationError, StreamProcessor, ToolCallManager, WordBoundaryStrategy, boolean, brandProviderTool, buildBaseUsage, canonicalInterruptJson, canonicalizeInterruptResolutions, chat, chatParamsFromRequest, chatParamsFromRequestBody, choice, cloneAndDeepFreezeJson, combineStrategies, convertMessagesToModelMessages, convertSchemaToJsonSchema, countEmbeddingInputModalities, createAudioOptions, createCapability, createChatMiddleware, createChatOptions, createEmbedOptions, createFrozenRegistry, createImageOptions, createInterruptBinding, createLiveVideoOptions, createModel, createRealtimeEventEmitter, createReplayStream, createRerankOptions, createSpeechOptions, createSummarizeOptions, createToolRegistry, createTranscriptionOptions, createVideoOptions, createVoiceOptions, createWorldOptions, decide, decodeWsFrame, defaultJSONParser, defineChatMiddleware, defineInterrupt, defineRunStore, detectImageMimeType, digestInterruptJson, embed, encodeWsFrame, extendAdapter, firstSentence, fromSpecTokenUsage, generateAudio, generateImage, generateLiveVideo, generateMessageId, generateSpeech, generateTranscription, generateVideo, generateVoice, generateWorld, generationParamsFromBody, generationParamsFromRequest, genericInterruptContinuationFromDescriptor, getChunkRunId, getChunkThreadId, getDetachableRun, getMetadata, getProviderExecutedMetadata, getRunDetached, getVideoJobStatus, hashSchemaInput, interruptItemError, isCancelRequestedReason, isContentPart, isContentPartArray, isCustomEvent, isProviderExecutedToolCall, isRunStatus, isStandardSchema, isTerminalRunStatus, listVoices, maxIterations, memoryStream, mergeAgentTools, mergeMetadata, modelMessageToUIMessage, modelMessagesToUIMessages, normalizeApprovalSchema, normalizeStreamChunk, normalizeSystemPrompts, normalizeToUIMessage, normalizeToolResult, parsePartialJSON, parseWithStandardSchema, provideDetachableRun, provideMetadata, provideRunDetached, readGenericInterruptContinuation, readInterruptBinding, readUnopenedInterruptBinding, realtimeToken, renderLazyCatalogEntry, replayRunStream, requestRunCancel, requireTextOnlyEmbeddingInput, rerank, resolveEmbeddingInput, resolveMediaPrompt, resolveResumeRunId, resumeHttpResponse, resumeServerSentEventsResponse, resumeWebSocketResponse, resumeWebSocketStream, score, streamToText, summarize, toHttpResponse, toHttpStream, toServerSentEventsResponse, toServerSentEventsStream, toSpecTokenUsage, toWebSocketResponse, toWebSocketStream, toolDefinition, uiMessageToModelMessages, uiMessagesToWire, untilFinishReason, validateInterruptResumeBatch, validateWithStandardSchema, wasCancelRequested, withInterruptBinding, withTanstackMetadata, withoutInterruptBinding, wrapGenericInterruptContinuation };
|
|
@@ -18,9 +18,11 @@ var OPERATION_NAME = {
|
|
|
18
18
|
video: "video_generation",
|
|
19
19
|
audio: "audio_generation",
|
|
20
20
|
tts: "text_to_speech",
|
|
21
|
+
voice: "voice_generation",
|
|
21
22
|
transcription: "transcription",
|
|
22
23
|
embedding: "embeddings",
|
|
23
24
|
rerank: "rerank",
|
|
25
|
+
evaluate: "evaluate",
|
|
24
26
|
summarize: "summarize",
|
|
25
27
|
world: "world_generation",
|
|
26
28
|
liveVideo: "live_video_generation"
|