@assistant-ui/react 0.5.22 → 0.5.24

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/assistant-ui/assistant-ui/packages/react/dist/index.js","../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"],"names":["create","createContext","useContext","useCallback","useRef","useInsertionEffect","useState","jsx","useEffect","useMemo","c","forwardRef","Primitive","composeEventHandlers","Fragment","useContentPartContext","useSmoothStatus","useCallbackRef","text","jsxs","Text","Image","Fallback","memo","BranchPickerPrevious","classNames","exports"],"mappings":"AAAA,spCAAY;AACZ;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACbA,8BAAqB;ADerB;AACA;AEdA;AFgBA;AACA;AGlBA;AAYO,IAAM,iBAAA,EAAmB,kCAAA;AAAA,EAC9B;AACF,CAAA;AAMO,SAAS,mBAAA,CAAoB,OAAA,EAA8B;AAChE,EAAA,MAAM,QAAA,EAAU,+BAAA,gBAA2B,CAAA;AAC3C,EAAA,GAAA,CAAI,iBAAC,OAAA,6BAAS,WAAA,GAAY,CAAC,OAAA;AACzB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,IACF,CAAA;AACF,EAAA,OAAO,OAAA;AACT;AHIA;AACA;AIhCA,kCAAuB;AJkCvB;AACA;AK/BO,IAAM,oBAAA,YAAN,MAAyD;AAAA,iBACtD,WAAA,kBAAa,IAAI,GAAA,CAAyB,EAAA;AAAA,EAElD,cAAA,CAAA,EAAiB;AACf,IAAA,OAAO,gDAAA,IAAkB,CAAK,UAAU,CAAA;AAAA,EAC1C;AAAA,EAEA,2BAAA,CAA4B,QAAA,EAA+B;AACzD,IAAA,IAAA,CAAK,UAAA,CAAW,GAAA,CAAI,QAAQ,CAAA;AAC5B,IAAA,OAAO,CAAA,EAAA,GAAM;AACX,MAAA,IAAA,CAAK,U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mB;AvI4pHqB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/assistant-ui/assistant-ui/packages/react/dist/index.js","sourcesContent":[null,"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"]}
1
+ {"version":3,"sources":["/home/runner/work/assistant-ui/assistant-ui/packages/react/dist/index.js","../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/getExternalStoreMessage.tsx","../src/runtimes/external-store/ThreadMessageConverter.ts","../src/runtimes/external-store/auto-status.tsx","../src/runtimes/external-store/ThreadMessageLike.tsx","../src/runtimes/external-store/ExternalStoreThreadRuntime.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"],"names":["create","createContext","useContext","useCallback","useRef","useInsertionEffect","useState","jsx","useEffect","useMemo","c","forwardRef","Primitive","composeEventHandlers","Fragment","useContentPartContext","useSmoothStatus","useCallbackRef","text","jsxs","Text","Image","Fallback","memo","BranchPickerPrevious","classNames","exports"],"mappings":"AAAA,spCAAY;AACZ;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACbA,8BAAqB;ADerB;AACA;AEdA;AFgBA;AACA;AGlBA;AAYO,IAAM,iBAAA,EAAmB,kCAAA;AAAA,EAC9B;AACF,CAAA;AAMO,SAAS,mBAAA,CAAoB,OAAA,EAA8B;AAChE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AA;AACoD,UAAA;AACrD,QAAA;AACG,QAAA;AACkD,UAAA;AACrD,QAAA;AACF,MAAA;AACF,IAAA;AACa,EAAA;AAC6B,EAAA;AAG/CZ,EAAAA;AAAC,IAAA;AAAA,IAAA;AACM,MAAA;AACL,MAAA;AACY,MAAA;AACR,MAAA;AACJ,MAAA;AAGEO,MAAAA;AACEP,wBAAAA;AAAC,UAAA;AAAA,UAAA;AACa,YAAA;AACF,YAAA;AAAA,UAAA;AACZ,QAAA;AACAA,wBAAAA;AAAC,UAAA;AAAA,UAAA;AACa,YAAA;AACF,YAAA;AAAA,UAAA;AACZ,QAAA;AACF,MAAA;AAAA,IAAA;AAEJ,EAAA;AAEH;AAEkC;AAEgC;AACtD,EAAA;AACC,EAAA;AACb;AAEmC;AAEpB;AACR,EAAA;AACG,EAAA;AACA,EAAA;AACX;AAE6CmB;AtIqpHqB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/assistant-ui/assistant-ui/packages/react/dist/index.js","sourcesContent":[null,"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 // ensure the child is not part of parent tree\n for (\n let current: RepositoryMessage | null = newParent;\n current;\n current = current.prev\n ) {\n if (current.current.id === child.current.id) {\n throw new Error(\n \"MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.\",\n );\n }\n }\n\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 { 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 { 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","import { MessageStatus } from \"../../types\";\n\nconst AUTO_STATUS_RUNNING = Object.freeze({ type: \"running\" });\nconst AUTO_STATUS_COMPLETE = Object.freeze({\n type: \"complete\",\n reason: \"unknown\",\n});\n\nexport const isAutoStatus = (status: MessageStatus) =>\n status === AUTO_STATUS_RUNNING || status === AUTO_STATUS_COMPLETE;\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 { ReactThreadRuntime } from \"../core\";\nimport { MessageRepository } from \"../utils/MessageRepository\";\nimport { AppendMessage, ThreadMessage, Unsubscribe } from \"../../types\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport { AddToolResultOptions } from \"../../context\";\nimport {\n getExternalStoreMessage,\n symbolInnerMessage,\n} from \"./getExternalStoreMessage\";\nimport {\n ConverterCallback,\n ThreadMessageConverter,\n} from \"./ThreadMessageConverter\";\nimport { getAutoStatus, isAutoStatus } from \"./auto-status\";\nimport { fromThreadMessageLike } from \"./ThreadMessageLike\";\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 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 public converter = new ThreadMessageConverter();\n\n private _store!: ExternalStoreAdapter<any>;\n\n constructor(store: ExternalStoreAdapter<any>) {\n this.store = store;\n }\n\n public set store(store: ExternalStoreAdapter<any>) {\n const oldStore = this._store as ExternalStoreAdapter<any> | undefined;\n\n // flush the converter cache when the convertMessage prop changes\n if (oldStore) {\n if (oldStore.convertMessage !== store.convertMessage) {\n this.converter = new ThreadMessageConverter();\n } else if (\n oldStore.isDisabled === store.isDisabled &&\n oldStore.isRunning === store.isRunning &&\n oldStore.messages === store.messages\n ) {\n // no update needed\n return;\n }\n }\n\n this._store = store;\n const isRunning = store.isRunning ?? false;\n const isDisabled = store.isDisabled ?? false;\n\n const convertCallback: ConverterCallback<any> = (cache, m, idx) => {\n if (!store.convertMessage) return m;\n\n const isLast = idx === store.messages.length - 1;\n const autoStatus = getAutoStatus(isLast, isRunning);\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n )\n return cache;\n\n const newMessage = fromThreadMessageLike(\n store.convertMessage(m, idx),\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = m;\n return newMessage;\n };\n\n const messages = this.converter.convertMessages(\n store.messages,\n convertCallback,\n );\n\n for (let i = 0; i < messages.length; i++) {\n const message = messages[i]!;\n const parent = messages[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, messages)) {\n this.assistantOptimisticId = this.repository.appendOptimisticMessage(\n messages.at(-1)?.id ?? null,\n {\n role: \"assistant\",\n content: [],\n },\n );\n }\n\n this.repository.resetHead(\n this.assistantOptimisticId ?? messages.at(-1)?.id ?? null,\n );\n\n this.messages = this.repository.getMessages();\n this.isDisabled = isDisabled;\n this.isRunning = isRunning;\n for (const callback of this._subscriptions) callback();\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 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 { 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 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 { useInsertionEffect, useState } from \"react\";\nimport { ExternalStoreRuntime } from \"./ExternalStoreRuntime\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\n\nexport const useExternalStoreRuntime = <T,>(store: ExternalStoreAdapter<T>) => {\n const [runtime] = useState(() => new ExternalStoreRuntime(store));\n\n useInsertionEffect(() => {\n runtime.store = store;\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"]}