@assistant-ui/react 0.5.100 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/api/AssistantRuntime.d.ts +6 -86
- package/dist/api/AssistantRuntime.d.ts.map +1 -1
- package/dist/api/AssistantRuntime.js +0 -8
- package/dist/api/AssistantRuntime.js.map +1 -1
- package/dist/api/AssistantRuntime.mjs +0 -8
- package/dist/api/AssistantRuntime.mjs.map +1 -1
- package/dist/api/AttachmentRuntime.d.ts +4 -16
- package/dist/api/AttachmentRuntime.d.ts.map +1 -1
- package/dist/api/AttachmentRuntime.js.map +1 -1
- package/dist/api/AttachmentRuntime.mjs.map +1 -1
- package/dist/api/ComposerRuntime.d.ts +15 -131
- package/dist/api/ComposerRuntime.d.ts.map +1 -1
- package/dist/api/ComposerRuntime.js +4 -84
- package/dist/api/ComposerRuntime.js.map +1 -1
- package/dist/api/ComposerRuntime.mjs +4 -84
- package/dist/api/ComposerRuntime.mjs.map +1 -1
- package/dist/api/ContentPartRuntime.d.ts +2 -6
- package/dist/api/ContentPartRuntime.d.ts.map +1 -1
- package/dist/api/ContentPartRuntime.js.map +1 -1
- package/dist/api/ContentPartRuntime.mjs.map +1 -1
- package/dist/api/MessageRuntime.d.ts +8 -19
- package/dist/api/MessageRuntime.d.ts.map +1 -1
- package/dist/api/MessageRuntime.js +11 -7
- package/dist/api/MessageRuntime.js.map +1 -1
- package/dist/api/MessageRuntime.mjs +10 -6
- package/dist/api/MessageRuntime.mjs.map +1 -1
- package/dist/api/RuntimePathTypes.d.ts +33 -33
- package/dist/api/RuntimePathTypes.d.ts.map +1 -1
- package/dist/api/RuntimePathTypes.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.d.ts +12 -8
- package/dist/api/ThreadListItemRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListItemRuntime.js +10 -6
- package/dist/api/ThreadListItemRuntime.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.mjs +10 -6
- package/dist/api/ThreadListItemRuntime.mjs.map +1 -1
- package/dist/api/ThreadListRuntime.d.ts +10 -28
- package/dist/api/ThreadListRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListRuntime.js +23 -26
- package/dist/api/ThreadListRuntime.js.map +1 -1
- package/dist/api/ThreadListRuntime.mjs +23 -26
- package/dist/api/ThreadListRuntime.mjs.map +1 -1
- package/dist/api/ThreadRuntime.d.ts +53 -211
- package/dist/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js +2 -94
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.mjs +2 -94
- package/dist/api/ThreadRuntime.mjs.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.js +0 -1
- package/dist/context/providers/AssistantRuntimeProvider.js.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.mjs +0 -1
- package/dist/context/providers/AssistantRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/TextContentPartProvider.d.ts.map +1 -1
- package/dist/context/providers/TextContentPartProvider.js +0 -2
- package/dist/context/providers/TextContentPartProvider.js.map +1 -1
- package/dist/context/providers/TextContentPartProvider.mjs +0 -2
- package/dist/context/providers/TextContentPartProvider.mjs.map +1 -1
- package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts +1 -4
- package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/ThreadRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/ThreadRuntimeProvider.js +1 -13
- package/dist/context/providers/ThreadRuntimeProvider.js.map +1 -1
- package/dist/context/providers/ThreadRuntimeProvider.mjs +1 -13
- package/dist/context/providers/ThreadRuntimeProvider.mjs.map +1 -1
- package/dist/context/react/AssistantContext.d.ts +10 -120
- package/dist/context/react/AssistantContext.d.ts.map +1 -1
- package/dist/context/react/AssistantContext.js +0 -15
- package/dist/context/react/AssistantContext.js.map +1 -1
- package/dist/context/react/AssistantContext.mjs +0 -11
- package/dist/context/react/AssistantContext.mjs.map +1 -1
- package/dist/context/react/AttachmentContext.d.ts +32 -48
- package/dist/context/react/AttachmentContext.d.ts.map +1 -1
- package/dist/context/react/ComposerContext.d.ts +0 -5
- package/dist/context/react/ComposerContext.d.ts.map +1 -1
- package/dist/context/react/ComposerContext.js +3 -5
- package/dist/context/react/ComposerContext.js.map +1 -1
- package/dist/context/react/ComposerContext.mjs +2 -3
- package/dist/context/react/ComposerContext.mjs.map +1 -1
- package/dist/context/react/ContentPartContext.d.ts +0 -5
- package/dist/context/react/ContentPartContext.d.ts.map +1 -1
- package/dist/context/react/ContentPartContext.js +3 -5
- package/dist/context/react/ContentPartContext.js.map +1 -1
- package/dist/context/react/ContentPartContext.mjs +2 -3
- package/dist/context/react/ContentPartContext.mjs.map +1 -1
- package/dist/context/react/MessageContext.d.ts +6 -46
- package/dist/context/react/MessageContext.d.ts.map +1 -1
- package/dist/context/react/MessageContext.js +2 -6
- package/dist/context/react/MessageContext.js.map +1 -1
- package/dist/context/react/MessageContext.mjs +2 -4
- package/dist/context/react/MessageContext.mjs.map +1 -1
- package/dist/context/react/ThreadContext.d.ts +11 -1749
- package/dist/context/react/ThreadContext.d.ts.map +1 -1
- package/dist/context/react/ThreadContext.js +4 -30
- package/dist/context/react/ThreadContext.js.map +1 -1
- package/dist/context/react/ThreadContext.mjs +4 -22
- package/dist/context/react/ThreadContext.mjs.map +1 -1
- package/dist/context/react/ThreadListItemContext.d.ts +6 -24
- package/dist/context/react/ThreadListItemContext.d.ts.map +1 -1
- package/dist/context/react/index.d.ts +5 -101
- package/dist/context/react/index.d.ts.map +1 -1
- package/dist/context/react/index.js +0 -38
- package/dist/context/react/index.js.map +1 -1
- package/dist/context/react/index.mjs +5 -49
- package/dist/context/react/index.mjs.map +1 -1
- package/dist/context/stores/AssistantToolUIs.d.ts +9 -6
- package/dist/context/stores/AssistantToolUIs.d.ts.map +1 -1
- package/dist/context/stores/AssistantToolUIs.js.map +1 -1
- package/dist/context/stores/AssistantToolUIs.mjs.map +1 -1
- package/dist/context/stores/MessageUtils.d.ts +7 -12
- package/dist/context/stores/MessageUtils.d.ts.map +1 -1
- package/dist/context/stores/MessageUtils.js.map +1 -1
- package/dist/context/stores/MessageUtils.mjs.map +1 -1
- package/dist/context/stores/ThreadViewport.d.ts +6 -10
- package/dist/context/stores/ThreadViewport.d.ts.map +1 -1
- package/dist/context/stores/ThreadViewport.js +0 -1
- package/dist/context/stores/ThreadViewport.js.map +1 -1
- package/dist/context/stores/ThreadViewport.mjs +0 -2
- package/dist/context/stores/ThreadViewport.mjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +3 -0
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +2 -0
- package/dist/internal.mjs.map +1 -1
- package/dist/model-config/useAssistantToolUI.d.ts.map +1 -1
- package/dist/model-config/useAssistantToolUI.js.map +1 -1
- package/dist/model-config/useAssistantToolUI.mjs.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.d.ts +1 -4
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.d.ts.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.js.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.mjs.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartImage.d.ts +1 -4
- package/dist/primitive-hooks/contentPart/useContentPartImage.d.ts.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartImage.js.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartImage.mjs.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartText.d.ts +1 -4
- package/dist/primitive-hooks/contentPart/useContentPartText.d.ts.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartText.js.map +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartText.mjs.map +1 -1
- package/dist/primitive-hooks/index.d.ts +0 -5
- package/dist/primitive-hooks/index.d.ts.map +1 -1
- package/dist/primitive-hooks/index.js +1 -11
- package/dist/primitive-hooks/index.js.map +1 -1
- package/dist/primitive-hooks/index.mjs +0 -5
- package/dist/primitive-hooks/index.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.d.ts +1 -5
- package/dist/primitives/actionBar/ActionBarCopy.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.d.ts +0 -4
- package/dist/primitives/actionBar/ActionBarEdit.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.d.ts +0 -4
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.d.ts +0 -4
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.d.ts +0 -4
- package/dist/primitives/actionBar/ActionBarReload.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.d.ts +0 -4
- package/dist/primitives/actionBar/ActionBarRoot.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.d.ts +0 -4
- package/dist/primitives/actionBar/ActionBarSpeak.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.mjs.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.d.ts +0 -4
- package/dist/primitives/actionBar/ActionBarStopSpeaking.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.mjs.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.d.ts +0 -4
- package/dist/primitives/assistantModal/AssistantModalContent.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.mjs.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.d.ts +0 -4
- package/dist/primitives/assistantModal/AssistantModalRoot.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.mjs.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts +0 -4
- package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.mjs.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.d.ts +0 -4
- package/dist/primitives/branchPicker/BranchPickerCount.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.mjs.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.d.ts +0 -4
- package/dist/primitives/branchPicker/BranchPickerNext.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.mjs.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.d.ts +0 -4
- package/dist/primitives/branchPicker/BranchPickerNumber.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.mjs.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts +0 -4
- package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.mjs.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.d.ts +0 -4
- package/dist/primitives/branchPicker/BranchPickerRoot.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.mjs.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.d.ts +1 -5
- package/dist/primitives/composer/ComposerAddAttachment.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +2 -2
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.mjs +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.mjs.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.d.ts +0 -4
- package/dist/primitives/composer/ComposerAttachments.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.mjs.map +1 -1
- package/dist/primitives/composer/ComposerCancel.d.ts +0 -4
- package/dist/primitives/composer/ComposerCancel.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerCancel.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.mjs.map +1 -1
- package/dist/primitives/composer/ComposerIf.d.ts +0 -4
- package/dist/primitives/composer/ComposerIf.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerIf.js.map +1 -1
- package/dist/primitives/composer/ComposerIf.mjs.map +1 -1
- package/dist/primitives/composer/ComposerInput.d.ts +0 -4
- package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.mjs.map +1 -1
- package/dist/primitives/composer/ComposerRoot.d.ts +0 -1
- package/dist/primitives/composer/ComposerRoot.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js +2 -2
- package/dist/primitives/composer/ComposerRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerRoot.mjs +1 -1
- package/dist/primitives/composer/ComposerRoot.mjs.map +1 -1
- package/dist/primitives/composer/ComposerSend.d.ts +1 -5
- package/dist/primitives/composer/ComposerSend.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerSend.js +2 -2
- package/dist/primitives/composer/ComposerSend.js.map +1 -1
- package/dist/primitives/composer/ComposerSend.mjs +1 -1
- package/dist/primitives/composer/ComposerSend.mjs.map +1 -1
- package/dist/primitives/contentPart/ContentPartDisplay.d.ts +0 -4
- package/dist/primitives/contentPart/ContentPartDisplay.d.ts.map +1 -1
- package/dist/primitives/contentPart/ContentPartDisplay.js.map +1 -1
- package/dist/primitives/contentPart/ContentPartDisplay.mjs.map +1 -1
- package/dist/primitives/contentPart/ContentPartImage.d.ts +0 -4
- package/dist/primitives/contentPart/ContentPartImage.d.ts.map +1 -1
- package/dist/primitives/contentPart/ContentPartImage.js.map +1 -1
- package/dist/primitives/contentPart/ContentPartImage.mjs.map +1 -1
- package/dist/primitives/contentPart/ContentPartInProgress.d.ts +0 -4
- package/dist/primitives/contentPart/ContentPartInProgress.d.ts.map +1 -1
- package/dist/primitives/contentPart/ContentPartInProgress.js.map +1 -1
- package/dist/primitives/contentPart/ContentPartInProgress.mjs.map +1 -1
- package/dist/primitives/contentPart/ContentPartText.d.ts +0 -4
- package/dist/primitives/contentPart/ContentPartText.d.ts.map +1 -1
- package/dist/primitives/contentPart/ContentPartText.js.map +1 -1
- package/dist/primitives/contentPart/ContentPartText.mjs.map +1 -1
- package/dist/primitives/index.d.ts +0 -7
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/index.mjs.map +1 -1
- package/dist/primitives/message/MessageAttachments.d.ts +0 -4
- package/dist/primitives/message/MessageAttachments.d.ts.map +1 -1
- package/dist/primitives/message/MessageAttachments.js +2 -4
- package/dist/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/primitives/message/MessageAttachments.mjs +2 -4
- package/dist/primitives/message/MessageAttachments.mjs.map +1 -1
- package/dist/primitives/message/MessageContent.d.ts +0 -4
- package/dist/primitives/message/MessageContent.d.ts.map +1 -1
- package/dist/primitives/message/MessageContent.js +6 -6
- package/dist/primitives/message/MessageContent.js.map +1 -1
- package/dist/primitives/message/MessageContent.mjs +7 -7
- package/dist/primitives/message/MessageContent.mjs.map +1 -1
- package/dist/primitives/message/MessageIf.d.ts +0 -4
- package/dist/primitives/message/MessageIf.d.ts.map +1 -1
- package/dist/primitives/message/MessageIf.js.map +1 -1
- package/dist/primitives/message/MessageIf.mjs.map +1 -1
- package/dist/primitives/message/MessageRoot.d.ts +0 -4
- package/dist/primitives/message/MessageRoot.d.ts.map +1 -1
- package/dist/primitives/message/MessageRoot.js.map +1 -1
- package/dist/primitives/message/MessageRoot.mjs.map +1 -1
- package/dist/primitives/message/index.d.ts +0 -1
- package/dist/primitives/message/index.d.ts.map +1 -1
- package/dist/primitives/message/index.js +0 -3
- package/dist/primitives/message/index.js.map +1 -1
- package/dist/primitives/message/index.mjs +0 -2
- package/dist/primitives/message/index.mjs.map +1 -1
- package/dist/primitives/thread/ThreadEmpty.d.ts +0 -4
- package/dist/primitives/thread/ThreadEmpty.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadEmpty.js +2 -2
- package/dist/primitives/thread/ThreadEmpty.js.map +1 -1
- package/dist/primitives/thread/ThreadEmpty.mjs +1 -1
- package/dist/primitives/thread/ThreadEmpty.mjs.map +1 -1
- package/dist/primitives/thread/ThreadIf.d.ts +0 -4
- package/dist/primitives/thread/ThreadIf.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadIf.js.map +1 -1
- package/dist/primitives/thread/ThreadIf.mjs.map +1 -1
- package/dist/primitives/thread/ThreadMessages.d.ts +0 -4
- package/dist/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/primitives/thread/ThreadMessages.mjs.map +1 -1
- package/dist/primitives/thread/ThreadRoot.d.ts +0 -4
- package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadRoot.js.map +1 -1
- package/dist/primitives/thread/ThreadRoot.mjs.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.d.ts +0 -4
- package/dist/primitives/thread/ThreadScrollToBottom.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.js.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.mjs.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.d.ts +0 -4
- package/dist/primitives/thread/ThreadSuggestion.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.mjs.map +1 -1
- package/dist/primitives/thread/ThreadViewport.d.ts +0 -4
- package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/thread/ThreadViewport.mjs.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemArchive.js +3 -2
- package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemArchive.mjs +3 -2
- package/dist/primitives/threadListItem/ThreadListItemArchive.mjs.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts +14 -0
- package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemRoot.js +47 -0
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemRoot.mjs +23 -0
- package/dist/primitives/threadListItem/ThreadListItemRoot.mjs.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemTitle.d.ts +8 -0
- package/dist/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -0
- package/dist/primitives/{message/MessageInProgress.js → threadListItem/ThreadListItemTitle.js} +13 -10
- package/dist/primitives/threadListItem/ThreadListItemTitle.js.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemTitle.mjs +14 -0
- package/dist/primitives/threadListItem/ThreadListItemTitle.mjs.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemTrigger.d.ts +13 -0
- package/dist/primitives/threadListItem/ThreadListItemTrigger.d.ts.map +1 -0
- package/dist/{runtimes/core/subscribeToMainThread.js → primitives/threadListItem/ThreadListItemTrigger.js} +17 -22
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemTrigger.mjs +21 -0
- package/dist/primitives/threadListItem/ThreadListItemTrigger.mjs.map +1 -0
- package/dist/primitives/threadListItem/index.d.ts +3 -0
- package/dist/primitives/threadListItem/index.d.ts.map +1 -1
- package/dist/primitives/threadListItem/index.js +9 -0
- package/dist/primitives/threadListItem/index.js.map +1 -1
- package/dist/primitives/threadListItem/index.mjs +6 -0
- package/dist/primitives/threadListItem/index.mjs.map +1 -1
- package/dist/runtimes/attachment/AttachmentAdapter.d.ts +3 -7
- package/dist/runtimes/attachment/AttachmentAdapter.d.ts.map +1 -1
- package/dist/runtimes/attachment/AttachmentAdapter.js.map +1 -1
- package/dist/runtimes/attachment/CompositeAttachmentAdapter.d.ts +2 -6
- package/dist/runtimes/attachment/CompositeAttachmentAdapter.d.ts.map +1 -1
- package/dist/runtimes/attachment/CompositeAttachmentAdapter.js +1 -2
- package/dist/runtimes/attachment/CompositeAttachmentAdapter.js.map +1 -1
- package/dist/runtimes/attachment/CompositeAttachmentAdapter.mjs +1 -2
- package/dist/runtimes/attachment/CompositeAttachmentAdapter.mjs.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js +0 -6
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs +0 -6
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts +6 -7
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.js +8 -4
- package/dist/runtimes/core/BaseThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.mjs +8 -4
- package/dist/runtimes/core/BaseThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/ComposerRuntimeCore.d.ts +0 -3
- package/dist/runtimes/core/ComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts +7 -10
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts +30 -17
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/index.d.ts +1 -2
- package/dist/runtimes/core/index.d.ts.map +1 -1
- package/dist/runtimes/core/index.js +0 -12
- package/dist/runtimes/core/index.js.map +1 -1
- package/dist/runtimes/core/index.mjs +0 -5
- package/dist/runtimes/core/index.mjs.map +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.d.ts +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.d.ts.map +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.mjs.map +1 -1
- package/dist/runtimes/edge/createEdgeRuntimeAPI.d.ts +0 -4
- package/dist/runtimes/edge/createEdgeRuntimeAPI.d.ts.map +1 -1
- package/dist/runtimes/edge/createEdgeRuntimeAPI.js +0 -2
- package/dist/runtimes/edge/createEdgeRuntimeAPI.js.map +1 -1
- package/dist/runtimes/edge/createEdgeRuntimeAPI.mjs +0 -2
- package/dist/runtimes/edge/createEdgeRuntimeAPI.mjs.map +1 -1
- package/dist/runtimes/edge/streams/runResultStream.js +0 -2
- package/dist/runtimes/edge/streams/runResultStream.js.map +1 -1
- package/dist/runtimes/edge/streams/runResultStream.mjs +0 -2
- package/dist/runtimes/edge/streams/runResultStream.mjs.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts +3 -16
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js +0 -3
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs +0 -3
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +10 -12
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js +29 -7
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs +29 -7
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts +2 -12
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +4 -3
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs +4 -3
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.js +2 -0
- package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.mjs +2 -0
- package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
- package/dist/runtimes/local/ChatModelAdapter.d.ts +0 -8
- package/dist/runtimes/local/ChatModelAdapter.d.ts.map +1 -1
- package/dist/runtimes/local/ChatModelAdapter.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.d.ts +1 -6
- package/dist/runtimes/local/LocalRuntimeOptions.d.ts.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.js +1 -2
- package/dist/runtimes/local/LocalRuntimeOptions.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.mjs +1 -2
- package/dist/runtimes/local/LocalRuntimeOptions.mjs.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts +16 -20
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js +112 -72
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs +112 -72
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/LocalThreadMetadataRuntimeCore.d.ts +19 -0
- package/dist/runtimes/local/LocalThreadMetadataRuntimeCore.d.ts.map +1 -0
- package/dist/runtimes/local/LocalThreadMetadataRuntimeCore.js +87 -0
- package/dist/runtimes/local/LocalThreadMetadataRuntimeCore.js.map +1 -0
- package/dist/runtimes/local/LocalThreadMetadataRuntimeCore.mjs +62 -0
- package/dist/runtimes/local/LocalThreadMetadataRuntimeCore.mjs.map +1 -0
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js +15 -11
- package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +15 -11
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
- package/dist/styles/index.css.map +1 -1
- package/dist/types/AssistantTypes.d.ts +1 -18
- package/dist/types/AssistantTypes.d.ts.map +1 -1
- package/dist/types/AssistantTypes.js.map +1 -1
- package/dist/types/AttachmentTypes.d.ts +1 -1
- package/dist/types/AttachmentTypes.d.ts.map +1 -1
- package/dist/types/AttachmentTypes.js.map +1 -1
- package/dist/types/ContentPartComponentTypes.d.ts +4 -28
- package/dist/types/ContentPartComponentTypes.d.ts.map +1 -1
- package/dist/types/ContentPartComponentTypes.js.map +1 -1
- package/dist/ui/assistant-message.d.ts +1 -10
- package/dist/ui/assistant-message.d.ts.map +1 -1
- package/dist/ui/assistant-message.js.map +1 -1
- package/dist/ui/assistant-message.mjs.map +1 -1
- package/dist/ui/composer.d.ts +1 -25
- package/dist/ui/composer.d.ts.map +1 -1
- package/dist/ui/composer.js.map +1 -1
- package/dist/ui/composer.mjs.map +1 -1
- package/dist/ui/index.d.ts +6 -14
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +0 -4
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +14 -24
- package/dist/ui/index.mjs.map +1 -1
- package/dist/ui/thread-welcome.d.ts +5 -17
- package/dist/ui/thread-welcome.d.ts.map +1 -1
- package/dist/ui/thread-welcome.js.map +1 -1
- package/dist/ui/thread-welcome.mjs.map +1 -1
- package/dist/ui/thread.d.ts +1 -19
- package/dist/ui/thread.d.ts.map +1 -1
- package/dist/ui/thread.js.map +1 -1
- package/dist/ui/thread.mjs.map +1 -1
- package/dist/ui/user-message.d.ts +1 -18
- package/dist/ui/user-message.d.ts.map +1 -1
- package/dist/ui/user-message.js.map +1 -1
- package/dist/ui/user-message.mjs.map +1 -1
- package/dist/utils/smooth/SmoothContext.js +2 -2
- package/dist/utils/smooth/SmoothContext.js.map +1 -1
- package/dist/utils/smooth/SmoothContext.mjs +3 -3
- package/dist/utils/smooth/SmoothContext.mjs.map +1 -1
- package/dist/utils/smooth/useSmooth.d.ts.map +1 -1
- package/dist/utils/smooth/useSmooth.js +0 -1
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/smooth/useSmooth.mjs +0 -1
- package/dist/utils/smooth/useSmooth.mjs.map +1 -1
- package/package.json +7 -7
- package/src/api/AssistantRuntime.ts +3 -25
- package/src/api/AttachmentRuntime.ts +4 -16
- package/src/api/ComposerRuntime.ts +18 -214
- package/src/api/ContentPartRuntime.ts +2 -6
- package/src/api/MessageRuntime.ts +16 -20
- package/src/api/RuntimePathTypes.ts +26 -26
- package/src/api/ThreadListItemRuntime.ts +19 -11
- package/src/api/ThreadListRuntime.ts +39 -58
- package/src/api/ThreadRuntime.ts +52 -213
- package/src/api/index.ts +4 -0
- package/src/context/providers/AssistantRuntimeProvider.tsx +0 -1
- package/src/context/providers/TextContentPartProvider.tsx +0 -2
- package/src/context/providers/ThreadRuntimeProvider.tsx +1 -17
- package/src/context/react/AssistantContext.ts +0 -25
- package/src/context/react/ComposerContext.ts +1 -1
- package/src/context/react/ContentPartContext.ts +1 -1
- package/src/context/react/MessageContext.ts +2 -2
- package/src/context/react/ThreadContext.ts +5 -42
- package/src/context/react/index.ts +2 -125
- package/src/context/stores/AssistantToolUIs.ts +9 -2
- package/src/context/stores/MessageUtils.ts +6 -6
- package/src/context/stores/ThreadViewport.tsx +5 -6
- package/src/index.ts +0 -1
- package/src/internal.ts +1 -0
- package/src/model-config/useAssistantToolUI.tsx +0 -1
- package/src/primitive-hooks/contentPart/useContentPartDisplay.tsx +1 -1
- package/src/primitive-hooks/contentPart/useContentPartImage.tsx +1 -2
- package/src/primitive-hooks/contentPart/useContentPartText.tsx +1 -1
- package/src/primitive-hooks/index.ts +0 -5
- package/src/primitives/actionBar/ActionBarCopy.tsx +0 -5
- package/src/primitives/actionBar/ActionBarEdit.tsx +0 -5
- package/src/primitives/actionBar/ActionBarFeedbackNegative.tsx +0 -6
- package/src/primitives/actionBar/ActionBarFeedbackPositive.tsx +0 -6
- package/src/primitives/actionBar/ActionBarReload.tsx +0 -5
- package/src/primitives/actionBar/ActionBarRoot.tsx +0 -5
- package/src/primitives/actionBar/ActionBarSpeak.tsx +0 -5
- package/src/primitives/actionBar/ActionBarStopSpeaking.tsx +0 -6
- package/src/primitives/assistantModal/AssistantModalContent.tsx +1 -7
- package/src/primitives/assistantModal/AssistantModalRoot.tsx +0 -6
- package/src/primitives/assistantModal/AssistantModalTrigger.tsx +0 -6
- package/src/primitives/branchPicker/BranchPickerCount.tsx +0 -5
- package/src/primitives/branchPicker/BranchPickerNext.tsx +0 -6
- package/src/primitives/branchPicker/BranchPickerNumber.tsx +0 -5
- package/src/primitives/branchPicker/BranchPickerPrevious.tsx +1 -6
- package/src/primitives/branchPicker/BranchPickerRoot.tsx +0 -5
- package/src/primitives/composer/ComposerAddAttachment.tsx +2 -7
- package/src/primitives/composer/ComposerAttachments.tsx +0 -6
- package/src/primitives/composer/ComposerCancel.tsx +0 -5
- package/src/primitives/composer/ComposerIf.tsx +0 -5
- package/src/primitives/composer/ComposerInput.tsx +0 -5
- package/src/primitives/composer/ComposerRoot.tsx +1 -3
- package/src/primitives/composer/ComposerSend.tsx +2 -7
- package/src/primitives/contentPart/ContentPartDisplay.tsx +0 -6
- package/src/primitives/contentPart/ContentPartImage.tsx +0 -5
- package/src/primitives/contentPart/ContentPartInProgress.tsx +0 -6
- package/src/primitives/contentPart/ContentPartText.tsx +0 -5
- package/src/primitives/index.ts +0 -8
- package/src/primitives/message/MessageAttachments.tsx +2 -10
- package/src/primitives/message/MessageContent.tsx +7 -15
- package/src/primitives/message/MessageIf.tsx +0 -5
- package/src/primitives/message/MessageRoot.tsx +0 -5
- package/src/primitives/message/index.ts +0 -1
- package/src/primitives/thread/ThreadEmpty.tsx +1 -6
- package/src/primitives/thread/ThreadIf.tsx +0 -5
- package/src/primitives/thread/ThreadMessages.tsx +0 -5
- package/src/primitives/thread/ThreadRoot.tsx +0 -5
- package/src/primitives/thread/ThreadScrollToBottom.tsx +0 -6
- package/src/primitives/thread/ThreadSuggestion.tsx +0 -5
- package/src/primitives/thread/ThreadViewport.tsx +0 -5
- package/src/primitives/threadListItem/ThreadListItemArchive.ts +3 -2
- package/src/primitives/threadListItem/ThreadListItemRoot.tsx +29 -0
- package/src/primitives/threadListItem/ThreadListItemTitle.tsx +19 -0
- package/src/primitives/threadListItem/ThreadListItemTrigger.ts +25 -0
- package/src/primitives/threadListItem/index.ts +4 -1
- package/src/runtimes/attachment/AttachmentAdapter.ts +2 -12
- package/src/runtimes/attachment/CompositeAttachmentAdapter.ts +1 -1
- package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +0 -8
- package/src/runtimes/core/BaseThreadRuntimeCore.tsx +11 -5
- package/src/runtimes/core/ComposerRuntimeCore.tsx +0 -3
- package/src/runtimes/core/ThreadListRuntimeCore.tsx +7 -11
- package/src/runtimes/core/ThreadRuntimeCore.tsx +33 -17
- package/src/runtimes/core/index.ts +1 -2
- package/src/runtimes/edge/converters/toCoreMessages.ts +1 -1
- package/src/runtimes/edge/createEdgeRuntimeAPI.ts +0 -6
- package/src/runtimes/edge/streams/runResultStream.ts +0 -2
- package/src/runtimes/external-store/ExternalStoreAdapter.tsx +3 -17
- package/src/runtimes/external-store/ExternalStoreRuntimeCore.tsx +0 -3
- package/src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx +39 -7
- package/src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx +4 -3
- package/src/runtimes/external-store/ThreadMessageLike.tsx +4 -3
- package/src/runtimes/local/ChatModelAdapter.tsx +0 -9
- package/src/runtimes/local/LocalRuntimeOptions.tsx +1 -7
- package/src/runtimes/local/LocalThreadListRuntimeCore.tsx +140 -96
- package/src/runtimes/local/LocalThreadMetadataRuntimeCore.tsx +79 -0
- package/src/runtimes/local/LocalThreadRuntimeCore.tsx +16 -11
- package/src/types/AssistantTypes.ts +1 -20
- package/src/types/AttachmentTypes.ts +1 -2
- package/src/types/ContentPartComponentTypes.tsx +4 -31
- package/src/ui/assistant-message.tsx +0 -5
- package/src/ui/composer.tsx +0 -5
- package/src/ui/index.ts +5 -23
- package/src/ui/thread-welcome.tsx +6 -9
- package/src/ui/thread.tsx +0 -5
- package/src/ui/user-message.tsx +2 -12
- package/src/utils/smooth/SmoothContext.tsx +3 -3
- package/src/utils/smooth/useSmooth.tsx +0 -1
- package/dist/hooks/index.d.ts +0 -3
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js +0 -34
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/index.mjs +0 -8
- package/dist/hooks/index.mjs.map +0 -1
- package/dist/hooks/useAppendMessage.d.ts +0 -6
- package/dist/hooks/useAppendMessage.d.ts.map +0 -1
- package/dist/hooks/useAppendMessage.js +0 -42
- package/dist/hooks/useAppendMessage.js.map +0 -1
- package/dist/hooks/useAppendMessage.mjs +0 -17
- package/dist/hooks/useAppendMessage.mjs.map +0 -1
- package/dist/hooks/useSwitchToNewThread.d.ts +0 -5
- package/dist/hooks/useSwitchToNewThread.d.ts.map +0 -1
- package/dist/hooks/useSwitchToNewThread.js +0 -39
- package/dist/hooks/useSwitchToNewThread.js.map +0 -1
- package/dist/hooks/useSwitchToNewThread.mjs +0 -14
- package/dist/hooks/useSwitchToNewThread.mjs.map +0 -1
- package/dist/primitive-hooks/actionBar/index.d.ts +0 -34
- package/dist/primitive-hooks/actionBar/index.d.ts.map +0 -1
- package/dist/primitive-hooks/actionBar/index.js +0 -49
- package/dist/primitive-hooks/actionBar/index.js.map +0 -1
- package/dist/primitive-hooks/actionBar/index.mjs +0 -20
- package/dist/primitive-hooks/actionBar/index.mjs.map +0 -1
- package/dist/primitive-hooks/branchPicker/index.d.ts +0 -17
- package/dist/primitive-hooks/branchPicker/index.d.ts.map +0 -1
- package/dist/primitive-hooks/branchPicker/index.js +0 -40
- package/dist/primitive-hooks/branchPicker/index.js.map +0 -1
- package/dist/primitive-hooks/branchPicker/index.mjs +0 -12
- package/dist/primitive-hooks/branchPicker/index.mjs.map +0 -1
- package/dist/primitive-hooks/composer/index.d.ts +0 -17
- package/dist/primitive-hooks/composer/index.d.ts.map +0 -1
- package/dist/primitive-hooks/composer/index.js +0 -40
- package/dist/primitive-hooks/composer/index.js.map +0 -1
- package/dist/primitive-hooks/composer/index.mjs +0 -12
- package/dist/primitive-hooks/composer/index.mjs.map +0 -1
- package/dist/primitive-hooks/message/index.d.ts +0 -5
- package/dist/primitive-hooks/message/index.d.ts.map +0 -1
- package/dist/primitive-hooks/message/index.js +0 -31
- package/dist/primitive-hooks/message/index.js.map +0 -1
- package/dist/primitive-hooks/message/index.mjs +0 -6
- package/dist/primitive-hooks/message/index.mjs.map +0 -1
- package/dist/primitive-hooks/thread/index.d.ts +0 -17
- package/dist/primitive-hooks/thread/index.d.ts.map +0 -1
- package/dist/primitive-hooks/thread/index.js +0 -40
- package/dist/primitive-hooks/thread/index.js.map +0 -1
- package/dist/primitive-hooks/thread/index.mjs +0 -12
- package/dist/primitive-hooks/thread/index.mjs.map +0 -1
- package/dist/primitives/actionBar/types.d.ts +0 -9
- package/dist/primitives/actionBar/types.d.ts.map +0 -1
- package/dist/primitives/actionBar/types.js +0 -19
- package/dist/primitives/actionBar/types.js.map +0 -1
- package/dist/primitives/actionBar/types.mjs +0 -1
- package/dist/primitives/actionBar/types.mjs.map +0 -1
- package/dist/primitives/assistantModal/types.d.ts +0 -4
- package/dist/primitives/assistantModal/types.d.ts.map +0 -1
- package/dist/primitives/assistantModal/types.js +0 -19
- package/dist/primitives/assistantModal/types.js.map +0 -1
- package/dist/primitives/assistantModal/types.mjs +0 -1
- package/dist/primitives/assistantModal/types.mjs.map +0 -1
- package/dist/primitives/attachment/types.d.ts +0 -1
- package/dist/primitives/attachment/types.d.ts.map +0 -1
- package/dist/primitives/attachment/types.js +0 -2
- package/dist/primitives/attachment/types.js.map +0 -1
- package/dist/primitives/attachment/types.mjs +0 -1
- package/dist/primitives/attachment/types.mjs.map +0 -1
- package/dist/primitives/branchPicker/types.d.ts +0 -6
- package/dist/primitives/branchPicker/types.d.ts.map +0 -1
- package/dist/primitives/branchPicker/types.js +0 -19
- package/dist/primitives/branchPicker/types.js.map +0 -1
- package/dist/primitives/branchPicker/types.mjs +0 -1
- package/dist/primitives/branchPicker/types.mjs.map +0 -1
- package/dist/primitives/composer/types.d.ts +0 -6
- package/dist/primitives/composer/types.d.ts.map +0 -1
- package/dist/primitives/composer/types.js +0 -19
- package/dist/primitives/composer/types.js.map +0 -1
- package/dist/primitives/composer/types.mjs +0 -1
- package/dist/primitives/composer/types.mjs.map +0 -1
- package/dist/primitives/contentPart/types.d.ts +0 -5
- package/dist/primitives/contentPart/types.d.ts.map +0 -1
- package/dist/primitives/contentPart/types.js +0 -19
- package/dist/primitives/contentPart/types.js.map +0 -1
- package/dist/primitives/contentPart/types.mjs +0 -1
- package/dist/primitives/contentPart/types.mjs.map +0 -1
- package/dist/primitives/message/MessageInProgress.d.ts +0 -13
- package/dist/primitives/message/MessageInProgress.d.ts.map +0 -1
- package/dist/primitives/message/MessageInProgress.js.map +0 -1
- package/dist/primitives/message/MessageInProgress.mjs +0 -11
- package/dist/primitives/message/MessageInProgress.mjs.map +0 -1
- package/dist/primitives/message/types.d.ts +0 -5
- package/dist/primitives/message/types.d.ts.map +0 -1
- package/dist/primitives/message/types.js +0 -19
- package/dist/primitives/message/types.js.map +0 -1
- package/dist/primitives/message/types.mjs +0 -1
- package/dist/primitives/message/types.mjs.map +0 -1
- package/dist/primitives/thread/types.d.ts +0 -8
- package/dist/primitives/thread/types.d.ts.map +0 -1
- package/dist/primitives/thread/types.js +0 -19
- package/dist/primitives/thread/types.js.map +0 -1
- package/dist/primitives/thread/types.mjs +0 -1
- package/dist/primitives/thread/types.mjs.map +0 -1
- package/dist/runtimes/core/subscribeToMainThread.d.ts +0 -6
- package/dist/runtimes/core/subscribeToMainThread.d.ts.map +0 -1
- package/dist/runtimes/core/subscribeToMainThread.js.map +0 -1
- package/dist/runtimes/core/subscribeToMainThread.mjs +0 -23
- package/dist/runtimes/core/subscribeToMainThread.mjs.map +0 -1
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useAppendMessage.tsx +0 -19
- package/src/hooks/useSwitchToNewThread.tsx +0 -14
- package/src/primitive-hooks/actionBar/index.ts +0 -39
- package/src/primitive-hooks/branchPicker/index.ts +0 -18
- package/src/primitive-hooks/composer/index.ts +0 -17
- package/src/primitive-hooks/message/index.ts +0 -4
- package/src/primitive-hooks/thread/index.ts +0 -16
- package/src/primitives/actionBar/types.ts +0 -8
- package/src/primitives/assistantModal/types.ts +0 -3
- package/src/primitives/attachment/types.ts +0 -0
- package/src/primitives/branchPicker/types.ts +0 -5
- package/src/primitives/composer/types.ts +0 -5
- package/src/primitives/contentPart/types.ts +0 -4
- package/src/primitives/message/MessageInProgress.tsx +0 -22
- package/src/primitives/message/types.ts +0 -4
- package/src/primitives/thread/types.ts +0 -7
- package/src/runtimes/core/subscribeToMainThread.ts +0 -30
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport {\n ThreadListMetadata,\n ThreadListRuntimeCore,\n} from \"../core/ThreadListRuntimeCore\";\nimport { ExportedMessageRepository } from \"../utils/MessageRepository\";\nimport { generateId } from \"../../utils/idUtils\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\n\nexport type LocalThreadData = {\n data: ExportedMessageRepository;\n metadata: ThreadListMetadata;\n isArchived: boolean;\n};\n\nexport type LocalThreadFactory = (\n threadId: string,\n data: ExportedMessageRepository,\n) => LocalThreadRuntimeCore;\n\nexport class LocalThreadListRuntimeCore implements ThreadListRuntimeCore {\n private _threadData = new Map<string, LocalThreadData>();\n\n private _threads: readonly ThreadListMetadata[] = [];\n private _archivedThreads: readonly ThreadListMetadata[] = [];\n\n public get threads() {\n return this._threads;\n }\n\n public get archivedThreads() {\n return this._archivedThreads;\n }\n\n private _mainThread: LocalThreadRuntimeCore;\n\n public get mainThread(): LocalThreadRuntimeCore {\n return this._mainThread;\n }\n\n constructor(private _threadFactory: LocalThreadFactory) {\n const threadId = generateId();\n this._threadData.set(threadId, {\n data: { messages: [] },\n metadata: { threadId },\n isArchived: false,\n });\n this._threads = [{ threadId }];\n this._mainThread = this._threadFactory(threadId, { messages: [] });\n }\n\n public getThreadMetadataById(threadId: string) {\n return this._threadData.get(threadId)?.metadata;\n }\n\n public switchToThread(threadId: string): void {\n if (this._mainThread.threadId === threadId) return;\n\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n const thread = this._threadFactory(threadId, data.data);\n this._performThreadSwitch(thread);\n }\n\n public switchToNewThread(): void {\n const threadId = generateId();\n this._threadData.set(threadId, {\n data: { messages: [] },\n metadata: { threadId },\n isArchived: false,\n });\n this._threads = [{ threadId }];\n const thread = this._threadFactory(threadId, { messages: [] });\n this._performThreadSwitch(thread);\n }\n\n private _performThreadSwitch(newThreadCore: LocalThreadRuntimeCore) {\n const data = this._threadData.get(this._mainThread.threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n const exprt = this._mainThread.export();\n data.data = exprt;\n\n this._mainThread._notifyEventSubscribers(\"switched-away\");\n this._mainThread = newThreadCore;\n newThreadCore._notifyEventSubscribers(\"switched-to\");\n\n this._notifySubscribers();\n }\n\n private _performMoveOp(\n threadId: string,\n operation: \"archive\" | \"unarchive\" | \"delete\",\n ) {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n if (operation === \"archive\" && data.isArchived) return;\n if (operation === \"unarchive\" && !data.isArchived) return;\n\n if (operation === \"archive\") {\n data.isArchived = true;\n this._archivedThreads = [...this._archivedThreads, data.metadata];\n }\n if (operation === \"unarchive\") {\n data.isArchived = false;\n this._threads = [...this._threads, data.metadata];\n }\n if (operation === \"delete\") {\n this._threadData.delete(threadId);\n }\n\n if (\n operation === \"archive\" ||\n (operation === \"delete\" && data.isArchived)\n ) {\n this._archivedThreads = this._archivedThreads.filter(\n (t) => t.threadId !== threadId,\n );\n }\n\n if (\n operation === \"unarchive\" ||\n (operation === \"delete\" && !data.isArchived)\n ) {\n this._threads = this._threads.filter((t) => t.threadId !== threadId);\n }\n\n this._notifySubscribers();\n }\n\n public async rename(threadId: string, newTitle: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n data.metadata = {\n ...data.metadata,\n title: newTitle,\n };\n\n const threadList = data.isArchived ? this.archivedThreads : this.threads;\n const idx = threadList.findIndex((t) => t.threadId === threadId);\n const updatedThreadList = threadList.toSpliced(idx, 1, data.metadata);\n if (data.isArchived) {\n this._archivedThreads = updatedThreadList;\n } else {\n this._threads = updatedThreadList;\n }\n this._notifySubscribers();\n }\n\n public async archive(threadId: string): Promise<void> {\n this._performMoveOp(threadId, \"archive\");\n }\n\n public async unarchive(threadId: string): Promise<void> {\n this._performMoveOp(threadId, \"unarchive\");\n }\n\n public async delete(threadId: string): Promise<void> {\n this._performMoveOp(threadId, \"delete\");\n }\n\n private _subscriptions = new Set<() => void>();\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private _notifySubscribers() {\n for (const callback of this._subscriptions) callback();\n }\n}\n"],"mappings":";AAMA,SAAS,kBAAkB;AAcpB,IAAM,6BAAN,MAAkE;AAAA,EAoBvE,YAAoB,gBAAoC;AAApC;AAClB,UAAM,WAAW,WAAW;AAC5B,SAAK,YAAY,IAAI,UAAU;AAAA,MAC7B,MAAM,EAAE,UAAU,CAAC,EAAE;AAAA,MACrB,UAAU,EAAE,SAAS;AAAA,MACrB,YAAY;AAAA,IACd,CAAC;AACD,SAAK,WAAW,CAAC,EAAE,SAAS,CAAC;AAC7B,SAAK,cAAc,KAAK,eAAe,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC;AAAA,EACnE;AAAA,EA5BQ,cAAc,oBAAI,IAA6B;AAAA,EAE/C,WAA0C,CAAC;AAAA,EAC3C,mBAAkD,CAAC;AAAA,EAE3D,IAAW,UAAU;AACnB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,kBAAkB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ;AAAA,EAER,IAAW,aAAqC;AAC9C,WAAO,KAAK;AAAA,EACd;AAAA,EAaO,sBAAsB,UAAkB;AAC7C,WAAO,KAAK,YAAY,IAAI,QAAQ,GAAG;AAAA,EACzC;AAAA,EAEO,eAAe,UAAwB;AAC5C,QAAI,KAAK,YAAY,aAAa,SAAU;AAE5C,UAAM,OAAO,KAAK,YAAY,IAAI,QAAQ;AAC1C,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,kBAAkB;AAE7C,UAAM,SAAS,KAAK,eAAe,UAAU,KAAK,IAAI;AACtD,SAAK,qBAAqB,MAAM;AAAA,EAClC;AAAA,EAEO,oBAA0B;AAC/B,UAAM,WAAW,WAAW;AAC5B,SAAK,YAAY,IAAI,UAAU;AAAA,MAC7B,MAAM,EAAE,UAAU,CAAC,EAAE;AAAA,MACrB,UAAU,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M,EAAE,aAAa,QAAQ;AAAA,IACrE;AAEA,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAEA,MAAa,OAAO,UAAkB,UAAiC;AACrE,UAAM,OAAO,KAAK,YAAY,IAAI,QAAQ;AAC1C,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,kBAAkB;AAE7C,SAAK,WAAW;AAAA,MACd,GAAG,KAAK;AAAA,MACR,OAAO;AAAA,IACT;AAEA,UAAM,aAAa,KAAK,aAAa,KAAK,kBAAkB,KAAK;AACjE,UAAM,MAAM,WAAW,UAAU,CAAC,MAAM,EAAE,aAAa,QAAQ;AAC/D,UAAM,oBAAoB,WAAW,UAAU,KAAK,GAAG,KAAK,QAAQ;AACpE,QAAI,KAAK,YAAY;AACnB,WAAK,mBAAmB;AAAA,IAC1B,OAAO;AACL,WAAK,WAAW;AAAA,IAClB;AACA,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAEA,MAAa,QAAQ,UAAiC;AACpD,SAAK,eAAe,UAAU,SAAS;AAAA,EACzC;AAAA,EAEA,MAAa,UAAU,UAAiC;AACtD,SAAK,eAAe,UAAU,WAAW;AAAA,EAC3C;AAAA,EAEA,MAAa,OAAO,UAAiC;AACnD,SAAK,eAAe,UAAU,QAAQ;AAAA,EACxC;AAAA,EAEQ,iBAAiB,oBAAI,IAAgB;AAAA,EAEtC,UAAU,UAAmC;AAClD,SAAK,eAAe,IAAI,QAAQ;AAChC,WAAO,MAAM,KAAK,eAAe,OAAO,QAAQ;AAAA,EAClD;AAAA,EAEQ,qBAAqB;AAC3B,eAAW,YAAY,KAAK,eAAgB,UAAS;AAAA,EACvD;AACF;","names":[]}
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport { ExportedMessageRepository } from \"../utils/MessageRepository\";\nimport { generateId } from \"../../utils/idUtils\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\nimport { ThreadMetadata } from \"../core/ThreadRuntimeCore\";\n\nexport type ThreadListAdapter = {\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport type LocalThreadData = {\n runtime: LocalThreadRuntimeCore;\n lastState: ThreadMetadata[\"state\"];\n dispose: Unsubscribe;\n};\n\nexport type LocalThreadFactory = (\n threadId: string,\n data: ExportedMessageRepository,\n) => LocalThreadRuntimeCore;\n\nexport class LocalThreadListRuntimeCore implements ThreadListRuntimeCore {\n private _threadData = new Map<string, LocalThreadData>();\n private _threads: readonly string[] = [];\n private _archivedThreads: readonly string[] = [];\n private _newThread: string | undefined;\n\n public get newThread() {\n return this._newThread;\n }\n\n public get threads() {\n return this._threads;\n }\n\n public get archivedThreads() {\n return this._archivedThreads;\n }\n\n private _mainThread!: LocalThreadRuntimeCore;\n\n public get mainThread(): LocalThreadRuntimeCore {\n return this._mainThread;\n }\n\n constructor(private _threadFactory: LocalThreadFactory) {\n this.switchToNewThread();\n }\n\n public getThreadMetadataById(threadId: string) {\n return this._threadData.get(threadId)?.runtime.metadata;\n }\n\n public switchToThread(threadId: string): Promise<void> {\n if (this._mainThread?.metadata.threadId === threadId)\n return Promise.resolve();\n\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n if (data.runtime.metadata.state === \"archived\") this.unarchive(threadId);\n\n this._mainThread?._notifyEventSubscribers(\"switched-away\");\n this._mainThread = data.runtime;\n this._notifySubscribers();\n\n data.runtime._notifyEventSubscribers(\"switched-to\");\n return Promise.resolve();\n }\n\n public switchToNewThread(): Promise<void> {\n if (this._newThread === undefined) {\n let threadId: string;\n do {\n threadId = generateId();\n } while (this._threadData.has(threadId));\n\n const runtime = this._threadFactory(threadId, { messages: [] });\n const dispose = runtime.metadata.subscribe(() => {\n this._syncState(threadId, runtime.metadata);\n threadId = runtime.metadata.threadId;\n });\n this._threadData.set(threadId, { runtime, lastState: \"new\", dispose });\n this._newThread = threadId;\n }\n\n this.switchToThread(this._newThread);\n return Promise.resolve();\n }\n\n private async _syncState(\n lastThreadId: string,\n { state, threadId }: ThreadMetadata,\n ) {\n const data = this._threadData.get(lastThreadId);\n if (!data) throw new Error(\"Thread not found\");\n const lastState = data.lastState;\n if (lastState === state && lastThreadId === threadId) return;\n\n if (lastThreadId !== threadId) {\n this._threadData.delete(lastThreadId);\n if (lastState === \"new\") {\n this._newThread = threadId;\n }\n if (lastState === \"regular\") {\n this._threads = this._threads.map((t) =>\n t === lastThreadId ? threadId : t,\n );\n }\n if (lastState === \"archived\") {\n this._archivedThreads = this._archivedThreads.map((t) =>\n t === lastThreadId ? threadId : t,\n );\n }\n }\n\n if (lastState !== state) {\n if (lastState === \"new\") {\n this._newThread = undefined;\n }\n\n if (lastState === \"regular\") {\n this._threads = this._threads.filter((t) => t !== threadId);\n }\n\n if (lastState === \"archived\") {\n this._archivedThreads = this._archivedThreads.filter(\n (t) => t !== threadId,\n );\n }\n\n if (state === \"new\") {\n if (this._newThread) {\n this.delete(this._newThread);\n }\n this._newThread = threadId;\n }\n if (state === \"archived\") {\n this._archivedThreads = [\n ...this._archivedThreads,\n data.runtime.metadata.threadId,\n ];\n }\n if (state === \"regular\") {\n this._threads = [...this._threads, data.runtime.metadata.threadId];\n }\n if (state === \"deleted\") {\n data.dispose();\n this._threadData.delete(threadId);\n }\n\n data.lastState = state;\n }\n\n this._notifySubscribers();\n\n if (\n threadId === this._mainThread.metadata.threadId &&\n (state === \"archived\" || state === \"deleted\")\n ) {\n const lastThread = this._threads[0];\n if (lastThread) {\n await this.switchToThread(lastThread);\n } else {\n await this.switchToNewThread();\n }\n }\n }\n\n public rename(threadId: string, newTitle: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n data.runtime.metadata.rename(newTitle);\n\n return Promise.resolve();\n }\n\n public archive(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.lastState !== \"regular\")\n throw new Error(\"Thread is not yet created or archived\");\n data.runtime.metadata.archive();\n\n return Promise.resolve();\n }\n\n public unarchive(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.lastState !== \"archived\")\n throw new Error(\"Thread is not archived\");\n data.runtime.metadata.unarchive();\n\n return Promise.resolve();\n }\n\n public delete(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.lastState !== \"regular\" && data.lastState !== \"archived\")\n throw new Error(\"Thread is not yet created or already deleted\");\n data.runtime.metadata.delete();\n\n return Promise.resolve();\n }\n\n private _subscriptions = new Set<() => void>();\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private _notifySubscribers() {\n for (const callback of this._subscriptions) callback();\n }\n}\n"],"mappings":";AAGA,SAAS,kBAAkB;AAmBpB,IAAM,6BAAN,MAAkE;AAAA,EAwBvE,YAAoB,gBAAoC;AAApC;AAClB,SAAK,kBAAkB;AAAA,EACzB;AAAA,EAzBQ,cAAc,oBAAI,IAA6B;AAAA,EAC/C,WAA8B,CAAC;AAAA,EAC/B,mBAAsC,CAAC;AAAA,EACvC;AAAA,EAER,IAAW,YAAY;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,UAAU;AACnB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,kBAAkB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ;AAAA,EAER,IAAW,aAAqC;AAC9C,WAAO,KAAK;AAAA,EACd;AAAA,EAMO,sBAAsB,UAAkB;AAC7C,WAAO,KAAK,YAAY,IAAI,QAAQ,GAAG,QAAQ;AAAA,EACjD;AAAA,EAEO,eAAe,UAAiC;AACrD,QAAI,KAAK,aAAa,SAAS,aAAa;AAC1C,aAAO,QAAQ,QAAQ;AAEzB,UAAM,OAAO,KAAK,YA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Core {
|
3
|
+
private _threadId;
|
4
|
+
private _state;
|
5
|
+
private _title;
|
6
|
+
private _subscribers;
|
7
|
+
constructor(_threadId: string);
|
8
|
+
get threadId(): string;
|
9
|
+
get state(): "archived" | "regular" | "new" | "deleted";
|
10
|
+
get title(): string | undefined;
|
11
|
+
rename(newTitle: string): Promise<void>;
|
12
|
+
archive(): Promise<void>;
|
13
|
+
unarchive(): Promise<void>;
|
14
|
+
delete(): Promise<void>;
|
15
|
+
create(title?: string): Promise<void>;
|
16
|
+
subscribe(callback: () => void): () => boolean;
|
17
|
+
private _notifySubscribers;
|
18
|
+
}
|
19
|
+
//# sourceMappingURL=LocalThreadMetadataRuntimeCore.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"LocalThreadMetadataRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/LocalThreadMetadataRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,qBAAa,8BACX,YAAW,yBAAyB;IAMxB,OAAO,CAAC,SAAS;IAJ7B,OAAO,CAAC,MAAM,CAAqD;IACnE,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,YAAY,CAAyB;gBAEzB,SAAS,EAAE,MAAM;IAErC,IAAW,QAAQ,WAElB;IAED,IAAW,KAAK,+CAEf;IAED,IAAW,KAAK,uBAEf;IAEM,MAAM,CAAC,QAAQ,EAAE,MAAM;IAOvB,OAAO;IAWP,SAAS;IAST,MAAM;IAUN,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM;IAUrB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI;IAKrC,OAAO,CAAC,kBAAkB;CAG3B"}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
|
20
|
+
// src/runtimes/local/LocalThreadMetadataRuntimeCore.tsx
|
21
|
+
var LocalThreadMetadataRuntimeCore_exports = {};
|
22
|
+
__export(LocalThreadMetadataRuntimeCore_exports, {
|
23
|
+
LocalThreadMetadataRuntimeCore: () => LocalThreadMetadataRuntimeCore
|
24
|
+
});
|
25
|
+
module.exports = __toCommonJS(LocalThreadMetadataRuntimeCore_exports);
|
26
|
+
var LocalThreadMetadataRuntimeCore = class {
|
27
|
+
constructor(_threadId) {
|
28
|
+
this._threadId = _threadId;
|
29
|
+
}
|
30
|
+
_state = "new";
|
31
|
+
_title;
|
32
|
+
_subscribers = /* @__PURE__ */ new Set();
|
33
|
+
get threadId() {
|
34
|
+
return this._threadId;
|
35
|
+
}
|
36
|
+
get state() {
|
37
|
+
return this._state;
|
38
|
+
}
|
39
|
+
get title() {
|
40
|
+
return this._title;
|
41
|
+
}
|
42
|
+
rename(newTitle) {
|
43
|
+
this._title = newTitle;
|
44
|
+
this._notifySubscribers();
|
45
|
+
return Promise.resolve();
|
46
|
+
}
|
47
|
+
archive() {
|
48
|
+
if (this._state === "new") throw new Error("Thread not created");
|
49
|
+
if (this._state === "archived") throw new Error("Thread already archived");
|
50
|
+
if (this._state === "deleted") throw new Error("Thread deleted");
|
51
|
+
this._state = "archived";
|
52
|
+
this._notifySubscribers();
|
53
|
+
return Promise.resolve();
|
54
|
+
}
|
55
|
+
unarchive() {
|
56
|
+
if (this._state !== "archived") throw new Error("Thread not archived");
|
57
|
+
this._state = "regular";
|
58
|
+
this._notifySubscribers();
|
59
|
+
return Promise.resolve();
|
60
|
+
}
|
61
|
+
delete() {
|
62
|
+
if (this._state === "new") throw new Error("Thread not created");
|
63
|
+
if (this._state === "deleted") throw new Error("Thread already deleted");
|
64
|
+
this._state = "deleted";
|
65
|
+
this._notifySubscribers();
|
66
|
+
return Promise.resolve();
|
67
|
+
}
|
68
|
+
create(title) {
|
69
|
+
if (this.state !== "new") throw new Error("Thread not new");
|
70
|
+
this._state = "regular";
|
71
|
+
this._title = title ?? this._title;
|
72
|
+
this._notifySubscribers();
|
73
|
+
return Promise.resolve();
|
74
|
+
}
|
75
|
+
subscribe(callback) {
|
76
|
+
this._subscribers.add(callback);
|
77
|
+
return () => this._subscribers.delete(callback);
|
78
|
+
}
|
79
|
+
_notifySubscribers() {
|
80
|
+
for (const callback of this._subscribers) callback();
|
81
|
+
}
|
82
|
+
};
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
84
|
+
0 && (module.exports = {
|
85
|
+
LocalThreadMetadataRuntimeCore
|
86
|
+
});
|
87
|
+
//# sourceMappingURL=LocalThreadMetadataRuntimeCore.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadMetadataRuntimeCore.tsx"],"sourcesContent":["import { ThreadMetadataRuntimeCore } from \"../core/ThreadRuntimeCore\";\n\nexport class LocalThreadMetadataRuntimeCore\n implements ThreadMetadataRuntimeCore\n{\n private _state: \"regular\" | \"archived\" | \"deleted\" | \"new\" = \"new\";\n private _title: string | undefined;\n private _subscribers = new Set<() => void>();\n\n constructor(private _threadId: string) {}\n\n public get threadId() {\n return this._threadId;\n }\n\n public get state() {\n return this._state;\n }\n\n public get title() {\n return this._title;\n }\n\n public rename(newTitle: string) {\n this._title = newTitle;\n this._notifySubscribers();\n\n return Promise.resolve();\n }\n\n public archive() {\n if (this._state === \"new\") throw new Error(\"Thread not created\");\n if (this._state === \"archived\") throw new Error(\"Thread already archived\");\n if (this._state === \"deleted\") throw new Error(\"Thread deleted\");\n\n this._state = \"archived\";\n this._notifySubscribers();\n\n return Promise.resolve();\n }\n\n public unarchive() {\n if (this._state !== \"archived\") throw new Error(\"Thread not archived\");\n\n this._state = \"regular\";\n this._notifySubscribers();\n\n return Promise.resolve();\n }\n\n public delete() {\n if (this._state === \"new\") throw new Error(\"Thread not created\");\n if (this._state === \"deleted\") throw new Error(\"Thread already deleted\");\n\n this._state = \"deleted\";\n this._notifySubscribers();\n\n return Promise.resolve();\n }\n\n public create(title?: string) {\n if (this.state !== \"new\") throw new Error(\"Thread not new\");\n\n this._state = \"regular\";\n this._title = title ?? this._title;\n this._notifySubscribers();\n\n return Promise.resolve();\n }\n\n public subscribe(callback: () => void) {\n this._subscribers.add(callback);\n return () => this._subscribers.delete(callback);\n }\n\n private _notifySubscribers() {\n for (const callback of this._subscribers) callback();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,iCAAN,MAEP;AAAA,EAKE,YAAoB,WAAmB;AAAnB;AAAA,EAAoB;AAAA,EAJhC,SAAqD;AAAA,EACrD;AAAA,EACA,eAAe,oBAAI,IAAgB;AAAA,EAI3C,IAAW,WAAW;AACpB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,QAAQ;AACjB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,QAAQ;AACjB,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,OAAO,UAAkB;AAC9B,SAAK,SAAS;AACd,SAAK,mBAAmB;AAExB,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,UAAU;AACf,QAAI,KAAK,WAAW,MAAO,OAAM,IAAI,MAAM,oBAAoB;AAC/D,QAAI,KAAK,WAAW,WAAY,OAAM,IAAI,MAAM,yBAAyB;AACzE,QAAI,KAAK,WAAW,UAAW,OAAM,IAAI,MAAM,gBAAgB;AAE/D,SAAK,SAAS;AACd,SAAK,mBAAmB;AAExB,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,YAAY;AACjB,QAAI,KAAK,WAAW,WAAY,OAAM,IAAI,MAAM,qBAAqB;AAErE,SAAK,SAAS;AACd,SAAK,mBAAmB;AAExB,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,SAAS;AACd,QAAI,KAAK,WAAW,MAAO,OAAM,IAAI,MAAM,oBAAoB;AAC/D,QAAI,KAAK,WAAW,UAAW,OAAM,IAAI,MAAM,wBAAwB;AAEvE,SAAK,SAAS;AACd,SAAK,mBAAmB;AAExB,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,OAAO,OAAgB;AAC5B,QAAI,KAAK,UAAU,MAAO,OAAM,IAAI,MAAM,gBAAgB;AAE1D,SAAK,SAAS;AACd,SAAK,SAAS,SAAS,KAAK;AAC5B,SAAK,mBAAmB;AAExB,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,UAAU,UAAsB;AACrC,SAAK,aAAa,IAAI,QAAQ;AAC9B,WAAO,MAAM,KAAK,aAAa,OAAO,QAAQ;AAAA,EAChD;AAAA,EAEQ,qBAAqB;AAC3B,eAAW,YAAY,KAAK,aAAc,UAAS;AAAA,EACrD;AACF;","names":[]}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
// src/runtimes/local/LocalThreadMetadataRuntimeCore.tsx
|
2
|
+
var LocalThreadMetadataRuntimeCore = class {
|
3
|
+
constructor(_threadId) {
|
4
|
+
this._threadId = _threadId;
|
5
|
+
}
|
6
|
+
_state = "new";
|
7
|
+
_title;
|
8
|
+
_subscribers = /* @__PURE__ */ new Set();
|
9
|
+
get threadId() {
|
10
|
+
return this._threadId;
|
11
|
+
}
|
12
|
+
get state() {
|
13
|
+
return this._state;
|
14
|
+
}
|
15
|
+
get title() {
|
16
|
+
return this._title;
|
17
|
+
}
|
18
|
+
rename(newTitle) {
|
19
|
+
this._title = newTitle;
|
20
|
+
this._notifySubscribers();
|
21
|
+
return Promise.resolve();
|
22
|
+
}
|
23
|
+
archive() {
|
24
|
+
if (this._state === "new") throw new Error("Thread not created");
|
25
|
+
if (this._state === "archived") throw new Error("Thread already archived");
|
26
|
+
if (this._state === "deleted") throw new Error("Thread deleted");
|
27
|
+
this._state = "archived";
|
28
|
+
this._notifySubscribers();
|
29
|
+
return Promise.resolve();
|
30
|
+
}
|
31
|
+
unarchive() {
|
32
|
+
if (this._state !== "archived") throw new Error("Thread not archived");
|
33
|
+
this._state = "regular";
|
34
|
+
this._notifySubscribers();
|
35
|
+
return Promise.resolve();
|
36
|
+
}
|
37
|
+
delete() {
|
38
|
+
if (this._state === "new") throw new Error("Thread not created");
|
39
|
+
if (this._state === "deleted") throw new Error("Thread already deleted");
|
40
|
+
this._state = "deleted";
|
41
|
+
this._notifySubscribers();
|
42
|
+
return Promise.resolve();
|
43
|
+
}
|
44
|
+
create(title) {
|
45
|
+
if (this.state !== "new") throw new Error("Thread not new");
|
46
|
+
this._state = "regular";
|
47
|
+
this._title = title ?? this._title;
|
48
|
+
this._notifySubscribers();
|
49
|
+
return Promise.resolve();
|
50
|
+
}
|
51
|
+
subscribe(callback) {
|
52
|
+
this._subscribers.add(callback);
|
53
|
+
return () => this._subscribers.delete(callback);
|
54
|
+
}
|
55
|
+
_notifySubscribers() {
|
56
|
+
for (const callback of this._subscribers) callback();
|
57
|
+
}
|
58
|
+
};
|
59
|
+
export {
|
60
|
+
LocalThreadMetadataRuntimeCore
|
61
|
+
};
|
62
|
+
//# sourceMappingURL=LocalThreadMetadataRuntimeCore.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadMetadataRuntimeCore.tsx"],"sourcesContent":["import { ThreadMetadataRuntimeCore } from \"../core/ThreadRuntimeCore\";\n\nexport class LocalThreadMetadataRuntimeCore\n implements ThreadMetadataRuntimeCore\n{\n private _state: \"regular\" | \"archived\" | \"deleted\" | \"new\" = \"new\";\n private _title: string | undefined;\n private _subscribers = new Set<() => void>();\n\n constructor(private _threadId: string) {}\n\n public get threadId() {\n return this._threadId;\n }\n\n public get state() {\n return this._state;\n }\n\n public get title() {\n return this._title;\n }\n\n public rename(newTitle: string) {\n this._title = newTitle;\n this._notifySubscribers();\n\n return Promise.resolve();\n }\n\n public archive() {\n if (this._state === \"new\") throw new Error(\"Thread not created\");\n if (this._state === \"archived\") throw new Error(\"Thread already archived\");\n if (this._state === \"deleted\") throw new Error(\"Thread deleted\");\n\n this._state = \"archived\";\n this._notifySubscribers();\n\n return Promise.resolve();\n }\n\n public unarchive() {\n if (this._state !== \"archived\") throw new Error(\"Thread not archived\");\n\n this._state = \"regular\";\n this._notifySubscribers();\n\n return Promise.resolve();\n }\n\n public delete() {\n if (this._state === \"new\") throw new Error(\"Thread not created\");\n if (this._state === \"deleted\") throw new Error(\"Thread already deleted\");\n\n this._state = \"deleted\";\n this._notifySubscribers();\n\n return Promise.resolve();\n }\n\n public create(title?: string) {\n if (this.state !== \"new\") throw new Error(\"Thread not new\");\n\n this._state = \"regular\";\n this._title = title ?? this._title;\n this._notifySubscribers();\n\n return Promise.resolve();\n }\n\n public subscribe(callback: () => void) {\n this._subscribers.add(callback);\n return () => this._subscribers.delete(callback);\n }\n\n private _notifySubscribers() {\n for (const callback of this._subscribers) callback();\n }\n}\n"],"mappings":";AAEO,IAAM,iCAAN,MAEP;AAAA,EAKE,YAAoB,WAAmB;AAAnB;AAAA,EAAoB;AAAA,EAJhC,SAAqD;AAAA,EACrD;AAAA,EACA,eAAe,oBAAI,IAAgB;AAAA,EAI3C,IAAW,WAAW;AACpB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,QAAQ;AACjB,WAAO,KAAK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ntimeOptions";
|
|
3
3
|
import { AddToolResultOptions, ThreadSuggestion, ThreadRuntimeCore } from "../core/ThreadRuntimeCore";
|
4
4
|
import { BaseThreadRuntimeCore } from "../core/BaseThreadRuntimeCore";
|
5
5
|
export declare class LocalThreadRuntimeCore extends BaseThreadRuntimeCore implements ThreadRuntimeCore {
|
6
|
-
readonly threadId: string;
|
7
6
|
readonly capabilities: {
|
8
7
|
switchToBranch: boolean;
|
9
8
|
edit: boolean;
|
@@ -27,6 +26,7 @@ export declare class LocalThreadRuntimeCore extends BaseThreadRuntimeCore implem
|
|
27
26
|
private _options;
|
28
27
|
get extras(): undefined;
|
29
28
|
setOptions(options: LocalRuntimeOptionsBase): void;
|
29
|
+
private _transitionAwayFromNewState;
|
30
30
|
append(message: AppendMessage): Promise<void>;
|
31
31
|
startRun(parentId: string | null): Promise<void>;
|
32
32
|
private performRoundtrip;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LocalThreadRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/LocalThreadRuntimeCore.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EAEd,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;
|
1
|
+
{"version":3,"file":"LocalThreadRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/LocalThreadRuntimeCore.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EAEd,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,qBAAa,sBACX,SAAQ,qBACR,YAAW,iBAAiB;IAE5B,SAAgB,YAAY;;;;;;;;;MAS1B;IAEF,OAAO,CAAC,eAAe,CAAgC;IAEvD,SAAgB,UAAU,SAAS;IACnC,SAAgB,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAM;IAE9D,IAAW,QAAQ;;;;;MAElB;gBAGC,cAAc,EAAE,mBAAmB,EACnC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,uBAAuB;IAMlC,OAAO,CAAC,QAAQ,CAA2B;IAE3C,IAAW,MAAM,cAEhB;IAEM,UAAU,CAAC,OAAO,EAAE,uBAAuB;IA4BlD,OAAO,CAAC,2BAA2B;IAMtB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB7C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YAsB/C,gBAAgB;IA0GvB,SAAS;IAKT,aAAa,CAAC,EACnB,SAAS,EACT,UAAU,EACV,MAAM,GACP,EAAE,oBAAoB;CAkCxB"}
|
@@ -27,12 +27,8 @@ var import_internal = require("../../internal.cjs");
|
|
27
27
|
var import_edge = require("../edge/index.cjs");
|
28
28
|
var import_shouldContinue = require("./shouldContinue.cjs");
|
29
29
|
var import_BaseThreadRuntimeCore = require("../core/BaseThreadRuntimeCore.cjs");
|
30
|
+
var import_LocalThreadMetadataRuntimeCore = require("./LocalThreadMetadataRuntimeCore.cjs");
|
30
31
|
var LocalThreadRuntimeCore = class extends import_BaseThreadRuntimeCore.BaseThreadRuntimeCore {
|
31
|
-
constructor(configProvider, threadId, options) {
|
32
|
-
super(configProvider);
|
33
|
-
this.threadId = threadId;
|
34
|
-
this.setOptions(options);
|
35
|
-
}
|
36
32
|
capabilities = {
|
37
33
|
switchToBranch: true,
|
38
34
|
edit: true,
|
@@ -49,6 +45,10 @@ var LocalThreadRuntimeCore = class extends import_BaseThreadRuntimeCore.BaseThre
|
|
49
45
|
get adapters() {
|
50
46
|
return this._options.adapters;
|
51
47
|
}
|
48
|
+
constructor(configProvider, threadId, options) {
|
49
|
+
super(configProvider, new import_LocalThreadMetadataRuntimeCore.LocalThreadMetadataRuntimeCore(threadId));
|
50
|
+
this.setOptions(options);
|
51
|
+
}
|
52
52
|
_options;
|
53
53
|
get extras() {
|
54
54
|
return void 0;
|
@@ -74,7 +74,13 @@ var LocalThreadRuntimeCore = class extends import_BaseThreadRuntimeCore.BaseThre
|
|
74
74
|
}
|
75
75
|
if (hasUpdates) this._notifySubscribers();
|
76
76
|
}
|
77
|
+
_transitionAwayFromNewState() {
|
78
|
+
if (this.metadata.state === "new") {
|
79
|
+
this.metadata.create();
|
80
|
+
}
|
81
|
+
}
|
77
82
|
async append(message) {
|
83
|
+
this._transitionAwayFromNewState();
|
78
84
|
const newMessage = (0, import_edge.fromCoreMessage)(message, {
|
79
85
|
attachments: message.attachments
|
80
86
|
});
|
@@ -88,6 +94,7 @@ var LocalThreadRuntimeCore = class extends import_BaseThreadRuntimeCore.BaseThre
|
|
88
94
|
}
|
89
95
|
}
|
90
96
|
async startRun(parentId) {
|
97
|
+
this._transitionAwayFromNewState();
|
91
98
|
this.repository.resetHead(parentId);
|
92
99
|
const id = (0, import_internal.generateId)();
|
93
100
|
let message = {
|
@@ -110,18 +117,16 @@ var LocalThreadRuntimeCore = class extends import_BaseThreadRuntimeCore.BaseThre
|
|
110
117
|
const initialSteps = message.metadata?.steps;
|
111
118
|
const initalCustom = message.metadata?.custom;
|
112
119
|
const updateMessage = (m) => {
|
113
|
-
const newSteps = m.metadata?.steps
|
120
|
+
const newSteps = m.metadata?.steps;
|
114
121
|
const steps2 = newSteps ? [...initialSteps ?? [], ...newSteps] : void 0;
|
115
122
|
message = {
|
116
123
|
...message,
|
117
124
|
...m.content ? { content: [...initialContent, ...m.content ?? []] } : void 0,
|
118
125
|
status: m.status ?? message.status,
|
119
|
-
// TODO deprecated, remove in v0.6
|
120
|
-
...steps2 ? { roundtrips: steps2 } : void 0,
|
121
126
|
...m.metadata ? {
|
122
127
|
metadata: {
|
123
128
|
...message.metadata,
|
124
|
-
...steps2 ? {
|
129
|
+
...steps2 ? { steps: steps2 } : void 0,
|
125
130
|
...m.metadata?.custom ? {
|
126
131
|
custom: { ...initalCustom ?? {}, ...m.metadata.custom }
|
127
132
|
} : void 0
|
@@ -131,7 +136,7 @@ var LocalThreadRuntimeCore = class extends import_BaseThreadRuntimeCore.BaseThre
|
|
131
136
|
this.repository.addOrUpdateMessage(parentId, message);
|
132
137
|
this._notifySubscribers();
|
133
138
|
};
|
134
|
-
const maxSteps = this._options.maxSteps
|
139
|
+
const maxSteps = this._options.maxSteps ?? 2;
|
135
140
|
const steps = message.metadata?.steps?.length ?? 0;
|
136
141
|
if (steps >= maxSteps) {
|
137
142
|
updateMessage({
|
@@ -153,7 +158,6 @@ var LocalThreadRuntimeCore = class extends import_BaseThreadRuntimeCore.BaseThre
|
|
153
158
|
messages,
|
154
159
|
abortSignal: this.abortController.signal,
|
155
160
|
config: this.getModelConfig(),
|
156
|
-
onUpdate: updateMessage,
|
157
161
|
unstable_assistantMessageId: message.id
|
158
162
|
});
|
159
163
|
if (Symbol.asyncIterator in promiseOrGenerator) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadRuntimeCore.tsx"],"sourcesContent":["import { generateId } from \"../../internal\";\nimport type {\n ModelConfigProvider,\n AppendMessage,\n ThreadAssistantMessage,\n} from \"../../types\";\nimport { fromCoreMessage } from \"../edge\";\nimport type { ChatModelRunResult } from \"./ChatModelAdapter\";\nimport { shouldContinue } from \"./shouldContinue\";\nimport { LocalRuntimeOptionsBase } from \"./LocalRuntimeOptions\";\nimport {\n AddToolResultOptions,\n ThreadSuggestion,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\n\nexport class LocalThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n public readonly capabilities = {\n switchToBranch: true,\n edit: true,\n reload: true,\n cancel: true,\n unstable_copy: true,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n private abortController: AbortController | null = null;\n\n public readonly isDisabled = false;\n public readonly suggestions: readonly ThreadSuggestion[] = [];\n\n public get adapters() {\n return this._options.adapters;\n }\n\n constructor(\n configProvider: ModelConfigProvider,\n public readonly threadId: string,\n options: LocalRuntimeOptionsBase,\n ) {\n super(configProvider);\n\n this.setOptions(options);\n }\n\n private _options!: LocalRuntimeOptionsBase;\n\n public get extras() {\n return undefined;\n }\n\n public setOptions(options: LocalRuntimeOptionsBase) {\n if (this._options === options) return;\n\n this._options = options;\n\n let hasUpdates = false;\n\n const canSpeak = options.adapters?.speech !== undefined;\n if (this.capabilities.speech !== canSpeak) {\n this.capabilities.speech = canSpeak;\n hasUpdates = true;\n }\n\n const canAttach = options.adapters?.attachments !== undefined;\n if (this.capabilities.attachments !== canAttach) {\n this.capabilities.attachments = canAttach;\n hasUpdates = true;\n }\n\n const canFeedback = options.adapters?.feedback !== undefined;\n if (this.capabilities.feedback !== canFeedback) {\n this.capabilities.feedback = canFeedback;\n hasUpdates = true;\n }\n\n if (hasUpdates) this._notifySubscribers();\n }\n\n public async append(message: AppendMessage): Promise<void> {\n const newMessage = fromCoreMessage(message, {\n attachments: message.attachments,\n });\n this.repository.addOrUpdateMessage(message.parentId, newMessage);\n\n const startRun = message.startRun ?? message.role === \"user\";\n if (startRun) {\n await this.startRun(newMessage.id);\n } else {\n this.repository.resetHead(newMessage.id);\n this._notifySubscribers();\n }\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n this.repository.resetHead(parentId);\n\n // add assistant message\n const id = generateId();\n let message: ThreadAssistantMessage = {\n id,\n role: \"assistant\",\n status: { type: \"running\" },\n content: [],\n createdAt: new Date(),\n };\n\n this._notifyEventSubscribers(\"run-start\");\n\n do {\n message = await this.performRoundtrip(parentId, message);\n } while (shouldContinue(message));\n }\n\n private async performRoundtrip(\n parentId: string | null,\n message: ThreadAssistantMessage,\n ) {\n const messages = this.repository.getMessages();\n\n // abort existing run\n this.abortController?.abort();\n this.abortController = new AbortController();\n\n const initialContent = message.content;\n const initialSteps = message.metadata?.steps;\n const initalCustom = message.metadata?.custom;\n const updateMessage = (m: Partial<ChatModelRunResult>) => {\n const newSteps = m.metadata?.steps || m.metadata?.roundtrips;\n const steps = newSteps\n ? [...(initialSteps ?? []), ...newSteps]\n : undefined;\n\n message = {\n ...message,\n ...(m.content\n ? { content: [...initialContent, ...(m.content ?? [])] }\n : undefined),\n status: m.status ?? message.status,\n // TODO deprecated, remove in v0.6\n ...(steps ? { roundtrips: steps } : undefined),\n ...(m.metadata\n ? {\n metadata: {\n ...message.metadata,\n ...(steps ? { roundtrips: steps, steps } : undefined),\n ...(m.metadata?.custom\n ? {\n custom: { ...(initalCustom ?? {}), ...m.metadata.custom },\n }\n : undefined),\n },\n }\n : undefined),\n };\n this.repository.addOrUpdateMessage(parentId, message);\n this._notifySubscribers();\n };\n\n const maxSteps = this._options.maxSteps\n ? this._options.maxSteps\n : (this._options.maxToolRoundtrips ?? 1) + 1;\n\n const steps = message.metadata?.steps?.length ?? 0;\n if (steps >= maxSteps) {\n // reached max tool steps\n updateMessage({\n status: {\n type: \"incomplete\",\n reason: \"tool-calls\",\n },\n });\n return message;\n } else {\n updateMessage({\n status: {\n type: \"running\",\n },\n });\n }\n\n try {\n const promiseOrGenerator = this.adapters.chatModel.run({\n messages,\n abortSignal: this.abortController.signal,\n config: this.getModelConfig(),\n onUpdate: updateMessage,\n unstable_assistantMessageId: message.id,\n });\n\n // handle async iterator for streaming results\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n updateMessage(r);\n }\n } else {\n updateMessage(await promiseOrGenerator);\n }\n\n this.abortController = null;\n\n if (message.status.type === \"running\") {\n updateMessage({\n status: { type: \"complete\", reason: \"unknown\" },\n });\n }\n } catch (e) {\n this.abortController = null;\n\n // TODO this should be handled by the run result stream\n if (e instanceof Error && e.name === \"AbortError\") {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n } else {\n updateMessage({\n status: { type: \"incomplete\", reason: \"error\", error: e },\n });\n\n throw e;\n }\n }\n return message;\n }\n\n public cancelRun() {\n this.abortController?.abort();\n this.abortController = null;\n }\n\n public addToolResult({\n messageId,\n toolCallId,\n result,\n }: AddToolResultOptions) {\n const messageData = this.repository.getMessage(messageId);\n const { parentId } = messageData;\n let { message } = messageData;\n\n if (message.role !== \"assistant\")\n throw new Error(\"Tried to add tool result to non-assistant message\");\n\n let added = false;\n let found = false;\n const newContent = message.content.map((c) => {\n if (c.type !== \"tool-call\") return c;\n if (c.toolCallId !== toolCallId) return c;\n found = true;\n if (!c.result) added = true;\n return {\n ...c,\n result,\n };\n });\n\n if (!found)\n throw new Error(\"Tried to add tool result to non-existing tool call\");\n\n message = {\n ...message,\n content: newContent,\n };\n this.repository.addOrUpdateMessage(parentId, message);\n\n if (added && shouldContinue(message)) {\n this.performRoundtrip(parentId, message);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA2B;AAM3B,kBAAgC;AAEhC,4BAA+B;AAO/B,mCAAsC;AAE/B,IAAM,yBAAN,cACG,mDAEV;AAAA,EAqBE,YACE,gBACgB,UAChB,SACA;AACA,UAAM,cAAc;AAHJ;AAKhB,SAAK,WAAW,OAAO;AAAA,EACzB;AAAA,EA5BgB,eAAe;AAAA,IAC7B,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,EAEQ,kBAA0C;AAAA,E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;AAAA,EACF,GAAyB;AACvB,UAAM,cAAc,KAAK,WAAW,WAAW,SAAS;AACxD,UAAM,EAAE,SAAS,IAAI;AACrB,QAAI,EAAE,QAAQ,IAAI;AAElB,QAAI,QAAQ,SAAS;AACnB,YAAM,IAAI,MAAM,mDAAmD;AAErE,QAAI,QAAQ;AACZ,QAAI,QAAQ;AACZ,UAAM,aAAa,QAAQ,QAAQ,IAAI,CAAC,MAAM;AAC5C,UAAI,EAAE,SAAS,YAAa,QAAO;AACnC,UAAI,EAAE,eAAe,WAAY,QAAO;AACxC,cAAQ;AACR,UAAI,CAAC,EAAE,OAAQ,SAAQ;AACvB,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,MACF;AAAA,IACF,CAAC;AAED,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,oDAAoD;AAEtE,cAAU;AAAA,MACR,GAAG;AAAA,MACH,SAAS;AAAA,IACX;AACA,SAAK,WAAW,mBAAmB,UAAU,OAAO;AAEpD,QAAI,aAAS,sCAAe,OAAO,GAAG;AACpC,WAAK,iBAAiB,UAAU,OAAO;AAAA,IACzC;AAAA,EACF;AACF;","names":["steps"]}
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadRuntimeCore.tsx"],"sourcesContent":["import { generateId } from \"../../internal\";\nimport type {\n ModelConfigProvider,\n AppendMessage,\n ThreadAssistantMessage,\n} from \"../../types\";\nimport { fromCoreMessage } from \"../edge\";\nimport type { ChatModelRunResult } from \"./ChatModelAdapter\";\nimport { shouldContinue } from \"./shouldContinue\";\nimport { LocalRuntimeOptionsBase } from \"./LocalRuntimeOptions\";\nimport {\n AddToolResultOptions,\n ThreadSuggestion,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\nimport { LocalThreadMetadataRuntimeCore } from \"./LocalThreadMetadataRuntimeCore\";\n\nexport class LocalThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n public readonly capabilities = {\n switchToBranch: true,\n edit: true,\n reload: true,\n cancel: true,\n unstable_copy: true,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n private abortController: AbortController | null = null;\n\n public readonly isDisabled = false;\n public readonly suggestions: readonly ThreadSuggestion[] = [];\n\n public get adapters() {\n return this._options.adapters;\n }\n\n constructor(\n configProvider: ModelConfigProvider,\n threadId: string,\n options: LocalRuntimeOptionsBase,\n ) {\n super(configProvider, new LocalThreadMetadataRuntimeCore(threadId));\n this.setOptions(options);\n }\n\n private _options!: LocalRuntimeOptionsBase;\n\n public get extras() {\n return undefined;\n }\n\n public setOptions(options: LocalRuntimeOptionsBase) {\n if (this._options === options) return;\n\n this._options = options;\n\n let hasUpdates = false;\n\n const canSpeak = options.adapters?.speech !== undefined;\n if (this.capabilities.speech !== canSpeak) {\n this.capabilities.speech = canSpeak;\n hasUpdates = true;\n }\n\n const canAttach = options.adapters?.attachments !== undefined;\n if (this.capabilities.attachments !== canAttach) {\n this.capabilities.attachments = canAttach;\n hasUpdates = true;\n }\n\n const canFeedback = options.adapters?.feedback !== undefined;\n if (this.capabilities.feedback !== canFeedback) {\n this.capabilities.feedback = canFeedback;\n hasUpdates = true;\n }\n\n if (hasUpdates) this._notifySubscribers();\n }\n\n private _transitionAwayFromNewState() {\n if (this.metadata.state === \"new\") {\n this.metadata.create();\n }\n }\n\n public async append(message: AppendMessage): Promise<void> {\n this._transitionAwayFromNewState();\n\n const newMessage = fromCoreMessage(message, {\n attachments: message.attachments,\n });\n this.repository.addOrUpdateMessage(message.parentId, newMessage);\n\n const startRun = message.startRun ?? message.role === \"user\";\n if (startRun) {\n await this.startRun(newMessage.id);\n } else {\n this.repository.resetHead(newMessage.id);\n this._notifySubscribers();\n }\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n this._transitionAwayFromNewState();\n\n this.repository.resetHead(parentId);\n\n // add assistant message\n const id = generateId();\n let message: ThreadAssistantMessage = {\n id,\n role: \"assistant\",\n status: { type: \"running\" },\n content: [],\n createdAt: new Date(),\n };\n\n this._notifyEventSubscribers(\"run-start\");\n\n do {\n message = await this.performRoundtrip(parentId, message);\n } while (shouldContinue(message));\n }\n\n private async performRoundtrip(\n parentId: string | null,\n message: ThreadAssistantMessage,\n ) {\n const messages = this.repository.getMessages();\n\n // abort existing run\n this.abortController?.abort();\n this.abortController = new AbortController();\n\n const initialContent = message.content;\n const initialSteps = message.metadata?.steps;\n const initalCustom = message.metadata?.custom;\n const updateMessage = (m: Partial<ChatModelRunResult>) => {\n const newSteps = m.metadata?.steps;\n const steps = newSteps\n ? [...(initialSteps ?? []), ...newSteps]\n : undefined;\n\n message = {\n ...message,\n ...(m.content\n ? { content: [...initialContent, ...(m.content ?? [])] }\n : undefined),\n status: m.status ?? message.status,\n ...(m.metadata\n ? {\n metadata: {\n ...message.metadata,\n ...(steps ? { steps } : undefined),\n ...(m.metadata?.custom\n ? {\n custom: { ...(initalCustom ?? {}), ...m.metadata.custom },\n }\n : undefined),\n },\n }\n : undefined),\n };\n this.repository.addOrUpdateMessage(parentId, message);\n this._notifySubscribers();\n };\n\n const maxSteps = this._options.maxSteps ?? 2;\n\n const steps = message.metadata?.steps?.length ?? 0;\n if (steps >= maxSteps) {\n // reached max tool steps\n updateMessage({\n status: {\n type: \"incomplete\",\n reason: \"tool-calls\",\n },\n });\n return message;\n } else {\n updateMessage({\n status: {\n type: \"running\",\n },\n });\n }\n\n try {\n const promiseOrGenerator = this.adapters.chatModel.run({\n messages,\n abortSignal: this.abortController.signal,\n config: this.getModelConfig(),\n unstable_assistantMessageId: message.id,\n });\n\n // handle async iterator for streaming results\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n updateMessage(r);\n }\n } else {\n updateMessage(await promiseOrGenerator);\n }\n\n this.abortController = null;\n\n if (message.status.type === \"running\") {\n updateMessage({\n status: { type: \"complete\", reason: \"unknown\" },\n });\n }\n } catch (e) {\n this.abortController = null;\n\n // TODO this should be handled by the run result stream\n if (e instanceof Error && e.name === \"AbortError\") {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n } else {\n updateMessage({\n status: { type: \"incomplete\", reason: \"error\", error: e },\n });\n\n throw e;\n }\n }\n return message;\n }\n\n public cancelRun() {\n this.abortController?.abort();\n this.abortController = null;\n }\n\n public addToolResult({\n messageId,\n toolCallId,\n result,\n }: AddToolResultOptions) {\n const messageData = this.repository.getMessage(messageId);\n const { parentId } = messageData;\n let { message } = messageData;\n\n if (message.role !== \"assistant\")\n throw new Error(\"Tried to add tool result to non-assistant message\");\n\n let added = false;\n let found = false;\n const newContent = message.content.map((c) => {\n if (c.type !== \"tool-call\") return c;\n if (c.toolCallId !== toolCallId) return c;\n found = true;\n if (!c.result) added = true;\n return {\n ...c,\n result,\n };\n });\n\n if (!found)\n throw new Error(\"Tried to add tool result to non-existing tool call\");\n\n message = {\n ...message,\n content: newContent,\n };\n this.repository.addOrUpdateMessage(parentId, message);\n\n if (added && shouldContinue(message)) {\n this.performRoundtrip(parentId, message);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA2B;AAM3B,kBAAgC;AAEhC,4BAA+B;AAO/B,mCAAsC;AACtC,4CAA+C;AAExC,IAAM,yBAAN,cACG,mDAEV;AAAA,EACkB,eAAe;AAAA,IAC7B,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,EAEQ,kBAA0C;AAAA,EAElC,aAAa;AAAA,EACb,cAA2C,CAAC;AAAA,EAE5D,IAAW,WAAW;AACpB,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,YACE,gBACA,UACA,SACA;AACA,UAAM,gBAAgB,IAAI,qEAA+B,QAAQ,CAAC;AAClE,SAAK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EAAE,SAAS,IAAI;AACrB,QAAI,EAAE,QAAQ,IAAI;AAElB,QAAI,QAAQ,SAAS;AACnB,YAAM,IAAI,MAAM,mDAAmD;AAErE,QAAI,QAAQ;AACZ,QAAI,QAAQ;AACZ,UAAM,aAAa,QAAQ,QAAQ,IAAI,CAAC,MAAM;AAC5C,UAAI,EAAE,SAAS,YAAa,QAAO;AACnC,UAAI,EAAE,eAAe,WAAY,QAAO;AACxC,cAAQ;AACR,UAAI,CAAC,EAAE,OAAQ,SAAQ;AACvB,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,MACF;AAAA,IACF,CAAC;AAED,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,oDAAoD;AAEtE,cAAU;AAAA,MACR,GAAG;AAAA,MACH,SAAS;AAAA,IACX;AACA,SAAK,WAAW,mBAAmB,UAAU,OAAO;AAEpD,QAAI,aAAS,sCAAe,OAAO,GAAG;AACpC,WAAK,iBAAiB,UAAU,OAAO;AAAA,IACzC;AAAA,EACF;AACF;","names":["steps"]}
|
@@ -3,12 +3,8 @@ import { generateId } from "../../internal.mjs";
|
|
3
3
|
import { fromCoreMessage } from "../edge/index.mjs";
|
4
4
|
import { shouldContinue } from "./shouldContinue.mjs";
|
5
5
|
import { BaseThreadRuntimeCore } from "../core/BaseThreadRuntimeCore.mjs";
|
6
|
+
import { LocalThreadMetadataRuntimeCore } from "./LocalThreadMetadataRuntimeCore.mjs";
|
6
7
|
var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
7
|
-
constructor(configProvider, threadId, options) {
|
8
|
-
super(configProvider);
|
9
|
-
this.threadId = threadId;
|
10
|
-
this.setOptions(options);
|
11
|
-
}
|
12
8
|
capabilities = {
|
13
9
|
switchToBranch: true,
|
14
10
|
edit: true,
|
@@ -25,6 +21,10 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
25
21
|
get adapters() {
|
26
22
|
return this._options.adapters;
|
27
23
|
}
|
24
|
+
constructor(configProvider, threadId, options) {
|
25
|
+
super(configProvider, new LocalThreadMetadataRuntimeCore(threadId));
|
26
|
+
this.setOptions(options);
|
27
|
+
}
|
28
28
|
_options;
|
29
29
|
get extras() {
|
30
30
|
return void 0;
|
@@ -50,7 +50,13 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
50
50
|
}
|
51
51
|
if (hasUpdates) this._notifySubscribers();
|
52
52
|
}
|
53
|
+
_transitionAwayFromNewState() {
|
54
|
+
if (this.metadata.state === "new") {
|
55
|
+
this.metadata.create();
|
56
|
+
}
|
57
|
+
}
|
53
58
|
async append(message) {
|
59
|
+
this._transitionAwayFromNewState();
|
54
60
|
const newMessage = fromCoreMessage(message, {
|
55
61
|
attachments: message.attachments
|
56
62
|
});
|
@@ -64,6 +70,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
64
70
|
}
|
65
71
|
}
|
66
72
|
async startRun(parentId) {
|
73
|
+
this._transitionAwayFromNewState();
|
67
74
|
this.repository.resetHead(parentId);
|
68
75
|
const id = generateId();
|
69
76
|
let message = {
|
@@ -86,18 +93,16 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
86
93
|
const initialSteps = message.metadata?.steps;
|
87
94
|
const initalCustom = message.metadata?.custom;
|
88
95
|
const updateMessage = (m) => {
|
89
|
-
const newSteps = m.metadata?.steps
|
96
|
+
const newSteps = m.metadata?.steps;
|
90
97
|
const steps2 = newSteps ? [...initialSteps ?? [], ...newSteps] : void 0;
|
91
98
|
message = {
|
92
99
|
...message,
|
93
100
|
...m.content ? { content: [...initialContent, ...m.content ?? []] } : void 0,
|
94
101
|
status: m.status ?? message.status,
|
95
|
-
// TODO deprecated, remove in v0.6
|
96
|
-
...steps2 ? { roundtrips: steps2 } : void 0,
|
97
102
|
...m.metadata ? {
|
98
103
|
metadata: {
|
99
104
|
...message.metadata,
|
100
|
-
...steps2 ? {
|
105
|
+
...steps2 ? { steps: steps2 } : void 0,
|
101
106
|
...m.metadata?.custom ? {
|
102
107
|
custom: { ...initalCustom ?? {}, ...m.metadata.custom }
|
103
108
|
} : void 0
|
@@ -107,7 +112,7 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
107
112
|
this.repository.addOrUpdateMessage(parentId, message);
|
108
113
|
this._notifySubscribers();
|
109
114
|
};
|
110
|
-
const maxSteps = this._options.maxSteps
|
115
|
+
const maxSteps = this._options.maxSteps ?? 2;
|
111
116
|
const steps = message.metadata?.steps?.length ?? 0;
|
112
117
|
if (steps >= maxSteps) {
|
113
118
|
updateMessage({
|
@@ -129,7 +134,6 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
129
134
|
messages,
|
130
135
|
abortSignal: this.abortController.signal,
|
131
136
|
config: this.getModelConfig(),
|
132
|
-
onUpdate: updateMessage,
|
133
137
|
unstable_assistantMessageId: message.id
|
134
138
|
});
|
135
139
|
if (Symbol.asyncIterator in promiseOrGenerator) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadRuntimeCore.tsx"],"sourcesContent":["import { generateId } from \"../../internal\";\nimport type {\n ModelConfigProvider,\n AppendMessage,\n ThreadAssistantMessage,\n} from \"../../types\";\nimport { fromCoreMessage } from \"../edge\";\nimport type { ChatModelRunResult } from \"./ChatModelAdapter\";\nimport { shouldContinue } from \"./shouldContinue\";\nimport { LocalRuntimeOptionsBase } from \"./LocalRuntimeOptions\";\nimport {\n AddToolResultOptions,\n ThreadSuggestion,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\n\nexport class LocalThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n public readonly capabilities = {\n switchToBranch: true,\n edit: true,\n reload: true,\n cancel: true,\n unstable_copy: true,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n private abortController: AbortController | null = null;\n\n public readonly isDisabled = false;\n public readonly suggestions: readonly ThreadSuggestion[] = [];\n\n public get adapters() {\n return this._options.adapters;\n }\n\n constructor(\n configProvider: ModelConfigProvider,\n public readonly threadId: string,\n options: LocalRuntimeOptionsBase,\n ) {\n super(configProvider);\n\n this.setOptions(options);\n }\n\n private _options!: LocalRuntimeOptionsBase;\n\n public get extras() {\n return undefined;\n }\n\n public setOptions(options: LocalRuntimeOptionsBase) {\n if (this._options === options) return;\n\n this._options = options;\n\n let hasUpdates = false;\n\n const canSpeak = options.adapters?.speech !== undefined;\n if (this.capabilities.speech !== canSpeak) {\n this.capabilities.speech = canSpeak;\n hasUpdates = true;\n }\n\n const canAttach = options.adapters?.attachments !== undefined;\n if (this.capabilities.attachments !== canAttach) {\n this.capabilities.attachments = canAttach;\n hasUpdates = true;\n }\n\n const canFeedback = options.adapters?.feedback !== undefined;\n if (this.capabilities.feedback !== canFeedback) {\n this.capabilities.feedback = canFeedback;\n hasUpdates = true;\n }\n\n if (hasUpdates) this._notifySubscribers();\n }\n\n public async append(message: AppendMessage): Promise<void> {\n const newMessage = fromCoreMessage(message, {\n attachments: message.attachments,\n });\n this.repository.addOrUpdateMessage(message.parentId, newMessage);\n\n const startRun = message.startRun ?? message.role === \"user\";\n if (startRun) {\n await this.startRun(newMessage.id);\n } else {\n this.repository.resetHead(newMessage.id);\n this._notifySubscribers();\n }\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n this.repository.resetHead(parentId);\n\n // add assistant message\n const id = generateId();\n let message: ThreadAssistantMessage = {\n id,\n role: \"assistant\",\n status: { type: \"running\" },\n content: [],\n createdAt: new Date(),\n };\n\n this._notifyEventSubscribers(\"run-start\");\n\n do {\n message = await this.performRoundtrip(parentId, message);\n } while (shouldContinue(message));\n }\n\n private async performRoundtrip(\n parentId: string | null,\n message: ThreadAssistantMessage,\n ) {\n const messages = this.repository.getMessages();\n\n // abort existing run\n this.abortController?.abort();\n this.abortController = new AbortController();\n\n const initialContent = message.content;\n const initialSteps = message.metadata?.steps;\n const initalCustom = message.metadata?.custom;\n const updateMessage = (m: Partial<ChatModelRunResult>) => {\n const newSteps = m.metadata?.steps || m.metadata?.roundtrips;\n const steps = newSteps\n ? [...(initialSteps ?? []), ...newSteps]\n : undefined;\n\n message = {\n ...message,\n ...(m.content\n ? { content: [...initialContent, ...(m.content ?? [])] }\n : undefined),\n status: m.status ?? message.status,\n // TODO deprecated, remove in v0.6\n ...(steps ? { roundtrips: steps } : undefined),\n ...(m.metadata\n ? {\n metadata: {\n ...message.metadata,\n ...(steps ? { roundtrips: steps, steps } : undefined),\n ...(m.metadata?.custom\n ? {\n custom: { ...(initalCustom ?? {}), ...m.metadata.custom },\n }\n : undefined),\n },\n }\n : undefined),\n };\n this.repository.addOrUpdateMessage(parentId, message);\n this._notifySubscribers();\n };\n\n const maxSteps = this._options.maxSteps\n ? this._options.maxSteps\n : (this._options.maxToolRoundtrips ?? 1) + 1;\n\n const steps = message.metadata?.steps?.length ?? 0;\n if (steps >= maxSteps) {\n // reached max tool steps\n updateMessage({\n status: {\n type: \"incomplete\",\n reason: \"tool-calls\",\n },\n });\n return message;\n } else {\n updateMessage({\n status: {\n type: \"running\",\n },\n });\n }\n\n try {\n const promiseOrGenerator = this.adapters.chatModel.run({\n messages,\n abortSignal: this.abortController.signal,\n config: this.getModelConfig(),\n onUpdate: updateMessage,\n unstable_assistantMessageId: message.id,\n });\n\n // handle async iterator for streaming results\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n updateMessage(r);\n }\n } else {\n updateMessage(await promiseOrGenerator);\n }\n\n this.abortController = null;\n\n if (message.status.type === \"running\") {\n updateMessage({\n status: { type: \"complete\", reason: \"unknown\" },\n });\n }\n } catch (e) {\n this.abortController = null;\n\n // TODO this should be handled by the run result stream\n if (e instanceof Error && e.name === \"AbortError\") {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n } else {\n updateMessage({\n status: { type: \"incomplete\", reason: \"error\", error: e },\n });\n\n throw e;\n }\n }\n return message;\n }\n\n public cancelRun() {\n this.abortController?.abort();\n this.abortController = null;\n }\n\n public addToolResult({\n messageId,\n toolCallId,\n result,\n }: AddToolResultOptions) {\n const messageData = this.repository.getMessage(messageId);\n const { parentId } = messageData;\n let { message } = messageData;\n\n if (message.role !== \"assistant\")\n throw new Error(\"Tried to add tool result to non-assistant message\");\n\n let added = false;\n let found = false;\n const newContent = message.content.map((c) => {\n if (c.type !== \"tool-call\") return c;\n if (c.toolCallId !== toolCallId) return c;\n found = true;\n if (!c.result) added = true;\n return {\n ...c,\n result,\n };\n });\n\n if (!found)\n throw new Error(\"Tried to add tool result to non-existing tool call\");\n\n message = {\n ...message,\n content: newContent,\n };\n this.repository.addOrUpdateMessage(parentId, message);\n\n if (added && shouldContinue(message)) {\n this.performRoundtrip(parentId, message);\n }\n }\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAM3B,SAAS,uBAAuB;AAEhC,SAAS,sBAAsB;AAO/B,SAAS,6BAA6B;AAE/B,IAAM,yBAAN,cACG,sBAEV;AAAA,EAqBE,YACE,gBACgB,UAChB,SACA;AACA,UAAM,cAAc;AAHJ;AAKhB,SAAK,WAAW,OAAO;AAAA,EACzB;AAAA,EA5BgB,eAAe;AAAA,IAC7B,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,EAEQ,kBAA0C;AAAA,EAElC,aAAa;AAAA,EACb,cAA2C,CAAC;AAAA,EAE5D,IAAW,WAAW;AACpB,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAYQ;AAAA,EAER,IAAW,SAAS;AAClB,WAAO;AAAA,EACT;AAAA,EAEO,WAAW,SAAkC;AAClD,QAAI,KAAK,aAAa,QAAS;AAE/B,SAAK,WAAW;AAEhB,QAAI,aAAa;AAEjB,UAAM,W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M;AAC5C,UAAI,EAAE,SAAS,YAAa,QAAO;AACnC,UAAI,EAAE,eAAe,WAAY,QAAO;AACxC,cAAQ;AACR,UAAI,CAAC,EAAE,OAAQ,SAAQ;AACvB,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,MACF;AAAA,IACF,CAAC;AAED,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,oDAAoD;AAEtE,cAAU;AAAA,MACR,GAAG;AAAA,MACH,SAAS;AAAA,IACX;AACA,SAAK,WAAW,mBAAmB,UAAU,OAAO;AAEpD,QAAI,SAAS,eAAe,OAAO,GAAG;AACpC,WAAK,iBAAiB,UAAU,OAAO;AAAA,IACzC;AAAA,EACF;AACF;","names":["steps"]}
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadRuntimeCore.tsx"],"sourcesContent":["import { generateId } from \"../../internal\";\nimport type {\n ModelConfigProvider,\n AppendMessage,\n ThreadAssistantMessage,\n} from \"../../types\";\nimport { fromCoreMessage } from \"../edge\";\nimport type { ChatModelRunResult } from \"./ChatModelAdapter\";\nimport { shouldContinue } from \"./shouldContinue\";\nimport { LocalRuntimeOptionsBase } from \"./LocalRuntimeOptions\";\nimport {\n AddToolResultOptions,\n ThreadSuggestion,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\nimport { LocalThreadMetadataRuntimeCore } from \"./LocalThreadMetadataRuntimeCore\";\n\nexport class LocalThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n public readonly capabilities = {\n switchToBranch: true,\n edit: true,\n reload: true,\n cancel: true,\n unstable_copy: true,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n private abortController: AbortController | null = null;\n\n public readonly isDisabled = false;\n public readonly suggestions: readonly ThreadSuggestion[] = [];\n\n public get adapters() {\n return this._options.adapters;\n }\n\n constructor(\n configProvider: ModelConfigProvider,\n threadId: string,\n options: LocalRuntimeOptionsBase,\n ) {\n super(configProvider, new LocalThreadMetadataRuntimeCore(threadId));\n this.setOptions(options);\n }\n\n private _options!: LocalRuntimeOptionsBase;\n\n public get extras() {\n return undefined;\n }\n\n public setOptions(options: LocalRuntimeOptionsBase) {\n if (this._options === options) return;\n\n this._options = options;\n\n let hasUpdates = false;\n\n const canSpeak = options.adapters?.speech !== undefined;\n if (this.capabilities.speech !== canSpeak) {\n this.capabilities.speech = canSpeak;\n hasUpdates = true;\n }\n\n const canAttach = options.adapters?.attachments !== undefined;\n if (this.capabilities.attachments !== canAttach) {\n this.capabilities.attachments = canAttach;\n hasUpdates = true;\n }\n\n const canFeedback = options.adapters?.feedback !== undefined;\n if (this.capabilities.feedback !== canFeedback) {\n this.capabilities.feedback = canFeedback;\n hasUpdates = true;\n }\n\n if (hasUpdates) this._notifySubscribers();\n }\n\n private _transitionAwayFromNewState() {\n if (this.metadata.state === \"new\") {\n this.metadata.create();\n }\n }\n\n public async append(message: AppendMessage): Promise<void> {\n this._transitionAwayFromNewState();\n\n const newMessage = fromCoreMessage(message, {\n attachments: message.attachments,\n });\n this.repository.addOrUpdateMessage(message.parentId, newMessage);\n\n const startRun = message.startRun ?? message.role === \"user\";\n if (startRun) {\n await this.startRun(newMessage.id);\n } else {\n this.repository.resetHead(newMessage.id);\n this._notifySubscribers();\n }\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n this._transitionAwayFromNewState();\n\n this.repository.resetHead(parentId);\n\n // add assistant message\n const id = generateId();\n let message: ThreadAssistantMessage = {\n id,\n role: \"assistant\",\n status: { type: \"running\" },\n content: [],\n createdAt: new Date(),\n };\n\n this._notifyEventSubscribers(\"run-start\");\n\n do {\n message = await this.performRoundtrip(parentId, message);\n } while (shouldContinue(message));\n }\n\n private async performRoundtrip(\n parentId: string | null,\n message: ThreadAssistantMessage,\n ) {\n const messages = this.repository.getMessages();\n\n // abort existing run\n this.abortController?.abort();\n this.abortController = new AbortController();\n\n const initialContent = message.content;\n const initialSteps = message.metadata?.steps;\n const initalCustom = message.metadata?.custom;\n const updateMessage = (m: Partial<ChatModelRunResult>) => {\n const newSteps = m.metadata?.steps;\n const steps = newSteps\n ? [...(initialSteps ?? []), ...newSteps]\n : undefined;\n\n message = {\n ...message,\n ...(m.content\n ? { content: [...initialContent, ...(m.content ?? [])] }\n : undefined),\n status: m.status ?? message.status,\n ...(m.metadata\n ? {\n metadata: {\n ...message.metadata,\n ...(steps ? { steps } : undefined),\n ...(m.metadata?.custom\n ? {\n custom: { ...(initalCustom ?? {}), ...m.metadata.custom },\n }\n : undefined),\n },\n }\n : undefined),\n };\n this.repository.addOrUpdateMessage(parentId, message);\n this._notifySubscribers();\n };\n\n const maxSteps = this._options.maxSteps ?? 2;\n\n const steps = message.metadata?.steps?.length ?? 0;\n if (steps >= maxSteps) {\n // reached max tool steps\n updateMessage({\n status: {\n type: \"incomplete\",\n reason: \"tool-calls\",\n },\n });\n return message;\n } else {\n updateMessage({\n status: {\n type: \"running\",\n },\n });\n }\n\n try {\n const promiseOrGenerator = this.adapters.chatModel.run({\n messages,\n abortSignal: this.abortController.signal,\n config: this.getModelConfig(),\n unstable_assistantMessageId: message.id,\n });\n\n // handle async iterator for streaming results\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n updateMessage(r);\n }\n } else {\n updateMessage(await promiseOrGenerator);\n }\n\n this.abortController = null;\n\n if (message.status.type === \"running\") {\n updateMessage({\n status: { type: \"complete\", reason: \"unknown\" },\n });\n }\n } catch (e) {\n this.abortController = null;\n\n // TODO this should be handled by the run result stream\n if (e instanceof Error && e.name === \"AbortError\") {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n } else {\n updateMessage({\n status: { type: \"incomplete\", reason: \"error\", error: e },\n });\n\n throw e;\n }\n }\n return message;\n }\n\n public cancelRun() {\n this.abortController?.abort();\n this.abortController = null;\n }\n\n public addToolResult({\n messageId,\n toolCallId,\n result,\n }: AddToolResultOptions) {\n const messageData = this.repository.getMessage(messageId);\n const { parentId } = messageData;\n let { message } = messageData;\n\n if (message.role !== \"assistant\")\n throw new Error(\"Tried to add tool result to non-assistant message\");\n\n let added = false;\n let found = false;\n const newContent = message.content.map((c) => {\n if (c.type !== \"tool-call\") return c;\n if (c.toolCallId !== toolCallId) return c;\n found = true;\n if (!c.result) added = true;\n return {\n ...c,\n result,\n };\n });\n\n if (!found)\n throw new Error(\"Tried to add tool result to non-existing tool call\");\n\n message = {\n ...message,\n content: newContent,\n };\n this.repository.addOrUpdateMessage(parentId, message);\n\n if (added && shouldContinue(message)) {\n this.performRoundtrip(parentId, message);\n }\n }\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAM3B,SAAS,uBAAuB;AAEhC,SAAS,sBAAsB;AAO/B,SAAS,6BAA6B;AACtC,SAAS,sCAAsC;AAExC,IAAM,yBAAN,cACG,sBAEV;AAAA,EACkB,eAAe;AAAA,IAC7B,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,EAEQ,kBAA0C;AAAA,EAElC,aAAa;AAAA,EACb,cAA2C,CAAC;AAAA,EAE5D,IAAW,WAAW;AACpB,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,YACE,gBACA,UACA,SACA;AACA,UAAM,gBAAgB,IAAI,+BAA+B,QAAQ,CAAC;AAClE,SAAK,WAAW,OAAO;AAAA,EACzB;AAAA,EAEQ;AAAA,EAER,IAAW,SAAS;AAClB,WAAO;AAAA,EACT;AAAA,EAEO,WAAW,SAAkC;AAClD,QAAI,KAAK,aAAa,QAAS;AAE/B,SAAK,WAAW;AAEhB,QAAI,aAAa;AAEjB,UAAM,WAAW,QAAQ,UAAU,WAAW;AAC9C,QAAI,KAAK,aAAa,WAAW,UAAU;AACzC,WAAK,aAAa,SAAS;AAC3B,mBAAa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