@assistant-ui/react 0.7.0 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/api/AssistantRuntime.d.ts +4 -34
- package/dist/api/AssistantRuntime.d.ts.map +1 -1
- package/dist/api/AssistantRuntime.js.map +1 -1
- package/dist/api/AssistantRuntime.mjs.map +1 -1
- package/dist/api/AttachmentRuntime.d.ts +4 -4
- package/dist/api/AttachmentRuntime.d.ts.map +1 -1
- package/dist/api/AttachmentRuntime.js.map +1 -1
- package/dist/api/AttachmentRuntime.mjs.map +1 -1
- package/dist/api/ComposerRuntime.d.ts +10 -10
- package/dist/api/ComposerRuntime.d.ts.map +1 -1
- package/dist/api/ComposerRuntime.js.map +1 -1
- package/dist/api/ComposerRuntime.mjs.map +1 -1
- package/dist/api/ContentPartRuntime.d.ts +2 -2
- package/dist/api/ContentPartRuntime.d.ts.map +1 -1
- package/dist/api/ContentPartRuntime.js.map +1 -1
- package/dist/api/ContentPartRuntime.mjs.map +1 -1
- package/dist/api/MessageRuntime.d.ts +7 -7
- package/dist/api/MessageRuntime.d.ts.map +1 -1
- package/dist/api/MessageRuntime.js +2 -2
- package/dist/api/MessageRuntime.js.map +1 -1
- package/dist/api/MessageRuntime.mjs +2 -2
- package/dist/api/MessageRuntime.mjs.map +1 -1
- package/dist/api/RuntimePathTypes.d.ts +33 -33
- package/dist/api/RuntimePathTypes.d.ts.map +1 -1
- package/dist/api/RuntimePathTypes.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.d.ts +4 -4
- package/dist/api/ThreadListItemRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListItemRuntime.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.mjs.map +1 -1
- package/dist/api/ThreadListRuntime.d.ts +9 -9
- package/dist/api/ThreadListRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListRuntime.js.map +1 -1
- package/dist/api/ThreadListRuntime.mjs.map +1 -1
- package/dist/api/ThreadRuntime.d.ts +45 -56
- package/dist/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.mjs.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts +1 -1
- package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
- package/dist/context/react/AssistantContext.d.ts +10 -48
- package/dist/context/react/AssistantContext.d.ts.map +1 -1
- package/dist/context/react/AttachmentContext.d.ts +16 -16
- package/dist/context/react/MessageContext.d.ts +6 -36
- package/dist/context/react/MessageContext.d.ts.map +1 -1
- package/dist/context/react/ThreadContext.d.ts +10 -138
- package/dist/context/react/ThreadContext.d.ts.map +1 -1
- package/dist/context/stores/AssistantToolUIs.d.ts +9 -6
- package/dist/context/stores/AssistantToolUIs.d.ts.map +1 -1
- package/dist/context/stores/AssistantToolUIs.js.map +1 -1
- package/dist/context/stores/AssistantToolUIs.mjs.map +1 -1
- package/dist/context/stores/MessageUtils.d.ts +7 -12
- package/dist/context/stores/MessageUtils.d.ts.map +1 -1
- package/dist/context/stores/MessageUtils.js.map +1 -1
- package/dist/context/stores/MessageUtils.mjs.map +1 -1
- package/dist/context/stores/ThreadViewport.d.ts +6 -10
- package/dist/context/stores/ThreadViewport.d.ts.map +1 -1
- package/dist/context/stores/ThreadViewport.js +0 -1
- package/dist/context/stores/ThreadViewport.js.map +1 -1
- package/dist/context/stores/ThreadViewport.mjs +0 -2
- package/dist/context/stores/ThreadViewport.mjs.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.d.ts +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartImage.d.ts +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartText.d.ts +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts +2 -4
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts +22 -22
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/edge/converters/fromCoreMessage.d.ts.map +1 -1
- package/dist/runtimes/edge/converters/fromCoreMessage.js +6 -3
- package/dist/runtimes/edge/converters/fromCoreMessage.js.map +1 -1
- package/dist/runtimes/edge/converters/fromCoreMessage.mjs +6 -3
- package/dist/runtimes/edge/converters/fromCoreMessage.mjs.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +3 -3
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts +2 -11
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts +5 -1
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.js +18 -6
- package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.mjs +18 -6
- package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
- package/dist/runtimes/local/ChatModelAdapter.d.ts +4 -4
- package/dist/runtimes/local/ChatModelAdapter.d.ts.map +1 -1
- package/dist/runtimes/local/ChatModelAdapter.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js +1 -0
- package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +1 -0
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
- package/dist/types/AssistantTypes.d.ts +13 -4
- package/dist/types/AssistantTypes.d.ts.map +1 -1
- package/dist/types/AssistantTypes.js.map +1 -1
- package/package.json +3 -3
- package/src/api/AssistantRuntime.ts +2 -2
- package/src/api/AttachmentRuntime.ts +4 -4
- package/src/api/ComposerRuntime.ts +10 -10
- package/src/api/ContentPartRuntime.ts +2 -2
- package/src/api/MessageRuntime.ts +9 -9
- package/src/api/RuntimePathTypes.ts +26 -26
- package/src/api/ThreadListItemRuntime.ts +4 -4
- package/src/api/ThreadListRuntime.ts +10 -10
- package/src/api/ThreadRuntime.ts +45 -14
- package/src/api/index.ts +4 -0
- package/src/context/stores/AssistantToolUIs.ts +9 -2
- package/src/context/stores/MessageUtils.ts +6 -6
- package/src/context/stores/ThreadViewport.tsx +5 -6
- package/src/runtimes/core/ThreadRuntimeCore.tsx +28 -29
- package/src/runtimes/edge/converters/fromCoreMessage.ts +4 -0
- package/src/runtimes/external-store/ThreadMessageLike.tsx +21 -4
- package/src/runtimes/local/ChatModelAdapter.tsx +4 -4
- package/src/runtimes/local/LocalThreadRuntimeCore.tsx +1 -0
- package/src/types/AssistantTypes.ts +13 -5
@@ -15,9 +15,9 @@ export declare class ExternalStoreThreadListRuntimeCore implements ThreadListRun
|
|
15
15
|
get mainThread(): ExternalStoreThreadRuntimeCore;
|
16
16
|
constructor(adapter: ExternalStoreThreadListAdapter | undefined, threadFactory: ExternalStoreThreadFactory);
|
17
17
|
getThreadMetadataById(threadId: string): Readonly<{
|
18
|
-
threadId: string;
|
19
|
-
state: "archived" | "regular" | "new" | "deleted";
|
20
|
-
title?: string | undefined;
|
18
|
+
readonly threadId: string;
|
19
|
+
readonly state: "archived" | "regular" | "new" | "deleted";
|
20
|
+
readonly title?: string | undefined;
|
21
21
|
}> | undefined;
|
22
22
|
setAdapter(adapter: ExternalStoreThreadListAdapter): void;
|
23
23
|
switchToThread(threadId: string): Promise<void>;
|
@@ -1,22 +1,13 @@
|
|
1
1
|
import { AddToolResultOptions, ThreadSuggestion } from "../core/ThreadRuntimeCore";
|
2
2
|
import { AppendMessage, ModelConfigProvider, ThreadMessage } from "../../types";
|
3
3
|
import { ExternalStoreAdapter } from "./ExternalStoreAdapter";
|
4
|
-
import { ThreadRuntimeCore } from "../core/ThreadRuntimeCore";
|
4
|
+
import { RuntimeCapabilities, ThreadRuntimeCore } from "../core/ThreadRuntimeCore";
|
5
5
|
import { BaseThreadRuntimeCore } from "../core/BaseThreadRuntimeCore";
|
6
6
|
export declare const hasUpcomingMessage: (isRunning: boolean, messages: ThreadMessage[]) => boolean;
|
7
7
|
export declare class ExternalStoreThreadRuntimeCore extends BaseThreadRuntimeCore implements ThreadRuntimeCore {
|
8
8
|
private assistantOptimisticId;
|
9
9
|
private _capabilities;
|
10
|
-
get capabilities():
|
11
|
-
switchToBranch: boolean;
|
12
|
-
edit: boolean;
|
13
|
-
reload: boolean;
|
14
|
-
cancel: boolean;
|
15
|
-
unstable_copy: boolean;
|
16
|
-
speech: boolean;
|
17
|
-
attachments: boolean;
|
18
|
-
feedback: boolean;
|
19
|
-
}>;
|
10
|
+
get capabilities(): RuntimeCapabilities;
|
20
11
|
private _messages;
|
21
12
|
isDisabled: boolean;
|
22
13
|
get messages(): ThreadMessage[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ExternalStoreThreadRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAS9D,OAAO,
|
1
|
+
{"version":3,"file":"ExternalStoreThreadRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAA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|
-
import { CoreToolCallContentPart, Unstable_AudioContentPart } from "../../types/AssistantTypes";
|
2
|
+
import { CoreToolCallContentPart, ThreadStep, Unstable_AudioContentPart } from "../../types/AssistantTypes";
|
3
3
|
export type ThreadMessageLike = {
|
4
4
|
role: "assistant" | "user" | "system";
|
5
5
|
content: string | (TextContentPart | ImageContentPart | Unstable_AudioContentPart | ToolCallContentPart<any, any> | CoreToolCallContentPart<any, any> | UIContentPart)[];
|
@@ -7,6 +7,10 @@ export type ThreadMessageLike = {
|
|
7
7
|
createdAt?: Date | undefined;
|
8
8
|
status?: MessageStatus | undefined;
|
9
9
|
attachments?: CompleteAttachment[] | undefined;
|
10
|
+
metadata?: {
|
11
|
+
steps?: ThreadStep[] | undefined;
|
12
|
+
custom?: Record<string, unknown> | undefined;
|
13
|
+
};
|
10
14
|
};
|
11
15
|
export declare const fromThreadMessageLike: (like: ThreadMessageLike, fallbackId: string, fallbackStatus: MessageStatus) => ThreadMessage;
|
12
16
|
//# sourceMappingURL=ThreadMessageLike.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ThreadMessageLike.d.ts","sourceRoot":"","sources":["../../../src/runtimes/external-store/ThreadMessageLike.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,aAAa,EAMb,kBAAkB,EACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,4BAA4B,CAAC;AAEpC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAC;IACtC,OAAO,EACH,MAAM,GACN,CACI,eAAe,GACf,gBAAgB,GAChB,yBAAyB,GACzB,mBAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,GAC7B,uBAAuB,CAAC,GAAG,EAAE,GAAG,CAAC,GACjC,aAAa,CAChB,EAAE,CAAC;IACR,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,SAAS,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAC7B,MAAM,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IACnC,WAAW,CAAC,EAAE,kBAAkB,EAAE,GAAG,SAAS,CAAC;
|
1
|
+
{"version":3,"file":"ThreadMessageLike.d.ts","sourceRoot":"","sources":["../../../src/runtimes/external-store/ThreadMessageLike.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,aAAa,EAMb,kBAAkB,EACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,uBAAuB,EACvB,UAAU,EACV,yBAAyB,EAC1B,MAAM,4BAA4B,CAAC;AAEpC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAC;IACtC,OAAO,EACH,MAAM,GACN,CACI,eAAe,GACf,gBAAgB,GAChB,yBAAyB,GACzB,mBAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,GAC7B,uBAAuB,CAAC,GAAG,EAAE,GAAG,CAAC,GACjC,aAAa,CAChB,EAAE,CAAC;IACR,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,SAAS,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAC7B,MAAM,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IACnC,WAAW,CAAC,EAAE,kBAAkB,EAAE,GAAG,SAAS,CAAC;IAC/C,QAAQ,CAAC,EAAE;QACT,KAAK,CAAC,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC;QACjC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;KAC9C,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,qBAAqB,SAC1B,iBAAiB,cACX,MAAM,kBACF,aAAa,KAC5B,aAwGF,CAAC"}
|
@@ -24,16 +24,18 @@ __export(ThreadMessageLike_exports, {
|
|
24
24
|
});
|
25
25
|
module.exports = __toCommonJS(ThreadMessageLike_exports);
|
26
26
|
var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
27
|
-
const { role, id, createdAt, attachments, status } = like;
|
27
|
+
const { role, id, createdAt, attachments, status, metadata } = like;
|
28
28
|
const common = {
|
29
29
|
id: id ?? fallbackId,
|
30
30
|
createdAt: createdAt ?? /* @__PURE__ */ new Date()
|
31
31
|
};
|
32
32
|
const content = typeof like.content === "string" ? [{ type: "text", text: like.content }] : like.content;
|
33
33
|
if (role !== "user" && attachments)
|
34
|
-
throw new Error("
|
34
|
+
throw new Error("attachments are only supported for user messages");
|
35
35
|
if (role !== "assistant" && status)
|
36
|
-
throw new Error("
|
36
|
+
throw new Error("status is only supported for assistant messages");
|
37
|
+
if (role !== "assistant" && metadata?.steps)
|
38
|
+
throw new Error("metadata.steps is only supported for assistant messages");
|
37
39
|
switch (role) {
|
38
40
|
case "assistant":
|
39
41
|
return {
|
@@ -60,7 +62,11 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
60
62
|
}
|
61
63
|
}
|
62
64
|
}).filter((c) => !!c),
|
63
|
-
status: status ?? fallbackStatus
|
65
|
+
status: status ?? fallbackStatus,
|
66
|
+
metadata: {
|
67
|
+
custom: metadata?.custom ?? {},
|
68
|
+
steps: metadata?.steps ?? []
|
69
|
+
}
|
64
70
|
};
|
65
71
|
case "user":
|
66
72
|
return {
|
@@ -80,7 +86,10 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
80
86
|
}
|
81
87
|
}
|
82
88
|
}),
|
83
|
-
attachments: attachments ?? []
|
89
|
+
attachments: attachments ?? [],
|
90
|
+
metadata: {
|
91
|
+
custom: metadata?.custom ?? {}
|
92
|
+
}
|
84
93
|
};
|
85
94
|
case "system":
|
86
95
|
if (content.length !== 1 || content[0].type !== "text")
|
@@ -90,7 +99,10 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
90
99
|
return {
|
91
100
|
...common,
|
92
101
|
role,
|
93
|
-
content
|
102
|
+
content,
|
103
|
+
metadata: {
|
104
|
+
custom: metadata?.custom ?? {}
|
105
|
+
}
|
94
106
|
};
|
95
107
|
default: {
|
96
108
|
const unsupportedRole = role;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/ThreadMessageLike.tsx"],"sourcesContent":["import {\n MessageStatus,\n TextContentPart,\n ImageContentPart,\n ToolCallContentPart,\n UIContentPart,\n ThreadMessage,\n ThreadAssistantContentPart,\n ThreadAssistantMessage,\n ThreadUserContentPart,\n ThreadUserMessage,\n ThreadSystemMessage,\n CompleteAttachment,\n} from \"../../types\";\nimport {\n CoreToolCallContentPart,\n Unstable_AudioContentPart,\n} from \"../../types/AssistantTypes\";\n\nexport type ThreadMessageLike = {\n role: \"assistant\" | \"user\" | \"system\";\n content:\n | string\n | (\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart\n | ToolCallContentPart<any, any>\n | CoreToolCallContentPart<any, any>\n | UIContentPart\n )[];\n id?: string | undefined;\n createdAt?: Date | undefined;\n status?: MessageStatus | undefined;\n attachments?: CompleteAttachment[] | undefined;\n
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/ThreadMessageLike.tsx"],"sourcesContent":["import {\n MessageStatus,\n TextContentPart,\n ImageContentPart,\n ToolCallContentPart,\n UIContentPart,\n ThreadMessage,\n ThreadAssistantContentPart,\n ThreadAssistantMessage,\n ThreadUserContentPart,\n ThreadUserMessage,\n ThreadSystemMessage,\n CompleteAttachment,\n} from \"../../types\";\nimport {\n CoreToolCallContentPart,\n ThreadStep,\n Unstable_AudioContentPart,\n} from \"../../types/AssistantTypes\";\n\nexport type ThreadMessageLike = {\n role: \"assistant\" | \"user\" | \"system\";\n content:\n | string\n | (\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart\n | ToolCallContentPart<any, any>\n | CoreToolCallContentPart<any, any>\n | UIContentPart\n )[];\n id?: string | undefined;\n createdAt?: Date | undefined;\n status?: MessageStatus | undefined;\n attachments?: CompleteAttachment[] | undefined;\n metadata?: {\n steps?: ThreadStep[] | undefined;\n custom?: Record<string, unknown> | undefined;\n };\n};\n\nexport const fromThreadMessageLike = (\n like: ThreadMessageLike,\n fallbackId: string,\n fallbackStatus: MessageStatus,\n): ThreadMessage => {\n const { role, id, createdAt, attachments, status, metadata } = like;\n const common = {\n id: id ?? fallbackId,\n createdAt: createdAt ?? new Date(),\n };\n\n const content =\n typeof like.content === \"string\"\n ? [{ type: \"text\" as const, text: like.content }]\n : like.content;\n\n if (role !== \"user\" && attachments)\n throw new Error(\"attachments are only supported for user messages\");\n\n if (role !== \"assistant\" && status)\n throw new Error(\"status is only supported for assistant messages\");\n\n if (role !== \"assistant\" && metadata?.steps)\n throw new Error(\"metadata.steps is only supported for assistant messages\");\n\n switch (role) {\n case \"assistant\":\n return {\n ...common,\n role,\n content: content\n .map((part): ThreadAssistantContentPart | null => {\n const type = part.type;\n switch (type) {\n case \"text\":\n if (part.text.trim().length === 0) return null;\n return part;\n\n case \"ui\":\n return part;\n\n case \"tool-call\": {\n if (\"argsText\" in part) return part;\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n };\n }\n\n default: {\n const unhandledType: \"image\" | \"audio\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n })\n .filter((c) => !!c),\n status: status ?? fallbackStatus,\n metadata: {\n custom: metadata?.custom ?? {},\n steps: metadata?.steps ?? [],\n },\n } satisfies ThreadAssistantMessage;\n\n case \"user\":\n return {\n ...common,\n role,\n content: content.map((part): ThreadUserContentPart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"ui\":\n case \"image\":\n case \"audio\":\n return part;\n\n default: {\n const unhandledType: \"tool-call\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n attachments: attachments ?? [],\n metadata: {\n custom: metadata?.custom ?? {},\n },\n } satisfies ThreadUserMessage;\n\n case \"system\":\n if (content.length !== 1 || content[0]!.type !== \"text\")\n throw new Error(\n \"System messages must have exactly one text content part.\",\n );\n\n return {\n ...common,\n role,\n content: content as [TextContentPart],\n metadata: {\n custom: metadata?.custom ?? {},\n },\n } satisfies ThreadSystemMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CO,IAAM,wBAAwB,CACnC,MACA,YACA,mBACkB;AAClB,QAAM,EAAE,MAAM,IAAI,WAAW,aAAa,QAAQ,SAAS,IAAI;AAC/D,QAAM,SAAS;AAAA,IACb,IAAI,MAAM;AAAA,IACV,WAAW,aAAa,oBAAI,KAAK;AAAA,EACnC;AAEA,QAAM,UACJ,OAAO,KAAK,YAAY,WACpB,CAAC,EAAE,MAAM,QAAiB,MAAM,KAAK,QAAQ,CAAC,IAC9C,KAAK;AAEX,MAAI,SAAS,UAAU;AACrB,UAAM,IAAI,MAAM,kDAAkD;AAEpE,MAAI,SAAS,eAAe;AAC1B,UAAM,IAAI,MAAM,iDAAiD;AAEnE,MAAI,SAAS,eAAe,UAAU;AACpC,UAAM,IAAI,MAAM,yDAAyD;AAE3E,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QACN,IAAI,CAAC,SAA4C;AAChD,gBAAM,OAAO,KAAK;AAClB,kBAAQ,MAAM;AAAA,YACZ,KAAK;AACH,kBAAI,KAAK,KAAK,KAAK,EAAE,WAAW,EAAG,QAAO;AAC1C,qBAAO;AAAA,YAET,KAAK;AACH,qBAAO;AAAA,YAET,KAAK,aAAa;AAChB,kBAAI,cAAc,KAAM,QAAO;AAC/B,qBAAO;AAAA,gBACL,GAAG;AAAA,gBACH,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adMessageLike.tsx
|
2
2
|
var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
3
|
-
const { role, id, createdAt, attachments, status } = like;
|
3
|
+
const { role, id, createdAt, attachments, status, metadata } = like;
|
4
4
|
const common = {
|
5
5
|
id: id ?? fallbackId,
|
6
6
|
createdAt: createdAt ?? /* @__PURE__ */ new Date()
|
7
7
|
};
|
8
8
|
const content = typeof like.content === "string" ? [{ type: "text", text: like.content }] : like.content;
|
9
9
|
if (role !== "user" && attachments)
|
10
|
-
throw new Error("
|
10
|
+
throw new Error("attachments are only supported for user messages");
|
11
11
|
if (role !== "assistant" && status)
|
12
|
-
throw new Error("
|
12
|
+
throw new Error("status is only supported for assistant messages");
|
13
|
+
if (role !== "assistant" && metadata?.steps)
|
14
|
+
throw new Error("metadata.steps is only supported for assistant messages");
|
13
15
|
switch (role) {
|
14
16
|
case "assistant":
|
15
17
|
return {
|
@@ -36,7 +38,11 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
36
38
|
}
|
37
39
|
}
|
38
40
|
}).filter((c) => !!c),
|
39
|
-
status: status ?? fallbackStatus
|
41
|
+
status: status ?? fallbackStatus,
|
42
|
+
metadata: {
|
43
|
+
custom: metadata?.custom ?? {},
|
44
|
+
steps: metadata?.steps ?? []
|
45
|
+
}
|
40
46
|
};
|
41
47
|
case "user":
|
42
48
|
return {
|
@@ -56,7 +62,10 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
56
62
|
}
|
57
63
|
}
|
58
64
|
}),
|
59
|
-
attachments: attachments ?? []
|
65
|
+
attachments: attachments ?? [],
|
66
|
+
metadata: {
|
67
|
+
custom: metadata?.custom ?? {}
|
68
|
+
}
|
60
69
|
};
|
61
70
|
case "system":
|
62
71
|
if (content.length !== 1 || content[0].type !== "text")
|
@@ -66,7 +75,10 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
66
75
|
return {
|
67
76
|
...common,
|
68
77
|
role,
|
69
|
-
content
|
78
|
+
content,
|
79
|
+
metadata: {
|
80
|
+
custom: metadata?.custom ?? {}
|
81
|
+
}
|
70
82
|
};
|
71
83
|
default: {
|
72
84
|
const unsupportedRole = role;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/ThreadMessageLike.tsx"],"sourcesContent":["import {\n MessageStatus,\n TextContentPart,\n ImageContentPart,\n ToolCallContentPart,\n UIContentPart,\n ThreadMessage,\n ThreadAssistantContentPart,\n ThreadAssistantMessage,\n ThreadUserContentPart,\n ThreadUserMessage,\n ThreadSystemMessage,\n CompleteAttachment,\n} from \"../../types\";\nimport {\n CoreToolCallContentPart,\n Unstable_AudioContentPart,\n} from \"../../types/AssistantTypes\";\n\nexport type ThreadMessageLike = {\n role: \"assistant\" | \"user\" | \"system\";\n content:\n | string\n | (\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart\n | ToolCallContentPart<any, any>\n | CoreToolCallContentPart<any, any>\n | UIContentPart\n )[];\n id?: string | undefined;\n createdAt?: Date | undefined;\n status?: MessageStatus | undefined;\n attachments?: CompleteAttachment[] | undefined;\n
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/ThreadMessageLike.tsx"],"sourcesContent":["import {\n MessageStatus,\n TextContentPart,\n ImageContentPart,\n ToolCallContentPart,\n UIContentPart,\n ThreadMessage,\n ThreadAssistantContentPart,\n ThreadAssistantMessage,\n ThreadUserContentPart,\n ThreadUserMessage,\n ThreadSystemMessage,\n CompleteAttachment,\n} from \"../../types\";\nimport {\n CoreToolCallContentPart,\n ThreadStep,\n Unstable_AudioContentPart,\n} from \"../../types/AssistantTypes\";\n\nexport type ThreadMessageLike = {\n role: \"assistant\" | \"user\" | \"system\";\n content:\n | string\n | (\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart\n | ToolCallContentPart<any, any>\n | CoreToolCallContentPart<any, any>\n | UIContentPart\n )[];\n id?: string | undefined;\n createdAt?: Date | undefined;\n status?: MessageStatus | undefined;\n attachments?: CompleteAttachment[] | undefined;\n metadata?: {\n steps?: ThreadStep[] | undefined;\n custom?: Record<string, unknown> | undefined;\n };\n};\n\nexport const fromThreadMessageLike = (\n like: ThreadMessageLike,\n fallbackId: string,\n fallbackStatus: MessageStatus,\n): ThreadMessage => {\n const { role, id, createdAt, attachments, status, metadata } = like;\n const common = {\n id: id ?? fallbackId,\n createdAt: createdAt ?? new Date(),\n };\n\n const content =\n typeof like.content === \"string\"\n ? [{ type: \"text\" as const, text: like.content }]\n : like.content;\n\n if (role !== \"user\" && attachments)\n throw new Error(\"attachments are only supported for user messages\");\n\n if (role !== \"assistant\" && status)\n throw new Error(\"status is only supported for assistant messages\");\n\n if (role !== \"assistant\" && metadata?.steps)\n throw new Error(\"metadata.steps is only supported for assistant messages\");\n\n switch (role) {\n case \"assistant\":\n return {\n ...common,\n role,\n content: content\n .map((part): ThreadAssistantContentPart | null => {\n const type = part.type;\n switch (type) {\n case \"text\":\n if (part.text.trim().length === 0) return null;\n return part;\n\n case \"ui\":\n return part;\n\n case \"tool-call\": {\n if (\"argsText\" in part) return part;\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n };\n }\n\n default: {\n const unhandledType: \"image\" | \"audio\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n })\n .filter((c) => !!c),\n status: status ?? fallbackStatus,\n metadata: {\n custom: metadata?.custom ?? {},\n steps: metadata?.steps ?? [],\n },\n } satisfies ThreadAssistantMessage;\n\n case \"user\":\n return {\n ...common,\n role,\n content: content.map((part): ThreadUserContentPart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"ui\":\n case \"image\":\n case \"audio\":\n return part;\n\n default: {\n const unhandledType: \"tool-call\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n attachments: attachments ?? [],\n metadata: {\n custom: metadata?.custom ?? {},\n },\n } satisfies ThreadUserMessage;\n\n case \"system\":\n if (content.length !== 1 || content[0]!.type !== \"text\")\n throw new Error(\n \"System messages must have exactly one text content part.\",\n );\n\n return {\n ...common,\n role,\n content: content as [TextContentPart],\n metadata: {\n custom: metadata?.custom ?? {},\n },\n } satisfies ThreadSystemMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n"],"mappings":";AA0CO,IAAM,wBAAwB,CACnC,MACA,YACA,mBACkB;AAClB,QAAM,EAAE,MAAM,IAAI,WAAW,aAAa,QAAQ,SAAS,IAAI;AAC/D,QAAM,SAAS;AAAA,IACb,IAAI,MAAM;AAAA,IACV,WAAW,aAAa,oBAAI,KAAK;AAAA,EACnC;AAEA,QAAM,UACJ,OAAO,KAAK,YAAY,WACpB,CAAC,EAAE,MAAM,QAAiB,MAAM,KAAK,QAAQ,CAAC,IAC9C,KAAK;AAEX,MAAI,SAAS,UAAU;AACrB,UAAM,IAAI,MAAM,kDAAkD;AAEpE,MAAI,SAAS,eAAe;AAC1B,UAAM,IAAI,MAAM,iDAAiD;AAEnE,MAAI,SAAS,eAAe,UAAU;AACpC,UAAM,IAAI,MAAM,yDAAyD;AAE3E,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QACN,IAAI,CAAC,SAA4C;AAChD,gBAAM,OAAO,KAAK;AAClB,kBAAQ,MAAM;AAAA,YACZ,KAAK;AACH,kBAAI,KAAK,KAAK,KAAK,EAAE,WAAW,EAAG,QAAO;AAC1C,qBAAO;AAAA,YAET,KAAK;AACH,qBAAO;AAAA,YAET,KAAK,aAAa;AAChB,kBAAI,cAAc,KAAM,QAAO;AAC/B,qBAAO;AAAA,gBACL,GAAG;AAAA,gBACH,UAAU,KAAK,UAAU,KAAK,IAAI;AAAA,cACpC;AAAA,YACF;AAAA,YAEA,SAAS;AACP,oBAAM,gBAAmC;AACzC,oBAAM,IAAI,MAAM,8BAA8B,aAAa,EAAE;AAAA,YAC/D;AAAA,UACF;AAAA,QACF,CAAC,EACA,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAAA,QACpB,QAAQ,UAAU;AAAA,QAClB,UAAU;AAAA,UACR,QAAQ,UAAU,UAAU,CAAC;AAAA,UAC7B,OAAO,UAAU,SAAS,CAAC;AAAA,QAC7B;AAAA,MACF;AAAA,IAEF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QAAQ,IAAI,CAAC,SAAgC;AACpD,gBAAM,OAAO,KAAK;AAClB,kBAAQ,MAAM;AAAA,YACZ,KAAK;AAAA,YACL,KAAK;AAAA,YACL,KAAK;AAAA,YACL,KAAK;AACH,qBAAO;AAAA,YAET,SAAS;AACP,oBAAM,gBAA6B;AACnC,oBAAM,IAAI,MAAM,8BAA8B,aAAa,EAAE;AAAA,YAC/D;AAAA,UACF;AAAA,QACF,CAAC;AAAA,QACD,aAAa,eAAe,CAAC;AAAA,QAC7B,UAAU;AAAA,UACR,QAAQ,UAAU,UAAU,CAAC;AAAA,QAC/B;AAAA,MACF;AAAA,IAEF,KAAK;AACH,UAAI,QAAQ,WAAW,KAAK,QAAQ,CAAC,EAAG,SAAS;AAC/C,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAEF,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,UAAU;AAAA,UACR,QAAQ,UAAU,UAAU,CAAC;AAAA,QAC/B;AAAA,MACF;AAAA,IAEF,SAAS;AACP,YAAM,kBAAyB;AAC/B,YAAM,IAAI,MAAM,yBAAyB,eAAe,EAAE;AAAA,IAC5D;AAAA,EACF;AACF;","names":[]}
|
@@ -5,11 +5,11 @@ export type ChatModelRunUpdate = {
|
|
5
5
|
metadata?: Record<string, unknown>;
|
6
6
|
};
|
7
7
|
export type ChatModelRunResult = {
|
8
|
-
content?: ThreadAssistantContentPart[];
|
9
|
-
status?: MessageStatus;
|
8
|
+
content?: ThreadAssistantContentPart[] | undefined;
|
9
|
+
status?: MessageStatus | undefined;
|
10
10
|
metadata?: {
|
11
|
-
steps?: ThreadStep[];
|
12
|
-
custom?: Record<string, unknown
|
11
|
+
steps?: ThreadStep[] | undefined;
|
12
|
+
custom?: Record<string, unknown> | undefined;
|
13
13
|
};
|
14
14
|
};
|
15
15
|
export type ChatModelRunOptions = {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ChatModelAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/ChatModelAdapter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,0BAA0B,EAC1B,aAAa,EACb,UAAU,EACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,0BAA0B,EAAE,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,0BAA0B,EAAE,CAAC;
|
1
|
+
{"version":3,"file":"ChatModelAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/ChatModelAdapter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,0BAA0B,EAC1B,aAAa,EACb,UAAU,EACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,0BAA0B,EAAE,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,0BAA0B,EAAE,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,EAAE;QACT,KAAK,CAAC,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC;QACjC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;KAC9C,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,WAAW,CAAC;IAEpB,2BAA2B,CAAC,EAAE,MAAM,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,CACH,OAAO,EAAE,mBAAmB,KACzB,OAAO,CAAC,kBAAkB,CAAC,GAAG,cAAc,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;CAC7E,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/ChatModelAdapter.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n MessageStatus,\n ThreadAssistantContentPart,\n ThreadMessage,\n ThreadStep,\n} from \"../../types/AssistantTypes\";\nimport type { ModelConfig } from \"../../types/ModelConfigTypes\";\n\nexport type ChatModelRunUpdate = {\n content: ThreadAssistantContentPart[];\n metadata?: Record<string, unknown>;\n};\n\nexport type ChatModelRunResult = {\n content?: ThreadAssistantContentPart[];\n status?: MessageStatus;\n metadata?: {\n steps?: ThreadStep[];\n custom?: Record<string, unknown
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/ChatModelAdapter.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n MessageStatus,\n ThreadAssistantContentPart,\n ThreadMessage,\n ThreadStep,\n} from \"../../types/AssistantTypes\";\nimport type { ModelConfig } from \"../../types/ModelConfigTypes\";\n\nexport type ChatModelRunUpdate = {\n content: ThreadAssistantContentPart[];\n metadata?: Record<string, unknown>;\n};\n\nexport type ChatModelRunResult = {\n content?: ThreadAssistantContentPart[] | undefined;\n status?: MessageStatus | undefined;\n metadata?: {\n steps?: ThreadStep[] | undefined;\n custom?: Record<string, unknown> | undefined;\n };\n};\n\nexport type ChatModelRunOptions = {\n messages: ThreadMessage[];\n abortSignal: AbortSignal;\n config: ModelConfig;\n\n unstable_assistantMessageId?: string;\n};\n\nexport type ChatModelAdapter = {\n run: (\n options: ChatModelRunOptions,\n ) => Promise<ChatModelRunResult> | AsyncGenerator<ChatModelRunResult, void>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LocalThreadRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/LocalThreadRuntimeCore.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EAEd,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,qBAAa,sBACX,SAAQ,qBACR,YAAW,iBAAiB;IAE5B,SAAgB,YAAY;;;;;;;;;MAS1B;IAEF,OAAO,CAAC,eAAe,CAAgC;IAEvD,SAAgB,UAAU,SAAS;IACnC,SAAgB,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAM;IAE9D,IAAW,QAAQ;;;;;MAElB;gBAGC,cAAc,EAAE,mBAAmB,EACnC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,uBAAuB;IAMlC,OAAO,CAAC,QAAQ,CAA2B;IAE3C,IAAW,MAAM,cAEhB;IAEM,UAAU,CAAC,OAAO,EAAE,uBAAuB;IA4BlD,OAAO,CAAC,2BAA2B;IAMtB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB7C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;
|
1
|
+
{"version":3,"file":"LocalThreadRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/LocalThreadRuntimeCore.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EAEd,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,qBAAa,sBACX,SAAQ,qBACR,YAAW,iBAAiB;IAE5B,SAAgB,YAAY;;;;;;;;;MAS1B;IAEF,OAAO,CAAC,eAAe,CAAgC;IAEvD,SAAgB,UAAU,SAAS;IACnC,SAAgB,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAM;IAE9D,IAAW,QAAQ;;;;;MAElB;gBAGC,cAAc,EAAE,mBAAmB,EACnC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,uBAAuB;IAMlC,OAAO,CAAC,QAAQ,CAA2B;IAE3C,IAAW,MAAM,cAEhB;IAEM,UAAU,CAAC,OAAO,EAAE,uBAAuB;IA4BlD,OAAO,CAAC,2BAA2B;IAMtB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB7C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YAuB/C,gBAAgB;IA0GvB,SAAS;IAKT,aAAa,CAAC,EACnB,SAAS,EACT,UAAU,EACV,MAAM,GACP,EAAE,oBAAoB;CAkCxB"}
|
@@ -102,6 +102,7 @@ var LocalThreadRuntimeCore = class extends import_BaseThreadRuntimeCore.BaseThre
|
|
102
102
|
role: "assistant",
|
103
103
|
status: { type: "running" },
|
104
104
|
content: [],
|
105
|
+
metadata: { steps: [], custom: {} },
|
105
106
|
createdAt: /* @__PURE__ */ new Date()
|
106
107
|
};
|
107
108
|
this._notifyEventSubscribers("run-start");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadRuntimeCore.tsx"],"sourcesContent":["import { generateId } from \"../../internal\";\nimport type {\n ModelConfigProvider,\n AppendMessage,\n ThreadAssistantMessage,\n} from \"../../types\";\nimport { fromCoreMessage } from \"../edge\";\nimport type { ChatModelRunResult } from \"./ChatModelAdapter\";\nimport { shouldContinue } from \"./shouldContinue\";\nimport { LocalRuntimeOptionsBase } from \"./LocalRuntimeOptions\";\nimport {\n AddToolResultOptions,\n ThreadSuggestion,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\nimport { LocalThreadMetadataRuntimeCore } from \"./LocalThreadMetadataRuntimeCore\";\n\nexport class LocalThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n public readonly capabilities = {\n switchToBranch: true,\n edit: true,\n reload: true,\n cancel: true,\n unstable_copy: true,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n private abortController: AbortController | null = null;\n\n public readonly isDisabled = false;\n public readonly suggestions: readonly ThreadSuggestion[] = [];\n\n public get adapters() {\n return this._options.adapters;\n }\n\n constructor(\n configProvider: ModelConfigProvider,\n threadId: string,\n options: LocalRuntimeOptionsBase,\n ) {\n super(configProvider, new LocalThreadMetadataRuntimeCore(threadId));\n this.setOptions(options);\n }\n\n private _options!: LocalRuntimeOptionsBase;\n\n public get extras() {\n return undefined;\n }\n\n public setOptions(options: LocalRuntimeOptionsBase) {\n if (this._options === options) return;\n\n this._options = options;\n\n let hasUpdates = false;\n\n const canSpeak = options.adapters?.speech !== undefined;\n if (this.capabilities.speech !== canSpeak) {\n this.capabilities.speech = canSpeak;\n hasUpdates = true;\n }\n\n const canAttach = options.adapters?.attachments !== undefined;\n if (this.capabilities.attachments !== canAttach) {\n this.capabilities.attachments = canAttach;\n hasUpdates = true;\n }\n\n const canFeedback = options.adapters?.feedback !== undefined;\n if (this.capabilities.feedback !== canFeedback) {\n this.capabilities.feedback = canFeedback;\n hasUpdates = true;\n }\n\n if (hasUpdates) this._notifySubscribers();\n }\n\n private _transitionAwayFromNewState() {\n if (this.metadata.state === \"new\") {\n this.metadata.create();\n }\n }\n\n public async append(message: AppendMessage): Promise<void> {\n this._transitionAwayFromNewState();\n\n const newMessage = fromCoreMessage(message, {\n attachments: message.attachments,\n });\n this.repository.addOrUpdateMessage(message.parentId, newMessage);\n\n const startRun = message.startRun ?? message.role === \"user\";\n if (startRun) {\n await this.startRun(newMessage.id);\n } else {\n this.repository.resetHead(newMessage.id);\n this._notifySubscribers();\n }\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n this._transitionAwayFromNewState();\n\n this.repository.resetHead(parentId);\n\n // add assistant message\n const id = generateId();\n let message: ThreadAssistantMessage = {\n id,\n role: \"assistant\",\n status: { type: \"running\" },\n content: [],\n createdAt: new Date(),\n };\n\n this._notifyEventSubscribers(\"run-start\");\n\n do {\n message = await this.performRoundtrip(parentId, message);\n } while (shouldContinue(message));\n }\n\n private async performRoundtrip(\n parentId: string | null,\n message: ThreadAssistantMessage,\n ) {\n const messages = this.repository.getMessages();\n\n // abort existing run\n this.abortController?.abort();\n this.abortController = new AbortController();\n\n const initialContent = message.content;\n const initialSteps = message.metadata?.steps;\n const initalCustom = message.metadata?.custom;\n const updateMessage = (m: Partial<ChatModelRunResult>) => {\n const newSteps = m.metadata?.steps;\n const steps = newSteps\n ? [...(initialSteps ?? []), ...newSteps]\n : undefined;\n\n message = {\n ...message,\n ...(m.content\n ? { content: [...initialContent, ...(m.content ?? [])] }\n : undefined),\n status: m.status ?? message.status,\n ...(m.metadata\n ? {\n metadata: {\n ...message.metadata,\n ...(steps ? { steps } : undefined),\n ...(m.metadata?.custom\n ? {\n custom: { ...(initalCustom ?? {}), ...m.metadata.custom },\n }\n : undefined),\n },\n }\n : undefined),\n };\n this.repository.addOrUpdateMessage(parentId, message);\n this._notifySubscribers();\n };\n\n const maxSteps = this._options.maxSteps ?? 2;\n\n const steps = message.metadata?.steps?.length ?? 0;\n if (steps >= maxSteps) {\n // reached max tool steps\n updateMessage({\n status: {\n type: \"incomplete\",\n reason: \"tool-calls\",\n },\n });\n return message;\n } else {\n updateMessage({\n status: {\n type: \"running\",\n },\n });\n }\n\n try {\n const promiseOrGenerator = this.adapters.chatModel.run({\n messages,\n abortSignal: this.abortController.signal,\n config: this.getModelConfig(),\n unstable_assistantMessageId: message.id,\n });\n\n // handle async iterator for streaming results\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n updateMessage(r);\n }\n } else {\n updateMessage(await promiseOrGenerator);\n }\n\n this.abortController = null;\n\n if (message.status.type === \"running\") {\n updateMessage({\n status: { type: \"complete\", reason: \"unknown\" },\n });\n }\n } catch (e) {\n this.abortController = null;\n\n // TODO this should be handled by the run result stream\n if (e instanceof Error && e.name === \"AbortError\") {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n } else {\n updateMessage({\n status: { type: \"incomplete\", reason: \"error\", error: e },\n });\n\n throw e;\n }\n }\n return message;\n }\n\n public cancelRun() {\n this.abortController?.abort();\n this.abortController = null;\n }\n\n public addToolResult({\n messageId,\n toolCallId,\n result,\n }: AddToolResultOptions) {\n const messageData = this.repository.getMessage(messageId);\n const { parentId } = messageData;\n let { message } = messageData;\n\n if (message.role !== \"assistant\")\n throw new Error(\"Tried to add tool result to non-assistant message\");\n\n let added = false;\n let found = false;\n const newContent = message.content.map((c) => {\n if (c.type !== \"tool-call\") return c;\n if (c.toolCallId !== toolCallId) return c;\n found = true;\n if (!c.result) added = true;\n return {\n ...c,\n result,\n };\n });\n\n if (!found)\n throw new Error(\"Tried to add tool result to non-existing tool call\");\n\n message = {\n ...message,\n content: newContent,\n };\n this.repository.addOrUpdateMessage(parentId, message);\n\n if (added && shouldContinue(message)) {\n this.performRoundtrip(parentId, message);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA2B;AAM3B,kBAAgC;AAEhC,4BAA+B;AAO/B,mCAAsC;AACtC,4CAA+C;AAExC,IAAM,yBAAN,cACG,mDAEV;AAAA,EACkB,eAAe;AAAA,IAC7B,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EAEQ,kBAA0C;AAAA,EAElC,aAAa;AAAA,EACb,cAA2C,CAAC;AAAA,EAE5D,IAAW,WAAW;AACpB,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,YACE,gBACA,UACA,SACA;AACA,UAAM,gBAAgB,IAAI,qEAA+B,QAAQ,CAAC;AAClE,SAAK,WAAW,OAAO;AAAA,EACzB;AAAA,EAEQ;AAAA,EAER,IAAW,SAAS;AAClB,WAAO;AAAA,EACT;AAAA,EAEO,WAAW,SAAkC;AAClD,QAAI,KAAK,aAAa,QAAS;AAE/B,SAAK,WAAW;AAEhB,QAAI,aAAa;AAEjB,UAAM,WAAW,QAAQ,UAAU,WAAW;AAC9C,QAAI,KAAK,aAAa,WAAW,UAAU;AACzC,WAAK,aAAa,SAAS;AAC3B,mBAAa;AAAA,IACf;AAEA,UAAM,YAAY,QAAQ,UAAU,gBAAgB;AACpD,QAAI,KAAK,aAAa,gBAAgB,WAAW;AAC/C,WAAK,aAAa,cAAc;AAChC,mBAAa;AAAA,IACf;AAEA,UAAM,cAAc,QAAQ,UAAU,aAAa;AACnD,QAAI,KAAK,aAAa,aAAa,aAAa;AAC9C,WAAK,aAAa,WAAW;AAC7B,mBA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AI,aAAS,sCAAe,OAAO,GAAG;AACpC,WAAK,iBAAiB,UAAU,OAAO;AAAA,IACzC;AAAA,EACF;AACF;","names":["steps"]}
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadRuntimeCore.tsx"],"sourcesContent":["import { generateId } from \"../../internal\";\nimport type {\n ModelConfigProvider,\n AppendMessage,\n ThreadAssistantMessage,\n} from \"../../types\";\nimport { fromCoreMessage } from \"../edge\";\nimport type { ChatModelRunResult } from \"./ChatModelAdapter\";\nimport { shouldContinue } from \"./shouldContinue\";\nimport { LocalRuntimeOptionsBase } from \"./LocalRuntimeOptions\";\nimport {\n AddToolResultOptions,\n ThreadSuggestion,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\nimport { LocalThreadMetadataRuntimeCore } from \"./LocalThreadMetadataRuntimeCore\";\n\nexport class LocalThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n public readonly capabilities = {\n switchToBranch: true,\n edit: true,\n reload: true,\n cancel: true,\n unstable_copy: true,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n private abortController: AbortController | null = null;\n\n public readonly isDisabled = false;\n public readonly suggestions: readonly ThreadSuggestion[] = [];\n\n public get adapters() {\n return this._options.adapters;\n }\n\n constructor(\n configProvider: ModelConfigProvider,\n threadId: string,\n options: LocalRuntimeOptionsBase,\n ) {\n super(configProvider, new LocalThreadMetadataRuntimeCore(threadId));\n this.setOptions(options);\n }\n\n private _options!: LocalRuntimeOptionsBase;\n\n public get extras() {\n return undefined;\n }\n\n public setOptions(options: LocalRuntimeOptionsBase) {\n if (this._options === options) return;\n\n this._options = options;\n\n let hasUpdates = false;\n\n const canSpeak = options.adapters?.speech !== undefined;\n if (this.capabilities.speech !== canSpeak) {\n this.capabilities.speech = canSpeak;\n hasUpdates = true;\n }\n\n const canAttach = options.adapters?.attachments !== undefined;\n if (this.capabilities.attachments !== canAttach) {\n this.capabilities.attachments = canAttach;\n hasUpdates = true;\n }\n\n const canFeedback = options.adapters?.feedback !== undefined;\n if (this.capabilities.feedback !== canFeedback) {\n this.capabilities.feedback = canFeedback;\n hasUpdates = true;\n }\n\n if (hasUpdates) this._notifySubscribers();\n }\n\n private _transitionAwayFromNewState() {\n if (this.metadata.state === \"new\") {\n this.metadata.create();\n }\n }\n\n public async append(message: AppendMessage): Promise<void> {\n this._transitionAwayFromNewState();\n\n const newMessage = fromCoreMessage(message, {\n attachments: message.attachments,\n });\n this.repository.addOrUpdateMessage(message.parentId, newMessage);\n\n const startRun = message.startRun ?? message.role === \"user\";\n if (startRun) {\n await this.startRun(newMessage.id);\n } else {\n this.repository.resetHead(newMessage.id);\n this._notifySubscribers();\n }\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n this._transitionAwayFromNewState();\n\n this.repository.resetHead(parentId);\n\n // add assistant message\n const id = generateId();\n let message: ThreadAssistantMessage = {\n id,\n role: \"assistant\",\n status: { type: \"running\" },\n content: [],\n metadata: { steps: [], custom: {} },\n createdAt: new Date(),\n };\n\n this._notifyEventSubscribers(\"run-start\");\n\n do {\n message = await this.performRoundtrip(parentId, message);\n } while (shouldContinue(message));\n }\n\n private async performRoundtrip(\n parentId: string | null,\n message: ThreadAssistantMessage,\n ) {\n const messages = this.repository.getMessages();\n\n // abort existing run\n this.abortController?.abort();\n this.abortController = new AbortController();\n\n const initialContent = message.content;\n const initialSteps = message.metadata?.steps;\n const initalCustom = message.metadata?.custom;\n const updateMessage = (m: Partial<ChatModelRunResult>) => {\n const newSteps = m.metadata?.steps;\n const steps = newSteps\n ? [...(initialSteps ?? []), ...newSteps]\n : undefined;\n\n message = {\n ...message,\n ...(m.content\n ? { content: [...initialContent, ...(m.content ?? [])] }\n : undefined),\n status: m.status ?? message.status,\n ...(m.metadata\n ? {\n metadata: {\n ...message.metadata,\n ...(steps ? { steps } : undefined),\n ...(m.metadata?.custom\n ? {\n custom: { ...(initalCustom ?? {}), ...m.metadata.custom },\n }\n : undefined),\n },\n }\n : undefined),\n };\n this.repository.addOrUpdateMessage(parentId, message);\n this._notifySubscribers();\n };\n\n const maxSteps = this._options.maxSteps ?? 2;\n\n const steps = message.metadata?.steps?.length ?? 0;\n if (steps >= maxSteps) {\n // reached max tool steps\n updateMessage({\n status: {\n type: \"incomplete\",\n reason: \"tool-calls\",\n },\n });\n return message;\n } else {\n updateMessage({\n status: {\n type: \"running\",\n },\n });\n }\n\n try {\n const promiseOrGenerator = this.adapters.chatModel.run({\n messages,\n abortSignal: this.abortController.signal,\n config: this.getModelConfig(),\n unstable_assistantMessageId: message.id,\n });\n\n // handle async iterator for streaming results\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n updateMessage(r);\n }\n } else {\n updateMessage(await promiseOrGenerator);\n }\n\n this.abortController = null;\n\n if (message.status.type === \"running\") {\n updateMessage({\n status: { type: \"complete\", reason: \"unknown\" },\n });\n }\n } catch (e) {\n this.abortController = null;\n\n // TODO this should be handled by the run result stream\n if (e instanceof Error && e.name === \"AbortError\") {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n } else {\n updateMessage({\n status: { type: \"incomplete\", reason: \"error\", error: e },\n });\n\n throw e;\n }\n }\n return message;\n }\n\n public cancelRun() {\n this.abortController?.abort();\n this.abortController = null;\n }\n\n public addToolResult({\n messageId,\n toolCallId,\n result,\n }: AddToolResultOptions) {\n const messageData = this.repository.getMessage(messageId);\n const { parentId } = messageData;\n let { message } = messageData;\n\n if (message.role !== \"assistant\")\n throw new Error(\"Tried to add tool result to non-assistant message\");\n\n let added = false;\n let found = false;\n const newContent = message.content.map((c) => {\n if (c.type !== \"tool-call\") return c;\n if (c.toolCallId !== toolCallId) return c;\n found = true;\n if (!c.result) added = true;\n return {\n ...c,\n result,\n };\n });\n\n if (!found)\n throw new Error(\"Tried to add tool result to non-existing tool call\");\n\n message = {\n ...message,\n content: newContent,\n };\n this.repository.addOrUpdateMessage(parentId, message);\n\n if (added && shouldContinue(message)) {\n this.performRoundtrip(parentId, message);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA2B;AAM3B,kBAAgC;AAEhC,4BAA+B;AAO/B,mCAAsC;AACtC,4CAA+C;AAExC,IAAM,yBAAN,cACG,mDAEV;AAAA,EACkB,eAAe;AAAA,IAC7B,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EAEQ,kBAA0C;AAAA,EAElC,aAAa;AAAA,EACb,cAA2C,CAAC;AAAA,EAE5D,IAAW,WAAW;AACpB,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,YACE,gBACA,UACA,SACA;AACA,UAAM,gBAAgB,IAAI,qEAA+B,QAAQ,CAAC;AAClE,SAAK,WAAW,OAAO;AAAA,EACzB;AAAA,EAEQ;AAAA,EAER,IAAW,SAAS;AAClB,WAAO;AAAA,EACT;AAAA,EAEO,WAAW,SAAkC;AAClD,QAAI,KAAK,aAAa,QAAS;AAE/B,SAAK,WAAW;AAEhB,QAAI,aAAa;AAEjB,UAAM,WAAW,QAAQ,UAAU,WAAW;AAC9C,QAAI,KAAK,aAAa,WAAW,UAAU;AACzC,WAAK,aAAa,SAAS;AAC3B,mBAAa;AAAA,IACf;AAEA,UAAM,YAAY,QAAQ,UAAU,gBAAgB;AACpD,QAAI,KAAK,aAAa,gBAAgB,WAAW;AAC/C,WAAK,aAAa,cAAc;AAChC,mBAAa;AAAA,IACf;AAEA,UAAM,cAAc,QAAQ,UAAU,aAAa;AACnD,QAAI,KAAK,aAAa,aAAa,aAAa;AAC9C,WAAK,aAAa,WAAW;AAC7B,mBAAa;AAAA,IACf;AAEA,QAAI,WAAY,MAAK,mBAAmB;AAAA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AAEpD,QAAI,aAAS,sCAAe,OAAO,GAAG;AACpC,WAAK,iBAAiB,UAAU,OAAO;AAAA,IACzC;AAAA,EACF;AACF;","names":["steps"]}
|
@@ -78,6 +78,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
78
78
|
role: "assistant",
|
79
79
|
status: { type: "running" },
|
80
80
|
content: [],
|
81
|
+
metadata: { steps: [], custom: {} },
|
81
82
|
createdAt: /* @__PURE__ */ new Date()
|
82
83
|
};
|
83
84
|
this._notifyEventSubscribers("run-start");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadRuntimeCore.tsx"],"sourcesContent":["import { generateId } from \"../../internal\";\nimport type {\n ModelConfigProvider,\n AppendMessage,\n ThreadAssistantMessage,\n} from \"../../types\";\nimport { fromCoreMessage } from \"../edge\";\nimport type { ChatModelRunResult } from \"./ChatModelAdapter\";\nimport { shouldContinue } from \"./shouldContinue\";\nimport { LocalRuntimeOptionsBase } from \"./LocalRuntimeOptions\";\nimport {\n AddToolResultOptions,\n ThreadSuggestion,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\nimport { LocalThreadMetadataRuntimeCore } from \"./LocalThreadMetadataRuntimeCore\";\n\nexport class LocalThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n public readonly capabilities = {\n switchToBranch: true,\n edit: true,\n reload: true,\n cancel: true,\n unstable_copy: true,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n private abortController: AbortController | null = null;\n\n public readonly isDisabled = false;\n public readonly suggestions: readonly ThreadSuggestion[] = [];\n\n public get adapters() {\n return this._options.adapters;\n }\n\n constructor(\n configProvider: ModelConfigProvider,\n threadId: string,\n options: LocalRuntimeOptionsBase,\n ) {\n super(configProvider, new LocalThreadMetadataRuntimeCore(threadId));\n this.setOptions(options);\n }\n\n private _options!: LocalRuntimeOptionsBase;\n\n public get extras() {\n return undefined;\n }\n\n public setOptions(options: LocalRuntimeOptionsBase) {\n if (this._options === options) return;\n\n this._options = options;\n\n let hasUpdates = false;\n\n const canSpeak = options.adapters?.speech !== undefined;\n if (this.capabilities.speech !== canSpeak) {\n this.capabilities.speech = canSpeak;\n hasUpdates = true;\n }\n\n const canAttach = options.adapters?.attachments !== undefined;\n if (this.capabilities.attachments !== canAttach) {\n this.capabilities.attachments = canAttach;\n hasUpdates = true;\n }\n\n const canFeedback = options.adapters?.feedback !== undefined;\n if (this.capabilities.feedback !== canFeedback) {\n this.capabilities.feedback = canFeedback;\n hasUpdates = true;\n }\n\n if (hasUpdates) this._notifySubscribers();\n }\n\n private _transitionAwayFromNewState() {\n if (this.metadata.state === \"new\") {\n this.metadata.create();\n }\n }\n\n public async append(message: AppendMessage): Promise<void> {\n this._transitionAwayFromNewState();\n\n const newMessage = fromCoreMessage(message, {\n attachments: message.attachments,\n });\n this.repository.addOrUpdateMessage(message.parentId, newMessage);\n\n const startRun = message.startRun ?? message.role === \"user\";\n if (startRun) {\n await this.startRun(newMessage.id);\n } else {\n this.repository.resetHead(newMessage.id);\n this._notifySubscribers();\n }\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n this._transitionAwayFromNewState();\n\n this.repository.resetHead(parentId);\n\n // add assistant message\n const id = generateId();\n let message: ThreadAssistantMessage = {\n id,\n role: \"assistant\",\n status: { type: \"running\" },\n content: [],\n createdAt: new Date(),\n };\n\n this._notifyEventSubscribers(\"run-start\");\n\n do {\n message = await this.performRoundtrip(parentId, message);\n } while (shouldContinue(message));\n }\n\n private async performRoundtrip(\n parentId: string | null,\n message: ThreadAssistantMessage,\n ) {\n const messages = this.repository.getMessages();\n\n // abort existing run\n this.abortController?.abort();\n this.abortController = new AbortController();\n\n const initialContent = message.content;\n const initialSteps = message.metadata?.steps;\n const initalCustom = message.metadata?.custom;\n const updateMessage = (m: Partial<ChatModelRunResult>) => {\n const newSteps = m.metadata?.steps;\n const steps = newSteps\n ? [...(initialSteps ?? []), ...newSteps]\n : undefined;\n\n message = {\n ...message,\n ...(m.content\n ? { content: [...initialContent, ...(m.content ?? [])] }\n : undefined),\n status: m.status ?? message.status,\n ...(m.metadata\n ? {\n metadata: {\n ...message.metadata,\n ...(steps ? { steps } : undefined),\n ...(m.metadata?.custom\n ? {\n custom: { ...(initalCustom ?? {}), ...m.metadata.custom },\n }\n : undefined),\n },\n }\n : undefined),\n };\n this.repository.addOrUpdateMessage(parentId, message);\n this._notifySubscribers();\n };\n\n const maxSteps = this._options.maxSteps ?? 2;\n\n const steps = message.metadata?.steps?.length ?? 0;\n if (steps >= maxSteps) {\n // reached max tool steps\n updateMessage({\n status: {\n type: \"incomplete\",\n reason: \"tool-calls\",\n },\n });\n return message;\n } else {\n updateMessage({\n status: {\n type: \"running\",\n },\n });\n }\n\n try {\n const promiseOrGenerator = this.adapters.chatModel.run({\n messages,\n abortSignal: this.abortController.signal,\n config: this.getModelConfig(),\n unstable_assistantMessageId: message.id,\n });\n\n // handle async iterator for streaming results\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n updateMessage(r);\n }\n } else {\n updateMessage(await promiseOrGenerator);\n }\n\n this.abortController = null;\n\n if (message.status.type === \"running\") {\n updateMessage({\n status: { type: \"complete\", reason: \"unknown\" },\n });\n }\n } catch (e) {\n this.abortController = null;\n\n // TODO this should be handled by the run result stream\n if (e instanceof Error && e.name === \"AbortError\") {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n } else {\n updateMessage({\n status: { type: \"incomplete\", reason: \"error\", error: e },\n });\n\n throw e;\n }\n }\n return message;\n }\n\n public cancelRun() {\n this.abortController?.abort();\n this.abortController = null;\n }\n\n public addToolResult({\n messageId,\n toolCallId,\n result,\n }: AddToolResultOptions) {\n const messageData = this.repository.getMessage(messageId);\n const { parentId } = messageData;\n let { message } = messageData;\n\n if (message.role !== \"assistant\")\n throw new Error(\"Tried to add tool result to non-assistant message\");\n\n let added = false;\n let found = false;\n const newContent = message.content.map((c) => {\n if (c.type !== \"tool-call\") return c;\n if (c.toolCallId !== toolCallId) return c;\n found = true;\n if (!c.result) added = true;\n return {\n ...c,\n result,\n };\n });\n\n if (!found)\n throw new Error(\"Tried to add tool result to non-existing tool call\");\n\n message = {\n ...message,\n content: newContent,\n };\n this.repository.addOrUpdateMessage(parentId, message);\n\n if (added && shouldContinue(message)) {\n this.performRoundtrip(parentId, message);\n }\n }\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAM3B,SAAS,uBAAuB;AAEhC,SAAS,sBAAsB;AAO/B,SAAS,6BAA6B;AACtC,SAAS,sCAAsC;AAExC,IAAM,yBAAN,cACG,sBAEV;AAAA,EACkB,eAAe;AAAA,IAC7B,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EAEQ,kBAA0C;AAAA,EAElC,aAAa;AAAA,EACb,cAA2C,CAAC;AAAA,EAE5D,IAAW,WAAW;AACpB,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,YACE,gBACA,UACA,SACA;AACA,UAAM,gBAAgB,IAAI,+BAA+B,QAAQ,CAAC;AAClE,SAAK,WAAW,OAAO;AAAA,EACzB;AAAA,EAEQ;AAAA,EAER,IAAW,SAAS;AAClB,WAAO;AAAA,EACT;AAAA,EAEO,WAAW,SAAkC;AAClD,QAAI,KAAK,aAAa,QAAS;AAE/B,SAAK,WAAW;AAEhB,QAAI,aAAa;AAEjB,UAAM,WAAW,QAAQ,UAAU,WAAW;AAC9C,QAAI,KAAK,aAAa,WAAW,UAAU;AACzC,WAAK,aAAa,SAAS;AAC3B,mBAAa;AAAA,IACf;AAEA,UAAM,YAAY,QAAQ,UAAU,gBAAgB;AACpD,QAAI,KAAK,aAAa,gBAAgB,WAA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AAC;AAED,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,oDAAoD;AAEtE,cAAU;AAAA,MACR,GAAG;AAAA,MACH,SAAS;AAAA,IACX;AACA,SAAK,WAAW,mBAAmB,UAAU,OAAO;AAEpD,QAAI,SAAS,eAAe,OAAO,GAAG;AACpC,WAAK,iBAAiB,UAAU,OAAO;AAAA,IACzC;AAAA,EACF;AACF;","names":["steps"]}
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadRuntimeCore.tsx"],"sourcesContent":["import { generateId } from \"../../internal\";\nimport type {\n ModelConfigProvider,\n AppendMessage,\n ThreadAssistantMessage,\n} from \"../../types\";\nimport { fromCoreMessage } from \"../edge\";\nimport type { ChatModelRunResult } from \"./ChatModelAdapter\";\nimport { shouldContinue } from \"./shouldContinue\";\nimport { LocalRuntimeOptionsBase } from \"./LocalRuntimeOptions\";\nimport {\n AddToolResultOptions,\n ThreadSuggestion,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\nimport { LocalThreadMetadataRuntimeCore } from \"./LocalThreadMetadataRuntimeCore\";\n\nexport class LocalThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n public readonly capabilities = {\n switchToBranch: true,\n edit: true,\n reload: true,\n cancel: true,\n unstable_copy: true,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n private abortController: AbortController | null = null;\n\n public readonly isDisabled = false;\n public readonly suggestions: readonly ThreadSuggestion[] = [];\n\n public get adapters() {\n return this._options.adapters;\n }\n\n constructor(\n configProvider: ModelConfigProvider,\n threadId: string,\n options: LocalRuntimeOptionsBase,\n ) {\n super(configProvider, new LocalThreadMetadataRuntimeCore(threadId));\n this.setOptions(options);\n }\n\n private _options!: LocalRuntimeOptionsBase;\n\n public get extras() {\n return undefined;\n }\n\n public setOptions(options: LocalRuntimeOptionsBase) {\n if (this._options === options) return;\n\n this._options = options;\n\n let hasUpdates = false;\n\n const canSpeak = options.adapters?.speech !== undefined;\n if (this.capabilities.speech !== canSpeak) {\n this.capabilities.speech = canSpeak;\n hasUpdates = true;\n }\n\n const canAttach = options.adapters?.attachments !== undefined;\n if (this.capabilities.attachments !== canAttach) {\n this.capabilities.attachments = canAttach;\n hasUpdates = true;\n }\n\n const canFeedback = options.adapters?.feedback !== undefined;\n if (this.capabilities.feedback !== canFeedback) {\n this.capabilities.feedback = canFeedback;\n hasUpdates = true;\n }\n\n if (hasUpdates) this._notifySubscribers();\n }\n\n private _transitionAwayFromNewState() {\n if (this.metadata.state === \"new\") {\n this.metadata.create();\n }\n }\n\n public async append(message: AppendMessage): Promise<void> {\n this._transitionAwayFromNewState();\n\n const newMessage = fromCoreMessage(message, {\n attachments: message.attachments,\n });\n this.repository.addOrUpdateMessage(message.parentId, newMessage);\n\n const startRun = message.startRun ?? message.role === \"user\";\n if (startRun) {\n await this.startRun(newMessage.id);\n } else {\n this.repository.resetHead(newMessage.id);\n this._notifySubscribers();\n }\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n this._transitionAwayFromNewState();\n\n this.repository.resetHead(parentId);\n\n // add assistant message\n const id = generateId();\n let message: ThreadAssistantMessage = {\n id,\n role: \"assistant\",\n status: { type: \"running\" },\n content: [],\n metadata: { steps: [], custom: {} },\n createdAt: new Date(),\n };\n\n this._notifyEventSubscribers(\"run-start\");\n\n do {\n message = await this.performRoundtrip(parentId, message);\n } while (shouldContinue(message));\n }\n\n private async performRoundtrip(\n parentId: string | null,\n message: ThreadAssistantMessage,\n ) {\n const messages = this.repository.getMessages();\n\n // abort existing run\n this.abortController?.abort();\n this.abortController = new AbortController();\n\n const initialContent = message.content;\n const initialSteps = message.metadata?.steps;\n const initalCustom = message.metadata?.custom;\n const updateMessage = (m: Partial<ChatModelRunResult>) => {\n const newSteps = m.metadata?.steps;\n const steps = newSteps\n ? [...(initialSteps ?? []), ...newSteps]\n : undefined;\n\n message = {\n ...message,\n ...(m.content\n ? { content: [...initialContent, ...(m.content ?? [])] }\n : undefined),\n status: m.status ?? message.status,\n ...(m.metadata\n ? {\n metadata: {\n ...message.metadata,\n ...(steps ? { steps } : undefined),\n ...(m.metadata?.custom\n ? {\n custom: { ...(initalCustom ?? {}), ...m.metadata.custom },\n }\n : undefined),\n },\n }\n : undefined),\n };\n this.repository.addOrUpdateMessage(parentId, message);\n this._notifySubscribers();\n };\n\n const maxSteps = this._options.maxSteps ?? 2;\n\n const steps = message.metadata?.steps?.length ?? 0;\n if (steps >= maxSteps) {\n // reached max tool steps\n updateMessage({\n status: {\n type: \"incomplete\",\n reason: \"tool-calls\",\n },\n });\n return message;\n } else {\n updateMessage({\n status: {\n type: \"running\",\n },\n });\n }\n\n try {\n const promiseOrGenerator = this.adapters.chatModel.run({\n messages,\n abortSignal: this.abortController.signal,\n config: this.getModelConfig(),\n unstable_assistantMessageId: message.id,\n });\n\n // handle async iterator for streaming results\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n updateMessage(r);\n }\n } else {\n updateMessage(await promiseOrGenerator);\n }\n\n this.abortController = null;\n\n if (message.status.type === \"running\") {\n updateMessage({\n status: { type: \"complete\", reason: \"unknown\" },\n });\n }\n } catch (e) {\n this.abortController = null;\n\n // TODO this should be handled by the run result stream\n if (e instanceof Error && e.name === \"AbortError\") {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n } else {\n updateMessage({\n status: { type: \"incomplete\", reason: \"error\", error: e },\n });\n\n throw e;\n }\n }\n return message;\n }\n\n public cancelRun() {\n this.abortController?.abort();\n this.abortController = null;\n }\n\n public addToolResult({\n messageId,\n toolCallId,\n result,\n }: AddToolResultOptions) {\n const messageData = this.repository.getMessage(messageId);\n const { parentId } = messageData;\n let { message } = messageData;\n\n if (message.role !== \"assistant\")\n throw new Error(\"Tried to add tool result to non-assistant message\");\n\n let added = false;\n let found = false;\n const newContent = message.content.map((c) => {\n if (c.type !== \"tool-call\") return c;\n if (c.toolCallId !== toolCallId) return c;\n found = true;\n if (!c.result) added = true;\n return {\n ...c,\n result,\n };\n });\n\n if (!found)\n throw new Error(\"Tried to add tool result to non-existing tool call\");\n\n message = {\n ...message,\n content: newContent,\n };\n this.repository.addOrUpdateMessage(parentId, message);\n\n if (added && shouldContinue(message)) {\n this.performRoundtrip(parentId, message);\n }\n }\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAM3B,SAAS,uBAAuB;AAEhC,SAAS,sBAAsB;AAO/B,SAAS,6BAA6B;AACtC,SAAS,sCAAsC;AAExC,IAAM,yBAAN,cACG,sBAEV;AAAA,EACkB,eAAe;AAAA,IAC7B,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EAEQ,kBAA0C;AAAA,EAElC,aAAa;AAAA,EACb,cAA2C,CAAC;AAAA,EAE5D,IAAW,WAAW;AACpB,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,YACE,gBACA,UACA,SACA;AACA,UAAM,gBAAgB,IAAI,+BAA+B,QAAQ,CAAC;AAClE,SAAK,WAAW,OAAO;AAAA,EACzB;AAAA,EAEQ;AAAA,EAER,IAAW,SAAS;AAClB,WAAO;AAAA,EACT;AAAA,EAEO,WAAW,SAAkC;AAClD,QAAI,KAAK,aAAa,QAAS;AAE/B,SAAK,WAAW;AAEhB,QAAI,aAAa;AAEjB,UAAM,WAAW,QAAQ,UAAU,WAAW;AAC9C,QAAI,KAAK,aAAa,WAAW,UAAU;AACzC,WAAK,aAAa,SAAS;AAC3B,mBAAa;AAAA,IACf;AAEA,UAAM,YAAY,QAAQ,UAAU,gBAAgB;AACpD,QAAI,KAAK,aAAa,gBAAgB,WAAW;AAC/C,WAAK,aAAa,cAAc;AAChC,mBAAa;AAAA,IACf;AAEA,UAAM,cAAc,QAAQ,UA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AC;AACH,YAAM,IAAI,MAAM,oDAAoD;AAEtE,cAAU;AAAA,MACR,GAAG;AAAA,MACH,SAAS;AAAA,IACX;AACA,SAAK,WAAW,mBAAmB,UAAU,OAAO;AAEpD,QAAI,SAAS,eAAe,OAAO,GAAG;AACpC,WAAK,iBAAiB,UAAU,OAAO;AAAA,IACzC;AAAA,EACF;AACF;","names":["steps"]}
|
@@ -72,19 +72,25 @@ export type MessageStatus = {
|
|
72
72
|
export type ThreadSystemMessage = MessageCommonProps & {
|
73
73
|
role: "system";
|
74
74
|
content: [TextContentPart];
|
75
|
+
metadata: {
|
76
|
+
custom: Record<string, unknown>;
|
77
|
+
};
|
75
78
|
};
|
76
79
|
export type ThreadUserMessage = MessageCommonProps & {
|
77
80
|
role: "user";
|
78
81
|
content: ThreadUserContentPart[];
|
79
82
|
attachments: readonly CompleteAttachment[];
|
83
|
+
metadata: {
|
84
|
+
custom: Record<string, unknown>;
|
85
|
+
};
|
80
86
|
};
|
81
87
|
export type ThreadAssistantMessage = MessageCommonProps & {
|
82
88
|
role: "assistant";
|
83
89
|
content: ThreadAssistantContentPart[];
|
84
90
|
status: MessageStatus;
|
85
|
-
metadata
|
86
|
-
steps
|
87
|
-
custom
|
91
|
+
metadata: {
|
92
|
+
steps: ThreadStep[];
|
93
|
+
custom: Record<string, unknown>;
|
88
94
|
};
|
89
95
|
};
|
90
96
|
export type AppendMessage = CoreMessage & {
|
@@ -94,7 +100,10 @@ export type AppendMessage = CoreMessage & {
|
|
94
100
|
};
|
95
101
|
type BaseThreadMessage = {
|
96
102
|
status?: ThreadAssistantMessage["status"];
|
97
|
-
metadata
|
103
|
+
metadata: {
|
104
|
+
steps?: ThreadStep[];
|
105
|
+
custom: Record<string, unknown>;
|
106
|
+
};
|
98
107
|
attachments?: ThreadUserMessage["attachments"];
|
99
108
|
};
|
100
109
|
export type ThreadMessage = BaseThreadMessage & (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);
|
@@ -1 +1 @@
|
|
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AAC;IAC3C,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,MAAM,CAAC,EAAE,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAC1C,QAAQ,EAAE;QACR,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACjC,CAAC;IACF,WAAW,CAAC,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAC3C,CAAC,mBAAmB,GAAG,iBAAiB,GAAG,sBAAsB,CAAC,CAAC;AAErE,oDAAoD;AAEpD,MAAM,MAAM,mBAAmB,GAC3B,eAAe,GACf,gBAAgB,GAChB,yBAAyB,CAAC;AAC9B,MAAM,MAAM,wBAAwB,GAChC,eAAe,GACf,uBAAuB,CAAC;AAE5B,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,CAAC,eAAe,CAAC,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,mBAAmB,EAAE,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,wBAAwB,EAAE,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB,iBAAiB,GACjB,eAAe,GACf,oBAAoB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/types/AssistantTypes.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { CompleteAttachment } from \"./AttachmentTypes\";\n\nexport type MessageRole = \"user\" | \"assistant\" | \"system\";\n\nexport type TextContentPart = {\n type: \"text\";\n text: string;\n};\n\nexport type ImageContentPart = {\n type: \"image\";\n image: string;\n};\n\nexport type Unstable_AudioContentPart = {\n type: \"audio\";\n audio: {\n data: string;\n format: \"mp3\" | \"wav\";\n };\n};\n\nexport type UIContentPart = {\n type: \"ui\";\n display: ReactNode;\n};\n\nexport type CoreToolCallContentPart<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = {\n type: \"tool-call\";\n toolCallId: string;\n toolName: string;\n args: TArgs;\n result?: TResult | undefined;\n isError?: boolean | undefined;\n};\n\nexport type ToolCallContentPart<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = CoreToolCallContentPart<TArgs, TResult> & {\n argsText: string;\n};\n\nexport type ThreadUserContentPart =\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart\n | UIContentPart;\n\nexport type ThreadAssistantContentPart =\n | TextContentPart\n | ToolCallContentPart\n | UIContentPart;\n\ntype MessageCommonProps = {\n id: string;\n createdAt: Date;\n};\n\nexport type ThreadStep = {\n usage?:\n | {\n promptTokens: number;\n completionTokens: number;\n }\n | undefined;\n};\n\nexport type ContentPartStatus =\n | {\n type: \"running\";\n }\n | {\n type: \"complete\";\n }\n | {\n type: \"incomplete\";\n reason: \"cancelled\" | \"length\" | \"content-filter\" | \"other\" | \"error\";\n error?: unknown;\n };\n\nexport type ToolCallContentPartStatus =\n | {\n type: \"requires-action\";\n reason: \"tool-calls\";\n }\n | ContentPartStatus;\n\nexport type MessageStatus =\n | {\n type: \"running\";\n }\n | {\n type: \"requires-action\";\n reason: \"tool-calls\";\n }\n | {\n type: \"complete\";\n reason: \"stop\" | \"unknown\";\n }\n | {\n type: \"incomplete\";\n reason:\n | \"cancelled\"\n | \"tool-calls\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n error?: unknown;\n };\n\nexport type ThreadSystemMessage = MessageCommonProps & {\n role: \"system\";\n content: [TextContentPart];\n};\n\nexport type ThreadUserMessage = MessageCommonProps & {\n role: \"user\";\n content: ThreadUserContentPart[];\n attachments: readonly CompleteAttachment[];\n
|
1
|
+
{"version":3,"sources":["../../src/types/AssistantTypes.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { CompleteAttachment } from \"./AttachmentTypes\";\n\nexport type MessageRole = \"user\" | \"assistant\" | \"system\";\n\nexport type TextContentPart = {\n type: \"text\";\n text: string;\n};\n\nexport type ImageContentPart = {\n type: \"image\";\n image: string;\n};\n\nexport type Unstable_AudioContentPart = {\n type: \"audio\";\n audio: {\n data: string;\n format: \"mp3\" | \"wav\";\n };\n};\n\nexport type UIContentPart = {\n type: \"ui\";\n display: ReactNode;\n};\n\nexport type CoreToolCallContentPart<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = {\n type: \"tool-call\";\n toolCallId: string;\n toolName: string;\n args: TArgs;\n result?: TResult | undefined;\n isError?: boolean | undefined;\n};\n\nexport type ToolCallContentPart<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = CoreToolCallContentPart<TArgs, TResult> & {\n argsText: string;\n};\n\nexport type ThreadUserContentPart =\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart\n | UIContentPart;\n\nexport type ThreadAssistantContentPart =\n | TextContentPart\n | ToolCallContentPart\n | UIContentPart;\n\ntype MessageCommonProps = {\n id: string;\n createdAt: Date;\n};\n\nexport type ThreadStep = {\n usage?:\n | {\n promptTokens: number;\n completionTokens: number;\n }\n | undefined;\n};\n\nexport type ContentPartStatus =\n | {\n type: \"running\";\n }\n | {\n type: \"complete\";\n }\n | {\n type: \"incomplete\";\n reason: \"cancelled\" | \"length\" | \"content-filter\" | \"other\" | \"error\";\n error?: unknown;\n };\n\nexport type ToolCallContentPartStatus =\n | {\n type: \"requires-action\";\n reason: \"tool-calls\";\n }\n | ContentPartStatus;\n\nexport type MessageStatus =\n | {\n type: \"running\";\n }\n | {\n type: \"requires-action\";\n reason: \"tool-calls\";\n }\n | {\n type: \"complete\";\n reason: \"stop\" | \"unknown\";\n }\n | {\n type: \"incomplete\";\n reason:\n | \"cancelled\"\n | \"tool-calls\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n error?: unknown;\n };\n\nexport type ThreadSystemMessage = MessageCommonProps & {\n role: \"system\";\n content: [TextContentPart];\n metadata: {\n custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadUserMessage = MessageCommonProps & {\n role: \"user\";\n content: ThreadUserContentPart[];\n attachments: readonly CompleteAttachment[];\n metadata: {\n custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadAssistantMessage = MessageCommonProps & {\n role: \"assistant\";\n content: ThreadAssistantContentPart[];\n status: MessageStatus;\n metadata: {\n steps: ThreadStep[];\n custom: Record<string, unknown>;\n };\n};\n\nexport type AppendMessage = CoreMessage & {\n parentId: string | null;\n attachments: readonly CompleteAttachment[];\n startRun?: boolean | undefined;\n};\n\ntype BaseThreadMessage = {\n status?: ThreadAssistantMessage[\"status\"];\n metadata: {\n steps?: ThreadStep[];\n custom: Record<string, unknown>;\n };\n attachments?: ThreadUserMessage[\"attachments\"];\n};\n\nexport type ThreadMessage = BaseThreadMessage &\n (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);\n\n/** Core Message Types (without UI content parts) */\n\nexport type CoreUserContentPart =\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart;\nexport type CoreAssistantContentPart =\n | TextContentPart\n | CoreToolCallContentPart;\n\nexport type CoreSystemMessage = {\n role: \"system\";\n content: [TextContentPart];\n};\n\nexport type CoreUserMessage = {\n role: \"user\";\n content: CoreUserContentPart[];\n};\n\nexport type CoreAssistantMessage = {\n role: \"assistant\";\n content: CoreAssistantContentPart[];\n};\n\nexport type CoreMessage =\n | CoreSystemMessage\n | CoreUserMessage\n | CoreAssistantMessage;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/package.json
CHANGED
@@ -29,7 +29,7 @@
|
|
29
29
|
"conversational-ui",
|
30
30
|
"conversational-ai"
|
31
31
|
],
|
32
|
-
"version": "0.7.
|
32
|
+
"version": "0.7.2",
|
33
33
|
"license": "MIT",
|
34
34
|
"exports": {
|
35
35
|
".": {
|
@@ -120,9 +120,9 @@
|
|
120
120
|
"tailwindcss-animate": "^1.0.7",
|
121
121
|
"tsup": "8.3.5",
|
122
122
|
"tsx": "^4.19.2",
|
123
|
-
"@assistant-ui/tailwindcss-transformer": "0.1.0",
|
124
123
|
"@assistant-ui/tsbuildutils": "^0.0.0",
|
125
|
-
"@assistant-ui/tsconfig": "0.0.0"
|
124
|
+
"@assistant-ui/tsconfig": "0.0.0",
|
125
|
+
"@assistant-ui/tailwindcss-transformer": "0.1.0"
|
126
126
|
},
|
127
127
|
"publishConfig": {
|
128
128
|
"access": "public",
|
@@ -13,12 +13,12 @@ export type AssistantRuntime = {
|
|
13
13
|
/**
|
14
14
|
* The currently selected main thread.
|
15
15
|
*/
|
16
|
-
thread: ThreadRuntime;
|
16
|
+
readonly thread: ThreadRuntime;
|
17
17
|
|
18
18
|
/**
|
19
19
|
* The thread manager, to rename, archive and delete threads.
|
20
20
|
*/
|
21
|
-
threadList: ThreadListRuntime;
|
21
|
+
readonly threadList: ThreadListRuntime;
|
22
22
|
|
23
23
|
/**
|
24
24
|
* Switch to a new thread.
|
@@ -10,15 +10,15 @@ import {
|
|
10
10
|
import { AttachmentRuntimePath } from "./RuntimePathTypes";
|
11
11
|
|
12
12
|
type MessageAttachmentState = CompleteAttachment & {
|
13
|
-
source: "message";
|
13
|
+
readonly source: "message";
|
14
14
|
};
|
15
15
|
|
16
16
|
type ThreadComposerAttachmentState = PendingAttachment & {
|
17
|
-
source: "thread-composer";
|
17
|
+
readonly source: "thread-composer";
|
18
18
|
};
|
19
19
|
|
20
20
|
type EditComposerAttachmentState = Attachment & {
|
21
|
-
source: "edit-composer";
|
21
|
+
readonly source: "edit-composer";
|
22
22
|
};
|
23
23
|
|
24
24
|
export type AttachmentState =
|
@@ -37,7 +37,7 @@ type AttachmentRuntimeSource = AttachmentState["source"];
|
|
37
37
|
export type AttachmentRuntime<
|
38
38
|
TSource extends AttachmentRuntimeSource = AttachmentRuntimeSource,
|
39
39
|
> = {
|
40
|
-
path: AttachmentRuntimePath & { attachmentSource: TSource };
|
40
|
+
readonly path: AttachmentRuntimePath & { attachmentSource: TSource };
|
41
41
|
readonly source: TSource;
|
42
42
|
getState(): AttachmentState & { source: TSource };
|
43
43
|
remove(): Promise<void>;
|