@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.
Files changed (113) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/internal.d.ts +1 -1
  6. package/dist/internal.d.ts.map +1 -1
  7. package/dist/internal.js +1 -1
  8. package/dist/internal.js.map +1 -1
  9. package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.d.ts +1 -4
  10. package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
  11. package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.js +2 -527
  12. package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  13. package/dist/legacy-runtime/hooks/AttachmentContext.d.ts +96 -96
  14. package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.d.ts +1 -16
  15. package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.d.ts.map +1 -1
  16. package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.js +1 -14
  17. package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.js.map +1 -1
  18. package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.d.ts +1 -13
  19. package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.d.ts.map +1 -1
  20. package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.js +2 -82
  21. package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.js.map +1 -1
  22. package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.d.ts +1 -23
  23. package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.d.ts.map +1 -1
  24. package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.js +1 -410
  25. package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.js.map +1 -1
  26. package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.d.ts +1 -16
  27. package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.d.ts.map +1 -1
  28. package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.js +1 -48
  29. package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.js.map +1 -1
  30. package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.d.ts +1 -33
  31. package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.d.ts.map +1 -1
  32. package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.js +1 -307
  33. package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.js.map +1 -1
  34. package/dist/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.d.ts +1 -3
  35. package/dist/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.d.ts.map +1 -1
  36. package/dist/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.js +1 -17
  37. package/dist/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.js.map +1 -1
  38. package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.d.ts +2 -26
  39. package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.d.ts.map +1 -1
  40. package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.js +1 -13
  41. package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.js.map +1 -1
  42. package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts +1 -3
  43. package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts.map +1 -1
  44. package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.js +1 -51
  45. package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.js.map +1 -1
  46. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +1 -96
  47. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  48. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js +1 -110
  49. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
  50. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +1 -112
  51. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  52. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +1 -439
  53. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  54. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts +1 -12
  55. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts.map +1 -1
  56. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.js +1 -102
  57. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.js.map +1 -1
  58. package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts +1 -3
  59. package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +1 -1
  60. package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js +1 -46
  61. package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
  62. package/dist/primitives/actionBar/ActionBarCopy.d.ts.map +1 -1
  63. package/dist/primitives/actionBar/ActionBarCopy.js +7 -20
  64. package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
  65. package/dist/primitives/actionBar/ActionBarEdit.d.ts.map +1 -1
  66. package/dist/primitives/actionBar/ActionBarEdit.js +3 -8
  67. package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
  68. package/dist/primitives/actionBar/ActionBarFeedbackNegative.d.ts.map +1 -1
  69. package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +4 -7
  70. package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
  71. package/dist/primitives/actionBar/ActionBarFeedbackPositive.d.ts.map +1 -1
  72. package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +5 -7
  73. package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
  74. package/dist/primitives/actionBar/ActionBarReload.d.ts.map +1 -1
  75. package/dist/primitives/actionBar/ActionBarReload.js +3 -10
  76. package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
  77. package/dist/primitives/composer/ComposerAddAttachment.d.ts.map +1 -1
  78. package/dist/primitives/composer/ComposerAddAttachment.js +5 -4
  79. package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
  80. package/dist/primitives/composer/ComposerCancel.d.ts.map +1 -1
  81. package/dist/primitives/composer/ComposerCancel.js +3 -8
  82. package/dist/primitives/composer/ComposerCancel.js.map +1 -1
  83. package/dist/primitives/composer/ComposerSend.d.ts.map +1 -1
  84. package/dist/primitives/composer/ComposerSend.js +3 -8
  85. package/dist/primitives/composer/ComposerSend.js.map +1 -1
  86. package/dist/utils/createActionButton.js +1 -1
  87. package/dist/utils/createActionButton.js.map +1 -1
  88. package/package.json +3 -3
  89. package/src/index.ts +1 -1
  90. package/src/internal.ts +1 -1
  91. package/src/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.ts +2 -784
  92. package/src/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.tsx +5 -43
  93. package/src/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.ts +2 -100
  94. package/src/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.ts +4 -580
  95. package/src/legacy-runtime/runtime-cores/external-store/createMessageConverter.ts +1 -76
  96. package/src/legacy-runtime/runtime-cores/external-store/external-message-converter.ts +4 -483
  97. package/src/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.ts +1 -27
  98. package/src/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.ts +2 -35
  99. package/src/legacy-runtime/runtime-cores/local/useLocalRuntime.ts +1 -67
  100. package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +1 -178
  101. package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +1 -529
  102. package/src/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.tsx +1 -152
  103. package/src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.ts +1 -80
  104. package/src/primitives/actionBar/ActionBarCopy.tsx +7 -26
  105. package/src/primitives/actionBar/ActionBarEdit.ts +3 -10
  106. package/src/primitives/actionBar/ActionBarFeedbackNegative.tsx +4 -9
  107. package/src/primitives/actionBar/ActionBarFeedbackPositive.tsx +5 -9
  108. package/src/primitives/actionBar/ActionBarReload.ts +3 -16
  109. package/src/primitives/composer/ComposerAddAttachment.ts +5 -4
  110. package/src/primitives/composer/ComposerCancel.ts +3 -10
  111. package/src/primitives/composer/ComposerSend.ts +3 -13
  112. package/src/tests/BaseComposerRuntimeCore.test.ts +2 -3
  113. package/src/utils/createActionButton.tsx +1 -1
@@ -1,45 +1,7 @@
1
1
  "use client";
2
2
 
3
- import { createContext, FC, ReactNode, useContext } from "react";
4
- import type {
5
- ThreadHistoryAdapter,
6
- AttachmentAdapter,
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
- import type { AssistantCloud } from "assistant-cloud";
2
- import type {
3
- Attachment,
4
- PendingAttachment,
5
- CompleteAttachment,
6
- ThreadUserMessagePart,
7
- AttachmentAdapter,
8
- } from "@assistant-ui/core";
1
+ "use client";
9
2
 
10
- const guessAttachmentType = (
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";