@assistant-ui/core 0.1.17 → 0.2.2

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.
Files changed (205) hide show
  1. package/README.md +45 -0
  2. package/dist/index.d.ts +5 -4
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +3 -2
  5. package/dist/index.js.map +1 -1
  6. package/dist/react/client/Tools.d.ts +6 -1
  7. package/dist/react/client/Tools.d.ts.map +1 -1
  8. package/dist/react/client/Tools.js +16 -19
  9. package/dist/react/client/Tools.js.map +1 -1
  10. package/dist/react/index.d.ts +2 -1
  11. package/dist/react/index.d.ts.map +1 -1
  12. package/dist/react/index.js +1 -0
  13. package/dist/react/index.js.map +1 -1
  14. package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
  15. package/dist/react/primitive-hooks/useComposerSend.js +2 -3
  16. package/dist/react/primitive-hooks/useComposerSend.js.map +1 -1
  17. package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts +5 -0
  18. package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -0
  19. package/dist/react/primitive-hooks/useThreadListLoadMore.js +11 -0
  20. package/dist/react/primitive-hooks/useThreadListLoadMore.js.map +1 -0
  21. package/dist/react/primitives/message/MessageAttachments.js +1 -1
  22. package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
  23. package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
  24. package/dist/react/primitives/message/MessageParts.js +14 -10
  25. package/dist/react/primitives/message/MessageParts.js.map +1 -1
  26. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +2 -2
  27. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  28. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +4 -3
  29. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
  30. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +8 -4
  31. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  32. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +86 -38
  33. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  34. package/dist/react/runtimes/cloud/auiV0.d.ts +10 -1
  35. package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
  36. package/dist/react/runtimes/cloud/auiV0.js +21 -3
  37. package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
  38. package/dist/react/runtimes/useLocalRuntime.d.ts +1 -1
  39. package/dist/react/runtimes/useToolInvocations.d.ts +2 -1
  40. package/dist/react/runtimes/useToolInvocations.d.ts.map +1 -1
  41. package/dist/react/runtimes/useToolInvocations.js +16 -1
  42. package/dist/react/runtimes/useToolInvocations.js.map +1 -1
  43. package/dist/react/types/scopes/tools.d.ts +4 -0
  44. package/dist/react/types/scopes/tools.d.ts.map +1 -1
  45. package/dist/runtime/api/assistant-runtime.d.ts +0 -33
  46. package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
  47. package/dist/runtime/api/assistant-runtime.js +0 -23
  48. package/dist/runtime/api/assistant-runtime.js.map +1 -1
  49. package/dist/runtime/api/bindings.d.ts +1 -3
  50. package/dist/runtime/api/bindings.d.ts.map +1 -1
  51. package/dist/runtime/api/composer-runtime.d.ts +1 -0
  52. package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
  53. package/dist/runtime/api/composer-runtime.js +2 -0
  54. package/dist/runtime/api/composer-runtime.js.map +1 -1
  55. package/dist/runtime/api/message-runtime.d.ts +1 -6
  56. package/dist/runtime/api/message-runtime.d.ts.map +1 -1
  57. package/dist/runtime/api/message-runtime.js.map +1 -1
  58. package/dist/runtime/api/thread-list-runtime.d.ts +4 -0
  59. package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
  60. package/dist/runtime/api/thread-list-runtime.js +6 -0
  61. package/dist/runtime/api/thread-list-runtime.js.map +1 -1
  62. package/dist/runtime/api/thread-runtime.d.ts +3 -24
  63. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  64. package/dist/runtime/api/thread-runtime.js +1 -20
  65. package/dist/runtime/api/thread-runtime.js.map +1 -1
  66. package/dist/runtime/base/base-composer-runtime-core.d.ts +1 -0
  67. package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
  68. package/dist/runtime/base/base-composer-runtime-core.js +1 -1
  69. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  70. package/dist/runtime/base/base-thread-runtime-core.d.ts +1 -1
  71. package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
  72. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +1 -0
  73. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
  74. package/dist/runtime/base/default-edit-composer-runtime-core.js +3 -0
  75. package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
  76. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +1 -0
  77. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
  78. package/dist/runtime/base/default-thread-composer-runtime-core.js +12 -1
  79. package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
  80. package/dist/runtime/interfaces/composer-runtime-core.d.ts +1 -0
  81. package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
  82. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +3 -0
  83. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
  84. package/dist/runtime/interfaces/thread-runtime-core.d.ts +6 -4
  85. package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
  86. package/dist/runtime/utils/chat-model-adapter.d.ts +0 -4
  87. package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
  88. package/dist/runtime/utils/external-store-message.d.ts +0 -4
  89. package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
  90. package/dist/runtime/utils/external-store-message.js +0 -7
  91. package/dist/runtime/utils/external-store-message.js.map +1 -1
  92. package/dist/runtimes/assistant-transport/utils.d.ts +0 -9
  93. package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
  94. package/dist/runtimes/assistant-transport/utils.js +0 -13
  95. package/dist/runtimes/assistant-transport/utils.js.map +1 -1
  96. package/dist/runtimes/external-store/external-store-adapter.d.ts +15 -0
  97. package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
  98. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +1 -1
  99. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
  100. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +14 -12
  101. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
  102. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +1 -1
  103. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  104. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +2 -3
  105. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  106. package/dist/runtimes/local/local-thread-runtime-core.d.ts +1 -1
  107. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  108. package/dist/runtimes/local/local-thread-runtime-core.js +1 -4
  109. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  110. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +2 -1
  111. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
  112. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +2 -3
  113. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
  114. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
  115. package/dist/runtimes/remote-thread-list/empty-thread-core.js +2 -3
  116. package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
  117. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +12 -1
  118. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
  119. package/dist/runtimes/remote-thread-list/remote-thread-state.js +34 -0
  120. package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
  121. package/dist/runtimes/remote-thread-list/types.d.ts +5 -1
  122. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  123. package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
  124. package/dist/store/clients/no-op-composer-client.js +1 -0
  125. package/dist/store/clients/no-op-composer-client.js.map +1 -1
  126. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  127. package/dist/store/clients/thread-message-client.js +0 -1
  128. package/dist/store/clients/thread-message-client.js.map +1 -1
  129. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  130. package/dist/store/runtime-clients/composer-runtime-client.js +1 -0
  131. package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
  132. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  133. package/dist/store/runtime-clients/thread-list-runtime-client.js +3 -0
  134. package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
  135. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  136. package/dist/store/runtime-clients/thread-runtime-client.js +0 -1
  137. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  138. package/dist/store/scopes/composer.d.ts +9 -0
  139. package/dist/store/scopes/composer.d.ts.map +1 -1
  140. package/dist/store/scopes/message.d.ts +1 -3
  141. package/dist/store/scopes/message.d.ts.map +1 -1
  142. package/dist/store/scopes/thread.d.ts +0 -4
  143. package/dist/store/scopes/thread.d.ts.map +1 -1
  144. package/dist/store/scopes/threads.d.ts +3 -0
  145. package/dist/store/scopes/threads.d.ts.map +1 -1
  146. package/dist/types/index.d.ts +1 -1
  147. package/dist/types/index.d.ts.map +1 -1
  148. package/dist/types/message.d.ts +28 -1
  149. package/dist/types/message.d.ts.map +1 -1
  150. package/dist/types/message.js +2 -1
  151. package/dist/types/message.js.map +1 -1
  152. package/package.json +11 -12
  153. package/src/index.ts +8 -6
  154. package/src/react/client/Tools.ts +46 -22
  155. package/src/react/index.ts +2 -1
  156. package/src/react/primitive-hooks/useComposerSend.ts +2 -3
  157. package/src/react/primitive-hooks/useThreadListLoadMore.ts +15 -0
  158. package/src/react/primitives/message/MessageAttachments.test.tsx +50 -0
  159. package/src/react/primitives/message/MessageAttachments.tsx +1 -1
  160. package/src/react/primitives/message/MessageParts.tsx +20 -9
  161. package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +7 -6
  162. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +96 -43
  163. package/src/react/runtimes/cloud/auiV0.ts +37 -4
  164. package/src/react/runtimes/useToolInvocations.ts +21 -1
  165. package/src/react/types/scopes/tools.ts +5 -0
  166. package/src/runtime/api/assistant-runtime.ts +0 -62
  167. package/src/runtime/api/bindings.ts +1 -6
  168. package/src/runtime/api/composer-runtime.ts +3 -0
  169. package/src/runtime/api/message-runtime.ts +1 -8
  170. package/src/runtime/api/thread-list-runtime.ts +10 -0
  171. package/src/runtime/api/thread-runtime.ts +1 -46
  172. package/src/runtime/base/base-composer-runtime-core.ts +2 -1
  173. package/src/runtime/base/base-thread-runtime-core.ts +1 -1
  174. package/src/runtime/base/default-edit-composer-runtime-core.ts +4 -0
  175. package/src/runtime/base/default-thread-composer-runtime-core.ts +12 -1
  176. package/src/runtime/interfaces/composer-runtime-core.ts +1 -0
  177. package/src/runtime/interfaces/thread-list-runtime-core.ts +3 -0
  178. package/src/runtime/interfaces/thread-runtime-core.ts +6 -5
  179. package/src/runtime/utils/chat-model-adapter.ts +0 -5
  180. package/src/runtime/utils/external-store-message.ts +0 -8
  181. package/src/runtimes/assistant-transport/utils.ts +0 -28
  182. package/src/runtimes/external-store/external-store-adapter.ts +15 -0
  183. package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +15 -9
  184. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +2 -4
  185. package/src/runtimes/local/local-thread-runtime-core.ts +1 -5
  186. package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +2 -4
  187. package/src/runtimes/remote-thread-list/empty-thread-core.ts +2 -4
  188. package/src/runtimes/remote-thread-list/remote-thread-state.ts +54 -1
  189. package/src/runtimes/remote-thread-list/types.ts +6 -1
  190. package/src/store/clients/no-op-composer-client.ts +1 -0
  191. package/src/store/clients/thread-message-client.ts +0 -1
  192. package/src/store/runtime-clients/composer-runtime-client.ts +1 -0
  193. package/src/store/runtime-clients/thread-list-runtime-client.ts +3 -0
  194. package/src/store/runtime-clients/thread-runtime-client.ts +0 -1
  195. package/src/store/scopes/composer.ts +9 -0
  196. package/src/store/scopes/message.ts +1 -6
  197. package/src/store/scopes/thread.ts +0 -5
  198. package/src/store/scopes/threads.ts +3 -0
  199. package/src/tests/RemoteThreadListThreadListRuntimeCore-loadMore.test.ts +448 -0
  200. package/src/tests/RemoteThreadListThreadListRuntimeCore-reload.test.ts +6 -1
  201. package/src/tests/auiV0Encode.test.ts +55 -0
  202. package/src/tests/composer-can-send.test.ts +112 -0
  203. package/src/tests/external-store-thread-list-runtime-core.test.ts +34 -0
  204. package/src/types/index.ts +2 -0
  205. package/src/types/message.ts +44 -7
@@ -28,6 +28,8 @@ export type ThreadListState = {
28
28
  readonly threadIds: readonly string[];
29
29
  readonly archivedThreadIds: readonly string[];
30
30
  readonly isLoading: boolean;
31
+ readonly isLoadingMore: boolean;
32
+ readonly hasMore: boolean;
31
33
  readonly threadItems: Readonly<
32
34
  Record<string, Omit<ThreadListItemState, "isMain" | "threadId">>
33
35
  >;
@@ -51,6 +53,7 @@ export type ThreadListRuntime = {
51
53
 
52
54
  getLoadThreadsPromise(): Promise<void>;
53
55
  reload(): Promise<void>;
56
+ loadMore(): Promise<void>;
54
57
  };
55
58
 
56
59
  const getThreadListState = (
@@ -62,6 +65,8 @@ const getThreadListState = (
62
65
  threadIds: threadList.threadIds,
63
66
  archivedThreadIds: threadList.archivedThreadIds,
64
67
  isLoading: threadList.isLoading,
68
+ isLoadingMore: threadList.isLoadingMore ?? false,
69
+ hasMore: threadList.hasMore ?? false,
65
70
  threadItems: threadList.threadItems,
66
71
  };
67
72
  };
@@ -138,6 +143,7 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
138
143
  this.switchToNewThread = this.switchToNewThread.bind(this);
139
144
  this.getLoadThreadsPromise = this.getLoadThreadsPromise.bind(this);
140
145
  this.reload = this.reload.bind(this);
146
+ this.loadMore = this.loadMore.bind(this);
141
147
  this.getState = this.getState.bind(this);
142
148
  this.subscribe = this.subscribe.bind(this);
143
149
  this.getById = this.getById.bind(this);
@@ -162,6 +168,10 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
162
168
  return this._core.reload?.() ?? RESOLVED_PROMISE;
163
169
  }
164
170
 
171
+ public loadMore(): Promise<void> {
172
+ return this._core.loadMore?.() ?? RESOLVED_PROMISE;
173
+ }
174
+
165
175
  public getState(): ThreadListState {
166
176
  return this._getState();
167
177
  }
@@ -252,10 +252,6 @@ export type ThreadRuntime = {
252
252
  */
253
253
  append(message: CreateAppendMessage): void;
254
254
 
255
- /**
256
- * @deprecated pass an object with `parentId` instead. This will be removed in 0.12.0.
257
- */
258
- startRun(parentId: string | null): void;
259
255
  /**
260
256
  * Start a new run with the given configuration.
261
257
  * @param config The configuration for starting the run
@@ -268,11 +264,6 @@ export type ThreadRuntime = {
268
264
  **/
269
265
  resumeRun(config: CreateResumeRunConfig): void;
270
266
 
271
- /**
272
- * @deprecated Use `resumeRun` instead.
273
- */
274
- unstable_resumeRun(config: CreateResumeRunConfig): void;
275
-
276
267
  /**
277
268
  * Export the thread state in the external store format.
278
269
  * For AI SDK runtimes, this returns the AI SDK message format.
@@ -289,22 +280,10 @@ export type ThreadRuntime = {
289
280
  */
290
281
  importExternalState(state: any): void;
291
282
 
292
- /**
293
- * Load external state into the thread.
294
- * @deprecated Use importExternalState instead. This method will be removed in 0.12.0.
295
- * @param state The state to load into the thread
296
- */
297
- unstable_loadExternalState(state: any): void;
298
-
299
283
  subscribe(callback: () => void): Unsubscribe;
300
284
  cancelRun(): void;
301
285
  getModelContext(): ModelContext;
302
286
 
303
- /**
304
- * @deprecated This method was renamed to `getModelContext`.
305
- */
306
- getModelConfig(): ModelContext;
307
-
308
287
  export(): ExportedMessageRepository;
309
288
  import(repository: ExportedMessageRepository): void;
310
289
 
@@ -396,9 +375,6 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
396
375
  protected __internal_bindMethods() {
397
376
  this.append = this.append.bind(this);
398
377
  this.resumeRun = this.resumeRun.bind(this);
399
- this.unstable_resumeRun = this.unstable_resumeRun.bind(this);
400
- this.unstable_loadExternalState =
401
- this.unstable_loadExternalState.bind(this);
402
378
  this.importExternalState = this.importExternalState.bind(this);
403
379
  this.exportExternalState = this.exportExternalState.bind(this);
404
380
  this.startRun = this.startRun.bind(this);
@@ -418,7 +394,6 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
418
394
  this.subscribe = this.subscribe.bind(this);
419
395
  this.unstable_on = this.unstable_on.bind(this);
420
396
  this.getModelContext = this.getModelContext.bind(this);
421
- this.getModelConfig = this.getModelConfig.bind(this);
422
397
  this.getState = this.getState.bind(this);
423
398
  }
424
399
 
@@ -444,15 +419,7 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
444
419
  return this._threadBinding.getState().getModelContext();
445
420
  }
446
421
 
447
- public getModelConfig() {
448
- return this.getModelContext();
449
- }
450
-
451
- public startRun(configOrParentId: string | null | CreateStartRunConfig) {
452
- const config =
453
- configOrParentId === null || typeof configOrParentId === "string"
454
- ? { parentId: configOrParentId }
455
- : configOrParentId;
422
+ public startRun(config: CreateStartRunConfig) {
456
423
  return this._threadBinding.getState().startRun(toStartRunConfig(config));
457
424
  }
458
425
 
@@ -460,11 +427,6 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
460
427
  return this._threadBinding.getState().resumeRun(toResumeRunConfig(config));
461
428
  }
462
429
 
463
- /** @deprecated Use `resumeRun` instead. */
464
- public unstable_resumeRun(config: CreateResumeRunConfig) {
465
- return this.resumeRun(config);
466
- }
467
-
468
430
  public exportExternalState() {
469
431
  return this._threadBinding.getState().exportExternalState();
470
432
  }
@@ -473,10 +435,6 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
473
435
  this._threadBinding.getState().importExternalState(state);
474
436
  }
475
437
 
476
- public unstable_loadExternalState(state: any) {
477
- this._threadBinding.getState().unstable_loadExternalState(state);
478
- }
479
-
480
438
  public cancelRun() {
481
439
  this._threadBinding.getState().cancelRun();
482
440
  }
@@ -575,7 +533,6 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
575
533
  const thread = this._threadBinding.getState();
576
534
 
577
535
  const branches = thread.getBranches(message.id);
578
- const submittedFeedback = message.metadata.submittedFeedback;
579
536
 
580
537
  return {
581
538
  ...message,
@@ -590,8 +547,6 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
590
547
 
591
548
  speech:
592
549
  speechState?.messageId === message.id ? speechState : undefined,
593
-
594
- submittedFeedback,
595
550
  } satisfies MessageState;
596
551
  },
597
552
  subscribe: (callback) => this._threadBinding.subscribe(callback),
@@ -52,6 +52,7 @@ export abstract class BaseComposerRuntimeCore
52
52
  }
53
53
 
54
54
  public abstract get canCancel(): boolean;
55
+ public abstract get canSend(): boolean;
55
56
 
56
57
  public get isEmpty() {
57
58
  return !this.text.trim() && !this.attachments.length;
@@ -157,7 +158,7 @@ export abstract class BaseComposerRuntimeCore
157
158
  }
158
159
 
159
160
  public async send(options?: SendOptions) {
160
- if (this.isEmpty) return;
161
+ if (!this.canSend) return;
161
162
 
162
163
  if (this._dictationSession) {
163
164
  this._dictationSession.cancel();
@@ -48,6 +48,7 @@ export abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {
48
48
  protected readonly repository = new MessageRepository();
49
49
  public abstract get adapters(): BaseThreadAdapters | undefined;
50
50
  public abstract get isDisabled(): boolean;
51
+ public abstract get isSendDisabled(): boolean;
51
52
  public abstract get isLoading(): boolean;
52
53
  public abstract get suggestions(): readonly ThreadSuggestion[];
53
54
  public abstract get extras(): unknown;
@@ -61,7 +62,6 @@ export abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {
61
62
  public abstract cancelRun(): void;
62
63
  public abstract exportExternalState(): any;
63
64
  public abstract importExternalState(state: any): void;
64
- public abstract unstable_loadExternalState(state: any): void;
65
65
 
66
66
  protected _voiceMessages: ThreadMessage[] = [];
67
67
  protected _voiceGeneration = 0;
@@ -13,6 +13,10 @@ export class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
13
13
  return true;
14
14
  }
15
15
 
16
+ public get canSend() {
17
+ return !this.isEmpty;
18
+ }
19
+
16
20
  protected getAttachmentAdapter() {
17
21
  return this.runtime.adapters?.attachments;
18
22
  }
@@ -17,6 +17,10 @@ export class DefaultThreadComposerRuntimeCore
17
17
  return this._canCancel;
18
18
  }
19
19
 
20
+ public get canSend() {
21
+ return !this.isEmpty && !this.runtime.isSendDisabled;
22
+ }
23
+
20
24
  protected getAttachmentAdapter() {
21
25
  return this.runtime.adapters?.attachments;
22
26
  }
@@ -40,11 +44,18 @@ export class DefaultThreadComposerRuntimeCore
40
44
  }
41
45
 
42
46
  public connect() {
47
+ let lastIsSendDisabled = this.runtime.isSendDisabled;
43
48
  return this.runtime.subscribe(() => {
49
+ let changed = false;
44
50
  if (this.canCancel !== this.runtime.capabilities.cancel) {
45
51
  this._canCancel = this.runtime.capabilities.cancel;
46
- this._notifySubscribers();
52
+ changed = true;
53
+ }
54
+ if (lastIsSendDisabled !== this.runtime.isSendDisabled) {
55
+ lastIsSendDisabled = this.runtime.isSendDisabled;
56
+ changed = true;
47
57
  }
58
+ if (changed) this._notifySubscribers();
48
59
  });
49
60
  }
50
61
 
@@ -51,6 +51,7 @@ export type ComposerRuntimeCore = Readonly<{
51
51
  isEditing: boolean;
52
52
 
53
53
  canCancel: boolean;
54
+ canSend: boolean;
54
55
  isEmpty: boolean;
55
56
 
56
57
  attachments: readonly Attachment[];
@@ -17,6 +17,8 @@ export type ThreadListItemCoreState = {
17
17
 
18
18
  export type ThreadListRuntimeCore = {
19
19
  readonly isLoading: boolean;
20
+ readonly isLoadingMore?: boolean;
21
+ readonly hasMore?: boolean;
20
22
  mainThreadId: string;
21
23
  newThreadId: string | undefined;
22
24
 
@@ -35,6 +37,7 @@ export type ThreadListRuntimeCore = {
35
37
 
36
38
  getLoadThreadsPromise(): Promise<void>;
37
39
  reload?(): Promise<void>;
40
+ loadMore?(): Promise<void>;
38
41
 
39
42
  detach(threadId: string): Promise<void>;
40
43
  rename(threadId: string, newTitle: string): Promise<void>;
@@ -158,6 +158,12 @@ export type ThreadRuntimeCore = Readonly<{
158
158
 
159
159
  capabilities: Readonly<RuntimeCapabilities>;
160
160
  isDisabled: boolean;
161
+ /**
162
+ * Whether sending from this thread's composer is disabled. Surfaces the
163
+ * `isSendDisabled` flag from external-store adapters; internal runtimes
164
+ * default to `false`. Composer state derives `canSend` from this.
165
+ */
166
+ isSendDisabled: boolean;
161
167
  isLoading: boolean;
162
168
  /**
163
169
  * Optional explicit thread-level running flag. When provided, takes
@@ -194,9 +200,4 @@ export type ThreadRuntimeCore = Readonly<{
194
200
  event: E,
195
201
  callback: ThreadRuntimeEventCallback<E>,
196
202
  ): Unsubscribe;
197
-
198
- /**
199
- * @deprecated Use importExternalState instead. This method will be removed in 0.12.0.
200
- */
201
- unstable_loadExternalState: (state: any) => void;
202
203
  }>;
@@ -50,11 +50,6 @@ export type ChatModelRunOptions = {
50
50
  readonly abortSignal: AbortSignal;
51
51
  readonly context: ModelContext;
52
52
 
53
- /**
54
- * @deprecated This field was renamed to `context`.
55
- */
56
- readonly config: ModelContext;
57
-
58
53
  readonly unstable_assistantMessageId?: string | undefined;
59
54
  readonly unstable_threadId?: string | undefined;
60
55
  readonly unstable_parentId?: string | null | undefined;
@@ -8,14 +8,6 @@ type WithInnerMessages<T> = {
8
8
  [symbolInnerMessages]?: T[];
9
9
  };
10
10
 
11
- /**
12
- * @deprecated Use `getExternalStoreMessages` (plural) instead. This function will be removed in 0.12.0.
13
- */
14
- export const getExternalStoreMessage = <T>(input: ThreadMessage) => {
15
- const withInnerMessages = input as WithInnerMessages<T>;
16
- return withInnerMessages[symbolInnerMessage];
17
- };
18
-
19
11
  const EMPTY_ARRAY: never[] = [];
20
12
 
21
13
  /**
@@ -1,31 +1,3 @@
1
- import {
2
- type Tool,
3
- toToolsJSONSchema,
4
- type ToolJSONSchema,
5
- } from "assistant-stream";
6
-
7
- /**
8
- * @deprecated Use `toToolsJSONSchema` from `assistant-stream` instead.
9
- */
10
- export function toAISDKTools(
11
- tools: Record<string, Tool>,
12
- ): Record<string, ToolJSONSchema> {
13
- return toToolsJSONSchema(tools, { filter: () => true });
14
- }
15
-
16
- /**
17
- * @deprecated Use `toToolsJSONSchema` from `assistant-stream` instead, which includes filtering by default.
18
- */
19
- export function getEnabledTools(
20
- tools: Record<string, Tool>,
21
- ): Record<string, Tool> {
22
- return Object.fromEntries(
23
- Object.entries(tools).filter(
24
- ([, tool]) => !tool.disabled && tool.type !== "backend",
25
- ),
26
- );
27
- }
28
-
29
1
  export async function createRequestHeaders(
30
2
  headersValue:
31
3
  | Record<string, string>
@@ -59,7 +59,22 @@ type ExternalStoreMessageConverterAdapter<T> = {
59
59
  };
60
60
 
61
61
  type ExternalStoreAdapterBase<T> = {
62
+ /**
63
+ * Whether the entire thread is disabled. When `true`, the composer's input
64
+ * is also disabled (the user cannot type, attach files, or submit). For a
65
+ * narrower gate that keeps the input usable but blocks only sending, use
66
+ * `isSendDisabled`.
67
+ */
62
68
  isDisabled?: boolean | undefined;
69
+ /**
70
+ * Whether sending new messages is currently disabled. When `true`, the
71
+ * thread composer's input remains usable but `send()` becomes a no-op
72
+ * and the thread composer's `canSend` is `false`. Use this to gate
73
+ * sending on external React state (e.g. while tool config is loading)
74
+ * without disabling the input itself the way `isDisabled` does. Edit
75
+ * composers (saving message edits) intentionally ignore this flag.
76
+ */
77
+ isSendDisabled?: boolean | undefined;
63
78
  /**
64
79
  * Whether the thread is running. When provided, this value flows directly
65
80
  * to `thread.isRunning`, letting the application keep the thread in a
@@ -78,14 +78,7 @@ export class ExternalStoreThreadListRuntimeCore
78
78
  }
79
79
 
80
80
  public getItemById(threadId: string) {
81
- for (const thread of this.adapter.threads ?? []) {
82
- if (thread.id === threadId) return thread as any;
83
- }
84
- for (const thread of this.adapter.archivedThreads ?? []) {
85
- if (thread.id === threadId) return thread as any;
86
- }
87
- if (threadId === DEFAULT_THREAD_ID) return DEFAULT_THREAD;
88
- return undefined;
81
+ return this._threadData[threadId];
89
82
  }
90
83
 
91
84
  public __internal_setAdapter(
@@ -115,7 +108,8 @@ export class ExternalStoreThreadListRuntimeCore
115
108
 
116
109
  if (
117
110
  previousThreads !== newThreads ||
118
- previousArchivedThreads !== newArchivedThreads
111
+ previousArchivedThreads !== newArchivedThreads ||
112
+ previousThreadId !== newThreadId
119
113
  ) {
120
114
  this._threadData = {
121
115
  ...DEFAULT_THREAD_DATA,
@@ -159,6 +153,18 @@ export class ExternalStoreThreadListRuntimeCore
159
153
  this._mainThread = this.threadFactory();
160
154
  }
161
155
 
156
+ if (!this._threadData[this._mainThreadId]) {
157
+ this._threadData = {
158
+ ...this._threadData,
159
+ [this._mainThreadId]: {
160
+ id: this._mainThreadId,
161
+ remoteId: undefined,
162
+ externalId: undefined,
163
+ status: "regular",
164
+ },
165
+ };
166
+ }
167
+
162
168
  this._notifySubscribers();
163
169
  }
164
170
 
@@ -75,6 +75,7 @@ export class ExternalStoreThreadRuntimeCore
75
75
 
76
76
  private _messages!: readonly ThreadMessage[];
77
77
  public isDisabled!: boolean;
78
+ public isSendDisabled!: boolean;
78
79
  public get isLoading() {
79
80
  return this._store.isLoading ?? false;
80
81
  }
@@ -122,6 +123,7 @@ export class ExternalStoreThreadRuntimeCore
122
123
 
123
124
  const isRunning = store.isRunning ?? false;
124
125
  this.isDisabled = store.isDisabled ?? false;
126
+ this.isSendDisabled = store.isSendDisabled ?? false;
125
127
 
126
128
  const oldStore = this._store as ExternalStoreAdapter<any> | undefined;
127
129
  this._store = store;
@@ -316,10 +318,6 @@ export class ExternalStoreThreadRuntimeCore
316
318
  this._store.onLoadExternalState(state);
317
319
  }
318
320
 
319
- public unstable_loadExternalState(state: any): void {
320
- this.importExternalState(state);
321
- }
322
-
323
321
  public cancelRun(): void {
324
322
  if (!this._store.onCancel)
325
323
  throw new Error("Runtime does not support cancelling runs.");
@@ -54,6 +54,7 @@ export class LocalThreadRuntimeCore
54
54
  private abortController: AbortController | null = null;
55
55
 
56
56
  public readonly isDisabled = false;
57
+ public readonly isSendDisabled = false;
57
58
 
58
59
  private _isLoading = false;
59
60
  public get isLoading() {
@@ -226,10 +227,6 @@ export class LocalThreadRuntimeCore
226
227
  throw new Error("Runtime does not support importing external states.");
227
228
  }
228
229
 
229
- public unstable_loadExternalState(): void {
230
- throw new Error("Runtime does not support importing external states.");
231
- }
232
-
233
230
  public async startRun(
234
231
  { parentId, runConfig }: StartRunConfig,
235
232
  runCallback?: ChatModelAdapter["run"],
@@ -405,7 +402,6 @@ export class LocalThreadRuntimeCore
405
402
  runConfig: this._lastRunConfig,
406
403
  abortSignal,
407
404
  context,
408
- config: context,
409
405
  unstable_assistantMessageId: message.id,
410
406
  unstable_threadId: threadId,
411
407
  unstable_parentId: parentId,
@@ -104,10 +104,6 @@ export class ReadonlyThreadRuntimeCore
104
104
  throw READONLY_THREAD_ERROR;
105
105
  }
106
106
 
107
- unstable_loadExternalState(): void {
108
- throw READONLY_THREAD_ERROR;
109
- }
110
-
111
107
  composer = {
112
108
  attachments: [] as never[],
113
109
  attachmentAccept: "*",
@@ -122,6 +118,7 @@ export class ReadonlyThreadRuntimeCore
122
118
 
123
119
  isEditing: false as const,
124
120
  canCancel: false,
121
+ canSend: false,
125
122
  isEmpty: true,
126
123
  text: "",
127
124
 
@@ -209,6 +206,7 @@ export class ReadonlyThreadRuntimeCore
209
206
  } as const;
210
207
 
211
208
  isDisabled = false;
209
+ isSendDisabled = false;
212
210
  isLoading = false;
213
211
 
214
212
  state = null;
@@ -83,10 +83,6 @@ export const EMPTY_THREAD_CORE: ThreadRuntimeCore = {
83
83
  throw EMPTY_THREAD_ERROR;
84
84
  },
85
85
 
86
- unstable_loadExternalState() {
87
- throw EMPTY_THREAD_ERROR;
88
- },
89
-
90
86
  composer: {
91
87
  attachments: [],
92
88
  attachmentAccept: "*",
@@ -102,6 +98,7 @@ export const EMPTY_THREAD_CORE: ThreadRuntimeCore = {
102
98
  isEditing: true,
103
99
 
104
100
  canCancel: false,
101
+ canSend: false,
105
102
  isEmpty: true,
106
103
 
107
104
  text: "",
@@ -190,6 +187,7 @@ export const EMPTY_THREAD_CORE: ThreadRuntimeCore = {
190
187
  },
191
188
 
192
189
  isDisabled: false,
190
+ isSendDisabled: false,
193
191
  isLoading: true,
194
192
 
195
193
  messages: [],
@@ -1,4 +1,7 @@
1
- import type { RemoteThreadInitializeResponse } from "./types";
1
+ import type {
2
+ RemoteThreadInitializeResponse,
3
+ RemoteThreadMetadata,
4
+ } from "./types";
2
5
 
3
6
  export type RemoteThreadData =
4
7
  | {
@@ -34,8 +37,58 @@ export function createThreadMappingId(id: string): THREAD_MAPPING_ID {
34
37
  return id as THREAD_MAPPING_ID;
35
38
  }
36
39
 
40
+ export const normalizeCursor = (c: string | undefined): string | undefined =>
41
+ c || undefined;
42
+
43
+ type ClassifyAccumulator = {
44
+ threadIds: string[];
45
+ archivedThreadIds: string[];
46
+ threadIdMap: Record<string, THREAD_MAPPING_ID>;
47
+ threadData: Record<THREAD_MAPPING_ID, RemoteThreadData>;
48
+ };
49
+
50
+ export const classifyThreads = (
51
+ threads: readonly RemoteThreadMetadata[],
52
+ acc: ClassifyAccumulator,
53
+ ): ClassifyAccumulator => {
54
+ for (const thread of threads) {
55
+ if (acc.threadIdMap[thread.remoteId] !== undefined) continue;
56
+
57
+ switch (thread.status) {
58
+ case "regular":
59
+ acc.threadIds.push(thread.remoteId);
60
+ break;
61
+ case "archived":
62
+ acc.archivedThreadIds.push(thread.remoteId);
63
+ break;
64
+ default: {
65
+ const _exhaustiveCheck: never = thread.status;
66
+ throw new Error(`Unsupported state: ${_exhaustiveCheck}`);
67
+ }
68
+ }
69
+
70
+ const mappingId = createThreadMappingId(thread.remoteId);
71
+ acc.threadIdMap[thread.remoteId] = mappingId;
72
+ acc.threadData[mappingId] = {
73
+ id: thread.remoteId,
74
+ remoteId: thread.remoteId,
75
+ externalId: thread.externalId,
76
+ status: thread.status,
77
+ title: thread.title,
78
+ custom: thread.custom,
79
+ initializeTask: Promise.resolve({
80
+ remoteId: thread.remoteId,
81
+ externalId: thread.externalId,
82
+ }),
83
+ };
84
+ }
85
+ return acc;
86
+ };
87
+
37
88
  export type RemoteThreadState = {
38
89
  readonly isLoading: boolean;
90
+ readonly isLoadingMore: boolean;
91
+ readonly cursor: string | undefined;
39
92
  readonly newThreadId: string | undefined;
40
93
  readonly threadIds: readonly string[];
41
94
  readonly archivedThreadIds: readonly string[];
@@ -18,10 +18,15 @@ export type RemoteThreadMetadata = {
18
18
 
19
19
  export type RemoteThreadListResponse = {
20
20
  threads: RemoteThreadMetadata[];
21
+ nextCursor?: string | undefined;
22
+ };
23
+
24
+ export type RemoteThreadListPageOptions = {
25
+ after?: string | undefined;
21
26
  };
22
27
 
23
28
  export type RemoteThreadListAdapter = {
24
- list(): Promise<RemoteThreadListResponse>;
29
+ list(params?: RemoteThreadListPageOptions): Promise<RemoteThreadListResponse>;
25
30
 
26
31
  rename(remoteId: string, newTitle: string): Promise<void>;
27
32
  archive(remoteId: string): Promise<void>;
@@ -14,6 +14,7 @@ export const NoOpComposerClient = resource(
14
14
  role: "user",
15
15
  runConfig: {},
16
16
  canCancel: false,
17
+ canSend: false,
17
18
  type: type,
18
19
  dictation: undefined,
19
20
  quote: undefined,
@@ -106,7 +106,6 @@ export const ThreadMessageClient = resource(
106
106
  branchNumber,
107
107
  branchCount,
108
108
  speech: undefined,
109
- submittedFeedback: message.metadata.submittedFeedback,
110
109
  isCopied: isCopiedState,
111
110
  isHovering: isHoveringState,
112
111
  };
@@ -103,6 +103,7 @@ export const ComposerClient = resource(
103
103
  runConfig: runtimeState.runConfig,
104
104
  isEditing: runtimeState.isEditing,
105
105
  canCancel: runtimeState.canCancel,
106
+ canSend: runtimeState.canSend,
106
107
  attachmentAccept: runtimeState.attachmentAccept,
107
108
  isEmpty: runtimeState.isEmpty,
108
109
  type: runtimeState.type ?? "thread",
@@ -53,6 +53,8 @@ export const ThreadListClient = resource(
53
53
  mainThreadId: runtimeState.mainThreadId,
54
54
  newThreadId: runtimeState.newThreadId ?? null,
55
55
  isLoading: runtimeState.isLoading,
56
+ isLoadingMore: runtimeState.isLoadingMore,
57
+ hasMore: runtimeState.hasMore,
56
58
  threadIds: runtimeState.threadIds,
57
59
  archivedThreadIds: runtimeState.archivedThreadIds,
58
60
  threadItems: threadItems.state,
@@ -87,6 +89,7 @@ export const ThreadListClient = resource(
87
89
  },
88
90
  getLoadThreadsPromise: () => runtime.getLoadThreadsPromise(),
89
91
  reload: () => runtime.reload(),
92
+ loadMore: () => runtime.loadMore(),
90
93
  __internal_getAssistantRuntime: () => __internal_assistantRuntime,
91
94
  };
92
95
  },
@@ -116,7 +116,6 @@ export const ThreadClient = resource(
116
116
  append: runtime.append,
117
117
  startRun: runtime.startRun,
118
118
  resumeRun: runtime.resumeRun,
119
- unstable_resumeRun: runtime.resumeRun,
120
119
  cancelRun: runtime.cancelRun,
121
120
  getModelContext: runtime.getModelContext,
122
121
  export: runtime.export,