@assistant-ui/core 0.2.5 → 0.2.7
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/index.d.ts +4 -2
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/duplicate-detection.d.ts +5 -0
- package/dist/internal/duplicate-detection.d.ts.map +1 -0
- package/dist/internal/duplicate-detection.js +11 -0
- package/dist/internal/duplicate-detection.js.map +1 -0
- package/dist/react/AssistantProvider.d.ts.map +1 -1
- package/dist/react/AssistantProvider.js.map +1 -1
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +2 -2
- package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.d.ts +25 -21
- package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageGroupedParts.js +6 -7
- package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
- package/dist/react/primitives/message/MessageParts.d.ts +2 -1
- package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/react/primitives/message/MessageParts.js +9 -4
- package/dist/react/primitives/message/MessageParts.js.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
- package/dist/react/providers/TextMessagePartProvider.js +3 -0
- package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +3 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +3 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.d.ts +1 -1
- package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
- package/dist/react/runtimes/external-message-converter.js +7 -3
- package/dist/react/runtimes/external-message-converter.js.map +1 -1
- package/dist/react/types/MessagePartComponentTypes.d.ts +8 -0
- package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
- package/dist/react/utils/groupParts.d.ts +40 -12
- package/dist/react/utils/groupParts.d.ts.map +1 -1
- package/dist/react/utils/groupParts.js +51 -9
- package/dist/react/utils/groupParts.js.map +1 -1
- package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
- package/dist/runtime/api/attachment-runtime.js.map +1 -1
- package/dist/runtime/api/message-part-runtime.d.ts +8 -0
- package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-part-runtime.js +13 -0
- package/dist/runtime/api/message-part-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +2 -1
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +2 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +15 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.d.ts +10 -0
- package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts +33 -1
- package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +27 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +98 -3
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +2 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +3 -0
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +1 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +3 -0
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js +3 -0
- package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +168 -0
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -0
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +449 -0
- package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -0
- package/dist/store/clients/thread-message-client.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.js +3 -0
- package/dist/store/clients/thread-message-client.js.map +1 -1
- package/dist/store/runtime-clients/message-part-runtime-client.js +1 -0
- package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
- package/dist/store/scopes/part.d.ts +7 -0
- package/dist/store/scopes/part.d.ts.map +1 -1
- package/dist/subscribable/subscribable.d.ts.map +1 -1
- package/dist/subscribable/subscribable.js.map +1 -1
- package/dist/types/message.d.ts +6 -0
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/package.json +4 -4
- package/src/adapters/index.ts +1 -4
- package/src/index.ts +11 -0
- package/src/internal/duplicate-detection.ts +26 -0
- package/src/react/AssistantProvider.tsx +2 -3
- package/src/react/index.ts +2 -6
- package/src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx +1 -2
- package/src/react/primitives/message/MessageAttachments.test.tsx +1 -1
- package/src/react/primitives/message/MessageGroupedParts.tsx +38 -31
- package/src/react/primitives/message/MessageParts.tsx +14 -1
- package/src/react/providers/TextMessagePartProvider.tsx +3 -0
- package/src/react/runtimes/external-message-converter.ts +26 -13
- package/src/react/types/MessagePartComponentTypes.ts +8 -0
- package/src/react/utils/groupParts.ts +67 -22
- package/src/runtime/api/attachment-runtime.ts +1 -2
- package/src/runtime/api/message-part-runtime.ts +26 -0
- package/src/runtime/base/base-thread-runtime-core.ts +4 -0
- package/src/runtime/interfaces/thread-runtime-core.ts +15 -0
- package/src/runtime/internal.ts +1 -4
- package/src/runtime/utils/thread-message-like.ts +7 -0
- package/src/runtimes/external-store/external-store-adapter.ts +37 -0
- package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +1 -3
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +168 -4
- package/src/runtimes/local/local-thread-runtime-core.ts +5 -0
- package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +4 -0
- package/src/runtimes/remote-thread-list/empty-thread-core.ts +4 -0
- package/src/runtimes/tool-invocations/EDGE_CASES.md +194 -0
- package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +1054 -0
- package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +783 -0
- package/src/store/clients/thread-message-client.ts +3 -0
- package/src/store/runtime-clients/message-part-runtime-client.ts +2 -0
- package/src/store/scopes/part.ts +4 -0
- package/src/subscribable/subscribable.ts +3 -3
- package/src/tests/OptimisticState-delete-crash.test.ts +2 -0
- package/src/tests/OptimisticState-list-race.test.ts +2 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-loadMore.test.ts +5 -5
- package/src/tests/auiV0Encode.test.ts +1 -1
- package/src/tests/composer-can-send.test.ts +8 -4
- package/src/tests/duplicate-detection.test.ts +34 -0
- package/src/tests/external-store-thread-list-runtime-core.test.ts +1 -1
- package/src/tests/external-store-thread-runtime-core.test.ts +7 -6
- package/src/tests/groupParts.test.ts +118 -32
- package/src/tests/no-unsafe-process-env.test.ts +1 -0
- package/src/tests/remote-thread-list-isLoading.test.ts +2 -0
- package/src/tests/thread-message-like.test.ts +4 -1
- package/src/types/index.ts +1 -4
- package/src/types/message.ts +7 -0
- package/dist/react/runtimes/useToolInvocations.d.ts +0 -53
- package/dist/react/runtimes/useToolInvocations.d.ts.map +0 -1
- package/dist/react/runtimes/useToolInvocations.js +0 -380
- package/dist/react/runtimes/useToolInvocations.js.map +0 -1
- package/src/react/runtimes/useToolInvocations.ts +0 -694
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference path="./store/scope-registration.d.ts" />
|
|
1
2
|
import { AppendMessage, DataMessagePart, FileMessagePart, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, ImageMessagePart, MCP_APP_URI_SCHEME, McpAppMetadata, MessagePartStatus, MessageRole, MessageStatus, MessageTiming, ReasoningMessagePart, RunConfig, SourceMessagePart, SourceProviderMetadata, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadMessage, ThreadStep, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolCallMessagePart, ToolCallMessagePartMcpMetadata, ToolCallMessagePartStatus, ToolModelContentPart, Unstable_AudioMessagePart, isMcpAppUri } from "./types/message.js";
|
|
2
3
|
import { Attachment, AttachmentStatus, CompleteAttachment, CompleteAttachmentStatus, CreateAttachment, PendingAttachment, PendingAttachmentStatus } from "./types/attachment.js";
|
|
3
4
|
import { AttachmentAdapter, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter } from "./adapters/attachment.js";
|
|
@@ -14,11 +15,12 @@ import { ThreadMessageLike } from "./runtime/utils/thread-message-like.js";
|
|
|
14
15
|
import { ExportedMessageRepository, ExportedMessageRepositoryItem } from "./runtime/utils/message-repository.js";
|
|
15
16
|
import { QuoteInfo } from "./types/quote.js";
|
|
16
17
|
import { AttachmentAddErrorEvent, AttachmentAddErrorReason, ComposerRuntimeCore, ComposerRuntimeEventCallback, ComposerRuntimeEventPayload, ComposerRuntimeEventType, DictationState, EditComposerRuntimeCore, SendOptions, ThreadComposerRuntimeCore } from "./runtime/interfaces/composer-runtime-core.js";
|
|
17
|
-
import { AddToolResultOptions, ResumeRunConfig, ResumeToolCallOptions, RuntimeCapabilities, SpeechState, StartRunConfig, SubmitFeedbackOptions, SubmittedFeedback, ThreadRuntimeCore, ThreadRuntimeEventCallback, ThreadRuntimeEventPayload, ThreadRuntimeEventType, ThreadSuggestion, VoiceSessionState } from "./runtime/interfaces/thread-runtime-core.js";
|
|
18
|
+
import { AddToolResultOptions, RespondToToolApprovalOptions, ResumeRunConfig, ResumeToolCallOptions, RuntimeCapabilities, SpeechState, StartRunConfig, SubmitFeedbackOptions, SubmittedFeedback, ThreadRuntimeCore, ThreadRuntimeEventCallback, ThreadRuntimeEventPayload, ThreadRuntimeEventType, ThreadSuggestion, VoiceSessionState } from "./runtime/interfaces/thread-runtime-core.js";
|
|
18
19
|
import { SuggestionAdapter } from "./adapters/suggestion.js";
|
|
19
20
|
import { Unstable_TriggerAdapter } from "./adapters/trigger.js";
|
|
20
21
|
import { GenericThreadHistoryAdapter, MessageFormatAdapter, MessageFormatItem, MessageFormatRepository, MessageStorageEntry, ThreadHistoryAdapter } from "./adapters/thread-history.js";
|
|
21
22
|
import { tool } from "./model-context/tool.js";
|
|
23
|
+
import { ToolExecutionStatus } from "./runtimes/tool-invocations/ToolInvocationTracker.js";
|
|
22
24
|
import { ModelContextRegistryInstructionHandle, ModelContextRegistryProviderHandle, ModelContextRegistryToolHandle } from "./model-context/registry-handles.js";
|
|
23
25
|
import { ModelContextRegistry } from "./model-context/registry.js";
|
|
24
26
|
import { AssistantFrameHost } from "./model-context/frame/host.js";
|
|
@@ -42,4 +44,4 @@ import { CreateAppendMessage, CreateResumeRunConfig, CreateStartRunConfig, Threa
|
|
|
42
44
|
import { AssistantRuntime } from "./runtime/api/assistant-runtime.js";
|
|
43
45
|
import { InMemoryThreadListAdapter } from "./runtimes/remote-thread-list/adapter/in-memory.js";
|
|
44
46
|
import { createRequestHeaders } from "./runtimes/assistant-transport/utils.js";
|
|
45
|
-
export { type AddToolResultOptions, type AppendMessage, type AssistantContextConfig, AssistantFrameHost, AssistantFrameProvider, type AssistantInstructionsConfig, type AssistantRuntime, type AssistantRuntimeCore, type AssistantToolProps, type Attachment, type AttachmentAdapter, type AttachmentAddErrorEvent, type AttachmentAddErrorReason, type AttachmentRuntime, type AttachmentRuntimePath, type AttachmentState, type AttachmentStatus, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, type CompleteAttachment, type CompleteAttachmentStatus, type ComposerRuntime, type ComposerRuntimeCore, type ComposerRuntimeEventCallback, type ComposerRuntimeEventPayload, type ComposerRuntimeEventType, type ComposerRuntimePath, type ComposerState, CompositeAttachmentAdapter, type CoreChatModelRunResult, type CreateAppendMessage, type CreateAttachment, type CreateResumeRunConfig, type CreateStartRunConfig, type DataMessagePart, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerRuntimeCore, type EditComposerState, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreMessageConverter, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, FRAME_MESSAGE_CHANNEL, type FeedbackAdapter, type FileMessagePart, type FrameMessage, type FrameMessageType, type GenerativeUIMessagePart, type GenerativeUINode, type GenerativeUISpec, type GenericThreadHistoryAdapter, type ImageMessagePart, InMemoryThreadListAdapter, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptionsBase, MCP_APP_URI_SCHEME, type McpAppMetadata, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, type MessagePartRuntime, type MessagePartRuntimePath, type MessagePartState, type MessagePartStatus, type MessageRole, type MessageRuntime, type MessageRuntimePath, type MessageState, type MessageStatus, type MessageStorageEntry, type MessageTiming, type ModelContext, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, type PendingAttachment, type PendingAttachmentStatus, type QuoteInfo, type RealtimeVoiceAdapter, type ReasoningMessagePart, type RemoteThreadInitializeResponse, type RemoteThreadListAdapter, type RemoteThreadListOptions, type RemoteThreadListPageOptions, type RemoteThreadListResponse, type RemoteThreadMetadata, type ResumeRunConfig, type ResumeToolCallOptions, type RunConfig, type RuntimeCapabilities, type SendOptions, type SerializedModelContext, type SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, type SourceMessagePart, type SourceProviderMetadata, type SpeechState, type SpeechSynthesisAdapter, type StartRunConfig, type SubmitFeedbackOptions, type SubmittedFeedback, type SuggestionAdapter, type TextMessagePart, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadComposerRuntimeCore, type ThreadComposerState, type ThreadHistoryAdapter, type ThreadListItemCoreState, type ThreadListItemEventCallback, type ThreadListItemEventPayload, type ThreadListItemEventType, type ThreadListItemRuntime, type ThreadListItemRuntimePath, type ThreadListItemState, type ThreadListItemStatus, type ThreadListRuntime, type ThreadListRuntimeCore, type ThreadListState, type ThreadMessage, type ThreadMessageLike, type ThreadRuntime, type ThreadRuntimeCore, type ThreadRuntimeEventCallback, type ThreadRuntimeEventPayload, type ThreadRuntimeEventType, type ThreadRuntimePath, type ThreadState, type ThreadStep, type ThreadSuggestion, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ToolCallMessagePart, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartStatus, type ToolModelContentPart, type Unstable_AudioMessagePart, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_TriggerAdapter, type Unstable_TriggerCategory, type Unstable_TriggerItem, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createRequestHeaders, createVoiceSession, getExternalStoreMessages, isMcpAppUri, mergeModelContexts, tool, unstable_defaultDirectiveFormatter };
|
|
47
|
+
export { type AddToolResultOptions, type AppendMessage, type AssistantContextConfig, AssistantFrameHost, AssistantFrameProvider, type AssistantInstructionsConfig, type AssistantRuntime, type AssistantRuntimeCore, type AssistantToolProps, type Attachment, type AttachmentAdapter, type AttachmentAddErrorEvent, type AttachmentAddErrorReason, type AttachmentRuntime, type AttachmentRuntimePath, type AttachmentState, type AttachmentStatus, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, type CompleteAttachment, type CompleteAttachmentStatus, type ComposerRuntime, type ComposerRuntimeCore, type ComposerRuntimeEventCallback, type ComposerRuntimeEventPayload, type ComposerRuntimeEventType, type ComposerRuntimePath, type ComposerState, CompositeAttachmentAdapter, type CoreChatModelRunResult, type CreateAppendMessage, type CreateAttachment, type CreateResumeRunConfig, type CreateStartRunConfig, type DataMessagePart, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerRuntimeCore, type EditComposerState, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreMessageConverter, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, FRAME_MESSAGE_CHANNEL, type FeedbackAdapter, type FileMessagePart, type FrameMessage, type FrameMessageType, type GenerativeUIMessagePart, type GenerativeUINode, type GenerativeUISpec, type GenericThreadHistoryAdapter, type ImageMessagePart, InMemoryThreadListAdapter, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptionsBase, MCP_APP_URI_SCHEME, type McpAppMetadata, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, type MessagePartRuntime, type MessagePartRuntimePath, type MessagePartState, type MessagePartStatus, type MessageRole, type MessageRuntime, type MessageRuntimePath, type MessageState, type MessageStatus, type MessageStorageEntry, type MessageTiming, type ModelContext, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, type PendingAttachment, type PendingAttachmentStatus, type QuoteInfo, type RealtimeVoiceAdapter, type ReasoningMessagePart, type RemoteThreadInitializeResponse, type RemoteThreadListAdapter, type RemoteThreadListOptions, type RemoteThreadListPageOptions, type RemoteThreadListResponse, type RemoteThreadMetadata, type RespondToToolApprovalOptions, type ResumeRunConfig, type ResumeToolCallOptions, type RunConfig, type RuntimeCapabilities, type SendOptions, type SerializedModelContext, type SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, type SourceMessagePart, type SourceProviderMetadata, type SpeechState, type SpeechSynthesisAdapter, type StartRunConfig, type SubmitFeedbackOptions, type SubmittedFeedback, type SuggestionAdapter, type TextMessagePart, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadComposerRuntimeCore, type ThreadComposerState, type ThreadHistoryAdapter, type ThreadListItemCoreState, type ThreadListItemEventCallback, type ThreadListItemEventPayload, type ThreadListItemEventType, type ThreadListItemRuntime, type ThreadListItemRuntimePath, type ThreadListItemState, type ThreadListItemStatus, type ThreadListRuntime, type ThreadListRuntimeCore, type ThreadListState, type ThreadMessage, type ThreadMessageLike, type ThreadRuntime, type ThreadRuntimeCore, type ThreadRuntimeEventCallback, type ThreadRuntimeEventPayload, type ThreadRuntimeEventType, type ThreadRuntimePath, type ThreadState, type ThreadStep, type ThreadSuggestion, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ToolCallMessagePart, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartStatus, type ToolExecutionStatus, type ToolModelContentPart, type Unstable_AudioMessagePart, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_TriggerAdapter, type Unstable_TriggerCategory, type Unstable_TriggerItem, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createRequestHeaders, createVoiceSession, getExternalStoreMessages, isMcpAppUri, mergeModelContexts, tool, unstable_defaultDirectiveFormatter };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { checkDuplicateCore } from "./internal/duplicate-detection.js";
|
|
1
2
|
import { MCP_APP_URI_SCHEME, isMcpAppUri } from "./types/message.js";
|
|
2
3
|
import { mergeModelContexts } from "./model-context/types.js";
|
|
3
4
|
import { tool } from "./model-context/tool.js";
|
|
@@ -13,4 +14,9 @@ import { bindExternalStoreMessage, getExternalStoreMessages } from "./runtime/ut
|
|
|
13
14
|
import { ExportedMessageRepository } from "./runtime/utils/message-repository.js";
|
|
14
15
|
import { InMemoryThreadListAdapter } from "./runtimes/remote-thread-list/adapter/in-memory.js";
|
|
15
16
|
import { createRequestHeaders } from "./runtimes/assistant-transport/utils.js";
|
|
17
|
+
//#region src/index.ts
|
|
18
|
+
if (process.env.NODE_ENV !== "production") checkDuplicateCore();
|
|
19
|
+
//#endregion
|
|
16
20
|
export { AssistantFrameHost, AssistantFrameProvider, CompositeAttachmentAdapter, ExportedMessageRepository, FRAME_MESSAGE_CHANNEL, InMemoryThreadListAdapter, MCP_APP_URI_SCHEME, ModelContextRegistry, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createRequestHeaders, createVoiceSession, getExternalStoreMessages, isMcpAppUri, mergeModelContexts, tool, unstable_defaultDirectiveFormatter };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// @assistant-ui/core - Framework-agnostic core runtime (public API)\n\n/// <reference path=\"./store/scope-registration.ts\" />\n\nimport { checkDuplicateCore } from \"./internal/duplicate-detection\";\n\nif (process.env.NODE_ENV !== \"production\") {\n checkDuplicateCore();\n}\n\nexport type {\n // Message parts\n TextMessagePart,\n ReasoningMessagePart,\n SourceProviderMetadata,\n SourceMessagePart,\n ImageMessagePart,\n FileMessagePart,\n DataMessagePart,\n GenerativeUIMessagePart,\n GenerativeUINode,\n GenerativeUISpec,\n Unstable_AudioMessagePart,\n ToolCallMessagePart,\n ToolCallMessagePartMcpMetadata,\n McpAppMetadata,\n ToolModelContentPart,\n ThreadUserMessagePart,\n ThreadAssistantMessagePart,\n // Message status\n MessagePartStatus,\n ToolCallMessagePartStatus,\n MessageStatus,\n // Thread messages\n MessageTiming,\n ThreadStep,\n ThreadSystemMessage,\n ThreadUserMessage,\n ThreadAssistantMessage,\n ThreadMessage,\n MessageRole,\n // Config\n RunConfig,\n AppendMessage,\n} from \"./types/message\";\n\nexport { MCP_APP_URI_SCHEME, isMcpAppUri } from \"./types/message\";\n\nexport type {\n Attachment,\n PendingAttachment,\n PendingAttachmentStatus,\n CompleteAttachment,\n CompleteAttachmentStatus,\n AttachmentStatus,\n CreateAttachment,\n} from \"./types/attachment\";\n\nexport type { Unsubscribe } from \"./types/unsubscribe\";\n\nexport type { QuoteInfo } from \"./types/quote\";\n\nexport type {\n Unstable_DirectiveSegment,\n Unstable_DirectiveFormatter,\n} from \"./types/directive\";\n\nexport type {\n Unstable_TriggerItem,\n Unstable_TriggerCategory,\n} from \"./types/trigger\";\n\nexport type { Unstable_TriggerAdapter } from \"./adapters/trigger\";\n\nexport type {\n // Language model settings\n LanguageModelV1CallSettings,\n LanguageModelConfig,\n // Model context\n ModelContext,\n ModelContextProvider,\n // Tool & instruction config\n AssistantToolProps,\n AssistantInstructionsConfig,\n AssistantContextConfig,\n} from \"./model-context/types\";\nexport { mergeModelContexts } from \"./model-context/types\";\n\nexport { tool } from \"./model-context/tool\";\n\nexport type { ToolExecutionStatus } from \"./runtimes/tool-invocations/ToolInvocationTracker\";\n\nexport { ModelContextRegistry } from \"./model-context/registry\";\nexport type {\n ModelContextRegistryToolHandle,\n ModelContextRegistryInstructionHandle,\n ModelContextRegistryProviderHandle,\n} from \"./model-context/registry-handles\";\n\nexport { AssistantFrameHost } from \"./model-context/frame/host\";\nexport { AssistantFrameProvider } from \"./model-context/frame/provider\";\nexport type {\n SerializedTool,\n SerializedModelContext,\n FrameMessageType,\n FrameMessage,\n} from \"./model-context/frame/types\";\nexport { FRAME_MESSAGE_CHANNEL } from \"./model-context/frame/types\";\n\n// Attachment adapters\nexport type { AttachmentAdapter } from \"./adapters/attachment\";\nexport {\n SimpleImageAttachmentAdapter,\n SimpleTextAttachmentAdapter,\n CompositeAttachmentAdapter,\n} from \"./adapters/attachment\";\n\n// Speech adapters\nexport type {\n SpeechSynthesisAdapter,\n DictationAdapter,\n} from \"./adapters/speech\";\nexport {\n WebSpeechSynthesisAdapter,\n WebSpeechDictationAdapter,\n} from \"./adapters/speech\";\n\n// Voice adapter\nexport type { RealtimeVoiceAdapter } from \"./adapters/voice\";\nexport { createVoiceSession } from \"./adapters/voice\";\nexport type {\n VoiceSessionControls,\n VoiceSessionHelpers,\n} from \"./adapters/voice\";\n\n// Feedback adapter\nexport type { FeedbackAdapter } from \"./adapters/feedback\";\n\n// Suggestion adapter\nexport type { SuggestionAdapter } from \"./adapters/suggestion\";\n\n// Directive formatter\nexport { unstable_defaultDirectiveFormatter } from \"./adapters/directive-formatter\";\n\n// Thread history adapters\nexport type {\n ThreadHistoryAdapter,\n GenericThreadHistoryAdapter,\n MessageFormatAdapter,\n MessageFormatItem,\n MessageFormatRepository,\n MessageStorageEntry,\n} from \"./adapters/thread-history\";\n\n// Path Types\nexport type {\n ThreadListItemRuntimePath,\n ThreadRuntimePath,\n MessageRuntimePath,\n MessagePartRuntimePath,\n AttachmentRuntimePath,\n ComposerRuntimePath,\n} from \"./runtime/api/paths\";\n\n// Runtime Core Interface Types\nexport type {\n AttachmentAddErrorEvent,\n AttachmentAddErrorReason,\n ComposerRuntimeCore,\n ComposerRuntimeEventCallback,\n ComposerRuntimeEventPayload,\n ComposerRuntimeEventType,\n DictationState,\n EditComposerRuntimeCore,\n SendOptions,\n ThreadComposerRuntimeCore,\n} from \"./runtime/interfaces/composer-runtime-core\";\n\nexport type {\n RuntimeCapabilities,\n AddToolResultOptions,\n ResumeToolCallOptions,\n RespondToToolApprovalOptions,\n SubmitFeedbackOptions,\n ThreadSuggestion,\n SpeechState,\n VoiceSessionState,\n SubmittedFeedback,\n ThreadRuntimeEventCallback,\n ThreadRuntimeEventPayload,\n ThreadRuntimeEventType,\n StartRunConfig,\n ResumeRunConfig,\n ThreadRuntimeCore,\n} from \"./runtime/interfaces/thread-runtime-core\";\n\nexport type {\n ThreadListItemStatus,\n ThreadListItemCoreState,\n ThreadListRuntimeCore,\n} from \"./runtime/interfaces/thread-list-runtime-core\";\n\nexport type { AssistantRuntimeCore } from \"./runtime/interfaces/assistant-runtime-core\";\n\n// Public Runtime Types\nexport type { AssistantRuntime } from \"./runtime/api/assistant-runtime\";\n\nexport type {\n CreateStartRunConfig,\n CreateResumeRunConfig,\n CreateAppendMessage,\n ThreadState,\n ThreadRuntime,\n} from \"./runtime/api/thread-runtime\";\n\nexport type {\n ThreadListState,\n ThreadListRuntime,\n} from \"./runtime/api/thread-list-runtime\";\n\nexport type {\n ThreadListItemEventCallback,\n ThreadListItemEventPayload,\n ThreadListItemEventType,\n ThreadListItemRuntime,\n} from \"./runtime/api/thread-list-item-runtime\";\n\nexport type { ThreadListItemState } from \"./runtime/api/bindings\";\n\nexport type {\n MessageState,\n MessageRuntime,\n} from \"./runtime/api/message-runtime\";\nexport type {\n MessagePartState,\n MessagePartRuntime,\n} from \"./runtime/api/message-part-runtime\";\n\nexport type {\n ThreadComposerState,\n EditComposerState,\n ComposerState,\n ComposerRuntime,\n ThreadComposerRuntime,\n EditComposerRuntime,\n} from \"./runtime/api/composer-runtime\";\n\nexport type {\n AttachmentState,\n AttachmentRuntime,\n} from \"./runtime/api/attachment-runtime\";\n\n// ChatModel Types\nexport type {\n ChatModelRunUpdate,\n ChatModelRunResult,\n CoreChatModelRunResult,\n ChatModelRunOptions,\n ChatModelAdapter,\n} from \"./runtime/utils/chat-model-adapter\";\n\n// ThreadMessageLike\nexport type { ThreadMessageLike } from \"./runtime/utils/thread-message-like\";\n\n// External Store Message Utilities\nexport {\n getExternalStoreMessages,\n bindExternalStoreMessage,\n} from \"./runtime/utils/external-store-message\";\n\n// ExportedMessageRepository\nexport type { ExportedMessageRepositoryItem } from \"./runtime/utils/message-repository\";\nexport { ExportedMessageRepository } from \"./runtime/utils/message-repository\";\n\n// Local Runtime Options\nexport type { LocalRuntimeOptionsBase } from \"./runtimes/local/local-runtime-options\";\n\n// External Store Adapter Types (user-facing)\nexport type {\n ExternalStoreAdapter,\n ExternalStoreMessageConverter,\n ExternalStoreThreadListAdapter,\n ExternalStoreThreadData,\n} from \"./runtimes/external-store/external-store-adapter\";\n\n// Remote Thread List (user-facing)\nexport type {\n RemoteThreadListAdapter,\n RemoteThreadListOptions,\n RemoteThreadInitializeResponse,\n RemoteThreadMetadata,\n RemoteThreadListResponse,\n RemoteThreadListPageOptions,\n} from \"./runtimes/remote-thread-list/types\";\n\nexport { InMemoryThreadListAdapter } from \"./runtimes/remote-thread-list/adapter/in-memory\";\n\n// Assistant Transport Utilities\nexport { createRequestHeaders } from \"./runtimes/assistant-transport/utils\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAMA,IAAI,QAAQ,IAAI,aAAa,cAC3B,mBAAmB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duplicate-detection.d.ts","names":[],"sources":["../../src/internal/duplicate-detection.ts"],"mappings":";iBAYgB,kBAAA,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/internal/duplicate-detection.ts
|
|
2
|
+
const KEY = Symbol.for("@assistant-ui/core.loaded");
|
|
3
|
+
function checkDuplicateCore() {
|
|
4
|
+
const g = globalThis;
|
|
5
|
+
if (g[KEY]) console.warn("[@assistant-ui/core] Multiple copies of @assistant-ui/core are loaded into the same runtime. This causes subtle bugs (tools not reaching the runtime, context lookups returning the wrong provider, instanceof checks failing). Run `npx assistant-ui doctor` to diagnose.");
|
|
6
|
+
g[KEY] = true;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { checkDuplicateCore };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=duplicate-detection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duplicate-detection.js","names":[],"sources":["../../src/internal/duplicate-detection.ts"],"sourcesContent":["// Warns once if a second copy of @assistant-ui/core is loaded into the\n// same runtime. Mismatched transitive versions of core silently break\n// runtime behavior — tools registered via `makeAssistantTool` don't reach\n// the active runtime, context lookups resolve to the wrong provider,\n// `instanceof` checks fail (see issue #4101). The actual version diagnosis\n// lives in `npx assistant-ui doctor`.\n//\n// The caller is responsible for gating on `process.env.NODE_ENV` so this\n// module tree-shakes out of production bundles.\n\nconst KEY = Symbol.for(\"@assistant-ui/core.loaded\");\n\nexport function checkDuplicateCore(): void {\n const g = globalThis as unknown as Record<symbol, boolean | undefined>;\n if (g[KEY]) {\n // eslint-disable-next-line no-console\n console.warn(\n \"[@assistant-ui/core] Multiple copies of @assistant-ui/core are \" +\n \"loaded into the same runtime. This causes subtle bugs (tools not \" +\n \"reaching the runtime, context lookups returning the wrong \" +\n \"provider, instanceof checks failing). Run \" +\n \"`npx assistant-ui doctor` to diagnose.\",\n );\n }\n g[KEY] = true;\n}\n"],"mappings":";AAUA,MAAM,MAAM,OAAO,IAAI,2BAA2B;AAElD,SAAgB,qBAA2B;CACzC,MAAM,IAAI;CACV,IAAI,EAAE,MAEJ,QAAQ,KACN,4QAKF;CAEF,EAAE,OAAO;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantProvider.d.ts","names":[],"sources":["../../src/react/AssistantProvider.tsx"],"mappings":";;;;;cAWa,kBAAA,GAAsB,OAAA,EAAS,gBAAA,
|
|
1
|
+
{"version":3,"file":"AssistantProvider.d.ts","names":[],"sources":["../../src/react/AssistantProvider.tsx"],"mappings":";;;;;cAWa,kBAAA,GAAsB,OAAA,EAAS,gBAAA,KAEnB,aAAa;AAAA,KAG1B,0BAAA,GAA6B,iBAAA;EACvC,OAAA,EAAS,gBAAA;EACT,GAAA,GAAM,eAAA;AAAA;AAAA,cAGK,qBAAA,EAAuB,EAAE,CAAC,0BAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantProvider.js","names":[],"sources":["../../src/react/AssistantProvider.tsx"],"sourcesContent":["import {\n memo,\n type ComponentType,\n type FC,\n type PropsWithChildren,\n} from \"react\";\nimport { useAui, AuiProvider, type AssistantClient } from \"@assistant-ui/store\";\nimport type { AssistantRuntime } from \"../runtime/api/assistant-runtime\";\nimport type { AssistantRuntimeCore } from \"../runtime/interfaces/assistant-runtime-core\";\nimport { RuntimeAdapter } from \"./RuntimeAdapter\";\n\nexport const getRenderComponent = (runtime: AssistantRuntime) => {\n return (runtime as { _core?: AssistantRuntimeCore })._core?.RenderComponent as
|
|
1
|
+
{"version":3,"file":"AssistantProvider.js","names":[],"sources":["../../src/react/AssistantProvider.tsx"],"sourcesContent":["import {\n memo,\n type ComponentType,\n type FC,\n type PropsWithChildren,\n} from \"react\";\nimport { useAui, AuiProvider, type AssistantClient } from \"@assistant-ui/store\";\nimport type { AssistantRuntime } from \"../runtime/api/assistant-runtime\";\nimport type { AssistantRuntimeCore } from \"../runtime/interfaces/assistant-runtime-core\";\nimport { RuntimeAdapter } from \"./RuntimeAdapter\";\n\nexport const getRenderComponent = (runtime: AssistantRuntime) => {\n return (runtime as { _core?: AssistantRuntimeCore })._core\n ?.RenderComponent as ComponentType | undefined;\n};\n\nexport type AssistantProviderBaseProps = PropsWithChildren<{\n runtime: AssistantRuntime;\n aui?: AssistantClient | null;\n}>;\n\nexport const AssistantProviderBase: FC<AssistantProviderBaseProps> = memo(\n ({ runtime, aui: parent = null, children }) => {\n const aui = useAui({ threads: RuntimeAdapter(runtime) }, { parent });\n const RenderComponent = getRenderComponent(runtime);\n return (\n <AuiProvider value={aui}>\n {RenderComponent && <RenderComponent />}\n {children}\n </AuiProvider>\n );\n },\n);\n"],"mappings":";;;;;AAWA,MAAa,sBAAsB,YAA8B;CAC/D,OAAQ,QAA6C,OACjD;AACN;AAOA,MAAa,wBAAwD,MAClE,EAAE,SAAS,KAAK,SAAS,MAAM,eAAe;CAC7C,MAAM,MAAM,OAAO,EAAE,SAAS,eAAe,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC;CACnE,MAAM,kBAAkB,mBAAmB,OAAO;CAClD,OACE,qBAAC,aAAD;EAAa,OAAO;YAApB,CACG,mBAAmB,oBAAC,iBAAD,CAAkB,CAAA,GACrC,QACU;;AAEjB,CACF"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference path="../store/scope-registration.d.ts" />
|
|
1
2
|
/// <reference path="./types/store-augmentation.d.ts" />
|
|
2
3
|
import { AssistantContextConfig } from "../model-context/types.js";
|
|
3
4
|
import { AssistantProviderBase, AssistantProviderBaseProps, getRenderComponent } from "./AssistantProvider.js";
|
|
@@ -37,7 +38,6 @@ import { SuggestionByIndexProvider, SuggestionByIndexProviderProps } from "./pro
|
|
|
37
38
|
import { QueueItemByIndexProvider, QueueItemByIndexProviderProps } from "./providers/QueueItemByIndexProvider.js";
|
|
38
39
|
import { ReadonlyThreadProvider } from "./providers/ReadonlyThreadProvider.js";
|
|
39
40
|
import { RuntimeAdapterProvider, RuntimeAdapters, useRuntimeAdapters } from "./runtimes/RuntimeAdapterProvider.js";
|
|
40
|
-
import { AddToolResultCommand, AssistantTransportState, ToolExecutionStatus, useToolInvocations } from "./runtimes/useToolInvocations.js";
|
|
41
41
|
import { useExternalStoreRuntime } from "./runtimes/useExternalStoreRuntime.js";
|
|
42
42
|
import { convertExternalMessages, useExternalMessageConverter } from "./runtimes/external-message-converter.js";
|
|
43
43
|
import { createMessageConverter } from "./runtimes/createMessageConverter.js";
|
|
@@ -51,6 +51,7 @@ import { PartState } from "../store/scopes/part.js";
|
|
|
51
51
|
import { ThreadPrimitiveMessageByIndex, ThreadPrimitiveMessages, ThreadPrimitiveMessagesImpl } from "./primitives/thread/ThreadMessages.js";
|
|
52
52
|
import { EnrichedPartState, MessagePartComponent, MessagePrimitivePartByIndex, MessagePrimitiveParts, defaultComponents } from "./primitives/message/MessageParts.js";
|
|
53
53
|
import { MessagePrimitiveGroupedParts } from "./primitives/message/MessageGroupedParts.js";
|
|
54
|
+
import { groupPartByType } from "./utils/groupParts.js";
|
|
54
55
|
import { GenerativeUIRender, GenerativeUIRenderError, MessagePrimitiveGenerativeUI } from "./primitives/generativeUI/GenerativeUI.js";
|
|
55
56
|
import { MessagePrimitiveQuote } from "./primitives/message/MessageQuote.js";
|
|
56
57
|
import { MessagePrimitiveAttachmentByIndex, MessagePrimitiveAttachments } from "./primitives/message/MessageAttachments.js";
|
|
@@ -93,4 +94,4 @@ import { useEditComposerCancel } from "./primitive-hooks/useEditComposerCancel.j
|
|
|
93
94
|
import { useEditComposerSend } from "./primitive-hooks/useEditComposerSend.js";
|
|
94
95
|
import { useMessageError } from "./primitive-hooks/useMessageError.js";
|
|
95
96
|
import { LocalRuntimeOptions, splitLocalRuntimeOptions, useLocalRuntime } from "./runtimes/useLocalRuntime.js";
|
|
96
|
-
export { type
|
|
97
|
+
export { type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantInteractableProps, AssistantProviderBase, type AssistantProviderBaseProps, AssistantRuntimeProvider, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AsyncStorageLike, ChainOfThoughtByIndicesProvider, ChainOfThoughtPartByIndexProvider, ChainOfThoughtPrimitiveParts, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, ComposerPrimitiveAttachmentByIndex, ComposerPrimitiveAttachments, ComposerPrimitiveIf, ComposerPrimitiveQueue, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, type DataRenderersClientSchema, type DataRenderersMethods, type DataRenderersState, type EmptyMessagePartComponent, type EmptyMessagePartProps, type EnrichedPartState, type FileMessagePartComponent, type FileMessagePartProps, type GenerativeUIComponentRegistry, type GenerativeUIMessagePartComponent, type GenerativeUIMessagePartProps, GenerativeUIRender, GenerativeUIRenderError, type GenerativeUIRenderProps, type ImageMessagePartComponent, type ImageMessagePartProps, type InteractableDefinition, type InteractablePersistedState, type InteractablePersistenceAdapter, type InteractablePersistenceStatus, type InteractableRegistration, type InteractableStateSchema, Interactables, type InteractablesClientSchema, type InteractablesMethods, type InteractablesState, type LocalRuntimeOptions, type McpAppResourceOutput, MessageAttachmentByIndexProvider, MessageByIndexProvider, MessagePartComponent, MessagePartPrimitiveInProgress, MessagePrimitiveAttachmentByIndex, MessagePrimitiveAttachments, MessagePrimitiveGenerativeUI, MessagePrimitiveGroupedParts, MessagePrimitivePartByIndex, MessagePrimitiveParts, MessagePrimitiveQuote, PartByIndexProvider, PartPrimitiveMessages, PartPrimitiveMessagesImpl, type PartState, QueueItemByIndexProvider, type QueueItemByIndexProviderProps, type QuoteMessagePartComponent, type QuoteMessagePartProps, ReadonlyThreadProvider, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, RemoteThreadListHookInstanceManager, RemoteThreadListThreadListRuntimeCore, RuntimeAdapter, RuntimeAdapterProvider, type RuntimeAdapters, type SourceMessagePartComponent, type SourceMessagePartProps, SuggestionByIndexProvider, type SuggestionByIndexProviderProps, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, ThreadListItemByIndexProvider, ThreadListItemPrimitiveTitle, ThreadListItemRuntimeProvider, ThreadListPrimitiveItemByIndex, ThreadListPrimitiveItems, ThreadPrimitiveMessageByIndex, ThreadPrimitiveMessages, ThreadPrimitiveMessagesImpl, ThreadPrimitiveSuggestionByIndex, ThreadPrimitiveSuggestions, ThreadPrimitiveSuggestionsImpl, type TitleGenerationAdapter, type ToolArgsStatus, type ToolCallMessagePartComponent, type ToolCallMessagePartProps, type ToolDefinition, type Toolkit, Tools, type ToolsClientSchema, type ToolsMethods, type ToolsState, type Unstable_AudioMessagePartComponent, type Unstable_AudioMessagePartProps, type UseActionBarCopyOptions, type UseComposerIfProps, type UseSuggestionTriggerOptions, convertExternalMessages, createLocalStorageAdapter, createMessageConverter, createSimpleTitleAdapter, getMessageQuote, getRenderComponent, groupPartByType, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, defaultComponents as messagePartsDefaultComponents, splitLocalRuntimeOptions, useActionBarCopy, useActionBarEdit, useActionBarFeedbackNegative, useActionBarFeedbackPositive, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAssistantCloudThreadHistoryAdapter, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useBranchPickerNext, useBranchPickerPrevious, useCloudThreadListAdapter, useComposerAddAttachment, useComposerCancel, useComposerDictate, useComposerSend, useEditComposerCancel, useEditComposerSend, useExternalMessageConverter, useExternalStoreRuntime, useInlineRender, useInteractableState, useLocalRuntime, useMessageBranching, useMessageError, useMessageReload, useRemoteThreadListRuntime, useRuntimeAdapters, useSuggestionTrigger, useThreadIsEmpty, useThreadIsRunning, useThreadListItemArchive, useThreadListItemDelete, useThreadListItemTrigger, useThreadListItemUnarchive, useThreadListLoadMore, useThreadListNew, useThreadMessages, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
|
package/dist/react/index.js
CHANGED
|
@@ -28,7 +28,6 @@ import { SuggestionByIndexProvider } from "./providers/SuggestionByIndexProvider
|
|
|
28
28
|
import { QueueItemByIndexProvider } from "./providers/QueueItemByIndexProvider.js";
|
|
29
29
|
import { ReadonlyThreadProvider } from "./providers/ReadonlyThreadProvider.js";
|
|
30
30
|
import { RuntimeAdapterProvider, useRuntimeAdapters } from "./runtimes/RuntimeAdapterProvider.js";
|
|
31
|
-
import { useToolInvocations } from "./runtimes/useToolInvocations.js";
|
|
32
31
|
import { useExternalStoreRuntime } from "./runtimes/useExternalStoreRuntime.js";
|
|
33
32
|
import { convertExternalMessages, useExternalMessageConverter } from "./runtimes/external-message-converter.js";
|
|
34
33
|
import { createMessageConverter } from "./runtimes/createMessageConverter.js";
|
|
@@ -44,6 +43,7 @@ import { ThreadPrimitiveMessageByIndex, ThreadPrimitiveMessages, ThreadPrimitive
|
|
|
44
43
|
import { getMessageQuote } from "./utils/getMessageQuote.js";
|
|
45
44
|
import { GenerativeUIRender, GenerativeUIRenderError, MessagePrimitiveGenerativeUI } from "./primitives/generativeUI/GenerativeUI.js";
|
|
46
45
|
import { MessagePartComponent, MessagePrimitivePartByIndex, MessagePrimitiveParts, defaultComponents } from "./primitives/message/MessageParts.js";
|
|
46
|
+
import { groupPartByType } from "./utils/groupParts.js";
|
|
47
47
|
import { MessagePrimitiveGroupedParts } from "./primitives/message/MessageGroupedParts.js";
|
|
48
48
|
import { MessagePrimitiveQuote } from "./primitives/message/MessageQuote.js";
|
|
49
49
|
import { MessagePrimitiveAttachmentByIndex, MessagePrimitiveAttachments } from "./primitives/message/MessageAttachments.js";
|
|
@@ -85,4 +85,4 @@ import { useEditComposerCancel } from "./primitive-hooks/useEditComposerCancel.j
|
|
|
85
85
|
import { useEditComposerSend } from "./primitive-hooks/useEditComposerSend.js";
|
|
86
86
|
import { useMessageError } from "./primitive-hooks/useMessageError.js";
|
|
87
87
|
import { splitLocalRuntimeOptions, useLocalRuntime } from "./runtimes/useLocalRuntime.js";
|
|
88
|
-
export { AssistantProviderBase, AssistantRuntimeProvider, ChainOfThoughtByIndicesProvider, ChainOfThoughtPartByIndexProvider, ChainOfThoughtPrimitiveParts, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, ComposerPrimitiveAttachmentByIndex, ComposerPrimitiveAttachments, ComposerPrimitiveIf, ComposerPrimitiveQueue, DataRenderers, GenerativeUIRender, GenerativeUIRenderError, Interactables, MessageAttachmentByIndexProvider, MessageByIndexProvider, MessagePartComponent, MessagePartPrimitiveInProgress, MessagePrimitiveAttachmentByIndex, MessagePrimitiveAttachments, MessagePrimitiveGenerativeUI, MessagePrimitiveGroupedParts, MessagePrimitivePartByIndex, MessagePrimitiveParts, MessagePrimitiveQuote, PartByIndexProvider, PartPrimitiveMessages, PartPrimitiveMessagesImpl, QueueItemByIndexProvider, ReadonlyThreadProvider, RemoteThreadListHookInstanceManager, RemoteThreadListThreadListRuntimeCore, RuntimeAdapter, RuntimeAdapterProvider, SuggestionByIndexProvider, TextMessagePartProvider, ThreadListItemByIndexProvider, ThreadListItemPrimitiveTitle, ThreadListItemRuntimeProvider, ThreadListPrimitiveItemByIndex, ThreadListPrimitiveItems, ThreadPrimitiveMessageByIndex, ThreadPrimitiveMessages, ThreadPrimitiveMessagesImpl, ThreadPrimitiveSuggestionByIndex, ThreadPrimitiveSuggestions, ThreadPrimitiveSuggestionsImpl, Tools, convertExternalMessages, createLocalStorageAdapter, createMessageConverter, createSimpleTitleAdapter, getMessageQuote, getRenderComponent, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, defaultComponents as messagePartsDefaultComponents, splitLocalRuntimeOptions, useActionBarCopy, useActionBarEdit, useActionBarFeedbackNegative, useActionBarFeedbackPositive, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAssistantCloudThreadHistoryAdapter, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useBranchPickerNext, useBranchPickerPrevious, useCloudThreadListAdapter, useComposerAddAttachment, useComposerCancel, useComposerDictate, useComposerSend, useEditComposerCancel, useEditComposerSend, useExternalMessageConverter, useExternalStoreRuntime, useInlineRender, useInteractableState, useLocalRuntime, useMessageBranching, useMessageError, useMessageReload, useRemoteThreadListRuntime, useRuntimeAdapters, useSuggestionTrigger, useThreadIsEmpty, useThreadIsRunning, useThreadListItemArchive, useThreadListItemDelete, useThreadListItemTrigger, useThreadListItemUnarchive, useThreadListLoadMore, useThreadListNew, useThreadMessages, useToolArgsStatus,
|
|
88
|
+
export { AssistantProviderBase, AssistantRuntimeProvider, ChainOfThoughtByIndicesProvider, ChainOfThoughtPartByIndexProvider, ChainOfThoughtPrimitiveParts, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, ComposerPrimitiveAttachmentByIndex, ComposerPrimitiveAttachments, ComposerPrimitiveIf, ComposerPrimitiveQueue, DataRenderers, GenerativeUIRender, GenerativeUIRenderError, Interactables, MessageAttachmentByIndexProvider, MessageByIndexProvider, MessagePartComponent, MessagePartPrimitiveInProgress, MessagePrimitiveAttachmentByIndex, MessagePrimitiveAttachments, MessagePrimitiveGenerativeUI, MessagePrimitiveGroupedParts, MessagePrimitivePartByIndex, MessagePrimitiveParts, MessagePrimitiveQuote, PartByIndexProvider, PartPrimitiveMessages, PartPrimitiveMessagesImpl, QueueItemByIndexProvider, ReadonlyThreadProvider, RemoteThreadListHookInstanceManager, RemoteThreadListThreadListRuntimeCore, RuntimeAdapter, RuntimeAdapterProvider, SuggestionByIndexProvider, TextMessagePartProvider, ThreadListItemByIndexProvider, ThreadListItemPrimitiveTitle, ThreadListItemRuntimeProvider, ThreadListPrimitiveItemByIndex, ThreadListPrimitiveItems, ThreadPrimitiveMessageByIndex, ThreadPrimitiveMessages, ThreadPrimitiveMessagesImpl, ThreadPrimitiveSuggestionByIndex, ThreadPrimitiveSuggestions, ThreadPrimitiveSuggestionsImpl, Tools, convertExternalMessages, createLocalStorageAdapter, createMessageConverter, createSimpleTitleAdapter, getMessageQuote, getRenderComponent, groupPartByType, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, defaultComponents as messagePartsDefaultComponents, splitLocalRuntimeOptions, useActionBarCopy, useActionBarEdit, useActionBarFeedbackNegative, useActionBarFeedbackPositive, useActionBarReload, useActionBarSpeak, useActionBarStopSpeaking, useAssistantCloudThreadHistoryAdapter, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useBranchPickerNext, useBranchPickerPrevious, useCloudThreadListAdapter, useComposerAddAttachment, useComposerCancel, useComposerDictate, useComposerSend, useEditComposerCancel, useEditComposerSend, useExternalMessageConverter, useExternalStoreRuntime, useInlineRender, useInteractableState, useLocalRuntime, useMessageBranching, useMessageError, useMessageReload, useRemoteThreadListRuntime, useRuntimeAdapters, useSuggestionTrigger, useThreadIsEmpty, useThreadIsRunning, useThreadListItemArchive, useThreadListItemDelete, useThreadListItemTrigger, useThreadListItemUnarchive, useThreadListLoadMore, useThreadListNew, useThreadMessages, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChainOfThoughtParts.js","names":[],"sources":["../../../../src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx"],"sourcesContent":["import {\n type ComponentType,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport { ChainOfThoughtPartByIndexProvider } from \"../../providers/ChainOfThoughtPartByIndexProvider\";\nimport { MessagePartComponent } from \"../message/MessageParts\";\nimport type {\n ReasoningMessagePartComponent,\n ToolCallMessagePartComponent,\n} from \"../../types/MessagePartComponentTypes\";\n\ntype ChainOfThoughtPartsComponentConfig = {\n /** Component for rendering reasoning parts */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Fallback component for tool-call parts */\n tools?: {\n Fallback?: ToolCallMessagePartComponent | undefined;\n };\n /** Layout component to wrap the rendered parts when expanded */\n Layout?: ComponentType<PropsWithChildren> | undefined;\n};\n\nexport namespace ChainOfThoughtPrimitiveParts {\n export type Props =\n | {\n /**\n * @deprecated Use the children render function instead.\n */\n components?: ChainOfThoughtPartsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each part. Receives the part. */\n children: (value: { part: PartState }) => ReactNode;\n components?: never;\n };\n}\n\nconst ChainOfThoughtPrimitivePartsInner: FC<{\n children: (value: { part: PartState }) => ReactNode;\n}> = ({ children }) => {\n const partsLength = useAuiState((s) => s.chainOfThought.parts.length);\n\n return useMemo(\n () =>\n Array.from({ length: partsLength }, (_, index) => (\n <ChainOfThoughtPartByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.chainOfThought().part({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get part() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </ChainOfThoughtPartByIndexProvider>\n )),\n [partsLength, children],\n );\n};\n\n/**\n * Renders the parts within a chain of thought, with support for collapsed/expanded states.\n *\n * When collapsed, no parts are shown. When expanded, all parts are rendered\n * using the provided component configuration through the part scope mechanism.\n */\nexport const ChainOfThoughtPrimitiveParts: FC<\n ChainOfThoughtPrimitiveParts.Props\n> = ({ components, children }) => {\n if (children) {\n return (\n <ChainOfThoughtPrimitivePartsInner>\n {children}\n </ChainOfThoughtPrimitivePartsInner>\n );\n }\n\n //
|
|
1
|
+
{"version":3,"file":"ChainOfThoughtParts.js","names":[],"sources":["../../../../src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx"],"sourcesContent":["import {\n type ComponentType,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport { ChainOfThoughtPartByIndexProvider } from \"../../providers/ChainOfThoughtPartByIndexProvider\";\nimport { MessagePartComponent } from \"../message/MessageParts\";\nimport type {\n ReasoningMessagePartComponent,\n ToolCallMessagePartComponent,\n} from \"../../types/MessagePartComponentTypes\";\n\ntype ChainOfThoughtPartsComponentConfig = {\n /** Component for rendering reasoning parts */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Fallback component for tool-call parts */\n tools?: {\n Fallback?: ToolCallMessagePartComponent | undefined;\n };\n /** Layout component to wrap the rendered parts when expanded */\n Layout?: ComponentType<PropsWithChildren> | undefined;\n};\n\nexport namespace ChainOfThoughtPrimitiveParts {\n export type Props =\n | {\n /**\n * @deprecated Use the children render function instead.\n */\n components?: ChainOfThoughtPartsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each part. Receives the part. */\n children: (value: { part: PartState }) => ReactNode;\n components?: never;\n };\n}\n\nconst ChainOfThoughtPrimitivePartsInner: FC<{\n children: (value: { part: PartState }) => ReactNode;\n}> = ({ children }) => {\n const partsLength = useAuiState((s) => s.chainOfThought.parts.length);\n\n return useMemo(\n () =>\n Array.from({ length: partsLength }, (_, index) => (\n <ChainOfThoughtPartByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.chainOfThought().part({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get part() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </ChainOfThoughtPartByIndexProvider>\n )),\n [partsLength, children],\n );\n};\n\n/**\n * Renders the parts within a chain of thought, with support for collapsed/expanded states.\n *\n * When collapsed, no parts are shown. When expanded, all parts are rendered\n * using the provided component configuration through the part scope mechanism.\n */\nexport const ChainOfThoughtPrimitiveParts: FC<\n ChainOfThoughtPrimitiveParts.Props\n> = ({ components, children }) => {\n if (children) {\n return (\n <ChainOfThoughtPrimitivePartsInner>\n {children}\n </ChainOfThoughtPrimitivePartsInner>\n );\n }\n\n // oxlint-disable-next-line react-hooks/rules-of-hooks -- intentional conditional hook below the early return above\n const messageComponents = useMemo(\n () => ({\n Reasoning: components?.Reasoning,\n tools: {\n Fallback: components?.tools?.Fallback,\n },\n }),\n [components?.Reasoning, components?.tools?.Fallback],\n );\n\n const Layout = components?.Layout;\n\n return (\n <ChainOfThoughtPrimitivePartsInner>\n {() =>\n Layout ? (\n <Layout>\n <MessagePartComponent components={messageComponents} />\n </Layout>\n ) : (\n <MessagePartComponent components={messageComponents} />\n )\n }\n </ChainOfThoughtPrimitivePartsInner>\n );\n};\n\nChainOfThoughtPrimitiveParts.displayName = \"ChainOfThoughtPrimitive.Parts\";\n"],"mappings":";;;;;;AA2CA,MAAM,qCAEA,EAAE,eAAe;CACrB,MAAM,cAAc,aAAa,MAAM,EAAE,eAAe,MAAM,MAAM;CAEpE,OAAO,cAEH,MAAM,KAAK,EAAE,QAAQ,YAAY,IAAI,GAAG,UACtC,oBAAC,mCAAD;EAAsD;YACpD,oBAAC,4BAAD;GACE,eAAe,QACb,IAAI,eAAe,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,SAAS;cAG9C,YACA,SAAS,EACP,IAAI,OAAO;IACT,OAAO,QAAQ;GACjB,EACF,CAAC;EAEuB,CAAA;CACK,GAdK,KAcL,CACpC,GACH,CAAC,aAAa,QAAQ,CACxB;AACF;;;;;;;AAQA,MAAa,gCAER,EAAE,YAAY,eAAe;CAChC,IAAI,UACF,OACE,oBAAC,mCAAD,EACG,SACgC,CAAA;CAKvC,MAAM,oBAAoB,eACjB;EACL,WAAW,YAAY;EACvB,OAAO,EACL,UAAU,YAAY,OAAO,SAC/B;CACF,IACA,CAAC,YAAY,WAAW,YAAY,OAAO,QAAQ,CACrD;CAEA,MAAM,SAAS,YAAY;CAE3B,OACE,oBAAC,mCAAD,EAAA,gBAEI,SACE,oBAAC,QAAD,EAAA,UACE,oBAAC,sBAAD,EAAsB,YAAY,kBAAoB,CAAA,EAChD,CAAA,IAER,oBAAC,sBAAD,EAAsB,YAAY,kBAAoB,CAAA,EAGzB,CAAA;AAEvC;AAEA,6BAA6B,cAAc"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MessagePartStatus, ToolCallMessagePartStatus } from "../../../types/message.js";
|
|
2
2
|
import { PartState } from "../../../store/scopes/part.js";
|
|
3
3
|
import { EnrichedPartState } from "./MessageParts.js";
|
|
4
|
-
import { GroupKey } from "../../utils/groupParts.js";
|
|
5
4
|
import { ReactNode } from "react";
|
|
6
5
|
|
|
7
6
|
//#region src/react/primitives/message/MessageGroupedParts.d.ts
|
|
@@ -34,26 +33,32 @@ declare namespace MessagePrimitiveGroupedParts {
|
|
|
34
33
|
};
|
|
35
34
|
type Props<TKey extends `group-${string}` = `group-${string}`> = {
|
|
36
35
|
/**
|
|
37
|
-
* Maps each part to
|
|
38
|
-
* prefix coalesce
|
|
39
|
-
*
|
|
40
|
-
* through `children` with `part` set to its {@link EnrichedPartState}.
|
|
36
|
+
* Maps each part to a group-key path. Adjacent parts that share a
|
|
37
|
+
* prefix coalesce into the same group. Return `[]` (or `null`) to
|
|
38
|
+
* leave a part ungrouped.
|
|
41
39
|
*
|
|
42
|
-
*
|
|
43
|
-
* `switch (part.type)` can
|
|
40
|
+
* Group keys must start with `"group-"` so the renderer's
|
|
41
|
+
* `switch (part.type)` can tell groups apart from real part types.
|
|
44
42
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
43
|
+
* **Prefer {@link groupPartByType}** for the common case of mapping by
|
|
44
|
+
* `part.type` — it ships a stable memo fingerprint so the tree
|
|
45
|
+
* survives unrelated re-renders. Use an inline function only when
|
|
46
|
+
* the helper isn't expressive enough (e.g. branching on
|
|
47
|
+
* `part.toolName` or part metadata).
|
|
47
48
|
*
|
|
48
49
|
* @example
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
50
|
+
* ```tsx
|
|
51
|
+
* import { groupPartByType } from "@assistant-ui/react";
|
|
52
|
+
*
|
|
53
|
+
* <MessagePrimitive.GroupedParts
|
|
54
|
+
* groupBy={groupPartByType({
|
|
55
|
+
* reasoning: ["group-thought", "group-reasoning"],
|
|
56
|
+
* "tool-call": ["group-thought", "group-tool"],
|
|
57
|
+
* })}
|
|
58
|
+
* >
|
|
54
59
|
* ```
|
|
55
60
|
*/
|
|
56
|
-
readonly groupBy: (part: PartState
|
|
61
|
+
readonly groupBy: (part: PartState) => readonly TKey[] | null;
|
|
57
62
|
/**
|
|
58
63
|
* Render function called once per group node and once per leaf part.
|
|
59
64
|
* Switch on `part.type`: `"group-…"` cases wrap `children`; real
|
|
@@ -61,7 +66,7 @@ declare namespace MessagePrimitiveGroupedParts {
|
|
|
61
66
|
*
|
|
62
67
|
* Leaf parts receive the same {@link EnrichedPartState} that
|
|
63
68
|
* `<MessagePrimitive.Parts>` would produce (`toolUI`, `addResult`,
|
|
64
|
-
* `resume`, `dataRendererUI`).
|
|
69
|
+
* `resume`, `respondToApproval`, `dataRendererUI`).
|
|
65
70
|
*/
|
|
66
71
|
readonly children: (info: RenderInfo<TKey>) => ReactNode;
|
|
67
72
|
};
|
|
@@ -80,11 +85,10 @@ declare namespace MessagePrimitiveGroupedParts {
|
|
|
80
85
|
* @example
|
|
81
86
|
* ```tsx
|
|
82
87
|
* <MessagePrimitive.GroupedParts
|
|
83
|
-
* groupBy={(
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* }
|
|
88
|
+
* groupBy={groupPartByType({
|
|
89
|
+
* reasoning: ["group-thought", "group-reasoning"],
|
|
90
|
+
* "tool-call": ["group-thought", "group-tool"],
|
|
91
|
+
* })}
|
|
88
92
|
* >
|
|
89
93
|
* {({ part, children }) => {
|
|
90
94
|
* switch (part.type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageGroupedParts.d.ts","names":[],"sources":["../../../../src/react/primitives/message/MessageGroupedParts.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MessageGroupedParts.d.ts","names":[],"sources":["../../../../src/react/primitives/message/MessageGroupedParts.tsx"],"mappings":";;;;;;kBAiBiB,4BAAA;;AAAjB;;;;;OAOc,SAAA;IAAA,SACD,IAAA,EAAM,IAAA;IAAA,SACN,MAAA,EAAQ,iBAAA,GAAoB,yBAAA;IAAA,SAC5B,OAAA;EAAA;EAAA,KAGC,UAAA;IA2CsC;;;;;IAAA,SArCvC,IAAA,EAAM,SAAA,CAAU,IAAA,IAAQ,iBAAA;IAZvB;;;;;;IAAA,SAmBD,QAAA,EAAU,SAAA;EAAA;EAAA,KAGT,KAAA;IAhBW;;;;;;;;;;;;;;;;;;;AAsDmC;AAqF5D;;;;;;IA3IyB,SA2CZ,OAAA,GAAU,IAAA,EAAM,SAAA,cAAuB,IAAA;IAmGN;;;;;;;;;IAAA,SAxFjC,QAAA,GAAW,IAAA,EAAM,UAAA,CAAW,IAAA,MAAU,SAAA;EAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqFtC,4BAAA;EAAA;IAA8D,OAAA;IAAA;EAAA,GAGxE,4BAAA,CAA6B,KAAA,CAAM,IAAA,IAAQ,SAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { MessagePartChildren } from "./MessageParts.js";
|
|
3
|
-
import {
|
|
3
|
+
import { GROUPBY_MEMO_KEY, buildGroupTree } from "../../utils/groupParts.js";
|
|
4
4
|
import { Fragment, useMemo } from "react";
|
|
5
5
|
import { useAuiState } from "@assistant-ui/store";
|
|
6
6
|
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
@@ -48,11 +48,10 @@ const renderNode = (node, parts, render) => {
|
|
|
48
48
|
* @example
|
|
49
49
|
* ```tsx
|
|
50
50
|
* <MessagePrimitive.GroupedParts
|
|
51
|
-
* groupBy={(
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* }
|
|
51
|
+
* groupBy={groupPartByType({
|
|
52
|
+
* reasoning: ["group-thought", "group-reasoning"],
|
|
53
|
+
* "tool-call": ["group-thought", "group-tool"],
|
|
54
|
+
* })}
|
|
56
55
|
* >
|
|
57
56
|
* {({ part, children }) => {
|
|
58
57
|
* switch (part.type) {
|
|
@@ -69,7 +68,7 @@ const renderNode = (node, parts, render) => {
|
|
|
69
68
|
*/
|
|
70
69
|
const MessagePrimitiveGroupedParts = ({ groupBy, children }) => {
|
|
71
70
|
const parts = useAuiState(useShallow((s) => s.message.parts));
|
|
72
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children: useMemo(() => buildGroupTree(parts.map((part
|
|
71
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: useMemo(() => buildGroupTree(parts.map((part) => groupBy(part) ?? [])), [parts, groupBy[GROUPBY_MEMO_KEY] ?? groupBy]).map((node) => renderNode(node, parts, children)) });
|
|
73
72
|
};
|
|
74
73
|
MessagePrimitiveGroupedParts.displayName = "MessagePrimitive.GroupedParts";
|
|
75
74
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageGroupedParts.js","names":[],"sources":["../../../../src/react/primitives/message/MessageGroupedParts.tsx"],"sourcesContent":["\"use client\";\n\nimport { Fragment, type FC, type ReactNode, useMemo } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useShallow } from \"zustand/shallow\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport type {\n MessagePartStatus,\n ToolCallMessagePartStatus,\n} from \"../../../types/message\";\nimport {\n buildGroupTree,\n
|
|
1
|
+
{"version":3,"file":"MessageGroupedParts.js","names":[],"sources":["../../../../src/react/primitives/message/MessageGroupedParts.tsx"],"sourcesContent":["\"use client\";\n\nimport { Fragment, type FC, type ReactNode, useMemo } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useShallow } from \"zustand/shallow\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport type {\n MessagePartStatus,\n ToolCallMessagePartStatus,\n} from \"../../../types/message\";\nimport {\n buildGroupTree,\n GROUPBY_MEMO_KEY,\n type GroupNode,\n} from \"../../utils/groupParts\";\nimport { MessagePartChildren, type EnrichedPartState } from \"./MessageParts\";\n\nexport namespace MessagePrimitiveGroupedParts {\n /**\n * A coalesced group of adjacent parts. Surfaced through the same\n * `{ part }` channel as a leaf {@link EnrichedPartState} so consumers\n * dispatch on a single `switch (part.type)`. `type` is the group key\n * (always `\"group-…\"`); `status` mirrors the last contained part.\n */\n export type GroupPart<TKey extends `group-${string}` = `group-${string}`> = {\n readonly type: TKey;\n readonly status: MessagePartStatus | ToolCallMessagePartStatus;\n readonly indices: readonly number[];\n };\n\n export type RenderInfo<TKey extends `group-${string}` = `group-${string}`> = {\n /**\n * Either a coalesced group ({@link GroupPart}, identified by a\n * `group-…` `type`) or a single enriched part. Use one switch over\n * `part.type` to handle both.\n */\n readonly part: GroupPart<TKey> | EnrichedPartState;\n /**\n * For group nodes: the recursively-rendered subtree (subgroups +\n * leaf parts). For leaf parts: a sentinel that throws when rendered\n * — accidental fall-through (`default: return children;`) errors\n * loudly instead of silently rendering nothing.\n */\n readonly children: ReactNode;\n };\n\n export type Props<TKey extends `group-${string}` = `group-${string}`> = {\n /**\n * Maps each part to a group-key path. Adjacent parts that share a\n * prefix coalesce into the same group. Return `[]` (or `null`) to\n * leave a part ungrouped.\n *\n * Group keys must start with `\"group-\"` so the renderer's\n * `switch (part.type)` can tell groups apart from real part types.\n *\n * **Prefer {@link groupPartByType}** for the common case of mapping by\n * `part.type` — it ships a stable memo fingerprint so the tree\n * survives unrelated re-renders. Use an inline function only when\n * the helper isn't expressive enough (e.g. branching on\n * `part.toolName` or part metadata).\n *\n * @example\n * ```tsx\n * import { groupPartByType } from \"@assistant-ui/react\";\n *\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * })}\n * >\n * ```\n */\n readonly groupBy: (part: PartState) => readonly TKey[] | null;\n\n /**\n * Render function called once per group node and once per leaf part.\n * Switch on `part.type`: `\"group-…\"` cases wrap `children`; real\n * part types (`\"text\"`, `\"tool-call\"`, …) render the part directly.\n *\n * Leaf parts receive the same {@link EnrichedPartState} that\n * `<MessagePrimitive.Parts>` would produce (`toolUI`, `addResult`,\n * `resume`, `respondToApproval`, `dataRendererUI`).\n */\n readonly children: (info: RenderInfo<TKey>) => ReactNode;\n };\n}\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({ type: \"complete\" });\n\n/**\n * `children` placeholder passed for leaf-part renders. Leaf parts have no\n * inner subtree; rendering this sentinel signals the consumer wrote\n * `default: return children;` and accidentally fell through for a part —\n * surface the bug loudly instead of silently rendering nothing.\n */\nconst PartChildrenSentinel: FC = () => {\n throw new Error(\n \"MessagePrimitive.GroupedParts: rendered `children` under a leaf \" +\n \"part. `children` is only meaningful for `group-…` cases — add a \" +\n \"matching case for the part type or return `null` to skip it.\",\n );\n};\n\nconst renderNode = <TKey extends `group-${string}`>(\n node: GroupNode,\n parts: readonly PartState[],\n render: (info: MessagePrimitiveGroupedParts.RenderInfo<TKey>) => ReactNode,\n): ReactNode => {\n if (node.type === \"part\") {\n // Key by absolute part index, not structural nodeKey — prevents zombie fiber subscriptions when parts reshape (#4051).\n return (\n <MessagePartChildren key={`part-${node.index}`} index={node.index}>\n {({ part }) => render({ part, children: <PartChildrenSentinel /> })}\n </MessagePartChildren>\n );\n }\n\n const status = parts[node.indices.at(-1)!]?.status ?? COMPLETE_STATUS;\n const groupPart: MessagePrimitiveGroupedParts.GroupPart<TKey> = {\n type: node.key as TKey,\n status,\n indices: node.indices,\n };\n\n return (\n <Fragment key={node.nodeKey}>\n {render({\n part: groupPart,\n children: (\n <>{node.children.map((child) => renderNode(child, parts, render))}</>\n ),\n })}\n </Fragment>\n );\n};\n\n/**\n * Groups adjacent message parts into a tree of coalesced runs and\n * renders each node — group or part — through a single `children`\n * function.\n *\n * The render function receives `{ part, children }` where `part.type`\n * is either a `\"group-…\"` literal (for a group, `children` is the\n * recursively-rendered subtree) or a real part type (`\"text\"`,\n * `\"tool-call\"`, …) for a leaf (`children` is a sentinel that throws\n * if rendered — use `part.type` to distinguish).\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * })}\n * >\n * {({ part, children }) => {\n * switch (part.type) {\n * case \"group-thought\": return <Thought>{children}</Thought>;\n * case \"group-reasoning\": return <Reasoning>{children}</Reasoning>;\n * case \"group-tool\": return <ToolStack>{children}</ToolStack>;\n * case \"text\": return <MarkdownText />;\n * case \"tool-call\": return part.toolUI ?? <ToolFallback {...part} />;\n * default: return null;\n * }\n * }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const MessagePrimitiveGroupedParts = <TKey extends `group-${string}`>({\n groupBy,\n children,\n}: MessagePrimitiveGroupedParts.Props<TKey>): ReactNode => {\n const parts = useAuiState(useShallow((s) => s.message.parts));\n\n // Helpers like `groupPartByType` tag the function with `GROUPBY_MEMO_KEY`\n // (a stable string fingerprint of the helper config). When present,\n // memo on `[parts, memoKey]` so the tree survives unrelated renders.\n // For inline `groupBy`, fall back to recomputing each render — O(n)\n // and cheap.\n const memoKey = (groupBy as { [GROUPBY_MEMO_KEY]?: string })[\n GROUPBY_MEMO_KEY\n ];\n const memoDep = memoKey ?? groupBy;\n const tree = useMemo(\n () => buildGroupTree(parts.map((part) => groupBy(part) ?? [])),\n // oxlint-disable-next-line tap-hooks/exhaustive-deps -- groupBy is captured via memoDep (either its identity or the helper's memoKey fingerprint); listing it directly would defeat the helper-tagged memo path\n [parts, memoDep],\n );\n\n return <>{tree.map((node) => renderNode(node, parts, children))}</>;\n};\n\nMessagePrimitiveGroupedParts.displayName = \"MessagePrimitive.GroupedParts\";\n"],"mappings":";;;;;;;;AAwFA,MAAM,kBAAqC,OAAO,OAAO,EAAE,MAAM,WAAW,CAAC;;;;;;;AAQ7E,MAAM,6BAAiC;CACrC,MAAM,IAAI,MACR,8LAGF;AACF;AAEA,MAAM,cACJ,MACA,OACA,WACc;CACd,IAAI,KAAK,SAAS,QAEhB,OACE,oBAAC,qBAAD;EAAgD,OAAO,KAAK;aACxD,EAAE,WAAW,OAAO;GAAE;GAAM,UAAU,oBAAC,sBAAD,CAAuB,CAAA;EAAE,CAAC;CAC/C,GAFK,QAAQ,KAAK,OAElB;CAIzB,MAAM,SAAS,MAAM,KAAK,QAAQ,GAAG,EAAE,IAAK,UAAU;CAOtD,OACE,oBAAC,UAAD,EAAA,UACG,OAAO;EACN,MAAM;GARV,MAAM,KAAK;GACX;GACA,SAAS,KAAK;EAMI;EACd,UACE,oBAAA,YAAA,EAAA,UAAG,KAAK,SAAS,KAAK,UAAU,WAAW,OAAO,OAAO,MAAM,CAAC,EAAI,CAAA;CAExE,CAAC,EACO,GAPK,KAAK,OAOV;AAEd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,gCAAgE,EAC3E,SACA,eACyD;CACzD,MAAM,QAAQ,YAAY,YAAY,MAAM,EAAE,QAAQ,KAAK,CAAC;CAiB5D,OAAO,oBAAA,YAAA,EAAA,UANM,cACL,eAAe,MAAM,KAAK,SAAS,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,GAE7D,CAAC,OAPc,QACf,qBAEyB,OAIV,CAGJ,EAAE,KAAK,SAAS,WAAW,MAAM,OAAO,QAAQ,CAAC,EAAI,CAAA;AACpE;AAEA,6BAA6B,cAAc"}
|
|
@@ -168,7 +168,8 @@ type EnrichedPartState = (Extract<PartState, {
|
|
|
168
168
|
}> & {
|
|
169
169
|
/** The registered tool UI element, or null if none registered. */readonly toolUI: ReactNode; /** Add a tool result to this tool call. */
|
|
170
170
|
addResult: ToolCallMessagePartProps["addResult"]; /** Resume a tool call waiting for human input. */
|
|
171
|
-
resume: ToolCallMessagePartProps["resume"];
|
|
171
|
+
resume: ToolCallMessagePartProps["resume"]; /** Respond to a server-side tool approval gate. */
|
|
172
|
+
respondToApproval: ToolCallMessagePartProps["respondToApproval"];
|
|
172
173
|
}) | (Extract<PartState, {
|
|
173
174
|
type: "data";
|
|
174
175
|
}> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageParts.d.ts","names":[],"sources":["../../../../src/react/primitives/message/MessageParts.tsx"],"mappings":";;;;;kBA6JiB,qBAAA;EAAA,KACV,UAAA;IADU,kDAGb,OAAA,GAAU,MAAA,SAAe,wBAAA,2BAHS;IAKlC,QAAA,GAAW,wBAAA;EAAA;EAAA,KAGR,cAAA;IAEK,6CAAR,KAAA,GAAQ,yBAAA,cAIC;IAFT,IAAA,GAAO,wBAAA,cAMA;IAJP,MAAA,GAAS,0BAAA,cAQF;IANP,KAAA,GAAQ,yBAAA,cAoBU;IAlBlB,IAAA,GAAO,wBAAA,cA+BgB;IA7BvB,cAAA,GAAiB,kCAAA,cAgCY;IA9B7B,IAAA,GAAO,UAAA,cAkCqB;IAhC5B,KAAA,GAAQ,yBAAA;IAyCgB;;;;;;;;IAhCxB,YAAA;MA+FsC,uDA5FhC,UAAA,EAAY,6BAAA,EAyGoC;MAvGhD,QAAA,GACI,aAAA;QAAgB,SAAA;QAAmB,KAAA;MAAA;IAAA;EAAA;EAAA,KAM1C,WAAA;IAxCQ,qDA2CP,OAAA,GACI,MAAA,SAAe,4BAAA,2BAvCvB;IA0CI,QAAA,GAAW,aAAA,CAAc,wBAAA;EAAA;IAxCtB,qDA4CH,QAAA,EAAU,aAAA,CAAc,wBAAA;EAAA;EAxC5B;;;;;;EAAA,KAiDG,kBAAA,GAAqB,cAAA;IA3CjB,mEA6CP,SAAA,GAAY,6BAAA,cA3CJ;IA6CR,KAAA,GAAQ,WAAA;IAjCF;;;;;;;;;IA4CN,SAAA,GAAY,aAAA,CACV,iBAAA;MAAoB,UAAA;MAAoB,QAAA;IAAA;IAzBtC;;;;;;;;;IAqCJ,cAAA,GAAiB,uBAAA;IAEjB,cAAA;EAAA;EAdsB;;;;;;;EAAA,KAwBnB,wBAAA,GAA2B,cAAA;IAMd;;;;;IAAhB,cAAA,EAAgB,aAAA;IAEhB,SAAA;IACA,KAAA;IACA,SAAA;IACA,cAAA;EAAA;EAAA,YAGU,KAAA;IAsBc;;;;;;;IAbpB,UAAA,GAAa,kBAAA,GAAqB,wBAAA;IA6D7B;;;;;;;IArDL,8BAAA;IACA,QAAA;EAAA;IA4D0C,8EAxD1C,QAAA,GAAW,KAAA;MAAS,IAAA,EAAM,iBAAA;IAAA,MAAwB,SAAA;IAClD,UAAA;IACA,8BAAA;EAAA;EAAA;AAAA;;;;;cA8CK,iBAAA;;;;;;;;;KAOe,iBAAA,KAAiB,SAAA;;;KACZ,iBAAA,KAAiB,SAAA;AAAA;AAAA,KAG7C,yBAAA;EACH,UAAA,EAAY,qBAAA,CAAsB,KAAK;AAAA;AAAA,cAG5B,oBAAA,EAAsB,EAAE,CAAC,yBAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"MessageParts.d.ts","names":[],"sources":["../../../../src/react/primitives/message/MessageParts.tsx"],"mappings":";;;;;kBA6JiB,qBAAA;EAAA,KACV,UAAA;IADU,kDAGb,OAAA,GAAU,MAAA,SAAe,wBAAA,2BAHS;IAKlC,QAAA,GAAW,wBAAA;EAAA;EAAA,KAGR,cAAA;IAEK,6CAAR,KAAA,GAAQ,yBAAA,cAIC;IAFT,IAAA,GAAO,wBAAA,cAMA;IAJP,MAAA,GAAS,0BAAA,cAQF;IANP,KAAA,GAAQ,yBAAA,cAoBU;IAlBlB,IAAA,GAAO,wBAAA,cA+BgB;IA7BvB,cAAA,GAAiB,kCAAA,cAgCY;IA9B7B,IAAA,GAAO,UAAA,cAkCqB;IAhC5B,KAAA,GAAQ,yBAAA;IAyCgB;;;;;;;;IAhCxB,YAAA;MA+FsC,uDA5FhC,UAAA,EAAY,6BAAA,EAyGoC;MAvGhD,QAAA,GACI,aAAA;QAAgB,SAAA;QAAmB,KAAA;MAAA;IAAA;EAAA;EAAA,KAM1C,WAAA;IAxCQ,qDA2CP,OAAA,GACI,MAAA,SAAe,4BAAA,2BAvCvB;IA0CI,QAAA,GAAW,aAAA,CAAc,wBAAA;EAAA;IAxCtB,qDA4CH,QAAA,EAAU,aAAA,CAAc,wBAAA;EAAA;EAxC5B;;;;;;EAAA,KAiDG,kBAAA,GAAqB,cAAA;IA3CjB,mEA6CP,SAAA,GAAY,6BAAA,cA3CJ;IA6CR,KAAA,GAAQ,WAAA;IAjCF;;;;;;;;;IA4CN,SAAA,GAAY,aAAA,CACV,iBAAA;MAAoB,UAAA;MAAoB,QAAA;IAAA;IAzBtC;;;;;;;;;IAqCJ,cAAA,GAAiB,uBAAA;IAEjB,cAAA;EAAA;EAdsB;;;;;;;EAAA,KAwBnB,wBAAA,GAA2B,cAAA;IAMd;;;;;IAAhB,cAAA,EAAgB,aAAA;IAEhB,SAAA;IACA,KAAA;IACA,SAAA;IACA,cAAA;EAAA;EAAA,YAGU,KAAA;IAsBc;;;;;;;IAbpB,UAAA,GAAa,kBAAA,GAAqB,wBAAA;IA6D7B;;;;;;;IArDL,8BAAA;IACA,QAAA;EAAA;IA4D0C,8EAxD1C,QAAA,GAAW,KAAA;MAAS,IAAA,EAAM,iBAAA;IAAA,MAAwB,SAAA;IAClD,UAAA;IACA,8BAAA;EAAA;EAAA;AAAA;;;;;cA8CK,iBAAA;;;;;;;;;KAOe,iBAAA,KAAiB,SAAA;;;KACZ,iBAAA,KAAiB,SAAA;AAAA;AAAA,KAG7C,yBAAA;EACH,UAAA,EAAY,qBAAA,CAAsB,KAAK;AAAA;AAAA,cAG5B,oBAAA,EAAsB,EAAE,CAAC,yBAAA;AAAA,kBAkGrB,2BAAA;EAAA,KACH,KAAA;IACV,KAAA;IACA,UAAA,EAAY,qBAAA,CAAsB,KAAK;EAAA;AAAA;AAH3C;;;AAAA,cAUa,2BAAA,EAA6B,EAAE,CAAC,2BAAA,CAA4B,KAAA;;;;;;AAP9B;AAO3C;;;;;;KAgMY,iBAAA,IACP,OAAA,CAAQ,SAAA;EAAa,IAAA;AAAA;EADd,2EAGG,MAAA,EAAQ,SAAA;EAEjB,SAAA,EAAW,wBAAA,eAJZ;EAMC,MAAA,EAAQ,wBAAA,YAFG;EAIX,iBAAA,EAAmB,wBAAA;AAAA,MAEpB,OAAA,CAAQ,SAAA;EAAa,IAAA;AAAA;EAEK,oFAAhB,cAAA,EAAgB,SAAA;AAAA,KAE3B,OAAA,CAAQ,SAAA;EAAa,IAAA;AAAA;EAAwB,IAAA;AAAA;;;;;;;cAoGpC,qBAAA,EAAuB,EAAE,CAAC,qBAAA,CAAsB,KAAA"}
|
|
@@ -131,17 +131,20 @@ const MessagePartComponent = ({ components: { Text = defaultComponents.Text, Rea
|
|
|
131
131
|
if (type === "tool-call") {
|
|
132
132
|
const addResult = aui.part().addToolResult;
|
|
133
133
|
const resume = aui.part().resumeToolCall;
|
|
134
|
+
const respondToApproval = aui.part().respondToToolApproval;
|
|
134
135
|
if ("Override" in tools) return /* @__PURE__ */ jsx(tools.Override, {
|
|
135
136
|
...part,
|
|
136
137
|
addResult,
|
|
137
|
-
resume
|
|
138
|
+
resume,
|
|
139
|
+
respondToApproval
|
|
138
140
|
});
|
|
139
141
|
const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;
|
|
140
142
|
return /* @__PURE__ */ jsx(ToolUIDisplay, {
|
|
141
143
|
...part,
|
|
142
144
|
Fallback: Tool,
|
|
143
145
|
addResult,
|
|
144
|
-
resume
|
|
146
|
+
resume,
|
|
147
|
+
respondToApproval
|
|
145
148
|
});
|
|
146
149
|
}
|
|
147
150
|
if (part.status?.type === "requires-action") throw new Error("Encountered unexpected requires-action status");
|
|
@@ -245,7 +248,8 @@ const RegisteredToolUI = () => {
|
|
|
245
248
|
return /* @__PURE__ */ jsx(Render, {
|
|
246
249
|
...part,
|
|
247
250
|
addResult: aui.part().addToolResult,
|
|
248
|
-
resume: aui.part().resumeToolCall
|
|
251
|
+
resume: aui.part().resumeToolCall,
|
|
252
|
+
respondToApproval: aui.part().respondToToolApproval
|
|
249
253
|
});
|
|
250
254
|
};
|
|
251
255
|
/**
|
|
@@ -306,7 +310,8 @@ const MessagePartChildren = ({ index, children }) => {
|
|
|
306
310
|
...state,
|
|
307
311
|
toolUI: hasUI ? /* @__PURE__ */ jsx(RegisteredToolUI, {}) : null,
|
|
308
312
|
addResult: partMethods.addToolResult,
|
|
309
|
-
resume: partMethods.resumeToolCall
|
|
313
|
+
resume: partMethods.resumeToolCall,
|
|
314
|
+
respondToApproval: partMethods.respondToToolApproval
|
|
310
315
|
};
|
|
311
316
|
}
|
|
312
317
|
if (state.type === "data") {
|