@assistant-ui/react 0.10.1 → 0.10.3
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/api/AssistantRuntime.js +5 -4
- package/dist/api/AssistantRuntime.js.map +1 -1
- package/dist/api/AttachmentRuntime.js +11 -10
- package/dist/api/AttachmentRuntime.js.map +1 -1
- package/dist/api/ComposerRuntime.js +16 -15
- package/dist/api/ComposerRuntime.js.map +1 -1
- package/dist/api/ContentPartRuntime.js +3 -2
- package/dist/api/ContentPartRuntime.js.map +1 -1
- package/dist/api/MessageRuntime.js +14 -13
- package/dist/api/MessageRuntime.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.js +3 -2
- package/dist/api/ThreadListItemRuntime.js.map +1 -1
- package/dist/api/ThreadListRuntime.js +11 -10
- package/dist/api/ThreadListRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.js +14 -13
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/subscribable/BaseSubject.js +3 -2
- package/dist/api/subscribable/BaseSubject.js.map +1 -1
- package/dist/api/subscribable/EventSubscriptionSubject.js +4 -3
- package/dist/api/subscribable/EventSubscriptionSubject.js.map +1 -1
- package/dist/api/subscribable/LazyMemoizeSubject.js +5 -4
- package/dist/api/subscribable/LazyMemoizeSubject.js.map +1 -1
- package/dist/api/subscribable/NestedSubscriptionSubject.js +4 -3
- package/dist/api/subscribable/NestedSubscriptionSubject.js.map +1 -1
- package/dist/api/subscribable/SKIP_UPDATE.js +2 -1
- package/dist/api/subscribable/SKIP_UPDATE.js.map +1 -1
- package/dist/api/subscribable/ShallowMemoizeSubject.js +6 -5
- package/dist/api/subscribable/ShallowMemoizeSubject.js.map +1 -1
- package/dist/api/subscribable/shallowEqual.js +1 -0
- package/dist/api/subscribable/shallowEqual.js.map +1 -1
- package/dist/cloud/AssistantCloud.js +7 -6
- package/dist/cloud/AssistantCloud.js.map +1 -1
- package/dist/cloud/AssistantCloudAPI.js +6 -5
- package/dist/cloud/AssistantCloudAPI.js.map +1 -1
- package/dist/cloud/AssistantCloudAuthStrategy.js +9 -8
- package/dist/cloud/AssistantCloudAuthStrategy.js.map +1 -1
- package/dist/cloud/AssistantCloudAuthTokens.js +3 -2
- package/dist/cloud/AssistantCloudAuthTokens.js.map +1 -1
- package/dist/cloud/AssistantCloudRuns.js +3 -2
- package/dist/cloud/AssistantCloudRuns.js.map +1 -1
- package/dist/cloud/AssistantCloudThreadHistoryAdapter.js +6 -5
- package/dist/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/cloud/AssistantCloudThreadMessages.js +3 -2
- package/dist/cloud/AssistantCloudThreadMessages.js.map +1 -1
- package/dist/cloud/AssistantCloudThreads.js +4 -3
- package/dist/cloud/AssistantCloudThreads.js.map +1 -1
- package/dist/cloud/auiV0.js +5 -4
- package/dist/cloud/auiV0.js.map +1 -1
- package/dist/cloud/index.js +3 -2
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/useCloudThreadListRuntime.js +5 -3
- package/dist/cloud/useCloudThreadListRuntime.js.map +1 -1
- package/dist/context/ReadonlyStore.js +2 -1
- package/dist/context/ReadonlyStore.js.map +1 -1
- package/dist/context/index.js +4 -3
- package/dist/context/index.js.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.js +13 -11
- package/dist/context/providers/AssistantRuntimeProvider.js.map +1 -1
- package/dist/context/providers/AttachmentRuntimeProvider.js +8 -6
- package/dist/context/providers/AttachmentRuntimeProvider.js.map +1 -1
- package/dist/context/providers/ContentPartRuntimeProvider.js +8 -6
- package/dist/context/providers/ContentPartRuntimeProvider.js.map +1 -1
- package/dist/context/providers/MessageRuntimeProvider.js +10 -8
- package/dist/context/providers/MessageRuntimeProvider.js.map +1 -1
- package/dist/context/providers/TextContentPartProvider.js +10 -8
- package/dist/context/providers/TextContentPartProvider.js.map +1 -1
- package/dist/context/providers/ThreadListItemRuntimeProvider.js +8 -6
- package/dist/context/providers/ThreadListItemRuntimeProvider.js.map +1 -1
- package/dist/context/providers/ThreadRuntimeProvider.js +10 -8
- package/dist/context/providers/ThreadRuntimeProvider.js.map +1 -1
- package/dist/context/providers/ThreadViewportProvider.js +8 -6
- package/dist/context/providers/ThreadViewportProvider.js.map +1 -1
- package/dist/context/providers/index.js +3 -2
- package/dist/context/providers/index.js.map +1 -1
- package/dist/context/react/AssistantContext.js +10 -8
- package/dist/context/react/AssistantContext.js.map +1 -1
- package/dist/context/react/AttachmentContext.js +10 -8
- package/dist/context/react/AttachmentContext.js.map +1 -1
- package/dist/context/react/ComposerContext.js +6 -4
- package/dist/context/react/ComposerContext.js.map +1 -1
- package/dist/context/react/ContentPartContext.js +7 -5
- package/dist/context/react/ContentPartContext.js.map +1 -1
- package/dist/context/react/MessageContext.js +11 -9
- package/dist/context/react/MessageContext.js.map +1 -1
- package/dist/context/react/ThreadContext.js +9 -7
- package/dist/context/react/ThreadContext.js.map +1 -1
- package/dist/context/react/ThreadListItemContext.js +7 -5
- package/dist/context/react/ThreadListItemContext.js.map +1 -1
- package/dist/context/react/ThreadViewportContext.js +7 -5
- package/dist/context/react/ThreadViewportContext.js.map +1 -1
- package/dist/context/react/index.js +11 -9
- package/dist/context/react/index.js.map +1 -1
- package/dist/context/react/utils/createContextHook.js +2 -0
- package/dist/context/react/utils/createContextHook.js.map +1 -1
- package/dist/context/react/utils/createContextStoreHook.js +1 -0
- package/dist/context/react/utils/createContextStoreHook.js.map +1 -1
- package/dist/context/react/utils/createStateHookForRuntime.js +2 -1
- package/dist/context/react/utils/createStateHookForRuntime.js.map +1 -1
- package/dist/context/react/utils/ensureBinding.js +2 -21
- package/dist/context/react/utils/ensureBinding.js.map +1 -1
- package/dist/context/react/utils/useRuntimeState.js +3 -2
- package/dist/context/react/utils/useRuntimeState.js.map +1 -1
- package/dist/context/stores/AssistantToolUIs.js +2 -1
- package/dist/context/stores/AssistantToolUIs.js.map +1 -1
- package/dist/context/stores/MessageUtils.js +2 -1
- package/dist/context/stores/MessageUtils.js.map +1 -1
- package/dist/context/stores/ThreadViewport.js +3 -1
- package/dist/context/stores/ThreadViewport.js.map +1 -1
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/internal.js +12 -11
- package/dist/internal.js.map +1 -1
- package/dist/model-context/ModelContextTypes.js +2 -1
- package/dist/model-context/ModelContextTypes.js.map +1 -1
- package/dist/model-context/index.js +10 -9
- package/dist/model-context/index.js.map +1 -1
- package/dist/model-context/makeAssistantTool.js +4 -2
- package/dist/model-context/makeAssistantTool.js.map +1 -1
- package/dist/model-context/makeAssistantToolUI.js +4 -2
- package/dist/model-context/makeAssistantToolUI.js.map +1 -1
- package/dist/model-context/makeAssistantVisible.js +9 -7
- package/dist/model-context/makeAssistantVisible.js.map +1 -1
- package/dist/model-context/tool.d.ts +1 -10
- package/dist/model-context/tool.d.ts.map +1 -1
- package/dist/model-context/tool.js +1 -0
- package/dist/model-context/tool.js.map +1 -1
- package/dist/model-context/useAssistantInstructions.js +5 -3
- package/dist/model-context/useAssistantInstructions.js.map +1 -1
- package/dist/model-context/useAssistantTool.d.ts +0 -1
- package/dist/model-context/useAssistantTool.d.ts.map +1 -1
- package/dist/model-context/useAssistantTool.js +5 -4
- package/dist/model-context/useAssistantTool.js.map +1 -1
- package/dist/model-context/useAssistantToolUI.js +4 -2
- package/dist/model-context/useAssistantToolUI.js.map +1 -1
- package/dist/model-context/useInlineRender.js +3 -1
- package/dist/model-context/useInlineRender.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js +8 -6
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js +6 -4
- package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +7 -5
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +6 -4
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.js +8 -6
- package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.js +5 -3
- package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.js +6 -4
- package/dist/primitives/actionBar/ActionBarSpeak.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js +6 -4
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js.map +1 -1
- package/dist/primitives/actionBar/index.js +9 -8
- package/dist/primitives/actionBar/index.js.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.js +6 -4
- package/dist/primitives/actionBar/useActionBarFloatStatus.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.js +5 -3
- package/dist/primitives/assistantModal/AssistantModalAnchor.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js +5 -3
- package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.js +7 -5
- package/dist/primitives/assistantModal/AssistantModalRoot.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.js +4 -3
- package/dist/primitives/assistantModal/AssistantModalTrigger.js.map +1 -1
- package/dist/primitives/assistantModal/index.js +5 -4
- package/dist/primitives/assistantModal/index.js.map +1 -1
- package/dist/primitives/assistantModal/scope.js +2 -1
- package/dist/primitives/assistantModal/scope.js.map +1 -1
- package/dist/primitives/attachment/AttachmentName.js +4 -2
- package/dist/primitives/attachment/AttachmentName.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRemove.js +6 -4
- package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRoot.js +3 -2
- package/dist/primitives/attachment/AttachmentRoot.js.map +1 -1
- package/dist/primitives/attachment/AttachmentThumb.js +5 -3
- package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
- package/dist/primitives/attachment/index.js +5 -4
- package/dist/primitives/attachment/index.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.js +5 -3
- package/dist/primitives/branchPicker/BranchPickerCount.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js +6 -4
- package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.js +5 -3
- package/dist/primitives/branchPicker/BranchPickerNumber.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js +6 -4
- package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js +4 -3
- package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
- package/dist/primitives/branchPicker/index.js +6 -5
- package/dist/primitives/branchPicker/index.js.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +6 -4
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.js +11 -9
- package/dist/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.js +6 -4
- package/dist/primitives/composer/ComposerCancel.js.map +1 -1
- package/dist/primitives/composer/ComposerIf.js +5 -3
- package/dist/primitives/composer/ComposerIf.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +8 -6
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js +5 -3
- package/dist/primitives/composer/ComposerRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerSend.js +8 -6
- package/dist/primitives/composer/ComposerSend.js.map +1 -1
- package/dist/primitives/composer/index.js +8 -7
- package/dist/primitives/composer/index.js.map +1 -1
- package/dist/primitives/contentPart/ContentPartImage.js +5 -3
- package/dist/primitives/contentPart/ContentPartImage.js.map +1 -1
- package/dist/primitives/contentPart/ContentPartInProgress.js +4 -2
- package/dist/primitives/contentPart/ContentPartInProgress.js.map +1 -1
- package/dist/primitives/contentPart/ContentPartText.js +6 -4
- package/dist/primitives/contentPart/ContentPartText.js.map +1 -1
- package/dist/primitives/contentPart/index.js +4 -3
- package/dist/primitives/contentPart/index.js.map +1 -1
- package/dist/primitives/contentPart/useContentPartFile.js +4 -2
- package/dist/primitives/contentPart/useContentPartFile.js.map +1 -1
- package/dist/primitives/contentPart/useContentPartImage.js +4 -2
- package/dist/primitives/contentPart/useContentPartImage.js.map +1 -1
- package/dist/primitives/contentPart/useContentPartReasoning.js +4 -2
- package/dist/primitives/contentPart/useContentPartReasoning.js.map +1 -1
- package/dist/primitives/contentPart/useContentPartSource.js +4 -2
- package/dist/primitives/contentPart/useContentPartSource.js.map +1 -1
- package/dist/primitives/contentPart/useContentPartText.js +4 -2
- package/dist/primitives/contentPart/useContentPartText.js.map +1 -1
- package/dist/primitives/index.js +17 -16
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/message/MessageAttachments.js +11 -9
- package/dist/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/primitives/message/MessageContent.js +19 -17
- package/dist/primitives/message/MessageContent.js.map +1 -1
- package/dist/primitives/message/MessageIf.js +6 -4
- package/dist/primitives/message/MessageIf.js.map +1 -1
- package/dist/primitives/message/MessageRoot.js +7 -5
- package/dist/primitives/message/MessageRoot.js.map +1 -1
- package/dist/primitives/message/index.js +5 -4
- package/dist/primitives/message/index.js.map +1 -1
- package/dist/primitives/thread/ThreadEmpty.js +4 -2
- package/dist/primitives/thread/ThreadEmpty.js.map +1 -1
- package/dist/primitives/thread/ThreadIf.js +5 -3
- package/dist/primitives/thread/ThreadIf.js.map +1 -1
- package/dist/primitives/thread/ThreadMessages.js +14 -12
- package/dist/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/primitives/thread/ThreadRoot.js +3 -2
- package/dist/primitives/thread/ThreadRoot.js.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.js +6 -4
- package/dist/primitives/thread/ThreadScrollToBottom.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.js +7 -5
- package/dist/primitives/thread/ThreadSuggestion.js.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js +7 -5
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/thread/index.js +8 -7
- package/dist/primitives/thread/index.js.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +9 -7
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.js +8 -6
- package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.js +6 -4
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
- package/dist/primitives/threadList/ThreadListRoot.js +3 -2
- package/dist/primitives/threadList/ThreadListRoot.js.map +1 -1
- package/dist/primitives/threadList/index.js +4 -3
- package/dist/primitives/threadList/index.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemArchive.js +6 -4
- package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemDelete.js +6 -4
- package/dist/primitives/threadListItem/ThreadListItemDelete.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js +5 -3
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTitle.js +4 -2
- package/dist/primitives/threadListItem/ThreadListItemTitle.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js +6 -4
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js +6 -4
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -1
- package/dist/primitives/threadListItem/index.js +7 -6
- package/dist/primitives/threadListItem/index.js.map +1 -1
- package/dist/runtimes/adapters/RuntimeAdapterProvider.js +5 -4
- package/dist/runtimes/adapters/RuntimeAdapterProvider.js.map +1 -1
- package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.js +3 -2
- package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.js.map +1 -1
- package/dist/runtimes/adapters/attachment/SimpleImageAttachmentAdapter.js +4 -3
- package/dist/runtimes/adapters/attachment/SimpleImageAttachmentAdapter.js.map +1 -1
- package/dist/runtimes/adapters/attachment/SimpleTextAttachmentAdapter.js +4 -3
- package/dist/runtimes/adapters/attachment/SimpleTextAttachmentAdapter.js.map +1 -1
- package/dist/runtimes/adapters/attachment/index.js +4 -3
- package/dist/runtimes/adapters/attachment/index.js.map +1 -1
- package/dist/runtimes/adapters/index.js +5 -4
- package/dist/runtimes/adapters/index.js.map +1 -1
- package/dist/runtimes/adapters/speech/WebSpeechSynthesisAdapter.js +3 -2
- package/dist/runtimes/adapters/speech/WebSpeechSynthesisAdapter.js.map +1 -1
- package/dist/runtimes/adapters/speech/index.js +2 -1
- package/dist/runtimes/adapters/speech/index.js.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js +5 -4
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +5 -4
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js +4 -3
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.js +4 -3
- package/dist/runtimes/core/BaseAssistantRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.js +7 -6
- package/dist/runtimes/core/BaseThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js +7 -6
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js +8 -7
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +11 -10
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageConverter.js +3 -2
- package/dist/runtimes/external-store/ThreadMessageConverter.js.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.js +3 -2
- package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
- package/dist/runtimes/external-store/auto-status.js +5 -4
- package/dist/runtimes/external-store/auto-status.js.map +1 -1
- package/dist/runtimes/external-store/createMessageConverter.js +6 -4
- package/dist/runtimes/external-store/createMessageConverter.js.map +1 -1
- package/dist/runtimes/external-store/external-message-converter.js +11 -9
- package/dist/runtimes/external-store/external-message-converter.js.map +1 -1
- package/dist/runtimes/external-store/getExternalStoreMessage.js +6 -5
- package/dist/runtimes/external-store/getExternalStoreMessage.js.map +1 -1
- package/dist/runtimes/external-store/index.js +5 -4
- package/dist/runtimes/external-store/index.js.map +1 -1
- package/dist/runtimes/external-store/useExternalStoreRuntime.js +6 -4
- package/dist/runtimes/external-store/useExternalStoreRuntime.js.map +1 -1
- package/dist/runtimes/index.js +7 -6
- package/dist/runtimes/index.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.js +7 -6
- package/dist/runtimes/local/LocalRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.js +2 -1
- package/dist/runtimes/local/LocalRuntimeOptions.js.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js +5 -4
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js +6 -5
- package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/index.js +2 -1
- package/dist/runtimes/local/index.js.map +1 -1
- package/dist/runtimes/local/shouldContinue.js +2 -1
- package/dist/runtimes/local/shouldContinue.js.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.js +9 -7
- package/dist/runtimes/local/useLocalRuntime.js.map +1 -1
- package/dist/runtimes/remote-thread-list/BaseSubscribable.js +3 -2
- package/dist/runtimes/remote-thread-list/BaseSubscribable.js.map +1 -1
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.js +3 -2
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.js.map +1 -1
- package/dist/runtimes/remote-thread-list/OptimisticState.js +5 -4
- package/dist/runtimes/remote-thread-list/OptimisticState.js.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js +9 -7
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +13 -11
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/cloud.js +9 -8
- package/dist/runtimes/remote-thread-list/adapter/cloud.js.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/in-memory.js +3 -2
- package/dist/runtimes/remote-thread-list/adapter/in-memory.js.map +1 -1
- package/dist/runtimes/remote-thread-list/index.js +3 -2
- package/dist/runtimes/remote-thread-list/index.js.map +1 -1
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js +8 -6
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/runtimes/utils/MessageRepository.js +10 -9
- package/dist/runtimes/utils/MessageRepository.js.map +1 -1
- package/dist/tests/setup.js +2971 -3
- package/dist/tests/setup.js.map +1 -1
- package/dist/utils/CompositeContextProvider.js +4 -3
- package/dist/utils/CompositeContextProvider.js.map +1 -1
- package/dist/utils/combined/createCombinedStore.js +3 -1
- package/dist/utils/combined/createCombinedStore.js.map +1 -1
- package/dist/utils/combined/useCombinedStore.js +4 -2
- package/dist/utils/combined/useCombinedStore.js.map +1 -1
- package/dist/utils/createActionButton.js +3 -2
- package/dist/utils/createActionButton.js.map +1 -1
- package/dist/utils/getThreadMessageText.js +2 -1
- package/dist/utils/getThreadMessageText.js.map +1 -1
- package/dist/utils/hooks/useManagedRef.js +2 -1
- package/dist/utils/hooks/useManagedRef.js.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.js +3 -2
- package/dist/utils/hooks/useOnResizeContent.js.map +1 -1
- package/dist/utils/hooks/useOnScrollToBottom.js +4 -2
- package/dist/utils/hooks/useOnScrollToBottom.js.map +1 -1
- package/dist/utils/idUtils.js +5 -4
- package/dist/utils/idUtils.js.map +1 -1
- package/dist/utils/json/is-json.js +1 -0
- package/dist/utils/json/is-json.js.map +1 -1
- package/dist/utils/smooth/SmoothContext.js +10 -8
- package/dist/utils/smooth/SmoothContext.js.map +1 -1
- package/dist/utils/smooth/index.js +4 -2
- package/dist/utils/smooth/index.js.map +1 -1
- package/dist/utils/smooth/useSmooth.js +9 -7
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/useToolArgsFieldStatus.js +4 -3
- package/dist/utils/useToolArgsFieldStatus.js.map +1 -1
- package/package.json +4 -4
- package/src/model-context/tool.ts +3 -16
- package/src/model-context/useAssistantTool.tsx +1 -4
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/context/providers/ThreadViewportProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport { useEffect, useState } from \"react\";\nimport { makeThreadViewportStore } from \"../stores/ThreadViewport\";\nimport {\n ThreadViewportContext,\n ThreadViewportContextValue,\n useThreadViewportStore,\n} from \"../react/ThreadViewportContext\";\nimport { writableStore } from \"../ReadonlyStore\";\n\nconst useThreadViewportStoreValue = () => {\n const outerViewport = useThreadViewportStore({ optional: true });\n const [store] = useState(() => makeThreadViewportStore());\n\n useEffect(() => {\n return outerViewport?.getState().onScrollToBottom(() => {\n store.getState().scrollToBottom();\n });\n }, [outerViewport, store]);\n\n useEffect(() => {\n if (!outerViewport) return;\n return store.subscribe((state) => {\n if (outerViewport.getState().isAtBottom !== state.isAtBottom) {\n writableStore(outerViewport).setState({ isAtBottom: state.isAtBottom });\n }\n });\n }, [store, outerViewport]);\n\n return store;\n};\n\nexport const ThreadViewportProvider: FC<PropsWithChildren> = ({ children }) => {\n const useThreadViewport = useThreadViewportStoreValue();\n\n const [context] = useState<ThreadViewportContextValue>(() => {\n return {\n useThreadViewport,\n };\n });\n\n return (\n <ThreadViewportContext.Provider value={context}>\n {children}\n </ThreadViewportContext.Provider>\n );\n};\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/context/providers/ThreadViewportProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport { useEffect, useState } from \"react\";\nimport { makeThreadViewportStore } from \"../stores/ThreadViewport\";\nimport {\n ThreadViewportContext,\n ThreadViewportContextValue,\n useThreadViewportStore,\n} from \"../react/ThreadViewportContext\";\nimport { writableStore } from \"../ReadonlyStore\";\n\nconst useThreadViewportStoreValue = () => {\n const outerViewport = useThreadViewportStore({ optional: true });\n const [store] = useState(() => makeThreadViewportStore());\n\n useEffect(() => {\n return outerViewport?.getState().onScrollToBottom(() => {\n store.getState().scrollToBottom();\n });\n }, [outerViewport, store]);\n\n useEffect(() => {\n if (!outerViewport) return;\n return store.subscribe((state) => {\n if (outerViewport.getState().isAtBottom !== state.isAtBottom) {\n writableStore(outerViewport).setState({ isAtBottom: state.isAtBottom });\n }\n });\n }, [store, outerViewport]);\n\n return store;\n};\n\nexport const ThreadViewportProvider: FC<PropsWithChildren> = ({ children }) => {\n const useThreadViewport = useThreadViewportStoreValue();\n\n const [context] = useState<ThreadViewportContextValue>(() => {\n return {\n useThreadViewport,\n };\n });\n\n return (\n <ThreadViewportContext.Provider value={context}>\n {children}\n </ThreadViewportContext.Provider>\n );\n};\n"],"mappings":";;;AAGA,SAAS,WAAW,gBAAgB;AACpC,SAAS,+BAA+B;AACxC;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,qBAAqB;AAkC1B;AAhCJ,IAAM,8BAA8B,MAAM;AACxC,QAAM,gBAAgB,uBAAuB,EAAE,UAAU,KAAK,CAAC;AAC/D,QAAM,CAAC,KAAK,IAAI,SAAS,MAAM,wBAAwB,CAAC;AAExD,YAAU,MAAM;AACd,WAAO,eAAe,SAAS,EAAE,iBAAiB,MAAM;AACtD,YAAM,SAAS,EAAE,eAAe;AAAA,IAClC,CAAC;AAAA,EACH,GAAG,CAAC,eAAe,KAAK,CAAC;AAEzB,YAAU,MAAM;AACd,QAAI,CAAC,cAAe;AACpB,WAAO,MAAM,UAAU,CAAC,UAAU;AAChC,UAAI,cAAc,SAAS,EAAE,eAAe,MAAM,YAAY;AAC5D,sBAAc,aAAa,EAAE,SAAS,EAAE,YAAY,MAAM,WAAW,CAAC;AAAA,MACxE;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,OAAO,aAAa,CAAC;AAEzB,SAAO;AACT;AAEO,IAAM,yBAAgD,CAAC,EAAE,SAAS,MAAM;AAC7E,QAAM,oBAAoB,4BAA4B;AAEtD,QAAM,CAAC,OAAO,IAAI,SAAqC,MAAM;AAC3D,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF,CAAC;AAED,SACE,oBAAC,sBAAsB,UAAtB,EAA+B,OAAO,SACpC,UACH;AAEJ;","names":[]}
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
import {
|
1
|
+
// src/context/providers/index.ts
|
2
|
+
import { AssistantRuntimeProvider } from "./AssistantRuntimeProvider.js";
|
3
|
+
import { TextContentPartProvider } from "./TextContentPartProvider.js";
|
3
4
|
export {
|
4
5
|
AssistantRuntimeProvider,
|
5
6
|
TextContentPartProvider
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/context/providers/index.ts"],"sourcesContent":["export { AssistantRuntimeProvider } from \"./AssistantRuntimeProvider\";\nexport { TextContentPartProvider } from \"./TextContentPartProvider\";\n"],"mappings":"AAAA,SAAS,gCAAgC;AACzC,SAAS,+BAA+B;","names":[]}
|
1
|
+
{"version":3,"sources":["../../../src/context/providers/index.ts"],"sourcesContent":["export { AssistantRuntimeProvider } from \"./AssistantRuntimeProvider\";\nexport { TextContentPartProvider } from \"./TextContentPartProvider\";\n"],"mappings":";AAAA,SAAS,gCAAgC;AACzC,SAAS,+BAA+B;","names":[]}
|
@@ -1,12 +1,14 @@
|
|
1
1
|
"use client";
|
2
|
+
|
3
|
+
// src/context/react/AssistantContext.ts
|
2
4
|
import { createContext } from "react";
|
3
|
-
import { createContextHook } from "./utils/createContextHook";
|
4
|
-
import { createContextStoreHook } from "./utils/createContextStoreHook";
|
5
|
-
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime";
|
6
|
-
|
5
|
+
import { createContextHook } from "./utils/createContextHook.js";
|
6
|
+
import { createContextStoreHook } from "./utils/createContextStoreHook.js";
|
7
|
+
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime.js";
|
8
|
+
var AssistantContext = createContext(
|
7
9
|
null
|
8
10
|
);
|
9
|
-
|
11
|
+
var useAssistantContext = createContextHook(
|
10
12
|
AssistantContext,
|
11
13
|
"AssistantRuntimeProvider"
|
12
14
|
);
|
@@ -15,12 +17,12 @@ function useAssistantRuntime(options) {
|
|
15
17
|
if (!context) return null;
|
16
18
|
return context.useAssistantRuntime();
|
17
19
|
}
|
18
|
-
|
20
|
+
var { useToolUIs, useToolUIsStore } = createContextStoreHook(
|
19
21
|
useAssistantContext,
|
20
22
|
"useToolUIs"
|
21
23
|
);
|
22
|
-
|
23
|
-
|
24
|
+
var useThreadListRuntime = (opt) => useAssistantRuntime(opt)?.threads ?? null;
|
25
|
+
var useThreadList = createStateHookForRuntime(useThreadListRuntime);
|
24
26
|
export {
|
25
27
|
AssistantContext,
|
26
28
|
useAssistantContext,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/AssistantContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport type { AssistantToolUIsState } from \"../stores/AssistantToolUIs\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createContextStoreHook } from \"./utils/createContextStoreHook\";\nimport { UseBoundStore } from \"zustand\";\nimport { AssistantRuntime } from \"../../api/AssistantRuntime\";\nimport { ThreadListRuntime } from \"../../api/ThreadListRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport type AssistantContextValue = {\n useAssistantRuntime: UseBoundStore<ReadonlyStore<AssistantRuntime>>;\n useToolUIs: UseBoundStore<ReadonlyStore<AssistantToolUIsState>>;\n};\n\nexport const AssistantContext = createContext<AssistantContextValue | null>(\n null,\n);\n\nexport const useAssistantContext = createContextHook(\n AssistantContext,\n \"AssistantRuntimeProvider\",\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 context = useAssistantContext(options);\n if (!context) return null;\n return context.useAssistantRuntime();\n}\n\nexport const { useToolUIs, useToolUIsStore } = createContextStoreHook(\n useAssistantContext,\n \"useToolUIs\",\n);\n\nconst useThreadListRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadListRuntime | null => useAssistantRuntime(opt)?.threads ?? null;\nexport const useThreadList = createStateHookForRuntime(useThreadListRuntime);\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/context/react/AssistantContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport type { AssistantToolUIsState } from \"../stores/AssistantToolUIs\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createContextStoreHook } from \"./utils/createContextStoreHook\";\nimport { UseBoundStore } from \"zustand\";\nimport { AssistantRuntime } from \"../../api/AssistantRuntime\";\nimport { ThreadListRuntime } from \"../../api/ThreadListRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport type AssistantContextValue = {\n useAssistantRuntime: UseBoundStore<ReadonlyStore<AssistantRuntime>>;\n useToolUIs: UseBoundStore<ReadonlyStore<AssistantToolUIsState>>;\n};\n\nexport const AssistantContext = createContext<AssistantContextValue | null>(\n null,\n);\n\nexport const useAssistantContext = createContextHook(\n AssistantContext,\n \"AssistantRuntimeProvider\",\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 context = useAssistantContext(options);\n if (!context) return null;\n return context.useAssistantRuntime();\n}\n\nexport const { useToolUIs, useToolUIsStore } = createContextStoreHook(\n useAssistantContext,\n \"useToolUIs\",\n);\n\nconst useThreadListRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadListRuntime | null => useAssistantRuntime(opt)?.threads ?? null;\nexport const useThreadList = createStateHookForRuntime(useThreadListRuntime);\n"],"mappings":";;;AAEA,SAAS,qBAAqB;AAG9B,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AAIvC,SAAS,iCAAiC;AAOnC,IAAM,mBAAmB;AAAA,EAC9B;AACF;AAEO,IAAM,sBAAsB;AAAA,EACjC;AAAA,EACA;AACF;AAQO,SAAS,oBAAoB,SAEjC;AACD,QAAM,UAAU,oBAAoB,OAAO;AAC3C,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,QAAQ,oBAAoB;AACrC;AAEO,IAAM,EAAE,YAAY,gBAAgB,IAAI;AAAA,EAC7C;AAAA,EACA;AACF;AAEA,IAAM,uBAAuB,CAAC,QAEE,oBAAoB,GAAG,GAAG,WAAW;AAC9D,IAAM,gBAAgB,0BAA0B,oBAAoB;","names":[]}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
"use client";
|
2
|
+
|
3
|
+
// src/context/react/AttachmentContext.ts
|
2
4
|
import { createContext } from "react";
|
3
|
-
import { createContextHook } from "./utils/createContextHook";
|
4
|
-
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime";
|
5
|
-
|
5
|
+
import { createContextHook } from "./utils/createContextHook.js";
|
6
|
+
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime.js";
|
7
|
+
var AttachmentContext = createContext(
|
6
8
|
null
|
7
9
|
);
|
8
|
-
|
10
|
+
var useAttachmentContext = createContextHook(
|
9
11
|
AttachmentContext,
|
10
12
|
"a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component"
|
11
13
|
);
|
@@ -41,14 +43,14 @@ function useMessageAttachmentRuntime(options) {
|
|
41
43
|
);
|
42
44
|
return attachmentRuntime;
|
43
45
|
}
|
44
|
-
|
45
|
-
|
46
|
+
var useAttachment = createStateHookForRuntime(useAttachmentRuntime);
|
47
|
+
var useThreadComposerAttachment = createStateHookForRuntime(
|
46
48
|
useThreadComposerAttachmentRuntime
|
47
49
|
);
|
48
|
-
|
50
|
+
var useEditComposerAttachment = createStateHookForRuntime(
|
49
51
|
useEditComposerAttachmentRuntime
|
50
52
|
);
|
51
|
-
|
53
|
+
var useMessageAttachment = createStateHookForRuntime(
|
52
54
|
useMessageAttachmentRuntime
|
53
55
|
);
|
54
56
|
export {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/AttachmentContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { AttachmentRuntime } from \"../../api/AttachmentRuntime\";\nimport { UseBoundStore } from \"zustand\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport type AttachmentContextValue = {\n useAttachmentRuntime: UseBoundStore<ReadonlyStore<AttachmentRuntime>>;\n};\n\nexport const AttachmentContext = createContext<AttachmentContextValue | null>(\n null,\n);\n\nconst useAttachmentContext = createContextHook(\n AttachmentContext,\n \"a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component\",\n);\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 attachmentRuntime = useAttachmentContext(options);\n if (!attachmentRuntime) return null;\n return attachmentRuntime.useAttachmentRuntime();\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\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,"sources":["../../../src/context/react/AttachmentContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { AttachmentRuntime } from \"../../api/AttachmentRuntime\";\nimport { UseBoundStore } from \"zustand\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport type AttachmentContextValue = {\n useAttachmentRuntime: UseBoundStore<ReadonlyStore<AttachmentRuntime>>;\n};\n\nexport const AttachmentContext = createContext<AttachmentContextValue | null>(\n null,\n);\n\nconst useAttachmentContext = createContextHook(\n AttachmentContext,\n \"a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component\",\n);\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 attachmentRuntime = useAttachmentContext(options);\n if (!attachmentRuntime) return null;\n return attachmentRuntime.useAttachmentRuntime();\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\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,SAAS,qBAAqB;AAI9B,SAAS,yBAAyB;AAClC,SAAS,iCAAiC;AAMnC,IAAM,oBAAoB;AAAA,EAC/B;AACF;AAEA,IAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AACF;AAQO,SAAS,qBAAqB,SAER;AAC3B,QAAM,oBAAoB,qBAAqB,OAAO;AACtD,MAAI,CAAC,kBAAmB,QAAO;AAC/B,SAAO,kBAAkB,qBAAqB;AAChD;AAQO,SAAS,mCAAmC,SAEH;AAC9C,QAAM,oBAAoB,qBAAqB,OAAO;AACtD,MAAI,CAAC,kBAAmB,QAAO;AAC/B,MAAI,kBAAkB,WAAW;AAC/B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;AAQO,SAAS,iCAAiC,SAEH;AAC5C,QAAM,oBAAoB,qBAAqB,OAAO;AACtD,MAAI,CAAC,kBAAmB,QAAO;AAC/B,MAAI,kBAAkB,WAAW;AAC/B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAEF,SAAO;AACT;AAQO,SAAS,4BAA4B,SAEJ;AACtC,QAAM,oBAAoB,qBAAqB,OAAO;AACtD,MAAI,CAAC,kBAAmB,QAAO;AAC/B,MAAI,kBAAkB,WAAW;AAC/B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;AAEO,IAAM,gBAAgB,0BAA0B,oBAAoB;AAEpE,IAAM,8BAA8B;AAAA,EACzC;AACF;AACO,IAAM,4BAA4B;AAAA,EACvC;AACF;AACO,IAAM,uBAAuB;AAAA,EAClC;AACF;","names":[]}
|
@@ -1,13 +1,15 @@
|
|
1
1
|
"use client";
|
2
|
-
|
3
|
-
|
4
|
-
import {
|
2
|
+
|
3
|
+
// src/context/react/ComposerContext.ts
|
4
|
+
import { useMessageRuntime } from "./MessageContext.js";
|
5
|
+
import { useThreadRuntime } from "./ThreadContext.js";
|
6
|
+
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime.js";
|
5
7
|
function useComposerRuntime(options) {
|
6
8
|
const messageRuntime = useMessageRuntime({ optional: true });
|
7
9
|
const threadRuntime = useThreadRuntime(options);
|
8
10
|
return messageRuntime ? messageRuntime.composer : threadRuntime?.composer ?? null;
|
9
11
|
}
|
10
|
-
|
12
|
+
var useComposer = createStateHookForRuntime(useComposerRuntime);
|
11
13
|
export {
|
12
14
|
useComposer,
|
13
15
|
useComposerRuntime
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/ComposerContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useMessageRuntime } from \"./MessageContext\";\nimport { useThreadRuntime } from \"./ThreadContext\";\nimport { ComposerRuntime } from \"../../api/ComposerRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\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 messageRuntime = useMessageRuntime({ optional: true });\n const threadRuntime = useThreadRuntime(options);\n return messageRuntime\n ? messageRuntime.composer\n : (threadRuntime?.composer ?? null);\n}\n\nexport const useComposer = createStateHookForRuntime(useComposerRuntime);\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/context/react/ComposerContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useMessageRuntime } from \"./MessageContext\";\nimport { useThreadRuntime } from \"./ThreadContext\";\nimport { ComposerRuntime } from \"../../api/ComposerRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\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 messageRuntime = useMessageRuntime({ optional: true });\n const threadRuntime = useThreadRuntime(options);\n return messageRuntime\n ? messageRuntime.composer\n : (threadRuntime?.composer ?? null);\n}\n\nexport const useComposer = createStateHookForRuntime(useComposerRuntime);\n"],"mappings":";;;AAEA,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAEjC,SAAS,iCAAiC;AAQnC,SAAS,mBAAmB,SAER;AACzB,QAAM,iBAAiB,kBAAkB,EAAE,UAAU,KAAK,CAAC;AAC3D,QAAM,gBAAgB,iBAAiB,OAAO;AAC9C,SAAO,iBACH,eAAe,WACd,eAAe,YAAY;AAClC;AAEO,IAAM,cAAc,0BAA0B,kBAAkB;","names":[]}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
"use client";
|
2
|
+
|
3
|
+
// src/context/react/ContentPartContext.ts
|
2
4
|
import { createContext } from "react";
|
3
|
-
import { createContextHook } from "./utils/createContextHook";
|
4
|
-
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime";
|
5
|
-
|
5
|
+
import { createContextHook } from "./utils/createContextHook.js";
|
6
|
+
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime.js";
|
7
|
+
var ContentPartContext = createContext(
|
6
8
|
null
|
7
9
|
);
|
8
|
-
|
10
|
+
var useContentPartContext = createContextHook(
|
9
11
|
ContentPartContext,
|
10
12
|
"a component passed to <MessagePrimitive.Content components={...}>"
|
11
13
|
);
|
@@ -14,7 +16,7 @@ function useContentPartRuntime(options) {
|
|
14
16
|
if (!context) return null;
|
15
17
|
return context.useContentPartRuntime();
|
16
18
|
}
|
17
|
-
|
19
|
+
var useContentPart = createStateHookForRuntime(useContentPartRuntime);
|
18
20
|
export {
|
19
21
|
ContentPartContext,
|
20
22
|
useContentPart,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/ContentPartContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { UseBoundStore } from \"zustand\";\nimport { ContentPartRuntime } from \"../../api/ContentPartRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport type ContentPartContextValue = {\n useContentPartRuntime: UseBoundStore<ReadonlyStore<ContentPartRuntime>>;\n};\n\nexport const ContentPartContext = createContext<ContentPartContextValue | null>(\n null,\n);\n\nconst useContentPartContext = createContextHook(\n ContentPartContext,\n \"a component passed to <MessagePrimitive.Content components={...}>\",\n);\n\nexport function useContentPartRuntime(options?: {\n optional?: false | undefined;\n}): ContentPartRuntime;\nexport function useContentPartRuntime(options?: {\n optional?: boolean | undefined;\n}): ContentPartRuntime | null;\nexport function useContentPartRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const context = useContentPartContext(options);\n if (!context) return null;\n return context.useContentPartRuntime();\n}\n\nexport const useContentPart = createStateHookForRuntime(useContentPartRuntime);\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/context/react/ContentPartContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { UseBoundStore } from \"zustand\";\nimport { ContentPartRuntime } from \"../../api/ContentPartRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport type ContentPartContextValue = {\n useContentPartRuntime: UseBoundStore<ReadonlyStore<ContentPartRuntime>>;\n};\n\nexport const ContentPartContext = createContext<ContentPartContextValue | null>(\n null,\n);\n\nconst useContentPartContext = createContextHook(\n ContentPartContext,\n \"a component passed to <MessagePrimitive.Content components={...}>\",\n);\n\nexport function useContentPartRuntime(options?: {\n optional?: false | undefined;\n}): ContentPartRuntime;\nexport function useContentPartRuntime(options?: {\n optional?: boolean | undefined;\n}): ContentPartRuntime | null;\nexport function useContentPartRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const context = useContentPartContext(options);\n if (!context) return null;\n return context.useContentPartRuntime();\n}\n\nexport const useContentPart = createStateHookForRuntime(useContentPartRuntime);\n"],"mappings":";;;AAEA,SAAS,qBAAqB;AAE9B,SAAS,yBAAyB;AAGlC,SAAS,iCAAiC;AAMnC,IAAM,qBAAqB;AAAA,EAChC;AACF;AAEA,IAAM,wBAAwB;AAAA,EAC5B;AAAA,EACA;AACF;AAQO,SAAS,sBAAsB,SAEnC;AACD,QAAM,UAAU,sBAAsB,OAAO;AAC7C,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,QAAQ,sBAAsB;AACvC;AAEO,IAAM,iBAAiB,0BAA0B,qBAAqB;","names":[]}
|
@@ -1,10 +1,12 @@
|
|
1
1
|
"use client";
|
2
|
+
|
3
|
+
// src/context/react/MessageContext.ts
|
2
4
|
import { createContext } from "react";
|
3
|
-
import { createContextHook } from "./utils/createContextHook";
|
4
|
-
import { createContextStoreHook } from "./utils/createContextStoreHook";
|
5
|
-
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime";
|
6
|
-
|
7
|
-
|
5
|
+
import { createContextHook } from "./utils/createContextHook.js";
|
6
|
+
import { createContextStoreHook } from "./utils/createContextStoreHook.js";
|
7
|
+
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime.js";
|
8
|
+
var MessageContext = createContext(null);
|
9
|
+
var useMessageContext = createContextHook(
|
8
10
|
MessageContext,
|
9
11
|
"a component passed to <ThreadPrimitive.Messages components={...} />"
|
10
12
|
);
|
@@ -13,12 +15,12 @@ function useMessageRuntime(options) {
|
|
13
15
|
if (!context) return null;
|
14
16
|
return context.useMessageRuntime();
|
15
17
|
}
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
var useMessage = createStateHookForRuntime(useMessageRuntime);
|
19
|
+
var useEditComposerRuntime = (opt) => useMessageRuntime(opt)?.composer ?? null;
|
20
|
+
var useEditComposer = createStateHookForRuntime(
|
19
21
|
useEditComposerRuntime
|
20
22
|
);
|
21
|
-
|
23
|
+
var { useMessageUtils, useMessageUtilsStore } = createContextStoreHook(
|
22
24
|
useMessageContext,
|
23
25
|
"useMessageUtils"
|
24
26
|
);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/MessageContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { MessageUtilsState } from \"../stores/MessageUtils\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createContextStoreHook } from \"./utils/createContextStoreHook\";\nimport { UseBoundStore } from \"zustand\";\nimport { MessageRuntime } from \"../../api/MessageRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\nimport { EditComposerRuntime } from \"../../api\";\n\nexport type MessageContextValue = {\n useMessageRuntime: UseBoundStore<ReadonlyStore<MessageRuntime>>;\n useMessageUtils: UseBoundStore<ReadonlyStore<MessageUtilsState>>;\n};\n\nexport const MessageContext = createContext<MessageContextValue | null>(null);\n\nconst useMessageContext = createContextHook(\n MessageContext,\n \"a component passed to <ThreadPrimitive.Messages components={...} />\",\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 context = useMessageContext(options);\n if (!context) return null;\n return context.useMessageRuntime();\n}\n\nexport const useMessage = createStateHookForRuntime(useMessageRuntime);\n\nconst useEditComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): EditComposerRuntime | null => useMessageRuntime(opt)?.composer ?? null;\nexport const useEditComposer = createStateHookForRuntime(\n useEditComposerRuntime,\n);\n\nexport const { useMessageUtils, useMessageUtilsStore } = createContextStoreHook(\n useMessageContext,\n \"useMessageUtils\",\n);\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/context/react/MessageContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { MessageUtilsState } from \"../stores/MessageUtils\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createContextStoreHook } from \"./utils/createContextStoreHook\";\nimport { UseBoundStore } from \"zustand\";\nimport { MessageRuntime } from \"../../api/MessageRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\nimport { EditComposerRuntime } from \"../../api\";\n\nexport type MessageContextValue = {\n useMessageRuntime: UseBoundStore<ReadonlyStore<MessageRuntime>>;\n useMessageUtils: UseBoundStore<ReadonlyStore<MessageUtilsState>>;\n};\n\nexport const MessageContext = createContext<MessageContextValue | null>(null);\n\nconst useMessageContext = createContextHook(\n MessageContext,\n \"a component passed to <ThreadPrimitive.Messages components={...} />\",\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 context = useMessageContext(options);\n if (!context) return null;\n return context.useMessageRuntime();\n}\n\nexport const useMessage = createStateHookForRuntime(useMessageRuntime);\n\nconst useEditComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): EditComposerRuntime | null => useMessageRuntime(opt)?.composer ?? null;\nexport const useEditComposer = createStateHookForRuntime(\n useEditComposerRuntime,\n);\n\nexport const { useMessageUtils, useMessageUtilsStore } = createContextStoreHook(\n useMessageContext,\n \"useMessageUtils\",\n);\n"],"mappings":";;;AAEA,SAAS,qBAAqB;AAG9B,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AAGvC,SAAS,iCAAiC;AAQnC,IAAM,iBAAiB,cAA0C,IAAI;AAE5E,IAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AACF;AAQO,SAAS,kBAAkB,SAE/B;AACD,QAAM,UAAU,kBAAkB,OAAO;AACzC,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,QAAQ,kBAAkB;AACnC;AAEO,IAAM,aAAa,0BAA0B,iBAAiB;AAErE,IAAM,yBAAyB,CAAC,QAEE,kBAAkB,GAAG,GAAG,YAAY;AAC/D,IAAM,kBAAkB;AAAA,EAC7B;AACF;AAEO,IAAM,EAAE,iBAAiB,qBAAqB,IAAI;AAAA,EACvD;AAAA,EACA;AACF;","names":[]}
|
@@ -1,9 +1,11 @@
|
|
1
1
|
"use client";
|
2
|
+
|
3
|
+
// src/context/react/ThreadContext.ts
|
2
4
|
import { createContext, useEffect, useState } from "react";
|
3
|
-
import { createContextHook } from "./utils/createContextHook";
|
4
|
-
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime";
|
5
|
-
|
6
|
-
|
5
|
+
import { createContextHook } from "./utils/createContextHook.js";
|
6
|
+
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime.js";
|
7
|
+
var ThreadContext = createContext(null);
|
8
|
+
var useThreadContext = createContextHook(
|
7
9
|
ThreadContext,
|
8
10
|
"AssistantRuntimeProvider"
|
9
11
|
);
|
@@ -12,9 +14,9 @@ function useThreadRuntime(options) {
|
|
12
14
|
if (!context) return null;
|
13
15
|
return context.useThreadRuntime();
|
14
16
|
}
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
var useThread = createStateHookForRuntime(useThreadRuntime);
|
18
|
+
var useThreadComposerRuntime = (opt) => useThreadRuntime(opt)?.composer ?? null;
|
19
|
+
var useThreadComposer = createStateHookForRuntime(
|
18
20
|
useThreadComposerRuntime
|
19
21
|
);
|
20
22
|
function useThreadModelContext(options) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/ThreadContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext, useEffect, useState } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { UseBoundStore } from \"zustand\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { ThreadRuntime } from \"../../api/ThreadRuntime\";\nimport { ModelContext } from \"../../model-context\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\nimport { ThreadComposerRuntime } from \"../../api\";\n\nexport type ThreadContextValue = {\n useThreadRuntime: UseBoundStore<ReadonlyStore<ThreadRuntime>>;\n};\n\nexport const ThreadContext = createContext<ThreadContextValue | null>(null);\n\nconst useThreadContext = createContextHook(\n ThreadContext,\n \"AssistantRuntimeProvider\",\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 context = useThreadContext(options);\n if (!context) return null;\n return context.useThreadRuntime();\n}\n\nexport const useThread = createStateHookForRuntime(useThreadRuntime);\n\nconst useThreadComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadComposerRuntime | null => useThreadRuntime(opt)?.composer ?? null;\nexport const useThreadComposer = createStateHookForRuntime(\n useThreadComposerRuntime,\n);\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 useEffect(() => {\n return runtime?.unstable_on(\"model-context-update\", () => rerender({}));\n }, [runtime]);\n\n if (!runtime) return null;\n return runtime?.getModelContext();\n}\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/context/react/ThreadContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext, useEffect, useState } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { UseBoundStore } from \"zustand\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { ThreadRuntime } from \"../../api/ThreadRuntime\";\nimport { ModelContext } from \"../../model-context\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\nimport { ThreadComposerRuntime } from \"../../api\";\n\nexport type ThreadContextValue = {\n useThreadRuntime: UseBoundStore<ReadonlyStore<ThreadRuntime>>;\n};\n\nexport const ThreadContext = createContext<ThreadContextValue | null>(null);\n\nconst useThreadContext = createContextHook(\n ThreadContext,\n \"AssistantRuntimeProvider\",\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 context = useThreadContext(options);\n if (!context) return null;\n return context.useThreadRuntime();\n}\n\nexport const useThread = createStateHookForRuntime(useThreadRuntime);\n\nconst useThreadComposerRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadComposerRuntime | null => useThreadRuntime(opt)?.composer ?? null;\nexport const useThreadComposer = createStateHookForRuntime(\n useThreadComposerRuntime,\n);\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 useEffect(() => {\n return runtime?.unstable_on(\"model-context-update\", () => rerender({}));\n }, [runtime]);\n\n if (!runtime) return null;\n return runtime?.getModelContext();\n}\n"],"mappings":";;;AAEA,SAAS,eAAe,WAAW,gBAAgB;AAGnD,SAAS,yBAAyB;AAGlC,SAAS,iCAAiC;AAOnC,IAAM,gBAAgB,cAAyC,IAAI;AAE1E,IAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AACF;AAQO,SAAS,iBAAiB,SAA8C;AAC7E,QAAM,UAAU,iBAAiB,OAAO;AACxC,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,QAAQ,iBAAiB;AAClC;AAEO,IAAM,YAAY,0BAA0B,gBAAgB;AAEnE,IAAM,2BAA2B,CAAC,QAEE,iBAAiB,GAAG,GAAG,YAAY;AAChE,IAAM,oBAAoB;AAAA,EAC/B;AACF;AAQO,SAAS,sBAAsB,SAEd;AACtB,QAAM,CAAC,EAAE,QAAQ,IAAI,SAAS,CAAC,CAAC;AAEhC,QAAM,UAAU,iBAAiB,OAAO;AACxC,YAAU,MAAM;AACd,WAAO,SAAS,YAAY,wBAAwB,MAAM,SAAS,CAAC,CAAC,CAAC;AAAA,EACxE,GAAG,CAAC,OAAO,CAAC;AAEZ,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,SAAS,gBAAgB;AAClC;","names":[]}
|
@@ -1,9 +1,11 @@
|
|
1
1
|
"use client";
|
2
|
+
|
3
|
+
// src/context/react/ThreadListItemContext.ts
|
2
4
|
import { createContext } from "react";
|
3
|
-
import { createContextHook } from "./utils/createContextHook";
|
4
|
-
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime";
|
5
|
-
|
6
|
-
|
5
|
+
import { createContextHook } from "./utils/createContextHook.js";
|
6
|
+
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime.js";
|
7
|
+
var ThreadListItemContext = createContext(null);
|
8
|
+
var useThreadListItemContext = createContextHook(
|
7
9
|
ThreadListItemContext,
|
8
10
|
"a component passed to <ThreadListPrimitive.Items components={...}>"
|
9
11
|
);
|
@@ -12,7 +14,7 @@ function useThreadListItemRuntime(options) {
|
|
12
14
|
if (!context) return null;
|
13
15
|
return context.useThreadListItemRuntime();
|
14
16
|
}
|
15
|
-
|
17
|
+
var useThreadListItem = createStateHookForRuntime(
|
16
18
|
useThreadListItemRuntime
|
17
19
|
);
|
18
20
|
export {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/ThreadListItemContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { UseBoundStore } from \"zustand\";\nimport { ThreadListItemRuntime } from \"../../api/ThreadListItemRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport type ThreadListItemContextValue = {\n useThreadListItemRuntime: UseBoundStore<ReadonlyStore<ThreadListItemRuntime>>;\n};\n\nexport const ThreadListItemContext =\n createContext<ThreadListItemContextValue | null>(null);\n\nconst useThreadListItemContext = createContextHook(\n ThreadListItemContext,\n \"a component passed to <ThreadListPrimitive.Items components={...}>\",\n);\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 context = useThreadListItemContext(options);\n if (!context) return null;\n return context.useThreadListItemRuntime();\n}\n\nexport const useThreadListItem = createStateHookForRuntime(\n useThreadListItemRuntime,\n);\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/context/react/ThreadListItemContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { UseBoundStore } from \"zustand\";\nimport { ThreadListItemRuntime } from \"../../api/ThreadListItemRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport type ThreadListItemContextValue = {\n useThreadListItemRuntime: UseBoundStore<ReadonlyStore<ThreadListItemRuntime>>;\n};\n\nexport const ThreadListItemContext =\n createContext<ThreadListItemContextValue | null>(null);\n\nconst useThreadListItemContext = createContextHook(\n ThreadListItemContext,\n \"a component passed to <ThreadListPrimitive.Items components={...}>\",\n);\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 context = useThreadListItemContext(options);\n if (!context) return null;\n return context.useThreadListItemRuntime();\n}\n\nexport const useThreadListItem = createStateHookForRuntime(\n useThreadListItemRuntime,\n);\n"],"mappings":";;;AAEA,SAAS,qBAAqB;AAE9B,SAAS,yBAAyB;AAGlC,SAAS,iCAAiC;AAMnC,IAAM,wBACX,cAAiD,IAAI;AAEvD,IAAM,2BAA2B;AAAA,EAC/B;AAAA,EACA;AACF;AAQO,SAAS,yBAAyB,SAEtC;AACD,QAAM,UAAU,yBAAyB,OAAO;AAChD,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,QAAQ,yBAAyB;AAC1C;AAEO,IAAM,oBAAoB;AAAA,EAC/B;AACF;","names":[]}
|
@@ -1,13 +1,15 @@
|
|
1
1
|
"use client";
|
2
|
+
|
3
|
+
// src/context/react/ThreadViewportContext.ts
|
2
4
|
import { createContext } from "react";
|
3
|
-
import { createContextHook } from "./utils/createContextHook";
|
4
|
-
import { createContextStoreHook } from "./utils/createContextStoreHook";
|
5
|
-
|
6
|
-
|
5
|
+
import { createContextHook } from "./utils/createContextHook.js";
|
6
|
+
import { createContextStoreHook } from "./utils/createContextStoreHook.js";
|
7
|
+
var ThreadViewportContext = createContext(null);
|
8
|
+
var useThreadViewportContext = createContextHook(
|
7
9
|
ThreadViewportContext,
|
8
10
|
"ThreadPrimitive.Viewport"
|
9
11
|
);
|
10
|
-
|
12
|
+
var { useThreadViewport, useThreadViewportStore } = createContextStoreHook(useThreadViewportContext, "useThreadViewport");
|
11
13
|
export {
|
12
14
|
ThreadViewportContext,
|
13
15
|
useThreadViewport,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/ThreadViewportContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { UseBoundStore } from \"zustand\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createContextStoreHook } from \"./utils/createContextStoreHook\";\nimport { ThreadViewportState } from \"../stores\";\n\nexport type ThreadViewportContextValue = {\n useThreadViewport: UseBoundStore<ReadonlyStore<ThreadViewportState>>;\n};\n\nexport const ThreadViewportContext =\n createContext<ThreadViewportContextValue | null>(null);\n\nconst useThreadViewportContext = createContextHook(\n ThreadViewportContext,\n \"ThreadPrimitive.Viewport\",\n);\n\nexport const { useThreadViewport, useThreadViewportStore } =\n createContextStoreHook(useThreadViewportContext, \"useThreadViewport\");\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/context/react/ThreadViewportContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { UseBoundStore } from \"zustand\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createContextStoreHook } from \"./utils/createContextStoreHook\";\nimport { ThreadViewportState } from \"../stores\";\n\nexport type ThreadViewportContextValue = {\n useThreadViewport: UseBoundStore<ReadonlyStore<ThreadViewportState>>;\n};\n\nexport const ThreadViewportContext =\n createContext<ThreadViewportContextValue | null>(null);\n\nconst useThreadViewportContext = createContextHook(\n ThreadViewportContext,\n \"ThreadPrimitive.Viewport\",\n);\n\nexport const { useThreadViewport, useThreadViewportStore } =\n createContextStoreHook(useThreadViewportContext, \"useThreadViewport\");\n"],"mappings":";;;AAEA,SAAS,qBAAqB;AAG9B,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AAOhC,IAAM,wBACX,cAAiD,IAAI;AAEvD,IAAM,2BAA2B;AAAA,EAC/B;AAAA,EACA;AACF;AAEO,IAAM,EAAE,mBAAmB,uBAAuB,IACvD,uBAAuB,0BAA0B,mBAAmB;","names":[]}
|
@@ -1,39 +1,41 @@
|
|
1
1
|
"use client";
|
2
|
+
|
3
|
+
// src/context/react/index.ts
|
2
4
|
import {
|
3
5
|
useAssistantRuntime,
|
4
6
|
useThreadList,
|
5
7
|
useToolUIs,
|
6
8
|
useToolUIsStore
|
7
|
-
} from "./AssistantContext";
|
9
|
+
} from "./AssistantContext.js";
|
8
10
|
import {
|
9
11
|
useThreadRuntime,
|
10
12
|
useThread,
|
11
13
|
useThreadComposer,
|
12
14
|
useThreadModelContext,
|
13
15
|
useThreadModelContext as useThreadModelContext2
|
14
|
-
} from "./ThreadContext";
|
16
|
+
} from "./ThreadContext.js";
|
15
17
|
import {
|
16
18
|
useThreadViewport,
|
17
19
|
useThreadViewportStore
|
18
|
-
} from "./ThreadViewportContext";
|
20
|
+
} from "./ThreadViewportContext.js";
|
19
21
|
import {
|
20
22
|
useThreadListItemRuntime,
|
21
23
|
useThreadListItem
|
22
|
-
} from "./ThreadListItemContext";
|
24
|
+
} from "./ThreadListItemContext.js";
|
23
25
|
import {
|
24
26
|
useMessageRuntime,
|
25
27
|
useMessage,
|
26
28
|
useEditComposer,
|
27
29
|
useMessageUtils,
|
28
30
|
useMessageUtilsStore
|
29
|
-
} from "./MessageContext";
|
30
|
-
import { useContentPartRuntime, useContentPart } from "./ContentPartContext";
|
31
|
-
import { useComposerRuntime, useComposer } from "./ComposerContext";
|
31
|
+
} from "./MessageContext.js";
|
32
|
+
import { useContentPartRuntime, useContentPart } from "./ContentPartContext.js";
|
33
|
+
import { useComposerRuntime, useComposer } from "./ComposerContext.js";
|
32
34
|
import {
|
33
35
|
useAttachment,
|
34
36
|
useAttachmentRuntime
|
35
|
-
} from "./AttachmentContext";
|
36
|
-
import { useRuntimeState } from "./utils/useRuntimeState";
|
37
|
+
} from "./AttachmentContext.js";
|
38
|
+
import { useRuntimeState } from "./utils/useRuntimeState.js";
|
37
39
|
export {
|
38
40
|
useAssistantRuntime,
|
39
41
|
useAttachment,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/index.ts"],"sourcesContent":["\"use client\";\n// TODO createContextStoreHook does not work well with server-side nextjs bundler\n// use client necessary here for now\n\nexport {\n useAssistantRuntime,\n useThreadList,\n useToolUIs,\n useToolUIsStore,\n} from \"./AssistantContext\";\n\nexport {\n useThreadRuntime,\n useThread,\n useThreadComposer,\n useThreadModelContext,\n /**\n * @deprecated This method was renamed to `useThreadModelContext`.\n */\n useThreadModelContext as useThreadModelConfig,\n} from \"./ThreadContext\";\n\nexport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"./ThreadViewportContext\";\n\nexport {\n useThreadListItemRuntime,\n useThreadListItem,\n} from \"./ThreadListItemContext\";\n\nexport {\n useMessageRuntime,\n useMessage,\n useEditComposer,\n useMessageUtils,\n useMessageUtilsStore,\n} from \"./MessageContext\";\nexport { useContentPartRuntime, useContentPart } from \"./ContentPartContext\";\nexport { useComposerRuntime, useComposer } from \"./ComposerContext\";\n\nexport {\n useAttachment,\n useAttachmentRuntime,\n\n // TODO decide if we want to export/drop these?\n // useEditComposerAttachment,\n // useEditComposerAttachmentRuntime,\n // useMessageAttachment,\n // useMessageAttachmentRuntime,\n // useThreadComposerAttachment,\n // useThreadComposerAttachmentRuntime,\n} from \"./AttachmentContext\";\n\nexport { useRuntimeState } from \"./utils/useRuntimeState\";\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/context/react/index.ts"],"sourcesContent":["\"use client\";\n// TODO createContextStoreHook does not work well with server-side nextjs bundler\n// use client necessary here for now\n\nexport {\n useAssistantRuntime,\n useThreadList,\n useToolUIs,\n useToolUIsStore,\n} from \"./AssistantContext\";\n\nexport {\n useThreadRuntime,\n useThread,\n useThreadComposer,\n useThreadModelContext,\n /**\n * @deprecated This method was renamed to `useThreadModelContext`.\n */\n useThreadModelContext as useThreadModelConfig,\n} from \"./ThreadContext\";\n\nexport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"./ThreadViewportContext\";\n\nexport {\n useThreadListItemRuntime,\n useThreadListItem,\n} from \"./ThreadListItemContext\";\n\nexport {\n useMessageRuntime,\n useMessage,\n useEditComposer,\n useMessageUtils,\n useMessageUtilsStore,\n} from \"./MessageContext\";\nexport { useContentPartRuntime, useContentPart } from \"./ContentPartContext\";\nexport { useComposerRuntime, useComposer } from \"./ComposerContext\";\n\nexport {\n useAttachment,\n useAttachmentRuntime,\n\n // TODO decide if we want to export/drop these?\n // useEditComposerAttachment,\n // useEditComposerAttachmentRuntime,\n // useMessageAttachment,\n // useMessageAttachmentRuntime,\n // useThreadComposerAttachment,\n // useThreadComposerAttachmentRuntime,\n} from \"./AttachmentContext\";\n\nexport { useRuntimeState } from \"./utils/useRuntimeState\";\n"],"mappings":";;;AAIA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIyB,yBAAzBA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB,sBAAsB;AACtD,SAAS,oBAAoB,mBAAmB;AAEhD;AAAA,EACE;AAAA,EACA;AAAA,OASK;AAEP,SAAS,uBAAuB;","names":["useThreadModelContext"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/context/react/utils/createContextHook.ts"],"sourcesContent":["\"use client\";\n\nimport { useContext, Context } from \"react\";\n\n/**\n * Creates a context hook with optional support.\n * @param context - The React context to consume.\n * @param providerName - The name of the provider for error messages.\n * @returns A hook function that provides the context value.\n */\nexport function createContextHook<T>(\n context: Context<T | null>,\n providerName: string,\n) {\n function useContextHook(options?: {\n optional?: boolean | undefined;\n }): T | null {\n const contextValue = useContext(context);\n if (!options?.optional && !contextValue) {\n throw new Error(`This component must be used within ${providerName}.`);\n }\n return contextValue;\n }\n\n return useContextHook;\n}\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../../src/context/react/utils/createContextHook.ts"],"sourcesContent":["\"use client\";\n\nimport { useContext, Context } from \"react\";\n\n/**\n * Creates a context hook with optional support.\n * @param context - The React context to consume.\n * @param providerName - The name of the provider for error messages.\n * @returns A hook function that provides the context value.\n */\nexport function createContextHook<T>(\n context: Context<T | null>,\n providerName: string,\n) {\n function useContextHook(options?: {\n optional?: boolean | undefined;\n }): T | null {\n const contextValue = useContext(context);\n if (!options?.optional && !contextValue) {\n throw new Error(`This component must be used within ${providerName}.`);\n }\n return contextValue;\n }\n\n return useContextHook;\n}\n"],"mappings":";;;AAEA,SAAS,kBAA2B;AAQ7B,SAAS,kBACd,SACA,cACA;AACA,WAAS,eAAe,SAEX;AACX,UAAM,eAAe,WAAW,OAAO;AACvC,QAAI,CAAC,SAAS,YAAY,CAAC,cAAc;AACvC,YAAM,IAAI,MAAM,sCAAsC,YAAY,GAAG;AAAA,IACvE;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/context/react/utils/createContextStoreHook.ts"],"sourcesContent":["import { UseBoundStore } from \"zustand\";\nimport { ReadonlyStore } from \"../../ReadonlyStore\";\n\n/**\n * Creates hooks for accessing a store within a context.\n * @param contextHook - The hook to access the context.\n * @param contextKey - The key of the store in the context.\n * @returns An object containing the hooks: `use...` and `use...Store`.\n */\nexport function createContextStoreHook<T, K extends keyof T & string>(\n contextHook: (options?: { optional?: boolean }) => T | null,\n contextKey: K,\n) {\n type StoreType = T[K];\n type StateType = StoreType extends ReadonlyStore<infer S> ? S : never;\n\n // Define useStoreStoreHook with overloads\n function useStoreStoreHook(): ReadonlyStore<StateType>;\n function useStoreStoreHook(options: {\n optional: true;\n }): ReadonlyStore<StateType> | null;\n function useStoreStoreHook(options?: {\n optional?: boolean;\n }): ReadonlyStore<StateType> | null {\n const context = contextHook(options);\n if (!context) return null;\n return context[contextKey] as ReadonlyStore<StateType>;\n }\n\n // Define useStoreHook with overloads\n function useStoreHook(): StateType;\n function useStoreHook<TSelected>(\n selector: (state: StateType) => TSelected,\n ): TSelected;\n function useStoreHook(options: { optional: true }): StateType | null;\n function useStoreHook<TSelected>(options: {\n optional: true;\n selector?: (state: StateType) => TSelected;\n }): TSelected | null;\n function useStoreHook<TSelected>(\n param?:\n | ((state: StateType) => TSelected)\n | {\n optional?: boolean;\n selector?: (state: StateType) => TSelected;\n },\n ): TSelected | StateType | null {\n let optional = false;\n let selector: ((state: StateType) => TSelected) | undefined;\n\n if (typeof param === \"function\") {\n selector = param;\n } else if (param && typeof param === \"object\") {\n optional = !!param.optional;\n selector = param.selector;\n }\n\n const store = useStoreStoreHook({\n optional,\n } as any) as UseBoundStore<ReadonlyStore<StateType>>;\n if (!store) return null;\n return selector ? store(selector) : store();\n }\n\n // Return an object with keys based on contextKey\n return {\n [contextKey]: useStoreHook,\n [`${contextKey}Store`]: useStoreStoreHook,\n } as {\n [P in K]: typeof useStoreHook;\n } & {\n [P in `${K}Store`]: typeof useStoreStoreHook;\n };\n}\n"],"mappings":"AASO,SAAS,uBACd,aACA,YACA;AASA,WAAS,kBAAkB,SAES;AAClC,UAAM,UAAU,YAAY,OAAO;AACnC,QAAI,CAAC,QAAS,QAAO;AACrB,WAAO,QAAQ,UAAU;AAAA,EAC3B;AAYA,WAAS,aACP,OAM8B;AAC9B,QAAI,WAAW;AACf,QAAI;AAEJ,QAAI,OAAO,UAAU,YAAY;AAC/B,iBAAW;AAAA,IACb,WAAW,SAAS,OAAO,UAAU,UAAU;AAC7C,iBAAW,CAAC,CAAC,MAAM;AACnB,iBAAW,MAAM;AAAA,IACnB;AAEA,UAAM,QAAQ,kBAAkB;AAAA,MAC9B;AAAA,IACF,CAAQ;AACR,QAAI,CAAC,MAAO,QAAO;AACnB,WAAO,WAAW,MAAM,QAAQ,IAAI,MAAM;AAAA,EAC5C;AAGA,SAAO;AAAA,IACL,CAAC,UAAU,GAAG;AAAA,IACd,CAAC,GAAG,UAAU,OAAO,GAAG;AAAA,EAC1B;AAKF;","names":[]}
|
1
|
+
{"version":3,"sources":["../../../../src/context/react/utils/createContextStoreHook.ts"],"sourcesContent":["import { UseBoundStore } from \"zustand\";\nimport { ReadonlyStore } from \"../../ReadonlyStore\";\n\n/**\n * Creates hooks for accessing a store within a context.\n * @param contextHook - The hook to access the context.\n * @param contextKey - The key of the store in the context.\n * @returns An object containing the hooks: `use...` and `use...Store`.\n */\nexport function createContextStoreHook<T, K extends keyof T & string>(\n contextHook: (options?: { optional?: boolean }) => T | null,\n contextKey: K,\n) {\n type StoreType = T[K];\n type StateType = StoreType extends ReadonlyStore<infer S> ? S : never;\n\n // Define useStoreStoreHook with overloads\n function useStoreStoreHook(): ReadonlyStore<StateType>;\n function useStoreStoreHook(options: {\n optional: true;\n }): ReadonlyStore<StateType> | null;\n function useStoreStoreHook(options?: {\n optional?: boolean;\n }): ReadonlyStore<StateType> | null {\n const context = contextHook(options);\n if (!context) return null;\n return context[contextKey] as ReadonlyStore<StateType>;\n }\n\n // Define useStoreHook with overloads\n function useStoreHook(): StateType;\n function useStoreHook<TSelected>(\n selector: (state: StateType) => TSelected,\n ): TSelected;\n function useStoreHook(options: { optional: true }): StateType | null;\n function useStoreHook<TSelected>(options: {\n optional: true;\n selector?: (state: StateType) => TSelected;\n }): TSelected | null;\n function useStoreHook<TSelected>(\n param?:\n | ((state: StateType) => TSelected)\n | {\n optional?: boolean;\n selector?: (state: StateType) => TSelected;\n },\n ): TSelected | StateType | null {\n let optional = false;\n let selector: ((state: StateType) => TSelected) | undefined;\n\n if (typeof param === \"function\") {\n selector = param;\n } else if (param && typeof param === \"object\") {\n optional = !!param.optional;\n selector = param.selector;\n }\n\n const store = useStoreStoreHook({\n optional,\n } as any) as UseBoundStore<ReadonlyStore<StateType>>;\n if (!store) return null;\n return selector ? store(selector) : store();\n }\n\n // Return an object with keys based on contextKey\n return {\n [contextKey]: useStoreHook,\n [`${contextKey}Store`]: useStoreStoreHook,\n } as {\n [P in K]: typeof useStoreHook;\n } & {\n [P in `${K}Store`]: typeof useStoreStoreHook;\n };\n}\n"],"mappings":";AASO,SAAS,uBACd,aACA,YACA;AASA,WAAS,kBAAkB,SAES;AAClC,UAAM,UAAU,YAAY,OAAO;AACnC,QAAI,CAAC,QAAS,QAAO;AACrB,WAAO,QAAQ,UAAU;AAAA,EAC3B;AAYA,WAAS,aACP,OAM8B;AAC9B,QAAI,WAAW;AACf,QAAI;AAEJ,QAAI,OAAO,UAAU,YAAY;AAC/B,iBAAW;AAAA,IACb,WAAW,SAAS,OAAO,UAAU,UAAU;AAC7C,iBAAW,CAAC,CAAC,MAAM;AACnB,iBAAW,MAAM;AAAA,IACnB;AAEA,UAAM,QAAQ,kBAAkB;AAAA,MAC9B;AAAA,IACF,CAAQ;AACR,QAAI,CAAC,MAAO,QAAO;AACnB,WAAO,WAAW,MAAM,QAAQ,IAAI,MAAM;AAAA,EAC5C;AAGA,SAAO;AAAA,IACL,CAAC,UAAU,GAAG;AAAA,IACd,CAAC,GAAG,UAAU,OAAO,GAAG;AAAA,EAC1B;AAKF;","names":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/context/react/utils/createStateHookForRuntime.ts"],"sourcesContent":["import {\n SubscribableRuntime,\n useRuntimeStateInternal,\n} from \"./useRuntimeState\";\n\nexport function createStateHookForRuntime<TState>(\n useRuntime: (options: {\n optional: boolean | undefined;\n }) => SubscribableRuntime<TState> | null,\n) {\n // empty\n function useStoreHook(): TState;\n\n // selector\n function useStoreHook<TSelected>(\n selector: (state: TState) => TSelected,\n ): TSelected;\n\n // selector?\n function useStoreHook<TSelected>(\n selector: ((state: TState) => TSelected) | undefined,\n ): TSelected | TState;\n\n // optional=false\n function useStoreHook(options: { optional?: false | undefined }): TState;\n\n // optional?\n function useStoreHook(options: {\n optional?: boolean | undefined;\n }): TState | null;\n\n // optional=false, selector\n function useStoreHook<TSelected>(options: {\n optional?: false | undefined;\n selector: (state: TState) => TSelected;\n }): TSelected;\n\n // optional=false, selector?\n function useStoreHook<TSelected>(options: {\n optional?: false | undefined;\n selector: ((state: TState) => TSelected) | undefined;\n }): TSelected | TState;\n\n // optional?, selector\n function useStoreHook<TSelected>(options: {\n optional?: boolean | undefined;\n selector: (state: TState) => TSelected;\n }): TSelected | null;\n\n // optional?, selector?\n function useStoreHook<TSelected>(options: {\n optional?: boolean | undefined;\n selector: ((state: TState) => TSelected) | undefined;\n }): TSelected | TState | null;\n\n function useStoreHook<TSelected>(\n param?:\n | ((state: TState) => TSelected)\n | {\n optional?: boolean | undefined;\n selector?: ((state: TState) => TSelected) | undefined;\n },\n ): TSelected | TState | null {\n let optional = false;\n let selector: ((state: TState) => TSelected) | undefined;\n\n if (typeof param === \"function\") {\n selector = param;\n } else if (param) {\n optional = !!param.optional;\n selector = param.selector;\n }\n\n const store = useRuntime({ optional });\n if (!store) return null;\n\n // it is ok to call useRuntimeStateInternal conditionally because it will never become null if its available\n // eslint-ignore-next-line react-hooks/rules-of-hooks\n return useRuntimeStateInternal(store, selector);\n }\n\n return useStoreHook;\n}\n"],"mappings":"AAAA;AAAA,EAEE;AAAA,OACK;AAEA,SAAS,0BACd,YAGA;AA8CA,WAAS,aACP,OAM2B;AAC3B,QAAI,WAAW;AACf,QAAI;AAEJ,QAAI,OAAO,UAAU,YAAY;AAC/B,iBAAW;AAAA,IACb,WAAW,OAAO;AAChB,iBAAW,CAAC,CAAC,MAAM;AACnB,iBAAW,MAAM;AAAA,IACnB;AAEA,UAAM,QAAQ,WAAW,EAAE,SAAS,CAAC;AACrC,QAAI,CAAC,MAAO,QAAO;AAInB,WAAO,wBAAwB,OAAO,QAAQ;AAAA,EAChD;AAEA,SAAO;AACT;","names":[]}
|
1
|
+
{"version":3,"sources":["../../../../src/context/react/utils/createStateHookForRuntime.ts"],"sourcesContent":["import {\n SubscribableRuntime,\n useRuntimeStateInternal,\n} from \"./useRuntimeState\";\n\nexport function createStateHookForRuntime<TState>(\n useRuntime: (options: {\n optional: boolean | undefined;\n }) => SubscribableRuntime<TState> | null,\n) {\n // empty\n function useStoreHook(): TState;\n\n // selector\n function useStoreHook<TSelected>(\n selector: (state: TState) => TSelected,\n ): TSelected;\n\n // selector?\n function useStoreHook<TSelected>(\n selector: ((state: TState) => TSelected) | undefined,\n ): TSelected | TState;\n\n // optional=false\n function useStoreHook(options: { optional?: false | undefined }): TState;\n\n // optional?\n function useStoreHook(options: {\n optional?: boolean | undefined;\n }): TState | null;\n\n // optional=false, selector\n function useStoreHook<TSelected>(options: {\n optional?: false | undefined;\n selector: (state: TState) => TSelected;\n }): TSelected;\n\n // optional=false, selector?\n function useStoreHook<TSelected>(options: {\n optional?: false | undefined;\n selector: ((state: TState) => TSelected) | undefined;\n }): TSelected | TState;\n\n // optional?, selector\n function useStoreHook<TSelected>(options: {\n optional?: boolean | undefined;\n selector: (state: TState) => TSelected;\n }): TSelected | null;\n\n // optional?, selector?\n function useStoreHook<TSelected>(options: {\n optional?: boolean | undefined;\n selector: ((state: TState) => TSelected) | undefined;\n }): TSelected | TState | null;\n\n function useStoreHook<TSelected>(\n param?:\n | ((state: TState) => TSelected)\n | {\n optional?: boolean | undefined;\n selector?: ((state: TState) => TSelected) | undefined;\n },\n ): TSelected | TState | null {\n let optional = false;\n let selector: ((state: TState) => TSelected) | undefined;\n\n if (typeof param === \"function\") {\n selector = param;\n } else if (param) {\n optional = !!param.optional;\n selector = param.selector;\n }\n\n const store = useRuntime({ optional });\n if (!store) return null;\n\n // it is ok to call useRuntimeStateInternal conditionally because it will never become null if its available\n // eslint-ignore-next-line react-hooks/rules-of-hooks\n return useRuntimeStateInternal(store, selector);\n }\n\n return useStoreHook;\n}\n"],"mappings":";AAAA;AAAA,EAEE;AAAA,OACK;AAEA,SAAS,0BACd,YAGA;AA8CA,WAAS,aACP,OAM2B;AAC3B,QAAI,WAAW;AACf,QAAI;AAEJ,QAAI,OAAO,UAAU,YAAY;AAC/B,iBAAW;AAAA,IACb,WAAW,OAAO;AAChB,iBAAW,CAAC,CAAC,MAAM;AACnB,iBAAW,MAAM;AAAA,IACnB;AAEA,UAAM,QAAQ,WAAW,EAAE,SAAS,CAAC;AACrC,QAAI,CAAC,MAAO,QAAO;AAInB,WAAO,wBAAwB,OAAO,QAAQ;AAAA,EAChD;AAEA,SAAO;AACT;","names":[]}
|
@@ -1,24 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
(methodStr) => {
|
4
|
-
const descriptor = Object.getOwnPropertyDescriptor(prototype, methodStr);
|
5
|
-
const isMethod = descriptor && typeof descriptor.value === "function";
|
6
|
-
if (!isMethod) return false;
|
7
|
-
const methodName = methodStr;
|
8
|
-
return isMethod && !methodName.startsWith("_") && methodName !== "constructor" && prototype[methodName] === runtime[methodName];
|
9
|
-
}
|
10
|
-
);
|
11
|
-
if (unboundMethods.length > 0) {
|
12
|
-
throw new Error(
|
13
|
-
"The following methods are not bound: " + JSON.stringify(unboundMethods)
|
14
|
-
);
|
15
|
-
}
|
16
|
-
const prototypePrototype = Object.getPrototypeOf(prototype);
|
17
|
-
if (prototypePrototype && prototypePrototype !== Object.prototype) {
|
18
|
-
debugVerifyPrototype(runtime, prototypePrototype);
|
19
|
-
}
|
20
|
-
};
|
21
|
-
const ensureBinding = (r) => {
|
1
|
+
// src/context/react/utils/ensureBinding.ts
|
2
|
+
var ensureBinding = (r) => {
|
22
3
|
const runtime = r;
|
23
4
|
if (runtime.__isBound) return;
|
24
5
|
runtime.__internal_bindMethods?.();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/context/react/utils/ensureBinding.ts"],"sourcesContent":["type Bindable = {\n __internal_bindMethods?: () => void;\n __isBound?: boolean;\n};\nconst debugVerifyPrototype = (\n runtime: Record<string, unknown>,\n prototype: any,\n) => {\n const unboundMethods = Object.getOwnPropertyNames(prototype).filter(\n (methodStr) => {\n const descriptor = Object.getOwnPropertyDescriptor(prototype, methodStr);\n const isMethod = descriptor && typeof descriptor.value === \"function\";\n if (!isMethod) return false;\n\n const methodName = methodStr as keyof typeof runtime | \"constructor\";\n return (\n isMethod &&\n !methodName.startsWith(\"_\") &&\n methodName !== \"constructor\" &&\n prototype[methodName] === runtime[methodName]\n );\n },\n );\n\n if (unboundMethods.length > 0) {\n throw new Error(\n \"The following methods are not bound: \" + JSON.stringify(unboundMethods),\n );\n }\n\n const prototypePrototype = Object.getPrototypeOf(prototype);\n if (prototypePrototype && prototypePrototype !== Object.prototype) {\n debugVerifyPrototype(runtime, prototypePrototype);\n }\n};\nexport const ensureBinding = (r: unknown) => {\n const runtime = r as Bindable;\n if (runtime.__isBound) return;\n\n runtime.__internal_bindMethods?.();\n runtime.__isBound = true;\n\n // @ts-expect-error - strip this out in production build\n DEV: debugVerifyPrototype(runtime, Object.getPrototypeOf(runtime));\n};\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../../src/context/react/utils/ensureBinding.ts"],"sourcesContent":["type Bindable = {\n __internal_bindMethods?: () => void;\n __isBound?: boolean;\n};\nconst debugVerifyPrototype = (\n runtime: Record<string, unknown>,\n prototype: any,\n) => {\n const unboundMethods = Object.getOwnPropertyNames(prototype).filter(\n (methodStr) => {\n const descriptor = Object.getOwnPropertyDescriptor(prototype, methodStr);\n const isMethod = descriptor && typeof descriptor.value === \"function\";\n if (!isMethod) return false;\n\n const methodName = methodStr as keyof typeof runtime | \"constructor\";\n return (\n isMethod &&\n !methodName.startsWith(\"_\") &&\n methodName !== \"constructor\" &&\n prototype[methodName] === runtime[methodName]\n );\n },\n );\n\n if (unboundMethods.length > 0) {\n throw new Error(\n \"The following methods are not bound: \" + JSON.stringify(unboundMethods),\n );\n }\n\n const prototypePrototype = Object.getPrototypeOf(prototype);\n if (prototypePrototype && prototypePrototype !== Object.prototype) {\n debugVerifyPrototype(runtime, prototypePrototype);\n }\n};\nexport const ensureBinding = (r: unknown) => {\n const runtime = r as Bindable;\n if (runtime.__isBound) return;\n\n runtime.__internal_bindMethods?.();\n runtime.__isBound = true;\n\n // @ts-expect-error - strip this out in production build\n DEV: debugVerifyPrototype(runtime, Object.getPrototypeOf(runtime));\n};\n"],"mappings":";AAmCO,IAAM,gBAAgB,CAAC,MAAe;AAC3C,QAAM,UAAU;AAChB,MAAI,QAAQ,UAAW;AAEvB,UAAQ,yBAAyB;AACjC,UAAQ,YAAY;AAItB;","names":[]}
|
@@ -1,5 +1,6 @@
|
|
1
|
+
// src/context/react/utils/useRuntimeState.ts
|
1
2
|
import { useDebugValue, useSyncExternalStore } from "react";
|
2
|
-
import { ensureBinding } from "./ensureBinding";
|
3
|
+
import { ensureBinding } from "./ensureBinding.js";
|
3
4
|
function useRuntimeStateInternal(runtime, selector = identity) {
|
4
5
|
ensureBinding(runtime);
|
5
6
|
const slice = useSyncExternalStore(
|
@@ -10,7 +11,7 @@ function useRuntimeStateInternal(runtime, selector = identity) {
|
|
10
11
|
useDebugValue(slice);
|
11
12
|
return slice;
|
12
13
|
}
|
13
|
-
|
14
|
+
var identity = (arg) => arg;
|
14
15
|
function useRuntimeState(runtime, selector) {
|
15
16
|
return useRuntimeStateInternal(runtime, selector);
|
16
17
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/context/react/utils/useRuntimeState.ts"],"sourcesContent":["import { useDebugValue, useSyncExternalStore } from \"react\";\nimport { Unsubscribe } from \"../../../types\";\nimport { ensureBinding } from \"./ensureBinding\";\n\nexport type SubscribableRuntime<TState> = {\n getState: () => TState;\n subscribe: (callback: () => void) => Unsubscribe;\n};\n\nexport function useRuntimeStateInternal<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: ((state: TState) => TSelected | TState) | undefined = identity,\n): TSelected | TState {\n // TODO move to useRuntimeState\n ensureBinding(runtime);\n\n const slice = useSyncExternalStore(\n runtime.subscribe,\n () => selector(runtime.getState()),\n () => selector(runtime.getState()),\n );\n useDebugValue(slice);\n return slice;\n}\n\nconst identity = <T>(arg: T): T => arg;\nexport function useRuntimeState<TState>(\n runtime: SubscribableRuntime<TState>,\n): TState;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: (state: TState) => TSelected,\n): TSelected;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: ((state: TState) => TSelected) | undefined,\n): TSelected | TState;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector?: ((state: TState) => TSelected) | undefined,\n): TSelected | TState {\n // ensure that the runtime is bound\n // ensureBinding(runtime);\n\n return useRuntimeStateInternal(runtime, selector);\n}\n"],"mappings":"AAAA,SAAS,eAAe,4BAA4B;AAEpD,SAAS,qBAAqB;AAOvB,SAAS,wBACd,SACA,WAAgE,UAC5C;AAEpB,gBAAc,OAAO;AAErB,QAAM,QAAQ;AAAA,IACZ,QAAQ;AAAA,IACR,MAAM,SAAS,QAAQ,SAAS,CAAC;AAAA,IACjC,MAAM,SAAS,QAAQ,SAAS,CAAC;AAAA,EACnC;AACA,gBAAc,KAAK;AACnB,SAAO;AACT;AAEA,
|
1
|
+
{"version":3,"sources":["../../../../src/context/react/utils/useRuntimeState.ts"],"sourcesContent":["import { useDebugValue, useSyncExternalStore } from \"react\";\nimport { Unsubscribe } from \"../../../types\";\nimport { ensureBinding } from \"./ensureBinding\";\n\nexport type SubscribableRuntime<TState> = {\n getState: () => TState;\n subscribe: (callback: () => void) => Unsubscribe;\n};\n\nexport function useRuntimeStateInternal<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: ((state: TState) => TSelected | TState) | undefined = identity,\n): TSelected | TState {\n // TODO move to useRuntimeState\n ensureBinding(runtime);\n\n const slice = useSyncExternalStore(\n runtime.subscribe,\n () => selector(runtime.getState()),\n () => selector(runtime.getState()),\n );\n useDebugValue(slice);\n return slice;\n}\n\nconst identity = <T>(arg: T): T => arg;\nexport function useRuntimeState<TState>(\n runtime: SubscribableRuntime<TState>,\n): TState;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: (state: TState) => TSelected,\n): TSelected;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: ((state: TState) => TSelected) | undefined,\n): TSelected | TState;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector?: ((state: TState) => TSelected) | undefined,\n): TSelected | TState {\n // ensure that the runtime is bound\n // ensureBinding(runtime);\n\n return useRuntimeStateInternal(runtime, selector);\n}\n"],"mappings":";AAAA,SAAS,eAAe,4BAA4B;AAEpD,SAAS,qBAAqB;AAOvB,SAAS,wBACd,SACA,WAAgE,UAC5C;AAEpB,gBAAc,OAAO;AAErB,QAAM,QAAQ;AAAA,IACZ,QAAQ;AAAA,IACR,MAAM,SAAS,QAAQ,SAAS,CAAC;AAAA,IACjC,MAAM,SAAS,QAAQ,SAAS,CAAC;AAAA,EACnC;AACA,gBAAc,KAAK;AACnB,SAAO;AACT;AAEA,IAAM,WAAW,CAAI,QAAc;AAY5B,SAAS,gBACd,SACA,UACoB;AAIpB,SAAO,wBAAwB,SAAS,QAAQ;AAClD;","names":[]}
|
@@ -1,5 +1,6 @@
|
|
1
|
+
// src/context/stores/AssistantToolUIs.ts
|
1
2
|
import { create } from "zustand";
|
2
|
-
|
3
|
+
var makeAssistantToolUIsStore = () => create((set) => {
|
3
4
|
const renderers = /* @__PURE__ */ new Map();
|
4
5
|
return Object.freeze({
|
5
6
|
getToolUI: (name) => {
|