@assistant-ui/react 0.12.15 → 0.12.17
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.d.ts +1 -4
- package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.js +2 -527
- package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/legacy-runtime/hooks/AttachmentContext.d.ts +96 -96
- package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.d.ts +1 -16
- package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.js +1 -14
- package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.d.ts +1 -13
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.js +2 -82
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.d.ts +1 -23
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.js +1 -410
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.d.ts +1 -16
- package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.js +1 -48
- package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.d.ts +1 -33
- package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.js +1 -307
- package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.d.ts +1 -3
- package/dist/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.js +1 -17
- package/dist/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.d.ts +2 -26
- package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.js +1 -13
- package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts +1 -3
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.js +1 -51
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +1 -96
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js +1 -110
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +1 -112
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +1 -439
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts +1 -12
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.js +1 -102
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts +1 -3
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js +1 -46
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js +7 -20
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js +3 -8
- package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +4 -7
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +5 -7
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.js +3 -10
- package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +5 -4
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerCancel.js +3 -8
- package/dist/primitives/composer/ComposerCancel.js.map +1 -1
- package/dist/primitives/composer/ComposerSend.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerSend.js +3 -8
- package/dist/primitives/composer/ComposerSend.js.map +1 -1
- package/dist/utils/createActionButton.js +1 -1
- package/dist/utils/createActionButton.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -1
- package/src/internal.ts +1 -1
- package/src/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.ts +2 -784
- package/src/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.tsx +5 -43
- package/src/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.ts +2 -100
- package/src/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.ts +4 -580
- package/src/legacy-runtime/runtime-cores/external-store/createMessageConverter.ts +1 -76
- package/src/legacy-runtime/runtime-cores/external-store/external-message-converter.ts +4 -483
- package/src/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.ts +1 -27
- package/src/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.ts +2 -35
- package/src/legacy-runtime/runtime-cores/local/useLocalRuntime.ts +1 -67
- package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +1 -178
- package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +1 -529
- package/src/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.tsx +1 -152
- package/src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.ts +1 -80
- package/src/primitives/actionBar/ActionBarCopy.tsx +7 -26
- package/src/primitives/actionBar/ActionBarEdit.ts +3 -10
- package/src/primitives/actionBar/ActionBarFeedbackNegative.tsx +4 -9
- package/src/primitives/actionBar/ActionBarFeedbackPositive.tsx +5 -9
- package/src/primitives/actionBar/ActionBarReload.ts +3 -16
- package/src/primitives/composer/ComposerAddAttachment.ts +5 -4
- package/src/primitives/composer/ComposerCancel.ts +3 -10
- package/src/primitives/composer/ComposerSend.ts +3 -13
- package/src/tests/BaseComposerRuntimeCore.test.ts +2 -3
- package/src/utils/createActionButton.tsx +1 -1
|
@@ -1,45 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "@assistant-ui/core";
|
|
8
|
-
import { ModelContextProvider } from "../../../model-context";
|
|
9
|
-
|
|
10
|
-
export type RuntimeAdapters = {
|
|
11
|
-
modelContext?: ModelContextProvider;
|
|
12
|
-
history?: ThreadHistoryAdapter;
|
|
13
|
-
attachments?: AttachmentAdapter;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const RuntimeAdaptersContext = createContext<RuntimeAdapters | null>(null);
|
|
17
|
-
|
|
18
|
-
export namespace RuntimeAdapterProvider {
|
|
19
|
-
export type Props = {
|
|
20
|
-
adapters: RuntimeAdapters;
|
|
21
|
-
children: ReactNode;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const RuntimeAdapterProvider: FC<RuntimeAdapterProvider.Props> = ({
|
|
26
|
-
adapters,
|
|
27
|
-
children,
|
|
28
|
-
}) => {
|
|
29
|
-
const context = useContext(RuntimeAdaptersContext);
|
|
30
|
-
return (
|
|
31
|
-
<RuntimeAdaptersContext.Provider
|
|
32
|
-
value={{
|
|
33
|
-
...context,
|
|
34
|
-
...adapters,
|
|
35
|
-
}}
|
|
36
|
-
>
|
|
37
|
-
{children}
|
|
38
|
-
</RuntimeAdaptersContext.Provider>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const useRuntimeAdapters = () => {
|
|
43
|
-
const adapters = useContext(RuntimeAdaptersContext);
|
|
44
|
-
return adapters;
|
|
45
|
-
};
|
|
3
|
+
export {
|
|
4
|
+
RuntimeAdapterProvider,
|
|
5
|
+
useRuntimeAdapters,
|
|
6
|
+
type RuntimeAdapters,
|
|
7
|
+
} from "@assistant-ui/core/react";
|
|
@@ -1,101 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
Attachment,
|
|
4
|
-
PendingAttachment,
|
|
5
|
-
CompleteAttachment,
|
|
6
|
-
ThreadUserMessagePart,
|
|
7
|
-
AttachmentAdapter,
|
|
8
|
-
} from "@assistant-ui/core";
|
|
1
|
+
"use client";
|
|
9
2
|
|
|
10
|
-
|
|
11
|
-
contentType: string,
|
|
12
|
-
): "image" | "document" | "file" => {
|
|
13
|
-
if (contentType.startsWith("image/")) return "image";
|
|
14
|
-
if (contentType.startsWith("text/")) return "document";
|
|
15
|
-
return "file";
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export class CloudFileAttachmentAdapter implements AttachmentAdapter {
|
|
19
|
-
public accept = "*";
|
|
20
|
-
|
|
21
|
-
constructor(private cloud: AssistantCloud) {}
|
|
22
|
-
|
|
23
|
-
private uploadedUrls = new Map<string, string>();
|
|
24
|
-
|
|
25
|
-
public async *add({
|
|
26
|
-
file,
|
|
27
|
-
}: {
|
|
28
|
-
file: File;
|
|
29
|
-
}): AsyncGenerator<PendingAttachment, void> {
|
|
30
|
-
const id = crypto.randomUUID();
|
|
31
|
-
const type = guessAttachmentType(file.type);
|
|
32
|
-
let attachment: PendingAttachment = {
|
|
33
|
-
id,
|
|
34
|
-
type,
|
|
35
|
-
name: file.name,
|
|
36
|
-
contentType: file.type,
|
|
37
|
-
file,
|
|
38
|
-
status: { type: "running", reason: "uploading", progress: 0 },
|
|
39
|
-
};
|
|
40
|
-
yield attachment;
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
const { signedUrl, publicUrl } =
|
|
44
|
-
await this.cloud.files.generatePresignedUploadUrl({
|
|
45
|
-
filename: file.name,
|
|
46
|
-
});
|
|
47
|
-
await fetch(signedUrl, {
|
|
48
|
-
method: "PUT",
|
|
49
|
-
body: file,
|
|
50
|
-
headers: {
|
|
51
|
-
"Content-Type": file.type,
|
|
52
|
-
},
|
|
53
|
-
mode: "cors",
|
|
54
|
-
});
|
|
55
|
-
this.uploadedUrls.set(id, publicUrl);
|
|
56
|
-
attachment = {
|
|
57
|
-
...attachment,
|
|
58
|
-
status: { type: "requires-action", reason: "composer-send" },
|
|
59
|
-
};
|
|
60
|
-
yield attachment;
|
|
61
|
-
} catch {
|
|
62
|
-
attachment = {
|
|
63
|
-
...attachment,
|
|
64
|
-
status: { type: "incomplete", reason: "error" },
|
|
65
|
-
};
|
|
66
|
-
yield attachment;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
public async remove(attachment: Attachment): Promise<void> {
|
|
71
|
-
this.uploadedUrls.delete(attachment.id);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public async send(
|
|
75
|
-
attachment: PendingAttachment,
|
|
76
|
-
): Promise<CompleteAttachment> {
|
|
77
|
-
const url = this.uploadedUrls.get(attachment.id);
|
|
78
|
-
if (!url) throw new Error("Attachment not uploaded");
|
|
79
|
-
this.uploadedUrls.delete(attachment.id);
|
|
80
|
-
|
|
81
|
-
let content: ThreadUserMessagePart[];
|
|
82
|
-
if (attachment.type === "image") {
|
|
83
|
-
content = [{ type: "image", image: url, filename: attachment.name }];
|
|
84
|
-
} else {
|
|
85
|
-
content = [
|
|
86
|
-
{
|
|
87
|
-
type: "file",
|
|
88
|
-
data: url,
|
|
89
|
-
mimeType: attachment.contentType ?? "",
|
|
90
|
-
filename: attachment.name,
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
...attachment,
|
|
97
|
-
status: { type: "complete" },
|
|
98
|
-
content,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
3
|
+
export { CloudFileAttachmentAdapter } from "@assistant-ui/core/react";
|