@assistant-ui/react 0.8.11 → 0.8.14

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 +28 -0
  39. package/src/runtimes/core/BaseThreadRuntimeCore.tsx +2 -0
  40. package/src/runtimes/core/ThreadRuntimeCore.tsx +8 -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 { ChatModelRunOptions, ChatModelRunResult } from "../runtimes";
34
36
 
35
37
  export type CreateStartRunConfig = {
36
38
  parentId: string | null;
@@ -38,6 +40,21 @@ export type CreateStartRunConfig = {
38
40
  runConfig?: RunConfig | undefined;
39
41
  };
40
42
 
43
+ export type CreateResumeRunConfig = CreateStartRunConfig & {
44
+ stream: (
45
+ options: ChatModelRunOptions,
46
+ ) => AsyncGenerator<ChatModelRunResult, void, unknown>;
47
+ };
48
+
49
+ const toResumeRunConfig = (message: CreateResumeRunConfig): ResumeRunConfig => {
50
+ return {
51
+ parentId: message.parentId ?? null,
52
+ sourceId: message.sourceId ?? null,
53
+ runConfig: message.runConfig ?? {},
54
+ stream: message.stream,
55
+ };
56
+ };
57
+
41
58
  const toStartRunConfig = (message: CreateStartRunConfig): StartRunConfig => {
42
59
  return {
43
60
  parentId: message.parentId ?? null,
@@ -211,6 +228,13 @@ export type ThreadRuntime = {
211
228
  * @param config The configuration for starting the run
212
229
  */
213
230
  startRun(config: CreateStartRunConfig): void;
231
+
232
+ /**
233
+ * Resume a run with the given configuration.
234
+ * @param config The configuration for resuming the run
235
+ **/
236
+ unstable_resumeRun(config: CreateResumeRunConfig): void;
237
+
214
238
  subscribe(callback: () => void): Unsubscribe;
215
239
  cancelRun(): void;
216
240
  getModelContext(): ModelContext;
@@ -338,6 +362,10 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
338
362
  return this._threadBinding.getState().startRun(toStartRunConfig(config));
339
363
  }
340
364
 
365
+ public unstable_resumeRun(config: CreateResumeRunConfig) {
366
+ return this._threadBinding.getState().resumeRun(toResumeRunConfig(config));
367
+ }
368
+
341
369
  public cancelRun() {
342
370
  this._threadBinding.getState().cancelRun();
343
371
  }
@@ -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 { ChatModelRunOptions, ChatModelRunResult } from "../local";
6
7
  import { ExportedMessageRepository } from "../utils/MessageRepository";
7
8
  import {
8
9
  ComposerRuntimeCore,
@@ -57,6 +58,12 @@ export type StartRunConfig = {
57
58
  runConfig: RunConfig;
58
59
  };
59
60
 
61
+ export type ResumeRunConfig = StartRunConfig & {
62
+ stream: (
63
+ options: ChatModelRunOptions,
64
+ ) => AsyncGenerator<ChatModelRunResult, void, unknown>;
65
+ };
66
+
60
67
  export type ThreadRuntimeCore = Readonly<{
61
68
  getMessageById: (messageId: string) =>
62
69
  | {
@@ -70,6 +77,7 @@ export type ThreadRuntimeCore = Readonly<{
70
77
 
71
78
  append: (message: AppendMessage) => void;
72
79
  startRun: (config: StartRunConfig) => void;
80
+ resumeRun: (config: ResumeRunConfig) => void;
73
81
  cancelRun: () => void;
74
82
 
75
83
  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 =