@assistant-ui/core 0.2.21 → 0.2.22
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/adapters/attachment.d.ts.map +1 -1
- package/dist/adapters/speech.d.ts.map +1 -1
- package/dist/adapters/speech.js +9 -2
- package/dist/adapters/speech.js.map +1 -1
- package/dist/adapters/voice.d.ts.map +1 -1
- package/dist/adapters/voice.js +13 -5
- package/dist/adapters/voice.js.map +1 -1
- package/dist/internal.d.ts +3 -1
- package/dist/internal.js +3 -1
- package/dist/model-context/frame/host.d.ts +1 -0
- package/dist/model-context/frame/host.d.ts.map +1 -1
- package/dist/model-context/frame/host.js +5 -0
- package/dist/model-context/frame/host.js.map +1 -1
- package/dist/model-context/frame/provider.d.ts.map +1 -1
- package/dist/model-context/frame/provider.js +1 -0
- package/dist/model-context/frame/provider.js.map +1 -1
- package/dist/model-context/interactable-composer-metadata.js.map +1 -1
- package/dist/react/AssistantProvider.js.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
- package/dist/react/adapters/LocalStorageThreadListAdapter.js +77 -50
- package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/Tools.d.ts.map +1 -1
- package/dist/react/client/interactable-model-context.d.ts.map +1 -1
- package/dist/react/model-context/useInteractable.js.map +1 -1
- package/dist/react/primitive-hooks/useActionBarCopy.js +13 -13
- package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
- package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts.map +1 -1
- package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +1 -1
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
- package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
- package/dist/react/primitives/composer/ComposerQueue.js.map +1 -1
- package/dist/react/primitives/generativeUI/GenerativeUI.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.d.ts +2 -1
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +46 -36
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/primitives/part/PartMessages.js.map +1 -1
- package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
- package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +18 -30
- package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
- package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
- package/dist/react/providers/PartByIndexProvider.js +18 -30
- package/dist/react/providers/PartByIndexProvider.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +1 -0
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +9 -2
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +49 -8
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +1 -1
- package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js +2 -1
- package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
- package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.js +1 -1
- package/dist/react/runtimes/external-message-converter.js.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.d.ts +1 -0
- package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.js +9 -1
- package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
- package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
- package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
- package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.js +4 -4
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-item-runtime.js +2 -1
- package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +4 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-composer-runtime-core.js +41 -14
- package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js +2 -1
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js +4 -2
- package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-thread-composer-runtime-core.js +2 -2
- package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
- package/dist/runtime/utils/message-repository.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js +4 -1
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtimes/external-store/external-store-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +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.map +1 -1
- package/dist/runtimes/local/local-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +5 -2
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +4 -4
- package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/optimistic-state.js +22 -9
- package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +1 -2
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
- package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
- package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/subscribable/subscribable.d.ts +1 -1
- package/dist/subscribable/subscribable.d.ts.map +1 -1
- package/dist/subscribable/subscribable.js +11 -3
- package/dist/subscribable/subscribable.js.map +1 -1
- package/dist/tests/remote-thread-list-test-helpers.d.ts +2 -1
- package/dist/tests/remote-thread-list-test-helpers.d.ts.map +1 -1
- package/dist/tests/remote-thread-list-test-helpers.js +5 -2
- package/dist/tests/remote-thread-list-test-helpers.js.map +1 -1
- package/dist/types/attachment.d.ts +2 -1
- package/dist/types/attachment.d.ts.map +1 -1
- package/dist/types/attachment.js +6 -0
- package/dist/types/attachment.js.map +1 -0
- package/dist/types/message.d.ts +1 -0
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/utils/data-url.d.ts +9 -0
- package/dist/utils/data-url.d.ts.map +1 -0
- package/dist/utils/data-url.js +14 -0
- package/dist/utils/data-url.js.map +1 -0
- package/dist/utils/notify-event-listeners.d.ts +6 -0
- package/dist/utils/notify-event-listeners.d.ts.map +1 -0
- package/dist/utils/notify-event-listeners.js +16 -0
- package/dist/utils/notify-event-listeners.js.map +1 -0
- package/package.json +10 -9
- package/src/adapters/speech.test.ts +88 -0
- package/src/adapters/speech.ts +17 -2
- package/src/adapters/voice.test.ts +130 -0
- package/src/adapters/voice.ts +26 -6
- package/src/internal.ts +5 -0
- package/src/model-context/frame/host.test.ts +100 -0
- package/src/model-context/frame/host.ts +10 -0
- package/src/model-context/frame/provider.test.ts +83 -0
- package/src/model-context/frame/provider.ts +1 -0
- package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +82 -0
- package/src/react/adapters/LocalStorageThreadListAdapter.tsx +94 -54
- package/src/react/primitive-hooks/useActionBarCopy.test.ts +79 -0
- package/src/react/primitive-hooks/useActionBarCopy.ts +4 -3
- package/src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx +1 -3
- package/src/react/primitives/message/MessageParts.tsx +48 -35
- package/src/react/providers/ChainOfThoughtPartByIndexProvider.tsx +19 -2
- package/src/react/providers/PartByIndexProvider.tsx +16 -2
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +18 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +1 -0
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +48 -7
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +69 -0
- package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +1 -1
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +16 -0
- package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +2 -1
- package/src/react/runtimes/external-message-converter.test.tsx +21 -0
- package/src/react/runtimes/external-message-converter.ts +1 -1
- package/src/react/runtimes/useLocalRuntime.test.tsx +56 -0
- package/src/react/runtimes/useLocalRuntime.ts +13 -1
- package/src/runtime/api/message-runtime.test.ts +81 -0
- package/src/runtime/api/message-runtime.ts +4 -6
- package/src/runtime/api/thread-list-item-runtime.ts +6 -1
- package/src/runtime/base/base-composer-runtime-core.ts +77 -31
- package/src/runtime/base/base-thread-runtime-core.ts +2 -1
- package/src/runtime/base/default-edit-composer-runtime-core.ts +4 -2
- package/src/runtime/base/default-thread-composer-runtime-core.ts +2 -2
- package/src/runtime/utils/thread-message-like.ts +1 -0
- package/src/runtimes/local/local-thread-runtime-core.test.ts +150 -1
- package/src/runtimes/local/local-thread-runtime-core.ts +4 -2
- package/src/runtimes/remote-thread-list/optimistic-state.test.ts +63 -0
- package/src/runtimes/remote-thread-list/optimistic-state.ts +49 -17
- package/src/runtimes/remote-thread-list/types.ts +1 -1
- package/src/runtimes/tool-invocations/EDGE_CASES.md +13 -19
- package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +127 -6
- package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +4 -2
- package/src/subscribable/subscribable.test.ts +58 -0
- package/src/subscribable/subscribable.ts +13 -3
- package/src/tests/OptimisticState-list-race.test.ts +33 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-switchToThread-order.test.ts +223 -0
- package/src/tests/base-composer-runtime-core-addAttachment.test.ts +44 -0
- package/src/tests/base-composer-runtime-core-send.test.ts +433 -5
- package/src/tests/default-edit-composer-runtime-core.test.ts +43 -5
- package/src/tests/event-subscription-listener-errors.test.ts +205 -0
- package/src/tests/remote-thread-list-test-helpers.ts +14 -7
- package/src/tests/thread-message-like.test.ts +57 -0
- package/src/types/attachment.ts +5 -0
- package/src/types/message.ts +1 -0
- package/src/utils/data-url.test.ts +50 -0
- package/src/utils/data-url.ts +9 -0
- package/src/utils/notify-event-listeners.ts +30 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActionBarCopy.js","names":["useCallback","useAui","useAuiState","UseActionBarCopyOptions","copiedDuration","copyToClipboard","text","Promise","useActionBarCopy","t0","$","_c","t1","undefined","t2","aui","disabled","_temp2","isCopied","_temp3","isEditing","_temp4","composerValue","_temp5","t3","valueToCopy","message","getCopyText","
|
|
1
|
+
{"version":3,"file":"useActionBarCopy.js","names":["useCallback","useAui","useAuiState","UseActionBarCopyOptions","copiedDuration","copyToClipboard","text","Promise","useActionBarCopy","t0","$","_c","t1","undefined","t2","aui","disabled","_temp2","isCopied","_temp3","isEditing","_temp4","composerValue","_temp5","t3","valueToCopy","message","getCopyText","resolve","then","setIsCopied","setTimeout","_temp6","copy","t4","t5","_temp","c","type","length","s","role","status","parts","some","s_0","s_1","composer","s_2"],"sources":["../../../src/react/primitive-hooks/useActionBarCopy.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\nexport type UseActionBarCopyOptions = {\n copiedDuration?: number | undefined;\n copyToClipboard?: ((text: string) => void | Promise<void>) | undefined;\n};\n\nexport const useActionBarCopy = ({\n copiedDuration = 3000,\n copyToClipboard,\n}: UseActionBarCopyOptions = {}) => {\n const aui = useAui();\n const disabled = useAuiState((s) => {\n return !(\n (s.message.role !== \"assistant\" ||\n s.message.status?.type !== \"running\") &&\n s.message.parts.some((c) => c.type === \"text\" && c.text.length > 0)\n );\n });\n const isCopied = useAuiState((s) => s.message.isCopied);\n const isEditing = useAuiState((s) => s.composer.isEditing);\n const composerValue = useAuiState((s) => s.composer.text);\n\n const copy = useCallback(() => {\n if (!copyToClipboard) return;\n\n const valueToCopy = isEditing ? composerValue : aui.message().getCopyText();\n if (!valueToCopy) return;\n\n // The rejection handler swallows clipboard write failures (permission denied,\n // API unavailable) so they don't surface as unhandled promise rejections.\n Promise.resolve(copyToClipboard(valueToCopy)).then(\n () => {\n aui.message().setIsCopied(true);\n setTimeout(() => aui.message().setIsCopied(false), copiedDuration);\n },\n () => {},\n );\n }, [aui, isEditing, composerValue, copiedDuration, copyToClipboard]);\n\n return { copy, disabled: disabled || !copyToClipboard, isCopied };\n};\n"],"mappings":";;;AAQA,MAAaQ,oBAAmBC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAD,IAAA;EAACG,KAAAH,OAAAI,KAAAA,IAAA,CAGH,IAHGJ;EAGFC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAHE,MAAA,EAAAN,gBAAAU,IAAAT,oBAAAO;CAC/B,MAAAR,iBAAAU,OAAAD,KAAAA,IAAA,MAAAC;CAGA,MAAAC,MAAYd,OAAO;CACnB,MAAAe,WAAiBd,YAAYe,MAM5B;CACD,MAAAC,WAAiBhB,YAAYiB,MAAyB;CACtD,MAAAC,YAAkBlB,YAAYmB,MAA2B;CACzD,MAAAC,gBAAsBpB,YAAYqB,MAAsB;CAAE,IAAAC;CAAA,IAAAd,EAAA,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IAACd,QAAQR;AAAS;AAZxB,SAAAG,OAAAyB,KAAA;CAAA,OAaON,IAACO,SAAS3B;AAAU;AAb3B,SAAAG,OAAAyB,KAAA;CAAA,OAcWR,IAACO,SAASzC;AAAK;AAd1B,SAAA0B,SAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useComposerAddAttachment.d.ts","names":[],"sources":["../../../src/react/primitive-hooks/useComposerAddAttachment.ts"],"mappings":";;cAIa;
|
|
1
|
+
{"version":3,"file":"useComposerAddAttachment.d.ts","names":[],"sources":["../../../src/react/primitive-hooks/useComposerAddAttachment.ts"],"mappings":";;cAIa;EAKF,gBAAA,MAAA,OAAO,qBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useComposerSend.d.ts","names":[],"sources":["../../../src/react/primitive-hooks/useComposerSend.ts"],"mappings":";;cAIa;
|
|
1
|
+
{"version":3,"file":"useComposerSend.d.ts","names":[],"sources":["../../../src/react/primitive-hooks/useComposerSend.ts"],"mappings":";;cAIa;EASD,OAAA,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChainOfThoughtParts.d.ts","names":[],"sources":["../../../../src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx"],"mappings":";;;;KAgBK;;EAEH,YAAY;;EAEZ;IACE,WAAW;;;EAGb,SAAS,cAAc;;kBAGR;OACH;;;;IAKN,aAAa;IACb;;;IAIA,WAAW;MAAS,MAAM;UAAgB;IAC1C;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtParts.d.ts","names":[],"sources":["../../../../src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx"],"mappings":";;;;KAgBK;;EAEH,YAAY;;EAEZ;IACE,WAAW;;;EAGb,SAAS,cAAc;;kBAGR;OACH;;;;IAKN,aAAa;IACb;;;IAIA,WAAW;MAAS,MAAM;UAAgB;IAC1C;;;;;;;;;cAoCK,8BAA8B,GACzC,6BAA6B"}
|
|
@@ -10,7 +10,7 @@ const ChainOfThoughtPrimitivePartsInner = ({ children }) => {
|
|
|
10
10
|
return useMemo(() => Array.from({ length: partsLength }, (_, index) => /* @__PURE__ */ jsx(ChainOfThoughtPartByIndexProvider, {
|
|
11
11
|
index,
|
|
12
12
|
children: /* @__PURE__ */ jsx(RenderChildrenWithAccessor, {
|
|
13
|
-
getItemState: (aui) => aui.
|
|
13
|
+
getItemState: (aui) => aui.part().getState(),
|
|
14
14
|
children: (getItem) => children({ get part() {
|
|
15
15
|
return getItem();
|
|
16
16
|
} })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChainOfThoughtParts.js","names":["ComponentType","FC","PropsWithChildren","ReactNode","useMemo","RenderChildrenWithAccessor","useAuiState","PartState","ChainOfThoughtPartByIndexProvider","MessagePartComponent","ReasoningMessagePartComponent","ToolCallMessagePartComponent","ChainOfThoughtPartsComponentConfig","Reasoning","tools","Fallback","Layout","ChainOfThoughtPrimitiveParts","Props","components","children","value","part","ChainOfThoughtPrimitivePartsInner","partsLength","s","chainOfThought","parts","length","Array","from","_","index","aui","getState","getItem","t0","$","_c","t1","t2","t3","t4","messageComponents","t5","displayName"],"sources":["../../../../src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx"],"sourcesContent":["import {\n type ComponentType,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport { ChainOfThoughtPartByIndexProvider } from \"../../providers/ChainOfThoughtPartByIndexProvider\";\nimport { MessagePartComponent } from \"../message/MessageParts\";\nimport type {\n ReasoningMessagePartComponent,\n ToolCallMessagePartComponent,\n} from \"../../types/MessagePartComponentTypes\";\n\ntype ChainOfThoughtPartsComponentConfig = {\n /** Component for rendering reasoning parts */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Fallback component for tool-call parts */\n tools?: {\n Fallback?: ToolCallMessagePartComponent | undefined;\n };\n /** Layout component to wrap the rendered parts when expanded */\n Layout?: ComponentType<PropsWithChildren> | undefined;\n};\n\nexport namespace ChainOfThoughtPrimitiveParts {\n export type Props =\n | {\n /**\n * @deprecated Use the children render function instead.\n */\n components?: ChainOfThoughtPartsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each part. Receives the part. */\n children: (value: { part: PartState }) => ReactNode;\n components?: never;\n };\n}\n\nconst ChainOfThoughtPrimitivePartsInner: FC<{\n children: (value: { part: PartState }) => ReactNode;\n}> = ({ children }) => {\n const partsLength = useAuiState((s) => s.chainOfThought.parts.length);\n\n return useMemo(\n () =>\n Array.from({ length: partsLength }, (_, index) => (\n <ChainOfThoughtPartByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui)
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtParts.js","names":["ComponentType","FC","PropsWithChildren","ReactNode","useMemo","RenderChildrenWithAccessor","useAuiState","PartState","ChainOfThoughtPartByIndexProvider","MessagePartComponent","ReasoningMessagePartComponent","ToolCallMessagePartComponent","ChainOfThoughtPartsComponentConfig","Reasoning","tools","Fallback","Layout","ChainOfThoughtPrimitiveParts","Props","components","children","value","part","ChainOfThoughtPrimitivePartsInner","partsLength","s","chainOfThought","parts","length","Array","from","_","index","aui","getState","getItem","t0","$","_c","t1","t2","t3","t4","messageComponents","t5","displayName"],"sources":["../../../../src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx"],"sourcesContent":["import {\n type ComponentType,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport { ChainOfThoughtPartByIndexProvider } from \"../../providers/ChainOfThoughtPartByIndexProvider\";\nimport { MessagePartComponent } from \"../message/MessageParts\";\nimport type {\n ReasoningMessagePartComponent,\n ToolCallMessagePartComponent,\n} from \"../../types/MessagePartComponentTypes\";\n\ntype ChainOfThoughtPartsComponentConfig = {\n /** Component for rendering reasoning parts */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Fallback component for tool-call parts */\n tools?: {\n Fallback?: ToolCallMessagePartComponent | undefined;\n };\n /** Layout component to wrap the rendered parts when expanded */\n Layout?: ComponentType<PropsWithChildren> | undefined;\n};\n\nexport namespace ChainOfThoughtPrimitiveParts {\n export type Props =\n | {\n /**\n * @deprecated Use the children render function instead.\n */\n components?: ChainOfThoughtPartsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each part. Receives the part. */\n children: (value: { part: PartState }) => ReactNode;\n components?: never;\n };\n}\n\nconst ChainOfThoughtPrimitivePartsInner: FC<{\n children: (value: { part: PartState }) => ReactNode;\n}> = ({ children }) => {\n const partsLength = useAuiState((s) => s.chainOfThought.parts.length);\n\n return useMemo(\n () =>\n Array.from({ length: partsLength }, (_, index) => (\n <ChainOfThoughtPartByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) => aui.part().getState()}\n >\n {(getItem) =>\n children({\n get part() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </ChainOfThoughtPartByIndexProvider>\n )),\n [partsLength, children],\n );\n};\n\n/**\n * Renders the parts within a chain of thought, with support for collapsed/expanded states.\n *\n * When collapsed, no parts are shown. When expanded, all parts are rendered\n * using the provided component configuration through the part scope mechanism.\n */\nexport const ChainOfThoughtPrimitiveParts: FC<\n ChainOfThoughtPrimitiveParts.Props\n> = ({ components, children }) => {\n if (children) {\n return (\n <ChainOfThoughtPrimitivePartsInner>\n {children}\n </ChainOfThoughtPrimitivePartsInner>\n );\n }\n\n // oxlint-disable-next-line react-hooks/rules-of-hooks -- intentional conditional hook below the early return above\n const messageComponents = useMemo(\n () => ({\n Reasoning: components?.Reasoning,\n tools: {\n Fallback: components?.tools?.Fallback,\n },\n }),\n [components?.Reasoning, components?.tools?.Fallback],\n );\n\n const Layout = components?.Layout;\n\n return (\n <ChainOfThoughtPrimitivePartsInner>\n {() =>\n Layout ? (\n <Layout>\n <MessagePartComponent components={messageComponents} />\n </Layout>\n ) : (\n <MessagePartComponent components={messageComponents} />\n )\n }\n </ChainOfThoughtPrimitivePartsInner>\n );\n};\n\nChainOfThoughtPrimitiveParts.displayName = \"ChainOfThoughtPrimitive.Parts\";\n"],"mappings":";;;;;;;AA2CA,MAAMuB,qCAEA,EAAEH,eAAe;CACrB,MAAMI,cAAclB,aAAamB,MAAMA,EAAEC,eAAeC,MAAMC,MAAM;CAEpE,OAAOxB,cAEHyB,MAAMC,KAAK,EAAEF,QAAQJ,YAAY,IAAIO,GAAGC,UACtC,oBAAC,mCAAD;EAAsDA;EACpD,UAAA,oBAAC,4BAAD;GACE,eAAeC,QAAQA,IAAIX,KAAK,CAAC,CAACY,SAAS;GAEzCC,WAAAA,YACAf,SAAS,EACP,IAAIE,OAAO;IACT,OAAOa,QAAQ;GACjB,EACF,CAAC;EAEuB,CAAA;CACK,GAZKH,KAYL,CACpC,GACH,CAACR,aAAaJ,QAAQ,CACxB;AACF;;;;;;;AAQA,MAAaH,gCAETmB,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAC,MAAA,EAAAnB,YAAAC,aAAAgB;CACH,IAAIhB,UAAQ;EAAA,IAAAmB;EAAA,IAAAF,EAAA,OAAAjB,UAAA;GAERmB,KAAA,oBAAC,mCAAD,EACGnB,SAD+B,CAAA;GAEEiB,EAAA,KAAAjB;GAAAiB,EAAA,KAAAE;EAAA,OAAAA,KAAAF,EAAA;EAAA,OAFpCE;CAEoC;CAYrCpB,YAAUN;CAAaM,YAAUL,OAAiBC;CALtC,MAAAwB,KAAApB,YAAUN;CAET,MAAA2B,KAAArB,YAAUL,OAAiBC;CAAA,IAAA0B;CAAA,IAAAJ,EAAA,OAAAG,IAAA;EADhCC,KAAA,EAAA1B,UACKyB,GACZ;EAACH,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAE,MAAAF,EAAA,OAAAI,IAAA;EAJIC,KAAA;GAAA7B,WACM0B;GAAqBzB,OACzB2B;EAGT;EAACJ,EAAA,KAAAE;EAAAF,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CANH,MAAAM,oBACSD;CAST,MAAA1B,SAAeG,YAAUH;CAAS,IAAA4B;CAAA,IAAAP,EAAA,OAAArB,UAAAqB,EAAA,OAAAM,mBAAA;EAGhCC,KAAA,oBAAC,mCAAD,EAAA,gBAEI5B,SACE,oBAAC,QAAD,EAAA,UACE,oBAAC,sBAAD,EAAkC2B,YAAAA,kBAAiB,CAAA,EAD9C,CAAA,IAIP,oBAAC,sBAAD,EAAkCA,YAAAA,kBAAiB,CAAA,EAPvB,CAAA;EAUEN,EAAA,KAAArB;EAAAqB,EAAA,KAAAM;EAAAN,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,OAVpCO;AAUoC;AAIxC3B,6BAA6B4B,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerAttachments.js","names":["Attachment","ComponentType","FC","ReactNode","memo","useMemo","RenderChildrenWithAccessor","useAuiState","ComposerAttachmentByIndexProvider","ComposerAttachmentsComponentConfig","Image","Document","File","ComposerPrimitiveAttachments","Props","components","children","value","attachment","getComponent","type","AttachmentComponent","t0","$","_c","_temp","t1","Component","t2","ComposerPrimitiveAttachmentByIndex","index","prev","next","displayName","ComposerPrimitiveAttachmentsInner","attachmentsCount","s","composer","attachments","length","Array","from","_","aui","getState","getItem"],"sources":["../../../../src/react/primitives/composer/ComposerAttachments.tsx"],"sourcesContent":["import type { Attachment } from \"../../../types/attachment\";\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport { ComposerAttachmentByIndexProvider } from \"../../providers/AttachmentByIndexProvider\";\n\ntype ComposerAttachmentsComponentConfig = {\n Image?: ComponentType | undefined;\n Document?: ComponentType | undefined;\n File?: ComponentType | undefined;\n Attachment?: ComponentType | undefined;\n};\n\nexport namespace ComposerPrimitiveAttachments {\n export type Props =\n | {\n /** @deprecated Use the children render function instead. */\n components: ComposerAttachmentsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each attachment. Receives the attachment. */\n children: (value: { attachment: Attachment }) => ReactNode;\n components?: never;\n };\n}\n\nconst getComponent = (\n components: ComposerAttachmentsComponentConfig | undefined,\n attachment: Attachment,\n) => {\n const type = attachment.type;\n switch (type) {\n case \"image\":\n return components?.Image ?? components?.Attachment;\n case \"document\":\n return components?.Document ?? components?.Attachment;\n case \"file\":\n return components?.File ?? components?.Attachment;\n default:\n return components?.Attachment;\n }\n};\n\nconst AttachmentComponent: FC<{\n components: ComposerAttachmentsComponentConfig | undefined;\n}> = ({ components }) => {\n const attachment = useAuiState((s) => s.attachment);\n if (!attachment) return null;\n\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n};\n\nexport namespace ComposerPrimitiveAttachmentByIndex {\n export type Props = {\n index: number;\n components?: ComposerAttachmentsComponentConfig;\n };\n}\n\n/**\n * Renders a single attachment at the specified index within the composer.\n */\nexport const ComposerPrimitiveAttachmentByIndex: FC<ComposerPrimitiveAttachmentByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <ComposerAttachmentByIndexProvider index={index}>\n <AttachmentComponent components={components} />\n </ComposerAttachmentByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.Document === next.components?.Document &&\n prev.components?.File === next.components?.File &&\n prev.components?.Attachment === next.components?.Attachment,\n );\n\nComposerPrimitiveAttachmentByIndex.displayName =\n \"ComposerPrimitive.AttachmentByIndex\";\n\nconst ComposerPrimitiveAttachmentsInner: FC<{\n children: (value: { attachment: Attachment }) => ReactNode;\n}> = ({ children }) => {\n const attachmentsCount = useAuiState((s) => s.composer.attachments.length);\n\n return useMemo(\n () =>\n Array.from({ length: attachmentsCount }, (_, index) => (\n <ComposerAttachmentByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.composer().attachment({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get attachment() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </ComposerAttachmentByIndexProvider>\n )),\n [attachmentsCount, children],\n );\n};\n\nexport const ComposerPrimitiveAttachments: FC<\n ComposerPrimitiveAttachments.Props\n> = ({ components, children }) => {\n if (components) {\n return (\n <ComposerPrimitiveAttachmentsInner>\n {({ attachment }) => {\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n }}\n </ComposerPrimitiveAttachmentsInner>\n );\n }\n return (\n <ComposerPrimitiveAttachmentsInner>\n {children}\n </ComposerPrimitiveAttachmentsInner>\n );\n};\n\nComposerPrimitiveAttachments.displayName = \"ComposerPrimitive.Attachments\";\n"],"mappings":";;;;;;AAgCA,MAAMmB,gBACJJ,YACAG,eACG;CAEH,QADaA,WAAWE,MACxB;EACE,KAAK,SACH,OAAOL,YAAYL,SAASK,YAAYf;EAC1C,KAAK,YACH,OAAOe,YAAYJ,YAAYI,YAAYf;EAC7C,KAAK,QACH,OAAOe,YAAYH,QAAQG,YAAYf;EACzC,SACE,OAAOe,YAAYf;CACvB;AACF;AAEA,MAAMqB,uBAEDC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAT,eAAAO;CACJ,MAAAJ,aAAmBX,YAAYkB,KAAmB;CAClD,IAAI,CAACP,YAAU,OAAS;CAAK,IAAAQ;CAAA,IAAAH,EAAA,OAAAL,cAAAK,EAAA,OAAAR,YAAA;EAEXW,KAAAP,aAAaJ,YAAYG,UAAU;EAACK,EAAA,KAAAL;EAAAK,EAAA,KAAAR;EAAAQ,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAtD,MAAAI,YAAkBD;CAClB,IAAI,CAACC,WAAS,OAAS;CAAK,IAAAC;CAAA,IAAAL,EAAA,OAAAI,WAAA;EACrBC,KAAA,oBAAC,WAAD,CAAU,CAAA;EAAGL,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAAbK;AAAa;;;;AAatB,MAAaC,qCACXzB,MACEkB,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAM,OAAAf,eAAAO;CAAqB,IAAAI;CAAA,IAAAH,EAAA,OAAAR,YAAA;EAGhBW,KAAA,oBAAC,qBAAD,EAAiCX,WAAU,CAAA;EAAIQ,EAAA,KAAAR;EAAAQ,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAO,SAAAP,EAAA,OAAAG,IAAA;EADjDE,KAAA,oBAAC,mCAAD;GAA0CE;
|
|
1
|
+
{"version":3,"file":"ComposerAttachments.js","names":["Attachment","ComponentType","FC","ReactNode","memo","useMemo","RenderChildrenWithAccessor","useAuiState","ComposerAttachmentByIndexProvider","ComposerAttachmentsComponentConfig","Image","Document","File","ComposerPrimitiveAttachments","Props","components","children","value","attachment","getComponent","type","AttachmentComponent","t0","$","_c","_temp","t1","Component","t2","ComposerPrimitiveAttachmentByIndex","index","prev","next","displayName","ComposerPrimitiveAttachmentsInner","attachmentsCount","s","composer","attachments","length","Array","from","_","aui","getState","getItem"],"sources":["../../../../src/react/primitives/composer/ComposerAttachments.tsx"],"sourcesContent":["import type { Attachment } from \"../../../types/attachment\";\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport { ComposerAttachmentByIndexProvider } from \"../../providers/AttachmentByIndexProvider\";\n\ntype ComposerAttachmentsComponentConfig = {\n Image?: ComponentType | undefined;\n Document?: ComponentType | undefined;\n File?: ComponentType | undefined;\n Attachment?: ComponentType | undefined;\n};\n\nexport namespace ComposerPrimitiveAttachments {\n export type Props =\n | {\n /** @deprecated Use the children render function instead. */\n components: ComposerAttachmentsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each attachment. Receives the attachment. */\n children: (value: { attachment: Attachment }) => ReactNode;\n components?: never;\n };\n}\n\nconst getComponent = (\n components: ComposerAttachmentsComponentConfig | undefined,\n attachment: Attachment,\n) => {\n const type = attachment.type;\n switch (type) {\n case \"image\":\n return components?.Image ?? components?.Attachment;\n case \"document\":\n return components?.Document ?? components?.Attachment;\n case \"file\":\n return components?.File ?? components?.Attachment;\n default:\n return components?.Attachment;\n }\n};\n\nconst AttachmentComponent: FC<{\n components: ComposerAttachmentsComponentConfig | undefined;\n}> = ({ components }) => {\n const attachment = useAuiState((s) => s.attachment);\n if (!attachment) return null;\n\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n};\n\nexport namespace ComposerPrimitiveAttachmentByIndex {\n export type Props = {\n index: number;\n components?: ComposerAttachmentsComponentConfig;\n };\n}\n\n/**\n * Renders a single attachment at the specified index within the composer.\n */\nexport const ComposerPrimitiveAttachmentByIndex: FC<ComposerPrimitiveAttachmentByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <ComposerAttachmentByIndexProvider index={index}>\n <AttachmentComponent components={components} />\n </ComposerAttachmentByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.Document === next.components?.Document &&\n prev.components?.File === next.components?.File &&\n prev.components?.Attachment === next.components?.Attachment,\n );\n\nComposerPrimitiveAttachmentByIndex.displayName =\n \"ComposerPrimitive.AttachmentByIndex\";\n\nconst ComposerPrimitiveAttachmentsInner: FC<{\n children: (value: { attachment: Attachment }) => ReactNode;\n}> = ({ children }) => {\n const attachmentsCount = useAuiState((s) => s.composer.attachments.length);\n\n return useMemo(\n () =>\n Array.from({ length: attachmentsCount }, (_, index) => (\n <ComposerAttachmentByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.composer().attachment({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get attachment() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </ComposerAttachmentByIndexProvider>\n )),\n [attachmentsCount, children],\n );\n};\n\nexport const ComposerPrimitiveAttachments: FC<\n ComposerPrimitiveAttachments.Props\n> = ({ components, children }) => {\n if (components) {\n return (\n <ComposerPrimitiveAttachmentsInner>\n {({ attachment }) => {\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n }}\n </ComposerPrimitiveAttachmentsInner>\n );\n }\n return (\n <ComposerPrimitiveAttachmentsInner>\n {children}\n </ComposerPrimitiveAttachmentsInner>\n );\n};\n\nComposerPrimitiveAttachments.displayName = \"ComposerPrimitive.Attachments\";\n"],"mappings":";;;;;;AAgCA,MAAMmB,gBACJJ,YACAG,eACG;CAEH,QADaA,WAAWE,MACxB;EACE,KAAK,SACH,OAAOL,YAAYL,SAASK,YAAYf;EAC1C,KAAK,YACH,OAAOe,YAAYJ,YAAYI,YAAYf;EAC7C,KAAK,QACH,OAAOe,YAAYH,QAAQG,YAAYf;EACzC,SACE,OAAOe,YAAYf;CACvB;AACF;AAEA,MAAMqB,uBAEDC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAT,eAAAO;CACJ,MAAAJ,aAAmBX,YAAYkB,KAAmB;CAClD,IAAI,CAACP,YAAU,OAAS;CAAK,IAAAQ;CAAA,IAAAH,EAAA,OAAAL,cAAAK,EAAA,OAAAR,YAAA;EAEXW,KAAAP,aAAaJ,YAAYG,UAAU;EAACK,EAAA,KAAAL;EAAAK,EAAA,KAAAR;EAAAQ,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAtD,MAAAI,YAAkBD;CAClB,IAAI,CAACC,WAAS,OAAS;CAAK,IAAAC;CAAA,IAAA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AC,CAACc,SAAS;GAG9CC,WAAAA,YACA7B,SAAS,EACP,IAAIE,aAAa;IACf,OAAO2B,QAAQ;GACjB,EACF,CAAC;EAEuB,CAAA;CACK,GAdKf,KAcL,CACpC,GACH,CAACK,kBAAkBnB,QAAQ,CAC7B;AACF;AAEA,MAAaH,gCAETS,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAT,YAAAC,aAAAM;CACH,IAAIP,YAAU;EAAA,IAAAW;EAAA,IAAAH,EAAA,OAAAR,YAAA;GAEVW,KAAA,oBAAC,mCAAD,EAAA,WACGE,OAAA;IAAC,MAAA,EAAAV,eAAAU;IACA,MAAAD,YAAkBR,aAAaJ,YAAYG,UAAU;IACrD,IAAI,CAACS,WAAS,OAAS;IAAK,OACrB,oBAAC,WAAD,CAAU,CAAA;GAAG,EAJU,CAAA;GAMEJ,EAAA,KAAAR;GAAAQ,EAAA,KAAAG;EAAA,OAAAA,KAAAH,EAAA;EAAA,OANpCG;CAMoC;CAEvC,IAAAA;CAAA,IAAAH,EAAA,OAAAP,UAAA;EAECU,KAAA,oBAAC,mCAAD,EACGV,SAD+B,CAAA;EAEEO,EAAA,KAAAP;EAAAO,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,OAFpCG;AAEoC;AAIxCb,6BAA6BoB,cAAc;AAxFtC,SAAAR,MAAAW,GAAA;CAAA,OACmCA,EAAClB;AAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerQueue.d.ts","names":[],"sources":["../../../../src/react/primitives/composer/ComposerQueue.tsx"],"mappings":";;;kBAKiB;OACH;;IAEV,WAAW;MAAS,WAAW;UAAqB;;;;;;;;;;;;;;;;;;cA+C3C,wCAAsB;
|
|
1
|
+
{"version":3,"file":"ComposerQueue.d.ts","names":[],"sources":["../../../../src/react/primitives/composer/ComposerQueue.tsx"],"mappings":";;;kBAKiB;OACH;;IAEV,WAAW;MAAS,WAAW;UAAqB;;;;;;;;;;;;;;;;;;cA+C3C,wCAAsB;EA1CvB,WAAC;IAAS,WAAW;QAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerQueue.js","names":["FC","ReactNode","memo","useMemo","RenderChildrenWithAccessor","useAuiState","QueueItemState","QueueItemByIndexProvider","ComposerPrimitiveQueue","Props","children","value","queueItem","ComposerPrimitiveQueueInner","queue","s","composer","length","Array","from","_","index","aui","getState","getItem","displayName"],"sources":["../../../../src/react/primitives/composer/ComposerQueue.tsx"],"sourcesContent":["import { type FC, type ReactNode, memo, useMemo } from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport type { QueueItemState } from \"../../../store/scopes/queue-item\";\nimport { QueueItemByIndexProvider } from \"../../providers/QueueItemByIndexProvider\";\n\nexport namespace ComposerPrimitiveQueue {\n export type Props = {\n /** Render function called for each queue item. Receives the queue item state. */\n children: (value: { queueItem: QueueItemState }) => ReactNode;\n };\n}\n\nconst ComposerPrimitiveQueueInner: FC<{\n children: (value: { queueItem: QueueItemState }) => ReactNode;\n}> = ({ children }) => {\n const queue = useAuiState((s) => s.composer.queue.length);\n\n return useMemo(\n () =>\n Array.from({ length: queue }, (_, index) => (\n <QueueItemByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.composer().queueItem({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get queueItem() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </QueueItemByIndexProvider>\n )),\n [queue, children],\n );\n};\n\n/**\n * Renders all queue items in the composer.\n *\n * @example\n * ```tsx\n * <ComposerPrimitive.Queue>\n * {({ queueItem }) => (\n * <div>\n * <QueueItemPrimitive.Text />\n * <QueueItemPrimitive.Steer>Run Now</QueueItemPrimitive.Steer>\n * </div>\n * )}\n * </ComposerPrimitive.Queue>\n * ```\n */\nexport const ComposerPrimitiveQueue = memo(ComposerPrimitiveQueueInner);\n\nComposerPrimitiveQueue.displayName = \"ComposerPrimitive.Queue\";\n"],"mappings":";;;;;AAYA,MAAMa,+BAEA,EAAEH,eAAe;CACrB,MAAMI,QAAQT,aAAaU,MAAMA,EAAEC,SAASF,MAAMG,MAAM;CAExD,OAAOd,cAEHe,MAAMC,KAAK,EAAEF,QAAQH,MAAM,IAAIM,GAAGC,UAChC,oBAAC,0BAAD;EAA6CA;
|
|
1
|
+
{"version":3,"file":"ComposerQueue.js","names":["FC","ReactNode","memo","useMemo","RenderChildrenWithAccessor","useAuiState","QueueItemState","QueueItemByIndexProvider","ComposerPrimitiveQueue","Props","children","value","queueItem","ComposerPrimitiveQueueInner","queue","s","composer","length","Array","from","_","index","aui","getState","getItem","displayName"],"sources":["../../../../src/react/primitives/composer/ComposerQueue.tsx"],"sourcesContent":["import { type FC, type ReactNode, memo, useMemo } from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport type { QueueItemState } from \"../../../store/scopes/queue-item\";\nimport { QueueItemByIndexProvider } from \"../../providers/QueueItemByIndexProvider\";\n\nexport namespace ComposerPrimitiveQueue {\n export type Props = {\n /** Render function called for each queue item. Receives the queue item state. */\n children: (value: { queueItem: QueueItemState }) => ReactNode;\n };\n}\n\nconst ComposerPrimitiveQueueInner: FC<{\n children: (value: { queueItem: QueueItemState }) => ReactNode;\n}> = ({ children }) => {\n const queue = useAuiState((s) => s.composer.queue.length);\n\n return useMemo(\n () =>\n Array.from({ length: queue }, (_, index) => (\n <QueueItemByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.composer().queueItem({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get queueItem() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </QueueItemByIndexProvider>\n )),\n [queue, children],\n );\n};\n\n/**\n * Renders all queue items in the composer.\n *\n * @example\n * ```tsx\n * <ComposerPrimitive.Queue>\n * {({ queueItem }) => (\n * <div>\n * <QueueItemPrimitive.Text />\n * <QueueItemPrimitive.Steer>Run Now</QueueItemPrimitive.Steer>\n * </div>\n * )}\n * </ComposerPrimitive.Queue>\n * ```\n */\nexport const ComposerPrimitiveQueue = memo(ComposerPrimitiveQueueInner);\n\nComposerPrimitiveQueue.displayName = \"ComposerPrimitive.Queue\";\n"],"mappings":";;;;;AAYA,MAAMa,+BAEA,EAAEH,eAAe;CACrB,MAAMI,QAAQT,aAAaU,MAAMA,EAAEC,SAASF,MAAMG,MAAM;CAExD,OAAOd,cAEHe,MAAMC,KAAK,EAAEF,QAAQH,MAAM,IAAIM,GAAGC,UAChC,oBAAC,0BAAD;EAA6CA;EAC3C,UAAA,oBAAC,4BAAD;GACE,eAAeC,QACbA,IAAIN,SAAS,CAAC,CAACJ,UAAU,EAAES,MAAM,CAAC,CAAC,CAACE,SAAS;GAG7CC,WAAAA,YACAd,SAAS,EACP,IAAIE,YAAY;IACd,OAAOY,QAAQ;GACjB,EACF,CAAC;EAEuB,CAAA;CACJ,GAdKH,KAcL,CAC3B,GACH,CAACP,OAAOJ,QAAQ,CAClB;AACF;;;;;;;;;;;;;;;;AAiBA,MAAaF,yBAAyBN,KAAKW,2BAA2B;AAEtEL,uBAAuBiB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerativeUI.d.ts","names":[],"sources":["../../../../src/react/primitives/generativeUI/GenerativeUI.tsx"],"mappings":";;;;;;;;;;cAyBa,gCAAgC;WAC3B;
|
|
1
|
+
{"version":3,"file":"GenerativeUI.d.ts","names":[],"sources":["../../../../src/react/primitives/generativeUI/GenerativeUI.tsx"],"mappings":";;;;;;;;;;cAyBa,gCAAgC;WAC3B;EAGd,YAAA,uBACA;;;;;;;cA2ES,oBAAoB,GAAG;kBAgBnB;OACH;;;;;;;;IAQV,YAAY;;;;;;IAMZ,OAAO;;IAEP,WACI;MAAgB;MAAmB;;;;;;;;;;;;;;;;;;;;;cAsB9B,8BAA8B,GACzC,6BAA6B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageAttachments.js","names":["CompleteAttachment","ComponentType","FC","ReactNode","memo","useMemo","RenderChildrenWithAccessor","useAuiState","MessageAttachmentByIndexProvider","MessageAttachmentsComponentConfig","Image","Document","File","Attachment","MessagePrimitiveAttachments","Props","components","children","value","attachment","getComponent","type","AttachmentComponent","t0","$","_c","_temp","t1","t2","Component","t3","MessagePrimitiveAttachmentByIndex","index","prev","next","displayName","MessagePrimitiveAttachmentsInner","attachmentsCount","s","message","role","attachments","length","Array","from","_","aui","getState","getItem"],"sources":["../../../../src/react/primitives/message/MessageAttachments.tsx"],"sourcesContent":["import type { CompleteAttachment } from \"../../../types/attachment\";\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport { MessageAttachmentByIndexProvider } from \"../../providers/AttachmentByIndexProvider\";\n\ntype MessageAttachmentsComponentConfig = {\n Image?: ComponentType | undefined;\n Document?: ComponentType | undefined;\n File?: ComponentType | undefined;\n Attachment?: ComponentType | undefined;\n};\n\nexport namespace MessagePrimitiveAttachments {\n export type Props =\n | {\n /** @deprecated Use the children render function instead. */\n components: MessageAttachmentsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each attachment. Receives the attachment. */\n children: (value: { attachment: CompleteAttachment }) => ReactNode;\n components?: never;\n };\n}\n\nconst getComponent = (\n components: MessageAttachmentsComponentConfig | undefined,\n attachment: CompleteAttachment,\n) => {\n const type = attachment.type;\n switch (type) {\n case \"image\":\n return components?.Image ?? components?.Attachment;\n case \"document\":\n return components?.Document ?? components?.Attachment;\n case \"file\":\n return components?.File ?? components?.Attachment;\n default:\n return components?.Attachment;\n }\n};\n\nconst AttachmentComponent: FC<{\n components: MessageAttachmentsComponentConfig | undefined;\n}> = ({ components }) => {\n const attachment = useAuiState((s) => s.attachment);\n if (!attachment) return null;\n\n const Component = getComponent(components, attachment as CompleteAttachment);\n if (!Component) return null;\n return <Component />;\n};\n\nexport namespace MessagePrimitiveAttachmentByIndex {\n export type Props = {\n index: number;\n components?: MessageAttachmentsComponentConfig;\n };\n}\n\n/**\n * Renders a single attachment at the specified index within the current message.\n */\nexport const MessagePrimitiveAttachmentByIndex: FC<MessagePrimitiveAttachmentByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <MessageAttachmentByIndexProvider index={index}>\n <AttachmentComponent components={components} />\n </MessageAttachmentByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.Document === next.components?.Document &&\n prev.components?.File === next.components?.File &&\n prev.components?.Attachment === next.components?.Attachment,\n );\n\nMessagePrimitiveAttachmentByIndex.displayName =\n \"MessagePrimitive.AttachmentByIndex\";\n\nconst MessagePrimitiveAttachmentsInner: FC<{\n children: (value: { attachment: CompleteAttachment }) => ReactNode;\n}> = ({ children }) => {\n const attachmentsCount = useAuiState((s) => {\n if (s.message.role !== \"user\") return 0;\n return (s.message.attachments ?? []).length;\n });\n\n return useMemo(\n () =>\n Array.from({ length: attachmentsCount }, (_, index) => (\n <MessageAttachmentByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.message().attachment({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get attachment() {\n return getItem() as CompleteAttachment;\n },\n })\n }\n </RenderChildrenWithAccessor>\n </MessageAttachmentByIndexProvider>\n )),\n [attachmentsCount, children],\n );\n};\n\nexport const MessagePrimitiveAttachments: FC<\n MessagePrimitiveAttachments.Props\n> = ({ components, children }) => {\n if (components) {\n return (\n <MessagePrimitiveAttachmentsInner>\n {({ attachment }) => {\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n }}\n </MessagePrimitiveAttachmentsInner>\n );\n }\n return (\n <MessagePrimitiveAttachmentsInner>\n {children}\n </MessagePrimitiveAttachmentsInner>\n );\n};\n\nMessagePrimitiveAttachments.displayName = \"M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CAAD;GAAyCI;
|
|
1
|
+
{"version":3,"file":"MessageAttachments.js","names":["CompleteAttachment","ComponentType","FC","ReactNode","memo","useMemo","RenderChildrenWithAccessor","useAuiState","MessageAttachmentByIndexProvider","MessageAttachmentsComponentConfig","Image","Document","File","Attachment","MessagePrimitiveAttachments","Props","components","children","value","attachment","getComponent","type","AttachmentComponent","t0","$","_c","_temp","t1","t2","Component","t3","MessagePrimitiveAttachmentByIndex","index","prev","next","displayName","MessagePrimitiveAttachmentsInner","attachmentsCount","s","message","role","attachments","length","Array","from","_","aui","getState","getItem"],"sources":["../../../../src/react/primitives/message/MessageAttachments.tsx"],"sourcesContent":["import type { CompleteAttachment } from \"../../../types/attachment\";\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport { MessageAttachmentByIndexProvider } from \"../../providers/AttachmentByIndexProvider\";\n\ntype MessageAttachmentsComponentConfig = {\n Image?: ComponentType | undefined;\n Document?: ComponentType | undefined;\n File?: ComponentType | undefined;\n Attachment?: ComponentType | undefined;\n};\n\nexport namespace MessagePrimitiveAttachments {\n export type Props =\n | {\n /** @deprecated Use the children render function instead. */\n components: MessageAttachmentsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each attachment. Receives the attachment. */\n children: (value: { attachment: CompleteAttachment }) => ReactNode;\n components?: never;\n };\n}\n\nconst getComponent = (\n components: MessageAttachmentsComponentConfig | undefined,\n attachment: CompleteAttachment,\n) => {\n const type = attachment.type;\n switch (type) {\n case \"image\":\n return components?.Image ?? components?.Attachment;\n case \"document\":\n return components?.Document ?? components?.Attachment;\n case \"file\":\n return components?.File ?? components?.Attachment;\n default:\n return components?.Attachment;\n }\n};\n\nconst AttachmentComponent: FC<{\n components: MessageAttachmentsComponentConfig | undefined;\n}> = ({ components }) => {\n const attachment = useAuiState((s) => s.attachment);\n if (!attachment) return null;\n\n const Component = getComponent(components, attachment as CompleteAttachment);\n if (!Component) return null;\n return <Component />;\n};\n\nexport namespace MessagePrimitiveAttachmentByIndex {\n export type Props = {\n index: number;\n components?: MessageAttachmentsComponentConfig;\n };\n}\n\n/**\n * Renders a single attachment at the specified index within the current message.\n */\nexport const MessagePrimitiveAttachmentByIndex: FC<MessagePrimitiveAttachmentByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <MessageAttachmentByIndexProvider index={index}>\n <AttachmentComponent components={components} />\n </MessageAttachmentByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.Document === next.components?.Document &&\n prev.components?.File === next.components?.File &&\n prev.components?.Attachment === next.components?.Attachment,\n );\n\nMessagePrimitiveAttachmentByIndex.displayName =\n \"MessagePrimitive.AttachmentByIndex\";\n\nconst MessagePrimitiveAttachmentsInner: FC<{\n children: (value: { attachment: CompleteAttachment }) => ReactNode;\n}> = ({ children }) => {\n const attachmentsCount = useAuiState((s) => {\n if (s.message.role !== \"user\") return 0;\n return (s.message.attachments ?? []).length;\n });\n\n return useMemo(\n () =>\n Array.from({ length: attachmentsCount }, (_, index) => (\n <MessageAttachmentByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.message().attachment({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get attachment() {\n return getItem() as CompleteAttachment;\n },\n })\n }\n </RenderChildrenWithAccessor>\n </MessageAttachmentByIndexProvider>\n )),\n [attachmentsCount, children],\n );\n};\n\nexport const MessagePrimitiveAttachments: FC<\n MessagePrimitiveAttachments.Props\n> = ({ components, children }) => {\n if (components) {\n return (\n <MessagePrimitiveAttachmentsInner>\n {({ attachment }) => {\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n }}\n </MessagePrimitiveAttachmentsInner>\n );\n }\n return (\n <MessagePrimitiveAttachmentsInner>\n {children}\n </MessagePrimitiveAttachmentsInner>\n );\n};\n\nMessagePrimitiveAttachments.display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AAAC,YAAkBT,aAAaJ,YAAYG,UAAU;IACrD,IAAI,CAACU,WAAS,OAAS;IAAK,OACrB,oBAAC,WAAD,CAAU,CAAA;GAAG,EAJS,CAAA;GAMEL,EAAA,KAAAR;GAAAQ,EAAA,KAAAG;EAAA,OAAAA,KAAAH,EAAA;EAAA,OANnCG;CAMmC;CAEtC,IAAAA;CAAA,IAAAH,EAAA,OAAAP,UAAA;EAECU,KAAA,oBAAC,kCAAD,EACGV,SAD8B,CAAA;EAEEO,EAAA,KAAAP;EAAAO,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,OAFnCG;AAEmC;AAIvCb,4BAA4BqB,cAAc;AA3FrC,SAAAT,MAAAY,GAAA;CAAA,OACmCA,EAACnB;AAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageGroupedParts.js","names":["Fragment","FC","ReactNode","useMemo","useAuiState","useShallow","PartState","MessagePartStatus","ToolCallMessagePartStatus","buildGroupTree","GROUPBY_MEMO_KEY","GroupByContext","GroupNode","MessagePartChildren","EnrichedPartState","MessagePrimitiveGroupedParts","GroupPart","type","TKey","status","indices","IndicatorPart","IndicatorMode","RenderInfo","part","children","Props","groupBy","context","indicator","info","COMPLETE_STATUS","Object","freeze","shouldShowIndicator","mode","parts","isRunning","length","last","undefined","PartChildrenSentinel","Error","renderNode","node","render","idKey","index","at","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 {\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` 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 COMPLETE_STATUS: MessagePartStatus = Object.freeze({ type: \"complete\" });\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 = parts[node.indices.at(-1)!]?.status ?? COMPLETE_STATUS;\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":";;;;;;;;AAuIA,MAAM+B,kBAAqCC,OAAOC,OAAO,EAAEhB,MAAM,WAAW,CAAC;AAE7E,MAAMiB,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,KAAKtB,SAAS,UAAUsB,KAAKtB,SAAS;EAE3C;CACF;AACF;;;;;;;AAQA,MAAMwB,6BAAiC;CACrC,MAAM,IAAIC,MACR,8LAGF;AACF;AAEA,MAAMC,cACJC,MACAR,OACAS,WACc;CACd,IAAID,KAAK3B,SAAS,QAIhB,OACE,oBAAC,qBAAD;EAEE,OAAO2B,KAAKG;aAEV,EAAEvB,WAAWqB,OAAO;GAAErB;GAAMC,UAAU,oBAAC,sBAAD,CAAqB,CAAA;EAAI,CAAC;CAC/C,GAJdmB,KAAKE,QAAQ,QAAQF,KAAKE,UAAU,QAAQF,KAAKG,OAInC;CAIzB,MAAM5B,SAASiB,MAAMQ,KAAKxB,QAAQ4B,GAAG,EAAE,EAAG,EAAE7B,UAAUY;CAOtD,OACE,oBAAC,UAAD,EAAA,UACGc,OAAO;EACNrB,MAAMyB;GARVhC,MAAM2B,KAAKM;GACX/B;GACAC,SAASwB,KAAKxB;EAMJ6B;EACNxB,UACE,oBAAA,YAAA,EAAA,UAAGmB,KAAKnB,SAAS2B,KAAKC,UAAUV,WAAWU,OAAOjB,OAAOS,MAAM,CAAC,EAAE,CAAA;CAEtE,CAAC,EACO,GAPKD,KAAKE,SAASF,KAAKO,OAOxB;AAEd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAapC,gCAAgE,EAC3EY,SACAE,YAAY,WACZJ,eACyD;CACzD,MAAMW,QAAQhC,YAAYC,YAAYiD,MAAMA,EAAEC,QAAQnB,KAAK,CAAC;CAE5D,MAAMoB,UAAUpD,aAAakD,QAAMA,IAAEG,MAAMD,OAAO;CAGlD,MAAMnB,YAAYjC,aAAakD,QAC7BzB,cAAc,UAAU,QAAQyB,IAAEC,QAAQpC,QAAQF,SAAS,SAC7D;CAsBA,OACE,qBAAA,YAAA,EAAA,UAAA,CAZWd,cAAc;EACzB,MAAMyB,UAA0B,EAAE4B,QAAQ;EAC1C,OAAO/C,eACL2B,MAAMgB,KAAK5B,SAASG,QAAQH,MAAMI,OAAO,KAAK,CAAA,CAAE,GAChDQ,MAAMgB,KAAK5B,WACTA,OAAKP,SAAS,cAAcO,OAAKqC,aAAarB,KAAAA,CAChD,CACF;CAEF,GAAG;EAACJ;EAbaT,QACfjB,qBAEyBiB;EAUP6B;CAAO,CAItBI,CAAI,CAACR,KAAKR,SAASD,WAAWC,MAAMR,OAAOX,QAAQ,CAAC,GACpDS,oBAAoBL,WAAWO,OAAOC,SAAS,KAC9CZ,SAAS;EACPD,MAAM,EAAEP,MAAM,YAAY;EAC1BQ,UAAU,oBAAC,sBAAD,CAAqB,CAAA;CACjC,CAAC,CACL,EAAA,CAAA;AAEJ;AAEAV,6BAA6B+C,cAAc"}
|
|
1
|
+
{"version":3,"file":"MessageGroupedParts.js","names":["Fragment","FC","ReactNode","useMemo","useAuiState","useShallow","PartState","MessagePartStatus","ToolCallMessagePartStatus","buildGroupTree","GROUPBY_MEMO_KEY","GroupByContext","GroupNode","MessagePartChildren","EnrichedPartState","MessagePrimitiveGroupedParts","GroupPart","type","TKey","status","indices","IndicatorPart","IndicatorMode","RenderInfo","part","children","Props","groupBy","context","indicator","info","COMPLETE_STATUS","Object","freeze","shouldShowIndicator","mode","parts","isRunning","length","last","undefined","PartChildrenSentinel","Error","renderNode","node","render","idKey","index","at","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 {\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` 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 COMPLETE_STATUS: MessagePartStatus = Object.freeze({ type: \"complete\" });\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 = parts[node.indices.at(-1)!]?.status ?? COMPLETE_STATUS;\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":";;;;;;;;AAuIA,MAAM+B,kBAAqCC,OAAOC,OAAO,EAAEhB,MAAM,WAAW,CAAC;AAE7E,MAAMiB,uBACJC,MACAC,OACAC,cACY;CAGZ,IAAI,CAACA,WAAW,OAAO;CAEvB,QAAQF,MAAR;EACE,KAAK,SACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,SACH,OAAOC,MA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AAA,CAZWd,cAAc;EACzB,MAAMyB,UAA0B,EAAE4B,QAAQ;EAC1C,OAAO/C,eACL2B,MAAMgB,KAAK5B,SAASG,QAAQH,MAAMI,OAAO,KAAK,CAAA,CAAE,GAChDQ,MAAMgB,KAAK5B,WACTA,OAAKP,SAAS,cAAcO,OAAKqC,aAAarB,KAAAA,CAChD,CACF;CAEF,GAAG;EAACJ;EAbaT,QACfjB,qBAEyBiB;EAUP6B;CAAO,CAItBI,CAAI,CAACR,KAAKR,SAASD,WAAWC,MAAMR,OAAOX,QAAQ,CAAC,GACpDS,oBAAoBL,WAAWO,OAAOC,SAAS,KAC9CZ,SAAS;EACPD,MAAM,EAAEP,MAAM,YAAY;EAC1BQ,UAAU,oBAAC,sBAAD,CAAqB,CAAA;CACjC,CAAC,CACL,EAAA,CAAA;AAEJ;AAEAV,6BAA6B+C,cAAc"}
|
|
@@ -224,6 +224,7 @@ type EnrichedPartState = (Extract<PartState, {
|
|
|
224
224
|
} | {
|
|
225
225
|
type: "data";
|
|
226
226
|
}>;
|
|
227
|
+
declare const MessagePartChildren: FC<MessagePartChildrenProps>;
|
|
227
228
|
/**
|
|
228
229
|
* Renders the parts of a message with support for multiple content types.
|
|
229
230
|
*
|
|
@@ -232,5 +233,5 @@ type EnrichedPartState = (Extract<PartState, {
|
|
|
232
233
|
*/
|
|
233
234
|
declare const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props>;
|
|
234
235
|
//#endregion
|
|
235
|
-
export { EnrichedPartState, MessagePartComponent, MessagePrimitivePartByIndex, MessagePrimitiveParts, type PartState, defaultComponents, groupMessageParts };
|
|
236
|
+
export { EnrichedPartState, MessagePartChildren, MessagePartComponent, MessagePrimitivePartByIndex, MessagePrimitiveParts, type PartState, defaultComponents, groupMessageParts };
|
|
236
237
|
//# sourceMappingURL=MessageParts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageParts.d.ts","names":[],"sources":["../../../../src/react/primitives/message/MessageParts.tsx"],"mappings":";;;;KA4CK;EACC;EAAgB;;EAEhB;EACA;EACA;EACA;;EAGA;EACA;EACA;EACA;;EAGA;EACA;EACA;EACA;;;;;;;;;cAiDO,oBACX,iCACA,4BACA,8CACC;kBAkFc;OACV;;IAEH,UAAU,eAAe;;IAEzB,WAAW;;OAGR;;IAEH,QAAQ;;IAER,OAAO;;IAEP,SAAS;;IAET,QAAQ;;IAER,OAAO;;IAEP,iBAAiB;;IAEjB,OAAO;;IAEP,QAAQ;;;;;;;;;IASR;;MAGM,YAAY;;MAEZ,WACI;QAAgB;QAAmB;;;;OAM1C;;IAGC,UACI,eAAe;;IAGnB,WAAW,cAAc;;;IAIzB,UAAU,cAAc;;;;;;;;OASzB,qBAAqB;;IAExB,YAAY;;IAEZ,QAAQ;;;;;;;;;;IAWR,YAAY,cACV;MAAoB;MAAoB;;;;;;;;;;;IAY1C,iBAAiB;IAEjB;;;;;;;;;OAUG,2BAA2B;;;;;;IAM9B,gBAAgB;IAEhB;IACA;IACA;IACA;;cAGU;;;;;;;;IASN,aAAa,qBAAqB;;;;;;;;IAQlC;IACA;;;IAIA,WAAW;MAAS,MAAM;UAAwB;IAClD;IACA;;;;;;;;cA4CK;;;;;;;
|
|
1
|
+
{"version":3,"file":"MessageParts.d.ts","names":[],"sources":["../../../../src/react/primitives/message/MessageParts.tsx"],"mappings":";;;;KA4CK;EACC;EAAgB;;EAEhB;EACA;EACA;EACA;;EAGA;EACA;EACA;EACA;;EAGA;EACA;EACA;EACA;;;;;;;;;cAiDO,oBACX,iCACA,4BACA,8CACC;kBAkFc;OACV;;IAEH,UAAU,eAAe;;IAEzB,WAAW;;OAGR;;IAEH,QAAQ;;IAER,OAAO;;IAEP,SAAS;;IAET,QAAQ;;IAER,OAAO;;IAEP,iBAAiB;;IAEjB,OAAO;;IAEP,QAAQ;;;;;;;;;IASR;;MAGM,YAAY;;MAEZ,WACI;QAAgB;QAAmB;;;;OAM1C;;IAGC,UACI,eAAe;;IAGnB,WAAW,cAAc;;;IAIzB,UAAU,cAAc;;;;;;;;OASzB,qBAAqB;;IAExB,YAAY;;IAEZ,QAAQ;;;;;;;;;;IAWR,YAAY,cACV;MAAoB;MAAoB;;;;;;;;;;;IAY1C,iBAAiB;IAEjB;;;;;;;;;OAUG,2BAA2B;;;;;;IAM9B,gBAAgB;IAEhB;IACA;IACA;IACA;;cAGU;;;;;;;;IASN,aAAa,qBAAqB;;;;;;;;IAQlC;IACA;;;IAIA,WAAW;MAAS,MAAM;UAAwB;IAClD;IACA;;;;;;;;cA4CK;;;;;;;EAOe,cAAA,YAAA,sBAAiB;EACZ,mBAAA,YAAA,sBAAiB;;KAG7C;EACH,YAAY,sBAAsB;;cAGvB,sBAAsB,GAAG;kBAkGrB;OACH;IACV;IACA,YAAY,sBAAsB;;;;;;cAOzB,6BAA6B,GAAG,4BAA4B;;;;;;;;;;;;;KA+L7D,qBACP,QAAQ;EAAa;;;WAEX,QAAQ;;EAEjB,WAAW;;EAEX,QAAQ;;EAER,mBAAmB;MAEpB,QAAQ;EAAa;;;WAEX,gBAAgB;KAE3B,QAAQ;EAAa;;EAAwB;;cAmEpC,qBAAqB,GAAG;;;;;;;cA8CxB,uBAAuB,GAAG,sBAAsB"}
|
|
@@ -649,46 +649,56 @@ const EMPTY_RUNNING_TEXT_PART = Object.freeze({
|
|
|
649
649
|
text: "",
|
|
650
650
|
status: RUNNING_STATUS
|
|
651
651
|
});
|
|
652
|
-
|
|
653
|
-
* @internal
|
|
654
|
-
* Renders a single part by index, calling `children` with the
|
|
655
|
-
* {@link EnrichedPartState} (tool/data UI enrichments + addResult/resume
|
|
656
|
-
* for tool calls). Shared between `<MessagePrimitive.Parts>` and
|
|
657
|
-
* `<MessagePrimitive.GroupedParts>`. Returns whatever `children`
|
|
658
|
-
* returns — callers decide how to handle a `null` return.
|
|
659
|
-
*/
|
|
660
|
-
const MessagePartChildren = ({ index, children }) => {
|
|
652
|
+
const MessagePartChildrenInner = ({ children }) => {
|
|
661
653
|
const aui = useAui();
|
|
662
654
|
const dataRenderers = useAuiState((s) => s.dataRenderers);
|
|
663
|
-
return /* @__PURE__ */ jsx(
|
|
664
|
-
|
|
665
|
-
children:
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
return state;
|
|
688
|
-
} })
|
|
689
|
-
})
|
|
655
|
+
return /* @__PURE__ */ jsx(RenderChildrenWithAccessor, {
|
|
656
|
+
getItemState: (client) => client.part().getState(),
|
|
657
|
+
children: (getItem) => children({ get part() {
|
|
658
|
+
const state = getItem();
|
|
659
|
+
if (state.type === "tool-call") {
|
|
660
|
+
const hasUI = resolveToolRender(aui.tools().getState(), state) !== null;
|
|
661
|
+
const partMethods = aui.part();
|
|
662
|
+
return {
|
|
663
|
+
...state,
|
|
664
|
+
toolUI: hasUI ? /* @__PURE__ */ jsx(RegisteredToolUI, {}) : null,
|
|
665
|
+
addResult: partMethods.addToolResult,
|
|
666
|
+
resume: partMethods.resumeToolCall,
|
|
667
|
+
respondToApproval: partMethods.respondToToolApproval
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
if (state.type === "data") {
|
|
671
|
+
const hasUI = getDataRenderer(dataRenderers, state.name, void 0) !== void 0;
|
|
672
|
+
return {
|
|
673
|
+
...state,
|
|
674
|
+
dataRendererUI: hasUI ? /* @__PURE__ */ jsx(RegisteredDataRendererUI, {}) : null
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
return state;
|
|
678
|
+
} })
|
|
690
679
|
});
|
|
691
680
|
};
|
|
681
|
+
const MessagePartChildren = (t0) => {
|
|
682
|
+
const $ = c(5);
|
|
683
|
+
const { index, children } = t0;
|
|
684
|
+
let t1;
|
|
685
|
+
if ($[0] !== children) {
|
|
686
|
+
t1 = /* @__PURE__ */ jsx(MessagePartChildrenInner, { children });
|
|
687
|
+
$[0] = children;
|
|
688
|
+
$[1] = t1;
|
|
689
|
+
} else t1 = $[1];
|
|
690
|
+
let t2;
|
|
691
|
+
if ($[2] !== index || $[3] !== t1) {
|
|
692
|
+
t2 = /* @__PURE__ */ jsx(PartByIndexProvider, {
|
|
693
|
+
index,
|
|
694
|
+
children: t1
|
|
695
|
+
});
|
|
696
|
+
$[2] = index;
|
|
697
|
+
$[3] = t1;
|
|
698
|
+
$[4] = t2;
|
|
699
|
+
} else t2 = $[4];
|
|
700
|
+
return t2;
|
|
701
|
+
};
|
|
692
702
|
const MessagePrimitivePartsInner = (t0) => {
|
|
693
703
|
const $ = c(9);
|
|
694
704
|
const { children } = t0;
|