@assistant-ui/react 0.14.8 → 0.14.11

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 (48) hide show
  1. package/dist/client/ExternalThread.d.ts.map +1 -1
  2. package/dist/client/ExternalThread.js +2 -1
  3. package/dist/client/ExternalThread.js.map +1 -1
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.js +2 -2
  6. package/dist/internal.d.ts +3 -4
  7. package/dist/internal.js +1 -3
  8. package/dist/internal.js.map +1 -1
  9. package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts +3 -2
  10. package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts.map +1 -1
  11. package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
  12. package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +4 -10
  13. package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
  14. package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.d.ts +1 -1
  15. package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.js.map +1 -1
  16. package/dist/mcp-apps/McpAppRenderer.js.map +1 -1
  17. package/dist/mcp-apps/app-frame.js.map +1 -1
  18. package/dist/primitives/assistantModal/AssistantModalRoot.js +5 -1
  19. package/dist/primitives/assistantModal/AssistantModalRoot.js.map +1 -1
  20. package/dist/primitives/message/MessagePartsGrouped.d.ts.map +1 -1
  21. package/dist/primitives/message/MessagePartsGrouped.js +5 -2
  22. package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
  23. package/dist/utils/useToolArgsFieldStatus.d.ts +2 -2
  24. package/dist/utils/useToolArgsFieldStatus.d.ts.map +1 -1
  25. package/package.json +4 -4
  26. package/src/client/ExternalThread.ts +1 -0
  27. package/src/index.ts +1 -0
  28. package/src/internal.ts +1 -4
  29. package/src/legacy-runtime/runtime/ThreadListRuntime.ts +1 -4
  30. package/src/legacy-runtime/runtime-cores/assistant-transport/types.ts +3 -1
  31. package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts +7 -15
  32. package/src/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.ts +1 -1
  33. package/src/mcp-apps/McpAppRenderer.tsx +1 -1
  34. package/src/mcp-apps/app-frame.tsx +2 -2
  35. package/src/primitives/assistantModal/AssistantModalRoot.tsx +1 -1
  36. package/src/primitives/composer/ComposerAttachmentDropzone.test.tsx +1 -1
  37. package/src/primitives/composer/ComposerInput.test.tsx +1 -1
  38. package/src/primitives/composer/trigger/TriggerPopoverRootContext.test.tsx +1 -1
  39. package/src/primitives/message/MessagePartsGrouped.tsx +10 -1
  40. package/src/primitives/threadListItem/ThreadListItemTitle.test.tsx +1 -1
  41. package/src/tests/BaseComposerRuntimeCore.test.ts +2 -2
  42. package/src/tests/MessageParts.loading.test.tsx +1 -1
  43. package/src/tests/RemoteThreadListRuntime.adapterProvider.test.tsx +2 -4
  44. package/src/tests/auiV0Encode.test.ts +1 -1
  45. package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.d.ts +0 -2
  46. package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.js +0 -2
  47. package/src/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.test.ts +0 -892
  48. package/src/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.ts +0 -4
@@ -1 +1 @@
1
- {"version":3,"file":"ExternalThread.d.ts","names":[],"sources":["../../src/client/ExternalThread.ts"],"mappings":";;;;;KAgCY,qBAAA,GAAwB,aAAa;EAC/C,EAAE;AAAA;AAAA,KAGQ,0BAAA;iCAEV,KAAA,WAAgB,cAAA,IALd;EAOF,OAAA,GAAU,OAAA,EAAS,aAAa,EAAE,IAAA;IAAQ,KAAA;EAAA,YAAV;EAEhC,KAAA,GAAQ,WAAA,mBAJQ;EAMhB,MAAA,GAAS,WAAA,mBAJU;EAMnB,KAAA,GAAQ,MAAA;AAAA;AAAA,KAGE,mBAAA;EACV,QAAA,WAAmB,qBAAA;EACnB,SAAA;EAPA;;;;;AAEgD;EAYhD,cAAA;EAT6B;;;;EAc7B,KAAA,IAAS,OAAA,EAAS,aAAA;EAClB,MAAA,IAAU,OAAA,EAAS,aAAA;EACnB,QAAA,IAAY,QAAA;EACZ,UAAA;EACA,QAAA,eAjBmB;EAmBnB,KAAA,GAAQ,0BAAA;AAAA;AAAA,cAgZG,cAAA,GAAc,KAAA,EAAA,mBAAA,iCAAA,eAAA,CAAA,YAAA,YAAA,mBAAA"}
1
+ {"version":3,"file":"ExternalThread.d.ts","names":[],"sources":["../../src/client/ExternalThread.ts"],"mappings":";;;;;KAgCY,qBAAA,GAAwB,aAAa;EAC/C,EAAE;AAAA;AAAA,KAGQ,0BAAA;iCAEV,KAAA,WAAgB,cAAA,IALd;EAOF,OAAA,GAAU,OAAA,EAAS,aAAa,EAAE,IAAA;IAAQ,KAAA;EAAA,YAAV;EAEhC,KAAA,GAAQ,WAAA,mBAJQ;EAMhB,MAAA,GAAS,WAAA,mBAJU;EAMnB,KAAA,GAAQ,MAAA;AAAA;AAAA,KAGE,mBAAA;EACV,QAAA,WAAmB,qBAAA;EACnB,SAAA;EAPA;;;;;AAEgD;EAYhD,cAAA;EAT6B;;;;EAc7B,KAAA,IAAS,OAAA,EAAS,aAAA;EAClB,MAAA,IAAU,OAAA,EAAS,aAAA;EACnB,QAAA,IAAY,QAAA;EACZ,UAAA;EACA,QAAA,eAjBmB;EAmBnB,KAAA,GAAQ,0BAAA;AAAA;AAAA,cAiZG,cAAA,GAAc,KAAA,EAAA,mBAAA,iCAAA,eAAA,CAAA,YAAA,YAAA,mBAAA"}
@@ -94,7 +94,8 @@ const PartResource = resource(({ part }) => {
94
94
  return {
95
95
  getState: () => state,
96
96
  addToolResult: () => {},
97
- resumeToolCall: () => {}
97
+ resumeToolCall: () => {},
98
+ respondToToolApproval: () => {}
98
99
  };
99
100
  });
100
101
  const AttachmentResource = resource(({ attachment, onRemove }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"ExternalThread.js","names":[],"sources":["../../src/client/ExternalThread.ts"],"sourcesContent":["import {\n resource,\n tapState,\n tapMemo,\n tapEffect,\n tapEffectEvent,\n} from \"@assistant-ui/tap\";\nimport {\n type ClientElement,\n type ClientOutput,\n tapClientLookup,\n attachTransformScopes,\n tapClientResource,\n Derived,\n} from \"@assistant-ui/store\";\nimport { withKey } from \"@assistant-ui/tap\";\nimport type {\n AppendMessage,\n Attachment,\n CreateAttachment,\n ThreadAssistantMessagePart,\n ThreadUserMessagePart,\n ThreadMessage,\n} from \"@assistant-ui/core\";\nimport type { QueueItemState } from \"@assistant-ui/core/store\";\nimport type { ComposerSendOptions } from \"@assistant-ui/core/store\";\nimport { ModelContext, Suggestions } from \"@assistant-ui/core/store\";\nimport { Tools, DataRenderers } from \"@assistant-ui/core/react\";\nimport { SingleThreadList } from \"./SingleThreadList\";\n\nconst EMPTY_QUEUE_ITEMS: readonly QueueItemState[] = [];\n\nexport type ExternalThreadMessage = ThreadMessage & {\n id: string;\n};\n\nexport type ExternalThreadQueueAdapter = {\n /** The current queue items. */\n items: readonly QueueItemState[];\n /** Called when a message is submitted via the composer. Receives the steer preference. */\n enqueue: (message: AppendMessage, opts: { steer: boolean }) => void;\n /** Called to promote an existing queue item (cancel current run, run this immediately). */\n steer: (queueItemId: string) => void;\n /** Called to remove an item from the queue. */\n remove: (queueItemId: string) => void;\n /** Called to clear all pending queue items, with the reason for clearing. */\n clear: (reason: \"edit\" | \"reload\" | \"cancel-run\") => void;\n};\n\nexport type ExternalThreadProps = {\n messages: readonly ExternalThreadMessage[];\n isRunning?: boolean;\n /**\n * Whether sending new messages is currently disabled. When `true`, the\n * thread composer's input remains usable but `send()` is a no-op and\n * `composer.canSend` is `false`. Edit composers (saving message edits)\n * intentionally ignore this flag.\n */\n isSendDisabled?: boolean;\n /**\n * Callback for new messages (non-queue runtimes).\n * @note Unused when `queue` is provided — new messages are routed through `queue.enqueue` instead.\n */\n onNew?: (message: AppendMessage) => void;\n onEdit?: (message: AppendMessage) => void;\n onReload?: (parentId: string | null) => void;\n onStartRun?: () => void;\n onCancel?: () => void;\n /** Queue adapter for runtimes that support message queuing and steering. */\n queue?: ExternalThreadQueueAdapter;\n};\n\ntype MessageClientProps = {\n message: ExternalThreadMessage;\n index: number;\n onEdit?: (message: AppendMessage) => void;\n onReload?: () => void;\n queue?: ExternalThreadQueueAdapter | undefined;\n};\n\n// Message Client - minimal implementation\nconst MessageClient = resource(\n ({\n message,\n index,\n onEdit,\n onReload,\n queue,\n }: MessageClientProps): ClientOutput<\"message\"> => {\n const [isCopied, setIsCopied] = tapState(false);\n const [isHovering, setIsHovering] = tapState(false);\n const [isEditing, setIsEditing] = tapState(false);\n\n const partClients = tapClientLookup(\n () =>\n message.content.map((part, idx) =>\n withKey(idx, PartResource({ part })),\n ),\n [message.content],\n );\n\n const attachmentClients = tapClientLookup(\n () =>\n (message.attachments ?? []).map((attachment) =>\n withKey(\n attachment.id,\n AttachmentResource({\n attachment,\n onRemove: () => {},\n }),\n ),\n ),\n [message.attachments],\n );\n\n const handleBeginEdit = () => {\n setIsEditing(true);\n };\n\n const handleCancelEdit = () => {\n setIsEditing(false);\n };\n\n const handleSendEdit = (msg: AppendMessage) => {\n queue?.clear(\"edit\");\n onEdit?.({\n ...msg,\n parentId: message.id,\n sourceId: message.id,\n });\n setIsEditing(false);\n };\n\n const composerClient = tapClientResource(\n ComposerClientResource({\n type: \"edit\",\n isEditing,\n canCancel: true,\n onCancel: handleCancelEdit,\n onBeginEdit: handleBeginEdit,\n onSend: handleSendEdit,\n message,\n queue,\n }),\n );\n\n const state = tapMemo(() => {\n return {\n ...message,\n attachments: message.attachments ?? [],\n parentId: null,\n isLast: false, // Will be set by thread\n branchNumber: 1,\n branchCount: 1,\n speech: undefined,\n parts: partClients.state,\n isCopied,\n isHovering,\n index,\n composer: composerClient.state,\n };\n }, [\n message,\n isCopied,\n isHovering,\n index,\n composerClient.state,\n partClients.state,\n ]);\n\n return {\n getState: () => state,\n composer: () => composerClient.methods,\n reload: () => {\n onReload?.();\n },\n speak: () => {},\n stopSpeaking: () => {},\n submitFeedback: () => {},\n switchToBranch: () => {},\n getCopyText: () =>\n message.content.map((c) => (\"text\" in c ? c.text : \"\")).join(\"\"),\n part: (selector) => {\n if (\"index\" in selector) {\n return partClients.get(selector);\n }\n const partIndex = state.parts.findIndex(\n (p) => p.type === \"tool-call\" && p.toolCallId === selector.toolCallId,\n );\n return partClients.get({ index: partIndex });\n },\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachmentClients.get({ key: selector.id });\n }\n return attachmentClients.get(selector);\n },\n setIsCopied,\n setIsHovering,\n };\n },\n);\n\ntype PartResourceProps = {\n part: ThreadAssistantMessagePart | ThreadUserMessagePart;\n};\n\n// Part Client - minimal implementation\nconst PartResource = resource(\n ({ part }: PartResourceProps): ClientOutput<\"part\"> => {\n const state = tapMemo(\n () => ({\n ...part,\n status: { type: \"complete\" as const },\n }),\n [part],\n );\n\n return {\n getState: () => state,\n addToolResult: () => {},\n resumeToolCall: () => {},\n };\n },\n);\n\ntype AttachmentResourceProps = {\n attachment: Attachment;\n onRemove?: () => void;\n};\n\n// Attachment Client - minimal implementation\nconst AttachmentResource = resource(\n ({\n attachment,\n onRemove,\n }: AttachmentResourceProps): ClientOutput<\"attachment\"> => {\n return {\n getState: () => attachment,\n remove: async () => {\n onRemove?.();\n },\n };\n },\n);\n\ntype ComposerClientResourceProps = {\n type: \"thread\" | \"edit\";\n isEditing: boolean;\n canCancel: boolean;\n isSendDisabled?: boolean;\n onCancel: () => void;\n onBeginEdit?: () => void;\n onSend?: (message: AppendMessage) => void;\n message?: ExternalThreadMessage;\n queue?: ExternalThreadQueueAdapter | undefined;\n};\n\nconst QueueItemClient = resource(\n ({\n item,\n onSteer,\n onRemove,\n }: {\n item: QueueItemState;\n onSteer: () => void;\n onRemove: () => void;\n }): ClientOutput<\"queueItem\"> => {\n return {\n getState: () => item,\n steer: onSteer,\n remove: onRemove,\n };\n },\n);\n\n// Composer Client - minimal implementation\nconst ComposerClientResource = resource(\n ({\n type,\n isEditing,\n canCancel,\n isSendDisabled = false,\n onCancel,\n onBeginEdit,\n onSend,\n message,\n queue,\n }: ComposerClientResourceProps): ClientOutput<\"composer\"> => {\n const [text, setText] = tapState(\"\");\n const [role, setRole] = tapState<\"user\" | \"assistant\" | \"system\">(\"user\");\n const [runConfig, setRunConfig] = tapState<Record<string, unknown>>({});\n const [attachments, setAttachments] = tapState<readonly Attachment[]>([]);\n const [quote, setQuote] = tapState<\n { readonly text: string; readonly messageId: string } | undefined\n >(undefined);\n\n // Update composer values when editing begins\n const updateFromMessage = tapEffectEvent(() => {\n if (message) {\n // Extract text from message content (text parts only)\n const textParts = message.content.filter(\n (part) => part.type === \"text\",\n );\n const messageText = textParts\n .map((part) => (\"text\" in part ? part.text : \"\"))\n .join(\"\\n\\n\");\n\n setText(messageText);\n setRole(message.role);\n setAttachments(message.attachments ?? []);\n }\n });\n\n tapEffect(() => {\n if (isEditing) {\n updateFromMessage();\n }\n }, [isEditing]);\n\n const attachmentClients = tapClientLookup(\n () =>\n attachments.map((attachment, idx) =>\n withKey(\n attachment.id,\n AttachmentResource({\n attachment,\n onRemove: () => {\n setAttachments(attachments.filter((_, i) => i !== idx));\n },\n }),\n ),\n ),\n [attachments],\n );\n\n const queueItems = queue?.items ?? EMPTY_QUEUE_ITEMS;\n const queueItemClients = tapClientLookup(\n () =>\n queueItems.map((item) =>\n withKey(\n item.id,\n QueueItemClient({\n item,\n onSteer: () => queue?.steer(item.id),\n onRemove: () => queue?.remove(item.id),\n }),\n ),\n ),\n [queueItems],\n );\n\n const state = tapMemo(() => {\n const isEmpty = !text.trim() && !attachments.length;\n return {\n text,\n role,\n attachments: attachmentClients.state,\n runConfig,\n isEditing,\n canCancel,\n canSend: isEditing && !isEmpty && !isSendDisabled,\n attachmentAccept: \"*\",\n isEmpty,\n type,\n dictation: undefined,\n quote,\n queue: queueItems,\n };\n }, [\n text,\n role,\n attachmentClients.state,\n runConfig,\n isEditing,\n canCancel,\n isSendDisabled,\n type,\n attachments.length,\n quote,\n queueItems,\n ]);\n\n return {\n getState: () => state,\n setText,\n setRole,\n setRunConfig,\n addAttachment: async (fileOrAttachment: File | CreateAttachment) => {\n if (fileOrAttachment instanceof File) {\n const newAttachment: Attachment = {\n id: Math.random().toString(36).substring(7),\n type: \"file\",\n name: fileOrAttachment.name,\n contentType: fileOrAttachment.type,\n file: fileOrAttachment,\n status: { type: \"complete\" },\n content: [],\n };\n setAttachments([...attachments, newAttachment]);\n } else {\n const newAttachment: Attachment = {\n id: fileOrAttachment.id ?? Math.random().toString(36).substring(7),\n type: fileOrAttachment.type ?? \"document\",\n name: fileOrAttachment.name,\n contentType: fileOrAttachment.contentType,\n content: fileOrAttachment.content,\n status: { type: \"complete\" },\n };\n setAttachments([...attachments, newAttachment]);\n }\n },\n clearAttachments: async () => {\n setAttachments([]);\n },\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachmentClients.get({ key: selector.id });\n }\n return attachmentClients.get(selector);\n },\n reset: async () => {\n setText(\"\");\n setRole(\"user\");\n setRunConfig({});\n setAttachments([]);\n setQuote(undefined);\n },\n send: (opts?: ComposerSendOptions) => {\n if (!state.canSend) return;\n\n const currentQuote = quote;\n const composedMessage: AppendMessage = {\n role,\n content: text ? [{ type: \"text\" as const, text }] : [],\n attachments: attachments as any,\n createdAt: new Date(),\n parentId: null,\n sourceId: null,\n runConfig,\n startRun: opts?.startRun,\n metadata: {\n custom: { ...(currentQuote ? { quote: currentQuote } : {}) },\n },\n };\n if (queue) {\n queue.enqueue(composedMessage, { steer: opts?.steer ?? false });\n } else {\n onSend?.(composedMessage);\n }\n setText(\"\");\n setAttachments([]);\n setQuote(undefined);\n },\n cancel: onCancel,\n beginEdit: () => {\n onBeginEdit?.();\n },\n startDictation: () => {},\n stopDictation: () => {},\n setQuote,\n queueItem: (selector: { index: number }) => {\n return queueItemClients.get(selector);\n },\n };\n },\n);\n\n// External Thread Client\nexport const ExternalThread = resource(\n ({\n messages,\n isRunning = false,\n isSendDisabled = false,\n onNew,\n onEdit,\n onReload,\n onStartRun,\n onCancel,\n queue,\n }: ExternalThreadProps): ClientOutput<\"thread\"> => {\n const handleReload = (messageId: string) => {\n const messageIndex = messages.findIndex((m) => m.id === messageId);\n if (messageIndex === -1) return;\n\n const parentId = messageIndex > 0 ? messages[messageIndex - 1]!.id : null;\n queue?.clear(\"reload\");\n onReload?.(parentId);\n };\n\n const messageClients = tapClientLookup(\n () =>\n messages.map((msg, index) => {\n const props: MessageClientProps = {\n message: msg,\n index,\n onReload: () => handleReload(msg.id),\n queue,\n };\n if (onEdit) props.onEdit = onEdit;\n return withKey(msg.id, MessageClient(props));\n }),\n [messages, onEdit, queue],\n );\n\n const handleCancelRun = () => {\n queue?.clear(\"cancel-run\");\n onCancel?.();\n };\n\n const handleSendNew = (message: AppendMessage) => {\n onNew?.(message);\n };\n\n const composerClient = tapClientResource(\n ComposerClientResource({\n type: \"thread\",\n isEditing: true,\n canCancel: isRunning,\n isSendDisabled,\n onCancel: handleCancelRun,\n onSend: handleSendNew,\n queue,\n }),\n );\n\n const hasQueue = !!queue;\n const state = tapMemo(() => {\n const messageStates = messageClients.state.map((s, idx, arr) => ({\n ...s,\n isLast: idx === arr.length - 1,\n }));\n\n return {\n isEmpty: messages.length === 0,\n isDisabled: false,\n isLoading: false,\n isRunning,\n capabilities: {\n edit: false,\n reload: false,\n cancel: isRunning,\n speech: false,\n attachments: false,\n feedback: false,\n voice: false,\n switchToBranch: false,\n switchBranchDuringRun: false,\n unstable_copy: false,\n dictation: false,\n queue: hasQueue,\n },\n messages: messageStates,\n state: {},\n suggestions: [],\n extras: undefined,\n speech: undefined,\n voice: undefined,\n composer: composerClient.state,\n };\n }, [\n messages,\n isRunning,\n hasQueue,\n messageClients.state,\n composerClient.state,\n ]);\n\n return {\n getState: () => state,\n composer: () => composerClient.methods,\n append: (message) => {\n const appendMessage: AppendMessage =\n typeof message === \"string\"\n ? {\n createdAt: new Date(),\n parentId: messages.at(-1)?.id ?? null,\n sourceId: null,\n runConfig: {},\n role: \"user\",\n content: [{ type: \"text\", text: message }],\n attachments: [],\n metadata: { custom: {} },\n }\n : {\n createdAt: message.createdAt ?? new Date(),\n parentId: message.parentId ?? messages.at(-1)?.id ?? null,\n sourceId: message.sourceId ?? null,\n role: message.role ?? \"user\",\n content: message.content,\n attachments: message.attachments ?? [],\n metadata: message.metadata ?? { custom: {} },\n runConfig: message.runConfig ?? {},\n startRun: message.startRun,\n };\n if (queue) {\n queue.enqueue(appendMessage, { steer: false });\n } else {\n onNew?.(appendMessage);\n }\n },\n startRun: () => {\n onStartRun?.();\n },\n resumeRun: () => {},\n cancelRun: handleCancelRun,\n getModelContext: () => ({ tools: {}, config: {} }),\n export: () => ({ messages: [] }),\n import: () => {},\n reset: () => {},\n message: (selector) => {\n if (\"id\" in selector) {\n return messageClients.get({ key: selector.id });\n }\n return messageClients.get(selector);\n },\n stopSpeaking: () => {},\n connectVoice: () => {},\n disconnectVoice: () => {},\n getVoiceVolume: () => 0,\n subscribeVoiceVolume: () => () => {},\n muteVoice: () => {},\n unmuteVoice: () => {},\n };\n },\n);\n\nattachTransformScopes(ExternalThread, (scopes, parent) => {\n if (!scopes.threads && parent.threads.source === null) {\n const threadElement = scopes.thread as ClientElement<\"thread\">;\n scopes.threads = SingleThreadList({ thread: threadElement });\n scopes.thread = Derived({\n source: \"threads\",\n query: { type: \"main\" },\n get: (aui) => aui.threads().thread(\"main\"),\n });\n }\n\n if (!scopes.threadListItem && parent.threadListItem.source === null) {\n scopes.threadListItem = Derived({\n source: \"threads\",\n query: { type: \"main\" },\n get: (aui) => aui.threads().item(\"main\"),\n });\n }\n\n scopes.composer ??= Derived({\n source: \"thread\",\n query: {},\n get: (aui) => aui.thread().composer(),\n });\n\n if (!scopes.modelContext && parent.modelContext.source === null) {\n scopes.modelContext = ModelContext();\n }\n if (!scopes.tools && parent.tools.source === null) {\n scopes.tools = Tools({});\n }\n if (!scopes.dataRenderers && parent.dataRenderers.source === null) {\n scopes.dataRenderers = DataRenderers();\n }\n if (!scopes.suggestions && parent.suggestions.source === null) {\n scopes.suggestions = Suggestions();\n }\n});\n"],"mappings":";;;;;;AA8BA,MAAM,oBAA+C,CAAC;AAmDtD,MAAM,gBAAgB,UACnB,EACC,SACA,OACA,QACA,UACA,YACiD;CACjD,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAClD,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAEhD,MAAM,cAAc,sBAEhB,QAAQ,QAAQ,KAAK,MAAM,QACzB,QAAQ,KAAK,aAAa,EAAE,KAAK,CAAC,CAAC,CACrC,GACF,CAAC,QAAQ,OAAO,CAClB;CAEA,MAAM,oBAAoB,uBAErB,QAAQ,eAAe,CAAC,GAAG,KAAK,eAC/B,QACE,WAAW,IACX,mBAAmB;EACjB;EACA,gBAAgB,CAAC;CACnB,CAAC,CACH,CACF,GACF,CAAC,QAAQ,WAAW,CACtB;CAEA,MAAM,wBAAwB;EAC5B,aAAa,IAAI;CACnB;CAEA,MAAM,yBAAyB;EAC7B,aAAa,KAAK;CACpB;CAEA,MAAM,kBAAkB,QAAuB;EAC7C,OAAO,MAAM,MAAM;EACnB,SAAS;GACP,GAAG;GACH,UAAU,QAAQ;GAClB,UAAU,QAAQ;EACpB,CAAC;EACD,aAAa,KAAK;CACpB;CAEA,MAAM,iBAAiB,kBACrB,uBAAuB;EACrB,MAAM;EACN;EACA,WAAW;EACX,UAAU;EACV,aAAa;EACb,QAAQ;EACR;EACA;CACF,CAAC,CACH;CAEA,MAAM,QAAQ,cAAc;EAC1B,OAAO;GACL,GAAG;GACH,aAAa,QAAQ,eAAe,CAAC;GACrC,UAAU;GACV,QAAQ;GACR,cAAc;GACd,aAAa;GACb,QAAQ,KAAA;GACR,OAAO,YA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C,IAAI,CAAC,OAAO,SAAS,OAAO,MAAM,WAAW,MAC3C,OAAO,QAAQ,MAAM,CAAC,CAAC;CAEzB,IAAI,CAAC,OAAO,iBAAiB,OAAO,cAAc,WAAW,MAC3D,OAAO,gBAAgB,cAAc;CAEvC,IAAI,CAAC,OAAO,eAAe,OAAO,YAAY,WAAW,MACvD,OAAO,cAAc,YAAY;AAErC,CAAC"}
1
+ {"version":3,"file":"ExternalThread.js","names":[],"sources":["../../src/client/ExternalThread.ts"],"sourcesContent":["import {\n resource,\n tapState,\n tapMemo,\n tapEffect,\n tapEffectEvent,\n} from \"@assistant-ui/tap\";\nimport {\n type ClientElement,\n type ClientOutput,\n tapClientLookup,\n attachTransformScopes,\n tapClientResource,\n Derived,\n} from \"@assistant-ui/store\";\nimport { withKey } from \"@assistant-ui/tap\";\nimport type {\n AppendMessage,\n Attachment,\n CreateAttachment,\n ThreadAssistantMessagePart,\n ThreadUserMessagePart,\n ThreadMessage,\n} from \"@assistant-ui/core\";\nimport type { QueueItemState } from \"@assistant-ui/core/store\";\nimport type { ComposerSendOptions } from \"@assistant-ui/core/store\";\nimport { ModelContext, Suggestions } from \"@assistant-ui/core/store\";\nimport { Tools, DataRenderers } from \"@assistant-ui/core/react\";\nimport { SingleThreadList } from \"./SingleThreadList\";\n\nconst EMPTY_QUEUE_ITEMS: readonly QueueItemState[] = [];\n\nexport type ExternalThreadMessage = ThreadMessage & {\n id: string;\n};\n\nexport type ExternalThreadQueueAdapter = {\n /** The current queue items. */\n items: readonly QueueItemState[];\n /** Called when a message is submitted via the composer. Receives the steer preference. */\n enqueue: (message: AppendMessage, opts: { steer: boolean }) => void;\n /** Called to promote an existing queue item (cancel current run, run this immediately). */\n steer: (queueItemId: string) => void;\n /** Called to remove an item from the queue. */\n remove: (queueItemId: string) => void;\n /** Called to clear all pending queue items, with the reason for clearing. */\n clear: (reason: \"edit\" | \"reload\" | \"cancel-run\") => void;\n};\n\nexport type ExternalThreadProps = {\n messages: readonly ExternalThreadMessage[];\n isRunning?: boolean;\n /**\n * Whether sending new messages is currently disabled. When `true`, the\n * thread composer's input remains usable but `send()` is a no-op and\n * `composer.canSend` is `false`. Edit composers (saving message edits)\n * intentionally ignore this flag.\n */\n isSendDisabled?: boolean;\n /**\n * Callback for new messages (non-queue runtimes).\n * @note Unused when `queue` is provided — new messages are routed through `queue.enqueue` instead.\n */\n onNew?: (message: AppendMessage) => void;\n onEdit?: (message: AppendMessage) => void;\n onReload?: (parentId: string | null) => void;\n onStartRun?: () => void;\n onCancel?: () => void;\n /** Queue adapter for runtimes that support message queuing and steering. */\n queue?: ExternalThreadQueueAdapter;\n};\n\ntype MessageClientProps = {\n message: ExternalThreadMessage;\n index: number;\n onEdit?: (message: AppendMessage) => void;\n onReload?: () => void;\n queue?: ExternalThreadQueueAdapter | undefined;\n};\n\n// Message Client - minimal implementation\nconst MessageClient = resource(\n ({\n message,\n index,\n onEdit,\n onReload,\n queue,\n }: MessageClientProps): ClientOutput<\"message\"> => {\n const [isCopied, setIsCopied] = tapState(false);\n const [isHovering, setIsHovering] = tapState(false);\n const [isEditing, setIsEditing] = tapState(false);\n\n const partClients = tapClientLookup(\n () =>\n message.content.map((part, idx) =>\n withKey(idx, PartResource({ part })),\n ),\n [message.content],\n );\n\n const attachmentClients = tapClientLookup(\n () =>\n (message.attachments ?? []).map((attachment) =>\n withKey(\n attachment.id,\n AttachmentResource({\n attachment,\n onRemove: () => {},\n }),\n ),\n ),\n [message.attachments],\n );\n\n const handleBeginEdit = () => {\n setIsEditing(true);\n };\n\n const handleCancelEdit = () => {\n setIsEditing(false);\n };\n\n const handleSendEdit = (msg: AppendMessage) => {\n queue?.clear(\"edit\");\n onEdit?.({\n ...msg,\n parentId: message.id,\n sourceId: message.id,\n });\n setIsEditing(false);\n };\n\n const composerClient = tapClientResource(\n ComposerClientResource({\n type: \"edit\",\n isEditing,\n canCancel: true,\n onCancel: handleCancelEdit,\n onBeginEdit: handleBeginEdit,\n onSend: handleSendEdit,\n message,\n queue,\n }),\n );\n\n const state = tapMemo(() => {\n return {\n ...message,\n attachments: message.attachments ?? [],\n parentId: null,\n isLast: false, // Will be set by thread\n branchNumber: 1,\n branchCount: 1,\n speech: undefined,\n parts: partClients.state,\n isCopied,\n isHovering,\n index,\n composer: composerClient.state,\n };\n }, [\n message,\n isCopied,\n isHovering,\n index,\n composerClient.state,\n partClients.state,\n ]);\n\n return {\n getState: () => state,\n composer: () => composerClient.methods,\n reload: () => {\n onReload?.();\n },\n speak: () => {},\n stopSpeaking: () => {},\n submitFeedback: () => {},\n switchToBranch: () => {},\n getCopyText: () =>\n message.content.map((c) => (\"text\" in c ? c.text : \"\")).join(\"\"),\n part: (selector) => {\n if (\"index\" in selector) {\n return partClients.get(selector);\n }\n const partIndex = state.parts.findIndex(\n (p) => p.type === \"tool-call\" && p.toolCallId === selector.toolCallId,\n );\n return partClients.get({ index: partIndex });\n },\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachmentClients.get({ key: selector.id });\n }\n return attachmentClients.get(selector);\n },\n setIsCopied,\n setIsHovering,\n };\n },\n);\n\ntype PartResourceProps = {\n part: ThreadAssistantMessagePart | ThreadUserMessagePart;\n};\n\n// Part Client - minimal implementation\nconst PartResource = resource(\n ({ part }: PartResourceProps): ClientOutput<\"part\"> => {\n const state = tapMemo(\n () => ({\n ...part,\n status: { type: \"complete\" as const },\n }),\n [part],\n );\n\n return {\n getState: () => state,\n addToolResult: () => {},\n resumeToolCall: () => {},\n respondToToolApproval: () => {},\n };\n },\n);\n\ntype AttachmentResourceProps = {\n attachment: Attachment;\n onRemove?: () => void;\n};\n\n// Attachment Client - minimal implementation\nconst AttachmentResource = resource(\n ({\n attachment,\n onRemove,\n }: AttachmentResourceProps): ClientOutput<\"attachment\"> => {\n return {\n getState: () => attachment,\n remove: async () => {\n onRemove?.();\n },\n };\n },\n);\n\ntype ComposerClientResourceProps = {\n type: \"thread\" | \"edit\";\n isEditing: boolean;\n canCancel: boolean;\n isSendDisabled?: boolean;\n onCancel: () => void;\n onBeginEdit?: () => void;\n onSend?: (message: AppendMessage) => void;\n message?: ExternalThreadMessage;\n queue?: ExternalThreadQueueAdapter | undefined;\n};\n\nconst QueueItemClient = resource(\n ({\n item,\n onSteer,\n onRemove,\n }: {\n item: QueueItemState;\n onSteer: () => void;\n onRemove: () => void;\n }): ClientOutput<\"queueItem\"> => {\n return {\n getState: () => item,\n steer: onSteer,\n remove: onRemove,\n };\n },\n);\n\n// Composer Client - minimal implementation\nconst ComposerClientResource = resource(\n ({\n type,\n isEditing,\n canCancel,\n isSendDisabled = false,\n onCancel,\n onBeginEdit,\n onSend,\n message,\n queue,\n }: ComposerClientResourceProps): ClientOutput<\"composer\"> => {\n const [text, setText] = tapState(\"\");\n const [role, setRole] = tapState<\"user\" | \"assistant\" | \"system\">(\"user\");\n const [runConfig, setRunConfig] = tapState<Record<string, unknown>>({});\n const [attachments, setAttachments] = tapState<readonly Attachment[]>([]);\n const [quote, setQuote] = tapState<\n { readonly text: string; readonly messageId: string } | undefined\n >(undefined);\n\n // Update composer values when editing begins\n const updateFromMessage = tapEffectEvent(() => {\n if (message) {\n // Extract text from message content (text parts only)\n const textParts = message.content.filter(\n (part) => part.type === \"text\",\n );\n const messageText = textParts\n .map((part) => (\"text\" in part ? part.text : \"\"))\n .join(\"\\n\\n\");\n\n setText(messageText);\n setRole(message.role);\n setAttachments(message.attachments ?? []);\n }\n });\n\n tapEffect(() => {\n if (isEditing) {\n updateFromMessage();\n }\n }, [isEditing]);\n\n const attachmentClients = tapClientLookup(\n () =>\n attachments.map((attachment, idx) =>\n withKey(\n attachment.id,\n AttachmentResource({\n attachment,\n onRemove: () => {\n setAttachments(attachments.filter((_, i) => i !== idx));\n },\n }),\n ),\n ),\n [attachments],\n );\n\n const queueItems = queue?.items ?? EMPTY_QUEUE_ITEMS;\n const queueItemClients = tapClientLookup(\n () =>\n queueItems.map((item) =>\n withKey(\n item.id,\n QueueItemClient({\n item,\n onSteer: () => queue?.steer(item.id),\n onRemove: () => queue?.remove(item.id),\n }),\n ),\n ),\n [queueItems],\n );\n\n const state = tapMemo(() => {\n const isEmpty = !text.trim() && !attachments.length;\n return {\n text,\n role,\n attachments: attachmentClients.state,\n runConfig,\n isEditing,\n canCancel,\n canSend: isEditing && !isEmpty && !isSendDisabled,\n attachmentAccept: \"*\",\n isEmpty,\n type,\n dictation: undefined,\n quote,\n queue: queueItems,\n };\n }, [\n text,\n role,\n attachmentClients.state,\n runConfig,\n isEditing,\n canCancel,\n isSendDisabled,\n type,\n attachments.length,\n quote,\n queueItems,\n ]);\n\n return {\n getState: () => state,\n setText,\n setRole,\n setRunConfig,\n addAttachment: async (fileOrAttachment: File | CreateAttachment) => {\n if (fileOrAttachment instanceof File) {\n const newAttachment: Attachment = {\n id: Math.random().toString(36).substring(7),\n type: \"file\",\n name: fileOrAttachment.name,\n contentType: fileOrAttachment.type,\n file: fileOrAttachment,\n status: { type: \"complete\" },\n content: [],\n };\n setAttachments([...attachments, newAttachment]);\n } else {\n const newAttachment: Attachment = {\n id: fileOrAttachment.id ?? Math.random().toString(36).substring(7),\n type: fileOrAttachment.type ?? \"document\",\n name: fileOrAttachment.name,\n contentType: fileOrAttachment.contentType,\n content: fileOrAttachment.content,\n status: { type: \"complete\" },\n };\n setAttachments([...attachments, newAttachment]);\n }\n },\n clearAttachments: async () => {\n setAttachments([]);\n },\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachmentClients.get({ key: selector.id });\n }\n return attachmentClients.get(selector);\n },\n reset: async () => {\n setText(\"\");\n setRole(\"user\");\n setRunConfig({});\n setAttachments([]);\n setQuote(undefined);\n },\n send: (opts?: ComposerSendOptions) => {\n if (!state.canSend) return;\n\n const currentQuote = quote;\n const composedMessage: AppendMessage = {\n role,\n content: text ? [{ type: \"text\" as const, text }] : [],\n attachments: attachments as any,\n createdAt: new Date(),\n parentId: null,\n sourceId: null,\n runConfig,\n startRun: opts?.startRun,\n metadata: {\n custom: { ...(currentQuote ? { quote: currentQuote } : {}) },\n },\n };\n if (queue) {\n queue.enqueue(composedMessage, { steer: opts?.steer ?? false });\n } else {\n onSend?.(composedMessage);\n }\n setText(\"\");\n setAttachments([]);\n setQuote(undefined);\n },\n cancel: onCancel,\n beginEdit: () => {\n onBeginEdit?.();\n },\n startDictation: () => {},\n stopDictation: () => {},\n setQuote,\n queueItem: (selector: { index: number }) => {\n return queueItemClients.get(selector);\n },\n };\n },\n);\n\n// External Thread Client\nexport const ExternalThread = resource(\n ({\n messages,\n isRunning = false,\n isSendDisabled = false,\n onNew,\n onEdit,\n onReload,\n onStartRun,\n onCancel,\n queue,\n }: ExternalThreadProps): ClientOutput<\"thread\"> => {\n const handleReload = (messageId: string) => {\n const messageIndex = messages.findIndex((m) => m.id === messageId);\n if (messageIndex === -1) return;\n\n const parentId = messageIndex > 0 ? messages[messageIndex - 1]!.id : null;\n queue?.clear(\"reload\");\n onReload?.(parentId);\n };\n\n const messageClients = tapClientLookup(\n () =>\n messages.map((msg, index) => {\n const props: MessageClientProps = {\n message: msg,\n index,\n onReload: () => handleReload(msg.id),\n queue,\n };\n if (onEdit) props.onEdit = onEdit;\n return withKey(msg.id, MessageClient(props));\n }),\n [messages, onEdit, queue],\n );\n\n const handleCancelRun = () => {\n queue?.clear(\"cancel-run\");\n onCancel?.();\n };\n\n const handleSendNew = (message: AppendMessage) => {\n onNew?.(message);\n };\n\n const composerClient = tapClientResource(\n ComposerClientResource({\n type: \"thread\",\n isEditing: true,\n canCancel: isRunning,\n isSendDisabled,\n onCancel: handleCancelRun,\n onSend: handleSendNew,\n queue,\n }),\n );\n\n const hasQueue = !!queue;\n const state = tapMemo(() => {\n const messageStates = messageClients.state.map((s, idx, arr) => ({\n ...s,\n isLast: idx === arr.length - 1,\n }));\n\n return {\n isEmpty: messages.length === 0,\n isDisabled: false,\n isLoading: false,\n isRunning,\n capabilities: {\n edit: false,\n reload: false,\n cancel: isRunning,\n speech: false,\n attachments: false,\n feedback: false,\n voice: false,\n switchToBranch: false,\n switchBranchDuringRun: false,\n unstable_copy: false,\n dictation: false,\n queue: hasQueue,\n },\n messages: messageStates,\n state: {},\n suggestions: [],\n extras: undefined,\n speech: undefined,\n voice: undefined,\n composer: composerClient.state,\n };\n }, [\n messages,\n isRunning,\n hasQueue,\n messageClients.state,\n composerClient.state,\n ]);\n\n return {\n getState: () => state,\n composer: () => composerClient.methods,\n append: (message) => {\n const appendMessage: AppendMessage =\n typeof message === \"string\"\n ? {\n createdAt: new Date(),\n parentId: messages.at(-1)?.id ?? null,\n sourceId: null,\n runConfig: {},\n role: \"user\",\n content: [{ type: \"text\", text: message }],\n attachments: [],\n metadata: { custom: {} },\n }\n : {\n createdAt: message.createdAt ?? new Date(),\n parentId: message.parentId ?? messages.at(-1)?.id ?? null,\n sourceId: message.sourceId ?? null,\n role: message.role ?? \"user\",\n content: message.content,\n attachments: message.attachments ?? [],\n metadata: message.metadata ?? { custom: {} },\n runConfig: message.runConfig ?? {},\n startRun: message.startRun,\n };\n if (queue) {\n queue.enqueue(appendMessage, { steer: false });\n } else {\n onNew?.(appendMessage);\n }\n },\n startRun: () => {\n onStartRun?.();\n },\n resumeRun: () => {},\n cancelRun: handleCancelRun,\n getModelContext: () => ({ tools: {}, config: {} }),\n export: () => ({ messages: [] }),\n import: () => {},\n reset: () => {},\n message: (selector) => {\n if (\"id\" in selector) {\n return messageClients.get({ key: selector.id });\n }\n return messageClients.get(selector);\n },\n stopSpeaking: () => {},\n connectVoice: () => {},\n disconnectVoice: () => {},\n getVoiceVolume: () => 0,\n subscribeVoiceVolume: () => () => {},\n muteVoice: () => {},\n unmuteVoice: () => {},\n };\n },\n);\n\nattachTransformScopes(ExternalThread, (scopes, parent) => {\n if (!scopes.threads && parent.threads.source === null) {\n const threadElement = scopes.thread as ClientElement<\"thread\">;\n scopes.threads = SingleThreadList({ thread: threadElement });\n scopes.thread = Derived({\n source: \"threads\",\n query: { type: \"main\" },\n get: (aui) => aui.threads().thread(\"main\"),\n });\n }\n\n if (!scopes.threadListItem && parent.threadListItem.source === null) {\n scopes.threadListItem = Derived({\n source: \"threads\",\n query: { type: \"main\" },\n get: (aui) => aui.threads().item(\"main\"),\n });\n }\n\n scopes.composer ??= Derived({\n source: \"thread\",\n query: {},\n get: (aui) => aui.thread().composer(),\n });\n\n if (!scopes.modelContext && parent.modelContext.source === null) {\n scopes.modelContext = ModelContext();\n }\n if (!scopes.tools && parent.tools.source === null) {\n scopes.tools = Tools({});\n }\n if (!scopes.dataRenderers && parent.dataRenderers.source === null) {\n scopes.dataRenderers = DataRenderers();\n }\n if (!scopes.suggestions && parent.suggestions.source === null) {\n scopes.suggestions = Suggestions();\n }\n});\n"],"mappings":";;;;;;AA8BA,MAAM,oBAA+C,CAAC;AAmDtD,MAAM,gBAAgB,UACnB,EACC,SACA,OACA,QACA,UACA,YACiD;CACjD,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAClD,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAEhD,MAAM,cAAc,sBAEhB,QAAQ,QAAQ,KAAK,MAAM,QACzB,QAAQ,KAAK,aAAa,EAAE,KAAK,CAAC,CAAC,CACrC,GACF,CAAC,QAAQ,OAAO,CAClB;CAEA,MAAM,oBAAoB,uBAErB,QAAQ,eAAe,CAAC,GAAG,KAAK,eAC/B,QACE,WAAW,IACX,mBAAmB;EACjB;EACA,gBAAgB,CAAC;CACnB,CAAC,CACH,CACF,GACF,CAAC,QAAQ,WAAW,CACtB;CAEA,MAAM,wBAAwB;EAC5B,aAAa,IAAI;CACnB;CAEA,MAAM,yBAAyB;EAC7B,aAAa,KAAK;CACpB;CAEA,MAAM,kBAAkB,QAAuB;EAC7C,OAAO,MAAM,MAAM;EACnB,SAAS;GACP,GAAG;GACH,UAAU,QAAQ;GAClB,UAAU,QAAQ;EACpB,CAAC;EACD,aAAa,KAAK;CACpB;CAEA,MAAM,iBAAiB,kBACrB,uBAAuB;EACrB,MAAM;EACN;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B,MAAM,QAAQ,IAAI,QAAQ,EAAE,KAAK,MAAM;CACzC,CAAC;CAGH,OAAO,aAAa,QAAQ;EAC1B,QAAQ;EACR,OAAO,CAAC;EACR,MAAM,QAAQ,IAAI,OAAO,EAAE,SAAS;CACtC,CAAC;CAED,IAAI,CAAC,OAAO,gBAAgB,OAAO,aAAa,WAAW,MACzD,OAAO,eAAe,aAAa;CAErC,IAAI,CAAC,OAAO,SAAS,OAAO,MAAM,WAAW,MAC3C,OAAO,QAAQ,MAAM,CAAC,CAAC;CAEzB,IAAI,CAAC,OAAO,iBAAiB,OAAO,cAAc,WAAW,MAC3D,OAAO,gBAAgB,cAAc;CAEvC,IAAI,CAAC,OAAO,eAAe,OAAO,YAAY,WAAW,MACvD,OAAO,cAAc,YAAY;AAErC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -74,9 +74,9 @@ import { McpAppRenderer, McpAppRendererOptions } from "./mcp-apps/McpAppRenderer
74
74
  import { McpAppsRemoteHost } from "./mcp-apps/McpAppsRemoteHost.js";
75
75
  import { getMcpAppFromToolPart } from "./mcp-apps/utils.js";
76
76
  import { AssistantClient, AssistantEventCallback, AssistantEventName, AssistantEventPayload, AssistantEventScope, AssistantEventSelector, AssistantState, AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
77
- import { AssistantContextConfig, AssistantDataUI, AssistantDataUIProps, AssistantInteractableProps, AssistantTool, AssistantToolProps, AssistantToolUI, AssistantToolUIProps, DataMessagePartComponent, DataMessagePartProps, DataRenderers, EmptyMessagePartComponent, EmptyMessagePartProps, EnrichedPartState, FileMessagePartComponent, FileMessagePartProps, GenerativeUIComponentRegistry, GenerativeUIMessagePartComponent, GenerativeUIMessagePartProps, GenerativeUIRender, GenerativeUIRenderError, GenerativeUIRenderProps, ImageMessagePartComponent, ImageMessagePartProps, Interactables, McpAppResourceOutput, PartState, QuoteMessagePartComponent, QuoteMessagePartProps, ReasoningGroupComponent, ReasoningGroupProps, ReasoningMessagePartComponent, ReasoningMessagePartProps, RuntimeAdapterProvider, RuntimeAdapters, SourceMessagePartComponent, SourceMessagePartProps, TextMessagePartComponent, TextMessagePartProps, ToolArgsStatus, ToolCallMessagePartComponent, ToolCallMessagePartProps, ToolDefinition, Toolkit, Tools, Unstable_AudioMessagePartComponent, Unstable_AudioMessagePartProps, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
77
+ import { AssistantContextConfig, AssistantDataUI, AssistantDataUIProps, AssistantInteractableProps, AssistantTool, AssistantToolProps, AssistantToolUI, AssistantToolUIProps, DataMessagePartComponent, DataMessagePartProps, DataRenderers, EmptyMessagePartComponent, EmptyMessagePartProps, EnrichedPartState, FileMessagePartComponent, FileMessagePartProps, GenerativeUIComponentRegistry, GenerativeUIMessagePartComponent, GenerativeUIMessagePartProps, GenerativeUIRender, GenerativeUIRenderError, GenerativeUIRenderProps, ImageMessagePartComponent, ImageMessagePartProps, Interactables, McpAppResourceOutput, PartState, QuoteMessagePartComponent, QuoteMessagePartProps, ReasoningGroupComponent, ReasoningGroupProps, ReasoningMessagePartComponent, ReasoningMessagePartProps, RuntimeAdapterProvider, RuntimeAdapters, SourceMessagePartComponent, SourceMessagePartProps, TextMessagePartComponent, TextMessagePartProps, ToolArgsStatus, ToolCallMessagePartComponent, ToolCallMessagePartProps, ToolDefinition, Toolkit, Tools, Unstable_AudioMessagePartComponent, Unstable_AudioMessagePartProps, groupPartByType, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
78
78
  import { AssistantCloud } from "assistant-cloud";
79
79
  import { AddToolResultOptions, AppendMessage, AssistantFrameHost, AssistantFrameProvider, AssistantRuntime, Attachment, AttachmentAdapter, AttachmentRuntime, AttachmentState, AttachmentStatus, ChatModelAdapter, ChatModelRunOptions, ChatModelRunResult, ChatModelRunUpdate, CompleteAttachment, ComposerRuntime, ComposerState, CompositeAttachmentAdapter, CreateAppendMessage, CreateAttachment, CreateResumeRunConfig, CreateStartRunConfig, DataMessagePart, DictationAdapter, DictationState, EditComposerRuntime, EditComposerState, ExportedMessageRepository, ExportedMessageRepositoryItem, ExternalStoreAdapter, ExternalStoreMessageConverter, ExternalStoreThreadData, ExternalStoreThreadListAdapter, FRAME_MESSAGE_CHANNEL, FeedbackAdapter, FileMessagePart, FrameMessage, FrameMessageType, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, GenericThreadHistoryAdapter, ImageMessagePart, InMemoryThreadListAdapter, LanguageModelConfig, LanguageModelV1CallSettings, LocalRuntimeOptionsBase, MessageFormatAdapter, MessageFormatItem, MessageFormatRepository, MessagePartRuntime, MessagePartState, MessagePartStatus, MessageRuntime, MessageState, MessageStatus, MessageStorageEntry, MessageTiming, ModelContext, ModelContextProvider, ModelContextRegistry, ModelContextRegistryInstructionHandle, ModelContextRegistryProviderHandle, ModelContextRegistryToolHandle, PendingAttachment, QuoteInfo, RealtimeVoiceAdapter, ReasoningMessagePart, RemoteThreadListAdapter, SerializedModelContext, SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SourceMessagePart, SourceProviderMetadata, SpeechSynthesisAdapter, SubmitFeedbackOptions, SuggestionAdapter, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadComposerRuntime, ThreadComposerState, ThreadHistoryAdapter, ThreadListItemRuntime, ThreadListItemState, ThreadListItemStatus, ThreadListRuntime, ThreadListState, ThreadMessage, ThreadMessageLike, ThreadRuntime, ThreadState, ThreadSuggestion, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolCallMessagePart, ToolCallMessagePartStatus, ToolModelContentPart, Unstable_AudioMessagePart, Unstable_DirectiveFormatter, Unstable_DirectiveSegment, Unstable_TriggerItem, Unsubscribe, VoiceSessionControls, VoiceSessionHelpers, VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, getExternalStoreMessages, mergeModelContexts, tool, unstable_defaultDirectiveFormatter } from "@assistant-ui/core";
80
80
  import { Tool } from "assistant-stream";
81
81
  import { ChainOfThoughtClient, ComposerSendOptions, ModelContext as ModelContextClient, QueueItemMethods, QueueItemState, SuggestionConfig, Suggestions } from "@assistant-ui/core/store";
82
- export { actionBarMore_d_exports as ActionBarMorePrimitive, actionBar_d_exports as ActionBarPrimitive, type AddToolResultOptions, type AppendMessage, type Assistant, type AssistantClient, AssistantCloud, type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantEventCallback, type AssistantEventName, type AssistantEventPayload, type AssistantEventScope, type AssistantEventSelector, AssistantFrameHost, AssistantFrameProvider, type AssistantInteractableProps, assistantModal_d_exports as AssistantModalPrimitive, type AssistantRuntime, AssistantRuntimeProvider, type AssistantState, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantTransportCommand, type AssistantTransportConnectionMetadata, type AssistantTransportProtocol, type Attachment, type AttachmentAdapter, attachment_d_exports as AttachmentPrimitive, type AttachmentRuntime, type AttachmentState, type AttachmentStatus, AuiIf, AuiProvider, branchPicker_d_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_d_exports as ChainOfThoughtPrimitive, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, CloudFileAttachmentAdapter, type CompleteAttachment, ComposerAttachmentByIndexProvider, composer_d_exports as ComposerPrimitive, type ComposerRuntime, type ComposerSendOptions, type ComposerState, CompositeAttachmentAdapter, type CreateAppendMessage, type CreateAttachment, type CreateResumeRunConfig, type CreateStartRunConfig, type DataMessagePart, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, DevToolsHooks, DevToolsProviderApi, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerState, type EmptyMessagePartComponent, type EmptyMessagePartProps, type EnrichedPartState, error_d_exports as ErrorPrimitive, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreMessageConverter, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, ExternalThread, type ExternalThreadMessage, type ExternalThreadProps, type ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, type FeedbackAdapter, type FileMessagePart, type FileMessagePartComponent, type FileMessagePartProps, type FrameMessage, type FrameMessageType, type GenerativeUIComponentRegistry, type GenerativeUIMessagePart, type GenerativeUIMessagePartComponent, type GenerativeUIMessagePartProps, type GenerativeUINode, GenerativeUIRender, GenerativeUIRenderError, type GenerativeUIRenderProps, type GenerativeUISpec, type GenericThreadHistoryAdapter, internal_d_exports as INTERNAL, type ImageMessagePart, type ImageMessagePartComponent, type ImageMessagePartProps, InMemoryThreadList, InMemoryThreadListAdapter, type InMemoryThreadListProps, Interactables, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptions, type LocalRuntimeOptionsBase, type McpAppDisplayMode, type McpAppHostContext, type McpAppHostInfo, type McpAppMetadata, McpAppRenderer, type McpAppRendererOptions, type McpAppResource, type McpAppResourceCSP, type McpAppResourceMeta, type McpAppResourceOutput, type McpAppSandboxConfig, type McpAppToolCallParams, type McpAppsHost, McpAppsRemoteHost, type McpAppsRemoteHostOptions, MessageAttachmentByIndexProvider, MessageByIndexProvider, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, messagePart_d_exports as MessagePartPrimitive, type MessagePartRuntime, type MessagePartState, type MessagePartStatus, message_d_exports as MessagePrimitive, MessageProvider, type MessageRuntime, type MessageState, type MessageStatus, type MessageStorageEntry, type MessageTiming, type ModelContext, ModelContextClient, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, PartByIndexProvider, type PartState, type PendingAttachment, type QueueItemMethods, queueItem_d_exports as QueueItemPrimitive, type QueueItemState, type QuoteInfo, type QuoteMessagePartComponent, type QuoteMessagePartProps, ReadonlyThreadProvider, type RealtimeVoiceAdapter, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePart, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, type RemoteThreadListAdapter, RuntimeAdapterProvider, type RuntimeAdapters, selectionToolbar_d_exports as SelectionToolbarPrimitive, type SendCommandsRequestBody, type SerializedModelContext, type SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, type SourceMessagePart, type SourceMessagePartComponent, type SourceMessagePartProps, type SourceProviderMetadata, type SpeechSynthesisAdapter, type SubmitFeedbackOptions, type SuggestionAdapter, SuggestionByIndexProvider, type SuggestionConfig, suggestion_d_exports as SuggestionPrimitive, Suggestions, type TextMessagePart, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadComposerState, type ThreadHistoryAdapter, ThreadListItemByIndexProvider, threadListItemMore_d_exports as ThreadListItemMorePrimitive, threadListItem_d_exports as ThreadListItemPrimitive, type ThreadListItemRuntime, ThreadListItemRuntimeProvider, type ThreadListItemState, type ThreadListItemStatus, threadList_d_exports as ThreadListPrimitive, type ThreadListRuntime, type ThreadListState, type ThreadMessage, type ThreadMessageLike, thread_d_exports as ThreadPrimitive, type ThreadRuntime, type ThreadState, type ThreadSuggestion, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ThreadViewportState, type Tool, type ToolArgsStatus, type ToolCallMessagePart, type ToolCallMessagePartComponent, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartProps, type ToolCallMessagePartStatus, type ToolDefinition, type ToolExecutionStatus, type ToolModelContentPart, type Toolkit, Tools, type Unstable_AudioMessagePart, type Unstable_AudioMessagePartComponent, type Unstable_AudioMessagePartProps, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_IconComponent, type Unstable_Mention, type Unstable_MentionCategory, type Unstable_MentionDirective, type Unstable_ModelContextToolsOptions, type RegisteredTrigger as Unstable_RegisteredTrigger, type Unstable_SlashCommand, type Unstable_SlashCommandAction, type TriggerBehavior as Unstable_TriggerBehavior, type Unstable_TriggerItem, type Unstable_UseMentionAdapterOptions, type Unstable_UseSlashCommandAdapterOptions, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, getExternalStoreMessages, getMcpAppFromToolPart, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, tool, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, unstable_useMentionAdapter, unstable_useSlashCommandAdapter, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantRuntime, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAttachment, useAttachmentRuntime, useAui, useAuiEvent, useAuiState, useCloudThreadListAdapter, useCloudThreadListRuntime, useComposer, useComposerRuntime, useEditComposer, useEditComposerAttachment, useEditComposerAttachmentRuntime, useExternalMessageConverter, useExternalStoreRuntime, useInlineRender, useInteractableState, useLocalRuntime, useMessage, useMessageAttachment, useMessageAttachmentRuntime, useMessagePart, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartRuntime, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageRuntime, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useThread, useThreadComposer, useThreadComposerAttachment, useThreadComposerAttachmentRuntime, useThreadList, useThreadListItem, useThreadListItemRuntime, useThreadModelContext, useThreadRuntime, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
82
+ export { actionBarMore_d_exports as ActionBarMorePrimitive, actionBar_d_exports as ActionBarPrimitive, type AddToolResultOptions, type AppendMessage, type Assistant, type AssistantClient, AssistantCloud, type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantEventCallback, type AssistantEventName, type AssistantEventPayload, type AssistantEventScope, type AssistantEventSelector, AssistantFrameHost, AssistantFrameProvider, type AssistantInteractableProps, assistantModal_d_exports as AssistantModalPrimitive, type AssistantRuntime, AssistantRuntimeProvider, type AssistantState, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantTransportCommand, type AssistantTransportConnectionMetadata, type AssistantTransportProtocol, type Attachment, type AttachmentAdapter, attachment_d_exports as AttachmentPrimitive, type AttachmentRuntime, type AttachmentState, type AttachmentStatus, AuiIf, AuiProvider, branchPicker_d_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_d_exports as ChainOfThoughtPrimitive, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, CloudFileAttachmentAdapter, type CompleteAttachment, ComposerAttachmentByIndexProvider, composer_d_exports as ComposerPrimitive, type ComposerRuntime, type ComposerSendOptions, type ComposerState, CompositeAttachmentAdapter, type CreateAppendMessage, type CreateAttachment, type CreateResumeRunConfig, type CreateStartRunConfig, type DataMessagePart, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, DevToolsHooks, DevToolsProviderApi, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerState, type EmptyMessagePartComponent, type EmptyMessagePartProps, type EnrichedPartState, error_d_exports as ErrorPrimitive, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreMessageConverter, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, ExternalThread, type ExternalThreadMessage, type ExternalThreadProps, type ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, type FeedbackAdapter, type FileMessagePart, type FileMessagePartComponent, type FileMessagePartProps, type FrameMessage, type FrameMessageType, type GenerativeUIComponentRegistry, type GenerativeUIMessagePart, type GenerativeUIMessagePartComponent, type GenerativeUIMessagePartProps, type GenerativeUINode, GenerativeUIRender, GenerativeUIRenderError, type GenerativeUIRenderProps, type GenerativeUISpec, type GenericThreadHistoryAdapter, internal_d_exports as INTERNAL, type ImageMessagePart, type ImageMessagePartComponent, type ImageMessagePartProps, InMemoryThreadList, InMemoryThreadListAdapter, type InMemoryThreadListProps, Interactables, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptions, type LocalRuntimeOptionsBase, type McpAppDisplayMode, type McpAppHostContext, type McpAppHostInfo, type McpAppMetadata, McpAppRenderer, type McpAppRendererOptions, type McpAppResource, type McpAppResourceCSP, type McpAppResourceMeta, type McpAppResourceOutput, type McpAppSandboxConfig, type McpAppToolCallParams, type McpAppsHost, McpAppsRemoteHost, type McpAppsRemoteHostOptions, MessageAttachmentByIndexProvider, MessageByIndexProvider, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, messagePart_d_exports as MessagePartPrimitive, type MessagePartRuntime, type MessagePartState, type MessagePartStatus, message_d_exports as MessagePrimitive, MessageProvider, type MessageRuntime, type MessageState, type MessageStatus, type MessageStorageEntry, type MessageTiming, type ModelContext, ModelContextClient, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, PartByIndexProvider, type PartState, type PendingAttachment, type QueueItemMethods, queueItem_d_exports as QueueItemPrimitive, type QueueItemState, type QuoteInfo, type QuoteMessagePartComponent, type QuoteMessagePartProps, ReadonlyThreadProvider, type RealtimeVoiceAdapter, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePart, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, type RemoteThreadListAdapter, RuntimeAdapterProvider, type RuntimeAdapters, selectionToolbar_d_exports as SelectionToolbarPrimitive, type SendCommandsRequestBody, type SerializedModelContext, type SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, type SourceMessagePart, type SourceMessagePartComponent, type SourceMessagePartProps, type SourceProviderMetadata, type SpeechSynthesisAdapter, type SubmitFeedbackOptions, type SuggestionAdapter, SuggestionByIndexProvider, type SuggestionConfig, suggestion_d_exports as SuggestionPrimitive, Suggestions, type TextMessagePart, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadComposerState, type ThreadHistoryAdapter, ThreadListItemByIndexProvider, threadListItemMore_d_exports as ThreadListItemMorePrimitive, threadListItem_d_exports as ThreadListItemPrimitive, type ThreadListItemRuntime, ThreadListItemRuntimeProvider, type ThreadListItemState, type ThreadListItemStatus, threadList_d_exports as ThreadListPrimitive, type ThreadListRuntime, type ThreadListState, type ThreadMessage, type ThreadMessageLike, thread_d_exports as ThreadPrimitive, type ThreadRuntime, type ThreadState, type ThreadSuggestion, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ThreadViewportState, type Tool, type ToolArgsStatus, type ToolCallMessagePart, type ToolCallMessagePartComponent, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartProps, type ToolCallMessagePartStatus, type ToolDefinition, type ToolExecutionStatus, type ToolModelContentPart, type Toolkit, Tools, type Unstable_AudioMessagePart, type Unstable_AudioMessagePartComponent, type Unstable_AudioMessagePartProps, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_IconComponent, type Unstable_Mention, type Unstable_MentionCategory, type Unstable_MentionDirective, type Unstable_ModelContextToolsOptions, type RegisteredTrigger as Unstable_RegisteredTrigger, type Unstable_SlashCommand, type Unstable_SlashCommandAction, type TriggerBehavior as Unstable_TriggerBehavior, type Unstable_TriggerItem, type Unstable_UseMentionAdapterOptions, type Unstable_UseSlashCommandAdapterOptions, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, tool, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, unstable_useMentionAdapter, unstable_useSlashCommandAdapter, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantRuntime, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAttachment, useAttachmentRuntime, useAui, useAuiEvent, useAuiState, useCloudThreadListAdapter, useCloudThreadListRuntime, useComposer, useComposerRuntime, useEditComposer, useEditComposerAttachment, useEditComposerAttachmentRuntime, useExternalMessageConverter, useExternalStoreRuntime, useInlineRender, useInteractableState, useLocalRuntime, useMessage, useMessageAttachment, useMessageAttachmentRuntime, useMessagePart, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartRuntime, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageRuntime, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useThread, useThreadComposer, useThreadComposerAttachment, useThreadComposerAttachmentRuntime, useThreadList, useThreadListItem, useThreadListItemRuntime, useThreadModelContext, useThreadRuntime, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
package/dist/index.js CHANGED
@@ -67,8 +67,8 @@ import { getMcpAppFromToolPart } from "./mcp-apps/utils.js";
67
67
  import { McpAppRenderer } from "./mcp-apps/McpAppRenderer.js";
68
68
  import { McpAppsRemoteHost } from "./mcp-apps/McpAppsRemoteHost.js";
69
69
  import { AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
70
- import { DataRenderers, GenerativeUIRender, GenerativeUIRenderError, Interactables, RuntimeAdapterProvider, Tools, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
70
+ import { DataRenderers, GenerativeUIRender, GenerativeUIRenderError, Interactables, RuntimeAdapterProvider, Tools, groupPartByType, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
71
71
  import { AssistantCloud } from "assistant-cloud";
72
72
  import { AssistantFrameHost, AssistantFrameProvider, CompositeAttachmentAdapter, ExportedMessageRepository, FRAME_MESSAGE_CHANNEL, InMemoryThreadListAdapter, ModelContextRegistry, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, getExternalStoreMessages, mergeModelContexts, tool, unstable_defaultDirectiveFormatter } from "@assistant-ui/core";
73
73
  import { ChainOfThoughtClient, ModelContext as ModelContextClient, Suggestions } from "@assistant-ui/core/store";
74
- export { actionBarMore_exports as ActionBarMorePrimitive, actionBar_exports as ActionBarPrimitive, AssistantCloud, AssistantFrameHost, AssistantFrameProvider, assistantModal_exports as AssistantModalPrimitive, AssistantRuntimeProvider, attachment_exports as AttachmentPrimitive, AuiIf, AuiProvider, branchPicker_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_exports as ChainOfThoughtPrimitive, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, composer_exports as ComposerPrimitive, CompositeAttachmentAdapter, DataRenderers, DevToolsHooks, DevToolsProviderApi, error_exports as ErrorPrimitive, ExportedMessageRepository, ExternalThread, FRAME_MESSAGE_CHANNEL, GenerativeUIRender, GenerativeUIRenderError, internal_exports as INTERNAL, InMemoryThreadList, InMemoryThreadListAdapter, Interactables, McpAppRenderer, McpAppsRemoteHost, MessageAttachmentByIndexProvider, MessageByIndexProvider, messagePart_exports as MessagePartPrimitive, message_exports as MessagePrimitive, MessageProvider, ModelContextClient, ModelContextRegistry, PartByIndexProvider, queueItem_exports as QueueItemPrimitive, ReadonlyThreadProvider, RuntimeAdapterProvider, selectionToolbar_exports as SelectionToolbarPrimitive, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, SuggestionByIndexProvider, suggestion_exports as SuggestionPrimitive, Suggestions, TextMessagePartProvider, ThreadListItemByIndexProvider, threadListItemMore_exports as ThreadListItemMorePrimitive, threadListItem_exports as ThreadListItemPrimitive, ThreadListItemRuntimeProvider, threadList_exports as ThreadListPrimitive, thread_exports as ThreadPrimitive, Tools, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, getExternalStoreMessages, getMcpAppFromToolPart, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, tool, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, unstable_useMentionAdapter, unstable_useSlashCommandAdapter, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantRuntime, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAttachment, useAttachmentRuntime, useAui, useAuiEvent, useAuiState, useCloudThreadListAdapter, useCloudThreadListRuntime, useComposer, useComposerRuntime, useEditComposer, useEditComposerAttachment, useEditComposerAttachmentRuntime, useExternalMessageConverter, useExternalStoreRuntime, useInlineRender, useInteractableState, useLocalRuntime, useMessage, useMessageAttachment, useMessageAttachmentRuntime, useMessagePart, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartRuntime, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageRuntime, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useThread, useThreadComposer, useThreadComposerAttachment, useThreadComposerAttachmentRuntime, useThreadList, useThreadListItem, useThreadListItemRuntime, useThreadModelContext, useThreadRuntime, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
74
+ export { actionBarMore_exports as ActionBarMorePrimitive, actionBar_exports as ActionBarPrimitive, AssistantCloud, AssistantFrameHost, AssistantFrameProvider, assistantModal_exports as AssistantModalPrimitive, AssistantRuntimeProvider, attachment_exports as AttachmentPrimitive, AuiIf, AuiProvider, branchPicker_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_exports as ChainOfThoughtPrimitive, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, composer_exports as ComposerPrimitive, CompositeAttachmentAdapter, DataRenderers, DevToolsHooks, DevToolsProviderApi, error_exports as ErrorPrimitive, ExportedMessageRepository, ExternalThread, FRAME_MESSAGE_CHANNEL, GenerativeUIRender, GenerativeUIRenderError, internal_exports as INTERNAL, InMemoryThreadList, InMemoryThreadListAdapter, Interactables, McpAppRenderer, McpAppsRemoteHost, MessageAttachmentByIndexProvider, MessageByIndexProvider, messagePart_exports as MessagePartPrimitive, message_exports as MessagePrimitive, MessageProvider, ModelContextClient, ModelContextRegistry, PartByIndexProvider, queueItem_exports as QueueItemPrimitive, ReadonlyThreadProvider, RuntimeAdapterProvider, selectionToolbar_exports as SelectionToolbarPrimitive, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, SuggestionByIndexProvider, suggestion_exports as SuggestionPrimitive, Suggestions, TextMessagePartProvider, ThreadListItemByIndexProvider, threadListItemMore_exports as ThreadListItemMorePrimitive, threadListItem_exports as ThreadListItemPrimitive, ThreadListItemRuntimeProvider, threadList_exports as ThreadListPrimitive, thread_exports as ThreadPrimitive, Tools, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createVoiceSession, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, tool, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, unstable_useMentionAdapter, unstable_useSlashCommandAdapter, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantRuntime, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAttachment, useAttachmentRuntime, useAui, useAuiEvent, useAuiState, useCloudThreadListAdapter, useCloudThreadListRuntime, useComposer, useComposerRuntime, useEditComposer, useEditComposerAttachment, useEditComposerAttachmentRuntime, useExternalMessageConverter, useExternalStoreRuntime, useInlineRender, useInteractableState, useLocalRuntime, useMessage, useMessageAttachment, useMessageAttachmentRuntime, useMessagePart, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartRuntime, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageRuntime, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useThread, useThreadComposer, useThreadComposerAttachment, useThreadComposerAttachmentRuntime, useThreadList, useThreadListItem, useThreadListItemRuntime, useThreadModelContext, useThreadRuntime, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
@@ -2,14 +2,13 @@ import { splitLocalRuntimeOptions } from "./legacy-runtime/runtime-cores/local/L
2
2
  import { useSmooth } from "./utils/smooth/useSmooth.js";
3
3
  import { useSmoothStatus, withSmoothContextProvider } from "./utils/smooth/SmoothContext.js";
4
4
  import { useComposerInputPluginRegistryOptional } from "./primitives/composer/ComposerInputPluginContext.js";
5
- import { ToolExecutionStatus, useToolInvocations } from "@assistant-ui/core/react";
6
- import { ThreadListRuntimeCore, ThreadRuntimeCore } from "@assistant-ui/core";
5
+ import { ThreadListRuntimeCore, ThreadRuntimeCore, ToolExecutionStatus } from "@assistant-ui/core";
7
6
  import { AssistantRuntimeImpl, BaseAssistantRuntimeCore, CompositeContextProvider, DefaultThreadComposerRuntimeCore, MessageRepository, ThreadListItemRuntimeBinding, ThreadRuntimeCoreBinding, ThreadRuntimeImpl, fromThreadMessageLike, generateId, getAutoStatus } from "@assistant-ui/core/internal";
8
7
 
9
8
  //#region src/internal.d.ts
10
9
  declare namespace internal_d_exports {
11
- export { AssistantRuntimeImpl, BaseAssistantRuntimeCore, CompositeContextProvider, DefaultThreadComposerRuntimeCore, MessageRepository, ThreadListItemRuntimeBinding, ThreadListRuntimeCore, ThreadRuntimeCore, ThreadRuntimeCoreBinding, ThreadRuntimeImpl, ToolExecutionStatus, fromThreadMessageLike, generateId, getAutoStatus, splitLocalRuntimeOptions, useComposerInputPluginRegistryOptional, useSmooth, useSmoothStatus, useToolInvocations, withSmoothContextProvider };
10
+ export { AssistantRuntimeImpl, BaseAssistantRuntimeCore, CompositeContextProvider, DefaultThreadComposerRuntimeCore, MessageRepository, ThreadListItemRuntimeBinding, ThreadListRuntimeCore, ThreadRuntimeCore, ThreadRuntimeCoreBinding, ThreadRuntimeImpl, ToolExecutionStatus, fromThreadMessageLike, generateId, getAutoStatus, splitLocalRuntimeOptions, useComposerInputPluginRegistryOptional, useSmooth, useSmoothStatus, withSmoothContextProvider };
12
11
  }
13
12
  //#endregion
14
- export { AssistantRuntimeImpl, BaseAssistantRuntimeCore, CompositeContextProvider, DefaultThreadComposerRuntimeCore, MessageRepository, type ThreadListItemRuntimeBinding, type ThreadListRuntimeCore, type ThreadRuntimeCore, type ThreadRuntimeCoreBinding, ThreadRuntimeImpl, type ToolExecutionStatus, fromThreadMessageLike, generateId, getAutoStatus, internal_d_exports, splitLocalRuntimeOptions, useComposerInputPluginRegistryOptional, useSmooth, useSmoothStatus, useToolInvocations, withSmoothContextProvider };
13
+ export { AssistantRuntimeImpl, BaseAssistantRuntimeCore, CompositeContextProvider, DefaultThreadComposerRuntimeCore, MessageRepository, type ThreadListItemRuntimeBinding, type ThreadListRuntimeCore, type ThreadRuntimeCore, type ThreadRuntimeCoreBinding, ThreadRuntimeImpl, type ToolExecutionStatus, fromThreadMessageLike, generateId, getAutoStatus, internal_d_exports, splitLocalRuntimeOptions, useComposerInputPluginRegistryOptional, useSmooth, useSmoothStatus, withSmoothContextProvider };
15
14
  //# sourceMappingURL=internal.d.ts.map
package/dist/internal.js CHANGED
@@ -3,7 +3,6 @@ import { useComposerInputPluginRegistryOptional } from "./primitives/composer/Co
3
3
  import { useSmoothStatus, withSmoothContextProvider } from "./utils/smooth/SmoothContext.js";
4
4
  import { useSmooth } from "./utils/smooth/useSmooth.js";
5
5
  import { splitLocalRuntimeOptions } from "./legacy-runtime/runtime-cores/local/LocalRuntimeOptions.js";
6
- import { useToolInvocations } from "@assistant-ui/core/react";
7
6
  import { AssistantRuntimeImpl, BaseAssistantRuntimeCore, CompositeContextProvider, DefaultThreadComposerRuntimeCore, MessageRepository, ThreadRuntimeImpl, fromThreadMessageLike, generateId, getAutoStatus } from "@assistant-ui/core/internal";
8
7
  //#region src/internal.ts
9
8
  var internal_exports = /* @__PURE__ */ __exportAll({
@@ -20,10 +19,9 @@ var internal_exports = /* @__PURE__ */ __exportAll({
20
19
  useComposerInputPluginRegistryOptional: () => useComposerInputPluginRegistryOptional,
21
20
  useSmooth: () => useSmooth,
22
21
  useSmoothStatus: () => useSmoothStatus,
23
- useToolInvocations: () => useToolInvocations,
24
22
  withSmoothContextProvider: () => withSmoothContextProvider
25
23
  });
26
24
  //#endregion
27
- export { AssistantRuntimeImpl, BaseAssistantRuntimeCore, CompositeContextProvider, DefaultThreadComposerRuntimeCore, MessageRepository, ThreadRuntimeImpl, fromThreadMessageLike, generateId, getAutoStatus, internal_exports, splitLocalRuntimeOptions, useComposerInputPluginRegistryOptional, useSmooth, useSmoothStatus, useToolInvocations, withSmoothContextProvider };
25
+ export { AssistantRuntimeImpl, BaseAssistantRuntimeCore, CompositeContextProvider, DefaultThreadComposerRuntimeCore, MessageRepository, ThreadRuntimeImpl, fromThreadMessageLike, generateId, getAutoStatus, internal_exports, splitLocalRuntimeOptions, useComposerInputPluginRegistryOptional, useSmooth, useSmoothStatus, withSmoothContextProvider };
28
26
 
29
27
  //# sourceMappingURL=internal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","names":[],"sources":["../src/internal.ts"],"sourcesContent":["// Re-export from @assistant-ui/core\nexport type {\n ThreadRuntimeCore,\n ThreadListRuntimeCore,\n} from \"@assistant-ui/core\";\n\n// Re-export from @assistant-ui/core/internal\nexport {\n DefaultThreadComposerRuntimeCore,\n CompositeContextProvider,\n MessageRepository,\n BaseAssistantRuntimeCore,\n generateId,\n AssistantRuntimeImpl,\n ThreadRuntimeImpl,\n fromThreadMessageLike,\n getAutoStatus,\n} from \"@assistant-ui/core/internal\";\nexport type {\n ThreadRuntimeCoreBinding,\n ThreadListItemRuntimeBinding,\n} from \"@assistant-ui/core/internal\";\n\n// React-specific (stay in react)\nexport { splitLocalRuntimeOptions } from \"./legacy-runtime/runtime-cores/local/LocalRuntimeOptions\";\nexport {\n useToolInvocations,\n type ToolExecutionStatus,\n} from \"@assistant-ui/core/react\";\n\nexport { useSmooth } from \"./utils/smooth/useSmooth\";\nexport {\n useSmoothStatus,\n withSmoothContextProvider,\n} from \"./utils/smooth/SmoothContext\";\n\n// ComposerInput plugin registry (used by react-lexical)\nexport { useComposerInputPluginRegistryOptional } from \"./primitives/composer/ComposerInputPluginContext\";\n"],"mappings":""}
1
+ {"version":3,"file":"internal.js","names":[],"sources":["../src/internal.ts"],"sourcesContent":["// Re-export from @assistant-ui/core\nexport type {\n ThreadRuntimeCore,\n ThreadListRuntimeCore,\n} from \"@assistant-ui/core\";\n\n// Re-export from @assistant-ui/core/internal\nexport {\n DefaultThreadComposerRuntimeCore,\n CompositeContextProvider,\n MessageRepository,\n BaseAssistantRuntimeCore,\n generateId,\n AssistantRuntimeImpl,\n ThreadRuntimeImpl,\n fromThreadMessageLike,\n getAutoStatus,\n} from \"@assistant-ui/core/internal\";\nexport type {\n ThreadRuntimeCoreBinding,\n ThreadListItemRuntimeBinding,\n} from \"@assistant-ui/core/internal\";\n\n// React-specific (stay in react)\nexport { splitLocalRuntimeOptions } from \"./legacy-runtime/runtime-cores/local/LocalRuntimeOptions\";\nexport type { ToolExecutionStatus } from \"@assistant-ui/core\";\n\nexport { useSmooth } from \"./utils/smooth/useSmooth\";\nexport {\n useSmoothStatus,\n withSmoothContextProvider,\n} from \"./utils/smooth/SmoothContext\";\n\n// ComposerInput plugin registry (used by react-lexical)\nexport { useComposerInputPluginRegistryOptional } from \"./primitives/composer/ComposerInputPluginContext\";\n"],"mappings":""}
@@ -1,7 +1,7 @@
1
1
  import { UserCommands } from "../../../augmentations.js";
2
- import { ToolExecutionStatus } from "./useToolInvocations.js";
3
- import { AttachmentAdapter, LanguageModelConfig, LanguageModelV1CallSettings, ThreadHistoryAdapter, ThreadMessage } from "@assistant-ui/core";
2
+ import { AttachmentAdapter, LanguageModelConfig, LanguageModelV1CallSettings, ThreadHistoryAdapter, ThreadMessage, ToolExecutionStatus } from "@assistant-ui/core";
4
3
  import { ReadonlyJSONValue } from "assistant-stream/utils";
4
+ import { ToolModelContentPart } from "assistant-stream";
5
5
 
6
6
  //#region src/legacy-runtime/runtime-cores/assistant-transport/types.d.ts
7
7
  type TextPart = {
@@ -34,6 +34,7 @@ type AddToolResultCommand = {
34
34
  readonly result: ReadonlyJSONValue;
35
35
  readonly isError: boolean;
36
36
  readonly artifact?: ReadonlyJSONValue;
37
+ readonly modelContent?: readonly ToolModelContentPart[];
37
38
  };
38
39
  type AssistantTransportCommand = AddMessageCommand | AddToolResultCommand | UserCommands;
39
40
  type AssistantTransportState = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],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A,EAAO,MAAA;EACP,YAAA,EAAc,2BAAA;EACd,MAAA,EAAQ,mBAAA;EACR,QAAA;EACA,QAAA;EAAA,CAIC,GAAA;AAAA;AAAA,KAGS,yBAAA;EACV,YAAA,EAAc,CAAA;EACd,GAAA;EACA,SAAA;EACA,QAAA,GAAW,0BAAA;EACX,SAAA,EAAW,gCAAA,CAAiC,CAAA;EAC5C,OAAA,EAAS,YAAA,UAAsB,OAAA,CAAQ,YAAA;EACvC,IAAA,mBAAuB,OAAA;EA3DrB;;;AACY;AAGhB;;;;;;;;EAoEE,0BAAA,IACE,IAAA,EAAM,uBAAA,KACH,MAAA,oBAA0B,OAAA,CAAQ,MAAA;EACvC,UAAA,IAAc,QAAA,EAAU,QAAA;EACxB,QAAA;EACA,OAAA,IACE,KAAA,EAAO,KAAA,EACP,MAAA;IACE,QAAA,EAAU,yBAAA;IACV,WAAA,GAAc,OAAA,GAAU,KAAA,EAAO,CAAA,KAAM,CAAA;EAAA,aAE7B,OAAA;EAtEiB;;;;;;EA6E7B,QAAA,IAAY,MAAA;IACV,QAAA,EAAU,yBAAA;IACV,WAAA,GAAc,OAAA,GAAU,KAAA,EAAO,CAAA,KAAM,CAAA;IACrC,KAAA,GAAQ,KAAA;EAAA;EAEV,YAAA;IACE,IAAA;EAAA;EAEF,QAAA;IACE,WAAA,GAAc,iBAAA;IACd,OAAA,GAAU,oBAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/types.ts"],"mappings":";;;;;;KAaY,QAAA;EAAA,SACD,IAAA;EAAA,SACA,IAAI;AAAA;AAAA,KAGH,SAAA;EAAA,SACD,IAAA;EAAA,SACA,KAAK;AAAA;AAAA,KAGJ,eAAA,GAAkB,QAAA,GAAW,SAAS;AAAA,KAEtC,WAAA;EAAA,SACD,IAAA;EAAA,SACA,KAAA,WAAgB,eAAe;AAAA;AAAA,KAG9B,gBAAA;EAAA,SACD,IAAA;EAA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,mBAAuB,OAAA;EA1DrB;;;;;;;AAAY;AAGhB;;;;EAoEE,0BAAA,IACE,IAAA,EAAM,uBAAA,KACH,MAAA,oBAA0B,OAAA,CAAQ,MAAA;EACvC,UAAA,IAAc,QAAA,EAAU,QAAA;EACxB,QAAA;EACA,OAAA,IACE,KAAA,EAAO,KAAA,EACP,MAAA;IACE,QAAA,EAAU,yBAAA;IACV,WAAA,GAAc,OAAA,GAAU,KAAA,EAAO,CAAA,KAAM,CAAA;EAAA,aAE7B,OAAA;EAzEF;;;;;;EAgFV,QAAA,IAAY,MAAA;IACV,QAAA,EAAU,yBAAA;IACV,WAAA,GAAc,OAAA,GAAU,KAAA,EAAO,CAAA,KAAM,CAAA;IACrC,KAAA,GAAQ,KAAA;EAAA;EAEV,YAAA;IACE,IAAA;EAAA;EAEF,QAAA;IACE,WAAA,GAAc,iBAAA;IACd,OAAA,GAAU,oBAAA;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useAssistantTransportRuntime.d.ts","names":[],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts"],"mappings":";;;;;cA6Fa,gCAAA,SAGH,OAAkC,EAAzB,yBAAyB;AAAA,iBAO5B,0BAAA,CAAA,GAA8B,iBAAiB;AAAA,iBAC/C,0BAAA,GAAA,CACd,QAAA,GAAW,KAAA,EAAO,iBAAA,KAAsB,CAAA,GACvC,CAAA;;;;cAwQU,4BAAA,MACX,OAAA,EAAS,yBAAA,CAA0B,CAAA,MAClC,gBAAA"}
1
+ {"version":3,"file":"useAssistantTransportRuntime.d.ts","names":[],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts"],"mappings":";;;;;cA0Fa,gCAAA,SAGH,OAAkC,EAAzB,yBAAyB;AAAA,iBAO5B,0BAAA,CAAA,GAA8B,iBAAiB;AAAA,iBAC/C,0BAAA,GAAA,CACd,QAAA,GAAW,KAAA,EAAO,iBAAA,KAAsB,CAAA,GACvC,CAAA;;;;cAmQU,4BAAA,MACX,OAAA,EAAS,yBAAA,CAA0B,CAAA,MAClC,gBAAA"}
@@ -4,7 +4,6 @@ import { useExternalStoreRuntime } from "../external-store/useExternalStoreRunti
4
4
  import { useCommandQueue } from "./commandQueue.js";
5
5
  import { useRunManager } from "./runManager.js";
6
6
  import { useConvertedState } from "./useConvertedState.js";
7
- import { useToolInvocations } from "./useToolInvocations.js";
8
7
  import { useAui, useAuiState } from "@assistant-ui/store";
9
8
  import { InMemoryThreadListAdapter, createRequestHeaders } from "@assistant-ui/core";
10
9
  import { asAsyncIterableStream } from "assistant-stream/utils";
@@ -152,6 +151,8 @@ const useAssistantTransportThreadRuntime = (options) => {
152
151
  state: converted.state,
153
152
  isRunning: converted.isRunning,
154
153
  adapters: options.adapters,
154
+ unstable_enableToolInvocations: true,
155
+ setToolStatuses,
155
156
  extras: {
156
157
  [symbolAssistantTransportExtras]: true,
157
158
  sendCommand: (command) => {
@@ -171,7 +172,6 @@ const useAssistantTransportThreadRuntime = (options) => {
171
172
  } },
172
173
  onCancel: async () => {
173
174
  runManager.cancel();
174
- await toolInvocations.abort();
175
175
  },
176
176
  onResume: async () => {
177
177
  if (!options.resumeApi) throw new Error("Must pass resumeApi to options to resume runs");
@@ -185,22 +185,16 @@ const useAssistantTransportThreadRuntime = (options) => {
185
185
  result: toolOptions.result,
186
186
  toolName: toolOptions.toolName,
187
187
  isError: toolOptions.isError,
188
- ...toolOptions.artifact && { artifact: toolOptions.artifact }
188
+ ...toolOptions.artifact && { artifact: toolOptions.artifact },
189
+ ...toolOptions.modelContent !== void 0 && { modelContent: toolOptions.modelContent }
189
190
  };
190
191
  commandQueue.enqueue(command);
191
192
  },
192
193
  onLoadExternalState: async (state) => {
193
194
  agentStateRef.current = state;
194
- toolInvocations.reset();
195
195
  rerender((prev) => prev + 1);
196
196
  }
197
197
  });
198
- const toolInvocations = useToolInvocations({
199
- state: converted,
200
- getTools: () => runtime.thread.getModelContext().tools,
201
- onResult: commandQueue.enqueue,
202
- setToolStatuses
203
- });
204
198
  return runtime;
205
199
  };
206
200
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"useAssistantTransportRuntime.js","names":["createInitialMessage"],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts"],"sourcesContent":["\"use client\";\n\nimport type { AppendMessage } from \"@assistant-ui/core\";\nimport {\n type ReadonlyJSONObject,\n type ReadonlyJSONValue,\n asAsyncIterableStream,\n} from \"assistant-stream/utils\";\nimport { useExternalStoreRuntime } from \"../external-store/useExternalStoreRuntime\";\nimport type { AssistantRuntime } from \"../../runtime/AssistantRuntime\";\nimport type { AddToolResultOptions } from \"@assistant-ui/core\";\nimport { useState, useRef, useMemo } from \"react\";\nimport {\n AssistantMessageAccumulator,\n DataStreamDecoder,\n AssistantTransportDecoder,\n unstable_createInitialMessage as createInitialMessage,\n toToolsJSONSchema,\n} from \"assistant-stream\";\nimport type {\n AssistantTransportOptions,\n AddMessageCommand,\n AddToolResultCommand,\n UserMessagePart,\n QueuedCommand,\n AssistantTransportCommand,\n SendCommandsRequestBody,\n} from \"./types\";\nimport { useCommandQueue } from \"./commandQueue\";\nimport { useRunManager } from \"./runManager\";\nimport { useConvertedState } from \"./useConvertedState\";\nimport {\n type ToolExecutionStatus,\n useToolInvocations,\n} from \"./useToolInvocations\";\nimport { createRequestHeaders } from \"@assistant-ui/core\";\nimport { useRemoteThreadListRuntime } from \"../remote-thread-list/useRemoteThreadListRuntime\";\nimport { InMemoryThreadListAdapter } from \"@assistant-ui/core\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type { UserExternalState } from \"../../../augmentations\";\n\nconst convertAppendMessageToCommand = (\n message: AppendMessage,\n): AddMessageCommand => {\n if (message.role !== \"user\")\n throw new Error(\"Only user messages are supported\");\n\n const parts: UserMessagePart[] = [];\n const content = [\n ...message.content,\n ...(message.attachments?.flatMap((a) => a.content) ?? []),\n ];\n for (const contentPart of content) {\n if (contentPart.type === \"text\") {\n parts.push({ type: \"text\", text: contentPart.text });\n } else if (contentPart.type === \"image\") {\n parts.push({ type: \"image\", image: contentPart.image });\n }\n }\n\n return {\n type: \"add-message\",\n message: {\n role: \"user\",\n parts,\n },\n parentId: message.parentId,\n sourceId: message.sourceId,\n };\n};\n\nconst symbolAssistantTransportExtras = Symbol(\"assistant-transport-extras\");\ntype AssistantTransportExtras = {\n [symbolAssistantTransportExtras]: true;\n sendCommand: (command: AssistantTransportCommand) => void;\n state: UserExternalState;\n};\n\nconst asAssistantTransportExtras = (\n extras: unknown,\n): AssistantTransportExtras => {\n if (\n typeof extras !== \"object\" ||\n extras == null ||\n !(symbolAssistantTransportExtras in extras)\n )\n throw new Error(\n \"This method can only be called when you are using useAssistantTransportRuntime\",\n );\n\n return extras as AssistantTransportExtras;\n};\n\nexport const useAssistantTransportSendCommand = () => {\n const aui = useAui();\n\n return (command: AssistantTransportCommand) => {\n const extras = aui.thread().getState().extras;\n const transportExtras = asAssistantTransportExtras(extras);\n transportExtras.sendCommand(command);\n };\n};\n\nexport function useAssistantTransportState(): UserExternalState;\nexport function useAssistantTransportState<T>(\n selector: (state: UserExternalState) => T,\n): T;\nexport function useAssistantTransportState<T>(\n selector: (state: UserExternalState) => T = (t) => t as T,\n): T | UserExternalState {\n return useAuiState((s) =>\n selector(asAssistantTransportExtras(s.thread.extras).state),\n );\n}\n\nconst useAssistantTransportThreadRuntime = <T>(\n options: AssistantTransportOptions<T>,\n): AssistantRuntime => {\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const agentStateRef = useRef(options.initialState);\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const [, rerender] = useState(0);\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const resumeFlagRef = useRef(false);\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const parentIdRef = useRef<string | null | undefined>(undefined);\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const commandQueue = useCommandQueue({\n onQueue: () => runManager.schedule(),\n });\n\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const threadId = useAuiState((s) => s.threadListItem.remoteId);\n\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const runManager = useRunManager({\n onRun: async (signal: AbortSignal) => {\n const isResume = resumeFlagRef.current;\n resumeFlagRef.current = false;\n const commands: QueuedCommand[] = isResume ? [] : commandQueue.flush();\n if (commands.length === 0 && !isResume)\n throw new Error(\"No commands to send\");\n\n const headers = await createRequestHeaders(options.headers);\n const bodyValue =\n typeof options.body === \"function\"\n ? await options.body()\n : options.body;\n const context = runtime.thread.getModelContext();\n\n let requestBody: Record<string, unknown> = {\n commands,\n state: agentStateRef.current,\n system: context.system,\n tools: context.tools ? toToolsJSONSchema(context.tools) : undefined,\n threadId,\n ...(parentIdRef.current !== undefined && {\n parentId: parentIdRef.current,\n }),\n // nested (new format, aligned with AssistantChatTransport)\n callSettings: context.callSettings,\n config: context.config,\n // @deprecated spread at top level — use nested `callSettings`/`config` instead. Will be removed in a future version.\n ...context.callSettings,\n ...context.config,\n ...(bodyValue ?? {}),\n };\n\n if (options.prepareSendCommandsRequest) {\n requestBody = await options.prepareSendCommandsRequest(\n requestBody as SendCommandsRequestBody,\n );\n }\n\n const response = await fetch(\n isResume ? options.resumeApi! : options.api,\n {\n method: \"POST\",\n headers,\n body: JSON.stringify(requestBody),\n signal,\n },\n );\n\n options.onResponse?.(response);\n\n if (!response.ok) {\n throw new Error(`Status ${response.status}: ${await response.text()}`);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n // Select decoder based on protocol option\n const protocol = options.protocol ?? \"data-stream\";\n const decoder =\n protocol === \"assistant-transport\"\n ? new AssistantTransportDecoder()\n : new DataStreamDecoder();\n\n let err: string | undefined;\n const stream = response.body.pipeThrough(decoder).pipeThrough(\n new AssistantMessageAccumulator({\n initialMessage: createInitialMessage({\n unstable_state:\n (agentStateRef.current as ReadonlyJSONValue) ?? null,\n }),\n throttle: isResume,\n onError: (error) => {\n err = error;\n },\n }),\n );\n\n let markedDelivered = false;\n\n for await (const chunk of asAsyncIterableStream(stream)) {\n if (chunk.metadata.unstable_state === agentStateRef.current) continue;\n\n if (!markedDelivered) {\n commandQueue.markDelivered();\n markedDelivered = true;\n }\n\n agentStateRef.current = chunk.metadata.unstable_state as T;\n rerender((prev) => prev + 1);\n }\n\n if (err) {\n throw new Error(err);\n }\n },\n onFinish: options.onFinish,\n onCancel: () => {\n const cmds = [\n ...commandQueue.state.inTransit,\n ...commandQueue.state.queued,\n ];\n\n commandQueue.reset();\n\n options.onCancel?.({\n commands: cmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n });\n },\n onError: async (error) => {\n const inTransitCmds = [...commandQueue.state.inTransit];\n const queuedCmds = [...commandQueue.state.queued];\n\n commandQueue.reset();\n\n try {\n await options.onError?.(error as Error, {\n commands: inTransitCmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n });\n } finally {\n options.onCancel?.({\n commands: queuedCmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n error: error as Error,\n });\n }\n },\n });\n\n // Tool execution status state\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const [toolStatuses, setToolStatuses] = useState<\n Record<string, ToolExecutionStatus>\n >({});\n\n // Reactive conversion of agent state + connection metadata → UI state\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const pendingCommands = useMemo(\n () => [...commandQueue.state.inTransit, ...commandQueue.state.queued],\n [commandQueue.state],\n );\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const converted = useConvertedState(\n options.converter,\n agentStateRef.current,\n pendingCommands,\n runManager.isRunning,\n toolStatuses,\n );\n\n // Create runtime\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const runtime = useExternalStoreRuntime({\n messages: converted.messages,\n state: converted.state,\n isRunning: converted.isRunning,\n adapters: options.adapters,\n extras: {\n [symbolAssistantTransportExtras]: true,\n sendCommand: (command: AssistantTransportCommand) => {\n commandQueue.enqueue(command);\n },\n state: agentStateRef.current as UserExternalState,\n } satisfies AssistantTransportExtras,\n onNew: async (message: AppendMessage): Promise<void> => {\n parentIdRef.current = message.parentId;\n const command = convertAppendMessageToCommand(message);\n commandQueue.enqueue(command);\n },\n ...(options.capabilities?.edit && {\n onEdit: async (message: AppendMessage): Promise<void> => {\n parentIdRef.current = message.parentId;\n const command = convertAppendMessageToCommand(message);\n commandQueue.enqueue(command);\n },\n }),\n onCancel: async () => {\n runManager.cancel();\n await toolInvocations.abort();\n },\n onResume: async () => {\n if (!options.resumeApi)\n throw new Error(\"Must pass resumeApi to options to resume runs\");\n\n resumeFlagRef.current = true;\n runManager.schedule();\n },\n onAddToolResult: async (\n toolOptions: AddToolResultOptions,\n ): Promise<void> => {\n const command: AddToolResultCommand = {\n type: \"add-tool-result\",\n toolCallId: toolOptions.toolCallId,\n result: toolOptions.result as ReadonlyJSONObject,\n toolName: toolOptions.toolName,\n isError: toolOptions.isError,\n ...(toolOptions.artifact && { artifact: toolOptions.artifact }),\n };\n\n commandQueue.enqueue(command);\n },\n onLoadExternalState: async (state) => {\n agentStateRef.current = state as T;\n toolInvocations.reset();\n rerender((prev) => prev + 1);\n },\n });\n\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const toolInvocations = useToolInvocations({\n state: converted,\n getTools: () => runtime.thread.getModelContext().tools,\n onResult: commandQueue.enqueue,\n setToolStatuses,\n });\n\n return runtime;\n};\n\n/**\n * @alpha This is an experimental API that is subject to change.\n */\nexport const useAssistantTransportRuntime = <T>(\n options: AssistantTransportOptions<T>,\n): AssistantRuntime => {\n const runtime = useRemoteThreadListRuntime({\n runtimeHook: function RuntimeHook() {\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n return useAssistantTransportThreadRuntime(options);\n },\n adapter: new InMemoryThreadListAdapter(),\n allowNesting: true,\n });\n return runtime;\n};\n"],"mappings":";;;;;;;;;;;;;AAyCA,MAAM,iCACJ,YACsB;CACtB,IAAI,QAAQ,SAAS,QACnB,MAAM,IAAI,MAAM,kCAAkC;CAEpD,MAAM,QAA2B,CAAC;CAClC,MAAM,UAAU,CACd,GAAG,QAAQ,SACX,GAAI,QAAQ,aAAa,SAAS,MAAM,EAAE,OAAO,KAAK,CAAC,CACzD;CACA,KAAK,MAAM,eAAe,SACxB,IAAI,YAAY,SAAS,QACvB,MAAM,KAAK;EAAE,MAAM;EAAQ,MAAM,YAAY;CAAK,CAAC;MAC9C,IAAI,YAAY,SAAS,SAC9B,MAAM,KAAK;EAAE,MAAM;EAAS,OAAO,YAAY;CAAM,CAAC;CAI1D,OAAO;EACL,MAAM;EACN,SAAS;GACP,MAAM;GACN;EACF;EACA,UAAU,QAAQ;EAClB,UAAU,QAAQ;CACpB;AACF;AAEA,MAAM,iCAAiC,OAAO,4BAA4B;AAO1E,MAAM,8BACJ,WAC6B;CAC7B,IACE,OAAO,WAAW,YAClB,UAAU,QACV,EAAE,kCAAkC,SAEpC,MAAM,IAAI,MACR,gFACF;CAEF,OAAO;AACT;AAEA,MAAa,yCAAyC;CACpD,MAAM,MAAM,OAAO;CAEnB,QAAQ,YAAuC;EAC7C,MAAM,SAAS,IAAI,OAAO,EAAE,SAAS,EAAE;EAEvC,2BADmD,MACrC,EAAE,YAAY,OAAO;CACrC;AACF;AAMA,SAAgB,2BACd,YAA6C,MAAM,GAC5B;CACvB,OAAO,aAAa,MAClB,SAAS,2BAA2B,EAAE,OAAO,MAAM,EAAE,KAAK,CAC5D;AACF;AAEA,MAAM,sCACJ,YACqB;CAErB,MAAM,gBAAgB,OAAO,QAAQ,YAAY;C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ACpC,cAAc,UAAU;GACxB,gBAAgB,MAAM;GACtB,UAAU,SAAS,OAAO,CAAC;EAC7B;CACF,CAAC;CAGD,MAAM,kBAAkB,mBAAmB;EACzC,OAAO;EACP,gBAAgB,QAAQ,OAAO,gBAAgB,EAAE;EACjD,UAAU,aAAa;EACvB;CACF,CAAC;CAED,OAAO;AACT;;;;AAKA,MAAa,gCACX,YACqB;CASrB,OARgB,2BAA2B;EACzC,aAAa,SAAS,cAAc;GAElC,OAAO,mCAAmC,OAAO;EACnD;EACA,SAAS,IAAI,0BAA0B;EACvC,cAAc;CAChB,CACa;AACf"}
1
+ {"version":3,"file":"useAssistantTransportRuntime.js","names":["createInitialMessage"],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts"],"sourcesContent":["\"use client\";\n\nimport type { AppendMessage } from \"@assistant-ui/core\";\nimport {\n type ReadonlyJSONObject,\n type ReadonlyJSONValue,\n asAsyncIterableStream,\n} from \"assistant-stream/utils\";\nimport { useExternalStoreRuntime } from \"../external-store/useExternalStoreRuntime\";\nimport type { AssistantRuntime } from \"../../runtime/AssistantRuntime\";\nimport type { AddToolResultOptions } from \"@assistant-ui/core\";\nimport { useMemo, useRef, useState } from \"react\";\nimport {\n AssistantMessageAccumulator,\n DataStreamDecoder,\n AssistantTransportDecoder,\n unstable_createInitialMessage as createInitialMessage,\n toToolsJSONSchema,\n} from \"assistant-stream\";\nimport type {\n AssistantTransportOptions,\n AddMessageCommand,\n AddToolResultCommand,\n UserMessagePart,\n QueuedCommand,\n AssistantTransportCommand,\n SendCommandsRequestBody,\n} from \"./types\";\nimport { useCommandQueue } from \"./commandQueue\";\nimport { useRunManager } from \"./runManager\";\nimport { useConvertedState } from \"./useConvertedState\";\nimport type { ToolExecutionStatus } from \"@assistant-ui/core\";\nimport { createRequestHeaders } from \"@assistant-ui/core\";\nimport { useRemoteThreadListRuntime } from \"../remote-thread-list/useRemoteThreadListRuntime\";\nimport { InMemoryThreadListAdapter } from \"@assistant-ui/core\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type { UserExternalState } from \"../../../augmentations\";\n\nconst convertAppendMessageToCommand = (\n message: AppendMessage,\n): AddMessageCommand => {\n if (message.role !== \"user\")\n throw new Error(\"Only user messages are supported\");\n\n const parts: UserMessagePart[] = [];\n const content = [\n ...message.content,\n ...(message.attachments?.flatMap((a) => a.content) ?? []),\n ];\n for (const contentPart of content) {\n if (contentPart.type === \"text\") {\n parts.push({ type: \"text\", text: contentPart.text });\n } else if (contentPart.type === \"image\") {\n parts.push({ type: \"image\", image: contentPart.image });\n }\n }\n\n return {\n type: \"add-message\",\n message: {\n role: \"user\",\n parts,\n },\n parentId: message.parentId,\n sourceId: message.sourceId,\n };\n};\n\nconst symbolAssistantTransportExtras = Symbol(\"assistant-transport-extras\");\ntype AssistantTransportExtras = {\n [symbolAssistantTransportExtras]: true;\n sendCommand: (command: AssistantTransportCommand) => void;\n state: UserExternalState;\n};\n\nconst asAssistantTransportExtras = (\n extras: unknown,\n): AssistantTransportExtras => {\n if (\n typeof extras !== \"object\" ||\n extras == null ||\n !(symbolAssistantTransportExtras in extras)\n )\n throw new Error(\n \"This method can only be called when you are using useAssistantTransportRuntime\",\n );\n\n return extras as AssistantTransportExtras;\n};\n\nexport const useAssistantTransportSendCommand = () => {\n const aui = useAui();\n\n return (command: AssistantTransportCommand) => {\n const extras = aui.thread().getState().extras;\n const transportExtras = asAssistantTransportExtras(extras);\n transportExtras.sendCommand(command);\n };\n};\n\nexport function useAssistantTransportState(): UserExternalState;\nexport function useAssistantTransportState<T>(\n selector: (state: UserExternalState) => T,\n): T;\nexport function useAssistantTransportState<T>(\n selector: (state: UserExternalState) => T = (t) => t as T,\n): T | UserExternalState {\n return useAuiState((s) =>\n selector(asAssistantTransportExtras(s.thread.extras).state),\n );\n}\n\nconst useAssistantTransportThreadRuntime = <T>(\n options: AssistantTransportOptions<T>,\n): AssistantRuntime => {\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const agentStateRef = useRef(options.initialState);\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const [, rerender] = useState(0);\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const resumeFlagRef = useRef(false);\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const parentIdRef = useRef<string | null | undefined>(undefined);\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const commandQueue = useCommandQueue({\n onQueue: () => runManager.schedule(),\n });\n\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const threadId = useAuiState((s) => s.threadListItem.remoteId);\n\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const runManager = useRunManager({\n onRun: async (signal: AbortSignal) => {\n const isResume = resumeFlagRef.current;\n resumeFlagRef.current = false;\n const commands: QueuedCommand[] = isResume ? [] : commandQueue.flush();\n if (commands.length === 0 && !isResume)\n throw new Error(\"No commands to send\");\n\n const headers = await createRequestHeaders(options.headers);\n const bodyValue =\n typeof options.body === \"function\"\n ? await options.body()\n : options.body;\n const context = runtime.thread.getModelContext();\n\n let requestBody: Record<string, unknown> = {\n commands,\n state: agentStateRef.current,\n system: context.system,\n tools: context.tools ? toToolsJSONSchema(context.tools) : undefined,\n threadId,\n ...(parentIdRef.current !== undefined && {\n parentId: parentIdRef.current,\n }),\n // nested (new format, aligned with AssistantChatTransport)\n callSettings: context.callSettings,\n config: context.config,\n // @deprecated spread at top level — use nested `callSettings`/`config` instead. Will be removed in a future version.\n ...context.callSettings,\n ...context.config,\n ...(bodyValue ?? {}),\n };\n\n if (options.prepareSendCommandsRequest) {\n requestBody = await options.prepareSendCommandsRequest(\n requestBody as SendCommandsRequestBody,\n );\n }\n\n const response = await fetch(\n isResume ? options.resumeApi! : options.api,\n {\n method: \"POST\",\n headers,\n body: JSON.stringify(requestBody),\n signal,\n },\n );\n\n options.onResponse?.(response);\n\n if (!response.ok) {\n throw new Error(`Status ${response.status}: ${await response.text()}`);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n // Select decoder based on protocol option\n const protocol = options.protocol ?? \"data-stream\";\n const decoder =\n protocol === \"assistant-transport\"\n ? new AssistantTransportDecoder()\n : new DataStreamDecoder();\n\n let err: string | undefined;\n const stream = response.body.pipeThrough(decoder).pipeThrough(\n new AssistantMessageAccumulator({\n initialMessage: createInitialMessage({\n unstable_state:\n (agentStateRef.current as ReadonlyJSONValue) ?? null,\n }),\n throttle: isResume,\n onError: (error) => {\n err = error;\n },\n }),\n );\n\n let markedDelivered = false;\n\n for await (const chunk of asAsyncIterableStream(stream)) {\n if (chunk.metadata.unstable_state === agentStateRef.current) continue;\n\n if (!markedDelivered) {\n commandQueue.markDelivered();\n markedDelivered = true;\n }\n\n agentStateRef.current = chunk.metadata.unstable_state as T;\n rerender((prev) => prev + 1);\n }\n\n if (err) {\n throw new Error(err);\n }\n },\n onFinish: options.onFinish,\n onCancel: () => {\n const cmds = [\n ...commandQueue.state.inTransit,\n ...commandQueue.state.queued,\n ];\n\n commandQueue.reset();\n\n options.onCancel?.({\n commands: cmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n });\n },\n onError: async (error) => {\n const inTransitCmds = [...commandQueue.state.inTransit];\n const queuedCmds = [...commandQueue.state.queued];\n\n commandQueue.reset();\n\n try {\n await options.onError?.(error as Error, {\n commands: inTransitCmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n });\n } finally {\n options.onCancel?.({\n commands: queuedCmds,\n updateState: (updater) => {\n agentStateRef.current = updater(agentStateRef.current);\n rerender((prev) => prev + 1);\n },\n error: error as Error,\n });\n }\n },\n });\n\n // Tool execution status state\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const [toolStatuses, setToolStatuses] = useState<\n Record<string, ToolExecutionStatus>\n >({});\n\n // Reactive conversion of agent state + connection metadata → UI state\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const pendingCommands = useMemo(\n () => [...commandQueue.state.inTransit, ...commandQueue.state.queued],\n [commandQueue.state],\n );\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const converted = useConvertedState(\n options.converter,\n agentStateRef.current,\n pendingCommands,\n runManager.isRunning,\n toolStatuses,\n );\n\n // Create runtime\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n const runtime = useExternalStoreRuntime({\n messages: converted.messages,\n state: converted.state,\n isRunning: converted.isRunning,\n adapters: options.adapters,\n unstable_enableToolInvocations: true,\n setToolStatuses,\n extras: {\n [symbolAssistantTransportExtras]: true,\n sendCommand: (command: AssistantTransportCommand) => {\n commandQueue.enqueue(command);\n },\n state: agentStateRef.current as UserExternalState,\n } satisfies AssistantTransportExtras,\n onNew: async (message: AppendMessage): Promise<void> => {\n parentIdRef.current = message.parentId;\n const command = convertAppendMessageToCommand(message);\n commandQueue.enqueue(command);\n },\n ...(options.capabilities?.edit && {\n onEdit: async (message: AppendMessage): Promise<void> => {\n parentIdRef.current = message.parentId;\n const command = convertAppendMessageToCommand(message);\n commandQueue.enqueue(command);\n },\n }),\n onCancel: async () => {\n runManager.cancel();\n },\n onResume: async () => {\n if (!options.resumeApi)\n throw new Error(\"Must pass resumeApi to options to resume runs\");\n\n resumeFlagRef.current = true;\n runManager.schedule();\n },\n onAddToolResult: async (\n toolOptions: AddToolResultOptions,\n ): Promise<void> => {\n const command: AddToolResultCommand = {\n type: \"add-tool-result\",\n toolCallId: toolOptions.toolCallId,\n result: toolOptions.result as ReadonlyJSONObject,\n toolName: toolOptions.toolName,\n isError: toolOptions.isError,\n ...(toolOptions.artifact && { artifact: toolOptions.artifact }),\n ...(toolOptions.modelContent !== undefined && {\n modelContent: toolOptions.modelContent,\n }),\n };\n\n commandQueue.enqueue(command);\n },\n onLoadExternalState: async (state) => {\n agentStateRef.current = state as T;\n rerender((prev) => prev + 1);\n },\n });\n\n return runtime;\n};\n\n/**\n * @alpha This is an experimental API that is subject to change.\n */\nexport const useAssistantTransportRuntime = <T>(\n options: AssistantTransportOptions<T>,\n): AssistantRuntime => {\n const runtime = useRemoteThreadListRuntime({\n runtimeHook: function RuntimeHook() {\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n return useAssistantTransportThreadRuntime(options);\n },\n adapter: new InMemoryThreadListAdapter(),\n allowNesting: true,\n });\n return runtime;\n};\n"],"mappings":";;;;;;;;;;;;AAsCA,MAAM,iCACJ,YACsB;CACtB,IAAI,QAAQ,SAAS,QACnB,MAAM,IAAI,MAAM,kCAAkC;CAEpD,MAAM,QAA2B,CAAC;CAClC,MAAM,UAAU,CACd,GAAG,QAAQ,SACX,GAAI,QAAQ,aAAa,SAAS,MAAM,EAAE,OAAO,KAAK,CAAC,CACzD;CACA,KAAK,MAAM,eAAe,SACxB,IAAI,YAAY,SAAS,QACvB,MAAM,KAAK;EAAE,MAAM;EAAQ,MAAM,YAAY;CAAK,CAAC;MAC9C,IAAI,YAAY,SAAS,SAC9B,MAAM,KAAK;EAAE,MAAM;EAAS,OAAO,YAAY;CAAM,CAAC;CAI1D,OAAO;EACL,MAAM;EACN,SAAS;GACP,MAAM;GACN;EACF;EACA,UAAU,QAAQ;EAClB,UAAU,QAAQ;CACpB;AACF;AAEA,MAAM,iCAAiC,OAAO,4BAA4B;AAO1E,MAAM,8BACJ,WAC6B;CAC7B,IACE,OAAO,WAAW,YAClB,UAAU,QACV,EAAE,kCAAkC,SAEpC,MAAM,IAAI,MACR,gFACF;CAEF,OAAO;AACT;AAEA,MAAa,yCAAyC;CACpD,MAAM,MAAM,OAAO;CAEnB,QAAQ,YAAuC;EAC7C,MAAM,SAAS,IAAI,OAAO,EAAE,SAAS,EAAE;EAEvC,2BADmD,MACrC,EAAE,YAAY,OAAO;CACrC;AACF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AY,YAAY;IACxB,QAAQ,YAAY;IACpB,UAAU,YAAY;IACtB,SAAS,YAAY;IACrB,GAAI,YAAY,YAAY,EAAE,UAAU,YAAY,SAAS;IAC7D,GAAI,YAAY,iBAAiB,KAAA,KAAa,EAC5C,cAAc,YAAY,aAC5B;GACF;GAEA,aAAa,QAAQ,OAAO;EAC9B;EACA,qBAAqB,OAAO,UAAU;GACpC,cAAc,UAAU;GACxB,UAAU,SAAS,OAAO,CAAC;EAC7B;CACF,CAAC;CAED,OAAO;AACT;;;;AAKA,MAAa,gCACX,YACqB;CASrB,OARgB,2BAA2B;EACzC,aAAa,SAAS,cAAc;GAElC,OAAO,mCAAmC,OAAO;EACnD;EACA,SAAS,IAAI,0BAA0B;EACvC,cAAc;CAChB,CACa;AACf"}
@@ -1,5 +1,5 @@
1
- import { ToolExecutionStatus } from "./useToolInvocations.js";
2
1
  import { AssistantTransportCommand, AssistantTransportState, AssistantTransportStateConverter } from "./types.js";
2
+ import { ToolExecutionStatus } from "@assistant-ui/core";
3
3
 
4
4
  //#region src/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.d.ts
5
5
  declare function useConvertedState<T>(converter: AssistantTransportStateConverter<T>, agentState: T, pendingCommands: AssistantTransportCommand[], isSending: boolean, toolStatuses: Record<string, ToolExecutionStatus>): AssistantTransportState;
@@ -1 +1 @@
1
- {"version":3,"file":"useConvertedState.js","names":[],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport type {\n AssistantTransportCommand,\n AssistantTransportState,\n AssistantTransportStateConverter,\n} from \"./types\";\nimport type { ToolExecutionStatus } from \"./useToolInvocations\";\n\nexport function useConvertedState<T>(\n converter: AssistantTransportStateConverter<T>,\n agentState: T,\n pendingCommands: AssistantTransportCommand[],\n isSending: boolean,\n toolStatuses: Record<string, ToolExecutionStatus>,\n): AssistantTransportState {\n return useMemo(\n () => converter(agentState, { pendingCommands, isSending, toolStatuses }),\n [converter, agentState, pendingCommands, isSending, toolStatuses],\n );\n}\n"],"mappings":";;AAQA,SAAgB,kBACd,WACA,YACA,iBACA,WACA,cACyB;CACzB,OAAO,cACC,UAAU,YAAY;EAAE;EAAiB;EAAW;CAAa,CAAC,GACxE;EAAC;EAAW;EAAY;EAAiB;EAAW;CAAY,CAClE;AACF"}
1
+ {"version":3,"file":"useConvertedState.js","names":[],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport type {\n AssistantTransportCommand,\n AssistantTransportState,\n AssistantTransportStateConverter,\n} from \"./types\";\nimport type { ToolExecutionStatus } from \"@assistant-ui/core\";\n\nexport function useConvertedState<T>(\n converter: AssistantTransportStateConverter<T>,\n agentState: T,\n pendingCommands: AssistantTransportCommand[],\n isSending: boolean,\n toolStatuses: Record<string, ToolExecutionStatus>,\n): AssistantTransportState {\n return useMemo(\n () => converter(agentState, { pendingCommands, isSending, toolStatuses }),\n [converter, agentState, pendingCommands, isSending, toolStatuses],\n );\n}\n"],"mappings":";;AAQA,SAAgB,kBACd,WACA,YACA,iBACA,WACA,cACyB;CACzB,OAAO,cACC,UAAU,YAAY;EAAE;EAAiB;EAAW;CAAa,CAAC,GACxE;EAAC;EAAW;EAAY;EAAiB;EAAW;CAAY,CAClE;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"McpAppRenderer.js","names":[],"sources":["../../src/mcp-apps/McpAppRenderer.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n useEffect,\n useMemo,\n useRef,\n useState,\n type MutableRefObject,\n type ReactNode,\n} from \"react\";\nimport type { McpAppMetadata } from \"@assistant-ui/core\";\nimport type {\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n} from \"@assistant-ui/core/react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport {\n resource,\n tapConst,\n tapRef,\n tapResource,\n type ResourceElement,\n} from \"@assistant-ui/tap\";\nimport { McpAppFrame } from \"./app-frame\";\nimport type {\n McpAppBridgeHandlers,\n McpAppHostContext,\n McpAppHostInfo,\n McpAppResource,\n McpAppSandboxConfig,\n McpAppsHost,\n} from \"./types\";\nimport { getMcpAppFromToolPart } from \"./utils\";\n\nexport type McpAppRendererOptions = {\n /**\n * Provides the data-plane operations the widget can request\n * (`loadResource`, `callTool`, `readResource`, `listResources`). Use\n * `McpAppsRemoteHost({ url })` for the default HTTP-route convention.\n */\n host: ResourceElement<McpAppsHost>;\n /** Sandbox + container styling. Passes through to SafeContentFrame. */\n sandbox?: McpAppSandboxConfig;\n /**\n * Upper bound (in pixels) applied to the widget-driven auto-resize height.\n * Defaults to 800.\n */\n maxHeight?: number;\n /** Identifies the host to the widget in the `ui/initialize` response. */\n hostInfo?: McpAppHostInfo;\n /** Delivered to the widget on initialize and pushed via `notifications/host_context/changed` on change. */\n hostContext?: McpAppHostContext;\n /** Rendered when no MCP app is on the part, or while load is in flight / failed (unless overridden). */\n fallback?: ReactNode;\n /** Rendered while the resource is loading. Defaults to `fallback`. */\n loadingFallback?: ReactNode;\n /** Rendered when the resource load rejects. Defaults to `fallback`. */\n errorFallback?: ReactNode | ((error: Error) => ReactNode);\n};\n\ntype LoadedResourceState = {\n resourceUri: string;\n resource?: McpAppResource;\n error?: Error;\n};\n\nfunction getInput(part: {\n status: { type: string };\n argsText: string;\n args: unknown;\n}): unknown {\n if (\n part.status.type === \"running\" &&\n (part.argsText === \"\" || part.argsText === \"{}\")\n ) {\n return undefined;\n }\n return part.args;\n}\n\nconst defaultOpenLink = ({ url }: { url: string }) => {\n window.open(url, \"_blank\", \"noopener,noreferrer\");\n};\n\nfunction extractSendMessageText(params: unknown): string | undefined {\n if (typeof params === \"string\") return params;\n if (!params || typeof params !== \"object\") return undefined;\n const obj = params as Record<string, unknown>;\n if (typeof obj[\"prompt\"] === \"string\") return obj[\"prompt\"];\n if (typeof obj[\"text\"] === \"string\") return obj[\"text\"];\n if (typeof obj[\"message\"] === \"string\") return obj[\"message\"];\n return undefined;\n}\n\nfunction InlineRenderer({\n part,\n internalsRef,\n optionsRef,\n}: {\n part: ToolCallMessagePartProps;\n internalsRef: MutableRefObject<{ host: McpAppsHost }>;\n optionsRef: MutableRefObject<McpAppRendererOptions>;\n}) {\n const opts = optionsRef.current;\n const aui = useAui();\n const app = getMcpAppFromToolPart(part);\n const cachedAppRef = useRef<McpAppMetadata | undefined>(undefined);\n if (app != null && cachedAppRef.current?.resourceUri !== app.resourceUri) {\n cachedAppRef.current = app;\n }\n const appForRender = app ?? cachedAppRef.current;\n\n const [loadedResource, setLoadedResource] = useState<LoadedResourceState>();\n\n const resourceUri = appForRender?.resourceUri;\n // biome-ignore lint/correctness/useExhaustiveDependencies: re-fetches only when URI changes; mcp.app object identity is unstable across renders\n useEffect(() => {\n if (appForRender == null || resourceUri == null) return;\n let cancelled = false;\n const targetUri = resourceUri;\n\n internalsRef.current.host\n .loadResource({ uri: targetUri })\n .then((res) => {\n if (!cancelled)\n setLoadedResource({ resourceUri: targetUri, resource: res });\n })\n .catch((error: unknown) => {\n if (!cancelled) {\n setLoadedResource({\n resourceUri: targetUri,\n error: error instanceof Error ? error : new Error(String(error)),\n });\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [resourceUri]);\n\n const bridgeHandlers = useMemo<McpAppBridgeHandlers>(\n () => ({\n openLink: defaultOpenLink,\n sendMessage: (params) => {\n const text = extractSendMessageText(params);\n if (!text) return { ok: false, reason: \"unrecognised params shape\" };\n aui.thread().append({ content: [{ type: \"text\", text }] });\n return { ok: true };\n },\n callTool: (params) => internalsRef.current.host.callTool(params),\n readResource: (params) => internalsRef.current.host.readResource(params),\n listResources: (params) =>\n internalsRef.current.host.listResources(params),\n }),\n [aui, internalsRef],\n );\n\n const loadedResourceForApp =\n loadedResource?.resourceUri === appForRender?.resourceUri\n ? loadedResource\n : undefined;\n const appResource = loadedResourceForApp?.resource;\n const error = loadedResourceForApp?.error;\n\n const fallback = opts.fallback ?? null;\n if (appForRender == null) {\n return <>{fallback}</>;\n }\n if (error != null) {\n const errorFallback = opts.errorFallback;\n if (errorFallback === undefined) return <>{fallback}</>;\n if (typeof errorFallback === \"function\") return <>{errorFallback(error)}</>;\n return <>{errorFallback}</>;\n }\n if (appResource == null) {\n return <>{opts.loadingFallback ?? fallback}</>;\n }\n\n return (\n <McpAppFrame\n app={appForRender}\n resource={appResource}\n input={getInput(part)}\n output={part.result}\n sandbox={opts.sandbox}\n handlers={bridgeHandlers}\n hostInfo={opts.hostInfo}\n hostContext={opts.hostContext}\n maxHeight={opts.maxHeight}\n />\n );\n}\n\n/**\n * Creates a tool-call renderer for MCP Apps embedded in assistant messages.\n *\n * Compose this into the `Tools` resource through its `mcpApp` option. When a\n * tool-call part carries `mcp.app` metadata for a `ui://` resource, the\n * renderer loads that resource from the configured host and displays it in a\n * sandboxed frame.\n */\nexport const McpAppRenderer = resource(\n (\n options: McpAppRendererOptions,\n ): { readonly render: ToolCallMessagePartComponent } => {\n const host = tapResource(options.host);\n\n const optionsRef = tapRef<McpAppRendererOptions>(options);\n optionsRef.current = options;\n\n const internalsRef = tapRef<{ host: McpAppsHost }>({ host });\n internalsRef.current = { host };\n\n const render = tapConst((): ToolCallMessagePartComponent => {\n const Render: ToolCallMessagePartComponent = (props) => (\n <InlineRenderer\n part={props}\n internalsRef={internalsRef}\n optionsRef={optionsRef}\n />\n );\n Render.displayName = \"McpAppRenderer\";\n return Render;\n }, []);\n\n return { render };\n },\n);\n"],"mappings":";;;;;;;;AAkEA,SAAS,SAAS,MAIN;CACV,IACE,KAAK,OAAO,SAAS,cACpB,KAAK,aAAa,MAAM,KAAK,aAAa,OAE3C;CAEF,OAAO,KAAK;AACd;AAEA,MAAM,mBAAmB,EAAE,UAA2B;CACpD,OAAO,KAAK,KAAK,UAAU,qBAAqB;AAClD;AAEA,SAAS,uBAAuB,QAAqC;CACnE,IAAI,OAAO,WAAW,UAAU,OAAO;CACvC,IAAI,CAAC,UAAU,OAAO,WAAW,UAAU,OAAO,KAAA;CAClD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ACb,CAAA;EAEH,OAAO,cAAc;EACrB,OAAO;CACT,GAAG,CAAC,CAEU,EAAE;AAClB,CACF"}
1
+ {"version":3,"file":"McpAppRenderer.js","names":[],"sources":["../../src/mcp-apps/McpAppRenderer.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n useEffect,\n useMemo,\n useRef,\n useState,\n type MutableRefObject,\n type ReactNode,\n} from \"react\";\nimport type { McpAppMetadata } from \"@assistant-ui/core\";\nimport type {\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n} from \"@assistant-ui/core/react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport {\n resource,\n tapConst,\n tapRef,\n tapResource,\n type ResourceElement,\n} from \"@assistant-ui/tap\";\nimport { McpAppFrame } from \"./app-frame\";\nimport type {\n McpAppBridgeHandlers,\n McpAppHostContext,\n McpAppHostInfo,\n McpAppResource,\n McpAppSandboxConfig,\n McpAppsHost,\n} from \"./types\";\nimport { getMcpAppFromToolPart } from \"./utils\";\n\nexport type McpAppRendererOptions = {\n /**\n * Provides the data-plane operations the widget can request\n * (`loadResource`, `callTool`, `readResource`, `listResources`). Use\n * `McpAppsRemoteHost({ url })` for the default HTTP-route convention.\n */\n host: ResourceElement<McpAppsHost>;\n /** Sandbox + container styling. Passes through to SafeContentFrame. */\n sandbox?: McpAppSandboxConfig;\n /**\n * Upper bound (in pixels) applied to the widget-driven auto-resize height.\n * Defaults to 800.\n */\n maxHeight?: number;\n /** Identifies the host to the widget in the `ui/initialize` response. */\n hostInfo?: McpAppHostInfo;\n /** Delivered to the widget on initialize and pushed via `notifications/host_context/changed` on change. */\n hostContext?: McpAppHostContext;\n /** Rendered when no MCP app is on the part, or while load is in flight / failed (unless overridden). */\n fallback?: ReactNode;\n /** Rendered while the resource is loading. Defaults to `fallback`. */\n loadingFallback?: ReactNode;\n /** Rendered when the resource load rejects. Defaults to `fallback`. */\n errorFallback?: ReactNode | ((error: Error) => ReactNode);\n};\n\ntype LoadedResourceState = {\n resourceUri: string;\n resource?: McpAppResource;\n error?: Error;\n};\n\nfunction getInput(part: {\n status: { type: string };\n argsText: string;\n args: unknown;\n}): unknown {\n if (\n part.status.type === \"running\" &&\n (part.argsText === \"\" || part.argsText === \"{}\")\n ) {\n return undefined;\n }\n return part.args;\n}\n\nconst defaultOpenLink = ({ url }: { url: string }) => {\n window.open(url, \"_blank\", \"noopener,noreferrer\");\n};\n\nfunction extractSendMessageText(params: unknown): string | undefined {\n if (typeof params === \"string\") return params;\n if (!params || typeof params !== \"object\") return undefined;\n const obj = params as Record<string, unknown>;\n if (typeof obj[\"prompt\"] === \"string\") return obj[\"prompt\"];\n if (typeof obj[\"text\"] === \"string\") return obj[\"text\"];\n if (typeof obj[\"message\"] === \"string\") return obj[\"message\"];\n return undefined;\n}\n\nfunction InlineRenderer({\n part,\n internalsRef,\n optionsRef,\n}: {\n part: ToolCallMessagePartProps;\n internalsRef: MutableRefObject<{ host: McpAppsHost }>;\n optionsRef: MutableRefObject<McpAppRendererOptions>;\n}) {\n const opts = optionsRef.current;\n const aui = useAui();\n const app = getMcpAppFromToolPart(part);\n const cachedAppRef = useRef<McpAppMetadata | undefined>(undefined);\n if (app != null && cachedAppRef.current?.resourceUri !== app.resourceUri) {\n cachedAppRef.current = app;\n }\n const appForRender = app ?? cachedAppRef.current;\n\n const [loadedResource, setLoadedResource] = useState<LoadedResourceState>();\n\n const resourceUri = appForRender?.resourceUri;\n useEffect(() => {\n if (appForRender == null || resourceUri == null) return;\n let cancelled = false;\n const targetUri = resourceUri;\n\n internalsRef.current.host\n .loadResource({ uri: targetUri })\n .then((res) => {\n if (!cancelled)\n setLoadedResource({ resourceUri: targetUri, resource: res });\n })\n .catch((error: unknown) => {\n if (!cancelled) {\n setLoadedResource({\n resourceUri: targetUri,\n error: error instanceof Error ? error : new Error(String(error)),\n });\n }\n });\n\n return () => {\n cancelled = true;\n };\n // oxlint-disable-next-line tap-hooks/exhaustive-deps -- re-fetch only when URI changes; appForRender identity is unstable and internalsRef is a stable ref\n }, [resourceUri]);\n\n const bridgeHandlers = useMemo<McpAppBridgeHandlers>(\n () => ({\n openLink: defaultOpenLink,\n sendMessage: (params) => {\n const text = extractSendMessageText(params);\n if (!text) return { ok: false, reason: \"unrecognised params shape\" };\n aui.thread().append({ content: [{ type: \"text\", text }] });\n return { ok: true };\n },\n callTool: (params) => internalsRef.current.host.callTool(params),\n readResource: (params) => internalsRef.current.host.readResource(params),\n listResources: (params) =>\n internalsRef.current.host.listResources(params),\n }),\n [aui, internalsRef],\n );\n\n const loadedResourceForApp =\n loadedResource?.resourceUri === appForRender?.resourceUri\n ? loadedResource\n : undefined;\n const appResource = loadedResourceForApp?.resource;\n const error = loadedResourceForApp?.error;\n\n const fallback = opts.fallback ?? null;\n if (appForRender == null) {\n return <>{fallback}</>;\n }\n if (error != null) {\n const errorFallback = opts.errorFallback;\n if (errorFallback === undefined) return <>{fallback}</>;\n if (typeof errorFallback === \"function\") return <>{errorFallback(error)}</>;\n return <>{errorFallback}</>;\n }\n if (appResource == null) {\n return <>{opts.loadingFallback ?? fallback}</>;\n }\n\n return (\n <McpAppFrame\n app={appForRender}\n resource={appResource}\n input={getInput(part)}\n output={part.result}\n sandbox={opts.sandbox}\n handlers={bridgeHandlers}\n hostInfo={opts.hostInfo}\n hostContext={opts.hostContext}\n maxHeight={opts.maxHeight}\n />\n );\n}\n\n/**\n * Creates a tool-call renderer for MCP Apps embedded in assistant messages.\n *\n * Compose this into the `Tools` resource through its `mcpApp` option. When a\n * tool-call part carries `mcp.app` metadata for a `ui://` resource, the\n * renderer loads that resource from the configured host and displays it in a\n * sandboxed frame.\n */\nexport const McpAppRenderer = resource(\n (\n options: McpAppRendererOptions,\n ): { readonly render: ToolCallMessagePartComponent } => {\n const host = tapResource(options.host);\n\n const optionsRef = tapRef<McpAppRendererOptions>(options);\n optionsRef.current = options;\n\n const internalsRef = tapRef<{ host: McpAppsHost }>({ host });\n internalsRef.current = { host };\n\n const render = tapConst((): ToolCallMessagePartComponent => {\n const Render: ToolCallMessagePartComponent = (props) => (\n <InlineRenderer\n part={props}\n internalsRef={internalsRef}\n optionsRef={optionsRef}\n />\n );\n Render.displayName = \"McpAppRenderer\";\n return Render;\n }, []);\n\n return { render };\n },\n);\n"],"mappings":";;;;;;;;AAkEA,SAAS,SAAS,MAIN;CACV,IACE,KAAK,OAAO,SAAS,cACpB,KAAK,aAAa,MAAM,KAAK,aAAa,OAE3C;CAEF,OAAO,KAAK;AACd;AAEA,MAAM,mBAAmB,EAAE,UAA2B;CACpD,OAAO,KAAK,KAAK,UAAU,qBAAqB;AAClD;AAEA,SAAS,uBAAuB,QAAqC;CACnE,IAAI,OAAO,WAAW,UAAU,OAAO;CACvC,IAAI,CAAC,UAAU,OAAO,WAAW,UAAU,OAAO,KAAA;CAClD,MAAM,MAAM;CACZ,IAAI,OAAO,IAAI,cAAc,UAAU,OAAO,IAAI;CAClD,IAAI,OAAO,IAAI,YAAY,UAAU,OAAO,IAAI;CAChD,IAAI,OAAO,IAAI,eAAe,UAAU,OAAO,IAAI;AAErD;AAEA,SAAS,eAAe,EACtB,MACA,cACA,cAKC;CACD,MAAM,OAAO,WAAW;CACxB,MAAM,MAAM,OAAO;CACnB,MAAM,MAAM,sBAAsB,IAAI;CACtC,MAAM,eAAe,OAAmC,KAAA,CAAS;CACjE,IAAI,OAAO,QAAQ,aAAa,SAAS,gBAAgB,IAAI,aAC3D,aAAa,UAAU;CAEzB,MAAM,eAAe,OAAO,aAAa;CAEzC,MAAM,CAAC,gBAAgB,qBAAqB,SAA8B;CAE1E,MAAM,cAAc,cAAc;CAClC,gBAAgB;EACd,IAAI,gBAAgB,QAAQ,eAAe,MAAM;EACjD,IAAI,YAAY;EAChB,MAAM,YAAY;EAElB,aAAa,QAAQ,KAClB,aAAa,EAAE,KAAK,UAAU,CAAC,EAC/B,MAAM,QAAQ;GACb,IAAI,CAAC,WACH,kBAAkB;IAAE,aAAa;IAAW,UAAU;GAAI,CAAC;EAC/D,CAAC,EACA,OAAO,UAAmB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