@assistant-ui/react 0.5.97 → 0.5.99
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/api/AssistantRuntime.d.ts +4 -4
- package/dist/api/AssistantRuntime.d.ts.map +1 -1
- package/dist/api/AssistantRuntime.js +15 -13
- package/dist/api/AssistantRuntime.js.map +1 -1
- package/dist/api/AssistantRuntime.mjs +14 -15
- package/dist/api/AssistantRuntime.mjs.map +1 -1
- package/dist/api/AttachmentRuntime.js +12 -10
- package/dist/api/AttachmentRuntime.js.map +1 -1
- package/dist/api/AttachmentRuntime.mjs +11 -10
- package/dist/api/AttachmentRuntime.mjs.map +1 -1
- package/dist/api/ComposerRuntime.d.ts +7 -0
- package/dist/api/ComposerRuntime.d.ts.map +1 -1
- package/dist/api/ComposerRuntime.js +29 -14
- package/dist/api/ComposerRuntime.js.map +1 -1
- package/dist/api/ComposerRuntime.mjs +28 -14
- package/dist/api/ComposerRuntime.mjs.map +1 -1
- package/dist/api/ContentPartRuntime.js +4 -2
- package/dist/api/ContentPartRuntime.js.map +1 -1
- package/dist/api/ContentPartRuntime.mjs +3 -2
- package/dist/api/ContentPartRuntime.mjs.map +1 -1
- package/dist/api/MessageRuntime.d.ts.map +1 -1
- package/dist/api/MessageRuntime.js +15 -18
- package/dist/api/MessageRuntime.js.map +1 -1
- package/dist/api/MessageRuntime.mjs +14 -18
- package/dist/api/MessageRuntime.mjs.map +1 -1
- package/dist/api/RuntimePathTypes.d.ts +16 -1
- package/dist/api/RuntimePathTypes.d.ts.map +1 -1
- package/dist/api/RuntimePathTypes.js +2 -0
- package/dist/api/RuntimePathTypes.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.d.ts +29 -0
- package/dist/api/ThreadListItemRuntime.d.ts.map +1 -0
- package/dist/api/ThreadListItemRuntime.js +61 -0
- package/dist/api/ThreadListItemRuntime.js.map +1 -0
- package/dist/api/ThreadListItemRuntime.mjs +36 -0
- package/dist/api/ThreadListItemRuntime.mjs.map +1 -0
- package/dist/api/ThreadListRuntime.d.ts +51 -0
- package/dist/api/ThreadListRuntime.d.ts.map +1 -0
- package/dist/api/ThreadListRuntime.js +128 -0
- package/dist/api/ThreadListRuntime.js.map +1 -0
- package/dist/api/ThreadListRuntime.mjs +105 -0
- package/dist/api/ThreadListRuntime.mjs.map +1 -0
- package/dist/api/ThreadRuntime.d.ts +3 -0
- package/dist/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js +13 -11
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.mjs +12 -11
- package/dist/api/ThreadRuntime.mjs.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/subscribable/BaseSubject.js +4 -2
- package/dist/api/subscribable/BaseSubject.js.map +1 -1
- package/dist/api/subscribable/BaseSubject.mjs +3 -2
- package/dist/api/subscribable/BaseSubject.mjs.map +1 -1
- package/dist/api/subscribable/LazyMemoizeSubject.js +6 -4
- package/dist/api/subscribable/LazyMemoizeSubject.js.map +1 -1
- package/dist/api/subscribable/LazyMemoizeSubject.mjs +5 -4
- package/dist/api/subscribable/LazyMemoizeSubject.mjs.map +1 -1
- package/dist/api/subscribable/NestedSubscriptionSubject.js +5 -3
- package/dist/api/subscribable/NestedSubscriptionSubject.js.map +1 -1
- package/dist/api/subscribable/NestedSubscriptionSubject.mjs +4 -3
- package/dist/api/subscribable/NestedSubscriptionSubject.mjs.map +1 -1
- package/dist/api/subscribable/SKIP_UPDATE.js +3 -1
- package/dist/api/subscribable/SKIP_UPDATE.js.map +1 -1
- package/dist/api/subscribable/SKIP_UPDATE.mjs +2 -1
- package/dist/api/subscribable/SKIP_UPDATE.mjs.map +1 -1
- package/dist/api/subscribable/ShallowMemoizeSubject.js +7 -5
- package/dist/api/subscribable/ShallowMemoizeSubject.js.map +1 -1
- package/dist/api/subscribable/ShallowMemoizeSubject.mjs +6 -5
- package/dist/api/subscribable/ShallowMemoizeSubject.mjs.map +1 -1
- package/dist/api/subscribable/Subscribable.js +2 -0
- package/dist/api/subscribable/Subscribable.js.map +1 -1
- package/dist/api/subscribable/shallowEqual.js +2 -0
- package/dist/api/subscribable/shallowEqual.js.map +1 -1
- package/dist/api/subscribable/shallowEqual.mjs +1 -0
- package/dist/api/subscribable/shallowEqual.mjs.map +1 -1
- package/dist/context/ReadonlyStore.js +3 -1
- package/dist/context/ReadonlyStore.js.map +1 -1
- package/dist/context/ReadonlyStore.mjs +2 -1
- package/dist/context/ReadonlyStore.mjs.map +1 -1
- package/dist/context/index.js +8 -6
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +4 -3
- package/dist/context/index.mjs.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.js +18 -18
- package/dist/context/providers/AssistantRuntimeProvider.js.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.mjs +18 -18
- package/dist/context/providers/AssistantRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/AttachmentRuntimeProvider.d.ts +6 -5
- package/dist/context/providers/AttachmentRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/AttachmentRuntimeProvider.js +8 -6
- package/dist/context/providers/AttachmentRuntimeProvider.js.map +1 -1
- package/dist/context/providers/AttachmentRuntimeProvider.mjs +8 -6
- package/dist/context/providers/AttachmentRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/ContentPartRuntimeProvider.d.ts +6 -5
- package/dist/context/providers/ContentPartRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/ContentPartRuntimeProvider.js +8 -9
- package/dist/context/providers/ContentPartRuntimeProvider.js.map +1 -1
- package/dist/context/providers/ContentPartRuntimeProvider.mjs +8 -9
- package/dist/context/providers/ContentPartRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/MessageRuntimeProvider.d.ts +6 -5
- package/dist/context/providers/MessageRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/MessageRuntimeProvider.js +11 -9
- package/dist/context/providers/MessageRuntimeProvider.js.map +1 -1
- package/dist/context/providers/MessageRuntimeProvider.mjs +11 -9
- package/dist/context/providers/MessageRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/TextContentPartProvider.d.ts +7 -6
- package/dist/context/providers/TextContentPartProvider.d.ts.map +1 -1
- package/dist/context/providers/TextContentPartProvider.js +13 -7
- package/dist/context/providers/TextContentPartProvider.js.map +1 -1
- package/dist/context/providers/TextContentPartProvider.mjs +13 -7
- package/dist/context/providers/TextContentPartProvider.mjs.map +1 -1
- package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts +13 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.js +62 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.js.map +1 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.mjs +39 -0
- package/dist/context/providers/ThreadListItemRuntimeProvider.mjs.map +1 -0
- package/dist/context/providers/ThreadRuntimeProvider.js +11 -9
- package/dist/context/providers/ThreadRuntimeProvider.js.map +1 -1
- package/dist/context/providers/ThreadRuntimeProvider.mjs +10 -9
- package/dist/context/providers/ThreadRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/index.js +4 -2
- package/dist/context/providers/index.js.map +1 -1
- package/dist/context/providers/index.mjs +3 -2
- package/dist/context/providers/index.mjs.map +1 -1
- package/dist/context/react/AssistantContext.d.ts +35 -11
- package/dist/context/react/AssistantContext.d.ts.map +1 -1
- package/dist/context/react/AssistantContext.js +15 -13
- package/dist/context/react/AssistantContext.js.map +1 -1
- package/dist/context/react/AssistantContext.mjs +14 -12
- package/dist/context/react/AssistantContext.mjs.map +1 -1
- package/dist/context/react/AttachmentContext.js +8 -6
- package/dist/context/react/AttachmentContext.js.map +1 -1
- package/dist/context/react/AttachmentContext.mjs +8 -6
- package/dist/context/react/AttachmentContext.mjs.map +1 -1
- package/dist/context/react/ComposerContext.js +7 -5
- package/dist/context/react/ComposerContext.js.map +1 -1
- package/dist/context/react/ComposerContext.mjs +6 -5
- package/dist/context/react/ComposerContext.mjs.map +1 -1
- package/dist/context/react/ContentPartContext.js +7 -5
- package/dist/context/react/ContentPartContext.js.map +1 -1
- package/dist/context/react/ContentPartContext.mjs +7 -5
- package/dist/context/react/ContentPartContext.mjs.map +1 -1
- package/dist/context/react/MessageContext.js +9 -7
- package/dist/context/react/MessageContext.js.map +1 -1
- package/dist/context/react/MessageContext.mjs +9 -7
- package/dist/context/react/MessageContext.mjs.map +1 -1
- package/dist/context/react/ThreadContext.js +16 -14
- package/dist/context/react/ThreadContext.js.map +1 -1
- package/dist/context/react/ThreadContext.mjs +16 -14
- package/dist/context/react/ThreadContext.mjs.map +1 -1
- package/dist/context/react/ThreadListItemContext.d.ts +58 -0
- package/dist/context/react/ThreadListItemContext.d.ts.map +1 -0
- package/dist/context/react/ThreadListItemContext.js +53 -0
- package/dist/context/react/ThreadListItemContext.js.map +1 -0
- package/dist/context/react/ThreadListItemContext.mjs +25 -0
- package/dist/context/react/ThreadListItemContext.mjs.map +1 -0
- package/dist/context/react/index.d.ts +1 -1
- package/dist/context/react/index.d.ts.map +1 -1
- package/dist/context/react/index.js +10 -8
- package/dist/context/react/index.js.map +1 -1
- package/dist/context/react/index.mjs +9 -8
- package/dist/context/react/index.mjs.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/createContextHook.mjs +1 -0
- package/dist/context/react/utils/createContextHook.mjs.map +1 -1
- package/dist/context/react/utils/createContextStoreHook.js +2 -0
- package/dist/context/react/utils/createContextStoreHook.js.map +1 -1
- package/dist/context/react/utils/createContextStoreHook.mjs +1 -0
- package/dist/context/react/utils/createContextStoreHook.mjs.map +1 -1
- package/dist/context/stores/AssistantToolUIs.js +3 -1
- package/dist/context/stores/AssistantToolUIs.js.map +1 -1
- package/dist/context/stores/AssistantToolUIs.mjs +3 -1
- package/dist/context/stores/AssistantToolUIs.mjs.map +1 -1
- package/dist/context/stores/MessageUtils.js +3 -1
- package/dist/context/stores/MessageUtils.js.map +1 -1
- package/dist/context/stores/MessageUtils.mjs +2 -1
- package/dist/context/stores/MessageUtils.mjs.map +1 -1
- package/dist/context/stores/ThreadViewport.js +3 -1
- package/dist/context/stores/ThreadViewport.js.map +1 -1
- package/dist/context/stores/ThreadViewport.mjs +3 -1
- package/dist/context/stores/ThreadViewport.mjs.map +1 -1
- package/dist/context/stores/index.js +2 -0
- package/dist/context/stores/index.js.map +1 -1
- package/dist/edge.js +3 -1
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +2 -1
- package/dist/edge.mjs.map +1 -1
- package/dist/hooks/index.js +4 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +3 -2
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/useAppendMessage.js +4 -2
- package/dist/hooks/useAppendMessage.js.map +1 -1
- package/dist/hooks/useAppendMessage.mjs +3 -2
- package/dist/hooks/useAppendMessage.mjs.map +1 -1
- package/dist/hooks/useSwitchToNewThread.js +4 -2
- package/dist/hooks/useSwitchToNewThread.js.map +1 -1
- package/dist/hooks/useSwitchToNewThread.mjs +3 -2
- package/dist/hooks/useSwitchToNewThread.mjs.map +1 -1
- package/dist/index.js +21 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -10
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +12 -10
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +10 -9
- package/dist/internal.mjs.map +1 -1
- package/dist/model-config/index.js +8 -6
- package/dist/model-config/index.js.map +1 -1
- package/dist/model-config/index.mjs +7 -6
- package/dist/model-config/index.mjs.map +1 -1
- package/dist/model-config/makeAssistantTool.js +4 -2
- package/dist/model-config/makeAssistantTool.js.map +1 -1
- package/dist/model-config/makeAssistantTool.mjs +4 -2
- package/dist/model-config/makeAssistantTool.mjs.map +1 -1
- package/dist/model-config/makeAssistantToolUI.js +4 -2
- package/dist/model-config/makeAssistantToolUI.js.map +1 -1
- package/dist/model-config/makeAssistantToolUI.mjs +4 -2
- package/dist/model-config/makeAssistantToolUI.mjs.map +1 -1
- package/dist/model-config/useAssistantInstructions.js +4 -2
- package/dist/model-config/useAssistantInstructions.js.map +1 -1
- package/dist/model-config/useAssistantInstructions.mjs +4 -2
- package/dist/model-config/useAssistantInstructions.mjs.map +1 -1
- package/dist/model-config/useAssistantTool.js +4 -2
- package/dist/model-config/useAssistantTool.js.map +1 -1
- package/dist/model-config/useAssistantTool.mjs +4 -2
- package/dist/model-config/useAssistantTool.mjs.map +1 -1
- package/dist/model-config/useAssistantToolUI.js +4 -2
- package/dist/model-config/useAssistantToolUI.js.map +1 -1
- package/dist/model-config/useAssistantToolUI.mjs +4 -2
- package/dist/model-config/useAssistantToolUI.mjs.map +1 -1
- package/dist/model-config/useInlineRender.js +3 -1
- package/dist/model-config/useInlineRender.js.map +1 -1
- package/dist/model-config/useInlineRender.mjs +2 -1
- package/dist/model-config/useInlineRender.mjs.map +1 -1
- package/dist/primitive-hooks/actionBar/index.js +9 -7
- package/dist/primitive-hooks/actionBar/index.js.map +1 -1
- package/dist/primitive-hooks/actionBar/index.mjs +8 -7
- package/dist/primitive-hooks/actionBar/index.mjs.map +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarCopy.js +5 -3
- package/dist/primitive-hooks/actionBar/useActionBarCopy.js.map +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarCopy.mjs +4 -3
- package/dist/primitive-hooks/actionBar/useActionBarCopy.mjs.map +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarEdit.js +4 -2
- package/dist/primitive-hooks/actionBar/useActionBarEdit.js.map +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarEdit.mjs +3 -2
- package/dist/primitive-hooks/actionBar/useActionBarEdit.mjs.map +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarFeedbackNegative.js +4 -2
- package/dist/primitive-hooks/actionBar/useActionBarFeedbackNegative.js.map +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarFeedbackNegative.mjs +3 -2
- package/dist/primitive-hooks/actionBar/useActionBarFeedbackNegative.mjs.map +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarFeedbackPositive.js +4 -2
- package/dist/primitive-hooks/actionBar/useActionBarFeedbackPositive.js.map +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarFeedbackPositive.mjs +3 -2
- package/dist/primitive-hooks/actionBar/useActionBarFeedbackPositive.mjs.map +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarReload.js +6 -4
- package/dist/primitive-hooks/actionBar/useActionBarReload.js.map +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarReload.mjs +5 -4
- package/dist/primitive-hooks/actionBar/useActionBarReload.mjs.map +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarSpeak.js +4 -2
- package/dist/primitive-hooks/actionBar/useActionBarSpeak.js.map +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarSpeak.mjs +3 -2
- package/dist/primitive-hooks/actionBar/useActionBarSpeak.mjs.map +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarStopSpeaking.js +4 -2
- package/dist/primitive-hooks/actionBar/useActionBarStopSpeaking.js.map +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarStopSpeaking.mjs +3 -2
- package/dist/primitive-hooks/actionBar/useActionBarStopSpeaking.mjs.map +1 -1
- package/dist/primitive-hooks/attachment/useAttachmentRemove.js +4 -2
- package/dist/primitive-hooks/attachment/useAttachmentRemove.js.map +1 -1
- package/dist/primitive-hooks/attachment/useAttachmentRemove.mjs +3 -2
- package/dist/primitive-hooks/attachment/useAttachmentRemove.mjs.map +1 -1
- package/dist/primitive-hooks/branchPicker/index.js +6 -4
- package/dist/primitive-hooks/branchPicker/index.js.map +1 -1
- package/dist/primitive-hooks/branchPicker/index.mjs +5 -4
- package/dist/primitive-hooks/branchPicker/index.mjs.map +1 -1
- package/dist/primitive-hooks/branchPicker/useBranchPickerCount.js +4 -2
- package/dist/primitive-hooks/branchPicker/useBranchPickerCount.js.map +1 -1
- package/dist/primitive-hooks/branchPicker/useBranchPickerCount.mjs +4 -2
- package/dist/primitive-hooks/branchPicker/useBranchPickerCount.mjs.map +1 -1
- package/dist/primitive-hooks/branchPicker/useBranchPickerNext.js +4 -2
- package/dist/primitive-hooks/branchPicker/useBranchPickerNext.js.map +1 -1
- package/dist/primitive-hooks/branchPicker/useBranchPickerNext.mjs +3 -2
- package/dist/primitive-hooks/branchPicker/useBranchPickerNext.mjs.map +1 -1
- package/dist/primitive-hooks/branchPicker/useBranchPickerNumber.js +4 -2
- package/dist/primitive-hooks/branchPicker/useBranchPickerNumber.js.map +1 -1
- package/dist/primitive-hooks/branchPicker/useBranchPickerNumber.mjs +4 -2
- package/dist/primitive-hooks/branchPicker/useBranchPickerNumber.mjs.map +1 -1
- package/dist/primitive-hooks/branchPicker/useBranchPickerPrevious.js +4 -2
- package/dist/primitive-hooks/branchPicker/useBranchPickerPrevious.js.map +1 -1
- package/dist/primitive-hooks/branchPicker/useBranchPickerPrevious.mjs +3 -2
- package/dist/primitive-hooks/branchPicker/useBranchPickerPrevious.mjs.map +1 -1
- package/dist/primitive-hooks/composer/index.js +6 -4
- package/dist/primitive-hooks/composer/index.js.map +1 -1
- package/dist/primitive-hooks/composer/index.mjs +5 -4
- package/dist/primitive-hooks/composer/index.mjs.map +1 -1
- package/dist/primitive-hooks/composer/useComposerAddAttachment.js +4 -2
- package/dist/primitive-hooks/composer/useComposerAddAttachment.js.map +1 -1
- package/dist/primitive-hooks/composer/useComposerAddAttachment.mjs +3 -2
- package/dist/primitive-hooks/composer/useComposerAddAttachment.mjs.map +1 -1
- package/dist/primitive-hooks/composer/useComposerCancel.js +4 -2
- package/dist/primitive-hooks/composer/useComposerCancel.js.map +1 -1
- package/dist/primitive-hooks/composer/useComposerCancel.mjs +3 -2
- package/dist/primitive-hooks/composer/useComposerCancel.mjs.map +1 -1
- package/dist/primitive-hooks/composer/useComposerIf.js +4 -2
- package/dist/primitive-hooks/composer/useComposerIf.js.map +1 -1
- package/dist/primitive-hooks/composer/useComposerIf.mjs +4 -2
- package/dist/primitive-hooks/composer/useComposerIf.mjs.map +1 -1
- package/dist/primitive-hooks/composer/useComposerSend.js +6 -4
- package/dist/primitive-hooks/composer/useComposerSend.js.map +1 -1
- package/dist/primitive-hooks/composer/useComposerSend.mjs +5 -4
- package/dist/primitive-hooks/composer/useComposerSend.mjs.map +1 -1
- package/dist/primitive-hooks/contentPart/index.js +5 -3
- package/dist/primitive-hooks/contentPart/index.js.map +1 -1
- package/dist/primitive-hooks/contentPart/index.mjs +4 -3
- package/dist/primitive-hooks/contentPart/index.mjs.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.js +4 -2
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.js.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.mjs +3 -2
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.mjs.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartImage.js +4 -2
- package/dist/primitive-hooks/contentPart/useContentPartImage.js.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartImage.mjs +3 -2
- package/dist/primitive-hooks/contentPart/useContentPartImage.mjs.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartText.js +4 -2
- package/dist/primitive-hooks/contentPart/useContentPartText.js.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartText.mjs +3 -2
- package/dist/primitive-hooks/contentPart/useContentPartText.mjs.map +1 -1
- package/dist/primitive-hooks/index.js +14 -12
- package/dist/primitive-hooks/index.js.map +1 -1
- package/dist/primitive-hooks/index.mjs +7 -6
- package/dist/primitive-hooks/index.mjs.map +1 -1
- package/dist/primitive-hooks/message/index.js +3 -1
- package/dist/primitive-hooks/message/index.js.map +1 -1
- package/dist/primitive-hooks/message/index.mjs +2 -1
- package/dist/primitive-hooks/message/index.mjs.map +1 -1
- package/dist/primitive-hooks/message/useMessageIf.js +5 -3
- package/dist/primitive-hooks/message/useMessageIf.js.map +1 -1
- package/dist/primitive-hooks/message/useMessageIf.mjs +5 -3
- package/dist/primitive-hooks/message/useMessageIf.mjs.map +1 -1
- package/dist/primitive-hooks/thread/index.js +6 -4
- package/dist/primitive-hooks/thread/index.js.map +1 -1
- package/dist/primitive-hooks/thread/index.mjs +5 -4
- package/dist/primitive-hooks/thread/index.mjs.map +1 -1
- package/dist/primitive-hooks/thread/useThreadEmpty.js +4 -2
- package/dist/primitive-hooks/thread/useThreadEmpty.js.map +1 -1
- package/dist/primitive-hooks/thread/useThreadEmpty.mjs +3 -2
- package/dist/primitive-hooks/thread/useThreadEmpty.mjs.map +1 -1
- package/dist/primitive-hooks/thread/useThreadIf.js +4 -2
- package/dist/primitive-hooks/thread/useThreadIf.js.map +1 -1
- package/dist/primitive-hooks/thread/useThreadIf.mjs +4 -2
- package/dist/primitive-hooks/thread/useThreadIf.mjs.map +1 -1
- package/dist/primitive-hooks/thread/useThreadScrollToBottom.js +5 -3
- package/dist/primitive-hooks/thread/useThreadScrollToBottom.js.map +1 -1
- package/dist/primitive-hooks/thread/useThreadScrollToBottom.mjs +4 -3
- package/dist/primitive-hooks/thread/useThreadScrollToBottom.mjs.map +1 -1
- package/dist/primitive-hooks/thread/useThreadSuggestion.js +5 -3
- package/dist/primitive-hooks/thread/useThreadSuggestion.js.map +1 -1
- package/dist/primitive-hooks/thread/useThreadSuggestion.mjs +4 -3
- package/dist/primitive-hooks/thread/useThreadSuggestion.mjs.map +1 -1
- package/dist/primitive-hooks/thread/useThreadViewportAutoScroll.js +8 -6
- package/dist/primitive-hooks/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/primitive-hooks/thread/useThreadViewportAutoScroll.mjs +8 -6
- package/dist/primitive-hooks/thread/useThreadViewportAutoScroll.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js +6 -4
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.mjs +6 -4
- package/dist/primitives/actionBar/ActionBarCopy.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js +5 -3
- package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.mjs +5 -3
- package/dist/primitives/actionBar/ActionBarEdit.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +6 -4
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.mjs +6 -4
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +6 -4
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.mjs +6 -4
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.js +5 -3
- package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.mjs +5 -3
- package/dist/primitives/actionBar/ActionBarReload.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.js +5 -3
- package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.mjs +5 -3
- package/dist/primitives/actionBar/ActionBarRoot.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.js +5 -3
- package/dist/primitives/actionBar/ActionBarSpeak.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.mjs +5 -3
- package/dist/primitives/actionBar/ActionBarSpeak.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js +5 -3
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.mjs +5 -3
- package/dist/primitives/actionBar/ActionBarStopSpeaking.mjs.map +1 -1
- package/dist/primitives/actionBar/index.js +10 -8
- package/dist/primitives/actionBar/index.js.map +1 -1
- package/dist/primitives/actionBar/index.mjs +9 -8
- package/dist/primitives/actionBar/index.mjs.map +1 -1
- package/dist/primitives/actionBar/types.js +2 -0
- package/dist/primitives/actionBar/types.js.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.js +6 -4
- package/dist/primitives/actionBar/useActionBarFloatStatus.js.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.mjs +6 -4
- package/dist/primitives/actionBar/useActionBarFloatStatus.mjs.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.js +5 -3
- package/dist/primitives/assistantModal/AssistantModalAnchor.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.mjs +5 -3
- package/dist/primitives/assistantModal/AssistantModalAnchor.mjs.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js +5 -3
- package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.mjs +5 -3
- package/dist/primitives/assistantModal/AssistantModalContent.mjs.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.js +7 -5
- package/dist/primitives/assistantModal/AssistantModalRoot.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.mjs +7 -5
- package/dist/primitives/assistantModal/AssistantModalRoot.mjs.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.js +5 -3
- package/dist/primitives/assistantModal/AssistantModalTrigger.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.mjs +5 -3
- package/dist/primitives/assistantModal/AssistantModalTrigger.mjs.map +1 -1
- package/dist/primitives/assistantModal/index.js +6 -4
- package/dist/primitives/assistantModal/index.js.map +1 -1
- package/dist/primitives/assistantModal/index.mjs +5 -4
- package/dist/primitives/assistantModal/index.mjs.map +1 -1
- package/dist/primitives/assistantModal/scope.js +3 -1
- package/dist/primitives/assistantModal/scope.js.map +1 -1
- package/dist/primitives/assistantModal/scope.mjs +2 -1
- package/dist/primitives/assistantModal/scope.mjs.map +1 -1
- package/dist/primitives/assistantModal/types.js +2 -0
- package/dist/primitives/assistantModal/types.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/AttachmentName.mjs +4 -2
- package/dist/primitives/attachment/AttachmentName.mjs.map +1 -1
- package/dist/primitives/attachment/AttachmentRemove.js +5 -3
- package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRemove.mjs +5 -3
- package/dist/primitives/attachment/AttachmentRemove.mjs.map +1 -1
- package/dist/primitives/attachment/AttachmentRoot.js +4 -2
- package/dist/primitives/attachment/AttachmentRoot.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRoot.mjs +3 -2
- package/dist/primitives/attachment/AttachmentRoot.mjs.map +1 -1
- package/dist/primitives/attachment/AttachmentThumb.js +5 -3
- package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
- package/dist/primitives/attachment/AttachmentThumb.mjs +5 -3
- package/dist/primitives/attachment/AttachmentThumb.mjs.map +1 -1
- package/dist/primitives/attachment/index.js +6 -4
- package/dist/primitives/attachment/index.js.map +1 -1
- package/dist/primitives/attachment/index.mjs +5 -4
- package/dist/primitives/attachment/index.mjs.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.js +4 -2
- package/dist/primitives/branchPicker/BranchPickerCount.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.mjs +4 -2
- package/dist/primitives/branchPicker/BranchPickerCount.mjs.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js +5 -3
- package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.mjs +5 -3
- package/dist/primitives/branchPicker/BranchPickerNext.mjs.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.js +4 -2
- package/dist/primitives/branchPicker/BranchPickerNumber.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.mjs +4 -2
- package/dist/primitives/branchPicker/BranchPickerNumber.mjs.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js +5 -3
- package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.mjs +5 -3
- package/dist/primitives/branchPicker/BranchPickerPrevious.mjs.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js +5 -3
- package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.mjs +5 -3
- package/dist/primitives/branchPicker/BranchPickerRoot.mjs.map +1 -1
- package/dist/primitives/branchPicker/index.js +7 -5
- package/dist/primitives/branchPicker/index.js.map +1 -1
- package/dist/primitives/branchPicker/index.mjs +6 -5
- package/dist/primitives/branchPicker/index.mjs.map +1 -1
- package/dist/primitives/branchPicker/types.js +2 -0
- package/dist/primitives/branchPicker/types.js.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +5 -3
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.mjs +5 -3
- package/dist/primitives/composer/ComposerAddAttachment.mjs.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.js +11 -9
- package/dist/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.mjs +11 -9
- package/dist/primitives/composer/ComposerAttachments.mjs.map +1 -1
- package/dist/primitives/composer/ComposerCancel.js +5 -3
- package/dist/primitives/composer/ComposerCancel.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.mjs +5 -3
- package/dist/primitives/composer/ComposerCancel.mjs.map +1 -1
- package/dist/primitives/composer/ComposerIf.js +4 -2
- package/dist/primitives/composer/ComposerIf.js.map +1 -1
- package/dist/primitives/composer/ComposerIf.mjs +4 -2
- package/dist/primitives/composer/ComposerIf.mjs.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +7 -5
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.mjs +7 -5
- package/dist/primitives/composer/ComposerInput.mjs.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js +5 -3
- package/dist/primitives/composer/ComposerRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerRoot.mjs +5 -3
- package/dist/primitives/composer/ComposerRoot.mjs.map +1 -1
- package/dist/primitives/composer/ComposerSend.js +5 -3
- package/dist/primitives/composer/ComposerSend.js.map +1 -1
- package/dist/primitives/composer/ComposerSend.mjs +5 -3
- package/dist/primitives/composer/ComposerSend.mjs.map +1 -1
- package/dist/primitives/composer/index.js +9 -7
- package/dist/primitives/composer/index.js.map +1 -1
- package/dist/primitives/composer/index.mjs +8 -7
- package/dist/primitives/composer/index.mjs.map +1 -1
- package/dist/primitives/composer/types.js +2 -0
- package/dist/primitives/composer/types.js.map +1 -1
- package/dist/primitives/contentPart/ContentPartDisplay.js +4 -2
- package/dist/primitives/contentPart/ContentPartDisplay.js.map +1 -1
- package/dist/primitives/contentPart/ContentPartDisplay.mjs +3 -2
- package/dist/primitives/contentPart/ContentPartDisplay.mjs.map +1 -1
- package/dist/primitives/contentPart/ContentPartImage.js +5 -3
- package/dist/primitives/contentPart/ContentPartImage.js.map +1 -1
- package/dist/primitives/contentPart/ContentPartImage.mjs +4 -3
- package/dist/primitives/contentPart/ContentPartImage.mjs.map +1 -1
- package/dist/primitives/contentPart/ContentPartInProgress.js +4 -2
- package/dist/primitives/contentPart/ContentPartInProgress.js.map +1 -1
- package/dist/primitives/contentPart/ContentPartInProgress.mjs +3 -2
- package/dist/primitives/contentPart/ContentPartInProgress.mjs.map +1 -1
- package/dist/primitives/contentPart/ContentPartText.js +6 -4
- package/dist/primitives/contentPart/ContentPartText.js.map +1 -1
- package/dist/primitives/contentPart/ContentPartText.mjs +6 -4
- package/dist/primitives/contentPart/ContentPartText.mjs.map +1 -1
- package/dist/primitives/contentPart/index.js +6 -4
- package/dist/primitives/contentPart/index.js.map +1 -1
- package/dist/primitives/contentPart/index.mjs +5 -4
- package/dist/primitives/contentPart/index.mjs.map +1 -1
- package/dist/primitives/contentPart/types.js +2 -0
- package/dist/primitives/contentPart/types.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +16 -8
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/index.mjs +13 -8
- package/dist/primitives/index.mjs.map +1 -1
- package/dist/primitives/message/MessageAttachments.js +11 -9
- package/dist/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/primitives/message/MessageAttachments.mjs +11 -9
- package/dist/primitives/message/MessageAttachments.mjs.map +1 -1
- package/dist/primitives/message/MessageContent.js +17 -15
- package/dist/primitives/message/MessageContent.js.map +1 -1
- package/dist/primitives/message/MessageContent.mjs +17 -15
- package/dist/primitives/message/MessageContent.mjs.map +1 -1
- package/dist/primitives/message/MessageIf.js +4 -2
- package/dist/primitives/message/MessageIf.js.map +1 -1
- package/dist/primitives/message/MessageIf.mjs +4 -2
- package/dist/primitives/message/MessageIf.mjs.map +1 -1
- package/dist/primitives/message/MessageInProgress.js +3 -1
- package/dist/primitives/message/MessageInProgress.js.map +1 -1
- package/dist/primitives/message/MessageInProgress.mjs +3 -1
- package/dist/primitives/message/MessageInProgress.mjs.map +1 -1
- package/dist/primitives/message/MessageRoot.js +7 -5
- package/dist/primitives/message/MessageRoot.js.map +1 -1
- package/dist/primitives/message/MessageRoot.mjs +7 -5
- package/dist/primitives/message/MessageRoot.mjs.map +1 -1
- package/dist/primitives/message/index.js +7 -5
- package/dist/primitives/message/index.js.map +1 -1
- package/dist/primitives/message/index.mjs +6 -5
- package/dist/primitives/message/index.mjs.map +1 -1
- package/dist/primitives/message/types.js +2 -0
- package/dist/primitives/message/types.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/ThreadEmpty.mjs +4 -2
- package/dist/primitives/thread/ThreadEmpty.mjs.map +1 -1
- package/dist/primitives/thread/ThreadIf.js +4 -2
- package/dist/primitives/thread/ThreadIf.js.map +1 -1
- package/dist/primitives/thread/ThreadIf.mjs +4 -2
- package/dist/primitives/thread/ThreadIf.mjs.map +1 -1
- package/dist/primitives/thread/ThreadMessages.js +14 -12
- package/dist/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/primitives/thread/ThreadMessages.mjs +14 -12
- package/dist/primitives/thread/ThreadMessages.mjs.map +1 -1
- package/dist/primitives/thread/ThreadRoot.js +4 -2
- package/dist/primitives/thread/ThreadRoot.js.map +1 -1
- package/dist/primitives/thread/ThreadRoot.mjs +4 -2
- package/dist/primitives/thread/ThreadRoot.mjs.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.js +5 -3
- package/dist/primitives/thread/ThreadScrollToBottom.js.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.mjs +5 -3
- package/dist/primitives/thread/ThreadScrollToBottom.mjs.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.js +5 -3
- package/dist/primitives/thread/ThreadSuggestion.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.mjs +5 -3
- package/dist/primitives/thread/ThreadSuggestion.mjs.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js +5 -3
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/thread/ThreadViewport.mjs +5 -3
- package/dist/primitives/thread/ThreadViewport.mjs.map +1 -1
- package/dist/primitives/thread/index.js +9 -7
- package/dist/primitives/thread/index.js.map +1 -1
- package/dist/primitives/thread/index.mjs +8 -7
- package/dist/primitives/thread/index.mjs.map +1 -1
- package/dist/primitives/thread/types.js +2 -0
- package/dist/primitives/thread/types.js.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.d.ts +11 -0
- package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -0
- package/dist/primitives/threadList/ThreadListItems.js +72 -0
- package/dist/primitives/threadList/ThreadListItems.js.map +1 -0
- package/dist/primitives/threadList/ThreadListItems.mjs +48 -0
- package/dist/primitives/threadList/ThreadListItems.mjs.map +1 -0
- package/dist/primitives/threadList/ThreadListNew.d.ts +13 -0
- package/dist/primitives/threadList/ThreadListNew.d.ts.map +1 -0
- package/dist/primitives/threadList/ThreadListNew.js +43 -0
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -0
- package/dist/primitives/threadList/ThreadListNew.mjs +21 -0
- package/dist/primitives/threadList/ThreadListNew.mjs.map +1 -0
- package/dist/primitives/threadList/index.d.ts +3 -0
- package/dist/primitives/threadList/index.d.ts.map +1 -0
- package/dist/primitives/threadList/index.js +34 -0
- package/dist/primitives/threadList/index.js.map +1 -0
- package/dist/primitives/threadList/index.mjs +8 -0
- package/dist/primitives/threadList/index.mjs.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts +13 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.js +43 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.mjs +21 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.mjs.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts +13 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.js +43 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.js.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.mjs +21 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.mjs.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts +13 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js +43 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.mjs +21 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.mjs.map +1 -0
- package/dist/primitives/threadListItem/index.d.ts +4 -0
- package/dist/primitives/threadListItem/index.d.ts.map +1 -0
- package/dist/primitives/threadListItem/index.js +37 -0
- package/dist/primitives/threadListItem/index.js.map +1 -0
- package/dist/primitives/threadListItem/index.mjs +10 -0
- package/dist/primitives/threadListItem/index.mjs.map +1 -0
- package/dist/runtimes/attachment/AttachmentAdapter.js +2 -0
- package/dist/runtimes/attachment/AttachmentAdapter.js.map +1 -1
- package/dist/runtimes/attachment/CompositeAttachmentAdapter.js +4 -2
- package/dist/runtimes/attachment/CompositeAttachmentAdapter.js.map +1 -1
- package/dist/runtimes/attachment/CompositeAttachmentAdapter.mjs +3 -2
- package/dist/runtimes/attachment/CompositeAttachmentAdapter.mjs.map +1 -1
- package/dist/runtimes/attachment/SimpleImageAttachmentAdapter.js +5 -3
- package/dist/runtimes/attachment/SimpleImageAttachmentAdapter.js.map +1 -1
- package/dist/runtimes/attachment/SimpleImageAttachmentAdapter.mjs +4 -3
- package/dist/runtimes/attachment/SimpleImageAttachmentAdapter.mjs.map +1 -1
- package/dist/runtimes/attachment/SimpleTextAttachmentAdapter.js +5 -3
- package/dist/runtimes/attachment/SimpleTextAttachmentAdapter.js.map +1 -1
- package/dist/runtimes/attachment/SimpleTextAttachmentAdapter.mjs +4 -3
- package/dist/runtimes/attachment/SimpleTextAttachmentAdapter.mjs.map +1 -1
- package/dist/runtimes/attachment/index.js +5 -3
- package/dist/runtimes/attachment/index.js.map +1 -1
- package/dist/runtimes/attachment/index.mjs +4 -3
- package/dist/runtimes/attachment/index.mjs.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts +5 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js +19 -8
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs +18 -8
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +8 -5
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs +7 -5
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js +5 -3
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.mjs +4 -3
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/AssistantRuntimeCore.d.ts +2 -2
- package/dist/runtimes/core/AssistantRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/AssistantRuntimeCore.js +2 -0
- package/dist/runtimes/core/AssistantRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.d.ts +2 -2
- package/dist/runtimes/core/BaseAssistantRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.js +5 -3
- package/dist/runtimes/core/BaseAssistantRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.mjs +4 -3
- package/dist/runtimes/core/BaseAssistantRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.js +8 -6
- package/dist/runtimes/core/BaseThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.mjs +7 -6
- package/dist/runtimes/core/BaseThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/ComposerRuntimeCore.d.ts +3 -0
- package/dist/runtimes/core/ComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ComposerRuntimeCore.js +2 -0
- package/dist/runtimes/core/ComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/{ThreadManagerRuntimeCore.d.ts → ThreadListRuntimeCore.d.ts} +7 -6
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts.map +1 -0
- package/dist/runtimes/core/{ThreadManagerRuntimeCore.js → ThreadListRuntimeCore.js} +5 -3
- package/dist/runtimes/core/ThreadListRuntimeCore.js.map +1 -0
- package/dist/runtimes/core/ThreadListRuntimeCore.mjs +1 -0
- package/dist/runtimes/core/ThreadRuntimeCore.js +2 -0
- package/dist/runtimes/core/ThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/index.js +3 -1
- package/dist/runtimes/core/index.js.map +1 -1
- package/dist/runtimes/core/index.mjs +2 -1
- package/dist/runtimes/core/index.mjs.map +1 -1
- package/dist/runtimes/core/subscribeToMainThread.js +5 -3
- package/dist/runtimes/core/subscribeToMainThread.js.map +1 -1
- package/dist/runtimes/core/subscribeToMainThread.mjs +4 -3
- package/dist/runtimes/core/subscribeToMainThread.mjs.map +1 -1
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.js +10 -8
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.js.map +1 -1
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.mjs +9 -8
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.mjs.map +1 -1
- package/dist/runtimes/dangerous-in-browser/index.js +3 -1
- package/dist/runtimes/dangerous-in-browser/index.js.map +1 -1
- package/dist/runtimes/dangerous-in-browser/index.mjs +2 -1
- package/dist/runtimes/dangerous-in-browser/index.mjs.map +1 -1
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.js +6 -4
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.js.map +1 -1
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.mjs +5 -4
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.mjs.map +1 -1
- package/dist/runtimes/edge/EdgeChatAdapter.js +11 -9
- package/dist/runtimes/edge/EdgeChatAdapter.js.map +1 -1
- package/dist/runtimes/edge/EdgeChatAdapter.mjs +10 -9
- package/dist/runtimes/edge/EdgeChatAdapter.mjs.map +1 -1
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.js +13 -11
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.js.map +1 -1
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.mjs +12 -11
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.mjs.map +1 -1
- package/dist/runtimes/edge/converters/fromCoreMessage.js +5 -3
- package/dist/runtimes/edge/converters/fromCoreMessage.js.map +1 -1
- package/dist/runtimes/edge/converters/fromCoreMessage.mjs +4 -3
- package/dist/runtimes/edge/converters/fromCoreMessage.mjs.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.js +3 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.mjs +2 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.mjs.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelTools.js +3 -1
- package/dist/runtimes/edge/converters/fromLanguageModelTools.js.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelTools.mjs +2 -1
- package/dist/runtimes/edge/converters/fromLanguageModelTools.mjs.map +1 -1
- package/dist/runtimes/edge/converters/index.js +8 -6
- package/dist/runtimes/edge/converters/index.js.map +1 -1
- package/dist/runtimes/edge/converters/index.mjs +7 -6
- package/dist/runtimes/edge/converters/index.mjs.map +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.js +4 -2
- package/dist/runtimes/edge/converters/toCoreMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.mjs +3 -2
- package/dist/runtimes/edge/converters/toCoreMessages.mjs.map +1 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.js +3 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs +2 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs.map +1 -1
- package/dist/runtimes/edge/converters/toLanguageModelTools.js +3 -1
- package/dist/runtimes/edge/converters/toLanguageModelTools.js.map +1 -1
- package/dist/runtimes/edge/converters/toLanguageModelTools.mjs +2 -1
- package/dist/runtimes/edge/converters/toLanguageModelTools.mjs.map +1 -1
- package/dist/runtimes/edge/createEdgeRuntimeAPI.js +15 -13
- package/dist/runtimes/edge/createEdgeRuntimeAPI.js.map +1 -1
- package/dist/runtimes/edge/createEdgeRuntimeAPI.mjs +14 -13
- package/dist/runtimes/edge/createEdgeRuntimeAPI.mjs.map +1 -1
- package/dist/runtimes/edge/index.js +8 -6
- package/dist/runtimes/edge/index.js.map +1 -1
- package/dist/runtimes/edge/index.mjs +5 -4
- package/dist/runtimes/edge/index.mjs.map +1 -1
- package/dist/runtimes/edge/partial-json/fix-json.js +2 -0
- package/dist/runtimes/edge/partial-json/fix-json.js.map +1 -1
- package/dist/runtimes/edge/partial-json/fix-json.mjs +1 -0
- package/dist/runtimes/edge/partial-json/fix-json.mjs.map +1 -1
- package/dist/runtimes/edge/partial-json/parse-partial-json.js +4 -2
- package/dist/runtimes/edge/partial-json/parse-partial-json.js.map +1 -1
- package/dist/runtimes/edge/partial-json/parse-partial-json.mjs +3 -2
- package/dist/runtimes/edge/partial-json/parse-partial-json.mjs.map +1 -1
- package/dist/runtimes/edge/streams/AssistantStreamChunkType.js +2 -0
- package/dist/runtimes/edge/streams/AssistantStreamChunkType.js.map +1 -1
- package/dist/runtimes/edge/streams/AssistantStreamChunkType.mjs +1 -0
- package/dist/runtimes/edge/streams/AssistantStreamChunkType.mjs.map +1 -1
- package/dist/runtimes/edge/streams/assistantDecoderStream.js +3 -1
- package/dist/runtimes/edge/streams/assistantDecoderStream.js.map +1 -1
- package/dist/runtimes/edge/streams/assistantDecoderStream.mjs +2 -1
- package/dist/runtimes/edge/streams/assistantDecoderStream.mjs.map +1 -1
- package/dist/runtimes/edge/streams/assistantEncoderStream.js +3 -1
- package/dist/runtimes/edge/streams/assistantEncoderStream.js.map +1 -1
- package/dist/runtimes/edge/streams/assistantEncoderStream.mjs +2 -1
- package/dist/runtimes/edge/streams/assistantEncoderStream.mjs.map +1 -1
- package/dist/runtimes/edge/streams/runResultStream.js +10 -8
- package/dist/runtimes/edge/streams/runResultStream.js.map +1 -1
- package/dist/runtimes/edge/streams/runResultStream.mjs +9 -8
- package/dist/runtimes/edge/streams/runResultStream.mjs.map +1 -1
- package/dist/runtimes/edge/streams/toolResultStream.js +2 -0
- package/dist/runtimes/edge/streams/toolResultStream.js.map +1 -1
- package/dist/runtimes/edge/streams/toolResultStream.mjs +1 -0
- package/dist/runtimes/edge/streams/toolResultStream.mjs.map +1 -1
- package/dist/runtimes/edge/streams/utils/PipeableTransformStream.js +4 -2
- package/dist/runtimes/edge/streams/utils/PipeableTransformStream.js.map +1 -1
- package/dist/runtimes/edge/streams/utils/PipeableTransformStream.mjs +3 -2
- package/dist/runtimes/edge/streams/utils/PipeableTransformStream.mjs.map +1 -1
- package/dist/runtimes/edge/streams/utils/StreamPart.js +2 -0
- package/dist/runtimes/edge/streams/utils/StreamPart.js.map +1 -1
- package/dist/runtimes/edge/streams/utils/chunkByLineStream.js +2 -0
- package/dist/runtimes/edge/streams/utils/chunkByLineStream.js.map +1 -1
- package/dist/runtimes/edge/streams/utils/chunkByLineStream.mjs +1 -0
- package/dist/runtimes/edge/streams/utils/chunkByLineStream.mjs.map +1 -1
- package/dist/runtimes/edge/streams/utils/index.js +5 -3
- package/dist/runtimes/edge/streams/utils/index.js.map +1 -1
- package/dist/runtimes/edge/streams/utils/index.mjs +4 -3
- package/dist/runtimes/edge/streams/utils/index.mjs.map +1 -1
- package/dist/runtimes/edge/streams/utils/streamPartDecoderStream.js +5 -3
- package/dist/runtimes/edge/streams/utils/streamPartDecoderStream.js.map +1 -1
- package/dist/runtimes/edge/streams/utils/streamPartDecoderStream.mjs +4 -3
- package/dist/runtimes/edge/streams/utils/streamPartDecoderStream.mjs.map +1 -1
- package/dist/runtimes/edge/streams/utils/streamPartEncoderStream.js +3 -1
- package/dist/runtimes/edge/streams/utils/streamPartEncoderStream.js.map +1 -1
- package/dist/runtimes/edge/streams/utils/streamPartEncoderStream.mjs +2 -1
- package/dist/runtimes/edge/streams/utils/streamPartEncoderStream.mjs.map +1 -1
- package/dist/runtimes/edge/useEdgeRuntime.js +6 -4
- package/dist/runtimes/edge/useEdgeRuntime.js.map +1 -1
- package/dist/runtimes/edge/useEdgeRuntime.mjs +5 -4
- package/dist/runtimes/edge/useEdgeRuntime.mjs.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts +8 -8
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.js +2 -0
- package/dist/runtimes/external-store/ExternalStoreAdapter.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts +2 -2
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js +14 -12
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs +13 -12
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +35 -0
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +1 -0
- package/dist/runtimes/external-store/{ExternalStoreThreadManagementAdapter.js → ExternalStoreThreadListRuntimeCore.js} +21 -10
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -0
- package/dist/runtimes/external-store/{ExternalStoreThreadManagementAdapter.mjs → ExternalStoreThreadListRuntimeCore.mjs} +16 -6
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs.map +1 -0
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +12 -10
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs +11 -10
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageConverter.js +4 -2
- package/dist/runtimes/external-store/ThreadMessageConverter.js.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageConverter.mjs +3 -2
- package/dist/runtimes/external-store/ThreadMessageConverter.mjs.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.js +3 -1
- package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.mjs +2 -1
- package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
- package/dist/runtimes/external-store/auto-status.js +6 -4
- package/dist/runtimes/external-store/auto-status.js.map +1 -1
- package/dist/runtimes/external-store/auto-status.mjs +5 -4
- package/dist/runtimes/external-store/auto-status.mjs.map +1 -1
- package/dist/runtimes/external-store/external-message-converter.js +10 -8
- package/dist/runtimes/external-store/external-message-converter.js.map +1 -1
- package/dist/runtimes/external-store/external-message-converter.mjs +9 -8
- package/dist/runtimes/external-store/external-message-converter.mjs.map +1 -1
- package/dist/runtimes/external-store/getExternalStoreMessage.js +4 -2
- package/dist/runtimes/external-store/getExternalStoreMessage.js.map +1 -1
- package/dist/runtimes/external-store/getExternalStoreMessage.mjs +3 -2
- package/dist/runtimes/external-store/getExternalStoreMessage.mjs.map +1 -1
- package/dist/runtimes/external-store/index.js +5 -3
- package/dist/runtimes/external-store/index.js.map +1 -1
- package/dist/runtimes/external-store/index.mjs +4 -3
- package/dist/runtimes/external-store/index.mjs.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/external-store/useExternalStoreRuntime.mjs +5 -4
- package/dist/runtimes/external-store/useExternalStoreRuntime.mjs.map +1 -1
- package/dist/runtimes/feedback/FeedbackAdapter.js +2 -0
- package/dist/runtimes/feedback/FeedbackAdapter.js.map +1 -1
- package/dist/runtimes/feedback/index.js +2 -0
- package/dist/runtimes/feedback/index.js.map +1 -1
- package/dist/runtimes/index.js +18 -16
- package/dist/runtimes/index.js.map +1 -1
- package/dist/runtimes/index.mjs +9 -8
- package/dist/runtimes/index.mjs.map +1 -1
- package/dist/runtimes/local/ChatModelAdapter.js +2 -0
- package/dist/runtimes/local/ChatModelAdapter.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.d.ts +2 -2
- package/dist/runtimes/local/LocalRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.js +15 -13
- package/dist/runtimes/local/LocalRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.mjs +14 -13
- package/dist/runtimes/local/LocalRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.js +3 -1
- package/dist/runtimes/local/LocalRuntimeOptions.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.mjs +2 -1
- package/dist/runtimes/local/LocalRuntimeOptions.mjs.map +1 -1
- package/dist/runtimes/local/{LocalThreadManagerRuntimeCore.d.ts → LocalThreadListRuntimeCore.d.ts} +16 -6
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts.map +1 -0
- package/dist/runtimes/local/{LocalThreadManagerRuntimeCore.js → LocalThreadListRuntimeCore.js} +14 -9
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -0
- package/dist/runtimes/local/{LocalThreadManagerRuntimeCore.mjs → LocalThreadListRuntimeCore.mjs} +9 -5
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs.map +1 -0
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js +10 -7
- package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +9 -7
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/index.js +3 -1
- package/dist/runtimes/local/index.js.map +1 -1
- package/dist/runtimes/local/index.mjs +2 -1
- package/dist/runtimes/local/index.mjs.map +1 -1
- package/dist/runtimes/local/shouldContinue.js +3 -1
- package/dist/runtimes/local/shouldContinue.js.map +1 -1
- package/dist/runtimes/local/shouldContinue.mjs +2 -1
- package/dist/runtimes/local/shouldContinue.mjs.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.js +9 -7
- package/dist/runtimes/local/useLocalRuntime.js.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.mjs +9 -7
- package/dist/runtimes/local/useLocalRuntime.mjs.map +1 -1
- package/dist/runtimes/speech/SpeechAdapterTypes.js +2 -0
- package/dist/runtimes/speech/SpeechAdapterTypes.js.map +1 -1
- package/dist/runtimes/speech/WebSpeechSynthesisAdapter.js +4 -2
- package/dist/runtimes/speech/WebSpeechSynthesisAdapter.js.map +1 -1
- package/dist/runtimes/speech/WebSpeechSynthesisAdapter.mjs +3 -2
- package/dist/runtimes/speech/WebSpeechSynthesisAdapter.mjs.map +1 -1
- package/dist/runtimes/speech/index.js +3 -1
- package/dist/runtimes/speech/index.js.map +1 -1
- package/dist/runtimes/speech/index.mjs +2 -1
- package/dist/runtimes/speech/index.mjs.map +1 -1
- package/dist/runtimes/utils/MessageRepository.js +7 -5
- package/dist/runtimes/utils/MessageRepository.js.map +1 -1
- package/dist/runtimes/utils/MessageRepository.mjs +6 -5
- package/dist/runtimes/utils/MessageRepository.mjs.map +1 -1
- package/dist/tailwindcss/index.d.ts.map +1 -1
- package/dist/tailwindcss/index.js +7 -5
- package/dist/tailwindcss/index.js.map +1 -1
- package/dist/tailwindcss/index.mjs +6 -5
- package/dist/tailwindcss/index.mjs.map +1 -1
- package/dist/types/AssistantTypes.d.ts +2 -0
- package/dist/types/AssistantTypes.d.ts.map +1 -1
- package/dist/types/AssistantTypes.js +2 -0
- package/dist/types/AssistantTypes.js.map +1 -1
- package/dist/types/AttachmentTypes.js +2 -0
- package/dist/types/AttachmentTypes.js.map +1 -1
- package/dist/types/ContentPartComponentTypes.js +2 -0
- package/dist/types/ContentPartComponentTypes.js.map +1 -1
- package/dist/types/ModelConfigTypes.js +5 -3
- package/dist/types/ModelConfigTypes.js.map +1 -1
- package/dist/types/ModelConfigTypes.mjs +4 -3
- package/dist/types/ModelConfigTypes.mjs.map +1 -1
- package/dist/types/Unsubscribe.js +2 -0
- package/dist/types/Unsubscribe.js.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/ui/assistant-action-bar.js +23 -21
- package/dist/ui/assistant-action-bar.js.map +1 -1
- package/dist/ui/assistant-action-bar.mjs +23 -21
- package/dist/ui/assistant-action-bar.mjs.map +1 -1
- package/dist/ui/assistant-message.js +16 -14
- package/dist/ui/assistant-message.js.map +1 -1
- package/dist/ui/assistant-message.mjs +16 -14
- package/dist/ui/assistant-message.mjs.map +1 -1
- package/dist/ui/assistant-modal.js +16 -14
- package/dist/ui/assistant-modal.js.map +1 -1
- package/dist/ui/assistant-modal.mjs +16 -14
- package/dist/ui/assistant-modal.mjs.map +1 -1
- package/dist/ui/attachment.js +22 -20
- package/dist/ui/attachment.js.map +1 -1
- package/dist/ui/attachment.mjs +19 -17
- package/dist/ui/attachment.mjs.map +1 -1
- package/dist/ui/base/CircleStopIcon.js +3 -1
- package/dist/ui/base/CircleStopIcon.js.map +1 -1
- package/dist/ui/base/CircleStopIcon.mjs +2 -1
- package/dist/ui/base/CircleStopIcon.mjs.map +1 -1
- package/dist/ui/base/avatar.js +8 -6
- package/dist/ui/base/avatar.js.map +1 -1
- package/dist/ui/base/avatar.mjs +8 -6
- package/dist/ui/base/avatar.mjs.map +1 -1
- package/dist/ui/base/button.js +5 -3
- package/dist/ui/base/button.js.map +1 -1
- package/dist/ui/base/button.mjs +4 -3
- package/dist/ui/base/button.mjs.map +1 -1
- package/dist/ui/base/dialog.js +9 -7
- package/dist/ui/base/dialog.js.map +1 -1
- package/dist/ui/base/dialog.mjs +9 -7
- package/dist/ui/base/dialog.mjs.map +1 -1
- package/dist/ui/base/index.js +7 -5
- package/dist/ui/base/index.js.map +1 -1
- package/dist/ui/base/index.mjs +6 -5
- package/dist/ui/base/index.mjs.map +1 -1
- package/dist/ui/base/tooltip-icon-button.js +6 -4
- package/dist/ui/base/tooltip-icon-button.js.map +1 -1
- package/dist/ui/base/tooltip-icon-button.mjs +6 -4
- package/dist/ui/base/tooltip-icon-button.mjs.map +1 -1
- package/dist/ui/base/tooltip.js +7 -5
- package/dist/ui/base/tooltip.js.map +1 -1
- package/dist/ui/base/tooltip.mjs +7 -5
- package/dist/ui/base/tooltip.mjs.map +1 -1
- package/dist/ui/branch-picker.js +16 -14
- package/dist/ui/branch-picker.js.map +1 -1
- package/dist/ui/branch-picker.mjs +16 -14
- package/dist/ui/branch-picker.mjs.map +1 -1
- package/dist/ui/composer.js +26 -24
- package/dist/ui/composer.js.map +1 -1
- package/dist/ui/composer.mjs +26 -24
- package/dist/ui/composer.mjs.map +1 -1
- package/dist/ui/content-part.js +7 -5
- package/dist/ui/content-part.js.map +1 -1
- package/dist/ui/content-part.mjs +6 -5
- package/dist/ui/content-part.mjs.map +1 -1
- package/dist/ui/edit-composer.js +14 -12
- package/dist/ui/edit-composer.js.map +1 -1
- package/dist/ui/edit-composer.mjs +14 -12
- package/dist/ui/edit-composer.mjs.map +1 -1
- package/dist/ui/index.js +15 -13
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +14 -13
- package/dist/ui/index.mjs.map +1 -1
- package/dist/ui/thread-config.js +8 -6
- package/dist/ui/thread-config.js.map +1 -1
- package/dist/ui/thread-config.mjs +8 -6
- package/dist/ui/thread-config.mjs.map +1 -1
- package/dist/ui/thread-welcome.js +20 -18
- package/dist/ui/thread-welcome.js.map +1 -1
- package/dist/ui/thread-welcome.mjs +20 -18
- package/dist/ui/thread-welcome.mjs.map +1 -1
- package/dist/ui/thread.js +24 -22
- package/dist/ui/thread.js.map +1 -1
- package/dist/ui/thread.mjs +24 -22
- package/dist/ui/thread.mjs.map +1 -1
- package/dist/ui/user-action-bar.js +13 -11
- package/dist/ui/user-action-bar.js.map +1 -1
- package/dist/ui/user-action-bar.mjs +13 -11
- package/dist/ui/user-action-bar.mjs.map +1 -1
- package/dist/ui/user-message.js +16 -14
- package/dist/ui/user-message.js.map +1 -1
- package/dist/ui/user-message.mjs +16 -14
- package/dist/ui/user-message.mjs.map +1 -1
- package/dist/ui/utils/withDefaults.js +5 -3
- package/dist/ui/utils/withDefaults.js.map +1 -1
- package/dist/ui/utils/withDefaults.mjs +4 -3
- package/dist/ui/utils/withDefaults.mjs.map +1 -1
- package/dist/utils/ProxyConfigProvider.js +5 -3
- package/dist/utils/ProxyConfigProvider.js.map +1 -1
- package/dist/utils/ProxyConfigProvider.mjs +4 -3
- package/dist/utils/ProxyConfigProvider.mjs.map +1 -1
- package/dist/utils/RequireAtLeastOne.js +2 -0
- package/dist/utils/RequireAtLeastOne.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/createCombinedStore.mjs +3 -1
- package/dist/utils/combined/createCombinedStore.mjs.map +1 -1
- package/dist/utils/combined/useCombinedStore.js +4 -2
- package/dist/utils/combined/useCombinedStore.js.map +1 -1
- package/dist/utils/combined/useCombinedStore.mjs +3 -2
- package/dist/utils/combined/useCombinedStore.mjs.map +1 -1
- package/dist/utils/createActionButton.js +4 -2
- package/dist/utils/createActionButton.js.map +1 -1
- package/dist/utils/createActionButton.mjs +4 -2
- package/dist/utils/createActionButton.mjs.map +1 -1
- package/dist/utils/getThreadMessageText.js +3 -1
- package/dist/utils/getThreadMessageText.js.map +1 -1
- package/dist/utils/getThreadMessageText.mjs +2 -1
- package/dist/utils/getThreadMessageText.mjs.map +1 -1
- package/dist/utils/hooks/useManagedRef.js +3 -1
- package/dist/utils/hooks/useManagedRef.js.map +1 -1
- package/dist/utils/hooks/useManagedRef.mjs +2 -1
- package/dist/utils/hooks/useManagedRef.mjs.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.js +4 -2
- package/dist/utils/hooks/useOnResizeContent.js.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.mjs +3 -2
- package/dist/utils/hooks/useOnResizeContent.mjs.map +1 -1
- package/dist/utils/hooks/useOnScrollToBottom.js +4 -2
- package/dist/utils/hooks/useOnScrollToBottom.js.map +1 -1
- package/dist/utils/hooks/useOnScrollToBottom.mjs +3 -2
- package/dist/utils/hooks/useOnScrollToBottom.mjs.map +1 -1
- package/dist/utils/idUtils.js +6 -4
- package/dist/utils/idUtils.js.map +1 -1
- package/dist/utils/idUtils.mjs +5 -4
- package/dist/utils/idUtils.mjs.map +1 -1
- package/dist/utils/smooth/SmoothContext.js +10 -8
- package/dist/utils/smooth/SmoothContext.js.map +1 -1
- package/dist/utils/smooth/SmoothContext.mjs +9 -8
- package/dist/utils/smooth/SmoothContext.mjs.map +1 -1
- package/dist/utils/smooth/index.js +5 -3
- package/dist/utils/smooth/index.js.map +1 -1
- package/dist/utils/smooth/index.mjs +4 -3
- package/dist/utils/smooth/index.mjs.map +1 -1
- package/dist/utils/smooth/useSmooth.js +9 -7
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/smooth/useSmooth.mjs +9 -7
- package/dist/utils/smooth/useSmooth.mjs.map +1 -1
- package/package.json +13 -12
- package/src/api/AssistantRuntime.ts +9 -12
- package/src/api/ComposerRuntime.ts +17 -0
- package/src/api/MessageRuntime.ts +0 -9
- package/src/api/RuntimePathTypes.ts +10 -1
- package/src/api/ThreadListItemRuntime.ts +67 -0
- package/src/api/ThreadListRuntime.ts +159 -0
- package/src/api/ThreadRuntime.ts +2 -1
- package/src/api/index.ts +1 -4
- package/src/context/providers/AssistantRuntimeProvider.tsx +7 -9
- package/src/context/providers/AttachmentRuntimeProvider.tsx +6 -4
- package/src/context/providers/ContentPartRuntimeProvider.tsx +8 -7
- package/src/context/providers/MessageRuntimeProvider.tsx +6 -4
- package/src/context/providers/TextContentPartProvider.tsx +11 -7
- package/src/context/providers/ThreadListItemRuntimeProvider.tsx +54 -0
- package/src/context/react/AssistantContext.ts +4 -4
- package/src/context/react/ThreadListItemContext.ts +39 -0
- package/src/context/react/index.ts +2 -2
- package/src/internal.ts +1 -1
- package/src/primitives/index.ts +2 -0
- package/src/primitives/threadList/ThreadListItems.tsx +73 -0
- package/src/primitives/threadList/ThreadListNew.ts +25 -0
- package/src/primitives/threadList/index.ts +2 -0
- package/src/primitives/threadListItem/ThreadListItemArchive.ts +25 -0
- package/src/primitives/threadListItem/ThreadListItemDelete.ts +25 -0
- package/src/primitives/threadListItem/ThreadListItemUnarchive.ts +25 -0
- package/src/primitives/threadListItem/index.ts +3 -0
- package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +19 -5
- package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +3 -2
- package/src/runtimes/core/AssistantRuntimeCore.tsx +2 -2
- package/src/runtimes/core/BaseAssistantRuntimeCore.tsx +2 -2
- package/src/runtimes/core/ComposerRuntimeCore.tsx +4 -0
- package/src/runtimes/core/{ThreadManagerRuntimeCore.tsx → ThreadListRuntimeCore.tsx} +7 -5
- package/src/runtimes/core/subscribeToMainThread.ts +2 -2
- package/src/runtimes/external-store/ExternalStoreAdapter.tsx +8 -8
- package/src/runtimes/external-store/ExternalStoreRuntimeCore.tsx +8 -8
- package/src/runtimes/external-store/{ExternalStoreThreadManagementAdapter.tsx → ExternalStoreThreadListRuntimeCore.tsx} +16 -6
- package/src/runtimes/local/LocalRuntimeCore.tsx +7 -7
- package/src/runtimes/local/{LocalThreadManagerRuntimeCore.tsx → LocalThreadListRuntimeCore.tsx} +11 -7
- package/src/runtimes/local/LocalThreadRuntimeCore.tsx +2 -1
- package/src/tailwindcss/index.ts +4 -4
- package/src/types/AssistantTypes.ts +3 -0
- package/dist/api/ThreadManagerRuntime.d.ts +0 -32
- package/dist/api/ThreadManagerRuntime.d.ts.map +0 -1
- package/dist/api/ThreadManagerRuntime.js +0 -71
- package/dist/api/ThreadManagerRuntime.js.map +0 -1
- package/dist/api/ThreadManagerRuntime.mjs +0 -47
- package/dist/api/ThreadManagerRuntime.mjs.map +0 -1
- package/dist/runtimes/core/ThreadManagerRuntimeCore.d.ts.map +0 -1
- package/dist/runtimes/core/ThreadManagerRuntimeCore.js.map +0 -1
- package/dist/runtimes/core/ThreadManagerRuntimeCore.mjs +0 -1
- package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.d.ts +0 -25
- package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.d.ts.map +0 -1
- package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.js.map +0 -1
- package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.mjs.map +0 -1
- package/dist/runtimes/local/LocalThreadManagerRuntimeCore.d.ts.map +0 -1
- package/dist/runtimes/local/LocalThreadManagerRuntimeCore.js.map +0 -1
- package/dist/runtimes/local/LocalThreadManagerRuntimeCore.mjs.map +0 -1
- package/src/api/ThreadManagerRuntime.ts +0 -80
- /package/dist/runtimes/core/{ThreadManagerRuntimeCore.mjs.map → ThreadListRuntimeCore.mjs.map} +0 -0
- /package/{generated → dist/styles/tailwindcss}/base-components.css.json +0 -0
- /package/{generated → dist/styles/tailwindcss}/modal.css.json +0 -0
- /package/{generated → dist/styles/tailwindcss}/thread.css.json +0 -0
- /package/{generated → dist/styles/themes}/default.css.json +0 -0
@@ -16,23 +16,25 @@ var __copyProps = (to, from, except, desc) => {
|
|
16
16
|
return to;
|
17
17
|
};
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
|
19
21
|
var ExternalStoreThreadRuntimeCore_exports = {};
|
20
22
|
__export(ExternalStoreThreadRuntimeCore_exports, {
|
21
23
|
ExternalStoreThreadRuntimeCore: () => ExternalStoreThreadRuntimeCore,
|
22
24
|
hasUpcomingMessage: () => hasUpcomingMessage
|
23
25
|
});
|
24
26
|
module.exports = __toCommonJS(ExternalStoreThreadRuntimeCore_exports);
|
25
|
-
var import_getExternalStoreMessage = require("./getExternalStoreMessage");
|
26
|
-
var import_ThreadMessageConverter = require("./ThreadMessageConverter");
|
27
|
-
var import_auto_status = require("./auto-status");
|
28
|
-
var import_ThreadMessageLike = require("./ThreadMessageLike");
|
29
|
-
var import_getThreadMessageText = require("../../utils/getThreadMessageText");
|
30
|
-
var import_BaseThreadRuntimeCore = require("../core/BaseThreadRuntimeCore");
|
31
|
-
|
32
|
-
|
27
|
+
var import_getExternalStoreMessage = require("./getExternalStoreMessage.cjs");
|
28
|
+
var import_ThreadMessageConverter = require("./ThreadMessageConverter.cjs");
|
29
|
+
var import_auto_status = require("./auto-status.cjs");
|
30
|
+
var import_ThreadMessageLike = require("./ThreadMessageLike.cjs");
|
31
|
+
var import_getThreadMessageText = require("../../utils/getThreadMessageText.cjs");
|
32
|
+
var import_BaseThreadRuntimeCore = require("../core/BaseThreadRuntimeCore.cjs");
|
33
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
34
|
+
var hasUpcomingMessage = (isRunning, messages) => {
|
33
35
|
return isRunning && messages[messages.length - 1]?.role !== "assistant";
|
34
36
|
};
|
35
|
-
|
37
|
+
var ExternalStoreThreadRuntimeCore = class extends import_BaseThreadRuntimeCore.BaseThreadRuntimeCore {
|
36
38
|
assistantOptimisticId = null;
|
37
39
|
_capabilities = {
|
38
40
|
switchToBranch: false,
|
@@ -188,7 +190,7 @@ class ExternalStoreThreadRuntimeCore extends import_BaseThreadRuntimeCore.BaseTh
|
|
188
190
|
messages.flatMap(import_getExternalStoreMessage.getExternalStoreMessage).filter((m) => m != null)
|
189
191
|
);
|
190
192
|
};
|
191
|
-
}
|
193
|
+
};
|
192
194
|
// Annotate the CommonJS export names for ESM import in node:
|
193
195
|
0 && (module.exports = {
|
194
196
|
ExternalStoreThreadRuntimeCore,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx"],"sourcesContent":["import {\n AddToolResultOptions,\n ThreadSuggestion,\n} from \"../core/ThreadRuntimeCore\";\n\nimport { AppendMessage, ModelConfigProvider, ThreadMessage } from \"../../types\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport {\n getExternalStoreMessage,\n symbolInnerMessage,\n} from \"./getExternalStoreMessage\";\nimport { ThreadMessageConverter } from \"./ThreadMessageConverter\";\nimport { getAutoStatus, isAutoStatus } from \"./auto-status\";\nimport { fromThreadMessageLike } from \"./ThreadMessageLike\";\nimport { getThreadMessageText } from \"../../utils/getThreadMessageText\";\nimport {\n RuntimeCapabilities,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\n\nconst EMPTY_ARRAY = Object.freeze([]);\n\nexport const hasUpcomingMessage = (\n isRunning: boolean,\n messages: ThreadMessage[],\n) => {\n return isRunning && messages[messages.length - 1]?.role !== \"assistant\";\n};\n\nexport class ExternalStoreThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n private assistantOptimisticId: string | null = null;\n\n private _capabilities: RuntimeCapabilities = {\n switchToBranch: false,\n edit: false,\n reload: false,\n cancel: false,\n unstable_copy: false,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n public get capabilities() {\n return this._capabilities;\n }\n\n public threadId!: string;\n private _messages!: ThreadMessage[];\n public isDisabled!: boolean;\n\n public override get messages() {\n return this._messages;\n }\n\n public get adapters() {\n return this._store.adapters;\n }\n\n public suggestions: readonly ThreadSuggestion[] = [];\n public extras: unknown = undefined;\n\n private _converter = new ThreadMessageConverter();\n\n private _store!: ExternalStoreAdapter<any>;\n\n public override beginEdit(messageId: string) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing.\");\n\n super.beginEdit(messageId);\n }\n\n constructor(\n configProvider: ModelConfigProvider,\n threadId: string,\n store: ExternalStoreAdapter<any>,\n ) {\n super(configProvider);\n this.threadId = threadId;\n this.setStore(store);\n }\n\n public setStore(store: ExternalStoreAdapter<any>) {\n if (this._store === store) return;\n\n const isRunning = store.isRunning ?? false;\n this.isDisabled = store.isDisabled ?? false;\n\n const oldStore = this._store as ExternalStoreAdapter<any> | undefined;\n this._store = store;\n this.extras = store.extras;\n this.suggestions = store.suggestions ?? EMPTY_ARRAY;\n this._capabilities = {\n switchToBranch: this._store.setMessages !== undefined,\n edit: this._store.onEdit !== undefined,\n reload: this._store.onReload !== undefined,\n cancel: this._store.onCancel !== undefined,\n speech: this._store.adapters?.speech !== undefined,\n unstable_copy: this._store.unstable_capabilities?.copy !== false, // default true\n attachments: !!this._store.adapters?.attachments,\n feedback: !!this._store.adapters?.feedback,\n };\n\n if (oldStore) {\n // flush the converter cache when the convertMessage prop changes\n if (oldStore.convertMessage !== store.convertMessage) {\n this._converter = new ThreadMessageConverter();\n } else if (\n oldStore.isRunning === store.isRunning &&\n oldStore.messages === store.messages\n ) {\n this._notifySubscribers();\n // no conversion update\n return;\n }\n }\n\n const messages = !store.convertMessage\n ? store.messages\n : this._converter.convertMessages(store.messages, (cache, m, idx) => {\n if (!store.convertMessage) return m;\n\n const isLast = idx === store.messages.length - 1;\n const autoStatus = getAutoStatus(isLast, isRunning);\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n )\n return cache;\n\n const newMessage = fromThreadMessageLike(\n store.convertMessage(m, idx),\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = m;\n return newMessage;\n });\n\n for (let i = 0; i < messages.length; i++) {\n const message = messages[i]!;\n const parent = messages[i - 1];\n this.repository.addOrUpdateMessage(parent?.id ?? null, message);\n }\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n if (hasUpcomingMessage(isRunning, messages)) {\n this.assistantOptimisticId = this.repository.appendOptimisticMessage(\n messages.at(-1)?.id ?? null,\n {\n role: \"assistant\",\n content: [],\n },\n );\n }\n\n this.repository.resetHead(\n this.assistantOptimisticId ?? messages.at(-1)?.id ?? null,\n );\n\n this._messages = this.repository.getMessages();\n this._notifySubscribers();\n }\n\n public override switchToBranch(branchId: string): void {\n if (!this._store.setMessages)\n throw new Error(\"Runtime does not support switching branches.\");\n\n this.repository.switchToBranch(branchId);\n this.updateMessages(this.repository.getMessages());\n }\n\n public async append(message: AppendMessage): Promise<void> {\n if (message.parentId !== (this.messages.at(-1)?.id ?? null)) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing messages.\");\n await this._store.onEdit(message);\n } else {\n await this._store.onNew(message);\n }\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n if (!this._store.onReload)\n throw new Error(\"Runtime does not support reloading messages.\");\n\n await this._store.onReload(parentId);\n }\n\n public cancelRun(): void {\n if (!this._store.onCancel)\n throw new Error(\"Runtime does not support cancelling runs.\");\n\n this._store.onCancel();\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n let messages = this.repository.getMessages();\n const previousMessage = messages[messages.length - 1];\n if (\n previousMessage?.role === \"user\" &&\n previousMessage.id === messages.at(-1)?.id // ensure the previous message is a leaf node\n ) {\n this.repository.deleteMessage(previousMessage.id);\n if (!this.composer.text.trim()) {\n this.composer.setText(getThreadMessageText(previousMessage));\n }\n\n messages = this.repository.getMessages();\n } else {\n this._notifySubscribers();\n }\n\n // resync messages (for reloading, to restore the previous branch)\n setTimeout(() => {\n this.updateMessages(messages);\n }, 0);\n }\n\n public addToolResult(options: AddToolResultOptions) {\n if (!this._store.onAddToolResult)\n throw new Error(\"Runtime does not support tool results.\");\n this._store.onAddToolResult(options);\n }\n\n private updateMessages = (messages: ThreadMessage[]) => {\n this._store.setMessages?.(\n messages.flatMap(getExternalStoreMessage).filter((m) => m != null),\n );\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,qCAGO;AACP,oCAAuC;AACvC,yBAA4C;AAC5C,+BAAsC;AACtC,kCAAqC;AAKrC,mCAAsC;AAEtC,MAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AAE7B,MAAM,qBAAqB,CAChC,WACA,aACG;AACH,SAAO,aAAa,SAAS,SAAS,SAAS,CAAC,GAAG,SAAS;AAC9D;AAEO,MAAM,uCACH,mDAEV;AAAA,EACU,wBAAuC;AAAA,EAEvC,gBAAqC;AAAA,IAC3C,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EAEA,IAAW,eAAe;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EAEO;AAAA,EACC;AAAA,EACD;AAAA,EAEP,IAAoB,WAAW;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,WAAW;AACpB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,E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AS,QAAQ,sDAAuB,EAAE,OAAO,CAAC,MAAM,KAAK,IAAI;AAAA,IACnE;AAAA,EACF;AACF;","names":[]}
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx"],"sourcesContent":["import {\n AddToolResultOptions,\n ThreadSuggestion,\n} from \"../core/ThreadRuntimeCore\";\n\nimport { AppendMessage, ModelConfigProvider, ThreadMessage } from \"../../types\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport {\n getExternalStoreMessage,\n symbolInnerMessage,\n} from \"./getExternalStoreMessage\";\nimport { ThreadMessageConverter } from \"./ThreadMessageConverter\";\nimport { getAutoStatus, isAutoStatus } from \"./auto-status\";\nimport { fromThreadMessageLike } from \"./ThreadMessageLike\";\nimport { getThreadMessageText } from \"../../utils/getThreadMessageText\";\nimport {\n RuntimeCapabilities,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\n\nconst EMPTY_ARRAY = Object.freeze([]);\n\nexport const hasUpcomingMessage = (\n isRunning: boolean,\n messages: ThreadMessage[],\n) => {\n return isRunning && messages[messages.length - 1]?.role !== \"assistant\";\n};\n\nexport class ExternalStoreThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n private assistantOptimisticId: string | null = null;\n\n private _capabilities: RuntimeCapabilities = {\n switchToBranch: false,\n edit: false,\n reload: false,\n cancel: false,\n unstable_copy: false,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n public get capabilities() {\n return this._capabilities;\n }\n\n public threadId!: string;\n private _messages!: ThreadMessage[];\n public isDisabled!: boolean;\n\n public override get messages() {\n return this._messages;\n }\n\n public get adapters() {\n return this._store.adapters;\n }\n\n public suggestions: readonly ThreadSuggestion[] = [];\n public extras: unknown = undefined;\n\n private _converter = new ThreadMessageConverter();\n\n private _store!: ExternalStoreAdapter<any>;\n\n public override beginEdit(messageId: string) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing.\");\n\n super.beginEdit(messageId);\n }\n\n constructor(\n configProvider: ModelConfigProvider,\n threadId: string,\n store: ExternalStoreAdapter<any>,\n ) {\n super(configProvider);\n this.threadId = threadId;\n this.setStore(store);\n }\n\n public setStore(store: ExternalStoreAdapter<any>) {\n if (this._store === store) return;\n\n const isRunning = store.isRunning ?? false;\n this.isDisabled = store.isDisabled ?? false;\n\n const oldStore = this._store as ExternalStoreAdapter<any> | undefined;\n this._store = store;\n this.extras = store.extras;\n this.suggestions = store.suggestions ?? EMPTY_ARRAY;\n this._capabilities = {\n switchToBranch: this._store.setMessages !== undefined,\n edit: this._store.onEdit !== undefined,\n reload: this._store.onReload !== undefined,\n cancel: this._store.onCancel !== undefined,\n speech: this._store.adapters?.speech !== undefined,\n unstable_copy: this._store.unstable_capabilities?.copy !== false, // default true\n attachments: !!this._store.adapters?.attachments,\n feedback: !!this._store.adapters?.feedback,\n };\n\n if (oldStore) {\n // flush the converter cache when the convertMessage prop changes\n if (oldStore.convertMessage !== store.convertMessage) {\n this._converter = new ThreadMessageConverter();\n } else if (\n oldStore.isRunning === store.isRunning &&\n oldStore.messages === store.messages\n ) {\n this._notifySubscribers();\n // no conversion update\n return;\n }\n }\n\n const messages = !store.convertMessage\n ? store.messages\n : this._converter.convertMessages(store.messages, (cache, m, idx) => {\n if (!store.convertMessage) return m;\n\n const isLast = idx === store.messages.length - 1;\n const autoStatus = getAutoStatus(isLast, isRunning);\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n )\n return cache;\n\n const newMessage = fromThreadMessageLike(\n store.convertMessage(m, idx),\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = m;\n return newMessage;\n });\n\n for (let i = 0; i < messages.length; i++) {\n const message = messages[i]!;\n const parent = messages[i - 1];\n this.repository.addOrUpdateMessage(parent?.id ?? null, message);\n }\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n if (hasUpcomingMessage(isRunning, messages)) {\n this.assistantOptimisticId = this.repository.appendOptimisticMessage(\n messages.at(-1)?.id ?? null,\n {\n role: \"assistant\",\n content: [],\n },\n );\n }\n\n this.repository.resetHead(\n this.assistantOptimisticId ?? messages.at(-1)?.id ?? null,\n );\n\n this._messages = this.repository.getMessages();\n this._notifySubscribers();\n }\n\n public override switchToBranch(branchId: string): void {\n if (!this._store.setMessages)\n throw new Error(\"Runtime does not support switching branches.\");\n\n this.repository.switchToBranch(branchId);\n this.updateMessages(this.repository.getMessages());\n }\n\n public async append(message: AppendMessage): Promise<void> {\n if (message.parentId !== (this.messages.at(-1)?.id ?? null)) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing messages.\");\n await this._store.onEdit(message);\n } else {\n await this._store.onNew(message);\n }\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n if (!this._store.onReload)\n throw new Error(\"Runtime does not support reloading messages.\");\n\n await this._store.onReload(parentId);\n }\n\n public cancelRun(): void {\n if (!this._store.onCancel)\n throw new Error(\"Runtime does not support cancelling runs.\");\n\n this._store.onCancel();\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n let messages = this.repository.getMessages();\n const previousMessage = messages[messages.length - 1];\n if (\n previousMessage?.role === \"user\" &&\n previousMessage.id === messages.at(-1)?.id // ensure the previous message is a leaf node\n ) {\n this.repository.deleteMessage(previousMessage.id);\n if (!this.composer.text.trim()) {\n this.composer.setText(getThreadMessageText(previousMessage));\n }\n\n messages = this.repository.getMessages();\n } else {\n this._notifySubscribers();\n }\n\n // resync messages (for reloading, to restore the previous branch)\n setTimeout(() => {\n this.updateMessages(messages);\n }, 0);\n }\n\n public addToolResult(options: AddToolResultOptions) {\n if (!this._store.onAddToolResult)\n throw new Error(\"Runtime does not support tool results.\");\n this._store.onAddToolResult(options);\n }\n\n private updateMessages = (messages: ThreadMessage[]) => {\n this._store.setMessages?.(\n messages.flatMap(getExternalStoreMessage).filter((m) => m != null),\n );\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,qCAGO;AACP,oCAAuC;AACvC,yBAA4C;AAC5C,+BAAsC;AACtC,kCAAqC;AAKrC,mCAAsC;AAEtC,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AAE7B,IAAM,qBAAqB,CAChC,WACA,aACG;AACH,SAAO,aAAa,SAAS,SAAS,SAAS,CAAC,GAAG,SAAS;AAC9D;AAEO,IAAM,iCAAN,cACG,mDAEV;AAAA,EACU,wBAAuC;AAAA,EAEvC,gBAAqC;AAAA,IAC3C,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EAEA,IAAW,eAAe;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EAEO;AAAA,EACC;AAAA,EACD;AAAA,EAEP,IAAoB,WAAW;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,WAAW;AACpB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEO,cAA2C,CAAC;AAAA,EAC5C,SAAkB;AAAA,EAEjB,aAAa,IAAI,qDAAuB;AAAA,EAExC;AAAA,EAEQ,UAAU,WAAmB;AAC3C,QAAI,CAAC,KAAK,OAAO;AACf,YAAM,IAAI,MAAM,mCAAmC;AAErD,UAAM,UAAU,SAAS;AAAA,EAC3B;AAAA,EAEA,YACE,gBACA,UACA,OACA;AACA,UAAM,cAAc;AACpB,SAAK,WAAW;AAChB,SAAK,SAAS,KAAK;AAAA,EACrB;AAAA,EAEO,SAAS,OAAkC;AAChD,QAAI,KAAK,WAAW,MAAO;AAE3B,U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AkB;AACvB,QAAI,CAAC,KAAK,OAAO;AACf,YAAM,IAAI,MAAM,2CAA2C;AAE7D,SAAK,OAAO,SAAS;AAErB,QAAI,KAAK,uBAAuB;AAC9B,WAAK,WAAW,cAAc,KAAK,qBAAqB;AACxD,WAAK,wBAAwB;AAAA,IAC/B;AAEA,QAAI,WAAW,KAAK,WAAW,YAAY;AAC3C,UAAM,kBAAkB,SAAS,SAAS,SAAS,CAAC;AACpD,QACE,iBAAiB,SAAS,UAC1B,gBAAgB,OAAO,SAAS,GAAG,EAAE,GAAG,IACxC;AACA,WAAK,WAAW,cAAc,gBAAgB,EAAE;AAChD,UAAI,CAAC,KAAK,SAAS,KAAK,KAAK,GAAG;AAC9B,aAAK,SAAS,YAAQ,kDAAqB,eAAe,CAAC;AAAA,MAC7D;AAEA,iBAAW,KAAK,WAAW,YAAY;AAAA,IACzC,OAAO;AACL,WAAK,mBAAmB;AAAA,IAC1B;AAGA,eAAW,MAAM;AACf,WAAK,eAAe,QAAQ;AAAA,IAC9B,GAAG,CAAC;AAAA,EACN;AAAA,EAEO,cAAc,SAA+B;AAClD,QAAI,CAAC,KAAK,OAAO;AACf,YAAM,IAAI,MAAM,wCAAwC;AAC1D,SAAK,OAAO,gBAAgB,OAAO;AAAA,EACrC;AAAA,EAEQ,iBAAiB,CAAC,aAA8B;AACtD,SAAK,OAAO;AAAA,MACV,SAAS,QAAQ,sDAAuB,EAAE,OAAO,CAAC,MAAM,KAAK,IAAI;AAAA,IACnE;AAAA,EACF;AACF;","names":[]}
|
@@ -1,17 +1,18 @@
|
|
1
|
+
// src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
|
1
2
|
import {
|
2
3
|
getExternalStoreMessage,
|
3
4
|
symbolInnerMessage
|
4
|
-
} from "./getExternalStoreMessage";
|
5
|
-
import { ThreadMessageConverter } from "./ThreadMessageConverter";
|
6
|
-
import { getAutoStatus, isAutoStatus } from "./auto-status";
|
7
|
-
import { fromThreadMessageLike } from "./ThreadMessageLike";
|
8
|
-
import { getThreadMessageText } from "../../utils/getThreadMessageText";
|
9
|
-
import { BaseThreadRuntimeCore } from "../core/BaseThreadRuntimeCore";
|
10
|
-
|
11
|
-
|
5
|
+
} from "./getExternalStoreMessage.mjs";
|
6
|
+
import { ThreadMessageConverter } from "./ThreadMessageConverter.mjs";
|
7
|
+
import { getAutoStatus, isAutoStatus } from "./auto-status.mjs";
|
8
|
+
import { fromThreadMessageLike } from "./ThreadMessageLike.mjs";
|
9
|
+
import { getThreadMessageText } from "../../utils/getThreadMessageText.mjs";
|
10
|
+
import { BaseThreadRuntimeCore } from "../core/BaseThreadRuntimeCore.mjs";
|
11
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
12
|
+
var hasUpcomingMessage = (isRunning, messages) => {
|
12
13
|
return isRunning && messages[messages.length - 1]?.role !== "assistant";
|
13
14
|
};
|
14
|
-
|
15
|
+
var ExternalStoreThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
15
16
|
assistantOptimisticId = null;
|
16
17
|
_capabilities = {
|
17
18
|
switchToBranch: false,
|
@@ -167,7 +168,7 @@ class ExternalStoreThreadRuntimeCore extends BaseThreadRuntimeCore {
|
|
167
168
|
messages.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
168
169
|
);
|
169
170
|
};
|
170
|
-
}
|
171
|
+
};
|
171
172
|
export {
|
172
173
|
ExternalStoreThreadRuntimeCore,
|
173
174
|
hasUpcomingMessage
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx"],"sourcesContent":["import {\n AddToolResultOptions,\n ThreadSuggestion,\n} from \"../core/ThreadRuntimeCore\";\n\nimport { AppendMessage, ModelConfigProvider, ThreadMessage } from \"../../types\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport {\n getExternalStoreMessage,\n symbolInnerMessage,\n} from \"./getExternalStoreMessage\";\nimport { ThreadMessageConverter } from \"./ThreadMessageConverter\";\nimport { getAutoStatus, isAutoStatus } from \"./auto-status\";\nimport { fromThreadMessageLike } from \"./ThreadMessageLike\";\nimport { getThreadMessageText } from \"../../utils/getThreadMessageText\";\nimport {\n RuntimeCapabilities,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\n\nconst EMPTY_ARRAY = Object.freeze([]);\n\nexport const hasUpcomingMessage = (\n isRunning: boolean,\n messages: ThreadMessage[],\n) => {\n return isRunning && messages[messages.length - 1]?.role !== \"assistant\";\n};\n\nexport class ExternalStoreThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n private assistantOptimisticId: string | null = null;\n\n private _capabilities: RuntimeCapabilities = {\n switchToBranch: false,\n edit: false,\n reload: false,\n cancel: false,\n unstable_copy: false,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n public get capabilities() {\n return this._capabilities;\n }\n\n public threadId!: string;\n private _messages!: ThreadMessage[];\n public isDisabled!: boolean;\n\n public override get messages() {\n return this._messages;\n }\n\n public get adapters() {\n return this._store.adapters;\n }\n\n public suggestions: readonly ThreadSuggestion[] = [];\n public extras: unknown = undefined;\n\n private _converter = new ThreadMessageConverter();\n\n private _store!: ExternalStoreAdapter<any>;\n\n public override beginEdit(messageId: string) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing.\");\n\n super.beginEdit(messageId);\n }\n\n constructor(\n configProvider: ModelConfigProvider,\n threadId: string,\n store: ExternalStoreAdapter<any>,\n ) {\n super(configProvider);\n this.threadId = threadId;\n this.setStore(store);\n }\n\n public setStore(store: ExternalStoreAdapter<any>) {\n if (this._store === store) return;\n\n const isRunning = store.isRunning ?? false;\n this.isDisabled = store.isDisabled ?? false;\n\n const oldStore = this._store as ExternalStoreAdapter<any> | undefined;\n this._store = store;\n this.extras = store.extras;\n this.suggestions = store.suggestions ?? EMPTY_ARRAY;\n this._capabilities = {\n switchToBranch: this._store.setMessages !== undefined,\n edit: this._store.onEdit !== undefined,\n reload: this._store.onReload !== undefined,\n cancel: this._store.onCancel !== undefined,\n speech: this._store.adapters?.speech !== undefined,\n unstable_copy: this._store.unstable_capabilities?.copy !== false, // default true\n attachments: !!this._store.adapters?.attachments,\n feedback: !!this._store.adapters?.feedback,\n };\n\n if (oldStore) {\n // flush the converter cache when the convertMessage prop changes\n if (oldStore.convertMessage !== store.convertMessage) {\n this._converter = new ThreadMessageConverter();\n } else if (\n oldStore.isRunning === store.isRunning &&\n oldStore.messages === store.messages\n ) {\n this._notifySubscribers();\n // no conversion update\n return;\n }\n }\n\n const messages = !store.convertMessage\n ? store.messages\n : this._converter.convertMessages(store.messages, (cache, m, idx) => {\n if (!store.convertMessage) return m;\n\n const isLast = idx === store.messages.length - 1;\n const autoStatus = getAutoStatus(isLast, isRunning);\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n )\n return cache;\n\n const newMessage = fromThreadMessageLike(\n store.convertMessage(m, idx),\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = m;\n return newMessage;\n });\n\n for (let i = 0; i < messages.length; i++) {\n const message = messages[i]!;\n const parent = messages[i - 1];\n this.repository.addOrUpdateMessage(parent?.id ?? null, message);\n }\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n if (hasUpcomingMessage(isRunning, messages)) {\n this.assistantOptimisticId = this.repository.appendOptimisticMessage(\n messages.at(-1)?.id ?? null,\n {\n role: \"assistant\",\n content: [],\n },\n );\n }\n\n this.repository.resetHead(\n this.assistantOptimisticId ?? messages.at(-1)?.id ?? null,\n );\n\n this._messages = this.repository.getMessages();\n this._notifySubscribers();\n }\n\n public override switchToBranch(branchId: string): void {\n if (!this._store.setMessages)\n throw new Error(\"Runtime does not support switching branches.\");\n\n this.repository.switchToBranch(branchId);\n this.updateMessages(this.repository.getMessages());\n }\n\n public async append(message: AppendMessage): Promise<void> {\n if (message.parentId !== (this.messages.at(-1)?.id ?? null)) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing messages.\");\n await this._store.onEdit(message);\n } else {\n await this._store.onNew(message);\n }\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n if (!this._store.onReload)\n throw new Error(\"Runtime does not support reloading messages.\");\n\n await this._store.onReload(parentId);\n }\n\n public cancelRun(): void {\n if (!this._store.onCancel)\n throw new Error(\"Runtime does not support cancelling runs.\");\n\n this._store.onCancel();\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n let messages = this.repository.getMessages();\n const previousMessage = messages[messages.length - 1];\n if (\n previousMessage?.role === \"user\" &&\n previousMessage.id === messages.at(-1)?.id // ensure the previous message is a leaf node\n ) {\n this.repository.deleteMessage(previousMessage.id);\n if (!this.composer.text.trim()) {\n this.composer.setText(getThreadMessageText(previousMessage));\n }\n\n messages = this.repository.getMessages();\n } else {\n this._notifySubscribers();\n }\n\n // resync messages (for reloading, to restore the previous branch)\n setTimeout(() => {\n this.updateMessages(messages);\n }, 0);\n }\n\n public addToolResult(options: AddToolResultOptions) {\n if (!this._store.onAddToolResult)\n throw new Error(\"Runtime does not support tool results.\");\n this._store.onAddToolResult(options);\n }\n\n private updateMessages = (messages: ThreadMessage[]) => {\n this._store.setMessages?.(\n messages.flatMap(getExternalStoreMessage).filter((m) => m != null),\n );\n };\n}\n"],"mappings":"AAOA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AACvC,SAAS,eAAe,oBAAoB;AAC5C,SAAS,6BAA6B;AACtC,SAAS,4BAA4B;AAKrC,SAAS,6BAA6B;AAEtC,MAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AAE7B,MAAM,qBAAqB,CAChC,WACA,aACG;AACH,SAAO,aAAa,SAAS,SAAS,SAAS,CAAC,GAAG,SAAS;AA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,KAAK,GAAG;AAC9B,aAAK,SAAS,QAAQ,qBAAqB,eAAe,CAAC;AAAA,MAC7D;AAEA,iBAAW,KAAK,WAAW,YAAY;AAAA,IACzC,OAAO;AACL,WAAK,mBAAmB;AAAA,IAC1B;AAGA,eAAW,MAAM;AACf,WAAK,eAAe,QAAQ;AAAA,IAC9B,GAAG,CAAC;AAAA,EACN;AAAA,EAEO,cAAc,SAA+B;AAClD,QAAI,CAAC,KAAK,OAAO;AACf,YAAM,IAAI,MAAM,wCAAwC;AAC1D,SAAK,OAAO,gBAAgB,OAAO;AAAA,EACrC;AAAA,EAEQ,iBAAiB,CAAC,aAA8B;AACtD,SAAK,OAAO;AAAA,MACV,SAAS,QAAQ,uBAAuB,EAAE,OAAO,CAAC,MAAM,KAAK,IAAI;AAAA,IACnE;AAAA,EACF;AACF;","names":[]}
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx"],"sourcesContent":["import {\n AddToolResultOptions,\n ThreadSuggestion,\n} from \"../core/ThreadRuntimeCore\";\n\nimport { AppendMessage, ModelConfigProvider, ThreadMessage } from \"../../types\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport {\n getExternalStoreMessage,\n symbolInnerMessage,\n} from \"./getExternalStoreMessage\";\nimport { ThreadMessageConverter } from \"./ThreadMessageConverter\";\nimport { getAutoStatus, isAutoStatus } from \"./auto-status\";\nimport { fromThreadMessageLike } from \"./ThreadMessageLike\";\nimport { getThreadMessageText } from \"../../utils/getThreadMessageText\";\nimport {\n RuntimeCapabilities,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\n\nconst EMPTY_ARRAY = Object.freeze([]);\n\nexport const hasUpcomingMessage = (\n isRunning: boolean,\n messages: ThreadMessage[],\n) => {\n return isRunning && messages[messages.length - 1]?.role !== \"assistant\";\n};\n\nexport class ExternalStoreThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n private assistantOptimisticId: string | null = null;\n\n private _capabilities: RuntimeCapabilities = {\n switchToBranch: false,\n edit: false,\n reload: false,\n cancel: false,\n unstable_copy: false,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n public get capabilities() {\n return this._capabilities;\n }\n\n public threadId!: string;\n private _messages!: ThreadMessage[];\n public isDisabled!: boolean;\n\n public override get messages() {\n return this._messages;\n }\n\n public get adapters() {\n return this._store.adapters;\n }\n\n public suggestions: readonly ThreadSuggestion[] = [];\n public extras: unknown = undefined;\n\n private _converter = new ThreadMessageConverter();\n\n private _store!: ExternalStoreAdapter<any>;\n\n public override beginEdit(messageId: string) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing.\");\n\n super.beginEdit(messageId);\n }\n\n constructor(\n configProvider: ModelConfigProvider,\n threadId: string,\n store: ExternalStoreAdapter<any>,\n ) {\n super(configProvider);\n this.threadId = threadId;\n this.setStore(store);\n }\n\n public setStore(store: ExternalStoreAdapter<any>) {\n if (this._store === store) return;\n\n const isRunning = store.isRunning ?? false;\n this.isDisabled = store.isDisabled ?? false;\n\n const oldStore = this._store as ExternalStoreAdapter<any> | undefined;\n this._store = store;\n this.extras = store.extras;\n this.suggestions = store.suggestions ?? EMPTY_ARRAY;\n this._capabilities = {\n switchToBranch: this._store.setMessages !== undefined,\n edit: this._store.onEdit !== undefined,\n reload: this._store.onReload !== undefined,\n cancel: this._store.onCancel !== undefined,\n speech: this._store.adapters?.speech !== undefined,\n unstable_copy: this._store.unstable_capabilities?.copy !== false, // default true\n attachments: !!this._store.adapters?.attachments,\n feedback: !!this._store.adapters?.feedback,\n };\n\n if (oldStore) {\n // flush the converter cache when the convertMessage prop changes\n if (oldStore.convertMessage !== store.convertMessage) {\n this._converter = new ThreadMessageConverter();\n } else if (\n oldStore.isRunning === store.isRunning &&\n oldStore.messages === store.messages\n ) {\n this._notifySubscribers();\n // no conversion update\n return;\n }\n }\n\n const messages = !store.convertMessage\n ? store.messages\n : this._converter.convertMessages(store.messages, (cache, m, idx) => {\n if (!store.convertMessage) return m;\n\n const isLast = idx === store.messages.length - 1;\n const autoStatus = getAutoStatus(isLast, isRunning);\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n )\n return cache;\n\n const newMessage = fromThreadMessageLike(\n store.convertMessage(m, idx),\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = m;\n return newMessage;\n });\n\n for (let i = 0; i < messages.length; i++) {\n const message = messages[i]!;\n const parent = messages[i - 1];\n this.repository.addOrUpdateMessage(parent?.id ?? null, message);\n }\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n if (hasUpcomingMessage(isRunning, messages)) {\n this.assistantOptimisticId = this.repository.appendOptimisticMessage(\n messages.at(-1)?.id ?? null,\n {\n role: \"assistant\",\n content: [],\n },\n );\n }\n\n this.repository.resetHead(\n this.assistantOptimisticId ?? messages.at(-1)?.id ?? null,\n );\n\n this._messages = this.repository.getMessages();\n this._notifySubscribers();\n }\n\n public override switchToBranch(branchId: string): void {\n if (!this._store.setMessages)\n throw new Error(\"Runtime does not support switching branches.\");\n\n this.repository.switchToBranch(branchId);\n this.updateMessages(this.repository.getMessages());\n }\n\n public async append(message: AppendMessage): Promise<void> {\n if (message.parentId !== (this.messages.at(-1)?.id ?? null)) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing messages.\");\n await this._store.onEdit(message);\n } else {\n await this._store.onNew(message);\n }\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n if (!this._store.onReload)\n throw new Error(\"Runtime does not support reloading messages.\");\n\n await this._store.onReload(parentId);\n }\n\n public cancelRun(): void {\n if (!this._store.onCancel)\n throw new Error(\"Runtime does not support cancelling runs.\");\n\n this._store.onCancel();\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n let messages = this.repository.getMessages();\n const previousMessage = messages[messages.length - 1];\n if (\n previousMessage?.role === \"user\" &&\n previousMessage.id === messages.at(-1)?.id // ensure the previous message is a leaf node\n ) {\n this.repository.deleteMessage(previousMessage.id);\n if (!this.composer.text.trim()) {\n this.composer.setText(getThreadMessageText(previousMessage));\n }\n\n messages = this.repository.getMessages();\n } else {\n this._notifySubscribers();\n }\n\n // resync messages (for reloading, to restore the previous branch)\n setTimeout(() => {\n this.updateMessages(messages);\n }, 0);\n }\n\n public addToolResult(options: AddToolResultOptions) {\n if (!this._store.onAddToolResult)\n throw new Error(\"Runtime does not support tool results.\");\n this._store.onAddToolResult(options);\n }\n\n private updateMessages = (messages: ThreadMessage[]) => {\n this._store.setMessages?.(\n messages.flatMap(getExternalStoreMessage).filter((m) => m != null),\n );\n };\n}\n"],"mappings":";AAOA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AACvC,SAAS,eAAe,oBAAoB;AAC5C,SAAS,6BAA6B;AACtC,SAAS,4BAA4B;AAKrC,SAAS,6BAA6B;AAEtC,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AAE7B,IAAM,qBAAqB,CAChC,WACA,aACG;AACH,SAAO,aAAa,SAAS,SAAS,SAAS,CAAC,GAAG,SAAS;AAC9D;AAEO,IAAM,iCAAN,cACG,sBAEV;AAAA,EACU,wBAAuC;AAAA,EAEvC,gBAAqC;AAAA,IAC3C,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EAEA,IAAW,eAAe;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EAEO;AAAA,EACC;AAAA,EACD;AAAA,EAEP,IAAoB,WAAW;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA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BAAiB,CAAC,aAA8B;AACtD,SAAK,OAAO;AAAA,MACV,SAAS,QAAQ,uBAAuB,EAAE,OAAO,CAAC,MAAM,KAAK,IAAI;AAAA,IACnE;AAAA,EACF;AACF;","names":[]}
|
@@ -16,12 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
16
16
|
return to;
|
17
17
|
};
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/runtimes/external-store/ThreadMessageConverter.ts
|
19
21
|
var ThreadMessageConverter_exports = {};
|
20
22
|
__export(ThreadMessageConverter_exports, {
|
21
23
|
ThreadMessageConverter: () => ThreadMessageConverter
|
22
24
|
});
|
23
25
|
module.exports = __toCommonJS(ThreadMessageConverter_exports);
|
24
|
-
|
26
|
+
var ThreadMessageConverter = class {
|
25
27
|
cache = /* @__PURE__ */ new WeakMap();
|
26
28
|
convertMessages(messages, converter) {
|
27
29
|
return messages.map((m, idx) => {
|
@@ -31,7 +33,7 @@ class ThreadMessageConverter {
|
|
31
33
|
return newMessage;
|
32
34
|
});
|
33
35
|
}
|
34
|
-
}
|
36
|
+
};
|
35
37
|
// Annotate the CommonJS export names for ESM import in node:
|
36
38
|
0 && (module.exports = {
|
37
39
|
ThreadMessageConverter
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/ThreadMessageConverter.ts"],"sourcesContent":["import { ThreadMessage } from \"../../types\";\n\nexport type ConverterCallback<TIn> = (\n cache: ThreadMessage | undefined,\n message: TIn,\n idx: number,\n) => ThreadMessage;\n\nexport class ThreadMessageConverter {\n private readonly cache = new WeakMap<WeakKey, ThreadMessage>();\n\n convertMessages<TIn extends WeakKey>(\n messages: TIn[],\n converter: ConverterCallback<TIn>,\n ): ThreadMessage[] {\n return messages.map((m, idx) => {\n const cached = this.cache.get(m);\n const newMessage = converter(cached, m, idx);\n this.cache.set(m, newMessage);\n return newMessage;\n });\n }\n}\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/ThreadMessageConverter.ts"],"sourcesContent":["import { ThreadMessage } from \"../../types\";\n\nexport type ConverterCallback<TIn> = (\n cache: ThreadMessage | undefined,\n message: TIn,\n idx: number,\n) => ThreadMessage;\n\nexport class ThreadMessageConverter {\n private readonly cache = new WeakMap<WeakKey, ThreadMessage>();\n\n convertMessages<TIn extends WeakKey>(\n messages: TIn[],\n converter: ConverterCallback<TIn>,\n ): ThreadMessage[] {\n return messages.map((m, idx) => {\n const cached = this.cache.get(m);\n const newMessage = converter(cached, m, idx);\n this.cache.set(m, newMessage);\n return newMessage;\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,IAAM,yBAAN,MAA6B;AAAA,EACjB,QAAQ,oBAAI,QAAgC;AAAA,EAE7D,gBACE,UACA,WACiB;AACjB,WAAO,SAAS,IAAI,CAAC,GAAG,QAAQ;AAC9B,YAAM,SAAS,KAAK,MAAM,IAAI,CAAC;AAC/B,YAAM,aAAa,UAAU,QAAQ,GAAG,GAAG;AAC3C,WAAK,MAAM,IAAI,GAAG,UAAU;AAC5B,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":[]}
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
// src/runtimes/external-store/ThreadMessageConverter.ts
|
2
|
+
var ThreadMessageConverter = class {
|
2
3
|
cache = /* @__PURE__ */ new WeakMap();
|
3
4
|
convertMessages(messages, converter) {
|
4
5
|
return messages.map((m, idx) => {
|
@@ -8,7 +9,7 @@ class ThreadMessageConverter {
|
|
8
9
|
return newMessage;
|
9
10
|
});
|
10
11
|
}
|
11
|
-
}
|
12
|
+
};
|
12
13
|
export {
|
13
14
|
ThreadMessageConverter
|
14
15
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/ThreadMessageConverter.ts"],"sourcesContent":["import { ThreadMessage } from \"../../types\";\n\nexport type ConverterCallback<TIn> = (\n cache: ThreadMessage | undefined,\n message: TIn,\n idx: number,\n) => ThreadMessage;\n\nexport class ThreadMessageConverter {\n private readonly cache = new WeakMap<WeakKey, ThreadMessage>();\n\n convertMessages<TIn extends WeakKey>(\n messages: TIn[],\n converter: ConverterCallback<TIn>,\n ): ThreadMessage[] {\n return messages.map((m, idx) => {\n const cached = this.cache.get(m);\n const newMessage = converter(cached, m, idx);\n this.cache.set(m, newMessage);\n return newMessage;\n });\n }\n}\n"],"mappings":"AAQO,
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/ThreadMessageConverter.ts"],"sourcesContent":["import { ThreadMessage } from \"../../types\";\n\nexport type ConverterCallback<TIn> = (\n cache: ThreadMessage | undefined,\n message: TIn,\n idx: number,\n) => ThreadMessage;\n\nexport class ThreadMessageConverter {\n private readonly cache = new WeakMap<WeakKey, ThreadMessage>();\n\n convertMessages<TIn extends WeakKey>(\n messages: TIn[],\n converter: ConverterCallback<TIn>,\n ): ThreadMessage[] {\n return messages.map((m, idx) => {\n const cached = this.cache.get(m);\n const newMessage = converter(cached, m, idx);\n this.cache.set(m, newMessage);\n return newMessage;\n });\n }\n}\n"],"mappings":";AAQO,IAAM,yBAAN,MAA6B;AAAA,EACjB,QAAQ,oBAAI,QAAgC;AAAA,EAE7D,gBACE,UACA,WACiB;AACjB,WAAO,SAAS,IAAI,CAAC,GAAG,QAAQ;AAC9B,YAAM,SAAS,KAAK,MAAM,IAAI,CAAC;AAC/B,YAAM,aAAa,UAAU,QAAQ,GAAG,GAAG;AAC3C,WAAK,MAAM,IAAI,GAAG,UAAU;AAC5B,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":[]}
|
@@ -16,12 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
16
16
|
return to;
|
17
17
|
};
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/runtimes/external-store/ThreadMessageLike.tsx
|
19
21
|
var ThreadMessageLike_exports = {};
|
20
22
|
__export(ThreadMessageLike_exports, {
|
21
23
|
fromThreadMessageLike: () => fromThreadMessageLike
|
22
24
|
});
|
23
25
|
module.exports = __toCommonJS(ThreadMessageLike_exports);
|
24
|
-
|
26
|
+
var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
25
27
|
const { role, id, createdAt, attachments, status } = like;
|
26
28
|
const common = {
|
27
29
|
id: id ?? fallbackId,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/ThreadMessageLike.tsx"],"sourcesContent":["import {\n MessageStatus,\n TextContentPart,\n ImageContentPart,\n ToolCallContentPart,\n UIContentPart,\n ThreadMessage,\n ThreadAssistantContentPart,\n ThreadAssistantMessage,\n ThreadUserContentPart,\n ThreadUserMessage,\n ThreadSystemMessage,\n CompleteAttachment,\n} from \"../../types\";\nimport {\n CoreToolCallContentPart,\n Unstable_AudioContentPart,\n} from \"../../types/AssistantTypes\";\n\nexport type ThreadMessageLike = {\n role: \"assistant\" | \"user\" | \"system\";\n content:\n | string\n | (\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart\n | ToolCallContentPart<any, any>\n | CoreToolCallContentPart<any, any>\n | UIContentPart\n )[];\n id?: string | undefined;\n createdAt?: Date | undefined;\n status?: MessageStatus | undefined;\n attachments?: CompleteAttachment[] | undefined;\n};\n\nexport const fromThreadMessageLike = (\n like: ThreadMessageLike,\n fallbackId: string,\n fallbackStatus: MessageStatus,\n): ThreadMessage => {\n const { role, id, createdAt, attachments, status } = like;\n const common = {\n id: id ?? fallbackId,\n createdAt: createdAt ?? new Date(),\n };\n\n const content =\n typeof like.content === \"string\"\n ? [{ type: \"text\" as const, text: like.content }]\n : like.content;\n\n if (role !== \"user\" && attachments)\n throw new Error(\"Attachments are only supported for user messages\");\n // TODO add in 0.6\n // if (role !== \"assistant\" && status)\n // throw new Error(\"Status is only supported for assistant messages\");\n\n switch (role) {\n case \"assistant\":\n return {\n ...common,\n role,\n content: content\n .map((part): ThreadAssistantContentPart | null => {\n const type = part.type;\n switch (type) {\n case \"text\":\n if (part.text.trim().length === 0) return null;\n return part;\n\n case \"ui\":\n return part;\n\n case \"tool-call\": {\n if (\"argsText\" in part) return part;\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n };\n }\n\n default: {\n const unhandledType: \"image\" | \"audio\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n })\n .filter((c) => !!c),\n status: status ?? fallbackStatus,\n } satisfies ThreadAssistantMessage;\n\n case \"user\":\n return {\n ...common,\n role,\n content: content.map((part): ThreadUserContentPart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"ui\":\n case \"image\":\n case \"audio\":\n return part;\n\n default: {\n const unhandledType: \"tool-call\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n attachments: attachments ?? [],\n } satisfies ThreadUserMessage;\n\n case \"system\":\n if (content.length !== 1 || content[0]!.type !== \"text\")\n throw new Error(\n \"System messages must have exactly one text content part.\",\n );\n\n return {\n ...common,\n role,\n content: content as [TextContentPart],\n } satisfies ThreadSystemMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/ThreadMessageLike.tsx"],"sourcesContent":["import {\n MessageStatus,\n TextContentPart,\n ImageContentPart,\n ToolCallContentPart,\n UIContentPart,\n ThreadMessage,\n ThreadAssistantContentPart,\n ThreadAssistantMessage,\n ThreadUserContentPart,\n ThreadUserMessage,\n ThreadSystemMessage,\n CompleteAttachment,\n} from \"../../types\";\nimport {\n CoreToolCallContentPart,\n Unstable_AudioContentPart,\n} from \"../../types/AssistantTypes\";\n\nexport type ThreadMessageLike = {\n role: \"assistant\" | \"user\" | \"system\";\n content:\n | string\n | (\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart\n | ToolCallContentPart<any, any>\n | CoreToolCallContentPart<any, any>\n | UIContentPart\n )[];\n id?: string | undefined;\n createdAt?: Date | undefined;\n status?: MessageStatus | undefined;\n attachments?: CompleteAttachment[] | undefined;\n};\n\nexport const fromThreadMessageLike = (\n like: ThreadMessageLike,\n fallbackId: string,\n fallbackStatus: MessageStatus,\n): ThreadMessage => {\n const { role, id, createdAt, attachments, status } = like;\n const common = {\n id: id ?? fallbackId,\n createdAt: createdAt ?? new Date(),\n };\n\n const content =\n typeof like.content === \"string\"\n ? [{ type: \"text\" as const, text: like.content }]\n : like.content;\n\n if (role !== \"user\" && attachments)\n throw new Error(\"Attachments are only supported for user messages\");\n // TODO add in 0.6\n // if (role !== \"assistant\" && status)\n // throw new Error(\"Status is only supported for assistant messages\");\n\n switch (role) {\n case \"assistant\":\n return {\n ...common,\n role,\n content: content\n .map((part): ThreadAssistantContentPart | null => {\n const type = part.type;\n switch (type) {\n case \"text\":\n if (part.text.trim().length === 0) return null;\n return part;\n\n case \"ui\":\n return part;\n\n case \"tool-call\": {\n if (\"argsText\" in part) return part;\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n };\n }\n\n default: {\n const unhandledType: \"image\" | \"audio\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n })\n .filter((c) => !!c),\n status: status ?? fallbackStatus,\n } satisfies ThreadAssistantMessage;\n\n case \"user\":\n return {\n ...common,\n role,\n content: content.map((part): ThreadUserContentPart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"ui\":\n case \"image\":\n case \"audio\":\n return part;\n\n default: {\n const unhandledType: \"tool-call\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n attachments: attachments ?? [],\n } satisfies ThreadUserMessage;\n\n case \"system\":\n if (content.length !== 1 || content[0]!.type !== \"text\")\n throw new Error(\n \"System messages must have exactly one text content part.\",\n );\n\n return {\n ...common,\n role,\n content: content as [TextContentPart],\n } satisfies ThreadSystemMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqCO,IAAM,wBAAwB,CACnC,MACA,YACA,mBACkB;AAClB,QAAM,EAAE,MAAM,IAAI,WAAW,aAAa,OAAO,IAAI;AACrD,QAAM,SAAS;AAAA,IACb,IAAI,MAAM;AAAA,IACV,WAAW,aAAa,oBAAI,KAAK;AAAA,EACnC;AAEA,QAAM,UACJ,OAAO,KAAK,YAAY,WACpB,CAAC,EAAE,MAAM,QAAiB,MAAM,KAAK,QAAQ,CAAC,IAC9C,KAAK;AAEX,MAAI,SAAS,UAAU;AACrB,UAAM,IAAI,MAAM,kDAAkD;AAKpE,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QACN,IAAI,CAAC,SAA4C;AAChD,gBAAM,OAAO,KAAK;AAClB,kBAAQ,MAAM;AAAA,YACZ,KAAK;AACH,kBAAI,KAAK,KAAK,KAAK,EAAE,WAAW,EAAG,QAAO;AAC1C,qBAAO;AAAA,YAET,KAAK;AACH,qBAAO;AAAA,YAET,KAAK,aAAa;AAChB,kBAAI,cAAc,KAAM,QAAO;AAC/B,qBAAO;AAAA,gBACL,GAAG;AAAA,gBACH,UAAU,KAAK,UAAU,KAAK,IAAI;AAAA,cACpC;AAAA,YACF;AAAA,YAEA,SAAS;AACP,oBAAM,gBAAmC;AACzC,oBAAM,IAAI,MAAM,8BAA8B,aAAa,EAAE;AAAA,YAC/D;AAAA,UACF;AAAA,QACF,CAAC,EACA,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAAA,QACpB,QAAQ,UAAU;AAAA,MACpB;AAAA,IAEF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QAAQ,IAAI,CAAC,SAAgC;AACpD,gBAAM,OAAO,KAAK;AAClB,kBAAQ,MAAM;AAAA,YACZ,KAAK;AAAA,YACL,KAAK;AAAA,YACL,KAAK;AAAA,YACL,KAAK;AACH,qBAAO;AAAA,YAET,SAAS;AACP,oBAAM,gBAA6B;AACnC,oBAAM,IAAI,MAAM,8BAA8B,aAAa,EAAE;AAAA,YAC/D;AAAA,UACF;AAAA,QACF,CAAC;AAAA,QACD,aAAa,eAAe,CAAC;AAAA,MAC/B;AAAA,IAEF,KAAK;AACH,UAAI,QAAQ,WAAW,KAAK,QAAQ,CAAC,EAAG,SAAS;AAC/C,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAEF,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,MACF;AAAA,IAEF,SAAS;AACP,YAAM,kBAAyB;AAC/B,YAAM,IAAI,MAAM,yBAAyB,eAAe,EAAE;AAAA,IAC5D;AAAA,EACF;AACF;","names":[]}
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
// src/runtimes/external-store/ThreadMessageLike.tsx
|
2
|
+
var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
2
3
|
const { role, id, createdAt, attachments, status } = like;
|
3
4
|
const common = {
|
4
5
|
id: id ?? fallbackId,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/ThreadMessageLike.tsx"],"sourcesContent":["import {\n MessageStatus,\n TextContentPart,\n ImageContentPart,\n ToolCallContentPart,\n UIContentPart,\n ThreadMessage,\n ThreadAssistantContentPart,\n ThreadAssistantMessage,\n ThreadUserContentPart,\n ThreadUserMessage,\n ThreadSystemMessage,\n CompleteAttachment,\n} from \"../../types\";\nimport {\n CoreToolCallContentPart,\n Unstable_AudioContentPart,\n} from \"../../types/AssistantTypes\";\n\nexport type ThreadMessageLike = {\n role: \"assistant\" | \"user\" | \"system\";\n content:\n | string\n | (\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart\n | ToolCallContentPart<any, any>\n | CoreToolCallContentPart<any, any>\n | UIContentPart\n )[];\n id?: string | undefined;\n createdAt?: Date | undefined;\n status?: MessageStatus | undefined;\n attachments?: CompleteAttachment[] | undefined;\n};\n\nexport const fromThreadMessageLike = (\n like: ThreadMessageLike,\n fallbackId: string,\n fallbackStatus: MessageStatus,\n): ThreadMessage => {\n const { role, id, createdAt, attachments, status } = like;\n const common = {\n id: id ?? fallbackId,\n createdAt: createdAt ?? new Date(),\n };\n\n const content =\n typeof like.content === \"string\"\n ? [{ type: \"text\" as const, text: like.content }]\n : like.content;\n\n if (role !== \"user\" && attachments)\n throw new Error(\"Attachments are only supported for user messages\");\n // TODO add in 0.6\n // if (role !== \"assistant\" && status)\n // throw new Error(\"Status is only supported for assistant messages\");\n\n switch (role) {\n case \"assistant\":\n return {\n ...common,\n role,\n content: content\n .map((part): ThreadAssistantContentPart | null => {\n const type = part.type;\n switch (type) {\n case \"text\":\n if (part.text.trim().length === 0) return null;\n return part;\n\n case \"ui\":\n return part;\n\n case \"tool-call\": {\n if (\"argsText\" in part) return part;\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n };\n }\n\n default: {\n const unhandledType: \"image\" | \"audio\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n })\n .filter((c) => !!c),\n status: status ?? fallbackStatus,\n } satisfies ThreadAssistantMessage;\n\n case \"user\":\n return {\n ...common,\n role,\n content: content.map((part): ThreadUserContentPart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"ui\":\n case \"image\":\n case \"audio\":\n return part;\n\n default: {\n const unhandledType: \"tool-call\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n attachments: attachments ?? [],\n } satisfies ThreadUserMessage;\n\n case \"system\":\n if (content.length !== 1 || content[0]!.type !== \"text\")\n throw new Error(\n \"System messages must have exactly one text content part.\",\n );\n\n return {\n ...common,\n role,\n content: content as [TextContentPart],\n } satisfies ThreadSystemMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n"],"mappings":"AAqCO,
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/ThreadMessageLike.tsx"],"sourcesContent":["import {\n MessageStatus,\n TextContentPart,\n ImageContentPart,\n ToolCallContentPart,\n UIContentPart,\n ThreadMessage,\n ThreadAssistantContentPart,\n ThreadAssistantMessage,\n ThreadUserContentPart,\n ThreadUserMessage,\n ThreadSystemMessage,\n CompleteAttachment,\n} from \"../../types\";\nimport {\n CoreToolCallContentPart,\n Unstable_AudioContentPart,\n} from \"../../types/AssistantTypes\";\n\nexport type ThreadMessageLike = {\n role: \"assistant\" | \"user\" | \"system\";\n content:\n | string\n | (\n | TextContentPart\n | ImageContentPart\n | Unstable_AudioContentPart\n | ToolCallContentPart<any, any>\n | CoreToolCallContentPart<any, any>\n | UIContentPart\n )[];\n id?: string | undefined;\n createdAt?: Date | undefined;\n status?: MessageStatus | undefined;\n attachments?: CompleteAttachment[] | undefined;\n};\n\nexport const fromThreadMessageLike = (\n like: ThreadMessageLike,\n fallbackId: string,\n fallbackStatus: MessageStatus,\n): ThreadMessage => {\n const { role, id, createdAt, attachments, status } = like;\n const common = {\n id: id ?? fallbackId,\n createdAt: createdAt ?? new Date(),\n };\n\n const content =\n typeof like.content === \"string\"\n ? [{ type: \"text\" as const, text: like.content }]\n : like.content;\n\n if (role !== \"user\" && attachments)\n throw new Error(\"Attachments are only supported for user messages\");\n // TODO add in 0.6\n // if (role !== \"assistant\" && status)\n // throw new Error(\"Status is only supported for assistant messages\");\n\n switch (role) {\n case \"assistant\":\n return {\n ...common,\n role,\n content: content\n .map((part): ThreadAssistantContentPart | null => {\n const type = part.type;\n switch (type) {\n case \"text\":\n if (part.text.trim().length === 0) return null;\n return part;\n\n case \"ui\":\n return part;\n\n case \"tool-call\": {\n if (\"argsText\" in part) return part;\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n };\n }\n\n default: {\n const unhandledType: \"image\" | \"audio\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n })\n .filter((c) => !!c),\n status: status ?? fallbackStatus,\n } satisfies ThreadAssistantMessage;\n\n case \"user\":\n return {\n ...common,\n role,\n content: content.map((part): ThreadUserContentPart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"ui\":\n case \"image\":\n case \"audio\":\n return part;\n\n default: {\n const unhandledType: \"tool-call\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n attachments: attachments ?? [],\n } satisfies ThreadUserMessage;\n\n case \"system\":\n if (content.length !== 1 || content[0]!.type !== \"text\")\n throw new Error(\n \"System messages must have exactly one text content part.\",\n );\n\n return {\n ...common,\n role,\n content: content as [TextContentPart],\n } satisfies ThreadSystemMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n"],"mappings":";AAqCO,IAAM,wBAAwB,CACnC,MACA,YACA,mBACkB;AAClB,QAAM,EAAE,MAAM,IAAI,WAAW,aAAa,OAAO,IAAI;AACrD,QAAM,SAAS;AAAA,IACb,IAAI,MAAM;AAAA,IACV,WAAW,aAAa,oBAAI,KAAK;AAAA,EACnC;AAEA,QAAM,UACJ,OAAO,KAAK,YAAY,WACpB,CAAC,EAAE,MAAM,QAAiB,MAAM,KAAK,QAAQ,CAAC,IAC9C,KAAK;AAEX,MAAI,SAAS,UAAU;AACrB,UAAM,IAAI,MAAM,kDAAkD;AAKpE,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QACN,IAAI,CAAC,SAA4C;AAChD,gBAAM,OAAO,KAAK;AAClB,kBAAQ,MAAM;AAAA,YACZ,KAAK;AACH,kBAAI,KAAK,KAAK,KAAK,EAAE,WAAW,EAAG,QAAO;AAC1C,qBAAO;AAAA,YAET,KAAK;AACH,qBAAO;AAAA,YAET,KAAK,aAAa;AAChB,kBAAI,cAAc,KAAM,QAAO;AAC/B,qBAAO;AAAA,gBACL,GAAG;AAAA,gBACH,UAAU,KAAK,UAAU,KAAK,IAAI;AAAA,cACpC;AAAA,YACF;AAAA,YAEA,SAAS;AACP,oBAAM,gBAAmC;AACzC,oBAAM,IAAI,MAAM,8BAA8B,aAAa,EAAE;AAAA,YAC/D;AAAA,UACF;AAAA,QACF,CAAC,EACA,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAAA,QACpB,QAAQ,UAAU;AAAA,MACpB;AAAA,IAEF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA,SAAS,QAAQ,IAAI,CAAC,SAAgC;AACpD,gBAAM,OAAO,KAAK;AAClB,kBAAQ,MAAM;AAAA,YACZ,KAAK;AAAA,YACL,KAAK;AAAA,YACL,KAAK;AAAA,YACL,KAAK;AACH,qBAAO;AAAA,YAET,SAAS;AACP,oBAAM,gBAA6B;AACnC,oBAAM,IAAI,MAAM,8BAA8B,aAAa,EAAE;AAAA,YAC/D;AAAA,UACF;AAAA,QACF,CAAC;AAAA,QACD,aAAa,eAAe,CAAC;AAAA,MAC/B;AAAA,IAEF,KAAK;AACH,UAAI,QAAQ,WAAW,KAAK,QAAQ,CAAC,EAAG,SAAS;AAC/C,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAEF,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,MACF;AAAA,IAEF,SAAS;AACP,YAAM,kBAAyB;AAC/B,YAAM,IAAI,MAAM,yBAAyB,eAAe,EAAE;AAAA,IAC5D;AAAA,EACF;AACF;","names":[]}
|
@@ -16,19 +16,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
16
16
|
return to;
|
17
17
|
};
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/runtimes/external-store/auto-status.tsx
|
19
21
|
var auto_status_exports = {};
|
20
22
|
__export(auto_status_exports, {
|
21
23
|
getAutoStatus: () => getAutoStatus,
|
22
24
|
isAutoStatus: () => isAutoStatus
|
23
25
|
});
|
24
26
|
module.exports = __toCommonJS(auto_status_exports);
|
25
|
-
|
26
|
-
|
27
|
+
var AUTO_STATUS_RUNNING = Object.freeze({ type: "running" });
|
28
|
+
var AUTO_STATUS_COMPLETE = Object.freeze({
|
27
29
|
type: "complete",
|
28
30
|
reason: "unknown"
|
29
31
|
});
|
30
|
-
|
31
|
-
|
32
|
+
var isAutoStatus = (status) => status === AUTO_STATUS_RUNNING || status === AUTO_STATUS_COMPLETE;
|
33
|
+
var getAutoStatus = (isLast, isRunning) => isLast && isRunning ? AUTO_STATUS_RUNNING : AUTO_STATUS_COMPLETE;
|
32
34
|
// Annotate the CommonJS export names for ESM import in node:
|
33
35
|
0 && (module.exports = {
|
34
36
|
getAutoStatus,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/auto-status.tsx"],"sourcesContent":["import { MessageStatus } from \"../../types\";\n\nconst AUTO_STATUS_RUNNING = Object.freeze({ type: \"running\" });\nconst AUTO_STATUS_COMPLETE = Object.freeze({\n type: \"complete\",\n reason: \"unknown\",\n});\n\nexport const isAutoStatus = (status: MessageStatus) =>\n status === AUTO_STATUS_RUNNING || status === AUTO_STATUS_COMPLETE;\n\nexport const getAutoStatus = (isLast: boolean, isRunning: boolean) =>\n isLast && isRunning ? AUTO_STATUS_RUNNING : AUTO_STATUS_COMPLETE;\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/auto-status.tsx"],"sourcesContent":["import { MessageStatus } from \"../../types\";\n\nconst AUTO_STATUS_RUNNING = Object.freeze({ type: \"running\" });\nconst AUTO_STATUS_COMPLETE = Object.freeze({\n type: \"complete\",\n reason: \"unknown\",\n});\n\nexport const isAutoStatus = (status: MessageStatus) =>\n status === AUTO_STATUS_RUNNING || status === AUTO_STATUS_COMPLETE;\n\nexport const getAutoStatus = (isLast: boolean, isRunning: boolean) =>\n isLast && isRunning ? AUTO_STATUS_RUNNING : AUTO_STATUS_COMPLETE;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAM,sBAAsB,OAAO,OAAO,EAAE,MAAM,UAAU,CAAC;AAC7D,IAAM,uBAAuB,OAAO,OAAO;AAAA,EACzC,MAAM;AAAA,EACN,QAAQ;AACV,CAAC;AAEM,IAAM,eAAe,CAAC,WAC3B,WAAW,uBAAuB,WAAW;AAExC,IAAM,gBAAgB,CAAC,QAAiB,cAC7C,UAAU,YAAY,sBAAsB;","names":[]}
|
@@ -1,10 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
// src/runtimes/external-store/auto-status.tsx
|
2
|
+
var AUTO_STATUS_RUNNING = Object.freeze({ type: "running" });
|
3
|
+
var AUTO_STATUS_COMPLETE = Object.freeze({
|
3
4
|
type: "complete",
|
4
5
|
reason: "unknown"
|
5
6
|
});
|
6
|
-
|
7
|
-
|
7
|
+
var isAutoStatus = (status) => status === AUTO_STATUS_RUNNING || status === AUTO_STATUS_COMPLETE;
|
8
|
+
var getAutoStatus = (isLast, isRunning) => isLast && isRunning ? AUTO_STATUS_RUNNING : AUTO_STATUS_COMPLETE;
|
8
9
|
export {
|
9
10
|
getAutoStatus,
|
10
11
|
isAutoStatus
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/auto-status.tsx"],"sourcesContent":["import { MessageStatus } from \"../../types\";\n\nconst AUTO_STATUS_RUNNING = Object.freeze({ type: \"running\" });\nconst AUTO_STATUS_COMPLETE = Object.freeze({\n type: \"complete\",\n reason: \"unknown\",\n});\n\nexport const isAutoStatus = (status: MessageStatus) =>\n status === AUTO_STATUS_RUNNING || status === AUTO_STATUS_COMPLETE;\n\nexport const getAutoStatus = (isLast: boolean, isRunning: boolean) =>\n isLast && isRunning ? AUTO_STATUS_RUNNING : AUTO_STATUS_COMPLETE;\n"],"mappings":"AAEA,
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/auto-status.tsx"],"sourcesContent":["import { MessageStatus } from \"../../types\";\n\nconst AUTO_STATUS_RUNNING = Object.freeze({ type: \"running\" });\nconst AUTO_STATUS_COMPLETE = Object.freeze({\n type: \"complete\",\n reason: \"unknown\",\n});\n\nexport const isAutoStatus = (status: MessageStatus) =>\n status === AUTO_STATUS_RUNNING || status === AUTO_STATUS_COMPLETE;\n\nexport const getAutoStatus = (isLast: boolean, isRunning: boolean) =>\n isLast && isRunning ? AUTO_STATUS_RUNNING : AUTO_STATUS_COMPLETE;\n"],"mappings":";AAEA,IAAM,sBAAsB,OAAO,OAAO,EAAE,MAAM,UAAU,CAAC;AAC7D,IAAM,uBAAuB,OAAO,OAAO;AAAA,EACzC,MAAM;AAAA,EACN,QAAQ;AACV,CAAC;AAEM,IAAM,eAAe,CAAC,WAC3B,WAAW,uBAAuB,WAAW;AAExC,IAAM,gBAAgB,CAAC,QAAiB,cAC7C,UAAU,YAAY,sBAAsB;","names":[]}
|
@@ -16,17 +16,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
16
16
|
return to;
|
17
17
|
};
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/runtimes/external-store/external-message-converter.tsx
|
19
21
|
var external_message_converter_exports = {};
|
20
22
|
__export(external_message_converter_exports, {
|
21
23
|
useExternalMessageConverter: () => useExternalMessageConverter
|
22
24
|
});
|
23
25
|
module.exports = __toCommonJS(external_message_converter_exports);
|
24
26
|
var import_react = require("react");
|
25
|
-
var import_ThreadMessageConverter = require("./ThreadMessageConverter");
|
26
|
-
var import_getExternalStoreMessage = require("./getExternalStoreMessage");
|
27
|
-
var import_ThreadMessageLike = require("./ThreadMessageLike");
|
28
|
-
var import_auto_status = require("./auto-status");
|
29
|
-
|
27
|
+
var import_ThreadMessageConverter = require("./ThreadMessageConverter.cjs");
|
28
|
+
var import_getExternalStoreMessage = require("./getExternalStoreMessage.cjs");
|
29
|
+
var import_ThreadMessageLike = require("./ThreadMessageLike.cjs");
|
30
|
+
var import_auto_status = require("./auto-status.cjs");
|
31
|
+
var joinExternalMessages = (messages) => {
|
30
32
|
const assistantMessage = {
|
31
33
|
role: "assistant",
|
32
34
|
content: []
|
@@ -76,7 +78,7 @@ const joinExternalMessages = (messages) => {
|
|
76
78
|
}
|
77
79
|
return assistantMessage;
|
78
80
|
};
|
79
|
-
|
81
|
+
var chunkExternalMessages = (callbackResults) => {
|
80
82
|
const results = [];
|
81
83
|
let isAssistant = false;
|
82
84
|
let inputs = [];
|
@@ -106,7 +108,7 @@ const chunkExternalMessages = (callbackResults) => {
|
|
106
108
|
flush();
|
107
109
|
return results;
|
108
110
|
};
|
109
|
-
|
111
|
+
var useExternalMessageConverter = ({
|
110
112
|
callback,
|
111
113
|
messages,
|
112
114
|
isRunning
|
@@ -162,7 +164,7 @@ const useExternalMessageConverter = ({
|
|
162
164
|
);
|
163
165
|
}, [state, messages, isRunning]);
|
164
166
|
};
|
165
|
-
|
167
|
+
var shallowArrayEqual = (a, b) => {
|
166
168
|
if (a.length !== b.length) return false;
|
167
169
|
for (let i = 0; i < a.length; i++) {
|
168
170
|
if (a[i] !== b[i]) return false;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/external-message-converter.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { ThreadMessageConverter } from \"./ThreadMessageConverter\";\nimport {\n getExternalStoreMessage,\n symbolInnerMessage,\n} from \"./getExternalStoreMessage\";\nimport { fromThreadMessageLike, ThreadMessageLike } from \"./ThreadMessageLike\";\nimport { getAutoStatus, isAutoStatus } from \"./auto-status\";\nimport { ToolCallContentPart } from \"../../types\";\n\nexport namespace useExternalMessageConverter {\n export type Message =\n | ThreadMessageLike\n | {\n role: \"tool\";\n toolCallId: string;\n toolName?: string | undefined;\n result: any;\n };\n\n export type Callback<T> = (message: T) => Message | Message[];\n}\n\ntype CallbackResult<T> = {\n input: T;\n outputs: useExternalMessageConverter.Message[];\n};\n\ntype ChunkResult<T> = {\n inputs: T[];\n outputs: useExternalMessageConverter.Message[];\n};\n\nconst joinExternalMessages = (\n messages: useExternalMessageConverter.Message[],\n): ThreadMessageLike => {\n const assistantMessage: ThreadMessageLike & { content: any[] } = {\n role: \"assistant\",\n content: [],\n };\n for (const output of messages) {\n if (output.role === \"tool\") {\n const toolCallIdx = assistantMessage.content.findIndex(\n (c) => c.type === \"tool-call\" && c.toolCallId === output.toolCallId,\n );\n if (toolCallIdx !== -1) {\n const toolCall = assistantMessage.content[\n toolCallIdx\n ]! as ToolCallContentPart;\n if (output.toolName) {\n if (toolCall.toolName !== output.toolName)\n throw new Error(\n `Tool call name ${output.toolCallId} ${output.toolName} does not match existing tool call ${toolCall.toolName}`,\n );\n }\n assistantMessage.content[toolCallIdx] = {\n ...toolCall,\n result: output.result,\n };\n } else {\n throw new Error(\n `Tool call ${output.toolCallId} ${output.toolName} not found in assistant message`,\n );\n }\n } else {\n const role = output.role;\n switch (role) {\n case \"system\":\n case \"user\":\n return output;\n case \"assistant\":\n if (assistantMessage.content.length === 0) {\n assistantMessage.id = output.id;\n assistantMessage.createdAt ??= output.createdAt;\n assistantMessage.status ??= output.status;\n // TODO keep this in sync\n }\n assistantMessage.content.push(...output.content);\n break;\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n }\n }\n return assistantMessage;\n};\n\nconst chunkExternalMessages = <T,>(callbackResults: CallbackResult<T>[]) => {\n const results: ChunkResult<T>[] = [];\n let isAssistant = false;\n let inputs: T[] = [];\n let outputs: useExternalMessageConverter.Message[] = [];\n\n const flush = () => {\n if (outputs.length) {\n results.push({\n inputs,\n outputs,\n });\n }\n inputs = [];\n outputs = [];\n };\n\n for (const callbackResult of callbackResults) {\n for (const output of callbackResult.outputs) {\n if (!isAssistant || output.role === \"user\" || output.role === \"system\") {\n flush();\n }\n isAssistant = output.role === \"assistant\" || output.role === \"tool\";\n\n if (inputs.at(-1) !== callbackResult.input) {\n inputs.push(callbackResult.input);\n }\n outputs.push(output);\n }\n }\n flush();\n return results;\n};\n\nexport const useExternalMessageConverter = <T extends WeakKey>({\n callback,\n messages,\n isRunning,\n}: {\n callback: useExternalMessageConverter.Callback<T>;\n messages: T[];\n isRunning: boolean;\n}) => {\n const state = useMemo(\n () => ({\n callback,\n callbackCache: new WeakMap<T, CallbackResult<T>>(),\n chunkCache: new WeakMap<\n useExternalMessageConverter.Message,\n ChunkResult<T>\n >(),\n converterCache: new ThreadMessageConverter(),\n }),\n [callback],\n );\n\n return useMemo(() => {\n const callbackResults: CallbackResult<T>[] = [];\n for (const message of messages) {\n let result = state.callbackCache.get(message);\n if (!result) {\n const output = state.callback(message);\n const outputs = Array.isArray(output) ? output : [output];\n result = { input: message, outputs };\n state.callbackCache.set(message, result);\n }\n callbackResults.push(result);\n }\n\n const chunks = chunkExternalMessages(callbackResults).map((m) => {\n const key = m.outputs[0];\n if (!key) return m;\n\n const cached = state.chunkCache.get(key);\n if (cached && shallowArrayEqual(cached.outputs, m.outputs)) return cached;\n state.chunkCache.set(key, m);\n return m;\n });\n\n return state.converterCache.convertMessages(\n chunks,\n (cache, message, idx) => {\n const isLast = idx === chunks.length - 1;\n const autoStatus = getAutoStatus(isLast, isRunning);\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n ) {\n const inputs = getExternalStoreMessage(cache) as T[];\n if (shallowArrayEqual(inputs, message.inputs)) {\n return cache;\n }\n }\n\n const newMessage = fromThreadMessageLike(\n joinExternalMessages(message.outputs),\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = message.inputs;\n return newMessage;\n },\n );\n }, [state, messages, isRunning]);\n};\n\nconst shallowArrayEqual = (a: unknown[], b: unknown[]) => {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n};\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/external-message-converter.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { ThreadMessageConverter } from \"./ThreadMessageConverter\";\nimport {\n getExternalStoreMessage,\n symbolInnerMessage,\n} from \"./getExternalStoreMessage\";\nimport { fromThreadMessageLike, ThreadMessageLike } from \"./ThreadMessageLike\";\nimport { getAutoStatus, isAutoStatus } from \"./auto-status\";\nimport { ToolCallContentPart } from \"../../types\";\n\nexport namespace useExternalMessageConverter {\n export type Message =\n | ThreadMessageLike\n | {\n role: \"tool\";\n toolCallId: string;\n toolName?: string | undefined;\n result: any;\n };\n\n export type Callback<T> = (message: T) => Message | Message[];\n}\n\ntype CallbackResult<T> = {\n input: T;\n outputs: useExternalMessageConverter.Message[];\n};\n\ntype ChunkResult<T> = {\n inputs: T[];\n outputs: useExternalMessageConverter.Message[];\n};\n\nconst joinExternalMessages = (\n messages: useExternalMessageConverter.Message[],\n): ThreadMessageLike => {\n const assistantMessage: ThreadMessageLike & { content: any[] } = {\n role: \"assistant\",\n content: [],\n };\n for (const output of messages) {\n if (output.role === \"tool\") {\n const toolCallIdx = assistantMessage.content.findIndex(\n (c) => c.type === \"tool-call\" && c.toolCallId === output.toolCallId,\n );\n if (toolCallIdx !== -1) {\n const toolCall = assistantMessage.content[\n toolCallIdx\n ]! as ToolCallContentPart;\n if (output.toolName) {\n if (toolCall.toolName !== output.toolName)\n throw new Error(\n `Tool call name ${output.toolCallId} ${output.toolName} does not match existing tool call ${toolCall.toolName}`,\n );\n }\n assistantMessage.content[toolCallIdx] = {\n ...toolCall,\n result: output.result,\n };\n } else {\n throw new Error(\n `Tool call ${output.toolCallId} ${output.toolName} not found in assistant message`,\n );\n }\n } else {\n const role = output.role;\n switch (role) {\n case \"system\":\n case \"user\":\n return output;\n case \"assistant\":\n if (assistantMessage.content.length === 0) {\n assistantMessage.id = output.id;\n assistantMessage.createdAt ??= output.createdAt;\n assistantMessage.status ??= output.status;\n // TODO keep this in sync\n }\n assistantMessage.content.push(...output.content);\n break;\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n }\n }\n return assistantMessage;\n};\n\nconst chunkExternalMessages = <T,>(callbackResults: CallbackResult<T>[]) => {\n const results: ChunkResult<T>[] = [];\n let isAssistant = false;\n let inputs: T[] = [];\n let outputs: useExternalMessageConverter.Message[] = [];\n\n const flush = () => {\n if (outputs.length) {\n results.push({\n inputs,\n outputs,\n });\n }\n inputs = [];\n outputs = [];\n };\n\n for (const callbackResult of callbackResults) {\n for (const output of callbackResult.outputs) {\n if (!isAssistant || output.role === \"user\" || output.role === \"system\") {\n flush();\n }\n isAssistant = output.role === \"assistant\" || output.role === \"tool\";\n\n if (inputs.at(-1) !== callbackResult.input) {\n inputs.push(callbackResult.input);\n }\n outputs.push(output);\n }\n }\n flush();\n return results;\n};\n\nexport const useExternalMessageConverter = <T extends WeakKey>({\n callback,\n messages,\n isRunning,\n}: {\n callback: useExternalMessageConverter.Callback<T>;\n messages: T[];\n isRunning: boolean;\n}) => {\n const state = useMemo(\n () => ({\n callback,\n callbackCache: new WeakMap<T, CallbackResult<T>>(),\n chunkCache: new WeakMap<\n useExternalMessageConverter.Message,\n ChunkResult<T>\n >(),\n converterCache: new ThreadMessageConverter(),\n }),\n [callback],\n );\n\n return useMemo(() => {\n const callbackResults: CallbackResult<T>[] = [];\n for (const message of messages) {\n let result = state.callbackCache.get(message);\n if (!result) {\n const output = state.callback(message);\n const outputs = Array.isArray(output) ? output : [output];\n result = { input: message, outputs };\n state.callbackCache.set(message, result);\n }\n callbackResults.push(result);\n }\n\n const chunks = chunkExternalMessages(callbackResults).map((m) => {\n const key = m.outputs[0];\n if (!key) return m;\n\n const cached = state.chunkCache.get(key);\n if (cached && shallowArrayEqual(cached.outputs, m.outputs)) return cached;\n state.chunkCache.set(key, m);\n return m;\n });\n\n return state.converterCache.convertMessages(\n chunks,\n (cache, message, idx) => {\n const isLast = idx === chunks.length - 1;\n const autoStatus = getAutoStatus(isLast, isRunning);\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n ) {\n const inputs = getExternalStoreMessage(cache) as T[];\n if (shallowArrayEqual(inputs, message.inputs)) {\n return cache;\n }\n }\n\n const newMessage = fromThreadMessageLike(\n joinExternalMessages(message.outputs),\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = message.inputs;\n return newMessage;\n },\n );\n }, [state, messages, isRunning]);\n};\n\nconst shallowArrayEqual = (a: unknown[], b: unknown[]) => {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwB;AACxB,oCAAuC;AACvC,qCAGO;AACP,+BAAyD;AACzD,yBAA4C;AA0B5C,IAAM,uBAAuB,CAC3B,aACsB;AACtB,QAAM,mBAA2D;AAAA,IAC/D,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,EACZ;AACA,aAAW,UAAU,UAAU;AAC7B,QAAI,OAAO,SAAS,QAAQ;AAC1B,YAAM,cAAc,iBAAiB,QAAQ;AAAA,QAC3C,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,eAAe,OAAO;AAAA,MAC3D;AACA,UAAI,gBAAgB,IAAI;AACtB,cAAM,WAAW,iBAAiB,QAChC,WACF;AACA,YAAI,OAAO,UAAU;AACnB,cAAI,SAAS,aAAa,OAAO;AAC/B,kBAAM,IAAI;AAAA,cACR,kBAAkB,OAAO,UAAU,IAAI,OAAO,QAAQ,sCAAsC,SAAS,QAAQ;AAAA,YAC/G;AAAA,QACJ;AACA,yBAAiB,QAAQ,WAAW,IAAI;AAAA,UACtC,GAAG;AAAA,UACH,QAAQ,O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;AAC7C,mBAAO;AAAA,UACT;AAAA,QACF;AAEA,cAAM,iBAAa;AAAA,UACjB,qBAAqB,QAAQ,OAAO;AAAA,UACpC,IAAI,SAAS;AAAA,UACb;AAAA,QACF;AACA,QAAC,WAAmB,iDAAkB,IAAI,QAAQ;AAClD,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF,GAAG,CAAC,OAAO,UAAU,SAAS,CAAC;AACjC;AAEA,IAAM,oBAAoB,CAAC,GAAc,MAAiB;AACxD,MAAI,EAAE,WAAW,EAAE,OAAQ,QAAO;AAClC,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AACjC,QAAI,EAAE,CAAC,MAAM,EAAE,CAAC,EAAG,QAAO;AAAA,EAC5B;AACA,SAAO;AACT;","names":[]}
|
@@ -1,12 +1,13 @@
|
|
1
|
+
// src/runtimes/external-store/external-message-converter.tsx
|
1
2
|
import { useMemo } from "react";
|
2
|
-
import { ThreadMessageConverter } from "./ThreadMessageConverter";
|
3
|
+
import { ThreadMessageConverter } from "./ThreadMessageConverter.mjs";
|
3
4
|
import {
|
4
5
|
getExternalStoreMessage,
|
5
6
|
symbolInnerMessage
|
6
|
-
} from "./getExternalStoreMessage";
|
7
|
-
import { fromThreadMessageLike } from "./ThreadMessageLike";
|
8
|
-
import { getAutoStatus, isAutoStatus } from "./auto-status";
|
9
|
-
|
7
|
+
} from "./getExternalStoreMessage.mjs";
|
8
|
+
import { fromThreadMessageLike } from "./ThreadMessageLike.mjs";
|
9
|
+
import { getAutoStatus, isAutoStatus } from "./auto-status.mjs";
|
10
|
+
var joinExternalMessages = (messages) => {
|
10
11
|
const assistantMessage = {
|
11
12
|
role: "assistant",
|
12
13
|
content: []
|
@@ -56,7 +57,7 @@ const joinExternalMessages = (messages) => {
|
|
56
57
|
}
|
57
58
|
return assistantMessage;
|
58
59
|
};
|
59
|
-
|
60
|
+
var chunkExternalMessages = (callbackResults) => {
|
60
61
|
const results = [];
|
61
62
|
let isAssistant = false;
|
62
63
|
let inputs = [];
|
@@ -86,7 +87,7 @@ const chunkExternalMessages = (callbackResults) => {
|
|
86
87
|
flush();
|
87
88
|
return results;
|
88
89
|
};
|
89
|
-
|
90
|
+
var useExternalMessageConverter = ({
|
90
91
|
callback,
|
91
92
|
messages,
|
92
93
|
isRunning
|
@@ -142,7 +143,7 @@ const useExternalMessageConverter = ({
|
|
142
143
|
);
|
143
144
|
}, [state, messages, isRunning]);
|
144
145
|
};
|
145
|
-
|
146
|
+
var shallowArrayEqual = (a, b) => {
|
146
147
|
if (a.length !== b.length) return false;
|
147
148
|
for (let i = 0; i < a.length; i++) {
|
148
149
|
if (a[i] !== b[i]) return false;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/external-message-converter.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { ThreadMessageConverter } from \"./ThreadMessageConverter\";\nimport {\n getExternalStoreMessage,\n symbolInnerMessage,\n} from \"./getExternalStoreMessage\";\nimport { fromThreadMessageLike, ThreadMessageLike } from \"./ThreadMessageLike\";\nimport { getAutoStatus, isAutoStatus } from \"./auto-status\";\nimport { ToolCallContentPart } from \"../../types\";\n\nexport namespace useExternalMessageConverter {\n export type Message =\n | ThreadMessageLike\n | {\n role: \"tool\";\n toolCallId: string;\n toolName?: string | undefined;\n result: any;\n };\n\n export type Callback<T> = (message: T) => Message | Message[];\n}\n\ntype CallbackResult<T> = {\n input: T;\n outputs: useExternalMessageConverter.Message[];\n};\n\ntype ChunkResult<T> = {\n inputs: T[];\n outputs: useExternalMessageConverter.Message[];\n};\n\nconst joinExternalMessages = (\n messages: useExternalMessageConverter.Message[],\n): ThreadMessageLike => {\n const assistantMessage: ThreadMessageLike & { content: any[] } = {\n role: \"assistant\",\n content: [],\n };\n for (const output of messages) {\n if (output.role === \"tool\") {\n const toolCallIdx = assistantMessage.content.findIndex(\n (c) => c.type === \"tool-call\" && c.toolCallId === output.toolCallId,\n );\n if (toolCallIdx !== -1) {\n const toolCall = assistantMessage.content[\n toolCallIdx\n ]! as ToolCallContentPart;\n if (output.toolName) {\n if (toolCall.toolName !== output.toolName)\n throw new Error(\n `Tool call name ${output.toolCallId} ${output.toolName} does not match existing tool call ${toolCall.toolName}`,\n );\n }\n assistantMessage.content[toolCallIdx] = {\n ...toolCall,\n result: output.result,\n };\n } else {\n throw new Error(\n `Tool call ${output.toolCallId} ${output.toolName} not found in assistant message`,\n );\n }\n } else {\n const role = output.role;\n switch (role) {\n case \"system\":\n case \"user\":\n return output;\n case \"assistant\":\n if (assistantMessage.content.length === 0) {\n assistantMessage.id = output.id;\n assistantMessage.createdAt ??= output.createdAt;\n assistantMessage.status ??= output.status;\n // TODO keep this in sync\n }\n assistantMessage.content.push(...output.content);\n break;\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n }\n }\n return assistantMessage;\n};\n\nconst chunkExternalMessages = <T,>(callbackResults: CallbackResult<T>[]) => {\n const results: ChunkResult<T>[] = [];\n let isAssistant = false;\n let inputs: T[] = [];\n let outputs: useExternalMessageConverter.Message[] = [];\n\n const flush = () => {\n if (outputs.length) {\n results.push({\n inputs,\n outputs,\n });\n }\n inputs = [];\n outputs = [];\n };\n\n for (const callbackResult of callbackResults) {\n for (const output of callbackResult.outputs) {\n if (!isAssistant || output.role === \"user\" || output.role === \"system\") {\n flush();\n }\n isAssistant = output.role === \"assistant\" || output.role === \"tool\";\n\n if (inputs.at(-1) !== callbackResult.input) {\n inputs.push(callbackResult.input);\n }\n outputs.push(output);\n }\n }\n flush();\n return results;\n};\n\nexport const useExternalMessageConverter = <T extends WeakKey>({\n callback,\n messages,\n isRunning,\n}: {\n callback: useExternalMessageConverter.Callback<T>;\n messages: T[];\n isRunning: boolean;\n}) => {\n const state = useMemo(\n () => ({\n callback,\n callbackCache: new WeakMap<T, CallbackResult<T>>(),\n chunkCache: new WeakMap<\n useExternalMessageConverter.Message,\n ChunkResult<T>\n >(),\n converterCache: new ThreadMessageConverter(),\n }),\n [callback],\n );\n\n return useMemo(() => {\n const callbackResults: CallbackResult<T>[] = [];\n for (const message of messages) {\n let result = state.callbackCache.get(message);\n if (!result) {\n const output = state.callback(message);\n const outputs = Array.isArray(output) ? output : [output];\n result = { input: message, outputs };\n state.callbackCache.set(message, result);\n }\n callbackResults.push(result);\n }\n\n const chunks = chunkExternalMessages(callbackResults).map((m) => {\n const key = m.outputs[0];\n if (!key) return m;\n\n const cached = state.chunkCache.get(key);\n if (cached && shallowArrayEqual(cached.outputs, m.outputs)) return cached;\n state.chunkCache.set(key, m);\n return m;\n });\n\n return state.converterCache.convertMessages(\n chunks,\n (cache, message, idx) => {\n const isLast = idx === chunks.length - 1;\n const autoStatus = getAutoStatus(isLast, isRunning);\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n ) {\n const inputs = getExternalStoreMessage(cache) as T[];\n if (shallowArrayEqual(inputs, message.inputs)) {\n return cache;\n }\n }\n\n const newMessage = fromThreadMessageLike(\n joinExternalMessages(message.outputs),\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = message.inputs;\n return newMessage;\n },\n );\n }, [state, messages, isRunning]);\n};\n\nconst shallowArrayEqual = (a: unknown[], b: unknown[]) => {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n};\n"],"mappings":"AAAA,SAAS,eAAe;AACxB,SAAS,8BAA8B;AACvC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAAgD;AACzD,SAAS,eAAe,oBAAoB;AA0B5C,
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/external-message-converter.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport { ThreadMessageConverter } from \"./ThreadMessageConverter\";\nimport {\n getExternalStoreMessage,\n symbolInnerMessage,\n} from \"./getExternalStoreMessage\";\nimport { fromThreadMessageLike, ThreadMessageLike } from \"./ThreadMessageLike\";\nimport { getAutoStatus, isAutoStatus } from \"./auto-status\";\nimport { ToolCallContentPart } from \"../../types\";\n\nexport namespace useExternalMessageConverter {\n export type Message =\n | ThreadMessageLike\n | {\n role: \"tool\";\n toolCallId: string;\n toolName?: string | undefined;\n result: any;\n };\n\n export type Callback<T> = (message: T) => Message | Message[];\n}\n\ntype CallbackResult<T> = {\n input: T;\n outputs: useExternalMessageConverter.Message[];\n};\n\ntype ChunkResult<T> = {\n inputs: T[];\n outputs: useExternalMessageConverter.Message[];\n};\n\nconst joinExternalMessages = (\n messages: useExternalMessageConverter.Message[],\n): ThreadMessageLike => {\n const assistantMessage: ThreadMessageLike & { content: any[] } = {\n role: \"assistant\",\n content: [],\n };\n for (const output of messages) {\n if (output.role === \"tool\") {\n const toolCallIdx = assistantMessage.content.findIndex(\n (c) => c.type === \"tool-call\" && c.toolCallId === output.toolCallId,\n );\n if (toolCallIdx !== -1) {\n const toolCall = assistantMessage.content[\n toolCallIdx\n ]! as ToolCallContentPart;\n if (output.toolName) {\n if (toolCall.toolName !== output.toolName)\n throw new Error(\n `Tool call name ${output.toolCallId} ${output.toolName} does not match existing tool call ${toolCall.toolName}`,\n );\n }\n assistantMessage.content[toolCallIdx] = {\n ...toolCall,\n result: output.result,\n };\n } else {\n throw new Error(\n `Tool call ${output.toolCallId} ${output.toolName} not found in assistant message`,\n );\n }\n } else {\n const role = output.role;\n switch (role) {\n case \"system\":\n case \"user\":\n return output;\n case \"assistant\":\n if (assistantMessage.content.length === 0) {\n assistantMessage.id = output.id;\n assistantMessage.createdAt ??= output.createdAt;\n assistantMessage.status ??= output.status;\n // TODO keep this in sync\n }\n assistantMessage.content.push(...output.content);\n break;\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n }\n }\n return assistantMessage;\n};\n\nconst chunkExternalMessages = <T,>(callbackResults: CallbackResult<T>[]) => {\n const results: ChunkResult<T>[] = [];\n let isAssistant = false;\n let inputs: T[] = [];\n let outputs: useExternalMessageConverter.Message[] = [];\n\n const flush = () => {\n if (outputs.length) {\n results.push({\n inputs,\n outputs,\n });\n }\n inputs = [];\n outputs = [];\n };\n\n for (const callbackResult of callbackResults) {\n for (const output of callbackResult.outputs) {\n if (!isAssistant || output.role === \"user\" || output.role === \"system\") {\n flush();\n }\n isAssistant = output.role === \"assistant\" || output.role === \"tool\";\n\n if (inputs.at(-1) !== callbackResult.input) {\n inputs.push(callbackResult.input);\n }\n outputs.push(output);\n }\n }\n flush();\n return results;\n};\n\nexport const useExternalMessageConverter = <T extends WeakKey>({\n callback,\n messages,\n isRunning,\n}: {\n callback: useExternalMessageConverter.Callback<T>;\n messages: T[];\n isRunning: boolean;\n}) => {\n const state = useMemo(\n () => ({\n callback,\n callbackCache: new WeakMap<T, CallbackResult<T>>(),\n chunkCache: new WeakMap<\n useExternalMessageConverter.Message,\n ChunkResult<T>\n >(),\n converterCache: new ThreadMessageConverter(),\n }),\n [callback],\n );\n\n return useMemo(() => {\n const callbackResults: CallbackResult<T>[] = [];\n for (const message of messages) {\n let result = state.callbackCache.get(message);\n if (!result) {\n const output = state.callback(message);\n const outputs = Array.isArray(output) ? output : [output];\n result = { input: message, outputs };\n state.callbackCache.set(message, result);\n }\n callbackResults.push(result);\n }\n\n const chunks = chunkExternalMessages(callbackResults).map((m) => {\n const key = m.outputs[0];\n if (!key) return m;\n\n const cached = state.chunkCache.get(key);\n if (cached && shallowArrayEqual(cached.outputs, m.outputs)) return cached;\n state.chunkCache.set(key, m);\n return m;\n });\n\n return state.converterCache.convertMessages(\n chunks,\n (cache, message, idx) => {\n const isLast = idx === chunks.length - 1;\n const autoStatus = getAutoStatus(isLast, isRunning);\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n ) {\n const inputs = getExternalStoreMessage(cache) as T[];\n if (shallowArrayEqual(inputs, message.inputs)) {\n return cache;\n }\n }\n\n const newMessage = fromThreadMessageLike(\n joinExternalMessages(message.outputs),\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = message.inputs;\n return newMessage;\n },\n );\n }, [state, messages, isRunning]);\n};\n\nconst shallowArrayEqual = (a: unknown[], b: unknown[]) => {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n};\n"],"mappings":";AAAA,SAAS,eAAe;AACxB,SAAS,8BAA8B;AACvC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAAgD;AACzD,SAAS,eAAe,oBAAoB;AA0B5C,IAAM,uBAAuB,CAC3B,aACsB;AACtB,QAAM,mBAA2D;AAAA,IAC/D,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,EACZ;AACA,aAAW,UAAU,UAAU;AAC7B,QAAI,OAAO,SAAS,QAAQ;AAC1B,YAAM,cAAc,iBAAiB,QAAQ;AAAA,QAC3C,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,eAAe,OAAO;AAAA,MAC3D;AACA,UAAI,gBAAgB,IAAI;AACtB,cAAM,WAAW,iBAAiB,QAChC,WACF;AACA,YAAI,OAAO,UAAU;AACnB,cAAI,SAAS,aAAa,OAAO;AAC/B,kBAAM,IAAI;AAAA,cACR,kBAAkB,OAAO,UAAU,IAAI,OAAO,QAAQ,sCAAsC,SAAS,QAAQ;AAAA,YAC/G;AAAA,QACJ;AACA,yBAAiB,QAAQ,WAAW,IAAI;AAAA,UACtC,GAAG;AAAA,UACH,QAAQ,OAAO;AAAA,QACjB;AAAA,MACF,OAAO;AACL,cAAM,IAAI;AAAA,UACR,aAAa,OAAO,UAAU,IAAI,OAAO,QAAQ;AAAA,QACnD;AAAA,MACF;AAAA,IACF,OAAO;AACL,YAAM,OAAO,OAAO;AACpB,cAAQ,MAAM;AAAA,QACZ,KAAK;AAAA,QACL,KAAK;AACH,iBAAO;AAAA,QACT,KAAK;AACH,cAAI,iBAAiB,QAA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