@assistant-ui/react 0.7.70 → 0.7.72

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. package/dist/cloud/auiV0.d.ts +3 -0
  2. package/dist/cloud/auiV0.d.ts.map +1 -1
  3. package/dist/cloud/auiV0.js +6 -0
  4. package/dist/cloud/auiV0.js.map +1 -1
  5. package/dist/cloud/auiV0.mjs +6 -0
  6. package/dist/cloud/auiV0.mjs.map +1 -1
  7. package/dist/primitives/contentPart/useContentPartReasoning.d.ts +5 -0
  8. package/dist/primitives/contentPart/useContentPartReasoning.d.ts.map +1 -0
  9. package/dist/primitives/contentPart/useContentPartReasoning.js +42 -0
  10. package/dist/primitives/contentPart/useContentPartReasoning.js.map +1 -0
  11. package/dist/primitives/contentPart/useContentPartReasoning.mjs +18 -0
  12. package/dist/primitives/contentPart/useContentPartReasoning.mjs.map +1 -0
  13. package/dist/primitives/index.d.ts +1 -0
  14. package/dist/primitives/index.d.ts.map +1 -1
  15. package/dist/primitives/index.js +3 -0
  16. package/dist/primitives/index.js.map +1 -1
  17. package/dist/primitives/index.mjs +2 -0
  18. package/dist/primitives/index.mjs.map +1 -1
  19. package/dist/primitives/message/MessageContent.d.ts +2 -1
  20. package/dist/primitives/message/MessageContent.d.ts.map +1 -1
  21. package/dist/primitives/message/MessageContent.js +5 -1
  22. package/dist/primitives/message/MessageContent.js.map +1 -1
  23. package/dist/primitives/message/MessageContent.mjs +5 -1
  24. package/dist/primitives/message/MessageContent.mjs.map +1 -1
  25. package/dist/runtimes/edge/EdgeRuntimeRequestOptions.d.ts +6 -6
  26. package/dist/runtimes/edge/converters/toCoreMessages.d.ts.map +1 -1
  27. package/dist/runtimes/edge/converters/toCoreMessages.js +2 -1
  28. package/dist/runtimes/edge/converters/toCoreMessages.js.map +1 -1
  29. package/dist/runtimes/edge/converters/toCoreMessages.mjs +2 -1
  30. package/dist/runtimes/edge/converters/toCoreMessages.mjs.map +1 -1
  31. package/dist/runtimes/edge/converters/toLanguageModelMessages.d.ts.map +1 -1
  32. package/dist/runtimes/edge/converters/toLanguageModelMessages.js +3 -0
  33. package/dist/runtimes/edge/converters/toLanguageModelMessages.js.map +1 -1
  34. package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs +3 -0
  35. package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs.map +1 -1
  36. package/dist/runtimes/edge/createEdgeRuntimeAPI.d.ts +2 -2
  37. package/dist/runtimes/edge/createEdgeRuntimeAPI.d.ts.map +1 -1
  38. package/dist/runtimes/edge/createEdgeRuntimeAPI.js +10 -1
  39. package/dist/runtimes/edge/createEdgeRuntimeAPI.js.map +1 -1
  40. package/dist/runtimes/edge/createEdgeRuntimeAPI.mjs +10 -1
  41. package/dist/runtimes/edge/createEdgeRuntimeAPI.mjs.map +1 -1
  42. package/dist/runtimes/edge/streams/assistantEncoderStream.d.ts.map +1 -1
  43. package/dist/runtimes/edge/streams/assistantEncoderStream.js +7 -0
  44. package/dist/runtimes/edge/streams/assistantEncoderStream.js.map +1 -1
  45. package/dist/runtimes/edge/streams/assistantEncoderStream.mjs +7 -0
  46. package/dist/runtimes/edge/streams/assistantEncoderStream.mjs.map +1 -1
  47. package/dist/runtimes/edge/streams/runResultStream.d.ts.map +1 -1
  48. package/dist/runtimes/edge/streams/runResultStream.js +21 -2
  49. package/dist/runtimes/edge/streams/runResultStream.js.map +1 -1
  50. package/dist/runtimes/edge/streams/runResultStream.mjs +21 -2
  51. package/dist/runtimes/edge/streams/runResultStream.mjs.map +1 -1
  52. package/dist/runtimes/edge/streams/toolResultStream.d.ts.map +1 -1
  53. package/dist/runtimes/edge/streams/toolResultStream.js +1 -0
  54. package/dist/runtimes/edge/streams/toolResultStream.js.map +1 -1
  55. package/dist/runtimes/edge/streams/toolResultStream.mjs +1 -0
  56. package/dist/runtimes/edge/streams/toolResultStream.mjs.map +1 -1
  57. package/dist/runtimes/external-store/ThreadMessageLike.d.ts +2 -2
  58. package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
  59. package/dist/runtimes/external-store/ThreadMessageLike.js +2 -1
  60. package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
  61. package/dist/runtimes/external-store/ThreadMessageLike.mjs +2 -1
  62. package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
  63. package/dist/runtimes/local/ChatModelAdapter.d.ts +2 -2
  64. package/dist/runtimes/local/ChatModelAdapter.d.ts.map +1 -1
  65. package/dist/runtimes/local/ChatModelAdapter.js.map +1 -1
  66. package/dist/styles/index.css +57 -29
  67. package/dist/styles/index.css.map +1 -1
  68. package/dist/styles/tailwindcss/thread.css +30 -23
  69. package/dist/styles/tailwindcss/thread.css.json +31 -25
  70. package/dist/types/AssistantTypes.d.ts +5 -1
  71. package/dist/types/AssistantTypes.d.ts.map +1 -1
  72. package/dist/types/AssistantTypes.js.map +1 -1
  73. package/dist/types/ContentPartComponentTypes.d.ts +3 -1
  74. package/dist/types/ContentPartComponentTypes.d.ts.map +1 -1
  75. package/dist/types/ContentPartComponentTypes.js.map +1 -1
  76. package/dist/types/index.d.ts +2 -2
  77. package/dist/types/index.d.ts.map +1 -1
  78. package/dist/types/index.js.map +1 -1
  79. package/package.json +14 -14
  80. package/src/cloud/auiV0.ts +11 -0
  81. package/src/primitives/contentPart/useContentPartReasoning.tsx +18 -0
  82. package/src/primitives/index.ts +1 -0
  83. package/src/primitives/message/MessageContent.tsx +8 -0
  84. package/src/runtimes/edge/converters/toCoreMessages.ts +2 -1
  85. package/src/runtimes/edge/converters/toLanguageModelMessages.ts +4 -0
  86. package/src/runtimes/edge/createEdgeRuntimeAPI.ts +12 -3
  87. package/src/runtimes/edge/streams/assistantEncoderStream.ts +8 -0
  88. package/src/runtimes/edge/streams/runResultStream.ts +26 -2
  89. package/src/runtimes/edge/streams/toolResultStream.ts +1 -0
  90. package/src/runtimes/external-store/ThreadMessageLike.tsx +5 -3
  91. package/src/runtimes/local/ChatModelAdapter.tsx +2 -1
  92. package/src/styles/tailwindcss/thread.css +30 -23
  93. package/src/types/AssistantTypes.ts +7 -0
  94. package/src/types/ContentPartComponentTypes.tsx +4 -0
  95. package/src/types/index.ts +3 -0
@@ -7,6 +7,9 @@ import { ExportedMessageRepositoryItem } from "../runtimes/utils/MessageReposito
7
7
  type AuiV0MessageContentPart = {
8
8
  readonly type: "text";
9
9
  readonly text: string;
10
+ } | {
11
+ readonly type: "reasoning";
12
+ readonly text: string;
10
13
  } | {
11
14
  readonly type: "tool-call";
12
15
  readonly toolCallId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"auiV0.d.ts","sourceRoot":"","sources":["../../src/cloud/auiV0.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AAEpF,KAAK,uBAAuB,GACxB;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;CACzB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAA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,CAAC;QAC5D,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAC;QACrD,QAAQ,CAAC,KAAK,EAAE,SAAS;YACvB,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACf,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;gBAC9B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;aACnC,CAAC;SACH,EAAE,CAAC;QACJ,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;KACvC,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,WAAW,YAAa,aAAa,KAAG,YAiEpD,CAAC;AAEF,eAAO,MAAM,WAAW,iBACR,YAAY,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,KAChD,6BAmBF,CAAC"}
@@ -38,6 +38,12 @@ var auiV0Encode = (message) => {
38
38
  text: part.text
39
39
  };
40
40
  }
41
+ case "reasoning": {
42
+ return {
43
+ type: "reasoning",
44
+ text: part.text
45
+ };
46
+ }
41
47
  case "tool-call": {
42
48
  if (!(0, import_is_json.isJSONValue)(part.result)) {
43
49
  console.warn(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cloud/auiV0.ts"],"sourcesContent":["import { JSONObject } from \"@ai-sdk/provider\";\nimport { ThreadMessage } from \"../types\";\nimport { MessageStatus } from \"../types/AssistantTypes\";\nimport { fromThreadMessageLike } from \"../runtimes/external-store/ThreadMessageLike\";\nimport { CloudMessage } from \"./AssistantCloudThreadMessages\";\nimport { isJSONValue } from \"../utils/json/is-json\";\nimport {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"../utils/json/json-value\";\nimport { ExportedMessageRepositoryItem } from \"../runtimes/utils/MessageRepository\";\n\ntype AuiV0MessageContentPart =\n | {\n readonly type: \"text\";\n readonly text: string;\n }\n | {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly args: ReadonlyJSONObject;\n readonly result?: ReadonlyJSONValue;\n readonly isError?: true;\n }\n | {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly argsText: string;\n readonly result?: ReadonlyJSONValue;\n readonly isError?: true;\n };\n\ntype AuiV0Message = {\n readonly role: \"assistant\" | \"user\" | \"system\";\n readonly status?: MessageStatus;\n readonly content: readonly AuiV0MessageContentPart[];\n readonly metadata: {\n readonly unstable_annotations: readonly ReadonlyJSONValue[];\n readonly unstable_data: readonly ReadonlyJSONValue[];\n readonly steps: readonly {\n readonly usage?: {\n readonly promptTokens: number;\n readonly completionTokens: number;\n };\n }[];\n readonly custom: Readonly<JSONObject>;\n };\n};\n\nexport const auiV0Encode = (message: ThreadMessage): AuiV0Message => {\n // TODO attachments are currently intentionally ignored\n // info: ID and createdAt are ignored (we use the server value instead)\n return {\n role: message.role,\n content: message.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\n case \"tool-call\": {\n if (!isJSONValue(part.result)) {\n console.warn(\n \"tool-call result is not JSON! \" + JSON.stringify(part),\n );\n }\n return {\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n ...(JSON.stringify(part.args) === part.argsText\n ? {\n args: part.args,\n }\n : { argsText: part.argsText }),\n ...(part.result\n ? { result: part.result as ReadonlyJSONValue }\n : {}),\n ...(part.isError ? { isError: true } : {}),\n };\n }\n\n default: {\n const unhandledType: \"ui\" | \"image\" | \"file\" | \"audio\" = type;\n throw new Error(\n `Content part type not supported by aui/v0: ${unhandledType}`,\n );\n }\n }\n }),\n metadata: message.metadata as AuiV0Message[\"metadata\"],\n ...(message.status\n ? {\n status:\n message.status?.type === \"running\"\n ? {\n type: \"incomplete\",\n reason: \"cancelled\",\n }\n : message.status,\n }\n : undefined),\n };\n};\n\nexport const auiV0Decode = (\n cloudMessage: CloudMessage & { format: \"aui/v0\" },\n): ExportedMessageRepositoryItem => {\n const payload = cloudMessage.content as unknown as AuiV0Message;\n const message = fromThreadMessageLike(\n {\n id: cloudMessage.id,\n createdAt: cloudMessage.created_at,\n ...payload,\n },\n cloudMessage.id,\n {\n type: \"complete\",\n reason: \"unknown\",\n },\n );\n\n return {\n parentId: cloudMessage.parent_id,\n message,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,+BAAsC;AAEtC,qBAA4B;AA8CrB,IAAM,cAAc,CAAC,YAAyC;AAGnE,SAAO;AAAA,IACL,MAAM,QAAQ;AAAA,IACd,SAAS,QAAQ,QAAQ,IAAI,CAAC,SAAS;AACrC,YAAM,OAAO,KAAK;AAClB,cAAQ,MAAM;AAAA,QACZ,KAAK,QAAQ;AACX,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,MAAM,KAAK;AAAA,UACb;AAAA,QACF;AAAA,QAEA,KAAK,aAAa;AAChB,cAAI,KAAC,4BAAY,KAAK,MAAM,GAAG;AAC7B,oBAAQ;AAAA,cACN,mCAAmC,KAAK,UAAU,IAAI;AAAA,YACxD;AAAA,UACF;AACA,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,YAAY,KAAK;AAAA,YACjB,UAAU,KAAK;AAAA,YACf,GAAI,KAAK,UAAU,KAAK,IAAI,MAAM,KAAK,WACnC;AAAA,cACE,MAAM,KAAK;AAAA,YACb,IACA,EAAE,UAAU,KAAK,SAAS;AAAA,YAC9B,GAAI,KAAK,SACL,EAAE,QAAQ,KAAK,OAA4B,IAC3C,CAAC;AAAA,YACL,GAAI,KAAK,UAAU,EAAE,SAAS,KAAK,IAAI,CAAC;AAAA,UAC1C;AAAA,QACF;AAAA,QAEA,SAAS;AACP,gBAAM,gBAAmD;AACzD,gBAAM,IAAI;AAAA,YACR,8CAA8C,aAAa;AAAA,UAC7D;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,IACD,UAAU,QAAQ;AAAA,IAClB,GAAI,QAAQ,SACR;AAAA,MACE,QACE,QAAQ,QAAQ,SAAS,YACrB;AAAA,QACE,MAAM;AAAA,QACN,QAAQ;AAAA,MACV,IACA,QAAQ;AAAA,IAChB,IACA;AAAA,EACN;AACF;AAEO,IAAM,cAAc,CACzB,iBACkC;AAClC,QAAM,UAAU,aAAa;AAC7B,QAAM,cAAU;AAAA,IACd;AAAA,MACE,IAAI,aAAa;AAAA,MACjB,WAAW,aAAa;AAAA,MACxB,GAAG;AAAA,IACL;AAAA,IACA,aAAa;AAAA,IACb;AAAA,MACE,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,SAAO;AAAA,IACL,UAAU,aAAa;AAAA,IACvB;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/cloud/auiV0.ts"],"sourcesContent":["import { JSONObject } from \"@ai-sdk/provider\";\nimport { ThreadMessage } from \"../types\";\nimport { MessageStatus } from \"../types/AssistantTypes\";\nimport { fromThreadMessageLike } from \"../runtimes/external-store/ThreadMessageLike\";\nimport { CloudMessage } from \"./AssistantCloudThreadMessages\";\nimport { isJSONValue } from \"../utils/json/is-json\";\nimport {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"../utils/json/json-value\";\nimport { ExportedMessageRepositoryItem } from \"../runtimes/utils/MessageRepository\";\n\ntype AuiV0MessageContentPart =\n | {\n readonly type: \"text\";\n readonly text: string;\n }\n | {\n readonly type: \"reasoning\";\n readonly text: string;\n }\n | {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly args: ReadonlyJSONObject;\n readonly result?: ReadonlyJSONValue;\n readonly isError?: true;\n }\n | {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly argsText: string;\n readonly result?: ReadonlyJSONValue;\n readonly isError?: true;\n };\n\ntype AuiV0Message = {\n readonly role: \"assistant\" | \"user\" | \"system\";\n readonly status?: MessageStatus;\n readonly content: readonly AuiV0MessageContentPart[];\n readonly metadata: {\n readonly unstable_annotations: readonly ReadonlyJSONValue[];\n readonly unstable_data: readonly ReadonlyJSONValue[];\n readonly steps: readonly {\n readonly usage?: {\n readonly promptTokens: number;\n readonly completionTokens: number;\n };\n }[];\n readonly custom: Readonly<JSONObject>;\n };\n};\n\nexport const auiV0Encode = (message: ThreadMessage): AuiV0Message => {\n // TODO attachments are currently intentionally ignored\n // info: ID and createdAt are ignored (we use the server value instead)\n return {\n role: message.role,\n content: message.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\n case \"reasoning\": {\n return {\n type: \"reasoning\",\n text: part.text,\n };\n }\n\n case \"tool-call\": {\n if (!isJSONValue(part.result)) {\n console.warn(\n \"tool-call result is not JSON! \" + JSON.stringify(part),\n );\n }\n return {\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n ...(JSON.stringify(part.args) === part.argsText\n ? {\n args: part.args,\n }\n : { argsText: part.argsText }),\n ...(part.result\n ? { result: part.result as ReadonlyJSONValue }\n : {}),\n ...(part.isError ? { isError: true } : {}),\n };\n }\n\n default: {\n const unhandledType: \"ui\" | \"image\" | \"file\" | \"audio\" = type;\n throw new Error(\n `Content part type not supported by aui/v0: ${unhandledType}`,\n );\n }\n }\n }),\n metadata: message.metadata as AuiV0Message[\"metadata\"],\n ...(message.status\n ? {\n status:\n message.status?.type === \"running\"\n ? {\n type: \"incomplete\",\n reason: \"cancelled\",\n }\n : message.status,\n }\n : undefined),\n };\n};\n\nexport const auiV0Decode = (\n cloudMessage: CloudMessage & { format: \"aui/v0\" },\n): ExportedMessageRepositoryItem => {\n const payload = cloudMessage.content as unknown as AuiV0Message;\n const message = fromThreadMessageLike(\n {\n id: cloudMessage.id,\n createdAt: cloudMessage.created_at,\n ...payload,\n },\n cloudMessage.id,\n {\n type: \"complete\",\n reason: \"unknown\",\n },\n );\n\n return {\n parentId: cloudMessage.parent_id,\n message,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AA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;AAEO,IAAM,cAAc,CACzB,iBACkC;AAClC,QAAM,UAAU,aAAa;AAC7B,QAAM,cAAU;AAAA,IACd;AAAA,MACE,IAAI,aAAa;AAAA,MACjB,WAAW,aAAa;AAAA,MACxB,GAAG;AAAA,IACL;AAAA,IACA,aAAa;AAAA,IACb;AAAA,MACE,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,SAAO;AAAA,IACL,UAAU,aAAa;AAAA,IACvB;AAAA,EACF;AACF;","names":[]}
@@ -13,6 +13,12 @@ var auiV0Encode = (message) => {
13
13
  text: part.text
14
14
  };
15
15
  }
16
+ case "reasoning": {
17
+ return {
18
+ type: "reasoning",
19
+ text: part.text
20
+ };
21
+ }
16
22
  case "tool-call": {
17
23
  if (!isJSONValue(part.result)) {
18
24
  console.warn(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cloud/auiV0.ts"],"sourcesContent":["import { JSONObject } from \"@ai-sdk/provider\";\nimport { ThreadMessage } from \"../types\";\nimport { MessageStatus } from \"../types/AssistantTypes\";\nimport { fromThreadMessageLike } from \"../runtimes/external-store/ThreadMessageLike\";\nimport { CloudMessage } from \"./AssistantCloudThreadMessages\";\nimport { isJSONValue } from \"../utils/json/is-json\";\nimport {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"../utils/json/json-value\";\nimport { ExportedMessageRepositoryItem } from \"../runtimes/utils/MessageRepository\";\n\ntype AuiV0MessageContentPart =\n | {\n readonly type: \"text\";\n readonly text: string;\n }\n | {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly args: ReadonlyJSONObject;\n readonly result?: ReadonlyJSONValue;\n readonly isError?: true;\n }\n | {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly argsText: string;\n readonly result?: ReadonlyJSONValue;\n readonly isError?: true;\n };\n\ntype AuiV0Message = {\n readonly role: \"assistant\" | \"user\" | \"system\";\n readonly status?: MessageStatus;\n readonly content: readonly AuiV0MessageContentPart[];\n readonly metadata: {\n readonly unstable_annotations: readonly ReadonlyJSONValue[];\n readonly unstable_data: readonly ReadonlyJSONValue[];\n readonly steps: readonly {\n readonly usage?: {\n readonly promptTokens: number;\n readonly completionTokens: number;\n };\n }[];\n readonly custom: Readonly<JSONObject>;\n };\n};\n\nexport const auiV0Encode = (message: ThreadMessage): AuiV0Message => {\n // TODO attachments are currently intentionally ignored\n // info: ID and createdAt are ignored (we use the server value instead)\n return {\n role: message.role,\n content: message.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\n case \"tool-call\": {\n if (!isJSONValue(part.result)) {\n console.warn(\n \"tool-call result is not JSON! \" + JSON.stringify(part),\n );\n }\n return {\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n ...(JSON.stringify(part.args) === part.argsText\n ? {\n args: part.args,\n }\n : { argsText: part.argsText }),\n ...(part.result\n ? { result: part.result as ReadonlyJSONValue }\n : {}),\n ...(part.isError ? { isError: true } : {}),\n };\n }\n\n default: {\n const unhandledType: \"ui\" | \"image\" | \"file\" | \"audio\" = type;\n throw new Error(\n `Content part type not supported by aui/v0: ${unhandledType}`,\n );\n }\n }\n }),\n metadata: message.metadata as AuiV0Message[\"metadata\"],\n ...(message.status\n ? {\n status:\n message.status?.type === \"running\"\n ? {\n type: \"incomplete\",\n reason: \"cancelled\",\n }\n : message.status,\n }\n : undefined),\n };\n};\n\nexport const auiV0Decode = (\n cloudMessage: CloudMessage & { format: \"aui/v0\" },\n): ExportedMessageRepositoryItem => {\n const payload = cloudMessage.content as unknown as AuiV0Message;\n const message = fromThreadMessageLike(\n {\n id: cloudMessage.id,\n createdAt: cloudMessage.created_at,\n ...payload,\n },\n cloudMessage.id,\n {\n type: \"complete\",\n reason: \"unknown\",\n },\n );\n\n return {\n parentId: cloudMessage.parent_id,\n message,\n };\n};\n"],"mappings":";AAGA,SAAS,6BAA6B;AAEt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ACxB,GAAG;AAAA,IACL;AAAA,IACA,aAAa;AAAA,IACb;AAAA,MACE,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,SAAO;AAAA,IACL,UAAU,aAAa;AAAA,IACvB;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/cloud/auiV0.ts"],"sourcesContent":["import { JSONObject } from \"@ai-sdk/provider\";\nimport { ThreadMessage } from \"../types\";\nimport { MessageStatus } from \"../types/AssistantTypes\";\nimport { fromThreadMessageLike } from \"../runtimes/external-store/ThreadMessageLike\";\nimport { CloudMessage } from \"./AssistantCloudThreadMessages\";\nimport { isJSONValue } from \"../utils/json/is-json\";\nimport {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"../utils/json/json-value\";\nimport { ExportedMessageRepositoryItem } from \"../runtimes/utils/MessageRepository\";\n\ntype AuiV0MessageContentPart =\n | {\n readonly type: \"text\";\n readonly text: string;\n }\n | {\n readonly type: \"reasoning\";\n readonly text: string;\n }\n | {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly args: ReadonlyJSONObject;\n readonly result?: ReadonlyJSONValue;\n readonly isError?: true;\n }\n | {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly argsText: string;\n readonly result?: ReadonlyJSONValue;\n readonly isError?: true;\n };\n\ntype AuiV0Message = {\n readonly role: \"assistant\" | \"user\" | \"system\";\n readonly status?: MessageStatus;\n readonly content: readonly AuiV0MessageContentPart[];\n readonly metadata: {\n readonly unstable_annotations: readonly ReadonlyJSONValue[];\n readonly unstable_data: readonly ReadonlyJSONValue[];\n readonly steps: readonly {\n readonly usage?: {\n readonly promptTokens: number;\n readonly completionTokens: number;\n };\n }[];\n readonly custom: Readonly<JSONObject>;\n };\n};\n\nexport const auiV0Encode = (message: ThreadMessage): AuiV0Message => {\n // TODO attachments are currently intentionally ignored\n // info: ID and createdAt are ignored (we use the server value instead)\n return {\n role: message.role,\n content: message.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\n case \"reasoning\": {\n return {\n type: \"reasoning\",\n text: part.text,\n };\n }\n\n case \"tool-call\": {\n if (!isJSONValue(part.result)) {\n console.warn(\n \"tool-call result is not JSON! \" + JSON.stringify(part),\n );\n }\n return {\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n ...(JSON.stringify(part.args) === part.argsText\n ? {\n args: part.args,\n }\n : { argsText: part.argsText }),\n ...(part.result\n ? { result: part.result as ReadonlyJSONValue }\n : {}),\n ...(part.isError ? { isError: true } : {}),\n };\n }\n\n default: {\n const unhandledType: \"ui\" | \"image\" | \"file\" | \"audio\" = type;\n throw new Error(\n `Content part type not supported by aui/v0: ${unhandledType}`,\n );\n }\n }\n }),\n metadata: message.metadata as AuiV0Message[\"metadata\"],\n ...(message.status\n ? {\n status:\n message.status?.type === \"running\"\n ? {\n type: \"incomplete\",\n reason: \"cancelled\",\n }\n : message.status,\n }\n : undefined),\n };\n};\n\nexport const auiV0Decode = (\n cloudMessage: CloudMessage & { format: \"aui/v0\" },\n): ExportedMessageRepositoryItem => {\n const payload = cloudMessage.content as unknown as AuiV0Message;\n const message = fromThreadMessageLike(\n {\n id: cloudMessage.id,\n createdAt: cloudMessage.created_at,\n ...payload,\n },\n cloudMessage.id,\n {\n type: \"complete\",\n reason: \"unknown\",\n },\n );\n\n return {\n parentId: cloudMessage.parent_id,\n message,\n };\n};\n"],"mappings":";AAGA,SAAS,6BAA6B;AAEtC,SAAS,mBAAmB;AAkDrB,IAAM,cAAc,CAAC,YAAyC;AAGnE,SAAO;AAAA,IACL,MAAM,QAAQ;AAAA,IACd,SAAS,QAAQ,QAAQ,IAAI,CAAC,SAAS;AACrC,YAAM,OAAO,KAAK;AAClB,cAAQ,MAAM;AAAA,QACZ,KAAK,QAAQ;AACX,iBAAO;AAAA,YACL,MAAM;AAAA,YACN,MAAM,KA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AA,EACF;AACF;","names":[]}
@@ -0,0 +1,5 @@
1
+ import { ReasoningContentPart } from "../../types";
2
+ export declare const useContentPartReasoning: () => ReasoningContentPart & {
3
+ readonly status: import("../../types/AssistantTypes").ContentPartStatus | import("../../types/AssistantTypes").ToolCallContentPartStatus;
4
+ };
5
+ //# sourceMappingURL=useContentPartReasoning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContentPartReasoning.d.ts","sourceRoot":"","sources":["../../../src/primitives/contentPart/useContentPartReasoning.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,eAAO,MAAM,uBAAuB;;CAWnC,CAAC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/primitives/contentPart/useContentPartReasoning.tsx
22
+ var useContentPartReasoning_exports = {};
23
+ __export(useContentPartReasoning_exports, {
24
+ useContentPartReasoning: () => useContentPartReasoning
25
+ });
26
+ module.exports = __toCommonJS(useContentPartReasoning_exports);
27
+ var import_ContentPartContext = require("../../context/react/ContentPartContext.js");
28
+ var useContentPartReasoning = () => {
29
+ const text = (0, import_ContentPartContext.useContentPart)((c) => {
30
+ if (c.type !== "reasoning")
31
+ throw new Error(
32
+ "ContentPartReasoning can only be used inside reasoning content parts."
33
+ );
34
+ return c;
35
+ });
36
+ return text;
37
+ };
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ useContentPartReasoning
41
+ });
42
+ //# sourceMappingURL=useContentPartReasoning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/primitives/contentPart/useContentPartReasoning.tsx"],"sourcesContent":["\"use client\";\n\nimport { ContentPartState } from \"../../api/ContentPartRuntime\";\nimport { useContentPart } from \"../../context/react/ContentPartContext\";\nimport { ReasoningContentPart } from \"../../types\";\n\nexport const useContentPartReasoning = () => {\n const text = useContentPart((c) => {\n if (c.type !== \"reasoning\")\n throw new Error(\n \"ContentPartReasoning can only be used inside reasoning content parts.\",\n );\n\n return c as ContentPartState & ReasoningContentPart;\n });\n\n return text;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gCAA+B;AAGxB,IAAM,0BAA0B,MAAM;AAC3C,QAAM,WAAO,0CAAe,CAAC,MAAM;AACjC,QAAI,EAAE,SAAS;AACb,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAEF,WAAO;AAAA,EACT,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -0,0 +1,18 @@
1
+ "use client";
2
+
3
+ // src/primitives/contentPart/useContentPartReasoning.tsx
4
+ import { useContentPart } from "../../context/react/ContentPartContext.mjs";
5
+ var useContentPartReasoning = () => {
6
+ const text = useContentPart((c) => {
7
+ if (c.type !== "reasoning")
8
+ throw new Error(
9
+ "ContentPartReasoning can only be used inside reasoning content parts."
10
+ );
11
+ return c;
12
+ });
13
+ return text;
14
+ };
15
+ export {
16
+ useContentPartReasoning
17
+ };
18
+ //# sourceMappingURL=useContentPartReasoning.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/primitives/contentPart/useContentPartReasoning.tsx"],"sourcesContent":["\"use client\";\n\nimport { ContentPartState } from \"../../api/ContentPartRuntime\";\nimport { useContentPart } from \"../../context/react/ContentPartContext\";\nimport { ReasoningContentPart } from \"../../types\";\n\nexport const useContentPartReasoning = () => {\n const text = useContentPart((c) => {\n if (c.type !== \"reasoning\")\n throw new Error(\n \"ContentPartReasoning can only be used inside reasoning content parts.\",\n );\n\n return c as ContentPartState & ReasoningContentPart;\n });\n\n return text;\n};\n"],"mappings":";;;AAGA,SAAS,sBAAsB;AAGxB,IAAM,0BAA0B,MAAM;AAC3C,QAAM,OAAO,eAAe,CAAC,MAAM;AACjC,QAAI,EAAE,SAAS;AACb,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAEF,WAAO;AAAA,EACT,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -11,5 +11,6 @@ export * as ThreadListItemPrimitive from "./threadListItem";
11
11
  export { useContentPartDisplay } from "./contentPart/useContentPartDisplay";
12
12
  export { useContentPartImage } from "./contentPart/useContentPartImage";
13
13
  export { useContentPartText } from "./contentPart/useContentPartText";
14
+ export { useContentPartReasoning } from "./contentPart/useContentPartReasoning";
14
15
  export { useThreadViewportAutoScroll } from "./thread/useThreadViewportAutoScroll";
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,uBAAuB,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,mBAAmB,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,qBAAqB,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,iBAAiB,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,oBAAoB,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,gBAAgB,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,eAAe,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,mBAAmB,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,uBAAuB,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,uBAAuB,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,mBAAmB,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,qBAAqB,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,iBAAiB,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,oBAAoB,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,gBAAgB,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,eAAe,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,mBAAmB,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,uBAAuB,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC"}
@@ -42,6 +42,7 @@ __export(primitives_exports, {
42
42
  ThreadPrimitive: () => ThreadPrimitive,
43
43
  useContentPartDisplay: () => import_useContentPartDisplay.useContentPartDisplay,
44
44
  useContentPartImage: () => import_useContentPartImage.useContentPartImage,
45
+ useContentPartReasoning: () => import_useContentPartReasoning.useContentPartReasoning,
45
46
  useContentPartText: () => import_useContentPartText.useContentPartText,
46
47
  useThreadViewportAutoScroll: () => import_useThreadViewportAutoScroll.useThreadViewportAutoScroll
47
48
  });
@@ -59,6 +60,7 @@ var ThreadListItemPrimitive = __toESM(require("./threadListItem/index.js"));
59
60
  var import_useContentPartDisplay = require("./contentPart/useContentPartDisplay.js");
60
61
  var import_useContentPartImage = require("./contentPart/useContentPartImage.js");
61
62
  var import_useContentPartText = require("./contentPart/useContentPartText.js");
63
+ var import_useContentPartReasoning = require("./contentPart/useContentPartReasoning.js");
62
64
  var import_useThreadViewportAutoScroll = require("./thread/useThreadViewportAutoScroll.js");
63
65
  // Annotate the CommonJS export names for ESM import in node:
64
66
  0 && (module.exports = {
@@ -74,6 +76,7 @@ var import_useThreadViewportAutoScroll = require("./thread/useThreadViewportAuto
74
76
  ThreadPrimitive,
75
77
  useContentPartDisplay,
76
78
  useContentPartImage,
79
+ useContentPartReasoning,
77
80
  useContentPartText,
78
81
  useThreadViewportAutoScroll
79
82
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/primitives/index.ts"],"sourcesContent":["export * as ActionBarPrimitive from \"./actionBar\";\nexport * as AssistantModalPrimitive from \"./assistantModal\";\nexport * as AttachmentPrimitive from \"./attachment\";\nexport * as BranchPickerPrimitive from \"./branchPicker\";\nexport * as ComposerPrimitive from \"./composer\";\nexport * as ContentPartPrimitive from \"./contentPart\";\nexport * as MessagePrimitive from \"./message\";\nexport * as ThreadPrimitive from \"./thread\";\nexport * as ThreadListPrimitive from \"./threadList\";\nexport * as ThreadListItemPrimitive from \"./threadListItem\";\n\nexport { useContentPartDisplay } from \"./contentPart/useContentPartDisplay\";\nexport { useContentPartImage } from \"./contentPart/useContentPartImage\";\nexport { useContentPartText } from \"./contentPart/useContentPartText\";\nexport { useThreadViewportAutoScroll } from \"./thread/useThreadViewportAutoScroll\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAoC;AACpC,8BAAyC;AACzC,0BAAqC;AACrC,4BAAuC;AACvC,wBAAmC;AACnC,2BAAsC;AACtC,uBAAkC;AAClC,sBAAiC;AACjC,0BAAqC;AACrC,8BAAyC;AAEzC,mCAAsC;AACtC,iCAAoC;AACpC,gCAAmC;AACnC,yCAA4C;","names":[]}
1
+ {"version":3,"sources":["../../src/primitives/index.ts"],"sourcesContent":["export * as ActionBarPrimitive from \"./actionBar\";\nexport * as AssistantModalPrimitive from \"./assistantModal\";\nexport * as AttachmentPrimitive from \"./attachment\";\nexport * as BranchPickerPrimitive from \"./branchPicker\";\nexport * as ComposerPrimitive from \"./composer\";\nexport * as ContentPartPrimitive from \"./contentPart\";\nexport * as MessagePrimitive from \"./message\";\nexport * as ThreadPrimitive from \"./thread\";\nexport * as ThreadListPrimitive from \"./threadList\";\nexport * as ThreadListItemPrimitive from \"./threadListItem\";\n\nexport { useContentPartDisplay } from \"./contentPart/useContentPartDisplay\";\nexport { useContentPartImage } from \"./contentPart/useContentPartImage\";\nexport { useContentPartText } from \"./contentPart/useContentPartText\";\nexport { useContentPartReasoning } from \"./contentPart/useContentPartReasoning\";\nexport { useThreadViewportAutoScroll } from \"./thread/useThreadViewportAutoScroll\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAoC;AACpC,8BAAyC;AACzC,0BAAqC;AACrC,4BAAuC;AACvC,wBAAmC;AACnC,2BAAsC;AACtC,uBAAkC;AAClC,sBAAiC;AACjC,0BAAqC;AACrC,8BAAyC;AAEzC,mCAAsC;AACtC,iCAAoC;AACpC,gCAAmC;AACnC,qCAAwC;AACxC,yCAA4C;","names":[]}
@@ -12,6 +12,7 @@ import * as ThreadListItemPrimitive from "./threadListItem/index.mjs";
12
12
  import { useContentPartDisplay } from "./contentPart/useContentPartDisplay.mjs";
13
13
  import { useContentPartImage } from "./contentPart/useContentPartImage.mjs";
14
14
  import { useContentPartText } from "./contentPart/useContentPartText.mjs";
15
+ import { useContentPartReasoning } from "./contentPart/useContentPartReasoning.mjs";
15
16
  import { useThreadViewportAutoScroll } from "./thread/useThreadViewportAutoScroll.mjs";
16
17
  export {
17
18
  ActionBarPrimitive,
@@ -26,6 +27,7 @@ export {
26
27
  ThreadPrimitive,
27
28
  useContentPartDisplay,
28
29
  useContentPartImage,
30
+ useContentPartReasoning,
29
31
  useContentPartText,
30
32
  useThreadViewportAutoScroll
31
33
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/primitives/index.ts"],"sourcesContent":["export * as ActionBarPrimitive from \"./actionBar\";\nexport * as AssistantModalPrimitive from \"./assistantModal\";\nexport * as AttachmentPrimitive from \"./attachment\";\nexport * as BranchPickerPrimitive from \"./branchPicker\";\nexport * as ComposerPrimitive from \"./composer\";\nexport * as ContentPartPrimitive from \"./contentPart\";\nexport * as MessagePrimitive from \"./message\";\nexport * as ThreadPrimitive from \"./thread\";\nexport * as ThreadListPrimitive from \"./threadList\";\nexport * as ThreadListItemPrimitive from \"./threadListItem\";\n\nexport { useContentPartDisplay } from \"./contentPart/useContentPartDisplay\";\nexport { useContentPartImage } from \"./contentPart/useContentPartImage\";\nexport { useContentPartText } from \"./contentPart/useContentPartText\";\nexport { useThreadViewportAutoScroll } from \"./thread/useThreadViewportAutoScroll\";\n"],"mappings":";AAAA,YAAY,wBAAwB;AACpC,YAAY,6BAA6B;AACzC,YAAY,yBAAyB;AACrC,YAAY,2BAA2B;AACvC,YAAY,uBAAuB;AACnC,YAAY,0BAA0B;AACtC,YAAY,sBAAsB;AAClC,YAAY,qBAAqB;AACjC,YAAY,yBAAyB;AACrC,YAAY,6BAA6B;AAEzC,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,mCAAmC;","names":[]}
1
+ {"version":3,"sources":["../../src/primitives/index.ts"],"sourcesContent":["export * as ActionBarPrimitive from \"./actionBar\";\nexport * as AssistantModalPrimitive from \"./assistantModal\";\nexport * as AttachmentPrimitive from \"./attachment\";\nexport * as BranchPickerPrimitive from \"./branchPicker\";\nexport * as ComposerPrimitive from \"./composer\";\nexport * as ContentPartPrimitive from \"./contentPart\";\nexport * as MessagePrimitive from \"./message\";\nexport * as ThreadPrimitive from \"./thread\";\nexport * as ThreadListPrimitive from \"./threadList\";\nexport * as ThreadListItemPrimitive from \"./threadListItem\";\n\nexport { useContentPartDisplay } from \"./contentPart/useContentPartDisplay\";\nexport { useContentPartImage } from \"./contentPart/useContentPartImage\";\nexport { useContentPartText } from \"./contentPart/useContentPartText\";\nexport { useContentPartReasoning } from \"./contentPart/useContentPartReasoning\";\nexport { useThreadViewportAutoScroll } from \"./thread/useThreadViewportAutoScroll\";\n"],"mappings":";AAAA,YAAY,wBAAwB;AACpC,YAAY,6BAA6B;AACzC,YAAY,yBAAyB;AACrC,YAAY,2BAA2B;AACvC,YAAY,uBAAuB;AACnC,YAAY,0BAA0B;AACtC,YAAY,sBAAsB;AAClC,YAAY,qBAAqB;AACjC,YAAY,yBAAyB;AACrC,YAAY,6BAA6B;AAEzC,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,+BAA+B;AACxC,SAAS,mCAAmC;","names":[]}
@@ -1,9 +1,10 @@
1
1
  import { type ComponentType, type FC } from "react";
2
- import type { Unstable_AudioContentPartComponent, EmptyContentPartComponent, ImageContentPartComponent, TextContentPartComponent, ToolCallContentPartComponent, ToolCallContentPartProps, UIContentPartComponent, FileContentPartComponent } from "../../types/ContentPartComponentTypes";
2
+ import type { Unstable_AudioContentPartComponent, EmptyContentPartComponent, ImageContentPartComponent, TextContentPartComponent, ToolCallContentPartComponent, ToolCallContentPartProps, UIContentPartComponent, FileContentPartComponent, ReasoningContentPartComponent } from "../../types/ContentPartComponentTypes";
3
3
  export declare namespace MessagePrimitiveContent {
4
4
  type Props = {
5
5
  components?: {
6
6
  Empty?: EmptyContentPartComponent | undefined;
7
+ Reasoning?: ReasoningContentPartComponent | undefined;
7
8
  Text?: TextContentPartComponent | undefined;
8
9
  Image?: ImageContentPartComponent | undefined;
9
10
  File?: FileContentPartComponent | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"MessageContent.d.ts","sourceRoot":"","sources":["../../../src/primitives/message/MessageContent.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,EAAE,EAAiB,MAAM,OAAO,CAAC;AAenE,OAAO,KAAK,EACV,kCAAkC,EAClC,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,4BAA4B,EAC5B,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,uCAAuC,CAAC;AAI/C,yBAAiB,uBAAuB,CAAC;IACvC,KAAY,KAAK,GAAG;QAClB,UAAU,CAAC,EACP;YACE,KAAK,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;YAC9C,IAAI,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;YAC5C,KAAK,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;YAC9C,IAAI,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;YAC5C,cAAc,CAAC,EAAE,kCAAkC,GAAG,SAAS,CAAC;YAChE,EAAE,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;YACxC,KAAK,CAAC,EACF;gBACE,OAAO,CAAC,EACJ,MAAM,CAAC,MAAM,EAAE,4BAA4B,GAAG,SAAS,CAAC,GACxD,SAAS,CAAC;gBACd,QAAQ,CAAC,EAAE,aAAa,CAAC,wBAAwB,CAAC,GAAG,SAAS,CAAC;aAChE,GACD;gBACE,QAAQ,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;aACnD,GACD,SAAS,CAAC;SACf,GACD,SAAS,CAAC;KACf,CAAC;CACH;AAyJD,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,uBAAuB,CAAC,KAAK,CAYrE,CAAC"}
1
+ {"version":3,"file":"MessageContent.d.ts","sourceRoot":"","sources":["../../../src/primitives/message/MessageContent.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,EAAE,EAAiB,MAAM,OAAO,CAAC;AAenE,OAAO,KAAK,EACV,kCAAkC,EAClC,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,4BAA4B,EAC5B,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,6BAA6B,EAC9B,MAAM,uCAAuC,CAAC;AAI/C,yBAAiB,uBAAuB,CAAC;IACvC,KAAY,KAAK,GAAG;QAClB,UAAU,CAAC,EACP;YACE,KAAK,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;YAC9C,SAAS,CAAC,EAAE,6BAA6B,GAAG,SAAS,CAAC;YACtD,IAAI,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;YAC5C,KAAK,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;YAC9C,IAAI,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;YAC5C,cAAc,CAAC,EAAE,kCAAkC,GAAG,SAAS,CAAC;YAChE,EAAE,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;YACxC,KAAK,CAAC,EACF;gBACE,OAAO,CAAC,EACJ,MAAM,CAAC,MAAM,EAAE,4BAA4B,GAAG,SAAS,CAAC,GACxD,SAAS,CAAC;gBACd,QAAQ,CAAC,EAAE,aAAa,CAAC,wBAAwB,CAAC,GAAG,SAAS,CAAC;aAChE,GACD;gBACE,QAAQ,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;aACnD,GACD,SAAS,CAAC;SACf,GACD,SAAS,CAAC;KACf,CAAC;CACH;AA+JD,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,uBAAuB,CAAC,KAAK,CAYrE,CAAC"}
@@ -46,6 +46,7 @@ var defaultComponents = {
46
46
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentPartText.ContentPartPrimitiveText, {}),
47
47
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentPartInProgress.ContentPartPrimitiveInProgress, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontFamily: "revert" }, children: " \u25CF" }) })
48
48
  ] }),
49
+ Reasoning: () => null,
49
50
  Image: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentPartImage.ContentPartPrimitiveImage, {}),
50
51
  File: () => null,
51
52
  Unstable_Audio: () => null,
@@ -54,6 +55,7 @@ var defaultComponents = {
54
55
  var MessageContentPartComponent = ({
55
56
  components: {
56
57
  Text = defaultComponents.Text,
58
+ Reasoning = defaultComponents.Reasoning,
57
59
  Image = defaultComponents.Image,
58
60
  File = defaultComponents.File,
59
61
  Unstable_Audio: Audio = defaultComponents.Unstable_Audio,
@@ -76,6 +78,8 @@ var MessageContentPartComponent = ({
76
78
  switch (type) {
77
79
  case "text":
78
80
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { ...part });
81
+ case "reasoning":
82
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Reasoning, { ...part });
79
83
  case "image":
80
84
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Image, { ...part });
81
85
  case "file":
@@ -102,7 +106,7 @@ var MessageContentPartImpl = ({
102
106
  };
103
107
  var MessageContentPart = (0, import_react.memo)(
104
108
  MessageContentPartImpl,
105
- (prev, next) => prev.partIndex === next.partIndex && prev.components?.Text === next.components?.Text && prev.components?.Image === next.components?.Image && prev.components?.File === next.components?.File && prev.components?.Unstable_Audio === next.components?.Unstable_Audio && prev.components?.UI === next.components?.UI && prev.components?.tools === next.components?.tools
109
+ (prev, next) => prev.partIndex === next.partIndex && prev.components?.Text === next.components?.Text && prev.components?.Reasoning === next.components?.Reasoning && prev.components?.Image === next.components?.Image && prev.components?.File === next.components?.File && prev.components?.Unstable_Audio === next.components?.Unstable_Audio && prev.components?.UI === next.components?.UI && prev.components?.tools === next.components?.tools
106
110
  );
107
111
  var COMPLETE_STATUS = Object.freeze({
108
112
  type: "complete"
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/primitives/message/MessageContent.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentType, type FC, memo, useMemo } from \"react\";\nimport {\n TextContentPartProvider,\n useContentPart,\n useContentPartRuntime,\n useToolUIs,\n} from \"../../context\";\nimport {\n useMessage,\n useMessageRuntime,\n} from \"../../context/react/MessageContext\";\nimport { ContentPartRuntimeProvider } from \"../../context/providers/ContentPartRuntimeProvider\";\nimport { ContentPartPrimitiveText } from \"../contentPart/ContentPartText\";\nimport { ContentPartPrimitiveImage } from \"../contentPart/ContentPartImage\";\nimport { ContentPartPrimitiveDisplay } from \"../contentPart/ContentPartDisplay\";\nimport type {\n Unstable_AudioContentPartComponent,\n EmptyContentPartComponent,\n ImageContentPartComponent,\n TextContentPartComponent,\n ToolCallContentPartComponent,\n ToolCallContentPartProps,\n UIContentPartComponent,\n FileContentPartComponent,\n} from \"../../types/ContentPartComponentTypes\";\nimport { ContentPartPrimitiveInProgress } from \"../contentPart/ContentPartInProgress\";\nimport { ContentPartStatus } from \"../../types/AssistantTypes\";\n\nexport namespace MessagePrimitiveContent {\n export type Props = {\n components?:\n | {\n Empty?: EmptyContentPartComponent | undefined;\n Text?: TextContentPartComponent | undefined;\n Image?: ImageContentPartComponent | undefined;\n File?: FileContentPartComponent | undefined;\n Unstable_Audio?: Unstable_AudioContentPartComponent | undefined;\n UI?: UIContentPartComponent | undefined;\n tools?:\n | {\n by_name?:\n | Record<string, ToolCallContentPartComponent | undefined>\n | undefined;\n Fallback?: ComponentType<ToolCallContentPartProps> | undefined;\n }\n | {\n Override: ComponentType<ToolCallContentPartProps>;\n }\n | undefined;\n }\n | undefined;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallContentPartComponent | undefined;\n} & ToolCallContentPartProps) => {\n const Render = useToolUIs((s) => s.getToolUI(props.toolName)) ?? Fallback;\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst defaultComponents = {\n Text: () => (\n <p style={{ whiteSpace: \"pre-line\" }}>\n <ContentPartPrimitiveText />\n <ContentPartPrimitiveInProgress>\n <span style={{ fontFamily: \"revert\" }}>{\" \\u25CF\"}</span>\n </ContentPartPrimitiveInProgress>\n </p>\n ),\n Image: () => <ContentPartPrimitiveImage />,\n File: () => null,\n Unstable_Audio: () => null,\n UI: () => <ContentPartPrimitiveDisplay />,\n} satisfies MessagePrimitiveContent.Props[\"components\"];\n\ntype MessageContentPartComponentProps = {\n components: MessagePrimitiveContent.Props[\"components\"];\n};\n\nconst MessageContentPartComponent: FC<MessageContentPartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Image = defaultComponents.Image,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n UI = defaultComponents.UI,\n tools = {},\n } = {},\n}) => {\n const contentPartRuntime = useContentPartRuntime();\n\n const part = useContentPart();\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = (result: any) => contentPartRuntime.addToolResult(result);\n if (\"Override\" in tools)\n return <tools.Override {...part} addResult={addResult} />;\n const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;\n return <ToolUIDisplay {...part} Fallback={Tool} addResult={addResult} />;\n }\n\n if (part.status.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"image\":\n // eslint-disable-next-line jsx-a11y/alt-text\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n case \"ui\":\n return <UI {...part} />;\n\n default:\n const unhandledType: never = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n};\n\ntype MessageContentPartProps = {\n partIndex: number;\n components: MessagePrimitiveContent.Props[\"components\"];\n};\n\nconst MessageContentPartImpl: FC<MessageContentPartProps> = ({\n partIndex,\n components,\n}) => {\n const messageRuntime = useMessageRuntime();\n const runtime = useMemo(\n () => messageRuntime.getContentPartByIndex(partIndex),\n [messageRuntime, partIndex],\n );\n\n return (\n <ContentPartRuntimeProvider runtime={runtime}>\n <MessageContentPartComponent components={components} />\n </ContentPartRuntimeProvider>\n );\n};\n\nconst MessageContentPart = memo(\n MessageContentPartImpl,\n (prev, next) =>\n prev.partIndex === next.partIndex &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.UI === next.components?.UI &&\n prev.components?.tools === next.components?.tools,\n);\n\nconst COMPLETE_STATUS: ContentPartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst EmptyContentFallback: FC<{\n status: ContentPartStatus;\n component: TextContentPartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextContentPartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextContentPartProvider>\n );\n};\n\nconst EmptyContentImpl: FC<MessageContentPartComponentProps> = ({\n components,\n}) => {\n const status =\n useMessage((s) => s.status as ContentPartStatus) ?? COMPLETE_STATUS;\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n return (\n <EmptyContentFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyContent = memo(\n EmptyContentImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\nexport const MessagePrimitiveContent: FC<MessagePrimitiveContent.Props> = ({\n components,\n}) => {\n const contentLength = useMessage((s) => s.content.length);\n\n if (contentLength === 0) {\n return <EmptyContent components={components} />;\n }\n\n return Array.from({ length: contentLength }, (_, index) => (\n <MessageContentPart key={index} partIndex={index} components={components} />\n ));\n};\n\nMessagePrimitiveContent.displayName = \"MessagePrimitive.Content\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA2D;AAC3D,qBAKO;AACP,4BAGO;AACP,wCAA2C;AAC3C,6BAAyC;AACzC,8BAA0C;AAC1C,gCAA4C;AAW5C,mCAA+C;AAqCtC;AART,IAAM,gBAAgB,CAAC;AAAA,EACrB;AAAA,EACA,GAAG;AACL,MAEiC;AAC/B,QAAM,aAAS,2BAAW,CAAC,MAAM,EAAE,UAAU,MAAM,QAAQ,CAAC,KAAK;AACjE,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,4CAAC,UAAQ,GAAG,OAAO;AAC5B;AAEA,IAAM,oBAAoB;AAAA,EACxB,MAAM,MACJ,6CAAC,OAAE,OAAO,EAAE,YAAY,WAAW,GACjC;AAAA,gDAAC,mDAAyB;AAAA,IAC1B,4CAAC,+DACC,sDAAC,UAAK,OAAO,EAAE,YAAY,SAAS,GAAI,qBAAU,GACpD;AAAA,KACF;AAAA,EAEF,OAAO,MAAM,4CAAC,qDAA0B;AAAA,EACxC,MAAM,MAAM;AAAA,EACZ,gBAAgB,MAAM;AAAA,EACtB,IAAI,MAAM,4CAAC,yDAA4B;AACzC;AAMA,IAAM,8BAAoE,CAAC;AAAA,EACzE,YAAY;AAAA,IACV,OAAO,kBAAkB;AAAA,IACzB,QAAQ,kBAAkB;AAAA,IAC1B,OAAO,kBAAkB;AAAA,IACzB,gBAAgB,QAAQ,kBAAkB;AAAA,IAC1C,KAAK,kBAAkB;AAAA,IACvB,QAAQ,CAAC;AAAA,EACX,IAAI,CAAC;AACP,MAAM;AACJ,QAAM,yBAAqB,sCAAsB;AAEjD,QAAM,WAAO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AY,mBAAmB,KAAK,YAAY,kBACrD,KAAK,YAAY,OAAO,KAAK,YAAY,MACzC,KAAK,YAAY,UAAU,KAAK,YAAY;AAChD;AAEA,IAAM,kBAAqC,OAAO,OAAO;AAAA,EACvD,MAAM;AACR,CAAC;AAED,IAAM,uBAGD,CAAC,EAAE,QAAQ,WAAW,UAAU,MAAM;AACzC,SACE,4CAAC,0CAAwB,MAAK,IAAG,WAAW,OAAO,SAAS,WAC1D,sDAAC,aAAU,MAAK,QAAO,MAAK,IAAG,QAAgB,GACjD;AAEJ;AAEA,IAAM,mBAAyD,CAAC;AAAA,EAC9D;AACF,MAAM;AACJ,QAAM,aACJ,kCAAW,CAAC,MAAM,EAAE,MAA2B,KAAK;AAEtD,MAAI,YAAY,MAAO,QAAO,4CAAC,WAAW,OAAX,EAAiB,QAAgB;AAEhE,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WAAW,YAAY,QAAQ,kBAAkB;AAAA;AAAA,EACnD;AAEJ;AAEA,IAAM,mBAAe;AAAA,EACnB;AAAA,EACA,CAAC,MAAM,SACL,KAAK,YAAY,UAAU,KAAK,YAAY,SAC5C,KAAK,YAAY,SAAS,KAAK,YAAY;AAC/C;AAEO,IAAM,0BAA6D,CAAC;AAAA,EACzE;AACF,MAAM;AACJ,QAAM,oBAAgB,kCAAW,CAAC,MAAM,EAAE,QAAQ,MAAM;AAExD,MAAI,kBAAkB,GAAG;AACvB,WAAO,4CAAC,gBAAa,YAAwB;AAAA,EAC/C;AAEA,SAAO,MAAM,KAAK,EAAE,QAAQ,cAAc,GAAG,CAAC,GAAG,UAC/C,4CAAC,sBAA+B,WAAW,OAAO,cAAzB,KAAiD,CAC3E;AACH;AAEA,wBAAwB,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../src/primitives/message/MessageContent.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentType, type FC, memo, useMemo } from \"react\";\nimport {\n TextContentPartProvider,\n useContentPart,\n useContentPartRuntime,\n useToolUIs,\n} from \"../../context\";\nimport {\n useMessage,\n useMessageRuntime,\n} from \"../../context/react/MessageContext\";\nimport { ContentPartRuntimeProvider } from \"../../context/providers/ContentPartRuntimeProvider\";\nimport { ContentPartPrimitiveText } from \"../contentPart/ContentPartText\";\nimport { ContentPartPrimitiveImage } from \"../contentPart/ContentPartImage\";\nimport { ContentPartPrimitiveDisplay } from \"../contentPart/ContentPartDisplay\";\nimport type {\n Unstable_AudioContentPartComponent,\n EmptyContentPartComponent,\n ImageContentPartComponent,\n TextContentPartComponent,\n ToolCallContentPartComponent,\n ToolCallContentPartProps,\n UIContentPartComponent,\n FileContentPartComponent,\n ReasoningContentPartComponent,\n} from \"../../types/ContentPartComponentTypes\";\nimport { ContentPartPrimitiveInProgress } from \"../contentPart/ContentPartInProgress\";\nimport { ContentPartStatus } from \"../../types/AssistantTypes\";\n\nexport namespace MessagePrimitiveContent {\n export type Props = {\n components?:\n | {\n Empty?: EmptyContentPartComponent | undefined;\n Reasoning?: ReasoningContentPartComponent | undefined;\n Text?: TextContentPartComponent | undefined;\n Image?: ImageContentPartComponent | undefined;\n File?: FileContentPartComponent | undefined;\n Unstable_Audio?: Unstable_AudioContentPartComponent | undefined;\n UI?: UIContentPartComponent | undefined;\n tools?:\n | {\n by_name?:\n | Record<string, ToolCallContentPartComponent | undefined>\n | undefined;\n Fallback?: ComponentType<ToolCallContentPartProps> | undefined;\n }\n | {\n Override: ComponentType<ToolCallContentPartProps>;\n }\n | undefined;\n }\n | undefined;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallContentPartComponent | undefined;\n} & ToolCallContentPartProps) => {\n const Render = useToolUIs((s) => s.getToolUI(props.toolName)) ?? Fallback;\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst defaultComponents = {\n Text: () => (\n <p style={{ whiteSpace: \"pre-line\" }}>\n <ContentPartPrimitiveText />\n <ContentPartPrimitiveInProgress>\n <span style={{ fontFamily: \"revert\" }}>{\" \\u25CF\"}</span>\n </ContentPartPrimitiveInProgress>\n </p>\n ),\n Reasoning: () => null,\n Image: () => <ContentPartPrimitiveImage />,\n File: () => null,\n Unstable_Audio: () => null,\n UI: () => <ContentPartPrimitiveDisplay />,\n} satisfies MessagePrimitiveContent.Props[\"components\"];\n\ntype MessageContentPartComponentProps = {\n components: MessagePrimitiveContent.Props[\"components\"];\n};\n\nconst MessageContentPartComponent: FC<MessageContentPartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Reasoning = defaultComponents.Reasoning,\n Image = defaultComponents.Image,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n UI = defaultComponents.UI,\n tools = {},\n } = {},\n}) => {\n const contentPartRuntime = useContentPartRuntime();\n\n const part = useContentPart();\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = (result: any) => contentPartRuntime.addToolResult(result);\n if (\"Override\" in tools)\n return <tools.Override {...part} addResult={addResult} />;\n const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;\n return <ToolUIDisplay {...part} Fallback={Tool} addResult={addResult} />;\n }\n\n if (part.status.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"reasoning\":\n return <Reasoning {...part} />;\n\n case \"image\":\n // eslint-disable-next-line jsx-a11y/alt-text\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n case \"ui\":\n return <UI {...part} />;\n\n default:\n const unhandledType: never = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n};\n\ntype MessageContentPartProps = {\n partIndex: number;\n components: MessagePrimitiveContent.Props[\"components\"];\n};\n\nconst MessageContentPartImpl: FC<MessageContentPartProps> = ({\n partIndex,\n components,\n}) => {\n const messageRuntime = useMessageRuntime();\n const runtime = useMemo(\n () => messageRuntime.getContentPartByIndex(partIndex),\n [messageRuntime, partIndex],\n );\n\n return (\n <ContentPartRuntimeProvider runtime={runtime}>\n <MessageContentPartComponent components={components} />\n </ContentPartRuntimeProvider>\n );\n};\n\nconst MessageContentPart = memo(\n MessageContentPartImpl,\n (prev, next) =>\n prev.partIndex === next.partIndex &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Reasoning === next.components?.Reasoning &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.UI === next.components?.UI &&\n prev.components?.tools === next.components?.tools,\n);\n\nconst COMPLETE_STATUS: ContentPartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst EmptyContentFallback: FC<{\n status: ContentPartStatus;\n component: TextContentPartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextContentPartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextContentPartProvider>\n );\n};\n\nconst EmptyContentImpl: FC<MessageContentPartComponentProps> = ({\n components,\n}) => {\n const status =\n useMessage((s) => s.status as ContentPartStatus) ?? COMPLETE_STATUS;\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n return (\n <EmptyContentFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyContent = memo(\n EmptyContentImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\nexport const MessagePrimitiveContent: FC<MessagePrimitiveContent.Props> = ({\n components,\n}) => {\n const contentLength = useMessage((s) => s.content.length);\n\n if (contentLength === 0) {\n return <EmptyContent components={components} />;\n }\n\n return Array.from({ length: contentLength }, (_, index) => (\n <MessageContentPart key={index} partIndex={index} components={components} />\n ));\n};\n\nMessagePrimitiveContent.displayName = \"MessagePrimitive.Content\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA2D;AAC3D,qBAKO;AACP,4BAGO;AACP,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CAAC;AAED,IAAM,uBAGD,CAAC,EAAE,QAAQ,WAAW,UAAU,MAAM;AACzC,SACE,4CAAC,0CAAwB,MAAK,IAAG,WAAW,OAAO,SAAS,WAC1D,sDAAC,aAAU,MAAK,QAAO,MAAK,IAAG,QAAgB,GACjD;AAEJ;AAEA,IAAM,mBAAyD,CAAC;AAAA,EAC9D;AACF,MAAM;AACJ,QAAM,aACJ,kCAAW,CAAC,MAAM,EAAE,MAA2B,KAAK;AAEtD,MAAI,YAAY,MAAO,QAAO,4CAAC,WAAW,OAAX,EAAiB,QAAgB;AAEhE,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WAAW,YAAY,QAAQ,kBAAkB;AAAA;AAAA,EACnD;AAEJ;AAEA,IAAM,mBAAe;AAAA,EACnB;AAAA,EACA,CAAC,MAAM,SACL,KAAK,YAAY,UAAU,KAAK,YAAY,SAC5C,KAAK,YAAY,SAAS,KAAK,YAAY;AAC/C;AAEO,IAAM,0BAA6D,CAAC;AAAA,EACzE;AACF,MAAM;AACJ,QAAM,oBAAgB,kCAAW,CAAC,MAAM,EAAE,QAAQ,MAAM;AAExD,MAAI,kBAAkB,GAAG;AACvB,WAAO,4CAAC,gBAAa,YAAwB;AAAA,EAC/C;AAEA,SAAO,MAAM,KAAK,EAAE,QAAQ,cAAc,GAAG,CAAC,GAAG,UAC/C,4CAAC,sBAA+B,WAAW,OAAO,cAAzB,KAAiD,CAC3E;AACH;AAEA,wBAAwB,cAAc;","names":[]}
@@ -31,6 +31,7 @@ var defaultComponents = {
31
31
  /* @__PURE__ */ jsx(ContentPartPrimitiveText, {}),
32
32
  /* @__PURE__ */ jsx(ContentPartPrimitiveInProgress, { children: /* @__PURE__ */ jsx("span", { style: { fontFamily: "revert" }, children: " \u25CF" }) })
33
33
  ] }),
34
+ Reasoning: () => null,
34
35
  Image: () => /* @__PURE__ */ jsx(ContentPartPrimitiveImage, {}),
35
36
  File: () => null,
36
37
  Unstable_Audio: () => null,
@@ -39,6 +40,7 @@ var defaultComponents = {
39
40
  var MessageContentPartComponent = ({
40
41
  components: {
41
42
  Text = defaultComponents.Text,
43
+ Reasoning = defaultComponents.Reasoning,
42
44
  Image = defaultComponents.Image,
43
45
  File = defaultComponents.File,
44
46
  Unstable_Audio: Audio = defaultComponents.Unstable_Audio,
@@ -61,6 +63,8 @@ var MessageContentPartComponent = ({
61
63
  switch (type) {
62
64
  case "text":
63
65
  return /* @__PURE__ */ jsx(Text, { ...part });
66
+ case "reasoning":
67
+ return /* @__PURE__ */ jsx(Reasoning, { ...part });
64
68
  case "image":
65
69
  return /* @__PURE__ */ jsx(Image, { ...part });
66
70
  case "file":
@@ -87,7 +91,7 @@ var MessageContentPartImpl = ({
87
91
  };
88
92
  var MessageContentPart = memo(
89
93
  MessageContentPartImpl,
90
- (prev, next) => prev.partIndex === next.partIndex && prev.components?.Text === next.components?.Text && prev.components?.Image === next.components?.Image && prev.components?.File === next.components?.File && prev.components?.Unstable_Audio === next.components?.Unstable_Audio && prev.components?.UI === next.components?.UI && prev.components?.tools === next.components?.tools
94
+ (prev, next) => prev.partIndex === next.partIndex && prev.components?.Text === next.components?.Text && prev.components?.Reasoning === next.components?.Reasoning && prev.components?.Image === next.components?.Image && prev.components?.File === next.components?.File && prev.components?.Unstable_Audio === next.components?.Unstable_Audio && prev.components?.UI === next.components?.UI && prev.components?.tools === next.components?.tools
91
95
  );
92
96
  var COMPLETE_STATUS = Object.freeze({
93
97
  type: "complete"
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/primitives/message/MessageContent.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentType, type FC, memo, useMemo } from \"react\";\nimport {\n TextContentPartProvider,\n useContentPart,\n useContentPartRuntime,\n useToolUIs,\n} from \"../../context\";\nimport {\n useMessage,\n useMessageRuntime,\n} from \"../../context/react/MessageContext\";\nimport { ContentPartRuntimeProvider } from \"../../context/providers/ContentPartRuntimeProvider\";\nimport { ContentPartPrimitiveText } from \"../contentPart/ContentPartText\";\nimport { ContentPartPrimitiveImage } from \"../contentPart/ContentPartImage\";\nimport { ContentPartPrimitiveDisplay } from \"../contentPart/ContentPartDisplay\";\nimport type {\n Unstable_AudioContentPartComponent,\n EmptyContentPartComponent,\n ImageContentPartComponent,\n TextContentPartComponent,\n ToolCallContentPartComponent,\n ToolCallContentPartProps,\n UIContentPartComponent,\n FileContentPartComponent,\n} from \"../../types/ContentPartComponentTypes\";\nimport { ContentPartPrimitiveInProgress } from \"../contentPart/ContentPartInProgress\";\nimport { ContentPartStatus } from \"../../types/AssistantTypes\";\n\nexport namespace MessagePrimitiveContent {\n export type Props = {\n components?:\n | {\n Empty?: EmptyContentPartComponent | undefined;\n Text?: TextContentPartComponent | undefined;\n Image?: ImageContentPartComponent | undefined;\n File?: FileContentPartComponent | undefined;\n Unstable_Audio?: Unstable_AudioContentPartComponent | undefined;\n UI?: UIContentPartComponent | undefined;\n tools?:\n | {\n by_name?:\n | Record<string, ToolCallContentPartComponent | undefined>\n | undefined;\n Fallback?: ComponentType<ToolCallContentPartProps> | undefined;\n }\n | {\n Override: ComponentType<ToolCallContentPartProps>;\n }\n | undefined;\n }\n | undefined;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallContentPartComponent | undefined;\n} & ToolCallContentPartProps) => {\n const Render = useToolUIs((s) => s.getToolUI(props.toolName)) ?? Fallback;\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst defaultComponents = {\n Text: () => (\n <p style={{ whiteSpace: \"pre-line\" }}>\n <ContentPartPrimitiveText />\n <ContentPartPrimitiveInProgress>\n <span style={{ fontFamily: \"revert\" }}>{\" \\u25CF\"}</span>\n </ContentPartPrimitiveInProgress>\n </p>\n ),\n Image: () => <ContentPartPrimitiveImage />,\n File: () => null,\n Unstable_Audio: () => null,\n UI: () => <ContentPartPrimitiveDisplay />,\n} satisfies MessagePrimitiveContent.Props[\"components\"];\n\ntype MessageContentPartComponentProps = {\n components: MessagePrimitiveContent.Props[\"components\"];\n};\n\nconst MessageContentPartComponent: FC<MessageContentPartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Image = defaultComponents.Image,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n UI = defaultComponents.UI,\n tools = {},\n } = {},\n}) => {\n const contentPartRuntime = useContentPartRuntime();\n\n const part = useContentPart();\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = (result: any) => contentPartRuntime.addToolResult(result);\n if (\"Override\" in tools)\n return <tools.Override {...part} addResult={addResult} />;\n const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;\n return <ToolUIDisplay {...part} Fallback={Tool} addResult={addResult} />;\n }\n\n if (part.status.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"image\":\n // eslint-disable-next-line jsx-a11y/alt-text\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n case \"ui\":\n return <UI {...part} />;\n\n default:\n const unhandledType: never = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n};\n\ntype MessageContentPartProps = {\n partIndex: number;\n components: MessagePrimitiveContent.Props[\"components\"];\n};\n\nconst MessageContentPartImpl: FC<MessageContentPartProps> = ({\n partIndex,\n components,\n}) => {\n const messageRuntime = useMessageRuntime();\n const runtime = useMemo(\n () => messageRuntime.getContentPartByIndex(partIndex),\n [messageRuntime, partIndex],\n );\n\n return (\n <ContentPartRuntimeProvider runtime={runtime}>\n <MessageContentPartComponent components={components} />\n </ContentPartRuntimeProvider>\n );\n};\n\nconst MessageContentPart = memo(\n MessageContentPartImpl,\n (prev, next) =>\n prev.partIndex === next.partIndex &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.UI === next.components?.UI &&\n prev.components?.tools === next.components?.tools,\n);\n\nconst COMPLETE_STATUS: ContentPartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst EmptyContentFallback: FC<{\n status: ContentPartStatus;\n component: TextContentPartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextContentPartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextContentPartProvider>\n );\n};\n\nconst EmptyContentImpl: FC<MessageContentPartComponentProps> = ({\n components,\n}) => {\n const status =\n useMessage((s) => s.status as ContentPartStatus) ?? COMPLETE_STATUS;\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n return (\n <EmptyContentFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyContent = memo(\n EmptyContentImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\nexport const MessagePrimitiveContent: FC<MessagePrimitiveContent.Props> = ({\n components,\n}) => {\n const contentLength = useMessage((s) => s.content.length);\n\n if (contentLength === 0) {\n return <EmptyContent components={components} />;\n }\n\n return Array.from({ length: contentLength }, (_, index) => (\n <MessageContentPart key={index} partIndex={index} components={components} />\n ));\n};\n\nMessagePrimitiveContent.displayName = \"MessagePrimitive.Content\";\n"],"mappings":";;;AAEA,SAAsC,MAAM,eAAe;AAC3D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,kCAAkC;AAC3C,SAAS,gCAAgC;AACzC,SAAS,iCAAiC;AAC1C,SAAS,mCAAmC;AAW5C,SAAS,sCAAsC;AAqCtC,cAKL,YALK;AART,IAAM,gBAAgB,CAAC;AAAA,EACrB;AAAA,EACA,GAAG;AACL,MAEiC;AAC/B,QAAM,SAAS,WAAW,CAAC,MAAM,EAAE,UAAU,MAAM,QAAQ,CAAC,KAAK;AACjE,MAAI,CAAC,OAAQ,QA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ACC;AAAA,MACA,WAAW,YAAY,QAAQ,kBAAkB;AAAA;AAAA,EACnD;AAEJ;AAEA,IAAM,eAAe;AAAA,EACnB;AAAA,EACA,CAAC,MAAM,SACL,KAAK,YAAY,UAAU,KAAK,YAAY,SAC5C,KAAK,YAAY,SAAS,KAAK,YAAY;AAC/C;AAEO,IAAM,0BAA6D,CAAC;AAAA,EACzE;AACF,MAAM;AACJ,QAAM,gBAAgB,WAAW,CAAC,MAAM,EAAE,QAAQ,MAAM;AAExD,MAAI,kBAAkB,GAAG;AACvB,WAAO,oBAAC,gBAAa,YAAwB;AAAA,EAC/C;AAEA,SAAO,MAAM,KAAK,EAAE,QAAQ,cAAc,GAAG,CAAC,GAAG,UAC/C,oBAAC,sBAA+B,WAAW,OAAO,cAAzB,KAAiD,CAC3E;AACH;AAEA,wBAAwB,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../src/primitives/message/MessageContent.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentType, type FC, memo, useMemo } from \"react\";\nimport {\n TextContentPartProvider,\n useContentPart,\n useContentPartRuntime,\n useToolUIs,\n} from \"../../context\";\nimport {\n useMessage,\n useMessageRuntime,\n} from \"../../context/react/MessageContext\";\nimport { ContentPartRuntimeProvider } from \"../../context/providers/ContentPartRuntimeProvider\";\nimport { ContentPartPrimitiveText } from \"../contentPart/ContentPartText\";\nimport { ContentPartPrimitiveImage } from \"../contentPart/ContentPartImage\";\nimport { ContentPartPrimitiveDisplay } from \"../contentPart/ContentPartDisplay\";\nimport type {\n Unstable_AudioContentPartComponent,\n EmptyContentPartComponent,\n ImageContentPartComponent,\n TextContentPartComponent,\n ToolCallContentPartComponent,\n ToolCallContentPartProps,\n UIContentPartComponent,\n FileContentPartComponent,\n ReasoningContentPartComponent,\n} from \"../../types/ContentPartComponentTypes\";\nimport { ContentPartPrimitiveInProgress } from \"../contentPart/ContentPartInProgress\";\nimport { ContentPartStatus } from \"../../types/AssistantTypes\";\n\nexport namespace MessagePrimitiveContent {\n export type Props = {\n components?:\n | {\n Empty?: EmptyContentPartComponent | undefined;\n Reasoning?: ReasoningContentPartComponent | undefined;\n Text?: TextContentPartComponent | undefined;\n Image?: ImageContentPartComponent | undefined;\n File?: FileContentPartComponent | undefined;\n Unstable_Audio?: Unstable_AudioContentPartComponent | undefined;\n UI?: UIContentPartComponent | undefined;\n tools?:\n | {\n by_name?:\n | Record<string, ToolCallContentPartComponent | undefined>\n | undefined;\n Fallback?: ComponentType<ToolCallContentPartProps> | undefined;\n }\n | {\n Override: ComponentType<ToolCallContentPartProps>;\n }\n | undefined;\n }\n | undefined;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallContentPartComponent | undefined;\n} & ToolCallContentPartProps) => {\n const Render = useToolUIs((s) => s.getToolUI(props.toolName)) ?? Fallback;\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst defaultComponents = {\n Text: () => (\n <p style={{ whiteSpace: \"pre-line\" }}>\n <ContentPartPrimitiveText />\n <ContentPartPrimitiveInProgress>\n <span style={{ fontFamily: \"revert\" }}>{\" \\u25CF\"}</span>\n </ContentPartPrimitiveInProgress>\n </p>\n ),\n Reasoning: () => null,\n Image: () => <ContentPartPrimitiveImage />,\n File: () => null,\n Unstable_Audio: () => null,\n UI: () => <ContentPartPrimitiveDisplay />,\n} satisfies MessagePrimitiveContent.Props[\"components\"];\n\ntype MessageContentPartComponentProps = {\n components: MessagePrimitiveContent.Props[\"components\"];\n};\n\nconst MessageContentPartComponent: FC<MessageContentPartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Reasoning = defaultComponents.Reasoning,\n Image = defaultComponents.Image,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n UI = defaultComponents.UI,\n tools = {},\n } = {},\n}) => {\n const contentPartRuntime = useContentPartRuntime();\n\n const part = useContentPart();\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = (result: any) => contentPartRuntime.addToolResult(result);\n if (\"Override\" in tools)\n return <tools.Override {...part} addResult={addResult} />;\n const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;\n return <ToolUIDisplay {...part} Fallback={Tool} addResult={addResult} />;\n }\n\n if (part.status.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"reasoning\":\n return <Reasoning {...part} />;\n\n case \"image\":\n // eslint-disable-next-line jsx-a11y/alt-text\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n case \"ui\":\n return <UI {...part} />;\n\n default:\n const unhandledType: never = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n};\n\ntype MessageContentPartProps = {\n partIndex: number;\n components: MessagePrimitiveContent.Props[\"components\"];\n};\n\nconst MessageContentPartImpl: FC<MessageContentPartProps> = ({\n partIndex,\n components,\n}) => {\n const messageRuntime = useMessageRuntime();\n const runtime = useMemo(\n () => messageRuntime.getContentPartByIndex(partIndex),\n [messageRuntime, partIndex],\n );\n\n return (\n <ContentPartRuntimeProvider runtime={runtime}>\n <MessageContentPartComponent components={components} />\n </ContentPartRuntimeProvider>\n );\n};\n\nconst MessageContentPart = memo(\n MessageContentPartImpl,\n (prev, next) =>\n prev.partIndex === next.partIndex &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Reasoning === next.components?.Reasoning &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.UI === next.components?.UI &&\n prev.components?.tools === next.components?.tools,\n);\n\nconst COMPLETE_STATUS: ContentPartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst EmptyContentFallback: FC<{\n status: ContentPartStatus;\n component: TextContentPartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextContentPartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextContentPartProvider>\n );\n};\n\nconst EmptyContentImpl: FC<MessageContentPartComponentProps> = ({\n components,\n}) => {\n const status =\n useMessage((s) => s.status as ContentPartStatus) ?? COMPLETE_STATUS;\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n return (\n <EmptyContentFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyContent = memo(\n EmptyContentImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\nexport const MessagePrimitiveContent: FC<MessagePrimitiveContent.Props> = ({\n components,\n}) => {\n const contentLength = useMessage((s) => s.content.length);\n\n if (contentLength === 0) {\n return <EmptyContent components={components} />;\n }\n\n return Array.from({ length: contentLength }, (_, index) => (\n <MessageContentPart key={index} partIndex={index} components={components} />\n ));\n};\n\nMessagePrimitiveContent.displayName = \"MessagePrimitive.Content\";\n"],"mappings":";;;AAEA,SAAsC,MAAM,eAAe;AAC3D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,kCAAkC;AAC3C,SAAS,gCAAgC;AACzC,SAAS,iCAAiC;AAC1C,SAAS,mCAAmC;AAY5C,SAAS,sCAAsC;AAsCtC,cAKL,YALK;AART,IAAM,gBAAgB,CAAC;AAAA,EACrB;AAAA,EACA,GAAG;AACL,MAEiC;AAC/B,QAAM,SAAS,WAAW,CAAC,MAAM,EAAE,UAAU,MAAM,QAAQ,CAAC,KAAK;AACjE,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,oBAAC,UAAQ,GAAG,OAAO;AAC5B;AAEA,IAAM,oBAAoB;AAAA,EACxB,MAAM,MACJ,qBAAC,OAAE,OAAO,EAAE,YAAY,WAAW,GACjC;AAAA,wBAAC,4BAAyB;AAAA,IAC1B,oBAAC,kCACC,8BAAC,UAAK,OAAO,EAAE,YAAY,SAAS,GAAI,qBAAU,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ACnB;AAAA,EACA,CAAC,MAAM,SACL,KAAK,YAAY,UAAU,KAAK,YAAY,SAC5C,KAAK,YAAY,SAAS,KAAK,YAAY;AAC/C;AAEO,IAAM,0BAA6D,CAAC;AAAA,EACzE;AACF,MAAM;AACJ,QAAM,gBAAgB,WAAW,CAAC,MAAM,EAAE,QAAQ,MAAM;AAExD,MAAI,kBAAkB,GAAG;AACvB,WAAO,oBAAC,gBAAa,YAAwB;AAAA,EAC/C;AAEA,SAAO,MAAM,KAAK,EAAE,QAAQ,cAAc,GAAG,CAAC,GAAG,UAC/C,oBAAC,sBAA+B,WAAW,OAAO,cAAzB,KAAiD,CAC3E;AACH;AAEA,wBAAwB,cAAc;","names":[]}
@@ -145,15 +145,15 @@ export declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.e
145
145
  toolCallId: string;
146
146
  toolName: string;
147
147
  args: ReadonlyJSONObject;
148
- isError?: boolean | undefined;
149
148
  result?: unknown;
149
+ isError?: boolean | undefined;
150
150
  }, {
151
151
  type: "tool-call";
152
152
  toolCallId: string;
153
153
  toolName: string;
154
154
  args: Record<string, unknown>;
155
- isError?: boolean | undefined;
156
155
  result?: unknown;
156
+ isError?: boolean | undefined;
157
157
  }>]>, "many">>;
158
158
  }, "strip", z.ZodTypeAny, {
159
159
  role: "assistant";
@@ -165,8 +165,8 @@ export declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.e
165
165
  toolCallId: string;
166
166
  toolName: string;
167
167
  args: ReadonlyJSONObject;
168
- isError?: boolean | undefined;
169
168
  result?: unknown;
169
+ isError?: boolean | undefined;
170
170
  })[];
171
171
  }, {
172
172
  role: "assistant";
@@ -178,8 +178,8 @@ export declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.e
178
178
  toolCallId: string;
179
179
  toolName: string;
180
180
  args: Record<string, unknown>;
181
- isError?: boolean | undefined;
182
181
  result?: unknown;
182
+ isError?: boolean | undefined;
183
183
  })[];
184
184
  }>]>, "many">>;
185
185
  runConfig: z.ZodOptional<z.ZodObject<{
@@ -248,8 +248,8 @@ export declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.e
248
248
  toolCallId: string;
249
249
  toolName: string;
250
250
  args: ReadonlyJSONObject;
251
- isError?: boolean | undefined;
252
251
  result?: unknown;
252
+ isError?: boolean | undefined;
253
253
  })[];
254
254
  } | {
255
255
  role: "system";
@@ -309,8 +309,8 @@ export declare const EdgeRuntimeRequestOptionsSchema: z.ZodObject<z.objectUtil.e
309
309
  toolCallId: string;
310
310
  toolName: string;
311
311
  args: Record<string, unknown>;
312
- isError?: boolean | undefined;
313
312
  result?: unknown;
313
+ isError?: boolean | undefined;
314
314
  })[];
315
315
  } | {
316
316
  role: "system";
@@ -1 +1 @@
1
- {"version":3,"file":"toCoreMessages.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/edge/converters/toCoreMessages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE5D,KAAK,4BAA4B,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS,KAAK,GAClE,WAAW,GACX,WAAW,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3C,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,OAAO,oBACpC,SAAS,aAAa,EAAE,YACzB;IAAE,kBAAkB,CAAC,EAAE,CAAC,GAAG,SAAS,CAAA;CAAE,KAC9C,4BAA4B,CAAC,CAAC,CAAC,EAEjC,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,OAAO,mBACpC,aAAa,YACb;IAAE,kBAAkB,CAAC,EAAE,CAAC,GAAG,SAAS,CAAA;CAAE,KAC9C,4BAA4B,CAAC,CAAC,CA4ChC,CAAC"}
1
+ {"version":3,"file":"toCoreMessages.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/edge/converters/toCoreMessages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE5D,KAAK,4BAA4B,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS,KAAK,GAClE,WAAW,GACX,WAAW,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3C,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,OAAO,oBACpC,SAAS,aAAa,EAAE,YACzB;IAAE,kBAAkB,CAAC,EAAE,CAAC,GAAG,SAAS,CAAA;CAAE,KAC9C,4BAA4B,CAAC,CAAC,CAAC,EAEjC,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,OAAO,mBACpC,aAAa,YACb;IAAE,kBAAkB,CAAC,EAAE,CAAC,GAAG,SAAS,CAAA;CAAE,KAC9C,4BAA4B,CAAC,CAAC,CA6ChC,CAAC"}
@@ -35,13 +35,14 @@ var toCoreMessage = (message, options = {}) => {
35
35
  return {
36
36
  role,
37
37
  content: message.content.map((part) => {
38
+ if (part.type === "reasoning") return null;
38
39
  if (part.type === "ui") throw new Error("UI parts are not supported");
39
40
  if (part.type === "tool-call") {
40
41
  const { argsText, ...rest } = part;
41
42
  return rest;
42
43
  }
43
44
  return part;
44
- }),
45
+ }).filter((c) => !!c),
45
46
  ...includeId ? { unstable_id: message.id } : {}
46
47
  };
47
48
  case "user":
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtimes/edge/converters/toCoreMessages.ts"],"sourcesContent":["import { ThreadMessage, CoreMessage } from \"../../../types\";\n\ntype CoreMessageWithConditionalId<T extends boolean> = T extends false\n ? CoreMessage\n : CoreMessage & { unstable_id?: string };\n\nexport const toCoreMessages = <T extends boolean = false>(\n messages: readonly ThreadMessage[],\n options: { unstable_includeId?: T | undefined } = {},\n): CoreMessageWithConditionalId<T>[] => {\n return messages.map((message) => toCoreMessage(message, options));\n};\n\nexport const toCoreMessage = <T extends boolean = false>(\n message: ThreadMessage,\n options: { unstable_includeId?: T | undefined } = {},\n): CoreMessageWithConditionalId<T> => {\n const includeId = options.unstable_includeId ?? false;\n const role = message.role;\n switch (role) {\n case \"assistant\":\n return {\n role,\n content: message.content.map((part) => {\n if (part.type === \"ui\") throw new Error(\"UI parts are not supported\");\n if (part.type === \"tool-call\") {\n const { argsText, ...rest } = part;\n return rest;\n }\n return part;\n }),\n ...(includeId ? { unstable_id: message.id } : {}),\n };\n\n case \"user\":\n return {\n role,\n content: [\n ...message.content.map((part) => {\n if (part.type === \"ui\")\n throw new Error(\"UI parts are not supported\");\n return part;\n }),\n ...message.attachments.map((a) => a.content).flat(),\n ],\n ...(includeId ? { unstable_id: message.id } : {}),\n };\n\n case \"system\":\n return {\n role,\n content: message.content,\n ...(includeId ? { unstable_id: message.id } : {}),\n };\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;AAMO,IAAM,iBAAiB,CAC5B,UACA,UAAkD,CAAC,MACb;AACtC,SAAO,SAAS,IAAI,CAAC,YAAY,cAAc,SAAS,OAAO,CAAC;AAClE;AAEO,IAAM,gBAAgB,CAC3B,SACA,UAAkD,CAAC,MACf;AACpC,QAAM,YAAY,QAAQ,sBAAsB;AAChD,QAAM,OAAO,QAAQ;AACrB,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA,SAAS,QAAQ,QAAQ,IAAI,CAAC,SAAS;AACrC,cAAI,KAAK,SAAS,KAAM,OAAM,IAAI,MAAM,4BAA4B;AACpE,cAAI,KAAK,SAAS,aAAa;AAC7B,kBAAM,EAAE,UAAU,GAAG,KAAK,IAAI;AAC9B,mBAAO;AAAA,UACT;AACA,iBAAO;AAAA,QACT,CAAC;AAAA,QACD,GAAI,YAAY,EAAE,aAAa,QAAQ,GAAG,IAAI,CAAC;AAAA,MACjD;AAAA,IAEF,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA,SAAS;AAAA,UACP,GAAG,QAAQ,QAAQ,IAAI,CAAC,SAAS;AAC/B,gBAAI,KAAK,SAAS;AAChB,oBAAM,IAAI,MAAM,4BAA4B;AAC9C,mBAAO;AAAA,UACT,CAAC;AAAA,UACD,GAAG,QAAQ,YAAY,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK;AAAA,QACpD;AAAA,QACA,GAAI,YAAY,EAAE,aAAa,QAAQ,GAAG,IAAI,CAAC;AAAA,MACjD;AAAA,IAEF,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA,SAAS,QAAQ;AAAA,QACjB,GAAI,YAAY,EAAE,aAAa,QAAQ,GAAG,IAAI,CAAC;AAAA,MACjD;AAAA,IAEF,SAAS;AACP,YAAM,kBAAyB;AAC/B,YAAM,IAAI,MAAM,yBAAyB,eAAe,EAAE;AAAA,IAC5D;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/runtimes/edge/converters/toCoreMessages.ts"],"sourcesContent":["import { ThreadMessage, CoreMessage } from \"../../../types\";\n\ntype CoreMessageWithConditionalId<T extends boolean> = T extends false\n ? CoreMessage\n : CoreMessage & { unstable_id?: string };\n\nexport const toCoreMessages = <T extends boolean = false>(\n messages: readonly ThreadMessage[],\n options: { unstable_includeId?: T | undefined } = {},\n): CoreMessageWithConditionalId<T>[] => {\n return messages.map((message) => toCoreMessage(message, options));\n};\n\nexport const toCoreMessage = <T extends boolean = false>(\n message: ThreadMessage,\n options: { unstable_includeId?: T | undefined } = {},\n): CoreMessageWithConditionalId<T> => {\n const includeId = options.unstable_includeId ?? false;\n const role = message.role;\n switch (role) {\n case \"assistant\":\n return {\n role,\n content: message.content.map((part) => {\n if (part.type === \"reasoning\") return null; // reasoning parts are omitted\n if (part.type === \"ui\") throw new Error(\"UI parts are not supported\");\n if (part.type === \"tool-call\") {\n const { argsText, ...rest } = part;\n return rest;\n }\n return part;\n }).filter(c => !!c),\n ...(includeId ? { unstable_id: message.id } : {}),\n };\n\n case \"user\":\n return {\n role,\n content: [\n ...message.content.map((part) => {\n if (part.type === \"ui\")\n throw new Error(\"UI parts are not supported\");\n return part;\n }),\n ...message.attachments.map((a) => a.content).flat(),\n ],\n ...(includeId ? { unstable_id: message.id } : {}),\n };\n\n case \"system\":\n return {\n role,\n content: message.content,\n ...(includeId ? { unstable_id: message.id } : {}),\n };\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;AAMO,IAAM,iBAAiB,CAC5B,UACA,UAAkD,CAAC,MACb;AACtC,SAAO,SAAS,IAAI,CAAC,YAAY,cAAc,SAAS,OAAO,CAAC;AAClE;AAEO,IAAM,gBAAgB,CAC3B,SACA,UAAkD,CAAC,MACf;AACpC,QAAM,YAAY,QAAQ,sBAAsB;AAChD,QAAM,OAAO,QAAQ;AACrB,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA,SAAS,QAAQ,QAAQ,IAAI,CAAC,SAAS;AACrC,cAAI,KAAK,SAAS,YAAa,QAAO;AACtC,cAAI,KAAK,SAAS,KAAM,OAAM,IAAI,MAAM,4BAA4B;AACpE,cAAI,KAAK,SAAS,aAAa;AAC7B,kBAAM,EAAE,UAAU,GAAG,KAAK,IAAI;AAC9B,mBAAO;AAAA,UACT;AACA,iBAAO;AAAA,QACT,CAAC,EAAE,OAAO,OAAK,CAAC,CAAC,CAAC;AAAA,QAClB,GAAI,YAAY,EAAE,aAAa,QAAQ,GAAG,IAAI,CAAC;AAAA,MACjD;AAAA,IAEF,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA,SAAS;AAAA,UACP,GAAG,QAAQ,QAAQ,IAAI,CAAC,SAAS;AAC/B,gBAAI,KAAK,SAAS;AAChB,oBAAM,IAAI,MAAM,4BAA4B;AAC9C,mBAAO;AAAA,UACT,CAAC;AAAA,UACD,GAAG,QAAQ,YAAY,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK;AAAA,QACpD;AAAA,QACA,GAAI,YAAY,EAAE,aAAa,QAAQ,GAAG,IAAI,CAAC;AAAA,MACjD;AAAA,IAEF,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA,SAAS,QAAQ;AAAA,QACjB,GAAI,YAAY,EAAE,aAAa,QAAQ,GAAG,IAAI,CAAC;AAAA,MACjD;AAAA,IAEF,SAAS;AACP,YAAM,kBAAyB;AAC/B,YAAM,IAAI,MAAM,yBAAyB,eAAe,EAAE;AAAA,IAC5D;AAAA,EACF;AACF;","names":[]}
@@ -10,13 +10,14 @@ var toCoreMessage = (message, options = {}) => {
10
10
  return {
11
11
  role,
12
12
  content: message.content.map((part) => {
13
+ if (part.type === "reasoning") return null;
13
14
  if (part.type === "ui") throw new Error("UI parts are not supported");
14
15
  if (part.type === "tool-call") {
15
16
  const { argsText, ...rest } = part;
16
17
  return rest;
17
18
  }
18
19
  return part;
19
- }),
20
+ }).filter((c) => !!c),
20
21
  ...includeId ? { unstable_id: message.id } : {}
21
22
  };
22
23
  case "user":
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtimes/edge/converters/toCoreMessages.ts"],"sourcesContent":["import { ThreadMessage, CoreMessage } from \"../../../types\";\n\ntype CoreMessageWithConditionalId<T extends boolean> = T extends false\n ? CoreMessage\n : CoreMessage & { unstable_id?: string };\n\nexport const toCoreMessages = <T extends boolean = false>(\n messages: readonly ThreadMessage[],\n options: { unstable_includeId?: T | undefined } = {},\n): CoreMessageWithConditionalId<T>[] => {\n return messages.map((message) => toCoreMessage(message, options));\n};\n\nexport const toCoreMessage = <T extends boolean = false>(\n message: ThreadMessage,\n options: { unstable_includeId?: T | undefined } = {},\n): CoreMessageWithConditionalId<T> => {\n const includeId = options.unstable_includeId ?? false;\n const role = message.role;\n switch (role) {\n case \"assistant\":\n return {\n role,\n content: message.content.map((part) => {\n if (part.type === \"ui\") throw new Error(\"UI parts are not supported\");\n if (part.type === \"tool-call\") {\n const { argsText, ...rest } = part;\n return rest;\n }\n return part;\n }),\n ...(includeId ? { unstable_id: message.id } : {}),\n };\n\n case \"user\":\n return {\n role,\n content: [\n ...message.content.map((part) => {\n if (part.type === \"ui\")\n throw new Error(\"UI parts are not supported\");\n return part;\n }),\n ...message.attachments.map((a) => a.content).flat(),\n ],\n ...(includeId ? { unstable_id: message.id } : {}),\n };\n\n case \"system\":\n return {\n role,\n content: message.content,\n ...(includeId ? { unstable_id: message.id } : {}),\n };\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n"],"mappings":";AAMO,IAAM,iBAAiB,CAC5B,UACA,UAAkD,CAAC,MACb;AACtC,SAAO,SAAS,IAAI,CAAC,YAAY,cAAc,SAAS,OAAO,CAAC;AAClE;AAEO,IAAM,gBAAgB,CAC3B,SACA,UAAkD,CAAC,MACf;AACpC,QAAM,YAAY,QAAQ,sBAAsB;AAChD,QAAM,OAAO,QAAQ;AACrB,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA,SAAS,QAAQ,QAAQ,IAAI,CAAC,SAAS;AACrC,cAAI,KAAK,SAAS,KAAM,OAAM,IAAI,MAAM,4BAA4B;AACpE,cAAI,KAAK,SAAS,aAAa;AAC7B,kBAAM,EAAE,UAAU,GAAG,KAAK,IAAI;AAC9B,mBAAO;AAAA,UACT;AACA,iBAAO;AAAA,QACT,CAAC;AAAA,QACD,GAAI,YAAY,EAAE,aAAa,QAAQ,GAAG,IAAI,CAAC;AAAA,MACjD;AAAA,IAEF,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA,SAAS;AAAA,UACP,GAAG,QAAQ,QAAQ,IAAI,CAAC,SAAS;AAC/B,gBAAI,KAAK,SAAS;AAChB,oBAAM,IAAI,MAAM,4BAA4B;AAC9C,mBAAO;AAAA,UACT,CAAC;AAAA,UACD,GAAG,QAAQ,YAAY,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK;AAAA,QACpD;AAAA,QACA,GAAI,YAAY,EAAE,aAAa,QAAQ,GAAG,IAAI,CAAC;AAAA,MACjD;AAAA,IAEF,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA,SAAS,QAAQ;AAAA,QACjB,GAAI,YAAY,EAAE,aAAa,QAAQ,GAAG,IAAI,CAAC;AAAA,MACjD;AAAA,IAEF,SAAS;AACP,YAAM,kBAAyB;AAC/B,YAAM,IAAI,MAAM,yBAAyB,eAAe,EAAE;AAAA,IAC5D;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/runtimes/edge/converters/toCoreMessages.ts"],"sourcesContent":["import { ThreadMessage, CoreMessage } from \"../../../types\";\n\ntype CoreMessageWithConditionalId<T extends boolean> = T extends false\n ? CoreMessage\n : CoreMessage & { unstable_id?: string };\n\nexport const toCoreMessages = <T extends boolean = false>(\n messages: readonly ThreadMessage[],\n options: { unstable_includeId?: T | undefined } = {},\n): CoreMessageWithConditionalId<T>[] => {\n return messages.map((message) => toCoreMessage(message, options));\n};\n\nexport const toCoreMessage = <T extends boolean = false>(\n message: ThreadMessage,\n options: { unstable_includeId?: T | undefined } = {},\n): CoreMessageWithConditionalId<T> => {\n const includeId = options.unstable_includeId ?? false;\n const role = message.role;\n switch (role) {\n case \"assistant\":\n return {\n role,\n content: message.content.map((part) => {\n if (part.type === \"reasoning\") return null; // reasoning parts are omitted\n if (part.type === \"ui\") throw new Error(\"UI parts are not supported\");\n if (part.type === \"tool-call\") {\n const { argsText, ...rest } = part;\n return rest;\n }\n return part;\n }).filter(c => !!c),\n ...(includeId ? { unstable_id: message.id } : {}),\n };\n\n case \"user\":\n return {\n role,\n content: [\n ...message.content.map((part) => {\n if (part.type === \"ui\")\n throw new Error(\"UI parts are not supported\");\n return part;\n }),\n ...message.attachments.map((a) => a.content).flat(),\n ],\n ...(includeId ? { unstable_id: message.id } : {}),\n };\n\n case \"system\":\n return {\n role,\n content: message.content,\n ...(includeId ? { unstable_id: message.id } : {}),\n };\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n"],"mappings":";AAMO,IAAM,iBAAiB,CAC5B,UACA,UAAkD,CAAC,MACb;AACtC,SAAO,SAAS,IAAI,CAAC,YAAY,cAAc,SAAS,OAAO,CAAC;AAClE;AAEO,IAAM,gBAAgB,CAC3B,SACA,UAAkD,CAAC,MACf;AACpC,QAAM,YAAY,QAAQ,sBAAsB;AAChD,QAAM,OAAO,QAAQ;AACrB,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA,SAAS,QAAQ,QAAQ,IAAI,CAAC,SAAS;AACrC,cAAI,KAAK,SAAS,YAAa,QAAO;AACtC,cAAI,KAAK,SAAS,KAAM,OAAM,IAAI,MAAM,4BAA4B;AACpE,cAAI,KAAK,SAAS,aAAa;AAC7B,kBAAM,EAAE,UAAU,GAAG,KAAK,IAAI;AAC9B,mBAAO;AAAA,UACT;AACA,iBAAO;AAAA,QACT,CAAC,EAAE,OAAO,OAAK,CAAC,CAAC,CAAC;AAAA,QAClB,GAAI,YAAY,EAAE,aAAa,QAAQ,GAAG,IAAI,CAAC;AAAA,MACjD;AAAA,IAEF,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA,SAAS;AAAA,UACP,GAAG,QAAQ,QAAQ,IAAI,CAAC,SAAS;AAC/B,gBAAI,KAAK,SAAS;AAChB,oBAAM,IAAI,MAAM,4BAA4B;AAC9C,mBAAO;AAAA,UACT,CAAC;AAAA,UACD,GAAG,QAAQ,YAAY,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK;AAAA,QACpD;AAAA,QACA,GAAI,YAAY,EAAE,aAAa,QAAQ,GAAG,IAAI,CAAC;AAAA,MAC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