@assistant-ui/react 0.7.2 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. package/dist/api/ContentPartRuntime.d.ts +5 -1
  2. package/dist/api/ContentPartRuntime.d.ts.map +1 -1
  3. package/dist/api/ContentPartRuntime.js.map +1 -1
  4. package/dist/api/ContentPartRuntime.mjs.map +1 -1
  5. package/dist/api/RuntimePathTypes.d.ts +0 -3
  6. package/dist/api/RuntimePathTypes.d.ts.map +1 -1
  7. package/dist/api/RuntimePathTypes.js.map +1 -1
  8. package/dist/api/ThreadListRuntime.d.ts +0 -5
  9. package/dist/api/ThreadListRuntime.d.ts.map +1 -1
  10. package/dist/api/ThreadListRuntime.js +4 -10
  11. package/dist/api/ThreadListRuntime.js.map +1 -1
  12. package/dist/api/ThreadListRuntime.mjs +4 -10
  13. package/dist/api/ThreadListRuntime.mjs.map +1 -1
  14. package/dist/runtimes/edge/converters/fromLanguageModelMessages.d.ts.map +1 -1
  15. package/dist/runtimes/edge/converters/fromLanguageModelMessages.js +3 -2
  16. package/dist/runtimes/edge/converters/fromLanguageModelMessages.js.map +1 -1
  17. package/dist/runtimes/edge/converters/fromLanguageModelMessages.mjs +3 -2
  18. package/dist/runtimes/edge/converters/fromLanguageModelMessages.mjs.map +1 -1
  19. package/dist/types/AssistantTypes.d.ts +57 -57
  20. package/dist/types/AssistantTypes.d.ts.map +1 -1
  21. package/dist/types/AssistantTypes.js.map +1 -1
  22. package/dist/ui/{attachment.d.ts → attachment-ui.d.ts} +3 -3
  23. package/dist/ui/attachment-ui.d.ts.map +1 -0
  24. package/dist/ui/{attachment.js → attachment-ui.js} +9 -9
  25. package/dist/ui/attachment-ui.js.map +1 -0
  26. package/dist/ui/{attachment.mjs → attachment-ui.mjs} +6 -6
  27. package/dist/ui/attachment-ui.mjs.map +1 -0
  28. package/dist/ui/composer.js +2 -2
  29. package/dist/ui/composer.js.map +1 -1
  30. package/dist/ui/composer.mjs +1 -1
  31. package/dist/ui/composer.mjs.map +1 -1
  32. package/dist/ui/index.d.ts +1 -1
  33. package/dist/ui/index.d.ts.map +1 -1
  34. package/dist/ui/index.js +2 -2
  35. package/dist/ui/index.js.map +1 -1
  36. package/dist/ui/index.mjs +1 -1
  37. package/dist/ui/index.mjs.map +1 -1
  38. package/dist/ui/thread-config.d.ts +3 -0
  39. package/dist/ui/thread-config.d.ts.map +1 -1
  40. package/dist/ui/thread-config.js.map +1 -1
  41. package/dist/ui/thread-config.mjs.map +1 -1
  42. package/dist/ui/thread.d.ts +3 -7
  43. package/dist/ui/thread.d.ts.map +1 -1
  44. package/dist/ui/thread.js +5 -5
  45. package/dist/ui/thread.js.map +1 -1
  46. package/dist/ui/thread.mjs +5 -5
  47. package/dist/ui/thread.mjs.map +1 -1
  48. package/dist/ui/user-message.js +2 -2
  49. package/dist/ui/user-message.js.map +1 -1
  50. package/dist/ui/user-message.mjs +1 -1
  51. package/dist/ui/user-message.mjs.map +1 -1
  52. package/dist/utils/smooth/SmoothContext.d.ts +42 -42
  53. package/package.json +3 -3
  54. package/src/api/ContentPartRuntime.ts +6 -2
  55. package/src/api/RuntimePathTypes.ts +0 -4
  56. package/src/api/ThreadListRuntime.ts +4 -16
  57. package/src/runtimes/edge/converters/fromLanguageModelMessages.ts +5 -2
  58. package/src/types/AssistantTypes.ts +62 -57
  59. package/src/ui/{attachment.tsx → attachment-ui.tsx} +3 -3
  60. package/src/ui/composer.tsx +1 -1
  61. package/src/ui/index.ts +1 -1
  62. package/src/ui/thread-config.tsx +3 -0
  63. package/src/ui/thread.tsx +6 -12
  64. package/src/ui/user-message.tsx +1 -1
  65. package/dist/ui/attachment.d.ts.map +0 -1
  66. package/dist/ui/attachment.js.map +0 -1
  67. 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,oBAAoB,CAAC;AAE5D,MAAM,MAAM,gBAAgB,GAAG,CAC3B,qBAAqB,GACrB,0BAA0B,CAC7B,GAAG;IACF,QAAQ,CAAC,MAAM,EAAE,iBAAiB,GAAG,yBAAyB,CAAC;CAChE,CAAC;AAEF,KAAK,0BAA0B,GAAG,qBAAqB,CACrD,gBAAgB,EAChB,sBAAsB,CACvB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;IAEtC,QAAQ,IAAI,gBAAgB,CAAC;IAC7B,aAAa,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC;IACjC,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;CAC9C,CAAC;AAEF,qBAAa,sBAAuB,YAAW,kBAAkB;IAM7D,OAAO,CAAC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B;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 readonly path: ContentPartRuntimePath;\n\n getState(): ContentPartState;\n addToolResult(result: any): void;\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;AAgCO,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
+ {"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 readonly path: ContentPartRuntimePath;\n\n getState(): ContentPartState;\n addToolResult(result: any): void;\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":";AAgCO,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
+ {"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,6 +1,3 @@
1
- export type ThreadListRuntimePath = {
2
- readonly ref: string;
3
- };
4
1
  export type ThreadListItemRuntimePath = {
5
2
  readonly ref: string;
6
3
  readonly threadSelector: {
@@ -1 +1 @@
1
- {"version":3,"file":"RuntimePathTypes.d.ts","sourceRoot":"","sources":["../../src/api/RuntimePathTypes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,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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["../../src/api/RuntimePathTypes.ts"],"sourcesContent":["export type ThreadListRuntimePath = {\n readonly ref: string;\n};\n\nexport 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
+ {"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,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,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,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,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;AAiCF,MAAM,MAAM,4BAA4B,GAAG,qBAAqB,CAAC;AAEjE,qBAAa,qBAAsB,YAAW,iBAAiB;IAMjD,OAAO,CAAC,KAAK;IALzB,IAAW,IAAI;;MAEd;IAED,OAAO,CAAC,SAAS,CAAC;gBACE,KAAK,EAAE,4BAA4B;IAUhD,QAAQ,IAAI,eAAe;IAI3B,SAAS,C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AE,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: THREAD_MANAGER_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: this.path.ref + `${this.path.ref}.threadItems[${idx}]`,
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: this.path.ref + `${this.path.ref}.archivedThreadItems[${idx}]`,
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: this.path.ref + `${this.path.ref}.threadItems[threadId=${threadId}]`,
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 { ThreadListRuntimePath } from \"./RuntimePathTypes\";\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 readonly path: ThreadListRuntimePath;\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\nconst THREAD_MANAGER_PATH = {\n ref: \"ThreadList\",\n};\n\nexport type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;\n\nexport class ThreadListRuntimeImpl implements ThreadListRuntime {\n public get path() {\n return THREAD_MANAGER_PATH;\n }\n\n private _getState;\n constructor(private _core: ThreadListRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: THREAD_MANAGER_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: this.path.ref + `${this.path.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: this.path.ref + `${this.path.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:\n this.path.ref +\n `${this.path.ref}.threadItems[threadId=${threadId}]`,\n threadSelector: { type: \"threadId\", threadId },\n },\n getState: () => {\n return getThreadListItemState(this._core, threadId);\n },\n subscribe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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,WA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,GAAG;AAAA,UAChC;AAAA,QACF;AAAA,QACA,WAAW,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: THREAD_MANAGER_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: this.path.ref + `${this.path.ref}.threadItems[${idx}]`,
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: this.path.ref + `${this.path.ref}.archivedThreadItems[${idx}]`,
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: this.path.ref + `${this.path.ref}.threadItems[threadId=${threadId}]`,
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 { ThreadListRuntimePath } from \"./RuntimePathTypes\";\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 readonly path: ThreadListRuntimePath;\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\nconst THREAD_MANAGER_PATH = {\n ref: \"ThreadList\",\n};\n\nexport type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;\n\nexport class ThreadListRuntimeImpl implements ThreadListRuntime {\n public get path() {\n return THREAD_MANAGER_PATH;\n }\n\n private _getState;\n constructor(private _core: ThreadListRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: THREAD_MANAGER_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: this.path.ref + `${this.path.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: this.path.ref + `${this.path.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:\n this.path.ref +\n `${this.path.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;AAInC;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAoBtC,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;AAEA,IAAM,sBAAsB;AAAA,EAC1B,KAAK;AACP;AAIO,IAAM,wBAAN,MAAyD;AAAA,EAM9D,YAAoB,OAAqC;AAArC;AAClB,UAAM,eAAe,IAAI,mBAAmB;AAAA,MAC1C,MAAM;AAAA,MACN,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,EAbA,IAAW,OAAO;AAChB,WAAO;AAAA,EACT;AAAA,EAEQ;AAAA,EAW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A,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":[]}
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,WA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AsB;AAAA,QACxB,MAAM;AAAA,UACJ,KAAK,uBAAuB,GAAG;AAAA,UAC/B,gBAAgB,EAAE,MAAM,gBAAgB,OAAO,IAAI;AAAA,QACrD;AAAA,QACA,UAAU,MAAM;AACd,iBAAO;AAAA,YACL,KAAK;AAAA,YACL,KAAK,MAAM,gBAAgB,GAAG;AAAA,UAChC;AAAA,QACF;AAAA,QACA,WAAW,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,sBAAsB;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":[]}
@@ -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;AAElE,KAAK,gCAAgC,GAAG;IACtC,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,yBAAyB,OAChC,sBAAsB,EAAE,kBACZ,gCAAgC,KAC/C,WAAW,EAkHb,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
- toolCall.result = tool.result;
116
+ const writable = toolCall;
117
+ writable.result = tool.result;
117
118
  if (tool.isError) {
118
- toolCall.isError = true;
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 toolCall.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;AAOO,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;A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;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;AAE5C,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
+ {"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;AACv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pD,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":[]}
@@ -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
- toolCall.result = tool.result;
92
+ const writable = toolCall;
93
+ writable.result = tool.result;
93
94
  if (tool.isError) {
94
- toolCall.isError = true;
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 toolCall.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":";AAOO,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,MAAM,yCAAyC;AAAA,cAC3D;AAAA,cACA,KAAK,QAAQ;AAEX,sBAAM,IAAI,MAAM,sCAAsC;AAAA,cACxD;AAAA,cACA,SAAS;AACP,sBAAM,gBAAuB;AAC7B,sBAAM,IAAI,MAAM,8BAA8B,aAAa,EAAE;AAAA,cAC/D;AAAA,YACF;AAAA,UACF,CAAC;AAAA,QACH,CAAC;AACD;AAAA,MACF;A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elMessages.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,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,MAAM,yCAAyC;AAAA,cAC3D;AAAA,cACA,KAAK,QAAQ;AAEX,sBAAM,IAAI,MAAM,sCAAsC;AAAA,cACxD;AAAA,cACA,SAAS;AACP,sBAAM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C7B,cAAM,IAAI,MAAM,yBAAyB,aAAa,EAAE;AAAA,MAC1D;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -2,95 +2,95 @@ import type { ReactNode } from "react";
2
2
  import { CompleteAttachment } from "./AttachmentTypes";
3
3
  export type MessageRole = "user" | "assistant" | "system";
4
4
  export type TextContentPart = {
5
- type: "text";
6
- text: string;
5
+ readonly type: "text";
6
+ readonly text: string;
7
7
  };
8
8
  export type ImageContentPart = {
9
- type: "image";
10
- image: string;
9
+ readonly type: "image";
10
+ readonly image: string;
11
11
  };
12
12
  export type Unstable_AudioContentPart = {
13
- type: "audio";
14
- audio: {
15
- data: string;
16
- format: "mp3" | "wav";
13
+ readonly type: "audio";
14
+ readonly audio: {
15
+ readonly data: string;
16
+ readonly format: "mp3" | "wav";
17
17
  };
18
18
  };
19
19
  export type UIContentPart = {
20
- type: "ui";
21
- display: ReactNode;
20
+ readonly type: "ui";
21
+ readonly display: ReactNode;
22
22
  };
23
23
  export type CoreToolCallContentPart<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = {
24
- type: "tool-call";
25
- toolCallId: string;
26
- toolName: string;
27
- args: TArgs;
28
- result?: TResult | undefined;
29
- isError?: boolean | undefined;
24
+ readonly type: "tool-call";
25
+ readonly toolCallId: string;
26
+ readonly toolName: string;
27
+ readonly args: TArgs;
28
+ readonly result?: TResult | undefined;
29
+ readonly isError?: boolean | undefined;
30
30
  };
31
31
  export type ToolCallContentPart<TArgs extends Record<string, unknown> = Record<string | number, unknown>, TResult = unknown> = CoreToolCallContentPart<TArgs, TResult> & {
32
- argsText: string;
32
+ readonly argsText: string;
33
33
  };
34
34
  export type ThreadUserContentPart = TextContentPart | ImageContentPart | Unstable_AudioContentPart | UIContentPart;
35
35
  export type ThreadAssistantContentPart = TextContentPart | ToolCallContentPart | UIContentPart;
36
36
  type MessageCommonProps = {
37
- id: string;
38
- createdAt: Date;
37
+ readonly id: string;
38
+ readonly createdAt: Date;
39
39
  };
40
40
  export type ThreadStep = {
41
- usage?: {
42
- promptTokens: number;
43
- completionTokens: number;
41
+ readonly usage?: {
42
+ readonly promptTokens: number;
43
+ readonly completionTokens: number;
44
44
  } | undefined;
45
45
  };
46
46
  export type ContentPartStatus = {
47
- type: "running";
47
+ readonly type: "running";
48
48
  } | {
49
- type: "complete";
49
+ readonly type: "complete";
50
50
  } | {
51
- type: "incomplete";
52
- reason: "cancelled" | "length" | "content-filter" | "other" | "error";
53
- error?: unknown;
51
+ readonly type: "incomplete";
52
+ readonly reason: "cancelled" | "length" | "content-filter" | "other" | "error";
53
+ readonly error?: unknown;
54
54
  };
55
55
  export type ToolCallContentPartStatus = {
56
- type: "requires-action";
57
- reason: "tool-calls";
56
+ readonly type: "requires-action";
57
+ readonly reason: "tool-calls";
58
58
  } | ContentPartStatus;
59
59
  export type MessageStatus = {
60
- type: "running";
60
+ readonly type: "running";
61
61
  } | {
62
- type: "requires-action";
63
- reason: "tool-calls";
62
+ readonly type: "requires-action";
63
+ readonly reason: "tool-calls";
64
64
  } | {
65
- type: "complete";
66
- reason: "stop" | "unknown";
65
+ readonly type: "complete";
66
+ readonly reason: "stop" | "unknown";
67
67
  } | {
68
- type: "incomplete";
69
- reason: "cancelled" | "tool-calls" | "length" | "content-filter" | "other" | "error";
70
- error?: unknown;
68
+ readonly type: "incomplete";
69
+ readonly reason: "cancelled" | "tool-calls" | "length" | "content-filter" | "other" | "error";
70
+ readonly error?: unknown;
71
71
  };
72
72
  export type ThreadSystemMessage = MessageCommonProps & {
73
- role: "system";
74
- content: [TextContentPart];
75
- metadata: {
76
- custom: Record<string, unknown>;
73
+ readonly role: "system";
74
+ readonly content: [TextContentPart];
75
+ readonly metadata: {
76
+ readonly custom: Record<string, unknown>;
77
77
  };
78
78
  };
79
79
  export type ThreadUserMessage = MessageCommonProps & {
80
- role: "user";
81
- content: ThreadUserContentPart[];
82
- attachments: readonly CompleteAttachment[];
83
- metadata: {
84
- custom: Record<string, unknown>;
80
+ readonly role: "user";
81
+ readonly content: ThreadUserContentPart[];
82
+ readonly attachments: readonly CompleteAttachment[];
83
+ readonly metadata: {
84
+ readonly custom: Record<string, unknown>;
85
85
  };
86
86
  };
87
87
  export type ThreadAssistantMessage = MessageCommonProps & {
88
- role: "assistant";
89
- content: ThreadAssistantContentPart[];
90
- status: MessageStatus;
91
- metadata: {
92
- steps: ThreadStep[];
93
- custom: Record<string, unknown>;
88
+ readonly role: "assistant";
89
+ readonly content: ThreadAssistantContentPart[];
90
+ readonly status: MessageStatus;
91
+ readonly metadata: {
92
+ readonly steps: ThreadStep[];
93
+ readonly custom: Record<string, unknown>;
94
94
  };
95
95
  };
96
96
  export type AppendMessage = CoreMessage & {
@@ -99,12 +99,12 @@ export type AppendMessage = CoreMessage & {
99
99
  startRun?: boolean | undefined;
100
100
  };
101
101
  type BaseThreadMessage = {
102
- status?: ThreadAssistantMessage["status"];
103
- metadata: {
104
- steps?: ThreadStep[];
105
- custom: Record<string, unknown>;
102
+ readonly status?: ThreadAssistantMessage["status"];
103
+ readonly metadata: {
104
+ readonly steps?: ThreadStep[];
105
+ readonly custom: Record<string, unknown>;
106
106
  };
107
- attachments?: ThreadUserMessage["attachments"];
107
+ readonly attachments?: ThreadUserMessage["attachments"];
108
108
  };
109
109
  export type ThreadMessage = BaseThreadMessage & (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);
110
110
  /** Core Message Types (without UI content parts) */
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantTypes.d.ts","sourceRoot":"","sources":["../../src/types/AssistantTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,I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M,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC1C,CAAC;IACF,QAAQ,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAC3C,CAAC,mBAAmB,GAAG,iBAAiB,GAAG,sBAAsB,CAAC,CAAC;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 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":[]}
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 readonly type: \"text\";\n readonly text: string;\n};\n\nexport type ImageContentPart = {\n readonly type: \"image\";\n readonly image: string;\n};\n\nexport type Unstable_AudioContentPart = {\n readonly type: \"audio\";\n readonly audio: {\n readonly data: string;\n readonly format: \"mp3\" | \"wav\";\n };\n};\n\nexport type UIContentPart = {\n readonly type: \"ui\";\n readonly display: ReactNode;\n};\n\nexport type CoreToolCallContentPart<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly args: TArgs;\n readonly result?: TResult | undefined;\n readonly isError?: boolean | undefined;\n};\n\nexport type ToolCallContentPart<\n TArgs extends Record<string, unknown> = Record<string | number, unknown>,\n TResult = unknown,\n> = CoreToolCallContentPart<TArgs, TResult> & {\n readonly 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 readonly id: string;\n readonly createdAt: Date;\n};\n\nexport type ThreadStep = {\n readonly usage?:\n | {\n readonly promptTokens: number;\n readonly completionTokens: number;\n }\n | undefined;\n};\n\nexport type ContentPartStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"complete\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ToolCallContentPartStatus =\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | ContentPartStatus;\n\nexport type MessageStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | {\n readonly type: \"complete\";\n readonly reason: \"stop\" | \"unknown\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"tool-calls\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ThreadSystemMessage = MessageCommonProps & {\n readonly role: \"system\";\n readonly content: [TextContentPart];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadUserMessage = MessageCommonProps & {\n readonly role: \"user\";\n readonly content: ThreadUserContentPart[];\n readonly attachments: readonly CompleteAttachment[];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadAssistantMessage = MessageCommonProps & {\n readonly role: \"assistant\";\n readonly content: ThreadAssistantContentPart[];\n readonly status: MessageStatus;\n readonly metadata: {\n readonly steps: ThreadStep[];\n readonly 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 readonly status?: ThreadAssistantMessage[\"status\"];\n readonly metadata: {\n readonly steps?: ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n readonly 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":[]}