@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.
- package/dist/cloud/auiV0.d.ts +2 -2
- package/dist/cloud/auiV0.d.ts.map +1 -1
- package/dist/cloud/auiV0.js.map +1 -1
- package/dist/cloud/auiV0.mjs.map +1 -1
- package/dist/primitives/threadList/ThreadListRoot.d.ts +12 -0
- package/dist/primitives/threadList/ThreadListRoot.d.ts.map +1 -0
- package/dist/primitives/threadList/ThreadListRoot.js +37 -0
- package/dist/primitives/threadList/ThreadListRoot.js.map +1 -0
- package/dist/primitives/threadList/ThreadListRoot.mjs +12 -0
- package/dist/primitives/threadList/ThreadListRoot.mjs.map +1 -0
- package/dist/primitives/threadList/index.d.ts +1 -0
- package/dist/primitives/threadList/index.d.ts.map +1 -1
- package/dist/primitives/threadList/index.js +5 -2
- package/dist/primitives/threadList/index.js.map +1 -1
- package/dist/primitives/threadList/index.mjs +3 -1
- package/dist/primitives/threadList/index.mjs.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts +11 -10
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.js +8 -6
- package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.mjs +8 -6
- package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/thread.css +1 -1
- package/dist/styles/tailwindcss/thread.css.json +1 -1
- package/dist/ui/thread-list.d.ts +3 -1
- package/dist/ui/thread-list.d.ts.map +1 -1
- package/dist/ui/thread-list.js +1 -1
- package/dist/ui/thread-list.js.map +1 -1
- package/dist/ui/thread-list.mjs +1 -1
- package/dist/ui/thread-list.mjs.map +1 -1
- package/dist/ui/thread-welcome.js +1 -1
- package/dist/ui/thread-welcome.js.map +1 -1
- package/dist/ui/thread-welcome.mjs +1 -1
- package/dist/ui/thread-welcome.mjs.map +1 -1
- package/dist/utils/smooth/useSmooth.d.ts.map +1 -1
- package/dist/utils/smooth/useSmooth.js +5 -7
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/smooth/useSmooth.mjs +5 -7
- package/dist/utils/smooth/useSmooth.mjs.map +1 -1
- package/package.json +1 -1
- package/src/cloud/auiV0.ts +5 -2
- package/src/primitives/threadList/ThreadListRoot.tsx +18 -0
- package/src/primitives/threadList/index.ts +1 -0
- package/src/runtimes/external-store/ThreadMessageLike.tsx +19 -20
- package/src/styles/tailwindcss/thread.css +1 -1
- package/src/ui/thread-list.tsx +1 -1
- package/src/ui/thread-welcome.tsx +1 -1
- package/src/utils/smooth/useSmooth.tsx +11 -7
package/package.json
CHANGED
package/src/cloud/auiV0.ts
CHANGED
@@ -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 {
|
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:
|
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,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
|
-
|
19
|
-
|
20
|
-
} from "../../
|
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
|
38
|
-
toolName: string;
|
39
|
-
|
40
|
-
|
41
|
-
|
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 (
|
104
|
-
if ("args" in part) {
|
105
|
-
return part;
|
106
|
-
}
|
107
|
-
|
102
|
+
if (part.args) {
|
108
103
|
return {
|
109
104
|
...part,
|
110
|
-
|
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
|
-
|
112
|
+
toolCallId: part.toolCallId ?? "tool-" + generateId(),
|
113
|
+
args: part.args ?? parsePartialJson(part.argsText ?? ""),
|
114
|
+
argsText: part.argsText ?? "",
|
116
115
|
};
|
117
116
|
}
|
118
117
|
|
package/src/ui/thread-list.tsx
CHANGED
@@ -18,7 +18,7 @@ const ThreadList: FC = () => {
|
|
18
18
|
);
|
19
19
|
};
|
20
20
|
|
21
|
-
const ThreadListRoot = withDefaults(
|
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-
|
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
|
-
|
87
|
-
|
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
|
-
|
96
|
-
|
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
|
103
|
+
}, [smoothStatusStore, text, displayedText, state.status]);
|
100
104
|
|
101
105
|
const [animatorRef] = useState<TextStreamAnimator>(
|
102
106
|
new TextStreamAnimator(text, setText),
|