@assistant-ui/react 0.12.15 → 0.12.16

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 (72) 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 +1 -1
  39. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +1 -96
  40. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  41. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js +1 -110
  42. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
  43. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +1 -112
  44. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  45. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +1 -439
  46. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  47. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts +1 -12
  48. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts.map +1 -1
  49. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.js +1 -102
  50. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.js.map +1 -1
  51. package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts +1 -3
  52. package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +1 -1
  53. package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js +1 -46
  54. package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
  55. package/dist/utils/createActionButton.js +1 -1
  56. package/dist/utils/createActionButton.js.map +1 -1
  57. package/package.json +3 -3
  58. package/src/index.ts +1 -1
  59. package/src/internal.ts +1 -1
  60. package/src/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.ts +2 -784
  61. package/src/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.tsx +5 -43
  62. package/src/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.ts +2 -100
  63. package/src/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.ts +4 -580
  64. package/src/legacy-runtime/runtime-cores/external-store/createMessageConverter.ts +1 -76
  65. package/src/legacy-runtime/runtime-cores/external-store/external-message-converter.ts +4 -483
  66. package/src/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.ts +1 -27
  67. package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +1 -178
  68. package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +1 -529
  69. package/src/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.tsx +1 -152
  70. package/src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.ts +1 -80
  71. package/src/tests/BaseComposerRuntimeCore.test.ts +2 -3
  72. package/src/utils/createActionButton.tsx +1 -1
@@ -1,34 +1,2 @@
1
- import { ThreadMessageLike } from "./ThreadMessageLike.js";
2
- import { ToolExecutionStatus } from "../assistant-transport/useToolInvocations.js";
3
- import { ReadonlyJSONValue } from "assistant-stream/utils";
4
- import type { MessageTiming, ThreadMessage } from "@assistant-ui/core";
5
- export declare namespace useExternalMessageConverter {
6
- type Message = (ThreadMessageLike & {
7
- readonly convertConfig?: {
8
- readonly joinStrategy?: "concat-content" | "none";
9
- };
10
- }) | {
11
- role: "tool";
12
- toolCallId: string;
13
- toolName?: string | undefined;
14
- result: any;
15
- artifact?: any;
16
- isError?: boolean;
17
- messages?: readonly ThreadMessage[];
18
- };
19
- type Metadata = {
20
- readonly toolStatuses?: Record<string, ToolExecutionStatus>;
21
- readonly error?: ReadonlyJSONValue;
22
- readonly messageTiming?: Record<string, MessageTiming>;
23
- };
24
- type Callback<T> = (message: T, metadata: Metadata) => Message | Message[];
25
- }
26
- export declare const convertExternalMessages: <T extends WeakKey>(messages: T[], callback: useExternalMessageConverter.Callback<T>, isRunning: boolean, metadata: useExternalMessageConverter.Metadata) => ThreadMessage[];
27
- export declare const useExternalMessageConverter: <T extends WeakKey>({ callback, messages, isRunning, joinStrategy, metadata, }: {
28
- callback: useExternalMessageConverter.Callback<T>;
29
- messages: T[];
30
- isRunning: boolean;
31
- joinStrategy?: "concat-content" | "none" | undefined;
32
- metadata?: useExternalMessageConverter.Metadata | undefined;
33
- }) => ThreadMessage[];
1
+ export { useExternalMessageConverter, convertExternalMessages, } from "@assistant-ui/core/react";
34
2
  //# sourceMappingURL=external-message-converter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-message-converter.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/external-store/external-message-converter.ts"],"names":[],"mappings":"AASA,OAAO,EAAyB,iBAAiB,EAAE,+BAA4B;AAE/E,OAAO,EAAE,mBAAmB,EAAE,qDAAkD;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,KAAK,EACV,aAAa,EAEb,aAAa,EAEd,MAAM,oBAAoB,CAAC;AAE5B,yBAAiB,2BAA2B,CAAC;IAC3C,KAAY,OAAO,GACf,CAAC,iBAAiB,GAAG;QACnB,QAAQ,CAAC,aAAa,CAAC,EAAE;YACvB,QAAQ,CAAC,YAAY,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAC;SACnD,CAAC;KACH,CAAC,GACF;QACE,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,MAAM,EAAE,GAAG,CAAC;QACZ,QAAQ,CAAC,EAAE,GAAG,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;KACrC,CAAC;IAEN,KAAY,QAAQ,GAAG;QACrB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;QAC5D,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC;QACnC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;KACxD,CAAC;IAEF,KAAY,QAAQ,CAAC,CAAC,IAAI,CACxB,OAAO,EAAE,CAAC,EACV,QAAQ,EAAE,QAAQ,KACf,OAAO,GAAG,OAAO,EAAE,CAAC;CAC1B;AA2QD,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,OAAO,EACvD,UAAU,CAAC,EAAE,EACb,UAAU,2BAA2B,CAAC,QAAQ,CAAC,CAAC,CAAC,EACjD,WAAW,OAAO,EAClB,UAAU,2BAA2B,CAAC,QAAQ,oBA4C/C,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,CAAC,SAAS,OAAO,EAAE,4DAM5D;IACD,QAAQ,EAAE,2BAA2B,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAClD,QAAQ,EAAE,CAAC,EAAE,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAAC;IACrD,QAAQ,CAAC,EAAE,2BAA2B,CAAC,QAAQ,GAAG,SAAS,CAAC;CAC7D,oBAkGA,CAAC"}
1
+ {"version":3,"file":"external-message-converter.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/external-store/external-message-converter.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,0BAA0B,CAAC"}
@@ -1,309 +1,3 @@
1
1
  "use client";
2
- import { useMemo } from "react";
3
- import { ThreadMessageConverter } from "./ThreadMessageConverter.js";
4
- import { getExternalStoreMessages, symbolInnerMessage, bindExternalStoreMessage, } from "./getExternalStoreMessage.js";
5
- import { fromThreadMessageLike } from "./ThreadMessageLike.js";
6
- import { getAutoStatus, isAutoStatus } from "./auto-status.js";
7
- import { generateErrorMessageId } from "@assistant-ui/core/internal";
8
- const mergeInnerMessages = (existing, incoming) => ({
9
- [symbolInnerMessage]: [
10
- ...(existing[symbolInnerMessage] ?? []),
11
- ...(incoming[symbolInnerMessage] ?? []),
12
- ],
13
- });
14
- const joinExternalMessages = (messages) => {
15
- const assistantMessage = {
16
- role: "assistant",
17
- content: [],
18
- };
19
- for (const output of messages) {
20
- if (output.role === "tool") {
21
- const toolCallIdx = assistantMessage.content.findIndex((c) => c.type === "tool-call" && c.toolCallId === output.toolCallId);
22
- // Ignore orphaned tool results so one bad tool message does not
23
- // prevent rendering the rest of the conversation.
24
- if (toolCallIdx !== -1) {
25
- const toolCall = assistantMessage.content[toolCallIdx];
26
- if (output.toolName !== undefined) {
27
- if (toolCall.toolName !== output.toolName)
28
- throw new Error(`Tool call name ${output.toolCallId} ${output.toolName} does not match existing tool call ${toolCall.toolName}`);
29
- }
30
- assistantMessage.content[toolCallIdx] = {
31
- ...toolCall,
32
- ...{
33
- [symbolInnerMessage]: [
34
- ...(toolCall[symbolInnerMessage] ?? []),
35
- output,
36
- ],
37
- },
38
- result: output.result,
39
- artifact: output.artifact,
40
- isError: output.isError,
41
- messages: output.messages,
42
- };
43
- }
44
- }
45
- else {
46
- const role = output.role;
47
- const content = (typeof output.content === "string"
48
- ? [{ type: "text", text: output.content }]
49
- : output.content).map((c) => ({
50
- ...c,
51
- ...{ [symbolInnerMessage]: [output] },
52
- }));
53
- switch (role) {
54
- case "system":
55
- case "user":
56
- return {
57
- ...output,
58
- content,
59
- };
60
- case "assistant":
61
- if (assistantMessage.content.length === 0) {
62
- assistantMessage.id = output.id;
63
- assistantMessage.createdAt ??= output.createdAt;
64
- assistantMessage.status ??= output.status;
65
- if (output.attachments) {
66
- assistantMessage.attachments = [
67
- ...(assistantMessage.attachments ?? []),
68
- ...output.attachments,
69
- ];
70
- }
71
- if (output.metadata) {
72
- assistantMessage.metadata ??= {};
73
- if (output.metadata.unstable_state) {
74
- assistantMessage.metadata.unstable_state =
75
- output.metadata.unstable_state;
76
- }
77
- if (output.metadata.unstable_annotations) {
78
- assistantMessage.metadata.unstable_annotations = [
79
- ...(assistantMessage.metadata.unstable_annotations ?? []),
80
- ...output.metadata.unstable_annotations,
81
- ];
82
- }
83
- if (output.metadata.unstable_data) {
84
- assistantMessage.metadata.unstable_data = [
85
- ...(assistantMessage.metadata.unstable_data ?? []),
86
- ...output.metadata.unstable_data,
87
- ];
88
- }
89
- if (output.metadata.steps) {
90
- assistantMessage.metadata.steps = [
91
- ...(assistantMessage.metadata.steps ?? []),
92
- ...output.metadata.steps,
93
- ];
94
- }
95
- if (output.metadata.custom) {
96
- assistantMessage.metadata.custom = {
97
- ...(assistantMessage.metadata.custom ?? {}),
98
- ...output.metadata.custom,
99
- };
100
- }
101
- if (output.metadata.timing) {
102
- assistantMessage.metadata.timing = output.metadata.timing;
103
- }
104
- if (output.metadata.submittedFeedback) {
105
- assistantMessage.metadata.submittedFeedback =
106
- output.metadata.submittedFeedback;
107
- }
108
- }
109
- // TODO keep this in sync
110
- }
111
- // Add content parts, merging reasoning parts with same parentId
112
- for (const part of content) {
113
- if (part.type === "tool-call") {
114
- const existingIdx = assistantMessage.content.findIndex((c) => c.type === "tool-call" && c.toolCallId === part.toolCallId);
115
- if (existingIdx !== -1) {
116
- const existing = assistantMessage.content[existingIdx];
117
- assistantMessage.content[existingIdx] = {
118
- ...existing,
119
- ...part,
120
- ...mergeInnerMessages(existing, part),
121
- };
122
- continue;
123
- }
124
- }
125
- if (part.type === "reasoning" &&
126
- "parentId" in part &&
127
- part.parentId) {
128
- const existingIdx = assistantMessage.content.findIndex((c) => c.type === "reasoning" &&
129
- "parentId" in c &&
130
- c.parentId === part.parentId);
131
- if (existingIdx !== -1) {
132
- const existing = assistantMessage.content[existingIdx];
133
- assistantMessage.content[existingIdx] = {
134
- ...existing,
135
- text: `${existing.text}\n\n${part.text}`,
136
- ...mergeInnerMessages(existing, part),
137
- };
138
- continue;
139
- }
140
- }
141
- assistantMessage.content.push(part);
142
- }
143
- break;
144
- default: {
145
- const unsupportedRole = role;
146
- throw new Error(`Unknown message role: ${unsupportedRole}`);
147
- }
148
- }
149
- }
150
- }
151
- return assistantMessage;
152
- };
153
- const chunkExternalMessages = (callbackResults, joinStrategy) => {
154
- const results = [];
155
- let isAssistant = false;
156
- let pendingNone = false; // true if the previous assistant message had joinStrategy "none"
157
- let inputs = [];
158
- let outputs = [];
159
- const flush = () => {
160
- if (outputs.length) {
161
- results.push({
162
- inputs,
163
- outputs,
164
- });
165
- }
166
- inputs = [];
167
- outputs = [];
168
- isAssistant = false;
169
- pendingNone = false;
170
- };
171
- for (const callbackResult of callbackResults) {
172
- for (const output of callbackResult.outputs) {
173
- if ((pendingNone && output.role !== "tool") ||
174
- !isAssistant ||
175
- output.role === "user" ||
176
- output.role === "system") {
177
- flush();
178
- }
179
- isAssistant = output.role === "assistant" || output.role === "tool";
180
- if (inputs.at(-1) !== callbackResult.input) {
181
- inputs.push(callbackResult.input);
182
- }
183
- outputs.push(output);
184
- if (output.role === "assistant" &&
185
- (output.convertConfig?.joinStrategy === "none" ||
186
- joinStrategy === "none")) {
187
- pendingNone = true;
188
- }
189
- }
190
- }
191
- flush();
192
- return results;
193
- };
194
- function createErrorAssistantMessage(error) {
195
- const msg = {
196
- id: generateErrorMessageId(),
197
- role: "assistant",
198
- content: [],
199
- status: { type: "incomplete", reason: "error", error },
200
- createdAt: new Date(),
201
- metadata: {
202
- unstable_state: null,
203
- unstable_annotations: [],
204
- unstable_data: [],
205
- custom: {},
206
- steps: [],
207
- },
208
- };
209
- bindExternalStoreMessage(msg, []);
210
- return msg;
211
- }
212
- export const convertExternalMessages = (messages, callback, isRunning, metadata) => {
213
- const callbackResults = [];
214
- for (const message of messages) {
215
- const output = callback(message, metadata);
216
- const outputs = Array.isArray(output) ? output : [output];
217
- const result = { input: message, outputs };
218
- callbackResults.push(result);
219
- }
220
- const chunks = chunkExternalMessages(callbackResults);
221
- const result = chunks.map((message, idx) => {
222
- const isLast = idx === chunks.length - 1;
223
- const joined = joinExternalMessages(message.outputs);
224
- const hasPendingToolCalls = typeof joined.content === "object" &&
225
- joined.content.some((c) => c.type === "tool-call" && c.result === undefined);
226
- const autoStatus = getAutoStatus(isLast, isRunning, hasPendingToolCalls, hasPendingToolCalls, isLast ? metadata.error : undefined);
227
- const newMessage = fromThreadMessageLike(joined, idx.toString(), autoStatus);
228
- bindExternalStoreMessage(newMessage, message.inputs);
229
- return newMessage;
230
- });
231
- if (metadata.error) {
232
- const lastMessage = result.at(-1);
233
- if (!lastMessage || lastMessage.role !== "assistant") {
234
- result.push(createErrorAssistantMessage(metadata.error));
235
- }
236
- }
237
- return result;
238
- };
239
- export const useExternalMessageConverter = ({ callback, messages, isRunning, joinStrategy, metadata, }) => {
240
- const state = useMemo(() => ({
241
- metadata: metadata ?? {},
242
- callback,
243
- callbackCache: new WeakMap(),
244
- chunkCache: new WeakMap(),
245
- converterCache: new ThreadMessageConverter(),
246
- }), [callback, metadata]);
247
- return useMemo(() => {
248
- const callbackResults = [];
249
- for (const message of messages) {
250
- let result = state.callbackCache.get(message);
251
- if (!result) {
252
- const output = state.callback(message, state.metadata);
253
- const outputs = Array.isArray(output) ? output : [output];
254
- result = { input: message, outputs };
255
- state.callbackCache.set(message, result);
256
- }
257
- callbackResults.push(result);
258
- }
259
- const chunks = chunkExternalMessages(callbackResults, joinStrategy).map((m) => {
260
- const key = m.outputs[0];
261
- if (!key)
262
- return m;
263
- const cached = state.chunkCache.get(key);
264
- if (cached && shallowArrayEqual(cached.outputs, m.outputs))
265
- return cached;
266
- state.chunkCache.set(key, m);
267
- return m;
268
- });
269
- const threadMessages = state.converterCache.convertMessages(chunks, (cache, message, idx) => {
270
- const isLast = idx === chunks.length - 1;
271
- const joined = joinExternalMessages(message.outputs);
272
- const hasSuspendedToolCalls = typeof joined.content === "object" &&
273
- joined.content.some((c) => c.type === "tool-call" && c.result === undefined);
274
- const hasPendingToolCalls = typeof joined.content === "object" &&
275
- joined.content.some((c) => c.type === "tool-call" && c.result === undefined);
276
- const autoStatus = getAutoStatus(isLast, isRunning, hasSuspendedToolCalls, hasPendingToolCalls, isLast ? state.metadata.error : undefined);
277
- if (cache &&
278
- (cache.role !== "assistant" ||
279
- !isAutoStatus(cache.status) ||
280
- cache.status === autoStatus)) {
281
- const inputs = getExternalStoreMessages(cache);
282
- if (shallowArrayEqual(inputs, message.inputs)) {
283
- return cache;
284
- }
285
- }
286
- const newMessage = fromThreadMessageLike(joined, idx.toString(), autoStatus);
287
- bindExternalStoreMessage(newMessage, message.inputs);
288
- return newMessage;
289
- });
290
- bindExternalStoreMessage(threadMessages, messages);
291
- if (state.metadata.error) {
292
- const lastMessage = threadMessages.at(-1);
293
- if (!lastMessage || lastMessage.role !== "assistant") {
294
- threadMessages.push(createErrorAssistantMessage(state.metadata.error));
295
- }
296
- }
297
- return threadMessages;
298
- }, [state, messages, isRunning, joinStrategy]);
299
- };
300
- const shallowArrayEqual = (a, b) => {
301
- if (a.length !== b.length)
302
- return false;
303
- for (let i = 0; i < a.length; i++) {
304
- if (a[i] !== b[i])
305
- return false;
306
- }
307
- return true;
308
- };
2
+ export { useExternalMessageConverter, convertExternalMessages, } from "@assistant-ui/core/react";
309
3
  //# sourceMappingURL=external-message-converter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-message-converter.js","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/external-store/external-message-converter.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,oCAAiC;AAClE,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,GACzB,qCAAkC;AACnC,OAAO,EAAE,qBAAqB,EAAqB,+BAA4B;AAC/E,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,yBAAsB;AAG5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAmDrE,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAE,QAAgB,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC,kBAAkB,CAAC,EAAE;QACpB,GAAG,CAAE,QAAgB,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC;QAChD,GAAG,CAAE,QAAgB,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC;KACjD;CACF,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAAG,CAC3B,QAAwD,EACrC,EAAE;IACrB,MAAM,gBAAgB,GAGlB;QACF,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AAC;gBACrD,cAAc,CAAC,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,CAAY,EAAE,CAAY,EAAE,EAAE;IACvD,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;IAClC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
1
+ {"version":3,"file":"external-message-converter.js","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/external-store/external-message-converter.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,0BAA0B,CAAC"}
@@ -1,4 +1,2 @@
1
- import { ExternalStoreAdapter } from "./ExternalStoreAdapter.js";
2
- import { AssistantRuntime } from "../../runtime/AssistantRuntime.js";
3
- export declare const useExternalStoreRuntime: <T>(store: ExternalStoreAdapter<T>) => AssistantRuntime;
1
+ export { useExternalStoreRuntime } from "@assistant-ui/core/react";
4
2
  //# sourceMappingURL=useExternalStoreRuntime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useExternalStoreRuntime.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,kCAA+B;AAC9D,OAAO,EACL,gBAAgB,EAEjB,0CAAuC;AAGxC,eAAO,MAAM,uBAAuB,GAAI,CAAC,EACvC,OAAO,oBAAoB,CAAC,CAAC,CAAC,KAC7B,gBAeF,CAAC"}
1
+ {"version":3,"file":"useExternalStoreRuntime.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,19 +1,3 @@
1
1
  "use client";
2
- import { useEffect, useMemo, useState } from "react";
3
- import { ExternalStoreRuntimeCore } from "./ExternalStoreRuntimeCore.js";
4
- import { AssistantRuntimeImpl, } from "../../runtime/AssistantRuntime.js";
5
- import { useRuntimeAdapters } from "../adapters/RuntimeAdapterProvider.js";
6
- export const useExternalStoreRuntime = (store) => {
7
- const [runtime] = useState(() => new ExternalStoreRuntimeCore(store));
8
- useEffect(() => {
9
- runtime.setAdapter(store);
10
- });
11
- const { modelContext } = useRuntimeAdapters() ?? {};
12
- useEffect(() => {
13
- if (!modelContext)
14
- return undefined;
15
- return runtime.registerModelContextProvider(modelContext);
16
- }, [modelContext, runtime]);
17
- return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);
18
- };
2
+ export { useExternalStoreRuntime } from "@assistant-ui/core/react";
19
3
  //# sourceMappingURL=useExternalStoreRuntime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useExternalStoreRuntime.js","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,sCAAmC;AAEtE,OAAO,EAEL,oBAAoB,GACrB,0CAAuC;AACxC,OAAO,EAAE,kBAAkB,EAAE,8CAA2C;AAExE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,KAA8B,EACZ,EAAE;IACpB,MAAM,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;IAEtE,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,MAAM,EAAE,YAAY,EAAE,GAAG,kBAAkB,EAAE,IAAI,EAAE,CAAC;IAEpD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,YAAY;YAAE,OAAO,SAAS,CAAC;QACpC,OAAO,OAAO,CAAC,4BAA4B,CAAC,YAAY,CAAC,CAAC;IAC5D,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;IAE5B,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC"}
1
+ {"version":3,"file":"useExternalStoreRuntime.js","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -23,6 +23,6 @@ export declare const splitLocalRuntimeOptions: <T extends LocalRuntimeOptions>(o
23
23
  }, "chatModel"> | undefined;
24
24
  unstable_humanToolNames: string[] | undefined;
25
25
  };
26
- otherOptions: Omit<T, "adapters" | "maxSteps" | "unstable_humanToolNames" | "cloud" | "initialMessages">;
26
+ otherOptions: Omit<T, "cloud" | "adapters" | "maxSteps" | "unstable_humanToolNames" | "initialMessages">;
27
27
  };
28
28
  //# sourceMappingURL=LocalRuntimeOptions.d.ts.map
@@ -1,97 +1,2 @@
1
- import { FC, PropsWithChildren, ComponentType } from "react";
2
- import { ThreadListRuntimeCore } from "../../../internal.js";
3
- import { BaseSubscribable } from "@assistant-ui/core/internal";
4
- import { AssistantRuntime } from "../../runtime/index.js";
5
- type RemoteThreadListHook = () => AssistantRuntime;
6
- export declare class RemoteThreadListHookInstanceManager extends BaseSubscribable {
7
- private useRuntimeHook;
8
- private instances;
9
- private useAliveThreadsKeysChanged;
10
- private parent;
11
- constructor(runtimeHook: RemoteThreadListHook, parent: ThreadListRuntimeCore);
12
- startThreadRuntime(threadId: string): Promise<Readonly<{
13
- getMessageById: (messageId: string) => {
14
- parentId: string | null;
15
- message: import("@assistant-ui/core").ThreadMessage;
16
- index: number;
17
- } | undefined;
18
- getBranches: (messageId: string) => readonly string[];
19
- switchToBranch: (branchId: string) => void;
20
- append: (message: import("@assistant-ui/core").AppendMessage) => void;
21
- startRun: (config: import("@assistant-ui/core").StartRunConfig) => void;
22
- resumeRun: (config: import("@assistant-ui/core").ResumeRunConfig) => void;
23
- cancelRun: () => void;
24
- addToolResult: (options: import("@assistant-ui/core").AddToolResultOptions) => void;
25
- resumeToolCall: (options: import("@assistant-ui/core").ResumeToolCallOptions) => void;
26
- speak: (messageId: string) => void;
27
- stopSpeaking: () => void;
28
- submitFeedback: (feedback: import("@assistant-ui/core").SubmitFeedbackOptions) => void;
29
- getModelContext: () => import("@assistant-ui/core").ModelContext;
30
- composer: import("@assistant-ui/core").ThreadComposerRuntimeCore;
31
- getEditComposer: (messageId: string) => import("@assistant-ui/core").ComposerRuntimeCore | undefined;
32
- beginEdit: (messageId: string) => void;
33
- speech: import("@assistant-ui/core").SpeechState | undefined;
34
- capabilities: Readonly<import("@assistant-ui/core").RuntimeCapabilities>;
35
- isDisabled: boolean;
36
- isLoading: boolean;
37
- messages: readonly import("@assistant-ui/core").ThreadMessage[];
38
- state: import("assistant-stream/utils").ReadonlyJSONValue;
39
- suggestions: readonly import("@assistant-ui/core").ThreadSuggestion[];
40
- extras: unknown;
41
- subscribe: (callback: () => void) => import("@assistant-ui/core").Unsubscribe;
42
- import(repository: import("@assistant-ui/core").ExportedMessageRepository): void;
43
- export(): import("@assistant-ui/core").ExportedMessageRepository;
44
- exportExternalState(): any;
45
- importExternalState(state: any): void;
46
- reset(initialMessages?: readonly import("@assistant-ui/core").ThreadMessageLike[]): void;
47
- unstable_on(event: import("@assistant-ui/core").ThreadRuntimeEventType, callback: () => void): import("@assistant-ui/core").Unsubscribe;
48
- unstable_loadExternalState: (state: any) => void;
49
- }>>;
50
- getThreadRuntimeCore(threadId: string): Readonly<{
51
- getMessageById: (messageId: string) => {
52
- parentId: string | null;
53
- message: import("@assistant-ui/core").ThreadMessage;
54
- index: number;
55
- } | undefined;
56
- getBranches: (messageId: string) => readonly string[];
57
- switchToBranch: (branchId: string) => void;
58
- append: (message: import("@assistant-ui/core").AppendMessage) => void;
59
- startRun: (config: import("@assistant-ui/core").StartRunConfig) => void;
60
- resumeRun: (config: import("@assistant-ui/core").ResumeRunConfig) => void;
61
- cancelRun: () => void;
62
- addToolResult: (options: import("@assistant-ui/core").AddToolResultOptions) => void;
63
- resumeToolCall: (options: import("@assistant-ui/core").ResumeToolCallOptions) => void;
64
- speak: (messageId: string) => void;
65
- stopSpeaking: () => void;
66
- submitFeedback: (feedback: import("@assistant-ui/core").SubmitFeedbackOptions) => void;
67
- getModelContext: () => import("@assistant-ui/core").ModelContext;
68
- composer: import("@assistant-ui/core").ThreadComposerRuntimeCore;
69
- getEditComposer: (messageId: string) => import("@assistant-ui/core").ComposerRuntimeCore | undefined;
70
- beginEdit: (messageId: string) => void;
71
- speech: import("@assistant-ui/core").SpeechState | undefined;
72
- capabilities: Readonly<import("@assistant-ui/core").RuntimeCapabilities>;
73
- isDisabled: boolean;
74
- isLoading: boolean;
75
- messages: readonly import("@assistant-ui/core").ThreadMessage[];
76
- state: import("assistant-stream/utils").ReadonlyJSONValue;
77
- suggestions: readonly import("@assistant-ui/core").ThreadSuggestion[];
78
- extras: unknown;
79
- subscribe: (callback: () => void) => import("@assistant-ui/core").Unsubscribe;
80
- import(repository: import("@assistant-ui/core").ExportedMessageRepository): void;
81
- export(): import("@assistant-ui/core").ExportedMessageRepository;
82
- exportExternalState(): any;
83
- importExternalState(state: any): void;
84
- reset(initialMessages?: readonly import("@assistant-ui/core").ThreadMessageLike[]): void;
85
- unstable_on(event: import("@assistant-ui/core").ThreadRuntimeEventType, callback: () => void): import("@assistant-ui/core").Unsubscribe;
86
- unstable_loadExternalState: (state: any) => void;
87
- }> | undefined;
88
- stopThreadRuntime(threadId: string): void;
89
- setRuntimeHook(newRuntimeHook: RemoteThreadListHook): void;
90
- private _InnerActiveThreadProvider;
91
- private _OuterActiveThreadProvider;
92
- __internal_RenderThreadRuntimes: FC<{
93
- provider: ComponentType<PropsWithChildren>;
94
- }>;
95
- }
96
- export {};
1
+ export { RemoteThreadListHookInstanceManager } from "@assistant-ui/core/react";
97
2
  //# sourceMappingURL=RemoteThreadListHookInstanceManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RemoteThreadListHookInstanceManager.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,EAAE,EAKF,iBAAiB,EACjB,aAAa,EAEd,MAAM,OAAO,CAAC;AAIf,OAAO,EACL,qBAAqB,EAGtB,6BAA0B;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,+BAAsB;AAGjD,KAAK,oBAAoB,GAAG,MAAM,gBAAgB,CAAC;AAKnD,qBAAa,mCAAoC,SAAQ,gBAAgB;IACvE,OAAO,CAAC,cAAc,CAEpB;IACF,OAAO,CAAC,SAAS,CAAmD;IACpE,OAAO,CAAC,0BAA0B,CAAsB;IACxD,OAAO,CAAC,MAAM,CAAwB;gBAGpC,WAAW,EAAE,oBAAoB,EACjC,MAAM,EAAE,qBAAqB;IAOxB,kBAAkB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwBnC,oBAAoB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAMrC,iBAAiB,CAAC,QAAQ,EAAE,MAAM;IAKlC,cAAc,CAAC,cAAc,EAAE,oBAAoB;IAO1D,OAAO,CAAC,0BAA0B,CA0DhC;IAEF,OAAO,CAAC,0BAA0B,CAgB/B;IAEI,+BAA+B,EAAE,EAAE,CAAC;QACzC,QAAQ,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;KAC5C,CAAC,CAUA;CACH"}
1
+ {"version":3,"file":"RemoteThreadListHookInstanceManager.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,mCAAmC,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,112 +1,3 @@
1
1
  "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { useCallback, useRef, useEffect, memo, useMemo, } from "react";
4
- import { create } from "zustand";
5
- import { useAui } from "@assistant-ui/store";
6
- import { ThreadListItemRuntimeProvider } from "../../../context/providers/index.js";
7
- import { BaseSubscribable } from "@assistant-ui/core/internal";
8
- import { ThreadListRuntimeImpl } from "../../runtime/ThreadListRuntime.js";
9
- export class RemoteThreadListHookInstanceManager extends BaseSubscribable {
10
- useRuntimeHook;
11
- instances = new Map();
12
- useAliveThreadsKeysChanged = create(() => ({}));
13
- parent;
14
- constructor(runtimeHook, parent) {
15
- super();
16
- this.parent = parent;
17
- this.useRuntimeHook = create(() => ({ useRuntime: runtimeHook }));
18
- }
19
- startThreadRuntime(threadId) {
20
- if (!this.instances.has(threadId)) {
21
- this.instances.set(threadId, {});
22
- this.useAliveThreadsKeysChanged.setState({}, true);
23
- }
24
- return new Promise((resolve, reject) => {
25
- const callback = () => {
26
- const instance = this.instances.get(threadId);
27
- if (!instance) {
28
- dispose();
29
- reject(new Error("Thread was deleted before runtime was started"));
30
- }
31
- else if (!instance.runtime) {
32
- return; // misc update
33
- }
34
- else {
35
- dispose();
36
- resolve(instance.runtime);
37
- }
38
- };
39
- const dispose = this.subscribe(callback);
40
- callback();
41
- });
42
- }
43
- getThreadRuntimeCore(threadId) {
44
- const instance = this.instances.get(threadId);
45
- if (!instance)
46
- return undefined;
47
- return instance.runtime;
48
- }
49
- stopThreadRuntime(threadId) {
50
- this.instances.delete(threadId);
51
- this.useAliveThreadsKeysChanged.setState({}, true);
52
- }
53
- setRuntimeHook(newRuntimeHook) {
54
- const prevRuntimeHook = this.useRuntimeHook.getState().useRuntime;
55
- if (prevRuntimeHook !== newRuntimeHook) {
56
- this.useRuntimeHook.setState({ useRuntime: newRuntimeHook }, true);
57
- }
58
- }
59
- _InnerActiveThreadProvider = ({ threadId }) => {
60
- const { useRuntime } = this.useRuntimeHook();
61
- const runtime = useRuntime();
62
- const threadBinding = runtime.thread
63
- .__internal_threadBinding;
64
- const updateRuntime = useCallback(() => {
65
- const aliveThread = this.instances.get(threadId);
66
- if (!aliveThread)
67
- throw new Error("Thread not found. This is a bug in assistant-ui.");
68
- aliveThread.runtime = threadBinding.getState();
69
- this._notifySubscribers();
70
- }, [threadId, threadBinding]);
71
- const isMounted = useRef(false);
72
- if (!isMounted.current) {
73
- updateRuntime();
74
- }
75
- useEffect(() => {
76
- isMounted.current = true;
77
- updateRuntime();
78
- return threadBinding.outerSubscribe(updateRuntime);
79
- }, [threadBinding, updateRuntime]);
80
- const aui = useAui();
81
- const initPromiseRef = useRef(undefined);
82
- useEffect(() => {
83
- const runtimeCore = threadBinding.getState();
84
- const setGetInitializePromise = runtimeCore["__internal_setGetInitializePromise"];
85
- if (typeof setGetInitializePromise === "function") {
86
- setGetInitializePromise.call(runtimeCore, () => initPromiseRef.current);
87
- }
88
- }, [threadBinding]);
89
- useEffect(() => {
90
- return runtime.threads.main.unstable_on("initialize", () => {
91
- const state = aui.threadListItem().getState();
92
- if (state.status === "new") {
93
- initPromiseRef.current = aui.threadListItem().initialize();
94
- const dispose = runtime.thread.unstable_on("runEnd", () => {
95
- dispose();
96
- aui.threadListItem().generateTitle();
97
- });
98
- }
99
- });
100
- }, [runtime, aui]);
101
- return null;
102
- };
103
- _OuterActiveThreadProvider = memo(({ threadId, provider: Provider }) => {
104
- const runtime = useMemo(() => new ThreadListRuntimeImpl(this.parent).getItemById(threadId), [threadId]);
105
- return (_jsx(ThreadListItemRuntimeProvider, { runtime: runtime, children: _jsx(Provider, { children: _jsx(this._InnerActiveThreadProvider, { threadId: threadId }) }) }));
106
- });
107
- __internal_RenderThreadRuntimes = ({ provider }) => {
108
- this.useAliveThreadsKeysChanged(); // trigger re-render on alive threads change
109
- return Array.from(this.instances.keys()).map((threadId) => (_jsx(this._OuterActiveThreadProvider, { threadId: threadId, provider: provider }, threadId)));
110
- };
111
- }
2
+ export { RemoteThreadListHookInstanceManager } from "@assistant-ui/core/react";
112
3
  //# sourceMappingURL=RemoteThreadListHookInstanceManager.js.map