@tanstack/ai-octane 0.9.1 → 1.0.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 CHANGED
@@ -62,6 +62,7 @@ export function Chat() @{
62
62
  const [input, setInput] = useState('')
63
63
  const chat = useChat({
64
64
  fetcher: myFetcher,
65
+ threadId: 'support-42',
65
66
  })
66
67
 
67
68
  <div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/ai-octane",
3
- "version": "0.9.1",
3
+ "version": "1.0.0",
4
4
  "description": "Octane bindings for TanStack AI streaming chat, structured outputs, and media generation.",
5
5
  "author": "Dominic Gannaway",
6
6
  "license": "MIT",
@@ -48,11 +48,11 @@
48
48
  ],
49
49
  "//lint": "The .tsrx.d.ts companions are generated declaration emits of the .tsrx implementations, so they are not hand-formatted and are excluded from lint rather than edited in place (a regeneration would undo any fix).",
50
50
  "dependencies": {
51
- "@tanstack/ai-client": "0.40.1"
51
+ "@tanstack/ai-client": "^1.0.0"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "octane": ">=0.12.0",
55
- "@tanstack/ai": "^0.71.0"
55
+ "@tanstack/ai": "^1.0.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@octanejs/testing-library": "0.1.62",
@@ -64,7 +64,7 @@
64
64
  "octane": "0.12.1",
65
65
  "vite": "^8.2.1",
66
66
  "zod": "^4.2.0",
67
- "@tanstack/ai": "0.71.0"
67
+ "@tanstack/ai": "1.0.0"
68
68
  },
69
69
  "scripts": {
70
70
  "lint:fix": "oxlint src --type-aware --fix",
@@ -21,10 +21,9 @@ type HeadlessOptions<TOptions> = UseChatOptions<
21
21
  >
22
22
 
23
23
  type ChatInstanceOverrides<TOptions> = {
24
- threadId?: string
24
+ threadId: string
25
25
  live?: boolean
26
26
  forwardedProps?: Record<string, any>
27
- body?: Record<string, any>
28
27
  initialMessages?: HeadlessOptions<TOptions>['initialMessages']
29
28
  }
30
29
 
@@ -36,7 +35,7 @@ type ChatInstanceOverrides<TOptions> = {
36
35
  * `useChatContext` reads that instance. Part and interrupt widgets take
37
36
  * `part` / `interrupt` as props. Do not read those from context.
38
37
  *
39
- * Pass instance overrides such as `threadId` into `useAppChat()`.
38
+ * Pass `threadId` and other instance overrides into `useAppChat()`.
40
39
  *
41
40
  * @example
42
41
  * ```tsx
@@ -70,15 +69,11 @@ export function createChatHook<
70
69
  chatComponents as ChatUIFactoryConfig<NoInfer<TOptions>, TInput>,
71
70
  )
72
71
 
73
- function useAppChat(overrides?: ChatInstanceOverrides<TOptions>) {
74
- const chat = (
75
- overrides
76
- ? useUnboundChat({
77
- ...(options as HeadlessOptions<TOptions>),
78
- ...overrides,
79
- })
80
- : useUnboundChat(options as HeadlessOptions<TOptions>)
81
- ) as ChatUIHost<TOptions>
72
+ function useAppChat(overrides: ChatInstanceOverrides<TOptions>) {
73
+ const chat = useUnboundChat({
74
+ ...(options as HeadlessOptions<TOptions>),
75
+ ...overrides,
76
+ }) as ChatUIHost<TOptions>
82
77
 
83
78
  // `useChat` returns a fresh object on every render. The mixed Chat
84
79
  // component must stay stable, or React remounts the tree on each
@@ -1,20 +1,70 @@
1
1
  import type { ComponentBody } from 'octane'
2
- import type { ChatUIFactoryConfig, ChatUIHost } from './create-ui.tsrx'
3
-
2
+ type ComponentType<P = any> = ComponentBody<P>
3
+ import type { InferredClientContext } from '@tanstack/ai-client'
4
+ import type {
5
+ ChatUIInterruptsOf,
6
+ ChatUISchemaOf,
7
+ ChatUIToolsOf,
8
+ } from '@tanstack/ai-client/ui'
9
+ import type { UseChatOptions } from '../types'
10
+ import type {
11
+ ChatUIFactoryConfig,
12
+ ChatUIHost,
13
+ InputProps,
14
+ } from './create-ui.tsrx'
15
+ type HeadlessOptions<TOptions> = UseChatOptions<
16
+ ChatUIToolsOf<TOptions>,
17
+ ChatUISchemaOf<TOptions>,
18
+ InferredClientContext<ChatUIToolsOf<TOptions>>,
19
+ ChatUIInterruptsOf<TOptions>
20
+ >
21
+ type ChatInstanceOverrides<TOptions> = {
22
+ threadId: string
23
+ live?: boolean
24
+ forwardedProps?: Record<string, any>
25
+ initialMessages?: HeadlessOptions<TOptions>['initialMessages']
26
+ }
27
+ /**
28
+ * Bind chat options and UI widgets once at module scope.
29
+ *
30
+ * This matches Form `createFormHook` and Table `createTableHook`. The
31
+ * returned `useAppChat` creates a chat instance. `chat.AppChat` renders it.
32
+ * `useChatContext` reads that instance. Part and interrupt widgets take
33
+ * `part` / `interrupt` as props. Do not read those from context.
34
+ *
35
+ * Pass `threadId` and other instance overrides into `useAppChat()`.
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * const { useAppChat, useChatContext } = createChatHook({
40
+ * options: chatOptions,
41
+ * components: { layout: ChatLayout, message: ChatMessage },
42
+ * partsComponents: { fallback: FallbackPart },
43
+ * toolsComponents: { getWeather: WeatherTool, purchaseItem: PurchaseTool },
44
+ * interruptsComponents: { generic: { choosePlan: ChoosePlan } },
45
+ * })
46
+ *
47
+ * function Support() {
48
+ * const chat = useAppChat({ threadId: 'support-1' })
49
+ * return <chat.AppChat />
50
+ * }
51
+ * ```
52
+ */
4
53
  export declare function createChatHook<
5
54
  const TOptions,
6
- TInput extends ComponentBody<any> | undefined =
7
- | ComponentBody<any>
55
+ TInput extends ComponentType<any> | undefined =
56
+ | ComponentType<InputProps<NoInfer<TOptions>>>
8
57
  | undefined,
9
- >(
10
- config: { options: TOptions } & ChatUIFactoryConfig<TOptions, TInput>,
11
- ): {
12
- useAppChat: (overrides?: {
13
- threadId?: string
14
- live?: boolean
15
- forwardedProps?: Record<string, any>
16
- body?: Record<string, any>
17
- initialMessages?: ChatUIHost<TOptions>['messages']
18
- }) => ChatUIHost<TOptions> & { AppChat: ComponentBody }
58
+ >({
59
+ options,
60
+ ...chatComponents
61
+ }: {
62
+ options: TOptions
63
+ } & ChatUIFactoryConfig<NoInfer<TOptions>, TInput>): {
64
+ useAppChat: (
65
+ overrides: ChatInstanceOverrides<TOptions>,
66
+ ) => ChatUIHost<TOptions> & {
67
+ AppChat: ComponentType
68
+ }
19
69
  useChatContext: () => ChatUIHost<TOptions>
20
70
  }
@@ -181,9 +181,11 @@ export type ChatUIFactoryConfig<
181
181
  context?: ChatUIContextConfig
182
182
  }
183
183
 
184
- type BoundWidget = ComponentType<Record<string, never>>
184
+ /** A zero-prop widget bound to the surrounding part or interrupt. */
185
+ export type BoundWidget = ComponentType<Record<string, never>>
185
186
 
186
- type PartMixins<TOptions> = {
187
+ /** The widgets `UI.Part` mixes onto the selected part it passes to children. */
188
+ export type PartMixins<TOptions> = {
187
189
  [K in ChatUIPartKey]?: BoundWidget
188
190
  } & {
189
191
  [K in ChatUIToolName<TOptions>]: BoundWidget
@@ -191,7 +193,8 @@ type PartMixins<TOptions> = {
191
193
  Render: BoundWidget
192
194
  }
193
195
 
194
- type InterruptMixins<TOptions> = {
196
+ /** The widgets `UI.Interrupt` mixes onto the interrupt it passes to children. */
197
+ export type InterruptMixins<TOptions> = {
195
198
  [K in ChatUINamedInterruptId<TOptions>]: BoundWidget
196
199
  } & {
197
200
  [K in ChatUIToolName<TOptions>]?: BoundWidget
@@ -1,43 +1,62 @@
1
- import type { ComponentBody, Context, OctaneNode } from 'octane'
2
- import type { UseChatReturn } from '../types'
3
- import type { ChatUIContexts } from './create-ui-contexts.tsrx'
1
+ import type { ComponentBody, OctaneNode } from 'octane'
2
+ type ComponentType<P = any> = ComponentBody<P>
4
3
  import type {
4
+ ChatUIData,
5
+ ChatUIHasNamedInterrupts,
6
+ ChatUIHasNamedTools,
7
+ ChatUIInterrupt,
5
8
  ChatUIInterruptName,
9
+ ChatUIInterruptOf,
6
10
  ChatUIInterruptsOf,
11
+ ChatUIMessages,
12
+ ChatUINamedInterruptId,
7
13
  ChatUIPartKey,
8
14
  ChatUIPartOf,
9
15
  ChatUISchemaOf,
16
+ ChatUISelectedPart,
17
+ ChatUIToolApproval,
10
18
  ChatUIToolName,
11
19
  ChatUIToolsOf,
12
20
  } from '@tanstack/ai-client/ui'
13
- import type { QueuedMessage } from '@tanstack/ai-client'
14
-
15
- type ComponentType<P = any> = ComponentBody<P>
16
-
21
+ import type {
22
+ MessagePart,
23
+ QueuedMessage,
24
+ ToolCallPart,
25
+ ToolResultPart,
26
+ UIMessage,
27
+ } from '@tanstack/ai-client'
28
+ import type { UseChatReturn } from '../types'
29
+ import type { ChatUIContexts } from './create-ui-contexts.tsrx'
17
30
  export type ChatUIHost<TOptions = unknown> = UseChatReturn<
18
31
  ChatUIToolsOf<TOptions>,
19
32
  ChatUISchemaOf<TOptions>,
20
33
  ChatUIInterruptsOf<TOptions>
21
34
  >
22
-
23
- export type ChatUIQueueItem = QueuedMessage & { cancelQueued: () => void }
24
-
35
+ export type ChatUIQueueItem = QueuedMessage & {
36
+ cancelQueued: () => void
37
+ }
25
38
  export type LayoutProps<
26
39
  TOptions,
27
- TInput extends ComponentType<any> | undefined = ComponentType<any>,
40
+ TInput extends ComponentType<any> | undefined = ComponentType<
41
+ InputProps<TOptions>
42
+ >,
28
43
  > = {
29
44
  Messages: ComponentType
30
45
  Interrupts: ComponentType
31
46
  Queue: ComponentType
32
47
  readonly __ui?: TOptions
33
- } & (TInput extends ComponentType<any> ? { Input: ComponentType } : {})
34
-
48
+ } & (TInput extends ComponentType<any>
49
+ ? {
50
+ Input: ComponentType
51
+ }
52
+ : {})
35
53
  export type MessageProps<TOptions> = {
36
- message: ChatUIHost<TOptions>['messages'][number]
54
+ message: UIMessage<ChatUIToolsOf<TOptions>, ChatUIData<TOptions>>
37
55
  Parts: ComponentType
38
56
  }
39
-
40
- export type InputProps<TOptions> = { readonly __ui?: TOptions }
57
+ export type InputProps<TOptions> = {
58
+ readonly __ui?: TOptions
59
+ }
41
60
  export type QueueProps<TOptions> = {
42
61
  item: ChatUIQueueItem
43
62
  readonly __ui?: TOptions
@@ -49,68 +68,195 @@ export type ToolProps<
49
68
  TOptions,
50
69
  TName extends ChatUIToolName<TOptions> = ChatUIToolName<TOptions>,
51
70
  > = {
52
- part: { name: TName }
53
- result?: unknown
54
- interrupt?: unknown
71
+ part: Extract<
72
+ ToolCallPart<ChatUIToolsOf<TOptions>>,
73
+ {
74
+ name: TName
75
+ }
76
+ >
77
+ result?: ToolResultPart
78
+ interrupt?: ChatUIToolApproval<TOptions, TName>
55
79
  }
56
80
  export type InterruptProps<
57
81
  TOptions,
58
82
  TName extends ChatUIInterruptName<TOptions> = never,
59
83
  > = {
60
- interrupt: { kind: string }
84
+ interrupt: ChatUIInterruptOf<TOptions, TName>
61
85
  readonly __ui?: TOptions
62
86
  }
63
-
64
- export type ChatUIFactoryConfig<
87
+ type GenericInterruptComponents<TOptions> =
88
+ ChatUIHasNamedInterrupts<TOptions> extends true
89
+ ? {
90
+ [K in ChatUINamedInterruptId<TOptions>]: ComponentType<
91
+ InterruptProps<TOptions, K & ChatUIInterruptName<TOptions>>
92
+ >
93
+ } & {
94
+ fallback?: ComponentType<InterruptProps<TOptions>>
95
+ }
96
+ : {
97
+ fallback?: ComponentType<InterruptProps<TOptions>>
98
+ }
99
+ type ToolApprovalMap<TOptions> = {
100
+ [K in ChatUIToolName<TOptions>]?: ComponentType<
101
+ InterruptProps<TOptions, K & ChatUIInterruptName<TOptions>>
102
+ >
103
+ }
104
+ /** The chrome around the message list: `layout`, `message`, and `input`. */
105
+ export type ChatUIChromeComponents<
65
106
  TOptions,
66
- TInput extends ComponentType<any> | undefined = ComponentType<any>,
107
+ TInput extends ComponentType<InputProps<TOptions>> | undefined =
108
+ ComponentType<InputProps<TOptions>>,
67
109
  > = {
68
- components: {
69
- layout: ComponentType<LayoutProps<TOptions, TInput>>
70
- message: ComponentType<MessageProps<TOptions>>
71
- input?: TInput
72
- queue?: ComponentType<QueueProps<TOptions>>
73
- }
74
- partsComponents: Record<string, ComponentType<any> | undefined>
75
- toolsComponents?: Record<string, ComponentType<any> | undefined>
76
- interruptsComponents?: {
77
- tools?: Record<string, ComponentType<any> | undefined>
78
- generic?: Record<string, ComponentType<any> | undefined>
79
- }
80
- context?: {
81
- chatContext?: ChatUIContexts['chatContext']
82
- partContext?: ChatUIContexts['partContext']
83
- interruptContext?: ChatUIContexts['interruptContext']
84
- }
110
+ layout: ComponentType<LayoutProps<TOptions, TInput>>
111
+ message: ComponentType<MessageProps<TOptions>>
112
+ input?: TInput
113
+ queue?: ComponentType<QueueProps<TOptions>>
114
+ }
115
+ export type ChatUIPartsComponents<TOptions> = {
116
+ [K in ChatUIPartKey]?: ComponentType<PartProps<TOptions, K>>
117
+ } & {
118
+ fallback?: ComponentType<PartProps<TOptions>>
119
+ }
120
+ export type ChatUIInterruptsComponents<TOptions> = {
121
+ tools?: ToolApprovalMap<TOptions>
122
+ generic: GenericInterruptComponents<TOptions>
85
123
  }
86
-
87
124
  export type ChatUIComponents<
88
125
  TOptions,
89
- TInput extends ComponentType<any> | undefined = ComponentType<any>,
90
- > = ChatUIFactoryConfig<TOptions, TInput>
91
-
126
+ TInput extends ComponentType<InputProps<TOptions>> | undefined =
127
+ ComponentType<InputProps<TOptions>>,
128
+ > = {
129
+ components: ChatUIChromeComponents<TOptions, TInput>
130
+ partsComponents: ChatUIPartsComponents<TOptions>
131
+ } & (ChatUIHasNamedTools<TOptions> extends true
132
+ ? {
133
+ toolsComponents: {
134
+ [K in ChatUIToolName<TOptions>]: ComponentType<ToolProps<TOptions, K>>
135
+ }
136
+ }
137
+ : {
138
+ toolsComponents?: {
139
+ [K in ChatUIToolName<TOptions>]?: ComponentType<ToolProps<TOptions, K>>
140
+ }
141
+ }) &
142
+ (ChatUIHasNamedInterrupts<TOptions> extends true
143
+ ? {
144
+ interruptsComponents: ChatUIInterruptsComponents<TOptions>
145
+ }
146
+ : {
147
+ interruptsComponents?: {
148
+ tools?: ToolApprovalMap<TOptions>
149
+ generic?: GenericInterruptComponents<TOptions>
150
+ }
151
+ })
152
+ /** Scoped contexts, for widgets in other files or nested chat trees. */
153
+ export type ChatUIContextConfig = {
154
+ chatContext?: ChatUIContexts['chatContext']
155
+ partContext?: ChatUIContexts['partContext']
156
+ interruptContext?: ChatUIContexts['interruptContext']
157
+ }
158
+ export type ChatUIFactoryConfig<
159
+ TOptions,
160
+ TInput extends ComponentType<InputProps<TOptions>> | undefined =
161
+ ComponentType<InputProps<TOptions>>,
162
+ > = ChatUIComponents<TOptions, TInput> & {
163
+ context?: ChatUIContextConfig
164
+ }
165
+ /** A zero-prop widget bound to the surrounding part or interrupt. */
166
+ export type BoundWidget = ComponentType<Record<string, never>>
167
+ /** The widgets `UI.Part` mixes onto the selected part it passes to children. */
168
+ export type PartMixins<TOptions> = {
169
+ [K in ChatUIPartKey]?: BoundWidget
170
+ } & {
171
+ [K in ChatUIToolName<TOptions>]: BoundWidget
172
+ } & {
173
+ Render: BoundWidget
174
+ }
175
+ /** The widgets `UI.Interrupt` mixes onto the interrupt it passes to children. */
176
+ export type InterruptMixins<TOptions> = {
177
+ [K in ChatUINamedInterruptId<TOptions>]: BoundWidget
178
+ } & {
179
+ [K in ChatUIToolName<TOptions>]?: BoundWidget
180
+ } & {
181
+ fallback?: BoundWidget
182
+ Render: BoundWidget
183
+ }
184
+ /**
185
+ * Bind chat options and UI widgets once at module scope. This matches Form
186
+ * `createFormHook` and Table `createTableHook`: widgets register here, mix
187
+ * onto Part / Interrupt / the UI kit, and automatic dispatch still walks the
188
+ * message list.
189
+ *
190
+ * `chatOptions` is type-only at runtime. Pass optional `chatContext`,
191
+ * `partContext`, and `interruptContext` from {@link createChatHookContexts}
192
+ * when widgets live in other files or when nested chats need isolation.
193
+ */
92
194
  export declare function createChatUI<
93
195
  const TOptions,
94
196
  TInput extends ComponentType<any> | undefined =
95
- | ComponentType<any>
197
+ | ComponentType<InputProps<NoInfer<TOptions>>>
96
198
  | undefined,
97
199
  >(
98
200
  options: TOptions,
99
- config: ChatUIFactoryConfig<TOptions, TInput>,
201
+ config: ChatUIFactoryConfig<NoInfer<TOptions>, TInput>,
100
202
  ): {
101
- Chat: ComponentType<{ chat: ChatUIHost<TOptions> }>
102
- Provider: ComponentType<{
203
+ Chat: ({
204
+ chat,
205
+ }: {
206
+ chat: ChatUIHost<TOptions>
207
+ }) => import('octane/jsx-runtime').JSX.Element
208
+ Provider: ({
209
+ chat,
210
+ children,
211
+ }: {
103
212
  chat: ChatUIHost<TOptions>
104
213
  children?: OctaneNode
105
- }>
106
- Messages: ComponentType
107
- Message: ComponentType
108
- Part: ComponentType
109
- Interrupts: ComponentType
110
- Interrupt: ComponentType
111
- Queue: ComponentType
214
+ }) => import('octane/jsx-runtime').JSX.Element
215
+ Messages: ({
216
+ children,
217
+ }?: {
218
+ children?: (messages: ChatUIMessages<TOptions>) => OctaneNode
219
+ }) => import('octane/jsx-runtime').JSX.Element
220
+ Message: ({
221
+ message,
222
+ children,
223
+ }: {
224
+ message: ChatUIMessages<TOptions>[number]
225
+ children?: (parts: Array<ChatUISelectedPart>) => OctaneNode
226
+ }) => import('octane/jsx-runtime').JSX.Element
227
+ Part: ({
228
+ part,
229
+ children,
230
+ }: {
231
+ part: MessagePart | ChatUISelectedPart
232
+ children?: (mixed: ChatUISelectedPart & PartMixins<TOptions>) => OctaneNode
233
+ }) => import('octane/jsx-runtime').JSX.Element | null
234
+ Interrupts: ({
235
+ children,
236
+ }?: {
237
+ children?: (interrupts: ReadonlyArray<ChatUIInterrupt>) => OctaneNode
238
+ }) => import('octane/jsx-runtime').JSX.Element
239
+ Interrupt: (({
240
+ interrupt,
241
+ children,
242
+ }: {
243
+ interrupt: ChatUIInterrupt
244
+ children?: (
245
+ mixed: ChatUIInterrupt & InterruptMixins<TOptions>,
246
+ ) => OctaneNode
247
+ }) => import('octane/jsx-runtime').JSX.Element) & {
248
+ readonly type: ({
249
+ interrupt,
250
+ children,
251
+ }: {
252
+ interrupt: ChatUIInterrupt
253
+ children?: (
254
+ mixed: ChatUIInterrupt & InterruptMixins<TOptions>,
255
+ ) => OctaneNode
256
+ }) => import('octane/jsx-runtime').JSX.Element
257
+ displayName?: string
258
+ }
259
+ Queue: () => import('octane/jsx-runtime').JSX.Element | null
112
260
  useChatContext: () => ChatUIHost<TOptions>
113
- Input: TInput
261
+ Input: TInput | undefined
114
262
  }
115
-
116
- export type { Context }
@@ -4,7 +4,10 @@ import type {
4
4
  InterruptDefinition,
5
5
  SchemaInput,
6
6
  } from '@tanstack/ai/client'
7
- import type { InferredClientContext } from '@tanstack/ai-client'
7
+ import type {
8
+ DistributedOmit,
9
+ InferredClientContext,
10
+ } from '@tanstack/ai-client'
8
11
  import type { UseChatOptions } from './types'
9
12
 
10
13
  type ChatHookOverrides<
@@ -13,10 +16,9 @@ type ChatHookOverrides<
13
16
  TContext,
14
17
  TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>>,
15
18
  > = {
16
- threadId?: string
19
+ threadId: string
17
20
  live?: boolean
18
21
  forwardedProps?: Record<string, any>
19
- body?: Record<string, any>
20
22
  initialMessages?: UseChatOptions<
21
23
  TTools,
22
24
  TSchema,
@@ -29,8 +31,8 @@ type ChatHookOverrides<
29
31
  * Bind chat options once at module scope. The returned `useChat` hook
30
32
  * creates a chat instance from those options.
31
33
  *
32
- * Pass per-call overrides for instance keys such as `threadId`,
33
- * `initialMessages`, `live`, and `forwardedProps`. Do not change `tools`,
34
+ * Pass `threadId` on every call. You can also override `initialMessages`,
35
+ * `live`, and `forwardedProps` per call. Do not change `tools`,
34
36
  * `interrupts`, or `outputSchema` here. Those stay on the factory options.
35
37
  */
36
38
  export function createChatHook<
@@ -40,14 +42,27 @@ export function createChatHook<
40
42
  const TInterrupts extends ReadonlyArray<
41
43
  InterruptDefinition<any, any, any, any>
42
44
  > = readonly [],
43
- >(options: UseChatOptions<TTools, TSchema, TContext, TInterrupts>) {
45
+ >(
46
+ options: DistributedOmit<
47
+ UseChatOptions<TTools, TSchema, TContext, TInterrupts>,
48
+ 'threadId'
49
+ > & {
50
+ // Plain keys so TypeScript can infer the generics through the Omit.
51
+ tools?: TTools
52
+ outputSchema?: TSchema
53
+ interrupts?: TInterrupts
54
+ },
55
+ ) {
44
56
  function useChat(
45
- overrides?: ChatHookOverrides<TTools, TSchema, TContext, TInterrupts>,
57
+ overrides: ChatHookOverrides<TTools, TSchema, TContext, TInterrupts>,
46
58
  ) {
47
- if (!overrides) {
48
- return useUnboundChat(options)
49
- }
50
- return useUnboundChat({ ...options, ...overrides })
59
+ // `overrides` carries the required `threadId`.
60
+ return useUnboundChat({ ...options, ...overrides } as UseChatOptions<
61
+ TTools,
62
+ TSchema,
63
+ TContext,
64
+ TInterrupts
65
+ >)
51
66
  }
52
67
 
53
68
  return { useChat }
package/src/index.ts CHANGED
@@ -6,12 +6,10 @@ export type { UseMcpAppBridgeOptions } from './use-mcp-app-bridge.tsrx'
6
6
  export {
7
7
  usePageWebMCPTools,
8
8
  useRegisterWebMCPTools,
9
- useWebMCPTools,
10
9
  } from './use-web-mcp-tools.tsrx'
11
10
  export type {
12
11
  UsePageWebMCPToolsOptions,
13
12
  UseRegisterWebMCPToolsOptions,
14
- UseWebMCPToolsOptions,
15
13
  } from './use-web-mcp-tools.tsrx'
16
14
  export type {
17
15
  DeepPartial,
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AnyClientTool,
3
+ RealtimeAdapter,
3
4
  RealtimeMessage,
4
5
  RealtimeMode,
5
6
  RealtimeSessionConfig,
@@ -7,7 +8,6 @@ import type {
7
8
  RealtimeToken,
8
9
  UsageInfo,
9
10
  } from '@tanstack/ai'
10
- import type { RealtimeAdapter } from '@tanstack/ai-client'
11
11
 
12
12
  /**
13
13
  * Options for the useRealtimeChat hook.
package/src/types.ts CHANGED
@@ -204,14 +204,6 @@ interface BaseUseChatReturn<
204
204
  errorText?: string
205
205
  }) => Promise<void>
206
206
 
207
- /**
208
- * Respond to a tool approval request
209
- */
210
- addToolApprovalResponse: (response: {
211
- id: string // approval.id, not toolCallId
212
- approved: boolean
213
- }) => Promise<void>
214
-
215
207
  /**
216
208
  * The id of the run this client has in flight — one it started or rejoined —
217
209
  * or `null` when there is none (including while a run sits paused on an
@@ -225,8 +217,6 @@ interface BaseUseChatReturn<
225
217
  */
226
218
  runId: string | null
227
219
  interrupts: BoundInterrupts<TTools, TInterrupts>
228
- /** @deprecated Use `interrupts`. */
229
- pendingInterrupts: BoundInterrupts<TTools, TInterrupts>
230
220
  interruptErrors: ChatInterruptState<TTools, TInterrupts>['interruptErrors']
231
221
  resuming: boolean
232
222
  resolveInterrupts: {
@@ -243,11 +233,6 @@ interface BaseUseChatReturn<
243
233
  resume: Array<RunAgentResumeItem>,
244
234
  state?: ChatResumeState,
245
235
  ) => Promise<boolean>
246
- /** @deprecated Use bound interrupt methods or `resumeInterruptsUnsafe`. */
247
- resumeInterrupts: (
248
- resume: Array<RunAgentResumeItem>,
249
- state?: ChatResumeState,
250
- ) => Promise<boolean>
251
236
 
252
237
  /**
253
238
  * Reload the last assistant message
@@ -42,7 +42,7 @@ export interface UseAudioRecorderReturn<TOutput> {
42
42
  * @example
43
43
  * ```tsx
44
44
  * const { isRecording, start, stop, recording } = useAudioRecorder()
45
- * const { sendMessage } = useChat({ connection })
45
+ * const { sendMessage } = useChat({ threadId: 'support-1', connection })
46
46
  * // ...
47
47
  * const rec = await stop()
48
48
  * sendMessage({ content: [rec.part] })
@@ -39,7 +39,7 @@ export interface UseAudioRecorderReturn<TOutput> {
39
39
  * @example
40
40
  * ```tsx
41
41
  * const { isRecording, start, stop, recording } = useAudioRecorder()
42
- * const { sendMessage } = useChat({ connection })
42
+ * const { sendMessage } = useChat({ threadId: 'support-1', connection })
43
43
  * // ...
44
44
  * const rec = await stop()
45
45
  * sendMessage({ content: [rec.part] })
package/src/use-chat.tsrx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ChatClient } from '@tanstack/ai-client'
2
2
  import { createChatDevtoolsBridge } from '@tanstack/ai-client/devtools'
3
- import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'octane'
3
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'octane'
4
4
  import type {
5
5
  AnyClientTool,
6
6
  InferSchemaType,
@@ -37,10 +37,8 @@ export function useChat<
37
37
  options: UseChatOptions<TTools, TSchema, TContext, TInterrupts>,
38
38
  ): UseChatReturn<TTools, TSchema, TInterrupts> {
39
39
  // The hook's identity is its `threadId`. Reload with the same `threadId`
40
- // restores the same conversation. `hookId` is only a recreation key when no
41
- // `threadId` is given. It is never sent on the wire.
42
- const hookId = useId()
43
- const clientId = options.threadId ?? hookId
40
+ // restores the same conversation.
41
+ const clientId = options.threadId
44
42
 
45
43
  const subscribedRef = useRef(false)
46
44
  const activeClientRef = useRef<ChatClient | null>(null)
@@ -93,27 +91,15 @@ export function useChat<
93
91
  devtoolsBridgeFactory: createChatDevtoolsBridge,
94
92
  ...transport,
95
93
  initialMessages: messagesToUse,
96
- ...(typeof initialOptions.threadId === 'string' &&
97
- initialOptions.persistence === true
94
+ threadId: initialOptions.threadId,
95
+ ...(initialOptions.persistence === true
98
96
  ? {
99
97
  persistence: true,
100
- threadId: initialOptions.threadId,
101
98
  ...(initialOptions.history !== undefined && {
102
99
  history: initialOptions.history,
103
100
  }),
104
101
  }
105
- : typeof initialOptions.threadId === 'string' &&
106
- initialOptions.persistence
107
- ? {
108
- persistence: initialOptions.persistence,
109
- threadId: initialOptions.threadId,
110
- }
111
- : {
112
- ...(initialOptions.threadId !== undefined && {
113
- threadId: initialOptions.threadId,
114
- }),
115
- }),
116
- ...(initialOptions.body !== undefined && { body: initialOptions.body }),
102
+ : { persistence: initialOptions.persistence }),
117
103
  ...(initialOptions.forwardedProps !== undefined && {
118
104
  forwardedProps: initialOptions.forwardedProps,
119
105
  }),
@@ -123,6 +109,8 @@ export function useChat<
123
109
  ...(initialOptions.context !== undefined && {
124
110
  context: initialOptions.context,
125
111
  }),
112
+ ...(initialOptions.byok !== undefined && { byok: initialOptions.byok }),
113
+ byokProvider: () => optionsRef.current.byokProvider?.(),
126
114
  devtools: {
127
115
  ...initialOptions.devtools,
128
116
  // OCTANE DIVERGENCE: identify this binding as Octane (not 'react') in TanStack AI Devtools.
@@ -247,10 +235,6 @@ export function useChat<
247
235
  // changing doesn't re-run the others. `updateOptions` declares strict-optional
248
236
  // fields and rejects explicit `undefined` under EOPT, so guard the optional
249
237
  // slots before passing them.
250
- useEffect(() => {
251
- client.updateOptions({ body: options.body })
252
- }, [client, options.body])
253
-
254
238
  useEffect(() => {
255
239
  if (options.forwardedProps !== undefined) {
256
240
  client.updateOptions({ forwardedProps: options.forwardedProps })
@@ -367,20 +351,6 @@ export function useChat<
367
351
  [client],
368
352
  )
369
353
 
370
- const addToolApprovalResponse = useCallback(
371
- async (response: { id: string; approved: boolean }) => {
372
- await client.addToolApprovalResponse(response)
373
- },
374
- [client],
375
- )
376
-
377
- const resumeInterrupts = useCallback(
378
- async (resumeItems: Array<RunAgentResumeItem>, state?: ChatResumeState) => {
379
- return await client.resumeInterrupts(resumeItems, state ?? undefined)
380
- },
381
- [client],
382
- )
383
-
384
354
  const resolveInterrupts = useCallback(
385
355
  (
386
356
  resolution:
@@ -479,19 +449,16 @@ export function useChat<
479
449
  setMessages: setMessagesManually,
480
450
  clear,
481
451
  addToolResult,
482
- addToolApprovalResponse,
483
452
  queue: snapshot.queue,
484
453
  cancelQueued,
485
454
  runId: snapshot.runId,
486
455
  interrupts: snapshot.interruptState.interrupts,
487
- pendingInterrupts: snapshot.interruptState.pendingInterrupts,
488
456
  interruptErrors: snapshot.interruptState.interruptErrors,
489
457
  resuming: snapshot.interruptState.resuming,
490
458
  resolveInterrupts,
491
459
  cancelInterrupts,
492
460
  retryInterrupts,
493
461
  resumeInterruptsUnsafe,
494
- resumeInterrupts,
495
462
  partial,
496
463
  final,
497
464
  } as unknown as UseChatReturn<TTools, TSchema, TInterrupts>
@@ -19,8 +19,8 @@ export interface UseGenerateAudioOptions<TOutput = AudioGenerationResult> {
19
19
  connection?: ConnectConnectionAdapter
20
20
  /** Direct async function for audio generation */
21
21
  fetcher?: GenerationFetcher<AudioGenerateInput, AudioGenerationResult>
22
- /** Unique identifier for this generation instance */
23
- id?: string
22
+ /** Stable scope for this generation. Also the wire and DevTools identity. */
23
+ threadId: string
24
24
  /** Additional body parameters to send with connect-based adapter requests */
25
25
  body?: Record<string, any>
26
26
  /** Display options for TanStack AI Devtools. */
@@ -77,6 +77,7 @@ export interface UseGenerateAudioReturn<TOutput = AudioGenerationResult> {
77
77
  *
78
78
  * function AudioGenerator() {
79
79
  * const { generate, result, isLoading, error, reset } = useGenerateAudio({
80
+ * threadId: 'theme-audio',
80
81
  * connection: fetchServerSentEvents('/api/generate/audio'),
81
82
  * })
82
83
  *
@@ -18,8 +18,8 @@ export interface UseGenerateAudioOptions<TOutput = AudioGenerationResult> {
18
18
  connection?: ConnectConnectionAdapter
19
19
  /** Direct async function for audio generation */
20
20
  fetcher?: GenerationFetcher<AudioGenerateInput, AudioGenerationResult>
21
- /** Unique identifier for this generation instance */
22
- id?: string
21
+ /** Stable scope for this generation. Also the wire and DevTools identity. */
22
+ threadId: string
23
23
  /** Additional body parameters to send with connect-based adapter requests */
24
24
  body?: Record<string, any>
25
25
  /** Display options for TanStack AI Devtools. */
@@ -74,6 +74,7 @@ export interface UseGenerateAudioReturn<TOutput = AudioGenerationResult> {
74
74
  *
75
75
  * function AudioGenerator() {
76
76
  * const { generate, result, isLoading, error, reset } = useGenerateAudio({
77
+ * threadId: 'theme-audio',
77
78
  * connection: fetchServerSentEvents('/api/generate/audio'),
78
79
  * })
79
80
  *
@@ -19,8 +19,8 @@ export interface UseGenerateImageOptions<TOutput = ImageGenerationResult> {
19
19
  connection?: ConnectConnectionAdapter
20
20
  /** Direct async function for image generation */
21
21
  fetcher?: GenerationFetcher<ImageGenerateInput, ImageGenerationResult>
22
- /** Unique identifier for this generation instance */
23
- id?: string
22
+ /** Stable scope for this generation. Also the wire and DevTools identity. */
23
+ threadId: string
24
24
  /** Additional body parameters to send with connect-based adapter requests */
25
25
  body?: Record<string, any>
26
26
  /** Display options for TanStack AI Devtools. */
@@ -77,6 +77,7 @@ export interface UseGenerateImageReturn<TOutput = ImageGenerationResult> {
77
77
  *
78
78
  * function ImageGenerator() {
79
79
  * const { generate, result, isLoading, error, reset } = useGenerateImage({
80
+ * threadId: 'hero-image',
80
81
  * connection: fetchServerSentEvents('/api/generate/image'),
81
82
  * })
82
83
  *
@@ -18,8 +18,8 @@ export interface UseGenerateImageOptions<TOutput = ImageGenerationResult> {
18
18
  connection?: ConnectConnectionAdapter
19
19
  /** Direct async function for image generation */
20
20
  fetcher?: GenerationFetcher<ImageGenerateInput, ImageGenerationResult>
21
- /** Unique identifier for this generation instance */
22
- id?: string
21
+ /** Stable scope for this generation. Also the wire and DevTools identity. */
22
+ threadId: string
23
23
  /** Additional body parameters to send with connect-based adapter requests */
24
24
  body?: Record<string, any>
25
25
  /** Display options for TanStack AI Devtools. */
@@ -74,6 +74,7 @@ export interface UseGenerateImageReturn<TOutput = ImageGenerationResult> {
74
74
  *
75
75
  * function ImageGenerator() {
76
76
  * const { generate, result, isLoading, error, reset } = useGenerateImage({
77
+ * threadId: 'hero-image',
77
78
  * connection: fetchServerSentEvents('/api/generate/image'),
78
79
  * })
79
80
  *
@@ -19,8 +19,8 @@ export interface UseGenerateSpeechOptions<TOutput = TTSResult> {
19
19
  connection?: ConnectConnectionAdapter
20
20
  /** Direct async function for speech generation */
21
21
  fetcher?: GenerationFetcher<SpeechGenerateInput, TTSResult>
22
- /** Unique identifier for this generation instance */
23
- id?: string
22
+ /** Stable scope for this generation. Also the wire and DevTools identity. */
23
+ threadId: string
24
24
  /** Additional body parameters to send with connect-based adapter requests */
25
25
  body?: Record<string, any>
26
26
  /** Display options for TanStack AI Devtools. */
@@ -73,6 +73,7 @@ export interface UseGenerateSpeechReturn<TOutput = TTSResult> {
73
73
  *
74
74
  * function SpeechGenerator() {
75
75
  * const { generate, result, isLoading } = useGenerateSpeech({
76
+ * threadId: 'welcome-speech',
76
77
  * connection: fetchServerSentEvents('/api/generate/speech'),
77
78
  * })
78
79
  *
@@ -18,8 +18,8 @@ export interface UseGenerateSpeechOptions<TOutput = TTSResult> {
18
18
  connection?: ConnectConnectionAdapter
19
19
  /** Direct async function for speech generation */
20
20
  fetcher?: GenerationFetcher<SpeechGenerateInput, TTSResult>
21
- /** Unique identifier for this generation instance */
22
- id?: string
21
+ /** Stable scope for this generation. Also the wire and DevTools identity. */
22
+ threadId: string
23
23
  /** Additional body parameters to send with connect-based adapter requests */
24
24
  body?: Record<string, any>
25
25
  /** Display options for TanStack AI Devtools. */
@@ -70,6 +70,7 @@ export interface UseGenerateSpeechReturn<TOutput = TTSResult> {
70
70
  *
71
71
  * function SpeechGenerator() {
72
72
  * const { generate, result, isLoading } = useGenerateSpeech({
73
+ * threadId: 'welcome-speech',
73
74
  * connection: fetchServerSentEvents('/api/generate/speech'),
74
75
  * })
75
76
  *
@@ -1,6 +1,6 @@
1
1
  import { VideoGenerationClient } from '@tanstack/ai-client'
2
2
  import { createVideoDevtoolsBridge } from '@tanstack/ai-client/devtools'
3
- import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'octane'
3
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'octane'
4
4
  import type { StreamChunk } from '@tanstack/ai'
5
5
  import type {
6
6
  AIDevtoolsDisplayOptions,
@@ -21,8 +21,8 @@ export interface UseGenerateVideoOptions<TOutput = VideoGenerateResult> {
21
21
  connection?: ConnectConnectionAdapter
22
22
  /** Direct async function that returns a completed video result */
23
23
  fetcher?: GenerationFetcher<VideoGenerateInput, VideoGenerateResult>
24
- /** Unique identifier for this generation instance */
25
- id?: string
24
+ /** Stable scope for this generation. Also the wire and DevTools identity. */
25
+ threadId: string
26
26
  /** Additional body parameters to send with connect-based adapter requests */
27
27
  body?: Record<string, any>
28
28
  /** Display options for TanStack AI Devtools. */
@@ -86,6 +86,7 @@ export interface UseGenerateVideoReturn<TOutput = VideoGenerateResult> {
86
86
  *
87
87
  * function VideoGenerator() {
88
88
  * const { generate, result, videoStatus, isLoading } = useGenerateVideo({
89
+ * threadId: 'intro-video',
89
90
  * connection: fetchServerSentEvents('/api/generate/video'),
90
91
  * onStatusUpdate: (status) => console.log(`Progress: ${status.progress}%`),
91
92
  * })
@@ -118,8 +119,7 @@ export function useGenerateVideo<TTransformed = void>(
118
119
  VideoGenerateResult,
119
120
  TTransformed
120
121
  >
121
- const hookId = useId()
122
- const clientId = options.id || hookId
122
+ const clientId = options.threadId
123
123
 
124
124
  const [result, setResult] = useState<TOutput | null>(null)
125
125
  const [jobId, setJobId] = useState<string | null>(null)
@@ -140,7 +140,7 @@ export function useGenerateVideo<TTransformed = void>(
140
140
  // return type (which `exactOptionalPropertyTypes` rejects
141
141
  // against the strict-optional target).
142
142
  const baseOptions = {
143
- id: clientId,
143
+ threadId: clientId,
144
144
  body: opts.body,
145
145
  devtoolsBridgeFactory: createVideoDevtoolsBridge,
146
146
  devtools: {
@@ -18,8 +18,8 @@ export interface UseGenerateVideoOptions<TOutput = VideoGenerateResult> {
18
18
  connection?: ConnectConnectionAdapter
19
19
  /** Direct async function that returns a completed video result */
20
20
  fetcher?: GenerationFetcher<VideoGenerateInput, VideoGenerateResult>
21
- /** Unique identifier for this generation instance */
22
- id?: string
21
+ /** Stable scope for this generation. Also the wire and DevTools identity. */
22
+ threadId: string
23
23
  /** Additional body parameters to send with connect-based adapter requests */
24
24
  body?: Record<string, any>
25
25
  /** Display options for TanStack AI Devtools. */
@@ -81,6 +81,7 @@ export interface UseGenerateVideoReturn<TOutput = VideoGenerateResult> {
81
81
  *
82
82
  * function VideoGenerator() {
83
83
  * const { generate, result, videoStatus, isLoading } = useGenerateVideo({
84
+ * threadId: 'intro-video',
84
85
  * connection: fetchServerSentEvents('/api/generate/video'),
85
86
  * onStatusUpdate: (status) => console.log(`Progress: ${status.progress}%`),
86
87
  * })
@@ -1,6 +1,6 @@
1
1
  import { GenerationClient } from '@tanstack/ai-client'
2
2
  import { createGenerationDevtoolsBridge } from '@tanstack/ai-client/devtools'
3
- import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'octane'
3
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'octane'
4
4
  import type { StreamChunk } from '@tanstack/ai'
5
5
  import type {
6
6
  AIDevtoolsDisplayOptions,
@@ -25,8 +25,8 @@ export interface UseGenerationOptions<TInput, TResult, TOutput = TResult> {
25
25
  connection?: ConnectConnectionAdapter
26
26
  /** Direct async function for one-shot generation (no streaming protocol needed) */
27
27
  fetcher?: GenerationFetcher<TInput, TResult>
28
- /** Unique identifier for this generation instance */
29
- id?: string
28
+ /** Stable scope for this generation. Also the wire and DevTools identity. */
29
+ threadId: string
30
30
  /** Additional body parameters to send with connect-based adapter requests */
31
31
  body?: Record<string, any>
32
32
  /** Display options for TanStack AI Devtools. */
@@ -114,8 +114,7 @@ export function useGeneration<
114
114
  InferGenerationOutputFromReturn<TResult, TTransformed>
115
115
  > {
116
116
  type TOutput = InferGenerationOutputFromReturn<TResult, TTransformed>
117
- const hookId = useId()
118
- const clientId = options.id || hookId
117
+ const clientId = options.threadId
119
118
 
120
119
  const [result, setResult] = useState<TOutput | null>(null)
121
120
  const [isLoading, setIsLoading] = useState(false)
@@ -133,7 +132,7 @@ export function useGeneration<
133
132
  // wrap optional ones in non-returning bodies so `?.()`'s
134
133
  // implicit `undefined` doesn't pollute the function return type.
135
134
  const clientOptions: GenerationClientOptions<TInput, TResult, TOutput> = {
136
- id: clientId,
135
+ threadId: clientId,
137
136
  body: opts.body,
138
137
  devtoolsBridgeFactory: createGenerationDevtoolsBridge,
139
138
  devtools: {
@@ -21,8 +21,8 @@ export interface UseGenerationOptions<TInput, TResult, TOutput = TResult> {
21
21
  connection?: ConnectConnectionAdapter
22
22
  /** Direct async function for one-shot generation (no streaming protocol needed) */
23
23
  fetcher?: GenerationFetcher<TInput, TResult>
24
- /** Unique identifier for this generation instance */
25
- id?: string
24
+ /** Stable scope for this generation. Also the wire and DevTools identity. */
25
+ threadId: string
26
26
  /** Additional body parameters to send with connect-based adapter requests */
27
27
  body?: Record<string, any>
28
28
  /** Display options for TanStack AI Devtools. */
@@ -19,8 +19,8 @@ export interface UseSummarizeOptions<TOutput = SummarizationResult> {
19
19
  connection?: ConnectConnectionAdapter
20
20
  /** Direct async function for summarization */
21
21
  fetcher?: GenerationFetcher<SummarizeGenerateInput, SummarizationResult>
22
- /** Unique identifier for this generation instance */
23
- id?: string
22
+ /** Stable scope for this generation. Also the wire and DevTools identity. */
23
+ threadId: string
24
24
  /** Additional body parameters to send with connect-based adapter requests */
25
25
  body?: Record<string, any>
26
26
  /** Display options for TanStack AI Devtools. */
@@ -73,6 +73,7 @@ export interface UseSummarizeReturn<TOutput = SummarizationResult> {
73
73
  *
74
74
  * function Summarizer() {
75
75
  * const { generate, result, isLoading } = useSummarize({
76
+ * threadId: 'article-summary',
76
77
  * connection: fetchServerSentEvents('/api/summarize'),
77
78
  * })
78
79
  *
@@ -18,8 +18,8 @@ export interface UseSummarizeOptions<TOutput = SummarizationResult> {
18
18
  connection?: ConnectConnectionAdapter
19
19
  /** Direct async function for summarization */
20
20
  fetcher?: GenerationFetcher<SummarizeGenerateInput, SummarizationResult>
21
- /** Unique identifier for this generation instance */
22
- id?: string
21
+ /** Stable scope for this generation. Also the wire and DevTools identity. */
22
+ threadId: string
23
23
  /** Additional body parameters to send with connect-based adapter requests */
24
24
  body?: Record<string, any>
25
25
  /** Display options for TanStack AI Devtools. */
@@ -70,6 +70,7 @@ export interface UseSummarizeReturn<TOutput = SummarizationResult> {
70
70
  *
71
71
  * function Summarizer() {
72
72
  * const { generate, result, isLoading } = useSummarize({
73
+ * threadId: 'article-summary',
73
74
  * connection: fetchServerSentEvents('/api/summarize'),
74
75
  * })
75
76
  *
@@ -19,8 +19,8 @@ export interface UseTranscriptionOptions<TOutput = TranscriptionResult> {
19
19
  connection?: ConnectConnectionAdapter
20
20
  /** Direct async function for transcription */
21
21
  fetcher?: GenerationFetcher<TranscriptionGenerateInput, TranscriptionResult>
22
- /** Unique identifier for this generation instance */
23
- id?: string
22
+ /** Stable scope for this generation. Also the wire and DevTools identity. */
23
+ threadId: string
24
24
  /** Additional body parameters to send with connect-based adapter requests */
25
25
  body?: Record<string, any>
26
26
  /** Display options for TanStack AI Devtools. */
@@ -73,6 +73,7 @@ export interface UseTranscriptionReturn<TOutput = TranscriptionResult> {
73
73
  *
74
74
  * function Transcriber() {
75
75
  * const { generate, result, isLoading } = useTranscription({
76
+ * threadId: 'meeting-transcript',
76
77
  * connection: fetchServerSentEvents('/api/transcribe'),
77
78
  * })
78
79
  *
@@ -18,8 +18,8 @@ export interface UseTranscriptionOptions<TOutput = TranscriptionResult> {
18
18
  connection?: ConnectConnectionAdapter
19
19
  /** Direct async function for transcription */
20
20
  fetcher?: GenerationFetcher<TranscriptionGenerateInput, TranscriptionResult>
21
- /** Unique identifier for this generation instance */
22
- id?: string
21
+ /** Stable scope for this generation. Also the wire and DevTools identity. */
22
+ threadId: string
23
23
  /** Additional body parameters to send with connect-based adapter requests */
24
24
  body?: Record<string, any>
25
25
  /** Display options for TanStack AI Devtools. */
@@ -70,6 +70,7 @@ export interface UseTranscriptionReturn<TOutput = TranscriptionResult> {
70
70
  *
71
71
  * function Transcriber() {
72
72
  * const { generate, result, isLoading } = useTranscription({
73
+ * threadId: 'meeting-transcript',
73
74
  * connection: fetchServerSentEvents('/api/transcribe'),
74
75
  * })
75
76
  *
@@ -16,12 +16,6 @@ export type UseRegisterWebMCPToolsOptions<
16
16
  onError?: (error: unknown) => void
17
17
  }
18
18
 
19
- /** @deprecated Use `UseRegisterWebMCPToolsOptions`. Removed in 1.0.0. */
20
- export type UseWebMCPToolsOptions<
21
- TTools extends ReadonlyArray<AnyClientTool>,
22
- TContext = InferredClientContext<TTools>,
23
- > = UseRegisterWebMCPToolsOptions<TTools, TContext>
24
-
25
19
  type UseRegisterWebMCPToolsArguments<
26
20
  TTools extends ReadonlyArray<AnyClientTool>,
27
21
  TContext,
@@ -68,9 +62,6 @@ export function useRegisterWebMCPTools<
68
62
  }, [tools, options])
69
63
  }
70
64
 
71
- /** @deprecated Use `useRegisterWebMCPTools`. Removed in 1.0.0. */
72
- export const useWebMCPTools = useRegisterWebMCPTools
73
-
74
65
  /** Options for {@link usePageWebMCPTools}. */
75
66
  export type UsePageWebMCPToolsOptions = Omit<
76
67
  SubscribeWebMCPToolsOptions,
@@ -91,7 +82,7 @@ export type UsePageWebMCPToolsOptions = Omit<
91
82
  * const pageTools = usePageWebMCPTools({
92
83
  * filter: (tool) => tool.origin === location.origin,
93
84
  * })
94
- * const chat = useChat({ connection, tools: pageTools })
85
+ * const chat = useChat({ threadId: 'support-1', connection, tools: pageTools })
95
86
  * ```
96
87
  */
97
88
  export function usePageWebMCPTools(
@@ -14,11 +14,6 @@ export type UseRegisterWebMCPToolsOptions<
14
14
  /** Receives an asynchronous registration failure. */
15
15
  onError?: (error: unknown) => void
16
16
  }
17
- /** @deprecated Use `UseRegisterWebMCPToolsOptions`. Removed in 1.0.0. */
18
- export type UseWebMCPToolsOptions<
19
- TTools extends ReadonlyArray<AnyClientTool>,
20
- TContext = InferredClientContext<TTools>,
21
- > = UseRegisterWebMCPToolsOptions<TTools, TContext>
22
17
  type UseRegisterWebMCPToolsArguments<
23
18
  TTools extends ReadonlyArray<AnyClientTool>,
24
19
  TContext,
@@ -49,8 +44,6 @@ export declare function useRegisterWebMCPTools<
49
44
  tools: TTools,
50
45
  ...[options]: UseRegisterWebMCPToolsArguments<TTools, TContext>
51
46
  ): void
52
- /** @deprecated Use `useRegisterWebMCPTools`. Removed in 1.0.0. */
53
- export declare const useWebMCPTools: typeof useRegisterWebMCPTools
54
47
  /** Options for {@link usePageWebMCPTools}. */
55
48
  export type UsePageWebMCPToolsOptions = Omit<
56
49
  SubscribeWebMCPToolsOptions,
@@ -70,7 +63,7 @@ export type UsePageWebMCPToolsOptions = Omit<
70
63
  * const pageTools = usePageWebMCPTools({
71
64
  * filter: (tool) => tool.origin === location.origin,
72
65
  * })
73
- * const chat = useChat({ connection, tools: pageTools })
66
+ * const chat = useChat({ threadId: 'support-1', connection, tools: pageTools })
74
67
  * ```
75
68
  */
76
69
  export declare function usePageWebMCPTools(