@assistant-ui/react 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/cloud/auiV0.d.ts +6 -0
  2. package/dist/cloud/auiV0.d.ts.map +1 -1
  3. package/dist/cloud/auiV0.js +2 -0
  4. package/dist/cloud/auiV0.js.map +1 -1
  5. package/dist/cloud/auiV0.mjs +2 -0
  6. package/dist/cloud/auiV0.mjs.map +1 -1
  7. package/dist/primitives/message/MessageContent.d.ts +3 -2
  8. package/dist/primitives/message/MessageContent.d.ts.map +1 -1
  9. package/dist/primitives/message/MessageContent.js +5 -1
  10. package/dist/primitives/message/MessageContent.js.map +1 -1
  11. package/dist/primitives/message/MessageContent.mjs +5 -1
  12. package/dist/primitives/message/MessageContent.mjs.map +1 -1
  13. package/dist/runtimes/edge/converters/toCoreMessages.d.ts.map +1 -1
  14. package/dist/runtimes/edge/converters/toCoreMessages.js +2 -1
  15. package/dist/runtimes/edge/converters/toCoreMessages.js.map +1 -1
  16. package/dist/runtimes/edge/converters/toCoreMessages.mjs +2 -1
  17. package/dist/runtimes/edge/converters/toCoreMessages.mjs.map +1 -1
  18. package/dist/runtimes/edge/converters/toLanguageModelMessages.d.ts.map +1 -1
  19. package/dist/runtimes/edge/converters/toLanguageModelMessages.js +2 -1
  20. package/dist/runtimes/edge/converters/toLanguageModelMessages.js.map +1 -1
  21. package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs +2 -1
  22. package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs.map +1 -1
  23. package/dist/runtimes/edge/streams/AssistantStreamChunkType.d.ts +8 -1
  24. package/dist/runtimes/edge/streams/AssistantStreamChunkType.d.ts.map +1 -1
  25. package/dist/runtimes/edge/streams/AssistantStreamChunkType.js +1 -0
  26. package/dist/runtimes/edge/streams/AssistantStreamChunkType.js.map +1 -1
  27. package/dist/runtimes/edge/streams/AssistantStreamChunkType.mjs +1 -0
  28. package/dist/runtimes/edge/streams/AssistantStreamChunkType.mjs.map +1 -1
  29. package/dist/runtimes/edge/streams/assistantDecoderStream.d.ts.map +1 -1
  30. package/dist/runtimes/edge/streams/assistantDecoderStream.js +6 -0
  31. package/dist/runtimes/edge/streams/assistantDecoderStream.js.map +1 -1
  32. package/dist/runtimes/edge/streams/assistantDecoderStream.mjs +6 -0
  33. package/dist/runtimes/edge/streams/assistantDecoderStream.mjs.map +1 -1
  34. package/dist/runtimes/edge/streams/assistantEncoderStream.d.ts.map +1 -1
  35. package/dist/runtimes/edge/streams/assistantEncoderStream.js +6 -0
  36. package/dist/runtimes/edge/streams/assistantEncoderStream.js.map +1 -1
  37. package/dist/runtimes/edge/streams/assistantEncoderStream.mjs +6 -0
  38. package/dist/runtimes/edge/streams/assistantEncoderStream.mjs.map +1 -1
  39. package/dist/runtimes/edge/streams/runResultStream.d.ts.map +1 -1
  40. package/dist/runtimes/edge/streams/runResultStream.js +17 -0
  41. package/dist/runtimes/edge/streams/runResultStream.js.map +1 -1
  42. package/dist/runtimes/edge/streams/runResultStream.mjs +17 -0
  43. package/dist/runtimes/edge/streams/runResultStream.mjs.map +1 -1
  44. package/dist/runtimes/edge/streams/toolResultStream.d.ts +8 -0
  45. package/dist/runtimes/edge/streams/toolResultStream.d.ts.map +1 -1
  46. package/dist/runtimes/edge/streams/toolResultStream.js +1 -0
  47. package/dist/runtimes/edge/streams/toolResultStream.js.map +1 -1
  48. package/dist/runtimes/edge/streams/toolResultStream.mjs +1 -0
  49. package/dist/runtimes/edge/streams/toolResultStream.mjs.map +1 -1
  50. package/dist/runtimes/external-store/ThreadMessageLike.d.ts +2 -2
  51. package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
  52. package/dist/runtimes/external-store/ThreadMessageLike.js +2 -0
  53. package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
  54. package/dist/runtimes/external-store/ThreadMessageLike.mjs +2 -0
  55. package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
  56. package/dist/runtimes/local/ChatModelAdapter.d.ts +2 -2
  57. package/dist/runtimes/local/ChatModelAdapter.d.ts.map +1 -1
  58. package/dist/runtimes/local/ChatModelAdapter.js.map +1 -1
  59. package/dist/runtimes/remote-thread-list/adapter/cloud.d.ts.map +1 -1
  60. package/dist/runtimes/remote-thread-list/adapter/cloud.js +1 -7
  61. package/dist/runtimes/remote-thread-list/adapter/cloud.js.map +1 -1
  62. package/dist/runtimes/remote-thread-list/adapter/cloud.mjs +1 -7
  63. package/dist/runtimes/remote-thread-list/adapter/cloud.mjs.map +1 -1
  64. package/dist/types/AssistantTypes.d.ts +9 -1
  65. package/dist/types/AssistantTypes.d.ts.map +1 -1
  66. package/dist/types/AssistantTypes.js.map +1 -1
  67. package/dist/types/ContentPartComponentTypes.d.ts +3 -1
  68. package/dist/types/ContentPartComponentTypes.d.ts.map +1 -1
  69. package/dist/types/ContentPartComponentTypes.js.map +1 -1
  70. package/dist/types/index.d.ts +2 -2
  71. package/dist/types/index.d.ts.map +1 -1
  72. package/dist/types/index.js.map +1 -1
  73. package/package.json +1 -1
  74. package/src/cloud/auiV0.ts +10 -0
  75. package/src/primitives/message/MessageContent.tsx +10 -2
  76. package/src/runtimes/edge/converters/toCoreMessages.ts +2 -1
  77. package/src/runtimes/edge/converters/toLanguageModelMessages.ts +3 -2
  78. package/src/runtimes/edge/streams/AssistantStreamChunkType.ts +7 -0
  79. package/src/runtimes/edge/streams/assistantDecoderStream.ts +7 -0
  80. package/src/runtimes/edge/streams/assistantEncoderStream.ts +7 -0
  81. package/src/runtimes/edge/streams/runResultStream.ts +25 -3
  82. package/src/runtimes/edge/streams/toolResultStream.ts +10 -0
  83. package/src/runtimes/external-store/ThreadMessageLike.tsx +10 -2
  84. package/src/runtimes/local/ChatModelAdapter.tsx +7 -1
  85. package/src/runtimes/remote-thread-list/adapter/cloud.tsx +4 -13
  86. package/src/types/AssistantTypes.ts +11 -2
  87. package/src/types/ContentPartComponentTypes.tsx +4 -0
  88. package/src/types/index.ts +3 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtimes/external-store/ThreadMessageLike.tsx"],"sourcesContent":["import { generateId } from \"../../internal\";\nimport {\n MessageStatus,\n TextContentPart,\n ImageContentPart,\n ThreadMessage,\n ThreadAssistantContentPart,\n ThreadAssistantMessage,\n ThreadUserContentPart,\n ThreadUserMessage,\n ThreadSystemMessage,\n CompleteAttachment,\n FileContentPart,\n Unstable_AudioContentPart,\n} from \"../../types\";\nimport { ReasoningContentPart, ThreadStep } from \"../../types/AssistantTypes\";\nimport {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"../../utils/json/json-value\";\nimport { parsePartialJson } from \"../../utils/json/parse-partial-json\";\n\nexport type ThreadMessageLike = {\n readonly role: \"assistant\" | \"user\" | \"system\";\n readonly content:\n | string\n | readonly (\n | TextContentPart\n | ReasoningContentPart\n | ImageContentPart\n | FileContentPart\n | Unstable_AudioContentPart\n | {\n readonly type: \"tool-call\";\n readonly toolCallId?: string;\n readonly toolName: string;\n readonly args?: ReadonlyJSONObject;\n readonly argsText?: string;\n readonly result?: any | undefined;\n readonly isError?: boolean | undefined;\n }\n )[];\n readonly id?: string | undefined;\n readonly createdAt?: Date | undefined;\n readonly status?: MessageStatus | undefined;\n readonly attachments?: readonly CompleteAttachment[] | undefined;\n readonly metadata?:\n | {\n readonly unstable_annotations?:\n | readonly ReadonlyJSONValue[]\n | undefined;\n readonly unstable_data?: readonly ReadonlyJSONValue[] | undefined;\n readonly steps?: readonly ThreadStep[] | undefined;\n readonly custom?: Record<string, unknown> | undefined;\n }\n | undefined;\n};\n\nexport const fromThreadMessageLike = (\n like: ThreadMessageLike,\n fallbackId: string,\n fallbackStatus: MessageStatus,\n): ThreadMessage => {\n const { role, id, createdAt, attachments, status, metadata } = like;\n const common = {\n id: id ?? fallbackId,\n createdAt: createdAt ?? new Date(),\n };\n\n const content =\n typeof like.content === \"string\"\n ? [{ type: \"text\" as const, text: like.content }]\n : like.content;\n\n if (role !== \"user\" && attachments)\n throw new Error(\"attachments are only supported for user messages\");\n\n if (role !== \"assistant\" && status)\n throw new Error(\"status is only supported for assistant messages\");\n\n if (role !== \"assistant\" && metadata?.steps)\n throw new Error(\"metadata.steps is only supported for assistant messages\");\n\n switch (role) {\n case \"assistant\":\n return {\n ...common,\n role,\n content: content\n .map((part): ThreadAssistantContentPart | null => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"reasoning\":\n if (part.text.trim().length === 0) return null;\n return part;\n\n case \"tool-call\": {\n if (part.args) {\n return {\n ...part,\n toolCallId: part.toolCallId ?? \"tool-\" + generateId(),\n args: part.args,\n argsText: JSON.stringify(part.args),\n };\n }\n return {\n ...part,\n toolCallId: part.toolCallId ?? \"tool-\" + generateId(),\n args: part.args ?? parsePartialJson(part.argsText ?? \"{}\"),\n argsText: part.argsText ?? \"\",\n };\n }\n\n default: {\n const unhandledType: \"image\" | \"audio\" | \"file\" = type;\n throw new Error(\n `Unsupported assistant content part type: ${unhandledType}`,\n );\n }\n }\n })\n .filter((c) => !!c),\n status: status ?? fallbackStatus,\n metadata: {\n unstable_annotations: metadata?.unstable_annotations ?? [],\n unstable_data: metadata?.unstable_data ?? [],\n custom: metadata?.custom ?? {},\n steps: metadata?.steps ?? [],\n },\n } satisfies ThreadAssistantMessage;\n\n case \"user\":\n return {\n ...common,\n role,\n content: content.map((part): ThreadUserContentPart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"image\":\n case \"audio\":\n case \"file\":\n return part;\n\n default: {\n const unhandledType: \"tool-call\" | \"reasoning\" = type;\n throw new Error(\n `Unsupported user content part type: ${unhandledType}`,\n );\n }\n }\n }),\n attachments: attachments ?? [],\n metadata: {\n custom: metadata?.custom ?? {},\n },\n } satisfies ThreadUserMessage;\n\n case \"system\":\n if (content.length !== 1 || content[0]!.type !== \"text\")\n throw new Error(\n \"System messages must have exactly one text content part.\",\n );\n\n return {\n ...common,\n role,\n content: content as [TextContentPart],\n metadata: {\n custom: metadata?.custom ?? {},\n },\n } satisfies ThreadSystemMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;AAoB3B,SAAS,wBAAwB;AAsC1B,IAAM,wBAAwB,CACnC,MACA,YACA,mBACkB;AAClB,QAAM,EAAE,MAAM,IAAI,WAAW,aAAa,QAAQ,SAAS,IAAI;AAC/D,QAAM,SAAS;AAAA,IACb,IAAI,MAAM;AAAA,IACV,WAAW,aAAa,oBAAI,KAAK;AAAA,EACnC;AAEA,QAAM,UACJ,OAAO,KAAK,YAAY,WACpB,CAAC,EAAE,MAAM,QAAiB,MAAM,KAAK,QAAQ,CAAC,IAC9C,KAAK;AAEX,MAAI,SAAS,UAAU;AACrB,UAAM,IAAI,MAAM,kDAAkD;AAEpE,MAAI,SAAS,eAAe;AAC1B,UAAM,IAAI,MAAM,iDAAiD;AAEnE,MAAI,SAAS,eAAe,UAAU;AACpC,UAAM,IAAI,MAAM,yDAAyD;AAE3E,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QACN,IAAI,CAAC,SAA4C;AAChD,gBAAM,OAAO,KAAK;AAClB,kBAAQ,MAAM;AAAA,YACZ,KAAK;AAAA,YACL,KAAK;AACH,kBAAI,KAAK,KAAK,KAAK,EAAE,WAAW,EAAG,QAAO;AAC1C,qBAAO;AAAA,YAET,KAAK,aAAa;AAChB,kBAAI,KAAK,MAAM;AACb,uBAAO;AAAA,kBACL,GAAG;AAAA,kBACH,YAAY,KAAK,cAAc,UAAU,WAAW;AAAA,kBACpD,MAAM,KAAK;AAAA,kBACX,UAAU,KAAK,UAAU,KAAK,IAAI;AAAA,gBACpC;AAAA,cACF;AACA,qBAAO;AAAA,gBACL,GAAG;AAAA,gBACH,YAAY,KAAK,cAAc,UAAU,WAAW;AAAA,gBACpD,MAAM,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kBAAyB;AAC/B,YAAM,IAAI,MAAM,yBAAyB,eAAe,EAAE;AAAA,IAC5D;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/runtimes/external-store/ThreadMessageLike.tsx"],"sourcesContent":["import { generateId } from \"../../internal\";\nimport {\n MessageStatus,\n TextContentPart,\n ImageContentPart,\n ThreadMessage,\n ThreadAssistantContentPart,\n ThreadAssistantMessage,\n ThreadUserContentPart,\n ThreadUserMessage,\n ThreadSystemMessage,\n CompleteAttachment,\n FileContentPart,\n Unstable_AudioContentPart,\n} from \"../../types\";\nimport {\n ReasoningContentPart,\n SourceContentPart,\n ThreadStep,\n} from \"../../types/AssistantTypes\";\nimport {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"../../utils/json/json-value\";\nimport { parsePartialJson } from \"../../utils/json/parse-partial-json\";\n\nexport type ThreadMessageLike = {\n readonly role: \"assistant\" | \"user\" | \"system\";\n readonly content:\n | string\n | readonly (\n | TextContentPart\n | ReasoningContentPart\n | SourceContentPart\n | ImageContentPart\n | FileContentPart\n | Unstable_AudioContentPart\n | {\n readonly type: \"tool-call\";\n readonly toolCallId?: string;\n readonly toolName: string;\n readonly args?: ReadonlyJSONObject;\n readonly argsText?: string;\n readonly result?: any | undefined;\n readonly isError?: boolean | undefined;\n }\n )[];\n readonly id?: string | undefined;\n readonly createdAt?: Date | undefined;\n readonly status?: MessageStatus | undefined;\n readonly attachments?: readonly CompleteAttachment[] | undefined;\n readonly metadata?:\n | {\n readonly unstable_annotations?:\n | readonly ReadonlyJSONValue[]\n | undefined;\n readonly unstable_data?: readonly ReadonlyJSONValue[] | undefined;\n readonly steps?: readonly ThreadStep[] | undefined;\n readonly custom?: Record<string, unknown> | undefined;\n }\n | undefined;\n};\n\nexport const fromThreadMessageLike = (\n like: ThreadMessageLike,\n fallbackId: string,\n fallbackStatus: MessageStatus,\n): ThreadMessage => {\n const { role, id, createdAt, attachments, status, metadata } = like;\n const common = {\n id: id ?? fallbackId,\n createdAt: createdAt ?? new Date(),\n };\n\n const content =\n typeof like.content === \"string\"\n ? [{ type: \"text\" as const, text: like.content }]\n : like.content;\n\n if (role !== \"user\" && attachments)\n throw new Error(\"attachments are only supported for user messages\");\n\n if (role !== \"assistant\" && status)\n throw new Error(\"status is only supported for assistant messages\");\n\n if (role !== \"assistant\" && metadata?.steps)\n throw new Error(\"metadata.steps is only supported for assistant messages\");\n\n switch (role) {\n case \"assistant\":\n return {\n ...common,\n role,\n content: content\n .map((part): ThreadAssistantContentPart | null => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"reasoning\":\n if (part.text.trim().length === 0) return null;\n return part;\n\n case \"source\":\n return part;\n\n case \"tool-call\": {\n if (part.args) {\n return {\n ...part,\n toolCallId: part.toolCallId ?? \"tool-\" + generateId(),\n args: part.args,\n argsText: JSON.stringify(part.args),\n };\n }\n return {\n ...part,\n toolCallId: part.toolCallId ?? \"tool-\" + generateId(),\n args: part.args ?? parsePartialJson(part.argsText ?? \"{}\"),\n argsText: part.argsText ?? \"\",\n };\n }\n\n default: {\n const unhandledType: \"image\" | \"audio\" | \"file\" = type;\n throw new Error(\n `Unsupported assistant content part type: ${unhandledType}`,\n );\n }\n }\n })\n .filter((c) => !!c),\n status: status ?? fallbackStatus,\n metadata: {\n unstable_annotations: metadata?.unstable_annotations ?? [],\n unstable_data: metadata?.unstable_data ?? [],\n custom: metadata?.custom ?? {},\n steps: metadata?.steps ?? [],\n },\n } satisfies ThreadAssistantMessage;\n\n case \"user\":\n return {\n ...common,\n role,\n content: content.map((part): ThreadUserContentPart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"image\":\n case \"audio\":\n case \"file\":\n return part;\n\n default: {\n const unhandledType: \"tool-call\" | \"reasoning\" | \"source\" = type;\n throw new Error(\n `Unsupported user content part type: ${unhandledType}`,\n );\n }\n }\n }),\n attachments: attachments ?? [],\n metadata: {\n custom: metadata?.custom ?? {},\n },\n } satisfies ThreadUserMessage;\n\n case \"system\":\n if (content.length !== 1 || content[0]!.type !== \"text\")\n throw new Error(\n \"System messages must have exactly one text content part.\",\n );\n\n return {\n ...common,\n role,\n content: content as [TextContentPart],\n metadata: {\n custom: metadata?.custom ?? {},\n },\n } satisfies ThreadSystemMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;AAwB3B,SAAS,wBAAwB;AAuC1B,IAAM,wBAAwB,CACnC,MACA,YACA,mBACkB;AAClB,QAAM,EAAE,MAAM,IAAI,WAAW,aAAa,QAAQ,SAAS,IAAI;AAC/D,QAAM,SAAS;AAAA,IACb,IAAI,MAAM;AAAA,IACV,WAAW,aAAa,oBAAI,KAAK;AAAA,EACnC;AAEA,QAAM,UACJ,OAAO,KAAK,YAAY,WACpB,CAAC,EAAE,MAAM,QAAiB,MAAM,KAAK,QAAQ,CAAC,IAC9C,KAAK;AAEX,MAAI,SAAS,UAAU;AACrB,UAAM,IAAI,MAAM,kDAAkD;AAEpE,MAAI,SAAS,eAAe;AAC1B,UAAM,IAAI,MAAM,iDAAiD;AAEnE,MAAI,SAAS,eAAe,UAAU;AACpC,UAAM,IAAI,MAAM,yDAAyD;AAE3E,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QACN,IAAI,CAAC,SAA4C;AAChD,gBAAM,OAAO,KAAK;AAClB,kBAAQ,MAAM;AAAA,YACZ,KAAK;AAAA,YACL,KAAK;AACH,kBAAI,KAAK,KAAK,KAAK,EAAE,WAAW,EAAG,QAAO;AAC1C,qBAAO;AAAA,YAET,KAAK;AACH,qBAAO;AAAA,YAET,KAAK,aAAa;AAChB,kBAAI,KAAK,MAAM;AACb,uBAAO;AAAA,kBACL,GAAG;AAAA,kBACH,YAAY,KAAK,cAAc,UAAU,WAAW;AAAA,kBACpD,MAAM,KAAK;AAAA,kBACX,UAAU,KAAK,U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GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,UAAU;AAAA,UACR,QAAQ,UAAU,UAAU,CAAC;AAAA,QAC/B;AAAA,MACF;AAAA,IAEF,SAAS;AACP,YAAM,kBAAyB;AAC/B,YAAM,IAAI,MAAM,yBAAyB,eAAe,EAAE;AAAA,IAC5D;AAAA,EACF;AACF;","names":[]}
@@ -1,4 +1,4 @@
1
- import type { MessageStatus, ReasoningContentPart, RunConfig, TextContentPart, ThreadAssistantContentPart, ThreadMessage, ThreadStep, ToolCallContentPart } from "../../types/AssistantTypes";
1
+ import type { MessageStatus, ReasoningContentPart, RunConfig, SourceContentPart, TextContentPart, ThreadAssistantContentPart, ThreadMessage, ThreadStep, ToolCallContentPart } from "../../types/AssistantTypes";
2
2
  import type { ModelContext } from "../../model-context/ModelContextTypes";
3
3
  import { ReadonlyJSONValue } from "../../utils/json/json-value";
4
4
  export type ChatModelRunUpdate = {
@@ -16,7 +16,7 @@ export type ChatModelRunResult = {
16
16
  };
17
17
  };
18
18
  export type CoreChatModelRunResult = Omit<ChatModelRunResult, "content"> & {
19
- readonly content: readonly (TextContentPart | ReasoningContentPart | ToolCallContentPart)[];
19
+ readonly content: readonly (TextContentPart | ReasoningContentPart | ToolCallContentPart | SourceContentPart)[];
20
20
  };
21
21
  export type ChatModelRunOptions = {
22
22
  readonly messages: readonly ThreadMessage[];
@@ -1 +1 @@
1
- {"version":3,"file":"ChatModelAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/ChatModelAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,eAAe,EACf,0BAA0B,EAC1B,aAAa,EACb,UAAU,EACV,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,MAAM,MAAM,kBA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AAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;KACvD,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,GAAG;IACzE,QAAQ,CAAC,OAAO,EAAE,SAAS,CACvB,eAAe,GACf,oBAAoB,GACpB,mBAAmB,GACnB,iBAAiB,CACpB,EAAE,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAE9B,QAAQ,CAAC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IAC9C,mBAAmB,IAAI,aAAa,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,CACD,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,GAAG,cAAc,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;CAC3E,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtimes/local/ChatModelAdapter.tsx"],"sourcesContent":["import type {\n MessageStatus,\n ReasoningContentPart,\n RunConfig,\n TextContentPart,\n ThreadAssistantContentPart,\n ThreadMessage,\n ThreadStep,\n ToolCallContentPart,\n} from \"../../types/AssistantTypes\";\nimport type { ModelContext } from \"../../model-context/ModelContextTypes\";\nimport { ReadonlyJSONValue } from \"../../utils/json/json-value\";\n\nexport type ChatModelRunUpdate = {\n readonly content: readonly ThreadAssistantContentPart[];\n readonly metadata?: Record<string, unknown>;\n};\n\nexport type ChatModelRunResult = {\n readonly content?: readonly ThreadAssistantContentPart[] | undefined;\n readonly status?: MessageStatus | undefined;\n readonly metadata?: {\n readonly unstable_annotations?: readonly ReadonlyJSONValue[] | undefined;\n readonly unstable_data?: readonly ReadonlyJSONValue[] | undefined;\n readonly steps?: readonly ThreadStep[] | undefined;\n readonly custom?: Record<string, unknown> | undefined;\n };\n};\n\nexport type CoreChatModelRunResult = Omit<ChatModelRunResult, \"content\"> & {\n readonly content: readonly (TextContentPart | ReasoningContentPart | ToolCallContentPart)[];\n};\n\nexport type ChatModelRunOptions = {\n readonly messages: readonly ThreadMessage[];\n readonly runConfig: RunConfig;\n readonly abortSignal: AbortSignal;\n readonly context: ModelContext;\n\n /**\n * @deprecated This field was renamed to `context`.\n */\n readonly config: ModelContext;\n\n readonly unstable_assistantMessageId?: string;\n unstable_getMessage(): ThreadMessage;\n};\n\nexport type ChatModelAdapter = {\n run(\n options: ChatModelRunOptions,\n ): Promise<ChatModelRunResult> | AsyncGenerator<ChatModelRunResult, void>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../src/runtimes/local/ChatModelAdapter.tsx"],"sourcesContent":["import type {\n MessageStatus,\n ReasoningContentPart,\n RunConfig,\n SourceContentPart,\n TextContentPart,\n ThreadAssistantContentPart,\n ThreadMessage,\n ThreadStep,\n ToolCallContentPart,\n} from \"../../types/AssistantTypes\";\nimport type { ModelContext } from \"../../model-context/ModelContextTypes\";\nimport { ReadonlyJSONValue } from \"../../utils/json/json-value\";\n\nexport type ChatModelRunUpdate = {\n readonly content: readonly ThreadAssistantContentPart[];\n readonly metadata?: Record<string, unknown>;\n};\n\nexport type ChatModelRunResult = {\n readonly content?: readonly ThreadAssistantContentPart[] | undefined;\n readonly status?: MessageStatus | undefined;\n readonly metadata?: {\n readonly unstable_annotations?: readonly ReadonlyJSONValue[] | undefined;\n readonly unstable_data?: readonly ReadonlyJSONValue[] | undefined;\n readonly steps?: readonly ThreadStep[] | undefined;\n readonly custom?: Record<string, unknown> | undefined;\n };\n};\n\nexport type CoreChatModelRunResult = Omit<ChatModelRunResult, \"content\"> & {\n readonly content: readonly (\n | TextContentPart\n | ReasoningContentPart\n | ToolCallContentPart\n | SourceContentPart\n )[];\n};\n\nexport type ChatModelRunOptions = {\n readonly messages: readonly ThreadMessage[];\n readonly runConfig: RunConfig;\n readonly abortSignal: AbortSignal;\n readonly context: ModelContext;\n\n /**\n * @deprecated This field was renamed to `context`.\n */\n readonly config: ModelContext;\n\n readonly unstable_assistantMessageId?: string;\n unstable_getMessage(): ThreadMessage;\n};\n\nexport type ChatModelAdapter = {\n run(\n options: ChatModelRunOptions,\n ): Promise<ChatModelRunResult> | AsyncGenerator<ChatModelRunResult, void>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/remote-thread-list/adapter/cloud.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAMnD,KAAK,UAAU,GAAG;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AACF,KAAK,6BAA6B,GAAG;IACnC,KAAK,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IAEnC,MAAM,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/B,MAAM,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C,CAAC;AAmBF,eAAO,MAAM,yBAAyB,YAC3B,6BAA6B,KACrC,uBA4EF,CAAC"}
1
+ {"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/remote-thread-list/adapter/cloud.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAMnD,KAAK,UAAU,GAAG;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,6BAA6B,GAAG;IACnC,KAAK,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IAEnC,MAAM,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/B,MAAM,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C,CAAC;AASF,eAAO,MAAM,yBAAyB,YAC3B,6BAA6B,KACrC,uBA4EF,CAAC"}
@@ -30,13 +30,7 @@ var import_RuntimeAdapterProvider = require("../../adapters/RuntimeAdapterProvid
30
30
  var import_edge = require("../../edge/index.js");
31
31
  var import_in_memory = require("./in-memory.js");
32
32
  var import_jsx_runtime = require("react/jsx-runtime");
33
- var getEnvVariable = (name) => {
34
- if (typeof process !== "undefined" && process.env && typeof process.env[name] === "string") {
35
- return process.env[name];
36
- }
37
- return void 0;
38
- };
39
- var baseUrl = getEnvVariable("NEXT_PUBLIC_ASSISTANT_BASE_URL");
33
+ var baseUrl = typeof process !== "undefined" && process?.env?.["NEXT_PUBLIC_ASSISTANT_BASE_URL"];
40
34
  var autoCloud = baseUrl ? new import_cloud.AssistantCloud({ baseUrl, anonymous: true }) : void 0;
41
35
  var useCloudThreadListAdapter = (adapter) => {
42
36
  const adapterRef = (0, import_react.useRef)(adapter);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtimes/remote-thread-list/adapter/cloud.tsx"],"sourcesContent":["import {\n FC,\n PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { AssistantCloud } from \"../../../cloud\";\nimport { RemoteThreadListAdapter } from \"../types\";\nimport { useAssistantCloudThreadHistoryAdapter } from \"../../../cloud/AssistantCloudThreadHistoryAdapter\";\nimport { RuntimeAdapterProvider } from \"../../adapters/RuntimeAdapterProvider\";\nimport { toCoreMessages } from \"../../edge\";\nimport { InMemoryThreadListAdapter } from \"./in-memory\";\n\ntype ThreadData = {\n externalId: string;\n};\ntype CloudThreadListAdapterOptions = {\n cloud?: AssistantCloud | undefined;\n\n create?(): Promise<ThreadData>;\n delete?(threadId: string): Promise<void>;\n};\n\nconst getEnvVariable = (name: string): string | undefined => {\n if (\n typeof process !== \"undefined\" &&\n process.env &&\n typeof process.env[name] === \"string\"\n ) {\n return process.env[name];\n }\n\n return undefined;\n};\n\nconst baseUrl = getEnvVariable(\"NEXT_PUBLIC_ASSISTANT_BASE_URL\");\nconst autoCloud = baseUrl\n ? new AssistantCloud({ baseUrl, anonymous: true })\n : undefined;\n\nexport const useCloudThreadListAdapter = (\n adapter: CloudThreadListAdapterOptions,\n): RemoteThreadListAdapter => {\n const adapterRef = useRef(adapter);\n useEffect(() => {\n adapterRef.current = adapter;\n }, [adapter]);\n\n const unstable_Provider = useCallback<FC<PropsWithChildren>>(\n ({ children }) => {\n const history = useAssistantCloudThreadHistoryAdapter({\n get current() {\n return adapterRef.current.cloud ?? autoCloud!;\n },\n });\n const adapters = useMemo(() => ({ history }), [history]);\n\n return (\n <RuntimeAdapterProvider adapters={adapters}>\n {children}\n </RuntimeAdapterProvider>\n );\n },\n [],\n );\n\n const cloud = adapter.cloud ?? autoCloud;\n if (!cloud) return new InMemoryThreadListAdapter();\n\n return {\n list: async () => {\n const { threads } = await cloud.threads.list();\n return {\n threads: threads.map((t) => ({\n status: t.is_archived ? \"archived\" : \"regular\",\n remoteId: t.id,\n title: t.title,\n externalId: t.external_id ?? undefined,\n })),\n };\n },\n\n initialize: async () => {\n const createTask = adapter.create?.() ?? Promise.resolve();\n const t = await createTask;\n const external_id = t ? t.externalId : undefined;\n const { thread_id: remoteId } = await cloud.threads.create({\n last_message_at: new Date(),\n external_id,\n });\n\n return { externalId: external_id, remoteId: remoteId };\n },\n\n rename: async (threadId, newTitle) => {\n return cloud.threads.update(threadId, { title: newTitle });\n },\n archive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: true });\n },\n unarchive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: false });\n },\n delete: async (threadId) => {\n await adapter.delete?.(threadId);\n return cloud.threads.delete(threadId);\n },\n\n generateTitle: async (threadId, messages) => {\n return cloud.runs.stream({\n thread_id: threadId,\n assistant_id: \"system/thread_title\",\n messages: toCoreMessages(messages),\n });\n },\n\n unstable_Provider,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAOO;AACP,mBAA+B;AAE/B,gDAAsD;AACtD,oCAAuC;AACvC,kBAA+B;AAC/B,uBAA0C;AA+ClC;AAnCR,IAAM,iBAAiB,CAAC,SAAqC;AAC3D,MACE,OAAO,YAAY,eACnB,QAAQ,OACR,OAAO,QAAQ,IAAI,IAAI,MAAM,UAC7B;AACA,WAAO,QAAQ,IAAI,IAAI;AAAA,EACzB;AAEA,SAAO;AACT;AAEA,IAAM,UAAU,eAAe,gCAAgC;AAC/D,IAAM,YAAY,UACd,IAAI,4BAAe,EAAE,SAAS,WAAW,KAAK,CAAC,IAC/C;AAEG,IAAM,4BAA4B,CACvC,YAC4B;AAC5B,QAAM,iBAAa,qBAAO,OAAO;AACjC,8BAAU,MAAM;AACd,eAAW,UAAU;AAAA,EACvB,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,wBAAoB;AAAA,IACxB,CAAC,EAAE,SAAS,MAAM;AAChB,YAAM,cAAU,iFAAsC;AAAA,QACpD,IAAI,UAAU;AACZ,iBAAO,WAAW,QAAQ,SAAS;AAAA,QACrC;AAAA,MACF,CAAC;AACD,YAAM,eAAW,sBAAQ,OAAO,EAAE,QAAQ,IAAI,CAAC,OAAO,CAAC;AAEvD,aACE,4CAAC,wDAAuB,UACrB,UACH;AAAA,IAEJ;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,QAAQ,QAAQ,SAAS;AAC/B,MAAI,CAAC,MAAO,QAAO,IAAI,2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;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/runtimes/remote-thread-list/adapter/cloud.tsx"],"sourcesContent":["import {\n FC,\n PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { AssistantCloud } from \"../../../cloud\";\nimport { RemoteThreadListAdapter } from \"../types\";\nimport { useAssistantCloudThreadHistoryAdapter } from \"../../../cloud/AssistantCloudThreadHistoryAdapter\";\nimport { RuntimeAdapterProvider } from \"../../adapters/RuntimeAdapterProvider\";\nimport { toCoreMessages } from \"../../edge\";\nimport { InMemoryThreadListAdapter } from \"./in-memory\";\n\ntype ThreadData = {\n externalId: string;\n};\n\ntype CloudThreadListAdapterOptions = {\n cloud?: AssistantCloud | undefined;\n\n create?(): Promise<ThreadData>;\n delete?(threadId: string): Promise<void>;\n};\n\nconst baseUrl =\n typeof process !== \"undefined\" &&\n process?.env?.[\"NEXT_PUBLIC_ASSISTANT_BASE_URL\"];\nconst autoCloud = baseUrl\n ? new AssistantCloud({ baseUrl, anonymous: true })\n : undefined;\n\nexport const useCloudThreadListAdapter = (\n adapter: CloudThreadListAdapterOptions,\n): RemoteThreadListAdapter => {\n const adapterRef = useRef(adapter);\n useEffect(() => {\n adapterRef.current = adapter;\n }, [adapter]);\n\n const unstable_Provider = useCallback<FC<PropsWithChildren>>(\n ({ children }) => {\n const history = useAssistantCloudThreadHistoryAdapter({\n get current() {\n return adapterRef.current.cloud ?? autoCloud!;\n },\n });\n const adapters = useMemo(() => ({ history }), [history]);\n\n return (\n <RuntimeAdapterProvider adapters={adapters}>\n {children}\n </RuntimeAdapterProvider>\n );\n },\n [],\n );\n\n const cloud = adapter.cloud ?? autoCloud;\n if (!cloud) return new InMemoryThreadListAdapter();\n\n return {\n list: async () => {\n const { threads } = await cloud.threads.list();\n return {\n threads: threads.map((t) => ({\n status: t.is_archived ? \"archived\" : \"regular\",\n remoteId: t.id,\n title: t.title,\n externalId: t.external_id ?? undefined,\n })),\n };\n },\n\n initialize: async () => {\n const createTask = adapter.create?.() ?? Promise.resolve();\n const t = await createTask;\n const external_id = t ? t.externalId : undefined;\n const { thread_id: remoteId } = await cloud.threads.create({\n last_message_at: new Date(),\n external_id,\n });\n\n return { externalId: external_id, remoteId: remoteId };\n },\n\n rename: async (threadId, newTitle) => {\n return cloud.threads.update(threadId, { title: newTitle });\n },\n archive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: true });\n },\n unarchive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: false });\n },\n delete: async (threadId) => {\n await adapter.delete?.(threadId);\n return cloud.threads.delete(threadId);\n },\n\n generateTitle: async (threadId, messages) => {\n return cloud.runs.stream({\n thread_id: threadId,\n assistant_id: \"system/thread_title\",\n messages: toCoreMessages(messages),\n });\n },\n\n unstable_Provider,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAOO;AACP,mBAA+B;AAE/B,gDAAsD;AACtD,oCAAuC;AACvC,kBAA+B;AAC/B,uBAA0C;AAsClC;AAzBR,IAAM,UACJ,OAAO,YAAY,eACnB,SAAS,MAAM,gCAAgC;AACjD,IAAM,YAAY,UACd,IAAI,4BAAe,EAAE,SAAS,WAAW,KAAK,CAAC,IAC/C;AAEG,IAAM,4BAA4B,CACvC,YAC4B;AAC5B,QAAM,iBAAa,qBAAO,OAAO;AACjC,8BAAU,MAAM;AACd,eAAW,UAAU;AAAA,EACvB,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,wBAAoB;AAAA,IACxB,CAAC,EAAE,SAAS,MAAM;AAChB,YAAM,cAAU,iFAAsC;AAAA,QACpD,IAAI,UAAU;AACZ,iBAAO,WAAW,QAAQ,SAAS;AAAA,QACrC;AAAA,MACF,CAAC;AACD,YAAM,eAAW,sBAAQ,OAAO,EAAE,QAAQ,IAAI,CAAC,OAAO,CAAC;AAEvD,aACE,4CAAC,wDAAuB,UACrB,UACH;AAAA,IAEJ;AA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B,WAAW;AAAA,QACX,cAAc;AAAA,QACd,cAAU,4BAAe,QAAQ;AAAA,MACnC,CAAC;AAAA,IACH;AAAA,IAEA;AAAA,EACF;AACF;","names":[]}
@@ -11,13 +11,7 @@ import { RuntimeAdapterProvider } from "../../adapters/RuntimeAdapterProvider.mj
11
11
  import { toCoreMessages } from "../../edge/index.mjs";
12
12
  import { InMemoryThreadListAdapter } from "./in-memory.mjs";
13
13
  import { jsx } from "react/jsx-runtime";
14
- var getEnvVariable = (name) => {
15
- if (typeof process !== "undefined" && process.env && typeof process.env[name] === "string") {
16
- return process.env[name];
17
- }
18
- return void 0;
19
- };
20
- var baseUrl = getEnvVariable("NEXT_PUBLIC_ASSISTANT_BASE_URL");
14
+ var baseUrl = typeof process !== "undefined" && process?.env?.["NEXT_PUBLIC_ASSISTANT_BASE_URL"];
21
15
  var autoCloud = baseUrl ? new AssistantCloud({ baseUrl, anonymous: true }) : void 0;
22
16
  var useCloudThreadListAdapter = (adapter) => {
23
17
  const adapterRef = useRef(adapter);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtimes/remote-thread-list/adapter/cloud.tsx"],"sourcesContent":["import {\n FC,\n PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { AssistantCloud } from \"../../../cloud\";\nimport { RemoteThreadListAdapter } from \"../types\";\nimport { useAssistantCloudThreadHistoryAdapter } from \"../../../cloud/AssistantCloudThreadHistoryAdapter\";\nimport { RuntimeAdapterProvider } from \"../../adapters/RuntimeAdapterProvider\";\nimport { toCoreMessages } from \"../../edge\";\nimport { InMemoryThreadListAdapter } from \"./in-memory\";\n\ntype ThreadData = {\n externalId: string;\n};\ntype CloudThreadListAdapterOptions = {\n cloud?: AssistantCloud | undefined;\n\n create?(): Promise<ThreadData>;\n delete?(threadId: string): Promise<void>;\n};\n\nconst getEnvVariable = (name: string): string | undefined => {\n if (\n typeof process !== \"undefined\" &&\n process.env &&\n typeof process.env[name] === \"string\"\n ) {\n return process.env[name];\n }\n\n return undefined;\n};\n\nconst baseUrl = getEnvVariable(\"NEXT_PUBLIC_ASSISTANT_BASE_URL\");\nconst autoCloud = baseUrl\n ? new AssistantCloud({ baseUrl, anonymous: true })\n : undefined;\n\nexport const useCloudThreadListAdapter = (\n adapter: CloudThreadListAdapterOptions,\n): RemoteThreadListAdapter => {\n const adapterRef = useRef(adapter);\n useEffect(() => {\n adapterRef.current = adapter;\n }, [adapter]);\n\n const unstable_Provider = useCallback<FC<PropsWithChildren>>(\n ({ children }) => {\n const history = useAssistantCloudThreadHistoryAdapter({\n get current() {\n return adapterRef.current.cloud ?? autoCloud!;\n },\n });\n const adapters = useMemo(() => ({ history }), [history]);\n\n return (\n <RuntimeAdapterProvider adapters={adapters}>\n {children}\n </RuntimeAdapterProvider>\n );\n },\n [],\n );\n\n const cloud = adapter.cloud ?? autoCloud;\n if (!cloud) return new InMemoryThreadListAdapter();\n\n return {\n list: async () => {\n const { threads } = await cloud.threads.list();\n return {\n threads: threads.map((t) => ({\n status: t.is_archived ? \"archived\" : \"regular\",\n remoteId: t.id,\n title: t.title,\n externalId: t.external_id ?? undefined,\n })),\n };\n },\n\n initialize: async () => {\n const createTask = adapter.create?.() ?? Promise.resolve();\n const t = await createTask;\n const external_id = t ? t.externalId : undefined;\n const { thread_id: remoteId } = await cloud.threads.create({\n last_message_at: new Date(),\n external_id,\n });\n\n return { externalId: external_id, remoteId: remoteId };\n },\n\n rename: async (threadId, newTitle) => {\n return cloud.threads.update(threadId, { title: newTitle });\n },\n archive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: true });\n },\n unarchive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: false });\n },\n delete: async (threadId) => {\n await adapter.delete?.(threadId);\n return cloud.threads.delete(threadId);\n },\n\n generateTitle: async (threadId, messages) => {\n return cloud.runs.stream({\n thread_id: threadId,\n assistant_id: \"system/thread_title\",\n messages: toCoreMessages(messages),\n });\n },\n\n unstable_Provider,\n };\n};\n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A,UACT,YAAY,EAAE,eAAe;AAAA,QAC/B,EAAE;AAAA,MACJ;AAAA,IACF;AAAA,IAEA,YAAY,YAAY;AACtB,YAAM,aAAa,QAAQ,SAAS,KAAK,QAAQ,QAAQ;AACzD,YAAM,IAAI,MAAM;AAChB,YAAM,cAAc,IAAI,EAAE,aAAa;AACvC,YAAM,EAAE,WAAW,SAAS,IAAI,MAAM,MAAM,QAAQ,OAAO;AAAA,QACzD,iBAAiB,oBAAI,KAAK;AAAA,QAC1B;AAAA,MACF,CAAC;AAED,aAAO,EAAE,YAAY,aAAa,SAAmB;AAAA,IACvD;AAAA,IAEA,QAAQ,OAAO,UAAU,aAAa;AACpC,aAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,OAAO,SAAS,CAAC;AAAA,IAC3D;AAAA,IACA,SAAS,OAAO,aAAa;AAC3B,aAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,aAAa,KAAK,CAAC;AAAA,IAC7D;AAAA,IACA,WAAW,OAAO,aAAa;AAC7B,aAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,aAAa,MAAM,CAAC;AAAA,IAC9D;AAAA,IACA,QAAQ,OAAO,aAAa;AAC1B,YAAM,QAAQ,SAAS,QAAQ;AAC/B,aAAO,MAAM,QAAQ,OAAO,QAAQ;AAAA,IACtC;AAAA,IAEA,eAAe,OAAO,UAAU,aAAa;AAC3C,aAAO,MAAM,KAAK,OAAO;AAAA,QACvB,WAAW;AAAA,QACX,cAAc;AAAA,QACd,UAAU,eAAe,QAAQ;AAAA,MACnC,CAAC;AAAA,IACH;AAAA,IAEA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/runtimes/remote-thread-list/adapter/cloud.tsx"],"sourcesContent":["import {\n FC,\n PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { AssistantCloud } from \"../../../cloud\";\nimport { RemoteThreadListAdapter } from \"../types\";\nimport { useAssistantCloudThreadHistoryAdapter } from \"../../../cloud/AssistantCloudThreadHistoryAdapter\";\nimport { RuntimeAdapterProvider } from \"../../adapters/RuntimeAdapterProvider\";\nimport { toCoreMessages } from \"../../edge\";\nimport { InMemoryThreadListAdapter } from \"./in-memory\";\n\ntype ThreadData = {\n externalId: string;\n};\n\ntype CloudThreadListAdapterOptions = {\n cloud?: AssistantCloud | undefined;\n\n create?(): Promise<ThreadData>;\n delete?(threadId: string): Promise<void>;\n};\n\nconst baseUrl =\n typeof process !== \"undefined\" &&\n process?.env?.[\"NEXT_PUBLIC_ASSISTANT_BASE_URL\"];\nconst autoCloud = baseUrl\n ? new AssistantCloud({ baseUrl, anonymous: true })\n : undefined;\n\nexport const useCloudThreadListAdapter = (\n adapter: CloudThreadListAdapterOptions,\n): RemoteThreadListAdapter => {\n const adapterRef = useRef(adapter);\n useEffect(() => {\n adapterRef.current = adapter;\n }, [adapter]);\n\n const unstable_Provider = useCallback<FC<PropsWithChildren>>(\n ({ children }) => {\n const history = useAssistantCloudThreadHistoryAdapter({\n get current() {\n return adapterRef.current.cloud ?? autoCloud!;\n },\n });\n const adapters = useMemo(() => ({ history }), [history]);\n\n return (\n <RuntimeAdapterProvider adapters={adapters}>\n {children}\n </RuntimeAdapterProvider>\n );\n },\n [],\n );\n\n const cloud = adapter.cloud ?? autoCloud;\n if (!cloud) return new InMemoryThreadListAdapter();\n\n return {\n list: async () => {\n const { threads } = await cloud.threads.list();\n return {\n threads: threads.map((t) => ({\n status: t.is_archived ? \"archived\" : \"regular\",\n remoteId: t.id,\n title: t.title,\n externalId: t.external_id ?? undefined,\n })),\n };\n },\n\n initialize: async () => {\n const createTask = adapter.create?.() ?? Promise.resolve();\n const t = await createTask;\n const external_id = t ? t.externalId : undefined;\n const { thread_id: remoteId } = await cloud.threads.create({\n last_message_at: new Date(),\n external_id,\n });\n\n return { externalId: external_id, remoteId: remoteId };\n },\n\n rename: async (threadId, newTitle) => {\n return cloud.threads.update(threadId, { title: newTitle });\n },\n archive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: true });\n },\n unarchive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: false });\n },\n delete: async (threadId) => {\n await adapter.delete?.(threadId);\n return cloud.threads.delete(threadId);\n },\n\n generateTitle: async (threadId, messages) => {\n return cloud.runs.stream({\n thread_id: threadId,\n assistant_id: \"system/thread_title\",\n messages: toCoreMessages(messages),\n });\n },\n\n unstable_Provider,\n };\n};\n"],"mappings":";AAAA;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAE/B,SAAS,6CAA6C;AACtD,SAAS,8BAA8B;AACvC,SAAS,sBAAsB;AAC/B,SAAS,iCAAiC;AAsClC;AAzBR,IAAM,UACJ,OAAO,YAAY,eACnB,SAAS,MAAM,gCAAgC;AACjD,IAAM,YAAY,UACd,IAAI,eAAe,EAAE,SAAS,WAAW,KAAK,CAAC,IAC/C;AAEG,IAAM,4BAA4B,CACvC,YAC4B;AAC5B,QAAM,aAAa,OAAO,OAAO;AACjC,YAAU,MAAM;AACd,eAAW,UAAU;AAAA,EACvB,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,oBAAoB;AAAA,IACxB,CAAC,EAAE,SAAS,MAAM;AAChB,YAAM,UAAU,sCAAsC;AAAA,QACpD,IAAI,UAAU;AACZ,iBAAO,WAAW,QAAQ,SAAS;AAAA,QACrC;AAAA,MACF,CAAC;AACD,YAAM,WAAW,QAAQ,OAAO,EAAE,QAAQ,IAAI,CAAC,OAAO,CAAC;AAEvD,aACE,oBAAC,0BAAuB,UACrB,UACH;AAAA,IAEJ;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,QAAQ,QAAQ,SAAS;AAC/B,MAAI,CAAC,MAAO,QAAO,IAAI,0BAA0B;AAEjD,SAAO;AAAA,IACL,MAAM,YAAY;AAChB,YAAM,EAAE,QAAQ,IAAI,MAAM,MAAM,QAAQ,KAAK;AAC7C,aAAO;AAAA,QACL,SAAS,QAAQ,IAAI,CAAC,OAAO;AAAA,UAC3B,QAAQ,EAAE,cAAc,aAAa;AAAA,UACrC,UAAU,EAAE;AAAA,UACZ,OAAO,EAAE;AAAA,UACT,YAAY,EAAE,eAAe;AAAA,QAC/B,EAAE;AAAA,MACJ;AAAA,IACF;AAAA,IAEA,YAAY,YAAY;AACtB,YAAM,aAAa,QAAQ,SAAS,KAAK,QAAQ,QAAQ;AACzD,YAAM,IAAI,MAAM;AAChB,YAAM,cAAc,IAAI,EAAE,aAAa;AACvC,YAAM,EAAE,WAAW,SAAS,IAAI,MAAM,MAAM,QAAQ,OAAO;AAAA,QACzD,iBAAiB,oBAAI,KAAK;AAAA,QAC1B;AAAA,MACF,CAAC;AAED,aAAO,EAAE,YAAY,aAAa,SAAmB;AAAA,IACvD;AAAA,IAEA,QAAQ,OAAO,UAAU,aAAa;AACpC,aAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,OAAO,SAAS,CAAC;AAAA,IAC3D;AAAA,IACA,SAAS,OAAO,aAAa;AAC3B,aAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,aAAa,KAAK,CAAC;AAAA,IAC7D;AAAA,IACA,WAAW,OAAO,aAAa;AAC7B,aAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,aAAa,MAAM,CAAC;AAAA,IAC9D;AAAA,IACA,QAAQ,OAAO,aAAa;AAC1B,YAAM,QAAQ,SAAS,QAAQ;AAC/B,aAAO,MAAM,QAAQ,OAAO,QAAQ;AAAA,IACtC;AAAA,IAEA,eAAe,OAAO,UAAU,aAAa;AAC3C,aAAO,MAAM,KAAK,OAAO;AAAA,QACvB,WAAW;AAAA,QACX,cAAc;AAAA,QACd,UAAU,eAAe,QAAQ;AAAA,MACnC,CAAC;AAAA,IACH;AAAA,IAEA;AAAA,EACF;AACF;","names":[]}
@@ -9,6 +9,13 @@ export type ReasoningContentPart = {
9
9
  readonly type: "reasoning";
10
10
  readonly text: string;
11
11
  };
12
+ export type SourceContentPart = {
13
+ readonly type: "source";
14
+ readonly sourceType: "url";
15
+ readonly id: string;
16
+ readonly url: string;
17
+ readonly title?: string;
18
+ };
12
19
  export type ImageContentPart = {
13
20
  readonly type: "image";
14
21
  readonly image: string;
@@ -75,12 +82,13 @@ export type ToolCallContentPart<TArgs = ReadonlyJSONObject, TResult = unknown> =
75
82
  readonly argsText: string;
76
83
  };
77
84
  export type ThreadUserContentPart = TextContentPart | ImageContentPart | FileContentPart | Unstable_AudioContentPart;
78
- export type ThreadAssistantContentPart = TextContentPart | ReasoningContentPart | ToolCallContentPart;
85
+ export type ThreadAssistantContentPart = TextContentPart | ReasoningContentPart | ToolCallContentPart | SourceContentPart;
79
86
  type MessageCommonProps = {
80
87
  readonly id: string;
81
88
  readonly createdAt: Date;
82
89
  };
83
90
  export type ThreadStep = {
91
+ readonly messageId?: string;
84
92
  readonly usage?: {
85
93
  readonly promptTokens: number;
86
94
  readonly completionTokens: number;
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantTypes.d.ts","sourceRoot":"","sources":["../../src/types/AssistantTypes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,C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e,GACf,uBAAuB,CAAC;AAE5B,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,SAAS,CAAC,eAAe,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,SAAS,mBAAmB,EAAE,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,SAAS,wBAAwB,EAAE,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB,iBAAiB,GACjB,eAAe,GACf,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/AssistantTypes.ts"],"sourcesContent":["\nimport { CompleteAttachment } from \"./AttachmentTypes\";\nimport {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"../utils/json/json-value\";\n\nexport type MessageRole = \"user\" | \"assistant\" | \"system\";\n\nexport type TextContentPart = {\n readonly type: \"text\";\n readonly text: string;\n};\n\nexport type ReasoningContentPart = {\n readonly type: \"reasoning\";\n readonly text: string;\n};\n\nexport type ImageContentPart = {\n readonly type: \"image\";\n readonly image: string;\n};\n\nexport type FileContentPart = {\n readonly type: \"file\";\n readonly data: string;\n readonly mimeType: string;\n};\n\nexport type Unstable_AudioContentPart = {\n readonly type: \"audio\";\n readonly audio: {\n readonly data: string;\n readonly format: \"mp3\" | \"wav\";\n };\n};\n\n/**\n * @deprecated UI content parts are deprecated and will be removed in v0.8.0.\n * Migration guide for external-store users using UI content parts:\n * If you must, store UI elements on your external store messages, update your\n * external store converter:\n * ```ts\n * const UI_PLACEHOLDER = Object.freeze({ type: \"text\", text: \"UI content placeholder\" });\n * const convertMessage = (message: TMessage): ThreadMessageLike => ({\n * content: [\n * // other content parts,\n * UI_PLACEHOLDER\n * ],\n * });\n * ```\n *\n * Then, define a custom `TextContentPartComponent`:\n *\n * ```tsx\n * const MyText: FC = () => {\n * const isUIPlaceholder = useContentPart(p => p === UI_PLACEHOLDER);\n *\n * // this assumes that you have a `display` field on your original message objects before conversion.\n * const ui = useMessage(m => isUIPlaceholder ? getExternalStoreMessage(m).display : undefined);\n * if (ui) {\n * return ui;\n * }\n *\n * return <MarkdownText />; // your default text component\n * }\n * ```\n *\n * Pass this component to your Thread:\n *\n * ```tsx\n * <Thread assistantMessage={{ components: { Text: MyText } }} userMessage={{ components: { Text: MyText } }} />\n * ```\n */\nexport type UIContentPart = never;\n\nexport type CoreToolCallContentPart<\n TArgs = ReadonlyJSONObject,\n TResult = unknown,\n> = {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly args: TArgs;\n readonly result?: TResult | undefined;\n readonly isError?: boolean | undefined;\n};\n\nexport type ToolCallContentPart<\n TArgs = ReadonlyJSONObject,\n TResult = unknown,\n> = CoreToolCallContentPart<TArgs, TResult> & {\n readonly argsText: string;\n};\n\nexport type ThreadUserContentPart =\n | TextContentPart\n | ImageContentPart\n | FileContentPart\n | Unstable_AudioContentPart;\n\nexport type ThreadAssistantContentPart =\n | TextContentPart\n | ReasoningContentPart\n | ToolCallContentPart;\n\ntype MessageCommonProps = {\n readonly id: string;\n readonly createdAt: Date;\n};\n\nexport type ThreadStep = {\n readonly usage?:\n | {\n readonly promptTokens: number;\n readonly completionTokens: number;\n }\n | undefined;\n};\n\nexport type ContentPartStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"complete\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ToolCallContentPartStatus =\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | ContentPartStatus;\n\nexport type MessageStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | {\n readonly type: \"complete\";\n readonly reason: \"stop\" | \"unknown\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"tool-calls\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: ReadonlyJSONValue;\n };\n\nexport type ThreadSystemMessage = MessageCommonProps & {\n readonly role: \"system\";\n readonly content: readonly [TextContentPart];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadUserMessage = MessageCommonProps & {\n readonly role: \"user\";\n readonly content: readonly ThreadUserContentPart[];\n readonly attachments: readonly CompleteAttachment[];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadAssistantMessage = MessageCommonProps & {\n readonly role: \"assistant\";\n readonly content: readonly ThreadAssistantContentPart[];\n readonly status: MessageStatus;\n readonly metadata: {\n readonly unstable_annotations: readonly ReadonlyJSONValue[];\n readonly unstable_data: readonly ReadonlyJSONValue[];\n readonly steps: readonly ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type RunConfig = {\n // TODO allow user customization via global type overrides\n readonly custom?: Record<string, unknown>;\n};\n\nexport type AppendMessage = CoreMessage & {\n parentId: string | null;\n\n /** The ID of the message that was edited or undefined. */\n sourceId: string | null;\n runConfig: RunConfig | undefined;\n\n attachments: readonly CompleteAttachment[];\n startRun?: boolean | undefined;\n};\n\ntype BaseThreadMessage = {\n readonly status?: ThreadAssistantMessage[\"status\"];\n readonly metadata: {\n readonly unstable_annotations?: readonly ReadonlyJSONValue[];\n readonly unstable_data?: readonly ReadonlyJSONValue[];\n readonly steps?: readonly ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n readonly attachments?: ThreadUserMessage[\"attachments\"];\n};\n\nexport type ThreadMessage = BaseThreadMessage &\n (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);\n\n/** Core Message Types (without UI content parts) */\n\nexport type CoreUserContentPart =\n | TextContentPart\n | ImageContentPart\n | FileContentPart\n | Unstable_AudioContentPart;\nexport type CoreAssistantContentPart =\n | TextContentPart\n | CoreToolCallContentPart;\n\nexport type CoreSystemMessage = {\n role: \"system\";\n content: readonly [TextContentPart];\n};\n\nexport type CoreUserMessage = {\n role: \"user\";\n content: readonly CoreUserContentPart[];\n};\n\nexport type CoreAssistantMessage = {\n role: \"assistant\";\n content: readonly CoreAssistantContentPart[];\n};\n\nexport type CoreMessage =\n | CoreSystemMessage\n | CoreUserMessage\n | CoreAssistantMessage;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/AssistantTypes.ts"],"sourcesContent":["import { CompleteAttachment } from \"./AttachmentTypes\";\nimport {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"../utils/json/json-value\";\n\nexport type MessageRole = \"user\" | \"assistant\" | \"system\";\n\nexport type TextContentPart = {\n readonly type: \"text\";\n readonly text: string;\n};\n\nexport type ReasoningContentPart = {\n readonly type: \"reasoning\";\n readonly text: string;\n};\n\nexport type SourceContentPart = {\n readonly type: \"source\";\n readonly sourceType: \"url\";\n readonly id: string;\n readonly url: string;\n readonly title?: string;\n};\n\nexport type ImageContentPart = {\n readonly type: \"image\";\n readonly image: string;\n};\n\nexport type FileContentPart = {\n readonly type: \"file\";\n readonly data: string;\n readonly mimeType: string;\n};\n\nexport type Unstable_AudioContentPart = {\n readonly type: \"audio\";\n readonly audio: {\n readonly data: string;\n readonly format: \"mp3\" | \"wav\";\n };\n};\n\n/**\n * @deprecated UI content parts are deprecated and will be removed in v0.8.0.\n * Migration guide for external-store users using UI content parts:\n * If you must, store UI elements on your external store messages, update your\n * external store converter:\n * ```ts\n * const UI_PLACEHOLDER = Object.freeze({ type: \"text\", text: \"UI content placeholder\" });\n * const convertMessage = (message: TMessage): ThreadMessageLike => ({\n * content: [\n * // other content parts,\n * UI_PLACEHOLDER\n * ],\n * });\n * ```\n *\n * Then, define a custom `TextContentPartComponent`:\n *\n * ```tsx\n * const MyText: FC = () => {\n * const isUIPlaceholder = useContentPart(p => p === UI_PLACEHOLDER);\n *\n * // this assumes that you have a `display` field on your original message objects before conversion.\n * const ui = useMessage(m => isUIPlaceholder ? getExternalStoreMessage(m).display : undefined);\n * if (ui) {\n * return ui;\n * }\n *\n * return <MarkdownText />; // your default text component\n * }\n * ```\n *\n * Pass this component to your Thread:\n *\n * ```tsx\n * <Thread assistantMessage={{ components: { Text: MyText } }} userMessage={{ components: { Text: MyText } }} />\n * ```\n */\nexport type UIContentPart = never;\n\nexport type CoreToolCallContentPart<\n TArgs = ReadonlyJSONObject,\n TResult = unknown,\n> = {\n readonly type: \"tool-call\";\n readonly toolCallId: string;\n readonly toolName: string;\n readonly args: TArgs;\n readonly result?: TResult | undefined;\n readonly isError?: boolean | undefined;\n};\n\nexport type ToolCallContentPart<\n TArgs = ReadonlyJSONObject,\n TResult = unknown,\n> = CoreToolCallContentPart<TArgs, TResult> & {\n readonly argsText: string;\n};\n\nexport type ThreadUserContentPart =\n | TextContentPart\n | ImageContentPart\n | FileContentPart\n | Unstable_AudioContentPart;\n\nexport type ThreadAssistantContentPart =\n | TextContentPart\n | ReasoningContentPart\n | ToolCallContentPart\n | SourceContentPart;\n\ntype MessageCommonProps = {\n readonly id: string;\n readonly createdAt: Date;\n};\n\nexport type ThreadStep = {\n readonly messageId?: string;\n readonly usage?:\n | {\n readonly promptTokens: number;\n readonly completionTokens: number;\n }\n | undefined;\n};\n\nexport type ContentPartStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"complete\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: unknown;\n };\n\nexport type ToolCallContentPartStatus =\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | ContentPartStatus;\n\nexport type MessageStatus =\n | {\n readonly type: \"running\";\n }\n | {\n readonly type: \"requires-action\";\n readonly reason: \"tool-calls\";\n }\n | {\n readonly type: \"complete\";\n readonly reason: \"stop\" | \"unknown\";\n }\n | {\n readonly type: \"incomplete\";\n readonly reason:\n | \"cancelled\"\n | \"tool-calls\"\n | \"length\"\n | \"content-filter\"\n | \"other\"\n | \"error\";\n readonly error?: ReadonlyJSONValue;\n };\n\nexport type ThreadSystemMessage = MessageCommonProps & {\n readonly role: \"system\";\n readonly content: readonly [TextContentPart];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadUserMessage = MessageCommonProps & {\n readonly role: \"user\";\n readonly content: readonly ThreadUserContentPart[];\n readonly attachments: readonly CompleteAttachment[];\n readonly metadata: {\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type ThreadAssistantMessage = MessageCommonProps & {\n readonly role: \"assistant\";\n readonly content: readonly ThreadAssistantContentPart[];\n readonly status: MessageStatus;\n readonly metadata: {\n readonly unstable_annotations: readonly ReadonlyJSONValue[];\n readonly unstable_data: readonly ReadonlyJSONValue[];\n readonly steps: readonly ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n};\n\nexport type RunConfig = {\n // TODO allow user customization via global type overrides\n readonly custom?: Record<string, unknown>;\n};\n\nexport type AppendMessage = CoreMessage & {\n parentId: string | null;\n\n /** The ID of the message that was edited or undefined. */\n sourceId: string | null;\n runConfig: RunConfig | undefined;\n\n attachments: readonly CompleteAttachment[];\n startRun?: boolean | undefined;\n};\n\ntype BaseThreadMessage = {\n readonly status?: ThreadAssistantMessage[\"status\"];\n readonly metadata: {\n readonly unstable_annotations?: readonly ReadonlyJSONValue[];\n readonly unstable_data?: readonly ReadonlyJSONValue[];\n readonly steps?: readonly ThreadStep[];\n readonly custom: Record<string, unknown>;\n };\n readonly attachments?: ThreadUserMessage[\"attachments\"];\n};\n\nexport type ThreadMessage = BaseThreadMessage &\n (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage);\n\n/** Core Message Types (without UI content parts) */\n\nexport type CoreUserContentPart =\n | TextContentPart\n | ImageContentPart\n | FileContentPart\n | Unstable_AudioContentPart;\nexport type CoreAssistantContentPart =\n | TextContentPart\n | CoreToolCallContentPart;\n\nexport type CoreSystemMessage = {\n role: \"system\";\n content: readonly [TextContentPart];\n};\n\nexport type CoreUserMessage = {\n role: \"user\";\n content: readonly CoreUserContentPart[];\n};\n\nexport type CoreAssistantMessage = {\n role: \"assistant\";\n content: readonly CoreAssistantContentPart[];\n};\n\nexport type CoreMessage =\n | CoreSystemMessage\n | CoreUserMessage\n | CoreAssistantMessage;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,5 +1,5 @@
1
1
  import type { ComponentType } from "react";
2
- import type { ContentPartStatus, FileContentPart, ImageContentPart, ReasoningContentPart, TextContentPart, ToolCallContentPart, Unstable_AudioContentPart } from "./AssistantTypes";
2
+ import type { ContentPartStatus, FileContentPart, ImageContentPart, ReasoningContentPart, SourceContentPart, TextContentPart, ToolCallContentPart, Unstable_AudioContentPart } from "./AssistantTypes";
3
3
  import { ContentPartState } from "../api/ContentPartRuntime";
4
4
  export type EmptyContentPartProps = {
5
5
  status: ContentPartStatus;
@@ -9,6 +9,8 @@ export type TextContentPartProps = ContentPartState & TextContentPart;
9
9
  export type TextContentPartComponent = ComponentType<TextContentPartProps>;
10
10
  export type ReasoningContentPartProps = ContentPartState & ReasoningContentPart;
11
11
  export type ReasoningContentPartComponent = ComponentType<ReasoningContentPartProps>;
12
+ export type SourceContentPartProps = ContentPartState & SourceContentPart;
13
+ export type SourceContentPartComponent = ComponentType<SourceContentPartProps>;
12
14
  export type ImageContentPartProps = ContentPartState & ImageContentPart;
13
15
  export type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
14
16
  export type FileContentPartProps = ContentPartState & FileContentPart;
@@ -1 +1 @@
1
- {"version":3,"file":"ContentPartComponentTypes.d.ts","sourceRoot":"","sources":["../../src/types/ContentPartComponentTypes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,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,aAAa,CAAC,oBAAoB,CAAC,CAAC;AAE3E,MAAM,MAAM,8BAA8B,GAAG,gBAAgB,GAC3D,yBAAyB,CAAC;AAC5B,MAAM,MAAM,kCAAkC,GAC5C,aAAa,CAAC,8BAA8B,CAAC,CAAC;AAEhD,MAAM,MAAM,wBAAwB,CAClC,KAAK,GAAG,GAAG,EACX,OAAO,GAAG,OAAO,IACf,gBAAgB,GAClB,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG;IACpC,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;CAClC,CAAC;AAEJ,MAAM,MAAM,4BAA4B,CACtC,KAAK,GAAG,GAAG,EACX,OAAO,GAAG,GAAG,IACX,aAAa,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/ContentPartComponentTypes.tsx"],"sourcesContent":["import type { ComponentType } from \"react\";\nimport type {\n ContentPartStatus,\n FileContentPart,\n ImageContentPart,\n ReasoningContentPart,\n TextContentPart,\n ToolCallContentPart,\n Unstable_AudioContentPart,\n} from \"./AssistantTypes\";\nimport { ContentPartState } from \"../api/ContentPartRuntime\";\n\nexport type EmptyContentPartProps = {\n status: ContentPartStatus;\n};\nexport type EmptyContentPartComponent = ComponentType<EmptyContentPartProps>;\n\nexport type TextContentPartProps = ContentPartState & TextContentPart;\nexport type TextContentPartComponent = ComponentType<TextContentPartProps>;\n\nexport type ReasoningContentPartProps = ContentPartState & ReasoningContentPart;\nexport type ReasoningContentPartComponent =\n ComponentType<ReasoningContentPartProps>;\n\nexport type ImageContentPartProps = ContentPartState & ImageContentPart;\nexport type ImageContentPartComponent = ComponentType<ImageContentPartProps>;\n\nexport type FileContentPartProps = ContentPartState & FileContentPart;\nexport type FileContentPartComponent = ComponentType<FileContentPartProps>;\n\nexport type Unstable_AudioContentPartProps = ContentPartState &\n Unstable_AudioContentPart;\nexport type Unstable_AudioContentPartComponent =\n ComponentType<Unstable_AudioContentPartProps>;\n\nexport type ToolCallContentPartProps<\n TArgs = any,\n TResult = unknown,\n> = ContentPartState &\n ToolCallContentPart<TArgs, TResult> & {\n addResult: (result: any) => void;\n };\n\nexport type ToolCallContentPartComponent<\n TArgs = any,\n TResult = any,\n> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/ContentPartComponentTypes.tsx"],"sourcesContent":["import type { ComponentType } from \"react\";\nimport type {\n ContentPartStatus,\n FileContentPart,\n ImageContentPart,\n ReasoningContentPart,\n SourceContentPart,\n TextContentPart,\n ToolCallContentPart,\n Unstable_AudioContentPart,\n} from \"./AssistantTypes\";\nimport { ContentPartState } from \"../api/ContentPartRuntime\";\n\nexport type EmptyContentPartProps = {\n status: ContentPartStatus;\n};\nexport type EmptyContentPartComponent = ComponentType<EmptyContentPartProps>;\n\nexport type TextContentPartProps = ContentPartState & TextContentPart;\nexport type TextContentPartComponent = ComponentType<TextContentPartProps>;\n\nexport type ReasoningContentPartProps = ContentPartState & ReasoningContentPart;\nexport type ReasoningContentPartComponent =\n ComponentType<ReasoningContentPartProps>;\n\nexport type SourceContentPartProps = ContentPartState & SourceContentPart;\nexport type SourceContentPartComponent = ComponentType<SourceContentPartProps>;\n\nexport type ImageContentPartProps = ContentPartState & ImageContentPart;\nexport type ImageContentPartComponent = ComponentType<ImageContentPartProps>;\n\nexport type FileContentPartProps = ContentPartState & FileContentPart;\nexport type FileContentPartComponent = ComponentType<FileContentPartProps>;\n\nexport type Unstable_AudioContentPartProps = ContentPartState &\n Unstable_AudioContentPart;\nexport type Unstable_AudioContentPartComponent =\n ComponentType<Unstable_AudioContentPartProps>;\n\nexport type ToolCallContentPartProps<\n TArgs = any,\n TResult = unknown,\n> = ContentPartState &\n ToolCallContentPart<TArgs, TResult> & {\n addResult: (result: any) => void;\n };\n\nexport type ToolCallContentPartComponent<\n TArgs = any,\n TResult = any,\n> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,5 +1,5 @@
1
1
  export type { Attachment, PendingAttachment, CompleteAttachment, AttachmentStatus, } from "./AttachmentTypes";
2
- export type { AppendMessage, TextContentPart, ReasoningContentPart, ImageContentPart, FileContentPart, Unstable_AudioContentPart, ToolCallContentPart, UIContentPart, MessageStatus, ThreadUserContentPart, ThreadAssistantContentPart, ThreadSystemMessage, ThreadAssistantMessage, ThreadUserMessage, ThreadMessage, CoreUserContentPart, CoreAssistantContentPart, CoreSystemMessage, CoreUserMessage, CoreAssistantMessage, CoreMessage, } from "./AssistantTypes";
3
- export type { EmptyContentPartProps, EmptyContentPartComponent, TextContentPartProps, TextContentPartComponent, ReasoningContentPartProps, ReasoningContentPartComponent, ImageContentPartProps, ImageContentPartComponent, FileContentPartProps, FileContentPartComponent, Unstable_AudioContentPartProps, Unstable_AudioContentPartComponent, ToolCallContentPartProps, ToolCallContentPartComponent, } from "./ContentPartComponentTypes";
2
+ export type { AppendMessage, TextContentPart, ReasoningContentPart, SourceContentPart, ImageContentPart, FileContentPart, Unstable_AudioContentPart, ToolCallContentPart, UIContentPart, MessageStatus, ThreadUserContentPart, ThreadAssistantContentPart, ThreadSystemMessage, ThreadAssistantMessage, ThreadUserMessage, ThreadMessage, CoreUserContentPart, CoreAssistantContentPart, CoreSystemMessage, CoreUserMessage, CoreAssistantMessage, CoreMessage, } from "./AssistantTypes";
3
+ export type { EmptyContentPartProps, EmptyContentPartComponent, TextContentPartProps, TextContentPartComponent, ReasoningContentPartProps, ReasoningContentPartComponent, SourceContentPartProps, SourceContentPartComponent, ImageContentPartProps, ImageContentPartComponent, FileContentPartProps, FileContentPartComponent, Unstable_AudioContentPartProps, Unstable_AudioContentPartComponent, ToolCallContentPartProps, ToolCallContentPartComponent, } from "./ContentPartComponentTypes";
4
4
  export type { Unsubscribe } from "./Unsubscribe";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACb,aAAa,EAGb,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EAGb,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,6BAA6B,EAC7B,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,8BAA8B,EAC9B,kCAAkC,EAClC,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACb,aAAa,EAGb,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EAGb,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,6BAA6B,EAC7B,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,8BAA8B,EAC9B,kCAAkC,EAClC,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export type {\n Attachment,\n PendingAttachment,\n CompleteAttachment,\n AttachmentStatus,\n} from \"./AttachmentTypes\";\n\nexport type {\n AppendMessage,\n TextContentPart,\n ReasoningContentPart,\n ImageContentPart,\n FileContentPart,\n Unstable_AudioContentPart,\n ToolCallContentPart,\n UIContentPart,\n MessageStatus,\n\n // thread message types\n ThreadUserContentPart,\n ThreadAssistantContentPart,\n ThreadSystemMessage,\n ThreadAssistantMessage,\n ThreadUserMessage,\n ThreadMessage,\n\n // core message types\n CoreUserContentPart,\n CoreAssistantContentPart,\n CoreSystemMessage,\n CoreUserMessage,\n CoreAssistantMessage,\n CoreMessage,\n} from \"./AssistantTypes\";\n\nexport type {\n EmptyContentPartProps,\n EmptyContentPartComponent,\n TextContentPartProps,\n TextContentPartComponent,\n ReasoningContentPartProps,\n ReasoningContentPartComponent,\n ImageContentPartProps,\n ImageContentPartComponent,\n FileContentPartProps,\n FileContentPartComponent,\n Unstable_AudioContentPartProps,\n Unstable_AudioContentPartComponent,\n ToolCallContentPartProps,\n ToolCallContentPartComponent,\n} from \"./ContentPartComponentTypes\";\n\nexport type { Unsubscribe } from \"./Unsubscribe\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export type {\n Attachment,\n PendingAttachment,\n CompleteAttachment,\n AttachmentStatus,\n} from \"./AttachmentTypes\";\n\nexport type {\n AppendMessage,\n TextContentPart,\n ReasoningContentPart,\n SourceContentPart,\n ImageContentPart,\n FileContentPart,\n Unstable_AudioContentPart,\n ToolCallContentPart,\n UIContentPart,\n MessageStatus,\n\n // thread message types\n ThreadUserContentPart,\n ThreadAssistantContentPart,\n ThreadSystemMessage,\n ThreadAssistantMessage,\n ThreadUserMessage,\n ThreadMessage,\n\n // core message types\n CoreUserContentPart,\n CoreAssistantContentPart,\n CoreSystemMessage,\n CoreUserMessage,\n CoreAssistantMessage,\n CoreMessage,\n} from \"./AssistantTypes\";\n\nexport type {\n EmptyContentPartProps,\n EmptyContentPartComponent,\n TextContentPartProps,\n TextContentPartComponent,\n ReasoningContentPartProps,\n ReasoningContentPartComponent,\n SourceContentPartProps,\n SourceContentPartComponent,\n ImageContentPartProps,\n ImageContentPartComponent,\n FileContentPartProps,\n FileContentPartComponent,\n Unstable_AudioContentPartProps,\n Unstable_AudioContentPartComponent,\n ToolCallContentPartProps,\n ToolCallContentPartComponent,\n} from \"./ContentPartComponentTypes\";\n\nexport type { Unsubscribe } from \"./Unsubscribe\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
package/package.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "conversational-ui",
30
30
  "conversational-ai"
31
31
  ],
32
- "version": "0.8.0",
32
+ "version": "0.8.2",
33
33
  "license": "MIT",
34
34
  "exports": {
35
35
  ".": {
@@ -19,6 +19,13 @@ type AuiV0MessageContentPart =
19
19
  readonly type: "reasoning";
20
20
  readonly text: string;
21
21
  }
22
+ | {
23
+ readonly type: "source";
24
+ readonly sourceType: "url";
25
+ readonly id: string;
26
+ readonly url: string;
27
+ readonly title?: string;
28
+ }
22
29
  | {
23
30
  readonly type: "tool-call";
24
31
  readonly toolCallId: string;
@@ -75,6 +82,9 @@ export const auiV0Encode = (message: ThreadMessage): AuiV0Message => {
75
82
  };
76
83
  }
77
84
 
85
+ case "source":
86
+ return part;
87
+
78
88
  case "tool-call": {
79
89
  if (!isJSONValue(part.result)) {
80
90
  console.warn(
@@ -17,8 +17,9 @@ import { ContentPartPrimitiveImage } from "../contentPart/ContentPartImage";
17
17
  import type {
18
18
  Unstable_AudioContentPartComponent,
19
19
  EmptyContentPartComponent,
20
- ImageContentPartComponent,
21
20
  TextContentPartComponent,
21
+ ImageContentPartComponent,
22
+ SourceContentPartComponent,
22
23
  ToolCallContentPartComponent,
23
24
  ToolCallContentPartProps,
24
25
  FileContentPartComponent,
@@ -32,8 +33,9 @@ export namespace MessagePrimitiveContent {
32
33
  components?:
33
34
  | {
34
35
  Empty?: EmptyContentPartComponent | undefined;
35
- Reasoning?: ReasoningContentPartComponent | undefined;
36
36
  Text?: TextContentPartComponent | undefined;
37
+ Reasoning?: ReasoningContentPartComponent | undefined;
38
+ Source?: SourceContentPartComponent | undefined;
37
39
  Image?: ImageContentPartComponent | undefined;
38
40
  File?: FileContentPartComponent | undefined;
39
41
  Unstable_Audio?: Unstable_AudioContentPartComponent | undefined;
@@ -74,6 +76,7 @@ const defaultComponents = {
74
76
  </p>
75
77
  ),
76
78
  Reasoning: () => null,
79
+ Source: () => null,
77
80
  Image: () => <ContentPartPrimitiveImage />,
78
81
  File: () => null,
79
82
  Unstable_Audio: () => null,
@@ -88,6 +91,7 @@ const MessageContentPartComponent: FC<MessageContentPartComponentProps> = ({
88
91
  Text = defaultComponents.Text,
89
92
  Reasoning = defaultComponents.Reasoning,
90
93
  Image = defaultComponents.Image,
94
+ Source = defaultComponents.Source,
91
95
  File = defaultComponents.File,
92
96
  Unstable_Audio: Audio = defaultComponents.Unstable_Audio,
93
97
  tools = {},
@@ -116,6 +120,9 @@ const MessageContentPartComponent: FC<MessageContentPartComponentProps> = ({
116
120
  case "reasoning":
117
121
  return <Reasoning {...part} />;
118
122
 
123
+ case "source":
124
+ return <Source {...part} />;
125
+
119
126
  case "image":
120
127
  // eslint-disable-next-line jsx-a11y/alt-text
121
128
  return <Image {...part} />;
@@ -160,6 +167,7 @@ const MessageContentPart = memo(
160
167
  prev.partIndex === next.partIndex &&
161
168
  prev.components?.Text === next.components?.Text &&
162
169
  prev.components?.Reasoning === next.components?.Reasoning &&
170
+ prev.components?.Source === next.components?.Source &&
163
171
  prev.components?.Image === next.components?.Image &&
164
172
  prev.components?.File === next.components?.File &&
165
173
  prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&
@@ -23,7 +23,8 @@ export const toCoreMessage = <T extends boolean = false>(
23
23
  role,
24
24
  content: message.content
25
25
  .map((part) => {
26
- if (part.type === "reasoning") return null; // reasoning parts are omitted
26
+ if (part.type === "reasoning" || part.type === "source")
27
+ return null; // reasoning and source parts are omitted
27
28
  if (part.type === "tool-call") {
28
29
  const { argsText, ...rest } = part;
29
30
  return rest;
@@ -150,8 +150,9 @@ export function toLanguageModelMessages(
150
150
  for (const part of message.content) {
151
151
  const type = part.type;
152
152
  switch (type) {
153
- case "reasoning": {
154
- break; // reasoning parts are omitted
153
+ case "reasoning":
154
+ case "source": {
155
+ break; // reasoning and source parts are omitted
155
156
  }
156
157
 
157
158
  case "text": {
@@ -14,6 +14,7 @@ export enum AssistantStreamChunkType {
14
14
  FinishStep = "e",
15
15
  StartStep = "f",
16
16
  ReasoningDelta = "g",
17
+ Source = "h",
17
18
  }
18
19
 
19
20
  export type AssistantStreamChunk = {
@@ -63,4 +64,10 @@ export type AssistantStreamChunk = {
63
64
  id: string;
64
65
  };
65
66
  [AssistantStreamChunkType.ReasoningDelta]: string;
67
+ [AssistantStreamChunkType.Source]: {
68
+ readonly sourceType: "url";
69
+ readonly id: string;
70
+ readonly url: string;
71
+ readonly title?: string;
72
+ };
66
73
  };
@@ -145,6 +145,13 @@ export function assistantDecoderStream() {
145
145
  });
146
146
  break;
147
147
 
148
+ case AssistantStreamChunkType.Source:
149
+ controller.enqueue({
150
+ type: "source",
151
+ source: value,
152
+ });
153
+ break;
154
+
148
155
  // TODO
149
156
  case AssistantStreamChunkType.ReasoningDelta:
150
157
  case AssistantStreamChunkType.StartStep:
@@ -22,6 +22,13 @@ export function assistantEncoderStream() {
22
22
  break;
23
23
  }
24
24
 
25
+ case "source":
26
+ controller.enqueue({
27
+ type: AssistantStreamChunkType.Source,
28
+ value: chunk.source,
29
+ });
30
+ break;
31
+
25
32
  case "text-delta": {
26
33
  if (!chunk.textDelta) break; // ignore empty text deltas
27
34
  controller.enqueue({
@@ -56,6 +56,12 @@ export function runResultStream() {
56
56
  break;
57
57
  }
58
58
 
59
+ case "source": {
60
+ message = appendSource(message, chunk);
61
+ controller.enqueue(message);
62
+ break;
63
+ }
64
+
59
65
  case "tool-result": {
60
66
  message = appendOrUpdateToolResult(
61
67
  message,
@@ -111,7 +117,7 @@ export function runResultStream() {
111
117
  });
112
118
  }
113
119
 
114
- const appendOrUpdateReasoning= (
120
+ const appendOrUpdateReasoning = (
115
121
  message: CoreChatModelRunResult,
116
122
  textDelta: string,
117
123
  ) => {
@@ -168,7 +174,7 @@ const appendOrUpdateToolCall = (
168
174
  toolCallId,
169
175
  toolName,
170
176
  argsText: argsTextDelta,
171
- args: argsTextDelta ? parsePartialJson(argsTextDelta) : {},
177
+ args: argsTextDelta ? parsePartialJson(argsTextDelta) : {},
172
178
  };
173
179
  contentParts = [...contentParts, contentPart];
174
180
  } else {
@@ -176,7 +182,7 @@ const appendOrUpdateToolCall = (
176
182
  contentPart = {
177
183
  ...contentPart,
178
184
  argsText,
179
- args: argsTextDelta ? parsePartialJson(argsText) : {},
185
+ args: argsTextDelta ? parsePartialJson(argsText) : {},
180
186
  };
181
187
  contentParts = [
182
188
  ...contentParts.slice(0, contentPartIdx),
@@ -299,6 +305,22 @@ const appendOrUpdateFinish = (
299
305
  };
300
306
  };
301
307
 
308
+ const appendSource = (
309
+ message: CoreChatModelRunResult,
310
+ chunk: ToolResultStreamPart & { type: "source" },
311
+ ): CoreChatModelRunResult => {
312
+ return {
313
+ ...message,
314
+ content: [
315
+ ...message.content,
316
+ {
317
+ type: "source",
318
+ ...chunk.source,
319
+ },
320
+ ],
321
+ };
322
+ };
323
+
302
324
  const getStatus = (
303
325
  chunk:
304
326
  | (LanguageModelV1StreamPart & { type: "finish" })
@@ -14,6 +14,15 @@ export type ToolResultStreamPart =
14
14
  type: "data";
15
15
  data: ReadonlyJSONValue[];
16
16
  }
17
+ | {
18
+ type: "source";
19
+ source: {
20
+ readonly sourceType: "url";
21
+ readonly id: string;
22
+ readonly url: string;
23
+ readonly title?: string;
24
+ };
25
+ }
17
26
  | {
18
27
  type: "tool-result";
19
28
  toolCallType: "function";
@@ -129,6 +138,7 @@ export function toolResultStream(
129
138
  // ignore other parts
130
139
  case "text-delta":
131
140
  case "reasoning":
141
+ case "source":
132
142
  case "tool-call-delta":
133
143
  case "tool-result":
134
144
  case "step-finish":