@tanstack/ai 0.21.3 → 0.22.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.
@@ -103,10 +103,10 @@ function createId(prefix: string): string {
103
103
  * @example Generate speech from text
104
104
  * ```ts
105
105
  * import { generateSpeech } from '@tanstack/ai'
106
- * import { openaiTTS } from '@tanstack/ai-openai'
106
+ * import { openaiSpeech } from '@tanstack/ai-openai'
107
107
  *
108
108
  * const result = await generateSpeech({
109
- * adapter: openaiTTS('tts-1-hd'),
109
+ * adapter: openaiSpeech('tts-1-hd'),
110
110
  * text: 'Hello, welcome to TanStack AI!',
111
111
  * voice: 'nova'
112
112
  * })
@@ -117,7 +117,7 @@ function createId(prefix: string): string {
117
117
  * @example With format and speed options
118
118
  * ```ts
119
119
  * const result = await generateSpeech({
120
- * adapter: openaiTTS('tts-1'),
120
+ * adapter: openaiSpeech('tts-1'),
121
121
  * text: 'This is slower speech.',
122
122
  * voice: 'alloy',
123
123
  * format: 'wav',
package/src/types.ts CHANGED
@@ -800,10 +800,26 @@ export interface TextOptions<
800
800
 
801
801
  /**
802
802
  * Schema for structured output.
803
- * When provided, the adapter should use the provider's native structured output API
804
- * to ensure the response conforms to this schema.
805
- * The schema will be converted to JSON Schema format before being sent to the provider.
806
- * Supports any Standard JSON Schema compliant library (Zod, ArkType, Valibot, etc.).
803
+ *
804
+ * **Two distinct use sites:**
805
+ *
806
+ * 1. **User-facing (activity layer):** accepts any
807
+ * {@link SchemaInput} — Zod, ArkType, Valibot, or a raw JSON Schema.
808
+ * The activity layer converts to JSON Schema before handing off.
809
+ *
810
+ * 2. **Adapter-facing (`chatStream` call):** the engine populates this with
811
+ * a pre-converted JSON Schema **only** when the adapter declared
812
+ * `supportsCombinedToolsAndSchema(modelOptions) === true`. The adapter
813
+ * should then wire the schema into the upstream request (e.g.
814
+ * `response_format: { type: 'json_schema', ... }`, `text.format`,
815
+ * `output_format`) alongside any `tools`. The model's natural final
816
+ * turn carries the schema-constrained JSON text and the engine
817
+ * harvests it from the agent loop without a separate finalization
818
+ * round-trip.
819
+ *
820
+ * Adapters that did NOT declare the capability never see this field
821
+ * populated — the engine instead invokes `structuredOutput` /
822
+ * `structuredOutputStream` after the agent loop.
807
823
  */
808
824
  outputSchema?: SchemaInput
809
825
  /**