@assistant-ui/react 0.14.18 → 0.14.20
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/client/ExternalThread.d.ts +3 -2
- package/dist/client/ExternalThread.d.ts.map +1 -1
- package/dist/client/ExternalThread.js +721 -256
- package/dist/client/ExternalThread.js.map +1 -1
- package/dist/client/InMemoryThreadList.d.ts.map +1 -1
- package/dist/client/InMemoryThreadList.js +292 -108
- package/dist/client/InMemoryThreadList.js.map +1 -1
- package/dist/client/SingleThreadList.js +139 -53
- package/dist/client/SingleThreadList.js.map +1 -1
- package/dist/context/ReadonlyStore.js.map +1 -1
- package/dist/context/providers/MessageProvider.js +38 -5
- package/dist/context/providers/MessageProvider.js.map +1 -1
- package/dist/context/providers/ThreadViewportProvider.js +76 -20
- package/dist/context/providers/ThreadViewportProvider.js.map +1 -1
- package/dist/context/react/ThreadViewportContext.js.map +1 -1
- package/dist/context/react/utils/createContextHook.js.map +1 -1
- package/dist/context/react/utils/createContextStoreHook.js +17 -2
- package/dist/context/react/utils/createContextStoreHook.js.map +1 -1
- package/dist/context/react/utils/createStateHookForRuntime.js.map +1 -1
- package/dist/context/react/utils/ensureBinding.js.map +1 -1
- package/dist/context/react/utils/useRuntimeState.js +18 -2
- package/dist/context/react/utils/useRuntimeState.js.map +1 -1
- package/dist/context/stores/ThreadViewport.js.map +1 -1
- package/dist/devtools/DevToolsHooks.js.map +1 -1
- package/dist/hooks/useMessageQuote.js.map +1 -1
- package/dist/hooks/useMessageTiming.js +4 -1
- package/dist/hooks/useMessageTiming.js.map +1 -1
- package/dist/hooks/useToolCallElapsed.d.ts +23 -0
- package/dist/hooks/useToolCallElapsed.d.ts.map +1 -0
- package/dist/hooks/useToolCallElapsed.js +72 -0
- package/dist/hooks/useToolCallElapsed.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/internal.js.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.js +46 -10
- package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
- package/dist/legacy-runtime/cloud/auiV0.js.map +1 -1
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.js +27 -6
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.js.map +1 -1
- package/dist/legacy-runtime/hooks/AssistantContext.js +13 -2
- package/dist/legacy-runtime/hooks/AssistantContext.js.map +1 -1
- package/dist/legacy-runtime/hooks/AttachmentContext.js +9 -1
- package/dist/legacy-runtime/hooks/AttachmentContext.js.map +1 -1
- package/dist/legacy-runtime/hooks/ComposerContext.js +9 -1
- package/dist/legacy-runtime/hooks/ComposerContext.js.map +1 -1
- package/dist/legacy-runtime/hooks/MessageContext.js +12 -2
- package/dist/legacy-runtime/hooks/MessageContext.js.map +1 -1
- package/dist/legacy-runtime/hooks/MessagePartContext.js +9 -1
- package/dist/legacy-runtime/hooks/MessagePartContext.js.map +1 -1
- package/dist/legacy-runtime/hooks/ThreadContext.js +33 -5
- package/dist/legacy-runtime/hooks/ThreadContext.js.map +1 -1
- package/dist/legacy-runtime/hooks/ThreadListItemContext.js +9 -1
- package/dist/legacy-runtime/hooks/ThreadListItemContext.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.js +3 -3
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.js +71 -31
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +24 -16
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.js +17 -12
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.js +17 -3
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.js.map +1 -1
- package/dist/mcp-apps/McpAppRenderer.js +6 -6
- package/dist/mcp-apps/McpAppRenderer.js.map +1 -1
- package/dist/mcp-apps/McpAppsRemoteHost.js +3 -3
- package/dist/mcp-apps/McpAppsRemoteHost.js.map +1 -1
- package/dist/mcp-apps/app-frame.js +33 -14
- package/dist/mcp-apps/app-frame.js.map +1 -1
- package/dist/mcp-apps/bridge.js.map +1 -1
- package/dist/mcp-apps/types.js.map +1 -1
- package/dist/mcp-apps/utils.js.map +1 -1
- package/dist/model-context/frame/useAssistantFrameHost.js +32 -14
- package/dist/model-context/frame/useAssistantFrameHost.js.map +1 -1
- package/dist/model-context/makeAssistantVisible.js +64 -26
- package/dist/model-context/makeAssistantVisible.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js +94 -20
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js +105 -37
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +60 -11
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +60 -11
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarInteractionContext.js +3 -1
- package/dist/primitives/actionBar/ActionBarInteractionContext.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.js +84 -25
- package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js +45 -14
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.js +22 -10
- package/dist/primitives/actionBar/useActionBarFloatStatus.js.map +1 -1
- package/dist/primitives/actionBar.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreContent.js +44 -7
- package/dist/primitives/actionBarMore/ActionBarMoreContent.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreItem.js +28 -6
- package/dist/primitives/actionBarMore/ActionBarMoreItem.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreRoot.js +103 -36
- package/dist/primitives/actionBarMore/ActionBarMoreRoot.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreSeparator.js +28 -6
- package/dist/primitives/actionBarMore/ActionBarMoreSeparator.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreTrigger.js +28 -6
- package/dist/primitives/actionBarMore/ActionBarMoreTrigger.js.map +1 -1
- package/dist/primitives/actionBarMore/scope.js.map +1 -1
- package/dist/primitives/actionBarMore.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.js +27 -6
- package/dist/primitives/assistantModal/AssistantModalAnchor.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js +71 -10
- package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.js +93 -26
- package/dist/primitives/assistantModal/AssistantModalRoot.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.js +27 -6
- package/dist/primitives/assistantModal/AssistantModalTrigger.js.map +1 -1
- package/dist/primitives/assistantModal/scope.js.map +1 -1
- package/dist/primitives/assistantModal.js.map +1 -1
- package/dist/primitives/attachment/AttachmentName.js +13 -1
- package/dist/primitives/attachment/AttachmentName.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRemove.js +11 -4
- package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRoot.js +13 -4
- package/dist/primitives/attachment/AttachmentRoot.js.map +1 -1
- package/dist/primitives/attachment/AttachmentThumb.js +20 -9
- package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
- package/dist/primitives/attachment.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.js +14 -2
- package/dist/primitives/branchPicker/BranchPickerCount.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.js +14 -2
- package/dist/primitives/branchPicker/BranchPickerNumber.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js +34 -6
- package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
- package/dist/primitives/branchPicker.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +16 -5
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtRoot.js +13 -4
- package/dist/primitives/chainOfThought/ChainOfThoughtRoot.js.map +1 -1
- package/dist/primitives/chainOfThought.js.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +37 -24
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.js +124 -49
- package/dist/primitives/composer/ComposerAttachmentDropzone.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.js.map +1 -1
- package/dist/primitives/composer/ComposerDictate.js.map +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.js +32 -7
- package/dist/primitives/composer/ComposerDictationTranscript.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +26 -26
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerInputPluginContext.js +71 -25
- package/dist/primitives/composer/ComposerInputPluginContext.js.map +1 -1
- package/dist/primitives/composer/ComposerQuote.js +92 -23
- package/dist/primitives/composer/ComposerQuote.js.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js +45 -11
- package/dist/primitives/composer/ComposerRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerSend.js +9 -2
- package/dist/primitives/composer/ComposerSend.js.map +1 -1
- package/dist/primitives/composer/ComposerStopDictation.js +15 -5
- package/dist/primitives/composer/ComposerStopDictation.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.js +215 -75
- package/dist/primitives/composer/trigger/TriggerPopover.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverAction.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverBack.js +35 -7
- package/dist/primitives/composer/trigger/TriggerPopoverBack.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.js +134 -28
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverItems.js +132 -28
- package/dist/primitives/composer/trigger/TriggerPopoverItems.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverResource.js +124 -52
- package/dist/primitives/composer/trigger/TriggerPopoverResource.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.js +181 -78
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.js.map +1 -1
- package/dist/primitives/composer/trigger/detectTrigger.js.map +1 -1
- package/dist/primitives/composer/trigger/index.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerDetectionResource.js +28 -14
- package/dist/primitives/composer/trigger/triggerDetectionResource.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerKeyboardResource.js +115 -58
- package/dist/primitives/composer/trigger/triggerKeyboardResource.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerNavigationResource.js +202 -70
- package/dist/primitives/composer/trigger/triggerNavigationResource.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerSelectionResource.js +49 -13
- package/dist/primitives/composer/trigger/triggerSelectionResource.js.map +1 -1
- package/dist/primitives/composer.js.map +1 -1
- package/dist/primitives/dropdownMenuRenderPrimitives.js.map +1 -1
- package/dist/primitives/error/ErrorMessage.js +28 -6
- package/dist/primitives/error/ErrorMessage.js.map +1 -1
- package/dist/primitives/error/ErrorRoot.js +14 -5
- package/dist/primitives/error/ErrorRoot.js.map +1 -1
- package/dist/primitives/error.js.map +1 -1
- package/dist/primitives/message/MessageError.js +2 -1
- package/dist/primitives/message/MessageError.js.map +1 -1
- package/dist/primitives/message/MessageIf.js +50 -20
- package/dist/primitives/message/MessageIf.js.map +1 -1
- package/dist/primitives/message/MessageParts.js +41 -7
- package/dist/primitives/message/MessageParts.js.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.js +399 -94
- package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
- package/dist/primitives/message/MessageRoot.js +197 -65
- package/dist/primitives/message/MessageRoot.js.map +1 -1
- package/dist/primitives/message.js.map +1 -1
- package/dist/primitives/messagePart/MessagePartImage.js +15 -5
- package/dist/primitives/messagePart/MessagePartImage.js.map +1 -1
- package/dist/primitives/messagePart/MessagePartText.js +35 -7
- package/dist/primitives/messagePart/MessagePartText.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartData.js +5 -4
- package/dist/primitives/messagePart/useMessagePartData.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartFile.js +5 -4
- package/dist/primitives/messagePart/useMessagePartFile.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartImage.js +5 -4
- package/dist/primitives/messagePart/useMessagePartImage.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartReasoning.js +5 -4
- package/dist/primitives/messagePart/useMessagePartReasoning.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartSource.js +5 -4
- package/dist/primitives/messagePart/useMessagePartSource.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartText.js +5 -4
- package/dist/primitives/messagePart/useMessagePartText.js.map +1 -1
- package/dist/primitives/messagePart.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemRemove.js +11 -4
- package/dist/primitives/queueItem/QueueItemRemove.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemSteer.js +11 -4
- package/dist/primitives/queueItem/QueueItemSteer.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemText.js +20 -6
- package/dist/primitives/queueItem/QueueItemText.js.map +1 -1
- package/dist/primitives/queueItem.js.map +1 -1
- package/dist/primitives/reasoning/useScrollLock.js +61 -43
- package/dist/primitives/reasoning/useScrollLock.js.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js +56 -16
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js +120 -59
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js.map +1 -1
- package/dist/primitives/selectionToolbar.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionDescription.js +20 -6
- package/dist/primitives/suggestion/SuggestionDescription.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionTitle.js +20 -6
- package/dist/primitives/suggestion/SuggestionTitle.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionTrigger.js +39 -26
- package/dist/primitives/suggestion/SuggestionTrigger.js.map +1 -1
- package/dist/primitives/suggestion.js.map +1 -1
- package/dist/primitives/thread/ThreadEmpty.js +6 -2
- package/dist/primitives/thread/ThreadEmpty.js.map +1 -1
- package/dist/primitives/thread/ThreadIf.js +32 -10
- package/dist/primitives/thread/ThreadIf.js.map +1 -1
- package/dist/primitives/thread/ThreadRoot.js +13 -4
- package/dist/primitives/thread/ThreadRoot.js.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.js +24 -6
- package/dist/primitives/thread/ThreadScrollToBottom.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.js +18 -6
- package/dist/primitives/thread/ThreadSuggestion.js.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js +185 -47
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/thread/ThreadViewportFooter.js +22 -9
- package/dist/primitives/thread/ThreadViewportFooter.js.map +1 -1
- package/dist/primitives/thread/topAnchor/computeTopAnchorSlack.js.map +1 -1
- package/dist/primitives/thread/topAnchor/createReserveObservers.js.map +1 -1
- package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.js.map +1 -1
- package/dist/primitives/thread/topAnchor/topAnchorTurn.js.map +1 -1
- package/dist/primitives/thread/topAnchor/topAnchorUtils.js.map +1 -1
- package/dist/primitives/thread/topAnchor/useTopAnchorReserve.js +19 -4
- package/dist/primitives/thread/topAnchor/useTopAnchorReserve.js.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +16 -16
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/primitives/thread.js.map +1 -1
- package/dist/primitives/threadList/ThreadListLoadMore.js.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.js +53 -11
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
- package/dist/primitives/threadList/ThreadListRoot.js +13 -4
- package/dist/primitives/threadList/ThreadListRoot.js.map +1 -1
- package/dist/primitives/threadList.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemDelete.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js +26 -7
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -1
- package/dist/primitives/threadListItem.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js +44 -7
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.js +28 -6
- package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.js +25 -5
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.js +28 -6
- package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js +28 -6
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js.map +1 -1
- package/dist/primitives/threadListItemMore/scope.js.map +1 -1
- package/dist/primitives/threadListItemMore.js.map +1 -1
- package/dist/sandbox-host/SandboxHost.js.map +1 -1
- package/dist/tests/remote-thread-list-test-helpers.js.map +1 -1
- package/dist/tests/setup.js.map +1 -1
- package/dist/unstable/useComposerInputHistory.js.map +1 -1
- package/dist/unstable/useMentionAdapter.js.map +1 -1
- package/dist/unstable/useMessageStallDetection.d.ts +29 -0
- package/dist/unstable/useMessageStallDetection.d.ts.map +1 -0
- package/dist/unstable/useMessageStallDetection.js +69 -0
- package/dist/unstable/useMessageStallDetection.js.map +1 -0
- package/dist/unstable/useSlashCommandAdapter.js.map +1 -1
- package/dist/utils/Primitive.js +57 -12
- package/dist/utils/Primitive.js.map +1 -1
- package/dist/utils/createActionButton.js +23 -7
- package/dist/utils/createActionButton.js.map +1 -1
- package/dist/utils/getSelectionMessageId.js.map +1 -1
- package/dist/utils/hooks/useManagedRef.js +16 -8
- package/dist/utils/hooks/useManagedRef.js.map +1 -1
- package/dist/utils/hooks/useMediaQuery.js +25 -10
- package/dist/utils/hooks/useMediaQuery.js.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.js +29 -19
- package/dist/utils/hooks/useOnResizeContent.js.map +1 -1
- package/dist/utils/hooks/useOnScrollToBottom.js +20 -4
- package/dist/utils/hooks/useOnScrollToBottom.js.map +1 -1
- package/dist/utils/hooks/useSizeHandle.js +23 -15
- package/dist/utils/hooks/useSizeHandle.js.map +1 -1
- package/dist/utils/json/is-json-equal.js.map +1 -1
- package/dist/utils/json/is-json.js.map +1 -1
- package/dist/utils/smooth/SmoothContext.js +41 -11
- package/dist/utils/smooth/SmoothContext.js.map +1 -1
- package/dist/utils/smooth/useSmooth.js +5 -5
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/useToolArgsFieldStatus.js +13 -5
- package/dist/utils/useToolArgsFieldStatus.js.map +1 -1
- package/package.json +9 -9
- package/src/client/ExternalThread.ts +81 -52
- package/src/client/InMemoryThreadList.ts +12 -14
- package/src/hooks/useToolCallElapsed.ts +52 -0
- package/src/index.ts +11 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.test.ts +10 -6
- package/src/primitives/composer/trigger/TriggerPopover.tsx +4 -5
- package/src/tests/toolCallTiming.test.tsx +221 -0
- package/src/unstable/useMessageStallDetection.ts +91 -0
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useRemoteThreadListRuntime } from "../runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js";
|
|
3
3
|
import { useCloudThreadListAdapter } from "../runtime-cores/remote-thread-list/adapter/cloud.js";
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
5
|
//#region src/legacy-runtime/cloud/useCloudThreadListRuntime.ts
|
|
5
|
-
function useCloudThreadListRuntime(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
function useCloudThreadListRuntime(t0) {
|
|
7
|
+
const $ = c(6);
|
|
8
|
+
let adapterOptions;
|
|
9
|
+
let runtimeHook;
|
|
10
|
+
if ($[0] !== t0) {
|
|
11
|
+
({runtimeHook, ...adapterOptions} = t0);
|
|
12
|
+
$[0] = t0;
|
|
13
|
+
$[1] = adapterOptions;
|
|
14
|
+
$[2] = runtimeHook;
|
|
15
|
+
} else {
|
|
16
|
+
adapterOptions = $[1];
|
|
17
|
+
runtimeHook = $[2];
|
|
18
|
+
}
|
|
19
|
+
const adapter = useCloudThreadListAdapter(adapterOptions);
|
|
20
|
+
let t1;
|
|
21
|
+
if ($[3] !== adapter || $[4] !== runtimeHook) {
|
|
22
|
+
t1 = {
|
|
23
|
+
runtimeHook,
|
|
24
|
+
adapter,
|
|
25
|
+
allowNesting: true
|
|
26
|
+
};
|
|
27
|
+
$[3] = adapter;
|
|
28
|
+
$[4] = runtimeHook;
|
|
29
|
+
$[5] = t1;
|
|
30
|
+
} else t1 = $[5];
|
|
31
|
+
return useRemoteThreadListRuntime(t1);
|
|
11
32
|
}
|
|
12
33
|
//#endregion
|
|
13
34
|
export { useCloudThreadListRuntime };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCloudThreadListRuntime.js","names":[],"sources":["../../../src/legacy-runtime/cloud/useCloudThreadListRuntime.ts"],"sourcesContent":["\"use client\";\n\nimport type { AssistantCloud } from \"assistant-cloud\";\nimport type { AssistantRuntime } from \"@assistant-ui/core\";\nimport { useRemoteThreadListRuntime } from \"../runtime-cores/remote-thread-list/useRemoteThreadListRuntime\";\nimport { useCloudThreadListAdapter } from \"../runtime-cores/remote-thread-list/adapter/cloud\";\n\ntype ThreadData = {\n externalId: string;\n};\n\ntype CloudThreadListAdapter = {\n cloud: AssistantCloud;\n\n runtimeHook: () => AssistantRuntime;\n\n create?(): Promise<ThreadData>;\n delete?(threadId: string): Promise<void>;\n};\n\nexport function useCloudThreadListRuntime({\n runtimeHook,\n ...adapterOptions\n}: CloudThreadListAdapter) {\n const adapter = useCloudThreadListAdapter(adapterOptions);\n return useRemoteThreadListRuntime({\n runtimeHook,\n adapter,\n allowNesting: true,\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCloudThreadListRuntime.js","names":["c","_c","AssistantCloud","AssistantRuntime","useRemoteThreadListRuntime","useCloudThreadListAdapter","ThreadData","externalId","CloudThreadListAdapter","cloud","runtimeHook","create","Promise","delete","threadId","useCloudThreadListRuntime","t0","$","adapterOptions","adapter","t1","allowNesting"],"sources":["../../../src/legacy-runtime/cloud/useCloudThreadListRuntime.ts"],"sourcesContent":["\"use client\";\n\nimport type { AssistantCloud } from \"assistant-cloud\";\nimport type { AssistantRuntime } from \"@assistant-ui/core\";\nimport { useRemoteThreadListRuntime } from \"../runtime-cores/remote-thread-list/useRemoteThreadListRuntime\";\nimport { useCloudThreadListAdapter } from \"../runtime-cores/remote-thread-list/adapter/cloud\";\n\ntype ThreadData = {\n externalId: string;\n};\n\ntype CloudThreadListAdapter = {\n cloud: AssistantCloud;\n\n runtimeHook: () => AssistantRuntime;\n\n create?(): Promise<ThreadData>;\n delete?(threadId: string): Promise<void>;\n};\n\nexport function useCloudThreadListRuntime({\n runtimeHook,\n ...adapterOptions\n}: CloudThreadListAdapter) {\n const adapter = useCloudThreadListAdapter(adapterOptions);\n return useRemoteThreadListRuntime({\n runtimeHook,\n adapter,\n allowNesting: true,\n });\n}\n"],"mappings":";;;;;AAoBA,SAAOe,0BAAAC,IAAA;CAAA,MAAAC,IAAAhB,EAAA,CAAA;CAAA,IAAAiB;CAAA,IAAAR;CAAA,IAAAO,EAAA,OAAAD,IAAA;EAAmC,CAAA,CAAAN,gBAAAQ,kBAAAF;EAGjBC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAP;CAAA,OAAA;EAAAQ,iBAAAD,EAAA;EAAAP,cAAAO,EAAA;CAAA;CACvB,MAAAE,UAAgBd,0BAA0Ba,cAAc;CAAE,IAAAE;CAAA,IAAAH,EAAA,OAAAE,WAAAF,EAAA,OAAAP,aAAA;EACxBU,KAAA;GAAAV;GAAAS;GAAAE,cAGlB;EAChB;EAACJ,EAAA,KAAAE;EAAAF,EAAA,KAAAP;EAAAO,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,OAJMb,2BAA2BgB,EAIjC;AAAC"}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime.js";
|
|
3
3
|
import { useAui } from "@assistant-ui/store";
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
5
|
//#region src/legacy-runtime/hooks/AssistantContext.ts
|
|
5
6
|
function useAssistantRuntime(options) {
|
|
6
|
-
const
|
|
7
|
+
const $ = c(2);
|
|
8
|
+
const aui = useAui();
|
|
9
|
+
let t0;
|
|
10
|
+
if ($[0] !== aui) {
|
|
11
|
+
t0 = aui.threads().__internal_getAssistantRuntime?.() ?? null;
|
|
12
|
+
$[0] = aui;
|
|
13
|
+
$[1] = t0;
|
|
14
|
+
} else t0 = $[1];
|
|
15
|
+
const runtime = t0;
|
|
7
16
|
if (!runtime && !options?.optional) throw new Error("AssistantRuntime is not available");
|
|
8
17
|
return runtime;
|
|
9
18
|
}
|
|
10
|
-
const useThreadListRuntime = (opt) =>
|
|
19
|
+
const useThreadListRuntime = (opt) => {
|
|
20
|
+
return useAssistantRuntime(opt)?.threads ?? null;
|
|
21
|
+
};
|
|
11
22
|
/**
|
|
12
23
|
* @deprecated Use {@link useAuiState}: `useAuiState((s) => s.threads)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
13
24
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/AssistantContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useAui } from \"@assistant-ui/store\";\nimport type { AssistantRuntime } from \"../runtime/AssistantRuntime\";\nimport type { ThreadListRuntime } from \"../runtime/ThreadListRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\n\n/**\n * @deprecated Use {@link useAui} instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the AssistantRuntime from the current context.\n *\n * The AssistantRuntime provides access to the top-level assistant state and actions,\n * including thread management, tool registration, and configuration.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The AssistantRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function MyComponent() {\n * const runtime = useAssistantRuntime();\n * const handleNewThread = () => {\n * runtime.switchToNewThread();\n * };\n * return <button onClick={handleNewThread}>New Thread</button>;\n * }\n *\n * // After:\n * function MyComponent() {\n * const aui = useAui();\n * const handleNewThread = () => {\n * aui.threads().switchToNewThread();\n * };\n * return <button onClick={handleNewThread}>New Thread</button>;\n * }\n * ```\n */\nexport function useAssistantRuntime(options?: {\n optional?: false | undefined;\n}): AssistantRuntime;\nexport function useAssistantRuntime(options?: {\n optional?: boolean | undefined;\n}): AssistantRuntime | null;\nexport function useAssistantRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = aui.threads().__internal_getAssistantRuntime?.() ?? null;\n\n if (!runtime && !options?.optional) {\n throw new Error(\"AssistantRuntime is not available\");\n }\n\n return runtime;\n}\n\nconst useThreadListRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadListRuntime | null => useAssistantRuntime(opt)?.threads ?? null;\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.threads)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useThreadList = createStateHookForRuntime(useThreadListRuntime);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AssistantContext.js","names":["c","_c","useAui","AssistantRuntime","ThreadListRuntime","createStateHookForRuntime","useAssistantRuntime","options","optional","$","aui","t0","threads","__internal_getAssistantRuntime","runtime","Error","useThreadListRuntime","opt","useThreadList"],"sources":["../../../src/legacy-runtime/hooks/AssistantContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useAui } from \"@assistant-ui/store\";\nimport type { AssistantRuntime } from \"../runtime/AssistantRuntime\";\nimport type { ThreadListRuntime } from \"../runtime/ThreadListRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\n\n/**\n * @deprecated Use {@link useAui} instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the AssistantRuntime from the current context.\n *\n * The AssistantRuntime provides access to the top-level assistant state and actions,\n * including thread management, tool registration, and configuration.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The AssistantRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function MyComponent() {\n * const runtime = useAssistantRuntime();\n * const handleNewThread = () => {\n * runtime.switchToNewThread();\n * };\n * return <button onClick={handleNewThread}>New Thread</button>;\n * }\n *\n * // After:\n * function MyComponent() {\n * const aui = useAui();\n * const handleNewThread = () => {\n * aui.threads().switchToNewThread();\n * };\n * return <button onClick={handleNewThread}>New Thread</button>;\n * }\n * ```\n */\nexport function useAssistantRuntime(options?: {\n optional?: false | undefined;\n}): AssistantRuntime;\nexport function useAssistantRuntime(options?: {\n optional?: boolean | undefined;\n}): AssistantRuntime | null;\nexport function useAssistantRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = aui.threads().__internal_getAssistantRuntime?.() ?? null;\n\n if (!runtime && !options?.optional) {\n throw new Error(\"AssistantRuntime is not available\");\n }\n\n return runtime;\n}\n\nconst useThreadListRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadListRuntime | null => useAssistantRuntime(opt)?.threads ?? null;\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.threads)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useThreadList = createStateHookForRuntime(useThreadListRuntime);\n"],"mappings":";;;;;AA8CA,SAAOM,oBAAAC,SAAA;CAAA,MAAAE,IAAAR,EAAA,CAAA;CAGL,MAAAS,MAAYR,OAAO;CAAE,IAAAS;CAAA,IAAAF,EAAA,OAAAC,KAAA;EACLC,KAAAD,IAAGE,QAAS,CAAC,CAAAC,iCAA0C,KAAvD;EAAwDJ,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAxE,MAAAK,UAAgBH;CAEhB,IAAI,CAACG,WAAD,CAAaP,SAAOC,UACtB,MAAM,IAAIO,MAAM,mCAAmC;CACpD,OAEMD;AAAO;AAGhB,MAAME,wBAAuBC,QAAA;CAAA,OAEGX,oBAAoBW,GAAY,CAAC,EAAAL,WAAjC;AAAyC;;;;AAKzE,MAAaM,gBAAgBb,0BAA0BW,oBAAoB"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime.js";
|
|
3
3
|
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
5
|
//#region src/legacy-runtime/hooks/AttachmentContext.ts
|
|
5
6
|
function useAttachmentRuntime(options) {
|
|
7
|
+
const $ = c(2);
|
|
6
8
|
const aui = useAui();
|
|
7
|
-
|
|
9
|
+
let t0;
|
|
10
|
+
if ($[0] !== aui) {
|
|
11
|
+
t0 = () => aui.attachment.source ? aui.attachment().__internal_getRuntime?.() ?? null : null;
|
|
12
|
+
$[0] = aui;
|
|
13
|
+
$[1] = t0;
|
|
14
|
+
} else t0 = $[1];
|
|
15
|
+
const runtime = useAuiState(t0);
|
|
8
16
|
if (!runtime && !options?.optional) throw new Error("AttachmentRuntime is not available");
|
|
9
17
|
return runtime;
|
|
10
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/AttachmentContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { AttachmentRuntime } from \"../runtime/AttachmentRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.attachment()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime;\nexport function useAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime | null;\nexport function useAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime | null {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.attachment.source\n ? (aui.attachment().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"AttachmentRuntime is not available\");\n }\n return runtime;\n}\n\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"thread-composer\">;\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"thread-composer\"> | null;\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"thread-composer\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"thread-composer\")\n throw new Error(\n \"This component must be used within a thread's ComposerPrimitive.Attachments component.\",\n );\n return attachmentRuntime as AttachmentRuntime<\"thread-composer\">;\n}\n\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"edit-composer\">;\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"edit-composer\"> | null;\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"edit-composer\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"edit-composer\")\n throw new Error(\n \"This component must be used within a message's ComposerPrimitive.Attachments component.\",\n );\n\n return attachmentRuntime as AttachmentRuntime<\"edit-composer\">;\n}\n\nexport function useMessageAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"message\">;\nexport function useMessageAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"message\"> | null;\nexport function useMessageAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"message\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"message\")\n throw new Error(\n \"This component must be used within a MessagePrimitive.Attachments component.\",\n );\n return attachmentRuntime as AttachmentRuntime<\"message\">;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.attachment)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useAttachment = createStateHookForRuntime(useAttachmentRuntime);\n\nexport const useThreadComposerAttachment = createStateHookForRuntime(\n useThreadComposerAttachmentRuntime,\n);\nexport const useEditComposerAttachment = createStateHookForRuntime(\n useEditComposerAttachmentRuntime,\n);\nexport const useMessageAttachment = createStateHookForRuntime(\n useMessageAttachmentRuntime,\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AttachmentContext.js","names":["c","_c","AttachmentRuntime","createStateHookForRuntime","useAui","useAuiState","useAttachmentRuntime","options","optional","$","aui","t0","attachment","source","__internal_getRuntime","runtime","Error","useThreadComposerAttachmentRuntime","attachmentRuntime","useEditComposerAttachmentRuntime","useMessageAttachmentRuntime","useAttachment","useThreadComposerAttachment","useEditComposerAttachment","useMessageAttachment"],"sources":["../../../src/legacy-runtime/hooks/AttachmentContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { AttachmentRuntime } from \"../runtime/AttachmentRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.attachment()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime;\nexport function useAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime | null;\nexport function useAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime | null {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.attachment.source\n ? (aui.attachment().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"AttachmentRuntime is not available\");\n }\n return runtime;\n}\n\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"thread-composer\">;\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"thread-composer\"> | null;\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"thread-composer\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"thread-composer\")\n throw new Error(\n \"This component must be used within a thread's ComposerPrimitive.Attachments component.\",\n );\n return attachmentRuntime as AttachmentRuntime<\"thread-composer\">;\n}\n\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"edit-composer\">;\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"edit-composer\"> | null;\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"edit-composer\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"edit-composer\")\n throw new Error(\n \"This component must be used within a message's ComposerPrimitive.Attachments component.\",\n );\n\n return attachmentRuntime as AttachmentRuntime<\"edit-composer\">;\n}\n\nexport function useMessageAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"message\">;\nexport function useMessageAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"message\"> | null;\nexport function useMessageAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"message\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"message\")\n throw new Error(\n \"This component must be used within a MessagePrimitive.Attachments component.\",\n );\n return attachmentRuntime as AttachmentRuntime<\"message\">;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.attachment)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useAttachment = createStateHookForRuntime(useAttachmentRuntime);\n\nexport const useThreadComposerAttachment = createStateHookForRuntime(\n useThreadComposerAttachmentRuntime,\n);\nexport const useEditComposerAttachment = createStateHookForRuntime(\n useEditComposerAttachmentRuntime,\n);\nexport const useMessageAttachment = createStateHookForRuntime(\n useMessageAttachmentRuntime,\n);\n"],"mappings":";;;;;AAeA,SAAOM,qBAAAC,SAAA;CAAA,MAAAE,IAAAR,EAAA,CAAA;CAGL,MAAAS,MAAYN,OAAO;CAAE,IAAAO;CAAA,IAAAF,EAAA,OAAAC,KAAA;EACOC,WAC1BD,IAAGE,WAAWC,SACTH,IAAGE,WAAY,CAAC,CAAAE,wBAAiC,KAAjD,OADL;EAEQL,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAHV,MAAAM,UAAgBV,YAAYM,EAI5B;CACA,IAAI,CAACI,WAAD,CAAaR,SAAOC,UACtB,MAAM,IAAIQ,MAAM,oCAAoC;CACrD,OACMD;AAAO;AAShB,SAAOE,mCAAAV,SAAA;CAGL,MAAAW,oBAA0BZ,qBAAqBC,OAAO;CACtD,IAAI,CAACW,mBAAiB,OAAS;CAC/B,IAAIA,kBAAiBL,WAAY,mBAC/B,MAAM,IAAIG,MACR,wFACF;CAAE,OACGE;AAAyD;AASlE,SAAOC,iCAAAZ,SAAA;CAGL,MAAAW,oBAA0BZ,qBAAqBC,OAAO;CACtD,IAAI,CAACW,mBAAiB,OAAS;CAC/B,IAAIA,kBAAiBL,WAAY,iBAC/B,MAAM,IAAIG,MACR,yFACF;CAAE,OAEGE;AAAuD;AAShE,SAAOE,4BAAAb,SAAA;CAGL,MAAAW,oBAA0BZ,qBAAqBC,OAAO;CACtD,IAAI,CAACW,mBAAiB,OAAS;CAC/B,IAAIA,kBAAiBL,WAAY,WAC/B,MAAM,IAAIG,MACR,8EACF;CAAE,OACGE;AAAiD;;;;AAM1D,MAAaG,gBAAgBlB,0BAA0BG,oBAAoB;AAE3E,MAAagB,8BAA8BnB,0BACzCc,kCACF;AACA,MAAaM,4BAA4BpB,0BACvCgB,gCACF;AACA,MAAaK,uBAAuBrB,0BAClCiB,2BACF"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime.js";
|
|
3
3
|
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
5
|
//#region src/legacy-runtime/hooks/ComposerContext.ts
|
|
5
6
|
function useComposerRuntime(options) {
|
|
7
|
+
const $ = c(2);
|
|
6
8
|
const aui = useAui();
|
|
7
|
-
|
|
9
|
+
let t0;
|
|
10
|
+
if ($[0] !== aui) {
|
|
11
|
+
t0 = () => aui.composer.source ? aui.composer().__internal_getRuntime?.() ?? null : null;
|
|
12
|
+
$[0] = aui;
|
|
13
|
+
$[1] = t0;
|
|
14
|
+
} else t0 = $[1];
|
|
15
|
+
const runtime = useAuiState(t0);
|
|
8
16
|
if (!runtime && !options?.optional) throw new Error("ComposerRuntime is not available");
|
|
9
17
|
return runtime;
|
|
10
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/ComposerContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type { ComposerRuntime } from \"../runtime/ComposerRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.composer()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the ComposerRuntime from the current context.\n *\n * The ComposerRuntime provides access to composer state and actions for message\n * composition, including text input, attachments, and sending functionality.\n * This hook automatically resolves to either the message's edit composer or\n * the thread's main composer depending on the context.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The ComposerRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function ComposerActions() {\n * const runtime = useComposerRuntime();\n * const handleSend = () => {\n * if (runtime.getState().canSend) {\n * runtime.send();\n * }\n * };\n * const handleCancel = () => {\n * if (runtime.getState().canCancel) {\n * runtime.cancel();\n * }\n * };\n * return (\n * <div>\n * <button onClick={handleSend}>Send</button>\n * <button onClick={handleCancel}>Cancel</button>\n * </div>\n * );\n * }\n *\n * // After:\n * function ComposerActions() {\n * const aui = useAui();\n * const canSend = useAuiState((s) => s.composer.canSend);\n * const canCancel = useAuiState((s) => s.composer.canCancel);\n * const handleSend = () => {\n * if (canSend) {\n * aui.composer().send();\n * }\n * };\n * const handleCancel = () => {\n * if (canCancel) {\n * aui.composer().cancel();\n * }\n * };\n * return (\n * <div>\n * <button onClick={handleSend}>Send</button>\n * <button onClick={handleCancel}>Cancel</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useComposerRuntime(options?: {\n optional?: false | undefined;\n}): ComposerRuntime;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.composer.source\n ? (aui.composer().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"ComposerRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the current composer state.\n *\n * This hook provides reactive access to the composer's state, including text content,\n * attachments, editing status, and send/cancel capabilities.\n *\n * @param selector Optional selector function to pick specific state properties\n * @returns The selected composer state or the entire composer state if no selector provided\n *\n * @example\n * ```tsx\n * // Before:\n * function ComposerStatus() {\n * const text = useComposer((state) => state.text);\n * const canSend = useComposer((state) => state.canSend);\n * const attachmentCount = useComposer((state) => state.attachments.length);\n * return (\n * <div>\n * Text: {text.length} chars,\n * Attachments: {attachmentCount},\n * Can send: {canSend}\n * </div>\n * );\n * }\n *\n * // After:\n * function ComposerStatus() {\n * const text = useAuiState((s) => s.composer.text);\n * const canSend = useAuiState((s) => s.composer.canSend);\n * const attachmentCount = useAuiState((s) => s.composer.attachments.length);\n * return (\n * <div>\n * Text: {text.length} chars,\n * Attachments: {attachmentCount},\n * Can send: {canSend}\n * </div>\n * );\n * }\n * ```\n */\nexport const useComposer = createStateHookForRuntime(useComposerRuntime);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ComposerContext.js","names":["c","_c","useAui","useAuiState","ComposerRuntime","createStateHookForRuntime","useComposerRuntime","options","optional","$","aui","t0","composer","source","__internal_getRuntime","runtime","Error","useComposer"],"sources":["../../../src/legacy-runtime/hooks/ComposerContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type { ComposerRuntime } from \"../runtime/ComposerRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.composer()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the ComposerRuntime from the current context.\n *\n * The ComposerRuntime provides access to composer state and actions for message\n * composition, including text input, attachments, and sending functionality.\n * This hook automatically resolves to either the message's edit composer or\n * the thread's main composer depending on the context.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The ComposerRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function ComposerActions() {\n * const runtime = useComposerRuntime();\n * const handleSend = () => {\n * if (runtime.getState().canSend) {\n * runtime.send();\n * }\n * };\n * const handleCancel = () => {\n * if (runtime.getState().canCancel) {\n * runtime.cancel();\n * }\n * };\n * return (\n * <div>\n * <button onClick={handleSend}>Send</button>\n * <button onClick={handleCancel}>Cancel</button>\n * </div>\n * );\n * }\n *\n * // After:\n * function ComposerActions() {\n * const aui = useAui();\n * const canSend = useAuiState((s) => s.composer.canSend);\n * const canCancel = useAuiState((s) => s.composer.canCancel);\n * const handleSend = () => {\n * if (canSend) {\n * aui.composer().send();\n * }\n * };\n * const handleCancel = () => {\n * if (canCancel) {\n * aui.composer().cancel();\n * }\n * };\n * return (\n * <div>\n * <button onClick={handleSend}>Send</button>\n * <button onClick={handleCancel}>Cancel</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useComposerRuntime(options?: {\n optional?: false | undefined;\n}): ComposerRuntime;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.composer.source\n ? (aui.composer().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"ComposerRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the current composer state.\n *\n * This hook provides reactive access to the composer's state, including text content,\n * attachments, editing status, and send/cancel capabilities.\n *\n * @param selector Optional selector function to pick specific state properties\n * @returns The selected composer state or the entire composer state if no selector provided\n *\n * @example\n * ```tsx\n * // Before:\n * function ComposerStatus() {\n * const text = useComposer((state) => state.text);\n * const canSend = useComposer((state) => state.canSend);\n * const attachmentCount = useComposer((state) => state.attachments.length);\n * return (\n * <div>\n * Text: {text.length} chars,\n * Attachments: {attachmentCount},\n * Can send: {canSend}\n * </div>\n * );\n * }\n *\n * // After:\n * function ComposerStatus() {\n * const text = useAuiState((s) => s.composer.text);\n * const canSend = useAuiState((s) => s.composer.canSend);\n * const attachmentCount = useAuiState((s) => s.composer.attachments.length);\n * return (\n * <div>\n * Text: {text.length} chars,\n * Attachments: {attachmentCount},\n * Can send: {canSend}\n * </div>\n * );\n * }\n * ```\n */\nexport const useComposer = createStateHookForRuntime(useComposerRuntime);\n"],"mappings":";;;;;AAyEA,SAAOM,mBAAAC,SAAA;CAAA,MAAAE,IAAAR,EAAA,CAAA;CAGL,MAAAS,MAAYR,OAAO;CAAE,IAAAS;CAAA,IAAAF,EAAA,OAAAC,KAAA;EACOC,WAC1BD,IAAGE,SAASC,SACPH,IAAGE,SAAU,CAAC,CAAAE,wBAAiC,KAA/C,OADL;EAEQL,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAHV,MAAAM,UAAgBZ,YAAYQ,EAI5B;CACA,IAAI,CAACI,WAAD,CAAaR,SAAOC,UACtB,MAAM,IAAIQ,MAAM,kCAAkC;CACnD,OACMD;AAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6ChB,MAAaE,cAAcZ,0BAA0BC,kBAAkB"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime.js";
|
|
3
3
|
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
5
|
//#region src/legacy-runtime/hooks/MessageContext.ts
|
|
5
6
|
function useMessageRuntime(options) {
|
|
7
|
+
const $ = c(2);
|
|
6
8
|
const aui = useAui();
|
|
7
|
-
|
|
9
|
+
let t0;
|
|
10
|
+
if ($[0] !== aui) {
|
|
11
|
+
t0 = () => aui.message.source ? aui.message().__internal_getRuntime?.() ?? null : null;
|
|
12
|
+
$[0] = aui;
|
|
13
|
+
$[1] = t0;
|
|
14
|
+
} else t0 = $[1];
|
|
15
|
+
const runtime = useAuiState(t0);
|
|
8
16
|
if (!runtime && !options?.optional) throw new Error("MessageRuntime is not available");
|
|
9
17
|
return runtime;
|
|
10
18
|
}
|
|
@@ -47,7 +55,9 @@ function useMessageRuntime(options) {
|
|
|
47
55
|
* ```
|
|
48
56
|
*/
|
|
49
57
|
const useMessage = createStateHookForRuntime(useMessageRuntime);
|
|
50
|
-
const useEditComposerRuntime = (opt) =>
|
|
58
|
+
const useEditComposerRuntime = (opt) => {
|
|
59
|
+
return useMessageRuntime(opt)?.composer ?? null;
|
|
60
|
+
};
|
|
51
61
|
/**
|
|
52
62
|
* @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
53
63
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/MessageContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { MessageRuntime } from \"../runtime/MessageRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport type { EditComposerRuntime } from \"@assistant-ui/core\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.message()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the MessageRuntime from the current context.\n *\n * The MessageRuntime provides access to message-level state and actions,\n * including message content, status, editing capabilities, and branching.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The MessageRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function MessageActions() {\n * const runtime = useMessageRuntime();\n * const handleReload = () => {\n * runtime.reload();\n * };\n * const handleEdit = () => {\n * runtime.startEdit();\n * };\n * return (\n * <div>\n * <button onClick={handleReload}>Reload</button>\n * <button onClick={handleEdit}>Edit</button>\n * </div>\n * );\n * }\n *\n * // After:\n * function MessageActions() {\n * const aui = useAui();\n * const handleReload = () => {\n * aui.message().reload();\n * };\n * const handleEdit = () => {\n * aui.message().startEdit();\n * };\n * return (\n * <div>\n * <button onClick={handleReload}>Reload</button>\n * <button onClick={handleEdit}>Edit</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useMessageRuntime(options?: {\n optional?: false | undefined;\n}): MessageRuntime;\nexport function useMessageRuntime(options?: {\n optional?: boolean | undefined;\n}): MessageRuntime | null;\nexport function useMessageRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.message.source\n ? (aui.message().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"MessageRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the current message state.\n *\n * This hook provides reactive access to the message's state, including content,\n * role, status, and other message-level properties.\n *\n * @param selector Optional selector function to pick specific state properties\n * @returns The selected message state or the entire message state if no selector provided\n *\n * @example\n * ```tsx\n * // Before:\n * function MessageContent() {\n * const role = useMessage((state) => state.role);\n * const content = useMessage((state) => state.content);\n * const isLoading = useMessage((state) => state.status.type === \"running\");\n * return (\n * <div className={`message-${role}`}>\n * {isLoading ? \"Loading...\" : content.map(part => part.text).join(\"\")}\n * </div>\n * );\n * }\n *\n * // After:\n * function MessageContent() {\n * const role = useAuiState((s) => s.message.role);\n * const content = useAuiState((s) => s.message.content);\n * const isLoading = useAuiState((s) => s.message.status.type === \"running\");\n * return (\n * <div className={`message-${role}`}>\n * {isLoading ? \"Loading...\" : content.map(part => part.text).join(\"\")}\n * </div>\n * );\n * }\n * ```\n */\nexport const useMessage = createStateHookForRuntime(useMessageRuntime);\n\nconst useEditComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): EditComposerRuntime | null => useMessageRuntime(opt)?.composer ?? null;\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useEditComposer = createStateHookForRuntime(\n useEditComposerRuntime,\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MessageContext.js","names":["c","_c","MessageRuntime","useAui","useAuiState","createStateHookForRuntime","EditComposerRuntime","useMessageRuntime","options","optional","$","aui","t0","message","source","__internal_getRuntime","runtime","Error","useMessage","useEditComposerRuntime","opt","composer","useEditComposer"],"sources":["../../../src/legacy-runtime/hooks/MessageContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { MessageRuntime } from \"../runtime/MessageRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport type { EditComposerRuntime } from \"@assistant-ui/core\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.message()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the MessageRuntime from the current context.\n *\n * The MessageRuntime provides access to message-level state and actions,\n * including message content, status, editing capabilities, and branching.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The MessageRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function MessageActions() {\n * const runtime = useMessageRuntime();\n * const handleReload = () => {\n * runtime.reload();\n * };\n * const handleEdit = () => {\n * runtime.startEdit();\n * };\n * return (\n * <div>\n * <button onClick={handleReload}>Reload</button>\n * <button onClick={handleEdit}>Edit</button>\n * </div>\n * );\n * }\n *\n * // After:\n * function MessageActions() {\n * const aui = useAui();\n * const handleReload = () => {\n * aui.message().reload();\n * };\n * const handleEdit = () => {\n * aui.message().startEdit();\n * };\n * return (\n * <div>\n * <button onClick={handleReload}>Reload</button>\n * <button onClick={handleEdit}>Edit</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useMessageRuntime(options?: {\n optional?: false | undefined;\n}): MessageRuntime;\nexport function useMessageRuntime(options?: {\n optional?: boolean | undefined;\n}): MessageRuntime | null;\nexport function useMessageRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.message.source\n ? (aui.message().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"MessageRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the current message state.\n *\n * This hook provides reactive access to the message's state, including content,\n * role, status, and other message-level properties.\n *\n * @param selector Optional selector function to pick specific state properties\n * @returns The selected message state or the entire message state if no selector provided\n *\n * @example\n * ```tsx\n * // Before:\n * function MessageContent() {\n * const role = useMessage((state) => state.role);\n * const content = useMessage((state) => state.content);\n * const isLoading = useMessage((state) => state.status.type === \"running\");\n * return (\n * <div className={`message-${role}`}>\n * {isLoading ? \"Loading...\" : content.map(part => part.text).join(\"\")}\n * </div>\n * );\n * }\n *\n * // After:\n * function MessageContent() {\n * const role = useAuiState((s) => s.message.role);\n * const content = useAuiState((s) => s.message.content);\n * const isLoading = useAuiState((s) => s.message.status.type === \"running\");\n * return (\n * <div className={`message-${role}`}>\n * {isLoading ? \"Loading...\" : content.map(part => part.text).join(\"\")}\n * </div>\n * );\n * }\n * ```\n */\nexport const useMessage = createStateHookForRuntime(useMessageRuntime);\n\nconst useEditComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): EditComposerRuntime | null => useMessageRuntime(opt)?.composer ?? null;\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.message.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useEditComposer = createStateHookForRuntime(\n useEditComposerRuntime,\n);\n"],"mappings":";;;;;AA8DA,SAAOO,kBAAAC,SAAA;CAAA,MAAAE,IAAAT,EAAA,CAAA;CAGL,MAAAU,MAAYR,OAAO;CAAE,IAAAS;CAAA,IAAAF,EAAA,OAAAC,KAAA;EACOC,WAC1BD,IAAGE,QAAQC,SACNH,IAAGE,QAAS,CAAC,CAAAE,wBAAiC,KAA9C,OADL;EAEQL,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAHV,MAAAM,UAAgBZ,YAAYQ,EAI5B;CACA,IAAI,CAACI,WAAD,CAAaR,SAAOC,UACtB,MAAM,IAAIQ,MAAM,iCAAiC;CAClD,OACMD;AAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyChB,MAAaE,aAAab,0BAA0BE,iBAAiB;AAErE,MAAMY,0BAAyBC,QAAA;CAAA,OAEGb,kBAAkBa,GAAa,CAAC,EAAAC,YAAhC;AAAwC;;;;AAK1E,MAAaC,kBAAkBjB,0BAC7Bc,sBACF"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime.js";
|
|
3
3
|
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
5
|
//#region src/legacy-runtime/hooks/MessagePartContext.ts
|
|
5
6
|
function useMessagePartRuntime(options) {
|
|
7
|
+
const $ = c(2);
|
|
6
8
|
const aui = useAui();
|
|
7
|
-
|
|
9
|
+
let t0;
|
|
10
|
+
if ($[0] !== aui) {
|
|
11
|
+
t0 = () => aui.part.source ? aui.part().__internal_getRuntime?.() ?? null : null;
|
|
12
|
+
$[0] = aui;
|
|
13
|
+
$[1] = t0;
|
|
14
|
+
} else t0 = $[1];
|
|
15
|
+
const runtime = useAuiState(t0);
|
|
8
16
|
if (!runtime && !options?.optional) throw new Error("MessagePartRuntime is not available");
|
|
9
17
|
return runtime;
|
|
10
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessagePartContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/MessagePartContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { MessagePartRuntime } from \"../runtime/MessagePartRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.part()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useMessagePartRuntime(options?: {\n optional?: false | undefined;\n}): MessagePartRuntime;\nexport function useMessagePartRuntime(options?: {\n optional?: boolean | undefined;\n}): MessagePartRuntime | null;\nexport function useMessagePartRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.part.source ? (aui.part().__internal_getRuntime?.() ?? null) : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"MessagePartRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.part)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useMessagePart = createStateHookForRuntime(useMessagePartRuntime);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MessagePartContext.js","names":["c","_c","MessagePartRuntime","createStateHookForRuntime","useAui","useAuiState","useMessagePartRuntime","options","optional","$","aui","t0","part","source","__internal_getRuntime","runtime","Error","useMessagePart"],"sources":["../../../src/legacy-runtime/hooks/MessagePartContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { MessagePartRuntime } from \"../runtime/MessagePartRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.part()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useMessagePartRuntime(options?: {\n optional?: false | undefined;\n}): MessagePartRuntime;\nexport function useMessagePartRuntime(options?: {\n optional?: boolean | undefined;\n}): MessagePartRuntime | null;\nexport function useMessagePartRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.part.source ? (aui.part().__internal_getRuntime?.() ?? null) : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"MessagePartRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.part)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useMessagePart = createStateHookForRuntime(useMessagePartRuntime);\n"],"mappings":";;;;;AAeA,SAAOM,sBAAAC,SAAA;CAAA,MAAAE,IAAAR,EAAA,CAAA;CAGL,MAAAS,MAAYN,OAAO;CAAE,IAAAO;CAAA,IAAAF,EAAA,OAAAC,KAAA;EACOC,WAC1BD,IAAGE,KAAKC,SAAWH,IAAGE,KAAM,CAAC,CAAAE,wBAAiC,KAA3C,OAAnB;EAAuEL,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CADzE,MAAAM,UAAgBV,YAAYM,EAE5B;CACA,IAAI,CAACI,WAAD,CAAaR,SAAOC,UACtB,MAAM,IAAIQ,MAAM,qCAAqC;CACtD,OACMD;AAAO;;;;AAMhB,MAAaE,iBAAiBd,0BAA0BG,qBAAqB"}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime.js";
|
|
3
3
|
import { useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
5
|
import { useState } from "@assistant-ui/tap/react-shim";
|
|
5
6
|
//#region src/legacy-runtime/hooks/ThreadContext.ts
|
|
6
7
|
function useThreadRuntime(options) {
|
|
8
|
+
const $ = c(2);
|
|
7
9
|
const aui = useAui();
|
|
8
|
-
|
|
10
|
+
let t0;
|
|
11
|
+
if ($[0] !== aui) {
|
|
12
|
+
t0 = () => aui.thread.source ? aui.thread().__internal_getRuntime?.() ?? null : null;
|
|
13
|
+
$[0] = aui;
|
|
14
|
+
$[1] = t0;
|
|
15
|
+
} else t0 = $[1];
|
|
16
|
+
const runtime = useAuiState(t0);
|
|
9
17
|
if (!runtime && !options?.optional) throw new Error("ThreadRuntime is not available");
|
|
10
18
|
return runtime;
|
|
11
19
|
}
|
|
@@ -38,17 +46,37 @@ function useThreadRuntime(options) {
|
|
|
38
46
|
* ```
|
|
39
47
|
*/
|
|
40
48
|
const useThread = createStateHookForRuntime(useThreadRuntime);
|
|
41
|
-
const useThreadComposerRuntime = (opt) =>
|
|
49
|
+
const useThreadComposerRuntime = (opt) => {
|
|
50
|
+
return useThreadRuntime(opt)?.composer ?? null;
|
|
51
|
+
};
|
|
42
52
|
/**
|
|
43
53
|
* @deprecated Use {@link useAuiState}: `useAuiState((s) => s.thread.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
44
54
|
*/
|
|
45
55
|
const useThreadComposer = createStateHookForRuntime(useThreadComposerRuntime);
|
|
46
56
|
function useThreadModelContext(options) {
|
|
47
|
-
const
|
|
57
|
+
const $ = c(5);
|
|
58
|
+
let t0;
|
|
59
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
60
|
+
t0 = {};
|
|
61
|
+
$[0] = t0;
|
|
62
|
+
} else t0 = $[0];
|
|
63
|
+
const [, rerender] = useState(t0);
|
|
48
64
|
const runtime = useThreadRuntime(options);
|
|
49
|
-
|
|
65
|
+
let t1;
|
|
66
|
+
if ($[1] !== rerender) {
|
|
67
|
+
t1 = () => rerender({});
|
|
68
|
+
$[1] = rerender;
|
|
69
|
+
$[2] = t1;
|
|
70
|
+
} else t1 = $[2];
|
|
71
|
+
useAuiEvent("thread.modelContextUpdate", t1);
|
|
50
72
|
if (!runtime) return null;
|
|
51
|
-
|
|
73
|
+
let t2;
|
|
74
|
+
if ($[3] !== runtime) {
|
|
75
|
+
t2 = runtime?.getModelContext();
|
|
76
|
+
$[3] = runtime;
|
|
77
|
+
$[4] = t2;
|
|
78
|
+
} else t2 = $[4];
|
|
79
|
+
return t2;
|
|
52
80
|
}
|
|
53
81
|
//#endregion
|
|
54
82
|
export { useThread, useThreadComposer, useThreadModelContext, useThreadRuntime };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/ThreadContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport type { ThreadRuntime } from \"../runtime/ThreadRuntime\";\nimport type { ModelContext } from \"@assistant-ui/core\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport type { ThreadComposerRuntime } from \"@assistant-ui/core\";\nimport { useAui, useAuiEvent, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.thread()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the ThreadRuntime from the current context.\n *\n * The ThreadRuntime provides access to thread-level state and actions,\n * including message management, thread state, and composer functionality.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The ThreadRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function MyComponent() {\n * const runtime = useThreadRuntime();\n * const handleSendMessage = (text: string) => {\n * runtime.append({ role: \"user\", content: [{ type: \"text\", text }] });\n * };\n * return <button onClick={() => handleSendMessage(\"Hello!\")}>Send</button>;\n * }\n *\n * // After:\n * function MyComponent() {\n * const aui = useAui();\n * const handleSendMessage = (text: string) => {\n * aui.thread().append({ role: \"user\", content: [{ type: \"text\", text }] });\n * };\n * return <button onClick={() => handleSendMessage(\"Hello!\")}>Send</button>;\n * }\n * ```\n */\nexport function useThreadRuntime(options?: {\n optional?: false | undefined;\n}): ThreadRuntime;\nexport function useThreadRuntime(options?: {\n optional?: boolean | undefined;\n}): ThreadRuntime | null;\nexport function useThreadRuntime(options?: { optional?: boolean | undefined }) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.thread.source ? (aui.thread().__internal_getRuntime?.() ?? null) : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"ThreadRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.thread)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the current thread state.\n *\n * This hook provides reactive access to the thread's state, including messages,\n * running status, capabilities, and other thread-level properties.\n *\n * @param selector Optional selector function to pick specific state properties\n * @returns The selected thread state or the entire thread state if no selector provided\n *\n * @example\n * ```tsx\n * // Before:\n * function ThreadStatus() {\n * const isRunning = useThread((state) => state.isRunning);\n * const messageCount = useThread((state) => state.messages.length);\n * return <div>Running: {isRunning}, Messages: {messageCount}</div>;\n * }\n *\n * // After:\n * function ThreadStatus() {\n * const isRunning = useAuiState((s) => s.thread.isRunning);\n * const messageCount = useAuiState((s) => s.thread.messages.length);\n * return <div>Running: {isRunning}, Messages: {messageCount}</div>;\n * }\n * ```\n */\nexport const useThread = createStateHookForRuntime(useThreadRuntime);\n\nconst useThreadComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadComposerRuntime | null => useThreadRuntime(opt)?.composer ?? null;\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.thread.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useThreadComposer = createStateHookForRuntime(\n useThreadComposerRuntime,\n);\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.thread.modelContext)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useThreadModelContext(options?: {\n optional?: false | undefined;\n}): ModelContext;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null {\n const [, rerender] = useState({});\n\n const runtime = useThreadRuntime(options);\n useAuiEvent(\"thread.modelContextUpdate\", () => rerender({}));\n\n if (!runtime) return null;\n return runtime?.getModelContext();\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ThreadContext.js","names":["c","_c","useState","ThreadRuntime","ModelContext","createStateHookForRuntime","ThreadComposerRuntime","useAui","useAuiEvent","useAuiState","useThreadRuntime","options","optional","$","aui","t0","thread","source","__internal_getRuntime","runtime","Error","useThread","useThreadComposerRuntime","opt","composer","useThreadComposer","useThreadModelContext","Symbol","for","rerender","t1","t2","getModelContext"],"sources":["../../../src/legacy-runtime/hooks/ThreadContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport type { ThreadRuntime } from \"../runtime/ThreadRuntime\";\nimport type { ModelContext } from \"@assistant-ui/core\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport type { ThreadComposerRuntime } from \"@assistant-ui/core\";\nimport { useAui, useAuiEvent, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.thread()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the ThreadRuntime from the current context.\n *\n * The ThreadRuntime provides access to thread-level state and actions,\n * including message management, thread state, and composer functionality.\n *\n * @param options Configuration options\n * @param options.optional Whether the hook should return null if no context is found\n * @returns The ThreadRuntime instance, or null if optional is true and no context exists\n *\n * @example\n * ```tsx\n * // Before:\n * function MyComponent() {\n * const runtime = useThreadRuntime();\n * const handleSendMessage = (text: string) => {\n * runtime.append({ role: \"user\", content: [{ type: \"text\", text }] });\n * };\n * return <button onClick={() => handleSendMessage(\"Hello!\")}>Send</button>;\n * }\n *\n * // After:\n * function MyComponent() {\n * const aui = useAui();\n * const handleSendMessage = (text: string) => {\n * aui.thread().append({ role: \"user\", content: [{ type: \"text\", text }] });\n * };\n * return <button onClick={() => handleSendMessage(\"Hello!\")}>Send</button>;\n * }\n * ```\n */\nexport function useThreadRuntime(options?: {\n optional?: false | undefined;\n}): ThreadRuntime;\nexport function useThreadRuntime(options?: {\n optional?: boolean | undefined;\n}): ThreadRuntime | null;\nexport function useThreadRuntime(options?: { optional?: boolean | undefined }) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.thread.source ? (aui.thread().__internal_getRuntime?.() ?? null) : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"ThreadRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.thread)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n *\n * Hook to access the current thread state.\n *\n * This hook provides reactive access to the thread's state, including messages,\n * running status, capabilities, and other thread-level properties.\n *\n * @param selector Optional selector function to pick specific state properties\n * @returns The selected thread state or the entire thread state if no selector provided\n *\n * @example\n * ```tsx\n * // Before:\n * function ThreadStatus() {\n * const isRunning = useThread((state) => state.isRunning);\n * const messageCount = useThread((state) => state.messages.length);\n * return <div>Running: {isRunning}, Messages: {messageCount}</div>;\n * }\n *\n * // After:\n * function ThreadStatus() {\n * const isRunning = useAuiState((s) => s.thread.isRunning);\n * const messageCount = useAuiState((s) => s.thread.messages.length);\n * return <div>Running: {isRunning}, Messages: {messageCount}</div>;\n * }\n * ```\n */\nexport const useThread = createStateHookForRuntime(useThreadRuntime);\n\nconst useThreadComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadComposerRuntime | null => useThreadRuntime(opt)?.composer ?? null;\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.thread.composer)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useThreadComposer = createStateHookForRuntime(\n useThreadComposerRuntime,\n);\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.thread.modelContext)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useThreadModelContext(options?: {\n optional?: false | undefined;\n}): ModelContext;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null;\nexport function useThreadModelContext(options?: {\n optional?: boolean | undefined;\n}): ModelContext | null {\n const [, rerender] = useState({});\n\n const runtime = useThreadRuntime(options);\n useAuiEvent(\"thread.modelContextUpdate\", () => rerender({}));\n\n if (!runtime) return null;\n return runtime?.getModelContext();\n}\n"],"mappings":";;;;;;AAgDA,SAAOU,iBAAAC,SAAA;CAAA,MAAAE,IAAAZ,EAAA,CAAA;CACL,MAAAa,MAAYP,OAAO;CAAE,IAAAQ;CAAA,IAAAF,EAAA,OAAAC,KAAA;EACOC,WAC1BD,IAAGE,OAAOC,SAAWH,IAAGE,OAAQ,CAAC,CAAAE,wBAAiC,KAA7C,OAArB;EAA2EL,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAD7E,MAAAM,UAAgBV,YAAYM,EAE5B;CACA,IAAI,CAACI,WAAD,CAAaR,SAAOC,UACtB,MAAM,IAAIQ,MAAM,gCAAgC;CACjD,OACMD;AAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BhB,MAAaE,YAAYhB,0BAA0BK,gBAAgB;AAEnE,MAAMY,4BAA2BC,QAAA;CAAA,OAEGb,iBAAiBa,GAAa,CAAC,EAAAC,YAA/B;AAAuC;;;;AAK3E,MAAaC,oBAAoBpB,0BAC/BiB,wBACF;AAWA,SAAOI,sBAAAf,SAAA;CAAA,MAAAE,IAAAZ,EAAA,CAAA;CAAA,IAAAc;CAAA,IAAAF,EAAA,OAAAc,OAAAC,IAAA,2BAAA,GAAA;EAGyBb,KAAA,CAAC;EAACF,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAhC,MAAA,GAAAgB,YAAqB3B,SAASa,EAAE;CAEhC,MAAAI,UAAgBT,iBAAiBC,OAAO;CAAE,IAAAmB;CAAA,IAAAjB,EAAA,OAAAgB,UAAA;EACDC,WAAMD,SAAS,CAAC,CAAC;EAAChB,EAAA,KAAAgB;EAAAhB,EAAA,KAAAiB;CAAA,OAAAA,KAAAjB,EAAA;CAA3DL,YAAY,6BAA6BsB,EAAkB;CAE3D,IAAI,CAACX,SAAO,OAAS;CAAK,IAAAY;CAAA,IAAAlB,EAAA,OAAAM,SAAA;EACnBY,KAAAZ,SAAOa,gBAAkB;EAACnB,EAAA,KAAAM;EAAAN,EAAA,KAAAkB;CAAA,OAAAA,KAAAlB,EAAA;CAAA,OAA1BkB;AAA0B"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime.js";
|
|
3
3
|
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
5
|
//#region src/legacy-runtime/hooks/ThreadListItemContext.ts
|
|
5
6
|
function useThreadListItemRuntime(options) {
|
|
7
|
+
const $ = c(2);
|
|
6
8
|
const aui = useAui();
|
|
7
|
-
|
|
9
|
+
let t0;
|
|
10
|
+
if ($[0] !== aui) {
|
|
11
|
+
t0 = () => aui.threadListItem.source ? aui.threadListItem().__internal_getRuntime?.() ?? null : null;
|
|
12
|
+
$[0] = aui;
|
|
13
|
+
$[1] = t0;
|
|
14
|
+
} else t0 = $[1];
|
|
15
|
+
const runtime = useAuiState(t0);
|
|
8
16
|
if (!runtime && !options?.optional) throw new Error("ThreadListItemRuntime is not available");
|
|
9
17
|
return runtime;
|
|
10
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadListItemContext.js","names":[],"sources":["../../../src/legacy-runtime/hooks/ThreadListItemContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { ThreadListItemRuntime } from \"../runtime/ThreadListItemRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.threadListItem()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useThreadListItemRuntime(options?: {\n optional?: false | undefined;\n}): ThreadListItemRuntime;\nexport function useThreadListItemRuntime(options?: {\n optional?: boolean | undefined;\n}): ThreadListItemRuntime | null;\nexport function useThreadListItemRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.threadListItem.source\n ? (aui.threadListItem().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"ThreadListItemRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.threadListItem)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useThreadListItem = createStateHookForRuntime(\n useThreadListItemRuntime,\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ThreadListItemContext.js","names":["c","_c","ThreadListItemRuntime","createStateHookForRuntime","useAui","useAuiState","useThreadListItemRuntime","options","optional","$","aui","t0","threadListItem","source","__internal_getRuntime","runtime","Error","useThreadListItem"],"sources":["../../../src/legacy-runtime/hooks/ThreadListItemContext.ts"],"sourcesContent":["\"use client\";\n\nimport type { ThreadListItemRuntime } from \"../runtime/ThreadListItemRuntime\";\nimport { createStateHookForRuntime } from \"../../context/react/utils/createStateHookForRuntime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\n/**\n * @deprecated Use {@link useAui} with `aui.threadListItem()` instead. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport function useThreadListItemRuntime(options?: {\n optional?: false | undefined;\n}): ThreadListItemRuntime;\nexport function useThreadListItemRuntime(options?: {\n optional?: boolean | undefined;\n}): ThreadListItemRuntime | null;\nexport function useThreadListItemRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const aui = useAui();\n const runtime = useAuiState(() =>\n aui.threadListItem.source\n ? (aui.threadListItem().__internal_getRuntime?.() ?? null)\n : null,\n );\n if (!runtime && !options?.optional) {\n throw new Error(\"ThreadListItemRuntime is not available\");\n }\n return runtime;\n}\n\n/**\n * @deprecated Use {@link useAuiState}: `useAuiState((s) => s.threadListItem)`. See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useThreadListItem = createStateHookForRuntime(\n useThreadListItemRuntime,\n);\n"],"mappings":";;;;;AAeA,SAAOM,yBAAAC,SAAA;CAAA,MAAAE,IAAAR,EAAA,CAAA;CAGL,MAAAS,MAAYN,OAAO;CAAE,IAAAO;CAAA,IAAAF,EAAA,OAAAC,KAAA;EACOC,WAC1BD,IAAGE,eAAeC,SACbH,IAAGE,eAAgB,CAAC,CAAAE,wBAAiC,KAArD,OADL;EAEQL,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAHV,MAAAM,UAAgBV,YAAYM,EAI5B;CACA,IAAI,CAACI,WAAD,CAAaR,SAAOC,UACtB,MAAM,IAAIQ,MAAM,wCAAwC;CACzD,OACMD;AAAO;;;;AAMhB,MAAaE,oBAAoBd,0BAC/BG,wBACF"}
|
|
@@ -26,7 +26,7 @@ const useCommandQueue = (opts) => {
|
|
|
26
26
|
queued: [],
|
|
27
27
|
inTransit: [...queueStateRef.current.inTransit, ...queued]
|
|
28
28
|
};
|
|
29
|
-
rerender((
|
|
29
|
+
rerender((prev_0) => prev_0 + 1);
|
|
30
30
|
return queued;
|
|
31
31
|
};
|
|
32
32
|
const markDelivered = () => {
|
|
@@ -34,11 +34,11 @@ const useCommandQueue = (opts) => {
|
|
|
34
34
|
...queueStateRef.current,
|
|
35
35
|
inTransit: []
|
|
36
36
|
};
|
|
37
|
-
rerender((
|
|
37
|
+
rerender((prev_1) => prev_1 + 1);
|
|
38
38
|
};
|
|
39
39
|
const reset = useCallback(() => {
|
|
40
40
|
queueStateRef.current = createInitialQueueState();
|
|
41
|
-
rerender((
|
|
41
|
+
rerender((prev_2) => prev_2 + 1);
|
|
42
42
|
}, []);
|
|
43
43
|
return {
|
|
44
44
|
state: queueStateRef.current,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandQueue.js","names":[],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/commandQueue.ts"],"sourcesContent":["import { useState, useCallback, useRef, useEffect } from \"react\";\nimport type {\n AssistantTransportCommand,\n CommandQueueState,\n QueuedCommand,\n} from \"./types\";\n\nexport const createInitialQueueState = (): CommandQueueState => ({\n queued: [],\n inTransit: [],\n});\n\nexport const useCommandQueue = (opts: { onQueue: () => void }) => {\n const onQueueRef = useRef(opts.onQueue);\n useEffect(() => {\n onQueueRef.current = opts.onQueue;\n });\n\n const [, rerender] = useState(0);\n const queueStateRef = useRef<CommandQueueState>(createInitialQueueState());\n\n const enqueue = (command: AssistantTransportCommand) => {\n queueStateRef.current = {\n queued: [...queueStateRef.current.queued, command],\n inTransit: queueStateRef.current.inTransit,\n };\n rerender((prev) => prev + 1);\n\n onQueueRef.current();\n };\n\n const flush = (): QueuedCommand[] => {\n if (queueStateRef.current.queued.length === 0) return [];\n\n const queued = queueStateRef.current.queued;\n queueStateRef.current = {\n queued: [],\n inTransit: [...queueStateRef.current.inTransit, ...queued],\n };\n rerender((prev) => prev + 1);\n\n return queued;\n };\n\n const markDelivered = () => {\n queueStateRef.current = { ...queueStateRef.current, inTransit: [] };\n rerender((prev) => prev + 1);\n };\n\n const reset = useCallback(() => {\n queueStateRef.current = createInitialQueueState();\n rerender((prev) => prev + 1);\n }, []);\n\n return {\n state: queueStateRef.current,\n enqueue,\n flush,\n markDelivered,\n reset,\n };\n};\n"],"mappings":";;AAOA,
|
|
1
|
+
{"version":3,"file":"commandQueue.js","names":["useState","useCallback","useRef","useEffect","AssistantTransportCommand","CommandQueueState","QueuedCommand","createInitialQueueState","queued","inTransit","useCommandQueue","opts","onQueue","onQueueRef","current","rerender","queueStateRef","enqueue","command","prev","flush","length","markDelivered","reset","state"],"sources":["../../../../src/legacy-runtime/runtime-cores/assistant-transport/commandQueue.ts"],"sourcesContent":["import { useState, useCallback, useRef, useEffect } from \"react\";\nimport type {\n AssistantTransportCommand,\n CommandQueueState,\n QueuedCommand,\n} from \"./types\";\n\nexport const createInitialQueueState = (): CommandQueueState => ({\n queued: [],\n inTransit: [],\n});\n\nexport const useCommandQueue = (opts: { onQueue: () => void }) => {\n const onQueueRef = useRef(opts.onQueue);\n useEffect(() => {\n onQueueRef.current = opts.onQueue;\n });\n\n const [, rerender] = useState(0);\n const queueStateRef = useRef<CommandQueueState>(createInitialQueueState());\n\n const enqueue = (command: AssistantTransportCommand) => {\n queueStateRef.current = {\n queued: [...queueStateRef.current.queued, command],\n inTransit: queueStateRef.current.inTransit,\n };\n rerender((prev) => prev + 1);\n\n onQueueRef.current();\n };\n\n const flush = (): QueuedCommand[] => {\n if (queueStateRef.current.queued.length === 0) return [];\n\n const queued = queueStateRef.current.queued;\n queueStateRef.current = {\n queued: [],\n inTransit: [...queueStateRef.current.inTransit, ...queued],\n };\n rerender((prev) => prev + 1);\n\n return queued;\n };\n\n const markDelivered = () => {\n queueStateRef.current = { ...queueStateRef.current, inTransit: [] };\n rerender((prev) => prev + 1);\n };\n\n const reset = useCallback(() => {\n queueStateRef.current = createInitialQueueState();\n rerender((prev) => prev + 1);\n }, []);\n\n return {\n state: queueStateRef.current,\n enqueue,\n flush,\n markDelivered,\n reset,\n };\n};\n"],"mappings":";;AAOA,MAAaO,iCAAoD;CAC/DC,QAAQ,CAAA;CACRC,WAAW,CAAA;AACb;AAEA,MAAaC,mBAAmBC,SAAkC;CAChE,MAAME,aAAaX,OAAOS,KAAKC,OAAO;CACtCT,gBAAgB;EACdU,WAAWC,UAAUH,KAAKC;CAC5B,CAAC;CAED,MAAM,GAAGG,YAAYf,SAAS,CAAC;CAC/B,MAAMgB,gBAAgBd,OAA0BK,wBAAwB,CAAC;CAEzE,MAAMU,WAAWC,YAAuC;EACtDF,cAAcF,UAAU;GACtBN,QAAQ,CAAC,GAAGQ,cAAcF,QAAQN,QAAQU,OAAO;GACjDT,WAAWO,cAAcF,QAAQL;EACnC;EACAM,UAAUI,SAASA,OAAO,CAAC;EAE3BN,WAAWC,QAAQ;CACrB;CAEA,MAAMM,cAA+B;EACnC,IAAIJ,cAAcF,QAAQN,OAAOa,WAAW,GAAG,OAAO,CAAA;EAEtD,MAAMb,SAASQ,cAAcF,QAAQN;EACrCQ,cAAcF,UAAU;GACtBN,QAAQ,CAAA;GACRC,WAAW,CAAC,GAAGO,cAAcF,QAAQL,WAAW,GAAGD,MAAM;EAC3D;EACAO,UAAUI,WAASA,SAAO,CAAC;EAE3B,OAAOX;CACT;CAEA,MAAMc,sBAAsB;EAC1BN,cAAcF,UAAU;GAAE,GAAGE,cAAcF;GAASL,WAAW,CAAA;EAAG;EAClEM,UAAUI,WAASA,SAAO,CAAC;CAC7B;CAEA,MAAMI,QAAQtB,kBAAkB;EAC9Be,cAAcF,UAAUP,wBAAwB;EAChDQ,UAAUI,WAASA,SAAO,CAAC;CAC7B,GAAG,CAAA,CAAE;CAEL,OAAO;EACLK,OAAOR,cAAcF;EACrBG;EACAG;EACAE;EACAC;CACF;AACF"}
|
|
@@ -1,41 +1,81 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "@assistant-ui/tap/react-shim";
|
|
3
4
|
//#region src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.ts
|
|
4
5
|
const REPLAY_CONTENT_LENGTH_HEADER = "Aui-Replay-Content-Length";
|
|
5
6
|
const useReplayRenderWait = () => {
|
|
7
|
+
const $ = c(8);
|
|
6
8
|
const [renderTicket, setRenderTicket] = useState(0);
|
|
7
9
|
const mountedRef = useRef(true);
|
|
8
10
|
const nextTicketRef = useRef(0);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
11
|
+
let t0;
|
|
12
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
13
|
+
t0 = [];
|
|
14
|
+
$[0] = t0;
|
|
15
|
+
} else t0 = $[0];
|
|
16
|
+
const waitersRef = useRef(t0);
|
|
17
|
+
let t1;
|
|
18
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
19
|
+
t1 = (committedTicket) => {
|
|
20
|
+
const pendingWaiters = [];
|
|
21
|
+
for (const waiter of waitersRef.current) if (committedTicket === void 0 || waiter.ticket <= committedTicket) waiter.resolve();
|
|
22
|
+
else pendingWaiters.push(waiter);
|
|
23
|
+
waitersRef.current = pendingWaiters;
|
|
24
|
+
};
|
|
25
|
+
$[1] = t1;
|
|
26
|
+
} else t1 = $[1];
|
|
27
|
+
const resolveWaiters = t1;
|
|
28
|
+
let t2;
|
|
29
|
+
let t3;
|
|
30
|
+
if ($[2] !== renderTicket) {
|
|
31
|
+
t2 = () => {
|
|
32
|
+
mountedRef.current = true;
|
|
33
|
+
resolveWaiters(renderTicket);
|
|
34
|
+
};
|
|
35
|
+
t3 = [renderTicket, resolveWaiters];
|
|
36
|
+
$[2] = renderTicket;
|
|
37
|
+
$[3] = t2;
|
|
38
|
+
$[4] = t3;
|
|
39
|
+
} else {
|
|
40
|
+
t2 = $[3];
|
|
41
|
+
t3 = $[4];
|
|
42
|
+
}
|
|
43
|
+
useEffect(t2, t3);
|
|
44
|
+
let t4;
|
|
45
|
+
let t5;
|
|
46
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
47
|
+
t4 = () => () => {
|
|
48
|
+
mountedRef.current = false;
|
|
49
|
+
resolveWaiters();
|
|
50
|
+
};
|
|
51
|
+
t5 = [resolveWaiters];
|
|
52
|
+
$[5] = t4;
|
|
53
|
+
$[6] = t5;
|
|
54
|
+
} else {
|
|
55
|
+
t4 = $[5];
|
|
56
|
+
t5 = $[6];
|
|
57
|
+
}
|
|
58
|
+
useEffect(t4, t5);
|
|
59
|
+
let t6;
|
|
60
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
61
|
+
t6 = () => new Promise((resolve) => {
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
if (!mountedRef.current) {
|
|
64
|
+
resolve();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const ticket = nextTicketRef.current + 1;
|
|
68
|
+
nextTicketRef.current = ticket;
|
|
69
|
+
waitersRef.current.push({
|
|
70
|
+
ticket,
|
|
71
|
+
resolve
|
|
72
|
+
});
|
|
73
|
+
setRenderTicket(ticket);
|
|
74
|
+
}, 0);
|
|
75
|
+
});
|
|
76
|
+
$[7] = t6;
|
|
77
|
+
} else t6 = $[7];
|
|
78
|
+
return t6;
|
|
39
79
|
};
|
|
40
80
|
const parseReplayContentLength = (headers) => {
|
|
41
81
|
const raw = headers.get(REPLAY_CONTENT_LENGTH_HEADER);
|