@assistant-ui/react 0.8.20 → 0.9.0
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/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js +3 -1
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.mjs +3 -1
- package/dist/api/ThreadRuntime.mjs.map +1 -1
- package/dist/cloud/AssistantCloudRuns.d.ts +2 -2
- package/dist/cloud/AssistantCloudRuns.d.ts.map +1 -1
- package/dist/cloud/AssistantCloudRuns.js.map +1 -1
- package/dist/cloud/AssistantCloudRuns.mjs.map +1 -1
- package/dist/cloud/auiV0.d.ts +1 -2
- package/dist/cloud/auiV0.d.ts.map +1 -1
- package/dist/cloud/auiV0.js.map +1 -1
- package/dist/cloud/auiV0.mjs.map +1 -1
- package/dist/context/react/AttachmentContext.d.ts +108 -108
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +4 -4
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +3 -3
- package/dist/internal.mjs.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js +3 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs +3 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.js +2 -2
- package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.mjs +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
- package/dist/runtimes/index.d.ts +1 -2
- package/dist/runtimes/index.d.ts.map +1 -1
- package/dist/runtimes/index.js +6 -5
- package/dist/runtimes/index.js.map +1 -1
- package/dist/runtimes/index.mjs +7 -3
- package/dist/runtimes/index.mjs.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js +3 -3
- package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +4 -4
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/cloud.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/cloud.js +2 -2
- package/dist/runtimes/remote-thread-list/adapter/cloud.js.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/cloud.mjs +2 -2
- package/dist/runtimes/remote-thread-list/adapter/cloud.mjs.map +1 -1
- package/dist/runtimes/{edge/streams → streams}/toolResultStream.d.ts +1 -1
- package/dist/runtimes/streams/toolResultStream.d.ts.map +1 -0
- package/dist/runtimes/{edge/streams → streams}/toolResultStream.js +1 -1
- package/dist/runtimes/streams/toolResultStream.js.map +1 -0
- package/dist/runtimes/{edge/streams → streams}/toolResultStream.mjs +1 -1
- package/dist/runtimes/streams/toolResultStream.mjs.map +1 -0
- package/dist/runtimes/utils/MessageRepository.d.ts +2 -2
- package/dist/runtimes/utils/MessageRepository.d.ts.map +1 -1
- package/dist/runtimes/utils/MessageRepository.js +1 -5
- package/dist/runtimes/utils/MessageRepository.js.map +1 -1
- package/dist/runtimes/utils/MessageRepository.mjs +1 -5
- package/dist/runtimes/utils/MessageRepository.mjs.map +1 -1
- package/dist/types/AssistantTypes.d.ts +3 -60
- package/dist/types/AssistantTypes.d.ts.map +1 -1
- package/dist/types/AssistantTypes.js.map +1 -1
- package/dist/types/AttachmentTypes.d.ts +3 -3
- package/dist/types/AttachmentTypes.d.ts.map +1 -1
- package/dist/types/AttachmentTypes.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +2 -8
- package/src/api/ThreadRuntime.ts +2 -0
- package/src/cloud/AssistantCloudRuns.tsx +2 -2
- package/src/cloud/auiV0.ts +1 -2
- package/src/index.ts +0 -2
- package/src/internal.ts +1 -1
- package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +2 -0
- package/src/runtimes/external-store/ThreadMessageLike.tsx +1 -1
- package/src/runtimes/index.ts +4 -2
- package/src/runtimes/local/LocalThreadRuntimeCore.tsx +4 -4
- package/src/runtimes/remote-thread-list/adapter/cloud.tsx +1 -2
- package/src/runtimes/{edge/streams → streams}/toolResultStream.ts +1 -1
- package/src/runtimes/utils/MessageRepository.tsx +3 -7
- package/src/tests/MessageRepository.test.ts +7 -10
- package/src/types/AssistantTypes.ts +3 -81
- package/src/types/AttachmentTypes.ts +3 -3
- package/src/types/index.ts +0 -9
- package/dist/edge.d.ts +0 -2
- package/dist/edge.d.ts.map +0 -1
- package/dist/edge.js +0 -33
- package/dist/edge.js.map +0 -1
- package/dist/edge.mjs +0 -10
- package/dist/edge.mjs.map +0 -1
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.d.ts +0 -9
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.d.ts.map +0 -1
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.js +0 -58
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.js.map +0 -1
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.mjs +0 -35
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.mjs.map +0 -1
- package/dist/runtimes/dangerous-in-browser/index.d.ts +0 -2
- package/dist/runtimes/dangerous-in-browser/index.d.ts.map +0 -1
- package/dist/runtimes/dangerous-in-browser/index.js +0 -31
- package/dist/runtimes/dangerous-in-browser/index.js.map +0 -1
- package/dist/runtimes/dangerous-in-browser/index.mjs +0 -8
- package/dist/runtimes/dangerous-in-browser/index.mjs.map +0 -1
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.d.ts +0 -5
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.d.ts.map +0 -1
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.js +0 -40
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.js.map +0 -1
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.mjs +0 -18
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.mjs.map +0 -1
- package/dist/runtimes/edge/EdgeModelAdapter.d.ts +0 -48
- package/dist/runtimes/edge/EdgeModelAdapter.d.ts.map +0 -1
- package/dist/runtimes/edge/EdgeModelAdapter.js +0 -127
- package/dist/runtimes/edge/EdgeModelAdapter.js.map +0 -1
- package/dist/runtimes/edge/EdgeModelAdapter.mjs +0 -94
- package/dist/runtimes/edge/EdgeModelAdapter.mjs.map +0 -1
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.d.ts +0 -345
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.d.ts.map +0 -1
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.js +0 -106
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.js.map +0 -1
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.mjs +0 -84
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.mjs.map +0 -1
- package/dist/runtimes/edge/converters/fromCoreMessage.d.ts +0 -8
- package/dist/runtimes/edge/converters/fromCoreMessage.d.ts.map +0 -1
- package/dist/runtimes/edge/converters/fromCoreMessage.js +0 -89
- package/dist/runtimes/edge/converters/fromCoreMessage.js.map +0 -1
- package/dist/runtimes/edge/converters/fromCoreMessage.mjs +0 -63
- package/dist/runtimes/edge/converters/fromCoreMessage.mjs.map +0 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.d.ts +0 -8
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.d.ts.map +0 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.js +0 -149
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.js.map +0 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.mjs +0 -124
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.mjs.map +0 -1
- package/dist/runtimes/edge/converters/fromLanguageModelTools.d.ts +0 -4
- package/dist/runtimes/edge/converters/fromLanguageModelTools.d.ts.map +0 -1
- package/dist/runtimes/edge/converters/fromLanguageModelTools.js +0 -41
- package/dist/runtimes/edge/converters/fromLanguageModelTools.js.map +0 -1
- package/dist/runtimes/edge/converters/fromLanguageModelTools.mjs +0 -16
- package/dist/runtimes/edge/converters/fromLanguageModelTools.mjs.map +0 -1
- package/dist/runtimes/edge/converters/index.d.ts +0 -35
- package/dist/runtimes/edge/converters/index.d.ts.map +0 -1
- package/dist/runtimes/edge/converters/index.js +0 -50
- package/dist/runtimes/edge/converters/index.js.map +0 -1
- package/dist/runtimes/edge/converters/index.mjs +0 -24
- package/dist/runtimes/edge/converters/index.mjs.map +0 -1
- package/dist/runtimes/edge/converters/toCoreMessages.d.ts +0 -12
- package/dist/runtimes/edge/converters/toCoreMessages.d.ts.map +0 -1
- package/dist/runtimes/edge/converters/toCoreMessages.js +0 -74
- package/dist/runtimes/edge/converters/toCoreMessages.js.map +0 -1
- package/dist/runtimes/edge/converters/toCoreMessages.mjs +0 -48
- package/dist/runtimes/edge/converters/toCoreMessages.mjs.map +0 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.d.ts +0 -6
- package/dist/runtimes/edge/converters/toLanguageModelMessages.d.ts.map +0 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.js +0 -168
- package/dist/runtimes/edge/converters/toLanguageModelMessages.js.map +0 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs +0 -143
- package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs.map +0 -1
- package/dist/runtimes/edge/converters/toLanguageModelTools.d.ts +0 -4
- package/dist/runtimes/edge/converters/toLanguageModelTools.d.ts.map +0 -1
- package/dist/runtimes/edge/converters/toLanguageModelTools.js +0 -50
- package/dist/runtimes/edge/converters/toLanguageModelTools.js.map +0 -1
- package/dist/runtimes/edge/converters/toLanguageModelTools.mjs +0 -15
- package/dist/runtimes/edge/converters/toLanguageModelTools.mjs.map +0 -1
- package/dist/runtimes/edge/createEdgeRuntimeAPI.d.ts +0 -36
- package/dist/runtimes/edge/createEdgeRuntimeAPI.d.ts.map +0 -1
- package/dist/runtimes/edge/createEdgeRuntimeAPI.js +0 -179
- package/dist/runtimes/edge/createEdgeRuntimeAPI.js.map +0 -1
- package/dist/runtimes/edge/createEdgeRuntimeAPI.mjs +0 -156
- package/dist/runtimes/edge/createEdgeRuntimeAPI.mjs.map +0 -1
- package/dist/runtimes/edge/index.d.ts +0 -6
- package/dist/runtimes/edge/index.d.ts.map +0 -1
- package/dist/runtimes/edge/index.js +0 -40
- package/dist/runtimes/edge/index.js.map +0 -1
- package/dist/runtimes/edge/index.mjs +0 -11
- package/dist/runtimes/edge/index.mjs.map +0 -1
- package/dist/runtimes/edge/streams/toolResultStream.d.ts.map +0 -1
- package/dist/runtimes/edge/streams/toolResultStream.js.map +0 -1
- package/dist/runtimes/edge/streams/toolResultStream.mjs.map +0 -1
- package/dist/runtimes/edge/useEdgeRuntime.d.ts +0 -5
- package/dist/runtimes/edge/useEdgeRuntime.d.ts.map +0 -1
- package/dist/runtimes/edge/useEdgeRuntime.js +0 -41
- package/dist/runtimes/edge/useEdgeRuntime.js.map +0 -1
- package/dist/runtimes/edge/useEdgeRuntime.mjs +0 -17
- package/dist/runtimes/edge/useEdgeRuntime.mjs.map +0 -1
- package/dist/utils/json/parse-partial-json.d.ts +0 -4
- package/dist/utils/json/parse-partial-json.d.ts.map +0 -1
- package/dist/utils/json/parse-partial-json.js +0 -90
- package/dist/utils/json/parse-partial-json.js.map +0 -1
- package/dist/utils/json/parse-partial-json.mjs +0 -54
- package/dist/utils/json/parse-partial-json.mjs.map +0 -1
- package/edge/README.md +0 -1
- package/edge/package.json +0 -5
- package/src/edge.ts +0 -4
- package/src/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.ts +0 -42
- package/src/runtimes/dangerous-in-browser/index.ts +0 -4
- package/src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts +0 -21
- package/src/runtimes/edge/EdgeModelAdapter.ts +0 -188
- package/src/runtimes/edge/EdgeRuntimeRequestOptions.ts +0 -109
- package/src/runtimes/edge/converters/fromCoreMessage.ts +0 -76
- package/src/runtimes/edge/converters/fromLanguageModelMessages.ts +0 -149
- package/src/runtimes/edge/converters/fromLanguageModelTools.ts +0 -16
- package/src/runtimes/edge/converters/index.ts +0 -41
- package/src/runtimes/edge/converters/toCoreMessages.ts +0 -64
- package/src/runtimes/edge/converters/toLanguageModelMessages.ts +0 -184
- package/src/runtimes/edge/converters/toLanguageModelTools.ts +0 -18
- package/src/runtimes/edge/createEdgeRuntimeAPI.ts +0 -234
- package/src/runtimes/edge/index.ts +0 -7
- package/src/runtimes/edge/useEdgeRuntime.ts +0 -17
- package/src/utils/json/parse-partial-json.ts +0 -74
@@ -1,6 +1,6 @@
|
|
1
1
|
import { CompleteAttachment } from "./AttachmentTypes";
|
2
2
|
import { ReadonlyJSONObject, ReadonlyJSONValue } from "../utils/json/json-value";
|
3
|
-
export type MessageRole = "
|
3
|
+
export type MessageRole = ThreadMessage["role"];
|
4
4
|
export type TextContentPart = {
|
5
5
|
readonly type: "text";
|
6
6
|
readonly text: string;
|
@@ -32,53 +32,13 @@ export type Unstable_AudioContentPart = {
|
|
32
32
|
readonly format: "mp3" | "wav";
|
33
33
|
};
|
34
34
|
};
|
35
|
-
|
36
|
-
* @deprecated UI content parts are deprecated and will be removed in v0.8.0.
|
37
|
-
* Migration guide for external-store users using UI content parts:
|
38
|
-
* If you must, store UI elements on your external store messages, update your
|
39
|
-
* external store converter:
|
40
|
-
* ```ts
|
41
|
-
* const UI_PLACEHOLDER = Object.freeze({ type: "text", text: "UI content placeholder" });
|
42
|
-
* const convertMessage = (message: TMessage): ThreadMessageLike => ({
|
43
|
-
* content: [
|
44
|
-
* // other content parts,
|
45
|
-
* UI_PLACEHOLDER
|
46
|
-
* ],
|
47
|
-
* });
|
48
|
-
* ```
|
49
|
-
*
|
50
|
-
* Then, define a custom `TextContentPartComponent`:
|
51
|
-
*
|
52
|
-
* ```tsx
|
53
|
-
* const MyText: FC = () => {
|
54
|
-
* const isUIPlaceholder = useContentPart(p => p === UI_PLACEHOLDER);
|
55
|
-
*
|
56
|
-
* // this assumes that you have a `display` field on your original message objects before conversion.
|
57
|
-
* const ui = useMessage(m => isUIPlaceholder ? getExternalStoreMessage(m).display : undefined);
|
58
|
-
* if (ui) {
|
59
|
-
* return ui;
|
60
|
-
* }
|
61
|
-
*
|
62
|
-
* return <MarkdownText />; // your default text component
|
63
|
-
* }
|
64
|
-
* ```
|
65
|
-
*
|
66
|
-
* Pass this component to your Thread:
|
67
|
-
*
|
68
|
-
* ```tsx
|
69
|
-
* <Thread assistantMessage={{ components: { Text: MyText } }} userMessage={{ components: { Text: MyText } }} />
|
70
|
-
* ```
|
71
|
-
*/
|
72
|
-
export type UIContentPart = never;
|
73
|
-
export type CoreToolCallContentPart<TArgs = ReadonlyJSONObject, TResult = unknown> = {
|
35
|
+
export type ToolCallContentPart<TArgs = ReadonlyJSONObject, TResult = unknown> = {
|
74
36
|
readonly type: "tool-call";
|
75
37
|
readonly toolCallId: string;
|
76
38
|
readonly toolName: string;
|
77
39
|
readonly args: TArgs;
|
78
40
|
readonly result?: TResult | undefined;
|
79
41
|
readonly isError?: boolean | undefined;
|
80
|
-
};
|
81
|
-
export type ToolCallContentPart<TArgs = ReadonlyJSONObject, TResult = unknown> = CoreToolCallContentPart<TArgs, TResult> & {
|
82
42
|
readonly argsText: string;
|
83
43
|
readonly artifact?: unknown;
|
84
44
|
};
|
@@ -150,12 +110,11 @@ export type ThreadAssistantMessage = MessageCommonProps & {
|
|
150
110
|
export type RunConfig = {
|
151
111
|
readonly custom?: Record<string, unknown>;
|
152
112
|
};
|
153
|
-
export type AppendMessage =
|
113
|
+
export type AppendMessage = Omit<ThreadMessage, "id"> & {
|
154
114
|
parentId: string | null;
|
155
115
|
/** The ID of the message that was edited or undefined. */
|
156
116
|
sourceId: string | null;
|
157
117
|
runConfig: RunConfig | undefined;
|
158
|
-
attachments: readonly CompleteAttachment[];
|
159
118
|
startRun?: boolean | undefined;
|
160
119
|
};
|
161
120
|
type BaseThreadMessage = {
|
@@ -169,21 +128,5 @@ type BaseThreadMessage = {
|
|
169
128
|
readonly attachments?: ThreadUserMessage["attachments"];
|
170
129
|
};
|
171
130
|
export type ThreadMessage = BaseThreadMessage & (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);
|
172
|
-
/** Core Message Types (without UI content parts) */
|
173
|
-
export type CoreUserContentPart = TextContentPart | ImageContentPart | FileContentPart | Unstable_AudioContentPart;
|
174
|
-
export type CoreAssistantContentPart = TextContentPart | CoreToolCallContentPart;
|
175
|
-
export type CoreSystemMessage = {
|
176
|
-
role: "system";
|
177
|
-
content: readonly [TextContentPart];
|
178
|
-
};
|
179
|
-
export type CoreUserMessage = {
|
180
|
-
role: "user";
|
181
|
-
content: readonly CoreUserContentPart[];
|
182
|
-
};
|
183
|
-
export type CoreAssistantMessage = {
|
184
|
-
role: "assistant";
|
185
|
-
content: readonly CoreAssistantContentPart[];
|
186
|
-
};
|
187
|
-
export type CoreMessage = CoreSystemMessage | CoreUserMessage | CoreAssistantMessage;
|
188
131
|
export {};
|
189
132
|
//# sourceMappingURL=AssistantTypes.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AssistantTypes.d.ts","sourceRoot":"","sources":["../../src/types/AssistantTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,WAAW,GAAG,
|
1
|
+
{"version":3,"file":"AssistantTypes.d.ts","sourceRoot":"","sources":["../../src/types/AssistantTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI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ExB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE;QACjB,QAAQ,CAAC,oBAAoB,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;QAC7D,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;QACtD,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;QACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC1C,CAAC;IACF,QAAQ,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAC3C,CAAC,mBAAmB,GAAG,iBAAiB,GAAG,sBAAsB,CAAC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/types/AssistantTypes.ts"],"sourcesContent":["import { CompleteAttachment } from \"./AttachmentTypes\";\nimport {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"../utils/json/json-value\";\n\nexport type MessageRole = \"
|
1
|
+
{"version":3,"sources":["../../src/types/AssistantTypes.ts"],"sourcesContent":["import { CompleteAttachment } from \"./AttachmentTypes\";\nimport {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"../utils/json/json-value\";\n\nexport type MessageRole = ThreadMessage[\"role\"];\n\nexport type TextContentPart = {\n readonly type: \"text\";\n readonly text: string;\n};\n\nexport type ReasoningContentPart = {\n readonly type: \"reasoning\";\n readonly text: string;\n};\n\nexport type SourceContentPart = {\n readonly type: \"source\";\n readonly sourceType: \"url\";\n readonly id: string;\n readonly url: string;\n readonly title?: string;\n};\n\nexport type ImageContentPart = {\n readonly type: \"image\";\n readonly image: string;\n};\n\nexport type FileContentPart = {\n readonly type: \"file\";\n readonly data: string;\n readonly mimeType: string;\n};\n\nexport type Unstable_AudioContentPart = {\n readonly type: \"audio\";\n readonly audio: {\n readonly data: string;\n readonly format: \"mp3\" | \"wav\";\n };\n};\n\nexport type ToolCallContentPart<\n TArgs = ReadonlyJSONObject,\n TResult = unknown,\n> = {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly args: TArgs;\n readonly result?: TResult | undefined;\n readonly isError?: boolean | undefined;\n readonly argsText: string;\n readonly artifact?: unknown;\n};\n\nexport type ThreadUserContentPart =\n | TextContentPart\n | ImageContentPart\n | FileContentPart\n | Unstable_AudioContentPart;\n\nexport type ThreadAssistantContentPart =\n | TextContentPart\n | ReasoningContentPart\n | ToolCallContentPart\n | SourceContentPart\n | FileContentPart;\n\ntype MessageCommonProps = {\n readonly id: string;\n readonly createdAt: Date;\n};\n\nexport type ThreadStep = {\n readonly messageId?: string;\n readonly usage?:\n | {\n readonly promptTokens: number;\n readonly completionTokens: number;\n }\n | undefined;\n};\n\nexport type ContentPartStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"complete\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ToolCallContentPartStatus =\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | ContentPartStatus;\n\nexport type MessageStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | {\n readonly type: \"complete\";\n readonly reason: \"stop\" | \"unknown\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"tool-calls\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: ReadonlyJSONValue;\n };\n\nexport type ThreadSystemMessage = MessageCommonProps & {\n readonly role: \"system\";\n readonly content: readonly [TextContentPart];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadUserMessage = MessageCommonProps & {\n readonly role: \"user\";\n readonly content: readonly ThreadUserContentPart[];\n readonly attachments: readonly CompleteAttachment[];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadAssistantMessage = MessageCommonProps & {\n readonly role: \"assistant\";\n readonly content: readonly ThreadAssistantContentPart[];\n readonly status: MessageStatus;\n readonly metadata: {\n readonly unstable_annotations: readonly ReadonlyJSONValue[];\n readonly unstable_data: readonly ReadonlyJSONValue[];\n readonly steps: readonly ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type RunConfig = {\n // TODO allow user customization via global type overrides\n readonly custom?: Record<string, unknown>;\n};\n\nexport type AppendMessage = Omit<ThreadMessage, \"id\"> & {\n parentId: string | null;\n\n /** The ID of the message that was edited or undefined. */\n sourceId: string | null;\n runConfig: RunConfig | undefined;\n startRun?: boolean | undefined;\n};\n\ntype BaseThreadMessage = {\n readonly status?: ThreadAssistantMessage[\"status\"];\n readonly metadata: {\n readonly unstable_annotations?: readonly ReadonlyJSONValue[];\n readonly unstable_data?: readonly ReadonlyJSONValue[];\n readonly steps?: readonly ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n readonly attachments?: ThreadUserMessage[\"attachments\"];\n};\n\nexport type ThreadMessage = BaseThreadMessage &\n (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { ThreadUserContentPart } from "./AssistantTypes";
|
2
2
|
export type PendingAttachmentStatus = {
|
3
3
|
type: "running";
|
4
4
|
reason: "uploading";
|
@@ -20,7 +20,7 @@ type BaseAttachment = {
|
|
20
20
|
name: string;
|
21
21
|
contentType: string;
|
22
22
|
file?: File;
|
23
|
-
content?:
|
23
|
+
content?: ThreadUserContentPart[];
|
24
24
|
};
|
25
25
|
export type PendingAttachment = BaseAttachment & {
|
26
26
|
status: PendingAttachmentStatus;
|
@@ -28,7 +28,7 @@ export type PendingAttachment = BaseAttachment & {
|
|
28
28
|
};
|
29
29
|
export type CompleteAttachment = BaseAttachment & {
|
30
30
|
status: CompleteAttachmentStatus;
|
31
|
-
content:
|
31
|
+
content: ThreadUserContentPart[];
|
32
32
|
};
|
33
33
|
export type Attachment = PendingAttachment | CompleteAttachment;
|
34
34
|
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AttachmentTypes.d.ts","sourceRoot":"","sources":["../../src/types/AttachmentTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"AttachmentTypes.d.ts","sourceRoot":"","sources":["../../src/types/AttachmentTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,MAAM,uBAAuB,GAC/B;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,GACD;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,MAAM,EAAE,eAAe,CAAC;CACzB,GACD;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,OAAO,GAAG,eAAe,CAAC;CACnC,CAAC;AAEN,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACxB,uBAAuB,GACvB,wBAAwB,CAAC;AAE7B,KAAK,cAAc,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG;IAC/C,MAAM,EAAE,uBAAuB,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,cAAc,GAAG;IAChD,MAAM,EAAE,wBAAwB,CAAC;IACjC,OAAO,EAAE,qBAAqB,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,iBAAiB,GAAG,kBAAkB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/types/AttachmentTypes.ts"],"sourcesContent":["import {
|
1
|
+
{"version":3,"sources":["../../src/types/AttachmentTypes.ts"],"sourcesContent":["import { ThreadUserContentPart } from \"./AssistantTypes\";\n\nexport type PendingAttachmentStatus =\n | {\n type: \"running\";\n reason: \"uploading\";\n progress: number;\n }\n | {\n type: \"requires-action\";\n reason: \"composer-send\";\n }\n | {\n type: \"incomplete\";\n reason: \"error\" | \"upload-paused\";\n };\n\nexport type CompleteAttachmentStatus = {\n type: \"complete\";\n};\n\nexport type AttachmentStatus =\n | PendingAttachmentStatus\n | CompleteAttachmentStatus;\n\ntype BaseAttachment = {\n id: string;\n type: \"image\" | \"document\" | \"file\";\n name: string;\n contentType: string;\n file?: File;\n content?: ThreadUserContentPart[];\n};\n\nexport type PendingAttachment = BaseAttachment & {\n status: PendingAttachmentStatus;\n file: File;\n};\n\nexport type CompleteAttachment = BaseAttachment & {\n status: CompleteAttachmentStatus;\n content: ThreadUserContentPart[];\n};\n\nexport type Attachment = PendingAttachment | CompleteAttachment;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/types/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export type { Attachment, PendingAttachment, CompleteAttachment, AttachmentStatus, } from "./AttachmentTypes";
|
2
|
-
export type { AppendMessage, TextContentPart, ReasoningContentPart, SourceContentPart, ImageContentPart, FileContentPart, Unstable_AudioContentPart, ToolCallContentPart,
|
2
|
+
export type { AppendMessage, TextContentPart, ReasoningContentPart, SourceContentPart, ImageContentPart, FileContentPart, Unstable_AudioContentPart, ToolCallContentPart, MessageStatus, ThreadUserContentPart, ThreadAssistantContentPart, ThreadSystemMessage, ThreadAssistantMessage, ThreadUserMessage, ThreadMessage, } from "./AssistantTypes";
|
3
3
|
export type { EmptyContentPartProps, EmptyContentPartComponent, TextContentPartProps, TextContentPartComponent, ReasoningContentPartProps, ReasoningContentPartComponent, SourceContentPartProps, SourceContentPartComponent, ImageContentPartProps, ImageContentPartComponent, FileContentPartProps, FileContentPartComponent, Unstable_AudioContentPartProps, Unstable_AudioContentPartComponent, ToolCallContentPartProps, ToolCallContentPartComponent, } from "./ContentPartComponentTypes";
|
4
4
|
export type { Unsubscribe } from "./Unsubscribe";
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EAGb,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,6BAA6B,EAC7B,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,8BAA8B,EAC9B,kCAAkC,EAClC,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/types/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export type {\n Attachment,\n PendingAttachment,\n CompleteAttachment,\n AttachmentStatus,\n} from \"./AttachmentTypes\";\n\nexport type {\n AppendMessage,\n TextContentPart,\n ReasoningContentPart,\n SourceContentPart,\n ImageContentPart,\n FileContentPart,\n Unstable_AudioContentPart,\n ToolCallContentPart,\n
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export type {\n Attachment,\n PendingAttachment,\n CompleteAttachment,\n AttachmentStatus,\n} from \"./AttachmentTypes\";\n\nexport type {\n AppendMessage,\n TextContentPart,\n ReasoningContentPart,\n SourceContentPart,\n ImageContentPart,\n FileContentPart,\n Unstable_AudioContentPart,\n ToolCallContentPart,\n MessageStatus,\n\n // thread message types\n ThreadUserContentPart,\n ThreadAssistantContentPart,\n ThreadSystemMessage,\n ThreadAssistantMessage,\n ThreadUserMessage,\n ThreadMessage,\n} from \"./AssistantTypes\";\n\nexport type {\n EmptyContentPartProps,\n EmptyContentPartComponent,\n TextContentPartProps,\n TextContentPartComponent,\n ReasoningContentPartProps,\n ReasoningContentPartComponent,\n SourceContentPartProps,\n SourceContentPartComponent,\n ImageContentPartProps,\n ImageContentPartComponent,\n FileContentPartProps,\n FileContentPartComponent,\n Unstable_AudioContentPartProps,\n Unstable_AudioContentPartComponent,\n ToolCallContentPartProps,\n ToolCallContentPartComponent,\n} from \"./ContentPartComponentTypes\";\n\nexport type { Unsubscribe } from \"./Unsubscribe\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/package.json
CHANGED
@@ -18,7 +18,6 @@
|
|
18
18
|
"chat",
|
19
19
|
"chatbot",
|
20
20
|
"copilot",
|
21
|
-
"assistant",
|
22
21
|
"ai-chat",
|
23
22
|
"ai-chatbot",
|
24
23
|
"ai-assistant",
|
@@ -29,7 +28,7 @@
|
|
29
28
|
"conversational-ui",
|
30
29
|
"conversational-ai"
|
31
30
|
],
|
32
|
-
"version": "0.
|
31
|
+
"version": "0.9.0",
|
33
32
|
"license": "MIT",
|
34
33
|
"exports": {
|
35
34
|
".": {
|
@@ -50,13 +49,11 @@
|
|
50
49
|
"files": [
|
51
50
|
"dist",
|
52
51
|
"generated",
|
53
|
-
"edge",
|
54
52
|
"src",
|
55
53
|
"README.md"
|
56
54
|
],
|
57
55
|
"sideEffects": false,
|
58
56
|
"dependencies": {
|
59
|
-
"@ai-sdk/provider": "^1.1.0",
|
60
57
|
"@radix-ui/primitive": "^1.1.1",
|
61
58
|
"@radix-ui/react-compose-refs": "^1.1.1",
|
62
59
|
"@radix-ui/react-context": "^1.1.1",
|
@@ -65,13 +62,10 @@
|
|
65
62
|
"@radix-ui/react-slot": "^1.1.2",
|
66
63
|
"@radix-ui/react-use-callback-ref": "^1.1.0",
|
67
64
|
"@radix-ui/react-use-escape-keydown": "^1.1.0",
|
68
|
-
"assistant-stream": "^0.0
|
69
|
-
"json-schema": "^0.4.0",
|
65
|
+
"assistant-stream": "^0.1.0",
|
70
66
|
"nanoid": "5.1.5",
|
71
67
|
"react-textarea-autosize": "^8.5.9",
|
72
|
-
"secure-json-parse": "^4.0.0",
|
73
68
|
"zod": "^3.24.2",
|
74
|
-
"zod-to-json-schema": "^3.24.5",
|
75
69
|
"zustand": "^5.0.3"
|
76
70
|
},
|
77
71
|
"peerDependencies": {
|
package/src/api/ThreadRuntime.ts
CHANGED
@@ -80,12 +80,14 @@ const toAppendMessage = (
|
|
80
80
|
): AppendMessage => {
|
81
81
|
if (typeof message === "string") {
|
82
82
|
return {
|
83
|
+
createdAt: new Date(),
|
83
84
|
parentId: messages.at(-1)?.id ?? null,
|
84
85
|
sourceId: null,
|
85
86
|
runConfig: {},
|
86
87
|
role: "user",
|
87
88
|
content: [{ type: "text", text: message }],
|
88
89
|
attachments: [],
|
90
|
+
metadata: { custom: {} },
|
89
91
|
};
|
90
92
|
}
|
91
93
|
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import {
|
1
|
+
import { ThreadMessage } from "../types";
|
2
2
|
import { AssistantCloudAPI } from "./AssistantCloudAPI";
|
3
3
|
import { AssistantStream, PlainTextDecoder } from "assistant-stream";
|
4
4
|
|
5
5
|
type AssistantCloudRunsStreamBody = {
|
6
6
|
thread_id: string;
|
7
7
|
assistant_id: "system/thread_title";
|
8
|
-
messages:
|
8
|
+
messages: readonly ThreadMessage[];
|
9
9
|
};
|
10
10
|
|
11
11
|
export class AssistantCloudRuns {
|
package/src/cloud/auiV0.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { JSONObject } from "@ai-sdk/provider";
|
2
1
|
import { ThreadMessage } from "../types";
|
3
2
|
import { MessageStatus } from "../types/AssistantTypes";
|
4
3
|
import { fromThreadMessageLike } from "../runtimes/external-store/ThreadMessageLike";
|
@@ -56,7 +55,7 @@ type AuiV0Message = {
|
|
56
55
|
readonly completionTokens: number;
|
57
56
|
};
|
58
57
|
}[];
|
59
|
-
readonly custom:
|
58
|
+
readonly custom: ReadonlyJSONObject;
|
60
59
|
};
|
61
60
|
};
|
62
61
|
|
package/src/index.ts
CHANGED
package/src/internal.ts
CHANGED
@@ -13,6 +13,6 @@ export {
|
|
13
13
|
} from "./api/ThreadRuntime";
|
14
14
|
export { fromThreadMessageLike } from "./runtimes/external-store/ThreadMessageLike";
|
15
15
|
export { getAutoStatus } from "./runtimes/external-store/auto-status";
|
16
|
-
export {
|
16
|
+
export { splitLocalRuntimeOptions } from "./runtimes/local/LocalRuntimeOptions";
|
17
17
|
|
18
18
|
export * from "./utils/smooth";
|
@@ -134,10 +134,12 @@ export abstract class BaseComposerRuntimeCore
|
|
134
134
|
: [];
|
135
135
|
|
136
136
|
const message: Omit<AppendMessage, "parentId" | "sourceId"> = {
|
137
|
+
createdAt: new Date(),
|
137
138
|
role: this.role,
|
138
139
|
content: this.text ? [{ type: "text", text: this.text }] : [],
|
139
140
|
attachments,
|
140
141
|
runConfig: this.runConfig,
|
142
|
+
metadata: { custom: {} },
|
141
143
|
};
|
142
144
|
this._emptyTextAndAttachments();
|
143
145
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { parsePartialJson } from "assistant-stream/utils";
|
1
2
|
import { generateId } from "../../internal";
|
2
3
|
import {
|
3
4
|
MessageStatus,
|
@@ -22,7 +23,6 @@ import {
|
|
22
23
|
ReadonlyJSONObject,
|
23
24
|
ReadonlyJSONValue,
|
24
25
|
} from "../../utils/json/json-value";
|
25
|
-
import { parsePartialJson } from "../../utils/json/parse-partial-json";
|
26
26
|
|
27
27
|
export type ThreadMessageLike = {
|
28
28
|
readonly role: "assistant" | "user" | "system";
|
package/src/runtimes/index.ts
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
export * from "./adapters";
|
2
2
|
export * from "./core";
|
3
|
-
export * from "./dangerous-in-browser";
|
4
|
-
export * from "./edge";
|
5
3
|
export * from "./external-store";
|
6
4
|
export * from "./local";
|
7
5
|
export * from "./remote-thread-list";
|
8
6
|
|
7
|
+
export {
|
8
|
+
toolResultStream as unstable_toolResultStream,
|
9
|
+
unstable_runPendingTools,
|
10
|
+
} from "./streams/toolResultStream";
|
9
11
|
export { ExportedMessageRepository } from "./utils/MessageRepository";
|
@@ -1,6 +1,5 @@
|
|
1
|
-
import { generateId } from "../../internal";
|
1
|
+
import { fromThreadMessageLike, generateId } from "../../internal";
|
2
2
|
import type { AppendMessage, ThreadAssistantMessage } from "../../types";
|
3
|
-
import { fromCoreMessage } from "../edge";
|
4
3
|
import type { ChatModelAdapter, ChatModelRunResult } from "./ChatModelAdapter";
|
5
4
|
import { shouldContinue } from "./shouldContinue";
|
6
5
|
import { LocalRuntimeOptionsBase } from "./LocalRuntimeOptions";
|
@@ -118,8 +117,9 @@ export class LocalThreadRuntimeCore
|
|
118
117
|
public async append(message: AppendMessage): Promise<void> {
|
119
118
|
this.ensureInitialized();
|
120
119
|
|
121
|
-
const newMessage =
|
122
|
-
|
120
|
+
const newMessage = fromThreadMessageLike(message, generateId(), {
|
121
|
+
type: "complete",
|
122
|
+
reason: "unknown",
|
123
123
|
});
|
124
124
|
this.repository.addOrUpdateMessage(message.parentId, newMessage);
|
125
125
|
this._options.adapters.history?.append({
|
@@ -10,7 +10,6 @@ import { AssistantCloud } from "../../../cloud";
|
|
10
10
|
import { RemoteThreadListAdapter } from "../types";
|
11
11
|
import { useAssistantCloudThreadHistoryAdapter } from "../../../cloud/AssistantCloudThreadHistoryAdapter";
|
12
12
|
import { RuntimeAdapterProvider } from "../../adapters/RuntimeAdapterProvider";
|
13
|
-
import { toCoreMessages } from "../../edge";
|
14
13
|
import { InMemoryThreadListAdapter } from "./in-memory";
|
15
14
|
|
16
15
|
type ThreadData = {
|
@@ -103,7 +102,7 @@ export const useCloudThreadListAdapter = (
|
|
103
102
|
return cloud.runs.stream({
|
104
103
|
thread_id: threadId,
|
105
104
|
assistant_id: "system/thread_title",
|
106
|
-
messages:
|
105
|
+
messages: messages, // TODO serialize these to a more efficient format
|
107
106
|
});
|
108
107
|
},
|
109
108
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Tool } from "
|
1
|
+
import { Tool } from "../../model-context/ModelContextTypes";
|
2
2
|
import { z } from "zod";
|
3
3
|
import { AssistantMessage, ToolExecutionStream } from "assistant-stream";
|
4
4
|
import { ToolResponse } from "assistant-stream";
|
@@ -1,6 +1,5 @@
|
|
1
|
-
import type {
|
1
|
+
import type { ThreadMessage } from "../../types";
|
2
2
|
import { generateId, generateOptimisticId } from "../../utils/idUtils";
|
3
|
-
import { fromCoreMessage } from "../edge/converters/fromCoreMessage";
|
4
3
|
import { ThreadMessageLike } from "../external-store";
|
5
4
|
import { getAutoStatus } from "../external-store/auto-status";
|
6
5
|
import { fromThreadMessageLike } from "../external-store/ThreadMessageLike";
|
@@ -303,7 +302,7 @@ export class MessageRepository {
|
|
303
302
|
* @param message - The core message to convert to an optimistic message
|
304
303
|
* @returns The generated optimistic ID
|
305
304
|
*/
|
306
|
-
appendOptimisticMessage(parentId: string | null, message:
|
305
|
+
appendOptimisticMessage(parentId: string | null, message: ThreadMessageLike) {
|
307
306
|
let optimisticId: string;
|
308
307
|
do {
|
309
308
|
optimisticId = generateOptimisticId();
|
@@ -311,10 +310,7 @@ export class MessageRepository {
|
|
311
310
|
|
312
311
|
this.addOrUpdateMessage(
|
313
312
|
parentId,
|
314
|
-
|
315
|
-
id: optimisticId,
|
316
|
-
status: { type: "running" },
|
317
|
-
}),
|
313
|
+
fromThreadMessageLike(message, optimisticId, { type: "running" }),
|
318
314
|
);
|
319
315
|
|
320
316
|
return optimisticId;
|
@@ -3,11 +3,8 @@ import {
|
|
3
3
|
MessageRepository,
|
4
4
|
ExportedMessageRepository,
|
5
5
|
} from "../runtimes/utils/MessageRepository";
|
6
|
-
import type {
|
7
|
-
|
8
|
-
ThreadMessage,
|
9
|
-
TextContentPart,
|
10
|
-
} from "../types/AssistantTypes";
|
6
|
+
import type { ThreadMessage, TextContentPart } from "../types/AssistantTypes";
|
7
|
+
import { ThreadMessageLike } from "../runtimes";
|
11
8
|
|
12
9
|
// Mock generateId and generateOptimisticId to make tests deterministic
|
13
10
|
const mockGenerateId = vi.fn();
|
@@ -58,7 +55,7 @@ describe("MessageRepository", () => {
|
|
58
55
|
/**
|
59
56
|
* Creates a test CoreMessage with the given overrides.
|
60
57
|
*/
|
61
|
-
const
|
58
|
+
const createThreadMessageLike = (overrides = {}): ThreadMessageLike => ({
|
62
59
|
role: "assistant",
|
63
60
|
content: [{ type: "text", text: "Test message" }],
|
64
61
|
...overrides,
|
@@ -333,7 +330,7 @@ describe("MessageRepository", () => {
|
|
333
330
|
it("should create an optimistic message with a unique ID", () => {
|
334
331
|
mockGenerateOptimisticId.mockReturnValue("__optimistic__generated-id");
|
335
332
|
|
336
|
-
const coreMessage =
|
333
|
+
const coreMessage = createThreadMessageLike();
|
337
334
|
const optimisticId = repository.appendOptimisticMessage(
|
338
335
|
null,
|
339
336
|
coreMessage,
|
@@ -353,7 +350,7 @@ describe("MessageRepository", () => {
|
|
353
350
|
const parent = createTestMessage({ id: "parent-id" });
|
354
351
|
repository.addOrUpdateMessage(null, parent);
|
355
352
|
|
356
|
-
const coreMessage =
|
353
|
+
const coreMessage = createThreadMessageLike();
|
357
354
|
const optimisticId = repository.appendOptimisticMessage(
|
358
355
|
"parent-id",
|
359
356
|
coreMessage,
|
@@ -381,7 +378,7 @@ describe("MessageRepository", () => {
|
|
381
378
|
// Second call returns a unique ID
|
382
379
|
mockGenerateOptimisticId.mockReturnValueOnce("__optimistic__unique-id");
|
383
380
|
|
384
|
-
const coreMessage =
|
381
|
+
const coreMessage = createThreadMessageLike();
|
385
382
|
const optimisticId = repository.appendOptimisticMessage(
|
386
383
|
null,
|
387
384
|
coreMessage,
|
@@ -498,7 +495,7 @@ describe("MessageRepository", () => {
|
|
498
495
|
it("should convert an array of messages to repository format", () => {
|
499
496
|
mockGenerateId.mockReturnValue("generated-id");
|
500
497
|
|
501
|
-
const messages:
|
498
|
+
const messages: ThreadMessageLike[] = [
|
502
499
|
{
|
503
500
|
role: "user" as const,
|
504
501
|
content: [
|
@@ -4,7 +4,7 @@ import {
|
|
4
4
|
ReadonlyJSONValue,
|
5
5
|
} from "../utils/json/json-value";
|
6
6
|
|
7
|
-
export type MessageRole = "
|
7
|
+
export type MessageRole = ThreadMessage["role"];
|
8
8
|
|
9
9
|
export type TextContentPart = {
|
10
10
|
readonly type: "text";
|
@@ -43,46 +43,7 @@ export type Unstable_AudioContentPart = {
|
|
43
43
|
};
|
44
44
|
};
|
45
45
|
|
46
|
-
|
47
|
-
* @deprecated UI content parts are deprecated and will be removed in v0.8.0.
|
48
|
-
* Migration guide for external-store users using UI content parts:
|
49
|
-
* If you must, store UI elements on your external store messages, update your
|
50
|
-
* external store converter:
|
51
|
-
* ```ts
|
52
|
-
* const UI_PLACEHOLDER = Object.freeze({ type: "text", text: "UI content placeholder" });
|
53
|
-
* const convertMessage = (message: TMessage): ThreadMessageLike => ({
|
54
|
-
* content: [
|
55
|
-
* // other content parts,
|
56
|
-
* UI_PLACEHOLDER
|
57
|
-
* ],
|
58
|
-
* });
|
59
|
-
* ```
|
60
|
-
*
|
61
|
-
* Then, define a custom `TextContentPartComponent`:
|
62
|
-
*
|
63
|
-
* ```tsx
|
64
|
-
* const MyText: FC = () => {
|
65
|
-
* const isUIPlaceholder = useContentPart(p => p === UI_PLACEHOLDER);
|
66
|
-
*
|
67
|
-
* // this assumes that you have a `display` field on your original message objects before conversion.
|
68
|
-
* const ui = useMessage(m => isUIPlaceholder ? getExternalStoreMessage(m).display : undefined);
|
69
|
-
* if (ui) {
|
70
|
-
* return ui;
|
71
|
-
* }
|
72
|
-
*
|
73
|
-
* return <MarkdownText />; // your default text component
|
74
|
-
* }
|
75
|
-
* ```
|
76
|
-
*
|
77
|
-
* Pass this component to your Thread:
|
78
|
-
*
|
79
|
-
* ```tsx
|
80
|
-
* <Thread assistantMessage={{ components: { Text: MyText } }} userMessage={{ components: { Text: MyText } }} />
|
81
|
-
* ```
|
82
|
-
*/
|
83
|
-
export type UIContentPart = never;
|
84
|
-
|
85
|
-
export type CoreToolCallContentPart<
|
46
|
+
export type ToolCallContentPart<
|
86
47
|
TArgs = ReadonlyJSONObject,
|
87
48
|
TResult = unknown,
|
88
49
|
> = {
|
@@ -92,12 +53,6 @@ export type CoreToolCallContentPart<
|
|
92
53
|
readonly args: TArgs;
|
93
54
|
readonly result?: TResult | undefined;
|
94
55
|
readonly isError?: boolean | undefined;
|
95
|
-
};
|
96
|
-
|
97
|
-
export type ToolCallContentPart<
|
98
|
-
TArgs = ReadonlyJSONObject,
|
99
|
-
TResult = unknown,
|
100
|
-
> = CoreToolCallContentPart<TArgs, TResult> & {
|
101
56
|
readonly argsText: string;
|
102
57
|
readonly artifact?: unknown;
|
103
58
|
};
|
@@ -213,14 +168,12 @@ export type RunConfig = {
|
|
213
168
|
readonly custom?: Record<string, unknown>;
|
214
169
|
};
|
215
170
|
|
216
|
-
export type AppendMessage =
|
171
|
+
export type AppendMessage = Omit<ThreadMessage, "id"> & {
|
217
172
|
parentId: string | null;
|
218
173
|
|
219
174
|
/** The ID of the message that was edited or undefined. */
|
220
175
|
sourceId: string | null;
|
221
176
|
runConfig: RunConfig | undefined;
|
222
|
-
|
223
|
-
attachments: readonly CompleteAttachment[];
|
224
177
|
startRun?: boolean | undefined;
|
225
178
|
};
|
226
179
|
|
@@ -237,34 +190,3 @@ type BaseThreadMessage = {
|
|
237
190
|
|
238
191
|
export type ThreadMessage = BaseThreadMessage &
|
239
192
|
(ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);
|
240
|
-
|
241
|
-
/** Core Message Types (without UI content parts) */
|
242
|
-
|
243
|
-
export type CoreUserContentPart =
|
244
|
-
| TextContentPart
|
245
|
-
| ImageContentPart
|
246
|
-
| FileContentPart
|
247
|
-
| Unstable_AudioContentPart;
|
248
|
-
export type CoreAssistantContentPart =
|
249
|
-
| TextContentPart
|
250
|
-
| CoreToolCallContentPart;
|
251
|
-
|
252
|
-
export type CoreSystemMessage = {
|
253
|
-
role: "system";
|
254
|
-
content: readonly [TextContentPart];
|
255
|
-
};
|
256
|
-
|
257
|
-
export type CoreUserMessage = {
|
258
|
-
role: "user";
|
259
|
-
content: readonly CoreUserContentPart[];
|
260
|
-
};
|
261
|
-
|
262
|
-
export type CoreAssistantMessage = {
|
263
|
-
role: "assistant";
|
264
|
-
content: readonly CoreAssistantContentPart[];
|
265
|
-
};
|
266
|
-
|
267
|
-
export type CoreMessage =
|
268
|
-
| CoreSystemMessage
|
269
|
-
| CoreUserMessage
|
270
|
-
| CoreAssistantMessage;
|