@assistant-ui/react 0.12.11 → 0.12.14
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/README.md +68 -58
- package/dist/client/ExternalThread.d.ts.map +1 -1
- package/dist/client/ExternalThread.js +25 -13
- package/dist/client/ExternalThread.js.map +1 -1
- package/dist/client/InMemoryThreadList.d.ts.map +1 -1
- package/dist/client/InMemoryThreadList.js +1 -2
- package/dist/client/InMemoryThreadList.js.map +1 -1
- package/dist/client/index.d.ts +1 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -2
- package/dist/client/index.js.map +1 -1
- package/dist/context/providers/AttachmentByIndexProvider.d.ts +1 -7
- package/dist/context/providers/AttachmentByIndexProvider.d.ts.map +1 -1
- package/dist/context/providers/AttachmentByIndexProvider.js +1 -22
- package/dist/context/providers/AttachmentByIndexProvider.js.map +1 -1
- package/dist/context/providers/ChainOfThoughtByIndicesProvider.d.ts +1 -5
- package/dist/context/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
- package/dist/context/providers/ChainOfThoughtByIndicesProvider.js +1 -19
- package/dist/context/providers/ChainOfThoughtByIndicesProvider.js.map +1 -1
- package/dist/context/providers/ChainOfThoughtPartByIndexProvider.d.ts +1 -4
- package/dist/context/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
- package/dist/context/providers/ChainOfThoughtPartByIndexProvider.js +1 -12
- package/dist/context/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
- package/dist/context/providers/MessageByIndexProvider.d.ts +1 -4
- package/dist/context/providers/MessageByIndexProvider.d.ts.map +1 -1
- package/dist/context/providers/MessageByIndexProvider.js +1 -17
- package/dist/context/providers/MessageByIndexProvider.js.map +1 -1
- package/dist/context/providers/PartByIndexProvider.d.ts +1 -4
- package/dist/context/providers/PartByIndexProvider.d.ts.map +1 -1
- package/dist/context/providers/PartByIndexProvider.js +1 -12
- package/dist/context/providers/PartByIndexProvider.js.map +1 -1
- package/dist/context/providers/SuggestionByIndexProvider.d.ts +1 -5
- package/dist/context/providers/SuggestionByIndexProvider.d.ts.map +1 -1
- package/dist/context/providers/SuggestionByIndexProvider.js +1 -12
- package/dist/context/providers/SuggestionByIndexProvider.js.map +1 -1
- package/dist/context/providers/TextMessagePartProvider.d.ts +1 -5
- package/dist/context/providers/TextMessagePartProvider.d.ts.map +1 -1
- package/dist/context/providers/TextMessagePartProvider.js +1 -25
- package/dist/context/providers/TextMessagePartProvider.js.map +1 -1
- package/dist/context/providers/ThreadListItemProvider.d.ts +1 -9
- package/dist/context/providers/ThreadListItemProvider.d.ts.map +1 -1
- package/dist/context/providers/ThreadListItemProvider.js +1 -19
- package/dist/context/providers/ThreadListItemProvider.js.map +1 -1
- package/dist/context/providers/index.d.ts +1 -0
- package/dist/context/providers/index.d.ts.map +1 -1
- package/dist/context/providers/index.js +1 -0
- package/dist/context/providers/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.js +8 -9
- package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
- package/dist/legacy-runtime/RuntimeAdapter.d.ts +1 -2
- package/dist/legacy-runtime/RuntimeAdapter.d.ts.map +1 -1
- package/dist/legacy-runtime/RuntimeAdapter.js +1 -48
- package/dist/legacy-runtime/RuntimeAdapter.js.map +1 -1
- package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.js +135 -27
- package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
- package/dist/legacy-runtime/hooks/AttachmentContext.d.ts +280 -112
- package/dist/legacy-runtime/hooks/AttachmentContext.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.js +1 -1
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/index.d.ts +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/index.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts +22 -0
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +17 -13
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.js +8 -6
- package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/getExternalStoreMessage.d.ts +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/getExternalStoreMessage.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/getExternalStoreMessage.js +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/getExternalStoreMessage.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/index.d.ts +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/index.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/index.js +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/index.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js +14 -4
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/model-context/index.d.ts +4 -13
- package/dist/model-context/index.d.ts.map +1 -1
- package/dist/model-context/index.js +6 -11
- package/dist/model-context/index.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreContent.d.ts +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreContent.d.ts.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreContent.js +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreContent.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreItem.d.ts +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreItem.d.ts.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreItem.js +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreItem.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreRoot.d.ts +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreRoot.d.ts.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreRoot.js +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreRoot.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreSeparator.d.ts +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreSeparator.d.ts.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreSeparator.js +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreSeparator.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreTrigger.d.ts +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreTrigger.d.ts.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreTrigger.js +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreTrigger.js.map +1 -1
- package/dist/primitives/actionBarMore/scope.d.ts +1 -1
- package/dist/primitives/actionBarMore/scope.d.ts.map +1 -1
- package/dist/primitives/actionBarMore/scope.js +1 -1
- package/dist/primitives/actionBarMore/scope.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.d.ts +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.js +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.d.ts +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.d.ts +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.js +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.js +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.js.map +1 -1
- package/dist/primitives/assistantModal/scope.d.ts +1 -1
- package/dist/primitives/assistantModal/scope.d.ts.map +1 -1
- package/dist/primitives/assistantModal/scope.js +1 -1
- package/dist/primitives/assistantModal/scope.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.d.ts +1 -38
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.js +1 -38
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.js +2 -2
- package/dist/primitives/composer/ComposerAttachmentDropzone.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.d.ts +1 -36
- package/dist/primitives/composer/ComposerAttachments.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.js +1 -61
- package/dist/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/primitives/composer/ComposerIf.d.ts +2 -17
- package/dist/primitives/composer/ComposerIf.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerIf.js +1 -23
- package/dist/primitives/composer/ComposerIf.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +2 -2
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/message/MessageAttachments.d.ts +1 -36
- package/dist/primitives/message/MessageAttachments.d.ts.map +1 -1
- package/dist/primitives/message/MessageAttachments.js +1 -65
- package/dist/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/primitives/message/MessageIf.d.ts +1 -1
- package/dist/primitives/message/MessageIf.js +1 -1
- package/dist/primitives/message/MessageParts.d.ts +5 -219
- package/dist/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/primitives/message/MessageParts.js +29 -270
- package/dist/primitives/message/MessageParts.js.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.d.ts +1 -1
- package/dist/primitives/message/MessagePartsGrouped.d.ts.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.js +2 -2
- package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
- package/dist/primitives/thread/ThreadEmpty.d.ts +3 -0
- package/dist/primitives/thread/ThreadEmpty.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadEmpty.js +4 -1
- package/dist/primitives/thread/ThreadEmpty.js.map +1 -1
- package/dist/primitives/thread/ThreadIf.d.ts +1 -1
- package/dist/primitives/thread/ThreadIf.js +1 -1
- package/dist/primitives/thread/ThreadMessages.d.ts +1 -94
- package/dist/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadMessages.js +1 -109
- package/dist/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestions.d.ts +1 -52
- package/dist/primitives/thread/ThreadSuggestions.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadSuggestions.js +1 -56
- package/dist/primitives/thread/ThreadSuggestions.js.map +1 -1
- package/dist/primitives/thread/ThreadViewportSlack.js +2 -2
- package/dist/primitives/thread/ThreadViewportSlack.js.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.d.ts +1 -34
- package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.js +1 -35
- package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTitle.d.ts +1 -7
- package/dist/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTitle.js +1 -7
- package/dist/primitives/threadListItem/ThreadListItemTitle.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.d.ts +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.d.ts +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.js +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.d.ts +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.js +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.d.ts +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.js +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.d.ts +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js.map +1 -1
- package/dist/primitives/threadListItemMore/scope.d.ts +1 -1
- package/dist/primitives/threadListItemMore/scope.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/scope.js +1 -1
- package/dist/primitives/threadListItemMore/scope.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/scopes/index.d.ts +1 -2
- package/dist/types/scopes/index.d.ts.map +1 -1
- package/package.json +10 -12
- package/src/client/ExternalThread.ts +25 -13
- package/src/client/InMemoryThreadList.ts +1 -2
- package/src/client/index.ts +3 -2
- package/src/context/providers/AttachmentByIndexProvider.tsx +4 -34
- package/src/context/providers/ChainOfThoughtByIndicesProvider.tsx +1 -34
- package/src/context/providers/ChainOfThoughtPartByIndexProvider.tsx +1 -18
- package/src/context/providers/MessageByIndexProvider.tsx +1 -23
- package/src/context/providers/PartByIndexProvider.tsx +1 -18
- package/src/context/providers/SuggestionByIndexProvider.tsx +4 -21
- package/src/context/providers/TextMessagePartProvider.tsx +1 -46
- package/src/context/providers/ThreadListItemProvider.tsx +4 -33
- package/src/context/providers/index.ts +1 -0
- package/src/index.ts +1 -1
- package/src/legacy-runtime/AssistantRuntimeProvider.tsx +13 -21
- package/src/legacy-runtime/RuntimeAdapter.ts +1 -66
- package/src/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.ts +179 -40
- package/src/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.ts +1 -1
- package/src/legacy-runtime/runtime-cores/assistant-transport/index.ts +1 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/types.ts +25 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts +22 -13
- package/src/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.test.ts +6 -3
- package/src/legacy-runtime/runtime-cores/external-store/external-message-converter.ts +19 -21
- package/src/legacy-runtime/runtime-cores/external-store/getExternalStoreMessage.ts +1 -0
- package/src/legacy-runtime/runtime-cores/external-store/index.ts +1 -0
- package/src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.ts +20 -4
- package/src/model-context/index.ts +29 -22
- package/src/primitives/actionBarMore/ActionBarMoreContent.tsx +1 -1
- package/src/primitives/actionBarMore/ActionBarMoreItem.tsx +1 -1
- package/src/primitives/actionBarMore/ActionBarMoreRoot.tsx +1 -1
- package/src/primitives/actionBarMore/ActionBarMoreSeparator.tsx +1 -1
- package/src/primitives/actionBarMore/ActionBarMoreTrigger.tsx +1 -1
- package/src/primitives/actionBarMore/scope.ts +1 -1
- package/src/primitives/assistantModal/AssistantModalAnchor.tsx +1 -1
- package/src/primitives/assistantModal/AssistantModalContent.tsx +1 -1
- package/src/primitives/assistantModal/AssistantModalRoot.tsx +1 -1
- package/src/primitives/assistantModal/AssistantModalTrigger.tsx +1 -1
- package/src/primitives/assistantModal/scope.ts +1 -1
- package/src/primitives/chainOfThought/ChainOfThoughtParts.tsx +1 -85
- package/src/primitives/composer/ComposerAttachmentDropzone.tsx +2 -2
- package/src/primitives/composer/ComposerAttachments.tsx +4 -110
- package/src/primitives/composer/ComposerIf.ts +2 -42
- package/src/primitives/composer/ComposerInput.tsx +2 -2
- package/src/primitives/message/MessageAttachments.tsx +4 -113
- package/src/primitives/message/MessageIf.ts +1 -1
- package/src/primitives/message/MessageParts.tsx +43 -642
- package/src/primitives/message/MessagePartsGrouped.tsx +3 -3
- package/src/primitives/thread/ThreadEmpty.ts +4 -3
- package/src/primitives/thread/ThreadIf.ts +1 -1
- package/src/primitives/thread/ThreadMessages.tsx +4 -217
- package/src/primitives/thread/ThreadSuggestions.tsx +4 -106
- package/src/primitives/thread/ThreadViewportSlack.tsx +2 -2
- package/src/primitives/threadList/ThreadListItems.tsx +4 -79
- package/src/primitives/threadListItem/ThreadListItemTitle.test.tsx +7 -3
- package/src/primitives/threadListItem/ThreadListItemTitle.tsx +1 -17
- package/src/primitives/threadListItemMore/ThreadListItemMoreContent.tsx +1 -1
- package/src/primitives/threadListItemMore/ThreadListItemMoreItem.tsx +1 -1
- package/src/primitives/threadListItemMore/ThreadListItemMoreRoot.tsx +1 -1
- package/src/primitives/threadListItemMore/ThreadListItemMoreSeparator.tsx +1 -1
- package/src/primitives/threadListItemMore/ThreadListItemMoreTrigger.tsx +1 -1
- package/src/primitives/threadListItemMore/scope.ts +1 -1
- package/src/tests/BaseComposerRuntimeCore.test.ts +106 -1
- package/src/tests/DataRenderers.test.ts +1 -2
- package/src/types/index.ts +3 -2
- package/src/types/scopes/index.ts +5 -3
- package/dist/client/DataRenderers.d.ts +0 -3
- package/dist/client/DataRenderers.d.ts.map +0 -1
- package/dist/client/DataRenderers.js +0 -33
- package/dist/client/DataRenderers.js.map +0 -1
- package/dist/client/Tools.d.ts +0 -8
- package/dist/client/Tools.d.ts.map +0 -1
- package/dist/client/Tools.js +0 -68
- package/dist/client/Tools.js.map +0 -1
- package/dist/model-context/makeAssistantDataUI.d.ts +0 -7
- package/dist/model-context/makeAssistantDataUI.d.ts.map +0 -1
- package/dist/model-context/makeAssistantDataUI.js +0 -11
- package/dist/model-context/makeAssistantDataUI.js.map +0 -1
- package/dist/model-context/makeAssistantTool.d.ts +0 -7
- package/dist/model-context/makeAssistantTool.d.ts.map +0 -1
- package/dist/model-context/makeAssistantTool.js +0 -11
- package/dist/model-context/makeAssistantTool.js.map +0 -1
- package/dist/model-context/makeAssistantToolUI.d.ts +0 -7
- package/dist/model-context/makeAssistantToolUI.d.ts.map +0 -1
- package/dist/model-context/makeAssistantToolUI.js +0 -11
- package/dist/model-context/makeAssistantToolUI.js.map +0 -1
- package/dist/model-context/toolbox.d.ts +0 -10
- package/dist/model-context/toolbox.d.ts.map +0 -1
- package/dist/model-context/toolbox.js +0 -3
- package/dist/model-context/toolbox.js.map +0 -1
- package/dist/model-context/useAssistantDataUI.d.ts +0 -7
- package/dist/model-context/useAssistantDataUI.d.ts.map +0 -1
- package/dist/model-context/useAssistantDataUI.js +0 -12
- package/dist/model-context/useAssistantDataUI.js.map +0 -1
- package/dist/model-context/useAssistantInstructions.d.ts +0 -4
- package/dist/model-context/useAssistantInstructions.d.ts.map +0 -1
- package/dist/model-context/useAssistantInstructions.js +0 -23
- package/dist/model-context/useAssistantInstructions.js.map +0 -1
- package/dist/model-context/useAssistantTool.d.ts +0 -7
- package/dist/model-context/useAssistantTool.d.ts.map +0 -1
- package/dist/model-context/useAssistantTool.js +0 -23
- package/dist/model-context/useAssistantTool.js.map +0 -1
- package/dist/model-context/useAssistantToolUI.d.ts +0 -7
- package/dist/model-context/useAssistantToolUI.d.ts.map +0 -1
- package/dist/model-context/useAssistantToolUI.js +0 -12
- package/dist/model-context/useAssistantToolUI.js.map +0 -1
- package/dist/model-context/useInlineRender.d.ts +0 -4
- package/dist/model-context/useInlineRender.d.ts.map +0 -1
- package/dist/model-context/useInlineRender.js +0 -16
- package/dist/model-context/useInlineRender.js.map +0 -1
- package/dist/types/MessagePartComponentTypes.d.ts +0 -33
- package/dist/types/MessagePartComponentTypes.d.ts.map +0 -1
- package/dist/types/MessagePartComponentTypes.js +0 -2
- package/dist/types/MessagePartComponentTypes.js.map +0 -1
- package/dist/types/scopes/dataRenderers.d.ts +0 -13
- package/dist/types/scopes/dataRenderers.d.ts.map +0 -1
- package/dist/types/scopes/dataRenderers.js +0 -2
- package/dist/types/scopes/dataRenderers.js.map +0 -1
- package/dist/types/scopes/tools.d.ts +0 -13
- package/dist/types/scopes/tools.d.ts.map +0 -1
- package/dist/types/scopes/tools.js +0 -2
- package/dist/types/scopes/tools.js.map +0 -1
- package/dist/types/store-augmentation.d.ts +0 -10
- package/dist/types/store-augmentation.d.ts.map +0 -1
- package/dist/types/store-augmentation.js +0 -2
- package/dist/types/store-augmentation.js.map +0 -1
- package/src/client/DataRenderers.ts +0 -42
- package/src/client/Tools.ts +0 -97
- package/src/model-context/makeAssistantDataUI.ts +0 -22
- package/src/model-context/makeAssistantTool.ts +0 -22
- package/src/model-context/makeAssistantToolUI.ts +0 -22
- package/src/model-context/toolbox.ts +0 -17
- package/src/model-context/useAssistantDataUI.ts +0 -18
- package/src/model-context/useAssistantInstructions.ts +0 -32
- package/src/model-context/useAssistantTool.ts +0 -39
- package/src/model-context/useAssistantToolUI.ts +0 -20
- package/src/model-context/useInlineRender.ts +0 -27
- package/src/types/MessagePartComponentTypes.ts +0 -66
- package/src/types/scopes/dataRenderers.ts +0 -15
- package/src/types/scopes/tools.ts +0 -18
- package/src/types/store-augmentation.ts +0 -11
|
@@ -64,10 +64,12 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
64
64
|
stepTimestamps?: StepTimestamp[];
|
|
65
65
|
},
|
|
66
66
|
) {
|
|
67
|
-
const
|
|
68
|
-
|
|
67
|
+
const encodedRunMessages = items.map((item) =>
|
|
68
|
+
formatAdapter.encode(item),
|
|
69
|
+
);
|
|
70
|
+
adapter._reportRunTelemetry(
|
|
69
71
|
formatAdapter.format,
|
|
70
|
-
|
|
72
|
+
encodedRunMessages,
|
|
71
73
|
options,
|
|
72
74
|
);
|
|
73
75
|
},
|
|
@@ -109,9 +111,9 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
109
111
|
};
|
|
110
112
|
}
|
|
111
113
|
|
|
112
|
-
private
|
|
114
|
+
private _reportRunTelemetry<T>(
|
|
113
115
|
format: string,
|
|
114
|
-
|
|
116
|
+
runMessages: T[],
|
|
115
117
|
options?: {
|
|
116
118
|
durationMs?: number;
|
|
117
119
|
stepTimestamps?: StepTimestamp[];
|
|
@@ -122,7 +124,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
122
124
|
const remoteId = this.aui.threadListItem().getState().remoteId;
|
|
123
125
|
if (!remoteId) return;
|
|
124
126
|
|
|
125
|
-
const extracted =
|
|
127
|
+
const extracted = extractRunTelemetry(format, runMessages);
|
|
126
128
|
if (!extracted) return;
|
|
127
129
|
|
|
128
130
|
this._sendReport(
|
|
@@ -147,6 +149,8 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
147
149
|
stepTimestamps?: StepTimestamp[],
|
|
148
150
|
) {
|
|
149
151
|
const mergedSteps = mergeStepTimestamps(data.steps, stepTimestamps);
|
|
152
|
+
// Keep in sync with assistant-cloud createRunSchema
|
|
153
|
+
// (apps/aui-cloud-api/src/endpoints/runs/create.ts).
|
|
150
154
|
const initial: Parameters<typeof this.cloudRef.current.runs.report>[0] = {
|
|
151
155
|
thread_id: remoteId,
|
|
152
156
|
status: data.status,
|
|
@@ -161,6 +165,12 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
|
|
|
161
165
|
...(data.outputTokens != null
|
|
162
166
|
? { output_tokens: data.outputTokens }
|
|
163
167
|
: undefined),
|
|
168
|
+
...(data.reasoningTokens != null
|
|
169
|
+
? { reasoning_tokens: data.reasoningTokens }
|
|
170
|
+
: undefined),
|
|
171
|
+
...(data.cachedInputTokens != null
|
|
172
|
+
? { cached_input_tokens: data.cachedInputTokens }
|
|
173
|
+
: undefined),
|
|
164
174
|
...(durationMs != null ? { duration_ms: durationMs } : undefined),
|
|
165
175
|
...(data.outputText != null
|
|
166
176
|
? { output_text: data.outputText }
|
|
@@ -253,6 +263,8 @@ function buildToolCall(
|
|
|
253
263
|
type TelemetryStepData = {
|
|
254
264
|
input_tokens?: number;
|
|
255
265
|
output_tokens?: number;
|
|
266
|
+
reasoning_tokens?: number;
|
|
267
|
+
cached_input_tokens?: number;
|
|
256
268
|
tool_calls?: TelemetryToolCall[];
|
|
257
269
|
start_ms?: number;
|
|
258
270
|
end_ms?: number;
|
|
@@ -280,6 +292,8 @@ type TelemetryData = {
|
|
|
280
292
|
totalSteps?: number;
|
|
281
293
|
inputTokens?: number;
|
|
282
294
|
outputTokens?: number;
|
|
295
|
+
reasoningTokens?: number;
|
|
296
|
+
cachedInputTokens?: number;
|
|
283
297
|
outputText?: string;
|
|
284
298
|
metadata?: Record<string, unknown>;
|
|
285
299
|
steps?: TelemetryStepData[];
|
|
@@ -297,15 +311,15 @@ function extractTelemetry<T>(format: string, content: T): TelemetryData | null {
|
|
|
297
311
|
}
|
|
298
312
|
}
|
|
299
313
|
|
|
300
|
-
function
|
|
314
|
+
function extractRunTelemetry<T>(
|
|
301
315
|
format: string,
|
|
302
|
-
|
|
316
|
+
runMessages: T[],
|
|
303
317
|
): TelemetryData | null {
|
|
304
318
|
if (format === "ai-sdk/v6") {
|
|
305
|
-
return
|
|
319
|
+
return aggregateAiSdkV6RunSteps(runMessages);
|
|
306
320
|
}
|
|
307
|
-
for (let i =
|
|
308
|
-
const result = extractTelemetry(format,
|
|
321
|
+
for (let i = runMessages.length - 1; i >= 0; i--) {
|
|
322
|
+
const result = extractTelemetry(format, runMessages[i]!);
|
|
309
323
|
if (result) return result;
|
|
310
324
|
}
|
|
311
325
|
return null;
|
|
@@ -332,7 +346,12 @@ function extractAuiV0<T>(content: T): TelemetryData | null {
|
|
|
332
346
|
metadata?: {
|
|
333
347
|
modelId?: string;
|
|
334
348
|
steps?: readonly {
|
|
335
|
-
usage?: {
|
|
349
|
+
usage?: {
|
|
350
|
+
inputTokens?: number;
|
|
351
|
+
outputTokens?: number;
|
|
352
|
+
reasoningTokens?: number;
|
|
353
|
+
cachedInputTokens?: number;
|
|
354
|
+
};
|
|
336
355
|
}[];
|
|
337
356
|
custom?: Record<string, unknown> & { modelId?: string };
|
|
338
357
|
};
|
|
@@ -355,13 +374,39 @@ function extractAuiV0<T>(content: T): TelemetryData | null {
|
|
|
355
374
|
const steps = msg.metadata?.steps;
|
|
356
375
|
let inputTokens: number | undefined;
|
|
357
376
|
let outputTokens: number | undefined;
|
|
377
|
+
let reasoningTokens: number | undefined;
|
|
378
|
+
let cachedInputTokens: number | undefined;
|
|
358
379
|
if (steps && steps.length > 0) {
|
|
359
|
-
|
|
360
|
-
|
|
380
|
+
let totalInput = 0;
|
|
381
|
+
let totalOutput = 0;
|
|
382
|
+
let totalReasoning = 0;
|
|
383
|
+
let totalCachedInput = 0;
|
|
384
|
+
let hasInput = false;
|
|
385
|
+
let hasOutput = false;
|
|
386
|
+
let hasReasoning = false;
|
|
387
|
+
let hasCachedInput = false;
|
|
361
388
|
for (const step of steps) {
|
|
362
|
-
|
|
363
|
-
|
|
389
|
+
if (step.usage?.inputTokens != null) {
|
|
390
|
+
totalInput += step.usage.inputTokens;
|
|
391
|
+
hasInput = true;
|
|
392
|
+
}
|
|
393
|
+
if (step.usage?.outputTokens != null) {
|
|
394
|
+
totalOutput += step.usage.outputTokens;
|
|
395
|
+
hasOutput = true;
|
|
396
|
+
}
|
|
397
|
+
if (step.usage?.reasoningTokens != null) {
|
|
398
|
+
totalReasoning += step.usage.reasoningTokens;
|
|
399
|
+
hasReasoning = true;
|
|
400
|
+
}
|
|
401
|
+
if (step.usage?.cachedInputTokens != null) {
|
|
402
|
+
totalCachedInput += step.usage.cachedInputTokens;
|
|
403
|
+
hasCachedInput = true;
|
|
404
|
+
}
|
|
364
405
|
}
|
|
406
|
+
inputTokens = hasInput ? totalInput : undefined;
|
|
407
|
+
outputTokens = hasOutput ? totalOutput : undefined;
|
|
408
|
+
reasoningTokens = hasReasoning ? totalReasoning : undefined;
|
|
409
|
+
cachedInputTokens = hasCachedInput ? totalCachedInput : undefined;
|
|
365
410
|
}
|
|
366
411
|
|
|
367
412
|
const statusType = msg.status?.type;
|
|
@@ -384,6 +429,12 @@ function extractAuiV0<T>(content: T): TelemetryData | null {
|
|
|
384
429
|
...(s.usage?.outputTokens != null
|
|
385
430
|
? { output_tokens: s.usage.outputTokens }
|
|
386
431
|
: undefined),
|
|
432
|
+
...(s.usage?.reasoningTokens != null
|
|
433
|
+
? { reasoning_tokens: s.usage.reasoningTokens }
|
|
434
|
+
: undefined),
|
|
435
|
+
...(s.usage?.cachedInputTokens != null
|
|
436
|
+
? { cached_input_tokens: s.usage.cachedInputTokens }
|
|
437
|
+
: undefined),
|
|
387
438
|
}))
|
|
388
439
|
: undefined;
|
|
389
440
|
|
|
@@ -393,6 +444,8 @@ function extractAuiV0<T>(content: T): TelemetryData | null {
|
|
|
393
444
|
...(steps?.length ? { totalSteps: steps.length } : undefined),
|
|
394
445
|
...(inputTokens != null ? { inputTokens } : undefined),
|
|
395
446
|
...(outputTokens != null ? { outputTokens } : undefined),
|
|
447
|
+
...(reasoningTokens != null ? { reasoningTokens } : undefined),
|
|
448
|
+
...(cachedInputTokens != null ? { cachedInputTokens } : undefined),
|
|
396
449
|
...(outputText != null ? { outputText } : undefined),
|
|
397
450
|
...(metadata ? { metadata } : undefined),
|
|
398
451
|
...(telemetrySteps ? { steps: telemetrySteps } : undefined),
|
|
@@ -491,7 +544,12 @@ function buildAiSdkV6Result(
|
|
|
491
544
|
totalSteps: number,
|
|
492
545
|
metadata?: Record<string, unknown>,
|
|
493
546
|
stepsData?: { tool_calls: TelemetryToolCall[] }[],
|
|
494
|
-
usage?: {
|
|
547
|
+
usage?: {
|
|
548
|
+
inputTokens?: number;
|
|
549
|
+
outputTokens?: number;
|
|
550
|
+
reasoningTokens?: number;
|
|
551
|
+
cachedInputTokens?: number;
|
|
552
|
+
},
|
|
495
553
|
): TelemetryData {
|
|
496
554
|
const hasText = textParts.length > 0;
|
|
497
555
|
const outputText = hasText ? truncateStr(textParts.join("")) : undefined;
|
|
@@ -516,6 +574,12 @@ function buildAiSdkV6Result(
|
|
|
516
574
|
...(usage?.outputTokens != null
|
|
517
575
|
? { outputTokens: usage.outputTokens }
|
|
518
576
|
: undefined),
|
|
577
|
+
...(usage?.reasoningTokens != null
|
|
578
|
+
? { reasoningTokens: usage.reasoningTokens }
|
|
579
|
+
: undefined),
|
|
580
|
+
...(usage?.cachedInputTokens != null
|
|
581
|
+
? { cachedInputTokens: usage.cachedInputTokens }
|
|
582
|
+
: undefined),
|
|
519
583
|
...(outputText != null ? { outputText } : undefined),
|
|
520
584
|
...(metadata ? { metadata } : undefined),
|
|
521
585
|
...(steps ? { steps } : undefined),
|
|
@@ -528,23 +592,49 @@ type UsageFields = {
|
|
|
528
592
|
outputTokens?: number;
|
|
529
593
|
promptTokens?: number;
|
|
530
594
|
completionTokens?: number;
|
|
595
|
+
reasoningTokens?: number;
|
|
596
|
+
cachedInputTokens?: number;
|
|
531
597
|
};
|
|
532
598
|
|
|
533
|
-
function normalizeUsage(
|
|
534
|
-
|
|
535
|
-
|
|
599
|
+
function normalizeUsage(u: UsageFields):
|
|
600
|
+
| {
|
|
601
|
+
inputTokens?: number;
|
|
602
|
+
outputTokens?: number;
|
|
603
|
+
reasoningTokens?: number;
|
|
604
|
+
cachedInputTokens?: number;
|
|
605
|
+
}
|
|
606
|
+
| undefined {
|
|
536
607
|
const input = u.inputTokens ?? u.promptTokens;
|
|
537
608
|
const output = u.outputTokens ?? u.completionTokens;
|
|
538
|
-
if (
|
|
609
|
+
if (
|
|
610
|
+
input == null &&
|
|
611
|
+
output == null &&
|
|
612
|
+
u.reasoningTokens == null &&
|
|
613
|
+
u.cachedInputTokens == null
|
|
614
|
+
) {
|
|
615
|
+
return undefined;
|
|
616
|
+
}
|
|
617
|
+
|
|
539
618
|
return {
|
|
540
|
-
inputTokens: input
|
|
541
|
-
outputTokens: output
|
|
619
|
+
...(input != null ? { inputTokens: input } : undefined),
|
|
620
|
+
...(output != null ? { outputTokens: output } : undefined),
|
|
621
|
+
...(u.reasoningTokens != null
|
|
622
|
+
? { reasoningTokens: u.reasoningTokens }
|
|
623
|
+
: undefined),
|
|
624
|
+
...(u.cachedInputTokens != null
|
|
625
|
+
? { cachedInputTokens: u.cachedInputTokens }
|
|
626
|
+
: undefined),
|
|
542
627
|
};
|
|
543
628
|
}
|
|
544
629
|
|
|
545
|
-
function extractAiSdkV6Usage(
|
|
546
|
-
|
|
547
|
-
|
|
630
|
+
function extractAiSdkV6Usage(metadata?: Record<string, unknown>):
|
|
631
|
+
| {
|
|
632
|
+
inputTokens?: number;
|
|
633
|
+
outputTokens?: number;
|
|
634
|
+
reasoningTokens?: number;
|
|
635
|
+
cachedInputTokens?: number;
|
|
636
|
+
}
|
|
637
|
+
| undefined {
|
|
548
638
|
// Try top-level metadata.usage
|
|
549
639
|
const usage = metadata?.usage as UsageFields | undefined;
|
|
550
640
|
if (usage) {
|
|
@@ -559,17 +649,44 @@ function extractAiSdkV6Usage(
|
|
|
559
649
|
if (steps && steps.length > 0) {
|
|
560
650
|
let inputTokens = 0;
|
|
561
651
|
let outputTokens = 0;
|
|
652
|
+
let reasoningTokens = 0;
|
|
653
|
+
let cachedInputTokens = 0;
|
|
654
|
+
let hasInput = false;
|
|
655
|
+
let hasOutput = false;
|
|
656
|
+
let hasReasoning = false;
|
|
657
|
+
let hasCachedInput = false;
|
|
562
658
|
let hasAny = false;
|
|
563
659
|
for (const s of steps) {
|
|
564
660
|
if (!s.usage) continue;
|
|
565
661
|
const n = normalizeUsage(s.usage);
|
|
566
662
|
if (n) {
|
|
567
|
-
|
|
568
|
-
|
|
663
|
+
if (n.inputTokens != null) {
|
|
664
|
+
inputTokens += n.inputTokens;
|
|
665
|
+
hasInput = true;
|
|
666
|
+
}
|
|
667
|
+
if (n.outputTokens != null) {
|
|
668
|
+
outputTokens += n.outputTokens;
|
|
669
|
+
hasOutput = true;
|
|
670
|
+
}
|
|
671
|
+
if (n.reasoningTokens != null) {
|
|
672
|
+
reasoningTokens += n.reasoningTokens;
|
|
673
|
+
hasReasoning = true;
|
|
674
|
+
}
|
|
675
|
+
if (n.cachedInputTokens != null) {
|
|
676
|
+
cachedInputTokens += n.cachedInputTokens;
|
|
677
|
+
hasCachedInput = true;
|
|
678
|
+
}
|
|
569
679
|
hasAny = true;
|
|
570
680
|
}
|
|
571
681
|
}
|
|
572
|
-
if (hasAny)
|
|
682
|
+
if (hasAny) {
|
|
683
|
+
return {
|
|
684
|
+
...(hasInput ? { inputTokens } : undefined),
|
|
685
|
+
...(hasOutput ? { outputTokens } : undefined),
|
|
686
|
+
...(hasReasoning ? { reasoningTokens } : undefined),
|
|
687
|
+
...(hasCachedInput ? { cachedInputTokens } : undefined),
|
|
688
|
+
};
|
|
689
|
+
}
|
|
573
690
|
}
|
|
574
691
|
|
|
575
692
|
return undefined;
|
|
@@ -592,17 +709,22 @@ function extractAiSdkV6<T>(content: T): TelemetryData | null {
|
|
|
592
709
|
);
|
|
593
710
|
}
|
|
594
711
|
|
|
595
|
-
function
|
|
712
|
+
function aggregateAiSdkV6RunSteps<T>(stepMessages: T[]): TelemetryData | null {
|
|
596
713
|
const allTextParts: string[] = [];
|
|
597
714
|
const allToolCalls: TelemetryToolCall[] = [];
|
|
598
715
|
const allStepsData: { tool_calls: TelemetryToolCall[] }[] = [];
|
|
599
716
|
let hasAssistant = false;
|
|
600
717
|
let metadata: Record<string, unknown> | undefined;
|
|
601
|
-
let
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
718
|
+
let inputTokens = 0;
|
|
719
|
+
let outputTokens = 0;
|
|
720
|
+
let reasoningTokens = 0;
|
|
721
|
+
let cachedInputTokens = 0;
|
|
722
|
+
let hasInput = false;
|
|
723
|
+
let hasOutput = false;
|
|
724
|
+
let hasReasoning = false;
|
|
725
|
+
let hasCachedInput = false;
|
|
726
|
+
|
|
727
|
+
for (const content of stepMessages) {
|
|
606
728
|
const msg = content as AiSdkV6Message;
|
|
607
729
|
if (msg.role !== "assistant") continue;
|
|
608
730
|
hasAssistant = true;
|
|
@@ -617,10 +739,22 @@ function extractAiSdkV6Batch<T>(contents: T[]): TelemetryData | null {
|
|
|
617
739
|
|
|
618
740
|
const usage = extractAiSdkV6Usage(msg.metadata);
|
|
619
741
|
if (usage) {
|
|
620
|
-
if (
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
742
|
+
if (usage.inputTokens != null) {
|
|
743
|
+
inputTokens += usage.inputTokens;
|
|
744
|
+
hasInput = true;
|
|
745
|
+
}
|
|
746
|
+
if (usage.outputTokens != null) {
|
|
747
|
+
outputTokens += usage.outputTokens;
|
|
748
|
+
hasOutput = true;
|
|
749
|
+
}
|
|
750
|
+
if (usage.reasoningTokens != null) {
|
|
751
|
+
reasoningTokens += usage.reasoningTokens;
|
|
752
|
+
hasReasoning = true;
|
|
753
|
+
}
|
|
754
|
+
if (usage.cachedInputTokens != null) {
|
|
755
|
+
cachedInputTokens += usage.cachedInputTokens;
|
|
756
|
+
hasCachedInput = true;
|
|
757
|
+
}
|
|
624
758
|
}
|
|
625
759
|
}
|
|
626
760
|
|
|
@@ -631,7 +765,12 @@ function extractAiSdkV6Batch<T>(contents: T[]): TelemetryData | null {
|
|
|
631
765
|
allStepsData.length,
|
|
632
766
|
metadata,
|
|
633
767
|
allStepsData,
|
|
634
|
-
|
|
768
|
+
{
|
|
769
|
+
...(hasInput ? { inputTokens } : undefined),
|
|
770
|
+
...(hasOutput ? { outputTokens } : undefined),
|
|
771
|
+
...(hasReasoning ? { reasoningTokens } : undefined),
|
|
772
|
+
...(hasCachedInput ? { cachedInputTokens } : undefined),
|
|
773
|
+
},
|
|
635
774
|
);
|
|
636
775
|
}
|
|
637
776
|
|
|
@@ -83,6 +83,16 @@ export type HeadersValue = Record<string, string> | Headers;
|
|
|
83
83
|
|
|
84
84
|
export type AssistantTransportProtocol = "data-stream" | "assistant-transport";
|
|
85
85
|
|
|
86
|
+
export type SendCommandsRequestBody = {
|
|
87
|
+
commands: QueuedCommand[];
|
|
88
|
+
state: unknown;
|
|
89
|
+
system: string | undefined;
|
|
90
|
+
tools: Record<string, unknown> | undefined;
|
|
91
|
+
threadId: string | null;
|
|
92
|
+
parentId?: string | null;
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
};
|
|
95
|
+
|
|
86
96
|
export type AssistantTransportOptions<T> = {
|
|
87
97
|
initialState: T;
|
|
88
98
|
api: string;
|
|
@@ -91,6 +101,21 @@ export type AssistantTransportOptions<T> = {
|
|
|
91
101
|
converter: AssistantTransportStateConverter<T>;
|
|
92
102
|
headers: HeadersValue | (() => Promise<HeadersValue>);
|
|
93
103
|
body?: object | (() => Promise<object | undefined>);
|
|
104
|
+
/**
|
|
105
|
+
* Transform the request body before it is sent to the API.
|
|
106
|
+
* Receives the fully assembled body and returns the (potentially transformed) body.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* prepareSendCommandsRequest: (body) => ({
|
|
111
|
+
* ...body,
|
|
112
|
+
* trackingId: crypto.randomUUID(),
|
|
113
|
+
* })
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
prepareSendCommandsRequest?: (
|
|
117
|
+
body: SendCommandsRequestBody,
|
|
118
|
+
) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
94
119
|
onResponse?: (response: Response) => void;
|
|
95
120
|
onFinish?: () => void;
|
|
96
121
|
onError?: (
|
package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
UserMessagePart,
|
|
25
25
|
QueuedCommand,
|
|
26
26
|
AssistantTransportCommand,
|
|
27
|
+
SendCommandsRequestBody,
|
|
27
28
|
} from "./types";
|
|
28
29
|
import { useCommandQueue } from "./commandQueue";
|
|
29
30
|
import { useRunManager } from "./runManager";
|
|
@@ -137,24 +138,32 @@ const useAssistantTransportThreadRuntime = <T>(
|
|
|
137
138
|
: options.body;
|
|
138
139
|
const context = runtime.thread.getModelContext();
|
|
139
140
|
|
|
141
|
+
let requestBody: Record<string, unknown> = {
|
|
142
|
+
commands,
|
|
143
|
+
state: agentStateRef.current,
|
|
144
|
+
system: context.system,
|
|
145
|
+
tools: context.tools ? toToolsJSONSchema(context.tools) : undefined,
|
|
146
|
+
threadId,
|
|
147
|
+
...(parentIdRef.current !== undefined && {
|
|
148
|
+
parentId: parentIdRef.current,
|
|
149
|
+
}),
|
|
150
|
+
...context.callSettings,
|
|
151
|
+
...context.config,
|
|
152
|
+
...(bodyValue ?? {}),
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
if (options.prepareSendCommandsRequest) {
|
|
156
|
+
requestBody = await options.prepareSendCommandsRequest(
|
|
157
|
+
requestBody as SendCommandsRequestBody,
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
140
161
|
const response = await fetch(
|
|
141
162
|
isResume ? options.resumeApi! : options.api,
|
|
142
163
|
{
|
|
143
164
|
method: "POST",
|
|
144
165
|
headers,
|
|
145
|
-
body: JSON.stringify(
|
|
146
|
-
commands,
|
|
147
|
-
state: agentStateRef.current,
|
|
148
|
-
system: context.system,
|
|
149
|
-
tools: context.tools ? toToolsJSONSchema(context.tools) : undefined,
|
|
150
|
-
threadId,
|
|
151
|
-
...(parentIdRef.current !== undefined && {
|
|
152
|
-
parentId: parentIdRef.current,
|
|
153
|
-
}),
|
|
154
|
-
...context.callSettings,
|
|
155
|
-
...context.config,
|
|
156
|
-
...(bodyValue ?? {}),
|
|
157
|
-
}),
|
|
166
|
+
body: JSON.stringify(requestBody),
|
|
158
167
|
signal,
|
|
159
168
|
},
|
|
160
169
|
);
|
|
@@ -4,8 +4,9 @@ import type { ThreadAssistantMessage } from "@assistant-ui/core";
|
|
|
4
4
|
import type { Tool } from "assistant-stream";
|
|
5
5
|
import { act, renderHook, waitFor } from "@testing-library/react";
|
|
6
6
|
import { describe, expect, it, vi } from "vitest";
|
|
7
|
-
import type { AssistantTransportState
|
|
8
|
-
import { useToolInvocations } from "./useToolInvocations";
|
|
7
|
+
import type { AssistantTransportState } from "./types";
|
|
8
|
+
import { ToolExecutionStatus, useToolInvocations } from "./useToolInvocations";
|
|
9
|
+
import { ReadonlyJSONObject } from "assistant-stream/utils";
|
|
9
10
|
|
|
10
11
|
const createState = (
|
|
11
12
|
messages: ThreadAssistantMessage[],
|
|
@@ -34,7 +35,7 @@ const createAssistantMessage = (
|
|
|
34
35
|
type: "tool-call",
|
|
35
36
|
toolCallId: "tool-1",
|
|
36
37
|
toolName: "weatherSearch",
|
|
37
|
-
args,
|
|
38
|
+
args: args as ReadonlyJSONObject,
|
|
38
39
|
argsText,
|
|
39
40
|
},
|
|
40
41
|
],
|
|
@@ -45,6 +46,7 @@ describe("useToolInvocations", () => {
|
|
|
45
46
|
const execute = vi.fn(async () => ({ forecast: "ok" }));
|
|
46
47
|
const getTools = () => ({
|
|
47
48
|
weatherSearch: {
|
|
49
|
+
parameters: { type: "object", properties: {} },
|
|
48
50
|
execute,
|
|
49
51
|
} satisfies Tool,
|
|
50
52
|
});
|
|
@@ -137,6 +139,7 @@ describe("useToolInvocations", () => {
|
|
|
137
139
|
);
|
|
138
140
|
const getTools = () => ({
|
|
139
141
|
weatherSearch: {
|
|
142
|
+
parameters: { type: "object", properties: {} },
|
|
140
143
|
execute,
|
|
141
144
|
} satisfies Tool,
|
|
142
145
|
});
|
|
@@ -5,6 +5,7 @@ import { ThreadMessageConverter } from "./ThreadMessageConverter";
|
|
|
5
5
|
import {
|
|
6
6
|
getExternalStoreMessages,
|
|
7
7
|
symbolInnerMessage,
|
|
8
|
+
bindExternalStoreMessage,
|
|
8
9
|
} from "./getExternalStoreMessage";
|
|
9
10
|
import { fromThreadMessageLike, ThreadMessageLike } from "./ThreadMessageLike";
|
|
10
11
|
import { getAutoStatus, isAutoStatus } from "./auto-status";
|
|
@@ -276,23 +277,22 @@ const chunkExternalMessages = <T>(
|
|
|
276
277
|
function createErrorAssistantMessage(
|
|
277
278
|
error: ReadonlyJSONValue,
|
|
278
279
|
): ThreadAssistantMessage {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
steps: [],
|
|
292
|
-
},
|
|
280
|
+
const msg: ThreadAssistantMessage = {
|
|
281
|
+
id: generateErrorMessageId(),
|
|
282
|
+
role: "assistant",
|
|
283
|
+
content: [],
|
|
284
|
+
status: { type: "incomplete", reason: "error", error },
|
|
285
|
+
createdAt: new Date(),
|
|
286
|
+
metadata: {
|
|
287
|
+
unstable_state: null,
|
|
288
|
+
unstable_annotations: [],
|
|
289
|
+
unstable_data: [],
|
|
290
|
+
custom: {},
|
|
291
|
+
steps: [],
|
|
293
292
|
},
|
|
294
|
-
|
|
295
|
-
);
|
|
293
|
+
};
|
|
294
|
+
bindExternalStoreMessage(msg, []);
|
|
295
|
+
return msg;
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
export const convertExternalMessages = <T extends WeakKey>(
|
|
@@ -331,7 +331,7 @@ export const convertExternalMessages = <T extends WeakKey>(
|
|
|
331
331
|
idx.toString(),
|
|
332
332
|
autoStatus,
|
|
333
333
|
);
|
|
334
|
-
(newMessage
|
|
334
|
+
bindExternalStoreMessage(newMessage, message.inputs);
|
|
335
335
|
return newMessage;
|
|
336
336
|
});
|
|
337
337
|
|
|
@@ -439,14 +439,12 @@ export const useExternalMessageConverter = <T extends WeakKey>({
|
|
|
439
439
|
idx.toString(),
|
|
440
440
|
autoStatus,
|
|
441
441
|
);
|
|
442
|
-
(newMessage
|
|
442
|
+
bindExternalStoreMessage(newMessage, message.inputs);
|
|
443
443
|
return newMessage;
|
|
444
444
|
},
|
|
445
445
|
);
|
|
446
446
|
|
|
447
|
-
(threadMessages
|
|
448
|
-
symbolInnerMessage
|
|
449
|
-
] = messages;
|
|
447
|
+
bindExternalStoreMessage(threadMessages, messages);
|
|
450
448
|
|
|
451
449
|
if (state.metadata.error) {
|
|
452
450
|
const lastMessage = threadMessages.at(-1);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useState, useEffect, useMemo } from "react";
|
|
3
|
+
import { useState, useEffect, useMemo, useRef, useCallback } from "react";
|
|
4
4
|
import {
|
|
5
5
|
BaseAssistantRuntimeCore,
|
|
6
6
|
AssistantRuntimeImpl,
|
|
@@ -46,11 +46,27 @@ const useRemoteThreadListRuntimeImpl = (
|
|
|
46
46
|
export const useRemoteThreadListRuntime = (
|
|
47
47
|
options: RemoteThreadListOptions,
|
|
48
48
|
): AssistantRuntime => {
|
|
49
|
+
const runtimeHookRef = useRef(options.runtimeHook);
|
|
50
|
+
runtimeHookRef.current = options.runtimeHook;
|
|
51
|
+
|
|
52
|
+
const stableRuntimeHook = useCallback(() => {
|
|
53
|
+
return runtimeHookRef.current();
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
56
|
+
const stableOptions = useMemo<RemoteThreadListOptions>(
|
|
57
|
+
() => ({
|
|
58
|
+
adapter: options.adapter,
|
|
59
|
+
allowNesting: options.allowNesting,
|
|
60
|
+
runtimeHook: stableRuntimeHook,
|
|
61
|
+
}),
|
|
62
|
+
[options.adapter, options.allowNesting, stableRuntimeHook],
|
|
63
|
+
);
|
|
64
|
+
|
|
49
65
|
const aui = useAui();
|
|
50
66
|
const isNested = aui.threadListItem.source !== null;
|
|
51
67
|
|
|
52
68
|
if (isNested) {
|
|
53
|
-
if (!
|
|
69
|
+
if (!stableOptions.allowNesting) {
|
|
54
70
|
throw new Error(
|
|
55
71
|
"useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. " +
|
|
56
72
|
"Set allowNesting: true to allow nesting (the inner runtime will become a no-op).",
|
|
@@ -59,8 +75,8 @@ export const useRemoteThreadListRuntime = (
|
|
|
59
75
|
|
|
60
76
|
// If allowNesting is true and already inside a thread list context,
|
|
61
77
|
// just call the runtimeHook directly (no-op behavior)
|
|
62
|
-
return
|
|
78
|
+
return stableRuntimeHook();
|
|
63
79
|
}
|
|
64
80
|
|
|
65
|
-
return useRemoteThreadListRuntimeImpl(
|
|
81
|
+
return useRemoteThreadListRuntimeImpl(stableOptions);
|
|
66
82
|
};
|