@assistant-ui/react 0.5.22 → 0.5.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context/providers/AssistantRuntimeProvider.tsx","../src/context/providers/AssistantProvider.tsx","../src/context/react/AssistantContext.ts","../src/context/stores/AssistantModelConfig.ts","../src/utils/ProxyConfigProvider.ts","../src/context/stores/AssistantToolUIs.ts","../src/context/providers/ThreadProvider.tsx","../src/context/react/ThreadContext.ts","../src/context/stores/Composer.ts","../src/context/stores/BaseComposer.ts","../src/context/stores/Thread.ts","../src/context/stores/ThreadViewport.tsx","../src/context/stores/ThreadActions.ts","../src/context/stores/ThreadMessages.ts","../src/context/stores/ThreadRuntime.tsx","../src/utils/hooks/useManagedRef.ts","../src/context/stores/AssistantActions.tsx","../src/context/react/ComposerContext.ts","../src/context/react/MessageContext.ts","../src/context/react/ContentPartContext.ts","../src/hooks/useAppendMessage.tsx","../src/hooks/useSwitchToNewThread.tsx","../src/model-config/useAssistantTool.tsx","../src/model-config/makeAssistantTool.tsx","../src/model-config/useAssistantToolUI.tsx","../src/model-config/makeAssistantToolUI.tsx","../src/model-config/useAssistantInstructions.tsx","../src/primitive-hooks/actionBar/useActionBarCopy.tsx","../src/utils/combined/useCombinedStore.ts","../src/utils/combined/createCombinedStore.ts","../src/utils/getMessageText.tsx","../src/primitive-hooks/actionBar/useActionBarEdit.tsx","../src/primitive-hooks/actionBar/useActionBarReload.tsx","../src/primitive-hooks/branchPicker/useBranchPickerCount.tsx","../src/primitive-hooks/branchPicker/useBranchPickerNext.tsx","../src/primitive-hooks/branchPicker/useBranchPickerNumber.tsx","../src/primitive-hooks/branchPicker/useBranchPickerPrevious.tsx","../src/primitive-hooks/composer/useComposerCancel.tsx","../src/primitive-hooks/composer/useComposerIf.tsx","../src/primitive-hooks/composer/useComposerSend.tsx","../src/primitive-hooks/contentPart/useContentPartDisplay.tsx","../src/primitive-hooks/contentPart/useContentPartImage.tsx","../src/primitive-hooks/contentPart/useContentPartText.tsx","../src/primitive-hooks/message/useMessageIf.tsx","../src/primitive-hooks/thread/useThreadIf.tsx","../src/primitive-hooks/thread/useThreadEmpty.tsx","../src/primitive-hooks/thread/useThreadScrollToBottom.tsx","../src/primitive-hooks/thread/useThreadSuggestion.tsx","../src/primitives/actionBar/index.ts","../src/primitives/actionBar/ActionBarRoot.tsx","../src/primitives/actionBar/useActionBarFloatStatus.tsx","../src/utils/createActionButton.tsx","../src/primitives/actionBar/ActionBarCopy.tsx","../src/primitives/actionBar/ActionBarReload.tsx","../src/primitives/actionBar/ActionBarEdit.tsx","../src/primitives/assistantModal/index.ts","../src/primitives/assistantModal/AssistantModalRoot.tsx","../src/utils/hooks/useOnComposerFocus.tsx","../src/primitives/assistantModal/scope.tsx","../src/primitives/assistantModal/AssistantModalTrigger.tsx","../src/primitives/assistantModal/AssistantModalContent.tsx","../src/primitives/assistantModal/AssistantModalAnchor.tsx","../src/primitives/branchPicker/index.ts","../src/primitives/branchPicker/BranchPickerNext.tsx","../src/primitives/branchPicker/BranchPickerPrevious.tsx","../src/primitives/branchPicker/BranchPickerCount.tsx","../src/primitives/branchPicker/BranchPickerNumber.tsx","../src/primitives/branchPicker/BranchPickerRoot.tsx","../src/primitives/message/index.ts","../src/primitives/message/MessageRoot.tsx","../src/primitives/message/MessageIf.tsx","../src/primitives/message/MessageContent.tsx","../src/context/providers/ContentPartProvider.tsx","../src/primitives/contentPart/ContentPartText.tsx","../src/utils/smooth/useSmooth.tsx","../src/utils/smooth/SmoothContext.tsx","../src/primitives/contentPart/ContentPartImage.tsx","../src/primitives/contentPart/ContentPartDisplay.tsx","../src/primitives/contentPart/ContentPartInProgress.tsx","../src/primitives/message/MessageInProgress.tsx","../src/primitives/composer/index.ts","../src/primitives/composer/ComposerRoot.tsx","../src/primitives/composer/ComposerInput.tsx","../src/primitives/composer/ComposerSend.tsx","../src/primitives/composer/ComposerCancel.tsx","../src/primitives/composer/ComposerIf.tsx","../src/primitives/contentPart/index.ts","../src/primitives/thread/index.ts","../src/primitives/thread/ThreadRoot.tsx","../src/primitives/thread/ThreadEmpty.tsx","../src/primitives/thread/ThreadIf.tsx","../src/primitives/thread/ThreadViewport.tsx","../src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx","../src/utils/hooks/useOnResizeContent.tsx","../src/utils/hooks/useOnScrollToBottom.tsx","../src/primitives/thread/ThreadMessages.tsx","../src/context/providers/MessageProvider.tsx","../src/context/stores/EditComposer.ts","../src/context/stores/MessageUtils.ts","../src/primitives/thread/ThreadScrollToBottom.tsx","../src/primitives/thread/ThreadSuggestion.tsx","../src/runtimes/local/useLocalRuntime.tsx","../src/runtimes/core/BaseAssistantRuntime.tsx","../src/internal.ts","../src/utils/idUtils.tsx","../src/runtimes/edge/converters/fromCoreMessage.ts","../src/runtimes/utils/MessageRepository.tsx","../src/ui/base/tooltip-icon-button.tsx","../src/ui/base/tooltip.tsx","../src/ui/utils/withDefaults.tsx","../src/ui/base/button.tsx","../src/runtimes/edge/converters/fromLanguageModelMessages.ts","../src/runtimes/edge/converters/fromLanguageModelTools.ts","../src/runtimes/edge/useEdgeRuntime.ts","../src/runtimes/edge/streams/assistantDecoderStream.ts","../src/runtimes/edge/streams/chunkByLineStream.ts","../src/runtimes/edge/EdgeChatAdapter.ts","../src/runtimes/local/shouldContinue.tsx","../src/runtimes/local/LocalThreadRuntime.tsx","../src/runtimes/local/LocalRuntime.tsx","../src/runtimes/external-store/ExternalStoreThreadRuntime.tsx","../src/runtimes/external-store/getExternalStoreMessage.tsx","../src/runtimes/external-store/useExternalStoreSync.tsx","../src/runtimes/external-store/ThreadMessageConverter.ts","../src/runtimes/external-store/auto-status.tsx","../src/runtimes/external-store/ThreadMessageLike.tsx","../src/runtimes/external-store/ExternalStoreRuntime.tsx","../src/runtimes/external-store/useExternalStoreRuntime.tsx","../src/ui/thread-config.tsx","../src/ui/assistant-action-bar.tsx","../src/ui/assistant-message.tsx","../src/ui/branch-picker.tsx","../src/ui/base/avatar.tsx","../src/ui/content-part.tsx","../src/ui/assistant-modal.tsx","../src/ui/thread.tsx","../src/ui/composer.tsx","../src/ui/base/CircleStopIcon.tsx","../src/ui/thread-welcome.tsx","../src/ui/user-message.tsx","../src/ui/user-action-bar.tsx","../src/ui/edit-composer.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from \"react\";\nimport { memo } from \"react\";\nimport type { AssistantRuntime } from \"../../runtimes/core/AssistantRuntime\";\nimport { AssistantProvider } from \"./AssistantProvider\";\n\ntype AssistantRuntimeProviderProps = {\n runtime: AssistantRuntime;\n};\n\nconst AssistantRuntimeProviderImpl: FC<\n PropsWithChildren<AssistantRuntimeProviderProps>\n> = ({ children, runtime }) => {\n return <AssistantProvider runtime={runtime}>{children}</AssistantProvider>;\n};\n\nexport const AssistantRuntimeProvider = memo(AssistantRuntimeProviderImpl);\n","\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport { useEffect, useInsertionEffect, useRef, useState } from \"react\";\nimport type { AssistantRuntime } from \"../../runtimes\";\nimport { AssistantContext } from \"../react/AssistantContext\";\nimport { makeAssistantModelConfigStore } from \"../stores/AssistantModelConfig\";\nimport { makeAssistantToolUIsStore } from \"../stores/AssistantToolUIs\";\nimport { ThreadProvider } from \"./ThreadProvider\";\nimport { makeAssistantActionsStore } from \"../stores/AssistantActions\";\n\ntype AssistantProviderProps = {\n runtime: AssistantRuntime;\n};\n\nexport const AssistantProvider: FC<\n PropsWithChildren<AssistantProviderProps>\n> = ({ children, runtime }) => {\n const runtimeRef = useRef(runtime);\n useInsertionEffect(() => {\n runtimeRef.current = runtime;\n });\n\n const [context] = useState(() => {\n const useModelConfig = makeAssistantModelConfigStore();\n const useToolUIs = makeAssistantToolUIsStore();\n const useAssistantActions = makeAssistantActionsStore(runtimeRef);\n\n return { useModelConfig, useToolUIs, useAssistantActions };\n });\n\n const getModelConfig = context.useModelConfig();\n useEffect(() => {\n return runtime.registerModelConfigProvider(getModelConfig);\n }, [runtime, getModelConfig]);\n\n return (\n <AssistantContext.Provider value={context}>\n <ThreadProvider provider={runtime}>{children}</ThreadProvider>\n </AssistantContext.Provider>\n );\n};\n","\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport type { AssistantModelConfigState } from \"../stores/AssistantModelConfig\";\nimport type { AssistantToolUIsState } from \"../stores/AssistantToolUIs\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { AssistantActionsState } from \"../stores/AssistantActions\";\n\nexport type AssistantContextValue = {\n useModelConfig: ReadonlyStore<AssistantModelConfigState>;\n useToolUIs: ReadonlyStore<AssistantToolUIsState>;\n useAssistantActions: ReadonlyStore<AssistantActionsState>;\n};\n\nexport const AssistantContext = createContext<AssistantContextValue | null>(\n null,\n);\n\nexport function useAssistantContext(): AssistantContextValue;\nexport function useAssistantContext(options: {\n optional: true;\n}): AssistantContextValue | null;\nexport function useAssistantContext(options?: { optional: true }) {\n const context = useContext(AssistantContext);\n if (!options?.optional && !context)\n throw new Error(\n \"This component must be used within an AssistantRuntimeProvider.\",\n );\n return context;\n}\n","\"use client\";\n\nimport { create } from \"zustand\";\nimport type { ModelConfigProvider } from \"../../types/ModelConfigTypes\";\nimport { ProxyConfigProvider } from \"../../utils/ProxyConfigProvider\";\n\nexport type AssistantModelConfigState = Readonly<\n ModelConfigProvider & {\n registerModelConfigProvider: (provider: ModelConfigProvider) => () => void;\n }\n>;\n\nexport const makeAssistantModelConfigStore = () =>\n create<AssistantModelConfigState>(() => {\n const proxy = new ProxyConfigProvider();\n\n return Object.freeze({\n getModelConfig: () => {\n return proxy.getModelConfig();\n },\n registerModelConfigProvider: (provider: ModelConfigProvider) => {\n return proxy.registerModelConfigProvider(provider);\n },\n }) satisfies AssistantModelConfigState;\n });\n","\"use client\";\nimport {\n type ModelConfigProvider,\n mergeModelConfigs,\n} from \"../types/ModelConfigTypes\";\n\nexport class ProxyConfigProvider implements ModelConfigProvider {\n private _providers = new Set<ModelConfigProvider>();\n\n getModelConfig() {\n return mergeModelConfigs(this._providers);\n }\n\n registerModelConfigProvider(provider: ModelConfigProvider) {\n this._providers.add(provider);\n return () => {\n this._providers.delete(provider);\n };\n }\n}\n","\"use client\";\n\nimport { create } from \"zustand\";\nimport type { ToolCallContentPartComponent } from \"../../types/ContentPartComponentTypes\";\n\nexport type AssistantToolUIsState = Readonly<{\n getToolUI: (toolName: string) => ToolCallContentPartComponent | null;\n setToolUI: (\n toolName: string,\n render: ToolCallContentPartComponent,\n ) => () => void;\n}>;\n\nexport const makeAssistantToolUIsStore = () =>\n create<AssistantToolUIsState>((set) => {\n const renderers = new Map<string, ToolCallContentPartComponent[]>();\n\n return Object.freeze({\n getToolUI: (name) => {\n const arr = renderers.get(name);\n const last = arr?.at(-1);\n if (last) return last;\n return null;\n },\n setToolUI: (name, render) => {\n let arr = renderers.get(name);\n if (!arr) {\n arr = [];\n renderers.set(name, arr);\n }\n arr.push(render);\n set({}); // notify the store listeners\n\n return () => {\n const index = arr.indexOf(render);\n if (index !== -1) {\n arr.splice(index, 1);\n }\n if (index === arr.length) {\n set({}); // notify the store listeners\n }\n };\n },\n }) satisfies AssistantToolUIsState;\n });\n","import type { FC, PropsWithChildren } from \"react\";\nimport { useCallback, useInsertionEffect, useState } from \"react\";\nimport type { ReactThreadRuntime } from \"../../runtimes/core/ReactThreadRuntime\";\nimport type { ThreadContextValue } from \"../react/ThreadContext\";\nimport { ThreadContext } from \"../react/ThreadContext\";\nimport { makeComposerStore } from \"../stores/Composer\";\nimport { ThreadState, makeThreadStore } from \"../stores/Thread\";\nimport { makeThreadViewportStore } from \"../stores/ThreadViewport\";\nimport { makeThreadActionStore } from \"../stores/ThreadActions\";\nimport { StoreApi } from \"zustand\";\nimport {\n ThreadMessagesState,\n makeThreadMessagesStore,\n} from \"../stores/ThreadMessages\";\nimport { ThreadRuntimeWithSubscribe } from \"../../runtimes/core/AssistantRuntime\";\nimport {\n makeThreadRuntimeStore,\n ThreadRuntimeStore,\n} from \"../stores/ThreadRuntime\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\n\ntype ThreadProviderProps = {\n provider: ThreadRuntimeWithSubscribe;\n};\n\nexport const ThreadProvider: FC<PropsWithChildren<ThreadProviderProps>> = ({\n children,\n provider,\n}) => {\n const [context] = useState<ThreadContextValue>(() => {\n const useThreadRuntime = makeThreadRuntimeStore(provider.thread);\n const useThread = makeThreadStore(useThreadRuntime);\n const useThreadMessages = makeThreadMessagesStore(useThreadRuntime);\n const useThreadActions = makeThreadActionStore(useThreadRuntime);\n const useViewport = makeThreadViewportStore();\n const useComposer = makeComposerStore(useThreadMessages, useThreadActions);\n\n return {\n useThread,\n useThreadRuntime,\n useThreadMessages,\n useThreadActions,\n useComposer,\n useViewport,\n };\n });\n\n const threadRef = useManagedRef(\n useCallback(\n (thread: ReactThreadRuntime) => {\n const onThreadUpdate = () => {\n const threadState = context.useThread.getState();\n if (\n thread.isRunning !== threadState.isRunning ||\n thread.isDisabled !== threadState.isDisabled\n ) {\n (context.useThread as unknown as StoreApi<ThreadState>).setState(\n Object.freeze({\n isRunning: thread.isRunning,\n isDisabled: thread.isDisabled,\n }) satisfies ThreadState,\n true,\n );\n }\n\n if (thread.messages !== context.useThreadMessages.getState()) {\n (\n context.useThreadMessages as unknown as StoreApi<ThreadMessagesState>\n ).setState(thread.messages, true);\n }\n };\n\n onThreadUpdate();\n return thread.subscribe(onThreadUpdate);\n },\n [context],\n ),\n );\n\n useInsertionEffect(() => {\n const unsubscribe = provider.subscribe(() => {\n (\n context.useThreadRuntime as unknown as StoreApi<ThreadRuntimeStore>\n ).setState(provider.thread, true);\n threadRef(provider.thread);\n });\n threadRef(provider.thread);\n return () => {\n unsubscribe();\n threadRef(null);\n };\n }, [provider, context]);\n\n // subscribe to thread updates\n const Synchronizer = context.useThreadRuntime(\n (t) => (t as ReactThreadRuntime).unstable_synchronizer,\n );\n\n return (\n <ThreadContext.Provider value={context}>\n {Synchronizer && <Synchronizer />}\n {children}\n </ThreadContext.Provider>\n );\n};\n","\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport type { ComposerState } from \"../stores/Composer\";\nimport type { ThreadState } from \"../stores/Thread\";\nimport type { ThreadViewportState } from \"../stores/ThreadViewport\";\nimport { ThreadActionsState } from \"../stores/ThreadActions\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { ThreadMessagesState } from \"../stores/ThreadMessages\";\nimport { ThreadRuntimeStore } from \"../stores/ThreadRuntime\";\n\nexport type ThreadContextValue = {\n useThread: ReadonlyStore<ThreadState>;\n useThreadRuntime: ReadonlyStore<ThreadRuntimeStore>;\n useThreadMessages: ReadonlyStore<ThreadMessagesState>;\n useThreadActions: ReadonlyStore<ThreadActionsState>;\n useComposer: ReadonlyStore<ComposerState>;\n useViewport: ReadonlyStore<ThreadViewportState>;\n};\n\nexport const ThreadContext = createContext<ThreadContextValue | null>(null);\n\nexport function useThreadContext(): ThreadContextValue;\nexport function useThreadContext(options: {\n optional: true;\n}): ThreadContextValue | null;\nexport function useThreadContext(options?: { optional: true }) {\n const context = useContext(ThreadContext);\n if (!options?.optional && !context)\n throw new Error(\n \"This component must be used within an AssistantRuntimeProvider.\",\n );\n return context;\n}\n","import { create } from \"zustand\";\nimport { type BaseComposerState, makeBaseComposer } from \"./BaseComposer\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { Unsubscribe } from \"../../types/Unsubscribe\";\nimport { ThreadContextValue } from \"../react\";\n\nexport type ComposerState = BaseComposerState &\n Readonly<{\n canCancel: boolean;\n isEditing: true;\n\n send: () => void;\n cancel: () => void;\n focus: () => void;\n onFocus: (listener: () => void) => Unsubscribe;\n }>;\n\nexport const makeComposerStore = (\n useThreadMessages: ThreadContextValue[\"useThreadMessages\"],\n useThreadActions: ThreadContextValue[\"useThreadActions\"],\n): ReadonlyStore<ComposerState> => {\n const focusListeners = new Set<() => void>();\n return create<ComposerState>()((set, get, store) => {\n return {\n ...makeBaseComposer(set, get, store),\n\n get canCancel() {\n return useThreadActions.getState().capabilities.cancel;\n },\n isEditing: true,\n\n send: () => {\n const { setValue, value } = get();\n setValue(\"\");\n\n useThreadActions.getState().append({\n parentId: useThreadMessages.getState().at(-1)?.id ?? null,\n role: \"user\",\n content: [{ type: \"text\", text: value }],\n });\n },\n cancel: () => {\n useThreadActions.getState().cancelRun();\n },\n focus: () => {\n for (const listener of focusListeners) {\n listener();\n }\n },\n onFocus: (listener) => {\n focusListeners.add(listener);\n return () => {\n focusListeners.delete(listener);\n };\n },\n };\n });\n};\n","import type { StateCreator } from \"zustand\";\n\nexport type BaseComposerState = Readonly<{\n value: string;\n setValue: (value: string) => void;\n}>;\n\nexport const makeBaseComposer: StateCreator<\n BaseComposerState,\n [],\n [],\n BaseComposerState\n> = (set) => ({\n value: \"\",\n setValue: (value) => {\n set({ value });\n },\n});\n","import { create } from \"zustand\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { ThreadRuntimeStore } from \"./ThreadRuntime\";\n\nexport type ThreadState = Readonly<{\n isRunning: boolean;\n isDisabled: boolean;\n}>;\n\nexport const makeThreadStore = (\n runtimeRef: ReadonlyStore<ThreadRuntimeStore>,\n) => {\n return create<ThreadState>(() => ({\n isDisabled: runtimeRef.getState().isDisabled,\n isRunning: runtimeRef.getState().isRunning,\n }));\n};\n","\"use client\";\nimport { create } from \"zustand\";\nimport type { Unsubscribe } from \"../../types/Unsubscribe\";\n\nexport type ThreadViewportState = Readonly<{\n isAtBottom: boolean;\n scrollToBottom: () => void;\n onScrollToBottom: (callback: () => void) => Unsubscribe;\n}>;\n\nexport const makeThreadViewportStore = () => {\n const scrollToBottomListeners = new Set<() => void>();\n\n return create<ThreadViewportState>(() => ({\n isAtBottom: true,\n scrollToBottom: () => {\n for (const listener of scrollToBottomListeners) {\n listener();\n }\n },\n onScrollToBottom: (callback) => {\n scrollToBottomListeners.add(callback);\n return () => {\n scrollToBottomListeners.delete(callback);\n };\n },\n }));\n};\n","import { create } from \"zustand\";\nimport type { AppendMessage } from \"../../types/AssistantTypes\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { ThreadRuntimeStore } from \"./ThreadRuntime\";\n\nexport type AddToolResultOptions = {\n messageId: string;\n toolCallId: string;\n result: any;\n};\n\nexport type RuntimeCapabilities = {\n switchToBranch: boolean;\n edit: boolean;\n reload: boolean;\n cancel: boolean;\n copy: boolean;\n};\n\nexport type ThreadActionsState = Readonly<{\n capabilities: Readonly<RuntimeCapabilities>;\n\n getBranches: (messageId: string) => readonly string[];\n switchToBranch: (branchId: string) => void;\n\n append: (message: AppendMessage) => void;\n startRun: (parentId: string | null) => void;\n cancelRun: () => void;\n\n addToolResult: (options: AddToolResultOptions) => void;\n}>;\n\nexport const makeThreadActionStore = (\n runtimeStore: ReadonlyStore<ThreadRuntimeStore>,\n) => {\n return create<ThreadActionsState>(() =>\n Object.freeze({\n get capabilities() {\n return runtimeStore.getState().capabilities;\n },\n getBranches: (messageId) =>\n runtimeStore.getState().getBranches(messageId),\n switchToBranch: (branchId) =>\n runtimeStore.getState().switchToBranch(branchId),\n startRun: (parentId) => runtimeStore.getState().startRun(parentId),\n append: (message) => runtimeStore.getState().append(message),\n cancelRun: () => runtimeStore.getState().cancelRun(),\n addToolResult: (options) =>\n runtimeStore.getState().addToolResult(options),\n }),\n );\n};\n","import { create } from \"zustand\";\nimport type { ThreadMessage } from \"../../types/AssistantTypes\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { ThreadRuntimeStore } from \"./ThreadRuntime\";\n\nexport type ThreadMessagesState = readonly ThreadMessage[];\n\nexport const makeThreadMessagesStore = (\n runtimeRef: ReadonlyStore<ThreadRuntimeStore>,\n) => {\n return create<ThreadMessagesState>(() => runtimeRef.getState().messages);\n};\n","import { create } from \"zustand\";\nimport { ThreadRuntime } from \"../../runtimes\";\n\nexport type ThreadRuntimeStore = ThreadRuntime;\n\nexport const makeThreadRuntimeStore = (runtime: ThreadRuntime) => {\n return create<ThreadRuntimeStore>(() => runtime);\n};\n","import { useCallback, useRef } from \"react\";\n\nexport const useManagedRef = <TNode>(\n callback: (node: TNode) => (() => void) | void,\n) => {\n const cleanupRef = useRef<(() => void) | void>();\n\n const ref = useCallback(\n (el: TNode | null) => {\n // Call the previous cleanup function\n if (cleanupRef.current) {\n cleanupRef.current();\n }\n\n // Call the new callback and store its cleanup function\n if (el) {\n cleanupRef.current = callback(el);\n }\n },\n [callback],\n );\n\n return ref;\n};\n","import { create } from \"zustand\";\nimport { AssistantRuntime } from \"../../runtimes\";\nimport { MutableRefObject } from \"react\";\n\nexport type AssistantActionsState = Readonly<{\n switchToThread: (threadId: string | null) => void;\n getRuntime: () => AssistantRuntime;\n}>;\n\nexport const makeAssistantActionsStore = (\n runtimeRef: MutableRefObject<AssistantRuntime>,\n) =>\n create<AssistantActionsState>(() =>\n Object.freeze({\n switchToThread: () => runtimeRef.current.switchToThread(null),\n getRuntime: () => runtimeRef.current,\n }),\n );\n","import { useMemo } from \"react\";\nimport { useMessageContext } from \"./MessageContext\";\nimport { useThreadContext } from \"./ThreadContext\";\nimport type { ComposerState } from \"../stores/Composer\";\nimport type { EditComposerState } from \"../stores/EditComposer\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type ComposerContextValue = {\n useComposer: ReadonlyStore<EditComposerState | ComposerState>;\n type: \"edit\" | \"new\";\n};\n\nexport const useComposerContext = (): ComposerContextValue => {\n const { useComposer } = useThreadContext();\n const { useEditComposer } = useMessageContext({ optional: true }) ?? {};\n return useMemo(\n () => ({\n useComposer: (useEditComposer ?? useComposer) as ReadonlyStore<\n EditComposerState | ComposerState\n >,\n type: useEditComposer ? (\"edit\" as const) : (\"new\" as const),\n }),\n [useEditComposer, useComposer],\n );\n};\n","\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport type { MessageState } from \"../stores/Message\";\nimport type { EditComposerState } from \"../stores/EditComposer\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { MessageUtilsState } from \"../stores/MessageUtils\";\n\nexport type MessageContextValue = {\n useMessage: ReadonlyStore<MessageState>;\n useMessageUtils: ReadonlyStore<MessageUtilsState>;\n useEditComposer: ReadonlyStore<EditComposerState>;\n};\n\nexport const MessageContext = createContext<MessageContextValue | null>(null);\n\nexport function useMessageContext(): MessageContextValue;\nexport function useMessageContext(options: {\n optional: true;\n}): MessageContextValue | null;\nexport function useMessageContext(options?: { optional: true }) {\n const context = useContext(MessageContext);\n if (!options?.optional && !context)\n throw new Error(\n \"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />.\",\n );\n return context;\n}\n","\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport type { ContentPartState } from \"../stores/ContentPart\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type ContentPartContextValue = {\n useContentPart: ReadonlyStore<ContentPartState>;\n};\n\nexport const ContentPartContext = createContext<ContentPartContextValue | null>(\n null,\n);\n\nexport function useContentPartContext(): ContentPartContextValue;\nexport function useContentPartContext(options: {\n optional: true;\n}): ContentPartContextValue | null;\nexport function useContentPartContext(options?: { optional: true }) {\n const context = useContext(ContentPartContext);\n if (!options?.optional && !context)\n throw new Error(\n \"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >.\",\n );\n return context;\n}\n","import { useCallback } from \"react\";\nimport { ThreadContextValue, useThreadContext } from \"../context\";\nimport { AppendMessage } from \"../types\";\n\ntype CreateAppendMessage =\n | string\n | {\n parentId?: string | null | undefined;\n role?: AppendMessage[\"role\"] | undefined;\n content: AppendMessage[\"content\"];\n };\n\nconst toAppendMessage = (\n useThreadMessages: ThreadContextValue[\"useThreadMessages\"],\n message: CreateAppendMessage,\n): AppendMessage => {\n if (typeof message === \"string\") {\n return {\n parentId: useThreadMessages.getState().at(-1)?.id ?? null,\n role: \"user\",\n content: [{ type: \"text\", text: message }],\n };\n }\n\n return {\n parentId:\n message.parentId ?? useThreadMessages.getState().at(-1)?.id ?? null,\n role: message.role ?? \"user\",\n content: message.content,\n } as AppendMessage;\n};\n\nexport const useAppendMessage = () => {\n const { useThreadMessages, useThreadActions, useViewport, useComposer } =\n useThreadContext();\n\n const append = useCallback(\n (message: CreateAppendMessage) => {\n const appendMessage = toAppendMessage(useThreadMessages, message);\n useThreadActions.getState().append(appendMessage);\n\n useViewport.getState().scrollToBottom();\n useComposer.getState().focus();\n },\n [useThreadMessages, useThreadActions, useViewport, useComposer],\n );\n\n return append;\n};\n","import { useCallback } from \"react\";\nimport { useAssistantContext, useThreadContext } from \"../context\";\n\nexport const useSwitchToNewThread = () => {\n const { useAssistantActions } = useAssistantContext();\n const { useComposer } = useThreadContext();\n\n const switchToNewThread = useCallback(() => {\n useAssistantActions.getState().switchToThread(null);\n useComposer.getState().focus();\n }, [useAssistantActions, useComposer]);\n\n return switchToNewThread;\n};\n","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../types/ContentPartComponentTypes\";\nimport type { Tool } from \"../types/ModelConfigTypes\";\n\nexport type AssistantToolProps<\n TArgs extends Record<string, unknown>,\n TResult,\n> = Tool<TArgs, TResult> & {\n toolName: string;\n render?: ToolCallContentPartComponent<TArgs, TResult> | undefined;\n};\n\nexport const useAssistantTool = <\n TArgs extends Record<string, unknown>,\n TResult,\n>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const { useModelConfig, useToolUIs } = useAssistantContext();\n const registerModelConfigProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n const setToolUI = useToolUIs((s) => s.setToolUI);\n useEffect(() => {\n const { toolName, render, ...rest } = tool;\n const config = {\n tools: {\n [tool.toolName]: rest,\n },\n };\n const unsub1 = registerModelConfigProvider({\n getModelConfig: () => config,\n });\n const unsub2 = render ? setToolUI(toolName, render) : undefined;\n return () => {\n unsub1();\n unsub2?.();\n };\n }, [registerModelConfigProvider, setToolUI, tool]);\n};\n","\"use client\";\nimport { type AssistantToolProps, useAssistantTool } from \"./useAssistantTool\";\n\nexport const makeAssistantTool = <\n TArgs extends Record<string, unknown>,\n TResult,\n>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const Tool = () => {\n useAssistantTool(tool);\n return null;\n };\n return Tool;\n};\n","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../types/ContentPartComponentTypes\";\n\nexport type AssistantToolUIProps<\n TArgs extends Record<string, unknown>,\n TResult,\n> = {\n toolName: string;\n render: ToolCallContentPartComponent<TArgs, TResult>;\n};\n\nexport const useAssistantToolUI = (\n tool: AssistantToolUIProps<any, any> | null,\n) => {\n const { useToolUIs } = useAssistantContext();\n const setToolUI = useToolUIs((s) => s.setToolUI);\n useEffect(() => {\n if (!tool) return;\n const { toolName, render } = tool;\n return setToolUI(toolName, render);\n }, [setToolUI, tool]);\n};\n","\"use client\";\nimport {\n type AssistantToolUIProps,\n useAssistantToolUI,\n} from \"./useAssistantToolUI\";\n\nexport const makeAssistantToolUI = <\n TArgs extends Record<string, unknown>,\n TResult,\n>(\n tool: AssistantToolUIProps<TArgs, TResult>,\n) => {\n const ToolUI = () => {\n useAssistantToolUI(tool);\n return null;\n };\n return ToolUI;\n};\n","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/react/AssistantContext\";\n\nexport const useAssistantInstructions = (instruction: string) => {\n const { useModelConfig } = useAssistantContext();\n const registerModelConfigProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n useEffect(() => {\n const config = {\n system: instruction,\n };\n return registerModelConfigProvider({ getModelConfig: () => config });\n }, [registerModelConfigProvider, instruction]);\n};\n","import { useCallback } from \"react\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\nimport { getMessageText } from \"../../utils/getMessageText\";\n\nexport type UseActionBarCopyProps = {\n copiedDuration?: number | undefined;\n};\n\nexport const useActionBarCopy = ({\n copiedDuration = 3000,\n}: UseActionBarCopyProps = {}) => {\n const { useMessage, useMessageUtils, useEditComposer } = useMessageContext();\n\n const hasCopyableContent = useCombinedStore(\n [useMessage, useEditComposer],\n (m, c) => {\n return (\n !c.isEditing &&\n m.message.content.some((c) => c.type === \"text\" && c.text.length > 0)\n );\n },\n );\n\n const callback = useCallback(() => {\n const { message } = useMessage.getState();\n const { setIsCopied } = useMessageUtils.getState();\n const { isEditing, value: composerValue } = useEditComposer.getState();\n\n const valueToCopy = isEditing ? composerValue : getMessageText(message);\n\n navigator.clipboard.writeText(valueToCopy).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), copiedDuration);\n });\n }, [useMessage, useMessageUtils, useEditComposer, copiedDuration]);\n\n if (!hasCopyableContent) return null;\n return callback;\n};\n","import { useMemo } from \"react\";\nimport {\n type CombinedSelector,\n createCombinedStore,\n} from \"./createCombinedStore\";\nimport { ReadonlyStore } from \"../../context/ReadonlyStore\";\n\nexport const useCombinedStore = <T extends Array<unknown>, R>(\n stores: { [K in keyof T]: ReadonlyStore<T[K]> },\n selector: CombinedSelector<T, R>,\n): R => {\n // eslint-disable-next-line react-hooks/exhaustive-deps -- shallow-compare the store array\n const useCombined = useMemo(() => createCombinedStore<T, R>(stores), stores);\n return useCombined(selector);\n};\n","\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\nimport type { Unsubscribe } from \"../../types/Unsubscribe\";\nimport { ReadonlyStore } from \"../../context/ReadonlyStore\";\n\nexport type CombinedSelector<T extends Array<unknown>, R> = (...args: T) => R;\n\nexport const createCombinedStore = <T extends Array<unknown>, R>(stores: {\n [K in keyof T]: ReadonlyStore<T[K]>;\n}) => {\n const subscribe = (callback: () => void): Unsubscribe => {\n const unsubscribes = stores.map((store) => store.subscribe(callback));\n return () => {\n for (const unsub of unsubscribes) {\n unsub();\n }\n };\n };\n\n return (selector: CombinedSelector<T, R>): R => {\n const getSnapshot = (): R =>\n selector(...(stores.map((store) => store.getState()) as T));\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n };\n};\n","import type { TextContentPart, ThreadMessage } from \"../types/AssistantTypes\";\n\nexport const getMessageText = (message: ThreadMessage) => {\n const textParts = message.content.filter(\n (part) => part.type === \"text\",\n ) as TextContentPart[];\n\n return textParts.map((part) => part.text).join(\"\\n\\n\");\n};\n","import { useCallback } from \"react\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\nexport const useActionBarEdit = () => {\n const { useMessage, useEditComposer } = useMessageContext();\n\n const disabled = useCombinedStore(\n [useMessage, useEditComposer],\n (m, c) => m.message.role !== \"user\" || c.isEditing,\n );\n\n const callback = useCallback(() => {\n const { edit } = useEditComposer.getState();\n edit();\n }, [useEditComposer]);\n\n if (disabled) return null;\n return callback;\n};\n","import { useCallback } from \"react\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\nexport const useActionBarReload = () => {\n const { useThread, useThreadActions, useComposer, useViewport } =\n useThreadContext();\n const { useMessage } = useMessageContext();\n\n const disabled = useCombinedStore(\n [useThread, useMessage],\n (t, m) => t.isRunning || t.isDisabled || m.message.role !== \"assistant\",\n );\n\n const callback = useCallback(() => {\n const { parentId } = useMessage.getState();\n useThreadActions.getState().startRun(parentId);\n useViewport.getState().scrollToBottom();\n useComposer.getState().focus();\n }, [useThreadActions, useComposer, useViewport, useMessage]);\n\n if (disabled) return null;\n return callback;\n};\n","\"use client\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\n\nexport const useBranchPickerCount = () => {\n const { useMessage } = useMessageContext();\n const branchCount = useMessage((s) => s.branches.length);\n return branchCount;\n};\n","import { useCallback } from \"react\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\nexport const useBranchPickerNext = () => {\n const { useThreadActions } = useThreadContext();\n const { useMessage, useEditComposer } = useMessageContext();\n\n const disabled = useCombinedStore(\n [useMessage, useEditComposer],\n (m, c) =>\n c.isEditing || m.branches.indexOf(m.message.id) + 1 >= m.branches.length,\n );\n\n const callback = useCallback(() => {\n const { message, branches } = useMessage.getState();\n useThreadActions\n .getState()\n .switchToBranch(branches[branches.indexOf(message.id) + 1]!);\n }, [useThreadActions, useMessage]);\n\n if (disabled) return null;\n return callback;\n};\n","\"use client\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\n\nexport const useBranchPickerNumber = () => {\n const { useMessage } = useMessageContext();\n const branchIdx = useMessage((s) => s.branches.indexOf(s.message.id));\n return branchIdx + 1;\n};\n","import { useCallback } from \"react\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\nexport const useBranchPickerPrevious = () => {\n const { useThreadActions } = useThreadContext();\n const { useMessage, useEditComposer } = useMessageContext();\n\n const disabled = useCombinedStore(\n [useMessage, useEditComposer],\n (m, c) => c.isEditing || m.branches.indexOf(m.message.id) <= 0,\n );\n\n const callback = useCallback(() => {\n const { message, branches } = useMessage.getState();\n useThreadActions\n .getState()\n .switchToBranch(branches[branches.indexOf(message.id) - 1]!);\n }, [useThreadActions, useMessage]);\n\n if (disabled) return null;\n return callback;\n};\n","import { useCallback } from \"react\";\nimport { useComposerContext } from \"../../context\";\n\nexport const useComposerCancel = () => {\n const { useComposer } = useComposerContext();\n\n const disabled = useComposer((c) => !c.canCancel);\n\n const callback = useCallback(() => {\n const { cancel } = useComposer.getState();\n cancel();\n }, [useComposer]);\n\n if (disabled) return null;\n return callback;\n};\n","\"use client\";\nimport { useComposerContext } from \"../../context/react/ComposerContext\";\nimport type { RequireAtLeastOne } from \"../../utils/RequireAtLeastOne\";\n\ntype ComposerIfFilters = {\n editing: boolean | undefined;\n};\n\nexport type UseComposerIfProps = RequireAtLeastOne<ComposerIfFilters>;\n\nexport const useComposerIf = (props: UseComposerIfProps) => {\n const { useComposer } = useComposerContext();\n return useComposer((composer) => {\n if (props.editing === true && !composer.isEditing) return false;\n if (props.editing === false && composer.isEditing) return false;\n\n return true;\n });\n};\n","import { useCallback } from \"react\";\nimport { useComposerContext, useThreadContext } from \"../../context\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\nexport const useComposerSend = () => {\n const {\n useThread,\n useViewport,\n useComposer: useNewComposer,\n } = useThreadContext();\n const { useComposer } = useComposerContext();\n\n const disabled = useCombinedStore(\n [useThread, useComposer],\n (t, c) =>\n t.isDisabled || t.isRunning || !c.isEditing || c.value.length === 0,\n );\n\n const callback = useCallback(() => {\n const composerState = useComposer.getState();\n if (!composerState.isEditing) return;\n\n composerState.send();\n\n useViewport.getState().scrollToBottom();\n useNewComposer.getState().focus();\n }, [useNewComposer, useComposer, useViewport]);\n\n if (disabled) return null;\n return callback;\n};\n","import { useContentPartContext } from \"../../context/react/ContentPartContext\";\nimport { UIContentPartState } from \"../../context/stores/ContentPart\";\n\nexport const useContentPartDisplay = () => {\n const { useContentPart } = useContentPartContext();\n\n const display = useContentPart((c) => {\n if (c.part.type !== \"ui\")\n throw new Error(\n \"This component can only be used inside ui content parts.\",\n );\n\n return c as UIContentPartState;\n });\n\n return display;\n};\n","import { useContentPartContext } from \"../../context/react/ContentPartContext\";\nimport { ImageContentPartState } from \"../../context/stores/ContentPart\";\n\nexport const useContentPartImage = () => {\n const { useContentPart } = useContentPartContext();\n\n const image = useContentPart((c) => {\n if (c.part.type !== \"image\")\n throw new Error(\n \"ContentPartImage can only be used inside image content parts.\",\n );\n\n return c as ImageContentPartState;\n });\n\n return image;\n};\n","import { useContentPartContext } from \"../../context/react/ContentPartContext\";\nimport { TextContentPartState } from \"../../context/stores/ContentPart\";\n\nexport const useContentPartText = () => {\n const { useContentPart } = useContentPartContext();\n\n const text = useContentPart((c) => {\n if (c.part.type !== \"text\")\n throw new Error(\n \"ContentPartText can only be used inside text content parts.\",\n );\n\n return c as TextContentPartState;\n });\n\n return text;\n};\n","\"use client\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport type { RequireAtLeastOne } from \"../../utils/RequireAtLeastOne\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\ntype MessageIfFilters = {\n user: boolean | undefined;\n assistant: boolean | undefined;\n system: boolean | undefined;\n hasBranches: boolean | undefined;\n copied: boolean | undefined;\n lastOrHover: boolean | undefined;\n};\nexport type UseMessageIfProps = RequireAtLeastOne<MessageIfFilters>;\n\nexport const useMessageIf = (props: UseMessageIfProps) => {\n const { useMessage, useMessageUtils } = useMessageContext();\n\n return useCombinedStore(\n [useMessage, useMessageUtils],\n ({ message, branches, isLast }, { isCopied, isHovering }) => {\n if (props.hasBranches === true && branches.length < 2) return false;\n\n if (props.user && message.role !== \"user\") return false;\n if (props.assistant && message.role !== \"assistant\") return false;\n if (props.system && message.role !== \"system\") return false;\n\n if (props.lastOrHover === true && !isHovering && !isLast) return false;\n\n if (props.copied === true && !isCopied) return false;\n if (props.copied === false && isCopied) return false;\n\n return true;\n },\n );\n};\n","\"use client\";\n\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport type { RequireAtLeastOne } from \"../../utils/RequireAtLeastOne\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\ntype ThreadIfFilters = {\n empty: boolean | undefined;\n running: boolean | undefined;\n disabled: boolean | undefined;\n};\n\nexport type UseThreadIfProps = RequireAtLeastOne<ThreadIfFilters>;\n\nexport const useThreadIf = (props: UseThreadIfProps) => {\n const { useThread, useThreadMessages } = useThreadContext();\n return useCombinedStore(\n [useThread, useThreadMessages],\n (thread, messages) => {\n if (props.empty === true && messages.length !== 0) return false;\n if (props.empty === false && messages.length === 0) return false;\n if (props.running === true && !thread.isRunning) return false;\n if (props.running === false && thread.isRunning) return false;\n if (props.disabled === true && thread.isDisabled) return false;\n if (props.disabled === false && thread.isDisabled) return false;\n\n return true;\n },\n );\n};\n","import { useThreadIf } from \"./useThreadIf\";\n\nexport const useThreadEmpty = () => {\n return useThreadIf({ empty: true });\n};\n","import { useCallback } from \"react\";\nimport { useThreadContext } from \"../../context\";\n\nexport const useThreadScrollToBottom = () => {\n const { useComposer, useViewport } = useThreadContext();\n\n const isAtBottom = useViewport((s) => s.isAtBottom);\n\n const handleScrollToBottom = useCallback(() => {\n useViewport.getState().scrollToBottom();\n useComposer.getState().focus();\n }, [useViewport, useComposer]);\n\n if (isAtBottom) return null;\n return handleScrollToBottom;\n};\n","import { useCallback } from \"react\";\nimport { useThreadContext } from \"../../context\";\nimport { useAppendMessage } from \"../../hooks\";\n\nexport type UseApplyThreadSuggestionProps = {\n prompt: string;\n method: \"replace\";\n autoSend?: boolean | undefined;\n};\n\nexport const useThreadSuggestion = ({\n prompt,\n autoSend,\n}: UseApplyThreadSuggestionProps) => {\n const { useThread, useComposer } = useThreadContext();\n\n const append = useAppendMessage();\n const disabled = useThread((t) => t.isDisabled);\n const callback = useCallback(() => {\n const thread = useThread.getState();\n const composer = useComposer.getState();\n if (autoSend && !thread.isRunning) {\n append(prompt);\n composer.setValue(\"\");\n } else {\n composer.setValue(prompt);\n }\n }, [useThread, useComposer, autoSend, append, prompt]);\n\n if (disabled) return null;\n return callback;\n};\n","export { ActionBarPrimitiveRoot as Root } from \"./ActionBarRoot\";\nexport { ActionBarPrimitiveCopy as Copy } from \"./ActionBarCopy\";\nexport { ActionBarPrimitiveReload as Reload } from \"./ActionBarReload\";\nexport { ActionBarPrimitiveEdit as Edit } from \"./ActionBarEdit\";\n","\"use client\";\n\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { type ElementRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\nimport {\n useActionBarFloatStatus,\n HideAndFloatStatus,\n UseActionBarFloatStatusProps,\n} from \"./useActionBarFloatStatus\";\n\ntype ActionBarPrimitiveRootElement = ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport type ActionBarPrimitiveRootProps = PrimitiveDivProps &\n UseActionBarFloatStatusProps;\n\nexport const ActionBarPrimitiveRoot = forwardRef<\n ActionBarPrimitiveRootElement,\n ActionBarPrimitiveRootProps\n>(({ hideWhenRunning, autohide, autohideFloat, ...rest }, ref) => {\n const hideAndfloatStatus = useActionBarFloatStatus({\n hideWhenRunning,\n autohide,\n autohideFloat,\n });\n\n if (hideAndfloatStatus === HideAndFloatStatus.Hidden) return null;\n\n return (\n <Primitive.div\n {...(hideAndfloatStatus === HideAndFloatStatus.Floating\n ? { \"data-floating\": \"true\" }\n : null)}\n {...rest}\n ref={ref}\n />\n );\n});\n\nActionBarPrimitiveRoot.displayName = \"ActionBarPrimitive.Root\";\n","\"use client\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\nexport enum HideAndFloatStatus {\n Hidden = \"hidden\",\n Floating = \"floating\",\n Normal = \"normal\",\n}\n\nexport type UseActionBarFloatStatusProps = {\n hideWhenRunning?: boolean | undefined;\n autohide?: \"always\" | \"not-last\" | \"never\" | undefined;\n autohideFloat?: \"always\" | \"single-branch\" | \"never\" | undefined;\n};\n\nexport const useActionBarFloatStatus = ({\n hideWhenRunning,\n autohide,\n autohideFloat,\n}: UseActionBarFloatStatusProps) => {\n const { useThread } = useThreadContext();\n const { useMessage, useMessageUtils } = useMessageContext();\n\n return useCombinedStore(\n [useThread, useMessage, useMessageUtils],\n (t, m, mu) => {\n if (hideWhenRunning && t.isRunning) return HideAndFloatStatus.Hidden;\n\n const autohideEnabled =\n autohide === \"always\" || (autohide === \"not-last\" && !m.isLast);\n\n // normal status\n if (!autohideEnabled) return HideAndFloatStatus.Normal;\n\n // hidden status\n if (!mu.isHovering) return HideAndFloatStatus.Hidden;\n\n // floating status\n if (\n autohideFloat === \"always\" ||\n (autohideFloat === \"single-branch\" && m.branches.length <= 1)\n )\n return HideAndFloatStatus.Floating;\n\n return HideAndFloatStatus.Normal;\n },\n );\n};\n","\"use client\";\n\nimport { ElementRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\n\ntype ActionButtonCallback<TProps> = (props: TProps) => null | (() => void);\n\ntype PrimitiveButtonElement = ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = ComponentPropsWithoutRef<typeof Primitive.button>;\n\nexport type ActionButtonProps<THook> = PrimitiveButtonProps &\n (THook extends (props: infer TProps) => unknown ? TProps : never);\n\nexport const createActionButton = <TProps,>(\n displayName: string,\n useActionButton: ActionButtonCallback<TProps>,\n forwardProps: (keyof NonNullable<TProps>)[] = [],\n) => {\n const ActionButton = forwardRef<\n PrimitiveButtonElement,\n PrimitiveButtonProps & TProps\n >((props, forwardedRef) => {\n const forwardedProps = {} as TProps;\n const primitiveProps = {} as PrimitiveButtonProps;\n\n (Object.keys(props) as Array<keyof typeof props>).forEach((key) => {\n if (forwardProps.includes(key as keyof TProps)) {\n (forwardedProps as any)[key] = props[key];\n } else {\n (primitiveProps as any)[key] = props[key];\n }\n });\n\n const callback = useActionButton(forwardedProps as TProps);\n return (\n <Primitive.button\n type=\"button\"\n disabled={!callback}\n {...primitiveProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(primitiveProps.onClick, () => {\n callback?.();\n })}\n />\n );\n });\n\n ActionButton.displayName = displayName;\n\n return ActionButton;\n};\n","\"use client\";\n\nimport { useActionBarCopy } from \"../../primitive-hooks/actionBar/useActionBarCopy\";\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\n\nexport type ActionBarPrimitiveCopyProps = ActionButtonProps<\n typeof useActionBarCopy\n>;\n\nexport const ActionBarPrimitiveCopy = createActionButton(\n \"ActionBarPrimitive.Copy\",\n useActionBarCopy,\n [\"copiedDuration\"],\n);\n","\"use client\";\n\nimport { useActionBarReload } from \"../../primitive-hooks/actionBar/useActionBarReload\";\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\n\nexport type ActionBarPrimitiveReloadProps = ActionButtonProps<\n typeof useActionBarReload\n>;\n\nexport const ActionBarPrimitiveReload = createActionButton(\n \"ActionBarPrimitive.Reload\",\n useActionBarReload,\n);\n","\"use client\";\n\nimport { useActionBarEdit } from \"../../primitive-hooks/actionBar/useActionBarEdit\";\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\n\nexport type ActionBarPrimitiveEditProps = ActionButtonProps<\n typeof useActionBarEdit\n>;\n\nexport const ActionBarPrimitiveEdit = createActionButton(\n \"ActionBarPrimitive.Edit\",\n useActionBarEdit,\n);\n","export { AssistantModalPrimitiveRoot as Root } from \"./AssistantModalRoot\";\nexport { AssistantModalPrimitiveTrigger as Trigger } from \"./AssistantModalTrigger\";\nexport { AssistantModalPrimitiveContent as Content } from \"./AssistantModalContent\";\nexport { AssistantModalPrimitiveAnchor as Anchor } from \"./AssistantModalAnchor\";\n","\"use client\";\n\nimport { FC, useState } from \"react\";\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useOnComposerFocus } from \"../../utils/hooks/useOnComposerFocus\";\nimport { ScopedProps, usePopoverScope } from \"./scope\";\n\nexport type AssistantModalPrimitiveRootProps = PopoverPrimitive.PopoverProps;\n\nconst useAssistantModalOpenState = (defaultOpen = false) => {\n const state = useState(defaultOpen);\n\n const [, setOpen] = state;\n useOnComposerFocus(() => {\n setOpen(true);\n });\n\n return state;\n};\n\nexport const AssistantModalPrimitiveRoot: FC<\n AssistantModalPrimitiveRootProps\n> = ({\n __scopeAssistantModal,\n defaultOpen,\n open,\n onOpenChange,\n ...rest\n}: ScopedProps<AssistantModalPrimitiveRootProps>) => {\n const scope = usePopoverScope(__scopeAssistantModal);\n\n const [modalOpen, setOpen] = useAssistantModalOpenState(defaultOpen);\n\n return (\n <PopoverPrimitive.Root\n {...scope}\n open={open === undefined ? modalOpen : open}\n onOpenChange={composeEventHandlers(onOpenChange, setOpen)}\n {...rest}\n />\n );\n};\n\nAssistantModalPrimitiveRoot.displayName = \"AssistantModalPrimitive.Root\";\n","import { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { useEffect } from \"react\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\n\nexport const useOnComposerFocus = (callback: () => void) => {\n const callbackRef = useCallbackRef(callback);\n\n const { useComposer } = useThreadContext();\n useEffect(() => {\n return useComposer.getState().onFocus(() => {\n callbackRef();\n });\n }, [useComposer, callbackRef]);\n};\n","import * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport type { Scope } from \"@radix-ui/react-context\";\n\nexport type ScopedProps<P> = P & { __scopeAssistantModal?: Scope };\nexport const usePopoverScope = PopoverPrimitive.createPopoverScope();\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, ElementRef, forwardRef } from \"react\";\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport { ScopedProps, usePopoverScope } from \"./scope\";\n\ntype AssistantModalPrimitiveTriggerElement = ElementRef<\n typeof PopoverPrimitive.Trigger\n>;\nexport type AssistantModalPrimitiveTriggerProps = ComponentPropsWithoutRef<\n typeof PopoverPrimitive.Trigger\n>;\n\nexport const AssistantModalPrimitiveTrigger = forwardRef<\n AssistantModalPrimitiveTriggerElement,\n AssistantModalPrimitiveTriggerProps\n>(\n (\n {\n __scopeAssistantModal,\n ...rest\n }: ScopedProps<AssistantModalPrimitiveTriggerProps>,\n ref,\n ) => {\n const scope = usePopoverScope(__scopeAssistantModal);\n\n return <PopoverPrimitive.Trigger {...scope} {...rest} ref={ref} />;\n },\n);\n\nAssistantModalPrimitiveTrigger.displayName = \"AssistantModalPrimitive.Trigger\";\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, ElementRef, forwardRef } from \"react\";\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport { ScopedProps, usePopoverScope } from \"./scope\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\n\ntype AssistantModalPrimitiveContentElement = ElementRef<\n typeof PopoverPrimitive.Content\n>;\nexport type AssistantModalPrimitiveContentProps = ComponentPropsWithoutRef<\n typeof PopoverPrimitive.Content\n> & {\n dissmissOnInteractOutside?: boolean | undefined;\n};\n\nexport const AssistantModalPrimitiveContent = forwardRef<\n AssistantModalPrimitiveContentElement,\n AssistantModalPrimitiveContentProps\n>(\n (\n {\n __scopeAssistantModal,\n side,\n align,\n onInteractOutside,\n dissmissOnInteractOutside = false,\n ...props\n }: ScopedProps<AssistantModalPrimitiveContentProps>,\n forwardedRef,\n ) => {\n const scope = usePopoverScope(__scopeAssistantModal);\n\n return (\n <PopoverPrimitive.Portal {...scope}>\n <PopoverPrimitive.Content\n {...scope}\n {...props}\n ref={forwardedRef}\n side={side ?? \"top\"}\n align={align ?? \"end\"}\n onInteractOutside={composeEventHandlers(\n onInteractOutside,\n dissmissOnInteractOutside ? undefined : (e) => e.preventDefault(),\n )}\n />\n </PopoverPrimitive.Portal>\n );\n },\n);\n\nAssistantModalPrimitiveContent.displayName = \"AssistantModalPrimitive.Content\";\n","\"use client\";\nimport { ComponentPropsWithoutRef, ElementRef, forwardRef } from \"react\";\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport { ScopedProps, usePopoverScope } from \"./scope\";\n\ntype AssistantModalPrimitiveAnchorElement = ElementRef<\n typeof PopoverPrimitive.Anchor\n>;\ntype AssistantModalPrimitiveAnchorProps = ComponentPropsWithoutRef<\n typeof PopoverPrimitive.Anchor\n>;\n\nexport const AssistantModalPrimitiveAnchor = forwardRef<\n AssistantModalPrimitiveAnchorElement,\n AssistantModalPrimitiveAnchorProps\n>(\n (\n {\n __scopeAssistantModal,\n ...rest\n }: ScopedProps<AssistantModalPrimitiveAnchorProps>,\n ref,\n ) => {\n const scope = usePopoverScope(__scopeAssistantModal);\n\n return <PopoverPrimitive.Anchor {...scope} {...rest} ref={ref} />;\n },\n);\nAssistantModalPrimitiveAnchor.displayName = \"AssistantModalPrimitive.Anchor\";\n","export { BranchPickerPrimitiveNext as Next } from \"./BranchPickerNext\";\nexport { BranchPickerPrevious as Previous } from \"./BranchPickerPrevious\";\nexport { BranchPickerPrimitiveCount as Count } from \"./BranchPickerCount\";\nexport { BranchPickerPrimitiveNumber as Number } from \"./BranchPickerNumber\";\nexport { BranchPickerPrimitiveRoot as Root } from \"./BranchPickerRoot\";\n","\"use client\";\n\nimport { useBranchPickerNext } from \"../../primitive-hooks/branchPicker/useBranchPickerNext\";\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\n\nexport type BranchPickerPrimitiveNextProps = ActionButtonProps<\n typeof useBranchPickerNext\n>;\n\nexport const BranchPickerPrimitiveNext = createActionButton(\n \"BranchPickerPrimitive.Next\",\n useBranchPickerNext,\n);\n","\"use client\";\n\nimport { useBranchPickerPrevious } from \"../../primitive-hooks/branchPicker/useBranchPickerPrevious\";\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\n\nexport type BranchPickerPrimitivePreviousProps = ActionButtonProps<\n typeof useBranchPickerPrevious\n>;\n\nexport const BranchPickerPrevious = createActionButton(\n \"BranchPickerPrimitive.Previous\",\n useBranchPickerPrevious,\n);\n","\"use client\";\n\nimport type { FC } from \"react\";\nimport { useBranchPickerCount } from \"../../primitive-hooks/branchPicker/useBranchPickerCount\";\n\nexport type BranchPickerPrimitiveCountProps = {};\n\nexport const BranchPickerPrimitiveCount: FC<\n BranchPickerPrimitiveCountProps\n> = () => {\n const branchCount = useBranchPickerCount();\n return <>{branchCount}</>;\n};\n\nBranchPickerPrimitiveCount.displayName = \"BranchPickerPrimitive.Count\";\n","\"use client\";\n\nimport type { FC } from \"react\";\nimport { useBranchPickerNumber } from \"../../primitive-hooks/branchPicker/useBranchPickerNumber\";\n\nexport type BranchPickerPrimitiveNumberProps = {};\n\nexport const BranchPickerPrimitiveNumber: FC<\n BranchPickerPrimitiveNumberProps\n> = () => {\n const branchNumber = useBranchPickerNumber();\n return <>{branchNumber}</>;\n};\n\nBranchPickerPrimitiveNumber.displayName = \"BranchPickerPrimitive.Number\";\n","\"use client\";\n\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { type ElementRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\nimport { If } from \"../message\";\n\ntype BranchPickerPrimitiveRootElement = ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport type BranchPickerPrimitiveRootProps = PrimitiveDivProps & {\n hideWhenSingleBranch?: boolean | undefined;\n};\n\nexport const BranchPickerPrimitiveRoot = forwardRef<\n BranchPickerPrimitiveRootElement,\n BranchPickerPrimitiveRootProps\n>(({ hideWhenSingleBranch, ...rest }, ref) => {\n return (\n <If hasBranches={hideWhenSingleBranch ? true : undefined}>\n <Primitive.div {...rest} ref={ref} />\n </If>\n );\n});\n\nBranchPickerPrimitiveRoot.displayName = \"BranchPickerPrimitive.Root\";\n","export { MessagePrimitiveRoot as Root } from \"./MessageRoot\";\nexport { MessagePrimitiveIf as If } from \"./MessageIf\";\nexport { MessagePrimitiveContent as Content } from \"./MessageContent\";\nexport { MessagePrimitiveInProgress as InProgress } from \"./MessageInProgress\";\n","\"use client\";\n\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport {\n type ElementRef,\n forwardRef,\n ComponentPropsWithoutRef,\n useCallback,\n} from \"react\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\n\ntype MessagePrimitiveRootElement = ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nconst useIsHoveringRef = () => {\n const { useMessageUtils } = useMessageContext();\n\n const callbackRef = useCallback(\n (el: HTMLElement) => {\n const setIsHovering = useMessageUtils.getState().setIsHovering;\n\n const handleMouseEnter = () => {\n setIsHovering(true);\n };\n const handleMouseLeave = () => {\n setIsHovering(false);\n };\n\n el.addEventListener(\"mouseenter\", handleMouseEnter);\n el.addEventListener(\"mouseleave\", handleMouseLeave);\n\n return () => {\n el.removeEventListener(\"mouseenter\", handleMouseEnter);\n el.removeEventListener(\"mouseleave\", handleMouseLeave);\n setIsHovering(false);\n };\n },\n [useMessageUtils],\n );\n\n return useManagedRef(callbackRef);\n};\n\nexport type MessagePrimitiveRootProps = PrimitiveDivProps;\n\nexport const MessagePrimitiveRoot = forwardRef<\n MessagePrimitiveRootElement,\n MessagePrimitiveRootProps\n>(({ onMouseEnter, onMouseLeave, ...rest }, forwardRef) => {\n const isHoveringRef = useIsHoveringRef();\n const ref = useComposedRefs<HTMLDivElement>(forwardRef, isHoveringRef);\n\n return <Primitive.div {...rest} ref={ref} />;\n});\n\nMessagePrimitiveRoot.displayName = \"MessagePrimitive.Root\";\n","\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport {\n UseMessageIfProps,\n useMessageIf,\n} from \"../../primitive-hooks/message/useMessageIf\";\n\nexport type MessagePrimitiveIfProps = PropsWithChildren<UseMessageIfProps>;\n\nexport const MessagePrimitiveIf: FC<MessagePrimitiveIfProps> = ({\n children,\n ...query\n}) => {\n const result = useMessageIf(query);\n return result ? children : null;\n};\n\nMessagePrimitiveIf.displayName = \"MessagePrimitive.If\";\n","\"use client\";\n\nimport { type ComponentType, type FC, memo } from \"react\";\nimport {\n useAssistantContext,\n useContentPartContext,\n useThreadContext,\n} from \"../../context\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport {\n ContentPartProvider,\n EMPTY_CONTENT,\n} from \"../../context/providers/ContentPartProvider\";\nimport { ContentPartPrimitiveText } from \"../contentPart/ContentPartText\";\nimport { ContentPartPrimitiveImage } from \"../contentPart/ContentPartImage\";\nimport { ContentPartPrimitiveDisplay } from \"../contentPart/ContentPartDisplay\";\nimport type {\n ImageContentPartComponent,\n TextContentPartComponent,\n ToolCallContentPartComponent,\n ToolCallContentPartProps,\n UIContentPartComponent,\n} from \"../../types/ContentPartComponentTypes\";\nimport { ContentPartPrimitiveInProgress } from \"../contentPart/ContentPartInProgress\";\n\nexport type MessagePrimitiveContentProps = {\n components?:\n | {\n Empty?: TextContentPartComponent | undefined;\n Text?: TextContentPartComponent | undefined;\n Image?: ImageContentPartComponent | undefined;\n UI?: UIContentPartComponent | undefined;\n tools?: {\n by_name?:\n | Record<string, ToolCallContentPartComponent | undefined>\n | undefined;\n Fallback?: ComponentType<ToolCallContentPartProps> | undefined;\n };\n }\n | undefined;\n};\n\nconst defaultComponents = {\n Text: () => (\n <p style={{ whiteSpace: \"pre-line\" }}>\n <ContentPartPrimitiveText />\n <ContentPartPrimitiveInProgress>\n <span style={{ fontFamily: \"revert\" }}>{\" \\u25CF\"}</span>\n </ContentPartPrimitiveInProgress>\n </p>\n ),\n Image: () => <ContentPartPrimitiveImage />,\n UI: () => <ContentPartPrimitiveDisplay />,\n tools: {\n Fallback: (props) => {\n const { useToolUIs } = useAssistantContext();\n const Render = useToolUIs((s) => s.getToolUI(props.part.toolName));\n if (!Render) return null;\n return <Render {...props} />;\n },\n },\n} satisfies MessagePrimitiveContentProps[\"components\"];\n\ntype MessageContentPartComponentProps = {\n components: MessagePrimitiveContentProps[\"components\"];\n};\n\nconst MessageContentPartComponent: FC<MessageContentPartComponentProps> = ({\n components: {\n Empty = defaultComponents.Text,\n Text = defaultComponents.Text,\n Image = defaultComponents.Image,\n UI = defaultComponents.UI,\n tools: { by_name = {}, Fallback = defaultComponents.tools.Fallback } = {},\n } = {},\n}) => {\n const { useThreadActions } = useThreadContext();\n const { useMessage } = useMessageContext();\n const addToolResult = useThreadActions((t) => t.addToolResult);\n\n const { useContentPart } = useContentPartContext();\n const { part, status } = useContentPart();\n\n const type = part.type;\n switch (type) {\n case \"text\":\n if (status.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n if (part === EMPTY_CONTENT) return <Empty part={part} status={status} />;\n\n return <Text part={part} status={status} />;\n\n case \"image\":\n if (status.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n // eslint-disable-next-line jsx-a11y/alt-text\n return <Image part={part} status={status} />;\n\n case \"ui\":\n if (status.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n return <UI part={part} status={status} />;\n\n case \"tool-call\": {\n const Tool = by_name[part.toolName] || Fallback;\n const addResult = (result: any) =>\n addToolResult({\n messageId: useMessage.getState().message.id,\n toolCallId: part.toolCallId,\n result,\n });\n return <Tool part={part} status={status} addResult={addResult} />;\n }\n default:\n const unhandledType: never = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n};\n\ntype MessageContentPartProps = {\n partIndex: number;\n components: MessagePrimitiveContentProps[\"components\"];\n};\n\nconst MessageContentPartImpl: FC<MessageContentPartProps> = ({\n partIndex,\n components,\n}) => {\n return (\n <ContentPartProvider partIndex={partIndex}>\n <MessageContentPartComponent components={components} />\n </ContentPartProvider>\n );\n};\n\nconst MessageContentPart = memo(\n MessageContentPartImpl,\n (prev, next) =>\n prev.partIndex === next.partIndex &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.UI === next.components?.UI &&\n prev.components?.tools === next.components?.tools,\n);\n\nexport const MessagePrimitiveContent: FC<MessagePrimitiveContentProps> = ({\n components,\n}) => {\n const { useMessage } = useMessageContext();\n\n const contentLength = useMessage((s) => s.message.content.length) || 1;\n\n return new Array(contentLength).fill(null).map((_, idx) => {\n const partIndex = idx; // use the index as key, as message is generally append only\n return (\n <MessageContentPart\n key={partIndex}\n partIndex={partIndex}\n components={components}\n />\n );\n });\n};\n\nMessagePrimitiveContent.displayName = \"MessagePrimitive.Content\";\n","\"use client\";\n\nimport { type FC, type PropsWithChildren, useEffect, useState } from \"react\";\nimport { StoreApi, create } from \"zustand\";\nimport { ContentPartContext } from \"../react/ContentPartContext\";\nimport type { ContentPartContextValue } from \"../react/ContentPartContext\";\nimport { useMessageContext } from \"../react/MessageContext\";\nimport type { MessageState } from \"../stores\";\nimport type { ContentPartState } from \"../stores/ContentPart\";\nimport {\n ContentPartStatus,\n ThreadAssistantContentPart,\n ThreadMessage,\n ThreadUserContentPart,\n ToolCallContentPartStatus,\n} from \"../../types/AssistantTypes\";\n\ntype ContentPartProviderProps = PropsWithChildren<{\n partIndex: number;\n}>;\n\nconst COMPLETE_STATUS: ContentPartStatus = {\n type: \"complete\",\n};\n\nconst toContentPartStatus = (\n message: ThreadMessage,\n partIndex: number,\n part: ThreadUserContentPart | ThreadAssistantContentPart,\n): ToolCallContentPartStatus => {\n if (message.role !== \"assistant\") return COMPLETE_STATUS;\n\n const isLastPart = partIndex === Math.max(0, message.content.length - 1);\n if (part.type !== \"tool-call\") {\n if (\n \"reason\" in message.status &&\n message.status.reason === \"tool-calls\" &&\n isLastPart\n )\n throw new Error(\n \"Encountered unexpected requires-action status. This is likely an internal bug in assistant-ui.\",\n );\n\n return isLastPart ? (message.status as ContentPartStatus) : COMPLETE_STATUS;\n }\n\n if (!!part.result) {\n return COMPLETE_STATUS;\n }\n\n return message.status as ToolCallContentPartStatus;\n};\n\nexport const EMPTY_CONTENT = Object.freeze({ type: \"text\", text: \"\" });\n\nconst getContentPartState = (\n { message }: MessageState,\n useContentPart: ContentPartContextValue[\"useContentPart\"] | undefined,\n partIndex: number,\n) => {\n let part = message.content[partIndex];\n if (!part) {\n // for empty messages, show an empty text content part\n if (message.content.length === 0 && partIndex === 0) {\n part = EMPTY_CONTENT;\n } else {\n return null;\n }\n }\n\n // if the content part is the same, don't update\n const status = toContentPartStatus(message, partIndex, part);\n const currentState = useContentPart?.getState();\n if (\n currentState &&\n currentState.part === part &&\n currentState.status === status\n )\n return null;\n\n return Object.freeze({ part, status });\n};\n\nconst useContentPartContext = (partIndex: number) => {\n const { useMessage } = useMessageContext();\n const [context] = useState<ContentPartContextValue>(() => {\n const useContentPart = create<ContentPartState>(\n () => getContentPartState(useMessage.getState(), undefined, partIndex)!,\n );\n\n return { useContentPart };\n });\n\n useEffect(() => {\n const syncContentPart = (message: MessageState) => {\n const newState = getContentPartState(\n message,\n context.useContentPart,\n partIndex,\n );\n if (!newState) return;\n (\n context.useContentPart as unknown as StoreApi<ContentPartState>\n ).setState(newState, true);\n };\n\n syncContentPart(useMessage.getState());\n return useMessage.subscribe(syncContentPart);\n }, [context, useMessage, partIndex]);\n\n return context;\n};\n\nexport const ContentPartProvider: FC<ContentPartProviderProps> = ({\n partIndex,\n children,\n}) => {\n const context = useContentPartContext(partIndex);\n\n return (\n <ContentPartContext.Provider value={context}>\n {children}\n </ContentPartContext.Provider>\n );\n};\n","\"use client\";\n\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport {\n type ElementRef,\n forwardRef,\n ComponentPropsWithoutRef,\n ElementType,\n} from \"react\";\nimport { useContentPartText } from \"../../primitive-hooks/contentPart/useContentPartText\";\nimport { useSmooth } from \"../../utils/smooth/useSmooth\";\n\ntype ContentPartPrimitiveTextElement = ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = ComponentPropsWithoutRef<typeof Primitive.span>;\n\nexport type ContentPartPrimitiveTextProps = Omit<\n PrimitiveSpanProps,\n \"children\" | \"asChild\"\n> & {\n smooth?: boolean;\n component?: ElementType;\n};\n\nexport const ContentPartPrimitiveText = forwardRef<\n ContentPartPrimitiveTextElement,\n ContentPartPrimitiveTextProps\n>(({ smooth = true, component: Component = \"span\", ...rest }, forwardedRef) => {\n const {\n part: { text },\n status,\n } = useSmooth(useContentPartText(), smooth);\n\n return (\n <Component data-status={status.type} {...rest} ref={forwardedRef}>\n {text}\n </Component>\n );\n});\n\nContentPartPrimitiveText.displayName = \"ContentPartPrimitive.Text\";\n","\"use client\";\n\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useMessageContext } from \"../../context\";\nimport {\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../../types/AssistantTypes\";\nimport { TextContentPartState } from \"../../context/stores/ContentPart\";\nimport { useSmoothContext } from \"./SmoothContext\";\nimport { StoreApi } from \"zustand\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\n\nclass TextStreamAnimator {\n private animationFrameId: number | null = null;\n private lastUpdateTime: number = Date.now();\n\n public targetText: string = \"\";\n\n constructor(\n public currentText: string,\n private setText: (newText: string) => void,\n ) {}\n\n start() {\n if (this.animationFrameId !== null) return;\n this.lastUpdateTime = Date.now();\n this.animate();\n }\n\n stop() {\n if (this.animationFrameId !== null) {\n cancelAnimationFrame(this.animationFrameId);\n this.animationFrameId = null;\n }\n }\n\n private animate = () => {\n const currentTime = Date.now();\n const deltaTime = currentTime - this.lastUpdateTime;\n let timeToConsume = deltaTime;\n\n const remainingChars = this.targetText.length - this.currentText.length;\n const baseTimePerChar = Math.min(5, 250 / remainingChars);\n\n let charsToAdd = 0;\n while (timeToConsume >= baseTimePerChar && charsToAdd < remainingChars) {\n charsToAdd++;\n timeToConsume -= baseTimePerChar;\n }\n\n if (charsToAdd !== remainingChars) {\n this.animationFrameId = requestAnimationFrame(this.animate);\n } else {\n this.animationFrameId = null;\n }\n if (charsToAdd === 0) return;\n\n this.currentText = this.targetText.slice(\n 0,\n this.currentText.length + charsToAdd,\n );\n this.lastUpdateTime = currentTime - timeToConsume;\n this.setText(this.currentText);\n };\n}\n\nconst SMOOTH_STATUS: ContentPartStatus = Object.freeze({\n type: \"running\",\n});\n\nexport const useSmooth = (\n state: TextContentPartState,\n smooth: boolean = false,\n): TextContentPartState => {\n const { useSmoothStatus } = useSmoothContext({ optional: true }) ?? {};\n\n const {\n part: { text },\n } = state;\n const { useMessage } = useMessageContext();\n const id = useMessage((m) => m.message.id);\n\n const idRef = useRef(id);\n const [displayedText, setDisplayedText] = useState(text);\n\n const setText = useCallbackRef((text: string) => {\n setDisplayedText(text);\n (\n useSmoothStatus as unknown as\n | StoreApi<ToolCallContentPartStatus>\n | undefined\n )?.setState(text !== state.part.text ? SMOOTH_STATUS : state.status);\n });\n\n const [animatorRef] = useState<TextStreamAnimator>(\n new TextStreamAnimator(text, setText),\n );\n\n useEffect(() => {\n if (!smooth) {\n animatorRef.stop();\n return;\n }\n\n if (idRef.current !== id || !text.startsWith(animatorRef.targetText)) {\n idRef.current = id;\n setText(text);\n\n animatorRef.currentText = text;\n animatorRef.targetText = text;\n animatorRef.stop();\n\n return;\n }\n\n animatorRef.targetText = text;\n animatorRef.start();\n }, [setText, animatorRef, id, smooth, text]);\n\n useEffect(() => {\n return () => {\n animatorRef.stop();\n };\n }, [animatorRef]);\n\n return useMemo(\n () =>\n smooth\n ? {\n part: { type: \"text\", text: displayedText },\n status: text === displayedText ? state.status : SMOOTH_STATUS,\n }\n : state,\n [smooth, displayedText, state, text],\n );\n};\n","import {\n createContext,\n FC,\n forwardRef,\n PropsWithChildren,\n useContext,\n useState,\n} from \"react\";\nimport { useContentPartContext } from \"../../context\";\nimport { ReadonlyStore } from \"../../context/ReadonlyStore\";\nimport { create } from \"zustand\";\nimport {\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../../types/AssistantTypes\";\n\ntype SmoothContextValue = {\n useSmoothStatus: ReadonlyStore<ToolCallContentPartStatus | ContentPartStatus>;\n};\n\nconst SmoothContext = createContext<SmoothContextValue | null>(null);\n\nconst makeSmoothContext = (\n initialState: ContentPartStatus | ToolCallContentPartStatus,\n) => {\n const useSmoothStatus = create(() => initialState);\n return { useSmoothStatus };\n};\n\nexport const SmoothContextProvider: FC<PropsWithChildren> = ({ children }) => {\n const outer = useSmoothContext({ optional: true });\n const { useContentPart } = useContentPartContext();\n\n const [context] = useState(() =>\n makeSmoothContext(useContentPart.getState().status),\n );\n\n // do not wrap if there is an outer SmoothContextProvider\n if (outer) return children;\n\n return (\n <SmoothContext.Provider value={context}>{children}</SmoothContext.Provider>\n );\n};\n\nexport const withSmoothContextProvider = <C extends React.ComponentType<any>>(\n Component: C,\n): C => {\n const Wrapped = forwardRef((props, ref) => {\n return (\n <SmoothContextProvider>\n <Component {...(props as any)} ref={ref} />\n </SmoothContextProvider>\n );\n });\n Wrapped.displayName = Component.displayName;\n return Wrapped as any;\n};\n\nexport function useSmoothContext(): SmoothContextValue;\nexport function useSmoothContext(options: {\n optional: true;\n}): SmoothContextValue | null;\nexport function useSmoothContext(options?: { optional: true }) {\n const context = useContext(SmoothContext);\n if (!options?.optional && !context)\n throw new Error(\n \"This component must be used within a SmoothContextProvider.\",\n );\n return context;\n}\n\nexport const useSmoothStatus = () => {\n const { useSmoothStatus } = useSmoothContext();\n return useSmoothStatus();\n};\n","import { Primitive } from \"@radix-ui/react-primitive\";\nimport { type ElementRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\nimport { useContentPartImage } from \"../../primitive-hooks/contentPart/useContentPartImage\";\n\ntype ContentPartPrimitiveImageElement = ElementRef<typeof Primitive.img>;\ntype PrimitiveImageProps = ComponentPropsWithoutRef<typeof Primitive.img>;\n\nexport type ContentPartPrimitiveImageProps = PrimitiveImageProps;\n\nexport const ContentPartPrimitiveImage = forwardRef<\n ContentPartPrimitiveImageElement,\n ContentPartPrimitiveImageProps\n>((props, forwardedRef) => {\n const {\n part: { image },\n } = useContentPartImage();\n return <Primitive.img src={image} {...props} ref={forwardedRef} />;\n});\n\nContentPartPrimitiveImage.displayName = \"ContentPartPrimitive.Image\";\n","import type { FC } from \"react\";\nimport { useContentPartDisplay } from \"../../primitive-hooks/contentPart/useContentPartDisplay\";\n\nexport type ContentPartPrimitiveDisplayProps = {};\n\nexport const ContentPartPrimitiveDisplay: FC<\n ContentPartPrimitiveDisplayProps\n> = () => {\n const {\n part: { display },\n } = useContentPartDisplay();\n return display ?? null;\n};\n\nContentPartPrimitiveDisplay.displayName = \"ContentPartPrimitive.Display\";\n","import { FC, PropsWithChildren } from \"react\";\nimport { useContentPartContext } from \"../../context\";\n\nexport type ContentPartPrimitiveInProgressProps = PropsWithChildren;\n\nexport const ContentPartPrimitiveInProgress: FC<\n ContentPartPrimitiveInProgressProps\n> = ({ children }) => {\n const { useContentPart } = useContentPartContext();\n const isInProgress = useContentPart((c) => c.status.type === \"running\");\n\n return isInProgress ? children : null;\n};\n\nContentPartPrimitiveInProgress.displayName = \"ContentPartPrimitive.InProgress\";\n","\"use client\";\n\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { ComponentPropsWithoutRef, FC } from \"react\";\n\ntype PrimitiveSpanProps = ComponentPropsWithoutRef<typeof Primitive.span>;\n\nexport type MessagePrimitiveInProgressProps = PrimitiveSpanProps;\n\n/**\n * @deprecated Define a custom Text renderer via ContentPartPrimitiveInProgress instead.\n */\nexport const MessagePrimitiveInProgress: FC<\n MessagePrimitiveInProgressProps\n> = () => {\n return null;\n};\n\nMessagePrimitiveInProgress.displayName = \"MessagePrimitive.InProgress\";\n","export { ComposerPrimitiveRoot as Root } from \"./ComposerRoot\";\nexport { ComposerPrimitiveInput as Input } from \"./ComposerInput\";\nexport { ComposerPrimitiveSend as Send } from \"./ComposerSend\";\nexport { ComposerPrimitiveCancel as Cancel } from \"./ComposerCancel\";\nexport { ComposerPrimitiveIf as If } from \"./ComposerIf\";\n","\"use client\";\n\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport {\n type ElementRef,\n type FormEvent,\n forwardRef,\n ComponentPropsWithoutRef,\n} from \"react\";\nimport { useComposerSend } from \"../../primitive-hooks\";\n\ntype ComposerPrimitiveRootElement = ElementRef<typeof Primitive.form>;\ntype PrimitiveFormProps = ComponentPropsWithoutRef<typeof Primitive.form>;\n\nexport type ComposerPrimitiveRootProps = PrimitiveFormProps;\n\nexport const ComposerPrimitiveRoot = forwardRef<\n ComposerPrimitiveRootElement,\n ComposerPrimitiveRootProps\n>(({ onSubmit, ...rest }, forwardedRef) => {\n const send = useComposerSend();\n\n const handleSubmit = (e: FormEvent) => {\n e.preventDefault();\n\n if (!send) return;\n send();\n };\n\n return (\n <Primitive.form\n {...rest}\n ref={forwardedRef}\n onSubmit={composeEventHandlers(onSubmit, handleSubmit)}\n />\n );\n});\n\nComposerPrimitiveRoot.displayName = \"ComposerPrimitive.Root\";\n","\"use client\";\n\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport {\n type KeyboardEvent,\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport TextareaAutosize, {\n type TextareaAutosizeProps,\n} from \"react-textarea-autosize\";\nimport { useComposerContext } from \"../../context/react/ComposerContext\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport { useEscapeKeydown } from \"@radix-ui/react-use-escape-keydown\";\nimport { useOnComposerFocus } from \"../../utils/hooks/useOnComposerFocus\";\n\nexport type ComposerPrimitiveInputProps = TextareaAutosizeProps & {\n asChild?: boolean | undefined;\n};\n\nexport const ComposerPrimitiveInput = forwardRef<\n HTMLTextAreaElement,\n ComposerPrimitiveInputProps\n>(\n (\n {\n autoFocus = false,\n asChild,\n disabled: disabledProp,\n onChange,\n onKeyDown,\n ...rest\n },\n forwardedRef,\n ) => {\n const { useThread } = useThreadContext();\n const { useComposer, type } = useComposerContext();\n\n const value = useComposer((c) => {\n if (!c.isEditing) return \"\";\n return c.value;\n });\n\n const Component = asChild ? Slot : TextareaAutosize;\n\n const isDisabled = useThread((t) => t.isDisabled) ?? disabledProp ?? false;\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const ref = useComposedRefs(forwardedRef, textareaRef);\n\n useEscapeKeydown((e) => {\n const composer = useComposer.getState();\n if (composer.canCancel) {\n composer.cancel();\n e.preventDefault();\n }\n });\n\n const handleKeyPress = (e: KeyboardEvent) => {\n if (isDisabled) return;\n\n if (e.key === \"Enter\" && e.shiftKey === false) {\n const isRunning = useThread.getState().isRunning;\n if (!isRunning) {\n e.preventDefault();\n\n textareaRef.current?.closest(\"form\")?.requestSubmit();\n }\n }\n };\n\n const autoFocusEnabled = autoFocus && !isDisabled;\n const focus = useCallback(() => {\n const textarea = textareaRef.current;\n if (!textarea || !autoFocusEnabled) return;\n\n textarea.focus({ preventScroll: true });\n textarea.setSelectionRange(\n textareaRef.current.value.length,\n textareaRef.current.value.length,\n );\n }, [autoFocusEnabled]);\n\n useEffect(() => focus(), [focus]);\n\n useOnComposerFocus(() => {\n if (type === \"new\") {\n focus();\n }\n });\n\n return (\n <Component\n name=\"input\"\n value={value}\n {...rest}\n ref={ref}\n disabled={isDisabled}\n onChange={composeEventHandlers(onChange, (e) => {\n const composerState = useComposer.getState();\n if (!composerState.isEditing) return;\n return composerState.setValue(e.target.value);\n })}\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyPress)}\n />\n );\n },\n);\n\nComposerPrimitiveInput.displayName = \"ComposerPrimitive.Input\";\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, ElementRef, forwardRef } from \"react\";\nimport { useComposerContext } from \"../../context\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\n\ntype ComposerPrimitiveSendElement = ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = ComponentPropsWithoutRef<typeof Primitive.button>;\n\nexport type ComposerPrimitiveSendProps = PrimitiveButtonProps;\n\nexport const ComposerPrimitiveSend = forwardRef<\n ComposerPrimitiveSendElement,\n ComposerPrimitiveSendProps\n>(({ disabled, ...rest }, ref) => {\n const { useComposer } = useComposerContext();\n const hasValue = useComposer((c) => c.isEditing && c.value.length > 0);\n\n return (\n <Primitive.button\n type=\"submit\"\n {...rest}\n ref={ref}\n disabled={disabled || !hasValue}\n />\n );\n});\n\nComposerPrimitiveSend.displayName = \"ComposerPrimitive.Send\";\n","\"use client\";\n\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useComposerCancel } from \"../../primitive-hooks/composer/useComposerCancel\";\n\nexport type ComposerPrimitiveCancelProps = ActionButtonProps<\n typeof useComposerCancel\n>;\n\nexport const ComposerPrimitiveCancel = createActionButton(\n \"ComposerPrimitive.Cancel\",\n useComposerCancel,\n);\n","\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport {\n UseComposerIfProps,\n useComposerIf,\n} from \"../../primitive-hooks/composer/useComposerIf\";\n\nexport type ComposerPrimitiveIfProps = PropsWithChildren<UseComposerIfProps>;\n\nexport const ComposerPrimitiveIf: FC<ComposerPrimitiveIfProps> = ({\n children,\n ...query\n}) => {\n const result = useComposerIf(query);\n return result ? children : null;\n};\n\nComposerPrimitiveIf.displayName = \"ComposerPrimitive.If\";\n","export { ContentPartPrimitiveText as Text } from \"./ContentPartText\";\nexport { ContentPartPrimitiveImage as Image } from \"./ContentPartImage\";\nexport { ContentPartPrimitiveDisplay as Display } from \"./ContentPartDisplay\";\nexport { ContentPartPrimitiveInProgress as InProgress } from \"./ContentPartInProgress\";\n","export { ThreadPrimitiveRoot as Root } from \"./ThreadRoot\";\nexport { ThreadPrimitiveEmpty as Empty } from \"./ThreadEmpty\";\nexport { ThreadPrimitiveIf as If } from \"./ThreadIf\";\nexport { ThreadPrimitiveViewport as Viewport } from \"./ThreadViewport\";\nexport { ThreadPrimitiveMessages as Messages } from \"./ThreadMessages\";\nexport { ThreadPrimitiveScrollToBottom as ScrollToBottom } from \"./ThreadScrollToBottom\";\nexport { ThreadPrimitiveSuggestion as Suggestion } from \"./ThreadSuggestion\";\n","\"use client\";\n\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { type ElementRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\n\ntype ThreadPrimitiveRootElement = ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport type ThreadPrimitiveRootProps = PrimitiveDivProps;\n\nexport const ThreadPrimitiveRoot = forwardRef<\n ThreadPrimitiveRootElement,\n ThreadPrimitiveRootProps\n>((props, ref) => {\n return <Primitive.div {...props} ref={ref} />;\n});\n\nThreadPrimitiveRoot.displayName = \"ThreadPrimitive.Root\";\n","\"use client\";\n\nimport type { FC, ReactNode } from \"react\";\nimport { useThreadEmpty } from \"../../primitive-hooks\";\n\nexport type ThreadPrimitiveEmptyProps = {\n children: ReactNode;\n};\n\nexport const ThreadPrimitiveEmpty: FC<ThreadPrimitiveEmptyProps> = ({\n children,\n}) => {\n const empty = useThreadEmpty();\n return empty ? children : null;\n};\n\nThreadPrimitiveEmpty.displayName = \"ThreadPrimitive.Empty\";\n","\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport {\n UseThreadIfProps,\n useThreadIf,\n} from \"../../primitive-hooks/thread/useThreadIf\";\n\nexport type ThreadPrimitiveIfProps = PropsWithChildren<UseThreadIfProps>;\n\nexport const ThreadPrimitiveIf: FC<ThreadPrimitiveIfProps> = ({\n children,\n ...query\n}) => {\n const result = useThreadIf(query);\n return result ? children : null;\n};\n\nThreadPrimitiveIf.displayName = \"ThreadPrimitive.If\";\n","\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { type ElementRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\nimport {\n UseThreadViewportAutoScrollProps,\n useThreadViewportAutoScroll,\n} from \"../../primitive-hooks/thread/useThreadViewportAutoScroll\";\n\ntype ThreadPrimitiveViewportElement = ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport type ThreadPrimitiveViewportProps = PrimitiveDivProps &\n UseThreadViewportAutoScrollProps;\n\nexport const ThreadPrimitiveViewport = forwardRef<\n ThreadPrimitiveViewportElement,\n ThreadPrimitiveViewportProps\n>(({ autoScroll, onScroll, children, ...rest }, forwardedRef) => {\n const autoScrollRef = useThreadViewportAutoScroll<HTMLDivElement>({\n autoScroll,\n });\n\n const ref = useComposedRefs(forwardedRef, autoScrollRef);\n\n return (\n <Primitive.div {...rest} ref={ref}>\n {children}\n </Primitive.div>\n );\n});\n\nThreadPrimitiveViewport.displayName = \"ThreadPrimitive.Viewport\";\n","\"use client\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { useRef } from \"react\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport { useOnResizeContent } from \"../../utils/hooks/useOnResizeContent\";\nimport { useOnScrollToBottom } from \"../../utils/hooks/useOnScrollToBottom\";\nimport { StoreApi } from \"zustand\";\nimport { ThreadViewportState } from \"../../context\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\n\nexport type UseThreadViewportAutoScrollProps = {\n autoScroll?: boolean | undefined;\n};\n\nexport const useThreadViewportAutoScroll = <TElement extends HTMLElement>({\n autoScroll = true,\n}: UseThreadViewportAutoScrollProps) => {\n const divRef = useRef<TElement>(null);\n\n const { useViewport } = useThreadContext();\n\n const lastScrollTop = useRef<number>(0);\n\n // bug: when ScrollToBottom's button changes its disabled state, the scroll stops\n // fix: delay the state change until the scroll is done\n const isScrollingToBottomRef = useRef(false);\n\n const scrollToBottom = (behavior: ScrollBehavior) => {\n const div = divRef.current;\n if (!div || !autoScroll) return;\n\n isScrollingToBottomRef.current = true;\n div.scrollTo({ top: div.scrollHeight, behavior });\n };\n\n const handleScroll = () => {\n const div = divRef.current;\n if (!div) return;\n\n const isAtBottom = useViewport.getState().isAtBottom;\n const newIsAtBottom =\n div.scrollHeight - div.scrollTop <= div.clientHeight + 1; // TODO figure out why +1 is needed\n\n if (!newIsAtBottom && lastScrollTop.current < div.scrollTop) {\n // ignore scroll down\n } else {\n if (newIsAtBottom) {\n isScrollingToBottomRef.current = false;\n }\n\n if (newIsAtBottom !== isAtBottom) {\n (useViewport as unknown as StoreApi<ThreadViewportState>).setState({\n isAtBottom: newIsAtBottom,\n });\n }\n }\n\n lastScrollTop.current = div.scrollTop;\n };\n\n const resizeRef = useOnResizeContent(() => {\n if (isScrollingToBottomRef.current || useViewport.getState().isAtBottom) {\n scrollToBottom(\"instant\");\n }\n\n handleScroll();\n });\n\n const scrollRef = useManagedRef<HTMLElement>((el) => {\n el.addEventListener(\"scroll\", handleScroll);\n return () => {\n el.removeEventListener(\"scroll\", handleScroll);\n };\n });\n\n const autoScrollRef = useComposedRefs<TElement>(resizeRef, scrollRef, divRef);\n\n useOnScrollToBottom(() => {\n scrollToBottom(\"auto\");\n });\n\n return autoScrollRef;\n};\n","import { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { useCallback } from \"react\";\nimport { useManagedRef } from \"./useManagedRef\";\n\nexport const useOnResizeContent = (callback: () => void) => {\n const callbackRef = useCallbackRef(callback);\n\n const refCallback = useCallback(\n (el: HTMLElement) => {\n const resizeObserver = new ResizeObserver(() => {\n callbackRef();\n });\n\n const mutationObserver = new MutationObserver((mutations) => {\n for (const mutation of mutations) {\n for (const node of mutation.addedNodes) {\n if (node instanceof Element) {\n resizeObserver.observe(node);\n }\n }\n\n for (const node of mutation.removedNodes) {\n if (node instanceof Element) {\n resizeObserver.unobserve(node);\n }\n }\n }\n\n callbackRef();\n });\n\n resizeObserver.observe(el);\n mutationObserver.observe(el, { childList: true });\n\n // Observe existing children\n for (const child of el.children) {\n resizeObserver.observe(child);\n }\n\n return () => {\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n };\n },\n [callbackRef],\n );\n\n return useManagedRef(refCallback);\n};\n","import { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { useEffect } from \"react\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\n\nexport const useOnScrollToBottom = (callback: () => void) => {\n const callbackRef = useCallbackRef(callback);\n\n const { useViewport } = useThreadContext();\n useEffect(() => {\n return useViewport.getState().onScrollToBottom(() => {\n callbackRef();\n });\n }, [useViewport, callbackRef]);\n};\n","\"use client\";\n\nimport { type ComponentType, type FC, memo } from \"react\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport { MessageProvider } from \"../../context/providers/MessageProvider\";\nimport { ComposerPrimitiveIf } from \"../composer/ComposerIf\";\nimport { MessagePrimitiveIf } from \"../message/MessageIf\";\n\nexport type ThreadPrimitiveMessagesProps = {\n components:\n | {\n Message: ComponentType;\n UserMessage?: ComponentType | undefined;\n EditComposer?: ComponentType | undefined;\n AssistantMessage?: ComponentType | undefined;\n SystemMessage?: ComponentType | undefined;\n }\n | {\n Message?: ComponentType | undefined;\n UserMessage: ComponentType;\n EditComposer?: ComponentType | undefined;\n AssistantMessage: ComponentType;\n SystemMessage?: ComponentType | undefined;\n };\n};\n\nconst DEFAULT_SYSTEM_MESSAGE = () => null;\n\nconst getComponents = (\n components: ThreadPrimitiveMessagesProps[\"components\"],\n) => {\n return {\n EditComposer:\n components.EditComposer ??\n components.UserMessage ??\n (components.Message as ComponentType),\n UserMessage:\n components.UserMessage ?? (components.Message as ComponentType),\n AssistantMessage:\n components.AssistantMessage ?? (components.Message as ComponentType),\n SystemMessage: components.SystemMessage ?? DEFAULT_SYSTEM_MESSAGE,\n };\n};\n\ntype ThreadMessageProps = {\n messageIndex: number;\n components: ThreadPrimitiveMessagesProps[\"components\"];\n};\n\nconst ThreadMessageImpl: FC<ThreadMessageProps> = ({\n messageIndex,\n components,\n}) => {\n const { UserMessage, EditComposer, AssistantMessage, SystemMessage } =\n getComponents(components);\n return (\n <MessageProvider messageIndex={messageIndex}>\n <MessagePrimitiveIf user>\n <ComposerPrimitiveIf editing={false}>\n <UserMessage />\n </ComposerPrimitiveIf>\n <ComposerPrimitiveIf editing>\n <EditComposer />\n </ComposerPrimitiveIf>\n </MessagePrimitiveIf>\n <MessagePrimitiveIf assistant>\n <AssistantMessage />\n </MessagePrimitiveIf>\n <MessagePrimitiveIf system>\n <SystemMessage />\n </MessagePrimitiveIf>\n </MessageProvider>\n );\n};\n\nconst ThreadMessage = memo(\n ThreadMessageImpl,\n (prev, next) =>\n prev.messageIndex === next.messageIndex &&\n prev.components.Message === next.components.Message &&\n prev.components.UserMessage === next.components.UserMessage &&\n prev.components.EditComposer === next.components.EditComposer &&\n prev.components.AssistantMessage === next.components.AssistantMessage &&\n prev.components.SystemMessage === next.components.SystemMessage,\n);\n\nexport const ThreadPrimitiveMessagesImpl: FC<ThreadPrimitiveMessagesProps> = ({\n components,\n}) => {\n const { useThreadMessages } = useThreadContext();\n\n const messagesLength = useThreadMessages((t) => t.length);\n if (messagesLength === 0) return null;\n\n return new Array(messagesLength).fill(null).map((_, idx) => {\n const messageIndex = idx; // keep the same key when switching branches for better a11y support\n return (\n <ThreadMessage\n key={messageIndex}\n messageIndex={messageIndex}\n components={components}\n />\n );\n });\n};\n\nThreadPrimitiveMessagesImpl.displayName = \"ThreadPrimitive.Messages\";\n\nexport const ThreadPrimitiveMessages = memo(\n ThreadPrimitiveMessagesImpl,\n (prev, next) =>\n prev.components?.Message === next.components?.Message &&\n prev.components?.UserMessage === next.components?.UserMessage &&\n prev.components?.EditComposer === next.components?.EditComposer &&\n prev.components?.AssistantMessage === next.components?.AssistantMessage &&\n prev.components?.SystemMessage === next.components?.SystemMessage,\n);\n","\"use client\";\n\nimport { type FC, type PropsWithChildren, useEffect, useState } from \"react\";\nimport { StoreApi, create } from \"zustand\";\nimport type {\n CoreUserContentPart,\n ThreadMessage,\n} from \"../../types/AssistantTypes\";\nimport { getMessageText } from \"../../utils/getMessageText\";\nimport { MessageContext } from \"../react/MessageContext\";\nimport type { MessageContextValue } from \"../react/MessageContext\";\nimport { useThreadContext } from \"../react/ThreadContext\";\nimport type { MessageState } from \"../stores/Message\";\nimport { makeEditComposerStore } from \"../stores/EditComposer\";\nimport { makeMessageUtilsStore } from \"../stores/MessageUtils\";\nimport { ThreadMessagesState } from \"../stores/ThreadMessages\";\n\ntype MessageProviderProps = PropsWithChildren<{\n messageIndex: number;\n}>;\n\nconst getIsLast = (messages: ThreadMessagesState, message: ThreadMessage) => {\n return messages[messages.length - 1]?.id === message.id;\n};\n\nconst getMessageState = (\n messages: ThreadMessagesState,\n getBranches: (messageId: string) => readonly string[],\n useMessage: MessageContextValue[\"useMessage\"] | undefined,\n messageIndex: number,\n) => {\n const parentId = messages[messageIndex - 1]?.id ?? null;\n const message = messages[messageIndex];\n if (!message) return null;\n\n const isLast = getIsLast(messages, message);\n const branches = getBranches(message.id);\n\n // if the message is the same, don't update\n const currentState = useMessage?.getState();\n if (\n currentState &&\n currentState.message === message &&\n currentState.parentId === parentId &&\n currentState.branches === branches &&\n currentState.isLast === isLast\n )\n return null;\n\n return Object.freeze({\n message,\n parentId,\n branches,\n isLast,\n });\n};\n\nconst useMessageContext = (messageIndex: number) => {\n const { useThreadMessages, useThreadActions } = useThreadContext();\n\n const [context] = useState<MessageContextValue>(() => {\n const useMessage = create<MessageState>(\n () =>\n getMessageState(\n useThreadMessages.getState(),\n useThreadActions.getState().getBranches,\n undefined,\n messageIndex,\n )!,\n );\n const useMessageUtils = makeMessageUtilsStore();\n const useEditComposer = makeEditComposerStore({\n onEdit: () => {\n const message = useMessage.getState().message;\n if (message.role !== \"user\")\n throw new Error(\n \"Tried to edit a non-user message. Editing is only supported for user messages. This is likely an internal bug in assistant-ui.\",\n );\n\n const text = getMessageText(message);\n\n return text;\n },\n onSend: (text) => {\n const { message, parentId } = useMessage.getState();\n if (message.role !== \"user\")\n throw new Error(\n \"Tried to edit a non-user message. Editing is only supported for user messages. This is likely an internal bug in assistant-ui.\",\n );\n\n const nonTextParts = message.content.filter(\n (part): part is CoreUserContentPart =>\n part.type !== \"text\" && part.type !== \"ui\",\n );\n useThreadActions.getState().append({\n parentId,\n role: \"user\",\n content: [{ type: \"text\", text }, ...nonTextParts],\n });\n },\n });\n\n return { useMessage, useMessageUtils, useEditComposer };\n });\n\n useEffect(() => {\n const syncMessage = (thread: ThreadMessagesState) => {\n const newState = getMessageState(\n thread,\n useThreadActions.getState().getBranches,\n context.useMessage,\n messageIndex,\n );\n if (!newState) return;\n (context.useMessage as unknown as StoreApi<MessageState>).setState(\n newState,\n true,\n );\n };\n\n syncMessage(useThreadMessages.getState());\n\n return useThreadMessages.subscribe(syncMessage);\n }, [useThreadMessages, useThreadActions, context, messageIndex]);\n\n return context;\n};\n\nexport const MessageProvider: FC<MessageProviderProps> = ({\n messageIndex,\n children,\n}) => {\n const context = useMessageContext(messageIndex);\n\n return (\n <MessageContext.Provider value={context}>\n {children}\n </MessageContext.Provider>\n );\n};\n","import { create } from \"zustand\";\nimport { type BaseComposerState, makeBaseComposer } from \"./BaseComposer\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type EditComposerState = BaseComposerState &\n Readonly<{\n canCancel: boolean;\n isEditing: boolean;\n\n edit: () => void;\n send: () => void;\n cancel: () => void;\n }>;\n\nexport const makeEditComposerStore = ({\n onEdit,\n onSend,\n}: {\n onEdit: () => string;\n onSend: (value: string) => void;\n}): ReadonlyStore<EditComposerState> =>\n create<EditComposerState>()((set, get, store) => ({\n ...makeBaseComposer(set, get, store),\n\n canCancel: false,\n isEditing: false,\n\n edit: () => {\n const value = onEdit();\n set({ isEditing: true, canCancel: true, value });\n },\n send: () => {\n const value = get().value;\n set({ isEditing: false, canCancel: false });\n onSend(value);\n },\n cancel: () => {\n set({ isEditing: false, canCancel: false });\n },\n }));\n","import { create } from \"zustand\";\n\nexport type MessageUtilsState = Readonly<{\n isCopied: boolean;\n setIsCopied: (value: boolean) => void;\n isHovering: boolean;\n setIsHovering: (value: boolean) => void;\n}>;\n\nexport const makeMessageUtilsStore = () =>\n create<MessageUtilsState>((set) => ({\n isCopied: false,\n setIsCopied: (value) => {\n set({ isCopied: value });\n },\n isHovering: false,\n setIsHovering: (value) => {\n set({ isHovering: value });\n },\n }));\n","\"use client\";\n\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadScrollToBottom } from \"../../primitive-hooks/thread/useThreadScrollToBottom\";\n\nexport type ThreadPrimitiveScrollToBottomProps = ActionButtonProps<\n typeof useThreadScrollToBottom\n>;\n\nexport const ThreadPrimitiveScrollToBottom = createActionButton(\n \"ThreadPrimitive.ScrollToBottom\",\n useThreadScrollToBottom,\n);\n","\"use client\";\n\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadSuggestion } from \"../../primitive-hooks/thread/useThreadSuggestion\";\n\nexport type ThreadPrimitiveSuggestionProps = ActionButtonProps<\n typeof useThreadSuggestion\n>;\n\nexport const ThreadPrimitiveSuggestion = createActionButton(\n \"ThreadPrimitive.Suggestion\",\n useThreadSuggestion,\n [\"prompt\", \"autoSend\", \"method\"],\n);\n","\"use client\";\n\nimport { useInsertionEffect, useState } from \"react\";\nimport type { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { LocalRuntime } from \"./LocalRuntime\";\nimport { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\n\nexport const useLocalRuntime = (\n adapter: ChatModelAdapter,\n options?: LocalRuntimeOptions,\n) => {\n const [runtime] = useState(() => new LocalRuntime(adapter, options));\n\n useInsertionEffect(() => {\n runtime.adapter = adapter;\n });\n\n return runtime;\n};\n","import { type ModelConfigProvider } from \"../../types/ModelConfigTypes\";\nimport type { Unsubscribe } from \"../../types/Unsubscribe\";\nimport type { AssistantRuntime } from \"./AssistantRuntime\";\nimport { ReactThreadRuntime } from \"./ReactThreadRuntime\";\n\nexport abstract class BaseAssistantRuntime<\n TThreadRuntime extends ReactThreadRuntime,\n> implements AssistantRuntime\n{\n constructor(private _thread: TThreadRuntime) {\n this._thread = _thread;\n }\n\n get thread() {\n return this._thread;\n }\n\n set thread(thread: TThreadRuntime) {\n this._thread = thread;\n this.subscriptionHandler();\n }\n\n public abstract registerModelConfigProvider(\n provider: ModelConfigProvider,\n ): Unsubscribe;\n public abstract switchToThread(threadId: string | null): void;\n\n private _subscriptions = new Set<() => void>();\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private subscriptionHandler = () => {\n for (const callback of this._subscriptions) callback();\n };\n}\n","export { ProxyConfigProvider } from \"./utils/ProxyConfigProvider\";\nexport { MessageRepository } from \"./runtimes/utils/MessageRepository\";\nexport { BaseAssistantRuntime } from \"./runtimes/core/BaseAssistantRuntime\";\nexport * from \"./utils/smooth\";\nexport { TooltipIconButton } from \"./ui/base/tooltip-icon-button\";\nexport { generateId } from \"./utils/idUtils\";\n","import { customAlphabet } from \"nanoid/non-secure\";\n\nexport const generateId = customAlphabet(\n \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",\n 7,\n);\n\nconst optimisticPrefix = \"__optimistic__\";\nexport const generateOptimisticId = () => `${optimisticPrefix}${generateId()}`;\nexport const isOptimisticId = (id: string) => id.startsWith(optimisticPrefix);\n","import { generateId } from \"../../../internal\";\nimport {\n ThreadMessage,\n CoreMessage,\n ToolCallContentPart,\n MessageStatus,\n} from \"../../../types\";\n\nexport const fromCoreMessages = (\n message: readonly CoreMessage[],\n): ThreadMessage[] => {\n return message.map((message) => fromCoreMessage(message));\n};\n\nexport const fromCoreMessage = (\n message: CoreMessage,\n {\n id = generateId(),\n status = { type: \"complete\", reason: \"unknown\" } as MessageStatus,\n } = {},\n): ThreadMessage => {\n const commonProps = {\n id,\n createdAt: new Date(),\n };\n\n const role = message.role;\n switch (role) {\n case \"assistant\":\n return {\n ...commonProps,\n role,\n content: message.content.map((part) => {\n if (part.type === \"tool-call\") {\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n } satisfies ToolCallContentPart;\n }\n return part;\n }),\n status,\n } satisfies ThreadMessage;\n\n case \"user\":\n return {\n ...commonProps,\n role,\n content: message.content,\n } satisfies ThreadMessage;\n\n case \"system\":\n return {\n ...commonProps,\n role,\n content: message.content,\n } satisfies ThreadMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n","import type { CoreMessage, ThreadMessage } from \"../../types/AssistantTypes\";\nimport { generateOptimisticId } from \"../../utils/idUtils\";\nimport { fromCoreMessage } from \"../edge/converters/fromCoreMessage\";\n\ntype RepositoryParent = {\n children: string[];\n};\n\ntype RepositoryMessage = RepositoryParent & {\n prev: RepositoryMessage | null;\n current: ThreadMessage;\n next: RepositoryMessage | null;\n level: number;\n};\n\nconst findHead = (message: RepositoryMessage): RepositoryMessage => {\n if (message.next) return findHead(message.next);\n return message;\n};\n\nexport class MessageRepository {\n private messages = new Map<string, RepositoryMessage>(); // message_id -> item\n private head: RepositoryMessage | null = null;\n private root: RepositoryParent = {\n children: [],\n };\n\n private performOp(\n newParent: RepositoryMessage | null,\n child: RepositoryMessage,\n operation: \"cut\" | \"link\" | \"relink\",\n ) {\n const parentOrRoot = child.prev ?? this.root;\n const newParentOrRoot = newParent ?? this.root;\n\n if (operation === \"relink\" && parentOrRoot === newParentOrRoot) return;\n\n // cut\n if (operation !== \"link\") {\n parentOrRoot.children = parentOrRoot.children.filter(\n (m) => m !== child.current.id,\n );\n\n if (child.prev?.next === child) {\n const fallbackId = child.prev.children.at(-1);\n const fallback = fallbackId ? this.messages.get(fallbackId) : null;\n if (fallback === undefined) {\n throw new Error(\n \"MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.\",\n );\n }\n child.prev.next = fallback;\n }\n }\n\n // link\n if (operation !== \"cut\") {\n newParentOrRoot.children = [\n ...newParentOrRoot.children,\n child.current.id,\n ];\n\n if (\n newParent &&\n (findHead(child) === this.head || newParent.next === null)\n ) {\n newParent.next = child;\n }\n\n child.prev = newParent;\n }\n }\n getMessages() {\n const messages = new Array<ThreadMessage>(this.head?.level ?? 0);\n for (let current = this.head; current; current = current.prev) {\n messages[current.level] = current.current;\n }\n return messages;\n }\n\n addOrUpdateMessage(parentId: string | null, message: ThreadMessage) {\n const existingItem = this.messages.get(message.id);\n const prev = parentId ? this.messages.get(parentId) : null;\n if (prev === undefined)\n throw new Error(\n \"MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n // update existing message\n if (existingItem) {\n existingItem.current = message;\n this.performOp(prev, existingItem, \"relink\");\n return;\n }\n\n // create a new message\n const newItem: RepositoryMessage = {\n prev,\n current: message,\n next: null,\n children: [],\n level: prev ? prev.level + 1 : 0,\n };\n\n this.messages.set(message.id, newItem);\n this.performOp(prev, newItem, \"link\");\n\n if (this.head === prev) {\n this.head = newItem;\n }\n }\n\n getMessage(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n return {\n parentId: message.prev?.current.id ?? null,\n message: message.current,\n };\n }\n\n appendOptimisticMessage(parentId: string | null, message: CoreMessage) {\n let optimisticId: string;\n do {\n optimisticId = generateOptimisticId();\n } while (this.messages.has(optimisticId));\n\n this.addOrUpdateMessage(\n parentId,\n fromCoreMessage(message, {\n id: optimisticId,\n status: { type: \"running\" },\n }),\n );\n\n return optimisticId;\n }\n\n deleteMessage(messageId: string, replacementId?: string | null | undefined) {\n const message = this.messages.get(messageId);\n\n if (!message)\n throw new Error(\n \"MessageRepository(deleteMessage): Optimistic message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const replacement =\n replacementId === undefined\n ? message.prev // if no replacementId is provided, use the parent\n : replacementId === null\n ? null\n : this.messages.get(replacementId);\n if (replacement === undefined)\n throw new Error(\n \"MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.\",\n );\n\n for (const child of message.children) {\n const childMessage = this.messages.get(child);\n if (!childMessage)\n throw new Error(\n \"MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.\",\n );\n this.performOp(replacement, childMessage, \"relink\");\n }\n\n this.performOp(null, message, \"cut\");\n this.messages.delete(messageId);\n\n if (this.head === message) {\n this.head = replacement ? findHead(replacement) : null;\n }\n }\n\n getBranches(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const { children } = message.prev ?? this.root;\n return children;\n }\n\n switchToBranch(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.\",\n );\n\n if (message.prev) {\n message.prev.next = message;\n }\n\n this.head = findHead(message);\n }\n\n resetHead(messageId: string | null) {\n if (messageId === null) {\n this.head = null;\n return;\n }\n\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.\",\n );\n\n this.head = message;\n for (\n let current: RepositoryMessage | null = message;\n current;\n current = current.prev\n ) {\n if (current.prev) {\n current.prev.next = current;\n }\n }\n }\n}\n","\"use client\";\n\nimport { forwardRef } from \"react\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"./tooltip\";\nimport { Button, ButtonProps } from \"./button\";\n\nexport type TooltipIconButtonProps = ButtonProps & {\n tooltip: string;\n side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n};\n\nexport const TooltipIconButton = forwardRef<\n HTMLButtonElement,\n TooltipIconButtonProps\n>(({ children, tooltip, side = \"bottom\", ...rest }, ref) => {\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button variant=\"ghost\" size=\"icon\" {...rest} ref={ref}>\n {children}\n <span className=\"aui-sr-only\">{tooltip}</span>\n </Button>\n </TooltipTrigger>\n <TooltipContent side={side}>{tooltip}</TooltipContent>\n </Tooltip>\n );\n});\n\nTooltipIconButton.displayName = \"TooltipIconButton\";\n","\"use client\";\n\nimport * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\nimport { withDefaults } from \"../utils/withDefaults\";\nimport { FC } from \"react\";\n\nexport const Tooltip: FC<TooltipPrimitive.TooltipProps> = (props) => {\n return (\n <TooltipPrimitive.Provider>\n <TooltipPrimitive.Root {...props} />\n </TooltipPrimitive.Provider>\n );\n};\n\nTooltip.displayName = \"Tooltip\";\n\nexport const TooltipTrigger = TooltipPrimitive.Trigger;\n\nexport const TooltipContent = withDefaults(TooltipPrimitive.Content, {\n sideOffset: 4,\n className: \"aui-tooltip-content\",\n});\n\nTooltipContent.displayName = \"TooltipContent\";\n","import {\n ComponentPropsWithoutRef,\n ElementRef,\n ElementType,\n forwardRef,\n} from \"react\";\nimport classNames from \"classnames\";\n\nexport const withDefaultProps =\n <TProps extends { className?: string }>({\n className,\n ...defaultProps\n }: Partial<TProps>) =>\n ({ className: classNameProp, ...props }: TProps) => {\n return {\n className: classNames(className, classNameProp),\n ...defaultProps,\n ...props,\n } as TProps;\n };\n\nexport const withDefaults = <TComponent extends ElementType>(\n Component: TComponent,\n defaultProps: Partial<Omit<ComponentPropsWithoutRef<TComponent>, \"asChild\">>,\n) => {\n type TComponentProps = typeof defaultProps;\n const getProps = withDefaultProps<TComponentProps>(defaultProps);\n const WithDefaults = forwardRef<ElementRef<TComponent>, TComponentProps>(\n (props, ref) => {\n const ComponentAsAny = Component as any;\n return <ComponentAsAny {...getProps(props)} ref={ref} />;\n },\n );\n WithDefaults.displayName =\n \"withDefaults(\" +\n (typeof Component === \"string\" ? Component : Component.displayName) +\n \")\";\n return WithDefaults;\n};\n","import { cva, type VariantProps } from \"class-variance-authority\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { ElementRef, forwardRef } from \"react\";\n\nconst buttonVariants = cva(\"aui-button\", {\n variants: {\n variant: {\n default: \"aui-button-primary\",\n outline: \"aui-button-outline\",\n ghost: \"aui-button-ghost\",\n },\n size: {\n default: \"aui-button-medium\",\n icon: \"aui-button-icon\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n});\n\ntype ButtonElement = ElementRef<typeof Primitive.button>;\n\nexport type ButtonProps = React.ComponentPropsWithoutRef<\n typeof Primitive.button\n> &\n VariantProps<typeof buttonVariants>;\n\nconst Button = forwardRef<ButtonElement, ButtonProps>(\n ({ className, variant, size, ...props }, ref) => {\n return (\n <Primitive.button\n className={buttonVariants({ variant, size, className })}\n {...props}\n ref={ref}\n />\n );\n },\n);\n\nButton.displayName = \"Button\";\n\nexport { Button, buttonVariants };\n","import { LanguageModelV1Message } from \"@ai-sdk/provider\";\nimport { CoreMessage, ToolCallContentPart } from \"../../../types\";\n\ntype fromLanguageModelMessagesOptions = {\n mergeRoundtrips: boolean;\n};\n\nexport const fromLanguageModelMessages = (\n lm: LanguageModelV1Message[],\n { mergeRoundtrips }: fromLanguageModelMessagesOptions,\n): CoreMessage[] => {\n const messages: CoreMessage[] = [];\n\n for (const lmMessage of lm) {\n const role = lmMessage.role;\n switch (role) {\n case \"system\": {\n messages.push({\n role: \"system\",\n content: [\n {\n type: \"text\",\n text: lmMessage.content,\n },\n ],\n });\n break;\n }\n case \"user\": {\n messages.push({\n role: \"user\",\n content: lmMessage.content.map((part) => {\n const type = part.type;\n switch (type) {\n case \"text\": {\n return {\n type: \"text\",\n text: part.text,\n };\n }\n case \"image\": {\n if (part.image instanceof URL) {\n return {\n type: \"image\",\n image: part.image.href,\n };\n }\n throw new Error(\"Only images with URL data are supported\");\n }\n default: {\n const unhandledType: never = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n });\n break;\n }\n case \"assistant\": {\n const newContent = lmMessage.content.map((part) => {\n if (part.type === \"tool-call\") {\n return {\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n argsText: JSON.stringify(part.args),\n args: part.args as Record<string, unknown>,\n } satisfies ToolCallContentPart;\n }\n return part;\n });\n\n if (mergeRoundtrips) {\n const previousMessage = messages[messages.length - 1];\n if (previousMessage?.role === \"assistant\") {\n previousMessage.content.push(...newContent);\n break;\n }\n }\n\n messages.push({\n role: \"assistant\",\n content: newContent,\n });\n break;\n }\n case \"tool\": {\n const previousMessage = messages[messages.length - 1];\n if (previousMessage?.role !== \"assistant\")\n throw new Error(\n \"A tool message must be preceded by an assistant message.\",\n );\n\n for (const tool of lmMessage.content) {\n const toolCall = previousMessage.content.find(\n (c): c is ToolCallContentPart =>\n c.type === \"tool-call\" && c.toolCallId === tool.toolCallId,\n );\n if (!toolCall)\n throw new Error(\"Received tool result for an unknown tool call.\");\n if (toolCall.toolName !== tool.toolName)\n throw new Error(\"Tool call name mismatch.\");\n\n toolCall.result = tool.result;\n if (tool.isError) {\n toolCall.isError = true;\n }\n }\n\n break;\n }\n\n default: {\n const unhandledRole: never = role;\n throw new Error(`Unknown message role: ${unhandledRole}`);\n }\n }\n }\n\n return messages;\n};\n","import { LanguageModelV1FunctionTool } from \"@ai-sdk/provider\";\nimport { Tool } from \"../../../types/ModelConfigTypes\";\n\nexport const fromLanguageModelTools = (\n tools: LanguageModelV1FunctionTool[],\n): Record<string, Tool<any, any>> => {\n return Object.fromEntries(\n tools.map((tool) => [\n tool.name,\n {\n description: tool.description,\n parameters: tool.parameters,\n },\n ]),\n );\n};\n","import { LocalRuntimeOptions, useLocalRuntime } from \"..\";\nimport { useState } from \"react\";\nimport { EdgeChatAdapterOptions, EdgeChatAdapter } from \"./EdgeChatAdapter\";\n\nexport type EdgeRuntimeOptions = EdgeChatAdapterOptions & LocalRuntimeOptions;\n\nexport const useEdgeRuntime = ({\n initialMessages,\n ...options\n}: EdgeRuntimeOptions) => {\n const [adapter] = useState(() => new EdgeChatAdapter(options));\n return useLocalRuntime(adapter, { initialMessages });\n};\n","import {\n AssistantStreamChunkTuple,\n AssistantStreamChunkType,\n} from \"./AssistantStreamChunkType\";\nimport { ToolResultStreamPart } from \"./toolResultStream\";\n\nexport function assistantDecoderStream() {\n const toolCallNames = new Map<string, string>();\n let currentToolCall:\n | { id: string; name: string; argsText: string }\n | undefined;\n\n return new TransformStream<string, ToolResultStreamPart>({\n transform(chunk, controller) {\n const [code, value] = parseStreamPart(chunk);\n\n if (\n currentToolCall &&\n code !== AssistantStreamChunkType.ToolCallArgsTextDelta &&\n code !== AssistantStreamChunkType.Error\n ) {\n controller.enqueue({\n type: \"tool-call\",\n toolCallType: \"function\",\n toolCallId: currentToolCall.id,\n toolName: currentToolCall.name,\n args: currentToolCall.argsText,\n });\n currentToolCall = undefined;\n }\n\n switch (code) {\n case AssistantStreamChunkType.TextDelta: {\n controller.enqueue({\n type: \"text-delta\",\n textDelta: value,\n });\n break;\n }\n case AssistantStreamChunkType.ToolCallBegin: {\n const { id, name } = value;\n toolCallNames.set(id, name);\n currentToolCall = { id, name, argsText: \"\" };\n break;\n }\n case AssistantStreamChunkType.ToolCallArgsTextDelta: {\n const delta = value;\n currentToolCall!.argsText += delta;\n controller.enqueue({\n type: \"tool-call-delta\",\n toolCallType: \"function\",\n toolCallId: currentToolCall!.id,\n toolName: currentToolCall!.name,\n argsTextDelta: delta,\n });\n break;\n }\n case AssistantStreamChunkType.ToolCallResult: {\n controller.enqueue({\n type: \"tool-result\",\n toolCallType: \"function\",\n toolCallId: value.id,\n toolName: toolCallNames.get(value.id)!,\n result: value.result,\n });\n break;\n }\n case AssistantStreamChunkType.Finish: {\n controller.enqueue({\n type: \"finish\",\n ...value,\n });\n break;\n }\n case AssistantStreamChunkType.Error: {\n controller.enqueue({\n type: \"error\",\n error: value,\n });\n break;\n }\n default: {\n const unhandledType: never = code;\n throw new Error(`Unhandled chunk type: ${unhandledType}`);\n }\n }\n },\n });\n}\n\nconst parseStreamPart = (part: string): AssistantStreamChunkTuple => {\n const index = part.indexOf(\":\");\n if (index === -1) throw new Error(\"Invalid stream part\");\n return [\n part.slice(0, index) as AssistantStreamChunkType,\n JSON.parse(part.slice(index + 1)),\n ] as const;\n};\n","export function chunkByLineStream() {\n let buffer = \"\";\n\n return new TransformStream({\n transform(chunk, controller) {\n buffer += chunk;\n const lines = buffer.split(\"\\n\");\n\n // Process all complete lines\n for (let i = 0; i < lines.length - 1; i++) {\n controller.enqueue(lines[i]);\n }\n\n // Keep the last incomplete line in the buffer\n buffer = lines[lines.length - 1]!;\n },\n flush(controller) {\n // flush any remaining content in the buffer\n if (buffer) {\n controller.enqueue(buffer);\n }\n },\n });\n}\n","import { ChatModelAdapter, ChatModelRunOptions } from \"../local\";\nimport { ChatModelRunResult } from \"../local/ChatModelAdapter\";\nimport { toCoreMessages } from \"./converters/toCoreMessages\";\nimport { toLanguageModelTools } from \"./converters/toLanguageModelTools\";\nimport { EdgeRuntimeRequestOptions } from \"./EdgeRuntimeRequestOptions\";\nimport { assistantDecoderStream } from \"./streams/assistantDecoderStream\";\nimport { chunkByLineStream } from \"./streams/chunkByLineStream\";\nimport { runResultStream } from \"./streams/runResultStream\";\nimport { toolResultStream } from \"./streams/toolResultStream\";\n\nexport function asAsyncIterable<T>(\n source: ReadableStream<T>,\n): AsyncIterable<T> {\n return {\n [Symbol.asyncIterator]: () => {\n const reader = source.getReader();\n return {\n async next(): Promise<IteratorResult<T, undefined>> {\n const { done, value } = await reader.read();\n return done\n ? { done: true, value: undefined }\n : { done: false, value };\n },\n };\n },\n };\n}\nexport type EdgeChatAdapterOptions = {\n api: string;\n};\n\nexport class EdgeChatAdapter implements ChatModelAdapter {\n constructor(private options: EdgeChatAdapterOptions) {}\n\n async *run({ messages, abortSignal, config }: ChatModelRunOptions) {\n const result = await fetch(this.options.api, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n system: config.system,\n messages: toCoreMessages(messages),\n tools: config.tools ? toLanguageModelTools(config.tools) : [],\n ...config.callSettings,\n ...config.config,\n } satisfies EdgeRuntimeRequestOptions),\n signal: abortSignal,\n });\n\n if (result.status !== 200) {\n throw new Error(`Status ${result.status}: ${await result.text()}`);\n }\n\n const stream = result\n .body!.pipeThrough(new TextDecoderStream())\n .pipeThrough(chunkByLineStream())\n .pipeThrough(assistantDecoderStream())\n .pipeThrough(toolResultStream(config.tools))\n .pipeThrough(runResultStream());\n\n let update: ChatModelRunResult | undefined;\n for await (update of asAsyncIterable(stream)) {\n yield update;\n }\n\n if (update === undefined)\n throw new Error(\"No data received from Edge Runtime\");\n }\n}\n","import type { ThreadAssistantMessage } from \"../../types\";\n\nexport const shouldContinue = (result: ThreadAssistantMessage) =>\n result.status?.type === \"requires-action\" &&\n result.status.reason === \"tool-calls\" &&\n result.content.every((c) => c.type !== \"tool-call\" || !!c.result);\n","import { ThreadRuntime } from \"..\";\nimport { AddToolResultOptions } from \"../../context\";\nimport { generateId } from \"../../internal\";\nimport type {\n ModelConfigProvider,\n AppendMessage,\n ThreadUserMessage,\n ThreadAssistantMessage,\n Unsubscribe,\n} from \"../../types\";\nimport { fromCoreMessages } from \"../edge\";\nimport { MessageRepository } from \"../utils/MessageRepository\";\nimport type { ChatModelAdapter, ChatModelRunResult } from \"./ChatModelAdapter\";\nimport { shouldContinue } from \"./shouldContinue\";\nimport { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\n\nconst CAPABILITIES = Object.freeze({\n switchToBranch: true,\n edit: true,\n reload: true,\n cancel: true,\n copy: true,\n});\nexport class LocalThreadRuntime implements ThreadRuntime {\n private _subscriptions = new Set<() => void>();\n\n private abortController: AbortController | null = null;\n private readonly repository = new MessageRepository();\n\n public readonly capabilities = CAPABILITIES;\n\n public readonly isDisabled = false;\n\n public get messages() {\n return this.repository.getMessages();\n }\n public get isRunning() {\n return this.abortController != null;\n }\n\n constructor(\n private configProvider: ModelConfigProvider,\n public adapter: ChatModelAdapter,\n private options?: LocalRuntimeOptions,\n ) {\n if (options?.initialMessages) {\n let parentId: string | null = null;\n const messages = fromCoreMessages(options.initialMessages);\n for (const message of messages) {\n this.repository.addOrUpdateMessage(parentId, message);\n parentId = message.id;\n }\n }\n }\n\n public getBranches(messageId: string): string[] {\n return this.repository.getBranches(messageId);\n }\n\n public switchToBranch(branchId: string): void {\n this.repository.switchToBranch(branchId);\n this.notifySubscribers();\n }\n\n public async append(message: AppendMessage): Promise<void> {\n if (message.role !== \"user\")\n throw new Error(\n \"Only appending user messages are supported in LocalRuntime. This is likely an internal bug in assistant-ui.\",\n );\n\n // add user message\n const userMessageId = generateId();\n const userMessage: ThreadUserMessage = {\n id: userMessageId,\n role: \"user\",\n content: message.content,\n createdAt: new Date(),\n };\n this.repository.addOrUpdateMessage(message.parentId, userMessage);\n\n await this.startRun(userMessageId);\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n this.repository.resetHead(parentId);\n\n // add assistant message\n const id = generateId();\n let message: ThreadAssistantMessage = {\n id,\n role: \"assistant\",\n status: { type: \"running\" },\n content: [],\n createdAt: new Date(),\n };\n\n do {\n message = await this.performRoundtrip(parentId, message);\n } while (shouldContinue(message));\n }\n\n private async performRoundtrip(\n parentId: string | null,\n message: ThreadAssistantMessage,\n ) {\n const messages = this.repository.getMessages();\n\n // abort existing run\n this.abortController?.abort();\n this.abortController = new AbortController();\n\n const initialContent = message.content;\n const initialRoundtrips = message.roundtrips;\n const updateMessage = (m: Partial<ChatModelRunResult>) => {\n message = {\n ...message,\n ...(m.content\n ? { content: [...initialContent, ...(m.content ?? [])] }\n : undefined),\n status: m.status ?? message.status,\n ...(m.roundtrips?.length\n ? { roundtrips: [...(initialRoundtrips ?? []), ...m.roundtrips] }\n : undefined),\n };\n this.repository.addOrUpdateMessage(parentId, message);\n this.notifySubscribers();\n };\n\n const maxToolRoundtrips = this.options?.maxToolRoundtrips ?? 1;\n const toolRoundtrips = message.roundtrips?.length ?? 0;\n if (toolRoundtrips > maxToolRoundtrips) {\n // reached max tool roundtrips\n updateMessage({\n status: {\n type: \"incomplete\",\n reason: \"tool-calls\",\n },\n });\n return message;\n } else {\n updateMessage({\n status: {\n type: \"running\",\n },\n });\n }\n\n try {\n const promiseOrGenerator = this.adapter.run({\n messages,\n abortSignal: this.abortController.signal,\n config: this.configProvider.getModelConfig(),\n onUpdate: updateMessage,\n });\n\n // handle async iterator for streaming results\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n updateMessage(r);\n }\n } else {\n updateMessage(await promiseOrGenerator);\n }\n\n this.abortController = null;\n\n if (message.status.type === \"running\") {\n updateMessage({\n status: { type: \"complete\", reason: \"unknown\" },\n });\n } else {\n // notify subscribers that isRunning is now false\n this.notifySubscribers();\n }\n } catch (e) {\n this.abortController = null;\n\n // TODO this should be handled by the run result stream\n if (e instanceof Error && e.name === \"AbortError\") {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n } else {\n updateMessage({\n status: { type: \"incomplete\", reason: \"error\", error: e },\n });\n\n throw e;\n }\n }\n return message;\n }\n\n cancelRun(): void {\n if (!this.abortController) return;\n\n this.abortController.abort();\n this.abortController = null;\n }\n\n private notifySubscribers() {\n for (const callback of this._subscriptions) callback();\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n addToolResult({ messageId, toolCallId, result }: AddToolResultOptions) {\n let { parentId, message } = this.repository.getMessage(messageId);\n\n if (message.role !== \"assistant\")\n throw new Error(\"Tried to add tool result to non-assistant message\");\n\n let added = false;\n let found = false;\n const newContent = message.content.map((c) => {\n if (c.type !== \"tool-call\") return c;\n if (c.toolCallId !== toolCallId) return c;\n found = true;\n if (!c.result) added = true;\n return {\n ...c,\n result,\n };\n });\n\n if (!found)\n throw new Error(\"Tried to add tool result to non-existing tool call\");\n\n message = {\n ...message,\n content: newContent,\n };\n this.repository.addOrUpdateMessage(parentId, message);\n\n if (added && shouldContinue(message)) {\n this.performRoundtrip(parentId, message);\n }\n }\n}\n","import { type ModelConfigProvider } from \"../../types/ModelConfigTypes\";\nimport { BaseAssistantRuntime } from \"../core/BaseAssistantRuntime\";\nimport type { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { ProxyConfigProvider } from \"../../internal\";\nimport { LocalThreadRuntime } from \"./LocalThreadRuntime\";\nimport { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\n\nexport class LocalRuntime extends BaseAssistantRuntime<LocalThreadRuntime> {\n private readonly _proxyConfigProvider: ProxyConfigProvider;\n\n constructor(adapter: ChatModelAdapter, options?: LocalRuntimeOptions) {\n const proxyConfigProvider = new ProxyConfigProvider();\n super(new LocalThreadRuntime(proxyConfigProvider, adapter, options));\n this._proxyConfigProvider = proxyConfigProvider;\n }\n\n public set adapter(adapter: ChatModelAdapter) {\n this.thread.adapter = adapter;\n }\n\n registerModelConfigProvider(provider: ModelConfigProvider) {\n return this._proxyConfigProvider.registerModelConfigProvider(provider);\n }\n\n public switchToThread(threadId: string | null) {\n if (threadId) {\n throw new Error(\"LocalRuntime does not yet support switching threads\");\n }\n\n return (this.thread = new LocalThreadRuntime(\n this._proxyConfigProvider,\n this.thread.adapter,\n ));\n }\n}\n","import { create } from \"zustand\";\nimport { ReactThreadRuntime } from \"../core\";\nimport { MessageRepository } from \"../utils/MessageRepository\";\nimport { AppendMessage, ThreadMessage, Unsubscribe } from \"../../types\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport { AddToolResultOptions } from \"../../context\";\nimport { getExternalStoreMessage } from \"./getExternalStoreMessage\";\nimport { useExternalStoreSync } from \"./useExternalStoreSync\";\n\nexport const hasUpcomingMessage = (\n isRunning: boolean,\n messages: ThreadMessage[],\n) => {\n return isRunning && messages[messages.length - 1]?.role !== \"assistant\";\n};\n\nexport class ExternalStoreThreadRuntime implements ReactThreadRuntime {\n private _subscriptions = new Set<() => void>();\n private repository = new MessageRepository();\n private assistantOptimisticId: string | null = null;\n\n private useStore;\n\n public get capabilities() {\n return {\n switchToBranch: this.store.setMessages !== undefined,\n edit: this.store.onEdit !== undefined,\n reload: this.store.onReload !== undefined,\n cancel: this.store.onCancel !== undefined,\n copy: this.store.onCopy !== null,\n };\n }\n\n public messages: ThreadMessage[] = [];\n public isDisabled = false;\n public isRunning = false;\n\n constructor(public store: ExternalStoreAdapter<any>) {\n this.updateData(\n store.isDisabled ?? false,\n store.isRunning ?? false,\n store.messages,\n );\n\n this.useStore = create(() => ({\n store,\n }));\n }\n\n public getBranches(messageId: string): string[] {\n return this.repository.getBranches(messageId);\n }\n\n public switchToBranch(branchId: string): void {\n if (!this.store.setMessages)\n throw new Error(\"Runtime does not support switching branches.\");\n\n this.repository.switchToBranch(branchId);\n this.updateMessages(this.repository.getMessages());\n }\n\n public async append(message: AppendMessage): Promise<void> {\n if (message.parentId !== (this.messages.at(-1)?.id ?? null)) {\n if (!this.store.onEdit)\n throw new Error(\"Runtime does not support editing messages.\");\n await this.store.onEdit(message);\n } else {\n await this.store.onNew(message);\n }\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n if (!this.store.onReload)\n throw new Error(\"Runtime does not support reloading messages.\");\n\n await this.store.onReload(parentId);\n }\n\n public cancelRun(): void {\n if (!this.store.onCancel)\n throw new Error(\"Runtime does not support cancelling runs.\");\n\n this.store.onCancel();\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n let messages = this.repository.getMessages();\n\n // resync messages (for reloading, to restore the previous branch)\n setTimeout(() => {\n this.updateMessages(messages);\n }, 0);\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private updateMessages = (messages: ThreadMessage[]) => {\n this.store.setMessages?.(\n messages.flatMap(getExternalStoreMessage).filter((m) => m != null),\n );\n };\n\n public onStoreUpdated() {\n if (this.useStore.getState().store !== this.store) {\n this.useStore.setState({ store: this.store });\n }\n }\n\n private updateData = (\n isDisabled: boolean,\n isRunning: boolean,\n vm: ThreadMessage[],\n ) => {\n for (let i = 0; i < vm.length; i++) {\n const message = vm[i]!;\n const parent = vm[i - 1];\n this.repository.addOrUpdateMessage(parent?.id ?? null, message);\n }\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n if (hasUpcomingMessage(isRunning, vm)) {\n this.assistantOptimisticId = this.repository.appendOptimisticMessage(\n vm.at(-1)?.id ?? null,\n {\n role: \"assistant\",\n content: [],\n },\n );\n }\n\n this.repository.resetHead(\n this.assistantOptimisticId ?? vm.at(-1)?.id ?? null,\n );\n\n this.messages = this.repository.getMessages();\n this.isDisabled = isDisabled;\n this.isRunning = isRunning;\n\n for (const callback of this._subscriptions) callback();\n };\n\n unstable_synchronizer = () => {\n const { store } = this.useStore();\n\n useExternalStoreSync(store, this.updateData);\n\n return null;\n };\n\n addToolResult(options: AddToolResultOptions) {\n if (!this.store.onAddToolResult)\n throw new Error(\"Runtime does not support tool results.\");\n this.store.onAddToolResult(options);\n }\n}\n","import { ThreadMessage } from \"../../types\";\n\nexport const symbolInnerMessage = Symbol(\"innerMessage\");\n\nexport type ExternalStoreThreadMessage<T> = ThreadMessage & {\n [symbolInnerMessage]?: T;\n};\n\nexport const getExternalStoreMessage = <T,>(message: ThreadMessage) => {\n return (message as ExternalStoreThreadMessage<T>)[symbolInnerMessage];\n};\n","import { useEffect, useInsertionEffect, useMemo, useRef } from \"react\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport {\n ConverterCallback,\n ThreadMessageConverter,\n} from \"./ThreadMessageConverter\";\nimport { ThreadMessage } from \"../../types\";\nimport { symbolInnerMessage } from \"./getExternalStoreMessage\";\nimport { getAutoStatus } from \"./auto-status\";\nimport { fromThreadMessageLike } from \"./ThreadMessageLike\";\n\ntype UpdateDataCallback = (\n isDisabled: boolean,\n isRunning: boolean,\n messages: ThreadMessage[],\n) => void;\n\nexport const useExternalStoreSync = <T extends WeakKey>(\n adapter: ExternalStoreAdapter<T>,\n updateData: UpdateDataCallback,\n) => {\n const adapterRef = useRef(adapter);\n useInsertionEffect(() => {\n adapterRef.current = adapter;\n });\n\n // flush the converter cache when the convertMessage prop changes\n const [converter, convertCallback] = useMemo(() => {\n const converter = adapter.convertMessage ?? ((m: T) => m as ThreadMessage);\n const convertCallback: ConverterCallback<T> = (cache, m, idx) => {\n const autoStatus = getAutoStatus(\n adapterRef.current.messages.at(-1) === m,\n adapterRef.current.isRunning ?? false,\n );\n\n if (cache && (cache.role !== \"assistant\" || cache.status === autoStatus))\n return cache;\n\n const newMessage = fromThreadMessageLike(\n converter(m, idx),\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = m;\n return newMessage;\n };\n return [new ThreadMessageConverter(), convertCallback];\n\n // specify convertMessage bceause we want the ThreadMessageConverter to be recreated when the adapter changes\n }, [adapter.convertMessage]);\n\n useEffect(() => {\n updateData(\n adapter.isDisabled ?? false,\n adapter.isRunning ?? false,\n converter.convertMessages(adapter.messages, convertCallback),\n );\n }, [\n updateData,\n converter,\n convertCallback,\n adapter.isDisabled,\n adapter.isRunning,\n adapter.messages,\n ]);\n};\n","import { ThreadMessage } from \"../../types\";\n\nexport type ConverterCallback<TIn> = (\n cache: ThreadMessage | undefined,\n message: TIn,\n idx: number,\n) => ThreadMessage;\n\nexport class ThreadMessageConverter {\n private readonly cache = new WeakMap<WeakKey, ThreadMessage>();\n\n convertMessages<TIn extends WeakKey>(\n messages: TIn[],\n converter: ConverterCallback<TIn>,\n keyMapper: (m: TIn) => WeakKey = (key) => key,\n ): ThreadMessage[] {\n return messages.map((m, idx) => {\n const key = keyMapper(m);\n const cached = this.cache.get(key);\n const newMessage = converter(cached, m, idx);\n this.cache.set(key, newMessage);\n return newMessage;\n });\n }\n}\n","const AUTO_STATUS_RUNNING = Object.freeze({ type: \"running\" });\nconst AUTO_STATUS_COMPLETE = Object.freeze({\n type: \"complete\",\n reason: \"unknown\",\n});\n\nexport const getAutoStatus = (isLast: boolean, isRunning: boolean) =>\n isLast && isRunning ? AUTO_STATUS_RUNNING : AUTO_STATUS_COMPLETE;\n","import {\n MessageStatus,\n TextContentPart,\n ImageContentPart,\n ToolCallContentPart,\n UIContentPart,\n ThreadMessage,\n ThreadAssistantContentPart,\n ThreadAssistantMessage,\n ThreadUserContentPart,\n ThreadUserMessage,\n ThreadSystemMessage,\n} from \"../../types\";\nimport { CoreToolCallContentPart } from \"../../types/AssistantTypes\";\n\nexport type ThreadMessageLike = {\n role: \"assistant\" | \"user\" | \"system\";\n content: (\n | TextContentPart\n | ImageContentPart\n | ToolCallContentPart<any, any>\n | CoreToolCallContentPart<any, any>\n | UIContentPart\n )[];\n id?: string | undefined;\n createdAt?: Date | undefined;\n status?: MessageStatus | undefined;\n};\n\nexport const fromThreadMessageLike = (\n like: ThreadMessageLike,\n fallbackId: string,\n fallbackStatus: MessageStatus,\n): ThreadMessage => {\n const { role, content, id, createdAt, status } = like;\n const common = {\n id: id ?? fallbackId,\n createdAt: createdAt ?? new Date(),\n };\n switch (role) {\n case \"assistant\":\n return {\n ...common,\n role,\n content: content.map((part): ThreadAssistantContentPart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"ui\":\n return part;\n\n case \"tool-call\": {\n if (\"argsText\" in part) return part;\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n };\n }\n\n default: {\n const unhandledType: \"image\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n status: status ?? fallbackStatus,\n } satisfies ThreadAssistantMessage;\n\n case \"user\":\n return {\n ...common,\n role,\n content: content.map((part): ThreadUserContentPart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"ui\":\n case \"image\":\n return part;\n\n default: {\n const unhandledType: \"tool-call\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n } satisfies ThreadUserMessage;\n\n case \"system\":\n if (content.length !== 1 || content[0]!.type !== \"text\")\n throw new Error(\n \"System messages must have exactly one text content part.\",\n );\n\n return {\n ...common,\n role,\n content: content as [TextContentPart],\n } satisfies ThreadSystemMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n","import { BaseAssistantRuntime, ProxyConfigProvider } from \"../../internal\";\nimport { ModelConfigProvider } from \"../../types\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport { ExternalStoreThreadRuntime } from \"./ExternalStoreThreadRuntime\";\n\nexport class ExternalStoreRuntime extends BaseAssistantRuntime<ExternalStoreThreadRuntime> {\n private readonly _proxyConfigProvider = new ProxyConfigProvider();\n\n constructor(store: ExternalStoreAdapter<any>) {\n super(new ExternalStoreThreadRuntime(store));\n }\n\n public set store(store: ExternalStoreAdapter<any>) {\n this.thread.store = store;\n }\n\n public onStoreUpdated() {\n return this.thread.onStoreUpdated();\n }\n\n public getModelConfig() {\n return this._proxyConfigProvider.getModelConfig();\n }\n\n public registerModelConfigProvider(provider: ModelConfigProvider) {\n return this._proxyConfigProvider.registerModelConfigProvider(provider);\n }\n\n public switchToThread(threadId: string | null) {\n if (threadId) {\n if (!this.store.onSwitchThread)\n throw new Error(\"Runtime does not support switching threads.\");\n\n return this.store.onSwitchThread(threadId);\n } else {\n if (!this.store.onNewThread)\n throw new Error(\"Runtime does not support switching to new threads.\");\n\n return this.store.onNewThread();\n }\n }\n}\n","import { useEffect, useInsertionEffect, useState } from \"react\";\nimport { ExternalStoreRuntime } from \"./ExternalStoreRuntime\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\n\nexport const useExternalStoreRuntime = (store: ExternalStoreAdapter<any>) => {\n const [runtime] = useState(() => new ExternalStoreRuntime(store));\n\n useInsertionEffect(() => {\n runtime.store = store;\n });\n useEffect(() => {\n runtime.onStoreUpdated();\n });\n\n return runtime;\n};\n","\"use client\";\n\nimport {\n FC,\n PropsWithChildren,\n ReactNode,\n createContext,\n useContext,\n} from \"react\";\n\nimport { AvatarProps } from \"./base/avatar\";\nimport { TextContentPartComponent } from \"../types\";\nimport { AssistantRuntime } from \"../runtimes\";\nimport { AssistantRuntimeProvider, useAssistantContext } from \"../context\";\n\nexport type SuggestionConfig = {\n text?: ReactNode;\n prompt: string;\n};\n\nexport type ThreadWelcomeConfig = {\n message?: string | null | undefined;\n suggestions?: SuggestionConfig[] | undefined;\n};\n\nexport type UserMessageConfig = {\n allowEdit?: boolean | undefined;\n};\n\nexport type AssistantMessageConfig = {\n allowReload?: boolean | undefined;\n allowCopy?: boolean | undefined;\n components?:\n | {\n Text?: TextContentPartComponent | undefined;\n }\n | undefined;\n};\n\nexport type BranchPickerConfig = {\n allowBranchPicker?: boolean | undefined;\n};\n\nexport type StringsConfig = {\n assistantModal?: {\n open: {\n button: {\n tooltip?: string | undefined;\n };\n };\n closed: {\n button: {\n tooltip?: string | undefined;\n };\n };\n };\n thread?: {\n scrollToBottom?: {\n tooltip?: string | undefined;\n };\n };\n userMessage?: {\n edit?: {\n tooltip?: string | undefined;\n };\n };\n assistantMessage?: {\n reload?: {\n tooltip?: string | undefined;\n };\n copy?: {\n tooltip?: string | undefined;\n };\n };\n branchPicker?: {\n previous?: {\n tooltip?: string | undefined;\n };\n next?: {\n tooltip?: string | undefined;\n };\n };\n composer?: {\n send?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n cancel?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n input?: {\n placeholder?: string | undefined;\n };\n };\n editComposer?: {\n send?: {\n label?: string | undefined;\n };\n cancel?: {\n label?: string | undefined;\n };\n };\n code?: {\n header?: {\n copy?: {\n tooltip?: string | undefined;\n };\n };\n };\n};\n\nconst ThreadConfigContext = createContext<ThreadConfig>({});\n\nexport type ThreadConfig = {\n runtime?: AssistantRuntime;\n\n assistantAvatar?: AvatarProps;\n\n welcome?: ThreadWelcomeConfig;\n assistantMessage?: AssistantMessageConfig;\n userMessage?: UserMessageConfig;\n\n branchPicker?: BranchPickerConfig;\n\n strings?: StringsConfig;\n};\n\nexport const useThreadConfig = (): Omit<ThreadConfig, \"runtime\"> => {\n return useContext(ThreadConfigContext);\n};\n\nexport type ThreadConfigProviderProps = PropsWithChildren<{\n config?: ThreadConfig | undefined;\n}>;\n\nexport const ThreadConfigProvider: FC<ThreadConfigProviderProps> = ({\n children,\n config,\n}) => {\n const assistant = useAssistantContext({ optional: true });\n\n const configProvider =\n config && Object.keys(config ?? {}).length > 0 ? (\n <ThreadConfigContext.Provider value={config}>\n {children}\n </ThreadConfigContext.Provider>\n ) : (\n <>{children}</>\n );\n if (!config?.runtime) return configProvider;\n\n if (assistant) {\n throw new Error(\n \"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed.\",\n );\n }\n return (\n <AssistantRuntimeProvider runtime={config.runtime}>\n {configProvider}\n </AssistantRuntimeProvider>\n );\n};\n\nThreadConfigProvider.displayName = \"ThreadConfigProvider\";\n","\"use client\";\n\nimport { forwardRef, type FC } from \"react\";\nimport { CheckIcon, CopyIcon, RefreshCwIcon } from \"lucide-react\";\nimport { ActionBarPrimitive, MessagePrimitive } from \"../primitives\";\nimport {\n TooltipIconButton,\n TooltipIconButtonProps,\n} from \"./base/tooltip-icon-button\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { useThreadConfig } from \"./thread-config\";\nimport { useThreadContext } from \"../context\";\n\nconst useAllowCopy = () => {\n const { assistantMessage: { allowCopy = true } = {} } = useThreadConfig();\n const { useThreadActions } = useThreadContext();\n const copySupported = useThreadActions((t) => t.capabilities.copy);\n return copySupported && allowCopy;\n};\n\nconst useAllowReload = () => {\n const { assistantMessage: { allowReload = true } = {} } = useThreadConfig();\n const { useThreadActions } = useThreadContext();\n const reloadSupported = useThreadActions((t) => t.capabilities.reload);\n return reloadSupported && allowReload;\n};\n\nconst AssistantActionBar: FC = () => {\n const allowCopy = useAllowCopy();\n const allowReload = useAllowReload();\n if (!allowCopy && !allowReload) return null;\n return (\n <AssistantActionBarRoot\n hideWhenRunning\n autohide=\"not-last\"\n autohideFloat=\"single-branch\"\n >\n <AssistantActionBarCopy />\n <AssistantActionBarReload />\n </AssistantActionBarRoot>\n );\n};\n\nAssistantActionBar.displayName = \"AssistantActionBar\";\n\nconst AssistantActionBarRoot = withDefaults(ActionBarPrimitive.Root, {\n className: \"aui-assistant-action-bar-root\",\n});\n\nAssistantActionBarRoot.displayName = \"AssistantActionBarRoot\";\n\nconst AssistantActionBarCopy = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: {\n assistantMessage: { reload: { tooltip = \"Copy\" } = {} } = {},\n } = {},\n } = useThreadConfig();\n const allowCopy = useAllowCopy();\n if (!allowCopy) return null;\n return (\n <ActionBarPrimitive.Copy asChild>\n <TooltipIconButton tooltip={tooltip} {...props} ref={ref}>\n {props.children ?? (\n <>\n <MessagePrimitive.If copied>\n <CheckIcon />\n </MessagePrimitive.If>\n <MessagePrimitive.If copied={false}>\n <CopyIcon />\n </MessagePrimitive.If>\n </>\n )}\n </TooltipIconButton>\n </ActionBarPrimitive.Copy>\n );\n});\n\nAssistantActionBarCopy.displayName = \"AssistantActionBarCopy\";\n\nconst AssistantActionBarReload = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: {\n assistantMessage: { reload: { tooltip = \"Refresh\" } = {} } = {},\n } = {},\n } = useThreadConfig();\n const allowReload = useAllowReload();\n if (!allowReload) return null;\n return (\n <ActionBarPrimitive.Reload asChild>\n <TooltipIconButton tooltip={tooltip} {...props} ref={ref}>\n <RefreshCwIcon />\n </TooltipIconButton>\n </ActionBarPrimitive.Reload>\n );\n});\n\nAssistantActionBarReload.displayName = \"AssistantActionBarReload\";\n\nconst exports = {\n Root: AssistantActionBarRoot,\n Reload: AssistantActionBarReload,\n Copy: AssistantActionBarCopy,\n};\n\nexport default Object.assign(\n AssistantActionBar,\n exports,\n) as typeof AssistantActionBar & typeof exports;\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, forwardRef, type FC } from \"react\";\nimport { MessagePrimitive, MessagePrimitiveContentProps } from \"../primitives\";\nimport BranchPicker from \"./branch-picker\";\nimport { Avatar } from \"./base/avatar\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { useThreadConfig } from \"./thread-config\";\nimport AssistantActionBar from \"./assistant-action-bar\";\nimport ContentPart from \"./content-part\";\n\nconst AssistantMessage: FC = () => {\n return (\n <AssistantMessageRoot>\n <AssistantMessageAvatar />\n <AssistantMessageContent />\n <BranchPicker />\n <AssistantActionBar />\n </AssistantMessageRoot>\n );\n};\n\nAssistantMessage.displayName = \"AssistantMessage\";\n\nconst AssistantMessageAvatar: FC = () => {\n const { assistantAvatar: avatar = { fallback: \"A\" } } = useThreadConfig();\n return <Avatar {...avatar} />;\n};\n\nconst AssistantMessageRoot = withDefaults(MessagePrimitive.Root, {\n className: \"aui-assistant-message-root\",\n});\n\nAssistantMessageRoot.displayName = \"AssistantMessageRoot\";\n\nconst AssistantMessageContentWrapper = withDefaults(\"div\", {\n className: \"aui-assistant-message-content\",\n});\n\nexport type AssistantMessageContentProps = MessagePrimitiveContentProps &\n ComponentPropsWithoutRef<\"div\">;\n\nconst AssistantMessageContent = forwardRef<\n HTMLDivElement,\n AssistantMessageContentProps\n>(({ components: componentsProp, ...rest }, ref) => {\n const { assistantMessage: { components = {} } = {} } = useThreadConfig();\n return (\n <AssistantMessageContentWrapper {...rest} ref={ref}>\n <MessagePrimitive.Content\n components={{\n ...componentsProp,\n Text: componentsProp?.Text ?? components.Text ?? ContentPart.Text,\n }}\n />\n </AssistantMessageContentWrapper>\n );\n});\n\nAssistantMessageContent.displayName = \"AssistantMessageContent\";\n\nconst exports = {\n Root: AssistantMessageRoot,\n Avatar: AssistantMessageAvatar,\n Content: AssistantMessageContent,\n};\n\nexport default Object.assign(\n AssistantMessage,\n exports,\n) as typeof AssistantMessage & typeof exports;\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, forwardRef, type FC } from \"react\";\nimport { ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\";\n\nimport {\n TooltipIconButton,\n TooltipIconButtonProps,\n} from \"./base/tooltip-icon-button\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { useThreadConfig } from \"./thread-config\";\nimport { BranchPickerPrimitive } from \"../primitives\";\nimport { useThreadContext } from \"../context\";\n\nconst useAllowBranchPicker = () => {\n const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();\n const { useThreadActions } = useThreadContext();\n const branchPickerSupported = useThreadActions((t) => t.capabilities.edit);\n return branchPickerSupported && allowBranchPicker;\n};\n\nconst BranchPicker: FC = () => {\n const allowBranchPicker = useAllowBranchPicker();\n if (!allowBranchPicker) return null;\n return (\n <BranchPickerRoot hideWhenSingleBranch>\n <BranchPickerPrevious />\n <BranchPickerState />\n <BranchPickerNext />\n </BranchPickerRoot>\n );\n};\n\nBranchPicker.displayName = \"BranchPicker\";\n\nconst BranchPickerRoot = withDefaults(BranchPickerPrimitive.Root, {\n className: \"aui-branch-picker-root\",\n});\n\nBranchPickerRoot.displayName = \"BranchPickerRoot\";\n\nconst BranchPickerPrevious = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: {\n branchPicker: { previous: { tooltip = \"Previous\" } = {} } = {},\n } = {},\n } = useThreadConfig();\n return (\n <BranchPickerPrimitive.Previous asChild>\n <TooltipIconButton tooltip={tooltip} {...props} ref={ref}>\n {props.children ?? <ChevronLeftIcon />}\n </TooltipIconButton>\n </BranchPickerPrimitive.Previous>\n );\n});\n\nBranchPickerPrevious.displayName = \"BranchPickerPrevious\";\n\nconst BranchPickerStateWrapper = withDefaults(\"span\", {\n className: \"aui-branch-picker-state\",\n});\n\nconst BranchPickerState = forwardRef<\n HTMLSpanElement,\n ComponentPropsWithoutRef<\"span\">\n>((props, ref) => {\n return (\n <BranchPickerStateWrapper {...props} ref={ref}>\n <BranchPickerPrimitive.Number /> / <BranchPickerPrimitive.Count />\n </BranchPickerStateWrapper>\n );\n});\n\nBranchPickerState.displayName = \"BranchPickerState\";\n\nconst BranchPickerNext = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: { branchPicker: { next: { tooltip = \"Next\" } = {} } = {} } = {},\n } = useThreadConfig();\n return (\n <BranchPickerPrimitive.Next asChild>\n <TooltipIconButton tooltip={tooltip} {...props} ref={ref}>\n {props.children ?? <ChevronRightIcon />}\n </TooltipIconButton>\n </BranchPickerPrimitive.Next>\n );\n});\n\nBranchPickerNext.displayName = \"BranchPickerNext\";\n\nconst exports = {\n Root: BranchPickerRoot,\n Previous: BranchPickerPrevious,\n Next: BranchPickerNext,\n};\n\nexport default Object.assign(BranchPicker, exports) as typeof BranchPicker &\n typeof exports;\n","\"use client\";\n\nimport type { FC } from \"react\";\nimport * as AvatarPrimitive from \"@radix-ui/react-avatar\";\n\nimport { withDefaults } from \"../utils/withDefaults\";\n\nexport type AvatarProps = {\n src?: string | undefined;\n alt?: string | undefined;\n fallback?: string | undefined;\n};\n\nexport const Avatar: FC<AvatarProps> = ({ src, alt, fallback }) => {\n if (src == null && fallback == null) return null;\n\n return (\n <AvatarRoot>\n {src != null && <AvatarImage src={src} alt={alt} />}\n {fallback != null && <AvatarFallback>{fallback}</AvatarFallback>}\n </AvatarRoot>\n );\n};\n\nAvatar.displayName = \"Avatar\";\n\nexport const AvatarRoot = withDefaults(AvatarPrimitive.Root, {\n className: \"aui-avatar-root\",\n});\n\nAvatarRoot.displayName = \"AvatarRoot\";\n\nexport const AvatarImage = withDefaults(AvatarPrimitive.Image, {\n className: \"aui-avatar-image\",\n});\n\nAvatarImage.displayName = \"AvatarImage\";\n\nexport const AvatarFallback = withDefaults(AvatarPrimitive.Fallback, {\n className: \"aui-avatar-fallback\",\n});\n\nAvatarFallback.displayName = \"AvatarFallback\";\n","import { FC } from \"react\";\nimport { ContentPartPrimitive } from \"../primitives\";\nimport { useSmoothStatus, withSmoothContextProvider } from \"../utils/smooth\";\nimport classNames from \"classnames\";\n\nexport const Text: FC = () => {\n const status = useSmoothStatus();\n return (\n <ContentPartPrimitive.Text\n className={classNames(\n \"aui-text\",\n status.type === \"running\" && \"aui-text-running\",\n )}\n component=\"p\"\n />\n );\n};\n\nconst exports = { Text: withSmoothContextProvider(Text) };\n\nexport default exports;\n","\"use client\";\n\nimport { type FC, forwardRef } from \"react\";\nimport { BotIcon, ChevronDownIcon } from \"lucide-react\";\n\nimport {\n AssistantModalPrimitive,\n AssistantModalPrimitiveRootProps,\n} from \"../primitives\";\nimport Thread from \"./thread\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport {\n TooltipIconButton,\n TooltipIconButtonProps,\n} from \"./base/tooltip-icon-button\";\nimport {\n ThreadConfig,\n ThreadConfigProvider,\n ThreadConfigProviderProps,\n useThreadConfig,\n} from \"./thread-config\";\n\nconst AssistantModal: FC<ThreadConfig> = (config) => {\n return (\n <AssistantModalRoot config={config}>\n <AssistantModalTrigger />\n <AssistantModalContent>\n <Thread />\n </AssistantModalContent>\n </AssistantModalRoot>\n );\n};\n\nAssistantModal.displayName = \"AssistantModal\";\n\nconst AssistantModalRoot: FC<\n AssistantModalPrimitiveRootProps & ThreadConfigProviderProps\n> = ({ config, ...props }) => {\n return (\n <ThreadConfigProvider config={config}>\n <AssistantModalPrimitive.Root {...props} />\n </ThreadConfigProvider>\n );\n};\n\nAssistantModalRoot.displayName = \"AssistantModalRoot\";\n\nconst AssistantModalTrigger = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n return (\n <AssistantModalAnchor>\n <AssistantModalPrimitive.Trigger asChild>\n <AssistantModalButton {...props} ref={ref} />\n </AssistantModalPrimitive.Trigger>\n </AssistantModalAnchor>\n );\n});\n\nAssistantModalTrigger.displayName = \"AssistantModalTrigger\";\n\nconst AssistantModalAnchor = withDefaults(AssistantModalPrimitive.Anchor, {\n className: \"aui-root aui-modal-anchor\",\n});\n\nAssistantModalAnchor.displayName = \"AssistantModalAnchor\";\n\nconst ModalButtonStyled = withDefaults(TooltipIconButton, {\n variant: \"default\",\n className: \"aui-modal-button\",\n});\n\ntype AssistantModalButtonProps = TooltipIconButtonProps & {\n \"data-state\"?: \"open\" | \"closed\";\n};\n\nconst AssistantModalButton = forwardRef<\n HTMLButtonElement,\n Partial<AssistantModalButtonProps>\n>(({ \"data-state\": state, ...rest }, ref) => {\n const {\n strings: {\n assistantModal: {\n open: {\n button: { tooltip: openTooltip = \"Close Assistant\" } = {},\n } = {},\n closed: {\n button: { tooltip: closedTooltip = \"Open Assistant\" } = {},\n } = {},\n } = {},\n } = {},\n } = useThreadConfig();\n const tooltip = state === \"open\" ? openTooltip : closedTooltip;\n\n return (\n <ModalButtonStyled\n side=\"left\"\n tooltip={tooltip}\n data-state={state}\n {...rest}\n ref={ref}\n >\n {rest.children ?? (\n <>\n <BotIcon\n data-state={state}\n className=\"aui-modal-button-closed-icon\"\n />\n <ChevronDownIcon\n data-state={state}\n className=\"aui-modal-button-open-icon\"\n />\n </>\n )}\n </ModalButtonStyled>\n );\n});\n\nAssistantModalButton.displayName = \"AssistantModalButton\";\n\nconst AssistantModalContent = withDefaults(AssistantModalPrimitive.Content, {\n className: \"aui-root aui-modal-content\",\n sideOffset: 16,\n});\n\nAssistantModalContent.displayName = \"AssistantModalContent\";\n\nconst exports = {\n Root: AssistantModalRoot,\n Trigger: AssistantModalTrigger,\n Content: AssistantModalContent,\n};\n\nexport default Object.assign(AssistantModal, exports) as typeof AssistantModal &\n typeof exports;\n","\"use client\";\n\nimport { ComponentType, forwardRef, type FC } from \"react\";\nimport { ArrowDownIcon } from \"lucide-react\";\n\nimport { withDefaults } from \"./utils/withDefaults\";\nimport Composer from \"./composer\";\nimport ThreadWelcome from \"./thread-welcome\";\nimport {\n TooltipIconButton,\n TooltipIconButtonProps,\n} from \"./base/tooltip-icon-button\";\nimport AssistantMessage from \"./assistant-message\";\nimport UserMessage from \"./user-message\";\nimport EditComposer from \"./edit-composer\";\nimport {\n ThreadConfig,\n ThreadConfigProvider,\n ThreadConfigProviderProps,\n useThreadConfig,\n} from \"./thread-config\";\nimport { ThreadPrimitive, ThreadPrimitiveRootProps } from \"../primitives\";\n\nconst Thread: FC<ThreadConfig> = (config) => {\n return (\n <ThreadRoot config={config}>\n <ThreadViewport>\n <ThreadWelcome />\n <ThreadMessages />\n <ThreadViewportFooter>\n <ThreadScrollToBottom />\n <Composer />\n </ThreadViewportFooter>\n </ThreadViewport>\n </ThreadRoot>\n );\n};\n\nexport type ThreadRootProps = ThreadPrimitiveRootProps &\n ThreadConfigProviderProps;\n\nconst ThreadRootStyled = withDefaults(ThreadPrimitive.Root, {\n className: \"aui-root aui-thread-root\",\n});\n\nconst ThreadRoot = forwardRef<HTMLDivElement, ThreadRootProps>(\n ({ config, ...props }, ref) => {\n return (\n <ThreadConfigProvider config={config}>\n <ThreadRootStyled {...props} ref={ref} />\n </ThreadConfigProvider>\n );\n },\n);\n\nThreadRoot.displayName = \"ThreadRoot\";\n\nconst ThreadViewport = withDefaults(ThreadPrimitive.Viewport, {\n className: \"aui-thread-viewport\",\n});\n\nThreadViewport.displayName = \"ThreadViewport\";\n\nconst ThreadViewportFooter = withDefaults(\"div\", {\n className: \"aui-thread-viewport-footer\",\n});\n\nThreadViewportFooter.displayName = \"ThreadViewportFooter\";\n\nconst SystemMessage = () => null;\n\nconst ThreadMessages: FC<{\n components?: {\n UserMessage?: ComponentType | undefined;\n EditComposer?: ComponentType | undefined;\n AssistantMessage?: ComponentType | undefined;\n SystemMessage?: ComponentType | undefined;\n };\n}> = ({ components, ...rest }) => {\n return (\n <ThreadPrimitive.Messages\n components={{\n UserMessage: components?.UserMessage ?? UserMessage,\n EditComposer: components?.EditComposer ?? EditComposer,\n AssistantMessage: components?.AssistantMessage ?? AssistantMessage,\n SystemMessage: components?.SystemMessage ?? SystemMessage,\n }}\n {...rest}\n />\n );\n};\n\nThreadMessages.displayName = \"ThreadMessages\";\n\nconst ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {\n variant: \"outline\",\n className: \"aui-thread-scroll-to-bottom\",\n});\n\nconst ThreadScrollToBottom = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: {\n thread: { scrollToBottom: { tooltip = \"Scroll to bottom\" } = {} } = {},\n } = {},\n } = useThreadConfig();\n return (\n <ThreadPrimitive.ScrollToBottom asChild>\n <ThreadScrollToBottomIconButton tooltip={tooltip} {...props} ref={ref}>\n {props.children ?? <ArrowDownIcon />}\n </ThreadScrollToBottomIconButton>\n </ThreadPrimitive.ScrollToBottom>\n );\n});\n\nThreadScrollToBottom.displayName = \"ThreadScrollToBottom\";\n\nconst exports = {\n Root: ThreadRoot,\n Viewport: ThreadViewport,\n Messages: ThreadMessages,\n ScrollToBottom: ThreadScrollToBottom,\n ViewportFooter: ThreadViewportFooter,\n};\n\nexport default Object.assign(Thread, exports) as typeof Thread & typeof exports;\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, forwardRef, type FC } from \"react\";\n\nimport { SendHorizontalIcon } from \"lucide-react\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { useThreadConfig } from \"./thread-config\";\nimport {\n TooltipIconButton,\n TooltipIconButtonProps,\n} from \"./base/tooltip-icon-button\";\nimport { CircleStopIcon } from \"./base/CircleStopIcon\";\nimport { ComposerPrimitive, ThreadPrimitive } from \"../primitives\";\nimport { useThreadContext } from \"../context\";\n\nconst Composer: FC = () => {\n return (\n <ComposerRoot>\n <ComposerInput autoFocus />\n <ComposerAction />\n </ComposerRoot>\n );\n};\n\nComposer.displayName = \"Composer\";\n\nconst ComposerRoot = withDefaults(ComposerPrimitive.Root, {\n className: \"aui-composer-root\",\n});\n\nComposerRoot.displayName = \"ComposerRoot\";\n\nconst ComposerInputStyled = withDefaults(ComposerPrimitive.Input, {\n rows: 1,\n autoFocus: true,\n className: \"aui-composer-input\",\n});\n\nexport type ComposerInputProps = ComponentPropsWithoutRef<\n typeof ComposerInputStyled\n>;\nconst ComposerInput = forwardRef<HTMLTextAreaElement, ComposerInputProps>(\n (props, ref) => {\n const {\n strings: {\n composer: { input: { placeholder = \"Write a message...\" } = {} } = {},\n } = {},\n } = useThreadConfig();\n return (\n <ComposerInputStyled placeholder={placeholder} {...props} ref={ref} />\n );\n },\n);\n\nComposerInput.displayName = \"ComposerInput\";\n\nconst useAllowCancel = () => {\n const { useThreadActions } = useThreadContext();\n const cancelSupported = useThreadActions((t) => t.capabilities.cancel);\n return cancelSupported;\n};\n\nconst ComposerAction: FC = () => {\n const allowCancel = useAllowCancel();\n if (!allowCancel) return <ComposerSend />;\n return (\n <>\n <ThreadPrimitive.If running={false}>\n <ComposerSend />\n </ThreadPrimitive.If>\n <ThreadPrimitive.If running>\n <ComposerCancel />\n </ThreadPrimitive.If>\n </>\n );\n};\n\nComposerAction.displayName = \"ComposerAction\";\n\nconst ComposerSendButton = withDefaults(TooltipIconButton, {\n variant: \"default\",\n className: \"aui-composer-send\",\n});\n\nconst ComposerSend = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: { composer: { send: { tooltip = \"Send\" } = {} } = {} } = {},\n } = useThreadConfig();\n return (\n <ComposerPrimitive.Send asChild>\n <ComposerSendButton tooltip={tooltip} {...props} ref={ref}>\n {props.children ?? <SendHorizontalIcon />}\n </ComposerSendButton>\n </ComposerPrimitive.Send>\n );\n});\n\nComposerSend.displayName = \"ComposerSend\";\n\nconst ComposerCancelButton = withDefaults(TooltipIconButton, {\n variant: \"default\",\n className: \"aui-composer-cancel\",\n});\n\nconst ComposerCancel = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: { composer: { cancel: { tooltip = \"Cancel\" } = {} } = {} } = {},\n } = useThreadConfig();\n return (\n <ComposerPrimitive.Cancel asChild>\n <ComposerCancelButton tooltip={tooltip} {...props} ref={ref}>\n {props.children ?? <CircleStopIcon />}\n </ComposerCancelButton>\n </ComposerPrimitive.Cancel>\n );\n});\n\nComposerCancel.displayName = \"ComposerCancel\";\n\nconst exports = {\n Root: ComposerRoot,\n Input: ComposerInput,\n Action: ComposerAction,\n Send: ComposerSend,\n Cancel: ComposerCancel,\n};\n\nexport default Object.assign(Composer, exports) as typeof Composer &\n typeof exports;\n","import { FC } from \"react\";\n\nexport const CircleStopIcon: FC = () => {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n >\n <rect width=\"10\" height=\"10\" x=\"3\" y=\"3\" rx=\"2\" />\n </svg>\n );\n};\n\nCircleStopIcon.displayName = \"CircleStopIcon\";\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, forwardRef, type FC } from \"react\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { Avatar } from \"./base/avatar\";\nimport { SuggestionConfig, useThreadConfig } from \"./thread-config\";\nimport { ThreadPrimitive } from \"../primitives\";\n\nconst ThreadWelcome: FC = () => {\n return (\n <ThreadWelcomeRoot>\n <ThreadWelcomeCenter>\n <ThreadWelcomeAvatar />\n <ThreadWelcomeMessage />\n </ThreadWelcomeCenter>\n <ThreadWelcomeSuggestions />\n </ThreadWelcomeRoot>\n );\n};\n\nThreadWelcome.displayName = \"ThreadWelcome\";\n\nconst ThreadWelcomeRootStyled = withDefaults(\"div\", {\n className: \"aui-thread-welcome-root\",\n});\n\nconst ThreadWelcomeCenter = withDefaults(\"div\", {\n className: \"aui-thread-welcome-center\",\n});\n\ntype ThreadWelcomeRootProps = ComponentPropsWithoutRef<\"div\">;\n\nconst ThreadWelcomeRoot = forwardRef<HTMLDivElement, ThreadWelcomeRootProps>(\n (props, ref) => {\n return (\n <ThreadPrimitive.Empty>\n <ThreadWelcomeRootStyled {...props} ref={ref} />\n </ThreadPrimitive.Empty>\n );\n },\n);\n\nThreadWelcomeRoot.displayName = \"ThreadWelcomeRoot\";\n\nconst ThreadWelcomeAvatar: FC = () => {\n const { assistantAvatar: avatar = { fallback: \"A\" } } = useThreadConfig();\n return <Avatar {...avatar} />;\n};\n\nconst ThreadWelcomeMessageStyled = withDefaults(\"p\", {\n className: \"aui-thread-welcome-message\",\n});\n\nexport type ThreadWelcomeMessageProps = Omit<\n ComponentPropsWithoutRef<typeof ThreadWelcomeMessageStyled>,\n \"children\"\n> & { message?: string | undefined };\n\nconst ThreadWelcomeMessage = forwardRef<\n HTMLParagraphElement,\n ThreadWelcomeMessageProps\n>(({ message: messageProp, ...rest }, ref) => {\n const { welcome: { message = \"How can I help you today?\" } = {} } =\n useThreadConfig();\n return (\n <ThreadWelcomeMessageStyled {...rest} ref={ref}>\n {messageProp ?? message}\n </ThreadWelcomeMessageStyled>\n );\n});\n\nThreadWelcomeMessage.displayName = \"ThreadWelcomeMessage\";\n\nconst ThreadWelcomeSuggestionContainer = withDefaults(\"div\", {\n className: \"aui-thread-welcome-suggestion-container\",\n});\n\nconst ThreadWelcomeSuggestionStyled = withDefaults(ThreadPrimitive.Suggestion, {\n className: \"aui-thread-welcome-suggestion\",\n});\n\nexport type ThreadWelcomeSuggestionProps = {\n suggestion: SuggestionConfig;\n};\n\nconst ThreadWelcomeSuggestion: FC<ThreadWelcomeSuggestionProps> = ({\n suggestion: { text, prompt },\n}) => {\n return (\n <ThreadWelcomeSuggestionStyled\n prompt={prompt}\n method=\"replace\"\n autoSend\n >\n <span className=\"aui-thread-welcome-suggestion-text\">{text ?? prompt}</span>\n </ThreadWelcomeSuggestionStyled>\n );\n};\n\nconst ThreadWelcomeSuggestions: FC = () => {\n const { welcome: { suggestions } = {} } = useThreadConfig();\n return (\n <ThreadWelcomeSuggestionContainer>\n {suggestions?.map((suggestion, idx) => {\n const key = `${suggestion.prompt}-${idx}`;\n return <ThreadWelcomeSuggestion key={key} suggestion={suggestion} />;\n })}\n </ThreadWelcomeSuggestionContainer>\n );\n};\n\nThreadWelcomeSuggestions.displayName = \"ThreadWelcomeSuggestions\";\n\nconst exports = {\n Root: ThreadWelcomeRoot,\n Center: ThreadWelcomeCenter,\n Avatar: ThreadWelcomeAvatar,\n Message: ThreadWelcomeMessage,\n Suggestions: ThreadWelcomeSuggestions,\n Suggestion: ThreadWelcomeSuggestion,\n};\n\nexport default Object.assign(ThreadWelcome, exports) as typeof ThreadWelcome &\n typeof exports;\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, forwardRef, type FC } from \"react\";\n\nimport BranchPicker from \"./branch-picker\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport UserActionBar from \"./user-action-bar\";\nimport ContentPart from \"./content-part\";\nimport { MessagePrimitive, MessagePrimitiveContentProps } from \"../primitives\";\n\nconst UserMessage: FC = () => {\n return (\n <UserMessageRoot>\n <UserActionBar />\n <UserMessageContent />\n <BranchPicker />\n </UserMessageRoot>\n );\n};\n\nUserMessage.displayName = \"UserMessage\";\n\nconst UserMessageRoot = withDefaults(MessagePrimitive.Root, {\n className: \"aui-user-message-root\",\n});\n\nUserMessageRoot.displayName = \"UserMessageRoot\";\n\nconst UserMessageContentWrapper = withDefaults(\"div\", {\n className: \"aui-user-message-content\",\n});\n\nexport type UserMessageContentProps = MessagePrimitiveContentProps &\n ComponentPropsWithoutRef<\"div\">;\n\nconst UserMessageContent = forwardRef<HTMLDivElement, UserMessageContentProps>(\n ({ components, ...props }, ref) => {\n return (\n <UserMessageContentWrapper {...props} ref={ref}>\n <MessagePrimitive.Content\n components={{\n ...components,\n Text: components?.Text ?? ContentPart.Text,\n }}\n />\n </UserMessageContentWrapper>\n );\n },\n);\n\nUserMessageContent.displayName = \"UserMessageContent\";\n\nconst exports = {\n Root: UserMessageRoot,\n Content: UserMessageContent,\n};\n\nexport default Object.assign(UserMessage, exports) as typeof UserMessage &\n typeof exports;\n","\"use client\";\n\nimport { forwardRef, type FC } from \"react\";\nimport { PencilIcon } from \"lucide-react\";\n\nimport {\n TooltipIconButton,\n TooltipIconButtonProps,\n} from \"./base/tooltip-icon-button\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { useThreadConfig } from \"./thread-config\";\nimport { useThreadContext } from \"../context\";\nimport { ActionBarPrimitive } from \"../primitives\";\n\nconst useAllowEdit = () => {\n const { userMessage: { allowEdit = true } = {} } = useThreadConfig();\n const { useThreadActions } = useThreadContext();\n const editSupported = useThreadActions((t) => t.capabilities.edit);\n return editSupported && allowEdit;\n};\n\nconst UserActionBar: FC = () => {\n const allowEdit = useAllowEdit();\n if (!allowEdit) return null;\n return (\n <UserActionBarRoot hideWhenRunning autohide=\"not-last\">\n <UserActionBarEdit />\n </UserActionBarRoot>\n );\n};\n\nUserActionBar.displayName = \"UserActionBar\";\n\nconst UserActionBarRoot = withDefaults(ActionBarPrimitive.Root, {\n className: \"aui-user-action-bar-root\",\n});\n\nUserActionBarRoot.displayName = \"UserActionBarRoot\";\n\nconst UserActionBarEdit = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: { userMessage: { edit: { tooltip = \"Edit\" } = {} } = {} } = {},\n } = useThreadConfig();\n const allowEdit = useAllowEdit();\n if (!allowEdit) return null;\n return (\n <ActionBarPrimitive.Edit asChild>\n <TooltipIconButton tooltip={tooltip} {...props} ref={ref}>\n {props.children ?? <PencilIcon />}\n </TooltipIconButton>\n </ActionBarPrimitive.Edit>\n );\n});\n\nUserActionBarEdit.displayName = \"UserActionBarEdit\";\n\nconst exports = {\n Root: UserActionBarRoot,\n Edit: UserActionBarEdit,\n};\n\nexport default Object.assign(UserActionBar, exports) as typeof UserActionBar &\n typeof exports;\n","\"use client\";\n\nimport { forwardRef, type FC } from \"react\";\n\nimport { Button, ButtonProps } from \"./base/button\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { useThreadConfig } from \"./thread-config\";\nimport { ComposerPrimitive } from \"../primitives\";\n\nconst EditComposer: FC = () => {\n return (\n <EditComposerRoot>\n <EditComposerInput />\n\n <EditComposerFooter>\n <EditComposerCancel />\n <EditComposerSend />\n </EditComposerFooter>\n </EditComposerRoot>\n );\n};\n\nEditComposer.displayName = \"EditComposer\";\n\nconst EditComposerRoot = withDefaults(ComposerPrimitive.Root, {\n className: \"aui-edit-composer-root\",\n});\n\nEditComposerRoot.displayName = \"EditComposerRoot\";\n\nconst EditComposerInput = withDefaults(ComposerPrimitive.Input, {\n className: \"aui-edit-composer-input\",\n});\n\nEditComposerInput.displayName = \"EditComposerInput\";\n\nconst EditComposerFooter = withDefaults(\"div\", {\n className: \"aui-edit-composer-footer\",\n});\n\nEditComposerFooter.displayName = \"EditComposerFooter\";\n\nconst EditComposerCancel = forwardRef<HTMLButtonElement, Partial<ButtonProps>>(\n (props, ref) => {\n const {\n strings: {\n editComposer: { cancel: { label = \"Cancel\" } = {} } = {},\n } = {},\n } = useThreadConfig();\n return (\n <ComposerPrimitive.Cancel asChild>\n <Button variant=\"ghost\" {...props} ref={ref}>\n {props.children ?? label}\n </Button>\n </ComposerPrimitive.Cancel>\n );\n },\n);\n\nEditComposerCancel.displayName = \"EditComposerCancel\";\n\nconst EditComposerSend = forwardRef<HTMLButtonElement, Partial<ButtonProps>>(\n (props, ref) => {\n const {\n strings: { editComposer: { send: { label = \"Send\" } = {} } = {} } = {},\n } = useThreadConfig();\n return (\n <ComposerPrimitive.Send asChild>\n <Button {...props} ref={ref}>\n {props.children ?? label}\n </Button>\n </ComposerPrimitive.Send>\n );\n },\n);\n\nEditComposerSend.displayName = \"EditComposerSend\";\n\nconst exports = {\n Root: EditComposerRoot,\n Input: EditComposerInput,\n Footer: EditComposerFooter,\n Cancel: EditComposerCancel,\n Send: EditComposerSend,\n};\n\nexport default Object.assign(EditComposer, exports) as typeof EditComposer &\n typeof exports;\n"],"mappings":";;;;;;;;;;;;;;;AACA,SAAS,YAAY;;;ACErB,SAAS,WAAW,sBAAAA,qBAAoB,UAAAC,SAAQ,YAAAC,iBAAgB;;;ACDhE,SAAS,eAAe,kBAAkB;AAYnC,IAAM,mBAAmB;AAAA,EAC9B;AACF;AAMO,SAAS,oBAAoB,SAA8B;AAChE,QAAM,UAAU,WAAW,gBAAgB;AAC3C,MAAI,CAAC,SAAS,YAAY,CAAC;AACzB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;;;AC3BA,SAAS,cAAc;;;ACIhB,IAAM,sBAAN,MAAyD;AAAA,EACtD,aAAa,oBAAI,IAAyB;AAAA,EAElD,iBAAiB;AACf,WAAO,kBAAkB,KAAK,UAAU;AAAA,EAC1C;AAAA,EAEA,4BAA4B,UAA+B;AACzD,SAAK,WAAW,IAAI,QAAQ;AAC5B,WAAO,MAAM;AACX,WAAK,WAAW,OAAO,QAAQ;AAAA,IACjC;AAAA,EACF;AACF;;;ADPO,IAAM,gCAAgC,MAC3C,OAAkC,MAAM;AACtC,QAAM,QAAQ,IAAI,oBAAoB;AAEtC,SAAO,OAAO,OAAO;AAAA,IACnB,gBAAgB,MAAM;AACpB,aAAO,MA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wB,SAAS;AAAA,EAC1E,WAAW;AAAA,EACX,YAAY;AACd,CAAC;AAED,sBAAsB,cAAc;AAEpC,IAAMG,YAAU;AAAA,EACd,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AACX;AAEA,IAAO,0BAAQ,OAAO,OAAO,gBAAgBA,SAAO;","names":["useInsertionEffect","useRef","useState","create","useCallback","createContext","useContext","create","create","create","create","create","create","create","useCallback","create","jsx","useRef","useInsertionEffect","useState","jsx","createContext","useContext","createContext","useContext","useCallback","useCallback","useCallback","useCallback","useEffect","useEffect","useEffect","useEffect","useEffect","useEffect","useCallback","useMemo","useMemo","c","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","jsx","forwardRef","Primitive","jsx","useState","PopoverPrimitive","composeEventHandlers","useEffect","useEffect","jsx","useState","composeEventHandlers","forwardRef","PopoverPrimitive","jsx","forwardRef","forwardRef","PopoverPrimitive","composeEventHandlers","jsx","forwardRef","forwardRef","PopoverPrimitive","jsx","forwardRef","jsx","Fragment","jsx","Primitive","forwardRef","Primitive","forwardRef","useCallback","jsx","useCallback","forwardRef","Primitive","memo","useEffect","useState","create","jsx","useContentPartContext","useState","create","useEffect","forwardRef","useEffect","useMemo","useRef","useState","createContext","forwardRef","useContext","useState","create","jsx","createContext","useSmoothStatus","useState","forwardRef","useContext","useCallbackRef","useSmoothStatus","useRef","useState","text","useEffect","useMemo","jsx","forwardRef","Primitive","forwardRef","jsx","forwardRef","Primitive","jsx","jsxs","Text","Image","Fallback","memo","jsx","forwardRef","Primitive","composeEventHandlers","Primitive","forwardRef","jsx","forwardRef","Primitive","composeEventHandlers","composeEventHandlers","useComposedRefs","forwardRef","useCallback","useEffect","useRef","jsx","forwardRef","useRef","useComposedRefs","useCallback","useEffect","composeEventHandlers","forwardRef","Primitive","jsx","forwardRef","Primitive","forwardRef","jsx","useComposedRefs","Primitive","forwardRef","useComposedRefs","useRef","useCallbackRef","useCallback","useCallbackRef","useCallback","useCallbackRef","useEffect","useCallbackRef","useEffect","useRef","useComposedRefs","jsx","forwardRef","useComposedRefs","Primitive","memo","useEffect","useState","create","create","create","create","jsx","useMessageContext","useState","create","useEffect","jsx","jsxs","UserMessage","EditComposer","AssistantMessage","SystemMessage","memo","useInsertionEffect","useState","message","forwardRef","forwardRef","jsx","jsx","Primitive","forwardRef","jsx","jsx","jsxs","forwardRef","useState","useState","useState","useInsertionEffect","create","useEffect","useInsertionEffect","useMemo","useRef","useRef","useInsertionEffect","useMemo","converter","convertCallback","useEffect","create","useEffect","useInsertionEffect","useState","useState","useInsertionEffect","useEffect","createContext","useContext","Fragment","jsx","createContext","useContext","forwardRef","Fragment","jsx","jsxs","forwardRef","forwardRef","forwardRef","jsx","jsxs","BranchPickerPrevious","forwardRef","exports","jsx","jsxs","classNames","jsx","exports","jsx","jsxs","forwardRef","exports","forwardRef","forwardRef","forwardRef","jsx","Fragment","jsx","jsxs","forwardRef","exports","forwardRef","jsx","jsxs","forwardRef","exports","forwardRef","forwardRef","jsx","forwardRef","exports","jsx","jsxs","forwardRef","exports","forwardRef","jsx","jsxs","forwardRef","exports","jsx","jsxs","forwardRef","exports","Fragment","jsx","jsxs","forwardRef","exports"]}
1
+ {"version":3,"sources":["../src/context/providers/AssistantRuntimeProvider.tsx","../src/context/providers/AssistantProvider.tsx","../src/context/react/AssistantContext.ts","../src/context/stores/AssistantModelConfig.ts","../src/utils/ProxyConfigProvider.ts","../src/context/stores/AssistantToolUIs.ts","../src/context/providers/ThreadProvider.tsx","../src/context/react/ThreadContext.ts","../src/context/stores/Composer.ts","../src/context/stores/BaseComposer.ts","../src/context/stores/Thread.ts","../src/context/stores/ThreadViewport.tsx","../src/context/stores/ThreadActions.ts","../src/context/stores/ThreadMessages.ts","../src/context/stores/ThreadRuntime.tsx","../src/utils/hooks/useManagedRef.ts","../src/context/stores/AssistantActions.tsx","../src/context/react/ComposerContext.ts","../src/context/react/MessageContext.ts","../src/context/react/ContentPartContext.ts","../src/hooks/useAppendMessage.tsx","../src/hooks/useSwitchToNewThread.tsx","../src/model-config/useAssistantTool.tsx","../src/model-config/makeAssistantTool.tsx","../src/model-config/useAssistantToolUI.tsx","../src/model-config/makeAssistantToolUI.tsx","../src/model-config/useAssistantInstructions.tsx","../src/primitive-hooks/actionBar/useActionBarCopy.tsx","../src/utils/combined/useCombinedStore.ts","../src/utils/combined/createCombinedStore.ts","../src/utils/getMessageText.tsx","../src/primitive-hooks/actionBar/useActionBarEdit.tsx","../src/primitive-hooks/actionBar/useActionBarReload.tsx","../src/primitive-hooks/branchPicker/useBranchPickerCount.tsx","../src/primitive-hooks/branchPicker/useBranchPickerNext.tsx","../src/primitive-hooks/branchPicker/useBranchPickerNumber.tsx","../src/primitive-hooks/branchPicker/useBranchPickerPrevious.tsx","../src/primitive-hooks/composer/useComposerCancel.tsx","../src/primitive-hooks/composer/useComposerIf.tsx","../src/primitive-hooks/composer/useComposerSend.tsx","../src/primitive-hooks/contentPart/useContentPartDisplay.tsx","../src/primitive-hooks/contentPart/useContentPartImage.tsx","../src/primitive-hooks/contentPart/useContentPartText.tsx","../src/primitive-hooks/message/useMessageIf.tsx","../src/primitive-hooks/thread/useThreadIf.tsx","../src/primitive-hooks/thread/useThreadEmpty.tsx","../src/primitive-hooks/thread/useThreadScrollToBottom.tsx","../src/primitive-hooks/thread/useThreadSuggestion.tsx","../src/primitives/actionBar/index.ts","../src/primitives/actionBar/ActionBarRoot.tsx","../src/primitives/actionBar/useActionBarFloatStatus.tsx","../src/utils/createActionButton.tsx","../src/primitives/actionBar/ActionBarCopy.tsx","../src/primitives/actionBar/ActionBarReload.tsx","../src/primitives/actionBar/ActionBarEdit.tsx","../src/primitives/assistantModal/index.ts","../src/primitives/assistantModal/AssistantModalRoot.tsx","../src/utils/hooks/useOnComposerFocus.tsx","../src/primitives/assistantModal/scope.tsx","../src/primitives/assistantModal/AssistantModalTrigger.tsx","../src/primitives/assistantModal/AssistantModalContent.tsx","../src/primitives/assistantModal/AssistantModalAnchor.tsx","../src/primitives/branchPicker/index.ts","../src/primitives/branchPicker/BranchPickerNext.tsx","../src/primitives/branchPicker/BranchPickerPrevious.tsx","../src/primitives/branchPicker/BranchPickerCount.tsx","../src/primitives/branchPicker/BranchPickerNumber.tsx","../src/primitives/branchPicker/BranchPickerRoot.tsx","../src/primitives/message/index.ts","../src/primitives/message/MessageRoot.tsx","../src/primitives/message/MessageIf.tsx","../src/primitives/message/MessageContent.tsx","../src/context/providers/ContentPartProvider.tsx","../src/primitives/contentPart/ContentPartText.tsx","../src/utils/smooth/useSmooth.tsx","../src/utils/smooth/SmoothContext.tsx","../src/primitives/contentPart/ContentPartImage.tsx","../src/primitives/contentPart/ContentPartDisplay.tsx","../src/primitives/contentPart/ContentPartInProgress.tsx","../src/primitives/message/MessageInProgress.tsx","../src/primitives/composer/index.ts","../src/primitives/composer/ComposerRoot.tsx","../src/primitives/composer/ComposerInput.tsx","../src/primitives/composer/ComposerSend.tsx","../src/primitives/composer/ComposerCancel.tsx","../src/primitives/composer/ComposerIf.tsx","../src/primitives/contentPart/index.ts","../src/primitives/thread/index.ts","../src/primitives/thread/ThreadRoot.tsx","../src/primitives/thread/ThreadEmpty.tsx","../src/primitives/thread/ThreadIf.tsx","../src/primitives/thread/ThreadViewport.tsx","../src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx","../src/utils/hooks/useOnResizeContent.tsx","../src/utils/hooks/useOnScrollToBottom.tsx","../src/primitives/thread/ThreadMessages.tsx","../src/context/providers/MessageProvider.tsx","../src/context/stores/EditComposer.ts","../src/context/stores/MessageUtils.ts","../src/primitives/thread/ThreadScrollToBottom.tsx","../src/primitives/thread/ThreadSuggestion.tsx","../src/runtimes/local/useLocalRuntime.tsx","../src/runtimes/core/BaseAssistantRuntime.tsx","../src/internal.ts","../src/utils/idUtils.tsx","../src/runtimes/edge/converters/fromCoreMessage.ts","../src/runtimes/utils/MessageRepository.tsx","../src/ui/base/tooltip-icon-button.tsx","../src/ui/base/tooltip.tsx","../src/ui/utils/withDefaults.tsx","../src/ui/base/button.tsx","../src/runtimes/edge/converters/fromLanguageModelMessages.ts","../src/runtimes/edge/converters/fromLanguageModelTools.ts","../src/runtimes/edge/useEdgeRuntime.ts","../src/runtimes/edge/streams/assistantDecoderStream.ts","../src/runtimes/edge/streams/chunkByLineStream.ts","../src/runtimes/edge/EdgeChatAdapter.ts","../src/runtimes/local/shouldContinue.tsx","../src/runtimes/local/LocalThreadRuntime.tsx","../src/runtimes/local/LocalRuntime.tsx","../src/runtimes/external-store/ExternalStoreThreadRuntime.tsx","../src/runtimes/external-store/getExternalStoreMessage.tsx","../src/runtimes/external-store/useExternalStoreSync.tsx","../src/runtimes/external-store/ThreadMessageConverter.ts","../src/runtimes/external-store/auto-status.tsx","../src/runtimes/external-store/ThreadMessageLike.tsx","../src/runtimes/external-store/ExternalStoreRuntime.tsx","../src/runtimes/external-store/useExternalStoreRuntime.tsx","../src/ui/thread-config.tsx","../src/ui/assistant-action-bar.tsx","../src/ui/assistant-message.tsx","../src/ui/branch-picker.tsx","../src/ui/base/avatar.tsx","../src/ui/content-part.tsx","../src/ui/assistant-modal.tsx","../src/ui/thread.tsx","../src/ui/composer.tsx","../src/ui/base/CircleStopIcon.tsx","../src/ui/thread-welcome.tsx","../src/ui/user-message.tsx","../src/ui/user-action-bar.tsx","../src/ui/edit-composer.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from \"react\";\nimport { memo } from \"react\";\nimport type { AssistantRuntime } from \"../../runtimes/core/AssistantRuntime\";\nimport { AssistantProvider } from \"./AssistantProvider\";\n\ntype AssistantRuntimeProviderProps = {\n runtime: AssistantRuntime;\n};\n\nconst AssistantRuntimeProviderImpl: FC<\n PropsWithChildren<AssistantRuntimeProviderProps>\n> = ({ children, runtime }) => {\n return <AssistantProvider runtime={runtime}>{children}</AssistantProvider>;\n};\n\nexport const AssistantRuntimeProvider = memo(AssistantRuntimeProviderImpl);\n","\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport { useEffect, useInsertionEffect, useRef, useState } from \"react\";\nimport type { AssistantRuntime } from \"../../runtimes\";\nimport { AssistantContext } from \"../react/AssistantContext\";\nimport { makeAssistantModelConfigStore } from \"../stores/AssistantModelConfig\";\nimport { makeAssistantToolUIsStore } from \"../stores/AssistantToolUIs\";\nimport { ThreadProvider } from \"./ThreadProvider\";\nimport { makeAssistantActionsStore } from \"../stores/AssistantActions\";\n\ntype AssistantProviderProps = {\n runtime: AssistantRuntime;\n};\n\nexport const AssistantProvider: FC<\n PropsWithChildren<AssistantProviderProps>\n> = ({ children, runtime }) => {\n const runtimeRef = useRef(runtime);\n useInsertionEffect(() => {\n runtimeRef.current = runtime;\n });\n\n const [context] = useState(() => {\n const useModelConfig = makeAssistantModelConfigStore();\n const useToolUIs = makeAssistantToolUIsStore();\n const useAssistantActions = makeAssistantActionsStore(runtimeRef);\n\n return { useModelConfig, useToolUIs, useAssistantActions };\n });\n\n const getModelConfig = context.useModelConfig();\n useEffect(() => {\n return runtime.registerModelConfigProvider(getModelConfig);\n }, [runtime, getModelConfig]);\n\n return (\n <AssistantContext.Provider value={context}>\n <ThreadProvider provider={runtime}>{children}</ThreadProvider>\n </AssistantContext.Provider>\n );\n};\n","\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport type { AssistantModelConfigState } from \"../stores/AssistantModelConfig\";\nimport type { AssistantToolUIsState } from \"../stores/AssistantToolUIs\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { AssistantActionsState } from \"../stores/AssistantActions\";\n\nexport type AssistantContextValue = {\n useModelConfig: ReadonlyStore<AssistantModelConfigState>;\n useToolUIs: ReadonlyStore<AssistantToolUIsState>;\n useAssistantActions: ReadonlyStore<AssistantActionsState>;\n};\n\nexport const AssistantContext = createContext<AssistantContextValue | null>(\n null,\n);\n\nexport function useAssistantContext(): AssistantContextValue;\nexport function useAssistantContext(options: {\n optional: true;\n}): AssistantContextValue | null;\nexport function useAssistantContext(options?: { optional: true }) {\n const context = useContext(AssistantContext);\n if (!options?.optional && !context)\n throw new Error(\n \"This component must be used within an AssistantRuntimeProvider.\",\n );\n return context;\n}\n","\"use client\";\n\nimport { create } from \"zustand\";\nimport type { ModelConfigProvider } from \"../../types/ModelConfigTypes\";\nimport { ProxyConfigProvider } from \"../../utils/ProxyConfigProvider\";\n\nexport type AssistantModelConfigState = Readonly<\n ModelConfigProvider & {\n registerModelConfigProvider: (provider: ModelConfigProvider) => () => void;\n }\n>;\n\nexport const makeAssistantModelConfigStore = () =>\n create<AssistantModelConfigState>(() => {\n const proxy = new ProxyConfigProvider();\n\n return Object.freeze({\n getModelConfig: () => {\n return proxy.getModelConfig();\n },\n registerModelConfigProvider: (provider: ModelConfigProvider) => {\n return proxy.registerModelConfigProvider(provider);\n },\n }) satisfies AssistantModelConfigState;\n });\n","\"use client\";\nimport {\n type ModelConfigProvider,\n mergeModelConfigs,\n} from \"../types/ModelConfigTypes\";\n\nexport class ProxyConfigProvider implements ModelConfigProvider {\n private _providers = new Set<ModelConfigProvider>();\n\n getModelConfig() {\n return mergeModelConfigs(this._providers);\n }\n\n registerModelConfigProvider(provider: ModelConfigProvider) {\n this._providers.add(provider);\n return () => {\n this._providers.delete(provider);\n };\n }\n}\n","\"use client\";\n\nimport { create } from \"zustand\";\nimport type { ToolCallContentPartComponent } from \"../../types/ContentPartComponentTypes\";\n\nexport type AssistantToolUIsState = Readonly<{\n getToolUI: (toolName: string) => ToolCallContentPartComponent | null;\n setToolUI: (\n toolName: string,\n render: ToolCallContentPartComponent,\n ) => () => void;\n}>;\n\nexport const makeAssistantToolUIsStore = () =>\n create<AssistantToolUIsState>((set) => {\n const renderers = new Map<string, ToolCallContentPartComponent[]>();\n\n return Object.freeze({\n getToolUI: (name) => {\n const arr = renderers.get(name);\n const last = arr?.at(-1);\n if (last) return last;\n return null;\n },\n setToolUI: (name, render) => {\n let arr = renderers.get(name);\n if (!arr) {\n arr = [];\n renderers.set(name, arr);\n }\n arr.push(render);\n set({}); // notify the store listeners\n\n return () => {\n const index = arr.indexOf(render);\n if (index !== -1) {\n arr.splice(index, 1);\n }\n if (index === arr.length) {\n set({}); // notify the store listeners\n }\n };\n },\n }) satisfies AssistantToolUIsState;\n });\n","import type { FC, PropsWithChildren } from \"react\";\nimport { useCallback, useInsertionEffect, useState } from \"react\";\nimport type { ReactThreadRuntime } from \"../../runtimes/core/ReactThreadRuntime\";\nimport type { ThreadContextValue } from \"../react/ThreadContext\";\nimport { ThreadContext } from \"../react/ThreadContext\";\nimport { makeComposerStore } from \"../stores/Composer\";\nimport { ThreadState, makeThreadStore } from \"../stores/Thread\";\nimport { makeThreadViewportStore } from \"../stores/ThreadViewport\";\nimport { makeThreadActionStore } from \"../stores/ThreadActions\";\nimport { StoreApi } from \"zustand\";\nimport {\n ThreadMessagesState,\n makeThreadMessagesStore,\n} from \"../stores/ThreadMessages\";\nimport { ThreadRuntimeWithSubscribe } from \"../../runtimes/core/AssistantRuntime\";\nimport {\n makeThreadRuntimeStore,\n ThreadRuntimeStore,\n} from \"../stores/ThreadRuntime\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\n\ntype ThreadProviderProps = {\n provider: ThreadRuntimeWithSubscribe;\n};\n\nexport const ThreadProvider: FC<PropsWithChildren<ThreadProviderProps>> = ({\n children,\n provider,\n}) => {\n const [context] = useState<ThreadContextValue>(() => {\n const useThreadRuntime = makeThreadRuntimeStore(provider.thread);\n const useThread = makeThreadStore(useThreadRuntime);\n const useThreadMessages = makeThreadMessagesStore(useThreadRuntime);\n const useThreadActions = makeThreadActionStore(useThreadRuntime);\n const useViewport = makeThreadViewportStore();\n const useComposer = makeComposerStore(useThreadMessages, useThreadActions);\n\n return {\n useThread,\n useThreadRuntime,\n useThreadMessages,\n useThreadActions,\n useComposer,\n useViewport,\n };\n });\n\n const threadRef = useManagedRef(\n useCallback(\n (thread: ReactThreadRuntime) => {\n const onThreadUpdate = () => {\n const threadState = context.useThread.getState();\n if (\n thread.isRunning !== threadState.isRunning ||\n thread.isDisabled !== threadState.isDisabled\n ) {\n (context.useThread as unknown as StoreApi<ThreadState>).setState(\n Object.freeze({\n isRunning: thread.isRunning,\n isDisabled: thread.isDisabled,\n }) satisfies ThreadState,\n true,\n );\n }\n\n if (thread.messages !== context.useThreadMessages.getState()) {\n (\n context.useThreadMessages as unknown as StoreApi<ThreadMessagesState>\n ).setState(thread.messages, true);\n }\n };\n\n onThreadUpdate();\n return thread.subscribe(onThreadUpdate);\n },\n [context],\n ),\n );\n\n useInsertionEffect(() => {\n const unsubscribe = provider.subscribe(() => {\n (\n context.useThreadRuntime as unknown as StoreApi<ThreadRuntimeStore>\n ).setState(provider.thread, true);\n threadRef(provider.thread);\n });\n threadRef(provider.thread);\n return () => {\n unsubscribe();\n threadRef(null);\n };\n }, [provider, context]);\n\n // subscribe to thread updates\n const Synchronizer = context.useThreadRuntime(\n (t) => (t as ReactThreadRuntime).unstable_synchronizer,\n );\n\n return (\n <ThreadContext.Provider value={context}>\n {Synchronizer && <Synchronizer />}\n {children}\n </ThreadContext.Provider>\n );\n};\n","\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport type { ComposerState } from \"../stores/Composer\";\nimport type { ThreadState } from \"../stores/Thread\";\nimport type { ThreadViewportState } from \"../stores/ThreadViewport\";\nimport { ThreadActionsState } from \"../stores/ThreadActions\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { ThreadMessagesState } from \"../stores/ThreadMessages\";\nimport { ThreadRuntimeStore } from \"../stores/ThreadRuntime\";\n\nexport type ThreadContextValue = {\n useThread: ReadonlyStore<ThreadState>;\n useThreadRuntime: ReadonlyStore<ThreadRuntimeStore>;\n useThreadMessages: ReadonlyStore<ThreadMessagesState>;\n useThreadActions: ReadonlyStore<ThreadActionsState>;\n useComposer: ReadonlyStore<ComposerState>;\n useViewport: ReadonlyStore<ThreadViewportState>;\n};\n\nexport const ThreadContext = createContext<ThreadContextValue | null>(null);\n\nexport function useThreadContext(): ThreadContextValue;\nexport function useThreadContext(options: {\n optional: true;\n}): ThreadContextValue | null;\nexport function useThreadContext(options?: { optional: true }) {\n const context = useContext(ThreadContext);\n if (!options?.optional && !context)\n throw new Error(\n \"This component must be used within an AssistantRuntimeProvider.\",\n );\n return context;\n}\n","import { create } from \"zustand\";\nimport { type BaseComposerState, makeBaseComposer } from \"./BaseComposer\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { Unsubscribe } from \"../../types/Unsubscribe\";\nimport { ThreadContextValue } from \"../react\";\n\nexport type ComposerState = BaseComposerState &\n Readonly<{\n canCancel: boolean;\n isEditing: true;\n\n send: () => void;\n cancel: () => void;\n focus: () => void;\n onFocus: (listener: () => void) => Unsubscribe;\n }>;\n\nexport const makeComposerStore = (\n useThreadMessages: ThreadContextValue[\"useThreadMessages\"],\n useThreadActions: ThreadContextValue[\"useThreadActions\"],\n): ReadonlyStore<ComposerState> => {\n const focusListeners = new Set<() => void>();\n return create<ComposerState>()((set, get, store) => {\n return {\n ...makeBaseComposer(set, get, store),\n\n get canCancel() {\n return useThreadActions.getState().capabilities.cancel;\n },\n isEditing: true,\n\n send: () => {\n const { setValue, value } = get();\n setValue(\"\");\n\n useThreadActions.getState().append({\n parentId: useThreadMessages.getState().at(-1)?.id ?? null,\n role: \"user\",\n content: [{ type: \"text\", text: value }],\n });\n },\n cancel: () => {\n useThreadActions.getState().cancelRun();\n },\n focus: () => {\n for (const listener of focusListeners) {\n listener();\n }\n },\n onFocus: (listener) => {\n focusListeners.add(listener);\n return () => {\n focusListeners.delete(listener);\n };\n },\n };\n });\n};\n","import type { StateCreator } from \"zustand\";\n\nexport type BaseComposerState = Readonly<{\n value: string;\n setValue: (value: string) => void;\n}>;\n\nexport const makeBaseComposer: StateCreator<\n BaseComposerState,\n [],\n [],\n BaseComposerState\n> = (set) => ({\n value: \"\",\n setValue: (value) => {\n set({ value });\n },\n});\n","import { create } from \"zustand\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { ThreadRuntimeStore } from \"./ThreadRuntime\";\n\nexport type ThreadState = Readonly<{\n isRunning: boolean;\n isDisabled: boolean;\n}>;\n\nexport const makeThreadStore = (\n runtimeRef: ReadonlyStore<ThreadRuntimeStore>,\n) => {\n return create<ThreadState>(() => ({\n isDisabled: runtimeRef.getState().isDisabled,\n isRunning: runtimeRef.getState().isRunning,\n }));\n};\n","\"use client\";\nimport { create } from \"zustand\";\nimport type { Unsubscribe } from \"../../types/Unsubscribe\";\n\nexport type ThreadViewportState = Readonly<{\n isAtBottom: boolean;\n scrollToBottom: () => void;\n onScrollToBottom: (callback: () => void) => Unsubscribe;\n}>;\n\nexport const makeThreadViewportStore = () => {\n const scrollToBottomListeners = new Set<() => void>();\n\n return create<ThreadViewportState>(() => ({\n isAtBottom: true,\n scrollToBottom: () => {\n for (const listener of scrollToBottomListeners) {\n listener();\n }\n },\n onScrollToBottom: (callback) => {\n scrollToBottomListeners.add(callback);\n return () => {\n scrollToBottomListeners.delete(callback);\n };\n },\n }));\n};\n","import { create } from \"zustand\";\nimport type { AppendMessage } from \"../../types/AssistantTypes\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { ThreadRuntimeStore } from \"./ThreadRuntime\";\n\nexport type AddToolResultOptions = {\n messageId: string;\n toolCallId: string;\n result: any;\n};\n\nexport type RuntimeCapabilities = {\n switchToBranch: boolean;\n edit: boolean;\n reload: boolean;\n cancel: boolean;\n copy: boolean;\n};\n\nexport type ThreadActionsState = Readonly<{\n capabilities: Readonly<RuntimeCapabilities>;\n\n getBranches: (messageId: string) => readonly string[];\n switchToBranch: (branchId: string) => void;\n\n append: (message: AppendMessage) => void;\n startRun: (parentId: string | null) => void;\n cancelRun: () => void;\n\n addToolResult: (options: AddToolResultOptions) => void;\n}>;\n\nexport const makeThreadActionStore = (\n runtimeStore: ReadonlyStore<ThreadRuntimeStore>,\n) => {\n return create<ThreadActionsState>(() =>\n Object.freeze({\n get capabilities() {\n return runtimeStore.getState().capabilities;\n },\n getBranches: (messageId) =>\n runtimeStore.getState().getBranches(messageId),\n switchToBranch: (branchId) =>\n runtimeStore.getState().switchToBranch(branchId),\n startRun: (parentId) => runtimeStore.getState().startRun(parentId),\n append: (message) => runtimeStore.getState().append(message),\n cancelRun: () => runtimeStore.getState().cancelRun(),\n addToolResult: (options) =>\n runtimeStore.getState().addToolResult(options),\n }),\n );\n};\n","import { create } from \"zustand\";\nimport type { ThreadMessage } from \"../../types/AssistantTypes\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { ThreadRuntimeStore } from \"./ThreadRuntime\";\n\nexport type ThreadMessagesState = readonly ThreadMessage[];\n\nexport const makeThreadMessagesStore = (\n runtimeRef: ReadonlyStore<ThreadRuntimeStore>,\n) => {\n return create<ThreadMessagesState>(() => runtimeRef.getState().messages);\n};\n","import { create } from \"zustand\";\nimport { ThreadRuntime } from \"../../runtimes\";\n\nexport type ThreadRuntimeStore = ThreadRuntime;\n\nexport const makeThreadRuntimeStore = (runtime: ThreadRuntime) => {\n return create<ThreadRuntimeStore>(() => runtime);\n};\n","import { useCallback, useRef } from \"react\";\n\nexport const useManagedRef = <TNode>(\n callback: (node: TNode) => (() => void) | void,\n) => {\n const cleanupRef = useRef<(() => void) | void>();\n\n const ref = useCallback(\n (el: TNode | null) => {\n // Call the previous cleanup function\n if (cleanupRef.current) {\n cleanupRef.current();\n }\n\n // Call the new callback and store its cleanup function\n if (el) {\n cleanupRef.current = callback(el);\n }\n },\n [callback],\n );\n\n return ref;\n};\n","import { create } from \"zustand\";\nimport { AssistantRuntime } from \"../../runtimes\";\nimport { MutableRefObject } from \"react\";\n\nexport type AssistantActionsState = Readonly<{\n switchToThread: (threadId: string | null) => void;\n getRuntime: () => AssistantRuntime;\n}>;\n\nexport const makeAssistantActionsStore = (\n runtimeRef: MutableRefObject<AssistantRuntime>,\n) =>\n create<AssistantActionsState>(() =>\n Object.freeze({\n switchToThread: () => runtimeRef.current.switchToThread(null),\n getRuntime: () => runtimeRef.current,\n }),\n );\n","import { useMemo } from \"react\";\nimport { useMessageContext } from \"./MessageContext\";\nimport { useThreadContext } from \"./ThreadContext\";\nimport type { ComposerState } from \"../stores/Composer\";\nimport type { EditComposerState } from \"../stores/EditComposer\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type ComposerContextValue = {\n useComposer: ReadonlyStore<EditComposerState | ComposerState>;\n type: \"edit\" | \"new\";\n};\n\nexport const useComposerContext = (): ComposerContextValue => {\n const { useComposer } = useThreadContext();\n const { useEditComposer } = useMessageContext({ optional: true }) ?? {};\n return useMemo(\n () => ({\n useComposer: (useEditComposer ?? useComposer) as ReadonlyStore<\n EditComposerState | ComposerState\n >,\n type: useEditComposer ? (\"edit\" as const) : (\"new\" as const),\n }),\n [useEditComposer, useComposer],\n );\n};\n","\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport type { MessageState } from \"../stores/Message\";\nimport type { EditComposerState } from \"../stores/EditComposer\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { MessageUtilsState } from \"../stores/MessageUtils\";\n\nexport type MessageContextValue = {\n useMessage: ReadonlyStore<MessageState>;\n useMessageUtils: ReadonlyStore<MessageUtilsState>;\n useEditComposer: ReadonlyStore<EditComposerState>;\n};\n\nexport const MessageContext = createContext<MessageContextValue | null>(null);\n\nexport function useMessageContext(): MessageContextValue;\nexport function useMessageContext(options: {\n optional: true;\n}): MessageContextValue | null;\nexport function useMessageContext(options?: { optional: true }) {\n const context = useContext(MessageContext);\n if (!options?.optional && !context)\n throw new Error(\n \"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />.\",\n );\n return context;\n}\n","\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport type { ContentPartState } from \"../stores/ContentPart\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type ContentPartContextValue = {\n useContentPart: ReadonlyStore<ContentPartState>;\n};\n\nexport const ContentPartContext = createContext<ContentPartContextValue | null>(\n null,\n);\n\nexport function useContentPartContext(): ContentPartContextValue;\nexport function useContentPartContext(options: {\n optional: true;\n}): ContentPartContextValue | null;\nexport function useContentPartContext(options?: { optional: true }) {\n const context = useContext(ContentPartContext);\n if (!options?.optional && !context)\n throw new Error(\n \"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >.\",\n );\n return context;\n}\n","import { useCallback } from \"react\";\nimport { ThreadContextValue, useThreadContext } from \"../context\";\nimport { AppendMessage } from \"../types\";\n\ntype CreateAppendMessage =\n | string\n | {\n parentId?: string | null | undefined;\n role?: AppendMessage[\"role\"] | undefined;\n content: AppendMessage[\"content\"];\n };\n\nconst toAppendMessage = (\n useThreadMessages: ThreadContextValue[\"useThreadMessages\"],\n message: CreateAppendMessage,\n): AppendMessage => {\n if (typeof message === \"string\") {\n return {\n parentId: useThreadMessages.getState().at(-1)?.id ?? null,\n role: \"user\",\n content: [{ type: \"text\", text: message }],\n };\n }\n\n return {\n parentId:\n message.parentId ?? useThreadMessages.getState().at(-1)?.id ?? null,\n role: message.role ?? \"user\",\n content: message.content,\n } as AppendMessage;\n};\n\nexport const useAppendMessage = () => {\n const { useThreadMessages, useThreadActions, useViewport, useComposer } =\n useThreadContext();\n\n const append = useCallback(\n (message: CreateAppendMessage) => {\n const appendMessage = toAppendMessage(useThreadMessages, message);\n useThreadActions.getState().append(appendMessage);\n\n useViewport.getState().scrollToBottom();\n useComposer.getState().focus();\n },\n [useThreadMessages, useThreadActions, useViewport, useComposer],\n );\n\n return append;\n};\n","import { useCallback } from \"react\";\nimport { useAssistantContext, useThreadContext } from \"../context\";\n\nexport const useSwitchToNewThread = () => {\n const { useAssistantActions } = useAssistantContext();\n const { useComposer } = useThreadContext();\n\n const switchToNewThread = useCallback(() => {\n useAssistantActions.getState().switchToThread(null);\n useComposer.getState().focus();\n }, [useAssistantActions, useComposer]);\n\n return switchToNewThread;\n};\n","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../types/ContentPartComponentTypes\";\nimport type { Tool } from \"../types/ModelConfigTypes\";\n\nexport type AssistantToolProps<\n TArgs extends Record<string, unknown>,\n TResult,\n> = Tool<TArgs, TResult> & {\n toolName: string;\n render?: ToolCallContentPartComponent<TArgs, TResult> | undefined;\n};\n\nexport const useAssistantTool = <\n TArgs extends Record<string, unknown>,\n TResult,\n>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const { useModelConfig, useToolUIs } = useAssistantContext();\n const registerModelConfigProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n const setToolUI = useToolUIs((s) => s.setToolUI);\n useEffect(() => {\n const { toolName, render, ...rest } = tool;\n const config = {\n tools: {\n [tool.toolName]: rest,\n },\n };\n const unsub1 = registerModelConfigProvider({\n getModelConfig: () => config,\n });\n const unsub2 = render ? setToolUI(toolName, render) : undefined;\n return () => {\n unsub1();\n unsub2?.();\n };\n }, [registerModelConfigProvider, setToolUI, tool]);\n};\n","\"use client\";\nimport { type AssistantToolProps, useAssistantTool } from \"./useAssistantTool\";\n\nexport const makeAssistantTool = <\n TArgs extends Record<string, unknown>,\n TResult,\n>(\n tool: AssistantToolProps<TArgs, TResult>,\n) => {\n const Tool = () => {\n useAssistantTool(tool);\n return null;\n };\n return Tool;\n};\n","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/react/AssistantContext\";\nimport type { ToolCallContentPartComponent } from \"../types/ContentPartComponentTypes\";\n\nexport type AssistantToolUIProps<\n TArgs extends Record<string, unknown>,\n TResult,\n> = {\n toolName: string;\n render: ToolCallContentPartComponent<TArgs, TResult>;\n};\n\nexport const useAssistantToolUI = (\n tool: AssistantToolUIProps<any, any> | null,\n) => {\n const { useToolUIs } = useAssistantContext();\n const setToolUI = useToolUIs((s) => s.setToolUI);\n useEffect(() => {\n if (!tool) return;\n const { toolName, render } = tool;\n return setToolUI(toolName, render);\n }, [setToolUI, tool]);\n};\n","\"use client\";\nimport {\n type AssistantToolUIProps,\n useAssistantToolUI,\n} from \"./useAssistantToolUI\";\n\nexport const makeAssistantToolUI = <\n TArgs extends Record<string, unknown>,\n TResult,\n>(\n tool: AssistantToolUIProps<TArgs, TResult>,\n) => {\n const ToolUI = () => {\n useAssistantToolUI(tool);\n return null;\n };\n return ToolUI;\n};\n","\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantContext } from \"../context/react/AssistantContext\";\n\nexport const useAssistantInstructions = (instruction: string) => {\n const { useModelConfig } = useAssistantContext();\n const registerModelConfigProvider = useModelConfig(\n (s) => s.registerModelConfigProvider,\n );\n useEffect(() => {\n const config = {\n system: instruction,\n };\n return registerModelConfigProvider({ getModelConfig: () => config });\n }, [registerModelConfigProvider, instruction]);\n};\n","import { useCallback } from \"react\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\nimport { getMessageText } from \"../../utils/getMessageText\";\n\nexport type UseActionBarCopyProps = {\n copiedDuration?: number | undefined;\n};\n\nexport const useActionBarCopy = ({\n copiedDuration = 3000,\n}: UseActionBarCopyProps = {}) => {\n const { useMessage, useMessageUtils, useEditComposer } = useMessageContext();\n\n const hasCopyableContent = useCombinedStore(\n [useMessage, useEditComposer],\n (m, c) => {\n return (\n !c.isEditing &&\n m.message.content.some((c) => c.type === \"text\" && c.text.length > 0)\n );\n },\n );\n\n const callback = useCallback(() => {\n const { message } = useMessage.getState();\n const { setIsCopied } = useMessageUtils.getState();\n const { isEditing, value: composerValue } = useEditComposer.getState();\n\n const valueToCopy = isEditing ? composerValue : getMessageText(message);\n\n navigator.clipboard.writeText(valueToCopy).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), copiedDuration);\n });\n }, [useMessage, useMessageUtils, useEditComposer, copiedDuration]);\n\n if (!hasCopyableContent) return null;\n return callback;\n};\n","import { useMemo } from \"react\";\nimport {\n type CombinedSelector,\n createCombinedStore,\n} from \"./createCombinedStore\";\nimport { ReadonlyStore } from \"../../context/ReadonlyStore\";\n\nexport const useCombinedStore = <T extends Array<unknown>, R>(\n stores: { [K in keyof T]: ReadonlyStore<T[K]> },\n selector: CombinedSelector<T, R>,\n): R => {\n // eslint-disable-next-line react-hooks/exhaustive-deps -- shallow-compare the store array\n const useCombined = useMemo(() => createCombinedStore<T, R>(stores), stores);\n return useCombined(selector);\n};\n","\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\nimport type { Unsubscribe } from \"../../types/Unsubscribe\";\nimport { ReadonlyStore } from \"../../context/ReadonlyStore\";\n\nexport type CombinedSelector<T extends Array<unknown>, R> = (...args: T) => R;\n\nexport const createCombinedStore = <T extends Array<unknown>, R>(stores: {\n [K in keyof T]: ReadonlyStore<T[K]>;\n}) => {\n const subscribe = (callback: () => void): Unsubscribe => {\n const unsubscribes = stores.map((store) => store.subscribe(callback));\n return () => {\n for (const unsub of unsubscribes) {\n unsub();\n }\n };\n };\n\n return (selector: CombinedSelector<T, R>): R => {\n const getSnapshot = (): R =>\n selector(...(stores.map((store) => store.getState()) as T));\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n };\n};\n","import type { TextContentPart, ThreadMessage } from \"../types/AssistantTypes\";\n\nexport const getMessageText = (message: ThreadMessage) => {\n const textParts = message.content.filter(\n (part) => part.type === \"text\",\n ) as TextContentPart[];\n\n return textParts.map((part) => part.text).join(\"\\n\\n\");\n};\n","import { useCallback } from \"react\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\nexport const useActionBarEdit = () => {\n const { useMessage, useEditComposer } = useMessageContext();\n\n const disabled = useCombinedStore(\n [useMessage, useEditComposer],\n (m, c) => m.message.role !== \"user\" || c.isEditing,\n );\n\n const callback = useCallback(() => {\n const { edit } = useEditComposer.getState();\n edit();\n }, [useEditComposer]);\n\n if (disabled) return null;\n return callback;\n};\n","import { useCallback } from \"react\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\nexport const useActionBarReload = () => {\n const { useThread, useThreadActions, useComposer, useViewport } =\n useThreadContext();\n const { useMessage } = useMessageContext();\n\n const disabled = useCombinedStore(\n [useThread, useMessage],\n (t, m) => t.isRunning || t.isDisabled || m.message.role !== \"assistant\",\n );\n\n const callback = useCallback(() => {\n const { parentId } = useMessage.getState();\n useThreadActions.getState().startRun(parentId);\n useViewport.getState().scrollToBottom();\n useComposer.getState().focus();\n }, [useThreadActions, useComposer, useViewport, useMessage]);\n\n if (disabled) return null;\n return callback;\n};\n","\"use client\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\n\nexport const useBranchPickerCount = () => {\n const { useMessage } = useMessageContext();\n const branchCount = useMessage((s) => s.branches.length);\n return branchCount;\n};\n","import { useCallback } from \"react\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\nexport const useBranchPickerNext = () => {\n const { useThreadActions } = useThreadContext();\n const { useMessage, useEditComposer } = useMessageContext();\n\n const disabled = useCombinedStore(\n [useMessage, useEditComposer],\n (m, c) =>\n c.isEditing || m.branches.indexOf(m.message.id) + 1 >= m.branches.length,\n );\n\n const callback = useCallback(() => {\n const { message, branches } = useMessage.getState();\n useThreadActions\n .getState()\n .switchToBranch(branches[branches.indexOf(message.id) + 1]!);\n }, [useThreadActions, useMessage]);\n\n if (disabled) return null;\n return callback;\n};\n","\"use client\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\n\nexport const useBranchPickerNumber = () => {\n const { useMessage } = useMessageContext();\n const branchIdx = useMessage((s) => s.branches.indexOf(s.message.id));\n return branchIdx + 1;\n};\n","import { useCallback } from \"react\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\nexport const useBranchPickerPrevious = () => {\n const { useThreadActions } = useThreadContext();\n const { useMessage, useEditComposer } = useMessageContext();\n\n const disabled = useCombinedStore(\n [useMessage, useEditComposer],\n (m, c) => c.isEditing || m.branches.indexOf(m.message.id) <= 0,\n );\n\n const callback = useCallback(() => {\n const { message, branches } = useMessage.getState();\n useThreadActions\n .getState()\n .switchToBranch(branches[branches.indexOf(message.id) - 1]!);\n }, [useThreadActions, useMessage]);\n\n if (disabled) return null;\n return callback;\n};\n","import { useCallback } from \"react\";\nimport { useComposerContext } from \"../../context\";\n\nexport const useComposerCancel = () => {\n const { useComposer } = useComposerContext();\n\n const disabled = useComposer((c) => !c.canCancel);\n\n const callback = useCallback(() => {\n const { cancel } = useComposer.getState();\n cancel();\n }, [useComposer]);\n\n if (disabled) return null;\n return callback;\n};\n","\"use client\";\nimport { useComposerContext } from \"../../context/react/ComposerContext\";\nimport type { RequireAtLeastOne } from \"../../utils/RequireAtLeastOne\";\n\ntype ComposerIfFilters = {\n editing: boolean | undefined;\n};\n\nexport type UseComposerIfProps = RequireAtLeastOne<ComposerIfFilters>;\n\nexport const useComposerIf = (props: UseComposerIfProps) => {\n const { useComposer } = useComposerContext();\n return useComposer((composer) => {\n if (props.editing === true && !composer.isEditing) return false;\n if (props.editing === false && composer.isEditing) return false;\n\n return true;\n });\n};\n","import { useCallback } from \"react\";\nimport { useComposerContext, useThreadContext } from \"../../context\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\nexport const useComposerSend = () => {\n const {\n useThread,\n useViewport,\n useComposer: useNewComposer,\n } = useThreadContext();\n const { useComposer } = useComposerContext();\n\n const disabled = useCombinedStore(\n [useThread, useComposer],\n (t, c) =>\n t.isDisabled || t.isRunning || !c.isEditing || c.value.length === 0,\n );\n\n const callback = useCallback(() => {\n const composerState = useComposer.getState();\n if (!composerState.isEditing) return;\n\n composerState.send();\n\n useViewport.getState().scrollToBottom();\n useNewComposer.getState().focus();\n }, [useNewComposer, useComposer, useViewport]);\n\n if (disabled) return null;\n return callback;\n};\n","import { useContentPartContext } from \"../../context/react/ContentPartContext\";\nimport { UIContentPartState } from \"../../context/stores/ContentPart\";\n\nexport const useContentPartDisplay = () => {\n const { useContentPart } = useContentPartContext();\n\n const display = useContentPart((c) => {\n if (c.part.type !== \"ui\")\n throw new Error(\n \"This component can only be used inside ui content parts.\",\n );\n\n return c as UIContentPartState;\n });\n\n return display;\n};\n","import { useContentPartContext } from \"../../context/react/ContentPartContext\";\nimport { ImageContentPartState } from \"../../context/stores/ContentPart\";\n\nexport const useContentPartImage = () => {\n const { useContentPart } = useContentPartContext();\n\n const image = useContentPart((c) => {\n if (c.part.type !== \"image\")\n throw new Error(\n \"ContentPartImage can only be used inside image content parts.\",\n );\n\n return c as ImageContentPartState;\n });\n\n return image;\n};\n","import { useContentPartContext } from \"../../context/react/ContentPartContext\";\nimport { TextContentPartState } from \"../../context/stores/ContentPart\";\n\nexport const useContentPartText = () => {\n const { useContentPart } = useContentPartContext();\n\n const text = useContentPart((c) => {\n if (c.part.type !== \"text\")\n throw new Error(\n \"ContentPartText can only be used inside text content parts.\",\n );\n\n return c as TextContentPartState;\n });\n\n return text;\n};\n","\"use client\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport type { RequireAtLeastOne } from \"../../utils/RequireAtLeastOne\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\ntype MessageIfFilters = {\n user: boolean | undefined;\n assistant: boolean | undefined;\n system: boolean | undefined;\n hasBranches: boolean | undefined;\n copied: boolean | undefined;\n lastOrHover: boolean | undefined;\n};\nexport type UseMessageIfProps = RequireAtLeastOne<MessageIfFilters>;\n\nexport const useMessageIf = (props: UseMessageIfProps) => {\n const { useMessage, useMessageUtils } = useMessageContext();\n\n return useCombinedStore(\n [useMessage, useMessageUtils],\n ({ message, branches, isLast }, { isCopied, isHovering }) => {\n if (props.hasBranches === true && branches.length < 2) return false;\n\n if (props.user && message.role !== \"user\") return false;\n if (props.assistant && message.role !== \"assistant\") return false;\n if (props.system && message.role !== \"system\") return false;\n\n if (props.lastOrHover === true && !isHovering && !isLast) return false;\n\n if (props.copied === true && !isCopied) return false;\n if (props.copied === false && isCopied) return false;\n\n return true;\n },\n );\n};\n","\"use client\";\n\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport type { RequireAtLeastOne } from \"../../utils/RequireAtLeastOne\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\ntype ThreadIfFilters = {\n empty: boolean | undefined;\n running: boolean | undefined;\n disabled: boolean | undefined;\n};\n\nexport type UseThreadIfProps = RequireAtLeastOne<ThreadIfFilters>;\n\nexport const useThreadIf = (props: UseThreadIfProps) => {\n const { useThread, useThreadMessages } = useThreadContext();\n return useCombinedStore(\n [useThread, useThreadMessages],\n (thread, messages) => {\n if (props.empty === true && messages.length !== 0) return false;\n if (props.empty === false && messages.length === 0) return false;\n if (props.running === true && !thread.isRunning) return false;\n if (props.running === false && thread.isRunning) return false;\n if (props.disabled === true && thread.isDisabled) return false;\n if (props.disabled === false && thread.isDisabled) return false;\n\n return true;\n },\n );\n};\n","import { useThreadIf } from \"./useThreadIf\";\n\nexport const useThreadEmpty = () => {\n return useThreadIf({ empty: true });\n};\n","import { useCallback } from \"react\";\nimport { useThreadContext } from \"../../context\";\n\nexport const useThreadScrollToBottom = () => {\n const { useComposer, useViewport } = useThreadContext();\n\n const isAtBottom = useViewport((s) => s.isAtBottom);\n\n const handleScrollToBottom = useCallback(() => {\n useViewport.getState().scrollToBottom();\n useComposer.getState().focus();\n }, [useViewport, useComposer]);\n\n if (isAtBottom) return null;\n return handleScrollToBottom;\n};\n","import { useCallback } from \"react\";\nimport { useThreadContext } from \"../../context\";\nimport { useAppendMessage } from \"../../hooks\";\n\nexport type UseApplyThreadSuggestionProps = {\n prompt: string;\n method: \"replace\";\n autoSend?: boolean | undefined;\n};\n\nexport const useThreadSuggestion = ({\n prompt,\n autoSend,\n}: UseApplyThreadSuggestionProps) => {\n const { useThread, useComposer } = useThreadContext();\n\n const append = useAppendMessage();\n const disabled = useThread((t) => t.isDisabled);\n const callback = useCallback(() => {\n const thread = useThread.getState();\n const composer = useComposer.getState();\n if (autoSend && !thread.isRunning) {\n append(prompt);\n composer.setValue(\"\");\n } else {\n composer.setValue(prompt);\n }\n }, [useThread, useComposer, autoSend, append, prompt]);\n\n if (disabled) return null;\n return callback;\n};\n","export { ActionBarPrimitiveRoot as Root } from \"./ActionBarRoot\";\nexport { ActionBarPrimitiveCopy as Copy } from \"./ActionBarCopy\";\nexport { ActionBarPrimitiveReload as Reload } from \"./ActionBarReload\";\nexport { ActionBarPrimitiveEdit as Edit } from \"./ActionBarEdit\";\n","\"use client\";\n\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { type ElementRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\nimport {\n useActionBarFloatStatus,\n HideAndFloatStatus,\n UseActionBarFloatStatusProps,\n} from \"./useActionBarFloatStatus\";\n\ntype ActionBarPrimitiveRootElement = ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport type ActionBarPrimitiveRootProps = PrimitiveDivProps &\n UseActionBarFloatStatusProps;\n\nexport const ActionBarPrimitiveRoot = forwardRef<\n ActionBarPrimitiveRootElement,\n ActionBarPrimitiveRootProps\n>(({ hideWhenRunning, autohide, autohideFloat, ...rest }, ref) => {\n const hideAndfloatStatus = useActionBarFloatStatus({\n hideWhenRunning,\n autohide,\n autohideFloat,\n });\n\n if (hideAndfloatStatus === HideAndFloatStatus.Hidden) return null;\n\n return (\n <Primitive.div\n {...(hideAndfloatStatus === HideAndFloatStatus.Floating\n ? { \"data-floating\": \"true\" }\n : null)}\n {...rest}\n ref={ref}\n />\n );\n});\n\nActionBarPrimitiveRoot.displayName = \"ActionBarPrimitive.Root\";\n","\"use client\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport { useCombinedStore } from \"../../utils/combined/useCombinedStore\";\n\nexport enum HideAndFloatStatus {\n Hidden = \"hidden\",\n Floating = \"floating\",\n Normal = \"normal\",\n}\n\nexport type UseActionBarFloatStatusProps = {\n hideWhenRunning?: boolean | undefined;\n autohide?: \"always\" | \"not-last\" | \"never\" | undefined;\n autohideFloat?: \"always\" | \"single-branch\" | \"never\" | undefined;\n};\n\nexport const useActionBarFloatStatus = ({\n hideWhenRunning,\n autohide,\n autohideFloat,\n}: UseActionBarFloatStatusProps) => {\n const { useThread } = useThreadContext();\n const { useMessage, useMessageUtils } = useMessageContext();\n\n return useCombinedStore(\n [useThread, useMessage, useMessageUtils],\n (t, m, mu) => {\n if (hideWhenRunning && t.isRunning) return HideAndFloatStatus.Hidden;\n\n const autohideEnabled =\n autohide === \"always\" || (autohide === \"not-last\" && !m.isLast);\n\n // normal status\n if (!autohideEnabled) return HideAndFloatStatus.Normal;\n\n // hidden status\n if (!mu.isHovering) return HideAndFloatStatus.Hidden;\n\n // floating status\n if (\n autohideFloat === \"always\" ||\n (autohideFloat === \"single-branch\" && m.branches.length <= 1)\n )\n return HideAndFloatStatus.Floating;\n\n return HideAndFloatStatus.Normal;\n },\n );\n};\n","\"use client\";\n\nimport { ElementRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\n\ntype ActionButtonCallback<TProps> = (props: TProps) => null | (() => void);\n\ntype PrimitiveButtonElement = ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = ComponentPropsWithoutRef<typeof Primitive.button>;\n\nexport type ActionButtonProps<THook> = PrimitiveButtonProps &\n (THook extends (props: infer TProps) => unknown ? TProps : never);\n\nexport const createActionButton = <TProps,>(\n displayName: string,\n useActionButton: ActionButtonCallback<TProps>,\n forwardProps: (keyof NonNullable<TProps>)[] = [],\n) => {\n const ActionButton = forwardRef<\n PrimitiveButtonElement,\n PrimitiveButtonProps & TProps\n >((props, forwardedRef) => {\n const forwardedProps = {} as TProps;\n const primitiveProps = {} as PrimitiveButtonProps;\n\n (Object.keys(props) as Array<keyof typeof props>).forEach((key) => {\n if (forwardProps.includes(key as keyof TProps)) {\n (forwardedProps as any)[key] = props[key];\n } else {\n (primitiveProps as any)[key] = props[key];\n }\n });\n\n const callback = useActionButton(forwardedProps as TProps);\n return (\n <Primitive.button\n type=\"button\"\n disabled={!callback}\n {...primitiveProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(primitiveProps.onClick, () => {\n callback?.();\n })}\n />\n );\n });\n\n ActionButton.displayName = displayName;\n\n return ActionButton;\n};\n","\"use client\";\n\nimport { useActionBarCopy } from \"../../primitive-hooks/actionBar/useActionBarCopy\";\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\n\nexport type ActionBarPrimitiveCopyProps = ActionButtonProps<\n typeof useActionBarCopy\n>;\n\nexport const ActionBarPrimitiveCopy = createActionButton(\n \"ActionBarPrimitive.Copy\",\n useActionBarCopy,\n [\"copiedDuration\"],\n);\n","\"use client\";\n\nimport { useActionBarReload } from \"../../primitive-hooks/actionBar/useActionBarReload\";\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\n\nexport type ActionBarPrimitiveReloadProps = ActionButtonProps<\n typeof useActionBarReload\n>;\n\nexport const ActionBarPrimitiveReload = createActionButton(\n \"ActionBarPrimitive.Reload\",\n useActionBarReload,\n);\n","\"use client\";\n\nimport { useActionBarEdit } from \"../../primitive-hooks/actionBar/useActionBarEdit\";\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\n\nexport type ActionBarPrimitiveEditProps = ActionButtonProps<\n typeof useActionBarEdit\n>;\n\nexport const ActionBarPrimitiveEdit = createActionButton(\n \"ActionBarPrimitive.Edit\",\n useActionBarEdit,\n);\n","export { AssistantModalPrimitiveRoot as Root } from \"./AssistantModalRoot\";\nexport { AssistantModalPrimitiveTrigger as Trigger } from \"./AssistantModalTrigger\";\nexport { AssistantModalPrimitiveContent as Content } from \"./AssistantModalContent\";\nexport { AssistantModalPrimitiveAnchor as Anchor } from \"./AssistantModalAnchor\";\n","\"use client\";\n\nimport { FC, useState } from \"react\";\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useOnComposerFocus } from \"../../utils/hooks/useOnComposerFocus\";\nimport { ScopedProps, usePopoverScope } from \"./scope\";\n\nexport type AssistantModalPrimitiveRootProps = PopoverPrimitive.PopoverProps;\n\nconst useAssistantModalOpenState = (defaultOpen = false) => {\n const state = useState(defaultOpen);\n\n const [, setOpen] = state;\n useOnComposerFocus(() => {\n setOpen(true);\n });\n\n return state;\n};\n\nexport const AssistantModalPrimitiveRoot: FC<\n AssistantModalPrimitiveRootProps\n> = ({\n __scopeAssistantModal,\n defaultOpen,\n open,\n onOpenChange,\n ...rest\n}: ScopedProps<AssistantModalPrimitiveRootProps>) => {\n const scope = usePopoverScope(__scopeAssistantModal);\n\n const [modalOpen, setOpen] = useAssistantModalOpenState(defaultOpen);\n\n return (\n <PopoverPrimitive.Root\n {...scope}\n open={open === undefined ? modalOpen : open}\n onOpenChange={composeEventHandlers(onOpenChange, setOpen)}\n {...rest}\n />\n );\n};\n\nAssistantModalPrimitiveRoot.displayName = \"AssistantModalPrimitive.Root\";\n","import { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { useEffect } from \"react\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\n\nexport const useOnComposerFocus = (callback: () => void) => {\n const callbackRef = useCallbackRef(callback);\n\n const { useComposer } = useThreadContext();\n useEffect(() => {\n return useComposer.getState().onFocus(() => {\n callbackRef();\n });\n }, [useComposer, callbackRef]);\n};\n","import * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport type { Scope } from \"@radix-ui/react-context\";\n\nexport type ScopedProps<P> = P & { __scopeAssistantModal?: Scope };\nexport const usePopoverScope = PopoverPrimitive.createPopoverScope();\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, ElementRef, forwardRef } from \"react\";\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport { ScopedProps, usePopoverScope } from \"./scope\";\n\ntype AssistantModalPrimitiveTriggerElement = ElementRef<\n typeof PopoverPrimitive.Trigger\n>;\nexport type AssistantModalPrimitiveTriggerProps = ComponentPropsWithoutRef<\n typeof PopoverPrimitive.Trigger\n>;\n\nexport const AssistantModalPrimitiveTrigger = forwardRef<\n AssistantModalPrimitiveTriggerElement,\n AssistantModalPrimitiveTriggerProps\n>(\n (\n {\n __scopeAssistantModal,\n ...rest\n }: ScopedProps<AssistantModalPrimitiveTriggerProps>,\n ref,\n ) => {\n const scope = usePopoverScope(__scopeAssistantModal);\n\n return <PopoverPrimitive.Trigger {...scope} {...rest} ref={ref} />;\n },\n);\n\nAssistantModalPrimitiveTrigger.displayName = \"AssistantModalPrimitive.Trigger\";\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, ElementRef, forwardRef } from \"react\";\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport { ScopedProps, usePopoverScope } from \"./scope\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\n\ntype AssistantModalPrimitiveContentElement = ElementRef<\n typeof PopoverPrimitive.Content\n>;\nexport type AssistantModalPrimitiveContentProps = ComponentPropsWithoutRef<\n typeof PopoverPrimitive.Content\n> & {\n dissmissOnInteractOutside?: boolean | undefined;\n};\n\nexport const AssistantModalPrimitiveContent = forwardRef<\n AssistantModalPrimitiveContentElement,\n AssistantModalPrimitiveContentProps\n>(\n (\n {\n __scopeAssistantModal,\n side,\n align,\n onInteractOutside,\n dissmissOnInteractOutside = false,\n ...props\n }: ScopedProps<AssistantModalPrimitiveContentProps>,\n forwardedRef,\n ) => {\n const scope = usePopoverScope(__scopeAssistantModal);\n\n return (\n <PopoverPrimitive.Portal {...scope}>\n <PopoverPrimitive.Content\n {...scope}\n {...props}\n ref={forwardedRef}\n side={side ?? \"top\"}\n align={align ?? \"end\"}\n onInteractOutside={composeEventHandlers(\n onInteractOutside,\n dissmissOnInteractOutside ? undefined : (e) => e.preventDefault(),\n )}\n />\n </PopoverPrimitive.Portal>\n );\n },\n);\n\nAssistantModalPrimitiveContent.displayName = \"AssistantModalPrimitive.Content\";\n","\"use client\";\nimport { ComponentPropsWithoutRef, ElementRef, forwardRef } from \"react\";\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport { ScopedProps, usePopoverScope } from \"./scope\";\n\ntype AssistantModalPrimitiveAnchorElement = ElementRef<\n typeof PopoverPrimitive.Anchor\n>;\ntype AssistantModalPrimitiveAnchorProps = ComponentPropsWithoutRef<\n typeof PopoverPrimitive.Anchor\n>;\n\nexport const AssistantModalPrimitiveAnchor = forwardRef<\n AssistantModalPrimitiveAnchorElement,\n AssistantModalPrimitiveAnchorProps\n>(\n (\n {\n __scopeAssistantModal,\n ...rest\n }: ScopedProps<AssistantModalPrimitiveAnchorProps>,\n ref,\n ) => {\n const scope = usePopoverScope(__scopeAssistantModal);\n\n return <PopoverPrimitive.Anchor {...scope} {...rest} ref={ref} />;\n },\n);\nAssistantModalPrimitiveAnchor.displayName = \"AssistantModalPrimitive.Anchor\";\n","export { BranchPickerPrimitiveNext as Next } from \"./BranchPickerNext\";\nexport { BranchPickerPrevious as Previous } from \"./BranchPickerPrevious\";\nexport { BranchPickerPrimitiveCount as Count } from \"./BranchPickerCount\";\nexport { BranchPickerPrimitiveNumber as Number } from \"./BranchPickerNumber\";\nexport { BranchPickerPrimitiveRoot as Root } from \"./BranchPickerRoot\";\n","\"use client\";\n\nimport { useBranchPickerNext } from \"../../primitive-hooks/branchPicker/useBranchPickerNext\";\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\n\nexport type BranchPickerPrimitiveNextProps = ActionButtonProps<\n typeof useBranchPickerNext\n>;\n\nexport const BranchPickerPrimitiveNext = createActionButton(\n \"BranchPickerPrimitive.Next\",\n useBranchPickerNext,\n);\n","\"use client\";\n\nimport { useBranchPickerPrevious } from \"../../primitive-hooks/branchPicker/useBranchPickerPrevious\";\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\n\nexport type BranchPickerPrimitivePreviousProps = ActionButtonProps<\n typeof useBranchPickerPrevious\n>;\n\nexport const BranchPickerPrevious = createActionButton(\n \"BranchPickerPrimitive.Previous\",\n useBranchPickerPrevious,\n);\n","\"use client\";\n\nimport type { FC } from \"react\";\nimport { useBranchPickerCount } from \"../../primitive-hooks/branchPicker/useBranchPickerCount\";\n\nexport type BranchPickerPrimitiveCountProps = {};\n\nexport const BranchPickerPrimitiveCount: FC<\n BranchPickerPrimitiveCountProps\n> = () => {\n const branchCount = useBranchPickerCount();\n return <>{branchCount}</>;\n};\n\nBranchPickerPrimitiveCount.displayName = \"BranchPickerPrimitive.Count\";\n","\"use client\";\n\nimport type { FC } from \"react\";\nimport { useBranchPickerNumber } from \"../../primitive-hooks/branchPicker/useBranchPickerNumber\";\n\nexport type BranchPickerPrimitiveNumberProps = {};\n\nexport const BranchPickerPrimitiveNumber: FC<\n BranchPickerPrimitiveNumberProps\n> = () => {\n const branchNumber = useBranchPickerNumber();\n return <>{branchNumber}</>;\n};\n\nBranchPickerPrimitiveNumber.displayName = \"BranchPickerPrimitive.Number\";\n","\"use client\";\n\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { type ElementRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\nimport { If } from \"../message\";\n\ntype BranchPickerPrimitiveRootElement = ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport type BranchPickerPrimitiveRootProps = PrimitiveDivProps & {\n hideWhenSingleBranch?: boolean | undefined;\n};\n\nexport const BranchPickerPrimitiveRoot = forwardRef<\n BranchPickerPrimitiveRootElement,\n BranchPickerPrimitiveRootProps\n>(({ hideWhenSingleBranch, ...rest }, ref) => {\n return (\n <If hasBranches={hideWhenSingleBranch ? true : undefined}>\n <Primitive.div {...rest} ref={ref} />\n </If>\n );\n});\n\nBranchPickerPrimitiveRoot.displayName = \"BranchPickerPrimitive.Root\";\n","export { MessagePrimitiveRoot as Root } from \"./MessageRoot\";\nexport { MessagePrimitiveIf as If } from \"./MessageIf\";\nexport { MessagePrimitiveContent as Content } from \"./MessageContent\";\nexport { MessagePrimitiveInProgress as InProgress } from \"./MessageInProgress\";\n","\"use client\";\n\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport {\n type ElementRef,\n forwardRef,\n ComponentPropsWithoutRef,\n useCallback,\n} from \"react\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\n\ntype MessagePrimitiveRootElement = ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nconst useIsHoveringRef = () => {\n const { useMessageUtils } = useMessageContext();\n\n const callbackRef = useCallback(\n (el: HTMLElement) => {\n const setIsHovering = useMessageUtils.getState().setIsHovering;\n\n const handleMouseEnter = () => {\n setIsHovering(true);\n };\n const handleMouseLeave = () => {\n setIsHovering(false);\n };\n\n el.addEventListener(\"mouseenter\", handleMouseEnter);\n el.addEventListener(\"mouseleave\", handleMouseLeave);\n\n return () => {\n el.removeEventListener(\"mouseenter\", handleMouseEnter);\n el.removeEventListener(\"mouseleave\", handleMouseLeave);\n setIsHovering(false);\n };\n },\n [useMessageUtils],\n );\n\n return useManagedRef(callbackRef);\n};\n\nexport type MessagePrimitiveRootProps = PrimitiveDivProps;\n\nexport const MessagePrimitiveRoot = forwardRef<\n MessagePrimitiveRootElement,\n MessagePrimitiveRootProps\n>(({ onMouseEnter, onMouseLeave, ...rest }, forwardRef) => {\n const isHoveringRef = useIsHoveringRef();\n const ref = useComposedRefs<HTMLDivElement>(forwardRef, isHoveringRef);\n\n return <Primitive.div {...rest} ref={ref} />;\n});\n\nMessagePrimitiveRoot.displayName = \"MessagePrimitive.Root\";\n","\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport {\n UseMessageIfProps,\n useMessageIf,\n} from \"../../primitive-hooks/message/useMessageIf\";\n\nexport type MessagePrimitiveIfProps = PropsWithChildren<UseMessageIfProps>;\n\nexport const MessagePrimitiveIf: FC<MessagePrimitiveIfProps> = ({\n children,\n ...query\n}) => {\n const result = useMessageIf(query);\n return result ? children : null;\n};\n\nMessagePrimitiveIf.displayName = \"MessagePrimitive.If\";\n","\"use client\";\n\nimport { type ComponentType, type FC, memo } from \"react\";\nimport {\n useAssistantContext,\n useContentPartContext,\n useThreadContext,\n} from \"../../context\";\nimport { useMessageContext } from \"../../context/react/MessageContext\";\nimport {\n ContentPartProvider,\n EMPTY_CONTENT,\n} from \"../../context/providers/ContentPartProvider\";\nimport { ContentPartPrimitiveText } from \"../contentPart/ContentPartText\";\nimport { ContentPartPrimitiveImage } from \"../contentPart/ContentPartImage\";\nimport { ContentPartPrimitiveDisplay } from \"../contentPart/ContentPartDisplay\";\nimport type {\n ImageContentPartComponent,\n TextContentPartComponent,\n ToolCallContentPartComponent,\n ToolCallContentPartProps,\n UIContentPartComponent,\n} from \"../../types/ContentPartComponentTypes\";\nimport { ContentPartPrimitiveInProgress } from \"../contentPart/ContentPartInProgress\";\n\nexport type MessagePrimitiveContentProps = {\n components?:\n | {\n Empty?: TextContentPartComponent | undefined;\n Text?: TextContentPartComponent | undefined;\n Image?: ImageContentPartComponent | undefined;\n UI?: UIContentPartComponent | undefined;\n tools?: {\n by_name?:\n | Record<string, ToolCallContentPartComponent | undefined>\n | undefined;\n Fallback?: ComponentType<ToolCallContentPartProps> | undefined;\n };\n }\n | undefined;\n};\n\nconst defaultComponents = {\n Text: () => (\n <p style={{ whiteSpace: \"pre-line\" }}>\n <ContentPartPrimitiveText />\n <ContentPartPrimitiveInProgress>\n <span style={{ fontFamily: \"revert\" }}>{\" \\u25CF\"}</span>\n </ContentPartPrimitiveInProgress>\n </p>\n ),\n Image: () => <ContentPartPrimitiveImage />,\n UI: () => <ContentPartPrimitiveDisplay />,\n tools: {\n Fallback: (props) => {\n const { useToolUIs } = useAssistantContext();\n const Render = useToolUIs((s) => s.getToolUI(props.part.toolName));\n if (!Render) return null;\n return <Render {...props} />;\n },\n },\n} satisfies MessagePrimitiveContentProps[\"components\"];\n\ntype MessageContentPartComponentProps = {\n components: MessagePrimitiveContentProps[\"components\"];\n};\n\nconst MessageContentPartComponent: FC<MessageContentPartComponentProps> = ({\n components: {\n Empty = defaultComponents.Text,\n Text = defaultComponents.Text,\n Image = defaultComponents.Image,\n UI = defaultComponents.UI,\n tools: { by_name = {}, Fallback = defaultComponents.tools.Fallback } = {},\n } = {},\n}) => {\n const { useThreadActions } = useThreadContext();\n const { useMessage } = useMessageContext();\n const addToolResult = useThreadActions((t) => t.addToolResult);\n\n const { useContentPart } = useContentPartContext();\n const { part, status } = useContentPart();\n\n const type = part.type;\n switch (type) {\n case \"text\":\n if (status.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n if (part === EMPTY_CONTENT) return <Empty part={part} status={status} />;\n\n return <Text part={part} status={status} />;\n\n case \"image\":\n if (status.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n // eslint-disable-next-line jsx-a11y/alt-text\n return <Image part={part} status={status} />;\n\n case \"ui\":\n if (status.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n return <UI part={part} status={status} />;\n\n case \"tool-call\": {\n const Tool = by_name[part.toolName] || Fallback;\n const addResult = (result: any) =>\n addToolResult({\n messageId: useMessage.getState().message.id,\n toolCallId: part.toolCallId,\n result,\n });\n return <Tool part={part} status={status} addResult={addResult} />;\n }\n default:\n const unhandledType: never = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n};\n\ntype MessageContentPartProps = {\n partIndex: number;\n components: MessagePrimitiveContentProps[\"components\"];\n};\n\nconst MessageContentPartImpl: FC<MessageContentPartProps> = ({\n partIndex,\n components,\n}) => {\n return (\n <ContentPartProvider partIndex={partIndex}>\n <MessageContentPartComponent components={components} />\n </ContentPartProvider>\n );\n};\n\nconst MessageContentPart = memo(\n MessageContentPartImpl,\n (prev, next) =>\n prev.partIndex === next.partIndex &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.UI === next.components?.UI &&\n prev.components?.tools === next.components?.tools,\n);\n\nexport const MessagePrimitiveContent: FC<MessagePrimitiveContentProps> = ({\n components,\n}) => {\n const { useMessage } = useMessageContext();\n\n const contentLength = useMessage((s) => s.message.content.length) || 1;\n\n return new Array(contentLength).fill(null).map((_, idx) => {\n const partIndex = idx; // use the index as key, as message is generally append only\n return (\n <MessageContentPart\n key={partIndex}\n partIndex={partIndex}\n components={components}\n />\n );\n });\n};\n\nMessagePrimitiveContent.displayName = \"MessagePrimitive.Content\";\n","\"use client\";\n\nimport { type FC, type PropsWithChildren, useEffect, useState } from \"react\";\nimport { StoreApi, create } from \"zustand\";\nimport { ContentPartContext } from \"../react/ContentPartContext\";\nimport type { ContentPartContextValue } from \"../react/ContentPartContext\";\nimport { useMessageContext } from \"../react/MessageContext\";\nimport type { MessageState } from \"../stores\";\nimport type { ContentPartState } from \"../stores/ContentPart\";\nimport {\n ContentPartStatus,\n ThreadAssistantContentPart,\n ThreadMessage,\n ThreadUserContentPart,\n ToolCallContentPartStatus,\n} from \"../../types/AssistantTypes\";\n\ntype ContentPartProviderProps = PropsWithChildren<{\n partIndex: number;\n}>;\n\nconst COMPLETE_STATUS: ContentPartStatus = {\n type: \"complete\",\n};\n\nconst toContentPartStatus = (\n message: ThreadMessage,\n partIndex: number,\n part: ThreadUserContentPart | ThreadAssistantContentPart,\n): ToolCallContentPartStatus => {\n if (message.role !== \"assistant\") return COMPLETE_STATUS;\n\n const isLastPart = partIndex === Math.max(0, message.content.length - 1);\n if (part.type !== \"tool-call\") {\n if (\n \"reason\" in message.status &&\n message.status.reason === \"tool-calls\" &&\n isLastPart\n )\n throw new Error(\n \"Encountered unexpected requires-action status. This is likely an internal bug in assistant-ui.\",\n );\n\n return isLastPart ? (message.status as ContentPartStatus) : COMPLETE_STATUS;\n }\n\n if (!!part.result) {\n return COMPLETE_STATUS;\n }\n\n return message.status as ToolCallContentPartStatus;\n};\n\nexport const EMPTY_CONTENT = Object.freeze({ type: \"text\", text: \"\" });\n\nconst getContentPartState = (\n { message }: MessageState,\n useContentPart: ContentPartContextValue[\"useContentPart\"] | undefined,\n partIndex: number,\n) => {\n let part = message.content[partIndex];\n if (!part) {\n // for empty messages, show an empty text content part\n if (message.content.length === 0 && partIndex === 0) {\n part = EMPTY_CONTENT;\n } else {\n return null;\n }\n }\n\n // if the content part is the same, don't update\n const status = toContentPartStatus(message, partIndex, part);\n const currentState = useContentPart?.getState();\n if (\n currentState &&\n currentState.part === part &&\n currentState.status === status\n )\n return null;\n\n return Object.freeze({ part, status });\n};\n\nconst useContentPartContext = (partIndex: number) => {\n const { useMessage } = useMessageContext();\n const [context] = useState<ContentPartContextValue>(() => {\n const useContentPart = create<ContentPartState>(\n () => getContentPartState(useMessage.getState(), undefined, partIndex)!,\n );\n\n return { useContentPart };\n });\n\n useEffect(() => {\n const syncContentPart = (message: MessageState) => {\n const newState = getContentPartState(\n message,\n context.useContentPart,\n partIndex,\n );\n if (!newState) return;\n (\n context.useContentPart as unknown as StoreApi<ContentPartState>\n ).setState(newState, true);\n };\n\n syncContentPart(useMessage.getState());\n return useMessage.subscribe(syncContentPart);\n }, [context, useMessage, partIndex]);\n\n return context;\n};\n\nexport const ContentPartProvider: FC<ContentPartProviderProps> = ({\n partIndex,\n children,\n}) => {\n const context = useContentPartContext(partIndex);\n\n return (\n <ContentPartContext.Provider value={context}>\n {children}\n </ContentPartContext.Provider>\n );\n};\n","\"use client\";\n\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport {\n type ElementRef,\n forwardRef,\n ComponentPropsWithoutRef,\n ElementType,\n} from \"react\";\nimport { useContentPartText } from \"../../primitive-hooks/contentPart/useContentPartText\";\nimport { useSmooth } from \"../../utils/smooth/useSmooth\";\n\ntype ContentPartPrimitiveTextElement = ElementRef<typeof Primitive.span>;\ntype PrimitiveSpanProps = ComponentPropsWithoutRef<typeof Primitive.span>;\n\nexport type ContentPartPrimitiveTextProps = Omit<\n PrimitiveSpanProps,\n \"children\" | \"asChild\"\n> & {\n smooth?: boolean;\n component?: ElementType;\n};\n\nexport const ContentPartPrimitiveText = forwardRef<\n ContentPartPrimitiveTextElement,\n ContentPartPrimitiveTextProps\n>(({ smooth = true, component: Component = \"span\", ...rest }, forwardedRef) => {\n const {\n part: { text },\n status,\n } = useSmooth(useContentPartText(), smooth);\n\n return (\n <Component data-status={status.type} {...rest} ref={forwardedRef}>\n {text}\n </Component>\n );\n});\n\nContentPartPrimitiveText.displayName = \"ContentPartPrimitive.Text\";\n","\"use client\";\n\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useMessageContext } from \"../../context\";\nimport {\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../../types/AssistantTypes\";\nimport { TextContentPartState } from \"../../context/stores/ContentPart\";\nimport { useSmoothContext } from \"./SmoothContext\";\nimport { StoreApi } from \"zustand\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\n\nclass TextStreamAnimator {\n private animationFrameId: number | null = null;\n private lastUpdateTime: number = Date.now();\n\n public targetText: string = \"\";\n\n constructor(\n public currentText: string,\n private setText: (newText: string) => void,\n ) {}\n\n start() {\n if (this.animationFrameId !== null) return;\n this.lastUpdateTime = Date.now();\n this.animate();\n }\n\n stop() {\n if (this.animationFrameId !== null) {\n cancelAnimationFrame(this.animationFrameId);\n this.animationFrameId = null;\n }\n }\n\n private animate = () => {\n const currentTime = Date.now();\n const deltaTime = currentTime - this.lastUpdateTime;\n let timeToConsume = deltaTime;\n\n const remainingChars = this.targetText.length - this.currentText.length;\n const baseTimePerChar = Math.min(5, 250 / remainingChars);\n\n let charsToAdd = 0;\n while (timeToConsume >= baseTimePerChar && charsToAdd < remainingChars) {\n charsToAdd++;\n timeToConsume -= baseTimePerChar;\n }\n\n if (charsToAdd !== remainingChars) {\n this.animationFrameId = requestAnimationFrame(this.animate);\n } else {\n this.animationFrameId = null;\n }\n if (charsToAdd === 0) return;\n\n this.currentText = this.targetText.slice(\n 0,\n this.currentText.length + charsToAdd,\n );\n this.lastUpdateTime = currentTime - timeToConsume;\n this.setText(this.currentText);\n };\n}\n\nconst SMOOTH_STATUS: ContentPartStatus = Object.freeze({\n type: \"running\",\n});\n\nexport const useSmooth = (\n state: TextContentPartState,\n smooth: boolean = false,\n): TextContentPartState => {\n const { useSmoothStatus } = useSmoothContext({ optional: true }) ?? {};\n\n const {\n part: { text },\n } = state;\n const { useMessage } = useMessageContext();\n const id = useMessage((m) => m.message.id);\n\n const idRef = useRef(id);\n const [displayedText, setDisplayedText] = useState(text);\n\n const setText = useCallbackRef((text: string) => {\n setDisplayedText(text);\n (\n useSmoothStatus as unknown as\n | StoreApi<ToolCallContentPartStatus>\n | undefined\n )?.setState(text !== state.part.text ? SMOOTH_STATUS : state.status);\n });\n\n const [animatorRef] = useState<TextStreamAnimator>(\n new TextStreamAnimator(text, setText),\n );\n\n useEffect(() => {\n if (!smooth) {\n animatorRef.stop();\n return;\n }\n\n if (idRef.current !== id || !text.startsWith(animatorRef.targetText)) {\n idRef.current = id;\n setText(text);\n\n animatorRef.currentText = text;\n animatorRef.targetText = text;\n animatorRef.stop();\n\n return;\n }\n\n animatorRef.targetText = text;\n animatorRef.start();\n }, [setText, animatorRef, id, smooth, text]);\n\n useEffect(() => {\n return () => {\n animatorRef.stop();\n };\n }, [animatorRef]);\n\n return useMemo(\n () =>\n smooth\n ? {\n part: { type: \"text\", text: displayedText },\n status: text === displayedText ? state.status : SMOOTH_STATUS,\n }\n : state,\n [smooth, displayedText, state, text],\n );\n};\n","import {\n createContext,\n FC,\n forwardRef,\n PropsWithChildren,\n useContext,\n useState,\n} from \"react\";\nimport { useContentPartContext } from \"../../context\";\nimport { ReadonlyStore } from \"../../context/ReadonlyStore\";\nimport { create } from \"zustand\";\nimport {\n ContentPartStatus,\n ToolCallContentPartStatus,\n} from \"../../types/AssistantTypes\";\n\ntype SmoothContextValue = {\n useSmoothStatus: ReadonlyStore<ToolCallContentPartStatus | ContentPartStatus>;\n};\n\nconst SmoothContext = createContext<SmoothContextValue | null>(null);\n\nconst makeSmoothContext = (\n initialState: ContentPartStatus | ToolCallContentPartStatus,\n) => {\n const useSmoothStatus = create(() => initialState);\n return { useSmoothStatus };\n};\n\nexport const SmoothContextProvider: FC<PropsWithChildren> = ({ children }) => {\n const outer = useSmoothContext({ optional: true });\n const { useContentPart } = useContentPartContext();\n\n const [context] = useState(() =>\n makeSmoothContext(useContentPart.getState().status),\n );\n\n // do not wrap if there is an outer SmoothContextProvider\n if (outer) return children;\n\n return (\n <SmoothContext.Provider value={context}>{children}</SmoothContext.Provider>\n );\n};\n\nexport const withSmoothContextProvider = <C extends React.ComponentType<any>>(\n Component: C,\n): C => {\n const Wrapped = forwardRef((props, ref) => {\n return (\n <SmoothContextProvider>\n <Component {...(props as any)} ref={ref} />\n </SmoothContextProvider>\n );\n });\n Wrapped.displayName = Component.displayName;\n return Wrapped as any;\n};\n\nexport function useSmoothContext(): SmoothContextValue;\nexport function useSmoothContext(options: {\n optional: true;\n}): SmoothContextValue | null;\nexport function useSmoothContext(options?: { optional: true }) {\n const context = useContext(SmoothContext);\n if (!options?.optional && !context)\n throw new Error(\n \"This component must be used within a SmoothContextProvider.\",\n );\n return context;\n}\n\nexport const useSmoothStatus = () => {\n const { useSmoothStatus } = useSmoothContext();\n return useSmoothStatus();\n};\n","import { Primitive } from \"@radix-ui/react-primitive\";\nimport { type ElementRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\nimport { useContentPartImage } from \"../../primitive-hooks/contentPart/useContentPartImage\";\n\ntype ContentPartPrimitiveImageElement = ElementRef<typeof Primitive.img>;\ntype PrimitiveImageProps = ComponentPropsWithoutRef<typeof Primitive.img>;\n\nexport type ContentPartPrimitiveImageProps = PrimitiveImageProps;\n\nexport const ContentPartPrimitiveImage = forwardRef<\n ContentPartPrimitiveImageElement,\n ContentPartPrimitiveImageProps\n>((props, forwardedRef) => {\n const {\n part: { image },\n } = useContentPartImage();\n return <Primitive.img src={image} {...props} ref={forwardedRef} />;\n});\n\nContentPartPrimitiveImage.displayName = \"ContentPartPrimitive.Image\";\n","import type { FC } from \"react\";\nimport { useContentPartDisplay } from \"../../primitive-hooks/contentPart/useContentPartDisplay\";\n\nexport type ContentPartPrimitiveDisplayProps = {};\n\nexport const ContentPartPrimitiveDisplay: FC<\n ContentPartPrimitiveDisplayProps\n> = () => {\n const {\n part: { display },\n } = useContentPartDisplay();\n return display ?? null;\n};\n\nContentPartPrimitiveDisplay.displayName = \"ContentPartPrimitive.Display\";\n","import { FC, PropsWithChildren } from \"react\";\nimport { useContentPartContext } from \"../../context\";\n\nexport type ContentPartPrimitiveInProgressProps = PropsWithChildren;\n\nexport const ContentPartPrimitiveInProgress: FC<\n ContentPartPrimitiveInProgressProps\n> = ({ children }) => {\n const { useContentPart } = useContentPartContext();\n const isInProgress = useContentPart((c) => c.status.type === \"running\");\n\n return isInProgress ? children : null;\n};\n\nContentPartPrimitiveInProgress.displayName = \"ContentPartPrimitive.InProgress\";\n","\"use client\";\n\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { ComponentPropsWithoutRef, FC } from \"react\";\n\ntype PrimitiveSpanProps = ComponentPropsWithoutRef<typeof Primitive.span>;\n\nexport type MessagePrimitiveInProgressProps = PrimitiveSpanProps;\n\n/**\n * @deprecated Define a custom Text renderer via ContentPartPrimitiveInProgress instead.\n */\nexport const MessagePrimitiveInProgress: FC<\n MessagePrimitiveInProgressProps\n> = () => {\n return null;\n};\n\nMessagePrimitiveInProgress.displayName = \"MessagePrimitive.InProgress\";\n","export { ComposerPrimitiveRoot as Root } from \"./ComposerRoot\";\nexport { ComposerPrimitiveInput as Input } from \"./ComposerInput\";\nexport { ComposerPrimitiveSend as Send } from \"./ComposerSend\";\nexport { ComposerPrimitiveCancel as Cancel } from \"./ComposerCancel\";\nexport { ComposerPrimitiveIf as If } from \"./ComposerIf\";\n","\"use client\";\n\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport {\n type ElementRef,\n type FormEvent,\n forwardRef,\n ComponentPropsWithoutRef,\n} from \"react\";\nimport { useComposerSend } from \"../../primitive-hooks\";\n\ntype ComposerPrimitiveRootElement = ElementRef<typeof Primitive.form>;\ntype PrimitiveFormProps = ComponentPropsWithoutRef<typeof Primitive.form>;\n\nexport type ComposerPrimitiveRootProps = PrimitiveFormProps;\n\nexport const ComposerPrimitiveRoot = forwardRef<\n ComposerPrimitiveRootElement,\n ComposerPrimitiveRootProps\n>(({ onSubmit, ...rest }, forwardedRef) => {\n const send = useComposerSend();\n\n const handleSubmit = (e: FormEvent) => {\n e.preventDefault();\n\n if (!send) return;\n send();\n };\n\n return (\n <Primitive.form\n {...rest}\n ref={forwardedRef}\n onSubmit={composeEventHandlers(onSubmit, handleSubmit)}\n />\n );\n});\n\nComposerPrimitiveRoot.displayName = \"ComposerPrimitive.Root\";\n","\"use client\";\n\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport {\n type KeyboardEvent,\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport TextareaAutosize, {\n type TextareaAutosizeProps,\n} from \"react-textarea-autosize\";\nimport { useComposerContext } from \"../../context/react/ComposerContext\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport { useEscapeKeydown } from \"@radix-ui/react-use-escape-keydown\";\nimport { useOnComposerFocus } from \"../../utils/hooks/useOnComposerFocus\";\n\nexport type ComposerPrimitiveInputProps = TextareaAutosizeProps & {\n asChild?: boolean | undefined;\n};\n\nexport const ComposerPrimitiveInput = forwardRef<\n HTMLTextAreaElement,\n ComposerPrimitiveInputProps\n>(\n (\n {\n autoFocus = false,\n asChild,\n disabled: disabledProp,\n onChange,\n onKeyDown,\n ...rest\n },\n forwardedRef,\n ) => {\n const { useThread } = useThreadContext();\n const { useComposer, type } = useComposerContext();\n\n const value = useComposer((c) => {\n if (!c.isEditing) return \"\";\n return c.value;\n });\n\n const Component = asChild ? Slot : TextareaAutosize;\n\n const isDisabled = useThread((t) => t.isDisabled) ?? disabledProp ?? false;\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const ref = useComposedRefs(forwardedRef, textareaRef);\n\n useEscapeKeydown((e) => {\n const composer = useComposer.getState();\n if (composer.canCancel) {\n composer.cancel();\n e.preventDefault();\n }\n });\n\n const handleKeyPress = (e: KeyboardEvent) => {\n if (isDisabled) return;\n\n if (e.key === \"Enter\" && e.shiftKey === false) {\n const isRunning = useThread.getState().isRunning;\n if (!isRunning) {\n e.preventDefault();\n\n textareaRef.current?.closest(\"form\")?.requestSubmit();\n }\n }\n };\n\n const autoFocusEnabled = autoFocus && !isDisabled;\n const focus = useCallback(() => {\n const textarea = textareaRef.current;\n if (!textarea || !autoFocusEnabled) return;\n\n textarea.focus({ preventScroll: true });\n textarea.setSelectionRange(\n textareaRef.current.value.length,\n textareaRef.current.value.length,\n );\n }, [autoFocusEnabled]);\n\n useEffect(() => focus(), [focus]);\n\n useOnComposerFocus(() => {\n if (type === \"new\") {\n focus();\n }\n });\n\n return (\n <Component\n name=\"input\"\n value={value}\n {...rest}\n ref={ref}\n disabled={isDisabled}\n onChange={composeEventHandlers(onChange, (e) => {\n const composerState = useComposer.getState();\n if (!composerState.isEditing) return;\n return composerState.setValue(e.target.value);\n })}\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyPress)}\n />\n );\n },\n);\n\nComposerPrimitiveInput.displayName = \"ComposerPrimitive.Input\";\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, ElementRef, forwardRef } from \"react\";\nimport { useComposerContext } from \"../../context\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\n\ntype ComposerPrimitiveSendElement = ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = ComponentPropsWithoutRef<typeof Primitive.button>;\n\nexport type ComposerPrimitiveSendProps = PrimitiveButtonProps;\n\nexport const ComposerPrimitiveSend = forwardRef<\n ComposerPrimitiveSendElement,\n ComposerPrimitiveSendProps\n>(({ disabled, ...rest }, ref) => {\n const { useComposer } = useComposerContext();\n const hasValue = useComposer((c) => c.isEditing && c.value.length > 0);\n\n return (\n <Primitive.button\n type=\"submit\"\n {...rest}\n ref={ref}\n disabled={disabled || !hasValue}\n />\n );\n});\n\nComposerPrimitiveSend.displayName = \"ComposerPrimitive.Send\";\n","\"use client\";\n\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useComposerCancel } from \"../../primitive-hooks/composer/useComposerCancel\";\n\nexport type ComposerPrimitiveCancelProps = ActionButtonProps<\n typeof useComposerCancel\n>;\n\nexport const ComposerPrimitiveCancel = createActionButton(\n \"ComposerPrimitive.Cancel\",\n useComposerCancel,\n);\n","\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport {\n UseComposerIfProps,\n useComposerIf,\n} from \"../../primitive-hooks/composer/useComposerIf\";\n\nexport type ComposerPrimitiveIfProps = PropsWithChildren<UseComposerIfProps>;\n\nexport const ComposerPrimitiveIf: FC<ComposerPrimitiveIfProps> = ({\n children,\n ...query\n}) => {\n const result = useComposerIf(query);\n return result ? children : null;\n};\n\nComposerPrimitiveIf.displayName = \"ComposerPrimitive.If\";\n","export { ContentPartPrimitiveText as Text } from \"./ContentPartText\";\nexport { ContentPartPrimitiveImage as Image } from \"./ContentPartImage\";\nexport { ContentPartPrimitiveDisplay as Display } from \"./ContentPartDisplay\";\nexport { ContentPartPrimitiveInProgress as InProgress } from \"./ContentPartInProgress\";\n","export { ThreadPrimitiveRoot as Root } from \"./ThreadRoot\";\nexport { ThreadPrimitiveEmpty as Empty } from \"./ThreadEmpty\";\nexport { ThreadPrimitiveIf as If } from \"./ThreadIf\";\nexport { ThreadPrimitiveViewport as Viewport } from \"./ThreadViewport\";\nexport { ThreadPrimitiveMessages as Messages } from \"./ThreadMessages\";\nexport { ThreadPrimitiveScrollToBottom as ScrollToBottom } from \"./ThreadScrollToBottom\";\nexport { ThreadPrimitiveSuggestion as Suggestion } from \"./ThreadSuggestion\";\n","\"use client\";\n\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { type ElementRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\n\ntype ThreadPrimitiveRootElement = ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport type ThreadPrimitiveRootProps = PrimitiveDivProps;\n\nexport const ThreadPrimitiveRoot = forwardRef<\n ThreadPrimitiveRootElement,\n ThreadPrimitiveRootProps\n>((props, ref) => {\n return <Primitive.div {...props} ref={ref} />;\n});\n\nThreadPrimitiveRoot.displayName = \"ThreadPrimitive.Root\";\n","\"use client\";\n\nimport type { FC, ReactNode } from \"react\";\nimport { useThreadEmpty } from \"../../primitive-hooks\";\n\nexport type ThreadPrimitiveEmptyProps = {\n children: ReactNode;\n};\n\nexport const ThreadPrimitiveEmpty: FC<ThreadPrimitiveEmptyProps> = ({\n children,\n}) => {\n const empty = useThreadEmpty();\n return empty ? children : null;\n};\n\nThreadPrimitiveEmpty.displayName = \"ThreadPrimitive.Empty\";\n","\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport {\n UseThreadIfProps,\n useThreadIf,\n} from \"../../primitive-hooks/thread/useThreadIf\";\n\nexport type ThreadPrimitiveIfProps = PropsWithChildren<UseThreadIfProps>;\n\nexport const ThreadPrimitiveIf: FC<ThreadPrimitiveIfProps> = ({\n children,\n ...query\n}) => {\n const result = useThreadIf(query);\n return result ? children : null;\n};\n\nThreadPrimitiveIf.displayName = \"ThreadPrimitive.If\";\n","\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { type ElementRef, forwardRef, ComponentPropsWithoutRef } from \"react\";\nimport {\n UseThreadViewportAutoScrollProps,\n useThreadViewportAutoScroll,\n} from \"../../primitive-hooks/thread/useThreadViewportAutoScroll\";\n\ntype ThreadPrimitiveViewportElement = ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport type ThreadPrimitiveViewportProps = PrimitiveDivProps &\n UseThreadViewportAutoScrollProps;\n\nexport const ThreadPrimitiveViewport = forwardRef<\n ThreadPrimitiveViewportElement,\n ThreadPrimitiveViewportProps\n>(({ autoScroll, onScroll, children, ...rest }, forwardedRef) => {\n const autoScrollRef = useThreadViewportAutoScroll<HTMLDivElement>({\n autoScroll,\n });\n\n const ref = useComposedRefs(forwardedRef, autoScrollRef);\n\n return (\n <Primitive.div {...rest} ref={ref}>\n {children}\n </Primitive.div>\n );\n});\n\nThreadPrimitiveViewport.displayName = \"ThreadPrimitive.Viewport\";\n","\"use client\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { useRef } from \"react\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport { useOnResizeContent } from \"../../utils/hooks/useOnResizeContent\";\nimport { useOnScrollToBottom } from \"../../utils/hooks/useOnScrollToBottom\";\nimport { StoreApi } from \"zustand\";\nimport { ThreadViewportState } from \"../../context\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\n\nexport type UseThreadViewportAutoScrollProps = {\n autoScroll?: boolean | undefined;\n};\n\nexport const useThreadViewportAutoScroll = <TElement extends HTMLElement>({\n autoScroll = true,\n}: UseThreadViewportAutoScrollProps) => {\n const divRef = useRef<TElement>(null);\n\n const { useViewport } = useThreadContext();\n\n const lastScrollTop = useRef<number>(0);\n\n // bug: when ScrollToBottom's button changes its disabled state, the scroll stops\n // fix: delay the state change until the scroll is done\n const isScrollingToBottomRef = useRef(false);\n\n const scrollToBottom = (behavior: ScrollBehavior) => {\n const div = divRef.current;\n if (!div || !autoScroll) return;\n\n isScrollingToBottomRef.current = true;\n div.scrollTo({ top: div.scrollHeight, behavior });\n };\n\n const handleScroll = () => {\n const div = divRef.current;\n if (!div) return;\n\n const isAtBottom = useViewport.getState().isAtBottom;\n const newIsAtBottom =\n div.scrollHeight - div.scrollTop <= div.clientHeight + 1; // TODO figure out why +1 is needed\n\n if (!newIsAtBottom && lastScrollTop.current < div.scrollTop) {\n // ignore scroll down\n } else {\n if (newIsAtBottom) {\n isScrollingToBottomRef.current = false;\n }\n\n if (newIsAtBottom !== isAtBottom) {\n (useViewport as unknown as StoreApi<ThreadViewportState>).setState({\n isAtBottom: newIsAtBottom,\n });\n }\n }\n\n lastScrollTop.current = div.scrollTop;\n };\n\n const resizeRef = useOnResizeContent(() => {\n if (isScrollingToBottomRef.current || useViewport.getState().isAtBottom) {\n scrollToBottom(\"instant\");\n }\n\n handleScroll();\n });\n\n const scrollRef = useManagedRef<HTMLElement>((el) => {\n el.addEventListener(\"scroll\", handleScroll);\n return () => {\n el.removeEventListener(\"scroll\", handleScroll);\n };\n });\n\n const autoScrollRef = useComposedRefs<TElement>(resizeRef, scrollRef, divRef);\n\n useOnScrollToBottom(() => {\n scrollToBottom(\"auto\");\n });\n\n return autoScrollRef;\n};\n","import { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { useCallback } from \"react\";\nimport { useManagedRef } from \"./useManagedRef\";\n\nexport const useOnResizeContent = (callback: () => void) => {\n const callbackRef = useCallbackRef(callback);\n\n const refCallback = useCallback(\n (el: HTMLElement) => {\n const resizeObserver = new ResizeObserver(() => {\n callbackRef();\n });\n\n const mutationObserver = new MutationObserver((mutations) => {\n for (const mutation of mutations) {\n for (const node of mutation.addedNodes) {\n if (node instanceof Element) {\n resizeObserver.observe(node);\n }\n }\n\n for (const node of mutation.removedNodes) {\n if (node instanceof Element) {\n resizeObserver.unobserve(node);\n }\n }\n }\n\n callbackRef();\n });\n\n resizeObserver.observe(el);\n mutationObserver.observe(el, { childList: true });\n\n // Observe existing children\n for (const child of el.children) {\n resizeObserver.observe(child);\n }\n\n return () => {\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n };\n },\n [callbackRef],\n );\n\n return useManagedRef(refCallback);\n};\n","import { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nimport { useEffect } from \"react\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\n\nexport const useOnScrollToBottom = (callback: () => void) => {\n const callbackRef = useCallbackRef(callback);\n\n const { useViewport } = useThreadContext();\n useEffect(() => {\n return useViewport.getState().onScrollToBottom(() => {\n callbackRef();\n });\n }, [useViewport, callbackRef]);\n};\n","\"use client\";\n\nimport { type ComponentType, type FC, memo } from \"react\";\nimport { useThreadContext } from \"../../context/react/ThreadContext\";\nimport { MessageProvider } from \"../../context/providers/MessageProvider\";\nimport { ComposerPrimitiveIf } from \"../composer/ComposerIf\";\nimport { MessagePrimitiveIf } from \"../message/MessageIf\";\n\nexport type ThreadPrimitiveMessagesProps = {\n components:\n | {\n Message: ComponentType;\n UserMessage?: ComponentType | undefined;\n EditComposer?: ComponentType | undefined;\n AssistantMessage?: ComponentType | undefined;\n SystemMessage?: ComponentType | undefined;\n }\n | {\n Message?: ComponentType | undefined;\n UserMessage: ComponentType;\n EditComposer?: ComponentType | undefined;\n AssistantMessage: ComponentType;\n SystemMessage?: ComponentType | undefined;\n };\n};\n\nconst DEFAULT_SYSTEM_MESSAGE = () => null;\n\nconst getComponents = (\n components: ThreadPrimitiveMessagesProps[\"components\"],\n) => {\n return {\n EditComposer:\n components.EditComposer ??\n components.UserMessage ??\n (components.Message as ComponentType),\n UserMessage:\n components.UserMessage ?? (components.Message as ComponentType),\n AssistantMessage:\n components.AssistantMessage ?? (components.Message as ComponentType),\n SystemMessage: components.SystemMessage ?? DEFAULT_SYSTEM_MESSAGE,\n };\n};\n\ntype ThreadMessageProps = {\n messageIndex: number;\n components: ThreadPrimitiveMessagesProps[\"components\"];\n};\n\nconst ThreadMessageImpl: FC<ThreadMessageProps> = ({\n messageIndex,\n components,\n}) => {\n const { UserMessage, EditComposer, AssistantMessage, SystemMessage } =\n getComponents(components);\n return (\n <MessageProvider messageIndex={messageIndex}>\n <MessagePrimitiveIf user>\n <ComposerPrimitiveIf editing={false}>\n <UserMessage />\n </ComposerPrimitiveIf>\n <ComposerPrimitiveIf editing>\n <EditComposer />\n </ComposerPrimitiveIf>\n </MessagePrimitiveIf>\n <MessagePrimitiveIf assistant>\n <AssistantMessage />\n </MessagePrimitiveIf>\n <MessagePrimitiveIf system>\n <SystemMessage />\n </MessagePrimitiveIf>\n </MessageProvider>\n );\n};\n\nconst ThreadMessage = memo(\n ThreadMessageImpl,\n (prev, next) =>\n prev.messageIndex === next.messageIndex &&\n prev.components.Message === next.components.Message &&\n prev.components.UserMessage === next.components.UserMessage &&\n prev.components.EditComposer === next.components.EditComposer &&\n prev.components.AssistantMessage === next.components.AssistantMessage &&\n prev.components.SystemMessage === next.components.SystemMessage,\n);\n\nexport const ThreadPrimitiveMessagesImpl: FC<ThreadPrimitiveMessagesProps> = ({\n components,\n}) => {\n const { useThreadMessages } = useThreadContext();\n\n const messagesLength = useThreadMessages((t) => t.length);\n if (messagesLength === 0) return null;\n\n return new Array(messagesLength).fill(null).map((_, idx) => {\n const messageIndex = idx; // keep the same key when switching branches for better a11y support\n return (\n <ThreadMessage\n key={messageIndex}\n messageIndex={messageIndex}\n components={components}\n />\n );\n });\n};\n\nThreadPrimitiveMessagesImpl.displayName = \"ThreadPrimitive.Messages\";\n\nexport const ThreadPrimitiveMessages = memo(\n ThreadPrimitiveMessagesImpl,\n (prev, next) =>\n prev.components?.Message === next.components?.Message &&\n prev.components?.UserMessage === next.components?.UserMessage &&\n prev.components?.EditComposer === next.components?.EditComposer &&\n prev.components?.AssistantMessage === next.components?.AssistantMessage &&\n prev.components?.SystemMessage === next.components?.SystemMessage,\n);\n","\"use client\";\n\nimport { type FC, type PropsWithChildren, useEffect, useState } from \"react\";\nimport { StoreApi, create } from \"zustand\";\nimport type {\n CoreUserContentPart,\n ThreadMessage,\n} from \"../../types/AssistantTypes\";\nimport { getMessageText } from \"../../utils/getMessageText\";\nimport { MessageContext } from \"../react/MessageContext\";\nimport type { MessageContextValue } from \"../react/MessageContext\";\nimport { useThreadContext } from \"../react/ThreadContext\";\nimport type { MessageState } from \"../stores/Message\";\nimport { makeEditComposerStore } from \"../stores/EditComposer\";\nimport { makeMessageUtilsStore } from \"../stores/MessageUtils\";\nimport { ThreadMessagesState } from \"../stores/ThreadMessages\";\n\ntype MessageProviderProps = PropsWithChildren<{\n messageIndex: number;\n}>;\n\nconst getIsLast = (messages: ThreadMessagesState, message: ThreadMessage) => {\n return messages[messages.length - 1]?.id === message.id;\n};\n\nconst getMessageState = (\n messages: ThreadMessagesState,\n getBranches: (messageId: string) => readonly string[],\n useMessage: MessageContextValue[\"useMessage\"] | undefined,\n messageIndex: number,\n) => {\n const parentId = messages[messageIndex - 1]?.id ?? null;\n const message = messages[messageIndex];\n if (!message) return null;\n\n const isLast = getIsLast(messages, message);\n const branches = getBranches(message.id);\n\n // if the message is the same, don't update\n const currentState = useMessage?.getState();\n if (\n currentState &&\n currentState.message === message &&\n currentState.parentId === parentId &&\n currentState.branches === branches &&\n currentState.isLast === isLast\n )\n return null;\n\n return Object.freeze({\n message,\n parentId,\n branches,\n isLast,\n });\n};\n\nconst useMessageContext = (messageIndex: number) => {\n const { useThreadMessages, useThreadActions } = useThreadContext();\n\n const [context] = useState<MessageContextValue>(() => {\n const useMessage = create<MessageState>(\n () =>\n getMessageState(\n useThreadMessages.getState(),\n useThreadActions.getState().getBranches,\n undefined,\n messageIndex,\n )!,\n );\n const useMessageUtils = makeMessageUtilsStore();\n const useEditComposer = makeEditComposerStore({\n onEdit: () => {\n const message = useMessage.getState().message;\n if (message.role !== \"user\")\n throw new Error(\n \"Tried to edit a non-user message. Editing is only supported for user messages. This is likely an internal bug in assistant-ui.\",\n );\n\n const text = getMessageText(message);\n\n return text;\n },\n onSend: (text) => {\n const { message, parentId } = useMessage.getState();\n if (message.role !== \"user\")\n throw new Error(\n \"Tried to edit a non-user message. Editing is only supported for user messages. This is likely an internal bug in assistant-ui.\",\n );\n\n const nonTextParts = message.content.filter(\n (part): part is CoreUserContentPart =>\n part.type !== \"text\" && part.type !== \"ui\",\n );\n useThreadActions.getState().append({\n parentId,\n role: \"user\",\n content: [{ type: \"text\", text }, ...nonTextParts],\n });\n },\n });\n\n return { useMessage, useMessageUtils, useEditComposer };\n });\n\n useEffect(() => {\n const syncMessage = (thread: ThreadMessagesState) => {\n const newState = getMessageState(\n thread,\n useThreadActions.getState().getBranches,\n context.useMessage,\n messageIndex,\n );\n if (!newState) return;\n (context.useMessage as unknown as StoreApi<MessageState>).setState(\n newState,\n true,\n );\n };\n\n syncMessage(useThreadMessages.getState());\n\n return useThreadMessages.subscribe(syncMessage);\n }, [useThreadMessages, useThreadActions, context, messageIndex]);\n\n return context;\n};\n\nexport const MessageProvider: FC<MessageProviderProps> = ({\n messageIndex,\n children,\n}) => {\n const context = useMessageContext(messageIndex);\n\n return (\n <MessageContext.Provider value={context}>\n {children}\n </MessageContext.Provider>\n );\n};\n","import { create } from \"zustand\";\nimport { type BaseComposerState, makeBaseComposer } from \"./BaseComposer\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\n\nexport type EditComposerState = BaseComposerState &\n Readonly<{\n canCancel: boolean;\n isEditing: boolean;\n\n edit: () => void;\n send: () => void;\n cancel: () => void;\n }>;\n\nexport const makeEditComposerStore = ({\n onEdit,\n onSend,\n}: {\n onEdit: () => string;\n onSend: (value: string) => void;\n}): ReadonlyStore<EditComposerState> =>\n create<EditComposerState>()((set, get, store) => ({\n ...makeBaseComposer(set, get, store),\n\n canCancel: false,\n isEditing: false,\n\n edit: () => {\n const value = onEdit();\n set({ isEditing: true, canCancel: true, value });\n },\n send: () => {\n const value = get().value;\n set({ isEditing: false, canCancel: false });\n onSend(value);\n },\n cancel: () => {\n set({ isEditing: false, canCancel: false });\n },\n }));\n","import { create } from \"zustand\";\n\nexport type MessageUtilsState = Readonly<{\n isCopied: boolean;\n setIsCopied: (value: boolean) => void;\n isHovering: boolean;\n setIsHovering: (value: boolean) => void;\n}>;\n\nexport const makeMessageUtilsStore = () =>\n create<MessageUtilsState>((set) => ({\n isCopied: false,\n setIsCopied: (value) => {\n set({ isCopied: value });\n },\n isHovering: false,\n setIsHovering: (value) => {\n set({ isHovering: value });\n },\n }));\n","\"use client\";\n\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadScrollToBottom } from \"../../primitive-hooks/thread/useThreadScrollToBottom\";\n\nexport type ThreadPrimitiveScrollToBottomProps = ActionButtonProps<\n typeof useThreadScrollToBottom\n>;\n\nexport const ThreadPrimitiveScrollToBottom = createActionButton(\n \"ThreadPrimitive.ScrollToBottom\",\n useThreadScrollToBottom,\n);\n","\"use client\";\n\nimport {\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadSuggestion } from \"../../primitive-hooks/thread/useThreadSuggestion\";\n\nexport type ThreadPrimitiveSuggestionProps = ActionButtonProps<\n typeof useThreadSuggestion\n>;\n\nexport const ThreadPrimitiveSuggestion = createActionButton(\n \"ThreadPrimitive.Suggestion\",\n useThreadSuggestion,\n [\"prompt\", \"autoSend\", \"method\"],\n);\n","\"use client\";\n\nimport { useInsertionEffect, useState } from \"react\";\nimport type { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { LocalRuntime } from \"./LocalRuntime\";\nimport { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\n\nexport const useLocalRuntime = (\n adapter: ChatModelAdapter,\n options?: LocalRuntimeOptions,\n) => {\n const [runtime] = useState(() => new LocalRuntime(adapter, options));\n\n useInsertionEffect(() => {\n runtime.adapter = adapter;\n });\n\n return runtime;\n};\n","import { type ModelConfigProvider } from \"../../types/ModelConfigTypes\";\nimport type { Unsubscribe } from \"../../types/Unsubscribe\";\nimport type { AssistantRuntime } from \"./AssistantRuntime\";\nimport { ReactThreadRuntime } from \"./ReactThreadRuntime\";\n\nexport abstract class BaseAssistantRuntime<\n TThreadRuntime extends ReactThreadRuntime,\n> implements AssistantRuntime\n{\n constructor(private _thread: TThreadRuntime) {\n this._thread = _thread;\n }\n\n get thread() {\n return this._thread;\n }\n\n set thread(thread: TThreadRuntime) {\n this._thread = thread;\n this.subscriptionHandler();\n }\n\n public abstract registerModelConfigProvider(\n provider: ModelConfigProvider,\n ): Unsubscribe;\n public abstract switchToThread(threadId: string | null): void;\n\n private _subscriptions = new Set<() => void>();\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private subscriptionHandler = () => {\n for (const callback of this._subscriptions) callback();\n };\n}\n","export { ProxyConfigProvider } from \"./utils/ProxyConfigProvider\";\nexport { MessageRepository } from \"./runtimes/utils/MessageRepository\";\nexport { BaseAssistantRuntime } from \"./runtimes/core/BaseAssistantRuntime\";\nexport * from \"./utils/smooth\";\nexport { TooltipIconButton } from \"./ui/base/tooltip-icon-button\";\nexport { generateId } from \"./utils/idUtils\";\n","import { customAlphabet } from \"nanoid/non-secure\";\n\nexport const generateId = customAlphabet(\n \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",\n 7,\n);\n\nconst optimisticPrefix = \"__optimistic__\";\nexport const generateOptimisticId = () => `${optimisticPrefix}${generateId()}`;\nexport const isOptimisticId = (id: string) => id.startsWith(optimisticPrefix);\n","import { generateId } from \"../../../internal\";\nimport {\n ThreadMessage,\n CoreMessage,\n ToolCallContentPart,\n MessageStatus,\n} from \"../../../types\";\n\nexport const fromCoreMessages = (\n message: readonly CoreMessage[],\n): ThreadMessage[] => {\n return message.map((message) => fromCoreMessage(message));\n};\n\nexport const fromCoreMessage = (\n message: CoreMessage,\n {\n id = generateId(),\n status = { type: \"complete\", reason: \"unknown\" } as MessageStatus,\n } = {},\n): ThreadMessage => {\n const commonProps = {\n id,\n createdAt: new Date(),\n };\n\n const role = message.role;\n switch (role) {\n case \"assistant\":\n return {\n ...commonProps,\n role,\n content: message.content.map((part) => {\n if (part.type === \"tool-call\") {\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n } satisfies ToolCallContentPart;\n }\n return part;\n }),\n status,\n } satisfies ThreadMessage;\n\n case \"user\":\n return {\n ...commonProps,\n role,\n content: message.content,\n } satisfies ThreadMessage;\n\n case \"system\":\n return {\n ...commonProps,\n role,\n content: message.content,\n } satisfies ThreadMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n","import type { CoreMessage, ThreadMessage } from \"../../types/AssistantTypes\";\nimport { generateOptimisticId } from \"../../utils/idUtils\";\nimport { fromCoreMessage } from \"../edge/converters/fromCoreMessage\";\n\ntype RepositoryParent = {\n children: string[];\n};\n\ntype RepositoryMessage = RepositoryParent & {\n prev: RepositoryMessage | null;\n current: ThreadMessage;\n next: RepositoryMessage | null;\n level: number;\n};\n\nexport interface ExportedMessageRepository {\n headId?: string | null;\n messages: Array<{\n message: ThreadMessage;\n parentId: string | null;\n }>;\n}\n\nconst findHead = (message: RepositoryMessage): RepositoryMessage => {\n if (message.next) return findHead(message.next);\n return message;\n};\n\nexport class MessageRepository {\n private messages = new Map<string, RepositoryMessage>(); // message_id -> item\n private head: RepositoryMessage | null = null;\n private root: RepositoryParent = {\n children: [],\n };\n\n private performOp(\n newParent: RepositoryMessage | null,\n child: RepositoryMessage,\n operation: \"cut\" | \"link\" | \"relink\",\n ) {\n const parentOrRoot = child.prev ?? this.root;\n const newParentOrRoot = newParent ?? this.root;\n\n if (operation === \"relink\" && parentOrRoot === newParentOrRoot) return;\n\n // cut\n if (operation !== \"link\") {\n parentOrRoot.children = parentOrRoot.children.filter(\n (m) => m !== child.current.id,\n );\n\n if (child.prev?.next === child) {\n const fallbackId = child.prev.children.at(-1);\n const fallback = fallbackId ? this.messages.get(fallbackId) : null;\n if (fallback === undefined) {\n throw new Error(\n \"MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.\",\n );\n }\n child.prev.next = fallback;\n }\n }\n\n // link\n if (operation !== \"cut\") {\n newParentOrRoot.children = [\n ...newParentOrRoot.children,\n child.current.id,\n ];\n\n if (\n newParent &&\n (findHead(child) === this.head || newParent.next === null)\n ) {\n newParent.next = child;\n }\n\n child.prev = newParent;\n }\n }\n getMessages() {\n const messages = new Array<ThreadMessage>(this.head?.level ?? 0);\n for (let current = this.head; current; current = current.prev) {\n messages[current.level] = current.current;\n }\n return messages;\n }\n\n addOrUpdateMessage(parentId: string | null, message: ThreadMessage) {\n const existingItem = this.messages.get(message.id);\n const prev = parentId ? this.messages.get(parentId) : null;\n if (prev === undefined)\n throw new Error(\n \"MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n // update existing message\n if (existingItem) {\n existingItem.current = message;\n this.performOp(prev, existingItem, \"relink\");\n return;\n }\n\n // create a new message\n const newItem: RepositoryMessage = {\n prev,\n current: message,\n next: null,\n children: [],\n level: prev ? prev.level + 1 : 0,\n };\n\n this.messages.set(message.id, newItem);\n this.performOp(prev, newItem, \"link\");\n\n if (this.head === prev) {\n this.head = newItem;\n }\n }\n\n getMessage(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n return {\n parentId: message.prev?.current.id ?? null,\n message: message.current,\n };\n }\n\n appendOptimisticMessage(parentId: string | null, message: CoreMessage) {\n let optimisticId: string;\n do {\n optimisticId = generateOptimisticId();\n } while (this.messages.has(optimisticId));\n\n this.addOrUpdateMessage(\n parentId,\n fromCoreMessage(message, {\n id: optimisticId,\n status: { type: \"running\" },\n }),\n );\n\n return optimisticId;\n }\n\n deleteMessage(messageId: string, replacementId?: string | null | undefined) {\n const message = this.messages.get(messageId);\n\n if (!message)\n throw new Error(\n \"MessageRepository(deleteMessage): Optimistic message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const replacement =\n replacementId === undefined\n ? message.prev // if no replacementId is provided, use the parent\n : replacementId === null\n ? null\n : this.messages.get(replacementId);\n if (replacement === undefined)\n throw new Error(\n \"MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.\",\n );\n\n for (const child of message.children) {\n const childMessage = this.messages.get(child);\n if (!childMessage)\n throw new Error(\n \"MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.\",\n );\n this.performOp(replacement, childMessage, \"relink\");\n }\n\n this.performOp(null, message, \"cut\");\n this.messages.delete(messageId);\n\n if (this.head === message) {\n this.head = replacement ? findHead(replacement) : null;\n }\n }\n\n getBranches(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const { children } = message.prev ?? this.root;\n return children;\n }\n\n switchToBranch(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.\",\n );\n\n if (message.prev) {\n message.prev.next = message;\n }\n\n this.head = findHead(message);\n }\n\n resetHead(messageId: string | null) {\n if (messageId === null) {\n this.head = null;\n return;\n }\n\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.\",\n );\n\n this.head = message;\n for (\n let current: RepositoryMessage | null = message;\n current;\n current = current.prev\n ) {\n if (current.prev) {\n current.prev.next = current;\n }\n }\n }\n\n export(): ExportedMessageRepository {\n const exportItems: ExportedMessageRepository[\"messages\"] = [];\n\n // hint: we are relying on the insertion order of the messages\n // this is important for the import function to properly link the messages\n for (const [, message] of this.messages) {\n exportItems.push({\n message: message.current,\n parentId: message.prev?.current.id ?? null,\n });\n }\n\n return {\n headId: this.head?.current.id ?? null,\n messages: exportItems,\n };\n }\n\n import({ headId, messages }: ExportedMessageRepository) {\n for (const { message, parentId } of messages) {\n this.addOrUpdateMessage(parentId, message);\n }\n\n // switch to the saved head id if it is not the most recent message\n this.resetHead(headId ?? messages.at(-1)?.message.id ?? null);\n }\n}\n","\"use client\";\n\nimport { forwardRef } from \"react\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"./tooltip\";\nimport { Button, ButtonProps } from \"./button\";\n\nexport type TooltipIconButtonProps = ButtonProps & {\n tooltip: string;\n side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n};\n\nexport const TooltipIconButton = forwardRef<\n HTMLButtonElement,\n TooltipIconButtonProps\n>(({ children, tooltip, side = \"bottom\", ...rest }, ref) => {\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button variant=\"ghost\" size=\"icon\" {...rest} ref={ref}>\n {children}\n <span className=\"aui-sr-only\">{tooltip}</span>\n </Button>\n </TooltipTrigger>\n <TooltipContent side={side}>{tooltip}</TooltipContent>\n </Tooltip>\n );\n});\n\nTooltipIconButton.displayName = \"TooltipIconButton\";\n","\"use client\";\n\nimport * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\nimport { withDefaults } from \"../utils/withDefaults\";\nimport { FC } from \"react\";\n\nexport const Tooltip: FC<TooltipPrimitive.TooltipProps> = (props) => {\n return (\n <TooltipPrimitive.Provider>\n <TooltipPrimitive.Root {...props} />\n </TooltipPrimitive.Provider>\n );\n};\n\nTooltip.displayName = \"Tooltip\";\n\nexport const TooltipTrigger = TooltipPrimitive.Trigger;\n\nexport const TooltipContent = withDefaults(TooltipPrimitive.Content, {\n sideOffset: 4,\n className: \"aui-tooltip-content\",\n});\n\nTooltipContent.displayName = \"TooltipContent\";\n","import {\n ComponentPropsWithoutRef,\n ElementRef,\n ElementType,\n forwardRef,\n} from \"react\";\nimport classNames from \"classnames\";\n\nexport const withDefaultProps =\n <TProps extends { className?: string }>({\n className,\n ...defaultProps\n }: Partial<TProps>) =>\n ({ className: classNameProp, ...props }: TProps) => {\n return {\n className: classNames(className, classNameProp),\n ...defaultProps,\n ...props,\n } as TProps;\n };\n\nexport const withDefaults = <TComponent extends ElementType>(\n Component: TComponent,\n defaultProps: Partial<Omit<ComponentPropsWithoutRef<TComponent>, \"asChild\">>,\n) => {\n type TComponentProps = typeof defaultProps;\n const getProps = withDefaultProps<TComponentProps>(defaultProps);\n const WithDefaults = forwardRef<ElementRef<TComponent>, TComponentProps>(\n (props, ref) => {\n const ComponentAsAny = Component as any;\n return <ComponentAsAny {...getProps(props)} ref={ref} />;\n },\n );\n WithDefaults.displayName =\n \"withDefaults(\" +\n (typeof Component === \"string\" ? Component : Component.displayName) +\n \")\";\n return WithDefaults;\n};\n","import { cva, type VariantProps } from \"class-variance-authority\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { ElementRef, forwardRef } from \"react\";\n\nconst buttonVariants = cva(\"aui-button\", {\n variants: {\n variant: {\n default: \"aui-button-primary\",\n outline: \"aui-button-outline\",\n ghost: \"aui-button-ghost\",\n },\n size: {\n default: \"aui-button-medium\",\n icon: \"aui-button-icon\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n});\n\ntype ButtonElement = ElementRef<typeof Primitive.button>;\n\nexport type ButtonProps = React.ComponentPropsWithoutRef<\n typeof Primitive.button\n> &\n VariantProps<typeof buttonVariants>;\n\nconst Button = forwardRef<ButtonElement, ButtonProps>(\n ({ className, variant, size, ...props }, ref) => {\n return (\n <Primitive.button\n className={buttonVariants({ variant, size, className })}\n {...props}\n ref={ref}\n />\n );\n },\n);\n\nButton.displayName = \"Button\";\n\nexport { Button, buttonVariants };\n","import { LanguageModelV1Message } from \"@ai-sdk/provider\";\nimport { CoreMessage, ToolCallContentPart } from \"../../../types\";\n\ntype fromLanguageModelMessagesOptions = {\n mergeRoundtrips: boolean;\n};\n\nexport const fromLanguageModelMessages = (\n lm: LanguageModelV1Message[],\n { mergeRoundtrips }: fromLanguageModelMessagesOptions,\n): CoreMessage[] => {\n const messages: CoreMessage[] = [];\n\n for (const lmMessage of lm) {\n const role = lmMessage.role;\n switch (role) {\n case \"system\": {\n messages.push({\n role: \"system\",\n content: [\n {\n type: \"text\",\n text: lmMessage.content,\n },\n ],\n });\n break;\n }\n case \"user\": {\n messages.push({\n role: \"user\",\n content: lmMessage.content.map((part) => {\n const type = part.type;\n switch (type) {\n case \"text\": {\n return {\n type: \"text\",\n text: part.text,\n };\n }\n case \"image\": {\n if (part.image instanceof URL) {\n return {\n type: \"image\",\n image: part.image.href,\n };\n }\n throw new Error(\"Only images with URL data are supported\");\n }\n default: {\n const unhandledType: never = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n });\n break;\n }\n case \"assistant\": {\n const newContent = lmMessage.content.map((part) => {\n if (part.type === \"tool-call\") {\n return {\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n argsText: JSON.stringify(part.args),\n args: part.args as Record<string, unknown>,\n } satisfies ToolCallContentPart;\n }\n return part;\n });\n\n if (mergeRoundtrips) {\n const previousMessage = messages[messages.length - 1];\n if (previousMessage?.role === \"assistant\") {\n previousMessage.content.push(...newContent);\n break;\n }\n }\n\n messages.push({\n role: \"assistant\",\n content: newContent,\n });\n break;\n }\n case \"tool\": {\n const previousMessage = messages[messages.length - 1];\n if (previousMessage?.role !== \"assistant\")\n throw new Error(\n \"A tool message must be preceded by an assistant message.\",\n );\n\n for (const tool of lmMessage.content) {\n const toolCall = previousMessage.content.find(\n (c): c is ToolCallContentPart =>\n c.type === \"tool-call\" && c.toolCallId === tool.toolCallId,\n );\n if (!toolCall)\n throw new Error(\"Received tool result for an unknown tool call.\");\n if (toolCall.toolName !== tool.toolName)\n throw new Error(\"Tool call name mismatch.\");\n\n toolCall.result = tool.result;\n if (tool.isError) {\n toolCall.isError = true;\n }\n }\n\n break;\n }\n\n default: {\n const unhandledRole: never = role;\n throw new Error(`Unknown message role: ${unhandledRole}`);\n }\n }\n }\n\n return messages;\n};\n","import { LanguageModelV1FunctionTool } from \"@ai-sdk/provider\";\nimport { Tool } from \"../../../types/ModelConfigTypes\";\n\nexport const fromLanguageModelTools = (\n tools: LanguageModelV1FunctionTool[],\n): Record<string, Tool<any, any>> => {\n return Object.fromEntries(\n tools.map((tool) => [\n tool.name,\n {\n description: tool.description,\n parameters: tool.parameters,\n },\n ]),\n );\n};\n","import { LocalRuntimeOptions, useLocalRuntime } from \"..\";\nimport { useState } from \"react\";\nimport { EdgeChatAdapterOptions, EdgeChatAdapter } from \"./EdgeChatAdapter\";\n\nexport type EdgeRuntimeOptions = EdgeChatAdapterOptions & LocalRuntimeOptions;\n\nexport const useEdgeRuntime = ({\n initialMessages,\n ...options\n}: EdgeRuntimeOptions) => {\n const [adapter] = useState(() => new EdgeChatAdapter(options));\n return useLocalRuntime(adapter, { initialMessages });\n};\n","import {\n AssistantStreamChunkTuple,\n AssistantStreamChunkType,\n} from \"./AssistantStreamChunkType\";\nimport { ToolResultStreamPart } from \"./toolResultStream\";\n\nexport function assistantDecoderStream() {\n const toolCallNames = new Map<string, string>();\n let currentToolCall:\n | { id: string; name: string; argsText: string }\n | undefined;\n\n return new TransformStream<string, ToolResultStreamPart>({\n transform(chunk, controller) {\n const [code, value] = parseStreamPart(chunk);\n\n if (\n currentToolCall &&\n code !== AssistantStreamChunkType.ToolCallArgsTextDelta &&\n code !== AssistantStreamChunkType.Error\n ) {\n controller.enqueue({\n type: \"tool-call\",\n toolCallType: \"function\",\n toolCallId: currentToolCall.id,\n toolName: currentToolCall.name,\n args: currentToolCall.argsText,\n });\n currentToolCall = undefined;\n }\n\n switch (code) {\n case AssistantStreamChunkType.TextDelta: {\n controller.enqueue({\n type: \"text-delta\",\n textDelta: value,\n });\n break;\n }\n case AssistantStreamChunkType.ToolCallBegin: {\n const { id, name } = value;\n toolCallNames.set(id, name);\n currentToolCall = { id, name, argsText: \"\" };\n break;\n }\n case AssistantStreamChunkType.ToolCallArgsTextDelta: {\n const delta = value;\n currentToolCall!.argsText += delta;\n controller.enqueue({\n type: \"tool-call-delta\",\n toolCallType: \"function\",\n toolCallId: currentToolCall!.id,\n toolName: currentToolCall!.name,\n argsTextDelta: delta,\n });\n break;\n }\n case AssistantStreamChunkType.ToolCallResult: {\n controller.enqueue({\n type: \"tool-result\",\n toolCallType: \"function\",\n toolCallId: value.id,\n toolName: toolCallNames.get(value.id)!,\n result: value.result,\n });\n break;\n }\n case AssistantStreamChunkType.Finish: {\n controller.enqueue({\n type: \"finish\",\n ...value,\n });\n break;\n }\n case AssistantStreamChunkType.Error: {\n controller.enqueue({\n type: \"error\",\n error: value,\n });\n break;\n }\n default: {\n const unhandledType: never = code;\n throw new Error(`Unhandled chunk type: ${unhandledType}`);\n }\n }\n },\n });\n}\n\nconst parseStreamPart = (part: string): AssistantStreamChunkTuple => {\n const index = part.indexOf(\":\");\n if (index === -1) throw new Error(\"Invalid stream part\");\n return [\n part.slice(0, index) as AssistantStreamChunkType,\n JSON.parse(part.slice(index + 1)),\n ] as const;\n};\n","export function chunkByLineStream() {\n let buffer = \"\";\n\n return new TransformStream({\n transform(chunk, controller) {\n buffer += chunk;\n const lines = buffer.split(\"\\n\");\n\n // Process all complete lines\n for (let i = 0; i < lines.length - 1; i++) {\n controller.enqueue(lines[i]);\n }\n\n // Keep the last incomplete line in the buffer\n buffer = lines[lines.length - 1]!;\n },\n flush(controller) {\n // flush any remaining content in the buffer\n if (buffer) {\n controller.enqueue(buffer);\n }\n },\n });\n}\n","import { ChatModelAdapter, ChatModelRunOptions } from \"../local\";\nimport { ChatModelRunResult } from \"../local/ChatModelAdapter\";\nimport { toCoreMessages } from \"./converters/toCoreMessages\";\nimport { toLanguageModelTools } from \"./converters/toLanguageModelTools\";\nimport { EdgeRuntimeRequestOptions } from \"./EdgeRuntimeRequestOptions\";\nimport { assistantDecoderStream } from \"./streams/assistantDecoderStream\";\nimport { chunkByLineStream } from \"./streams/chunkByLineStream\";\nimport { runResultStream } from \"./streams/runResultStream\";\nimport { toolResultStream } from \"./streams/toolResultStream\";\n\nexport function asAsyncIterable<T>(\n source: ReadableStream<T>,\n): AsyncIterable<T> {\n return {\n [Symbol.asyncIterator]: () => {\n const reader = source.getReader();\n return {\n async next(): Promise<IteratorResult<T, undefined>> {\n const { done, value } = await reader.read();\n return done\n ? { done: true, value: undefined }\n : { done: false, value };\n },\n };\n },\n };\n}\nexport type EdgeChatAdapterOptions = {\n api: string;\n};\n\nexport class EdgeChatAdapter implements ChatModelAdapter {\n constructor(private options: EdgeChatAdapterOptions) {}\n\n async *run({ messages, abortSignal, config }: ChatModelRunOptions) {\n const result = await fetch(this.options.api, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n system: config.system,\n messages: toCoreMessages(messages),\n tools: config.tools ? toLanguageModelTools(config.tools) : [],\n ...config.callSettings,\n ...config.config,\n } satisfies EdgeRuntimeRequestOptions),\n signal: abortSignal,\n });\n\n if (result.status !== 200) {\n throw new Error(`Status ${result.status}: ${await result.text()}`);\n }\n\n const stream = result\n .body!.pipeThrough(new TextDecoderStream())\n .pipeThrough(chunkByLineStream())\n .pipeThrough(assistantDecoderStream())\n .pipeThrough(toolResultStream(config.tools))\n .pipeThrough(runResultStream());\n\n let update: ChatModelRunResult | undefined;\n for await (update of asAsyncIterable(stream)) {\n yield update;\n }\n\n if (update === undefined)\n throw new Error(\"No data received from Edge Runtime\");\n }\n}\n","import type { ThreadAssistantMessage } from \"../../types\";\n\nexport const shouldContinue = (result: ThreadAssistantMessage) =>\n result.status?.type === \"requires-action\" &&\n result.status.reason === \"tool-calls\" &&\n result.content.every((c) => c.type !== \"tool-call\" || !!c.result);\n","import { ThreadRuntime } from \"..\";\nimport { AddToolResultOptions } from \"../../context\";\nimport { generateId } from \"../../internal\";\nimport type {\n ModelConfigProvider,\n AppendMessage,\n ThreadUserMessage,\n ThreadAssistantMessage,\n Unsubscribe,\n} from \"../../types\";\nimport { fromCoreMessages } from \"../edge\";\nimport { ExportedMessageRepository, MessageRepository } from \"../utils/MessageRepository\";\nimport type { ChatModelAdapter, ChatModelRunResult } from \"./ChatModelAdapter\";\nimport { shouldContinue } from \"./shouldContinue\";\nimport { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\n\nconst CAPABILITIES = Object.freeze({\n switchToBranch: true,\n edit: true,\n reload: true,\n cancel: true,\n copy: true,\n});\nexport class LocalThreadRuntime implements ThreadRuntime {\n private _subscriptions = new Set<() => void>();\n\n private abortController: AbortController | null = null;\n private readonly repository = new MessageRepository();\n\n public readonly capabilities = CAPABILITIES;\n\n public readonly isDisabled = false;\n\n public get messages() {\n return this.repository.getMessages();\n }\n public get isRunning() {\n return this.abortController != null;\n }\n\n constructor(\n private configProvider: ModelConfigProvider,\n public adapter: ChatModelAdapter,\n private options?: LocalRuntimeOptions,\n ) {\n if (options?.initialMessages) {\n let parentId: string | null = null;\n const messages = fromCoreMessages(options.initialMessages);\n for (const message of messages) {\n this.repository.addOrUpdateMessage(parentId, message);\n parentId = message.id;\n }\n }\n }\n\n public getBranches(messageId: string): string[] {\n return this.repository.getBranches(messageId);\n }\n\n public switchToBranch(branchId: string): void {\n this.repository.switchToBranch(branchId);\n this.notifySubscribers();\n }\n\n public async append(message: AppendMessage): Promise<void> {\n if (message.role !== \"user\")\n throw new Error(\n \"Only appending user messages are supported in LocalRuntime. This is likely an internal bug in assistant-ui.\",\n );\n\n // add user message\n const userMessageId = generateId();\n const userMessage: ThreadUserMessage = {\n id: userMessageId,\n role: \"user\",\n content: message.content,\n createdAt: new Date(),\n };\n this.repository.addOrUpdateMessage(message.parentId, userMessage);\n\n await this.startRun(userMessageId);\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n this.repository.resetHead(parentId);\n\n // add assistant message\n const id = generateId();\n let message: ThreadAssistantMessage = {\n id,\n role: \"assistant\",\n status: { type: \"running\" },\n content: [],\n createdAt: new Date(),\n };\n\n do {\n message = await this.performRoundtrip(parentId, message);\n } while (shouldContinue(message));\n }\n\n private async performRoundtrip(\n parentId: string | null,\n message: ThreadAssistantMessage,\n ) {\n const messages = this.repository.getMessages();\n\n // abort existing run\n this.abortController?.abort();\n this.abortController = new AbortController();\n\n const initialContent = message.content;\n const initialRoundtrips = message.roundtrips;\n const updateMessage = (m: Partial<ChatModelRunResult>) => {\n message = {\n ...message,\n ...(m.content\n ? { content: [...initialContent, ...(m.content ?? [])] }\n : undefined),\n status: m.status ?? message.status,\n ...(m.roundtrips?.length\n ? { roundtrips: [...(initialRoundtrips ?? []), ...m.roundtrips] }\n : undefined),\n };\n this.repository.addOrUpdateMessage(parentId, message);\n this.notifySubscribers();\n };\n\n const maxToolRoundtrips = this.options?.maxToolRoundtrips ?? 1;\n const toolRoundtrips = message.roundtrips?.length ?? 0;\n if (toolRoundtrips > maxToolRoundtrips) {\n // reached max tool roundtrips\n updateMessage({\n status: {\n type: \"incomplete\",\n reason: \"tool-calls\",\n },\n });\n return message;\n } else {\n updateMessage({\n status: {\n type: \"running\",\n },\n });\n }\n\n try {\n const promiseOrGenerator = this.adapter.run({\n messages,\n abortSignal: this.abortController.signal,\n config: this.configProvider.getModelConfig(),\n onUpdate: updateMessage,\n });\n\n // handle async iterator for streaming results\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n updateMessage(r);\n }\n } else {\n updateMessage(await promiseOrGenerator);\n }\n\n this.abortController = null;\n\n if (message.status.type === \"running\") {\n updateMessage({\n status: { type: \"complete\", reason: \"unknown\" },\n });\n } else {\n // notify subscribers that isRunning is now false\n this.notifySubscribers();\n }\n } catch (e) {\n this.abortController = null;\n\n // TODO this should be handled by the run result stream\n if (e instanceof Error && e.name === \"AbortError\") {\n updateMessage({\n status: { type: \"incomplete\", reason: \"cancelled\" },\n });\n } else {\n updateMessage({\n status: { type: \"incomplete\", reason: \"error\", error: e },\n });\n\n throw e;\n }\n }\n return message;\n }\n\n cancelRun(): void {\n if (!this.abortController) return;\n\n this.abortController.abort();\n this.abortController = null;\n }\n\n private notifySubscribers() {\n for (const callback of this._subscriptions) callback();\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n addToolResult({ messageId, toolCallId, result }: AddToolResultOptions) {\n let { parentId, message } = this.repository.getMessage(messageId);\n\n if (message.role !== \"assistant\")\n throw new Error(\"Tried to add tool result to non-assistant message\");\n\n let added = false;\n let found = false;\n const newContent = message.content.map((c) => {\n if (c.type !== \"tool-call\") return c;\n if (c.toolCallId !== toolCallId) return c;\n found = true;\n if (!c.result) added = true;\n return {\n ...c,\n result,\n };\n });\n\n if (!found)\n throw new Error(\"Tried to add tool result to non-existing tool call\");\n\n message = {\n ...message,\n content: newContent,\n };\n this.repository.addOrUpdateMessage(parentId, message);\n\n if (added && shouldContinue(message)) {\n this.performRoundtrip(parentId, message);\n }\n }\n\n export() {\n return this.repository.export();\n }\n\n import(data: ExportedMessageRepository) {\n this.repository.import(data);\n this.notifySubscribers()\n }\n}\n","import { type ModelConfigProvider } from \"../../types/ModelConfigTypes\";\nimport { BaseAssistantRuntime } from \"../core/BaseAssistantRuntime\";\nimport type { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { ProxyConfigProvider } from \"../../internal\";\nimport { LocalThreadRuntime } from \"./LocalThreadRuntime\";\nimport { LocalRuntimeOptions } from \"./LocalRuntimeOptions\";\n\nexport class LocalRuntime extends BaseAssistantRuntime<LocalThreadRuntime> {\n private readonly _proxyConfigProvider: ProxyConfigProvider;\n\n constructor(adapter: ChatModelAdapter, options?: LocalRuntimeOptions) {\n const proxyConfigProvider = new ProxyConfigProvider();\n super(new LocalThreadRuntime(proxyConfigProvider, adapter, options));\n this._proxyConfigProvider = proxyConfigProvider;\n }\n\n public set adapter(adapter: ChatModelAdapter) {\n this.thread.adapter = adapter;\n }\n\n registerModelConfigProvider(provider: ModelConfigProvider) {\n return this._proxyConfigProvider.registerModelConfigProvider(provider);\n }\n\n public switchToThread(threadId: string | null) {\n if (threadId) {\n throw new Error(\"LocalRuntime does not yet support switching threads\");\n }\n\n return (this.thread = new LocalThreadRuntime(\n this._proxyConfigProvider,\n this.thread.adapter,\n ));\n }\n}\n","import { create } from \"zustand\";\nimport { ReactThreadRuntime } from \"../core\";\nimport { MessageRepository } from \"../utils/MessageRepository\";\nimport { AppendMessage, ThreadMessage, Unsubscribe } from \"../../types\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport { AddToolResultOptions } from \"../../context\";\nimport { getExternalStoreMessage } from \"./getExternalStoreMessage\";\nimport { useExternalStoreSync } from \"./useExternalStoreSync\";\n\nexport const hasUpcomingMessage = (\n isRunning: boolean,\n messages: ThreadMessage[],\n) => {\n return isRunning && messages[messages.length - 1]?.role !== \"assistant\";\n};\n\nexport class ExternalStoreThreadRuntime implements ReactThreadRuntime {\n private _subscriptions = new Set<() => void>();\n private repository = new MessageRepository();\n private assistantOptimisticId: string | null = null;\n\n private useStore;\n\n public get capabilities() {\n return {\n switchToBranch: this.store.setMessages !== undefined,\n edit: this.store.onEdit !== undefined,\n reload: this.store.onReload !== undefined,\n cancel: this.store.onCancel !== undefined,\n copy: this.store.onCopy !== null,\n };\n }\n\n public messages: ThreadMessage[] = [];\n public isDisabled = false;\n public isRunning = false;\n\n constructor(public store: ExternalStoreAdapter<any>) {\n this.updateData(\n store.isDisabled ?? false,\n store.isRunning ?? false,\n store.messages,\n );\n\n this.useStore = create(() => ({\n store,\n }));\n }\n\n public getBranches(messageId: string): string[] {\n return this.repository.getBranches(messageId);\n }\n\n public switchToBranch(branchId: string): void {\n if (!this.store.setMessages)\n throw new Error(\"Runtime does not support switching branches.\");\n\n this.repository.switchToBranch(branchId);\n this.updateMessages(this.repository.getMessages());\n }\n\n public async append(message: AppendMessage): Promise<void> {\n if (message.parentId !== (this.messages.at(-1)?.id ?? null)) {\n if (!this.store.onEdit)\n throw new Error(\"Runtime does not support editing messages.\");\n await this.store.onEdit(message);\n } else {\n await this.store.onNew(message);\n }\n }\n\n public async startRun(parentId: string | null): Promise<void> {\n if (!this.store.onReload)\n throw new Error(\"Runtime does not support reloading messages.\");\n\n await this.store.onReload(parentId);\n }\n\n public cancelRun(): void {\n if (!this.store.onCancel)\n throw new Error(\"Runtime does not support cancelling runs.\");\n\n this.store.onCancel();\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n let messages = this.repository.getMessages();\n\n // resync messages (for reloading, to restore the previous branch)\n setTimeout(() => {\n this.updateMessages(messages);\n }, 0);\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private updateMessages = (messages: ThreadMessage[]) => {\n this.store.setMessages?.(\n messages.flatMap(getExternalStoreMessage).filter((m) => m != null),\n );\n };\n\n public onStoreUpdated() {\n if (this.useStore.getState().store !== this.store) {\n this.useStore.setState({ store: this.store });\n }\n }\n\n private updateData = (\n isDisabled: boolean,\n isRunning: boolean,\n vm: ThreadMessage[],\n ) => {\n for (let i = 0; i < vm.length; i++) {\n const message = vm[i]!;\n const parent = vm[i - 1];\n this.repository.addOrUpdateMessage(parent?.id ?? null, message);\n }\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n if (hasUpcomingMessage(isRunning, vm)) {\n this.assistantOptimisticId = this.repository.appendOptimisticMessage(\n vm.at(-1)?.id ?? null,\n {\n role: \"assistant\",\n content: [],\n },\n );\n }\n\n this.repository.resetHead(\n this.assistantOptimisticId ?? vm.at(-1)?.id ?? null,\n );\n\n this.messages = this.repository.getMessages();\n this.isDisabled = isDisabled;\n this.isRunning = isRunning;\n\n for (const callback of this._subscriptions) callback();\n };\n\n unstable_synchronizer = () => {\n const { store } = this.useStore();\n\n useExternalStoreSync(store, this.updateData);\n\n return null;\n };\n\n addToolResult(options: AddToolResultOptions) {\n if (!this.store.onAddToolResult)\n throw new Error(\"Runtime does not support tool results.\");\n this.store.onAddToolResult(options);\n }\n}\n","import { ThreadMessage } from \"../../types\";\n\nexport const symbolInnerMessage = Symbol(\"innerMessage\");\n\nexport type ExternalStoreThreadMessage<T> = ThreadMessage & {\n [symbolInnerMessage]?: T;\n};\n\nexport const getExternalStoreMessage = <T,>(message: ThreadMessage) => {\n return (message as ExternalStoreThreadMessage<T>)[symbolInnerMessage];\n};\n","import { useEffect, useInsertionEffect, useMemo, useRef } from \"react\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport {\n ConverterCallback,\n ThreadMessageConverter,\n} from \"./ThreadMessageConverter\";\nimport { ThreadMessage } from \"../../types\";\nimport { symbolInnerMessage } from \"./getExternalStoreMessage\";\nimport { getAutoStatus } from \"./auto-status\";\nimport { fromThreadMessageLike } from \"./ThreadMessageLike\";\n\ntype UpdateDataCallback = (\n isDisabled: boolean,\n isRunning: boolean,\n messages: ThreadMessage[],\n) => void;\n\nexport const useExternalStoreSync = <T extends WeakKey>(\n adapter: ExternalStoreAdapter<T>,\n updateData: UpdateDataCallback,\n) => {\n const adapterRef = useRef(adapter);\n useInsertionEffect(() => {\n adapterRef.current = adapter;\n });\n\n // flush the converter cache when the convertMessage prop changes\n const [converter, convertCallback] = useMemo(() => {\n const converter = adapter.convertMessage ?? ((m: T) => m as ThreadMessage);\n const convertCallback: ConverterCallback<T> = (cache, m, idx) => {\n const autoStatus = getAutoStatus(\n adapterRef.current.messages.at(-1) === m,\n adapterRef.current.isRunning ?? false,\n );\n\n if (cache && (cache.role !== \"assistant\" || cache.status === autoStatus))\n return cache;\n\n const newMessage = fromThreadMessageLike(\n converter(m, idx),\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = m;\n return newMessage;\n };\n return [new ThreadMessageConverter(), convertCallback];\n\n // specify convertMessage bceause we want the ThreadMessageConverter to be recreated when the adapter changes\n }, [adapter.convertMessage]);\n\n useEffect(() => {\n updateData(\n adapter.isDisabled ?? false,\n adapter.isRunning ?? false,\n converter.convertMessages(adapter.messages, convertCallback),\n );\n }, [\n updateData,\n converter,\n convertCallback,\n adapter.isDisabled,\n adapter.isRunning,\n adapter.messages,\n ]);\n};\n","import { ThreadMessage } from \"../../types\";\n\nexport type ConverterCallback<TIn> = (\n cache: ThreadMessage | undefined,\n message: TIn,\n idx: number,\n) => ThreadMessage;\n\nexport class ThreadMessageConverter {\n private readonly cache = new WeakMap<WeakKey, ThreadMessage>();\n\n convertMessages<TIn extends WeakKey>(\n messages: TIn[],\n converter: ConverterCallback<TIn>,\n keyMapper: (m: TIn) => WeakKey = (key) => key,\n ): ThreadMessage[] {\n return messages.map((m, idx) => {\n const key = keyMapper(m);\n const cached = this.cache.get(key);\n const newMessage = converter(cached, m, idx);\n this.cache.set(key, newMessage);\n return newMessage;\n });\n }\n}\n","const AUTO_STATUS_RUNNING = Object.freeze({ type: \"running\" });\nconst AUTO_STATUS_COMPLETE = Object.freeze({\n type: \"complete\",\n reason: \"unknown\",\n});\n\nexport const getAutoStatus = (isLast: boolean, isRunning: boolean) =>\n isLast && isRunning ? AUTO_STATUS_RUNNING : AUTO_STATUS_COMPLETE;\n","import {\n MessageStatus,\n TextContentPart,\n ImageContentPart,\n ToolCallContentPart,\n UIContentPart,\n ThreadMessage,\n ThreadAssistantContentPart,\n ThreadAssistantMessage,\n ThreadUserContentPart,\n ThreadUserMessage,\n ThreadSystemMessage,\n} from \"../../types\";\nimport { CoreToolCallContentPart } from \"../../types/AssistantTypes\";\n\nexport type ThreadMessageLike = {\n role: \"assistant\" | \"user\" | \"system\";\n content: (\n | TextContentPart\n | ImageContentPart\n | ToolCallContentPart<any, any>\n | CoreToolCallContentPart<any, any>\n | UIContentPart\n )[];\n id?: string | undefined;\n createdAt?: Date | undefined;\n status?: MessageStatus | undefined;\n};\n\nexport const fromThreadMessageLike = (\n like: ThreadMessageLike,\n fallbackId: string,\n fallbackStatus: MessageStatus,\n): ThreadMessage => {\n const { role, content, id, createdAt, status } = like;\n const common = {\n id: id ?? fallbackId,\n createdAt: createdAt ?? new Date(),\n };\n switch (role) {\n case \"assistant\":\n return {\n ...common,\n role,\n content: content.map((part): ThreadAssistantContentPart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"ui\":\n return part;\n\n case \"tool-call\": {\n if (\"argsText\" in part) return part;\n return {\n ...part,\n argsText: JSON.stringify(part.args),\n };\n }\n\n default: {\n const unhandledType: \"image\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n status: status ?? fallbackStatus,\n } satisfies ThreadAssistantMessage;\n\n case \"user\":\n return {\n ...common,\n role,\n content: content.map((part): ThreadUserContentPart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"ui\":\n case \"image\":\n return part;\n\n default: {\n const unhandledType: \"tool-call\" = type;\n throw new Error(`Unknown content part type: ${unhandledType}`);\n }\n }\n }),\n } satisfies ThreadUserMessage;\n\n case \"system\":\n if (content.length !== 1 || content[0]!.type !== \"text\")\n throw new Error(\n \"System messages must have exactly one text content part.\",\n );\n\n return {\n ...common,\n role,\n content: content as [TextContentPart],\n } satisfies ThreadSystemMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n","import { BaseAssistantRuntime, ProxyConfigProvider } from \"../../internal\";\nimport { ModelConfigProvider } from \"../../types\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport { ExternalStoreThreadRuntime } from \"./ExternalStoreThreadRuntime\";\n\nexport class ExternalStoreRuntime extends BaseAssistantRuntime<ExternalStoreThreadRuntime> {\n private readonly _proxyConfigProvider = new ProxyConfigProvider();\n\n constructor(store: ExternalStoreAdapter<any>) {\n super(new ExternalStoreThreadRuntime(store));\n }\n\n public set store(store: ExternalStoreAdapter<any>) {\n this.thread.store = store;\n }\n\n public onStoreUpdated() {\n return this.thread.onStoreUpdated();\n }\n\n public getModelConfig() {\n return this._proxyConfigProvider.getModelConfig();\n }\n\n public registerModelConfigProvider(provider: ModelConfigProvider) {\n return this._proxyConfigProvider.registerModelConfigProvider(provider);\n }\n\n public switchToThread(threadId: string | null) {\n if (threadId) {\n if (!this.store.onSwitchThread)\n throw new Error(\"Runtime does not support switching threads.\");\n\n return this.store.onSwitchThread(threadId);\n } else {\n if (!this.store.onNewThread)\n throw new Error(\"Runtime does not support switching to new threads.\");\n\n return this.store.onNewThread();\n }\n }\n}\n","import { useEffect, useInsertionEffect, useState } from \"react\";\nimport { ExternalStoreRuntime } from \"./ExternalStoreRuntime\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\n\nexport const useExternalStoreRuntime = (store: ExternalStoreAdapter<any>) => {\n const [runtime] = useState(() => new ExternalStoreRuntime(store));\n\n useInsertionEffect(() => {\n runtime.store = store;\n });\n useEffect(() => {\n runtime.onStoreUpdated();\n });\n\n return runtime;\n};\n","\"use client\";\n\nimport {\n FC,\n PropsWithChildren,\n ReactNode,\n createContext,\n useContext,\n} from \"react\";\n\nimport { AvatarProps } from \"./base/avatar\";\nimport { TextContentPartComponent } from \"../types\";\nimport { AssistantRuntime } from \"../runtimes\";\nimport { AssistantRuntimeProvider, useAssistantContext } from \"../context\";\n\nexport type SuggestionConfig = {\n text?: ReactNode;\n prompt: string;\n};\n\nexport type ThreadWelcomeConfig = {\n message?: string | null | undefined;\n suggestions?: SuggestionConfig[] | undefined;\n};\n\nexport type UserMessageConfig = {\n allowEdit?: boolean | undefined;\n};\n\nexport type AssistantMessageConfig = {\n allowReload?: boolean | undefined;\n allowCopy?: boolean | undefined;\n components?:\n | {\n Text?: TextContentPartComponent | undefined;\n }\n | undefined;\n};\n\nexport type BranchPickerConfig = {\n allowBranchPicker?: boolean | undefined;\n};\n\nexport type StringsConfig = {\n assistantModal?: {\n open: {\n button: {\n tooltip?: string | undefined;\n };\n };\n closed: {\n button: {\n tooltip?: string | undefined;\n };\n };\n };\n thread?: {\n scrollToBottom?: {\n tooltip?: string | undefined;\n };\n };\n userMessage?: {\n edit?: {\n tooltip?: string | undefined;\n };\n };\n assistantMessage?: {\n reload?: {\n tooltip?: string | undefined;\n };\n copy?: {\n tooltip?: string | undefined;\n };\n };\n branchPicker?: {\n previous?: {\n tooltip?: string | undefined;\n };\n next?: {\n tooltip?: string | undefined;\n };\n };\n composer?: {\n send?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n cancel?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n input?: {\n placeholder?: string | undefined;\n };\n };\n editComposer?: {\n send?: {\n label?: string | undefined;\n };\n cancel?: {\n label?: string | undefined;\n };\n };\n code?: {\n header?: {\n copy?: {\n tooltip?: string | undefined;\n };\n };\n };\n};\n\nconst ThreadConfigContext = createContext<ThreadConfig>({});\n\nexport type ThreadConfig = {\n runtime?: AssistantRuntime;\n\n assistantAvatar?: AvatarProps;\n\n welcome?: ThreadWelcomeConfig;\n assistantMessage?: AssistantMessageConfig;\n userMessage?: UserMessageConfig;\n\n branchPicker?: BranchPickerConfig;\n\n strings?: StringsConfig;\n};\n\nexport const useThreadConfig = (): Omit<ThreadConfig, \"runtime\"> => {\n return useContext(ThreadConfigContext);\n};\n\nexport type ThreadConfigProviderProps = PropsWithChildren<{\n config?: ThreadConfig | undefined;\n}>;\n\nexport const ThreadConfigProvider: FC<ThreadConfigProviderProps> = ({\n children,\n config,\n}) => {\n const assistant = useAssistantContext({ optional: true });\n\n const configProvider =\n config && Object.keys(config ?? {}).length > 0 ? (\n <ThreadConfigContext.Provider value={config}>\n {children}\n </ThreadConfigContext.Provider>\n ) : (\n <>{children}</>\n );\n if (!config?.runtime) return configProvider;\n\n if (assistant) {\n throw new Error(\n \"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed.\",\n );\n }\n return (\n <AssistantRuntimeProvider runtime={config.runtime}>\n {configProvider}\n </AssistantRuntimeProvider>\n );\n};\n\nThreadConfigProvider.displayName = \"ThreadConfigProvider\";\n","\"use client\";\n\nimport { forwardRef, type FC } from \"react\";\nimport { CheckIcon, CopyIcon, RefreshCwIcon } from \"lucide-react\";\nimport { ActionBarPrimitive, MessagePrimitive } from \"../primitives\";\nimport {\n TooltipIconButton,\n TooltipIconButtonProps,\n} from \"./base/tooltip-icon-button\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { useThreadConfig } from \"./thread-config\";\nimport { useThreadContext } from \"../context\";\n\nconst useAllowCopy = () => {\n const { assistantMessage: { allowCopy = true } = {} } = useThreadConfig();\n const { useThreadActions } = useThreadContext();\n const copySupported = useThreadActions((t) => t.capabilities.copy);\n return copySupported && allowCopy;\n};\n\nconst useAllowReload = () => {\n const { assistantMessage: { allowReload = true } = {} } = useThreadConfig();\n const { useThreadActions } = useThreadContext();\n const reloadSupported = useThreadActions((t) => t.capabilities.reload);\n return reloadSupported && allowReload;\n};\n\nconst AssistantActionBar: FC = () => {\n const allowCopy = useAllowCopy();\n const allowReload = useAllowReload();\n if (!allowCopy && !allowReload) return null;\n return (\n <AssistantActionBarRoot\n hideWhenRunning\n autohide=\"not-last\"\n autohideFloat=\"single-branch\"\n >\n <AssistantActionBarCopy />\n <AssistantActionBarReload />\n </AssistantActionBarRoot>\n );\n};\n\nAssistantActionBar.displayName = \"AssistantActionBar\";\n\nconst AssistantActionBarRoot = withDefaults(ActionBarPrimitive.Root, {\n className: \"aui-assistant-action-bar-root\",\n});\n\nAssistantActionBarRoot.displayName = \"AssistantActionBarRoot\";\n\nconst AssistantActionBarCopy = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: {\n assistantMessage: { reload: { tooltip = \"Copy\" } = {} } = {},\n } = {},\n } = useThreadConfig();\n const allowCopy = useAllowCopy();\n if (!allowCopy) return null;\n return (\n <ActionBarPrimitive.Copy asChild>\n <TooltipIconButton tooltip={tooltip} {...props} ref={ref}>\n {props.children ?? (\n <>\n <MessagePrimitive.If copied>\n <CheckIcon />\n </MessagePrimitive.If>\n <MessagePrimitive.If copied={false}>\n <CopyIcon />\n </MessagePrimitive.If>\n </>\n )}\n </TooltipIconButton>\n </ActionBarPrimitive.Copy>\n );\n});\n\nAssistantActionBarCopy.displayName = \"AssistantActionBarCopy\";\n\nconst AssistantActionBarReload = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: {\n assistantMessage: { reload: { tooltip = \"Refresh\" } = {} } = {},\n } = {},\n } = useThreadConfig();\n const allowReload = useAllowReload();\n if (!allowReload) return null;\n return (\n <ActionBarPrimitive.Reload asChild>\n <TooltipIconButton tooltip={tooltip} {...props} ref={ref}>\n <RefreshCwIcon />\n </TooltipIconButton>\n </ActionBarPrimitive.Reload>\n );\n});\n\nAssistantActionBarReload.displayName = \"AssistantActionBarReload\";\n\nconst exports = {\n Root: AssistantActionBarRoot,\n Reload: AssistantActionBarReload,\n Copy: AssistantActionBarCopy,\n};\n\nexport default Object.assign(\n AssistantActionBar,\n exports,\n) as typeof AssistantActionBar & typeof exports;\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, forwardRef, type FC } from \"react\";\nimport { MessagePrimitive, MessagePrimitiveContentProps } from \"../primitives\";\nimport BranchPicker from \"./branch-picker\";\nimport { Avatar } from \"./base/avatar\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { useThreadConfig } from \"./thread-config\";\nimport AssistantActionBar from \"./assistant-action-bar\";\nimport ContentPart from \"./content-part\";\n\nconst AssistantMessage: FC = () => {\n return (\n <AssistantMessageRoot>\n <AssistantMessageAvatar />\n <AssistantMessageContent />\n <BranchPicker />\n <AssistantActionBar />\n </AssistantMessageRoot>\n );\n};\n\nAssistantMessage.displayName = \"AssistantMessage\";\n\nconst AssistantMessageAvatar: FC = () => {\n const { assistantAvatar: avatar = { fallback: \"A\" } } = useThreadConfig();\n return <Avatar {...avatar} />;\n};\n\nconst AssistantMessageRoot = withDefaults(MessagePrimitive.Root, {\n className: \"aui-assistant-message-root\",\n});\n\nAssistantMessageRoot.displayName = \"AssistantMessageRoot\";\n\nconst AssistantMessageContentWrapper = withDefaults(\"div\", {\n className: \"aui-assistant-message-content\",\n});\n\nexport type AssistantMessageContentProps = MessagePrimitiveContentProps &\n ComponentPropsWithoutRef<\"div\">;\n\nconst AssistantMessageContent = forwardRef<\n HTMLDivElement,\n AssistantMessageContentProps\n>(({ components: componentsProp, ...rest }, ref) => {\n const { assistantMessage: { components = {} } = {} } = useThreadConfig();\n return (\n <AssistantMessageContentWrapper {...rest} ref={ref}>\n <MessagePrimitive.Content\n components={{\n ...componentsProp,\n Text: componentsProp?.Text ?? components.Text ?? ContentPart.Text,\n }}\n />\n </AssistantMessageContentWrapper>\n );\n});\n\nAssistantMessageContent.displayName = \"AssistantMessageContent\";\n\nconst exports = {\n Root: AssistantMessageRoot,\n Avatar: AssistantMessageAvatar,\n Content: AssistantMessageContent,\n};\n\nexport default Object.assign(\n AssistantMessage,\n exports,\n) as typeof AssistantMessage & typeof exports;\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, forwardRef, type FC } from \"react\";\nimport { ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\";\n\nimport {\n TooltipIconButton,\n TooltipIconButtonProps,\n} from \"./base/tooltip-icon-button\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { useThreadConfig } from \"./thread-config\";\nimport { BranchPickerPrimitive } from \"../primitives\";\nimport { useThreadContext } from \"../context\";\n\nconst useAllowBranchPicker = () => {\n const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();\n const { useThreadActions } = useThreadContext();\n const branchPickerSupported = useThreadActions((t) => t.capabilities.edit);\n return branchPickerSupported && allowBranchPicker;\n};\n\nconst BranchPicker: FC = () => {\n const allowBranchPicker = useAllowBranchPicker();\n if (!allowBranchPicker) return null;\n return (\n <BranchPickerRoot hideWhenSingleBranch>\n <BranchPickerPrevious />\n <BranchPickerState />\n <BranchPickerNext />\n </BranchPickerRoot>\n );\n};\n\nBranchPicker.displayName = \"BranchPicker\";\n\nconst BranchPickerRoot = withDefaults(BranchPickerPrimitive.Root, {\n className: \"aui-branch-picker-root\",\n});\n\nBranchPickerRoot.displayName = \"BranchPickerRoot\";\n\nconst BranchPickerPrevious = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: {\n branchPicker: { previous: { tooltip = \"Previous\" } = {} } = {},\n } = {},\n } = useThreadConfig();\n return (\n <BranchPickerPrimitive.Previous asChild>\n <TooltipIconButton tooltip={tooltip} {...props} ref={ref}>\n {props.children ?? <ChevronLeftIcon />}\n </TooltipIconButton>\n </BranchPickerPrimitive.Previous>\n );\n});\n\nBranchPickerPrevious.displayName = \"BranchPickerPrevious\";\n\nconst BranchPickerStateWrapper = withDefaults(\"span\", {\n className: \"aui-branch-picker-state\",\n});\n\nconst BranchPickerState = forwardRef<\n HTMLSpanElement,\n ComponentPropsWithoutRef<\"span\">\n>((props, ref) => {\n return (\n <BranchPickerStateWrapper {...props} ref={ref}>\n <BranchPickerPrimitive.Number /> / <BranchPickerPrimitive.Count />\n </BranchPickerStateWrapper>\n );\n});\n\nBranchPickerState.displayName = \"BranchPickerState\";\n\nconst BranchPickerNext = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: { branchPicker: { next: { tooltip = \"Next\" } = {} } = {} } = {},\n } = useThreadConfig();\n return (\n <BranchPickerPrimitive.Next asChild>\n <TooltipIconButton tooltip={tooltip} {...props} ref={ref}>\n {props.children ?? <ChevronRightIcon />}\n </TooltipIconButton>\n </BranchPickerPrimitive.Next>\n );\n});\n\nBranchPickerNext.displayName = \"BranchPickerNext\";\n\nconst exports = {\n Root: BranchPickerRoot,\n Previous: BranchPickerPrevious,\n Next: BranchPickerNext,\n};\n\nexport default Object.assign(BranchPicker, exports) as typeof BranchPicker &\n typeof exports;\n","\"use client\";\n\nimport type { FC } from \"react\";\nimport * as AvatarPrimitive from \"@radix-ui/react-avatar\";\n\nimport { withDefaults } from \"../utils/withDefaults\";\n\nexport type AvatarProps = {\n src?: string | undefined;\n alt?: string | undefined;\n fallback?: string | undefined;\n};\n\nexport const Avatar: FC<AvatarProps> = ({ src, alt, fallback }) => {\n if (src == null && fallback == null) return null;\n\n return (\n <AvatarRoot>\n {src != null && <AvatarImage src={src} alt={alt} />}\n {fallback != null && <AvatarFallback>{fallback}</AvatarFallback>}\n </AvatarRoot>\n );\n};\n\nAvatar.displayName = \"Avatar\";\n\nexport const AvatarRoot = withDefaults(AvatarPrimitive.Root, {\n className: \"aui-avatar-root\",\n});\n\nAvatarRoot.displayName = \"AvatarRoot\";\n\nexport const AvatarImage = withDefaults(AvatarPrimitive.Image, {\n className: \"aui-avatar-image\",\n});\n\nAvatarImage.displayName = \"AvatarImage\";\n\nexport const AvatarFallback = withDefaults(AvatarPrimitive.Fallback, {\n className: \"aui-avatar-fallback\",\n});\n\nAvatarFallback.displayName = \"AvatarFallback\";\n","import { FC } from \"react\";\nimport { ContentPartPrimitive } from \"../primitives\";\nimport { useSmoothStatus, withSmoothContextProvider } from \"../utils/smooth\";\nimport classNames from \"classnames\";\n\nexport const Text: FC = () => {\n const status = useSmoothStatus();\n return (\n <ContentPartPrimitive.Text\n className={classNames(\n \"aui-text\",\n status.type === \"running\" && \"aui-text-running\",\n )}\n component=\"p\"\n />\n );\n};\n\nconst exports = { Text: withSmoothContextProvider(Text) };\n\nexport default exports;\n","\"use client\";\n\nimport { type FC, forwardRef } from \"react\";\nimport { BotIcon, ChevronDownIcon } from \"lucide-react\";\n\nimport {\n AssistantModalPrimitive,\n AssistantModalPrimitiveRootProps,\n} from \"../primitives\";\nimport Thread from \"./thread\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport {\n TooltipIconButton,\n TooltipIconButtonProps,\n} from \"./base/tooltip-icon-button\";\nimport {\n ThreadConfig,\n ThreadConfigProvider,\n ThreadConfigProviderProps,\n useThreadConfig,\n} from \"./thread-config\";\n\nconst AssistantModal: FC<ThreadConfig> = (config) => {\n return (\n <AssistantModalRoot config={config}>\n <AssistantModalTrigger />\n <AssistantModalContent>\n <Thread />\n </AssistantModalContent>\n </AssistantModalRoot>\n );\n};\n\nAssistantModal.displayName = \"AssistantModal\";\n\nconst AssistantModalRoot: FC<\n AssistantModalPrimitiveRootProps & ThreadConfigProviderProps\n> = ({ config, ...props }) => {\n return (\n <ThreadConfigProvider config={config}>\n <AssistantModalPrimitive.Root {...props} />\n </ThreadConfigProvider>\n );\n};\n\nAssistantModalRoot.displayName = \"AssistantModalRoot\";\n\nconst AssistantModalTrigger = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n return (\n <AssistantModalAnchor>\n <AssistantModalPrimitive.Trigger asChild>\n <AssistantModalButton {...props} ref={ref} />\n </AssistantModalPrimitive.Trigger>\n </AssistantModalAnchor>\n );\n});\n\nAssistantModalTrigger.displayName = \"AssistantModalTrigger\";\n\nconst AssistantModalAnchor = withDefaults(AssistantModalPrimitive.Anchor, {\n className: \"aui-root aui-modal-anchor\",\n});\n\nAssistantModalAnchor.displayName = \"AssistantModalAnchor\";\n\nconst ModalButtonStyled = withDefaults(TooltipIconButton, {\n variant: \"default\",\n className: \"aui-modal-button\",\n});\n\ntype AssistantModalButtonProps = TooltipIconButtonProps & {\n \"data-state\"?: \"open\" | \"closed\";\n};\n\nconst AssistantModalButton = forwardRef<\n HTMLButtonElement,\n Partial<AssistantModalButtonProps>\n>(({ \"data-state\": state, ...rest }, ref) => {\n const {\n strings: {\n assistantModal: {\n open: {\n button: { tooltip: openTooltip = \"Close Assistant\" } = {},\n } = {},\n closed: {\n button: { tooltip: closedTooltip = \"Open Assistant\" } = {},\n } = {},\n } = {},\n } = {},\n } = useThreadConfig();\n const tooltip = state === \"open\" ? openTooltip : closedTooltip;\n\n return (\n <ModalButtonStyled\n side=\"left\"\n tooltip={tooltip}\n data-state={state}\n {...rest}\n ref={ref}\n >\n {rest.children ?? (\n <>\n <BotIcon\n data-state={state}\n className=\"aui-modal-button-closed-icon\"\n />\n <ChevronDownIcon\n data-state={state}\n className=\"aui-modal-button-open-icon\"\n />\n </>\n )}\n </ModalButtonStyled>\n );\n});\n\nAssistantModalButton.displayName = \"AssistantModalButton\";\n\nconst AssistantModalContent = withDefaults(AssistantModalPrimitive.Content, {\n className: \"aui-root aui-modal-content\",\n sideOffset: 16,\n});\n\nAssistantModalContent.displayName = \"AssistantModalContent\";\n\nconst exports = {\n Root: AssistantModalRoot,\n Trigger: AssistantModalTrigger,\n Content: AssistantModalContent,\n};\n\nexport default Object.assign(AssistantModal, exports) as typeof AssistantModal &\n typeof exports;\n","\"use client\";\n\nimport { ComponentType, forwardRef, type FC } from \"react\";\nimport { ArrowDownIcon } from \"lucide-react\";\n\nimport { withDefaults } from \"./utils/withDefaults\";\nimport Composer from \"./composer\";\nimport ThreadWelcome from \"./thread-welcome\";\nimport {\n TooltipIconButton,\n TooltipIconButtonProps,\n} from \"./base/tooltip-icon-button\";\nimport AssistantMessage from \"./assistant-message\";\nimport UserMessage from \"./user-message\";\nimport EditComposer from \"./edit-composer\";\nimport {\n ThreadConfig,\n ThreadConfigProvider,\n ThreadConfigProviderProps,\n useThreadConfig,\n} from \"./thread-config\";\nimport { ThreadPrimitive, ThreadPrimitiveRootProps } from \"../primitives\";\n\nconst Thread: FC<ThreadConfig> = (config) => {\n return (\n <ThreadRoot config={config}>\n <ThreadViewport>\n <ThreadWelcome />\n <ThreadMessages />\n <ThreadViewportFooter>\n <ThreadScrollToBottom />\n <Composer />\n </ThreadViewportFooter>\n </ThreadViewport>\n </ThreadRoot>\n );\n};\n\nexport type ThreadRootProps = ThreadPrimitiveRootProps &\n ThreadConfigProviderProps;\n\nconst ThreadRootStyled = withDefaults(ThreadPrimitive.Root, {\n className: \"aui-root aui-thread-root\",\n});\n\nconst ThreadRoot = forwardRef<HTMLDivElement, ThreadRootProps>(\n ({ config, ...props }, ref) => {\n return (\n <ThreadConfigProvider config={config}>\n <ThreadRootStyled {...props} ref={ref} />\n </ThreadConfigProvider>\n );\n },\n);\n\nThreadRoot.displayName = \"ThreadRoot\";\n\nconst ThreadViewport = withDefaults(ThreadPrimitive.Viewport, {\n className: \"aui-thread-viewport\",\n});\n\nThreadViewport.displayName = \"ThreadViewport\";\n\nconst ThreadViewportFooter = withDefaults(\"div\", {\n className: \"aui-thread-viewport-footer\",\n});\n\nThreadViewportFooter.displayName = \"ThreadViewportFooter\";\n\nconst SystemMessage = () => null;\n\nconst ThreadMessages: FC<{\n components?: {\n UserMessage?: ComponentType | undefined;\n EditComposer?: ComponentType | undefined;\n AssistantMessage?: ComponentType | undefined;\n SystemMessage?: ComponentType | undefined;\n };\n}> = ({ components, ...rest }) => {\n return (\n <ThreadPrimitive.Messages\n components={{\n UserMessage: components?.UserMessage ?? UserMessage,\n EditComposer: components?.EditComposer ?? EditComposer,\n AssistantMessage: components?.AssistantMessage ?? AssistantMessage,\n SystemMessage: components?.SystemMessage ?? SystemMessage,\n }}\n {...rest}\n />\n );\n};\n\nThreadMessages.displayName = \"ThreadMessages\";\n\nconst ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {\n variant: \"outline\",\n className: \"aui-thread-scroll-to-bottom\",\n});\n\nconst ThreadScrollToBottom = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: {\n thread: { scrollToBottom: { tooltip = \"Scroll to bottom\" } = {} } = {},\n } = {},\n } = useThreadConfig();\n return (\n <ThreadPrimitive.ScrollToBottom asChild>\n <ThreadScrollToBottomIconButton tooltip={tooltip} {...props} ref={ref}>\n {props.children ?? <ArrowDownIcon />}\n </ThreadScrollToBottomIconButton>\n </ThreadPrimitive.ScrollToBottom>\n );\n});\n\nThreadScrollToBottom.displayName = \"ThreadScrollToBottom\";\n\nconst exports = {\n Root: ThreadRoot,\n Viewport: ThreadViewport,\n Messages: ThreadMessages,\n ScrollToBottom: ThreadScrollToBottom,\n ViewportFooter: ThreadViewportFooter,\n};\n\nexport default Object.assign(Thread, exports) as typeof Thread & typeof exports;\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, forwardRef, type FC } from \"react\";\n\nimport { SendHorizontalIcon } from \"lucide-react\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { useThreadConfig } from \"./thread-config\";\nimport {\n TooltipIconButton,\n TooltipIconButtonProps,\n} from \"./base/tooltip-icon-button\";\nimport { CircleStopIcon } from \"./base/CircleStopIcon\";\nimport { ComposerPrimitive, ThreadPrimitive } from \"../primitives\";\nimport { useThreadContext } from \"../context\";\n\nconst Composer: FC = () => {\n return (\n <ComposerRoot>\n <ComposerInput autoFocus />\n <ComposerAction />\n </ComposerRoot>\n );\n};\n\nComposer.displayName = \"Composer\";\n\nconst ComposerRoot = withDefaults(ComposerPrimitive.Root, {\n className: \"aui-composer-root\",\n});\n\nComposerRoot.displayName = \"ComposerRoot\";\n\nconst ComposerInputStyled = withDefaults(ComposerPrimitive.Input, {\n rows: 1,\n autoFocus: true,\n className: \"aui-composer-input\",\n});\n\nexport type ComposerInputProps = ComponentPropsWithoutRef<\n typeof ComposerInputStyled\n>;\nconst ComposerInput = forwardRef<HTMLTextAreaElement, ComposerInputProps>(\n (props, ref) => {\n const {\n strings: {\n composer: { input: { placeholder = \"Write a message...\" } = {} } = {},\n } = {},\n } = useThreadConfig();\n return (\n <ComposerInputStyled placeholder={placeholder} {...props} ref={ref} />\n );\n },\n);\n\nComposerInput.displayName = \"ComposerInput\";\n\nconst useAllowCancel = () => {\n const { useThreadActions } = useThreadContext();\n const cancelSupported = useThreadActions((t) => t.capabilities.cancel);\n return cancelSupported;\n};\n\nconst ComposerAction: FC = () => {\n const allowCancel = useAllowCancel();\n if (!allowCancel) return <ComposerSend />;\n return (\n <>\n <ThreadPrimitive.If running={false}>\n <ComposerSend />\n </ThreadPrimitive.If>\n <ThreadPrimitive.If running>\n <ComposerCancel />\n </ThreadPrimitive.If>\n </>\n );\n};\n\nComposerAction.displayName = \"ComposerAction\";\n\nconst ComposerSendButton = withDefaults(TooltipIconButton, {\n variant: \"default\",\n className: \"aui-composer-send\",\n});\n\nconst ComposerSend = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: { composer: { send: { tooltip = \"Send\" } = {} } = {} } = {},\n } = useThreadConfig();\n return (\n <ComposerPrimitive.Send asChild>\n <ComposerSendButton tooltip={tooltip} {...props} ref={ref}>\n {props.children ?? <SendHorizontalIcon />}\n </ComposerSendButton>\n </ComposerPrimitive.Send>\n );\n});\n\nComposerSend.displayName = \"ComposerSend\";\n\nconst ComposerCancelButton = withDefaults(TooltipIconButton, {\n variant: \"default\",\n className: \"aui-composer-cancel\",\n});\n\nconst ComposerCancel = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: { composer: { cancel: { tooltip = \"Cancel\" } = {} } = {} } = {},\n } = useThreadConfig();\n return (\n <ComposerPrimitive.Cancel asChild>\n <ComposerCancelButton tooltip={tooltip} {...props} ref={ref}>\n {props.children ?? <CircleStopIcon />}\n </ComposerCancelButton>\n </ComposerPrimitive.Cancel>\n );\n});\n\nComposerCancel.displayName = \"ComposerCancel\";\n\nconst exports = {\n Root: ComposerRoot,\n Input: ComposerInput,\n Action: ComposerAction,\n Send: ComposerSend,\n Cancel: ComposerCancel,\n};\n\nexport default Object.assign(Composer, exports) as typeof Composer &\n typeof exports;\n","import { FC } from \"react\";\n\nexport const CircleStopIcon: FC = () => {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n >\n <rect width=\"10\" height=\"10\" x=\"3\" y=\"3\" rx=\"2\" />\n </svg>\n );\n};\n\nCircleStopIcon.displayName = \"CircleStopIcon\";\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, forwardRef, type FC } from \"react\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { Avatar } from \"./base/avatar\";\nimport { SuggestionConfig, useThreadConfig } from \"./thread-config\";\nimport { ThreadPrimitive } from \"../primitives\";\n\nconst ThreadWelcome: FC = () => {\n return (\n <ThreadWelcomeRoot>\n <ThreadWelcomeCenter>\n <ThreadWelcomeAvatar />\n <ThreadWelcomeMessage />\n </ThreadWelcomeCenter>\n <ThreadWelcomeSuggestions />\n </ThreadWelcomeRoot>\n );\n};\n\nThreadWelcome.displayName = \"ThreadWelcome\";\n\nconst ThreadWelcomeRootStyled = withDefaults(\"div\", {\n className: \"aui-thread-welcome-root\",\n});\n\nconst ThreadWelcomeCenter = withDefaults(\"div\", {\n className: \"aui-thread-welcome-center\",\n});\n\ntype ThreadWelcomeRootProps = ComponentPropsWithoutRef<\"div\">;\n\nconst ThreadWelcomeRoot = forwardRef<HTMLDivElement, ThreadWelcomeRootProps>(\n (props, ref) => {\n return (\n <ThreadPrimitive.Empty>\n <ThreadWelcomeRootStyled {...props} ref={ref} />\n </ThreadPrimitive.Empty>\n );\n },\n);\n\nThreadWelcomeRoot.displayName = \"ThreadWelcomeRoot\";\n\nconst ThreadWelcomeAvatar: FC = () => {\n const { assistantAvatar: avatar = { fallback: \"A\" } } = useThreadConfig();\n return <Avatar {...avatar} />;\n};\n\nconst ThreadWelcomeMessageStyled = withDefaults(\"p\", {\n className: \"aui-thread-welcome-message\",\n});\n\nexport type ThreadWelcomeMessageProps = Omit<\n ComponentPropsWithoutRef<typeof ThreadWelcomeMessageStyled>,\n \"children\"\n> & { message?: string | undefined };\n\nconst ThreadWelcomeMessage = forwardRef<\n HTMLParagraphElement,\n ThreadWelcomeMessageProps\n>(({ message: messageProp, ...rest }, ref) => {\n const { welcome: { message = \"How can I help you today?\" } = {} } =\n useThreadConfig();\n return (\n <ThreadWelcomeMessageStyled {...rest} ref={ref}>\n {messageProp ?? message}\n </ThreadWelcomeMessageStyled>\n );\n});\n\nThreadWelcomeMessage.displayName = \"ThreadWelcomeMessage\";\n\nconst ThreadWelcomeSuggestionContainer = withDefaults(\"div\", {\n className: \"aui-thread-welcome-suggestion-container\",\n});\n\nconst ThreadWelcomeSuggestionStyled = withDefaults(ThreadPrimitive.Suggestion, {\n className: \"aui-thread-welcome-suggestion\",\n});\n\nexport type ThreadWelcomeSuggestionProps = {\n suggestion: SuggestionConfig;\n};\n\nconst ThreadWelcomeSuggestion: FC<ThreadWelcomeSuggestionProps> = ({\n suggestion: { text, prompt },\n}) => {\n return (\n <ThreadWelcomeSuggestionStyled\n prompt={prompt}\n method=\"replace\"\n autoSend\n >\n <span className=\"aui-thread-welcome-suggestion-text\">{text ?? prompt}</span>\n </ThreadWelcomeSuggestionStyled>\n );\n};\n\nconst ThreadWelcomeSuggestions: FC = () => {\n const { welcome: { suggestions } = {} } = useThreadConfig();\n return (\n <ThreadWelcomeSuggestionContainer>\n {suggestions?.map((suggestion, idx) => {\n const key = `${suggestion.prompt}-${idx}`;\n return <ThreadWelcomeSuggestion key={key} suggestion={suggestion} />;\n })}\n </ThreadWelcomeSuggestionContainer>\n );\n};\n\nThreadWelcomeSuggestions.displayName = \"ThreadWelcomeSuggestions\";\n\nconst exports = {\n Root: ThreadWelcomeRoot,\n Center: ThreadWelcomeCenter,\n Avatar: ThreadWelcomeAvatar,\n Message: ThreadWelcomeMessage,\n Suggestions: ThreadWelcomeSuggestions,\n Suggestion: ThreadWelcomeSuggestion,\n};\n\nexport default Object.assign(ThreadWelcome, exports) as typeof ThreadWelcome &\n typeof exports;\n","\"use client\";\n\nimport { ComponentPropsWithoutRef, forwardRef, type FC } from \"react\";\n\nimport BranchPicker from \"./branch-picker\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport UserActionBar from \"./user-action-bar\";\nimport ContentPart from \"./content-part\";\nimport { MessagePrimitive, MessagePrimitiveContentProps } from \"../primitives\";\n\nconst UserMessage: FC = () => {\n return (\n <UserMessageRoot>\n <UserActionBar />\n <UserMessageContent />\n <BranchPicker />\n </UserMessageRoot>\n );\n};\n\nUserMessage.displayName = \"UserMessage\";\n\nconst UserMessageRoot = withDefaults(MessagePrimitive.Root, {\n className: \"aui-user-message-root\",\n});\n\nUserMessageRoot.displayName = \"UserMessageRoot\";\n\nconst UserMessageContentWrapper = withDefaults(\"div\", {\n className: \"aui-user-message-content\",\n});\n\nexport type UserMessageContentProps = MessagePrimitiveContentProps &\n ComponentPropsWithoutRef<\"div\">;\n\nconst UserMessageContent = forwardRef<HTMLDivElement, UserMessageContentProps>(\n ({ components, ...props }, ref) => {\n return (\n <UserMessageContentWrapper {...props} ref={ref}>\n <MessagePrimitive.Content\n components={{\n ...components,\n Text: components?.Text ?? ContentPart.Text,\n }}\n />\n </UserMessageContentWrapper>\n );\n },\n);\n\nUserMessageContent.displayName = \"UserMessageContent\";\n\nconst exports = {\n Root: UserMessageRoot,\n Content: UserMessageContent,\n};\n\nexport default Object.assign(UserMessage, exports) as typeof UserMessage &\n typeof exports;\n","\"use client\";\n\nimport { forwardRef, type FC } from \"react\";\nimport { PencilIcon } from \"lucide-react\";\n\nimport {\n TooltipIconButton,\n TooltipIconButtonProps,\n} from \"./base/tooltip-icon-button\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { useThreadConfig } from \"./thread-config\";\nimport { useThreadContext } from \"../context\";\nimport { ActionBarPrimitive } from \"../primitives\";\n\nconst useAllowEdit = () => {\n const { userMessage: { allowEdit = true } = {} } = useThreadConfig();\n const { useThreadActions } = useThreadContext();\n const editSupported = useThreadActions((t) => t.capabilities.edit);\n return editSupported && allowEdit;\n};\n\nconst UserActionBar: FC = () => {\n const allowEdit = useAllowEdit();\n if (!allowEdit) return null;\n return (\n <UserActionBarRoot hideWhenRunning autohide=\"not-last\">\n <UserActionBarEdit />\n </UserActionBarRoot>\n );\n};\n\nUserActionBar.displayName = \"UserActionBar\";\n\nconst UserActionBarRoot = withDefaults(ActionBarPrimitive.Root, {\n className: \"aui-user-action-bar-root\",\n});\n\nUserActionBarRoot.displayName = \"UserActionBarRoot\";\n\nconst UserActionBarEdit = forwardRef<\n HTMLButtonElement,\n Partial<TooltipIconButtonProps>\n>((props, ref) => {\n const {\n strings: { userMessage: { edit: { tooltip = \"Edit\" } = {} } = {} } = {},\n } = useThreadConfig();\n const allowEdit = useAllowEdit();\n if (!allowEdit) return null;\n return (\n <ActionBarPrimitive.Edit asChild>\n <TooltipIconButton tooltip={tooltip} {...props} ref={ref}>\n {props.children ?? <PencilIcon />}\n </TooltipIconButton>\n </ActionBarPrimitive.Edit>\n );\n});\n\nUserActionBarEdit.displayName = \"UserActionBarEdit\";\n\nconst exports = {\n Root: UserActionBarRoot,\n Edit: UserActionBarEdit,\n};\n\nexport default Object.assign(UserActionBar, exports) as typeof UserActionBar &\n typeof exports;\n","\"use client\";\n\nimport { forwardRef, type FC } from \"react\";\n\nimport { Button, ButtonProps } from \"./base/button\";\nimport { withDefaults } from \"./utils/withDefaults\";\nimport { useThreadConfig } from \"./thread-config\";\nimport { ComposerPrimitive } from \"../primitives\";\n\nconst EditComposer: FC = () => {\n return (\n <EditComposerRoot>\n <EditComposerInput />\n\n <EditComposerFooter>\n <EditComposerCancel />\n <EditComposerSend />\n </EditComposerFooter>\n </EditComposerRoot>\n );\n};\n\nEditComposer.displayName = \"EditComposer\";\n\nconst EditComposerRoot = withDefaults(ComposerPrimitive.Root, {\n className: \"aui-edit-composer-root\",\n});\n\nEditComposerRoot.displayName = \"EditComposerRoot\";\n\nconst EditComposerInput = withDefaults(ComposerPrimitive.Input, {\n className: \"aui-edit-composer-input\",\n});\n\nEditComposerInput.displayName = \"EditComposerInput\";\n\nconst EditComposerFooter = withDefaults(\"div\", {\n className: \"aui-edit-composer-footer\",\n});\n\nEditComposerFooter.displayName = \"EditComposerFooter\";\n\nconst EditComposerCancel = forwardRef<HTMLButtonElement, Partial<ButtonProps>>(\n (props, ref) => {\n const {\n strings: {\n editComposer: { cancel: { label = \"Cancel\" } = {} } = {},\n } = {},\n } = useThreadConfig();\n return (\n <ComposerPrimitive.Cancel asChild>\n <Button variant=\"ghost\" {...props} ref={ref}>\n {props.children ?? label}\n </Button>\n </ComposerPrimitive.Cancel>\n );\n },\n);\n\nEditComposerCancel.displayName = \"EditComposerCancel\";\n\nconst EditComposerSend = forwardRef<HTMLButtonElement, Partial<ButtonProps>>(\n (props, ref) => {\n const {\n strings: { editComposer: { send: { label = \"Send\" } = {} } = {} } = {},\n } = useThreadConfig();\n return (\n <ComposerPrimitive.Send asChild>\n <Button {...props} ref={ref}>\n {props.children ?? label}\n </Button>\n </ComposerPrimitive.Send>\n );\n },\n);\n\nEditComposerSend.displayName = \"EditComposerSend\";\n\nconst exports = {\n Root: EditComposerRoot,\n Input: EditComposerInput,\n Footer: EditComposerFooter,\n Cancel: EditComposerCancel,\n Send: EditComposerSend,\n};\n\nexport default Object.assign(EditComposer, exports) as typeof EditComposer &\n typeof exports;\n"],"mappings":";;;;;;;;;;;;;;;AACA,SAAS,YAAY;;;ACErB,SAAS,WAAW,sBAAAA,qBAAoB,UAAAC,SAAQ,YAAAC,iBAAgB;;;ACDhE,SAAS,eAAe,kBAAkB;AAYnC,IAAM,mBAAmB;AAAA,EAC9B;AACF;AAMO,SAAS,oBAAoB,SAA8B;AAChE,QAAM,UAAU,WAAW,gBAAgB;AAC3C,MAAI,CAAC,SAAS,YAAY,CAAC;AACzB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;;;AC3BA,SAAS,cAAc;;;ACIhB,IAAM,sBAAN,MAAyD;AAAA,EACtD,aAAa,oBAAI,IAAyB;AAAA,EAElD,iBAAiB;AACf,WAAO,kBAAkB,KAAK,UAAU;AAAA,EAC1C;AAAA,EAEA,4BAA4B,UAA+B;AACzD,SAAK,WAAW,IAAI,QAAQ;AAC5B,WAAO,MAAM;AACX,WAAK,WAAW,OAAO,QAAQ;AAAA,IACjC;AAAA,EACF;AACF;;;ADPO,IAAM,gCAAgC,MAC3C,OAAkC,MAAM;AACtC,QAAM,QAAQ,IAAI,oBAAoB;AAEtC,SAAO,OAAO,OAAO;A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AQ,EAAE,SAAS,cAAc,kBAAkB,IAAI,CAAC;AAAA,QAC1D,IAAI,CAAC;AAAA,QACL,QAAQ;AAAA,UACN,QAAQ,EAAE,SAAS,gBAAgB,iBAAiB,IAAI,CAAC;AAAA,QAC3D,IAAI,CAAC;AAAA,MACP,IAAI,CAAC;AAAA,IACP,IAAI,CAAC;AAAA,EACP,IAAI,gBAAgB;AACpB,QAAM,UAAU,UAAU,SAAS,cAAc;AAEjD,SACE,gBAAAF;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL;AAAA,MACA,cAAY;AAAA,MACX,GAAG;AAAA,MACJ;AAAA,MAEC,eAAK,YACJ,gBAAAC,OAAAF,WAAA,EACE;AAAA,wBAAAC;AAAA,UAAC;AAAA;AAAA,YACC,cAAY;AAAA,YACZ,WAAU;AAAA;AAAA,QACZ;AAAA,QACA,gBAAAA;AAAA,UAAC;AAAA;AAAA,YACC,cAAY;AAAA,YACZ,WAAU;AAAA;AAAA,QACZ;AAAA,SACF;AAAA;AAAA,EAEJ;AAEJ,CAAC;AAED,qBAAqB,cAAc;AAEnC,IAAM,wBAAwB,aAAa,uBAAwB,SAAS;AAAA,EAC1E,WAAW;AAAA,EACX,YAAY;AACd,CAAC;AAED,sBAAsB,cAAc;AAEpC,IAAMG,YAAU;AAAA,EACd,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AACX;AAEA,IAAO,0BAAQ,OAAO,OAAO,gBAAgBA,SAAO;","names":["useInsertionEffect","useRef","useState","create","useCallback","createContext","useContext","create","create","create","create","create","create","create","useCallback","create","jsx","useRef","useInsertionEffect","useState","jsx","createContext","useContext","createContext","useContext","useCallback","useCallback","useCallback","useCallback","useEffect","useEffect","useEffect","useEffect","useEffect","useEffect","useCallback","useMemo","useMemo","c","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","useCallback","jsx","forwardRef","Primitive","jsx","useState","PopoverPrimitive","composeEventHandlers","useEffect","useEffect","jsx","useState","composeEventHandlers","forwardRef","PopoverPrimitive","jsx","forwardRef","forwardRef","PopoverPrimitive","composeEventHandlers","jsx","forwardRef","forwardRef","PopoverPrimitive","jsx","forwardRef","jsx","Fragment","jsx","Primitive","forwardRef","Primitive","forwardRef","useCallback","jsx","useCallback","forwardRef","Primitive","memo","useEffect","useState","create","jsx","useContentPartContext","useState","create","useEffect","forwardRef","useEffect","useMemo","useRef","useState","createContext","forwardRef","useContext","useState","create","jsx","createContext","useSmoothStatus","useState","forwardRef","useContext","useCallbackRef","useSmoothStatus","useRef","useState","text","useEffect","useMemo","jsx","forwardRef","Primitive","forwardRef","jsx","forwardRef","Primitive","jsx","jsxs","Text","Image","Fallback","memo","jsx","forwardRef","Primitive","composeEventHandlers","Primitive","forwardRef","jsx","forwardRef","Primitive","composeEventHandlers","composeEventHandlers","useComposedRefs","forwardRef","useCallback","useEffect","useRef","jsx","forwardRef","useRef","useComposedRefs","useCallback","useEffect","composeEventHandlers","forwardRef","Primitive","jsx","forwardRef","Primitive","forwardRef","jsx","useComposedRefs","Primitive","forwardRef","useComposedRefs","useRef","useCallbackRef","useCallback","useCallbackRef","useCallback","useCallbackRef","useEffect","useCallbackRef","useEffect","useRef","useComposedRefs","jsx","forwardRef","useComposedRefs","Primitive","memo","useEffect","useState","create","create","create","create","jsx","useMessageContext","useState","create","useEffect","jsx","jsxs","UserMessage","EditComposer","AssistantMessage","SystemMessage","memo","useInsertionEffect","useState","message","forwardRef","forwardRef","jsx","jsx","Primitive","forwardRef","jsx","jsx","jsxs","forwardRef","useState","useState","useState","useInsertionEffect","create","useEffect","useInsertionEffect","useMemo","useRef","useRef","useInsertionEffect","useMemo","converter","convertCallback","useEffect","create","useEffect","useInsertionEffect","useState","useState","useInsertionEffect","useEffect","createContext","useContext","Fragment","jsx","createContext","useContext","forwardRef","Fragment","jsx","jsxs","forwardRef","forwardRef","forwardRef","jsx","jsxs","BranchPickerPrevious","forwardRef","exports","jsx","jsxs","classNames","jsx","exports","jsx","jsxs","forwardRef","exports","forwardRef","forwardRef","forwardRef","jsx","Fragment","jsx","jsxs","forwardRef","exports","forwardRef","jsx","jsxs","forwardRef","exports","forwardRef","forwardRef","jsx","forwardRef","exports","jsx","jsxs","forwardRef","exports","forwardRef","jsx","jsxs","forwardRef","exports","jsx","jsxs","forwardRef","exports","Fragment","jsx","jsxs","forwardRef","exports"]}