@assistant-ui/react 0.7.1 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/api/ContentPartRuntime.d.ts +5 -1
- 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/RuntimePathTypes.d.ts +0 -3
- package/dist/api/RuntimePathTypes.d.ts.map +1 -1
- package/dist/api/RuntimePathTypes.js.map +1 -1
- package/dist/api/ThreadListRuntime.d.ts +0 -5
- package/dist/api/ThreadListRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListRuntime.js +4 -10
- package/dist/api/ThreadListRuntime.js.map +1 -1
- package/dist/api/ThreadListRuntime.mjs +4 -10
- package/dist/api/ThreadListRuntime.mjs.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/edge/converters/fromLanguageModelMessages.d.ts.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.js +3 -2
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.mjs +3 -2
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.mjs.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 +60 -51
- package/dist/types/AssistantTypes.d.ts.map +1 -1
- package/dist/types/AssistantTypes.js.map +1 -1
- package/dist/ui/{attachment.d.ts → attachment-ui.d.ts} +3 -3
- package/dist/ui/attachment-ui.d.ts.map +1 -0
- package/dist/ui/{attachment.js → attachment-ui.js} +9 -9
- package/dist/ui/attachment-ui.js.map +1 -0
- package/dist/ui/{attachment.mjs → attachment-ui.mjs} +6 -6
- package/dist/ui/attachment-ui.mjs.map +1 -0
- package/dist/ui/composer.js +2 -2
- package/dist/ui/composer.js.map +1 -1
- package/dist/ui/composer.mjs +1 -1
- package/dist/ui/composer.mjs.map +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +2 -2
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +1 -1
- package/dist/ui/index.mjs.map +1 -1
- package/dist/ui/user-message.js +2 -2
- package/dist/ui/user-message.js.map +1 -1
- package/dist/ui/user-message.mjs +1 -1
- package/dist/ui/user-message.mjs.map +1 -1
- package/dist/utils/smooth/SmoothContext.d.ts +42 -42
- package/package.json +3 -3
- package/src/api/ContentPartRuntime.ts +6 -2
- package/src/api/RuntimePathTypes.ts +0 -4
- package/src/api/ThreadListRuntime.ts +4 -16
- package/src/runtimes/edge/converters/fromCoreMessage.ts +4 -0
- package/src/runtimes/edge/converters/fromLanguageModelMessages.ts +5 -2
- 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 +65 -52
- package/src/ui/{attachment.tsx → attachment-ui.tsx} +3 -3
- package/src/ui/composer.tsx +1 -1
- package/src/ui/index.ts +1 -1
- package/src/ui/user-message.tsx +1 -1
- package/dist/ui/attachment.d.ts.map +0 -1
- package/dist/ui/attachment.js.map +0 -1
- package/dist/ui/attachment.mjs.map +0 -1
@@ -9,9 +9,13 @@ export type ContentPartState = (ThreadUserContentPart | ThreadAssistantContentPa
|
|
9
9
|
};
|
10
10
|
type ContentPartSnapshotBinding = SubscribableWithState<ContentPartState, ContentPartRuntimePath>;
|
11
11
|
export type ContentPartRuntime = {
|
12
|
+
/**
|
13
|
+
* Add tool result to a tool call content part that has no tool result yet.
|
14
|
+
* This is useful when you are collecting a tool result via user input ("human tool calls").
|
15
|
+
*/
|
16
|
+
addToolResult(result: any): void;
|
12
17
|
readonly path: ContentPartRuntimePath;
|
13
18
|
getState(): ContentPartState;
|
14
|
-
addToolResult(result: any): void;
|
15
19
|
subscribe(callback: () => void): Unsubscribe;
|
16
20
|
};
|
17
21
|
export declare class ContentPartRuntimeImpl implements ContentPartRuntime {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ContentPartRuntime.d.ts","sourceRoot":"","sources":["../../src/api/ContentPartRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM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B,YAAW,kBAAkB;IAM7D,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,SAAS;IAPnB,IAAW,IAAI,2BAEd;gBAGS,cAAc,EAAE,0BAA0B,EAC1C,UAAU,EAAE,mBAAmB,EAC/B,SAAS,EAAE,wBAAwB;IAGtC,QAAQ;IAIR,aAAa,CAAC,MAAM,EAAE,GAAG;IAqBzB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI;CAGtC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/api/ContentPartRuntime.ts"],"sourcesContent":["import {\n ThreadAssistantContentPart,\n ThreadUserContentPart,\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../types/AssistantTypes\";\nimport { ThreadRuntimeCoreBinding } from \"./ThreadRuntime\";\nimport { MessageStateBinding } from \"./MessageRuntime\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { Unsubscribe } from \"../types\";\nimport { ContentPartRuntimePath } from \"./RuntimePathTypes\";\n\nexport type ContentPartState = (\n | ThreadUserContentPart\n | ThreadAssistantContentPart\n) & {\n readonly status: ContentPartStatus | ToolCallContentPartStatus;\n};\n\ntype ContentPartSnapshotBinding = SubscribableWithState<\n ContentPartState,\n ContentPartRuntimePath\n>;\n\nexport type ContentPartRuntime = {\n
|
1
|
+
{"version":3,"sources":["../../src/api/ContentPartRuntime.ts"],"sourcesContent":["import {\n ThreadAssistantContentPart,\n ThreadUserContentPart,\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../types/AssistantTypes\";\nimport { ThreadRuntimeCoreBinding } from \"./ThreadRuntime\";\nimport { MessageStateBinding } from \"./MessageRuntime\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { Unsubscribe } from \"../types\";\nimport { ContentPartRuntimePath } from \"./RuntimePathTypes\";\n\nexport type ContentPartState = (\n | ThreadUserContentPart\n | ThreadAssistantContentPart\n) & {\n readonly status: ContentPartStatus | ToolCallContentPartStatus;\n};\n\ntype ContentPartSnapshotBinding = SubscribableWithState<\n ContentPartState,\n ContentPartRuntimePath\n>;\n\nexport type ContentPartRuntime = {\n /**\n * Add tool result to a tool call content part that has no tool result yet.\n * This is useful when you are collecting a tool result via user input (\"human tool calls\").\n */\n addToolResult(result: any): void;\n\n readonly path: ContentPartRuntimePath;\n getState(): ContentPartState;\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport class ContentPartRuntimeImpl implements ContentPartRuntime {\n public get path() {\n return this.contentBinding.path;\n }\n\n constructor(\n private contentBinding: ContentPartSnapshotBinding,\n private messageApi: MessageStateBinding,\n private threadApi: ThreadRuntimeCoreBinding,\n ) {}\n\n public getState() {\n return this.contentBinding.getState();\n }\n\n public addToolResult(result: any) {\n const message = this.messageApi.getState();\n if (!message) throw new Error(\"Message is not available\");\n\n const state = this.contentBinding.getState();\n if (!state) throw new Error(\"Content part is not available\");\n\n if (state.type !== \"tool-call\")\n throw new Error(\"Tried to add tool result to non-tool content part\");\n\n const toolName = state.toolName;\n const toolCallId = state.toolCallId;\n\n this.threadApi.getState().addToolResult({\n messageId: message.id,\n toolName,\n toolCallId,\n result,\n });\n }\n\n public subscribe(callback: () => void) {\n return this.contentBinding.subscribe(callback);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoCO,IAAM,yBAAN,MAA2D;AAAA,EAKhE,YACU,gBACA,YACA,WACR;AAHQ;AACA;AACA;AAAA,EACP;AAAA,EARH,IAAW,OAAO;AAChB,WAAO,KAAK,eAAe;AAAA,EAC7B;AAAA,EAQO,WAAW;AAChB,WAAO,KAAK,eAAe,SAAS;AAAA,EACtC;AAAA,EAEO,cAAc,QAAa;AAChC,UAAM,UAAU,KAAK,WAAW,SAAS;AACzC,QAAI,CAAC,QAAS,OAAM,IAAI,MAAM,0BAA0B;AAExD,UAAM,QAAQ,KAAK,eAAe,SAAS;AAC3C,QAAI,CAAC,MAAO,OAAM,IAAI,MAAM,+BAA+B;AAE3D,QAAI,MAAM,SAAS;AACjB,YAAM,IAAI,MAAM,mDAAmD;AAErE,UAAM,WAAW,MAAM;AACvB,UAAM,aAAa,MAAM;AAEzB,SAAK,UAAU,SAAS,EAAE,cAAc;AAAA,MACtC,WAAW,QAAQ;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEO,UAAU,UAAsB;AACrC,WAAO,KAAK,eAAe,UAAU,QAAQ;AAAA,EAC/C;AACF;","names":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/api/ContentPartRuntime.ts"],"sourcesContent":["import {\n ThreadAssistantContentPart,\n ThreadUserContentPart,\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../types/AssistantTypes\";\nimport { ThreadRuntimeCoreBinding } from \"./ThreadRuntime\";\nimport { MessageStateBinding } from \"./MessageRuntime\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { Unsubscribe } from \"../types\";\nimport { ContentPartRuntimePath } from \"./RuntimePathTypes\";\n\nexport type ContentPartState = (\n | ThreadUserContentPart\n | ThreadAssistantContentPart\n) & {\n readonly status: ContentPartStatus | ToolCallContentPartStatus;\n};\n\ntype ContentPartSnapshotBinding = SubscribableWithState<\n ContentPartState,\n ContentPartRuntimePath\n>;\n\nexport type ContentPartRuntime = {\n
|
1
|
+
{"version":3,"sources":["../../src/api/ContentPartRuntime.ts"],"sourcesContent":["import {\n ThreadAssistantContentPart,\n ThreadUserContentPart,\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../types/AssistantTypes\";\nimport { ThreadRuntimeCoreBinding } from \"./ThreadRuntime\";\nimport { MessageStateBinding } from \"./MessageRuntime\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { Unsubscribe } from \"../types\";\nimport { ContentPartRuntimePath } from \"./RuntimePathTypes\";\n\nexport type ContentPartState = (\n | ThreadUserContentPart\n | ThreadAssistantContentPart\n) & {\n readonly status: ContentPartStatus | ToolCallContentPartStatus;\n};\n\ntype ContentPartSnapshotBinding = SubscribableWithState<\n ContentPartState,\n ContentPartRuntimePath\n>;\n\nexport type ContentPartRuntime = {\n /**\n * Add tool result to a tool call content part that has no tool result yet.\n * This is useful when you are collecting a tool result via user input (\"human tool calls\").\n */\n addToolResult(result: any): void;\n\n readonly path: ContentPartRuntimePath;\n getState(): ContentPartState;\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport class ContentPartRuntimeImpl implements ContentPartRuntime {\n public get path() {\n return this.contentBinding.path;\n }\n\n constructor(\n private contentBinding: ContentPartSnapshotBinding,\n private messageApi: MessageStateBinding,\n private threadApi: ThreadRuntimeCoreBinding,\n ) {}\n\n public getState() {\n return this.contentBinding.getState();\n }\n\n public addToolResult(result: any) {\n const message = this.messageApi.getState();\n if (!message) throw new Error(\"Message is not available\");\n\n const state = this.contentBinding.getState();\n if (!state) throw new Error(\"Content part is not available\");\n\n if (state.type !== \"tool-call\")\n throw new Error(\"Tried to add tool result to non-tool content part\");\n\n const toolName = state.toolName;\n const toolCallId = state.toolCallId;\n\n this.threadApi.getState().addToolResult({\n messageId: message.id,\n toolName,\n toolCallId,\n result,\n });\n }\n\n public subscribe(callback: () => void) {\n return this.contentBinding.subscribe(callback);\n }\n}\n"],"mappings":";AAoCO,IAAM,yBAAN,MAA2D;AAAA,EAKhE,YACU,gBACA,YACA,WACR;AAHQ;AACA;AACA;AAAA,EACP;AAAA,EARH,IAAW,OAAO;AAChB,WAAO,KAAK,eAAe;AAAA,EAC7B;AAAA,EAQO,WAAW;AAChB,WAAO,KAAK,eAAe,SAAS;AAAA,EACtC;AAAA,EAEO,cAAc,QAAa;AAChC,UAAM,UAAU,KAAK,WAAW,SAAS;AACzC,QAAI,CAAC,QAAS,OAAM,IAAI,MAAM,0BAA0B;AAExD,UAAM,QAAQ,KAAK,eAAe,SAAS;AAC3C,QAAI,CAAC,MAAO,OAAM,IAAI,MAAM,+BAA+B;AAE3D,QAAI,MAAM,SAAS;AACjB,YAAM,IAAI,MAAM,mDAAmD;AAErE,UAAM,WAAW,MAAM;AACvB,UAAM,aAAa,MAAM;AAEzB,SAAK,UAAU,SAAS,EAAE,cAAc;AAAA,MACtC,WAAW,QAAQ;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEO,UAAU,UAAsB;AACrC,WAAO,KAAK,eAAe,UAAU,QAAQ;AAAA,EAC/C;AACF;","names":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RuntimePathTypes.d.ts","sourceRoot":"","sources":["../../src/api/RuntimePathTypes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
1
|
+
{"version":3,"file":"RuntimePathTypes.d.ts","sourceRoot":"","sources":["../../src/api/RuntimePathTypes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,cAAc,EACnB;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GACzB;QAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAClD;QAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GACzD;QAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9D,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,cAAc,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG;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,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC,CAAC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/api/RuntimePathTypes.ts"],"sourcesContent":["export type
|
1
|
+
{"version":3,"sources":["../../src/api/RuntimePathTypes.ts"],"sourcesContent":["export type ThreadListItemRuntimePath = {\n readonly ref: string;\n readonly threadSelector:\n | { readonly type: \"main\" }\n | { readonly type: \"index\"; readonly index: number }\n | { readonly type: \"archiveIndex\"; readonly index: number }\n | { readonly type: \"threadId\"; readonly threadId: string };\n};\n\nexport type ThreadRuntimePath = {\n readonly ref: string;\n readonly threadSelector: { type: \"main\" };\n};\n\nexport type MessageRuntimePath = ThreadRuntimePath & {\n readonly messageSelector:\n | { readonly type: \"messageId\"; readonly messageId: string }\n | { readonly type: \"index\"; readonly index: number };\n};\n\nexport type ContentPartRuntimePath = MessageRuntimePath & {\n readonly contentPartSelector:\n | { readonly type: \"index\"; readonly index: number }\n | { readonly type: \"toolCallId\"; readonly toolCallId: string };\n};\n\nexport type AttachmentRuntimePath = (\n | (MessageRuntimePath & {\n readonly attachmentSource: \"message\" | \"edit-composer\";\n })\n | (ThreadRuntimePath & {\n readonly attachmentSource: \"thread-composer\";\n })\n) & {\n readonly attachmentSelector:\n | {\n readonly type: \"index\";\n readonly index: number;\n }\n | {\n readonly type: \"index\";\n readonly index: number;\n }\n | {\n readonly type: \"index\";\n readonly index: number;\n };\n};\n\nexport type ComposerRuntimePath =\n | (ThreadRuntimePath & {\n readonly composerSource: \"thread\";\n })\n | (MessageRuntimePath & {\n readonly composerSource: \"edit\";\n });\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { ThreadListRuntimeCore } from "../runtimes/core/ThreadListRuntimeCore";
|
2
2
|
import { Unsubscribe } from "../types";
|
3
|
-
import { ThreadListRuntimePath } from "./RuntimePathTypes";
|
4
3
|
import { ThreadListItemRuntime, ThreadListItemRuntimeImpl } from "./ThreadListItemRuntime";
|
5
4
|
export type ThreadListState = {
|
6
5
|
readonly mainThreadId: string;
|
@@ -9,7 +8,6 @@ export type ThreadListState = {
|
|
9
8
|
readonly archivedThreads: readonly string[];
|
10
9
|
};
|
11
10
|
export type ThreadListRuntime = {
|
12
|
-
readonly path: ThreadListRuntimePath;
|
13
11
|
getState(): ThreadListState;
|
14
12
|
subscribe(callback: () => void): Unsubscribe;
|
15
13
|
getThreadListItemById(threadId: string): ThreadListItemRuntime;
|
@@ -19,9 +17,6 @@ export type ThreadListRuntime = {
|
|
19
17
|
export type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;
|
20
18
|
export declare class ThreadListRuntimeImpl implements ThreadListRuntime {
|
21
19
|
private _core;
|
22
|
-
get path(): {
|
23
|
-
ref: string;
|
24
|
-
};
|
25
20
|
private _getState;
|
26
21
|
constructor(_core: ThreadListRuntimeCoreBinding);
|
27
22
|
getState(): ThreadListState;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ThreadListRuntime.d.ts","sourceRoot":"","sources":["../../src/api/ThreadListRuntime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,
|
1
|
+
{"version":3,"file":"ThreadListRuntime.d.ts","sourceRoot":"","sources":["../../src/api/ThreadListRuntime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EAE1B,MAAM,yBAAyB,CAAC;AAIjC,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,IAAI,eAAe,CAAC;IAE5B,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;IAE7C,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,CAAC;IAC/D,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAC;IAC7D,gCAAgC,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAC;CACtE,CAAC;AA6BF,MAAM,MAAM,4BAA4B,GAAG,qBAAqB,CAAC;AAEjE,qBAAa,qBAAsB,YAAW,iBAAiB;IAEjD,OAAO,CAAC,KAAK;IADzB,OAAO,CAAC,SAAS,CAAC;gBACE,KAAK,EAAE,4BAA4B;IAUhD,QAAQ,IAAI,eAAe;IAI3B,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW;IAI5C,wBAAwB,CAAC,GAAG,EAAE,MAAM;IAgBpC,gCAAgC,CAAC,GAAG,EAAE,MAAM;IAmB5C,qBAAqB,CAAC,QAAQ,EAAE,MAAM;CAe9C"}
|
@@ -46,22 +46,16 @@ var getThreadListItemState = (threadList, threadId) => {
|
|
46
46
|
isMain: threadList.mainThread.metadata.threadId === threadId
|
47
47
|
};
|
48
48
|
};
|
49
|
-
var THREAD_MANAGER_PATH = {
|
50
|
-
ref: "ThreadList"
|
51
|
-
};
|
52
49
|
var ThreadListRuntimeImpl = class {
|
53
50
|
constructor(_core) {
|
54
51
|
this._core = _core;
|
55
52
|
const stateBinding = new import_LazyMemoizeSubject.LazyMemoizeSubject({
|
56
|
-
path:
|
53
|
+
path: {},
|
57
54
|
getState: () => getThreadListState(_core),
|
58
55
|
subscribe: (callback) => _core.subscribe(callback)
|
59
56
|
});
|
60
57
|
this._getState = stateBinding.getState.bind(stateBinding);
|
61
58
|
}
|
62
|
-
get path() {
|
63
|
-
return THREAD_MANAGER_PATH;
|
64
|
-
}
|
65
59
|
_getState;
|
66
60
|
getState() {
|
67
61
|
return this._getState();
|
@@ -73,7 +67,7 @@ var ThreadListRuntimeImpl = class {
|
|
73
67
|
return new import_ThreadListItemRuntime.ThreadListItemRuntimeImpl(
|
74
68
|
new import_ShallowMemoizeSubject.ShallowMemoizeSubject({
|
75
69
|
path: {
|
76
|
-
ref:
|
70
|
+
ref: `threadItems[${idx}]`,
|
77
71
|
threadSelector: { type: "index", index: idx }
|
78
72
|
},
|
79
73
|
getState: () => {
|
@@ -88,7 +82,7 @@ var ThreadListRuntimeImpl = class {
|
|
88
82
|
return new import_ThreadListItemRuntime.ThreadListItemRuntimeImpl(
|
89
83
|
new import_ShallowMemoizeSubject.ShallowMemoizeSubject({
|
90
84
|
path: {
|
91
|
-
ref:
|
85
|
+
ref: `archivedThreadItems[${idx}]`,
|
92
86
|
threadSelector: { type: "archiveIndex", index: idx }
|
93
87
|
},
|
94
88
|
getState: () => {
|
@@ -106,7 +100,7 @@ var ThreadListRuntimeImpl = class {
|
|
106
100
|
return new import_ThreadListItemRuntime.ThreadListItemRuntimeImpl(
|
107
101
|
new import_ShallowMemoizeSubject.ShallowMemoizeSubject({
|
108
102
|
path: {
|
109
|
-
ref:
|
103
|
+
ref: `threadItems[threadId=${threadId}]`,
|
110
104
|
threadSelector: { type: "threadId", threadId }
|
111
105
|
},
|
112
106
|
getState: () => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/api/ThreadListRuntime.ts"],"sourcesContent":["import { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { ThreadListRuntimeCore } from \"../runtimes/core/ThreadListRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport {
|
1
|
+
{"version":3,"sources":["../../src/api/ThreadListRuntime.ts"],"sourcesContent":["import { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { ThreadListRuntimeCore } from \"../runtimes/core/ThreadListRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport {\n ThreadListItemRuntime,\n ThreadListItemRuntimeImpl,\n ThreadListItemState,\n} from \"./ThreadListItemRuntime\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\n\nexport type ThreadListState = {\n readonly mainThreadId: string;\n readonly newThread: string | undefined;\n readonly threads: readonly string[];\n readonly archivedThreads: readonly string[];\n};\n\nexport type ThreadListRuntime = {\n getState(): ThreadListState;\n\n subscribe(callback: () => void): Unsubscribe;\n\n getThreadListItemById(threadId: string): ThreadListItemRuntime;\n getThreadListItemByIndex(idx: number): ThreadListItemRuntime;\n getThreadListArchivedItemByIndex(idx: number): ThreadListItemRuntime;\n};\n\nconst getThreadListState = (\n threadList: ThreadListRuntimeCore,\n): ThreadListState => {\n return {\n mainThreadId: threadList.mainThread.metadata.threadId,\n newThread: threadList.newThread,\n threads: threadList.threads,\n archivedThreads: threadList.archivedThreads,\n };\n};\n\nconst getThreadListItemState = (\n threadList: ThreadListRuntimeCore,\n threadId: string | undefined,\n): ThreadListItemState | SKIP_UPDATE => {\n if (threadId === undefined) return SKIP_UPDATE;\n\n const threadData = threadList.getThreadMetadataById(threadId);\n if (!threadData) return SKIP_UPDATE;\n return {\n threadId: threadData.threadId,\n title: threadData.title,\n state: threadData.state,\n isMain: threadList.mainThread.metadata.threadId === threadId,\n };\n};\n\nexport type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;\n\nexport class ThreadListRuntimeImpl implements ThreadListRuntime {\n private _getState;\n constructor(private _core: ThreadListRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: {},\n getState: () => getThreadListState(_core),\n subscribe: (callback) => _core.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public getState(): ThreadListState {\n return this._getState();\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n return this._core.subscribe(callback);\n }\n\n public getThreadListItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: `threadItems[${idx}]`,\n threadSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(this._core, this._core.threads[idx]);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getThreadListArchivedItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: `archivedThreadItems[${idx}]`,\n threadSelector: { type: \"archiveIndex\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(\n this._core,\n this._core.archivedThreads[idx],\n );\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getThreadListItemById(threadId: string) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: `threadItems[threadId=${threadId}]`,\n threadSelector: { type: \"threadId\", threadId },\n },\n getState: () => {\n return getThreadListItemState(this._core, threadId);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAmC;AAGnC,mCAIO;AACP,yBAA4B;AAC5B,mCAAsC;AAmBtC,IAAM,qBAAqB,CACzB,eACoB;AACpB,SAAO;AAAA,IACL,cAAc,WAAW,WAAW,SAAS;AAAA,IAC7C,WAAW,WAAW;AAAA,IACtB,SAAS,WAAW;AAAA,IACpB,iBAAiB,WAAW;AAAA,EAC9B;AACF;AAEA,IAAM,yBAAyB,CAC7B,YACA,aACsC;AACtC,MAAI,aAAa,OAAW,QAAO;AAEnC,QAAM,aAAa,WAAW,sBAAsB,QAAQ;AAC5D,MAAI,CAAC,WAAY,QAAO;AACxB,SAAO;AAAA,IACL,UAAU,WAA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AAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EAEO,sBAAsB,UAAkB;AAC7C,WAAO,IAAI;AAAA,MACT,IAAI,mDAAsB;AAAA,QACxB,MAAM;AAAA,UACJ,KAAK,wBAAwB,QAAQ;AAAA,UACrC,gBAAgB,EAAE,MAAM,YAAY,SAAS;AAAA,QAC/C;AAAA,QACA,UAAU,MAAM;AACd,iBAAO,uBAAuB,KAAK,OAAO,QAAQ;AAAA,QACpD;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|
@@ -24,22 +24,16 @@ var getThreadListItemState = (threadList, threadId) => {
|
|
24
24
|
isMain: threadList.mainThread.metadata.threadId === threadId
|
25
25
|
};
|
26
26
|
};
|
27
|
-
var THREAD_MANAGER_PATH = {
|
28
|
-
ref: "ThreadList"
|
29
|
-
};
|
30
27
|
var ThreadListRuntimeImpl = class {
|
31
28
|
constructor(_core) {
|
32
29
|
this._core = _core;
|
33
30
|
const stateBinding = new LazyMemoizeSubject({
|
34
|
-
path:
|
31
|
+
path: {},
|
35
32
|
getState: () => getThreadListState(_core),
|
36
33
|
subscribe: (callback) => _core.subscribe(callback)
|
37
34
|
});
|
38
35
|
this._getState = stateBinding.getState.bind(stateBinding);
|
39
36
|
}
|
40
|
-
get path() {
|
41
|
-
return THREAD_MANAGER_PATH;
|
42
|
-
}
|
43
37
|
_getState;
|
44
38
|
getState() {
|
45
39
|
return this._getState();
|
@@ -51,7 +45,7 @@ var ThreadListRuntimeImpl = class {
|
|
51
45
|
return new ThreadListItemRuntimeImpl(
|
52
46
|
new ShallowMemoizeSubject({
|
53
47
|
path: {
|
54
|
-
ref:
|
48
|
+
ref: `threadItems[${idx}]`,
|
55
49
|
threadSelector: { type: "index", index: idx }
|
56
50
|
},
|
57
51
|
getState: () => {
|
@@ -66,7 +60,7 @@ var ThreadListRuntimeImpl = class {
|
|
66
60
|
return new ThreadListItemRuntimeImpl(
|
67
61
|
new ShallowMemoizeSubject({
|
68
62
|
path: {
|
69
|
-
ref:
|
63
|
+
ref: `archivedThreadItems[${idx}]`,
|
70
64
|
threadSelector: { type: "archiveIndex", index: idx }
|
71
65
|
},
|
72
66
|
getState: () => {
|
@@ -84,7 +78,7 @@ var ThreadListRuntimeImpl = class {
|
|
84
78
|
return new ThreadListItemRuntimeImpl(
|
85
79
|
new ShallowMemoizeSubject({
|
86
80
|
path: {
|
87
|
-
ref:
|
81
|
+
ref: `threadItems[threadId=${threadId}]`,
|
88
82
|
threadSelector: { type: "threadId", threadId }
|
89
83
|
},
|
90
84
|
getState: () => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/api/ThreadListRuntime.ts"],"sourcesContent":["import { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { ThreadListRuntimeCore } from \"../runtimes/core/ThreadListRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport {
|
1
|
+
{"version":3,"sources":["../../src/api/ThreadListRuntime.ts"],"sourcesContent":["import { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { ThreadListRuntimeCore } from \"../runtimes/core/ThreadListRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport {\n ThreadListItemRuntime,\n ThreadListItemRuntimeImpl,\n ThreadListItemState,\n} from \"./ThreadListItemRuntime\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\n\nexport type ThreadListState = {\n readonly mainThreadId: string;\n readonly newThread: string | undefined;\n readonly threads: readonly string[];\n readonly archivedThreads: readonly string[];\n};\n\nexport type ThreadListRuntime = {\n getState(): ThreadListState;\n\n subscribe(callback: () => void): Unsubscribe;\n\n getThreadListItemById(threadId: string): ThreadListItemRuntime;\n getThreadListItemByIndex(idx: number): ThreadListItemRuntime;\n getThreadListArchivedItemByIndex(idx: number): ThreadListItemRuntime;\n};\n\nconst getThreadListState = (\n threadList: ThreadListRuntimeCore,\n): ThreadListState => {\n return {\n mainThreadId: threadList.mainThread.metadata.threadId,\n newThread: threadList.newThread,\n threads: threadList.threads,\n archivedThreads: threadList.archivedThreads,\n };\n};\n\nconst getThreadListItemState = (\n threadList: ThreadListRuntimeCore,\n threadId: string | undefined,\n): ThreadListItemState | SKIP_UPDATE => {\n if (threadId === undefined) return SKIP_UPDATE;\n\n const threadData = threadList.getThreadMetadataById(threadId);\n if (!threadData) return SKIP_UPDATE;\n return {\n threadId: threadData.threadId,\n title: threadData.title,\n state: threadData.state,\n isMain: threadList.mainThread.metadata.threadId === threadId,\n };\n};\n\nexport type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;\n\nexport class ThreadListRuntimeImpl implements ThreadListRuntime {\n private _getState;\n constructor(private _core: ThreadListRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: {},\n getState: () => getThreadListState(_core),\n subscribe: (callback) => _core.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public getState(): ThreadListState {\n return this._getState();\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n return this._core.subscribe(callback);\n }\n\n public getThreadListItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: `threadItems[${idx}]`,\n threadSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(this._core, this._core.threads[idx]);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getThreadListArchivedItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: `archivedThreadItems[${idx}]`,\n threadSelector: { type: \"archiveIndex\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(\n this._core,\n this._core.archivedThreads[idx],\n );\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getThreadListItemById(threadId: string) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: `threadItems[threadId=${threadId}]`,\n threadSelector: { type: \"threadId\", threadId },\n },\n getState: () => {\n return getThreadListItemState(this._core, threadId);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";AAAA,SAAS,0BAA0B;AAGnC;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAmBtC,IAAM,qBAAqB,CACzB,eACoB;AACpB,SAAO;AAAA,IACL,cAAc,WAAW,WAAW,SAAS;AAAA,IAC7C,WAAW,WAAW;AAAA,IACtB,SAAS,WAAW;AAAA,IACpB,iBAAiB,WAAW;AAAA,EAC9B;AACF;AAEA,IAAM,yBAAyB,CAC7B,YACA,aACsC;AACtC,MAAI,aAAa,OAAW,QAAO;AAEnC,QAAM,aAAa,WAAW,sBAAsB,QAAQ;AAC5D,MAAI,CAAC,WAAY,QAAO;AACxB,SAAO;AAAA,IACL,UAAU,WAAW;AAAA,IACrB,OAAO,WAAW;AAAA,IAClB,OAAO,WAAW;AAAA,IAClB,QAAQ,WAAW,WAAW,SAAS,aAAa;AAAA,EACtD;AACF;AAIO,IAAM,wBAAN,MAAyD;AAAA,EAE9D,YAAoB,OAAqC;AAArC;AAClB,UAAM,eAAe,IAAI,mBAAmB;AAAA,MAC1C,MAAM,CAAC;AAAA,MACP,UAAU,MAAM,mBAAmB,KAAK;AAAA,MACxC,WAAW,CAAC,aAAa,MAAM,UAAU,QAAQ;AAAA,IACnD,CAAC;AAED,SAAK,YAAY,aAAa,SAAS,KAAK,YAAY;AAAA,EAC1D;AAAA,EATQ;AAAA,EAWD,WAA4B;AACjC,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEO,UAAU,UAAmC;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
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fromCoreMessage.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/edge/converters/fromCoreMessage.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,WAAW,EAEX,aAAa,EACb,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,gBAAgB,YAClB,SAAS,WAAW,EAAE,KAC9B,aAAa,EAEf,CAAC;AAEF,eAAO,MAAM,eAAe,YACjB,WAAW;;;;MAMnB,
|
1
|
+
{"version":3,"file":"fromCoreMessage.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/edge/converters/fromCoreMessage.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,WAAW,EAEX,aAAa,EACb,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,gBAAgB,YAClB,SAAS,WAAW,EAAE,KAC9B,aAAa,EAEf,CAAC;AAEF,eAAO,MAAM,eAAe,YACjB,WAAW;;;;MAMnB,aAgDF,CAAC"}
|
@@ -52,20 +52,23 @@ var fromCoreMessage = (message, {
|
|
52
52
|
}
|
53
53
|
return part;
|
54
54
|
}),
|
55
|
-
status
|
55
|
+
status,
|
56
|
+
metadata: { steps: [], custom: {} }
|
56
57
|
};
|
57
58
|
case "user":
|
58
59
|
return {
|
59
60
|
...commonProps,
|
60
61
|
role,
|
61
62
|
content: message.content,
|
62
|
-
attachments
|
63
|
+
attachments,
|
64
|
+
metadata: { custom: {} }
|
63
65
|
};
|
64
66
|
case "system":
|
65
67
|
return {
|
66
68
|
...commonProps,
|
67
69
|
role,
|
68
|
-
content: message.content
|
70
|
+
content: message.content,
|
71
|
+
metadata: { custom: {} }
|
69
72
|
};
|
70
73
|
default: {
|
71
74
|
const unsupportedRole = role;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/edge/converters/fromCoreMessage.ts"],"sourcesContent":["import { generateId } from \"../../../internal\";\nimport {\n ThreadMessage,\n CoreMessage,\n ToolCallContentPart,\n MessageStatus,\n CompleteAttachment,\n} from \"../../../types\";\n\nexport const fromCoreMessages = (\n message: readonly CoreMessage[],\n): ThreadMessage[] => {\n return message.map((message) => fromCoreMessage(message));\n};\n\nexport const fromCoreMessage = (\n message: CoreMessage,\n {\n id = generateId(),\n status = { type: \"complete\", reason: \"unknown\" } as MessageStatus,\n attachments = [] as readonly CompleteAttachment[],\n } = {},\n): ThreadMessage => {\n const commonProps = {\n id,\n createdAt: new Date(),\n };\n\n const role = message.role;\n switch (role) {\n case \"assistant\":\n return {\n ...commonProps,\n role,\n content: message.content.map((part) => {\n if (part.type === \"tool-call\") {\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n } satisfies ToolCallContentPart;\n }\n return part;\n }),\n status,\n } satisfies ThreadMessage;\n\n case \"user\":\n return {\n ...commonProps,\n role,\n content: message.content,\n attachments,\n } satisfies ThreadMessage;\n\n case \"system\":\n return {\n ...commonProps,\n role,\n content: message.content,\n } satisfies ThreadMessage;\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;AAAA;AAAA,sBAA2B;AASpB,IAAM,mBAAmB,CAC9B,YACoB;AACpB,SAAO,QAAQ,IAAI,CAACA,aAAY,gBAAgBA,QAAO,CAAC;AAC1D;AAEO,IAAM,kBAAkB,CAC7B,SACA;AAAA,EACE,SAAK,4BAAW;AAAA,EAChB,SAAS,EAAE,MAAM,YAAY,QAAQ,UAAU;AAAA,EAC/C,cAAc,CAAC;AACjB,IAAI,CAAC,MACa;AAClB,QAAM,cAAc;AAAA,IAClB;AAAA,IACA,WAAW,oBAAI,KAAK;AAAA,EACtB;AAEA,QAAM,OAAO,QAAQ;AACrB,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QAAQ,QAAQ,IAAI,CAAC,SAAS;AACrC,cAAI,KAAK,SAAS,aAAa;AAC7B,mBAAO;AAAA,cACL,GAAG;AAAA,cACH,UAAU,KAAK,UAAU,KAAK,IAAI;AAAA,YACpC;AAAA,UACF;AACA,iBAAO;AAAA,QACT,CAAC;AAAA,QACD;AAAA,
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/edge/converters/fromCoreMessage.ts"],"sourcesContent":["import { generateId } from \"../../../internal\";\nimport {\n ThreadMessage,\n CoreMessage,\n ToolCallContentPart,\n MessageStatus,\n CompleteAttachment,\n} from \"../../../types\";\n\nexport const fromCoreMessages = (\n message: readonly CoreMessage[],\n): ThreadMessage[] => {\n return message.map((message) => fromCoreMessage(message));\n};\n\nexport const fromCoreMessage = (\n message: CoreMessage,\n {\n id = generateId(),\n status = { type: \"complete\", reason: \"unknown\" } as MessageStatus,\n attachments = [] as readonly CompleteAttachment[],\n } = {},\n): ThreadMessage => {\n const commonProps = {\n id,\n createdAt: new Date(),\n };\n\n const role = message.role;\n switch (role) {\n case \"assistant\":\n return {\n ...commonProps,\n role,\n content: message.content.map((part) => {\n if (part.type === \"tool-call\") {\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n } satisfies ToolCallContentPart;\n }\n return part;\n }),\n status,\n\n metadata: { steps: [], custom: {} },\n } satisfies ThreadMessage;\n\n case \"user\":\n return {\n ...commonProps,\n role,\n content: message.content,\n attachments,\n metadata: { custom: {} },\n } satisfies ThreadMessage;\n\n case \"system\":\n return {\n ...commonProps,\n role,\n content: message.content,\n metadata: { custom: {} },\n } satisfies ThreadMessage;\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;AAAA;AAAA,sBAA2B;AASpB,IAAM,mBAAmB,CAC9B,YACoB;AACpB,SAAO,QAAQ,IAAI,CAACA,aAAY,gBAAgBA,QAAO,CAAC;AAC1D;AAEO,IAAM,kBAAkB,CAC7B,SACA;AAAA,EACE,SAAK,4BAAW;AAAA,EAChB,SAAS,EAAE,MAAM,YAAY,QAAQ,UAAU;AAAA,EAC/C,cAAc,CAAC;AACjB,IAAI,CAAC,MACa;AAClB,QAAM,cAAc;AAAA,IAClB;AAAA,IACA,WAAW,oBAAI,KAAK;AAAA,EACtB;AAEA,QAAM,OAAO,QAAQ;AACrB,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QAAQ,QAAQ,IAAI,CAAC,SAAS;AACrC,cAAI,KAAK,SAAS,aAAa;AAC7B,mBAAO;AAAA,cACL,GAAG;AAAA,cACH,UAAU,KAAK,UAAU,KAAK,IAAI;AAAA,YACpC;AAAA,UACF;AACA,iBAAO;AAAA,QACT,CAAC;AAAA,QACD;AAAA,QAEA,UAAU,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,EAAE;AAAA,MACpC;AAAA,IAEF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QAAQ;AAAA,QACjB;AAAA,QACA,UAAU,EAAE,QAAQ,CAAC,EAAE;AAAA,MACzB;AAAA,IAEF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QAAQ;AAAA,QACjB,UAAU,EAAE,QAAQ,CAAC,EAAE;AAAA,MACzB;AAAA,IAEF,SAAS;AACP,YAAM,kBAAyB;AAC/B,YAAM,IAAI,MAAM,yBAAyB,eAAe,EAAE;AAAA,IAC5D;AAAA,EACF;AACF;","names":["message"]}
|
@@ -27,20 +27,23 @@ var fromCoreMessage = (message, {
|
|
27
27
|
}
|
28
28
|
return part;
|
29
29
|
}),
|
30
|
-
status
|
30
|
+
status,
|
31
|
+
metadata: { steps: [], custom: {} }
|
31
32
|
};
|
32
33
|
case "user":
|
33
34
|
return {
|
34
35
|
...commonProps,
|
35
36
|
role,
|
36
37
|
content: message.content,
|
37
|
-
attachments
|
38
|
+
attachments,
|
39
|
+
metadata: { custom: {} }
|
38
40
|
};
|
39
41
|
case "system":
|
40
42
|
return {
|
41
43
|
...commonProps,
|
42
44
|
role,
|
43
|
-
content: message.content
|
45
|
+
content: message.content,
|
46
|
+
metadata: { custom: {} }
|
44
47
|
};
|
45
48
|
default: {
|
46
49
|
const unsupportedRole = role;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/edge/converters/fromCoreMessage.ts"],"sourcesContent":["import { generateId } from \"../../../internal\";\nimport {\n ThreadMessage,\n CoreMessage,\n ToolCallContentPart,\n MessageStatus,\n CompleteAttachment,\n} from \"../../../types\";\n\nexport const fromCoreMessages = (\n message: readonly CoreMessage[],\n): ThreadMessage[] => {\n return message.map((message) => fromCoreMessage(message));\n};\n\nexport const fromCoreMessage = (\n message: CoreMessage,\n {\n id = generateId(),\n status = { type: \"complete\", reason: \"unknown\" } as MessageStatus,\n attachments = [] as readonly CompleteAttachment[],\n } = {},\n): ThreadMessage => {\n const commonProps = {\n id,\n createdAt: new Date(),\n };\n\n const role = message.role;\n switch (role) {\n case \"assistant\":\n return {\n ...commonProps,\n role,\n content: message.content.map((part) => {\n if (part.type === \"tool-call\") {\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n } satisfies ToolCallContentPart;\n }\n return part;\n }),\n status,\n } satisfies ThreadMessage;\n\n case \"user\":\n return {\n ...commonProps,\n role,\n content: message.content,\n attachments,\n } satisfies ThreadMessage;\n\n case \"system\":\n return {\n ...commonProps,\n role,\n content: message.content,\n } satisfies ThreadMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;AASpB,IAAM,mBAAmB,CAC9B,YACoB;AACpB,SAAO,QAAQ,IAAI,CAACA,aAAY,gBAAgBA,QAAO,CAAC;AAC1D;AAEO,IAAM,kBAAkB,CAC7B,SACA;AAAA,EACE,KAAK,WAAW;AAAA,EAChB,SAAS,EAAE,MAAM,YAAY,QAAQ,UAAU;AAAA,EAC/C,cAAc,CAAC;AACjB,IAAI,CAAC,MACa;AAClB,QAAM,cAAc;AAAA,IAClB;AAAA,IACA,WAAW,oBAAI,KAAK;AAAA,EACtB;AAEA,QAAM,OAAO,QAAQ;AACrB,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QAAQ,QAAQ,IAAI,CAAC,SAAS;AACrC,cAAI,KAAK,SAAS,aAAa;AAC7B,mBAAO;AAAA,cACL,GAAG;AAAA,cACH,UAAU,KAAK,UAAU,KAAK,IAAI;AAAA,YACpC;AAAA,UACF;AACA,iBAAO;AAAA,QACT,CAAC;AAAA,QACD;AAAA,
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/edge/converters/fromCoreMessage.ts"],"sourcesContent":["import { generateId } from \"../../../internal\";\nimport {\n ThreadMessage,\n CoreMessage,\n ToolCallContentPart,\n MessageStatus,\n CompleteAttachment,\n} from \"../../../types\";\n\nexport const fromCoreMessages = (\n message: readonly CoreMessage[],\n): ThreadMessage[] => {\n return message.map((message) => fromCoreMessage(message));\n};\n\nexport const fromCoreMessage = (\n message: CoreMessage,\n {\n id = generateId(),\n status = { type: \"complete\", reason: \"unknown\" } as MessageStatus,\n attachments = [] as readonly CompleteAttachment[],\n } = {},\n): ThreadMessage => {\n const commonProps = {\n id,\n createdAt: new Date(),\n };\n\n const role = message.role;\n switch (role) {\n case \"assistant\":\n return {\n ...commonProps,\n role,\n content: message.content.map((part) => {\n if (part.type === \"tool-call\") {\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n } satisfies ToolCallContentPart;\n }\n return part;\n }),\n status,\n\n metadata: { steps: [], custom: {} },\n } satisfies ThreadMessage;\n\n case \"user\":\n return {\n ...commonProps,\n role,\n content: message.content,\n attachments,\n metadata: { custom: {} },\n } satisfies ThreadMessage;\n\n case \"system\":\n return {\n ...commonProps,\n role,\n content: message.content,\n metadata: { custom: {} },\n } satisfies ThreadMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;AASpB,IAAM,mBAAmB,CAC9B,YACoB;AACpB,SAAO,QAAQ,IAAI,CAACA,aAAY,gBAAgBA,QAAO,CAAC;AAC1D;AAEO,IAAM,kBAAkB,CAC7B,SACA;AAAA,EACE,KAAK,WAAW;AAAA,EAChB,SAAS,EAAE,MAAM,YAAY,QAAQ,UAAU;AAAA,EAC/C,cAAc,CAAC;AACjB,IAAI,CAAC,MACa;AAClB,QAAM,cAAc;AAAA,IAClB;AAAA,IACA,WAAW,oBAAI,KAAK;AAAA,EACtB;AAEA,QAAM,OAAO,QAAQ;AACrB,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QAAQ,QAAQ,IAAI,CAAC,SAAS;AACrC,cAAI,KAAK,SAAS,aAAa;AAC7B,mBAAO;AAAA,cACL,GAAG;AAAA,cACH,UAAU,KAAK,UAAU,KAAK,IAAI;AAAA,YACpC;AAAA,UACF;AACA,iBAAO;AAAA,QACT,CAAC;AAAA,QACD;AAAA,QAEA,UAAU,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,EAAE;AAAA,MACpC;AAAA,IAEF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QAAQ;AAAA,QACjB;AAAA,QACA,UAAU,EAAE,QAAQ,CAAC,EAAE;AAAA,MACzB;AAAA,IAEF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QAAQ;AAAA,QACjB,UAAU,EAAE,QAAQ,CAAC,EAAE;AAAA,MACzB;AAAA,IAEF,SAAS;AACP,YAAM,kBAAyB;AAC/B,YAAM,IAAI,MAAM,yBAAyB,eAAe,EAAE;AAAA,IAC5D;AAAA,EACF;AACF;","names":["message"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fromLanguageModelMessages.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/edge/converters/fromLanguageModelMessages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;
|
1
|
+
{"version":3,"file":"fromLanguageModelMessages.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/edge/converters/fromLanguageModelMessages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;AAGlE,KAAK,gCAAgC,GAAG;IACtC,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,yBAAyB,OAChC,sBAAsB,EAAE,kBACZ,gCAAgC,KAC/C,WAAW,EAoHb,CAAC"}
|
@@ -113,9 +113,10 @@ var fromLanguageModelMessages = (lm, { mergeSteps }) => {
|
|
113
113
|
throw new Error("Received tool result for an unknown tool call.");
|
114
114
|
if (toolCall.toolName !== tool.toolName)
|
115
115
|
throw new Error("Tool call name mismatch.");
|
116
|
-
|
116
|
+
const writable = toolCall;
|
117
|
+
writable.result = tool.result;
|
117
118
|
if (tool.isError) {
|
118
|
-
|
119
|
+
writable.isError = true;
|
119
120
|
}
|
120
121
|
}
|
121
122
|
break;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/edge/converters/fromLanguageModelMessages.ts"],"sourcesContent":["import { LanguageModelV1Message } from \"@ai-sdk/provider\";\nimport { CoreMessage, ToolCallContentPart } from \"../../../types\";\n\ntype fromLanguageModelMessagesOptions = {\n mergeSteps: boolean;\n};\n\nexport const fromLanguageModelMessages = (\n lm: LanguageModelV1Message[],\n { mergeSteps }: fromLanguageModelMessagesOptions,\n): CoreMessage[] => {\n const messages: CoreMessage[] = [];\n\n for (const lmMessage of lm) {\n const role = lmMessage.role;\n switch (role) {\n case \"system\": {\n messages.push({\n role: \"system\",\n content: [\n {\n type: \"text\",\n text: lmMessage.content,\n },\n ],\n });\n break;\n }\n case \"user\": {\n messages.push({\n role: \"user\",\n content: lmMessage.content.map((part) => {\n const type = part.type;\n switch (type) {\n case \"text\": {\n return {\n type: \"text\",\n text: part.text,\n };\n }\n case \"image\": {\n if (part.image instanceof URL) {\n return {\n type: \"image\",\n image: part.image.href,\n };\n }\n throw new Error(\"Only images with URL data are supported\");\n }\n case \"file\": {\n // TODO\n throw new Error(\"File content parts are not supported\");\n }\n default: {\n const unhandledType: never = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n });\n break;\n }\n case \"assistant\": {\n const newContent = lmMessage.content.map((part) => {\n if (part.type === \"tool-call\") {\n return {\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n argsText: JSON.stringify(part.args),\n args: part.args as Record<string, unknown>,\n } satisfies ToolCallContentPart;\n }\n return part;\n });\n\n if (mergeSteps) {\n const previousMessage = messages[messages.length - 1];\n if (previousMessage?.role === \"assistant\") {\n previousMessage.content.push(...newContent);\n break;\n }\n }\n\n messages.push({\n role: \"assistant\",\n content: newContent,\n });\n break;\n }\n case \"tool\": {\n const previousMessage = messages[messages.length - 1];\n if (previousMessage?.role !== \"assistant\")\n throw new Error(\n \"A tool message must be preceded by an assistant message.\",\n );\n\n for (const tool of lmMessage.content) {\n const toolCall = previousMessage.content.find(\n (c): c is ToolCallContentPart =>\n c.type === \"tool-call\" && c.toolCallId === tool.toolCallId,\n );\n if (!toolCall)\n throw new Error(\"Received tool result for an unknown tool call.\");\n if (toolCall.toolName !== tool.toolName)\n throw new Error(\"Tool call name mismatch.\");\n\n toolCall.result = tool.result;\n if (tool.isError) {\n
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/edge/converters/fromLanguageModelMessages.ts"],"sourcesContent":["import { LanguageModelV1Message } from \"@ai-sdk/provider\";\nimport { CoreMessage, ToolCallContentPart } from \"../../../types\";\nimport { Writable } from \"stream\";\n\ntype fromLanguageModelMessagesOptions = {\n mergeSteps: boolean;\n};\n\nexport const fromLanguageModelMessages = (\n lm: LanguageModelV1Message[],\n { mergeSteps }: fromLanguageModelMessagesOptions,\n): CoreMessage[] => {\n const messages: CoreMessage[] = [];\n\n for (const lmMessage of lm) {\n const role = lmMessage.role;\n switch (role) {\n case \"system\": {\n messages.push({\n role: \"system\",\n content: [\n {\n type: \"text\",\n text: lmMessage.content,\n },\n ],\n });\n break;\n }\n case \"user\": {\n messages.push({\n role: \"user\",\n content: lmMessage.content.map((part) => {\n const type = part.type;\n switch (type) {\n case \"text\": {\n return {\n type: \"text\",\n text: part.text,\n };\n }\n case \"image\": {\n if (part.image instanceof URL) {\n return {\n type: \"image\",\n image: part.image.href,\n };\n }\n throw new Error(\"Only images with URL data are supported\");\n }\n case \"file\": {\n // TODO\n throw new Error(\"File content parts are not supported\");\n }\n default: {\n const unhandledType: never = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n });\n break;\n }\n case \"assistant\": {\n const newContent = lmMessage.content.map((part) => {\n if (part.type === \"tool-call\") {\n return {\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n argsText: JSON.stringify(part.args),\n args: part.args as Record<string, unknown>,\n } satisfies ToolCallContentPart;\n }\n return part;\n });\n\n if (mergeSteps) {\n const previousMessage = messages[messages.length - 1];\n if (previousMessage?.role === \"assistant\") {\n previousMessage.content.push(...newContent);\n break;\n }\n }\n\n messages.push({\n role: \"assistant\",\n content: newContent,\n });\n break;\n }\n case \"tool\": {\n const previousMessage = messages[messages.length - 1];\n if (previousMessage?.role !== \"assistant\")\n throw new Error(\n \"A tool message must be preceded by an assistant message.\",\n );\n\n for (const tool of lmMessage.content) {\n const toolCall = previousMessage.content.find(\n (c): c is ToolCallContentPart =>\n c.type === \"tool-call\" && c.toolCallId === tool.toolCallId,\n );\n if (!toolCall)\n throw new Error(\"Received tool result for an unknown tool call.\");\n if (toolCall.toolName !== tool.toolName)\n throw new Error(\"Tool call name mismatch.\");\n\n type Writable<T> = { -readonly [P in keyof T]: T[P] };\n const writable = toolCall as Writable<ToolCallContentPart>;\n writable.result = tool.result;\n if (tool.isError) {\n writable.isError = true;\n }\n }\n\n break;\n }\n\n default: {\n const unhandledRole: never = role;\n throw new Error(`Unknown message role: ${unhandledRole}`);\n }\n }\n }\n\n return messages;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,IAAM,4BAA4B,CACvC,IACA,EAAE,WAAW,MACK;AAClB,QAAM,WAA0B,CAAC;AAEjC,aAAW,aAAa,IAAI;AAC1B,UAAM,OAAO,UAAU;AACvB,YAAQ,MAAM;AAAA,MACZ,KAAK,UAAU;AACb,iBAAS,KAAK;AAAA,UACZ,MAAM;AAAA,UACN,SAAS;AAAA,YACP;AAAA,cACE,MAAM;AAAA,cACN,MAAM,UAAU;AAAA,YAClB;AAAA,UACF;AAAA,QACF,CAAC;AACD;AAAA,MACF;AAAA,MACA,KAAK,QAAQ;AACX,iBAAS,KAAK;AAAA,UACZ,MAAM;AAAA,UACN,SAAS,UAAU,QAAQ,IAAI,CAAC,SAAS;AACvC,kBAAM,OAAO,KAAK;AAClB,oBAAQ,MAAM;AAAA,cACZ,KAAK,QAAQ;AACX,uBAAO;AAAA,kBACL,MAAM;AAAA,kBACN,MAAM,KAAK;AAAA,gBACb;AAAA,cACF;AAAA,cACA,KAAK,SAAS;AACZ,oBAAI,KAAK,iBAAiB,KAAK;AAC7B,yBAAO;AAAA,oBACL,MAAM;AAAA,oBACN,OAAO,KAAK,MAAM;AAAA,kBACpB;AAAA,gBACF;AACA,sBAAM,IAAI,MA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AACvB,cAAI,KAAK,SAAS;AAChB,qBAAS,UAAU;AAAA,UACrB;AAAA,QACF;AAEA;AAAA,MACF;AAAA,MAEA,SAAS;AACP,cAAM,gBAAuB;AAC7B,cAAM,IAAI,MAAM,yBAAyB,aAAa,EAAE;AAAA,MAC1D;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
@@ -89,9 +89,10 @@ var fromLanguageModelMessages = (lm, { mergeSteps }) => {
|
|
89
89
|
throw new Error("Received tool result for an unknown tool call.");
|
90
90
|
if (toolCall.toolName !== tool.toolName)
|
91
91
|
throw new Error("Tool call name mismatch.");
|
92
|
-
|
92
|
+
const writable = toolCall;
|
93
|
+
writable.result = tool.result;
|
93
94
|
if (tool.isError) {
|
94
|
-
|
95
|
+
writable.isError = true;
|
95
96
|
}
|
96
97
|
}
|
97
98
|
break;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/edge/converters/fromLanguageModelMessages.ts"],"sourcesContent":["import { LanguageModelV1Message } from \"@ai-sdk/provider\";\nimport { CoreMessage, ToolCallContentPart } from \"../../../types\";\n\ntype fromLanguageModelMessagesOptions = {\n mergeSteps: boolean;\n};\n\nexport const fromLanguageModelMessages = (\n lm: LanguageModelV1Message[],\n { mergeSteps }: fromLanguageModelMessagesOptions,\n): CoreMessage[] => {\n const messages: CoreMessage[] = [];\n\n for (const lmMessage of lm) {\n const role = lmMessage.role;\n switch (role) {\n case \"system\": {\n messages.push({\n role: \"system\",\n content: [\n {\n type: \"text\",\n text: lmMessage.content,\n },\n ],\n });\n break;\n }\n case \"user\": {\n messages.push({\n role: \"user\",\n content: lmMessage.content.map((part) => {\n const type = part.type;\n switch (type) {\n case \"text\": {\n return {\n type: \"text\",\n text: part.text,\n };\n }\n case \"image\": {\n if (part.image instanceof URL) {\n return {\n type: \"image\",\n image: part.image.href,\n };\n }\n throw new Error(\"Only images with URL data are supported\");\n }\n case \"file\": {\n // TODO\n throw new Error(\"File content parts are not supported\");\n }\n default: {\n const unhandledType: never = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n });\n break;\n }\n case \"assistant\": {\n const newContent = lmMessage.content.map((part) => {\n if (part.type === \"tool-call\") {\n return {\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n argsText: JSON.stringify(part.args),\n args: part.args as Record<string, unknown>,\n } satisfies ToolCallContentPart;\n }\n return part;\n });\n\n if (mergeSteps) {\n const previousMessage = messages[messages.length - 1];\n if (previousMessage?.role === \"assistant\") {\n previousMessage.content.push(...newContent);\n break;\n }\n }\n\n messages.push({\n role: \"assistant\",\n content: newContent,\n });\n break;\n }\n case \"tool\": {\n const previousMessage = messages[messages.length - 1];\n if (previousMessage?.role !== \"assistant\")\n throw new Error(\n \"A tool message must be preceded by an assistant message.\",\n );\n\n for (const tool of lmMessage.content) {\n const toolCall = previousMessage.content.find(\n (c): c is ToolCallContentPart =>\n c.type === \"tool-call\" && c.toolCallId === tool.toolCallId,\n );\n if (!toolCall)\n throw new Error(\"Received tool result for an unknown tool call.\");\n if (toolCall.toolName !== tool.toolName)\n throw new Error(\"Tool call name mismatch.\");\n\n toolCall.result = tool.result;\n if (tool.isError) {\n
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/edge/converters/fromLanguageModelMessages.ts"],"sourcesContent":["import { LanguageModelV1Message } from \"@ai-sdk/provider\";\nimport { CoreMessage, ToolCallContentPart } from \"../../../types\";\nimport { Writable } from \"stream\";\n\ntype fromLanguageModelMessagesOptions = {\n mergeSteps: boolean;\n};\n\nexport const fromLanguageModelMessages = (\n lm: LanguageModelV1Message[],\n { mergeSteps }: fromLanguageModelMessagesOptions,\n): CoreMessage[] => {\n const messages: CoreMessage[] = [];\n\n for (const lmMessage of lm) {\n const role = lmMessage.role;\n switch (role) {\n case \"system\": {\n messages.push({\n role: \"system\",\n content: [\n {\n type: \"text\",\n text: lmMessage.content,\n },\n ],\n });\n break;\n }\n case \"user\": {\n messages.push({\n role: \"user\",\n content: lmMessage.content.map((part) => {\n const type = part.type;\n switch (type) {\n case \"text\": {\n return {\n type: \"text\",\n text: part.text,\n };\n }\n case \"image\": {\n if (part.image instanceof URL) {\n return {\n type: \"image\",\n image: part.image.href,\n };\n }\n throw new Error(\"Only images with URL data are supported\");\n }\n case \"file\": {\n // TODO\n throw new Error(\"File content parts are not supported\");\n }\n default: {\n const unhandledType: never = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n });\n break;\n }\n case \"assistant\": {\n const newContent = lmMessage.content.map((part) => {\n if (part.type === \"tool-call\") {\n return {\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n argsText: JSON.stringify(part.args),\n args: part.args as Record<string, unknown>,\n } satisfies ToolCallContentPart;\n }\n return part;\n });\n\n if (mergeSteps) {\n const previousMessage = messages[messages.length - 1];\n if (previousMessage?.role === \"assistant\") {\n previousMessage.content.push(...newContent);\n break;\n }\n }\n\n messages.push({\n role: \"assistant\",\n content: newContent,\n });\n break;\n }\n case \"tool\": {\n const previousMessage = messages[messages.length - 1];\n if (previousMessage?.role !== \"assistant\")\n throw new Error(\n \"A tool message must be preceded by an assistant message.\",\n );\n\n for (const tool of lmMessage.content) {\n const toolCall = previousMessage.content.find(\n (c): c is ToolCallContentPart =>\n c.type === \"tool-call\" && c.toolCallId === tool.toolCallId,\n );\n if (!toolCall)\n throw new Error(\"Received tool result for an unknown tool call.\");\n if (toolCall.toolName !== tool.toolName)\n throw new Error(\"Tool call name mismatch.\");\n\n type Writable<T> = { -readonly [P in keyof T]: T[P] };\n const writable = toolCall as Writable<ToolCallContentPart>;\n writable.result = tool.result;\n if (tool.isError) {\n writable.isError = true;\n }\n }\n\n break;\n }\n\n default: {\n const unhandledRole: never = role;\n throw new Error(`Unknown message role: ${unhandledRole}`);\n }\n }\n }\n\n return messages;\n};\n"],"mappings":";AAQO,IAAM,4BAA4B,CACvC,IACA,EAAE,WAAW,MACK;AAClB,QAAM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AAC;AAED,YAAI,YAAY;AACd,gBAAM,kBAAkB,SAAS,SAAS,SAAS,CAAC;AACpD,cAAI,iBAAiB,SAAS,aAAa;AACzC,4BAAgB,QAAQ,KAAK,GAAG,UAAU;AAC1C;AAAA,UACF;AAAA,QACF;AAEA,iBAAS,KAAK;AAAA,UACZ,MAAM;AAAA,UACN,SAAS;AAAA,QACX,CAAC;AACD;AAAA,MACF;AAAA,MACA,KAAK,QAAQ;AACX,cAAM,kBAAkB,SAAS,SAAS,SAAS,CAAC;AACpD,YAAI,iBAAiB,SAAS;AAC5B,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAEF,mBAAW,QAAQ,UAAU,SAAS;AACpC,gBAAM,WAAW,gBAAgB,QAAQ;AAAA,YACvC,CAAC,MACC,EAAE,SAAS,eAAe,EAAE,eAAe,KAAK;AAAA,UACpD;AACA,cAAI,CAAC;AACH,kBAAM,IAAI,MAAM,gDAAgD;AAClE,cAAI,SAAS,aAAa,KAAK;AAC7B,kBAAM,IAAI,MAAM,0BAA0B;AAG5C,gBAAM,WAAW;AACjB,mBAAS,SAAS,KAAK;AACvB,cAAI,KAAK,SAAS;AAChB,qBAAS,UAAU;AAAA,UACrB;AAAA,QACF;AAEA;AAAA,MACF;AAAA,MAEA,SAAS;AACP,cAAM,gBAAuB;AAC7B,cAAM,IAAI,MAAM,yBAAyB,aAAa,EAAE;AAAA,MAC1D;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { MessageStatus, TextContentPart, ImageContentPart, ToolCallContentPart, UIContentPart, ThreadMessage, CompleteAttachment } from "../../types";
|
2
|
-
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,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,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