@assistant-ui/react 0.8.11 → 0.8.12

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 (44) hide show
  1. package/dist/api/ThreadRuntime.d.ts +12 -1
  2. package/dist/api/ThreadRuntime.d.ts.map +1 -1
  3. package/dist/api/ThreadRuntime.js +11 -0
  4. package/dist/api/ThreadRuntime.js.map +1 -1
  5. package/dist/api/ThreadRuntime.mjs +11 -0
  6. package/dist/api/ThreadRuntime.mjs.map +1 -1
  7. package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts +2 -1
  8. package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts.map +1 -1
  9. package/dist/runtimes/core/BaseThreadRuntimeCore.js.map +1 -1
  10. package/dist/runtimes/core/BaseThreadRuntimeCore.mjs.map +1 -1
  11. package/dist/runtimes/core/ThreadRuntimeCore.d.ts +5 -0
  12. package/dist/runtimes/core/ThreadRuntimeCore.d.ts.map +1 -1
  13. package/dist/runtimes/core/ThreadRuntimeCore.js.map +1 -1
  14. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts +1 -0
  15. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
  16. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +3 -0
  17. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
  18. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs +3 -0
  19. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs.map +1 -1
  20. package/dist/runtimes/external-store/ThreadMessageLike.d.ts +1 -0
  21. package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
  22. package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
  23. package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
  24. package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts +2 -1
  25. package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
  26. package/dist/runtimes/local/LocalThreadRuntimeCore.js +3 -0
  27. package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
  28. package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +3 -0
  29. package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
  30. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +2 -0
  31. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  32. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +2 -0
  33. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  34. package/dist/types/AssistantTypes.d.ts +1 -0
  35. package/dist/types/AssistantTypes.d.ts.map +1 -1
  36. package/dist/types/AssistantTypes.js.map +1 -1
  37. package/package.json +2 -2
  38. package/src/api/ThreadRuntime.ts +26 -0
  39. package/src/runtimes/core/BaseThreadRuntimeCore.tsx +2 -0
  40. package/src/runtimes/core/ThreadRuntimeCore.tsx +6 -0
  41. package/src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx +4 -0
  42. package/src/runtimes/external-store/ThreadMessageLike.tsx +1 -0
  43. package/src/runtimes/local/LocalThreadRuntimeCore.tsx +5 -0
  44. package/src/types/AssistantTypes.ts +1 -0
@@ -5,6 +5,7 @@ import {
5
5
  SpeechState,
6
6
  ThreadRuntimeEventType,
7
7
  StartRunConfig,
8
+ ResumeRunConfig,
8
9
  } from "../runtimes/core/ThreadRuntimeCore";
9
10
  import { ExportedMessageRepository } from "../runtimes/utils/MessageRepository";
10
11
  import { AppendMessage, ThreadMessage, Unsubscribe } from "../types";
@@ -31,6 +32,7 @@ import { RunConfig } from "../types/AssistantTypes";
31
32
  import { EventSubscriptionSubject } from "./subscribable/EventSubscriptionSubject";
32
33
  import { symbolInnerMessage } from "../runtimes/external-store/getExternalStoreMessage";
33
34
  import { ModelContext } from "../model-context";
35
+ import { ChatModelRunResult } from "../runtimes";
34
36
 
35
37
  export type CreateStartRunConfig = {
36
38
  parentId: string | null;
@@ -38,6 +40,19 @@ export type CreateStartRunConfig = {
38
40
  runConfig?: RunConfig | undefined;
39
41
  };
40
42
 
43
+ export type CreateResumeRunConfig = CreateStartRunConfig & {
44
+ stream: AsyncGenerator<ChatModelRunResult, void, unknown>;
45
+ };
46
+
47
+ const toResumeRunConfig = (message: CreateResumeRunConfig): ResumeRunConfig => {
48
+ return {
49
+ parentId: message.parentId ?? null,
50
+ sourceId: message.sourceId ?? null,
51
+ runConfig: message.runConfig ?? {},
52
+ stream: message.stream,
53
+ };
54
+ };
55
+
41
56
  const toStartRunConfig = (message: CreateStartRunConfig): StartRunConfig => {
42
57
  return {
43
58
  parentId: message.parentId ?? null,
@@ -211,6 +226,13 @@ export type ThreadRuntime = {
211
226
  * @param config The configuration for starting the run
212
227
  */
213
228
  startRun(config: CreateStartRunConfig): void;
229
+
230
+ /**
231
+ * Resume a run with the given configuration.
232
+ * @param config The configuration for resuming the run
233
+ **/
234
+ unstable_resumeRun(config: CreateResumeRunConfig): void;
235
+
214
236
  subscribe(callback: () => void): Unsubscribe;
215
237
  cancelRun(): void;
216
238
  getModelContext(): ModelContext;
@@ -338,6 +360,10 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
338
360
  return this._threadBinding.getState().startRun(toStartRunConfig(config));
339
361
  }
340
362
 
363
+ public unstable_resumeRun(config: CreateResumeRunConfig) {
364
+ return this._threadBinding.getState().resumeRun(toResumeRunConfig(config));
365
+ }
366
+
341
367
  public cancelRun() {
342
368
  this._threadBinding.getState().cancelRun();
343
369
  }
@@ -14,6 +14,7 @@ import {
14
14
  SubmittedFeedback,
15
15
  ThreadRuntimeEventType,
16
16
  StartRunConfig,
17
+ ResumeRunConfig,
17
18
  } from "../core/ThreadRuntimeCore";
18
19
  import { DefaultEditComposerRuntimeCore } from "../composer/DefaultEditComposerRuntimeCore";
19
20
  import { SpeechSynthesisAdapter } from "../adapters/speech/SpeechAdapterTypes";
@@ -41,6 +42,7 @@ export abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {
41
42
  public abstract get capabilities(): RuntimeCapabilities;
42
43
  public abstract append(message: AppendMessage): void;
43
44
  public abstract startRun(config: StartRunConfig): void;
45
+ public abstract resumeRun(config: ResumeRunConfig): void;
44
46
  public abstract addToolResult(options: AddToolResultOptions): void;
45
47
  public abstract cancelRun(): void;
46
48
 
@@ -3,6 +3,7 @@ import { AppendMessage, ThreadMessage } from "../../types";
3
3
  import { RunConfig } from "../../types/AssistantTypes";
4
4
  import type { Unsubscribe } from "../../types/Unsubscribe";
5
5
  import { SpeechSynthesisAdapter } from "../adapters/speech/SpeechAdapterTypes";
6
+ import { ChatModelRunResult } from "../local";
6
7
  import { ExportedMessageRepository } from "../utils/MessageRepository";
7
8
  import {
8
9
  ComposerRuntimeCore,
@@ -57,6 +58,10 @@ export type StartRunConfig = {
57
58
  runConfig: RunConfig;
58
59
  };
59
60
 
61
+ export type ResumeRunConfig = StartRunConfig & {
62
+ stream: AsyncGenerator<ChatModelRunResult, void, unknown>;
63
+ };
64
+
60
65
  export type ThreadRuntimeCore = Readonly<{
61
66
  getMessageById: (messageId: string) =>
62
67
  | {
@@ -70,6 +75,7 @@ export type ThreadRuntimeCore = Readonly<{
70
75
 
71
76
  append: (message: AppendMessage) => void;
72
77
  startRun: (config: StartRunConfig) => void;
78
+ resumeRun: (config: ResumeRunConfig) => void;
73
79
  cancelRun: () => void;
74
80
 
75
81
  addToolResult: (options: AddToolResultOptions) => void;
@@ -209,6 +209,10 @@ export class ExternalStoreThreadRuntimeCore
209
209
  await this._store.onReload(config.parentId, config);
210
210
  }
211
211
 
212
+ public async resumeRun(): Promise<void> {
213
+ throw new Error("Runtime does not support resuming runs.");
214
+ }
215
+
212
216
  public cancelRun(): void {
213
217
  if (!this._store.onCancel)
214
218
  throw new Error("Runtime does not support cancelling runs.");
@@ -41,6 +41,7 @@ export type ThreadMessageLike = {
41
41
  readonly toolName: string;
42
42
  readonly args?: ReadonlyJSONObject;
43
43
  readonly argsText?: string;
44
+ readonly artifact?: any;
44
45
  readonly result?: any | undefined;
45
46
  readonly isError?: boolean | undefined;
46
47
  }
@@ -9,6 +9,7 @@ import {
9
9
  ThreadSuggestion,
10
10
  ThreadRuntimeCore,
11
11
  StartRunConfig,
12
+ ResumeRunConfig,
12
13
  } from "../core/ThreadRuntimeCore";
13
14
  import { BaseThreadRuntimeCore } from "../core/BaseThreadRuntimeCore";
14
15
  import { RunConfig } from "../../types/AssistantTypes";
@@ -139,6 +140,10 @@ export class LocalThreadRuntimeCore
139
140
  }
140
141
  }
141
142
 
143
+ public resumeRun({ stream, ...startConfig }: ResumeRunConfig): Promise<void> {
144
+ return this.startRun(startConfig, () => stream);
145
+ }
146
+
142
147
  public async startRun(
143
148
  { parentId, runConfig }: StartRunConfig,
144
149
  runCallback?: ChatModelAdapter["run"],
@@ -99,6 +99,7 @@ export type ToolCallContentPart<
99
99
  TResult = unknown,
100
100
  > = CoreToolCallContentPart<TArgs, TResult> & {
101
101
  readonly argsText: string;
102
+ readonly artifact?: ReadonlyJSONValue;
102
103
  };
103
104
 
104
105
  export type ThreadUserContentPart =