@assistant-ui/react 0.15.13 → 0.15.15
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/assistant-transport.d.ts +32 -0
- package/dist/assistant-transport.d.ts.map +1 -0
- package/dist/assistant-transport.js +27 -0
- package/dist/assistant-transport.js.map +1 -0
- package/dist/context/providers/MessageProvider.js +1 -1
- package/dist/hooks/useMessageQuote.js +1 -1
- package/dist/hooks/useToolCallElapsed.js +1 -1
- package/dist/index.d.ts +5 -8
- package/dist/index.js +7 -9
- package/dist/legacy-runtime/AssistantRuntimeProvider.js +1 -1
- package/dist/mcp-apps/McpAppsRemoteHost.d.ts.map +1 -1
- package/dist/mcp-apps/McpAppsRemoteHost.js +18 -2
- package/dist/mcp-apps/McpAppsRemoteHost.js.map +1 -1
- package/dist/mcp-apps/bridge.js +39 -24
- package/dist/mcp-apps/bridge.js.map +1 -1
- package/dist/model-context/makeAssistantVisible.js +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js +24 -37
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.js +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.js +1 -1
- package/dist/primitives/attachment/AttachmentName.js +1 -1
- package/dist/primitives/attachment/AttachmentRemove.js +1 -1
- package/dist/primitives/attachment/AttachmentThumb.js +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.js +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.js +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.js +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.js +1 -1
- package/dist/primitives/composer/ComposerInput.js +2 -2
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerQuote.js +1 -1
- package/dist/primitives/composer/ComposerRoot.js +1 -1
- package/dist/primitives/composer/ComposerStopDictation.js +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.js +1 -1
- package/dist/primitives/composer/useComposerInputState.js +1 -1
- package/dist/primitives/message/MessageIf.js +1 -1
- package/dist/primitives/message/MessagePartsGrouped.js +1 -1
- package/dist/primitives/message/MessageRoot.js +1 -1
- package/dist/primitives/queueItem/QueueItemRemove.js +1 -1
- package/dist/primitives/queueItem/QueueItemSteer.js +1 -1
- package/dist/primitives/queueItem/QueueItemText.js +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js +1 -1
- package/dist/primitives/suggestion/SuggestionDescription.js +1 -1
- package/dist/primitives/suggestion/SuggestionTitle.js +1 -1
- package/dist/primitives/suggestion/SuggestionTrigger.js +1 -1
- package/dist/primitives/thread/ThreadIf.js +1 -1
- package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadRoot.js +41 -9
- package/dist/primitives/thread/ThreadRoot.js.map +1 -1
- package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js +2 -13
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +23 -8
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.js +1 -1
- package/dist/sandbox-host/SandboxHost.js +2 -0
- package/dist/sandbox-host/SandboxHost.js.map +1 -1
- package/dist/unstable/useComposerInput.d.ts +2 -2
- package/dist/unstable/useComposerInput.js +1 -1
- package/dist/unstable/useComposerInput.js.map +1 -1
- package/dist/unstable/useComposerInputHistory.js +1 -1
- package/dist/unstable/useComposerInputHistory.js.map +1 -1
- package/dist/unstable/useLiveCompletionAdapter.d.ts +5 -0
- package/dist/unstable/useLiveCompletionAdapter.d.ts.map +1 -1
- package/dist/unstable/useLiveCompletionAdapter.js +16 -3
- package/dist/unstable/useLiveCompletionAdapter.js.map +1 -1
- package/dist/unstable/useMentionAdapter.d.ts +1 -1
- package/dist/utils/smooth/SmoothContext.js +1 -1
- package/dist/utils/useToolArgsFieldStatus.js +1 -1
- package/package.json +9 -9
- package/src/assistant-transport.ts +94 -0
- package/src/index.ts +9 -4
- package/src/mcp-apps/McpAppsRemoteHost.test.ts +29 -3
- package/src/mcp-apps/McpAppsRemoteHost.ts +42 -7
- package/src/mcp-apps/bridge.test.ts +132 -0
- package/src/mcp-apps/bridge.ts +54 -30
- package/src/primitives/actionBar/ActionBarStopSpeaking.tsx +0 -9
- package/src/primitives/composer/ComposerInput.tsx +1 -1
- package/src/primitives/thread/ThreadRoot.test.tsx +251 -0
- package/src/primitives/thread/ThreadRoot.tsx +30 -0
- package/src/primitives/thread/ThreadViewport.tsx +1 -8
- package/src/primitives/thread/useThreadViewportAutoScroll.test.tsx +152 -0
- package/src/primitives/thread/useThreadViewportAutoScroll.ts +26 -19
- package/src/sandbox-host/SandboxHost.test.tsx +29 -0
- package/src/sandbox-host/SandboxHost.tsx +2 -0
- package/src/tests/RemoteThreadListRuntime.adapterProvider.test.tsx +24 -3
- package/src/tests/RemoteThreadListRuntime.reloadMainThread.test.tsx +1 -2
- package/src/tests/augmentations.test.ts +49 -0
- package/src/tests/in-memory-thread-list.test.tsx +87 -3
- package/src/tests/threadMessageById.test.tsx +61 -1
- package/src/unstable/useComposerInput.ts +2 -2
- package/src/unstable/useComposerInputHistory.test.tsx +4 -4
- package/src/unstable/useComposerInputHistory.ts +1 -1
- package/src/unstable/useLiveCompletionAdapter.test.tsx +100 -0
- package/src/unstable/useLiveCompletionAdapter.ts +41 -17
- package/dist/client/InMemoryThreadList.d.ts +0 -12
- package/dist/client/InMemoryThreadList.d.ts.map +0 -1
- package/dist/client/InMemoryThreadList.js +0 -365
- package/dist/client/InMemoryThreadList.js.map +0 -1
- package/dist/legacy-runtime/cloud/auiV0.d.ts +0 -119
- package/dist/legacy-runtime/cloud/auiV0.d.ts.map +0 -1
- package/dist/legacy-runtime/cloud/auiV0.js +0 -137
- package/dist/legacy-runtime/cloud/auiV0.js.map +0 -1
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.d.ts +0 -16
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.d.ts.map +0 -1
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.js +0 -36
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.d.ts +0 -17
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.js +0 -55
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.d.ts +0 -11
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.js +0 -141
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.d.ts +0 -15
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.js +0 -81
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts +0 -126
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.js +0 -0
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts +0 -14
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +0 -290
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.d.ts +0 -7
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.js +0 -25
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.d.ts +0 -7
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.js +0 -27
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/utils.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/assistant-transport/utils.js +0 -2
- package/src/client/InMemoryThreadList.ts +0 -241
- package/src/legacy-runtime/cloud/auiV0.ts +0 -331
- package/src/legacy-runtime/cloud/useCloudThreadListRuntime.ts +0 -31
- package/src/legacy-runtime/runtime-cores/assistant-transport/commandQueue.ts +0 -68
- package/src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.test.ts +0 -430
- package/src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.ts +0 -146
- package/src/legacy-runtime/runtime-cores/assistant-transport/runManager.ts +0 -113
- package/src/legacy-runtime/runtime-cores/assistant-transport/transport-delivery.test.tsx +0 -79
- package/src/legacy-runtime/runtime-cores/assistant-transport/transport-parentid.test.tsx +0 -97
- package/src/legacy-runtime/runtime-cores/assistant-transport/transport-scheduling.test.ts +0 -307
- package/src/legacy-runtime/runtime-cores/assistant-transport/types.ts +0 -170
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransport.spec.md +0 -141
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.test.tsx +0 -585
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts +0 -476
- package/src/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.ts +0 -20
- package/src/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.ts +0 -9
- package/src/legacy-runtime/runtime-cores/assistant-transport/utils.ts +0 -1
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
import { Derived, attachTransformScopes, useClientLookup, useClientResource } from "@assistant-ui/store";
|
|
2
|
-
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
3
|
-
import { DataRenderers, Tools } from "@assistant-ui/core/react";
|
|
4
|
-
import { useState } from "@assistant-ui/tap/react-shim";
|
|
5
|
-
import { ModelContext, Suggestions } from "@assistant-ui/core/store";
|
|
6
|
-
import { resource, withKey } from "@assistant-ui/tap";
|
|
7
|
-
//#region src/client/InMemoryThreadList.ts
|
|
8
|
-
const RESOLVED_PROMISE = Promise.resolve();
|
|
9
|
-
const useThreadListItemClient = (props) => {
|
|
10
|
-
const $ = c(19);
|
|
11
|
-
const { data, isRunning, onSwitchTo, onRename, onUpdateCustom, onArchive, onUnarchive, onDelete } = props;
|
|
12
|
-
let t0;
|
|
13
|
-
if ($[0] !== data.custom || $[1] !== data.id || $[2] !== data.status || $[3] !== data.title || $[4] !== isRunning) {
|
|
14
|
-
t0 = {
|
|
15
|
-
id: data.id,
|
|
16
|
-
remoteId: void 0,
|
|
17
|
-
externalId: void 0,
|
|
18
|
-
title: data.title,
|
|
19
|
-
status: data.status,
|
|
20
|
-
custom: data.custom,
|
|
21
|
-
isRunning
|
|
22
|
-
};
|
|
23
|
-
$[0] = data.custom;
|
|
24
|
-
$[1] = data.id;
|
|
25
|
-
$[2] = data.status;
|
|
26
|
-
$[3] = data.title;
|
|
27
|
-
$[4] = isRunning;
|
|
28
|
-
$[5] = t0;
|
|
29
|
-
} else t0 = $[5];
|
|
30
|
-
const state = t0;
|
|
31
|
-
let t1;
|
|
32
|
-
if ($[6] !== state) {
|
|
33
|
-
t1 = () => state;
|
|
34
|
-
$[6] = state;
|
|
35
|
-
$[7] = t1;
|
|
36
|
-
} else t1 = $[7];
|
|
37
|
-
let t2;
|
|
38
|
-
if ($[8] !== data.id) {
|
|
39
|
-
t2 = async () => ({
|
|
40
|
-
remoteId: data.id,
|
|
41
|
-
externalId: void 0
|
|
42
|
-
});
|
|
43
|
-
$[8] = data.id;
|
|
44
|
-
$[9] = t2;
|
|
45
|
-
} else t2 = $[9];
|
|
46
|
-
let t3;
|
|
47
|
-
if ($[10] !== onArchive || $[11] !== onDelete || $[12] !== onRename || $[13] !== onSwitchTo || $[14] !== onUnarchive || $[15] !== onUpdateCustom || $[16] !== t1 || $[17] !== t2) {
|
|
48
|
-
t3 = {
|
|
49
|
-
getState: t1,
|
|
50
|
-
switchTo: onSwitchTo,
|
|
51
|
-
rename: onRename,
|
|
52
|
-
updateCustom: onUpdateCustom,
|
|
53
|
-
archive: onArchive,
|
|
54
|
-
unarchive: onUnarchive,
|
|
55
|
-
delete: onDelete,
|
|
56
|
-
generateTitle: _temp,
|
|
57
|
-
initialize: t2,
|
|
58
|
-
detach: _temp2
|
|
59
|
-
};
|
|
60
|
-
$[10] = onArchive;
|
|
61
|
-
$[11] = onDelete;
|
|
62
|
-
$[12] = onRename;
|
|
63
|
-
$[13] = onSwitchTo;
|
|
64
|
-
$[14] = onUnarchive;
|
|
65
|
-
$[15] = onUpdateCustom;
|
|
66
|
-
$[16] = t1;
|
|
67
|
-
$[17] = t2;
|
|
68
|
-
$[18] = t3;
|
|
69
|
-
} else t3 = $[18];
|
|
70
|
-
return t3;
|
|
71
|
-
};
|
|
72
|
-
const ThreadListItemClient = resource(useThreadListItemClient);
|
|
73
|
-
const useInMemoryThreadList = (props) => {
|
|
74
|
-
const $ = c(57);
|
|
75
|
-
const { thread: threadFactory, onSwitchToThread, onSwitchToNewThread } = props;
|
|
76
|
-
const [mainThreadId, setMainThreadId] = useState("main");
|
|
77
|
-
const [threads, setThreads] = useState(_temp3);
|
|
78
|
-
let t0;
|
|
79
|
-
if ($[0] !== onSwitchToThread) {
|
|
80
|
-
t0 = (threadId) => {
|
|
81
|
-
setMainThreadId(threadId);
|
|
82
|
-
onSwitchToThread?.(threadId);
|
|
83
|
-
};
|
|
84
|
-
$[0] = onSwitchToThread;
|
|
85
|
-
$[1] = t0;
|
|
86
|
-
} else t0 = $[1];
|
|
87
|
-
const handleSwitchToThread = t0;
|
|
88
|
-
let t1;
|
|
89
|
-
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
90
|
-
t1 = (threadId_0, title) => {
|
|
91
|
-
setThreads((prev) => prev.map((t) => t.id === threadId_0 ? {
|
|
92
|
-
...t,
|
|
93
|
-
title
|
|
94
|
-
} : t));
|
|
95
|
-
};
|
|
96
|
-
$[2] = t1;
|
|
97
|
-
} else t1 = $[2];
|
|
98
|
-
const handleRename = t1;
|
|
99
|
-
let t2;
|
|
100
|
-
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
101
|
-
t2 = (threadId_1) => {
|
|
102
|
-
setThreads((prev_0) => prev_0.map((t_0) => t_0.id === threadId_1 ? {
|
|
103
|
-
...t_0,
|
|
104
|
-
status: "archived"
|
|
105
|
-
} : t_0));
|
|
106
|
-
};
|
|
107
|
-
$[3] = t2;
|
|
108
|
-
} else t2 = $[3];
|
|
109
|
-
const handleArchive = t2;
|
|
110
|
-
let t3;
|
|
111
|
-
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
112
|
-
t3 = (threadId_2) => {
|
|
113
|
-
setThreads((prev_1) => prev_1.map((t_1) => t_1.id === threadId_2 ? {
|
|
114
|
-
...t_1,
|
|
115
|
-
status: "regular"
|
|
116
|
-
} : t_1));
|
|
117
|
-
};
|
|
118
|
-
$[4] = t3;
|
|
119
|
-
} else t3 = $[4];
|
|
120
|
-
const handleUnarchive = t3;
|
|
121
|
-
let t4;
|
|
122
|
-
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
123
|
-
t4 = (threadId_3, custom) => {
|
|
124
|
-
setThreads((prev_2) => prev_2.map((t_2) => t_2.id === threadId_3 ? {
|
|
125
|
-
...t_2,
|
|
126
|
-
custom
|
|
127
|
-
} : t_2));
|
|
128
|
-
};
|
|
129
|
-
$[5] = t4;
|
|
130
|
-
} else t4 = $[5];
|
|
131
|
-
const handleUpdateCustom = t4;
|
|
132
|
-
let t5;
|
|
133
|
-
if ($[6] !== threads) {
|
|
134
|
-
t5 = (threadId_4) => {
|
|
135
|
-
setThreads((prev_3) => prev_3.filter((t_3) => t_3.id !== threadId_4));
|
|
136
|
-
setMainThreadId((prev_4) => prev_4 === threadId_4 ? threads.find((t_4) => t_4.id !== threadId_4)?.id || "main" : prev_4);
|
|
137
|
-
};
|
|
138
|
-
$[6] = threads;
|
|
139
|
-
$[7] = t5;
|
|
140
|
-
} else t5 = $[7];
|
|
141
|
-
const handleDelete = t5;
|
|
142
|
-
let t6;
|
|
143
|
-
if ($[8] !== onSwitchToNewThread) {
|
|
144
|
-
t6 = () => {
|
|
145
|
-
const newId = `thread-${Date.now()}`;
|
|
146
|
-
setThreads((prev_5) => [...prev_5, {
|
|
147
|
-
id: newId,
|
|
148
|
-
title: "New Thread",
|
|
149
|
-
status: "regular"
|
|
150
|
-
}]);
|
|
151
|
-
setMainThreadId(newId);
|
|
152
|
-
onSwitchToNewThread?.();
|
|
153
|
-
};
|
|
154
|
-
$[8] = onSwitchToNewThread;
|
|
155
|
-
$[9] = t6;
|
|
156
|
-
} else t6 = $[9];
|
|
157
|
-
const handleSwitchToNewThread = t6;
|
|
158
|
-
let t7;
|
|
159
|
-
if ($[10] !== mainThreadId || $[11] !== threadFactory) {
|
|
160
|
-
t7 = threadFactory(mainThreadId);
|
|
161
|
-
$[10] = mainThreadId;
|
|
162
|
-
$[11] = threadFactory;
|
|
163
|
-
$[12] = t7;
|
|
164
|
-
} else t7 = $[12];
|
|
165
|
-
const mainThreadClient = useClientResource(t7);
|
|
166
|
-
let t8;
|
|
167
|
-
if ($[13] !== handleDelete || $[14] !== handleSwitchToThread || $[15] !== mainThreadClient.state || $[16] !== mainThreadId || $[17] !== threads) {
|
|
168
|
-
let t9;
|
|
169
|
-
if ($[19] !== handleDelete || $[20] !== handleSwitchToThread || $[21] !== mainThreadClient.state || $[22] !== mainThreadId) {
|
|
170
|
-
t9 = (t_5) => withKey(t_5.id, ThreadListItemClient({
|
|
171
|
-
data: t_5,
|
|
172
|
-
isRunning: t_5.id === mainThreadId && mainThreadClient.state.isRunning,
|
|
173
|
-
onSwitchTo: () => handleSwitchToThread(t_5.id),
|
|
174
|
-
onRename: (title_0) => handleRename(t_5.id, title_0),
|
|
175
|
-
onUpdateCustom: (custom_0) => handleUpdateCustom(t_5.id, custom_0),
|
|
176
|
-
onArchive: () => handleArchive(t_5.id),
|
|
177
|
-
onUnarchive: () => handleUnarchive(t_5.id),
|
|
178
|
-
onDelete: () => handleDelete(t_5.id)
|
|
179
|
-
}));
|
|
180
|
-
$[19] = handleDelete;
|
|
181
|
-
$[20] = handleSwitchToThread;
|
|
182
|
-
$[21] = mainThreadClient.state;
|
|
183
|
-
$[22] = mainThreadId;
|
|
184
|
-
$[23] = t9;
|
|
185
|
-
} else t9 = $[23];
|
|
186
|
-
t8 = threads.map(t9);
|
|
187
|
-
$[13] = handleDelete;
|
|
188
|
-
$[14] = handleSwitchToThread;
|
|
189
|
-
$[15] = mainThreadClient.state;
|
|
190
|
-
$[16] = mainThreadId;
|
|
191
|
-
$[17] = threads;
|
|
192
|
-
$[18] = t8;
|
|
193
|
-
} else t8 = $[18];
|
|
194
|
-
const threadListItems = useClientLookup(t8);
|
|
195
|
-
let t10;
|
|
196
|
-
let t11;
|
|
197
|
-
let t12;
|
|
198
|
-
let t13;
|
|
199
|
-
let t14;
|
|
200
|
-
let t15;
|
|
201
|
-
let t9;
|
|
202
|
-
if ($[24] !== mainThreadId || $[25] !== threads) {
|
|
203
|
-
const regularThreads = threads.filter(_temp4);
|
|
204
|
-
const archivedThreads = threads.filter(_temp5);
|
|
205
|
-
t9 = mainThreadId;
|
|
206
|
-
t10 = null;
|
|
207
|
-
t11 = false;
|
|
208
|
-
t12 = false;
|
|
209
|
-
t13 = false;
|
|
210
|
-
t14 = regularThreads.map(_temp6);
|
|
211
|
-
t15 = archivedThreads.map(_temp7);
|
|
212
|
-
$[24] = mainThreadId;
|
|
213
|
-
$[25] = threads;
|
|
214
|
-
$[26] = t10;
|
|
215
|
-
$[27] = t11;
|
|
216
|
-
$[28] = t12;
|
|
217
|
-
$[29] = t13;
|
|
218
|
-
$[30] = t14;
|
|
219
|
-
$[31] = t15;
|
|
220
|
-
$[32] = t9;
|
|
221
|
-
} else {
|
|
222
|
-
t10 = $[26];
|
|
223
|
-
t11 = $[27];
|
|
224
|
-
t12 = $[28];
|
|
225
|
-
t13 = $[29];
|
|
226
|
-
t14 = $[30];
|
|
227
|
-
t15 = $[31];
|
|
228
|
-
t9 = $[32];
|
|
229
|
-
}
|
|
230
|
-
let t16;
|
|
231
|
-
if ($[33] !== mainThreadClient.state || $[34] !== t10 || $[35] !== t11 || $[36] !== t12 || $[37] !== t13 || $[38] !== t14 || $[39] !== t15 || $[40] !== t9 || $[41] !== threadListItems.state) {
|
|
232
|
-
t16 = {
|
|
233
|
-
mainThreadId: t9,
|
|
234
|
-
newThreadId: t10,
|
|
235
|
-
isLoading: t11,
|
|
236
|
-
isLoadingMore: t12,
|
|
237
|
-
hasMore: t13,
|
|
238
|
-
threadIds: t14,
|
|
239
|
-
archivedThreadIds: t15,
|
|
240
|
-
threadItems: threadListItems.state,
|
|
241
|
-
main: mainThreadClient.state
|
|
242
|
-
};
|
|
243
|
-
$[33] = mainThreadClient.state;
|
|
244
|
-
$[34] = t10;
|
|
245
|
-
$[35] = t11;
|
|
246
|
-
$[36] = t12;
|
|
247
|
-
$[37] = t13;
|
|
248
|
-
$[38] = t14;
|
|
249
|
-
$[39] = t15;
|
|
250
|
-
$[40] = t9;
|
|
251
|
-
$[41] = threadListItems.state;
|
|
252
|
-
$[42] = t16;
|
|
253
|
-
} else t16 = $[42];
|
|
254
|
-
const state = t16;
|
|
255
|
-
let t17;
|
|
256
|
-
if ($[43] !== state) {
|
|
257
|
-
t17 = () => state;
|
|
258
|
-
$[43] = state;
|
|
259
|
-
$[44] = t17;
|
|
260
|
-
} else t17 = $[44];
|
|
261
|
-
let t18;
|
|
262
|
-
if ($[45] !== mainThreadId || $[46] !== threadListItems || $[47] !== threads) {
|
|
263
|
-
t18 = (selector) => {
|
|
264
|
-
if (selector === "main") {
|
|
265
|
-
const index = threads.findIndex((t_10) => t_10.id === mainThreadId);
|
|
266
|
-
return threadListItems.get({ index: index === -1 ? 0 : index });
|
|
267
|
-
}
|
|
268
|
-
if ("id" in selector) {
|
|
269
|
-
const index_0 = threads.findIndex((t_11) => t_11.id === selector.id);
|
|
270
|
-
return threadListItems.get({ index: index_0 });
|
|
271
|
-
}
|
|
272
|
-
return threadListItems.get(selector);
|
|
273
|
-
};
|
|
274
|
-
$[45] = mainThreadId;
|
|
275
|
-
$[46] = threadListItems;
|
|
276
|
-
$[47] = threads;
|
|
277
|
-
$[48] = t18;
|
|
278
|
-
} else t18 = $[48];
|
|
279
|
-
let t19;
|
|
280
|
-
if ($[49] !== mainThreadClient.methods) {
|
|
281
|
-
t19 = () => mainThreadClient.methods;
|
|
282
|
-
$[49] = mainThreadClient.methods;
|
|
283
|
-
$[50] = t19;
|
|
284
|
-
} else t19 = $[50];
|
|
285
|
-
let t20;
|
|
286
|
-
if ($[51] !== handleSwitchToNewThread || $[52] !== handleSwitchToThread || $[53] !== t17 || $[54] !== t18 || $[55] !== t19) {
|
|
287
|
-
t20 = {
|
|
288
|
-
getState: t17,
|
|
289
|
-
switchToThread: handleSwitchToThread,
|
|
290
|
-
switchToNewThread: handleSwitchToNewThread,
|
|
291
|
-
getLoadThreadsPromise: _temp8,
|
|
292
|
-
reload: _temp9,
|
|
293
|
-
reloadMainThread: _temp0,
|
|
294
|
-
loadMore: _temp1,
|
|
295
|
-
item: t18,
|
|
296
|
-
thread: t19
|
|
297
|
-
};
|
|
298
|
-
$[51] = handleSwitchToNewThread;
|
|
299
|
-
$[52] = handleSwitchToThread;
|
|
300
|
-
$[53] = t17;
|
|
301
|
-
$[54] = t18;
|
|
302
|
-
$[55] = t19;
|
|
303
|
-
$[56] = t20;
|
|
304
|
-
} else t20 = $[56];
|
|
305
|
-
return t20;
|
|
306
|
-
};
|
|
307
|
-
const InMemoryThreadList = resource(useInMemoryThreadList);
|
|
308
|
-
attachTransformScopes(useInMemoryThreadList, (scopes, parent) => {
|
|
309
|
-
scopes.thread ??= Derived({
|
|
310
|
-
source: "threads",
|
|
311
|
-
query: { type: "main" },
|
|
312
|
-
get: (aui) => aui.threads.thread("main")
|
|
313
|
-
});
|
|
314
|
-
scopes.threadListItem ??= Derived({
|
|
315
|
-
source: "threads",
|
|
316
|
-
query: { type: "main" },
|
|
317
|
-
get: (aui) => aui.threads.item("main")
|
|
318
|
-
});
|
|
319
|
-
scopes.composer ??= Derived({
|
|
320
|
-
source: "thread",
|
|
321
|
-
query: {},
|
|
322
|
-
get: (aui) => aui.threads.thread("main").composer()
|
|
323
|
-
});
|
|
324
|
-
if (!scopes.modelContext && parent.modelContext.source === null) scopes.modelContext = ModelContext();
|
|
325
|
-
if (!scopes.tools && parent.tools.source === null) scopes.tools = Tools({});
|
|
326
|
-
if (!scopes.dataRenderers && parent.dataRenderers.source === null) scopes.dataRenderers = DataRenderers();
|
|
327
|
-
if (!scopes.suggestions && parent.suggestions.source === null) scopes.suggestions = Suggestions();
|
|
328
|
-
});
|
|
329
|
-
function _temp() {}
|
|
330
|
-
function _temp2() {}
|
|
331
|
-
function _temp3() {
|
|
332
|
-
return [{
|
|
333
|
-
id: "main",
|
|
334
|
-
title: "Main Thread",
|
|
335
|
-
status: "regular"
|
|
336
|
-
}];
|
|
337
|
-
}
|
|
338
|
-
function _temp4(t_6) {
|
|
339
|
-
return t_6.status === "regular";
|
|
340
|
-
}
|
|
341
|
-
function _temp5(t_7) {
|
|
342
|
-
return t_7.status === "archived";
|
|
343
|
-
}
|
|
344
|
-
function _temp6(t_8) {
|
|
345
|
-
return t_8.id;
|
|
346
|
-
}
|
|
347
|
-
function _temp7(t_9) {
|
|
348
|
-
return t_9.id;
|
|
349
|
-
}
|
|
350
|
-
function _temp8() {
|
|
351
|
-
return RESOLVED_PROMISE;
|
|
352
|
-
}
|
|
353
|
-
function _temp9() {
|
|
354
|
-
return RESOLVED_PROMISE;
|
|
355
|
-
}
|
|
356
|
-
function _temp0() {
|
|
357
|
-
return RESOLVED_PROMISE;
|
|
358
|
-
}
|
|
359
|
-
function _temp1() {
|
|
360
|
-
return RESOLVED_PROMISE;
|
|
361
|
-
}
|
|
362
|
-
//#endregion
|
|
363
|
-
export { InMemoryThreadList };
|
|
364
|
-
|
|
365
|
-
//# sourceMappingURL=InMemoryThreadList.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InMemoryThreadList.js","names":["useState","useMemo","resource","withKey","ResourceElement","ClientOutput","useClientLookup","Derived","attachTransformScopes","useClientResource","ModelContext","Suggestions","Tools","DataRenderers","RESOLVED_PROMISE","Promise","resolve","InMemoryThreadListProps","thread","threadId","onSwitchToThread","onSwitchToNewThread","ThreadData","id","title","status","custom","Record","useThreadListItemClient","props","$","_c","data","isRunning","onSwitchTo","onRename","onUpdateCustom","onArchive","onUnarchive","onDelete","t0","remoteId","undefined","externalId","state","t1","t2","t3","getState","switchTo","rename","updateCustom","archive","unarchive","delete","generateTitle","_temp","initialize","detach","_temp2","ThreadListItemClient","useInMemoryThreadList","threadFactory","mainThreadId","setMainThreadId","threads","setThreads","_temp3","handleSwitchToThread","Symbol","for","threadId_0","prev","map","t","handleRename","threadId_1","prev_0","t_0","const","handleArchive","threadId_2","prev_1","t_1","handleUnarchive","t4","threadId_3","prev_2","t_2","handleUpdateCustom","t5","threadId_4","prev_3","filter","t_3","prev_4","find","t_4","handleDelete","t6","newId","Date","now","prev_5","handleSwitchToNewThread","t7","mainThreadClient","t8","t9","t_5","title_0","custom_0","threadListItems","t10","t11","t12","t13","t14","t15","regularThreads","_temp4","archivedThreads","_temp5","_temp6","_temp7","t16","newThreadId","isLoading","isLoadingMore","hasMore","threadIds","archivedThreadIds","threadItems","main","t17","t18","selector","index","findIndex","t_10","get","index_0","t_11","t19","methods","t20","switchToThread","switchToNewThread","getLoadThreadsPromise","_temp8","reload","_temp9","reloadMainThread","_temp0","loadMore","_temp1","item","InMemoryThreadList","scopes","parent","source","query","type","aui","threadListItem","composer","modelContext","tools","dataRenderers","suggestions","t_6","t_7","t_8","t_9"],"sources":["../../src/client/InMemoryThreadList.ts"],"sourcesContent":["import { useState, useMemo } from \"react\";\nimport { resource, withKey, type ResourceElement } from \"@assistant-ui/tap\";\nimport {\n type ClientOutput,\n useClientLookup,\n Derived,\n attachTransformScopes,\n useClientResource,\n} from \"@assistant-ui/store\";\n\nimport { ModelContext, Suggestions } from \"@assistant-ui/core/store\";\nimport { Tools, DataRenderers } from \"@assistant-ui/core/react\";\n\nconst RESOLVED_PROMISE = Promise.resolve();\n\nexport type InMemoryThreadListProps = {\n thread: (threadId: string) => ResourceElement<ClientOutput<\"thread\">>;\n onSwitchToThread?: (threadId: string) => void;\n onSwitchToNewThread?: () => void;\n};\n\ntype ThreadData = {\n id: string;\n title?: string;\n status: \"regular\" | \"archived\";\n custom?: Record<string, unknown> | undefined;\n};\n\n// ThreadListItem Client\nconst useThreadListItemClient = (props: {\n data: ThreadData;\n isRunning: boolean;\n onSwitchTo: () => void;\n onRename: (title: string) => void;\n onUpdateCustom: (custom: Record<string, unknown> | undefined) => void;\n onArchive: () => void;\n onUnarchive: () => void;\n onDelete: () => void;\n}): ClientOutput<\"threadListItem\"> => {\n const {\n data,\n isRunning,\n onSwitchTo,\n onRename,\n onUpdateCustom,\n onArchive,\n onUnarchive,\n onDelete,\n } = props;\n const state = useMemo(\n () => ({\n id: data.id,\n remoteId: undefined,\n externalId: undefined,\n title: data.title,\n status: data.status,\n custom: data.custom,\n isRunning,\n }),\n [data.id, data.title, data.status, data.custom, isRunning],\n );\n\n return {\n getState: () => state,\n switchTo: onSwitchTo,\n rename: onRename,\n updateCustom: onUpdateCustom,\n archive: onArchive,\n unarchive: onUnarchive,\n delete: onDelete,\n generateTitle: () => {},\n initialize: async () => ({ remoteId: data.id, externalId: undefined }),\n detach: () => {},\n };\n};\n\nconst ThreadListItemClient = resource(useThreadListItemClient);\n\n// InMemoryThreadList Client\nconst useInMemoryThreadList = (\n props: InMemoryThreadListProps,\n): ClientOutput<\"threads\"> => {\n const {\n thread: threadFactory,\n onSwitchToThread,\n onSwitchToNewThread,\n } = props;\n\n const [mainThreadId, setMainThreadId] = useState(\"main\");\n const [threads, setThreads] = useState<readonly ThreadData[]>(() => [\n { id: \"main\", title: \"Main Thread\", status: \"regular\" },\n ]);\n\n const handleSwitchToThread = (threadId: string) => {\n setMainThreadId(threadId);\n onSwitchToThread?.(threadId);\n };\n\n const handleRename = (threadId: string, title: string) => {\n setThreads((prev) =>\n prev.map((t) => (t.id === threadId ? { ...t, title } : t)),\n );\n };\n\n const handleArchive = (threadId: string) => {\n setThreads((prev) =>\n prev.map((t) =>\n t.id === threadId ? { ...t, status: \"archived\" as const } : t,\n ),\n );\n };\n\n const handleUnarchive = (threadId: string) => {\n setThreads((prev) =>\n prev.map((t) =>\n t.id === threadId ? { ...t, status: \"regular\" as const } : t,\n ),\n );\n };\n\n const handleUpdateCustom = (\n threadId: string,\n custom: Record<string, unknown> | undefined,\n ) => {\n setThreads((prev) =>\n prev.map((t) => (t.id === threadId ? { ...t, custom } : t)),\n );\n };\n\n const handleDelete = (threadId: string) => {\n setThreads((prev) => prev.filter((t) => t.id !== threadId));\n setMainThreadId((prev) =>\n prev === threadId\n ? threads.find((t) => t.id !== threadId)?.id || \"main\"\n : prev,\n );\n };\n\n const handleSwitchToNewThread = () => {\n const newId = `thread-${Date.now()}`;\n setThreads((prev) => [\n ...prev,\n { id: newId, title: \"New Thread\", status: \"regular\" },\n ]);\n setMainThreadId(newId);\n onSwitchToNewThread?.();\n };\n\n // Only the main thread is mounted, so it is the only thread that can run.\n const mainThreadClient = useClientResource(threadFactory(mainThreadId));\n\n const threadListItems = useClientLookup(\n threads.map((t) =>\n withKey(\n t.id,\n ThreadListItemClient({\n data: t,\n isRunning: t.id === mainThreadId && mainThreadClient.state.isRunning,\n onSwitchTo: () => handleSwitchToThread(t.id),\n onRename: (title) => handleRename(t.id, title),\n onUpdateCustom: (custom) => handleUpdateCustom(t.id, custom),\n onArchive: () => handleArchive(t.id),\n onUnarchive: () => handleUnarchive(t.id),\n onDelete: () => handleDelete(t.id),\n }),\n ),\n ),\n );\n\n const state = useMemo(() => {\n const regularThreads = threads.filter((t) => t.status === \"regular\");\n const archivedThreads = threads.filter((t) => t.status === \"archived\");\n\n return {\n mainThreadId,\n newThreadId: null,\n isLoading: false,\n isLoadingMore: false,\n hasMore: false,\n threadIds: regularThreads.map((t) => t.id),\n archivedThreadIds: archivedThreads.map((t) => t.id),\n threadItems: threadListItems.state,\n main: mainThreadClient.state,\n };\n }, [mainThreadId, threads, threadListItems.state, mainThreadClient.state]);\n\n return {\n getState: () => state,\n switchToThread: handleSwitchToThread,\n switchToNewThread: handleSwitchToNewThread,\n getLoadThreadsPromise: () => RESOLVED_PROMISE,\n reload: () => RESOLVED_PROMISE,\n reloadMainThread: () => RESOLVED_PROMISE,\n loadMore: () => RESOLVED_PROMISE,\n item: (selector) => {\n if (selector === \"main\") {\n const index = threads.findIndex((t) => t.id === mainThreadId);\n return threadListItems.get({ index: index === -1 ? 0 : index });\n }\n if (\"id\" in selector) {\n const index = threads.findIndex((t) => t.id === selector.id);\n return threadListItems.get({ index });\n }\n return threadListItems.get(selector);\n },\n thread: () => mainThreadClient.methods,\n };\n};\n\nexport const InMemoryThreadList = resource(useInMemoryThreadList);\n\nattachTransformScopes(useInMemoryThreadList, (scopes, parent) => {\n scopes.thread ??= Derived({\n source: \"threads\",\n query: { type: \"main\" },\n get: (aui) => aui.threads.thread(\"main\"),\n });\n scopes.threadListItem ??= Derived({\n source: \"threads\",\n query: { type: \"main\" },\n get: (aui) => aui.threads.item(\"main\"),\n });\n scopes.composer ??= Derived({\n source: \"thread\",\n query: {},\n get: (aui) => aui.threads.thread(\"main\").composer(),\n });\n\n if (!scopes.modelContext && parent.modelContext.source === null) {\n scopes.modelContext = ModelContext();\n }\n if (!scopes.tools && parent.tools.source === null) {\n scopes.tools = Tools({});\n }\n if (!scopes.dataRenderers && parent.dataRenderers.source === null) {\n scopes.dataRenderers = DataRenderers();\n }\n if (!scopes.suggestions && parent.suggestions.source === null) {\n scopes.suggestions = Suggestions();\n }\n});\n"],"mappings":";;;;;;;AAaA,MAAMc,mBAAmBC,QAAQC,QAAQ;AAgBzC,MAAMY,2BAA0BC,UAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAU9B,MAAA,EAAAC,MAAAC,WAAAC,YAAAC,UAAAC,gBAAAC,WAAAC,aAAAC,aASIV;CAAM,IAAAW;CAAA,IAAAV,EAAA,OAAAE,KAAAN,UAAAI,EAAA,OAAAE,KAAAT,MAAAO,EAAA,OAAAE,KAAAP,UAAAK,EAAA,OAAAE,KAAAR,SAAAM,EAAA,OAAAG,WAAA;EAEDO,KAAA;GAAAjB,IACDS,KAAIT;GAAGkB,UACDC,KAAAA;GAASC,YACPD,KAAAA;GAASlB,OACdQ,KAAIR;GAAMC,QACTO,KAAIP;GAAOC,QACXM,KAAIN;GAAOO;EAErB;EAACH,EAAA,KAAAE,KAAAN;EAAAI,EAAA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QAAA,CAAA;AAAA,SAAAG,SAAA,CAAA;AAkDF,SAAAQ,SAAA;CAAA,OAUwC,CAClE;EAAA5C,IAAM;EAAMC,OAAS;EAAaC,QAAU;CAAU,CAAC;AACxD;AAZ2B,SAAA+F,OAAAkD,KAAA;CAAA,OA2FmBhG,IAACjD,WAAY;AAAS;AA3FzC,SAAAiG,OAAAiD,KAAA;CAAA,OA4FoBjG,IAACjD,WAAY;AAAU;AA5F3C,SAAAkG,OAAAiD,KAAA;CAAA,OAoGalG,IAACnD;AAAG;AApGjB,SAAAqG,OAAAiD,KAAA;CAAA,OAqGsBnG,IAACnD;AAAG;AArG1B,SAAA8H,SAAA;CAAA,OA+GGvI;AAAgB;AA/GnB,SAAAyI,SAAA;CAAA,OAgHZzI;AAAgB;AAhHJ,SAAA2I,SAAA;CAAA,OAiHF3I;AAAgB;AAjHd,SAAA6I,SAAA;CAAA,OAkHV7I;AAAgB"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { ExportedMessageRepositoryItem } from "../runtime-cores/utils/MessageRepository.js";
|
|
2
|
-
import { CloudMessage } from "assistant-cloud";
|
|
3
|
-
import { CompleteAttachment, MessageStatus, SourceProviderMetadata, ThreadMessage, ToolApprovalOption } from "@assistant-ui/core";
|
|
4
|
-
import { ReadonlyJSONObject, ReadonlyJSONValue } from "assistant-stream/utils";
|
|
5
|
-
//#region src/legacy-runtime/cloud/auiV0.d.ts
|
|
6
|
-
type AuiV0ToolApproval = {
|
|
7
|
-
readonly id: string;
|
|
8
|
-
readonly approved?: boolean;
|
|
9
|
-
readonly reason?: string;
|
|
10
|
-
readonly isAutomatic?: boolean;
|
|
11
|
-
readonly options?: readonly ToolApprovalOption[];
|
|
12
|
-
readonly optionId?: string;
|
|
13
|
-
readonly resolution?: "cancelled" | "expired";
|
|
14
|
-
};
|
|
15
|
-
type AuiV0MessagePart = {
|
|
16
|
-
readonly type: "text";
|
|
17
|
-
readonly text: string;
|
|
18
|
-
} | {
|
|
19
|
-
readonly type: "reasoning";
|
|
20
|
-
readonly text: string;
|
|
21
|
-
readonly unstable_summary?: string;
|
|
22
|
-
} | {
|
|
23
|
-
readonly type: "source";
|
|
24
|
-
readonly sourceType: "url";
|
|
25
|
-
readonly id: string;
|
|
26
|
-
readonly url: string;
|
|
27
|
-
readonly title?: string;
|
|
28
|
-
readonly providerMetadata?: SourceProviderMetadata;
|
|
29
|
-
} | {
|
|
30
|
-
readonly type: "source";
|
|
31
|
-
readonly sourceType: "document";
|
|
32
|
-
readonly id: string;
|
|
33
|
-
readonly title: string;
|
|
34
|
-
readonly mediaType: string;
|
|
35
|
-
readonly filename?: string;
|
|
36
|
-
readonly providerMetadata?: SourceProviderMetadata;
|
|
37
|
-
} | {
|
|
38
|
-
readonly type: "tool-call";
|
|
39
|
-
readonly toolCallId: string;
|
|
40
|
-
readonly toolName: string;
|
|
41
|
-
readonly args: ReadonlyJSONObject;
|
|
42
|
-
readonly result?: ReadonlyJSONValue;
|
|
43
|
-
readonly isError?: true;
|
|
44
|
-
readonly approval?: AuiV0ToolApproval;
|
|
45
|
-
} | {
|
|
46
|
-
readonly type: "tool-call";
|
|
47
|
-
readonly toolCallId: string;
|
|
48
|
-
readonly toolName: string;
|
|
49
|
-
readonly argsText: string;
|
|
50
|
-
readonly result?: ReadonlyJSONValue;
|
|
51
|
-
readonly isError?: true;
|
|
52
|
-
readonly approval?: AuiV0ToolApproval;
|
|
53
|
-
} | {
|
|
54
|
-
readonly type: "image";
|
|
55
|
-
readonly image: string;
|
|
56
|
-
} | {
|
|
57
|
-
readonly type: "file";
|
|
58
|
-
readonly data: string;
|
|
59
|
-
readonly mimeType: string;
|
|
60
|
-
readonly filename?: string;
|
|
61
|
-
readonly sourceType?: "url" | "id";
|
|
62
|
-
};
|
|
63
|
-
type AuiV0AttachmentPart = {
|
|
64
|
-
readonly type: "text";
|
|
65
|
-
readonly text: string;
|
|
66
|
-
} | {
|
|
67
|
-
readonly type: "image";
|
|
68
|
-
readonly image: string;
|
|
69
|
-
readonly filename?: string;
|
|
70
|
-
} | {
|
|
71
|
-
readonly type: "file";
|
|
72
|
-
readonly data: string;
|
|
73
|
-
readonly mimeType: string;
|
|
74
|
-
readonly filename?: string;
|
|
75
|
-
readonly sourceType?: "url" | "id";
|
|
76
|
-
} | {
|
|
77
|
-
readonly type: "audio";
|
|
78
|
-
readonly audio: {
|
|
79
|
-
readonly data: string;
|
|
80
|
-
readonly format: "mp3" | "wav";
|
|
81
|
-
};
|
|
82
|
-
} | {
|
|
83
|
-
readonly type: "data";
|
|
84
|
-
readonly name: string;
|
|
85
|
-
readonly data: ReadonlyJSONValue;
|
|
86
|
-
};
|
|
87
|
-
type AuiV0Attachment = {
|
|
88
|
-
readonly id: string;
|
|
89
|
-
readonly type: CompleteAttachment["type"];
|
|
90
|
-
readonly name: string;
|
|
91
|
-
readonly contentType?: string;
|
|
92
|
-
readonly status: CompleteAttachment["status"];
|
|
93
|
-
readonly content: readonly AuiV0AttachmentPart[];
|
|
94
|
-
};
|
|
95
|
-
type AuiV0Message = {
|
|
96
|
-
readonly role: "assistant" | "user" | "system";
|
|
97
|
-
readonly status?: MessageStatus;
|
|
98
|
-
readonly content: readonly AuiV0MessagePart[];
|
|
99
|
-
readonly attachments?: readonly AuiV0Attachment[];
|
|
100
|
-
readonly metadata: {
|
|
101
|
-
readonly unstable_state?: ReadonlyJSONValue;
|
|
102
|
-
readonly unstable_annotations: readonly ReadonlyJSONValue[];
|
|
103
|
-
readonly unstable_data: readonly ReadonlyJSONValue[];
|
|
104
|
-
readonly steps: readonly {
|
|
105
|
-
readonly usage?: {
|
|
106
|
-
readonly inputTokens: number;
|
|
107
|
-
readonly outputTokens: number;
|
|
108
|
-
};
|
|
109
|
-
}[];
|
|
110
|
-
readonly custom: ReadonlyJSONObject;
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
declare function auiV0Encode(message: ThreadMessage): AuiV0Message;
|
|
114
|
-
declare function auiV0Decode(cloudMessage: CloudMessage & {
|
|
115
|
-
format: "aui/v0";
|
|
116
|
-
}): ExportedMessageRepositoryItem;
|
|
117
|
-
//#endregion
|
|
118
|
-
export { auiV0Decode, auiV0Encode };
|
|
119
|
-
//# sourceMappingURL=auiV0.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auiV0.d.ts","names":[],"sources":["../../../src/legacy-runtime/cloud/auiV0.ts"],"mappings":";;;;;KAgBK;WACM;WACA;WACA;WACA;WACA,mBAAmB;WACnB;WACA;;KAGN;WAEU;WACA;;WAGA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA,mBAAmB;;WAGnB;WACA;WACA;WACA;WACA;WACA;WACA,mBAAmB;;WAGnB;WACA;WACA;WACA,MAAM;WACN,SAAS;WACT;WACA,WAAW;;WAGX;WACA;WACA;WACA;WACA,SAAS;WACT;WACA,WAAW;;WAGX;WACA;;WAGA;WACA;WACA;WACA;WACA;;KAGV;WAEU;WACA;;WAGA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;;WAGA;WACA;aACE;aACA;;;WAIF;WACA;WACA,MAAM;;KAGhB;WACM;WACA,MAAM;WACN;WACA;WACA,QAAQ;WACR,kBAAkB;;KAGxB;WACM;WACA,SAAS;WACT,kBAAkB;WAClB,uBAAuB;WACvB;aACE,iBAAiB;aACjB,+BAA+B;aAC/B,wBAAwB;aACxB;eACE;iBACE;iBACA;;;aAGJ,QAAQ;;;iBA2EL,YAAY,SAAS,gBAAgB;iBAoGrC,YACd,cAAc;EAAiB;IAC9B"}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { fromThreadMessageLike } from "../runtime-cores/external-store/ThreadMessageLike.js";
|
|
2
|
-
import { isJSONValue } from "@assistant-ui/core/internal";
|
|
3
|
-
//#region src/legacy-runtime/cloud/auiV0.ts
|
|
4
|
-
const encodeAttachmentPart = (part) => {
|
|
5
|
-
const type = part.type;
|
|
6
|
-
switch (type) {
|
|
7
|
-
case "text": return {
|
|
8
|
-
type: "text",
|
|
9
|
-
text: part.text
|
|
10
|
-
};
|
|
11
|
-
case "image": return {
|
|
12
|
-
type: "image",
|
|
13
|
-
image: part.image,
|
|
14
|
-
...part.filename != null ? { filename: part.filename } : void 0
|
|
15
|
-
};
|
|
16
|
-
case "file": return {
|
|
17
|
-
type: "file",
|
|
18
|
-
data: part.data,
|
|
19
|
-
mimeType: part.mimeType,
|
|
20
|
-
...part.filename != null ? { filename: part.filename } : void 0,
|
|
21
|
-
...part.sourceType != null ? { sourceType: part.sourceType } : void 0
|
|
22
|
-
};
|
|
23
|
-
case "audio": return {
|
|
24
|
-
type: "audio",
|
|
25
|
-
audio: {
|
|
26
|
-
data: part.audio.data,
|
|
27
|
-
format: part.audio.format
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
case "data":
|
|
31
|
-
if (!isJSONValue(part.data)) console.warn(`attachment data is not JSON! ${JSON.stringify(part)}`);
|
|
32
|
-
return {
|
|
33
|
-
type: "data",
|
|
34
|
-
name: part.name,
|
|
35
|
-
data: part.data
|
|
36
|
-
};
|
|
37
|
-
default: throw new Error(`Attachment part type not supported by aui/v0: ${type}`);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const encodeAttachments = (message) => {
|
|
41
|
-
if (message.role !== "user" || message.attachments.length === 0) return;
|
|
42
|
-
return message.attachments.map(({ id, type, name, contentType, status, content }) => ({
|
|
43
|
-
id,
|
|
44
|
-
type,
|
|
45
|
-
name,
|
|
46
|
-
status,
|
|
47
|
-
...contentType != null ? { contentType } : void 0,
|
|
48
|
-
content: content.map(encodeAttachmentPart)
|
|
49
|
-
}));
|
|
50
|
-
};
|
|
51
|
-
function auiV0Encode(message) {
|
|
52
|
-
const status = message.status?.type === "running" ? {
|
|
53
|
-
type: "incomplete",
|
|
54
|
-
reason: "cancelled"
|
|
55
|
-
} : message.status;
|
|
56
|
-
const attachments = encodeAttachments(message);
|
|
57
|
-
return {
|
|
58
|
-
role: message.role,
|
|
59
|
-
content: message.content.map((part) => {
|
|
60
|
-
const type = part.type;
|
|
61
|
-
switch (type) {
|
|
62
|
-
case "text": return {
|
|
63
|
-
type: "text",
|
|
64
|
-
text: part.text
|
|
65
|
-
};
|
|
66
|
-
case "reasoning": return {
|
|
67
|
-
type: "reasoning",
|
|
68
|
-
text: part.text,
|
|
69
|
-
...part.unstable_summary !== void 0 ? { unstable_summary: part.unstable_summary } : void 0
|
|
70
|
-
};
|
|
71
|
-
case "source":
|
|
72
|
-
if (part.sourceType === "url") return {
|
|
73
|
-
type: "source",
|
|
74
|
-
sourceType: "url",
|
|
75
|
-
id: part.id,
|
|
76
|
-
url: part.url,
|
|
77
|
-
...part.title != null ? { title: part.title } : void 0,
|
|
78
|
-
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : void 0
|
|
79
|
-
};
|
|
80
|
-
return {
|
|
81
|
-
type: "source",
|
|
82
|
-
sourceType: "document",
|
|
83
|
-
id: part.id,
|
|
84
|
-
title: part.title,
|
|
85
|
-
mediaType: part.mediaType,
|
|
86
|
-
...part.filename != null ? { filename: part.filename } : void 0,
|
|
87
|
-
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : void 0
|
|
88
|
-
};
|
|
89
|
-
case "tool-call":
|
|
90
|
-
if (part.result !== void 0 && !isJSONValue(part.result)) console.warn(`tool-call result is not JSON! ${JSON.stringify(part)}`);
|
|
91
|
-
return {
|
|
92
|
-
type: "tool-call",
|
|
93
|
-
toolCallId: part.toolCallId,
|
|
94
|
-
toolName: part.toolName,
|
|
95
|
-
...JSON.stringify(part.args) === part.argsText ? { args: part.args } : { argsText: part.argsText },
|
|
96
|
-
...part.result !== void 0 ? { result: part.result } : void 0,
|
|
97
|
-
...part.isError ? { isError: true } : void 0,
|
|
98
|
-
...part.approval ? { approval: part.approval } : void 0
|
|
99
|
-
};
|
|
100
|
-
case "image": return {
|
|
101
|
-
type: "image",
|
|
102
|
-
image: part.image
|
|
103
|
-
};
|
|
104
|
-
case "file": return {
|
|
105
|
-
type: "file",
|
|
106
|
-
data: part.data,
|
|
107
|
-
mimeType: part.mimeType,
|
|
108
|
-
...part.filename ? { filename: part.filename } : void 0,
|
|
109
|
-
...part.sourceType ? { sourceType: part.sourceType } : void 0
|
|
110
|
-
};
|
|
111
|
-
default: throw new Error(`Message part type not supported by aui/v0: ${type}`);
|
|
112
|
-
}
|
|
113
|
-
}),
|
|
114
|
-
metadata: message.metadata,
|
|
115
|
-
...status ? { status } : void 0,
|
|
116
|
-
...attachments ? { attachments } : void 0
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
function auiV0Decode(cloudMessage) {
|
|
120
|
-
const payload = cloudMessage.content;
|
|
121
|
-
const message = fromThreadMessageLike({
|
|
122
|
-
id: cloudMessage.id,
|
|
123
|
-
createdAt: cloudMessage.created_at,
|
|
124
|
-
...payload
|
|
125
|
-
}, cloudMessage.id, {
|
|
126
|
-
type: "complete",
|
|
127
|
-
reason: "unknown"
|
|
128
|
-
});
|
|
129
|
-
return {
|
|
130
|
-
parentId: cloudMessage.parent_id,
|
|
131
|
-
message
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
//#endregion
|
|
135
|
-
export { auiV0Decode, auiV0Encode };
|
|
136
|
-
|
|
137
|
-
//# sourceMappingURL=auiV0.js.map
|