@assistant-ui/core 0.3.8 → 0.3.10
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.
- package/dist/model-context/frame/provider.js +1 -3
- package/dist/model-context/frame/provider.js.map +1 -1
- package/dist/model-context/types.js +4 -2
- package/dist/model-context/types.js.map +1 -1
- package/dist/react/AssistantProvider.js +5 -4
- package/dist/react/AssistantProvider.js.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +2 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/client/Interactables.js +12 -10
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/model-context/useInteractable.js.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js +11 -8
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +27 -22
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +5 -4
- package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
- package/dist/react/runtimes/external-message-converter.js +3 -1
- package/dist/react/runtimes/external-message-converter.js.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.js +2 -1
- package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
- package/dist/runtime/api/message-runtime.js +4 -2
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +9 -5
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +9 -6
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +31 -28
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
- package/dist/subscribable/subscribable.js +6 -4
- package/dist/subscribable/subscribable.js.map +1 -1
- package/package.json +10 -10
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +5 -1
- package/src/runtimes/local/local-thread-runtime-core.test.ts +18 -22
- package/src/tests/external-store-thread-runtime-core.test.ts +36 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageGroupedParts.js","names":["Fragment","FC","ReactNode","useMemo","useAuiState","useShallow","PartState","MessagePartStatus","ToolCallMessagePartStatus","getGroupStatus","buildGroupTree","GROUPBY_MEMO_KEY","GroupByContext","GroupNode","MessagePartChildren","EnrichedPartState","MessagePrimitiveGroupedParts","GroupPart","type","TKey","status","indices","IndicatorPart","IndicatorMode","RenderInfo","part","children","Props","groupBy","context","indicator","info","shouldShowIndicator","mode","parts","isRunning","length","last","undefined","PartChildrenSentinel","Error","renderNode","node","render","idKey","index","groupPart","key","nodeKey","map","child","s","message","toolUIs","tools","memoKey","memoDep","tree","toolCallId","displayName"],"sources":["../../../../src/react/primitives/message/MessageGroupedParts.tsx"],"sourcesContent":["\"use client\";\n\nimport { Fragment, type FC, type ReactNode, useMemo } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useShallow } from \"zustand/shallow\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport type {\n MessagePartStatus,\n ToolCallMessagePartStatus,\n} from \"../../../types/message\";\nimport { getGroupStatus } from \"../../../utils/getGroupStatus\";\nimport {\n buildGroupTree,\n GROUPBY_MEMO_KEY,\n type GroupByContext,\n type GroupNode,\n} from \"../../utils/groupParts\";\nimport { MessagePartChildren, type EnrichedPartState } from \"./MessageParts\";\n\nexport namespace MessagePrimitiveGroupedParts {\n /**\n * A coalesced group of adjacent parts. Surfaced through the same\n * `{ part }` channel as a leaf {@link EnrichedPartState} so consumers\n * dispatch on a single `switch (part.type)`. `type` is the group key\n * (always `\"group-…\"`); `status` is running when any contained part runs,\n * otherwise it mirrors the last contained part.\n */\n export type GroupPart<TKey extends `group-${string}` = `group-${string}`> = {\n readonly type: TKey;\n readonly status: MessagePartStatus | ToolCallMessagePartStatus;\n readonly indices: readonly number[];\n };\n\n /**\n * Synthetic trailing slot for a streaming/loading affordance (a\n * \"thinking…\" dot, etc.). Surfaced through the same `{ part }` channel\n * as groups and leaf parts so a single `switch (part.type)` renders it\n * via `case \"indicator\"`.\n *\n * It is only ever emitted while the message is running, so its presence\n * alone means \"render your loading UI here\" — there's no `status` to\n * branch on.\n */\n export type IndicatorPart = {\n readonly type: \"indicator\";\n };\n\n /**\n * When to emit the synthetic {@link IndicatorPart}. It is **only** emitted\n * while the message is running (streaming); the mode further restricts\n * which running states qualify:\n * - `\"never\"` — never.\n * - `\"empty\"` — only when the message has no parts yet.\n * - `\"no-text\"` (default) — when the message has no parts yet or the last\n * part isn't `text`/`reasoning` (e.g. it ended on a tool call, so the\n * assistant likely isn't done).\n * - `\"always\"` — whenever the message is running, regardless of parts.\n */\n export type IndicatorMode = \"never\" | \"empty\" | \"no-text\" | \"always\";\n\n export type RenderInfo<TKey extends `group-${string}` = `group-${string}`> = {\n /**\n * Either a coalesced group ({@link GroupPart}, identified by a\n * `group-…` `type`), a single enriched leaf part, or the synthetic\n * {@link IndicatorPart} (`type: \"indicator\"`). Use one switch over\n * `part.type` to handle all three.\n */\n readonly part: GroupPart<TKey> | EnrichedPartState | IndicatorPart;\n /**\n * For group nodes: the recursively-rendered subtree (subgroups +\n * leaf parts). For leaf parts: a sentinel that throws when rendered\n * — accidental fall-through (`default: return children;`) errors\n * loudly instead of silently rendering nothing.\n */\n readonly children: ReactNode;\n };\n\n export type Props<TKey extends `group-${string}` = `group-${string}`> = {\n /**\n * Maps each part to a group-key path. Adjacent parts that share a\n * prefix coalesce into the same group. Return `[]` (or `null`) to\n * leave a part ungrouped.\n *\n * Group keys must start with `\"group-\"` so the renderer's\n * `switch (part.type)` can tell groups apart from real part types.\n *\n * **Prefer {@link groupPartByType}** for the common case of mapping by\n * `part.type` — it ships a stable memo fingerprint so the tree\n * survives unrelated re-renders. Use an inline function only when\n * the helper isn't expressive enough (e.g. branching on\n * `part.toolName` or part metadata).\n *\n * The second argument is a {@link GroupByContext} carrying the tool-UI\n * registry, for grouping that depends on it (e.g. standalone tool calls).\n *\n * @example\n * ```tsx\n * import { groupPartByType } from \"@assistant-ui/react\";\n *\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * })}\n * >\n * ```\n */\n readonly groupBy: (\n part: PartState,\n context: GroupByContext,\n ) => readonly TKey[] | null;\n\n /**\n * Controls emission of the synthetic {@link IndicatorPart} — a\n * trailing `{ part: { type: \"indicator\", status } }` render call you\n * handle with `case \"indicator\"` to show loading/status UI.\n *\n * @default \"no-text\"\n * @see IndicatorMode\n */\n readonly indicator?: IndicatorMode;\n\n /**\n * Render function called once per group node, once per leaf part, and\n * (when the `indicator` condition is met) once for the trailing\n * {@link IndicatorPart}. Switch on `part.type`: `\"group-…\"` cases wrap\n * `children`; real part types (`\"text\"`, `\"tool-call\"`, …) render the\n * part directly; `\"indicator\"` renders status/loading UI.\n *\n * Leaf parts receive the same {@link EnrichedPartState} that\n * `<MessagePrimitive.Parts>` would produce (`toolUI`, `addResult`,\n * `resume`, `respondToApproval`, `dataRendererUI`).\n */\n readonly children: (info: RenderInfo<TKey>) => ReactNode;\n };\n}\n\nconst shouldShowIndicator = (\n mode: MessagePrimitiveGroupedParts.IndicatorMode,\n parts: readonly PartState[],\n isRunning: boolean,\n): boolean => {\n // The indicator is a streaming affordance — never show it on a settled\n // message, whatever the mode.\n if (!isRunning) return false;\n\n switch (mode) {\n case \"never\":\n return false;\n case \"always\":\n return true;\n case \"empty\":\n return parts.length === 0;\n case \"no-text\": {\n const last = parts[parts.length - 1];\n return (\n last === undefined ||\n (last.type !== \"text\" && last.type !== \"reasoning\")\n );\n }\n }\n};\n\n/**\n * `children` placeholder passed for leaf-part renders. Leaf parts have no\n * inner subtree; rendering this sentinel signals the consumer wrote\n * `default: return children;` and accidentally fell through for a part —\n * surface the bug loudly instead of silently rendering nothing.\n */\nconst PartChildrenSentinel: FC = () => {\n throw new Error(\n \"MessagePrimitive.GroupedParts: rendered `children` under a leaf \" +\n \"part. `children` is only meaningful for `group-…` cases — add a \" +\n \"matching case for the part type or return `null` to skip it.\",\n );\n};\n\nconst renderNode = <TKey extends `group-${string}`>(\n node: GroupNode,\n parts: readonly PartState[],\n render: (info: MessagePrimitiveGroupedParts.RenderInfo<TKey>) => ReactNode,\n): ReactNode => {\n if (node.type === \"part\") {\n // Key by part identity when available, else absolute part index — never\n // the structural nodeKey, which leaves zombie fiber subscriptions when\n // parts reshape (#4051).\n return (\n <MessagePartChildren\n key={node.idKey ? `part-${node.idKey}` : `part-${node.index}`}\n index={node.index}\n >\n {({ part }) => render({ part, children: <PartChildrenSentinel /> })}\n </MessagePartChildren>\n );\n }\n\n const status = getGroupStatus(parts, node.indices);\n const groupPart: MessagePrimitiveGroupedParts.GroupPart<TKey> = {\n type: node.key as TKey,\n status,\n indices: node.indices,\n };\n\n return (\n <Fragment key={node.idKey ?? node.nodeKey}>\n {render({\n part: groupPart,\n children: (\n <>{node.children.map((child) => renderNode(child, parts, render))}</>\n ),\n })}\n </Fragment>\n );\n};\n\n/**\n * Groups adjacent message parts into a tree of coalesced runs and\n * renders each node — group or part — through a single `children`\n * function.\n *\n * The render function receives `{ part, children }` where `part.type`\n * is either a `\"group-…\"` literal (for a group, `children` is the\n * recursively-rendered subtree) or a real part type (`\"text\"`,\n * `\"tool-call\"`, …) for a leaf (`children` is a sentinel that throws\n * if rendered — use `part.type` to distinguish).\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * })}\n * >\n * {({ part, children }) => {\n * switch (part.type) {\n * case \"group-thought\": return <Thought>{children}</Thought>;\n * case \"group-reasoning\": return <Reasoning>{children}</Reasoning>;\n * case \"group-tool\": return <ToolStack>{children}</ToolStack>;\n * case \"text\": return <MarkdownText />;\n * case \"tool-call\": return part.toolUI ?? <ToolFallback {...part} />;\n * case \"indicator\": return <LoadingDots />;\n * default: return null;\n * }\n * }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const MessagePrimitiveGroupedParts = <TKey extends `group-${string}`>({\n groupBy,\n indicator = \"no-text\",\n children,\n}: MessagePrimitiveGroupedParts.Props<TKey>): ReactNode => {\n const parts = useAuiState(useShallow((s) => s.message.parts));\n // Handed to `groupBy` as its `context` argument (see GroupByContext).\n const toolUIs = useAuiState((s) => s.tools.toolUIs);\n // Subscribe to a boolean, not the status object: the tree only needs to\n // re-render when running-ness flips, and `\"never\"` opts out entirely.\n const isRunning = useAuiState((s) =>\n indicator === \"never\" ? false : s.message.status?.type === \"running\",\n );\n\n // Helpers like `groupPartByType` tag the function with `GROUPBY_MEMO_KEY`\n // (a stable string fingerprint of the helper config). When present,\n // memo on `[parts, memoKey]` so the tree survives unrelated renders.\n // For inline `groupBy`, fall back to recomputing each render — O(n)\n // and cheap.\n const memoKey = (groupBy as { [GROUPBY_MEMO_KEY]?: string })[\n GROUPBY_MEMO_KEY\n ];\n const memoDep = memoKey ?? groupBy;\n const tree = useMemo(() => {\n const context: GroupByContext = { toolUIs };\n return buildGroupTree(\n parts.map((part) => groupBy(part, context) ?? []),\n parts.map((part) =>\n part.type === \"tool-call\" ? part.toolCallId : undefined,\n ),\n );\n // oxlint-disable-next-line react/exhaustive-deps -- groupBy is captured via memoDep (either its identity or the helper's memoKey fingerprint); listing it directly would defeat the helper-tagged memo path\n }, [parts, memoDep, toolUIs]);\n\n return (\n <>\n {tree.map((node) => renderNode(node, parts, children))}\n {shouldShowIndicator(indicator, parts, isRunning) &&\n children({\n part: { type: \"indicator\" },\n children: <PartChildrenSentinel />,\n })}\n </>\n );\n};\n\nMessagePrimitiveGroupedParts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MAAMmB,UAAUjD,aAAa+C,QAAMA,IAAEG,MAAMD,OAAO;CAGlD,MAAMlB,YAAY/B,aAAa+C,QAC7BrB,cAAc,UAAU,QAAQqB,IAAEC,QAAQhC,QAAQF,SAAS,SAC7D;CAsBA,OACE,qBAAA,YAAA,EAAA,UAAA,CAZWf,cAAc;EACzB,MAAM0B,UAA0B,EAAEwB,QAAQ;EAC1C,OAAO3C,eACLwB,MAAMe,KAAKxB,SAASG,QAAQH,MAAMI,OAAO,KAAK,CAAA,CAAE,GAChDK,MAAMe,KAAKxB,WACTA,OAAKP,SAAS,cAAcO,OAAKiC,aAAapB,KAAAA,CAChD,CACF;CAEF,GAAG;EAACJ;EAbaN,QACfjB,qBAEyBiB;EAUPyB;CAAO,CAItBI,CAAI,CAACR,KAAKP,SAASD,WAAWC,MAAMR,OAAOR,QAAQ,CAAC,GACpDM,oBAAoBF,WAAWI,OAAOC,SAAS,KAC9CT,SAAS;EACPD,MAAM,EAAEP,MAAM,YAAY;EAC1BQ,UAAU,oBAAC,sBAAD,CAAqB,CAAA;CACjC,CAAC,CACL,EAAA,CAAA;AAEJ;AAEAV,6BAA6B2C,cAAc"}
|
|
1
|
+
{"version":3,"file":"MessageGroupedParts.js","names":["Fragment","FC","ReactNode","useMemo","useAuiState","useShallow","PartState","MessagePartStatus","ToolCallMessagePartStatus","getGroupStatus","buildGroupTree","GROUPBY_MEMO_KEY","GroupByContext","GroupNode","MessagePartChildren","EnrichedPartState","MessagePrimitiveGroupedParts","GroupPart","type","TKey","status","indices","IndicatorPart","IndicatorMode","RenderInfo","part","children","Props","groupBy","context","indicator","info","shouldShowIndicator","mode","parts","isRunning","length","last","undefined","PartChildrenSentinel","Error","renderNode","node","render","idKey","index","groupPart","key","nodeKey","map","child","s","message","toolUIs","tools","memoKey","memoDep","tree","toolCallId","displayName"],"sources":["../../../../src/react/primitives/message/MessageGroupedParts.tsx"],"sourcesContent":["\"use client\";\n\nimport { Fragment, type FC, type ReactNode, useMemo } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useShallow } from \"zustand/shallow\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport type {\n MessagePartStatus,\n ToolCallMessagePartStatus,\n} from \"../../../types/message\";\nimport { getGroupStatus } from \"../../../utils/getGroupStatus\";\nimport {\n buildGroupTree,\n GROUPBY_MEMO_KEY,\n type GroupByContext,\n type GroupNode,\n} from \"../../utils/groupParts\";\nimport { MessagePartChildren, type EnrichedPartState } from \"./MessageParts\";\n\nexport namespace MessagePrimitiveGroupedParts {\n /**\n * A coalesced group of adjacent parts. Surfaced through the same\n * `{ part }` channel as a leaf {@link EnrichedPartState} so consumers\n * dispatch on a single `switch (part.type)`. `type` is the group key\n * (always `\"group-…\"`); `status` is running when any contained part runs,\n * otherwise it mirrors the last contained part.\n */\n export type GroupPart<TKey extends `group-${string}` = `group-${string}`> = {\n readonly type: TKey;\n readonly status: MessagePartStatus | ToolCallMessagePartStatus;\n readonly indices: readonly number[];\n };\n\n /**\n * Synthetic trailing slot for a streaming/loading affordance (a\n * \"thinking…\" dot, etc.). Surfaced through the same `{ part }` channel\n * as groups and leaf parts so a single `switch (part.type)` renders it\n * via `case \"indicator\"`.\n *\n * It is only ever emitted while the message is running, so its presence\n * alone means \"render your loading UI here\" — there's no `status` to\n * branch on.\n */\n export type IndicatorPart = {\n readonly type: \"indicator\";\n };\n\n /**\n * When to emit the synthetic {@link IndicatorPart}. It is **only** emitted\n * while the message is running (streaming); the mode further restricts\n * which running states qualify:\n * - `\"never\"` — never.\n * - `\"empty\"` — only when the message has no parts yet.\n * - `\"no-text\"` (default) — when the message has no parts yet or the last\n * part isn't `text`/`reasoning` (e.g. it ended on a tool call, so the\n * assistant likely isn't done).\n * - `\"always\"` — whenever the message is running, regardless of parts.\n */\n export type IndicatorMode = \"never\" | \"empty\" | \"no-text\" | \"always\";\n\n export type RenderInfo<TKey extends `group-${string}` = `group-${string}`> = {\n /**\n * Either a coalesced group ({@link GroupPart}, identified by a\n * `group-…` `type`), a single enriched leaf part, or the synthetic\n * {@link IndicatorPart} (`type: \"indicator\"`). Use one switch over\n * `part.type` to handle all three.\n */\n readonly part: GroupPart<TKey> | EnrichedPartState | IndicatorPart;\n /**\n * For group nodes: the recursively-rendered subtree (subgroups +\n * leaf parts). For leaf parts: a sentinel that throws when rendered\n * — accidental fall-through (`default: return children;`) errors\n * loudly instead of silently rendering nothing.\n */\n readonly children: ReactNode;\n };\n\n export type Props<TKey extends `group-${string}` = `group-${string}`> = {\n /**\n * Maps each part to a group-key path. Adjacent parts that share a\n * prefix coalesce into the same group. Return `[]` (or `null`) to\n * leave a part ungrouped.\n *\n * Group keys must start with `\"group-\"` so the renderer's\n * `switch (part.type)` can tell groups apart from real part types.\n *\n * **Prefer {@link groupPartByType}** for the common case of mapping by\n * `part.type` — it ships a stable memo fingerprint so the tree\n * survives unrelated re-renders. Use an inline function only when\n * the helper isn't expressive enough (e.g. branching on\n * `part.toolName` or part metadata).\n *\n * The second argument is a {@link GroupByContext} carrying the tool-UI\n * registry, for grouping that depends on it (e.g. standalone tool calls).\n *\n * @example\n * ```tsx\n * import { groupPartByType } from \"@assistant-ui/react\";\n *\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * })}\n * >\n * ```\n */\n readonly groupBy: (\n part: PartState,\n context: GroupByContext,\n ) => readonly TKey[] | null;\n\n /**\n * Controls emission of the synthetic {@link IndicatorPart} — a\n * trailing `{ part: { type: \"indicator\", status } }` render call you\n * handle with `case \"indicator\"` to show loading/status UI.\n *\n * @default \"no-text\"\n * @see IndicatorMode\n */\n readonly indicator?: IndicatorMode;\n\n /**\n * Render function called once per group node, once per leaf part, and\n * (when the `indicator` condition is met) once for the trailing\n * {@link IndicatorPart}. Switch on `part.type`: `\"group-…\"` cases wrap\n * `children`; real part types (`\"text\"`, `\"tool-call\"`, …) render the\n * part directly; `\"indicator\"` renders status/loading UI.\n *\n * Leaf parts receive the same {@link EnrichedPartState} that\n * `<MessagePrimitive.Parts>` would produce (`toolUI`, `addResult`,\n * `resume`, `respondToApproval`, `dataRendererUI`).\n */\n readonly children: (info: RenderInfo<TKey>) => ReactNode;\n };\n}\n\nconst shouldShowIndicator = (\n mode: MessagePrimitiveGroupedParts.IndicatorMode,\n parts: readonly PartState[],\n isRunning: boolean,\n): boolean => {\n // The indicator is a streaming affordance — never show it on a settled\n // message, whatever the mode.\n if (!isRunning) return false;\n\n switch (mode) {\n case \"never\":\n return false;\n case \"always\":\n return true;\n case \"empty\":\n return parts.length === 0;\n case \"no-text\": {\n const last = parts[parts.length - 1];\n return (\n last === undefined ||\n (last.type !== \"text\" && last.type !== \"reasoning\")\n );\n }\n }\n};\n\n/**\n * `children` placeholder passed for leaf-part renders. Leaf parts have no\n * inner subtree; rendering this sentinel signals the consumer wrote\n * `default: return children;` and accidentally fell through for a part —\n * surface the bug loudly instead of silently rendering nothing.\n */\nconst PartChildrenSentinel: FC = () => {\n throw new Error(\n \"MessagePrimitive.GroupedParts: rendered `children` under a leaf \" +\n \"part. `children` is only meaningful for `group-…` cases — add a \" +\n \"matching case for the part type or return `null` to skip it.\",\n );\n};\n\nconst renderNode = <TKey extends `group-${string}`>(\n node: GroupNode,\n parts: readonly PartState[],\n render: (info: MessagePrimitiveGroupedParts.RenderInfo<TKey>) => ReactNode,\n): ReactNode => {\n if (node.type === \"part\") {\n // Key by part identity when available, else absolute part index — never\n // the structural nodeKey, which leaves zombie fiber subscriptions when\n // parts reshape (#4051).\n return (\n <MessagePartChildren\n key={node.idKey ? `part-${node.idKey}` : `part-${node.index}`}\n index={node.index}\n >\n {({ part }) => render({ part, children: <PartChildrenSentinel /> })}\n </MessagePartChildren>\n );\n }\n\n const status = getGroupStatus(parts, node.indices);\n const groupPart: MessagePrimitiveGroupedParts.GroupPart<TKey> = {\n type: node.key as TKey,\n status,\n indices: node.indices,\n };\n\n return (\n <Fragment key={node.idKey ?? node.nodeKey}>\n {render({\n part: groupPart,\n children: (\n <>{node.children.map((child) => renderNode(child, parts, render))}</>\n ),\n })}\n </Fragment>\n );\n};\n\n/**\n * Groups adjacent message parts into a tree of coalesced runs and\n * renders each node — group or part — through a single `children`\n * function.\n *\n * The render function receives `{ part, children }` where `part.type`\n * is either a `\"group-…\"` literal (for a group, `children` is the\n * recursively-rendered subtree) or a real part type (`\"text\"`,\n * `\"tool-call\"`, …) for a leaf (`children` is a sentinel that throws\n * if rendered — use `part.type` to distinguish).\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * })}\n * >\n * {({ part, children }) => {\n * switch (part.type) {\n * case \"group-thought\": return <Thought>{children}</Thought>;\n * case \"group-reasoning\": return <Reasoning>{children}</Reasoning>;\n * case \"group-tool\": return <ToolStack>{children}</ToolStack>;\n * case \"text\": return <MarkdownText />;\n * case \"tool-call\": return part.toolUI ?? <ToolFallback {...part} />;\n * case \"indicator\": return <LoadingDots />;\n * default: return null;\n * }\n * }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const MessagePrimitiveGroupedParts = <TKey extends `group-${string}`>({\n groupBy,\n indicator = \"no-text\",\n children,\n}: MessagePrimitiveGroupedParts.Props<TKey>): ReactNode => {\n const parts = useAuiState(useShallow((s) => s.message.parts));\n // Handed to `groupBy` as its `context` argument (see GroupByContext).\n const toolUIs = useAuiState((s) => s.tools.toolUIs);\n // Subscribe to a boolean, not the status object: the tree only needs to\n // re-render when running-ness flips, and `\"never\"` opts out entirely.\n const isRunning = useAuiState((s) =>\n indicator === \"never\" ? false : s.message.status?.type === \"running\",\n );\n\n // Helpers like `groupPartByType` tag the function with `GROUPBY_MEMO_KEY`\n // (a stable string fingerprint of the helper config). When present,\n // memo on `[parts, memoKey]` so the tree survives unrelated renders.\n // For inline `groupBy`, fall back to recomputing each render — O(n)\n // and cheap.\n const memoKey = (groupBy as { [GROUPBY_MEMO_KEY]?: string })[\n GROUPBY_MEMO_KEY\n ];\n const memoDep = memoKey ?? groupBy;\n const tree = useMemo(() => {\n const context: GroupByContext = { toolUIs };\n return buildGroupTree(\n parts.map((part) => groupBy(part, context) ?? []),\n parts.map((part) =>\n part.type === \"tool-call\" ? part.toolCallId : undefined,\n ),\n );\n // oxlint-disable-next-line react/exhaustive-deps -- groupBy is captured via memoDep (either its identity or the helper's memoKey fingerprint); listing it directly would defeat the helper-tagged memo path\n }, [parts, memoDep, toolUIs]);\n\n return (\n <>\n {tree.map((node) => renderNode(node, parts, children))}\n {shouldShowIndicator(indicator, parts, isRunning) &&\n children({\n part: { type: \"indicator\" },\n children: <PartChildrenSentinel />,\n })}\n </>\n );\n};\n\nMessagePrimitiveGroupedParts.displayName = \"MessagePrimitive.GroupedParts\";\n"],"mappings":";;;;;;;;;AAyIA,MAAMgC,uBACJC,MACAC,OACAC,cACY;CAGZ,IAAI,CAACA,WAAW,OAAO;CAEvB,QAAQF,MAAR;EACE,KAAK,SACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,SACH,OAAOC,MAAME,WAAW;EAC1B,KAAK,WAAW;GACd,MAAMC,OAAOH,MAAMA,MAAME,SAAS;GAClC,OACEC,SAASC,KAAAA,KACRD,KAAKnB,SAAS,UAAUmB,KAAKnB,SAAS;EAE3C;CACF;AACF;;;;;;;AAQA,MAAMqB,6BAAiC;CACrC,MAAM,IAAIC,MACR,8LAGF;AACF;AAEA,MAAMC,cACJC,MACAR,OACAS,WACc;CACd,IAAID,KAAKxB,SAAS,QAIhB,OACE,oBAAC,qBAAD;EAEE,OAAOwB,KAAKG;EAEV,WAAA,EAAEpB,WAAWkB,OAAO;GAAElB;GAAMC,UAAU,oBAAC,sBAAD,CAAqB,CAAA;EAAI,CAAC;CAC/C,GAJdgB,KAAKE,QAAQ,QAAQF,KAAKE,UAAU,QAAQF,KAAKG,OAInC;CAIzB,MAA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;CACjC,CAAC,CACL,EAAA,CAAA;AAEJ;AAEAV,6BAA6B2C,cAAc"}
|
|
@@ -779,28 +779,33 @@ const MessagePrimitivePartsCompat = (t0) => {
|
|
|
779
779
|
endIndex: range.endIndex,
|
|
780
780
|
children: /* @__PURE__ */ jsx(ChainOfThoughtComponent, {})
|
|
781
781
|
}, `chainOfThought-${range.idKey ?? range.startIndex}`);
|
|
782
|
-
} else if (range.type === "toolGroup")
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
782
|
+
} else if (range.type === "toolGroup") {
|
|
783
|
+
const ToolGroupComponent = components?.ToolGroup ?? defaultComponents.ToolGroup;
|
|
784
|
+
return /* @__PURE__ */ jsx(ToolGroupComponent, {
|
|
785
|
+
startIndex: range.startIndex,
|
|
786
|
+
endIndex: range.endIndex,
|
|
787
|
+
children: Array.from({ length: range.endIndex - range.startIndex + 1 }, (_, i) => {
|
|
788
|
+
const partIndex_0 = range.startIndex + i;
|
|
789
|
+
return /* @__PURE__ */ jsx(MessagePrimitivePartByIndex, {
|
|
790
|
+
index: partIndex_0,
|
|
791
|
+
components
|
|
792
|
+
}, toolLeafKey(partIndex_0));
|
|
793
|
+
})
|
|
794
|
+
}, `tool-${range.idKey ?? range.startIndex}`);
|
|
795
|
+
} else {
|
|
796
|
+
const ReasoningGroupComponent = components?.ReasoningGroup ?? defaultComponents.ReasoningGroup;
|
|
797
|
+
return /* @__PURE__ */ jsx(ReasoningGroupComponent, {
|
|
798
|
+
startIndex: range.startIndex,
|
|
799
|
+
endIndex: range.endIndex,
|
|
800
|
+
children: Array.from({ length: range.endIndex - range.startIndex + 1 }, (__0, i_0) => {
|
|
801
|
+
const partIndex_1 = range.startIndex + i_0;
|
|
802
|
+
return /* @__PURE__ */ jsx(MessagePrimitivePartByIndex, {
|
|
803
|
+
index: partIndex_1,
|
|
804
|
+
components
|
|
805
|
+
}, `part-${partIndex_1}`);
|
|
806
|
+
})
|
|
807
|
+
}, `reasoning-${range.startIndex}`);
|
|
808
|
+
}
|
|
804
809
|
});
|
|
805
810
|
$[2] = components;
|
|
806
811
|
$[3] = messageRanges;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageParts.js","names":["ComponentType","FC","ReactNode","memo","PropsWithChildren","useMemo","RenderChildrenWithAccessor","useAuiState","useAui","PartState","PartByIndexProvider","TextMessagePartProvider","ChainOfThoughtByIndicesProvider","getMessageQuote","Unstable_AudioMessagePartComponent","DataMessagePartComponent","DataMessagePartProps","EmptyMessagePartComponent","TextMessagePartComponent","ImageMessagePartComponent","SourceMessagePartComponent","ToolCallMessagePartComponent","ToolCallMessagePartProps","FileMessagePartComponent","ReasoningMessagePartComponent","ReasoningGroupComponent","QuoteMessagePartComponent","GenerativeUIComponentRegistry","GenerativeUIRender","isMcpAppUri","MessagePartStatus","GenerativeUIMessagePart","DataRenderersState","ToolsState","useShallow","MessagePartRange","type","index","startIndex","endIndex","idKey","createGroupState","groupType","T","start","startGroup","endGroup","ranges","push","finalize","groupMessageParts","messageTypes","useChainOfThought","partIds","chainOfThoughtGroup","i","length","toolGroup","reasoningGroup","claimed","Set","range","id","undefined","has","add","useMessagePartsGroups","$","_c","_temp2","_temp4","t0","bb0","t1","Symbol","for","t2","MessagePrimitiveParts","DataConfig","by_name","Record","Fallback","BaseComponents","Empty","Text","Source","Image","File","Unstable_Audio","data","Quote","generativeUI","components","component","props","ToolsConfig","Override","StandardComponents","Reasoning","tools","ToolGroup","ReasoningGroup","ChainOfThought","ChainOfThoughtComponents","Props","unstable_showEmptyOnNonTextEnd","children","value","part","EnrichedPartState","ToolUIDisplay","toolName","s","toolUIs","render","Render","getDataRenderer","dataRenderers","name","inlineFallback","named","renderers","fallbacks","DataUIDisplay","defaultComponents","MessagePartComponentProps","MessagePartComponent","t3","t4","t5","t6","t7","t8","t9","Audio","t10","aui","_temp5","addResult","addToolResult","resume","resumeToolCall","respondToApproval","respondToToolApproval","t11","Tool","status","Error","Data","process","env","NODE_ENV","console","warn","t12","spec","MessagePrimitivePartByIndex","prev","next","displayName","EmptyPartFallback","Component","COMPLETE_STATUS","Object","freeze","RUNNING_STATUS","EmptyPartsImpl","_temp6","EmptyParts","ConditionalEmptyImpl","enabled","message","parts","lastPart","shouldShowEmpty","ConditionalEmpty","QuoteRendererImpl","quoteInfo","messageId","text","QuoteRenderer","resolveToolRender","toolsState","Extract","mcp","app","resourceUri","mcpApp","RegisteredToolUI","_temp7","_temp8","RegisteredDataRendererUI","_temp9","_temp0","DefaultPartFallback","partType","_temp1","toolUI","dataRendererUI","Exclude","EMPTY_RUNNING_TEXT_PART","MessagePartChildrenProps","MessagePartChildrenInner","Pick","client","getState","getItem","state","hasUI","partMethods","MessagePartChildren","MessagePrimitivePartsInner","contentLength","_temp10","isRunning","_temp11","isEmptyRunning","_","Array","from","MessagePrimitivePartsCompat","_temp12","messageRanges","toolLeafKey","partIndex","map","ChainOfThoughtComponent","ToolGroupComponent","partIndex_0","__0","i_0","partIndex_1","partsElements","_temp","c","_temp3","c_0","toolCallId","s_0"],"sources":["../../../../src/react/primitives/message/MessageParts.tsx"],"sourcesContent":["import {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n type PropsWithChildren,\n useMemo,\n} from \"react\";\nimport {\n RenderChildrenWithAccessor,\n useAuiState,\n useAui,\n} from \"@assistant-ui/store\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport { PartByIndexProvider } from \"../../providers/PartByIndexProvider\";\nimport { TextMessagePartProvider } from \"../../providers/TextMessagePartProvider\";\nimport { ChainOfThoughtByIndicesProvider } from \"../../providers/ChainOfThoughtByIndicesProvider\";\nimport { getMessageQuote } from \"../../utils/getMessageQuote\";\nimport type {\n Unstable_AudioMessagePartComponent,\n DataMessagePartComponent,\n DataMessagePartProps,\n EmptyMessagePartComponent,\n TextMessagePartComponent,\n ImageMessagePartComponent,\n SourceMessagePartComponent,\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n FileMessagePartComponent,\n ReasoningMessagePartComponent,\n ReasoningGroupComponent,\n QuoteMessagePartComponent,\n GenerativeUIComponentRegistry,\n} from \"../../types/MessagePartComponentTypes\";\nimport { GenerativeUIRender } from \"../generativeUI/GenerativeUI\";\nimport {\n isMcpAppUri,\n type MessagePartStatus,\n type GenerativeUIMessagePart,\n} from \"../../../types/message\";\nimport type { DataRenderersState } from \"../../types/scopes/dataRenderers\";\nimport type { ToolsState } from \"../../types/scopes/tools\";\nimport { useShallow } from \"zustand/shallow\";\n\ntype MessagePartRange =\n | { type: \"single\"; index: number }\n | {\n type: \"toolGroup\";\n startIndex: number;\n endIndex: number;\n idKey?: string | undefined;\n }\n | {\n type: \"reasoningGroup\";\n startIndex: number;\n endIndex: number;\n idKey?: string | undefined;\n }\n | {\n type: \"chainOfThoughtGroup\";\n startIndex: number;\n endIndex: number;\n idKey?: string | undefined;\n };\n\n/**\n * Creates a group state manager for a specific part type.\n * Returns functions to start, end, and finalize groups.\n */\nconst createGroupState = <\n T extends \"toolGroup\" | \"reasoningGroup\" | \"chainOfThoughtGroup\",\n>(\n groupType: T,\n) => {\n let start = -1;\n\n return {\n startGroup: (index: number) => {\n if (start === -1) {\n start = index;\n }\n },\n endGroup: (endIndex: number, ranges: MessagePartRange[]) => {\n if (start !== -1) {\n ranges.push({\n type: groupType,\n startIndex: start,\n endIndex,\n } as MessagePartRange);\n start = -1;\n }\n },\n finalize: (endIndex: number, ranges: MessagePartRange[]) => {\n if (start !== -1) {\n ranges.push({\n type: groupType,\n startIndex: start,\n endIndex,\n } as MessagePartRange);\n }\n },\n };\n};\n\n/**\n * Groups consecutive tool-call and reasoning message parts into ranges.\n * Always groups tool calls and reasoning parts, even if there's only one.\n * When useChainOfThought is true, groups tool-call and reasoning parts together.\n * `partIds[i]` optionally carries a stable identity for part `i`; group\n * ranges derive an `idKey` from their first part's id (first claim wins).\n */\nexport const groupMessageParts = (\n messageTypes: readonly string[],\n useChainOfThought: boolean,\n partIds?: readonly (string | undefined)[],\n): MessagePartRange[] => {\n const ranges: MessagePartRange[] = [];\n\n if (useChainOfThought) {\n const chainOfThoughtGroup = createGroupState(\"chainOfThoughtGroup\");\n\n for (let i = 0; i < messageTypes.length; i++) {\n const type = messageTypes[i];\n\n if (type === \"tool-call\" || type === \"reasoning\") {\n chainOfThoughtGroup.startGroup(i);\n } else {\n chainOfThoughtGroup.endGroup(i - 1, ranges);\n ranges.push({ type: \"single\", index: i });\n }\n }\n\n chainOfThoughtGroup.finalize(messageTypes.length - 1, ranges);\n } else {\n const toolGroup = createGroupState(\"toolGroup\");\n const reasoningGroup = createGroupState(\"reasoningGroup\");\n\n for (let i = 0; i < messageTypes.length; i++) {\n const type = messageTypes[i];\n\n if (type === \"tool-call\") {\n reasoningGroup.endGroup(i - 1, ranges);\n toolGroup.startGroup(i);\n } else if (type === \"reasoning\") {\n toolGroup.endGroup(i - 1, ranges);\n reasoningGroup.startGroup(i);\n } else {\n toolGroup.endGroup(i - 1, ranges);\n reasoningGroup.endGroup(i - 1, ranges);\n ranges.push({ type: \"single\", index: i });\n }\n }\n\n toolGroup.finalize(messageTypes.length - 1, ranges);\n reasoningGroup.finalize(messageTypes.length - 1, ranges);\n }\n\n if (partIds) {\n const claimed = new Set<string>();\n for (const range of ranges) {\n if (range.type === \"single\") continue;\n const id = partIds[range.startIndex];\n if (id !== undefined && !claimed.has(id)) {\n claimed.add(id);\n range.idKey = `id:${id}`;\n }\n }\n }\n\n return ranges;\n};\n\nconst useMessagePartsGroups = (\n useChainOfThought: boolean,\n): { ranges: MessagePartRange[]; partIds: (string | undefined)[] } => {\n const messageTypes = useAuiState(\n useShallow((s) => s.message.parts.map((c: any) => c.type)),\n );\n const partIds = useAuiState(\n useShallow((s) =>\n s.message.parts.map((c: any) =>\n c.type === \"tool-call\" ? c.toolCallId : undefined,\n ),\n ),\n );\n\n return useMemo(() => {\n if (messageTypes.length === 0) {\n return { ranges: [], partIds };\n }\n return {\n ranges: groupMessageParts(messageTypes, useChainOfThought, partIds),\n partIds,\n };\n }, [messageTypes, partIds, useChainOfThought]);\n};\n\nexport namespace MessagePrimitiveParts {\n type DataConfig = {\n /** Map data event names to specific components */\n by_name?: Record<string, DataMessagePartComponent | undefined> | undefined;\n /** Fallback component for unmatched data events */\n Fallback?: DataMessagePartComponent | undefined;\n };\n\n type BaseComponents = {\n /** Component for rendering empty messages */\n Empty?: EmptyMessagePartComponent | undefined;\n /** Component for rendering text content */\n Text?: TextMessagePartComponent | undefined;\n /** Component for rendering source content */\n Source?: SourceMessagePartComponent | undefined;\n /** Component for rendering image content */\n Image?: ImageMessagePartComponent | undefined;\n /** Component for rendering file content */\n File?: FileMessagePartComponent | undefined;\n /**\n * Component for rendering audio content.\n *\n * @deprecated Render audio through the `File` slot instead, branching on an\n * `audio/*` mime type.\n */\n Unstable_Audio?: Unstable_AudioMessagePartComponent | undefined;\n /** Configuration for data part rendering */\n data?: DataConfig | undefined;\n /** Component for rendering a quoted message reference (from metadata, not parts) */\n Quote?: QuoteMessagePartComponent | undefined;\n /**\n * Configuration for generative-ui part rendering.\n *\n * `components` is the consumer-provided allowlist of React components\n * the agent's JSON spec is permitted to render. Any name not present in\n * the registry is rejected with a typed `GenerativeUIRenderError` —\n * this is the security boundary in the same-realm rendering path.\n */\n generativeUI?:\n | {\n /** The component allowlist (the security boundary). */\n components: GenerativeUIComponentRegistry;\n /** Optional fallback for unknown component names. */\n Fallback?:\n | ComponentType<{ component: string; props?: unknown }>\n | undefined;\n }\n | undefined;\n };\n\n type ToolsConfig =\n | {\n /** Map of tool names to their specific components */\n by_name?:\n | Record<string, ToolCallMessagePartComponent | undefined>\n | undefined;\n /** Fallback component for unregistered tools */\n Fallback?: ComponentType<ToolCallMessagePartProps> | undefined;\n }\n | {\n /** Override component that handles all tool calls */\n Override: ComponentType<ToolCallMessagePartProps>;\n };\n\n /**\n * Standard component configuration for rendering reasoning and tool-call parts\n * individually (with optional grouping).\n *\n * Cannot be combined with `ChainOfThought`.\n */\n type StandardComponents = BaseComponents & {\n /** Component for rendering reasoning content (typically hidden) */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Configuration for tool call rendering */\n tools?: ToolsConfig | undefined;\n\n /**\n * Component for rendering grouped consecutive tool calls.\n *\n * @param startIndex - Index of the first tool call in the group\n * @param endIndex - Index of the last tool call in the group\n * @param children - Rendered tool call components to display within the group\n *\n * @deprecated Use `<MessagePrimitive.GroupedParts>` with a custom `groupBy` instead.\n */\n ToolGroup?: ComponentType<\n PropsWithChildren<{ startIndex: number; endIndex: number }>\n >;\n\n /**\n * Component for rendering grouped reasoning parts.\n *\n * @param startIndex - Index of the first reasoning part in the group\n * @param endIndex - Index of the last reasoning part in the group\n * @param children - Rendered reasoning part components\n *\n * @deprecated Use `<MessagePrimitive.GroupedParts>` with a custom `groupBy` instead.\n */\n ReasoningGroup?: ReasoningGroupComponent;\n\n ChainOfThought?: never;\n };\n\n /**\n * Chain of thought component configuration.\n *\n * When `ChainOfThought` is set, it takes control of rendering ALL reasoning and\n * tool-call parts in the message. The `Reasoning`, `tools`, `ReasoningGroup`, and\n * `ToolGroup` components cannot be used alongside it.\n */\n type ChainOfThoughtComponents = BaseComponents & {\n /**\n * @deprecated Use `<MessagePrimitive.GroupedParts>` with a `groupBy`\n * that returns `[\"group-thought\", ...]` for reasoning and tool-call\n * parts. See `@assistant-ui/ui` for a worked example.\n */\n ChainOfThought: ComponentType;\n\n Reasoning?: never;\n tools?: never;\n ToolGroup?: never;\n ReasoningGroup?: never;\n };\n\n export type Props =\n | {\n /**\n * Component configuration for rendering different types of message content.\n *\n * Use either `Reasoning`/`tools`/`ToolGroup`/`ReasoningGroup` for standard rendering,\n * or `ChainOfThought` to group all reasoning and tool-call parts into a single\n * collapsible component. These two modes are mutually exclusive.\n */\n components?: StandardComponents | ChainOfThoughtComponents | undefined;\n /**\n * When enabled, shows the Empty component if the last part in the message\n * is anything other than Text or Reasoning.\n *\n * @experimental This API is experimental and may change in future versions.\n * @default true\n */\n unstable_showEmptyOnNonTextEnd?: boolean | undefined;\n children?: never;\n }\n | {\n /** Render function called for each part. Receives the enriched part state. */\n children: (value: { part: EnrichedPartState }) => ReactNode;\n components?: never;\n unstable_showEmptyOnNonTextEnd?: never;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallMessagePartComponent | undefined;\n} & ToolCallMessagePartProps) => {\n const Render = useAuiState(\n (s) => s.tools.toolUIs[props.toolName]?.[0]?.render ?? Fallback,\n );\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst getDataRenderer = (\n dataRenderers: DataRenderersState,\n name: string,\n inlineFallback: DataMessagePartComponent | undefined,\n): DataMessagePartComponent | undefined => {\n const named = dataRenderers.renderers[name]?.[0];\n if (named) return named;\n return dataRenderers.fallbacks[0] ?? inlineFallback;\n};\n\nconst DataUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: DataMessagePartComponent | undefined;\n} & DataMessagePartProps) => {\n const Render = useAuiState((s) =>\n getDataRenderer(s.dataRenderers, props.name, Fallback),\n );\n if (!Render) return null;\n return <Render {...props} />;\n};\n\n/**\n * Platform-agnostic no-op default components.\n * Each platform (web, RN) wraps MessagePrimitiveParts with its own defaults.\n */\nexport const defaultComponents = {\n Text: () => null,\n Reasoning: () => null,\n Source: () => null,\n Image: () => null,\n File: () => null,\n Unstable_Audio: () => null,\n ToolGroup: ({ children }: PropsWithChildren) => children,\n ReasoningGroup: ({ children }: PropsWithChildren) => children,\n} satisfies MessagePrimitiveParts.Props[\"components\"];\n\ntype MessagePartComponentProps = {\n components: MessagePrimitiveParts.Props[\"components\"];\n};\n\nexport const MessagePartComponent: FC<MessagePartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Reasoning = defaultComponents.Reasoning,\n Image = defaultComponents.Image,\n Source = defaultComponents.Source,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n tools = {},\n data,\n generativeUI,\n } = {},\n}) => {\n const aui = useAui();\n const part = useAuiState((s) => s.part);\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = aui.part.addToolResult;\n const resume = aui.part.resumeToolCall;\n const respondToApproval = aui.part.respondToToolApproval;\n if (\"Override\" in tools)\n return (\n <tools.Override\n {...part}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n />\n );\n const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;\n return (\n <ToolUIDisplay\n {...part}\n Fallback={Tool}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n />\n );\n }\n\n if (part.status?.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"reasoning\":\n return <Reasoning {...part} />;\n\n case \"source\":\n return <Source {...part} />;\n\n case \"image\":\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n case \"data\": {\n const Data = data?.by_name?.[part.name] ?? data?.Fallback;\n return <DataUIDisplay {...part} Fallback={Data} />;\n }\n\n case \"generative-ui\": {\n if (!generativeUI?.components) {\n if (\n typeof process !== \"undefined\" &&\n process.env?.NODE_ENV !== \"production\"\n ) {\n console.warn(\n \"MessagePrimitive.Parts received a generative-ui part but no \" +\n \"`components.generativeUI.components` allowlist was provided. \" +\n \"Pass an allowlist or render with <MessagePrimitive.GenerativeUI />.\",\n );\n }\n return null;\n }\n return (\n <GenerativeUIRender\n spec={(part as GenerativeUIMessagePart).spec}\n components={generativeUI.components}\n Fallback={generativeUI.Fallback}\n />\n );\n }\n\n default:\n console.warn(`Unknown message part type: ${type}`);\n return null;\n }\n};\n\nexport namespace MessagePrimitivePartByIndex {\n export type Props = {\n index: number;\n components: MessagePrimitiveParts.Props[\"components\"];\n };\n}\n\n/**\n * Renders a single message part at the specified index.\n */\nexport const MessagePrimitivePartByIndex: FC<MessagePrimitivePartByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <PartByIndexProvider index={index}>\n <MessagePartComponent components={components} />\n </PartByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Reasoning === next.components?.Reasoning &&\n prev.components?.Source === next.components?.Source &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.tools === next.components?.tools &&\n prev.components?.data === next.components?.data &&\n prev.components?.generativeUI === next.components?.generativeUI &&\n prev.components?.ToolGroup === next.components?.ToolGroup &&\n prev.components?.ReasoningGroup === next.components?.ReasoningGroup,\n );\n\nMessagePrimitivePartByIndex.displayName = \"MessagePrimitive.PartByIndex\";\n\nconst EmptyPartFallback: FC<{\n status: MessagePartStatus;\n component: TextMessagePartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextMessagePartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextMessagePartProvider>\n );\n};\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst RUNNING_STATUS: MessagePartStatus = Object.freeze({\n type: \"running\",\n});\n\nconst EmptyPartsImpl: FC<MessagePartComponentProps> = ({ components }) => {\n const status = useAuiState(\n (s) => (s.message.status ?? COMPLETE_STATUS) as MessagePartStatus,\n );\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n if (status.type !== \"running\") return null;\n\n return (\n <EmptyPartFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyParts = memo(\n EmptyPartsImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\nconst ConditionalEmptyImpl: FC<{\n components: MessagePrimitiveParts.Props[\"components\"];\n enabled: boolean;\n}> = ({ components, enabled }) => {\n const shouldShowEmpty = useAuiState((s) => {\n if (!enabled) return false;\n if (s.message.parts.length === 0) return false;\n\n const lastPart = s.message.parts[s.message.parts.length - 1];\n return lastPart?.type !== \"text\" && lastPart?.type !== \"reasoning\";\n });\n\n if (!shouldShowEmpty) return null;\n return <EmptyParts components={components} />;\n};\n\nconst ConditionalEmpty = memo(\n ConditionalEmptyImpl,\n (prev, next) =>\n prev.enabled === next.enabled &&\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\nconst QuoteRendererImpl: FC<{ Quote: QuoteMessagePartComponent }> = ({\n Quote,\n}) => {\n const quoteInfo = useAuiState(getMessageQuote);\n if (!quoteInfo) return null;\n return <Quote text={quoteInfo.text} messageId={quoteInfo.messageId} />;\n};\n\nconst QuoteRenderer = memo(QuoteRendererImpl);\n\nfunction resolveToolRender(\n toolsState: ToolsState,\n part: Extract<PartState, { type: \"tool-call\" }>,\n): ToolCallMessagePartComponent | null {\n const named = toolsState.toolUIs[part.toolName]?.[0]?.render ?? null;\n if (named) return named;\n if (isMcpAppUri(part.mcp?.app?.resourceUri) && toolsState.mcpApp) {\n return toolsState.mcpApp.render;\n }\n return null;\n}\n\n/**\n * Stable propless component that renders the registered tool UI for the\n * current part context. Reads tool registry and part state from context.\n */\nconst RegisteredToolUI: FC = () => {\n const aui = useAui();\n const part = useAuiState((s) => s.part);\n const Render = useAuiState((s) =>\n s.part.type === \"tool-call\" ? resolveToolRender(s.tools, s.part) : null,\n );\n\n if (!Render || part.type !== \"tool-call\") return null;\n\n return (\n <Render\n {...part}\n addResult={aui.part.addToolResult}\n resume={aui.part.resumeToolCall}\n respondToApproval={aui.part.respondToToolApproval}\n />\n );\n};\n\n/**\n * Stable propless component that renders the registered data renderer UI\n * for the current part context.\n */\nconst RegisteredDataRendererUI: FC = () => {\n const part = useAuiState((s) => s.part);\n const Render = useAuiState((s) =>\n s.part.type === \"data\"\n ? (getDataRenderer(s.dataRenderers, s.part.name, undefined) ?? null)\n : null,\n );\n\n if (!Render || part.type !== \"data\") return null;\n\n return <Render {...(part as DataMessagePartProps)} />;\n};\n\n/**\n * Fallback component rendered when the children render function returns null.\n * Renders registered tool/data UIs via context.\n * For all other part types, renders nothing.\n *\n * This allows users to write:\n * {({ part }) => {\n * if (part.type === \"text\") return <MyText />;\n * return null; // tool UIs and data UIs still render via registry\n * }}\n *\n * To explicitly render nothing (suppressing registered UIs), return <></>.\n */\nconst DefaultPartFallback: FC = () => {\n const partType = useAuiState((s) => s.part.type);\n\n if (partType === \"tool-call\") return <RegisteredToolUI />;\n if (partType === \"data\") return <RegisteredDataRendererUI />;\n\n return null;\n};\n\nexport type { PartState };\n\n/**\n * Enriched part state passed to children render functions.\n *\n * For tool-call parts, adds `toolUI`, `addResult`, and `resume`.\n * For data parts, adds `dataRendererUI`.\n *\n * The render function is also invoked once with a synthetic empty text part\n * (`{ type: \"text\", text: \"\", status: { type: \"running\" } }`) when the\n * assistant message has no parts yet but is in the running state, so a\n * loading indicator can render. Differentiate this from a real empty text\n * via `part.status?.type === \"running\" && part.text === \"\"`.\n */\nexport type EnrichedPartState =\n | (Extract<PartState, { type: \"tool-call\" }> & {\n /** The registered tool UI element, or null if none registered. */\n readonly toolUI: ReactNode;\n /** Add a tool result to this tool call. */\n addResult: ToolCallMessagePartProps[\"addResult\"];\n /** Resume a tool call waiting for human input. */\n resume: ToolCallMessagePartProps[\"resume\"];\n /** Respond to a server-side tool approval gate. */\n respondToApproval: ToolCallMessagePartProps[\"respondToApproval\"];\n })\n | (Extract<PartState, { type: \"data\" }> & {\n /** The registered data renderer UI element, or null if none registered. */\n readonly dataRendererUI: ReactNode;\n })\n | Exclude<PartState, { type: \"tool-call\" } | { type: \"data\" }>;\n\nconst EMPTY_RUNNING_TEXT_PART: Extract<EnrichedPartState, { type: \"text\" }> =\n Object.freeze({\n type: \"text\",\n text: \"\",\n status: RUNNING_STATUS,\n });\n\n/**\n * @internal\n * Renders a single part by index, calling `children` with the\n * {@link EnrichedPartState} (tool/data UI enrichments + addResult/resume\n * for tool calls). Shared between `<MessagePrimitive.Parts>` and\n * `<MessagePrimitive.GroupedParts>`. Returns whatever `children`\n * returns — callers decide how to handle a `null` return.\n */\ntype MessagePartChildrenProps = {\n index: number;\n children: (value: { part: EnrichedPartState }) => ReactNode;\n};\n\nconst MessagePartChildrenInner: FC<\n Pick<MessagePartChildrenProps, \"children\">\n> = ({ children }) => {\n const aui = useAui();\n // Subscribed (not snapshotted like `tools`) so fallbacks registered\n // after the first render trigger a re-render and `hasUI` re-evaluates.\n const dataRenderers = useAuiState((s) => s.dataRenderers);\n\n return (\n <RenderChildrenWithAccessor\n getItemState={(client) => client.part.getState()}\n >\n {(getItem) =>\n children({\n get part() {\n const state = getItem();\n if (state.type === \"tool-call\") {\n const toolsState = aui.tools.getState();\n const hasUI = resolveToolRender(toolsState, state) !== null;\n const partMethods = aui.part;\n return {\n ...state,\n toolUI: hasUI ? <RegisteredToolUI /> : null,\n addResult: partMethods.addToolResult,\n resume: partMethods.resumeToolCall,\n respondToApproval: partMethods.respondToToolApproval,\n };\n }\n if (state.type === \"data\") {\n const hasUI =\n getDataRenderer(dataRenderers, state.name, undefined) !==\n undefined;\n return {\n ...state,\n dataRendererUI: hasUI ? <RegisteredDataRendererUI /> : null,\n };\n }\n return state;\n },\n })\n }\n </RenderChildrenWithAccessor>\n );\n};\n\nexport const MessagePartChildren: FC<MessagePartChildrenProps> = ({\n index,\n children,\n}) => {\n return (\n <PartByIndexProvider index={index}>\n <MessagePartChildrenInner>{children}</MessagePartChildrenInner>\n </PartByIndexProvider>\n );\n};\n\nconst MessagePrimitivePartsInner: FC<{\n children: (value: { part: EnrichedPartState }) => ReactNode;\n}> = ({ children }) => {\n const contentLength = useAuiState((s) => s.message.parts.length);\n const isRunning = useAuiState(\n (s) => (s.message.status?.type ?? \"complete\") === \"running\",\n );\n const isEmptyRunning = contentLength === 0 && isRunning;\n\n if (contentLength === 0) {\n if (!isEmptyRunning) return null;\n return (\n <TextMessagePartProvider text=\"\" isRunning>\n {children({ part: EMPTY_RUNNING_TEXT_PART })}\n </TextMessagePartProvider>\n );\n }\n\n return (\n <>\n {Array.from({ length: contentLength }, (_, index) => (\n <MessagePartChildren key={index} index={index}>\n {(value) => children(value) ?? <DefaultPartFallback />}\n </MessagePartChildren>\n ))}\n </>\n );\n};\n\n/**\n * Renders the parts of a message with support for multiple content types.\n *\n * This is the platform-agnostic base. Each platform wraps this with its own\n * default components (web uses `<p>`, `<span>`; RN would use `<Text>`, etc.).\n */\nexport const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props> = ({\n components,\n unstable_showEmptyOnNonTextEnd = true,\n children,\n}) => {\n if (children) {\n return <MessagePrimitivePartsInner>{children}</MessagePrimitivePartsInner>;\n }\n return (\n <MessagePrimitivePartsCompat\n components={components}\n unstable_showEmptyOnNonTextEnd={unstable_showEmptyOnNonTextEnd}\n />\n );\n};\n\nMessagePrimitiveParts.displayName = \"MessagePrimitive.Parts\";\n\nconst MessagePrimitivePartsCompat: FC<{\n components: MessagePrimitiveParts.Props[\"components\"];\n unstable_showEmptyOnNonTextEnd: boolean;\n}> = ({ components, unstable_showEmptyOnNonTextEnd }) => {\n const contentLength = useAuiState((s) => s.message.parts.length);\n const useChainOfThought = !!components?.ChainOfThought;\n const { ranges: messageRanges, partIds } =\n useMessagePartsGroups(useChainOfThought);\n\n const partsElements = useMemo(() => {\n if (contentLength === 0) {\n return <EmptyParts components={components} />;\n }\n\n const claimed = new Set<string>();\n const toolLeafKey = (partIndex: number) => {\n const id = partIds[partIndex];\n if (id !== undefined && !claimed.has(id)) {\n claimed.add(id);\n return `part-id:${id}`;\n }\n return `part-${partIndex}`;\n };\n\n return messageRanges.map((range) => {\n if (range.type === \"single\") {\n return (\n <MessagePrimitivePartByIndex\n key={range.index}\n index={range.index}\n components={components}\n />\n );\n } else if (range.type === \"chainOfThoughtGroup\") {\n const ChainOfThoughtComponent = components?.ChainOfThought;\n if (!ChainOfThoughtComponent) return null;\n return (\n <ChainOfThoughtByIndicesProvider\n key={`chainOfThought-${range.idKey ?? range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n <ChainOfThoughtComponent />\n </ChainOfThoughtByIndicesProvider>\n );\n } else if (range.type === \"toolGroup\") {\n const ToolGroupComponent =\n components?.ToolGroup ?? defaultComponents.ToolGroup;\n return (\n <ToolGroupComponent\n key={`tool-${range.idKey ?? range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n {Array.from(\n { length: range.endIndex - range.startIndex + 1 },\n (_, i) => {\n const partIndex = range.startIndex + i;\n return (\n <MessagePrimitivePartByIndex\n key={toolLeafKey(partIndex)}\n index={partIndex}\n components={components}\n />\n );\n },\n )}\n </ToolGroupComponent>\n );\n } else {\n // reasoningGroup\n const ReasoningGroupComponent =\n components?.ReasoningGroup ?? defaultComponents.ReasoningGroup;\n return (\n <ReasoningGroupComponent\n key={`reasoning-${range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n {Array.from(\n { length: range.endIndex - range.startIndex + 1 },\n (_, i) => {\n const partIndex = range.startIndex + i;\n return (\n <MessagePrimitivePartByIndex\n key={`part-${partIndex}`}\n index={partIndex}\n components={components}\n />\n );\n },\n )}\n </ReasoningGroupComponent>\n );\n }\n });\n }, [messageRanges, partIds, components, contentLength]);\n\n return (\n <>\n {components?.Quote && <QuoteRenderer Quote={components.Quote} />}\n {partsElements}\n <ConditionalEmpty\n components={components}\n enabled={unstable_showEmptyOnNonTextEnd}\n />\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqEA,MAAMyC,oBAGJC,cACG;CACH,IAAIE,QAAQ;CAEZ,OAAO;EACLC,aAAaR,UAAkB;GAC7B,IAAIO,UAAU,IACZA,QAAQP;EAEZ;EACAS,WAAWP,UAAkBQ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AuiState","useAui","PartState","PartByIndexProvider","TextMessagePartProvider","ChainOfThoughtByIndicesProvider","getMessageQuote","Unstable_AudioMessagePartComponent","DataMessagePartComponent","DataMessagePartProps","EmptyMessagePartComponent","TextMessagePartComponent","ImageMessagePartComponent","SourceMessagePartComponent","ToolCallMessagePartComponent","ToolCallMessagePartProps","FileMessagePartComponent","ReasoningMessagePartComponent","ReasoningGroupComponent","QuoteMessagePartComponent","GenerativeUIComponentRegistry","GenerativeUIRender","isMcpAppUri","MessagePartStatus","GenerativeUIMessagePart","DataRenderersState","ToolsState","useShallow","MessagePartRange","type","index","startIndex","endIndex","idKey","createGroupState","groupType","T","start","startGroup","endGroup","ranges","push","finalize","groupMessageParts","messageTypes","useChainOfThought","partIds","chainOfThoughtGroup","i","length","toolGroup","reasoningGroup","claimed","Set","range","id","undefined","has","add","useMessagePartsGroups","$","_c","_temp2","_temp4","t0","bb0","t1","Symbol","for","t2","MessagePrimitiveParts","DataConfig","by_name","Record","Fallback","BaseComponents","Empty","Text","Source","Image","File","Unstable_Audio","data","Quote","generativeUI","components","component","props","ToolsConfig","Override","StandardComponents","Reasoning","tools","ToolGroup","ReasoningGroup","ChainOfThought","ChainOfThoughtComponents","Props","unstable_showEmptyOnNonTextEnd","children","value","part","EnrichedPartState","ToolUIDisplay","toolName","s","toolUIs","render","Render","getDataRenderer","dataRenderers","name","inlineFallback","named","renderers","fallbacks","DataUIDisplay","defaultComponents","MessagePartComponentProps","MessagePartComponent","t3","t4","t5","t6","t7","t8","t9","Audio","t10","aui","_temp5","addResult","addToolResult","resume","resumeToolCall","respondToApproval","respondToToolApproval","t11","Tool","status","Error","Data","process","env","NODE_ENV","console","warn","t12","spec","MessagePrimitivePartByIndex","prev","next","displayName","EmptyPartFallback","Component","COMPLETE_STATUS","Object","freeze","RUNNING_STATUS","EmptyPartsImpl","_temp6","EmptyParts","ConditionalEmptyImpl","enabled","message","parts","lastPart","shouldShowEmpty","ConditionalEmpty","QuoteRendererImpl","quoteInfo","messageId","text","QuoteRenderer","resolveToolRender","toolsState","Extract","mcp","app","resourceUri","mcpApp","RegisteredToolUI","_temp7","_temp8","RegisteredDataRendererUI","_temp9","_temp0","DefaultPartFallback","partType","_temp1","toolUI","dataRendererUI","Exclude","EMPTY_RUNNING_TEXT_PART","MessagePartChildrenProps","MessagePartChildrenInner","Pick","client","getState","getItem","state","hasUI","partMethods","MessagePartChildren","MessagePrimitivePartsInner","contentLength","_temp10","isRunning","_temp11","isEmptyRunning","_","Array","from","MessagePrimitivePartsCompat","_temp12","messageRanges","toolLeafKey","partIndex","map","ChainOfThoughtComponent","ToolGroupComponent","partIndex_0","__0","i_0","partIndex_1","partsElements","_temp","c","_temp3","c_0","toolCallId","s_0"],"sources":["../../../../src/react/primitives/message/MessageParts.tsx"],"sourcesContent":["import {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n type PropsWithChildren,\n useMemo,\n} from \"react\";\nimport {\n RenderChildrenWithAccessor,\n useAuiState,\n useAui,\n} from \"@assistant-ui/store\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport { PartByIndexProvider } from \"../../providers/PartByIndexProvider\";\nimport { TextMessagePartProvider } from \"../../providers/TextMessagePartProvider\";\nimport { ChainOfThoughtByIndicesProvider } from \"../../providers/ChainOfThoughtByIndicesProvider\";\nimport { getMessageQuote } from \"../../utils/getMessageQuote\";\nimport type {\n Unstable_AudioMessagePartComponent,\n DataMessagePartComponent,\n DataMessagePartProps,\n EmptyMessagePartComponent,\n TextMessagePartComponent,\n ImageMessagePartComponent,\n SourceMessagePartComponent,\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n FileMessagePartComponent,\n ReasoningMessagePartComponent,\n ReasoningGroupComponent,\n QuoteMessagePartComponent,\n GenerativeUIComponentRegistry,\n} from \"../../types/MessagePartComponentTypes\";\nimport { GenerativeUIRender } from \"../generativeUI/GenerativeUI\";\nimport {\n isMcpAppUri,\n type MessagePartStatus,\n type GenerativeUIMessagePart,\n} from \"../../../types/message\";\nimport type { DataRenderersState } from \"../../types/scopes/dataRenderers\";\nimport type { ToolsState } from \"../../types/scopes/tools\";\nimport { useShallow } from \"zustand/shallow\";\n\ntype MessagePartRange =\n | { type: \"single\"; index: number }\n | {\n type: \"toolGroup\";\n startIndex: number;\n endIndex: number;\n idKey?: string | undefined;\n }\n | {\n type: \"reasoningGroup\";\n startIndex: number;\n endIndex: number;\n idKey?: string | undefined;\n }\n | {\n type: \"chainOfThoughtGroup\";\n startIndex: number;\n endIndex: number;\n idKey?: string | undefined;\n };\n\n/**\n * Creates a group state manager for a specific part type.\n * Returns functions to start, end, and finalize groups.\n */\nconst createGroupState = <\n T extends \"toolGroup\" | \"reasoningGroup\" | \"chainOfThoughtGroup\",\n>(\n groupType: T,\n) => {\n let start = -1;\n\n return {\n startGroup: (index: number) => {\n if (start === -1) {\n start = index;\n }\n },\n endGroup: (endIndex: number, ranges: MessagePartRange[]) => {\n if (start !== -1) {\n ranges.push({\n type: groupType,\n startIndex: start,\n endIndex,\n } as MessagePartRange);\n start = -1;\n }\n },\n finalize: (endIndex: number, ranges: MessagePartRange[]) => {\n if (start !== -1) {\n ranges.push({\n type: groupType,\n startIndex: start,\n endIndex,\n } as MessagePartRange);\n }\n },\n };\n};\n\n/**\n * Groups consecutive tool-call and reasoning message parts into ranges.\n * Always groups tool calls and reasoning parts, even if there's only one.\n * When useChainOfThought is true, groups tool-call and reasoning parts together.\n * `partIds[i]` optionally carries a stable identity for part `i`; group\n * ranges derive an `idKey` from their first part's id (first claim wins).\n */\nexport const groupMessageParts = (\n messageTypes: readonly string[],\n useChainOfThought: boolean,\n partIds?: readonly (string | undefined)[],\n): MessagePartRange[] => {\n const ranges: MessagePartRange[] = [];\n\n if (useChainOfThought) {\n const chainOfThoughtGroup = createGroupState(\"chainOfThoughtGroup\");\n\n for (let i = 0; i < messageTypes.length; i++) {\n const type = messageTypes[i];\n\n if (type === \"tool-call\" || type === \"reasoning\") {\n chainOfThoughtGroup.startGroup(i);\n } else {\n chainOfThoughtGroup.endGroup(i - 1, ranges);\n ranges.push({ type: \"single\", index: i });\n }\n }\n\n chainOfThoughtGroup.finalize(messageTypes.length - 1, ranges);\n } else {\n const toolGroup = createGroupState(\"toolGroup\");\n const reasoningGroup = createGroupState(\"reasoningGroup\");\n\n for (let i = 0; i < messageTypes.length; i++) {\n const type = messageTypes[i];\n\n if (type === \"tool-call\") {\n reasoningGroup.endGroup(i - 1, ranges);\n toolGroup.startGroup(i);\n } else if (type === \"reasoning\") {\n toolGroup.endGroup(i - 1, ranges);\n reasoningGroup.startGroup(i);\n } else {\n toolGroup.endGroup(i - 1, ranges);\n reasoningGroup.endGroup(i - 1, ranges);\n ranges.push({ type: \"single\", index: i });\n }\n }\n\n toolGroup.finalize(messageTypes.length - 1, ranges);\n reasoningGroup.finalize(messageTypes.length - 1, ranges);\n }\n\n if (partIds) {\n const claimed = new Set<string>();\n for (const range of ranges) {\n if (range.type === \"single\") continue;\n const id = partIds[range.startIndex];\n if (id !== undefined && !claimed.has(id)) {\n claimed.add(id);\n range.idKey = `id:${id}`;\n }\n }\n }\n\n return ranges;\n};\n\nconst useMessagePartsGroups = (\n useChainOfThought: boolean,\n): { ranges: MessagePartRange[]; partIds: (string | undefined)[] } => {\n const messageTypes = useAuiState(\n useShallow((s) => s.message.parts.map((c: any) => c.type)),\n );\n const partIds = useAuiState(\n useShallow((s) =>\n s.message.parts.map((c: any) =>\n c.type === \"tool-call\" ? c.toolCallId : undefined,\n ),\n ),\n );\n\n return useMemo(() => {\n if (messageTypes.length === 0) {\n return { ranges: [], partIds };\n }\n return {\n ranges: groupMessageParts(messageTypes, useChainOfThought, partIds),\n partIds,\n };\n }, [messageTypes, partIds, useChainOfThought]);\n};\n\nexport namespace MessagePrimitiveParts {\n type DataConfig = {\n /** Map data event names to specific components */\n by_name?: Record<string, DataMessagePartComponent | undefined> | undefined;\n /** Fallback component for unmatched data events */\n Fallback?: DataMessagePartComponent | undefined;\n };\n\n type BaseComponents = {\n /** Component for rendering empty messages */\n Empty?: EmptyMessagePartComponent | undefined;\n /** Component for rendering text content */\n Text?: TextMessagePartComponent | undefined;\n /** Component for rendering source content */\n Source?: SourceMessagePartComponent | undefined;\n /** Component for rendering image content */\n Image?: ImageMessagePartComponent | undefined;\n /** Component for rendering file content */\n File?: FileMessagePartComponent | undefined;\n /**\n * Component for rendering audio content.\n *\n * @deprecated Render audio through the `File` slot instead, branching on an\n * `audio/*` mime type.\n */\n Unstable_Audio?: Unstable_AudioMessagePartComponent | undefined;\n /** Configuration for data part rendering */\n data?: DataConfig | undefined;\n /** Component for rendering a quoted message reference (from metadata, not parts) */\n Quote?: QuoteMessagePartComponent | undefined;\n /**\n * Configuration for generative-ui part rendering.\n *\n * `components` is the consumer-provided allowlist of React components\n * the agent's JSON spec is permitted to render. Any name not present in\n * the registry is rejected with a typed `GenerativeUIRenderError` —\n * this is the security boundary in the same-realm rendering path.\n */\n generativeUI?:\n | {\n /** The component allowlist (the security boundary). */\n components: GenerativeUIComponentRegistry;\n /** Optional fallback for unknown component names. */\n Fallback?:\n | ComponentType<{ component: string; props?: unknown }>\n | undefined;\n }\n | undefined;\n };\n\n type ToolsConfig =\n | {\n /** Map of tool names to their specific components */\n by_name?:\n | Record<string, ToolCallMessagePartComponent | undefined>\n | undefined;\n /** Fallback component for unregistered tools */\n Fallback?: ComponentType<ToolCallMessagePartProps> | undefined;\n }\n | {\n /** Override component that handles all tool calls */\n Override: ComponentType<ToolCallMessagePartProps>;\n };\n\n /**\n * Standard component configuration for rendering reasoning and tool-call parts\n * individually (with optional grouping).\n *\n * Cannot be combined with `ChainOfThought`.\n */\n type StandardComponents = BaseComponents & {\n /** Component for rendering reasoning content (typically hidden) */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Configuration for tool call rendering */\n tools?: ToolsConfig | undefined;\n\n /**\n * Component for rendering grouped consecutive tool calls.\n *\n * @param startIndex - Index of the first tool call in the group\n * @param endIndex - Index of the last tool call in the group\n * @param children - Rendered tool call components to display within the group\n *\n * @deprecated Use `<MessagePrimitive.GroupedParts>` with a custom `groupBy` instead.\n */\n ToolGroup?: ComponentType<\n PropsWithChildren<{ startIndex: number; endIndex: number }>\n >;\n\n /**\n * Component for rendering grouped reasoning parts.\n *\n * @param startIndex - Index of the first reasoning part in the group\n * @param endIndex - Index of the last reasoning part in the group\n * @param children - Rendered reasoning part components\n *\n * @deprecated Use `<MessagePrimitive.GroupedParts>` with a custom `groupBy` instead.\n */\n ReasoningGroup?: ReasoningGroupComponent;\n\n ChainOfThought?: never;\n };\n\n /**\n * Chain of thought component configuration.\n *\n * When `ChainOfThought` is set, it takes control of rendering ALL reasoning and\n * tool-call parts in the message. The `Reasoning`, `tools`, `ReasoningGroup`, and\n * `ToolGroup` components cannot be used alongside it.\n */\n type ChainOfThoughtComponents = BaseComponents & {\n /**\n * @deprecated Use `<MessagePrimitive.GroupedParts>` with a `groupBy`\n * that returns `[\"group-thought\", ...]` for reasoning and tool-call\n * parts. See `@assistant-ui/ui` for a worked example.\n */\n ChainOfThought: ComponentType;\n\n Reasoning?: never;\n tools?: never;\n ToolGroup?: never;\n ReasoningGroup?: never;\n };\n\n export type Props =\n | {\n /**\n * Component configuration for rendering different types of message content.\n *\n * Use either `Reasoning`/`tools`/`ToolGroup`/`ReasoningGroup` for standard rendering,\n * or `ChainOfThought` to group all reasoning and tool-call parts into a single\n * collapsible component. These two modes are mutually exclusive.\n */\n components?: StandardComponents | ChainOfThoughtComponents | undefined;\n /**\n * When enabled, shows the Empty component if the last part in the message\n * is anything other than Text or Reasoning.\n *\n * @experimental This API is experimental and may change in future versions.\n * @default true\n */\n unstable_showEmptyOnNonTextEnd?: boolean | undefined;\n children?: never;\n }\n | {\n /** Render function called for each part. Receives the enriched part state. */\n children: (value: { part: EnrichedPartState }) => ReactNode;\n components?: never;\n unstable_showEmptyOnNonTextEnd?: never;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallMessagePartComponent | undefined;\n} & ToolCallMessagePartProps) => {\n const Render = useAuiState(\n (s) => s.tools.toolUIs[props.toolName]?.[0]?.render ?? Fallback,\n );\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst getDataRenderer = (\n dataRenderers: DataRenderersState,\n name: string,\n inlineFallback: DataMessagePartComponent | undefined,\n): DataMessagePartComponent | undefined => {\n const named = dataRenderers.renderers[name]?.[0];\n if (named) return named;\n return dataRenderers.fallbacks[0] ?? inlineFallback;\n};\n\nconst DataUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: DataMessagePartComponent | undefined;\n} & DataMessagePartProps) => {\n const Render = useAuiState((s) =>\n getDataRenderer(s.dataRenderers, props.name, Fallback),\n );\n if (!Render) return null;\n return <Render {...props} />;\n};\n\n/**\n * Platform-agnostic no-op default components.\n * Each platform (web, RN) wraps MessagePrimitiveParts with its own defaults.\n */\nexport const defaultComponents = {\n Text: () => null,\n Reasoning: () => null,\n Source: () => null,\n Image: () => null,\n File: () => null,\n Unstable_Audio: () => null,\n ToolGroup: ({ children }: PropsWithChildren) => children,\n ReasoningGroup: ({ children }: PropsWithChildren) => children,\n} satisfies MessagePrimitiveParts.Props[\"components\"];\n\ntype MessagePartComponentProps = {\n components: MessagePrimitiveParts.Props[\"components\"];\n};\n\nexport const MessagePartComponent: FC<MessagePartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Reasoning = defaultComponents.Reasoning,\n Image = defaultComponents.Image,\n Source = defaultComponents.Source,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n tools = {},\n data,\n generativeUI,\n } = {},\n}) => {\n const aui = useAui();\n const part = useAuiState((s) => s.part);\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = aui.part.addToolResult;\n const resume = aui.part.resumeToolCall;\n const respondToApproval = aui.part.respondToToolApproval;\n if (\"Override\" in tools)\n return (\n <tools.Override\n {...part}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n />\n );\n const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;\n return (\n <ToolUIDisplay\n {...part}\n Fallback={Tool}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n />\n );\n }\n\n if (part.status?.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"reasoning\":\n return <Reasoning {...part} />;\n\n case \"source\":\n return <Source {...part} />;\n\n case \"image\":\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n case \"data\": {\n const Data = data?.by_name?.[part.name] ?? data?.Fallback;\n return <DataUIDisplay {...part} Fallback={Data} />;\n }\n\n case \"generative-ui\": {\n if (!generativeUI?.components) {\n if (\n typeof process !== \"undefined\" &&\n process.env?.NODE_ENV !== \"production\"\n ) {\n console.warn(\n \"MessagePrimitive.Parts received a generative-ui part but no \" +\n \"`components.generativeUI.components` allowlist was provided. \" +\n \"Pass an allowlist or render with <MessagePrimitive.GenerativeUI />.\",\n );\n }\n return null;\n }\n return (\n <GenerativeUIRender\n spec={(part as GenerativeUIMessagePart).spec}\n components={generativeUI.components}\n Fallback={generativeUI.Fallback}\n />\n );\n }\n\n default:\n console.warn(`Unknown message part type: ${type}`);\n return null;\n }\n};\n\nexport namespace MessagePrimitivePartByIndex {\n export type Props = {\n index: number;\n components: MessagePrimitiveParts.Props[\"components\"];\n };\n}\n\n/**\n * Renders a single message part at the specified index.\n */\nexport const MessagePrimitivePartByIndex: FC<MessagePrimitivePartByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <PartByIndexProvider index={index}>\n <MessagePartComponent components={components} />\n </PartByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Reasoning === next.components?.Reasoning &&\n prev.components?.Source === next.components?.Source &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.tools === next.components?.tools &&\n prev.components?.data === next.components?.data &&\n prev.components?.generativeUI === next.components?.generativeUI &&\n prev.components?.ToolGroup === next.components?.ToolGroup &&\n prev.components?.ReasoningGroup === next.components?.ReasoningGroup,\n );\n\nMessagePrimitivePartByIndex.displayName = \"MessagePrimitive.PartByIndex\";\n\nconst EmptyPartFallback: FC<{\n status: MessagePartStatus;\n component: TextMessagePartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextMessagePartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextMessagePartProvider>\n );\n};\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst RUNNING_STATUS: MessagePartStatus = Object.freeze({\n type: \"running\",\n});\n\nconst EmptyPartsImpl: FC<MessagePartComponentProps> = ({ components }) => {\n const status = useAuiState(\n (s) => (s.message.status ?? COMPLETE_STATUS) as MessagePartStatus,\n );\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n if (status.type !== \"running\") return null;\n\n return (\n <EmptyPartFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyParts = memo(\n EmptyPartsImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\nconst ConditionalEmptyImpl: FC<{\n components: MessagePrimitiveParts.Props[\"components\"];\n enabled: boolean;\n}> = ({ components, enabled }) => {\n const shouldShowEmpty = useAuiState((s) => {\n if (!enabled) return false;\n if (s.message.parts.length === 0) return false;\n\n const lastPart = s.message.parts[s.message.parts.length - 1];\n return lastPart?.type !== \"text\" && lastPart?.type !== \"reasoning\";\n });\n\n if (!shouldShowEmpty) return null;\n return <EmptyParts components={components} />;\n};\n\nconst ConditionalEmpty = memo(\n ConditionalEmptyImpl,\n (prev, next) =>\n prev.enabled === next.enabled &&\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\nconst QuoteRendererImpl: FC<{ Quote: QuoteMessagePartComponent }> = ({\n Quote,\n}) => {\n const quoteInfo = useAuiState(getMessageQuote);\n if (!quoteInfo) return null;\n return <Quote text={quoteInfo.text} messageId={quoteInfo.messageId} />;\n};\n\nconst QuoteRenderer = memo(QuoteRendererImpl);\n\nfunction resolveToolRender(\n toolsState: ToolsState,\n part: Extract<PartState, { type: \"tool-call\" }>,\n): ToolCallMessagePartComponent | null {\n const named = toolsState.toolUIs[part.toolName]?.[0]?.render ?? null;\n if (named) return named;\n if (isMcpAppUri(part.mcp?.app?.resourceUri) && toolsState.mcpApp) {\n return toolsState.mcpApp.render;\n }\n return null;\n}\n\n/**\n * Stable propless component that renders the registered tool UI for the\n * current part context. Reads tool registry and part state from context.\n */\nconst RegisteredToolUI: FC = () => {\n const aui = useAui();\n const part = useAuiState((s) => s.part);\n const Render = useAuiState((s) =>\n s.part.type === \"tool-call\" ? resolveToolRender(s.tools, s.part) : null,\n );\n\n if (!Render || part.type !== \"tool-call\") return null;\n\n return (\n <Render\n {...part}\n addResult={aui.part.addToolResult}\n resume={aui.part.resumeToolCall}\n respondToApproval={aui.part.respondToToolApproval}\n />\n );\n};\n\n/**\n * Stable propless component that renders the registered data renderer UI\n * for the current part context.\n */\nconst RegisteredDataRendererUI: FC = () => {\n const part = useAuiState((s) => s.part);\n const Render = useAuiState((s) =>\n s.part.type === \"data\"\n ? (getDataRenderer(s.dataRenderers, s.part.name, undefined) ?? null)\n : null,\n );\n\n if (!Render || part.type !== \"data\") return null;\n\n return <Render {...(part as DataMessagePartProps)} />;\n};\n\n/**\n * Fallback component rendered when the children render function returns null.\n * Renders registered tool/data UIs via context.\n * For all other part types, renders nothing.\n *\n * This allows users to write:\n * {({ part }) => {\n * if (part.type === \"text\") return <MyText />;\n * return null; // tool UIs and data UIs still render via registry\n * }}\n *\n * To explicitly render nothing (suppressing registered UIs), return <></>.\n */\nconst DefaultPartFallback: FC = () => {\n const partType = useAuiState((s) => s.part.type);\n\n if (partType === \"tool-call\") return <RegisteredToolUI />;\n if (partType === \"data\") return <RegisteredDataRendererUI />;\n\n return null;\n};\n\nexport type { PartState };\n\n/**\n * Enriched part state passed to children render functions.\n *\n * For tool-call parts, adds `toolUI`, `addResult`, and `resume`.\n * For data parts, adds `dataRendererUI`.\n *\n * The render function is also invoked once with a synthetic empty text part\n * (`{ type: \"text\", text: \"\", status: { type: \"running\" } }`) when the\n * assistant message has no parts yet but is in the running state, so a\n * loading indicator can render. Differentiate this from a real empty text\n * via `part.status?.type === \"running\" && part.text === \"\"`.\n */\nexport type EnrichedPartState =\n | (Extract<PartState, { type: \"tool-call\" }> & {\n /** The registered tool UI element, or null if none registered. */\n readonly toolUI: ReactNode;\n /** Add a tool result to this tool call. */\n addResult: ToolCallMessagePartProps[\"addResult\"];\n /** Resume a tool call waiting for human input. */\n resume: ToolCallMessagePartProps[\"resume\"];\n /** Respond to a server-side tool approval gate. */\n respondToApproval: ToolCallMessagePartProps[\"respondToApproval\"];\n })\n | (Extract<PartState, { type: \"data\" }> & {\n /** The registered data renderer UI element, or null if none registered. */\n readonly dataRendererUI: ReactNode;\n })\n | Exclude<PartState, { type: \"tool-call\" } | { type: \"data\" }>;\n\nconst EMPTY_RUNNING_TEXT_PART: Extract<EnrichedPartState, { type: \"text\" }> =\n Object.freeze({\n type: \"text\",\n text: \"\",\n status: RUNNING_STATUS,\n });\n\n/**\n * @internal\n * Renders a single part by index, calling `children` with the\n * {@link EnrichedPartState} (tool/data UI enrichments + addResult/resume\n * for tool calls). Shared between `<MessagePrimitive.Parts>` and\n * `<MessagePrimitive.GroupedParts>`. Returns whatever `children`\n * returns — callers decide how to handle a `null` return.\n */\ntype MessagePartChildrenProps = {\n index: number;\n children: (value: { part: EnrichedPartState }) => ReactNode;\n};\n\nconst MessagePartChildrenInner: FC<\n Pick<MessagePartChildrenProps, \"children\">\n> = ({ children }) => {\n const aui = useAui();\n // Subscribed (not snapshotted like `tools`) so fallbacks registered\n // after the first render trigger a re-render and `hasUI` re-evaluates.\n const dataRenderers = useAuiState((s) => s.dataRenderers);\n\n return (\n <RenderChildrenWithAccessor\n getItemState={(client) => client.part.getState()}\n >\n {(getItem) =>\n children({\n get part() {\n const state = getItem();\n if (state.type === \"tool-call\") {\n const toolsState = aui.tools.getState();\n const hasUI = resolveToolRender(toolsState, state) !== null;\n const partMethods = aui.part;\n return {\n ...state,\n toolUI: hasUI ? <RegisteredToolUI /> : null,\n addResult: partMethods.addToolResult,\n resume: partMethods.resumeToolCall,\n respondToApproval: partMethods.respondToToolApproval,\n };\n }\n if (state.type === \"data\") {\n const hasUI =\n getDataRenderer(dataRenderers, state.name, undefined) !==\n undefined;\n return {\n ...state,\n dataRendererUI: hasUI ? <RegisteredDataRendererUI /> : null,\n };\n }\n return state;\n },\n })\n }\n </RenderChildrenWithAccessor>\n );\n};\n\nexport const MessagePartChildren: FC<MessagePartChildrenProps> = ({\n index,\n children,\n}) => {\n return (\n <PartByIndexProvider index={index}>\n <MessagePartChildrenInner>{children}</MessagePartChildrenInner>\n </PartByIndexProvider>\n );\n};\n\nconst MessagePrimitivePartsInner: FC<{\n children: (value: { part: EnrichedPartState }) => ReactNode;\n}> = ({ children }) => {\n const contentLength = useAuiState((s) => s.message.parts.length);\n const isRunning = useAuiState(\n (s) => (s.message.status?.type ?? \"complete\") === \"running\",\n );\n const isEmptyRunning = contentLength === 0 && isRunning;\n\n if (contentLength === 0) {\n if (!isEmptyRunning) return null;\n return (\n <TextMessagePartProvider text=\"\" isRunning>\n {children({ part: EMPTY_RUNNING_TEXT_PART })}\n </TextMessagePartProvider>\n );\n }\n\n return (\n <>\n {Array.from({ length: contentLength }, (_, index) => (\n <MessagePartChildren key={index} index={index}>\n {(value) => children(value) ?? <DefaultPartFallback />}\n </MessagePartChildren>\n ))}\n </>\n );\n};\n\n/**\n * Renders the parts of a message with support for multiple content types.\n *\n * This is the platform-agnostic base. Each platform wraps this with its own\n * default components (web uses `<p>`, `<span>`; RN would use `<Text>`, etc.).\n */\nexport const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props> = ({\n components,\n unstable_showEmptyOnNonTextEnd = true,\n children,\n}) => {\n if (children) {\n return <MessagePrimitivePartsInner>{children}</MessagePrimitivePartsInner>;\n }\n return (\n <MessagePrimitivePartsCompat\n components={components}\n unstable_showEmptyOnNonTextEnd={unstable_showEmptyOnNonTextEnd}\n />\n );\n};\n\nMessagePrimitiveParts.displayName = \"MessagePrimitive.Parts\";\n\nconst MessagePrimitivePartsCompat: FC<{\n components: MessagePrimitiveParts.Props[\"components\"];\n unstable_showEmptyOnNonTextEnd: boolean;\n}> = ({ components, unstable_showEmptyOnNonTextEnd }) => {\n const contentLength = useAuiState((s) => s.message.parts.length);\n const useChainOfThought = !!components?.ChainOfThought;\n const { ranges: messageRanges, partIds } =\n useMessagePartsGroups(useChainOfThought);\n\n const partsElements = useMemo(() => {\n if (contentLength === 0) {\n return <EmptyParts components={components} />;\n }\n\n const claimed = new Set<string>();\n const toolLeafKey = (partIndex: number) => {\n const id = partIds[partIndex];\n if (id !== undefined && !claimed.has(id)) {\n claimed.add(id);\n return `part-id:${id}`;\n }\n return `part-${partIndex}`;\n };\n\n return messageRanges.map((range) => {\n if (range.type === \"single\") {\n return (\n <MessagePrimitivePartByIndex\n key={range.index}\n index={range.index}\n components={components}\n />\n );\n } else if (range.type === \"chainOfThoughtGroup\") {\n const ChainOfThoughtComponent = components?.ChainOfThought;\n if (!ChainOfThoughtComponent) return null;\n return (\n <ChainOfThoughtByIndicesProvider\n key={`chainOfThought-${range.idKey ?? range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n <ChainOfThoughtComponent />\n </ChainOfThoughtByIndicesProvider>\n );\n } else if (range.type === \"toolGroup\") {\n const ToolGroupComponent =\n components?.ToolGroup ?? defaultComponents.ToolGroup;\n return (\n <ToolGroupComponent\n key={`tool-${range.idKey ?? range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n {Array.from(\n { length: range.endIndex - range.startIndex + 1 },\n (_, i) => {\n const partIndex = range.startIndex + i;\n return (\n <MessagePrimitivePartByIndex\n key={toolLeafKey(partIndex)}\n index={partIndex}\n components={components}\n />\n );\n },\n )}\n </ToolGroupComponent>\n );\n } else {\n // reasoningGroup\n const ReasoningGroupComponent =\n components?.ReasoningGroup ?? defaultComponents.ReasoningGroup;\n return (\n <ReasoningGroupComponent\n key={`reasoning-${range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n {Array.from(\n { length: range.endIndex - range.startIndex + 1 },\n (_, i) => {\n const partIndex = range.startIndex + i;\n return (\n <MessagePrimitivePartByIndex\n key={`part-${partIndex}`}\n index={partIndex}\n components={components}\n />\n );\n },\n )}\n </ReasoningGroupComponent>\n );\n }\n });\n }, [messageRanges, partIds, components, contentLength]);\n\n return (\n <>\n {components?.Quote && <QuoteRenderer Quote={components.Quote} />}\n {partsElements}\n <ConditionalEmpty\n components={components}\n enabled={unstable_showEmptyOnNonTextEnd}\n />\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqEA,MAAMyC,oBAGJC,cACG;CACH,IAAIE,QAAQ;CAEZ,OAAO;EACLC,aAAaR,UAAkB;GAC7B,IAAIO,UAAU,IACZA,QAAQP;EAEZ;EACAS,WAAWP,UAAkBQ,WAA+B;GAC1D,IAAIH,UAAU,IAAI;IAChBG,OAAOC,KAAK;KACVZ,MAAMM;KACNJ,YAAYM;KACZL;IACF,CAAqB;IACrBK,QAAQ;GACV;EACF;EACAK,WAAWV,UAAkBQ,WAA+B;GAC1D,IAAIH,UAAU,IACZG,OAAOC,KAAK;IACVZ,MAAMM;IACNJ,YAAYM;IACZL;GACF,CAAqB;EAEzB;CACF;AACF;;;;;;;;AASA,MAAaW,qBACXC,cACAC,mBACAC,YACuB;CACvB,MAAMN,SAA6B,CAAA;CAEnC,IAAIK,mBAAmB;EACrB,MAAME,sBAAsBb,iBAAiB,qBAAqB;EAElE,KAA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cjCA,EAACJ;AAAK;AA2Ic,SAAA2D,OAAAvD,GAAA;CAAA,OAE1CA,EAAC2D,QAAQzB,UAATgB;AAAyD;AAwExC,SAAA2B,OAAA7E,GAAA;CAAA,OAEKA,EAACJ;AAAK;AAFX,SAAAkF,OAAAgD,KAAA;CAAA,OAIzB9H,IAACJ,KAAKxE,SAAU,cAAciJ,kBAAkBrE,IAACb,OAAQa,IAACJ,IAAY,IAAtE;AAAuE;AAmBtC,SAAAoF,OAAAhF,GAAA;CAAA,OACHA,EAACJ;AAAK;AADH,SAAAqF,OAAA6C,KAAA;CAAA,OAGjC9H,IAACJ,KAAKxE,SAAU,SACXgF,gBAAgBJ,IAACK,eAAgBL,IAACJ,KAAKU,MAAOvD,KAAAA,CAAiB,KAA/D,OADL;AAEQ;AAqBoB,SAAAqI,OAAApF,GAAA;CAAA,OACMA,EAACJ,KAAKxE;AAAK;AAqH5C,SAAAiL,QAAArG,GAAA;CAAA,OACsCA,EAAC2D,QAAQC,MAAMpH;AAAO;AAD5D,SAAA+J,QAAAuB,KAAA;CAAA,QAGO9H,IAAC2D,QAAQzB,QAAa9G,QAAtB,gBAA0C;AAAS;AAmD1D,SAAAyL,QAAA7G,GAAA;CAAA,OACsCA,EAAC2D,QAAQC,MAAMpH;AAAO"}
|
|
@@ -24,11 +24,12 @@ const useCloudThreadListAdapter = (adapter) => {
|
|
|
24
24
|
} });
|
|
25
25
|
const cloudInstance = adapterRef.current.cloud ?? autoCloud;
|
|
26
26
|
const attachments = useMemo(() => new CloudFileAttachmentAdapter(cloudInstance), [cloudInstance]);
|
|
27
|
+
const adapters = useMemo(() => ({
|
|
28
|
+
history,
|
|
29
|
+
attachments
|
|
30
|
+
}), [history, attachments]);
|
|
27
31
|
return /* @__PURE__ */ jsx(RuntimeAdapterProvider, {
|
|
28
|
-
adapters
|
|
29
|
-
history,
|
|
30
|
-
attachments
|
|
31
|
-
}), [history, attachments]),
|
|
32
|
+
adapters,
|
|
32
33
|
children
|
|
33
34
|
});
|
|
34
35
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCloudThreadListAdapter.js","names":["process","env","Record","FC","PropsWithChildren","useCallback","useEffect","useMemo","useRef","AssistantCloud","RemoteThreadListAdapter","InMemoryThreadListAdapter","useAssistantCloudThreadHistoryAdapter","RuntimeAdapterProvider","CloudFileAttachmentAdapter","isRecord","ThreadData","externalId","CloudThreadListAdapterOptions","cloud","create","Promise","delete","threadId","toCustom","value","undefined","baseUrl","NEXT_PUBLIC_ASSISTANT_BASE_URL","autoCloud","anonymous","useCloudThreadListAdapter","adapter","adapterRef","current","unstable_Provider","Provider","children","history","cloudInstance","attachments","adapters","ref","inMemory","initialize","result","remoteId","list","threads","map","t","status","is_archived","id","title","lastMessageAt","last_message_at","Date","external_id","custom","metadata","createTask","resolve","thread_id","rename","newTitle","update","updateCustom","archive","unarchive","generateTitle","messages","filteredMessages","msg","content","filter","part","type","runs","stream","assistant_id","fetch","thread","get"],"sources":["../../../../src/react/runtimes/cloud/useCloudThreadListAdapter.tsx"],"sourcesContent":["declare const process: { env: Record<string, string | undefined> };\n\nimport {\n type FC,\n type PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { AssistantCloud } from \"assistant-cloud\";\nimport type { RemoteThreadListAdapter } from \"../../../runtimes/remote-thread-list/types\";\nimport { InMemoryThreadListAdapter } from \"../../../runtimes/remote-thread-list/adapter/in-memory\";\nimport { useAssistantCloudThreadHistoryAdapter } from \"./AssistantCloudThreadHistoryAdapter\";\nimport { RuntimeAdapterProvider } from \"../RuntimeAdapterProvider\";\nimport { CloudFileAttachmentAdapter } from \"./CloudFileAttachmentAdapter\";\nimport { isRecord } from \"../../../utils/json/is-json\";\n\ntype ThreadData = {\n externalId: string | undefined;\n};\n\ntype CloudThreadListAdapterOptions = {\n cloud?: AssistantCloud | undefined;\n\n create?: (() => Promise<ThreadData>) | undefined;\n delete?: ((threadId: string) => Promise<void>) | undefined;\n};\n\nconst toCustom = (value: unknown): Record<string, unknown> | undefined =>\n isRecord(value) ? value : undefined;\n\nconst baseUrl =\n typeof process !== \"undefined\" &&\n process?.env?.NEXT_PUBLIC_ASSISTANT_BASE_URL;\nconst autoCloud = baseUrl\n ? new AssistantCloud({ baseUrl, anonymous: true })\n : undefined;\n\nexport const useCloudThreadListAdapter = (\n adapter: CloudThreadListAdapterOptions,\n): RemoteThreadListAdapter => {\n const adapterRef = useRef(adapter);\n useEffect(() => {\n adapterRef.current = adapter;\n }, [adapter]);\n\n const unstable_Provider = useCallback<FC<PropsWithChildren>>(\n function Provider({ children }) {\n const history = useAssistantCloudThreadHistoryAdapter({\n get current() {\n return adapterRef.current.cloud ?? autoCloud!;\n },\n });\n const cloudInstance = adapterRef.current.cloud ?? autoCloud!;\n const attachments = useMemo(\n () => new CloudFileAttachmentAdapter(cloudInstance),\n [cloudInstance],\n );\n\n const adapters = useMemo(\n () => ({\n history,\n attachments,\n }),\n [history, attachments],\n );\n\n return (\n <RuntimeAdapterProvider adapters={adapters}>\n {children}\n </RuntimeAdapterProvider>\n );\n },\n [],\n );\n\n const cloud = adapter.cloud ?? autoCloud;\n return useMemo<RemoteThreadListAdapter>(() => {\n if (!cloud) {\n const ref = adapterRef;\n const inMemory = new InMemoryThreadListAdapter();\n inMemory.initialize = async (threadId: string) => {\n const result = await ref.current.create?.();\n return { remoteId: threadId, externalId: result?.externalId };\n };\n return inMemory;\n }\n\n return {\n list: async () => {\n const { threads } = await cloud.threads.list();\n return {\n threads: threads.map((t) => ({\n status: t.is_archived ? \"archived\" : \"regular\",\n remoteId: t.id,\n title: t.title,\n lastMessageAt: t.last_message_at\n ? new Date(t.last_message_at)\n : undefined,\n externalId: t.external_id ?? undefined,\n custom: toCustom(t.metadata),\n })),\n };\n },\n\n initialize: async () => {\n const createTask = adapterRef.current.create?.() ?? Promise.resolve();\n const t = await createTask;\n const external_id = t ? t.externalId : undefined;\n const { thread_id: remoteId } = await cloud.threads.create({\n last_message_at: new Date(),\n external_id,\n });\n\n return { externalId: external_id, remoteId: remoteId };\n },\n\n rename: async (threadId, newTitle) => {\n return cloud.threads.update(threadId, { title: newTitle });\n },\n updateCustom: async (threadId, custom) => {\n return cloud.threads.update(threadId, { metadata: custom ?? null });\n },\n archive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: true });\n },\n unarchive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: false });\n },\n delete: async (threadId) => {\n await adapterRef.current.delete?.(threadId);\n return cloud.threads.delete(threadId);\n },\n\n generateTitle: async (threadId, messages) => {\n // Filter messages to only include content types the title generator understands\n // (reasoning, source, etc. are not needed for title generation)\n // TODO serialize these to a more efficient format\n const filteredMessages = messages.map((msg) => ({\n ...msg,\n content: msg.content.filter(\n (part) => part.type === \"text\" || part.type === \"tool-call\",\n ),\n }));\n\n return cloud.runs.stream({\n thread_id: threadId,\n assistant_id: \"system/thread_title\",\n messages: filteredMessages,\n });\n },\n\n fetch: async (threadId: string) => {\n const thread = await cloud.threads.get(threadId);\n return {\n status: thread.is_archived ? \"archived\" : \"regular\",\n remoteId: thread.id,\n title: thread.title,\n lastMessageAt: thread.last_message_at\n ? new Date(thread.last_message_at)\n : undefined,\n externalId: thread.external_id ?? undefined,\n custom: toCustom(thread.metadata),\n };\n },\n\n unstable_Provider,\n };\n }, [cloud, unstable_Provider]);\n};\n"],"mappings":";;;;;;;;;AA6BA,MAAMwB,YAAYC,UAChBV,SAASU,KAAK,IAAIA,QAAQC,KAAAA;AAE5B,MAAMC,UACJ,OAAO3B,YAAY,eACnBA,SAASC,KAAK2B;AAChB,MAAMC,YAAYF,UACd,IAAIlB,eAAe;CAAEkB;CAASG,WAAW;AAAK,CAAC,IAC/CJ,KAAAA;AAEJ,MAAaK,6BACXC,YAC4B;CAC5B,MAAMC,aAAazB,OAAOwB,OAAO;CACjC1B,gBAAgB;EACd2B,WAAWC,UAAUF;CACvB,GAAG,CAACA,OAAO,CAAC;CAEZ,MAAMG,oBAAoB9B,YACxB,SAAS+B,SAAS,EAAEC,YAAY;EAC9B,MAAMC,UAAU1B,sCAAsC,EACpD,IAAIsB,UAAU;GACZ,OAAOD,WAAWC,QAAQf,SAASU;EACrC,EACF,CAAC;EACD,MAAMU,gBAAgBN,WAAWC,QAAQf,SAASU;EAClD,MAAMW,cAAcjC,cACZ,IAAIO,2BAA2ByB,aAAa,GAClD,CAACA,aAAa,CAChB;
|
|
1
|
+
{"version":3,"file":"useCloudThreadListAdapter.js","names":["process","env","Record","FC","PropsWithChildren","useCallback","useEffect","useMemo","useRef","AssistantCloud","RemoteThreadListAdapter","InMemoryThreadListAdapter","useAssistantCloudThreadHistoryAdapter","RuntimeAdapterProvider","CloudFileAttachmentAdapter","isRecord","ThreadData","externalId","CloudThreadListAdapterOptions","cloud","create","Promise","delete","threadId","toCustom","value","undefined","baseUrl","NEXT_PUBLIC_ASSISTANT_BASE_URL","autoCloud","anonymous","useCloudThreadListAdapter","adapter","adapterRef","current","unstable_Provider","Provider","children","history","cloudInstance","attachments","adapters","ref","inMemory","initialize","result","remoteId","list","threads","map","t","status","is_archived","id","title","lastMessageAt","last_message_at","Date","external_id","custom","metadata","createTask","resolve","thread_id","rename","newTitle","update","updateCustom","archive","unarchive","generateTitle","messages","filteredMessages","msg","content","filter","part","type","runs","stream","assistant_id","fetch","thread","get"],"sources":["../../../../src/react/runtimes/cloud/useCloudThreadListAdapter.tsx"],"sourcesContent":["declare const process: { env: Record<string, string | undefined> };\n\nimport {\n type FC,\n type PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { AssistantCloud } from \"assistant-cloud\";\nimport type { RemoteThreadListAdapter } from \"../../../runtimes/remote-thread-list/types\";\nimport { InMemoryThreadListAdapter } from \"../../../runtimes/remote-thread-list/adapter/in-memory\";\nimport { useAssistantCloudThreadHistoryAdapter } from \"./AssistantCloudThreadHistoryAdapter\";\nimport { RuntimeAdapterProvider } from \"../RuntimeAdapterProvider\";\nimport { CloudFileAttachmentAdapter } from \"./CloudFileAttachmentAdapter\";\nimport { isRecord } from \"../../../utils/json/is-json\";\n\ntype ThreadData = {\n externalId: string | undefined;\n};\n\ntype CloudThreadListAdapterOptions = {\n cloud?: AssistantCloud | undefined;\n\n create?: (() => Promise<ThreadData>) | undefined;\n delete?: ((threadId: string) => Promise<void>) | undefined;\n};\n\nconst toCustom = (value: unknown): Record<string, unknown> | undefined =>\n isRecord(value) ? value : undefined;\n\nconst baseUrl =\n typeof process !== \"undefined\" &&\n process?.env?.NEXT_PUBLIC_ASSISTANT_BASE_URL;\nconst autoCloud = baseUrl\n ? new AssistantCloud({ baseUrl, anonymous: true })\n : undefined;\n\nexport const useCloudThreadListAdapter = (\n adapter: CloudThreadListAdapterOptions,\n): RemoteThreadListAdapter => {\n const adapterRef = useRef(adapter);\n useEffect(() => {\n adapterRef.current = adapter;\n }, [adapter]);\n\n const unstable_Provider = useCallback<FC<PropsWithChildren>>(\n function Provider({ children }) {\n const history = useAssistantCloudThreadHistoryAdapter({\n get current() {\n return adapterRef.current.cloud ?? autoCloud!;\n },\n });\n const cloudInstance = adapterRef.current.cloud ?? autoCloud!;\n const attachments = useMemo(\n () => new CloudFileAttachmentAdapter(cloudInstance),\n [cloudInstance],\n );\n\n const adapters = useMemo(\n () => ({\n history,\n attachments,\n }),\n [history, attachments],\n );\n\n return (\n <RuntimeAdapterProvider adapters={adapters}>\n {children}\n </RuntimeAdapterProvider>\n );\n },\n [],\n );\n\n const cloud = adapter.cloud ?? autoCloud;\n return useMemo<RemoteThreadListAdapter>(() => {\n if (!cloud) {\n const ref = adapterRef;\n const inMemory = new InMemoryThreadListAdapter();\n inMemory.initialize = async (threadId: string) => {\n const result = await ref.current.create?.();\n return { remoteId: threadId, externalId: result?.externalId };\n };\n return inMemory;\n }\n\n return {\n list: async () => {\n const { threads } = await cloud.threads.list();\n return {\n threads: threads.map((t) => ({\n status: t.is_archived ? \"archived\" : \"regular\",\n remoteId: t.id,\n title: t.title,\n lastMessageAt: t.last_message_at\n ? new Date(t.last_message_at)\n : undefined,\n externalId: t.external_id ?? undefined,\n custom: toCustom(t.metadata),\n })),\n };\n },\n\n initialize: async () => {\n const createTask = adapterRef.current.create?.() ?? Promise.resolve();\n const t = await createTask;\n const external_id = t ? t.externalId : undefined;\n const { thread_id: remoteId } = await cloud.threads.create({\n last_message_at: new Date(),\n external_id,\n });\n\n return { externalId: external_id, remoteId: remoteId };\n },\n\n rename: async (threadId, newTitle) => {\n return cloud.threads.update(threadId, { title: newTitle });\n },\n updateCustom: async (threadId, custom) => {\n return cloud.threads.update(threadId, { metadata: custom ?? null });\n },\n archive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: true });\n },\n unarchive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: false });\n },\n delete: async (threadId) => {\n await adapterRef.current.delete?.(threadId);\n return cloud.threads.delete(threadId);\n },\n\n generateTitle: async (threadId, messages) => {\n // Filter messages to only include content types the title generator understands\n // (reasoning, source, etc. are not needed for title generation)\n // TODO serialize these to a more efficient format\n const filteredMessages = messages.map((msg) => ({\n ...msg,\n content: msg.content.filter(\n (part) => part.type === \"text\" || part.type === \"tool-call\",\n ),\n }));\n\n return cloud.runs.stream({\n thread_id: threadId,\n assistant_id: \"system/thread_title\",\n messages: filteredMessages,\n });\n },\n\n fetch: async (threadId: string) => {\n const thread = await cloud.threads.get(threadId);\n return {\n status: thread.is_archived ? \"archived\" : \"regular\",\n remoteId: thread.id,\n title: thread.title,\n lastMessageAt: thread.last_message_at\n ? new Date(thread.last_message_at)\n : undefined,\n externalId: thread.external_id ?? undefined,\n custom: toCustom(thread.metadata),\n };\n },\n\n unstable_Provider,\n };\n }, [cloud, unstable_Provider]);\n};\n"],"mappings":";;;;;;;;;AA6BA,MAAMwB,YAAYC,UAChBV,SAASU,KAAK,IAAIA,QAAQC,KAAAA;AAE5B,MAAMC,UACJ,OAAO3B,YAAY,eACnBA,SAASC,KAAK2B;AAChB,MAAMC,YAAYF,UACd,IAA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AAC;GACH;GAEAS,OAAO,OAAO1D,eAAqB;IACjC,MAAM2D,SAAS,MAAM/D,MAAM6B,QAAQmC,IAAI5D,UAAQ;IAC/C,OAAO;KACL4B,QAAQ+B,OAAO9B,cAAc,aAAa;KAC1CN,UAAUoC,OAAO7B;KACjBC,OAAO4B,OAAO5B;KACdC,eAAe2B,OAAO1B,kBAClB,IAAIC,KAAKyB,OAAO1B,eAAe,IAC/B9B,KAAAA;KACJT,YAAYiE,OAAOxB,eAAehC,KAAAA;KAClCiC,QAAQnC,SAAS0D,OAAOtB,QAAQ;IAClC;GACF;GAEAzB;EACF;CACF,GAAG,CAAChB,OAAOgB,iBAAiB,CAAC;AAC/B"}
|
|
@@ -165,7 +165,9 @@ const convertExternalMessages = (messages, callback, isRunning, metadata) => {
|
|
|
165
165
|
const result = chunks.map((message, idx) => {
|
|
166
166
|
const isLast = idx === chunks.length - 1;
|
|
167
167
|
const joined = joinExternalMessages(message.outputs);
|
|
168
|
-
const
|
|
168
|
+
const hasInterruptedToolCalls = typeof joined.content === "object" && joined.content.some(isInterruptedToolCall);
|
|
169
|
+
const hasPendingToolCalls = typeof joined.content === "object" && joined.content.some(isPendingToolCall);
|
|
170
|
+
const autoStatus = getAutoStatus(isLast, isRunning, hasInterruptedToolCalls, hasPendingToolCalls, isLast ? metadata.error : void 0);
|
|
169
171
|
const newMessage = fromThreadMessageLike(joined, idx.toString(), autoStatus);
|
|
170
172
|
bindExternalStoreMessage(newMessage, message.inputs);
|
|
171
173
|
return newMessage;
|