@assistant-ui/core 0.3.2 → 0.3.3

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.
Files changed (56) hide show
  1. package/dist/index.d.ts +4 -4
  2. package/dist/index.js.map +1 -1
  3. package/dist/internal.d.ts +6 -6
  4. package/dist/internal.js +5 -5
  5. package/dist/react/primitive-hooks/useActionBarCopy.js +51 -24
  6. package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
  7. package/dist/react/primitives/message/MessageGroupedParts.d.ts +2 -1
  8. package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
  9. package/dist/react/primitives/message/MessageGroupedParts.js +2 -2
  10. package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
  11. package/dist/react/runtimes/cloud/auiV0.d.ts +24 -2
  12. package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
  13. package/dist/react/runtimes/cloud/auiV0.js +24 -5
  14. package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
  15. package/dist/runtime/api/message-runtime.d.ts.map +1 -1
  16. package/dist/runtime/api/message-runtime.js +5 -1
  17. package/dist/runtime/api/message-runtime.js.map +1 -1
  18. package/dist/runtime/internal.d.ts +4 -4
  19. package/dist/runtime/internal.js +4 -4
  20. package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
  21. package/dist/store/clients/chain-of-thought-client.js +29 -23
  22. package/dist/store/clients/chain-of-thought-client.js.map +1 -1
  23. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  24. package/dist/store/clients/thread-message-client.js +101 -89
  25. package/dist/store/clients/thread-message-client.js.map +1 -1
  26. package/dist/types/index.d.ts +2 -2
  27. package/dist/types/message.d.ts +11 -1
  28. package/dist/types/message.d.ts.map +1 -1
  29. package/dist/types/message.js.map +1 -1
  30. package/dist/utils/getGroupStatus.d.ts +9 -0
  31. package/dist/utils/getGroupStatus.d.ts.map +1 -0
  32. package/dist/utils/getGroupStatus.js +15 -0
  33. package/dist/utils/getGroupStatus.js.map +1 -0
  34. package/dist/utils/normalizePartStatus.d.ts +8 -0
  35. package/dist/utils/normalizePartStatus.d.ts.map +1 -0
  36. package/dist/utils/normalizePartStatus.js +39 -0
  37. package/dist/utils/normalizePartStatus.js.map +1 -0
  38. package/package.json +2 -2
  39. package/src/index.ts +1 -0
  40. package/src/internal.ts +1 -0
  41. package/src/react/primitive-hooks/useActionBarCopy.test.ts +109 -14
  42. package/src/react/primitive-hooks/useActionBarCopy.ts +27 -2
  43. package/src/react/primitives/message/MessageGroupedParts.tsx +4 -4
  44. package/src/react/runtimes/cloud/auiV0.ts +51 -12
  45. package/src/runtime/api/message-runtime.test.ts +140 -0
  46. package/src/runtime/api/message-runtime.ts +10 -5
  47. package/src/store/clients/chain-of-thought-client.ts +2 -7
  48. package/src/store/clients/thread-message-client.test.ts +84 -0
  49. package/src/store/clients/thread-message-client.ts +14 -4
  50. package/src/tests/auiV0Encode.test.ts +93 -0
  51. package/src/types/index.ts +1 -0
  52. package/src/types/message.ts +19 -0
  53. package/src/utils/getGroupStatus.test.ts +36 -0
  54. package/src/utils/getGroupStatus.ts +31 -0
  55. package/src/utils/normalizePartStatus.test.ts +59 -0
  56. package/src/utils/normalizePartStatus.ts +55 -0
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference path="./store/scope-registration.d.ts" />
2
- import { AppendMessage, DataMessagePart, FileMessagePart, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, ImageMessagePart, MCP_APP_URI_SCHEME, McpAppMetadata, MessagePartStatus, MessageRole, MessageStatus, MessageTiming, PartProviderMetadata, ReasoningMessagePart, RunConfig, SourceMessagePart, SourceProviderMetadata, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadMessage, ThreadStep, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolApprovalOption, ToolApprovalOptionKind, ToolApprovalResponse, ToolCallMessagePart, ToolCallMessagePartMcpMetadata, ToolCallMessagePartStatus, ToolCallTiming, ToolModelContentPart, Unstable_AudioMessagePart, isMcpAppUri } from "./types/message.js";
2
+ import { AppendMessage, DataMessagePart, FileMessagePart, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, ImageMessagePart, MCP_APP_URI_SCHEME, McpAppMetadata, MessagePartStatus, MessagePartStreamStatus, MessageRole, MessageStatus, MessageTiming, PartProviderMetadata, ReasoningMessagePart, RunConfig, SourceMessagePart, SourceProviderMetadata, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadMessage, ThreadStep, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolApprovalOption, ToolApprovalOptionKind, ToolApprovalResponse, ToolCallMessagePart, ToolCallMessagePartMcpMetadata, ToolCallMessagePartStatus, ToolCallTiming, ToolModelContentPart, Unstable_AudioMessagePart, isMcpAppUri } from "./types/message.js";
3
3
  import { Attachment, AttachmentStatus, CompleteAttachment, CompleteAttachmentStatus, CreateAttachment, PendingAttachment, PendingAttachmentStatus } from "./types/attachment.js";
4
4
  import { AttachmentAdapter, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter } from "./adapters/attachment.js";
5
5
  import { Unstable_TriggerCategory, Unstable_TriggerItem } from "./types/trigger.js";
@@ -33,12 +33,12 @@ import { ThreadListItemCoreState, ThreadListItemStatus, ThreadListRuntimeCore }
33
33
  import { AssistantRuntimeCore } from "./runtime/interfaces/assistant-runtime-core.js";
34
34
  import { generateId } from "./utils/id.js";
35
35
  import { ThreadListItemState } from "./runtime/api/bindings.js";
36
- import { ThreadListItemEventCallback, ThreadListItemEventPayload, ThreadListItemEventType, ThreadListItemRuntime } from "./runtime/api/thread-list-item-runtime.js";
37
- import { ThreadListRuntime, ThreadListState } from "./runtime/api/thread-list-runtime.js";
38
36
  import { AttachmentRuntime, AttachmentState } from "./runtime/api/attachment-runtime.js";
39
37
  import { ComposerRuntime, ComposerState, EditComposerRuntime, EditComposerState, ThreadComposerRuntime, ThreadComposerState } from "./runtime/api/composer-runtime.js";
40
38
  import { MessagePartRuntime, MessagePartState } from "./runtime/api/message-part-runtime.js";
41
39
  import { MessageRuntime, MessageState } from "./runtime/api/message-runtime.js";
40
+ import { ThreadListItemEventCallback, ThreadListItemEventPayload, ThreadListItemEventType, ThreadListItemRuntime } from "./runtime/api/thread-list-item-runtime.js";
41
+ import { ThreadListRuntime, ThreadListState } from "./runtime/api/thread-list-runtime.js";
42
42
  import { bindExternalStoreMessage, getExternalStoreMessages } from "./runtime/utils/external-store-message.js";
43
43
  import { LocalRuntimeOptionsBase } from "./runtimes/local/local-runtime-options.js";
44
44
  import { ExternalThreadQueueAdapter } from "./runtime/queue/external-thread-queue-adapter.js";
@@ -52,4 +52,4 @@ import { ExternalThreadBranchAdapter } from "./runtime/branch/external-thread-br
52
52
  import { MessageQueueController, MessageQueueDriver, createMessageQueue } from "./runtime/queue/message-queue.js";
53
53
  import { InMemoryThreadListAdapter } from "./runtimes/remote-thread-list/adapter/in-memory.js";
54
54
  import { createRequestHeaders } from "./runtimes/assistant-transport/utils.js";
55
- export { type AddToolResultOptions, type AppendMessage, type AssistantContextConfig, type AssistantError, type AssistantErrorCode, 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 CreateSuggestionAdapterOptions, type DataMessagePart, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerRuntimeCore, type EditComposerState, type ErrorDisplay, type ErrorSeverity, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreBranchChange, type ExternalStoreMessageConverter, type ExternalStoreSharedOptions, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, type ExternalThreadBranchAdapter, type ExternalThreadQueueAdapter, 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 MessageQueueController, type MessageQueueDriver, 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 PartProviderMetadata, 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 StreamingTimingAccessors, type StreamingTimingOptions, type StreamingTimingState, type SubmitFeedbackOptions, type SubmittedFeedback, type SuggestionAdapter, type SuggestionAdapterGenerateOptions, 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 ToolApprovalOption, type ToolApprovalOptionKind, type ToolApprovalResponse, type ToolCallMessagePart, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartStatus, type ToolCallTiming, type ToolExecutionStatus, type ToolModelContentPart, type Unstable_AudioMessagePart, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_InteractableSnapshotEntry, type Unstable_InteractableVersion, type Unstable_TriggerAdapter, type Unstable_TriggerCategory, type Unstable_TriggerItem, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createRequestHeaders, createSuggestionAdapter, createVoiceSession, fromThreadMessageLike, generateId, getExternalStoreMessages, isAssistantError, isMcpAppUri, mergeModelContexts, pickExternalStoreSharedOptions, stepStreamingTiming, toAssistantError, tool, unstable_defaultDirectiveFormatter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions };
55
+ export { type AddToolResultOptions, type AppendMessage, type AssistantContextConfig, type AssistantError, type AssistantErrorCode, 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 CreateSuggestionAdapterOptions, type DataMessagePart, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerRuntimeCore, type EditComposerState, type ErrorDisplay, type ErrorSeverity, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreBranchChange, type ExternalStoreMessageConverter, type ExternalStoreSharedOptions, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, type ExternalThreadBranchAdapter, type ExternalThreadQueueAdapter, 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 MessagePartStreamStatus, type MessageQueueController, type MessageQueueDriver, 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 PartProviderMetadata, 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 StreamingTimingAccessors, type StreamingTimingOptions, type StreamingTimingState, type SubmitFeedbackOptions, type SubmittedFeedback, type SuggestionAdapter, type SuggestionAdapterGenerateOptions, 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 ToolApprovalOption, type ToolApprovalOptionKind, type ToolApprovalResponse, type ToolCallMessagePart, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartStatus, type ToolCallTiming, type ToolExecutionStatus, type ToolModelContentPart, type Unstable_AudioMessagePart, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_InteractableSnapshotEntry, type Unstable_InteractableVersion, type Unstable_TriggerAdapter, type Unstable_TriggerCategory, type Unstable_TriggerItem, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createRequestHeaders, createSuggestionAdapter, createVoiceSession, fromThreadMessageLike, generateId, getExternalStoreMessages, isAssistantError, isMcpAppUri, mergeModelContexts, pickExternalStoreSharedOptions, stepStreamingTiming, toAssistantError, tool, unstable_defaultDirectiveFormatter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["checkDuplicateCore","process","env","NODE_ENV","TextMessagePart","ReasoningMessagePart","PartProviderMetadata","SourceProviderMetadata","SourceMessagePart","ImageMessagePart","FileMessagePart","DataMessagePart","GenerativeUIMessagePart","GenerativeUINode","GenerativeUISpec","Unstable_AudioMessagePart","ToolApprovalOption","ToolApprovalOptionKind","ToolApprovalResponse","ToolCallMessagePart","ToolCallTiming","ToolCallMessagePartMcpMetadata","McpAppMetadata","ToolModelContentPart","ThreadUserMessagePart","ThreadAssistantMessagePart","MessagePartStatus","ToolCallMessagePartStatus","MessageStatus","MessageTiming","ThreadStep","ThreadSystemMessage","ThreadUserMessage","ThreadAssistantMessage","ThreadMessage","MessageRole","RunConfig","AppendMessage","MCP_APP_URI_SCHEME","isMcpAppUri","Attachment","PendingAttachment","PendingAttachmentStatus","CompleteAttachment","CompleteAttachmentStatus","AttachmentStatus","CreateAttachment","Unsubscribe","QuoteInfo","Unstable_DirectiveSegment","Unstable_DirectiveFormatter","Unstable_TriggerItem","Unstable_TriggerCategory","Unstable_TriggerAdapter","LanguageModelV1CallSettings","LanguageModelConfig","ModelContext","ModelContextProvider","AssistantToolProps","AssistantInstructionsConfig","AssistantContextConfig","mergeModelContexts","tool","unstable_getInteractableSnapshots","unstable_formatInteractableSnapshot","unstable_getInteractableVersions","Unstable_InteractableSnapshotEntry","Unstable_InteractableVersion","ToolExecutionStatus","ModelContextRegistry","ModelContextRegistryToolHandle","ModelContextRegistryInstructionHandle","ModelContextRegistryProviderHandle","AssistantFrameHost","AssistantFrameProvider","SerializedTool","SerializedModelContext","FrameMessageType","FrameMessage","FRAME_MESSAGE_CHANNEL","AttachmentAdapter","SimpleImageAttachmentAdapter","SimpleTextAttachmentAdapter","CompositeAttachmentAdapter","SpeechSynthesisAdapter","DictationAdapter","WebSpeechSynthesisAdapter","WebSpeechDictationAdapter","RealtimeVoiceAdapter","createVoiceSession","VoiceSessionControls","VoiceSessionHelpers","FeedbackAdapter","SuggestionAdapter","SuggestionAdapterGenerateOptions","CreateSuggestionAdapterOptions","createSuggestionAdapter","unstable_defaultDirectiveFormatter","ThreadHistoryAdapter","GenericThreadHistoryAdapter","MessageFormatAdapter","MessageFormatItem","MessageFormatRepository","MessageStorageEntry","ThreadListItemRuntimePath","ThreadRuntimePath","MessageRuntimePath","MessagePartRuntimePath","AttachmentRuntimePath","ComposerRuntimePath","AttachmentAddErrorEvent","AttachmentAddErrorReason","ComposerRuntimeCore","ComposerRuntimeEventCallback","ComposerRuntimeEventPayload","ComposerRuntimeEventType","DictationState","EditComposerRuntimeCore","SendOptions","ThreadComposerRuntimeCore","ErrorSeverity","ErrorDisplay","AssistantErrorCode","AssistantError","toAssistantError","isAssistantError","RuntimeCapabilities","AddToolResultOptions","ResumeToolCallOptions","RespondToToolApprovalOptions","SubmitFeedbackOptions","ThreadSuggestion","SpeechState","VoiceSessionState","SubmittedFeedback","ThreadRuntimeEventCallback","ThreadRuntimeEventPayload","ThreadRuntimeEventType","StartRunConfig","ResumeRunConfig","ThreadRuntimeCore","ThreadListItemStatus","ThreadListItemCoreState","ThreadListRuntimeCore","AssistantRuntimeCore","AssistantRuntime","CreateStartRunConfig","CreateResumeRunConfig","CreateAppendMessage","ThreadState","ThreadRuntime","ThreadListState","ThreadListRuntime","ThreadListItemEventCallback","ThreadListItemEventPayload","ThreadListItemEventType","ThreadListItemRuntime","ThreadListItemState","MessageState","MessageRuntime","MessagePartState","MessagePartRuntime","ThreadComposerState","EditComposerState","ComposerState","ComposerRuntime","ThreadComposerRuntime","EditComposerRuntime","AttachmentState","AttachmentRuntime","ChatModelRunUpdate","ChatModelRunResult","CoreChatModelRunResult","ChatModelRunOptions","ChatModelAdapter","ThreadMessageLike","fromThreadMessageLike","StreamingTimingAccessors","StreamingTimingOptions","StreamingTimingState","stepStreamingTiming","generateId","getExternalStoreMessages","bindExternalStoreMessage","ExportedMessageRepositoryItem","ExportedMessageRepository","LocalRuntimeOptionsBase","ExternalStoreAdapter","ExternalStoreMessageConverter","ExternalStoreThreadListAdapter","ExternalStoreThreadData","ExternalStoreBranchChange","ExternalStoreSharedOptions","pickExternalStoreSharedOptions","ExternalThreadQueueAdapter","ExternalThreadBranchAdapter","createMessageQueue","MessageQueueDriver","MessageQueueController","RemoteThreadListAdapter","RemoteThreadListOptions","RemoteThreadInitializeResponse","RemoteThreadMetadata","RemoteThreadListResponse","RemoteThreadListPageOptions","InMemoryThreadListAdapter","createRequestHeaders"],"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 PartProviderMetadata,\n SourceProviderMetadata,\n SourceMessagePart,\n ImageMessagePart,\n FileMessagePart,\n DataMessagePart,\n GenerativeUIMessagePart,\n GenerativeUINode,\n GenerativeUISpec,\n Unstable_AudioMessagePart,\n ToolApprovalOption,\n ToolApprovalOptionKind,\n ToolApprovalResponse,\n ToolCallMessagePart,\n ToolCallTiming,\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 {\n unstable_getInteractableSnapshots,\n unstable_formatInteractableSnapshot,\n unstable_getInteractableVersions,\n type Unstable_InteractableSnapshotEntry,\n type Unstable_InteractableVersion,\n} from \"./model-context/interactable-composer-metadata\";\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 {\n SuggestionAdapter,\n SuggestionAdapterGenerateOptions,\n CreateSuggestionAdapterOptions,\n} from \"./adapters/suggestion\";\nexport { createSuggestionAdapter } 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 ErrorSeverity,\n ErrorDisplay,\n AssistantErrorCode,\n AssistantError,\n} from \"./types/error\";\nexport { toAssistantError, isAssistantError } from \"./types/error\";\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\";\nexport { fromThreadMessageLike } from \"./runtime/utils/thread-message-like\";\n\n// Streaming timing (client-side)\nexport type {\n StreamingTimingAccessors,\n StreamingTimingOptions,\n StreamingTimingState,\n} from \"./runtime/utils/streaming-timing\";\nexport { stepStreamingTiming } from \"./runtime/utils/streaming-timing\";\n\n// ID generation\nexport { generateId } from \"./utils/id\";\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 ExternalStoreBranchChange,\n} from \"./runtimes/external-store/external-store-adapter\";\nexport type { ExternalStoreSharedOptions } from \"./runtimes/external-store/external-store-shared-options\";\nexport { pickExternalStoreSharedOptions } from \"./runtimes/external-store/external-store-shared-options\";\n\n// Message queue\nexport type { ExternalThreadQueueAdapter } from \"./runtime/queue/external-thread-queue-adapter\";\nexport type { ExternalThreadBranchAdapter } from \"./runtime/branch/external-thread-branch-adapter\";\nexport {\n createMessageQueue,\n type MessageQueueDriver,\n type MessageQueueController,\n} from \"./runtime/queue/message-queue\";\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,IAAIC,QAAQC,IAAIC,aAAa,cAC3BH,mBAAmB"}
1
+ {"version":3,"file":"index.js","names":["checkDuplicateCore","process","env","NODE_ENV","TextMessagePart","ReasoningMessagePart","PartProviderMetadata","SourceProviderMetadata","SourceMessagePart","ImageMessagePart","FileMessagePart","DataMessagePart","GenerativeUIMessagePart","GenerativeUINode","GenerativeUISpec","Unstable_AudioMessagePart","ToolApprovalOption","ToolApprovalOptionKind","ToolApprovalResponse","ToolCallMessagePart","ToolCallTiming","ToolCallMessagePartMcpMetadata","McpAppMetadata","ToolModelContentPart","ThreadUserMessagePart","ThreadAssistantMessagePart","MessagePartStatus","MessagePartStreamStatus","ToolCallMessagePartStatus","MessageStatus","MessageTiming","ThreadStep","ThreadSystemMessage","ThreadUserMessage","ThreadAssistantMessage","ThreadMessage","MessageRole","RunConfig","AppendMessage","MCP_APP_URI_SCHEME","isMcpAppUri","Attachment","PendingAttachment","PendingAttachmentStatus","CompleteAttachment","CompleteAttachmentStatus","AttachmentStatus","CreateAttachment","Unsubscribe","QuoteInfo","Unstable_DirectiveSegment","Unstable_DirectiveFormatter","Unstable_TriggerItem","Unstable_TriggerCategory","Unstable_TriggerAdapter","LanguageModelV1CallSettings","LanguageModelConfig","ModelContext","ModelContextProvider","AssistantToolProps","AssistantInstructionsConfig","AssistantContextConfig","mergeModelContexts","tool","unstable_getInteractableSnapshots","unstable_formatInteractableSnapshot","unstable_getInteractableVersions","Unstable_InteractableSnapshotEntry","Unstable_InteractableVersion","ToolExecutionStatus","ModelContextRegistry","ModelContextRegistryToolHandle","ModelContextRegistryInstructionHandle","ModelContextRegistryProviderHandle","AssistantFrameHost","AssistantFrameProvider","SerializedTool","SerializedModelContext","FrameMessageType","FrameMessage","FRAME_MESSAGE_CHANNEL","AttachmentAdapter","SimpleImageAttachmentAdapter","SimpleTextAttachmentAdapter","CompositeAttachmentAdapter","SpeechSynthesisAdapter","DictationAdapter","WebSpeechSynthesisAdapter","WebSpeechDictationAdapter","RealtimeVoiceAdapter","createVoiceSession","VoiceSessionControls","VoiceSessionHelpers","FeedbackAdapter","SuggestionAdapter","SuggestionAdapterGenerateOptions","CreateSuggestionAdapterOptions","createSuggestionAdapter","unstable_defaultDirectiveFormatter","ThreadHistoryAdapter","GenericThreadHistoryAdapter","MessageFormatAdapter","MessageFormatItem","MessageFormatRepository","MessageStorageEntry","ThreadListItemRuntimePath","ThreadRuntimePath","MessageRuntimePath","MessagePartRuntimePath","AttachmentRuntimePath","ComposerRuntimePath","AttachmentAddErrorEvent","AttachmentAddErrorReason","ComposerRuntimeCore","ComposerRuntimeEventCallback","ComposerRuntimeEventPayload","ComposerRuntimeEventType","DictationState","EditComposerRuntimeCore","SendOptions","ThreadComposerRuntimeCore","ErrorSeverity","ErrorDisplay","AssistantErrorCode","AssistantError","toAssistantError","isAssistantError","RuntimeCapabilities","AddToolResultOptions","ResumeToolCallOptions","RespondToToolApprovalOptions","SubmitFeedbackOptions","ThreadSuggestion","SpeechState","VoiceSessionState","SubmittedFeedback","ThreadRuntimeEventCallback","ThreadRuntimeEventPayload","ThreadRuntimeEventType","StartRunConfig","ResumeRunConfig","ThreadRuntimeCore","ThreadListItemStatus","ThreadListItemCoreState","ThreadListRuntimeCore","AssistantRuntimeCore","AssistantRuntime","CreateStartRunConfig","CreateResumeRunConfig","CreateAppendMessage","ThreadState","ThreadRuntime","ThreadListState","ThreadListRuntime","ThreadListItemEventCallback","ThreadListItemEventPayload","ThreadListItemEventType","ThreadListItemRuntime","ThreadListItemState","MessageState","MessageRuntime","MessagePartState","MessagePartRuntime","ThreadComposerState","EditComposerState","ComposerState","ComposerRuntime","ThreadComposerRuntime","EditComposerRuntime","AttachmentState","AttachmentRuntime","ChatModelRunUpdate","ChatModelRunResult","CoreChatModelRunResult","ChatModelRunOptions","ChatModelAdapter","ThreadMessageLike","fromThreadMessageLike","StreamingTimingAccessors","StreamingTimingOptions","StreamingTimingState","stepStreamingTiming","generateId","getExternalStoreMessages","bindExternalStoreMessage","ExportedMessageRepositoryItem","ExportedMessageRepository","LocalRuntimeOptionsBase","ExternalStoreAdapter","ExternalStoreMessageConverter","ExternalStoreThreadListAdapter","ExternalStoreThreadData","ExternalStoreBranchChange","ExternalStoreSharedOptions","pickExternalStoreSharedOptions","ExternalThreadQueueAdapter","ExternalThreadBranchAdapter","createMessageQueue","MessageQueueDriver","MessageQueueController","RemoteThreadListAdapter","RemoteThreadListOptions","RemoteThreadInitializeResponse","RemoteThreadMetadata","RemoteThreadListResponse","RemoteThreadListPageOptions","InMemoryThreadListAdapter","createRequestHeaders"],"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 PartProviderMetadata,\n SourceProviderMetadata,\n SourceMessagePart,\n ImageMessagePart,\n FileMessagePart,\n DataMessagePart,\n GenerativeUIMessagePart,\n GenerativeUINode,\n GenerativeUISpec,\n Unstable_AudioMessagePart,\n ToolApprovalOption,\n ToolApprovalOptionKind,\n ToolApprovalResponse,\n ToolCallMessagePart,\n ToolCallTiming,\n ToolCallMessagePartMcpMetadata,\n McpAppMetadata,\n ToolModelContentPart,\n ThreadUserMessagePart,\n ThreadAssistantMessagePart,\n // Message status\n MessagePartStatus,\n MessagePartStreamStatus,\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 {\n unstable_getInteractableSnapshots,\n unstable_formatInteractableSnapshot,\n unstable_getInteractableVersions,\n type Unstable_InteractableSnapshotEntry,\n type Unstable_InteractableVersion,\n} from \"./model-context/interactable-composer-metadata\";\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 {\n SuggestionAdapter,\n SuggestionAdapterGenerateOptions,\n CreateSuggestionAdapterOptions,\n} from \"./adapters/suggestion\";\nexport { createSuggestionAdapter } 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 ErrorSeverity,\n ErrorDisplay,\n AssistantErrorCode,\n AssistantError,\n} from \"./types/error\";\nexport { toAssistantError, isAssistantError } from \"./types/error\";\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\";\nexport { fromThreadMessageLike } from \"./runtime/utils/thread-message-like\";\n\n// Streaming timing (client-side)\nexport type {\n StreamingTimingAccessors,\n StreamingTimingOptions,\n StreamingTimingState,\n} from \"./runtime/utils/streaming-timing\";\nexport { stepStreamingTiming } from \"./runtime/utils/streaming-timing\";\n\n// ID generation\nexport { generateId } from \"./utils/id\";\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 ExternalStoreBranchChange,\n} from \"./runtimes/external-store/external-store-adapter\";\nexport type { ExternalStoreSharedOptions } from \"./runtimes/external-store/external-store-shared-options\";\nexport { pickExternalStoreSharedOptions } from \"./runtimes/external-store/external-store-shared-options\";\n\n// Message queue\nexport type { ExternalThreadQueueAdapter } from \"./runtime/queue/external-thread-queue-adapter\";\nexport type { ExternalThreadBranchAdapter } from \"./runtime/branch/external-thread-branch-adapter\";\nexport {\n createMessageQueue,\n type MessageQueueDriver,\n type MessageQueueController,\n} from \"./runtime/queue/message-queue\";\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,IAAIC,QAAQC,IAAIC,aAAa,cAC3BH,mBAAmB"}
@@ -7,12 +7,16 @@ import { ToolInvocationTracker } from "./runtimes/tool-invocations/ToolInvocatio
7
7
  import { BaseSubject, BaseSubscribable, EventSubscribable, EventSubscriptionSubject, LazyMemoizeSubject, NestedSubscribable, NestedSubscriptionSubject, SKIP_UPDATE, ShallowMemoizeSubject, Subscribable, SubscribableWithState } from "./subscribable/subscribable.js";
8
8
  import { generateErrorMessageId, generateId, isErrorMessageId } from "./utils/id.js";
9
9
  import { getThreadMessageText } from "./utils/text.js";
10
+ import { ComposerRuntimeCoreBinding, EditComposerRuntimeCoreBinding, MessageStateBinding, ThreadComposerRuntimeCoreBinding } from "./runtime/api/bindings.js";
11
+ import { AttachmentRuntimeImpl, EditComposerAttachmentRuntimeImpl, MessageAttachmentRuntimeImpl, ThreadComposerAttachmentRuntimeImpl } from "./runtime/api/attachment-runtime.js";
12
+ import { ComposerRuntimeImpl, EditComposerRuntimeImpl, ThreadComposerRuntimeImpl } from "./runtime/api/composer-runtime.js";
13
+ import { MessagePartRuntimeImpl } from "./runtime/api/message-part-runtime.js";
14
+ import { MessageRuntimeImpl, toMessagePartStatus } from "./runtime/api/message-runtime.js";
10
15
  import { resolveToolApprovalResponse } from "./runtime/utils/resolveToolApprovalResponse.js";
11
16
  import { CompositeContextProvider } from "./utils/composite-context-provider.js";
12
17
  import { stableStringifyToolArgs, trackToolArgsKeyOrder } from "./utils/json/stable-stringify-tool-args.js";
13
18
  import { isJSONValue, isRecord } from "./utils/json/is-json.js";
14
19
  import { httpUrlPattern, parseDataUrl } from "./utils/data-url.js";
15
- import { ComposerRuntimeCoreBinding, EditComposerRuntimeCoreBinding, MessageStateBinding, ThreadComposerRuntimeCoreBinding } from "./runtime/api/bindings.js";
16
20
  import { BaseAssistantRuntimeCore } from "./runtime/base/base-assistant-runtime-core.js";
17
21
  import { BaseComposerRuntimeCore } from "./runtime/base/base-composer-runtime-core.js";
18
22
  import { DefaultThreadComposerRuntimeCore } from "./runtime/base/default-thread-composer-runtime-core.js";
@@ -20,10 +24,6 @@ import { DefaultEditComposerRuntimeCore } from "./runtime/base/default-edit-comp
20
24
  import { BaseThreadRuntimeCore } from "./runtime/base/base-thread-runtime-core.js";
21
25
  import { ThreadListItemRuntimeImpl, ThreadListItemStateBinding } from "./runtime/api/thread-list-item-runtime.js";
22
26
  import { ThreadListRuntimeCoreBinding, ThreadListRuntimeImpl } from "./runtime/api/thread-list-runtime.js";
23
- import { AttachmentRuntimeImpl, EditComposerAttachmentRuntimeImpl, MessageAttachmentRuntimeImpl, ThreadComposerAttachmentRuntimeImpl } from "./runtime/api/attachment-runtime.js";
24
- import { ComposerRuntimeImpl, EditComposerRuntimeImpl, ThreadComposerRuntimeImpl } from "./runtime/api/composer-runtime.js";
25
- import { MessagePartRuntimeImpl } from "./runtime/api/message-part-runtime.js";
26
- import { MessageRuntimeImpl } from "./runtime/api/message-runtime.js";
27
27
  import { symbolInnerMessage } from "./runtime/utils/external-store-message.js";
28
28
  import { getAutoStatus, isAutoStatus } from "./runtime/utils/auto-status.js";
29
29
  import "./runtime/internal.js";
@@ -44,4 +44,4 @@ import { RemoteThreadData, RemoteThreadState, THREAD_MAPPING_ID, createThreadMap
44
44
  import "./runtimes/internal.js";
45
45
  import { ThreadListItemRuntimeBinding, ThreadRuntimeCoreBinding, ThreadRuntimeImpl, getThreadState } from "./runtime/api/thread-runtime.js";
46
46
  import { AssistantRuntimeImpl } from "./runtime/api/assistant-runtime.js";
47
- export { AssistantRuntimeImpl, AttachmentRuntimeImpl, BaseAssistantRuntimeCore, BaseComposerRuntimeCore, BaseSubject, BaseSubscribable, BaseThreadRuntimeCore, type ComposerRuntimeCoreBinding, ComposerRuntimeImpl, CompositeContextProvider, type ConverterCallback, DefaultEditComposerRuntimeCore, DefaultThreadComposerRuntimeCore, EMPTY_THREAD_CORE, EditComposerAttachmentRuntimeImpl, type EditComposerRuntimeCoreBinding, EditComposerRuntimeImpl, type EventSubscribable, EventSubscriptionSubject, ExportedMessageRepository, type ExportedMessageRepositoryItem, ExternalStoreRuntimeCore, type ExternalStoreThreadFactory, ExternalStoreThreadListRuntimeCore, ExternalStoreThreadRuntimeCore, LazyMemoizeSubject, LocalRuntimeCore, type LocalRuntimeOptionsBase, type LocalThreadFactory, LocalThreadListRuntimeCore, LocalThreadRuntimeCore, MessageAttachmentRuntimeImpl, MessagePartRuntimeImpl, MessageRepository, MessageRuntimeImpl, type MessageStateBinding, type NestedSubscribable, NestedSubscriptionSubject, OptimisticState, ReadonlyThreadRuntimeCore, type RemoteThreadData, type RemoteThreadInitializeResponse, type RemoteThreadListOptions, type RemoteThreadState, SKIP_UPDATE, type SKIP_UPDATE as SKIP_UPDATE_TYPE, ShallowMemoizeSubject, type Subscribable, type SubscribableWithState, type THREAD_MAPPING_ID, ThreadComposerAttachmentRuntimeImpl, type ThreadComposerRuntimeCoreBinding, ThreadComposerRuntimeImpl, type ThreadListItemRuntimeBinding, ThreadListItemRuntimeImpl, type ThreadListItemStateBinding, type ThreadListRuntimeCoreBinding, ThreadListRuntimeImpl, ThreadMessageConverter, type ThreadRuntimeCoreBinding, ThreadRuntimeImpl, ToolInvocationTracker, consumeSuggestionResult, createThreadMappingId, fileMatchesAccept, fromThreadMessageLike, generateErrorMessageId, generateId, getAutoStatus, getFileDataURL, getThreadData, getThreadMessageText, getThreadState, hasUpcomingMessage, httpUrlPattern, isAutoStatus, isCreateAttachment, isErrorMessageId, isJSONValue, isRecord, parseDataUrl, resolveToolApprovalResponse, shouldContinue, stableStringifyToolArgs, symbolInnerMessage, trackToolArgsKeyOrder, updateStatusReducer };
47
+ export { AssistantRuntimeImpl, AttachmentRuntimeImpl, BaseAssistantRuntimeCore, BaseComposerRuntimeCore, BaseSubject, BaseSubscribable, BaseThreadRuntimeCore, type ComposerRuntimeCoreBinding, ComposerRuntimeImpl, CompositeContextProvider, type ConverterCallback, DefaultEditComposerRuntimeCore, DefaultThreadComposerRuntimeCore, EMPTY_THREAD_CORE, EditComposerAttachmentRuntimeImpl, type EditComposerRuntimeCoreBinding, EditComposerRuntimeImpl, type EventSubscribable, EventSubscriptionSubject, ExportedMessageRepository, type ExportedMessageRepositoryItem, ExternalStoreRuntimeCore, type ExternalStoreThreadFactory, ExternalStoreThreadListRuntimeCore, ExternalStoreThreadRuntimeCore, LazyMemoizeSubject, LocalRuntimeCore, type LocalRuntimeOptionsBase, type LocalThreadFactory, LocalThreadListRuntimeCore, LocalThreadRuntimeCore, MessageAttachmentRuntimeImpl, MessagePartRuntimeImpl, MessageRepository, MessageRuntimeImpl, type MessageStateBinding, type NestedSubscribable, NestedSubscriptionSubject, OptimisticState, ReadonlyThreadRuntimeCore, type RemoteThreadData, type RemoteThreadInitializeResponse, type RemoteThreadListOptions, type RemoteThreadState, SKIP_UPDATE, type SKIP_UPDATE as SKIP_UPDATE_TYPE, ShallowMemoizeSubject, type Subscribable, type SubscribableWithState, type THREAD_MAPPING_ID, ThreadComposerAttachmentRuntimeImpl, type ThreadComposerRuntimeCoreBinding, ThreadComposerRuntimeImpl, type ThreadListItemRuntimeBinding, ThreadListItemRuntimeImpl, type ThreadListItemStateBinding, type ThreadListRuntimeCoreBinding, ThreadListRuntimeImpl, ThreadMessageConverter, type ThreadRuntimeCoreBinding, ThreadRuntimeImpl, ToolInvocationTracker, consumeSuggestionResult, createThreadMappingId, fileMatchesAccept, fromThreadMessageLike, generateErrorMessageId, generateId, getAutoStatus, getFileDataURL, getThreadData, getThreadMessageText, getThreadState, hasUpcomingMessage, httpUrlPattern, isAutoStatus, isCreateAttachment, isErrorMessageId, isJSONValue, isRecord, parseDataUrl, resolveToolApprovalResponse, shouldContinue, stableStringifyToolArgs, symbolInnerMessage, toMessagePartStatus, trackToolArgsKeyOrder, updateStatusReducer };
package/dist/internal.js CHANGED
@@ -8,7 +8,11 @@ import { symbolInnerMessage } from "./runtime/utils/external-store-message.js";
8
8
  import { getAutoStatus, isAutoStatus } from "./runtime/utils/auto-status.js";
9
9
  import { ExportedMessageRepository, MessageRepository } from "./runtime/utils/message-repository.js";
10
10
  import { BaseSubject, BaseSubscribable, EventSubscriptionSubject, LazyMemoizeSubject, NestedSubscriptionSubject, SKIP_UPDATE, ShallowMemoizeSubject } from "./subscribable/subscribable.js";
11
+ import { AttachmentRuntimeImpl, EditComposerAttachmentRuntimeImpl, MessageAttachmentRuntimeImpl, ThreadComposerAttachmentRuntimeImpl } from "./runtime/api/attachment-runtime.js";
12
+ import { ComposerRuntimeImpl, EditComposerRuntimeImpl, ThreadComposerRuntimeImpl } from "./runtime/api/composer-runtime.js";
11
13
  import { resolveToolApprovalResponse } from "./runtime/utils/resolveToolApprovalResponse.js";
14
+ import { MessagePartRuntimeImpl } from "./runtime/api/message-part-runtime.js";
15
+ import { MessageRuntimeImpl, toMessagePartStatus } from "./runtime/api/message-runtime.js";
12
16
  import { CompositeContextProvider } from "./utils/composite-context-provider.js";
13
17
  import { isCreateAttachment } from "./types/attachment.js";
14
18
  import { stableStringifyToolArgs, trackToolArgsKeyOrder } from "./utils/json/stable-stringify-tool-args.js";
@@ -19,10 +23,6 @@ import { DefaultThreadComposerRuntimeCore } from "./runtime/base/default-thread-
19
23
  import { DefaultEditComposerRuntimeCore } from "./runtime/base/default-edit-composer-runtime-core.js";
20
24
  import { BaseThreadRuntimeCore } from "./runtime/base/base-thread-runtime-core.js";
21
25
  import { ThreadListItemRuntimeImpl } from "./runtime/api/thread-list-item-runtime.js";
22
- import { AttachmentRuntimeImpl, EditComposerAttachmentRuntimeImpl, MessageAttachmentRuntimeImpl, ThreadComposerAttachmentRuntimeImpl } from "./runtime/api/attachment-runtime.js";
23
- import { ComposerRuntimeImpl, EditComposerRuntimeImpl, ThreadComposerRuntimeImpl } from "./runtime/api/composer-runtime.js";
24
- import { MessagePartRuntimeImpl } from "./runtime/api/message-part-runtime.js";
25
- import { MessageRuntimeImpl } from "./runtime/api/message-runtime.js";
26
26
  import { ThreadRuntimeImpl, getThreadState } from "./runtime/api/thread-runtime.js";
27
27
  import { ThreadListRuntimeImpl } from "./runtime/api/thread-list-runtime.js";
28
28
  import { AssistantRuntimeImpl } from "./runtime/api/assistant-runtime.js";
@@ -39,4 +39,4 @@ import { ReadonlyThreadRuntimeCore } from "./runtimes/readonly/ReadonlyThreadRun
39
39
  import { OptimisticState } from "./runtimes/remote-thread-list/optimistic-state.js";
40
40
  import { EMPTY_THREAD_CORE } from "./runtimes/remote-thread-list/empty-thread-core.js";
41
41
  import { createThreadMappingId, getThreadData, updateStatusReducer } from "./runtimes/remote-thread-list/remote-thread-state.js";
42
- export { AssistantRuntimeImpl, AttachmentRuntimeImpl, BaseAssistantRuntimeCore, BaseComposerRuntimeCore, BaseSubject, BaseSubscribable, BaseThreadRuntimeCore, ComposerRuntimeImpl, CompositeContextProvider, DefaultEditComposerRuntimeCore, DefaultThreadComposerRuntimeCore, EMPTY_THREAD_CORE, EditComposerAttachmentRuntimeImpl, EditComposerRuntimeImpl, EventSubscriptionSubject, ExportedMessageRepository, ExternalStoreRuntimeCore, ExternalStoreThreadListRuntimeCore, ExternalStoreThreadRuntimeCore, LazyMemoizeSubject, LocalRuntimeCore, LocalThreadListRuntimeCore, LocalThreadRuntimeCore, MessageAttachmentRuntimeImpl, MessagePartRuntimeImpl, MessageRepository, MessageRuntimeImpl, NestedSubscriptionSubject, OptimisticState, ReadonlyThreadRuntimeCore, SKIP_UPDATE, ShallowMemoizeSubject, ThreadComposerAttachmentRuntimeImpl, ThreadComposerRuntimeImpl, ThreadListItemRuntimeImpl, ThreadListRuntimeImpl, ThreadMessageConverter, ThreadRuntimeImpl, ToolInvocationTracker, consumeSuggestionResult, createThreadMappingId, fileMatchesAccept, fromThreadMessageLike, generateErrorMessageId, generateId, getAutoStatus, getFileDataURL, getThreadData, getThreadMessageText, getThreadState, hasUpcomingMessage, httpUrlPattern, isAutoStatus, isCreateAttachment, isErrorMessageId, isJSONValue, isRecord, parseDataUrl, resolveToolApprovalResponse, shouldContinue, stableStringifyToolArgs, symbolInnerMessage, trackToolArgsKeyOrder, updateStatusReducer };
42
+ export { AssistantRuntimeImpl, AttachmentRuntimeImpl, BaseAssistantRuntimeCore, BaseComposerRuntimeCore, BaseSubject, BaseSubscribable, BaseThreadRuntimeCore, ComposerRuntimeImpl, CompositeContextProvider, DefaultEditComposerRuntimeCore, DefaultThreadComposerRuntimeCore, EMPTY_THREAD_CORE, EditComposerAttachmentRuntimeImpl, EditComposerRuntimeImpl, EventSubscriptionSubject, ExportedMessageRepository, ExternalStoreRuntimeCore, ExternalStoreThreadListRuntimeCore, ExternalStoreThreadRuntimeCore, LazyMemoizeSubject, LocalRuntimeCore, LocalThreadListRuntimeCore, LocalThreadRuntimeCore, MessageAttachmentRuntimeImpl, MessagePartRuntimeImpl, MessageRepository, MessageRuntimeImpl, NestedSubscriptionSubject, OptimisticState, ReadonlyThreadRuntimeCore, SKIP_UPDATE, ShallowMemoizeSubject, ThreadComposerAttachmentRuntimeImpl, ThreadComposerRuntimeImpl, ThreadListItemRuntimeImpl, ThreadListRuntimeImpl, ThreadMessageConverter, ThreadRuntimeImpl, ToolInvocationTracker, consumeSuggestionResult, createThreadMappingId, fileMatchesAccept, fromThreadMessageLike, generateErrorMessageId, generateId, getAutoStatus, getFileDataURL, getThreadData, getThreadMessageText, getThreadState, hasUpcomingMessage, httpUrlPattern, isAutoStatus, isCreateAttachment, isErrorMessageId, isJSONValue, isRecord, parseDataUrl, resolveToolApprovalResponse, shouldContinue, stableStringifyToolArgs, symbolInnerMessage, toMessagePartStatus, trackToolArgsKeyOrder, updateStatusReducer };
@@ -1,9 +1,9 @@
1
1
  import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
2
- import "@assistant-ui/tap/react-shim";
2
+ import { useEffect, useRef } from "@assistant-ui/tap/react-shim";
3
3
  import { useAui, useAuiState } from "@assistant-ui/store";
4
4
  //#region src/react/primitive-hooks/useActionBarCopy.ts
5
5
  const useActionBarCopy = (t0) => {
6
- const $ = c(12);
6
+ const $ = c(15);
7
7
  let t1;
8
8
  if ($[0] !== t0) {
9
9
  t1 = t0 === void 0 ? {} : t0;
@@ -17,39 +17,66 @@ const useActionBarCopy = (t0) => {
17
17
  const isCopied = useAuiState(_temp3);
18
18
  const isEditing = useAuiState(_temp4);
19
19
  const composerValue = useAuiState(_temp5);
20
+ const copiedTimerRef = useRef(void 0);
21
+ const scopeGenerationRef = useRef(0);
20
22
  let t3;
21
- if ($[2] !== aui || $[3] !== composerValue || $[4] !== copiedDuration || $[5] !== copyToClipboard || $[6] !== isEditing) {
22
- t3 = () => {
23
+ let t4;
24
+ if ($[2] !== aui) {
25
+ t3 = () => () => {
26
+ scopeGenerationRef.current = scopeGenerationRef.current + 1;
27
+ if (copiedTimerRef.current === void 0) return;
28
+ clearTimeout(copiedTimerRef.current);
29
+ copiedTimerRef.current = void 0;
30
+ aui.message.setIsCopied(false);
31
+ };
32
+ t4 = [aui];
33
+ $[2] = aui;
34
+ $[3] = t3;
35
+ $[4] = t4;
36
+ } else {
37
+ t3 = $[3];
38
+ t4 = $[4];
39
+ }
40
+ useEffect(t3, t4);
41
+ let t5;
42
+ if ($[5] !== aui || $[6] !== composerValue || $[7] !== copiedDuration || $[8] !== copyToClipboard || $[9] !== isEditing) {
43
+ t5 = () => {
23
44
  if (!copyToClipboard) return;
24
45
  const valueToCopy = isEditing ? composerValue : aui.message.getCopyText();
25
46
  if (!valueToCopy) return;
47
+ const scopeGeneration = scopeGenerationRef.current;
26
48
  Promise.resolve(copyToClipboard(valueToCopy)).then(() => {
49
+ if (scopeGeneration !== scopeGenerationRef.current) return;
50
+ if (copiedTimerRef.current !== void 0) clearTimeout(copiedTimerRef.current);
27
51
  aui.message.setIsCopied(true);
28
- setTimeout(() => aui.message.setIsCopied(false), copiedDuration);
52
+ copiedTimerRef.current = setTimeout(() => {
53
+ copiedTimerRef.current = void 0;
54
+ aui.message.setIsCopied(false);
55
+ }, copiedDuration);
29
56
  }, _temp6);
30
57
  };
31
- $[2] = aui;
32
- $[3] = composerValue;
33
- $[4] = copiedDuration;
34
- $[5] = copyToClipboard;
35
- $[6] = isEditing;
36
- $[7] = t3;
37
- } else t3 = $[7];
38
- const copy = t3;
39
- const t4 = disabled || !copyToClipboard;
40
- let t5;
41
- if ($[8] !== copy || $[9] !== isCopied || $[10] !== t4) {
42
- t5 = {
58
+ $[5] = aui;
59
+ $[6] = composerValue;
60
+ $[7] = copiedDuration;
61
+ $[8] = copyToClipboard;
62
+ $[9] = isEditing;
63
+ $[10] = t5;
64
+ } else t5 = $[10];
65
+ const copy = t5;
66
+ const t6 = disabled || !copyToClipboard;
67
+ let t7;
68
+ if ($[11] !== copy || $[12] !== isCopied || $[13] !== t6) {
69
+ t7 = {
43
70
  copy,
44
- disabled: t4,
71
+ disabled: t6,
45
72
  isCopied
46
73
  };
47
- $[8] = copy;
48
- $[9] = isCopied;
49
- $[10] = t4;
50
- $[11] = t5;
51
- } else t5 = $[11];
52
- return t5;
74
+ $[11] = copy;
75
+ $[12] = isCopied;
76
+ $[13] = t6;
77
+ $[14] = t7;
78
+ } else t7 = $[14];
79
+ return t7;
53
80
  };
54
81
  function _temp(c) {
55
82
  return c.type === "text" && c.text.length > 0;
@@ -1 +1 @@
1
- {"version":3,"file":"useActionBarCopy.js","names":["useCallback","useAui","useAuiState","UseActionBarCopyOptions","copiedDuration","copyToClipboard","text","Promise","useActionBarCopy","t0","$","_c","t1","undefined","t2","aui","disabled","_temp2","isCopied","_temp3","isEditing","_temp4","composerValue","_temp5","t3","valueToCopy","message","getCopyText","resolve","then","setIsCopied","setTimeout","_temp6","copy","t4","t5","_temp","c","type","length","s","role","status","parts","some","s_0","s_1","composer","s_2"],"sources":["../../../src/react/primitive-hooks/useActionBarCopy.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\nexport type UseActionBarCopyOptions = {\n copiedDuration?: number | undefined;\n copyToClipboard?: ((text: string) => void | Promise<void>) | undefined;\n};\n\nexport const useActionBarCopy = ({\n copiedDuration = 3000,\n copyToClipboard,\n}: UseActionBarCopyOptions = {}) => {\n const aui = useAui();\n const disabled = useAuiState((s) => {\n return !(\n (s.message.role !== \"assistant\" ||\n s.message.status?.type !== \"running\") &&\n s.message.parts.some((c) => c.type === \"text\" && c.text.length > 0)\n );\n });\n const isCopied = useAuiState((s) => s.message.isCopied);\n const isEditing = useAuiState((s) => s.composer.isEditing);\n const composerValue = useAuiState((s) => s.composer.text);\n\n const copy = useCallback(() => {\n if (!copyToClipboard) return;\n\n const valueToCopy = isEditing ? composerValue : aui.message.getCopyText();\n if (!valueToCopy) return;\n\n // The rejection handler swallows clipboard write failures (permission denied,\n // API unavailable) so they don't surface as unhandled promise rejections.\n Promise.resolve(copyToClipboard(valueToCopy)).then(\n () => {\n aui.message.setIsCopied(true);\n setTimeout(() => aui.message.setIsCopied(false), copiedDuration);\n },\n () => {},\n );\n }, [aui, isEditing, composerValue, copiedDuration, copyToClipboard]);\n\n return { copy, disabled: disabled || !copyToClipboard, isCopied };\n};\n"],"mappings":";;;;AAQA,MAAaQ,oBAAmBC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAD,IAAA;EAACG,KAAAH,OAAAI,KAAAA,IAAA,CAGH,IAHGJ;EAGFC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAHE,MAAA,EAAAN,gBAAAU,IAAAT,oBAAAO;CAC/B,MAAAR,iBAAAU,OAAAD,KAAAA,IAAA,MAAAC;CAGA,MAAAC,MAAYd,OAAO;CACnB,MAAAe,WAAiBd,YAAYe,MAM5B;CACD,MAAAC,WAAiBhB,YAAYiB,MAAyB;CACtD,MAAAC,YAAkBlB,YAAYmB,MAA2B;CACzD,MAAAC,gBAAsBpB,YAAYqB,MAAsB;CAAE,IAAAC;CAAA,IAAAd,EAAA,OAAAK,OAAAL,EAAA,OAAAY,iBAAAZ,EAAA,OAAAN,kBAAAM,EAAA,OAAAL,mBAAAK,EAAA,OAAAU,WAAA;EAEjCI,WAAA;GACvB,IAAI,CAACnB,iBAAe;GAEpB,MAAAoB,cAAoBL,YAAAE,gBAA4BP,IAAGW,QAAQC,YAAa;GACxE,IAAI,CAACF,aAAW;GAIhBlB,QAAOqB,QAASvB,gBAAgBoB,WAAW,CAAC,CAAC,CAAAI,WAC3C;IACEd,IAAGW,QAAQI,YAAa,IAAI;IAC5BC,iBAAiBhB,IAAGW,QAAQI,YAAa,KAAK,GAAG1B,cAAc;GAAC,GAElE4B,MACF;EAAC;EACFtB,EAAA,KAAAK;EAAAL,EAAA,KAAAY;EAAAZ,EAAA,KAAAN;EAAAM,EAAA,KAAAL;EAAAK,EAAA,KAAAU;EAAAV,EAAA,KAAAc;CAAA,OAAAA,KAAAd,EAAA;CAfD,MAAAuB,OAAaT;CAiBY,MAAAU,KAAAlB,YAAA,CAAaX;CAAe,IAAA8B;CAAA,IAAAzB,EAAA,OAAAuB,QAAAvB,EAAA,OAAAQ,YAAAR,EAAA,QAAAwB,IAAA;EAA9CC,KAAA;GAAAF;GAAAjB,UAAkBkB;GAA4BhB;EAAW;EAACR,EAAA,KAAAuB;EAAAvB,EAAA,KAAAQ;EAAAR,EAAA,MAAAwB;EAAAxB,EAAA,MAAAyB;CAAA,OAAAA,KAAAzB,EAAA;CAAA,OAA1DyB;AAA0D;AAjCnC,SAAAC,MAAAC,GAAA;CAAA,OASEA,EAACC,SAAU,UAAUD,EAAC/B,KAAKiC,SAAU;AAAC;AATxC,SAAAtB,OAAAuB,GAAA;CAAA,OAMrB,GACJA,EAACd,QAAQe,SAAU,eAClBD,EAACd,QAAQgB,QAAaJ,SAAK,cAC7BE,EAACd,QAAQiB,MAAMC,KAAMR,KAA6C;AACnE;AAV2B,SAAAjB,OAAA0B,KAAA;CAAA,OAYML,IAACd,QAAQR;AAAS;AAZxB,SAAAG,OAAAyB,KAAA;CAAA,OAaON,IAACO,SAAS3B;AAAU;AAb3B,SAAAG,OAAAyB,KAAA;CAAA,OAcWR,IAACO,SAASzC;AAAK;AAd1B,SAAA0B,SAAA,CAAA"}
1
+ {"version":3,"file":"useActionBarCopy.js","names":["useCallback","useEffect","useRef","useAui","useAuiState","UseActionBarCopyOptions","copiedDuration","copyToClipboard","text","Promise","useActionBarCopy","t0","$","_c","t1","undefined","t2","aui","disabled","_temp2","isCopied","_temp3","isEditing","_temp4","composerValue","_temp5","copiedTimerRef","scopeGenerationRef","t3","t4","current","clearTimeout","message","setIsCopied","t5","valueToCopy","getCopyText","scopeGeneration","resolve","then","setTimeout","_temp6","copy","t6","t7","_temp","c","type","length","s","role","status","parts","some","s_0","s_1","composer","s_2"],"sources":["../../../src/react/primitive-hooks/useActionBarCopy.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\nexport type UseActionBarCopyOptions = {\n copiedDuration?: number | undefined;\n copyToClipboard?: ((text: string) => void | Promise<void>) | undefined;\n};\n\nexport const useActionBarCopy = ({\n copiedDuration = 3000,\n copyToClipboard,\n}: UseActionBarCopyOptions = {}) => {\n const aui = useAui();\n const disabled = useAuiState((s) => {\n return !(\n (s.message.role !== \"assistant\" ||\n s.message.status?.type !== \"running\") &&\n s.message.parts.some((c) => c.type === \"text\" && c.text.length > 0)\n );\n });\n const isCopied = useAuiState((s) => s.message.isCopied);\n const isEditing = useAuiState((s) => s.composer.isEditing);\n const composerValue = useAuiState((s) => s.composer.text);\n const copiedTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(\n undefined,\n );\n const scopeGenerationRef = useRef(0);\n\n useEffect(\n () => () => {\n scopeGenerationRef.current += 1;\n if (copiedTimerRef.current === undefined) return;\n\n clearTimeout(copiedTimerRef.current);\n copiedTimerRef.current = undefined;\n aui.message.setIsCopied(false);\n },\n [aui],\n );\n\n const copy = useCallback(() => {\n if (!copyToClipboard) return;\n\n const valueToCopy = isEditing ? composerValue : aui.message.getCopyText();\n if (!valueToCopy) return;\n const scopeGeneration = scopeGenerationRef.current;\n\n // The rejection handler swallows clipboard write failures (permission denied,\n // API unavailable) so they don't surface as unhandled promise rejections.\n Promise.resolve(copyToClipboard(valueToCopy)).then(\n () => {\n if (scopeGeneration !== scopeGenerationRef.current) return;\n\n if (copiedTimerRef.current !== undefined) {\n clearTimeout(copiedTimerRef.current);\n }\n aui.message.setIsCopied(true);\n copiedTimerRef.current = setTimeout(() => {\n copiedTimerRef.current = undefined;\n aui.message.setIsCopied(false);\n }, copiedDuration);\n },\n () => {},\n );\n }, [aui, isEditing, composerValue, copiedDuration, copyToClipboard]);\n\n return { copy, disabled: disabled || !copyToClipboard, isCopied };\n};\n"],"mappings":";;;;AAQA,MAAaU,oBAAmBC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAD,IAAA;EAACG,KAAAH,OAAAI,KAAAA,IAAA,CAGH,IAHGJ;EAGFC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAHE,MAAA,EAAAN,gBAAAU,IAAAT,oBAAAO;CAC/B,MAAAR,iBAAAU,OAAAD,KAAAA,IAAA,MAAAC;CAGA,MAAAC,MAAYd,OAAO;CACnB,MAAAe,WAAiBd,YAAYe,MAM5B;CACD,MAAAC,WAAiBhB,YAAYiB,MAAyB;CACtD,MAAAC,YAAkBlB,YAAYmB,MAA2B;CACzD,MAAAC,gBAAsBpB,YAAYqB,MAAsB;CACxD,MAAAC,iBAAuBxB,OACrBa,KAAAA,CACF;CACA,MAAAY,qBAA2BzB,OAAO,CAAC;CAAE,IAAA0B;CAAA,IAAAC;CAAA,IAAAjB,EAAA,OAAAK,KAAA;EAGnCW,iBAAM;GACJD,mBAAkBG,UAAlBH,mBAAkBG,UAAY;GAC9B,IAAIJ,eAAcI,YAAaf,KAAAA,GAAS;GAExCgB,aAAaL,eAAcI,OAAQ;GACnCJ,eAAcI,UAAWf,KAAAA;GACzBE,IAAGe,QAAQC,YAAa,KAAK;EAAC;EAEhCJ,KAAA,CAACZ,GAAG;EAACL,EAAA,KAAAK;EAAAL,EAAA,KAAAgB;EAAAhB,EAAA,KAAAiB;CAAA,OAAA;EAAAD,KAAAhB,EAAA;EAAAiB,KAAAjB,EAAA;CAAA;CATPX,UACE2B,IAQAC,EACF;CAAC,IAAAK;CAAA,IAAAtB,EAAA,OAAAK,OAAAL,EAAA,OAAAY,iBAAAZ,EAAA,OAAAN,kBAAAM,EAAA,OAAAL,mBAAAK,EAAA,OAAAU,WAAA;EAEwBY,WAAA;GACvB,IAAI,CAAC3B,iBAAe;GAEpB,MAAA4B,cAAoBb,YAAAE,gBAA4BP,IAAGe,QAAQI,YAAa;GACxE,IAAI,CAACD,aAAW;GAChB,MAAAE,kBAAwBV,mBAAkBG;GAI1CrB,QAAO6B,QAAS/B,gBAAgB4B,WAAW,CAAC,CAAC,CAAAI,WAC3C;IACE,IAAIF,oBAAoBV,mBAAkBG,SAAQ;IAElD,IAAIJ,eAAcI,YAAaf,KAAAA,GAC7BgB,aAAaL,eAAcI,OAAQ;IAErCb,IAAGe,QAAQC,YAAa,IAAI;IAC5BP,eAAcI,UAAWU,iBAAW;KAClCd,eAAcI,UAAWf,KAAAA;KACzBE,IAAGe,QAAQC,YAAa,KAAK;IAAC,GAC7B3B,cAAc;GAHK,GAKxBmC,MACF;EAAC;EACF7B,EAAA,KAAAK;EAAAL,EAAA,KAAAY;EAAAZ,EAAA,KAAAN;EAAAM,EAAA,KAAAL;EAAAK,EAAA,KAAAU;EAAAV,EAAA,MAAAsB;CAAA,OAAAA,KAAAtB,EAAA;CAxBD,MAAA8B,OAAaR;CA0BY,MAAAS,KAAAzB,YAAA,CAAaX;CAAe,IAAAqC;CAAA,IAAAhC,EAAA,QAAA8B,QAAA9B,EAAA,QAAAQ,YAAAR,EAAA,QAAA+B,IAAA;EAA9CC,KAAA;GAAAF;GAAAxB,UAAkByB;GAA4BvB;EAAW;EAACR,EAAA,MAAA8B;EAAA9B,EAAA,MAAAQ;EAAAR,EAAA,MAAA+B;EAAA/B,EAAA,MAAAgC;CAAA,OAAAA,KAAAhC,EAAA;CAAA,OAA1DgC;AAA0D;AA1DnC,SAAAC,MAAAC,GAAA;CAAA,OASEA,EAACC,SAAU,UAAUD,EAACtC,KAAKwC,SAAU;AAAC;AATxC,SAAA7B,OAAA8B,GAAA;CAAA,OAMrB,GACJA,EAACjB,QAAQkB,SAAU,eAClBD,EAACjB,QAAQmB,QAAaJ,SAAK,cAC7BE,EAACjB,QAAQoB,MAAMC,KAAMR,KAA6C;AACnE;AAV2B,SAAAxB,OAAAiC,KAAA;CAAA,OAYML,IAACjB,QAAQZ;AAAS;AAZxB,SAAAG,OAAAgC,KAAA;CAAA,OAaON,IAACO,SAASlC;AAAU;AAb3B,SAAAG,OAAAgC,KAAA;CAAA,OAcWR,IAACO,SAAShD;AAAK;AAd1B,SAAAiC,SAAA,CAAA"}
@@ -9,7 +9,8 @@ declare namespace MessagePrimitiveGroupedParts {
9
9
  * A coalesced group of adjacent parts. Surfaced through the same
10
10
  * `{ part }` channel as a leaf {@link EnrichedPartState} so consumers
11
11
  * dispatch on a single `switch (part.type)`. `type` is the group key
12
- * (always `"group-…"`); `status` mirrors the last contained part.
12
+ * (always `"group-…"`); `status` is running when any contained part runs,
13
+ * otherwise it mirrors the last contained part.
13
14
  */
14
15
  type GroupPart<TKey extends `group-${string}` = `group-${string}`> = {
15
16
  readonly type: TKey;
@@ -1 +1 @@
1
- {"version":3,"file":"MessageGroupedParts.d.ts","names":[],"sources":["../../../../src/react/primitives/message/MessageGroupedParts.tsx"],"mappings":";;;;;;kBAkBiB;;;;;;;OAOH,UAAU;aACX,MAAM;aACN,QAAQ,oBAAoB;aAC5B;;;;;;;;;;;;OAaC;aACD;;;;;;;;;;;;;OAcC;OAEA,WAAW;;;;;;;aAOZ,MAAM,UAAU,QAAQ,oBAAoB;;;;;;;aAO5C,UAAU;;OAGT,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA8BP,UACP,MAAM,WACN,SAAS,4BACG;;;;;;;;;aAUL,YAAY;;;;;;;;;;;;aAaZ,WAAW,MAAM,WAAW,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqHtC;GAAgC,kCAA8B,SAAA,WAAA,YAIxE,6BAA6B,MAAM,QAAQ"}
1
+ {"version":3,"file":"MessageGroupedParts.d.ts","names":[],"sources":["../../../../src/react/primitives/message/MessageGroupedParts.tsx"],"mappings":";;;;;;kBAmBiB;;;;;;;;OAQH,UAAU;aACX,MAAM;aACN,QAAQ,oBAAoB;aAC5B;;;;;;;;;;;;OAaC;aACD;;;;;;;;;;;;;OAcC;OAEA,WAAW;;;;;;;aAOZ,MAAM,UAAU,QAAQ,oBAAoB;;;;;;;aAO5C,UAAU;;OAGT,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA8BP,UACP,MAAM,WACN,SAAS,4BACG;;;;;;;;;aAUL,YAAY;;;;;;;;;;;;aAaZ,WAAW,MAAM,WAAW,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmHtC;GAAgC,kCAA8B,SAAA,WAAA,YAIxE,6BAA6B,MAAM,QAAQ"}
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { getGroupStatus } from "../../../utils/getGroupStatus.js";
2
3
  import { MessagePartChildren } from "./MessageParts.js";
3
4
  import { GROUPBY_MEMO_KEY, buildGroupTree } from "../../utils/groupParts.js";
4
5
  import { Fragment, useMemo } from "@assistant-ui/tap/react-shim";
@@ -6,7 +7,6 @@ import { useAuiState } from "@assistant-ui/store";
6
7
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
8
  import { useShallow } from "zustand/shallow";
8
9
  //#region src/react/primitives/message/MessageGroupedParts.tsx
9
- const COMPLETE_STATUS = Object.freeze({ type: "complete" });
10
10
  const shouldShowIndicator = (mode, parts, isRunning) => {
11
11
  if (!isRunning) return false;
12
12
  switch (mode) {
@@ -36,7 +36,7 @@ const renderNode = (node, parts, render) => {
36
36
  children: /* @__PURE__ */ jsx(PartChildrenSentinel, {})
37
37
  })
38
38
  }, node.idKey ? `part-${node.idKey}` : `part-${node.index}`);
39
- const status = parts[node.indices.at(-1)]?.status ?? COMPLETE_STATUS;
39
+ const status = getGroupStatus(parts, node.indices);
40
40
  return /* @__PURE__ */ jsx(Fragment, { children: render({
41
41
  part: {
42
42
  type: node.key,
@@ -1 +1 @@
1
- {"version":3,"file":"MessageGroupedParts.js","names":["Fragment","FC","ReactNode","useMemo","useAuiState","useShallow","PartState","MessagePartStatus","ToolCallMessagePartStatus","buildGroupTree","GROUPBY_MEMO_KEY","GroupByContext","GroupNode","MessagePartChildren","EnrichedPartState","MessagePrimitiveGroupedParts","GroupPart","type","TKey","status","indices","IndicatorPart","IndicatorMode","RenderInfo","part","children","Props","groupBy","context","indicator","info","COMPLETE_STATUS","Object","freeze","shouldShowIndicator","mode","parts","isRunning","length","last","undefined","PartChildrenSentinel","Error","renderNode","node","render","idKey","index","at","groupPart","key","nodeKey","map","child","s","message","toolUIs","tools","memoKey","memoDep","tree","toolCallId","displayName"],"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 GroupByContext,\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 /**\n * Synthetic trailing slot for a streaming/loading affordance (a\n * \"thinking…\" dot, etc.). Surfaced through the same `{ part }` channel\n * as groups and leaf parts so a single `switch (part.type)` renders it\n * via `case \"indicator\"`.\n *\n * It is only ever emitted while the message is running, so its presence\n * alone means \"render your loading UI here\" — there's no `status` to\n * branch on.\n */\n export type IndicatorPart = {\n readonly type: \"indicator\";\n };\n\n /**\n * When to emit the synthetic {@link IndicatorPart}. It is **only** emitted\n * while the message is running (streaming); the mode further restricts\n * which running states qualify:\n * - `\"never\"` — never.\n * - `\"empty\"` — only when the message has no parts yet.\n * - `\"no-text\"` (default) — when the message has no parts yet or the last\n * part isn't `text`/`reasoning` (e.g. it ended on a tool call, so the\n * assistant likely isn't done).\n * - `\"always\"` — whenever the message is running, regardless of parts.\n */\n export type IndicatorMode = \"never\" | \"empty\" | \"no-text\" | \"always\";\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`), a single enriched leaf part, or the synthetic\n * {@link IndicatorPart} (`type: \"indicator\"`). Use one switch over\n * `part.type` to handle all three.\n */\n readonly part: GroupPart<TKey> | EnrichedPartState | IndicatorPart;\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 * The second argument is a {@link GroupByContext} carrying the tool-UI\n * registry, for grouping that depends on it (e.g. standalone tool calls).\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: (\n part: PartState,\n context: GroupByContext,\n ) => readonly TKey[] | null;\n\n /**\n * Controls emission of the synthetic {@link IndicatorPart} — a\n * trailing `{ part: { type: \"indicator\", status } }` render call you\n * handle with `case \"indicator\"` to show loading/status UI.\n *\n * @default \"no-text\"\n * @see IndicatorMode\n */\n readonly indicator?: IndicatorMode;\n\n /**\n * Render function called once per group node, once per leaf part, and\n * (when the `indicator` condition is met) once for the trailing\n * {@link IndicatorPart}. Switch on `part.type`: `\"group-…\"` cases wrap\n * `children`; real part types (`\"text\"`, `\"tool-call\"`, …) render the\n * part directly; `\"indicator\"` renders status/loading UI.\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\nconst shouldShowIndicator = (\n mode: MessagePrimitiveGroupedParts.IndicatorMode,\n parts: readonly PartState[],\n isRunning: boolean,\n): boolean => {\n // The indicator is a streaming affordance — never show it on a settled\n // message, whatever the mode.\n if (!isRunning) return false;\n\n switch (mode) {\n case \"never\":\n return false;\n case \"always\":\n return true;\n case \"empty\":\n return parts.length === 0;\n case \"no-text\": {\n const last = parts[parts.length - 1];\n return (\n last === undefined ||\n (last.type !== \"text\" && last.type !== \"reasoning\")\n );\n }\n }\n};\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 part identity when available, else absolute part index — never\n // the structural nodeKey, which leaves zombie fiber subscriptions when\n // parts reshape (#4051).\n return (\n <MessagePartChildren\n key={node.idKey ? `part-${node.idKey}` : `part-${node.index}`}\n index={node.index}\n >\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.idKey ?? 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 * case \"indicator\": return <LoadingDots />;\n * default: return null;\n * }\n * }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const MessagePrimitiveGroupedParts = <TKey extends `group-${string}`>({\n groupBy,\n indicator = \"no-text\",\n children,\n}: MessagePrimitiveGroupedParts.Props<TKey>): ReactNode => {\n const parts = useAuiState(useShallow((s) => s.message.parts));\n // Handed to `groupBy` as its `context` argument (see GroupByContext).\n const toolUIs = useAuiState((s) => s.tools.toolUIs);\n // Subscribe to a boolean, not the status object: the tree only needs to\n // re-render when running-ness flips, and `\"never\"` opts out entirely.\n const isRunning = useAuiState((s) =>\n indicator === \"never\" ? false : s.message.status?.type === \"running\",\n );\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 const context: GroupByContext = { toolUIs };\n return buildGroupTree(\n parts.map((part) => groupBy(part, context) ?? []),\n parts.map((part) =>\n part.type === \"tool-call\" ? part.toolCallId : undefined,\n ),\n );\n // oxlint-disable-next-line react/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, toolUIs]);\n\n return (\n <>\n {tree.map((node) => renderNode(node, parts, children))}\n {shouldShowIndicator(indicator, parts, isRunning) &&\n children({\n part: { type: \"indicator\" },\n children: <PartChildrenSentinel />,\n })}\n </>\n );\n};\n\nMessagePrimitiveGroupedParts.displayName = \"MessagePrimitive.GroupedParts\";\n"],"mappings":";;;;;;;;AAuIA,MAAM+B,kBAAqCC,OAAOC,OAAO,EAAEhB,MAAM,WAAW,CAAC;AAE7E,MAAMiB,uBACJC,MACAC,OACAC,cACY;CAGZ,IAAI,CAACA,WAAW,OAAO;CAEvB,QAAQF,MAAR;EACE,KAAK,SACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,SACH,OAAOC,MAAME,WAAW;EAC1B,KAAK,WAAW;GACd,MAAMC,OAAOH,MAAMA,MAAME,SAAS;GAClC,OACEC,SAASC,KAAAA,KACRD,KAAKtB,SAAS,UAAUsB,KAAKtB,SAAS;EAE3C;CACF;AACF;;;;;;;AAQA,MAAMwB,6BAAiC;CACrC,MAAM,IAAIC,MACR,8LAGF;AACF;AAEA,MAAMC,cACJC,MACAR,OACAS,WACc;CACd,IAAID,KAAK3B,SAAS,QAIhB,OACE,oBAAC,qBAAD;EAEE,OAAO2B,KAAKG;EAEV,WAAA,EAAEvB,WAAWqB,OAAO;GAAErB;GAAMC,UAAU,oBAAC,sBAAD,CAAqB,CAAA;EAAI,CAAC;CAC/C,GAJdmB,KAAKE,QAAQ,QAAQF,KAAKE,UAAU,QAAQF,KAAKG,OAInC;CAIzB,MAAM5B,SAASiB,MAAMQ,KAAKxB,QAAQ4B,GAAG,EAAE,EAAG,EAAE7B,UAAUY;CAOtD,OACE,oBAAC,UAAD,EAAA,UACGc,OAAO;EACNrB,MAAMyB;GARVhC,MAAM2B,KAAKM;GACX/B;GACAC,SAASwB,KAAKxB;EAMJ6B;EACNxB,UACE,oBAAA,YAAA,EAAA,UAAGmB,KAAKnB,SAAS2B,KAAKC,UAAUV,WAAWU,OAAOjB,OAAOS,MAAM,CAAC,EAAE,CAAA;CAEtE,CAAC,EACO,GAPKD,KAAKE,SAASF,KAAKO,OAOxB;AAEd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAapC,gCAAgE,EAC3EY,SACAE,YAAY,WACZJ,eACyD;CACzD,MAAMW,QAAQhC,YAAYC,YAAYiD,MAAMA,EAAEC,QAAQnB,KAAK,CAAC;CAE5D,MAAMoB,UAAUpD,aAAakD,QAAMA,IAAEG,MAAMD,OAAO;CAGlD,MAAMnB,YAAYjC,aAAakD,QAC7BzB,cAAc,UAAU,QAAQyB,IAAEC,QAAQpC,QAAQF,SAAS,SAC7D;CAsBA,OACE,qBAAA,YAAA,EAAA,UAAA,CAZWd,cAAc;EACzB,MAAMyB,UAA0B,EAAE4B,QAAQ;EAC1C,OAAO/C,eACL2B,MAAMgB,KAAK5B,SAASG,QAAQH,MAAMI,OAAO,KAAK,CAAA,CAAE,GAChDQ,MAAMgB,KAAK5B,WACTA,OAAKP,SAAS,cAAcO,OAAKqC,aAAarB,KAAAA,CAChD,CACF;CAEF,GAAG;EAACJ;EAbaT,QACfjB,qBAEyBiB;EAUP6B;CAAO,CAItBI,CAAI,CAACR,KAAKR,SAASD,WAAWC,MAAMR,OAAOX,QAAQ,CAAC,GACpDS,oBAAoBL,WAAWO,OAAOC,SAAS,KAC9CZ,SAAS;EACPD,MAAM,EAAEP,MAAM,YAAY;EAC1BQ,UAAU,oBAAC,sBAAD,CAAqB,CAAA;CACjC,CAAC,CACL,EAAA,CAAA;AAEJ;AAEAV,6BAA6B+C,cAAc"}
1
+ {"version":3,"file":"MessageGroupedParts.js","names":["Fragment","FC","ReactNode","useMemo","useAuiState","useShallow","PartState","MessagePartStatus","ToolCallMessagePartStatus","getGroupStatus","buildGroupTree","GROUPBY_MEMO_KEY","GroupByContext","GroupNode","MessagePartChildren","EnrichedPartState","MessagePrimitiveGroupedParts","GroupPart","type","TKey","status","indices","IndicatorPart","IndicatorMode","RenderInfo","part","children","Props","groupBy","context","indicator","info","shouldShowIndicator","mode","parts","isRunning","length","last","undefined","PartChildrenSentinel","Error","renderNode","node","render","idKey","index","groupPart","key","nodeKey","map","child","s","message","toolUIs","tools","memoKey","memoDep","tree","toolCallId","displayName"],"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 { getGroupStatus } from \"../../../utils/getGroupStatus\";\nimport {\n buildGroupTree,\n GROUPBY_MEMO_KEY,\n type GroupByContext,\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` is running when any contained part runs,\n * otherwise it 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 /**\n * Synthetic trailing slot for a streaming/loading affordance (a\n * \"thinking…\" dot, etc.). Surfaced through the same `{ part }` channel\n * as groups and leaf parts so a single `switch (part.type)` renders it\n * via `case \"indicator\"`.\n *\n * It is only ever emitted while the message is running, so its presence\n * alone means \"render your loading UI here\" — there's no `status` to\n * branch on.\n */\n export type IndicatorPart = {\n readonly type: \"indicator\";\n };\n\n /**\n * When to emit the synthetic {@link IndicatorPart}. It is **only** emitted\n * while the message is running (streaming); the mode further restricts\n * which running states qualify:\n * - `\"never\"` — never.\n * - `\"empty\"` — only when the message has no parts yet.\n * - `\"no-text\"` (default) — when the message has no parts yet or the last\n * part isn't `text`/`reasoning` (e.g. it ended on a tool call, so the\n * assistant likely isn't done).\n * - `\"always\"` — whenever the message is running, regardless of parts.\n */\n export type IndicatorMode = \"never\" | \"empty\" | \"no-text\" | \"always\";\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`), a single enriched leaf part, or the synthetic\n * {@link IndicatorPart} (`type: \"indicator\"`). Use one switch over\n * `part.type` to handle all three.\n */\n readonly part: GroupPart<TKey> | EnrichedPartState | IndicatorPart;\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 * The second argument is a {@link GroupByContext} carrying the tool-UI\n * registry, for grouping that depends on it (e.g. standalone tool calls).\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: (\n part: PartState,\n context: GroupByContext,\n ) => readonly TKey[] | null;\n\n /**\n * Controls emission of the synthetic {@link IndicatorPart} — a\n * trailing `{ part: { type: \"indicator\", status } }` render call you\n * handle with `case \"indicator\"` to show loading/status UI.\n *\n * @default \"no-text\"\n * @see IndicatorMode\n */\n readonly indicator?: IndicatorMode;\n\n /**\n * Render function called once per group node, once per leaf part, and\n * (when the `indicator` condition is met) once for the trailing\n * {@link IndicatorPart}. Switch on `part.type`: `\"group-…\"` cases wrap\n * `children`; real part types (`\"text\"`, `\"tool-call\"`, …) render the\n * part directly; `\"indicator\"` renders status/loading UI.\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 shouldShowIndicator = (\n mode: MessagePrimitiveGroupedParts.IndicatorMode,\n parts: readonly PartState[],\n isRunning: boolean,\n): boolean => {\n // The indicator is a streaming affordance — never show it on a settled\n // message, whatever the mode.\n if (!isRunning) return false;\n\n switch (mode) {\n case \"never\":\n return false;\n case \"always\":\n return true;\n case \"empty\":\n return parts.length === 0;\n case \"no-text\": {\n const last = parts[parts.length - 1];\n return (\n last === undefined ||\n (last.type !== \"text\" && last.type !== \"reasoning\")\n );\n }\n }\n};\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 part identity when available, else absolute part index — never\n // the structural nodeKey, which leaves zombie fiber subscriptions when\n // parts reshape (#4051).\n return (\n <MessagePartChildren\n key={node.idKey ? `part-${node.idKey}` : `part-${node.index}`}\n index={node.index}\n >\n {({ part }) => render({ part, children: <PartChildrenSentinel /> })}\n </MessagePartChildren>\n );\n }\n\n const status = getGroupStatus(parts, node.indices);\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.idKey ?? 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 * case \"indicator\": return <LoadingDots />;\n * default: return null;\n * }\n * }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const MessagePrimitiveGroupedParts = <TKey extends `group-${string}`>({\n groupBy,\n indicator = \"no-text\",\n children,\n}: MessagePrimitiveGroupedParts.Props<TKey>): ReactNode => {\n const parts = useAuiState(useShallow((s) => s.message.parts));\n // Handed to `groupBy` as its `context` argument (see GroupByContext).\n const toolUIs = useAuiState((s) => s.tools.toolUIs);\n // Subscribe to a boolean, not the status object: the tree only needs to\n // re-render when running-ness flips, and `\"never\"` opts out entirely.\n const isRunning = useAuiState((s) =>\n indicator === \"never\" ? false : s.message.status?.type === \"running\",\n );\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 const context: GroupByContext = { toolUIs };\n return buildGroupTree(\n parts.map((part) => groupBy(part, context) ?? []),\n parts.map((part) =>\n part.type === \"tool-call\" ? part.toolCallId : undefined,\n ),\n );\n // oxlint-disable-next-line react/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, toolUIs]);\n\n return (\n <>\n {tree.map((node) => renderNode(node, parts, children))}\n {shouldShowIndicator(indicator, parts, isRunning) &&\n children({\n part: { type: \"indicator\" },\n children: <PartChildrenSentinel />,\n })}\n </>\n );\n};\n\nMessagePrimitiveGroupedParts.displayName = \"MessagePrimitive.GroupedParts\";\n"],"mappings":";;;;;;;;;AAyIA,MAAMgC,uBACJC,MACAC,OACAC,cACY;CAGZ,IAAI,CAACA,WAAW,OAAO;CAEvB,QAAQF,MAAR;EACE,KAAK,SACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,SACH,OAAOC,MAAME,WAAW;EAC1B,KAAK,WAAW;GACd,MAAMC,OAAOH,MAAMA,MAAME,SAAS;GAClC,OACEC,SAASC,KAAAA,KACRD,KAAKnB,SAAS,UAAUmB,KAAKnB,SAAS;EAE3C;CACF;AACF;;;;;;;AAQA,MAAMqB,6BAAiC;CACrC,MAAM,IAAIC,MACR,8LAGF;AACF;AAEA,MAAMC,cACJC,MACAR,OACAS,WACc;CACd,IAAID,KAAKxB,SAAS,QAIhB,OACE,oBAAC,qBAAD;EAEE,OAAOwB,KAAKG;EAEV,WAAA,EAAEpB,WAAWkB,OAAO;GAAElB;GAAMC,UAAU,oBAAC,sBAAD,CAAqB,CAAA;EAAI,CAAC;CAC/C,GAJdgB,KAAKE,QAAQ,QAAQF,KAAKE,UAAU,QAAQF,KAAKG,OAInC;CAIzB,MAAMzB,SAASX,eAAeyB,OAAOQ,KAAKrB,OAAO;CAOjD,OACE,oBAAC,UAAD,EAAA,UACGsB,OAAO;EACNlB,MAAMqB;GARV5B,MAAMwB,KAAKK;GACX3B;GACAC,SAASqB,KAAKrB;EAMJyB;EACNpB,UACE,oBAAA,YAAA,EAAA,UAAGgB,KAAKhB,SAASuB,KAAKC,UAAUT,WAAWS,OAAOhB,OAAOS,MAAM,CAAC,EAAE,CAAA;CAEtE,CAAC,EACO,GAPKD,KAAKE,SAASF,KAAKM,OAOxB;AAEd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAahC,gCAAgE,EAC3EY,SACAE,YAAY,WACZJ,eACyD;CACzD,MAAMQ,QAAQ9B,YAAYC,YAAY8C,MAAMA,EAAEC,QAAQlB,KAAK,CAAC;CAE5D,MAAMmB,UAAUjD,aAAa+C,QAAMA,IAAEG,MAAMD,OAAO;CAGlD,MAAMlB,YAAY/B,aAAa+C,QAC7BrB,cAAc,UAAU,QAAQqB,IAAEC,QAAQhC,QAAQF,SAAS,SAC7D;CAsBA,OACE,qBAAA,YAAA,EAAA,UAAA,CAZWf,cAAc;EACzB,MAAM0B,UAA0B,EAAEwB,QAAQ;EAC1C,OAAO3C,eACLwB,MAAMe,KAAKxB,SAASG,QAAQH,MAAMI,OAAO,KAAK,CAAA,CAAE,GAChDK,MAAMe,KAAKxB,WACTA,OAAKP,SAAS,cAAcO,OAAKiC,aAAapB,KAAAA,CAChD,CACF;CAEF,GAAG;EAACJ;EAbaN,QACfjB,qBAEyBiB;EAUPyB;CAAO,CAItBI,CAAI,CAACR,KAAKP,SAASD,WAAWC,MAAMR,OAAOR,QAAQ,CAAC,GACpDM,oBAAoBF,WAAWI,OAAOC,SAAS,KAC9CT,SAAS;EACPD,MAAM,EAAEP,MAAM,YAAY;EAC1BQ,UAAU,oBAAC,sBAAD,CAAqB,CAAA;CACjC,CAAC,CACL,EAAA,CAAA;AAEJ;AAEAV,6BAA6B2C,cAAc"}
@@ -1,4 +1,4 @@
1
- import { DataMessagePart, FileMessagePart, ImageMessagePart, MessageStatus, SourceProviderMetadata, TextMessagePart, ThreadMessage, ToolApprovalOption, Unstable_AudioMessagePart } from "../../../types/message.js";
1
+ import { MessageStatus, SourceProviderMetadata, ThreadMessage, ToolApprovalOption } from "../../../types/message.js";
2
2
  import { CompleteAttachment } from "../../../types/attachment.js";
3
3
  import { ExportedMessageRepositoryItem } from "../../../runtime/utils/message-repository.js";
4
4
  import { ReadonlyJSONObject, ReadonlyJSONValue } from "assistant-stream/utils";
@@ -59,7 +59,29 @@ type AuiV0MessagePart = {
59
59
  readonly mimeType: string;
60
60
  readonly filename?: string;
61
61
  };
62
- type AuiV0AttachmentPart = TextMessagePart | ImageMessagePart | FileMessagePart | Unstable_AudioMessagePart | DataMessagePart<ReadonlyJSONValue>;
62
+ type AuiV0AttachmentPart = {
63
+ readonly type: "text";
64
+ readonly text: string;
65
+ } | {
66
+ readonly type: "image";
67
+ readonly image: string;
68
+ readonly filename?: string;
69
+ } | {
70
+ readonly type: "file";
71
+ readonly data: string;
72
+ readonly mimeType: string;
73
+ readonly filename?: string;
74
+ } | {
75
+ readonly type: "audio";
76
+ readonly audio: {
77
+ readonly data: string;
78
+ readonly format: "mp3" | "wav";
79
+ };
80
+ } | {
81
+ readonly type: "data";
82
+ readonly name: string;
83
+ readonly data: ReadonlyJSONValue;
84
+ };
63
85
  type AuiV0Attachment = {
64
86
  readonly id: string;
65
87
  readonly type: CompleteAttachment["type"];
@@ -1 +1 @@
1
- {"version":3,"file":"auiV0.d.ts","names":[],"sources":["../../../../src/react/runtimes/cloud/auiV0.ts"],"mappings":";;;;;;KAqBK;WACM;WACA;WACA;WACA;WACA,mBAAmB;WACnB;WACA;;KAGN;WAEU;WACA;;WAGA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA,mBAAmB;;WAGnB;WACA;WACA;WACA;WACA;WACA;WACA,mBAAmB;;WAGnB;WACA;WACA;WACA,MAAM;WACN,SAAS;WACT;WACA,WAAW;;WAGX;WACA;WACA;WACA;WACA,SAAS;WACT;WACA,WAAW;;WAGX;WACA;;WAGA;WACA;WACA;WACA;;KAGV,sBACD,kBACA,mBACA,kBACA,4BACA,gBAAgB;KAEf;WACM;WACA,MAAM;WACN;WACA;WACA,QAAQ;WACR,kBAAkB;;KAGxB;WACM;WACA,SAAS;WACT,kBAAkB;WAClB,uBAAuB;WACvB;aACE,iBAAiB;aACjB,+BAA+B;aAC/B,wBAAwB;aACxB;eACE;iBACE;iBACA;;;aAGJ,QAAQ;;;iBAkDL,YAAY,SAAS,gBAAgB;iBA6FrC,YACd,cAAc;EAAiB;IAC9B"}
1
+ {"version":3,"file":"auiV0.d.ts","names":[],"sources":["../../../../src/react/runtimes/cloud/auiV0.ts"],"mappings":";;;;;;KAgBK;WACM;WACA;WACA;WACA;WACA,mBAAmB;WACnB;WACA;;KAGN;WAEU;WACA;;WAGA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA,mBAAmB;;WAGnB;WACA;WACA;WACA;WACA;WACA;WACA,mBAAmB;;WAGnB;WACA;WACA;WACA,MAAM;WACN,SAAS;WACT;WACA,WAAW;;WAGX;WACA;WACA;WACA;WACA,SAAS;WACT;WACA,WAAW;;WAGX;WACA;;WAGA;WACA;WACA;WACA;;KAGV;WAEU;WACA;;WAGA;WACA;WACA;;WAGA;WACA;WACA;WACA;;WAGA;WACA;aACE;aACA;;;WAIF;WACA;WACA,MAAM;;KAGhB;WACM;WACA,MAAM;WACN;WACA;WACA,QAAQ;WACR,kBAAkB;;KAGxB;WACM;WACA,SAAS;WACT,kBAAkB;WAClB,uBAAuB;WACvB;aACE,iBAAiB;aACjB,+BAA+B;aAC/B,wBAAwB;aACxB;eACE;iBACE;iBACA;;;aAGJ,QAAQ;;;iBAwEL,YAAY,SAAS,gBAAgB;iBA6FrC,YACd,cAAc;EAAiB;IAC9B"}
@@ -4,14 +4,33 @@ import { fromThreadMessageLike } from "../../../runtime/utils/thread-message-lik
4
4
  const encodeAttachmentPart = (part) => {
5
5
  const type = part.type;
6
6
  switch (type) {
7
- case "text":
8
- case "image":
9
- case "file":
10
- case "audio": return part;
7
+ case "text": return {
8
+ type: "text",
9
+ text: part.text
10
+ };
11
+ case "image": return {
12
+ type: "image",
13
+ image: part.image,
14
+ ...part.filename != null ? { filename: part.filename } : void 0
15
+ };
16
+ case "file": return {
17
+ type: "file",
18
+ data: part.data,
19
+ mimeType: part.mimeType,
20
+ ...part.filename != null ? { filename: part.filename } : void 0
21
+ };
22
+ case "audio": return {
23
+ type: "audio",
24
+ audio: {
25
+ data: part.audio.data,
26
+ format: part.audio.format
27
+ }
28
+ };
11
29
  case "data":
12
30
  if (!isJSONValue(part.data)) console.warn(`attachment data is not JSON! ${JSON.stringify(part)}`);
13
31
  return {
14
- ...part,
32
+ type: "data",
33
+ name: part.name,
15
34
  data: part.data
16
35
  };
17
36
  default: throw new Error(`Attachment part type not supported by aui/v0: ${type}`);