@assistant-ui/react 0.7.75 → 0.7.77

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 (54) hide show
  1. package/README.md +36 -0
  2. package/dist/api/AssistantRuntime.d.ts +1 -1
  3. package/dist/api/AssistantRuntime.js +1 -1
  4. package/dist/api/AssistantRuntime.js.map +1 -1
  5. package/dist/api/AssistantRuntime.mjs +1 -1
  6. package/dist/api/AssistantRuntime.mjs.map +1 -1
  7. package/dist/context/providers/AssistantRuntimeProvider.js +1 -1
  8. package/dist/context/providers/AssistantRuntimeProvider.js.map +1 -1
  9. package/dist/context/providers/AssistantRuntimeProvider.mjs +1 -1
  10. package/dist/context/providers/AssistantRuntimeProvider.mjs.map +1 -1
  11. package/dist/primitives/threadList/ThreadListItems.js +1 -1
  12. package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
  13. package/dist/primitives/threadList/ThreadListItems.mjs +1 -1
  14. package/dist/primitives/threadList/ThreadListItems.mjs.map +1 -1
  15. package/dist/runtimes/edge/converters/toLanguageModelMessages.d.ts.map +1 -1
  16. package/dist/runtimes/edge/converters/toLanguageModelMessages.js +2 -2
  17. package/dist/runtimes/edge/converters/toLanguageModelMessages.js.map +1 -1
  18. package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs +2 -2
  19. package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs.map +1 -1
  20. package/dist/runtimes/edge/streams/toolResultStream.js +1 -1
  21. package/dist/runtimes/edge/streams/toolResultStream.js.map +1 -1
  22. package/dist/runtimes/edge/streams/toolResultStream.mjs +1 -1
  23. package/dist/runtimes/edge/streams/toolResultStream.mjs.map +1 -1
  24. package/dist/runtimes/local/LocalRuntimeOptions.d.ts +4 -5
  25. package/dist/runtimes/local/LocalRuntimeOptions.d.ts.map +1 -1
  26. package/dist/runtimes/local/LocalRuntimeOptions.js +2 -2
  27. package/dist/runtimes/local/LocalRuntimeOptions.js.map +1 -1
  28. package/dist/runtimes/local/LocalRuntimeOptions.mjs +2 -2
  29. package/dist/runtimes/local/LocalRuntimeOptions.mjs.map +1 -1
  30. package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
  31. package/dist/runtimes/local/LocalThreadRuntimeCore.js +2 -8
  32. package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
  33. package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +2 -8
  34. package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
  35. package/dist/runtimes/local/shouldContinue.d.ts +1 -1
  36. package/dist/runtimes/local/shouldContinue.d.ts.map +1 -1
  37. package/dist/runtimes/local/shouldContinue.js +8 -3
  38. package/dist/runtimes/local/shouldContinue.js.map +1 -1
  39. package/dist/runtimes/local/shouldContinue.mjs +8 -3
  40. package/dist/runtimes/local/shouldContinue.mjs.map +1 -1
  41. package/dist/styles/index.css +1 -1
  42. package/dist/styles/index.css.map +1 -1
  43. package/dist/styles/tailwindcss/thread.css +7 -7
  44. package/dist/styles/tailwindcss/thread.css.json +6 -6
  45. package/package.json +3 -3
  46. package/src/api/AssistantRuntime.ts +2 -2
  47. package/src/context/providers/AssistantRuntimeProvider.tsx +1 -1
  48. package/src/primitives/threadList/ThreadListItems.tsx +2 -2
  49. package/src/runtimes/edge/converters/toLanguageModelMessages.ts +5 -2
  50. package/src/runtimes/edge/streams/toolResultStream.ts +1 -1
  51. package/src/runtimes/local/LocalRuntimeOptions.tsx +4 -5
  52. package/src/runtimes/local/LocalThreadRuntimeCore.tsx +2 -10
  53. package/src/runtimes/local/shouldContinue.tsx +21 -9
  54. package/src/styles/tailwindcss/thread.css +7 -7
@@ -6,7 +6,7 @@
6
6
  "@apply flex h-full flex-col items-center overflow-y-scroll scroll-smooth bg-inherit px-4 pt-8": {}
7
7
  },
8
8
  ".aui-thread-viewport-footer": {
9
- "@apply max-w-[var(--aui-thread-max-width)] sticky bottom-0 mt-3 flex w-full flex-col items-center justify-end rounded-t-lg bg-inherit pb-4": {}
9
+ "@apply sticky bottom-0 mt-3 flex w-full max-w-[var(--aui-thread-max-width)] flex-col items-center justify-end rounded-t-lg bg-inherit pb-4": {}
10
10
  },
11
11
  ".aui-thread-scroll-to-bottom": {
12
12
  "@apply absolute -top-8 rounded-full disabled:invisible": {}
@@ -18,7 +18,7 @@
18
18
  "@apply bg-aui-background hover:bg-aui-muted/80 rounded-full border px-3 py-1 text-sm transition-colors ease-in": {}
19
19
  },
20
20
  ".aui-thread-welcome-root": {
21
- "@apply max-w-[var(--aui-thread-max-width)] flex w-full flex-grow flex-col": {}
21
+ "@apply flex w-full max-w-[var(--aui-thread-max-width)] flex-grow flex-col": {}
22
22
  },
23
23
  ".aui-thread-welcome-center": {
24
24
  "@apply flex w-full flex-grow flex-col items-center justify-center": {}
@@ -78,8 +78,8 @@
78
78
  "@apply text-aui-muted-foreground [&>svg]:bg-aui-background absolute -right-3 -top-3 size-6 [&>svg]:size-4 [&>svg]:rounded-full": {}
79
79
  },
80
80
  ".aui-user-message-root": {
81
- "@apply grid auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 [&>*]:col-start-2": {},
82
- "@apply max-w-[var(--aui-thread-max-width)] w-full py-4": {}
81
+ "@apply grid auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 [&:where(>*)]:col-start-2": {},
82
+ "@apply w-full max-w-[var(--aui-thread-max-width)] py-4": {}
83
83
  },
84
84
  ":where(.aui-user-message-root) > .aui-branch-picker-root": {
85
85
  "@apply col-span-full col-start-1 row-start-3": {},
@@ -103,7 +103,7 @@
103
103
  "@apply col-start-1 row-start-2 mr-3 mt-2.5": {}
104
104
  },
105
105
  ".aui-edit-composer-root": {
106
- "@apply bg-aui-muted max-w-[var(--aui-thread-max-width)] my-4 flex w-full flex-col gap-2 rounded-xl": {}
106
+ "@apply bg-aui-muted my-4 flex w-full max-w-[var(--aui-thread-max-width)] flex-col gap-2 rounded-xl": {}
107
107
  },
108
108
  ".aui-edit-composer-input": {
109
109
  "@apply text-aui-foreground flex h-8 w-full resize-none bg-transparent p-4 pb-0 outline-none": {}
@@ -113,7 +113,7 @@
113
113
  },
114
114
  ".aui-assistant-message-root": {
115
115
  "@apply grid grid-cols-[auto_auto_1fr] grid-rows-[auto_1fr]": {},
116
- "@apply max-w-[var(--aui-thread-max-width)] relative w-full py-4": {}
116
+ "@apply relative w-full max-w-[var(--aui-thread-max-width)] py-4": {}
117
117
  },
118
118
  ":where(.aui-assistant-message-root) > .aui-avatar-root": {
119
119
  "@apply col-start-1 row-span-full row-start-1 mr-4": {}
package/package.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "conversational-ui",
30
30
  "conversational-ai"
31
31
  ],
32
- "version": "0.7.75",
32
+ "version": "0.7.77",
33
33
  "license": "MIT",
34
34
  "exports": {
35
35
  ".": {
@@ -113,9 +113,9 @@
113
113
  "tailwindcss": "^3.4.17",
114
114
  "tailwindcss-animate": "^1.0.7",
115
115
  "tsx": "^4.19.2",
116
- "@assistant-ui/tsconfig": "0.0.0",
117
116
  "@assistant-ui/tailwindcss-transformer": "0.1.0",
118
- "@assistant-ui/tsbuildutils": "^0.0.1"
117
+ "@assistant-ui/tsbuildutils": "^0.0.1",
118
+ "@assistant-ui/tsconfig": "0.0.0"
119
119
  },
120
120
  "publishConfig": {
121
121
  "access": "public",
@@ -21,7 +21,7 @@ export type AssistantRuntime = {
21
21
  readonly thread: ThreadRuntime;
22
22
 
23
23
  /**
24
- * @deprecated This field was renamed to `threads.main`.
24
+ * @deprecated This field was renamed to `threads`.
25
25
  */
26
26
  readonly threadList: ThreadListRuntime;
27
27
 
@@ -69,7 +69,7 @@ export class AssistantRuntimeImpl implements AssistantRuntime {
69
69
  ) => ThreadRuntime = ThreadRuntimeImpl,
70
70
  ) {
71
71
  this.threads = new ThreadListRuntimeImpl(_core.threads, runtimeFactory);
72
- this._thread = this.threadList.main;
72
+ this._thread = this.threads.main;
73
73
  }
74
74
 
75
75
  protected __internal_bindMethods() {
@@ -66,7 +66,7 @@ export const AssistantRuntimeProviderImpl: FC<
66
66
  {RenderComponent && <RenderComponent />}
67
67
  <ThreadRuntimeProvider
68
68
  runtime={runtime.thread}
69
- listItemRuntime={runtime.threadList.mainItem}
69
+ listItemRuntime={runtime.threads.mainItem}
70
70
  >
71
71
  {children}
72
72
  </ThreadRuntimeProvider>
@@ -28,8 +28,8 @@ const ThreadListItemImpl: FC<ThreadListItemProps> = ({
28
28
  const runtime = useMemo(
29
29
  () =>
30
30
  archived
31
- ? assistantRuntime.threadList.getArchivedItemByIndex(partIndex)
32
- : assistantRuntime.threadList.getItemByIndex(partIndex),
31
+ ? assistantRuntime.threads.getArchivedItemByIndex(partIndex)
32
+ : assistantRuntime.threads.getItemByIndex(partIndex),
33
33
  [assistantRuntime, partIndex, archived],
34
34
  );
35
35
 
@@ -58,8 +58,11 @@ const assistantMessageSplitter = () => {
58
58
  type: "tool-result",
59
59
  toolCallId: part.toolCallId,
60
60
  toolName: part.toolName,
61
- result: part.result ?? "<no result>",
62
- isError: part.isError ?? false,
61
+ result:
62
+ part.result === undefined
63
+ ? "Error: tool is has no configured code to run"
64
+ : undefined,
65
+ isError: part.isError ?? part.result === undefined,
63
66
  });
64
67
  },
65
68
  getMessages: () => {
@@ -107,7 +107,7 @@ export function toolResultStream(
107
107
  toolCallType,
108
108
  toolCallId,
109
109
  toolName,
110
- result,
110
+ result: result === undefined ? "<no result>" : result,
111
111
  });
112
112
  } catch (error) {
113
113
  controller.enqueue({
@@ -17,10 +17,9 @@ export type LocalRuntimeOptionsBase = {
17
17
  };
18
18
 
19
19
  /**
20
- * @deprecated This is a temporary workaround for subgraph frontend function calls.
21
- * This feature will be removed in a future version without notice. DO NOT USE.
20
+ * Names of tools that are allowed to interrupt the run in order to wait for human/external approval.
22
21
  */
23
- unstable_shouldContinueIgnoreToolNames?: string[] | undefined;
22
+ unstable_humanToolNames?: string[] | undefined;
24
23
  };
25
24
 
26
25
  // TODO align LocalRuntimeOptions with LocalRuntimeOptionsBase
@@ -38,7 +37,7 @@ export const splitLocalRuntimeOptions = <T extends LocalRuntimeOptions>(
38
37
  initialMessages,
39
38
  maxSteps,
40
39
  adapters,
41
- unstable_shouldContinueIgnoreToolNames,
40
+ unstable_humanToolNames,
42
41
  ...rest
43
42
  } = options;
44
43
 
@@ -48,7 +47,7 @@ export const splitLocalRuntimeOptions = <T extends LocalRuntimeOptions>(
48
47
  initialMessages,
49
48
  maxSteps,
50
49
  adapters,
51
- unstable_shouldContinueIgnoreToolNames,
50
+ unstable_humanToolNames,
52
51
  },
53
52
  otherOptions: rest,
54
53
  };
@@ -151,12 +151,7 @@ export class LocalThreadRuntimeCore
151
151
  try {
152
152
  do {
153
153
  message = await this.performRoundtrip(parentId, message, runConfig);
154
- } while (
155
- shouldContinue(
156
- message,
157
- this._options.unstable_shouldContinueIgnoreToolNames ?? [],
158
- )
159
- );
154
+ } while (shouldContinue(message, this._options.unstable_humanToolNames));
160
155
  } finally {
161
156
  this._notifyEventSubscribers("run-end");
162
157
  }
@@ -347,10 +342,7 @@ export class LocalThreadRuntimeCore
347
342
 
348
343
  if (
349
344
  added &&
350
- shouldContinue(
351
- message,
352
- this._options.unstable_shouldContinueIgnoreToolNames ?? [],
353
- )
345
+ shouldContinue(message, this._options.unstable_humanToolNames)
354
346
  ) {
355
347
  this.performRoundtrip(parentId, message, this._lastRunConfig);
356
348
  }
@@ -2,13 +2,25 @@ import type { ThreadAssistantMessage } from "../../types";
2
2
 
3
3
  export const shouldContinue = (
4
4
  result: ThreadAssistantMessage,
5
- ignoreToolNames: string[],
6
- ) =>
7
- result.status?.type === "requires-action" &&
8
- result.status.reason === "tool-calls" &&
9
- result.content.every(
10
- (c) =>
11
- c.type !== "tool-call" ||
12
- !!c.result ||
13
- ignoreToolNames.includes(c.toolName),
5
+ humanToolNames: string[] | undefined,
6
+ ) => {
7
+ // TODO legacy behavior -- make specifying human tool names required
8
+ if (humanToolNames === undefined) {
9
+ return (
10
+ result.status?.type === "requires-action" &&
11
+ result.status.reason === "tool-calls" &&
12
+ result.content.every((c) => c.type !== "tool-call" || !!c.result)
13
+ );
14
+ }
15
+
16
+ return (
17
+ result.status?.type === "requires-action" &&
18
+ result.status.reason === "tool-calls" &&
19
+ result.content.every(
20
+ (c) =>
21
+ c.type !== "tool-call" ||
22
+ !!c.result ||
23
+ !humanToolNames.includes(c.toolName),
24
+ )
14
25
  );
26
+ };
@@ -8,7 +8,7 @@
8
8
  }
9
9
 
10
10
  .aui-thread-viewport-footer {
11
- @apply max-w-[var(--aui-thread-max-width)] sticky bottom-0 mt-3 flex w-full flex-col items-center justify-end rounded-t-lg bg-inherit pb-4;
11
+ @apply sticky bottom-0 mt-3 flex w-full max-w-[var(--aui-thread-max-width)] flex-col items-center justify-end rounded-t-lg bg-inherit pb-4;
12
12
  }
13
13
 
14
14
  .aui-thread-scroll-to-bottom {
@@ -26,7 +26,7 @@
26
26
  /* thread welcome */
27
27
 
28
28
  .aui-thread-welcome-root {
29
- @apply max-w-[var(--aui-thread-max-width)] flex w-full flex-grow flex-col;
29
+ @apply flex w-full max-w-[var(--aui-thread-max-width)] flex-grow flex-col;
30
30
  }
31
31
 
32
32
  .aui-thread-welcome-center {
@@ -110,8 +110,8 @@
110
110
  /* user message */
111
111
 
112
112
  .aui-user-message-root {
113
- @apply grid auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 [&>*]:col-start-2;
114
- @apply max-w-[var(--aui-thread-max-width)] w-full py-4;
113
+ @apply grid auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 [&:where(>*)]:col-start-2;
114
+ @apply w-full max-w-[var(--aui-thread-max-width)] py-4;
115
115
  }
116
116
 
117
117
  :where(.aui-user-message-root) > .aui-branch-picker-root {
@@ -126,7 +126,7 @@
126
126
 
127
127
  .aui-user-message-content {
128
128
  @apply bg-aui-muted text-aui-foreground max-w-[calc(var(--aui-thread-max-width)*0.8)] break-words rounded-3xl px-5 py-2.5;
129
-
129
+
130
130
  @apply col-start-2 row-start-2;
131
131
  }
132
132
 
@@ -148,7 +148,7 @@
148
148
  /* edit composer */
149
149
 
150
150
  .aui-edit-composer-root {
151
- @apply bg-aui-muted max-w-[var(--aui-thread-max-width)] my-4 flex w-full flex-col gap-2 rounded-xl;
151
+ @apply bg-aui-muted my-4 flex w-full max-w-[var(--aui-thread-max-width)] flex-col gap-2 rounded-xl;
152
152
  }
153
153
 
154
154
  .aui-edit-composer-input {
@@ -163,7 +163,7 @@
163
163
 
164
164
  .aui-assistant-message-root {
165
165
  @apply grid grid-cols-[auto_auto_1fr] grid-rows-[auto_1fr];
166
- @apply max-w-[var(--aui-thread-max-width)] relative w-full py-4;
166
+ @apply relative w-full max-w-[var(--aui-thread-max-width)] py-4;
167
167
  }
168
168
 
169
169
  :where(.aui-assistant-message-root) > .aui-avatar-root {