@assistant-ui/react 0.7.60 → 0.7.62

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 (50) hide show
  1. package/dist/cloud/auiV0.d.ts +2 -2
  2. package/dist/cloud/auiV0.d.ts.map +1 -1
  3. package/dist/cloud/auiV0.js.map +1 -1
  4. package/dist/cloud/auiV0.mjs.map +1 -1
  5. package/dist/primitives/threadList/ThreadListRoot.d.ts +12 -0
  6. package/dist/primitives/threadList/ThreadListRoot.d.ts.map +1 -0
  7. package/dist/primitives/threadList/ThreadListRoot.js +37 -0
  8. package/dist/primitives/threadList/ThreadListRoot.js.map +1 -0
  9. package/dist/primitives/threadList/ThreadListRoot.mjs +12 -0
  10. package/dist/primitives/threadList/ThreadListRoot.mjs.map +1 -0
  11. package/dist/primitives/threadList/index.d.ts +1 -0
  12. package/dist/primitives/threadList/index.d.ts.map +1 -1
  13. package/dist/primitives/threadList/index.js +5 -2
  14. package/dist/primitives/threadList/index.js.map +1 -1
  15. package/dist/primitives/threadList/index.mjs +3 -1
  16. package/dist/primitives/threadList/index.mjs.map +1 -1
  17. package/dist/runtimes/external-store/ThreadMessageLike.d.ts +11 -10
  18. package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
  19. package/dist/runtimes/external-store/ThreadMessageLike.js +8 -6
  20. package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
  21. package/dist/runtimes/external-store/ThreadMessageLike.mjs +8 -6
  22. package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
  23. package/dist/styles/index.css +1 -1
  24. package/dist/styles/index.css.map +1 -1
  25. package/dist/styles/tailwindcss/thread.css +1 -1
  26. package/dist/styles/tailwindcss/thread.css.json +1 -1
  27. package/dist/ui/thread-list.d.ts +3 -1
  28. package/dist/ui/thread-list.d.ts.map +1 -1
  29. package/dist/ui/thread-list.js +1 -1
  30. package/dist/ui/thread-list.js.map +1 -1
  31. package/dist/ui/thread-list.mjs +1 -1
  32. package/dist/ui/thread-list.mjs.map +1 -1
  33. package/dist/ui/thread-welcome.js +1 -1
  34. package/dist/ui/thread-welcome.js.map +1 -1
  35. package/dist/ui/thread-welcome.mjs +1 -1
  36. package/dist/ui/thread-welcome.mjs.map +1 -1
  37. package/dist/utils/smooth/useSmooth.d.ts.map +1 -1
  38. package/dist/utils/smooth/useSmooth.js +5 -7
  39. package/dist/utils/smooth/useSmooth.js.map +1 -1
  40. package/dist/utils/smooth/useSmooth.mjs +5 -7
  41. package/dist/utils/smooth/useSmooth.mjs.map +1 -1
  42. package/package.json +1 -1
  43. package/src/cloud/auiV0.ts +5 -2
  44. package/src/primitives/threadList/ThreadListRoot.tsx +18 -0
  45. package/src/primitives/threadList/index.ts +1 -0
  46. package/src/runtimes/external-store/ThreadMessageLike.tsx +19 -20
  47. package/src/styles/tailwindcss/thread.css +1 -1
  48. package/src/ui/thread-list.tsx +1 -1
  49. package/src/ui/thread-welcome.tsx +1 -1
  50. package/src/utils/smooth/useSmooth.tsx +11 -7
package/package.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "conversational-ui",
30
30
  "conversational-ai"
31
31
  ],
32
- "version": "0.7.60",
32
+ "version": "0.7.62",
33
33
  "license": "MIT",
34
34
  "exports": {
35
35
  ".": {
@@ -4,7 +4,10 @@ import { MessageStatus } from "../types/AssistantTypes";
4
4
  import { fromThreadMessageLike } from "../runtimes/external-store/ThreadMessageLike";
5
5
  import { CloudMessage } from "./AssistantCloudThreadMessages";
6
6
  import { isJSONValue } from "../utils/json/is-json";
7
- import { ReadonlyJSONValue } from "../utils/json/json-value";
7
+ import {
8
+ ReadonlyJSONObject,
9
+ ReadonlyJSONValue,
10
+ } from "../utils/json/json-value";
8
11
  import { ExportedMessageRepositoryItem } from "../runtimes/utils/MessageRepository";
9
12
 
10
13
  type AuiV0MessageContentPart =
@@ -16,7 +19,7 @@ type AuiV0MessageContentPart =
16
19
  readonly type: "tool-call";
17
20
  readonly toolCallId: string;
18
21
  readonly toolName: string;
19
- readonly args: ReadonlyJSONValue;
22
+ readonly args: ReadonlyJSONObject;
20
23
  readonly result?: ReadonlyJSONValue;
21
24
  readonly isError?: true;
22
25
  }
@@ -0,0 +1,18 @@
1
+ import { Primitive } from "@radix-ui/react-primitive";
2
+ import { ComponentPropsWithoutRef, ComponentRef, forwardRef } from "react";
3
+
4
+ type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;
5
+
6
+ export namespace ThreadListPrimitiveRoot {
7
+ export type Element = ComponentRef<typeof Primitive.div>;
8
+ export type Props = PrimitiveDivProps;
9
+ }
10
+
11
+ export const ThreadListPrimitiveRoot = forwardRef<
12
+ ThreadListPrimitiveRoot.Element,
13
+ ThreadListPrimitiveRoot.Props
14
+ >((props, ref) => {
15
+ return <Primitive.div {...props} ref={ref} />;
16
+ });
17
+
18
+ ThreadListPrimitiveRoot.displayName = "ThreadListPrimitive.Root";
@@ -1,2 +1,3 @@
1
1
  export { ThreadListPrimitiveNew as New } from "./ThreadListNew";
2
2
  export { ThreadListPrimitiveItems as Items } from "./ThreadListItems";
3
+ export { ThreadListPrimitiveRoot as Root } from "./ThreadListRoot";
@@ -1,8 +1,8 @@
1
+ import { generateId } from "../../internal";
1
2
  import {
2
3
  MessageStatus,
3
4
  TextContentPart,
4
5
  ImageContentPart,
5
- ToolCallContentPart,
6
6
  UIContentPart,
7
7
  ThreadMessage,
8
8
  ThreadAssistantContentPart,
@@ -14,11 +14,11 @@ import {
14
14
  FileContentPart,
15
15
  Unstable_AudioContentPart,
16
16
  } from "../../types";
17
+ import { ThreadStep } from "../../types/AssistantTypes";
17
18
  import {
18
- CoreToolCallContentPart,
19
- ThreadStep,
20
- } from "../../types/AssistantTypes";
21
- import { ReadonlyJSONValue } from "../../utils/json/json-value";
19
+ ReadonlyJSONObject,
20
+ ReadonlyJSONValue,
21
+ } from "../../utils/json/json-value";
22
22
  import { parsePartialJson } from "../../utils/json/parse-partial-json";
23
23
 
24
24
  export type ThreadMessageLike = {
@@ -30,15 +30,14 @@ export type ThreadMessageLike = {
30
30
  | ImageContentPart
31
31
  | FileContentPart
32
32
  | Unstable_AudioContentPart
33
- | ToolCallContentPart<any, any>
34
- | CoreToolCallContentPart<any, any>
35
33
  | {
36
- type: "tool-call";
37
- toolCallId: string;
38
- toolName: string;
39
- argsText: string;
40
- result?: unknown | undefined;
41
- isError?: boolean | undefined;
34
+ readonly type: "tool-call";
35
+ readonly toolCallId?: string;
36
+ readonly toolName: string;
37
+ readonly args?: ReadonlyJSONObject;
38
+ readonly argsText?: string;
39
+ readonly result?: any | undefined;
40
+ readonly isError?: boolean | undefined;
42
41
  }
43
42
  | UIContentPart
44
43
  )[];
@@ -100,19 +99,19 @@ export const fromThreadMessageLike = (
100
99
  return part;
101
100
 
102
101
  case "tool-call": {
103
- if ("argsText" in part) {
104
- if ("args" in part) {
105
- return part;
106
- }
107
-
102
+ if (part.args) {
108
103
  return {
109
104
  ...part,
110
- args: parsePartialJson(part.argsText),
105
+ toolCallId: part.toolCallId ?? "tool-" + generateId(),
106
+ args: part.args,
107
+ argsText: JSON.stringify(part.args),
111
108
  };
112
109
  }
113
110
  return {
114
111
  ...part,
115
- argsText: JSON.stringify(part.args),
112
+ toolCallId: part.toolCallId ?? "tool-" + generateId(),
113
+ args: part.args ?? parsePartialJson(part.argsText ?? ""),
114
+ argsText: part.argsText ?? "",
116
115
  };
117
116
  }
118
117
 
@@ -38,7 +38,7 @@
38
38
  @apply mt-4 font-medium;
39
39
  }
40
40
 
41
- .aui-thread-welcome-suggestion-container {
41
+ .aui-thread-welcome-suggestions {
42
42
  @apply mt-3 flex w-full items-stretch justify-center gap-4;
43
43
  }
44
44
 
@@ -18,7 +18,7 @@ const ThreadList: FC = () => {
18
18
  );
19
19
  };
20
20
 
21
- const ThreadListRoot = withDefaults("div", {
21
+ const ThreadListRoot = withDefaults(ThreadListPrimitive.Root, {
22
22
  className: "aui-root aui-thread-list-root",
23
23
  });
24
24
  ThreadListRoot.displayName = "ThreadListRoot";
@@ -84,7 +84,7 @@ const ThreadWelcomeMessage = forwardRef<
84
84
  ThreadWelcomeMessage.displayName = "ThreadWelcomeMessage";
85
85
 
86
86
  const ThreadWelcomeSuggestionContainer = withDefaults("div", {
87
- className: "aui-thread-welcome-suggestion-container",
87
+ className: "aui-thread-welcome-suggestions",
88
88
  });
89
89
 
90
90
  const ThreadWelcomeSuggestionStyled = withDefaults(ThreadPrimitive.Suggestion, {
@@ -83,20 +83,24 @@ export const useSmooth = (
83
83
  const setText = useCallbackRef((text: string) => {
84
84
  setDisplayedText(text);
85
85
  if (smoothStatusStore) {
86
- writableStore(smoothStatusStore).setState(
87
- text !== state.text ? SMOOTH_STATUS : state.status,
88
- );
86
+ const target =
87
+ displayedText !== text || state.status.type === "running"
88
+ ? SMOOTH_STATUS
89
+ : state.status;
90
+ writableStore(smoothStatusStore).setState(target, true);
89
91
  }
90
92
  });
91
93
 
92
94
  // TODO this is hacky
93
95
  useEffect(() => {
94
96
  if (smoothStatusStore) {
95
- writableStore(smoothStatusStore).setState(
96
- text !== state.text ? SMOOTH_STATUS : state.status,
97
- );
97
+ const target =
98
+ displayedText !== text || state.status.type === "running"
99
+ ? SMOOTH_STATUS
100
+ : state.status;
101
+ writableStore(smoothStatusStore).setState(target, true);
98
102
  }
99
- }, [smoothStatusStore, text, displayedText, state.status, state.text]);
103
+ }, [smoothStatusStore, text, displayedText, state.status]);
100
104
 
101
105
  const [animatorRef] = useState<TextStreamAnimator>(
102
106
  new TextStreamAnimator(text, setText),