@assistant-ui/react 0.7.43 → 0.7.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/AssistantRuntime.d.ts +11 -3
- package/dist/api/AssistantRuntime.d.ts.map +1 -1
- package/dist/api/AssistantRuntime.js +8 -17
- package/dist/api/AssistantRuntime.js.map +1 -1
- package/dist/api/AssistantRuntime.mjs +8 -17
- package/dist/api/AssistantRuntime.mjs.map +1 -1
- package/dist/api/RuntimePathTypes.d.ts +4 -1
- package/dist/api/RuntimePathTypes.d.ts.map +1 -1
- package/dist/api/RuntimePathTypes.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.d.ts +8 -0
- package/dist/api/ThreadListItemRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListItemRuntime.js +4 -0
- package/dist/api/ThreadListItemRuntime.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.mjs +4 -0
- package/dist/api/ThreadListItemRuntime.mjs.map +1 -1
- package/dist/api/ThreadListRuntime.d.ts +11 -1
- package/dist/api/ThreadListRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListRuntime.js +37 -1
- package/dist/api/ThreadListRuntime.js.map +1 -1
- package/dist/api/ThreadListRuntime.mjs +39 -1
- package/dist/api/ThreadListRuntime.mjs.map +1 -1
- package/dist/runtimes/adapters/RuntimeAdapterProvider.d.ts +15 -0
- package/dist/runtimes/adapters/RuntimeAdapterProvider.d.ts.map +1 -0
- package/dist/runtimes/adapters/RuntimeAdapterProvider.js +45 -0
- package/dist/runtimes/adapters/RuntimeAdapterProvider.js.map +1 -0
- package/dist/runtimes/adapters/RuntimeAdapterProvider.mjs +19 -0
- package/dist/runtimes/adapters/RuntimeAdapterProvider.mjs.map +1 -0
- package/dist/runtimes/{attachment → adapters/attachment}/AttachmentAdapter.d.ts +1 -1
- package/dist/runtimes/adapters/attachment/AttachmentAdapter.d.ts.map +1 -0
- package/dist/runtimes/{attachment → adapters/attachment}/AttachmentAdapter.js +1 -1
- package/dist/runtimes/adapters/attachment/AttachmentAdapter.js.map +1 -0
- package/dist/runtimes/{attachment → adapters/attachment}/CompositeAttachmentAdapter.d.ts +2 -2
- package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.d.ts.map +1 -0
- package/dist/runtimes/{attachment → adapters/attachment}/CompositeAttachmentAdapter.js +1 -1
- package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.js.map +1 -0
- package/dist/runtimes/{attachment → adapters/attachment}/CompositeAttachmentAdapter.mjs +1 -1
- package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.mjs.map +1 -0
- package/dist/runtimes/{attachment → adapters/attachment}/SimpleImageAttachmentAdapter.d.ts +1 -1
- package/dist/runtimes/adapters/attachment/SimpleImageAttachmentAdapter.d.ts.map +1 -0
- package/dist/runtimes/{attachment → adapters/attachment}/SimpleImageAttachmentAdapter.js +1 -1
- package/dist/runtimes/adapters/attachment/SimpleImageAttachmentAdapter.js.map +1 -0
- package/dist/runtimes/{attachment → adapters/attachment}/SimpleImageAttachmentAdapter.mjs +1 -1
- package/dist/runtimes/adapters/attachment/SimpleImageAttachmentAdapter.mjs.map +1 -0
- package/dist/runtimes/{attachment → adapters/attachment}/SimpleTextAttachmentAdapter.d.ts +1 -1
- package/dist/runtimes/adapters/attachment/SimpleTextAttachmentAdapter.d.ts.map +1 -0
- package/dist/runtimes/{attachment → adapters/attachment}/SimpleTextAttachmentAdapter.js +1 -1
- package/dist/runtimes/adapters/attachment/SimpleTextAttachmentAdapter.js.map +1 -0
- package/dist/runtimes/{attachment → adapters/attachment}/SimpleTextAttachmentAdapter.mjs +1 -1
- package/dist/runtimes/adapters/attachment/SimpleTextAttachmentAdapter.mjs.map +1 -0
- package/dist/runtimes/adapters/attachment/index.d.ts.map +1 -0
- package/dist/runtimes/{attachment → adapters/attachment}/index.js +1 -1
- package/dist/runtimes/adapters/attachment/index.js.map +1 -0
- package/dist/runtimes/{attachment → adapters/attachment}/index.mjs +1 -1
- package/dist/runtimes/adapters/attachment/index.mjs.map +1 -0
- package/dist/runtimes/{feedback → adapters/feedback}/FeedbackAdapter.d.ts +1 -1
- package/dist/runtimes/adapters/feedback/FeedbackAdapter.d.ts.map +1 -0
- package/dist/runtimes/{feedback → adapters/feedback}/FeedbackAdapter.js +1 -1
- package/dist/runtimes/adapters/feedback/FeedbackAdapter.js.map +1 -0
- package/dist/runtimes/adapters/feedback/index.d.ts.map +1 -0
- package/dist/runtimes/{feedback → adapters/feedback}/index.js +1 -1
- package/dist/runtimes/adapters/feedback/index.js.map +1 -0
- package/dist/runtimes/adapters/index.d.ts +4 -0
- package/dist/runtimes/adapters/index.d.ts.map +1 -0
- package/dist/runtimes/adapters/index.js +29 -0
- package/dist/runtimes/adapters/index.js.map +1 -0
- package/dist/runtimes/adapters/index.mjs +5 -0
- package/dist/runtimes/adapters/index.mjs.map +1 -0
- package/dist/runtimes/{speech → adapters/speech}/SpeechAdapterTypes.d.ts +1 -1
- package/dist/runtimes/adapters/speech/SpeechAdapterTypes.d.ts.map +1 -0
- package/dist/runtimes/{speech → adapters/speech}/SpeechAdapterTypes.js +1 -1
- package/dist/runtimes/adapters/speech/SpeechAdapterTypes.js.map +1 -0
- package/dist/runtimes/adapters/speech/WebSpeechSynthesisAdapter.d.ts.map +1 -0
- package/dist/runtimes/{speech → adapters/speech}/WebSpeechSynthesisAdapter.js +1 -1
- package/dist/runtimes/adapters/speech/WebSpeechSynthesisAdapter.js.map +1 -0
- package/dist/runtimes/{speech → adapters/speech}/WebSpeechSynthesisAdapter.mjs +1 -1
- package/dist/runtimes/adapters/speech/WebSpeechSynthesisAdapter.mjs.map +1 -0
- package/dist/runtimes/adapters/speech/index.d.ts.map +1 -0
- package/dist/runtimes/{speech → adapters/speech}/index.js +1 -1
- package/dist/runtimes/adapters/speech/index.js.map +1 -0
- package/dist/runtimes/{speech → adapters/speech}/index.mjs +1 -1
- package/dist/runtimes/adapters/speech/index.mjs.map +1 -0
- package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.d.ts +6 -0
- package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.d.ts.map +1 -0
- package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.js +19 -0
- package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.js.map +1 -0
- package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.mjs +1 -0
- package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.mjs.map +1 -0
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.d.ts +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/AssistantRuntimeCore.d.ts +1 -1
- package/dist/runtimes/core/AssistantRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/AssistantRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.d.ts +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts +3 -3
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts +5 -0
- 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 +2 -2
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts +3 -3
- 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 +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js +4 -4
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs +4 -4
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +2 -0
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js +6 -0
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs +6 -0
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +7 -0
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs +7 -0
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/index.d.ts +1 -3
- package/dist/runtimes/index.d.ts.map +1 -1
- package/dist/runtimes/index.js +3 -7
- package/dist/runtimes/index.js.map +1 -1
- package/dist/runtimes/index.mjs +1 -3
- package/dist/runtimes/index.mjs.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.d.ts +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.js +5 -5
- package/dist/runtimes/local/LocalRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.mjs +5 -5
- package/dist/runtimes/local/LocalRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.d.ts +6 -3
- package/dist/runtimes/local/LocalRuntimeOptions.d.ts.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.mjs.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts +2 -0
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js +8 -0
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs +8 -0
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts +1 -0
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js +7 -3
- package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +7 -3
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.js +1 -1
- package/dist/runtimes/local/useLocalRuntime.js.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.mjs +1 -1
- package/dist/runtimes/local/useLocalRuntime.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/OptimisticState.d.ts +1 -1
- package/dist/runtimes/remote-thread-list/OptimisticState.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/OptimisticState.js +7 -5
- package/dist/runtimes/remote-thread-list/OptimisticState.js.map +1 -1
- package/dist/runtimes/remote-thread-list/OptimisticState.mjs +7 -5
- package/dist/runtimes/remote-thread-list/OptimisticState.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js +9 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs +13 -2
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +41 -3
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +46 -14
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs +46 -14
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.d.ts +3 -2
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.js +9 -4
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.js.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.mjs +9 -4
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.d.ts +6 -3
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.js +13 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.js.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.mjs +13 -1
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/index.d.ts +0 -1
- package/dist/runtimes/remote-thread-list/cloud/index.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/index.js +0 -3
- package/dist/runtimes/remote-thread-list/cloud/index.js.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/index.mjs +0 -2
- package/dist/runtimes/remote-thread-list/cloud/index.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.js +26 -49
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.js.map +1 -1
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.mjs +27 -56
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +2 -2
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/types.js.map +1 -1
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js +5 -5
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs +5 -5
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs.map +1 -1
- package/dist/runtimes/utils/MessageRepository.d.ts +4 -0
- package/dist/runtimes/utils/MessageRepository.d.ts.map +1 -1
- package/dist/runtimes/utils/MessageRepository.js.map +1 -1
- package/dist/runtimes/utils/MessageRepository.mjs.map +1 -1
- package/dist/ui/assistant-message.d.ts.map +1 -1
- package/dist/ui/assistant-message.js +14 -10
- package/dist/ui/assistant-message.js.map +1 -1
- package/dist/ui/assistant-message.mjs +14 -10
- package/dist/ui/assistant-message.mjs.map +1 -1
- package/dist/ui/thread-config.d.ts +1 -0
- package/dist/ui/thread-config.d.ts.map +1 -1
- package/dist/ui/thread-config.js.map +1 -1
- package/dist/ui/thread-config.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/AssistantRuntime.ts +19 -18
- package/src/api/RuntimePathTypes.ts +6 -1
- package/src/api/ThreadListItemRuntime.ts +9 -0
- package/src/api/ThreadListRuntime.ts +56 -1
- package/src/runtimes/adapters/RuntimeAdapterProvider.tsx +31 -0
- package/src/runtimes/{attachment → adapters/attachment}/AttachmentAdapter.ts +1 -1
- package/src/runtimes/{attachment → adapters/attachment}/CompositeAttachmentAdapter.ts +1 -1
- package/src/runtimes/{attachment → adapters/attachment}/SimpleImageAttachmentAdapter.ts +1 -1
- package/src/runtimes/{attachment → adapters/attachment}/SimpleTextAttachmentAdapter.ts +1 -1
- package/src/runtimes/{feedback → adapters/feedback}/FeedbackAdapter.ts +1 -1
- package/src/runtimes/adapters/index.ts +3 -0
- package/src/runtimes/{speech → adapters/speech}/SpeechAdapterTypes.ts +1 -1
- package/src/runtimes/adapters/thread-history/ThreadHistoryAdapter.ts +9 -0
- package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +1 -1
- package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +1 -1
- package/src/runtimes/composer/DefaultThreadComposerRuntimeCore.tsx +1 -1
- package/src/runtimes/core/AssistantRuntimeCore.tsx +1 -1
- package/src/runtimes/core/BaseAssistantRuntimeCore.tsx +1 -1
- package/src/runtimes/core/BaseThreadRuntimeCore.tsx +3 -3
- package/src/runtimes/core/ThreadListRuntimeCore.tsx +6 -0
- package/src/runtimes/core/ThreadRuntimeCore.tsx +2 -1
- package/src/runtimes/external-store/ExternalStoreAdapter.tsx +3 -3
- package/src/runtimes/external-store/ExternalStoreRuntimeCore.tsx +4 -4
- package/src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx +8 -0
- package/src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx +8 -0
- package/src/runtimes/index.ts +1 -3
- package/src/runtimes/local/LocalRuntimeCore.tsx +5 -5
- package/src/runtimes/local/LocalRuntimeOptions.tsx +5 -3
- package/src/runtimes/local/LocalThreadListRuntimeCore.tsx +10 -0
- package/src/runtimes/local/LocalThreadRuntimeCore.tsx +7 -3
- package/src/runtimes/local/useLocalRuntime.tsx +1 -1
- package/src/runtimes/remote-thread-list/OptimisticState.ts +15 -8
- package/src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +15 -2
- package/src/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +56 -16
- package/src/runtimes/remote-thread-list/cloud/AssistantCloudAPI.tsx +13 -5
- package/src/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.tsx +24 -4
- package/src/runtimes/remote-thread-list/cloud/index.ts +0 -1
- package/src/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.tsx +36 -60
- package/src/runtimes/remote-thread-list/types.tsx +2 -5
- package/src/runtimes/remote-thread-list/useRemoteThreadListRuntime.tsx +5 -5
- package/src/runtimes/utils/MessageRepository.tsx +5 -0
- package/src/ui/assistant-message.tsx +2 -0
- package/src/ui/thread-config.tsx +1 -0
- package/dist/runtimes/attachment/AttachmentAdapter.d.ts.map +0 -1
- package/dist/runtimes/attachment/AttachmentAdapter.js.map +0 -1
- package/dist/runtimes/attachment/CompositeAttachmentAdapter.d.ts.map +0 -1
- package/dist/runtimes/attachment/CompositeAttachmentAdapter.js.map +0 -1
- package/dist/runtimes/attachment/CompositeAttachmentAdapter.mjs.map +0 -1
- package/dist/runtimes/attachment/SimpleImageAttachmentAdapter.d.ts.map +0 -1
- package/dist/runtimes/attachment/SimpleImageAttachmentAdapter.js.map +0 -1
- package/dist/runtimes/attachment/SimpleImageAttachmentAdapter.mjs.map +0 -1
- package/dist/runtimes/attachment/SimpleTextAttachmentAdapter.d.ts.map +0 -1
- package/dist/runtimes/attachment/SimpleTextAttachmentAdapter.js.map +0 -1
- package/dist/runtimes/attachment/SimpleTextAttachmentAdapter.mjs.map +0 -1
- package/dist/runtimes/attachment/index.d.ts.map +0 -1
- package/dist/runtimes/attachment/index.js.map +0 -1
- package/dist/runtimes/attachment/index.mjs.map +0 -1
- package/dist/runtimes/feedback/FeedbackAdapter.d.ts.map +0 -1
- package/dist/runtimes/feedback/FeedbackAdapter.js.map +0 -1
- package/dist/runtimes/feedback/index.d.ts.map +0 -1
- package/dist/runtimes/feedback/index.js.map +0 -1
- package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.d.ts +0 -22
- package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.d.ts.map +0 -1
- package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.js +0 -85
- package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.js.map +0 -1
- package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.mjs +0 -60
- package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.mjs.map +0 -1
- package/dist/runtimes/speech/SpeechAdapterTypes.d.ts.map +0 -1
- package/dist/runtimes/speech/SpeechAdapterTypes.js.map +0 -1
- package/dist/runtimes/speech/WebSpeechSynthesisAdapter.d.ts.map +0 -1
- package/dist/runtimes/speech/WebSpeechSynthesisAdapter.js.map +0 -1
- package/dist/runtimes/speech/WebSpeechSynthesisAdapter.mjs.map +0 -1
- package/dist/runtimes/speech/index.d.ts.map +0 -1
- package/dist/runtimes/speech/index.js.map +0 -1
- package/dist/runtimes/speech/index.mjs.map +0 -1
- package/src/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.tsx +0 -89
- /package/dist/runtimes/{attachment → adapters/attachment}/AttachmentAdapter.mjs +0 -0
- /package/dist/runtimes/{attachment → adapters/attachment}/AttachmentAdapter.mjs.map +0 -0
- /package/dist/runtimes/{attachment → adapters/attachment}/index.d.ts +0 -0
- /package/dist/runtimes/{feedback → adapters/feedback}/FeedbackAdapter.mjs +0 -0
- /package/dist/runtimes/{feedback → adapters/feedback}/FeedbackAdapter.mjs.map +0 -0
- /package/dist/runtimes/{feedback → adapters/feedback}/index.d.ts +0 -0
- /package/dist/runtimes/{feedback → adapters/feedback}/index.mjs +0 -0
- /package/dist/runtimes/{feedback → adapters/feedback}/index.mjs.map +0 -0
- /package/dist/runtimes/{speech → adapters/speech}/SpeechAdapterTypes.mjs +0 -0
- /package/dist/runtimes/{speech → adapters/speech}/SpeechAdapterTypes.mjs.map +0 -0
- /package/dist/runtimes/{speech → adapters/speech}/WebSpeechSynthesisAdapter.d.ts +0 -0
- /package/dist/runtimes/{speech → adapters/speech}/index.d.ts +0 -0
- /package/src/runtimes/{attachment → adapters/attachment}/index.ts +0 -0
- /package/src/runtimes/{feedback → adapters/feedback}/index.ts +0 -0
- /package/src/runtimes/{speech → adapters/speech}/WebSpeechSynthesisAdapter.ts +0 -0
- /package/src/runtimes/{speech → adapters/speech}/index.ts +0 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ThreadHistoryAdapter } from "../adapters/thread-history/ThreadHistoryAdapter";
|
|
2
|
+
import { AttachmentAdapter } from "../adapters/attachment/AttachmentAdapter";
|
|
2
3
|
import { ThreadMessageLike } from "../external-store";
|
|
3
|
-
import { FeedbackAdapter } from "../feedback/FeedbackAdapter";
|
|
4
|
-
import { SpeechSynthesisAdapter } from "../speech/SpeechAdapterTypes";
|
|
4
|
+
import { FeedbackAdapter } from "../adapters/feedback/FeedbackAdapter";
|
|
5
|
+
import { SpeechSynthesisAdapter } from "../adapters/speech/SpeechAdapterTypes";
|
|
5
6
|
import { ChatModelAdapter } from "./ChatModelAdapter";
|
|
6
7
|
|
|
7
8
|
export type LocalRuntimeOptionsBase = {
|
|
8
9
|
maxSteps?: number | undefined;
|
|
9
10
|
adapters: {
|
|
10
11
|
chatModel: ChatModelAdapter;
|
|
12
|
+
history?: ThreadHistoryAdapter | undefined;
|
|
11
13
|
attachments?: AttachmentAdapter | undefined;
|
|
12
14
|
speech?: SpeechSynthesisAdapter | undefined;
|
|
13
15
|
feedback?: FeedbackAdapter | undefined;
|
|
@@ -52,6 +52,12 @@ export class LocalThreadListRuntimeCore implements ThreadListRuntimeCore {
|
|
|
52
52
|
return result;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
public getThreadRuntimeCore(threadId: string) {
|
|
56
|
+
const result = this._threadData.get(threadId)?.runtime;
|
|
57
|
+
if (!result) throw new Error("Thread not found.");
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
|
|
55
61
|
public getLoadThreadsPromise(): Promise<void> {
|
|
56
62
|
return RESOLVED_PROMISE;
|
|
57
63
|
}
|
|
@@ -212,6 +218,10 @@ export class LocalThreadListRuntimeCore implements ThreadListRuntimeCore {
|
|
|
212
218
|
return Promise.resolve();
|
|
213
219
|
}
|
|
214
220
|
|
|
221
|
+
public initialize(): never {
|
|
222
|
+
throw new Error("Method not implemented.");
|
|
223
|
+
}
|
|
224
|
+
|
|
215
225
|
private _subscriptions = new Set<() => void>();
|
|
216
226
|
|
|
217
227
|
public subscribe(callback: () => void): Unsubscribe {
|
|
@@ -127,9 +127,13 @@ export class LocalThreadRuntimeCore
|
|
|
127
127
|
|
|
128
128
|
this._notifyEventSubscribers("run-start");
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
try {
|
|
131
|
+
do {
|
|
132
|
+
message = await this.performRoundtrip(parentId, message, runConfig);
|
|
133
|
+
} while (shouldContinue(message));
|
|
134
|
+
} finally {
|
|
135
|
+
this._notifyEventSubscribers("run-end");
|
|
136
|
+
}
|
|
133
137
|
}
|
|
134
138
|
|
|
135
139
|
private async performRoundtrip(
|
|
@@ -43,7 +43,7 @@ export const useLocalRuntime = (
|
|
|
43
43
|
const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));
|
|
44
44
|
|
|
45
45
|
useEffect(() => {
|
|
46
|
-
runtime.
|
|
46
|
+
runtime.threads.getMainThreadRuntimeCore().__internal_setOptions(opt);
|
|
47
47
|
}, [runtime, opt]);
|
|
48
48
|
|
|
49
49
|
return useMemo(() => LocalRuntimeImpl.create(runtime), [runtime]);
|
|
@@ -10,7 +10,11 @@ type Transform<TState, TResult> = {
|
|
|
10
10
|
optimistic?: (state: TState) => TState;
|
|
11
11
|
|
|
12
12
|
/** transform the state only while loading */
|
|
13
|
-
loading?: (state: TState) => TState;
|
|
13
|
+
loading?: (state: TState, task: Promise<TResult>) => TState;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type PendingTransform<TState, TResult> = Transform<TState, TResult> & {
|
|
17
|
+
task: Promise<TResult>;
|
|
14
18
|
};
|
|
15
19
|
|
|
16
20
|
const pipeTransforms = <TState, TExtra>(
|
|
@@ -24,7 +28,8 @@ const pipeTransforms = <TState, TExtra>(
|
|
|
24
28
|
};
|
|
25
29
|
|
|
26
30
|
export class OptimisticState<TState> extends BaseSubscribable {
|
|
27
|
-
private readonly _pendingTransforms: Array<
|
|
31
|
+
private readonly _pendingTransforms: Array<PendingTransform<TState, any>> =
|
|
32
|
+
[];
|
|
28
33
|
private _baseValue: TState;
|
|
29
34
|
private _cachedValue: TState;
|
|
30
35
|
|
|
@@ -36,7 +41,7 @@ export class OptimisticState<TState> extends BaseSubscribable {
|
|
|
36
41
|
|
|
37
42
|
private _updateState(): void {
|
|
38
43
|
this._cachedValue = this._pendingTransforms.reduce((state, transform) => {
|
|
39
|
-
return pipeTransforms(state,
|
|
44
|
+
return pipeTransforms(state, transform.task, [
|
|
40
45
|
transform.loading,
|
|
41
46
|
transform.optimistic,
|
|
42
47
|
]);
|
|
@@ -61,18 +66,20 @@ export class OptimisticState<TState> extends BaseSubscribable {
|
|
|
61
66
|
public async optimisticUpdate<TResult>(
|
|
62
67
|
transform: Transform<TState, TResult>,
|
|
63
68
|
): Promise<TResult> {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
const task = transform.execute();
|
|
70
|
+
const pendingTransform = { ...transform, task };
|
|
67
71
|
try {
|
|
68
|
-
|
|
72
|
+
this._pendingTransforms.push(pendingTransform);
|
|
73
|
+
this._updateState();
|
|
74
|
+
|
|
75
|
+
const result = await task;
|
|
69
76
|
this._baseValue = pipeTransforms(this._baseValue, result, [
|
|
70
77
|
transform.optimistic,
|
|
71
78
|
transform.then,
|
|
72
79
|
]);
|
|
73
80
|
return result;
|
|
74
81
|
} finally {
|
|
75
|
-
const index = this._pendingTransforms.indexOf(
|
|
82
|
+
const index = this._pendingTransforms.indexOf(pendingTransform);
|
|
76
83
|
if (index > -1) {
|
|
77
84
|
this._pendingTransforms.splice(index, 1);
|
|
78
85
|
}
|
|
@@ -13,7 +13,10 @@ import {
|
|
|
13
13
|
import { UseBoundStore, StoreApi, create } from "zustand";
|
|
14
14
|
import { useAssistantRuntime } from "../../context";
|
|
15
15
|
import { ThreadListItemRuntimeProvider } from "../../context/providers/ThreadListItemRuntimeProvider";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
useThreadListItem,
|
|
18
|
+
useThreadListItemRuntime,
|
|
19
|
+
} from "../../context/react/ThreadListItemContext";
|
|
17
20
|
import { ThreadRuntimeCore, ThreadRuntimeImpl } from "../../internal";
|
|
18
21
|
import { BaseSubscribable } from "./BaseSubscribable";
|
|
19
22
|
import { AssistantRuntime } from "../../api";
|
|
@@ -112,6 +115,16 @@ export class RemoteThreadListHookInstanceManager extends BaseSubscribable {
|
|
|
112
115
|
return threadBinding.outerSubscribe(updateRuntime);
|
|
113
116
|
}, [threadBinding]);
|
|
114
117
|
|
|
118
|
+
// auto initialize thread
|
|
119
|
+
const threadListItemRuntime = useThreadListItemRuntime();
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
return runtime.threads.main.unstable_on("initialize", () => {
|
|
122
|
+
if (threadListItemRuntime.getState().status === "new") {
|
|
123
|
+
threadListItemRuntime.initialize();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}, [runtime, threadListItemRuntime]);
|
|
127
|
+
|
|
115
128
|
return null;
|
|
116
129
|
};
|
|
117
130
|
|
|
@@ -121,7 +134,7 @@ export class RemoteThreadListHookInstanceManager extends BaseSubscribable {
|
|
|
121
134
|
}> = memo(({ threadId, provider: Provider }) => {
|
|
122
135
|
const assistantRuntime = useAssistantRuntime();
|
|
123
136
|
const threadListItemRuntime = useMemo(
|
|
124
|
-
() => assistantRuntime.
|
|
137
|
+
() => assistantRuntime.threads.getItemById(threadId),
|
|
125
138
|
[assistantRuntime, threadId],
|
|
126
139
|
);
|
|
127
140
|
|
|
@@ -24,6 +24,15 @@ type RemoteThreadData =
|
|
|
24
24
|
}
|
|
25
25
|
| {
|
|
26
26
|
readonly threadId: string;
|
|
27
|
+
readonly initializeTask: Promise<RemoteThreadInitializeResponse>;
|
|
28
|
+
readonly remoteId?: undefined;
|
|
29
|
+
readonly externalId?: undefined;
|
|
30
|
+
readonly status: "regular" | "archived";
|
|
31
|
+
readonly title?: string | undefined;
|
|
32
|
+
}
|
|
33
|
+
| {
|
|
34
|
+
readonly threadId: string;
|
|
35
|
+
readonly initializeTask: Promise<RemoteThreadInitializeResponse>;
|
|
27
36
|
readonly remoteId: string;
|
|
28
37
|
readonly externalId: string | undefined;
|
|
29
38
|
readonly status: "regular" | "archived";
|
|
@@ -188,6 +197,10 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
188
197
|
externalId: thread.externalId,
|
|
189
198
|
status: thread.status,
|
|
190
199
|
title: thread.title,
|
|
200
|
+
initializeTask: Promise.resolve({
|
|
201
|
+
remoteId: thread.remoteId,
|
|
202
|
+
externalId: thread.externalId,
|
|
203
|
+
}),
|
|
191
204
|
};
|
|
192
205
|
}
|
|
193
206
|
|
|
@@ -244,8 +257,7 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
244
257
|
|
|
245
258
|
public __internal_bindAdapter() {
|
|
246
259
|
this.getLoadThreadsPromise(); // begin loading on initial bind
|
|
247
|
-
return this._adapter.subscribe({
|
|
248
|
-
onInitialize: this._onInitialize,
|
|
260
|
+
return this._adapter.subscribe?.({
|
|
249
261
|
onGenerateTitle: this._onGenerateTitle,
|
|
250
262
|
});
|
|
251
263
|
}
|
|
@@ -272,6 +284,15 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
272
284
|
return result;
|
|
273
285
|
}
|
|
274
286
|
|
|
287
|
+
public getThreadRuntimeCore(threadIdOrRemoteId: string) {
|
|
288
|
+
const data = this.getItemById(threadIdOrRemoteId);
|
|
289
|
+
if (!data) throw new Error("Thread not found");
|
|
290
|
+
|
|
291
|
+
const result = this._hookManager.getThreadRuntimeCore(data.threadId);
|
|
292
|
+
if (!result) throw new Error("Thread not found");
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
|
|
275
296
|
public getItemById(threadIdOrRemoteId: string) {
|
|
276
297
|
return getThreadData(this._state.value, threadIdOrRemoteId);
|
|
277
298
|
}
|
|
@@ -332,20 +353,34 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
332
353
|
return this.switchToThread(threadId);
|
|
333
354
|
}
|
|
334
355
|
|
|
335
|
-
|
|
336
|
-
threadId
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
356
|
+
public initialize = async (threadId: string) => {
|
|
357
|
+
if (this._state.value.newThreadId !== threadId) {
|
|
358
|
+
const data = this.getItemById(threadId);
|
|
359
|
+
if (!data) throw new Error("Thread not found");
|
|
360
|
+
if (data.status === "new") throw new Error("Unexpected new state");
|
|
361
|
+
return data.initializeTask;
|
|
362
|
+
}
|
|
341
363
|
|
|
342
|
-
|
|
364
|
+
return this._state.optimisticUpdate({
|
|
343
365
|
execute: () => {
|
|
344
|
-
return
|
|
366
|
+
return this._adapter.initialize(threadId);
|
|
345
367
|
},
|
|
346
368
|
optimistic: (state) => {
|
|
347
369
|
return updateStatusReducer(state, threadId, "regular");
|
|
348
370
|
},
|
|
371
|
+
loading: (state, task) => {
|
|
372
|
+
const mappingId = createThreadMappingId(threadId);
|
|
373
|
+
return {
|
|
374
|
+
...state,
|
|
375
|
+
threadData: {
|
|
376
|
+
...state.threadData,
|
|
377
|
+
[mappingId]: {
|
|
378
|
+
...state.threadData[mappingId],
|
|
379
|
+
initializeTask: task,
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
};
|
|
383
|
+
},
|
|
349
384
|
then: (state, { remoteId, externalId }) => {
|
|
350
385
|
const data = getThreadData(state, threadId);
|
|
351
386
|
if (!data) return state;
|
|
@@ -359,8 +394,9 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
359
394
|
},
|
|
360
395
|
threadData: {
|
|
361
396
|
...state.threadData,
|
|
362
|
-
[
|
|
397
|
+
[mappingId]: {
|
|
363
398
|
...data,
|
|
399
|
+
initializeTask: Promise.resolve({ remoteId, externalId }),
|
|
364
400
|
remoteId,
|
|
365
401
|
externalId,
|
|
366
402
|
},
|
|
@@ -404,8 +440,9 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
404
440
|
if (data.status === "new") throw new Error("Thread is not yet initialized");
|
|
405
441
|
|
|
406
442
|
return this._state.optimisticUpdate({
|
|
407
|
-
execute: () => {
|
|
408
|
-
|
|
443
|
+
execute: async () => {
|
|
444
|
+
const { remoteId } = await data.initializeTask;
|
|
445
|
+
return this._adapter.rename(remoteId, newTitle);
|
|
409
446
|
},
|
|
410
447
|
optimistic: (state) => {
|
|
411
448
|
const data = getThreadData(state, threadIdOrRemoteId);
|
|
@@ -446,7 +483,8 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
446
483
|
return this._state.optimisticUpdate({
|
|
447
484
|
execute: async () => {
|
|
448
485
|
await this._ensureThreadIsNotMain(data.threadId);
|
|
449
|
-
|
|
486
|
+
const { remoteId } = await data.initializeTask;
|
|
487
|
+
return this._adapter.archive(remoteId);
|
|
450
488
|
},
|
|
451
489
|
optimistic: (state) => {
|
|
452
490
|
return updateStatusReducer(state, data.threadId, "archived");
|
|
@@ -462,7 +500,8 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
462
500
|
return this._state.optimisticUpdate({
|
|
463
501
|
execute: async () => {
|
|
464
502
|
try {
|
|
465
|
-
|
|
503
|
+
const { remoteId } = await data.initializeTask;
|
|
504
|
+
return await this._adapter.unarchive(remoteId);
|
|
466
505
|
} catch (error) {
|
|
467
506
|
await this._ensureThreadIsNotMain(data.threadId);
|
|
468
507
|
throw error;
|
|
@@ -483,7 +522,8 @@ export class RemoteThreadListThreadListRuntimeCore
|
|
|
483
522
|
return this._state.optimisticUpdate({
|
|
484
523
|
execute: async () => {
|
|
485
524
|
await this._ensureThreadIsNotMain(data.threadId);
|
|
486
|
-
|
|
525
|
+
const { remoteId } = await data.initializeTask;
|
|
526
|
+
return await this._adapter.delete(remoteId);
|
|
487
527
|
},
|
|
488
528
|
optimistic: (state) => {
|
|
489
529
|
return updateStatusReducer(state, data.threadId, "deleted");
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
export type AssistantCloudConfig =
|
|
8
8
|
| {
|
|
9
9
|
baseUrl: string;
|
|
10
|
-
authToken()
|
|
10
|
+
authToken: (() => Promise<string | null>) | undefined;
|
|
11
11
|
}
|
|
12
12
|
| {
|
|
13
13
|
apiKey: string;
|
|
@@ -30,16 +30,16 @@ type MakeRequestOptions = {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export class AssistantCloudAPI {
|
|
33
|
-
private
|
|
33
|
+
private _auth: AssistantCloudAuthStrategy;
|
|
34
34
|
private _baseUrl;
|
|
35
35
|
|
|
36
36
|
constructor(config: AssistantCloudConfig) {
|
|
37
37
|
if ("authToken" in config) {
|
|
38
38
|
this._baseUrl = config.baseUrl;
|
|
39
|
-
this.
|
|
39
|
+
this._auth = new AssistantCloudJWTAuthStrategy(config.authToken);
|
|
40
40
|
} else {
|
|
41
41
|
this._baseUrl = "https://backend.assistant-api.com";
|
|
42
|
-
this.
|
|
42
|
+
this._auth = new AssistantCloudAPIKeyAuthStrategy(
|
|
43
43
|
config.apiKey,
|
|
44
44
|
config.userId,
|
|
45
45
|
config.workspaceId,
|
|
@@ -47,11 +47,17 @@ export class AssistantCloudAPI {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
public async initializeAuth() {
|
|
51
|
+
return !!this._auth.getAuthHeaders();
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
public async makeRawRequest(
|
|
51
55
|
endpoint: string,
|
|
52
56
|
options: MakeRequestOptions = {},
|
|
53
57
|
) {
|
|
54
|
-
const authHeaders = await this.
|
|
58
|
+
const authHeaders = await this._auth.getAuthHeaders();
|
|
59
|
+
if (!authHeaders) throw new Error("Authronization failed");
|
|
60
|
+
|
|
55
61
|
const headers = {
|
|
56
62
|
...authHeaders,
|
|
57
63
|
...options.headers,
|
|
@@ -79,6 +85,8 @@ export class AssistantCloudAPI {
|
|
|
79
85
|
body: options.body ? JSON.stringify(options.body) : null,
|
|
80
86
|
});
|
|
81
87
|
|
|
88
|
+
this._auth.readAuthHeaders(response.headers);
|
|
89
|
+
|
|
82
90
|
if (!response.ok) {
|
|
83
91
|
const text = await response.text();
|
|
84
92
|
try {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type AssistantCloudAuthStrategy = {
|
|
2
2
|
readonly strategy: "jwt" | "api-key";
|
|
3
|
-
getAuthHeaders(): Promise<Record<string, string
|
|
3
|
+
getAuthHeaders(): Promise<Record<string, string> | false>;
|
|
4
|
+
readAuthHeaders(headers: Headers): void;
|
|
4
5
|
};
|
|
5
6
|
|
|
6
7
|
export class AssistantCloudJWTAuthStrategy
|
|
@@ -13,7 +14,7 @@ export class AssistantCloudJWTAuthStrategy
|
|
|
13
14
|
|
|
14
15
|
#authTokenCallback;
|
|
15
16
|
|
|
16
|
-
constructor(authTokenCallback: () => Promise<string>) {
|
|
17
|
+
constructor(authTokenCallback: (() => Promise<string | null>) | undefined) {
|
|
17
18
|
this.#authTokenCallback = authTokenCallback;
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -43,7 +44,7 @@ export class AssistantCloudJWTAuthStrategy
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
public async getAuthHeaders(): Promise<Record<string, string
|
|
47
|
+
public async getAuthHeaders(): Promise<Record<string, string> | false> {
|
|
47
48
|
const currentTime = Date.now();
|
|
48
49
|
|
|
49
50
|
// Check if the cached token is valid for at least 30 seconds
|
|
@@ -58,7 +59,9 @@ export class AssistantCloudJWTAuthStrategy
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
// Fetch a new token
|
|
61
|
-
const newToken = await this.#authTokenCallback();
|
|
62
|
+
const newToken = await this.#authTokenCallback?.();
|
|
63
|
+
if (!newToken) return false;
|
|
64
|
+
|
|
62
65
|
const expiry = this.getJwtExpiry(newToken);
|
|
63
66
|
|
|
64
67
|
this.cachedToken = newToken;
|
|
@@ -68,7 +71,20 @@ export class AssistantCloudJWTAuthStrategy
|
|
|
68
71
|
Authorization: `Bearer ${newToken}`,
|
|
69
72
|
};
|
|
70
73
|
}
|
|
74
|
+
|
|
75
|
+
public readAuthHeaders(headers: Headers) {
|
|
76
|
+
const authHeader = headers.get("Authorization");
|
|
77
|
+
if (!authHeader) return;
|
|
78
|
+
|
|
79
|
+
const [scheme, token] = authHeader.split(" ");
|
|
80
|
+
if (scheme !== "Bearer" || !token)
|
|
81
|
+
throw new Error("Invalid auth header received");
|
|
82
|
+
|
|
83
|
+
this.cachedToken = token;
|
|
84
|
+
this.tokenExpiry = this.getJwtExpiry(token);
|
|
85
|
+
}
|
|
71
86
|
}
|
|
87
|
+
|
|
72
88
|
export class AssistantCloudAPIKeyAuthStrategy
|
|
73
89
|
implements AssistantCloudAuthStrategy
|
|
74
90
|
{
|
|
@@ -91,4 +107,8 @@ export class AssistantCloudAPIKeyAuthStrategy
|
|
|
91
107
|
"Aui-Workspace-Id": this.#workspaceId,
|
|
92
108
|
};
|
|
93
109
|
}
|
|
110
|
+
|
|
111
|
+
public readAuthHeaders() {
|
|
112
|
+
// noop
|
|
113
|
+
}
|
|
94
114
|
}
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
PropsWithChildren,
|
|
5
|
-
useCallback,
|
|
6
|
-
useEffect,
|
|
7
|
-
useMemo,
|
|
8
|
-
useRef,
|
|
9
|
-
useState,
|
|
10
|
-
} from "react";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
11
4
|
import { useRemoteThreadListRuntime } from "../useRemoteThreadListRuntime";
|
|
12
5
|
import { AssistantCloud } from "./AssistantCloud";
|
|
13
6
|
import { AssistantRuntime } from "../../../api";
|
|
14
7
|
import { RemoteThreadListSubscriber } from "../types";
|
|
15
|
-
import { CloudThreadListItemRuntimeProvider } from "./CloudThreadListItemRuntime";
|
|
16
8
|
import { toCoreMessages } from "../../edge";
|
|
17
9
|
|
|
18
10
|
type ThreadData = {
|
|
@@ -45,45 +37,6 @@ export const useCloudThreadListRuntime = (adapter: CloudThreadListAdapter) => {
|
|
|
45
37
|
|
|
46
38
|
const [subscribers] = useState(() => new Set<RemoteThreadListSubscriber>());
|
|
47
39
|
|
|
48
|
-
const cloudThreadListItemRuntimeAdapter = useMemo(() => {
|
|
49
|
-
return {
|
|
50
|
-
initialize: async (threadId: string) => {
|
|
51
|
-
const begin = beginnable(async () => {
|
|
52
|
-
const createTask = adapterRef.current.create?.() ?? Promise.resolve();
|
|
53
|
-
const t = await createTask;
|
|
54
|
-
const external_id = t ? t.externalId : undefined;
|
|
55
|
-
const { thread_id } = await adapterRef.current.cloud.threads.create({
|
|
56
|
-
title: "New Thread",
|
|
57
|
-
last_message_at: new Date(),
|
|
58
|
-
external_id,
|
|
59
|
-
});
|
|
60
|
-
return { externalId: external_id, remoteId: thread_id };
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
for (const subscriber of subscribers) {
|
|
64
|
-
subscriber.onInitialize(threadId, begin);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// note: onInitialize immediately throws if there are any issues
|
|
68
|
-
// therefore begin is safe to call here
|
|
69
|
-
return begin();
|
|
70
|
-
},
|
|
71
|
-
generateTitle: async (remoteId: string) => {
|
|
72
|
-
const messages = runtime.thread.getState().messages;
|
|
73
|
-
const begin = beginnable(() => {
|
|
74
|
-
return adapterRef.current.cloud.runs.stream({
|
|
75
|
-
thread_id: remoteId,
|
|
76
|
-
assistant_id: "system/thread_title",
|
|
77
|
-
messages: toCoreMessages(messages),
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
for (const subscriber of subscribers) {
|
|
81
|
-
subscriber.onGenerateTitle(remoteId, begin);
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
}, [subscribers]);
|
|
86
|
-
|
|
87
40
|
const runtime = useRemoteThreadListRuntime({
|
|
88
41
|
runtimeHook: adapter.runtimeHook,
|
|
89
42
|
list: async () => {
|
|
@@ -97,6 +50,41 @@ export const useCloudThreadListRuntime = (adapter: CloudThreadListAdapter) => {
|
|
|
97
50
|
})),
|
|
98
51
|
};
|
|
99
52
|
},
|
|
53
|
+
|
|
54
|
+
initialize: async (threadId: string) => {
|
|
55
|
+
const createTask = adapterRef.current.create?.() ?? Promise.resolve();
|
|
56
|
+
const t = await createTask;
|
|
57
|
+
const external_id = t ? t.externalId : undefined;
|
|
58
|
+
const { thread_id: remoteId } =
|
|
59
|
+
await adapterRef.current.cloud.threads.create({
|
|
60
|
+
title: "New Thread",
|
|
61
|
+
last_message_at: new Date(),
|
|
62
|
+
external_id,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const dispose = runtime.threads
|
|
66
|
+
.getById(threadId)
|
|
67
|
+
.unstable_on("run-end", () => {
|
|
68
|
+
dispose();
|
|
69
|
+
|
|
70
|
+
const messages = runtime.threads
|
|
71
|
+
.getById(threadId)
|
|
72
|
+
.getState().messages;
|
|
73
|
+
const begin = beginnable(() => {
|
|
74
|
+
return adapterRef.current.cloud.runs.stream({
|
|
75
|
+
thread_id: remoteId,
|
|
76
|
+
assistant_id: "system/thread_title",
|
|
77
|
+
messages: toCoreMessages(messages),
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
for (const subscriber of subscribers) {
|
|
81
|
+
subscriber.onGenerateTitle(remoteId, begin);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return { externalId: external_id, remoteId: remoteId };
|
|
86
|
+
},
|
|
87
|
+
|
|
100
88
|
rename: async (threadId, newTitle) => {
|
|
101
89
|
return adapter.cloud.threads.update(threadId, { title: newTitle });
|
|
102
90
|
},
|
|
@@ -116,18 +104,6 @@ export const useCloudThreadListRuntime = (adapter: CloudThreadListAdapter) => {
|
|
|
116
104
|
subscribers.delete(callback);
|
|
117
105
|
};
|
|
118
106
|
},
|
|
119
|
-
unstable_Provider: useCallback(
|
|
120
|
-
({ children }: PropsWithChildren) => {
|
|
121
|
-
return (
|
|
122
|
-
<CloudThreadListItemRuntimeProvider
|
|
123
|
-
adapter={cloudThreadListItemRuntimeAdapter}
|
|
124
|
-
>
|
|
125
|
-
{children}
|
|
126
|
-
</CloudThreadListItemRuntimeProvider>
|
|
127
|
-
);
|
|
128
|
-
},
|
|
129
|
-
[cloudThreadListItemRuntimeAdapter],
|
|
130
|
-
),
|
|
131
107
|
});
|
|
132
108
|
|
|
133
109
|
return runtime;
|
|
@@ -20,10 +20,6 @@ export type RemoteThreadListResponse = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export type RemoteThreadListSubscriber = {
|
|
23
|
-
onInitialize: (
|
|
24
|
-
threadId: string,
|
|
25
|
-
begin: () => Promise<RemoteThreadInitializeResponse>,
|
|
26
|
-
) => void;
|
|
27
23
|
onGenerateTitle: (
|
|
28
24
|
threadId: string,
|
|
29
25
|
begin: () => Promise<AssistantStream>,
|
|
@@ -39,8 +35,9 @@ export type RemoteThreadListAdapter = {
|
|
|
39
35
|
archive(remoteId: string): Promise<void>;
|
|
40
36
|
unarchive(remoteId: string): Promise<void>;
|
|
41
37
|
delete(remoteId: string): Promise<void>;
|
|
38
|
+
initialize(threadId: string): Promise<RemoteThreadInitializeResponse>;
|
|
42
39
|
|
|
43
|
-
subscribe(subscriber: RemoteThreadListSubscriber): Unsubscribe;
|
|
40
|
+
subscribe?(subscriber: RemoteThreadListSubscriber): Unsubscribe;
|
|
44
41
|
|
|
45
42
|
unstable_Provider?: ComponentType<PropsWithChildren>;
|
|
46
43
|
};
|
|
@@ -11,15 +11,15 @@ class RemoteThreadListRuntimeCore
|
|
|
11
11
|
extends BaseAssistantRuntimeCore
|
|
12
12
|
implements AssistantRuntimeCore
|
|
13
13
|
{
|
|
14
|
-
public readonly
|
|
14
|
+
public readonly threads;
|
|
15
15
|
|
|
16
16
|
constructor(adapter: RemoteThreadListAdapter) {
|
|
17
17
|
super();
|
|
18
|
-
this.
|
|
18
|
+
this.threads = new RemoteThreadListThreadListRuntimeCore(adapter);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
public get RenderComponent() {
|
|
22
|
-
return this.
|
|
22
|
+
return this.threads.__internal_RenderComponent;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -28,8 +28,8 @@ export const useRemoteThreadListRuntime = (
|
|
|
28
28
|
) => {
|
|
29
29
|
const [runtime] = useState(() => new RemoteThreadListRuntimeCore(adapter));
|
|
30
30
|
useEffect(() => {
|
|
31
|
-
runtime.
|
|
32
|
-
return runtime.
|
|
31
|
+
runtime.threads.__internal_setAdapter(adapter);
|
|
32
|
+
return runtime.threads.__internal_bindAdapter();
|
|
33
33
|
}, [runtime, adapter]);
|
|
34
34
|
return useMemo(() => AssistantRuntimeImpl.create(runtime), [runtime]);
|
|
35
35
|
};
|
|
@@ -13,6 +13,11 @@ type RepositoryMessage = RepositoryParent & {
|
|
|
13
13
|
level: number;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
export type ExportedMessageRepositoryItem = {
|
|
17
|
+
message: ThreadMessage;
|
|
18
|
+
parentId: string | null;
|
|
19
|
+
};
|
|
20
|
+
|
|
16
21
|
export interface ExportedMessageRepository {
|
|
17
22
|
headId?: string | null;
|
|
18
23
|
messages: Array<{
|
|
@@ -65,6 +65,7 @@ const AssistantMessageContent = forwardRef<
|
|
|
65
65
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
66
|
[...(tools ?? []), components.ToolFallback],
|
|
67
67
|
);
|
|
68
|
+
const Footer = components.Footer;
|
|
68
69
|
|
|
69
70
|
return (
|
|
70
71
|
<AssistantMessageContentWrapper {...rest} ref={ref}>
|
|
@@ -76,6 +77,7 @@ const AssistantMessageContent = forwardRef<
|
|
|
76
77
|
tools: toolsComponents,
|
|
77
78
|
}}
|
|
78
79
|
/>
|
|
80
|
+
{Footer && <Footer />}
|
|
79
81
|
</AssistantMessageContentWrapper>
|
|
80
82
|
);
|
|
81
83
|
});
|
package/src/ui/thread-config.tsx
CHANGED
|
@@ -45,6 +45,7 @@ export type AssistantMessageConfig = {
|
|
|
45
45
|
Text?: TextContentPartComponent | undefined;
|
|
46
46
|
Empty?: EmptyContentPartComponent | undefined;
|
|
47
47
|
ToolFallback?: ComponentType<ToolCallContentPartProps> | undefined;
|
|
48
|
+
Footer?: ComponentType | undefined;
|
|
48
49
|
}
|
|
49
50
|
| undefined;
|
|
50
51
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtimes/attachment/AttachmentAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,6BAA6B,CAAC;AAErC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IAEf,GAAG,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACvD,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,IAAI,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAClE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/attachment/AttachmentAdapter.ts"],"sourcesContent":["import {\n Attachment,\n PendingAttachment,\n CompleteAttachment,\n} from \"../../types/AttachmentTypes\";\n\nexport type AttachmentAdapter = {\n accept: string;\n\n add(state: { file: File }): Promise<PendingAttachment>;\n remove(attachment: Attachment): Promise<void>;\n send(attachment: PendingAttachment): Promise<CompleteAttachment>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeAttachmentAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtimes/attachment/CompositeAttachmentAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AA6CxD,qBAAa,0BAA2B,YAAW,iBAAiB;IAClE,OAAO,CAAC,SAAS,CAAsB;IAEhC,MAAM,EAAE,MAAM,CAAC;gBAEV,QAAQ,EAAE,iBAAiB,EAAE;IAgB5B,GAAG,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE;IASzB,IAAI,CAAC,UAAU,EAAE,iBAAiB;IAUlC,MAAM,CAAC,UAAU,EAAE,UAAU;CAiB3C"}
|