@tanstack/ai-svelte 0.15.1 → 0.16.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/src/types.ts CHANGED
@@ -2,13 +2,18 @@ import type {
2
2
  AnyClientTool,
3
3
  InferSchemaType,
4
4
  ModelMessage,
5
+ RunAgentResumeItem,
5
6
  SchemaInput,
6
7
  } from '@tanstack/ai'
7
8
  import type {
8
9
  AIDevtoolsDisplayOptions,
10
+ BoundInterrupts,
9
11
  ChatClientOptions,
10
12
  ChatClientState,
13
+ ChatInterrupt,
14
+ ChatInterruptState,
11
15
  ChatRequestBody,
16
+ ChatResumeState,
12
17
  ClientContextOptionFromTools,
13
18
  ConnectionStatus,
14
19
  DistributedOmit,
@@ -83,8 +88,14 @@ export type CreateChatOptions<
83
88
  | 'onConnectionStatusChange'
84
89
  | 'onSessionGeneratingChange'
85
90
  | 'onQueueChange'
91
+ | 'onResumeStateChange'
92
+ | 'onRunIdChange'
86
93
  | 'context'
87
94
  | 'devtools'
95
+ // `id` is not a hook option: the hook's identity is its `threadId`, which is
96
+ // also the persistence key. Persist across reloads by passing a stable
97
+ // `threadId`; there is no separate id to set.
98
+ | 'id'
88
99
  > & {
89
100
  live?: boolean
90
101
  /** Display options for TanStack AI Devtools. */
@@ -182,6 +193,39 @@ interface BaseCreateChatReturn<
182
193
  approved: boolean
183
194
  }) => Promise<void>
184
195
 
196
+ /**
197
+ * The id of the run this client has in flight — one it started or rejoined —
198
+ * or `null` when there is none (including while a run sits paused on an
199
+ * interrupt, waiting on approval).
200
+ *
201
+ * A run is one turn of the conversation, so this changes from turn to turn. A
202
+ * whole tool loop stays inside one run, while resuming after an interrupt
203
+ * continues the turn under a new id — so one user message can produce several
204
+ * run ids. Use it to talk to your own server about that run (cancel it, poll
205
+ * it, correlate a log line).
206
+ */
207
+ readonly runId: string | null
208
+ readonly interrupts: BoundInterrupts<TTools>
209
+ /** @deprecated Use `interrupts`. */
210
+ readonly pendingInterrupts: BoundInterrupts<TTools>
211
+ readonly interruptErrors: ChatInterruptState<TTools>['interruptErrors']
212
+ readonly resuming: boolean
213
+ resolveInterrupts: {
214
+ (approved: boolean): void
215
+ (resolver: (interrupt: ChatInterrupt<TTools>) => undefined): void
216
+ }
217
+ cancelInterrupts: () => void
218
+ retryInterrupts: () => void
219
+ resumeInterruptsUnsafe: (
220
+ resume: Array<RunAgentResumeItem>,
221
+ state?: ChatResumeState,
222
+ ) => Promise<boolean>
223
+ /** @deprecated Use bound interrupt methods or `resumeInterruptsUnsafe`. */
224
+ resumeInterrupts: (
225
+ resume: Array<RunAgentResumeItem>,
226
+ state?: ChatResumeState,
227
+ ) => Promise<boolean>
228
+
185
229
  /**
186
230
  * Reload the last assistant message
187
231
  */