@assistant-ui/react 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -131,6 +131,9 @@ export type ThreadConfig = {
131
131
  strings?: StringsConfig | undefined;
132
132
  tools?: AssistantToolUI[] | undefined;
133
133
  components?: {
134
+ UserMessage?: ComponentType | undefined;
135
+ AssistantMessage?: ComponentType | undefined;
136
+ EditComposer?: ComponentType | undefined;
134
137
  Composer?: ComponentType | undefined;
135
138
  ThreadWelcome?: ComponentType | undefined;
136
139
  } | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"thread-config.d.ts","sourceRoot":"","sources":["../../src/ui/thread-config.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,EAAE,EACF,iBAAiB,EACjB,SAAS,EAGV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAE9E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC,WAAW,CAAC,EAAE,gBAAgB,EAAE,GAAG,SAAS,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,UAAU,CAA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O,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;IAC1C,gBAAgB,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;IACtD,WAAW,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAE5C,YAAY,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAE9C,QAAQ,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IAEtC,OAAO,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAEpC,KAAK,CAAC,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC;IAEtC,UAAU,CAAC,EACP;QACE,WAAW,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;QACxC,gBAAgB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;QAC7C,YAAY,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;QACzC,QAAQ,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;QACrC,aAAa,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;KAC3C,GACD,SAAS,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,eAAe,QAAO,IAAI,CAAC,YAAY,EAAE,SAAS,CAE9D,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,CAAC;IACxD,MAAM,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACnC,CAAC,CAAC;AAEH,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,yBAAyB,CA0B9D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ui/thread-config.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ComponentType,\n FC,\n PropsWithChildren,\n ReactNode,\n createContext,\n useContext,\n} from \"react\";\n\nimport { AssistantRuntime } from \"../api/AssistantRuntime\";\nimport { AvatarProps } from \"./base/avatar\";\nimport { TextContentPartComponent, ToolCallContentPartProps } from \"../types\";\nimport { AssistantRuntimeProvider } from \"../context\";\nimport { AssistantToolUI } from \"../model-config\";\nimport { useAssistantRuntime } from \"../context/react/AssistantContext\";\n\nexport type SuggestionConfig = {\n text?: ReactNode | undefined;\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 allowSpeak?: boolean | undefined;\n allowFeedbackPositive?: boolean | undefined;\n allowFeedbackNegative?: boolean | undefined;\n components?:\n | {\n Text?: TextContentPartComponent | undefined;\n ToolFallback?: ComponentType<ToolCallContentPartProps> | undefined;\n }\n | undefined;\n};\n\nexport type BranchPickerConfig = {\n allowBranchPicker?: boolean | undefined;\n};\n\nexport type ComposerConfig = {\n allowAttachments?: 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 welcome?: {\n message?: string | undefined;\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 speak?: {\n tooltip?: string | undefined;\n stop?: {\n tooltip?: string | undefined;\n };\n };\n feedback?: {\n positive?: {\n tooltip?: string | undefined;\n };\n negative?: {\n tooltip?: string | undefined;\n };\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 addAttachment?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n removeAttachment?: {\n tooltip?: string | undefined;\n };\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 | undefined;\n\n assistantAvatar?: AvatarProps | undefined;\n\n welcome?: ThreadWelcomeConfig | undefined;\n assistantMessage?: AssistantMessageConfig | undefined;\n userMessage?: UserMessageConfig | undefined;\n\n branchPicker?: BranchPickerConfig | undefined;\n\n composer?: ComposerConfig | undefined;\n\n strings?: StringsConfig | undefined;\n\n tools?: AssistantToolUI[] | undefined; // TODO add AssistantTool support\n\n components?:\n | {\n Composer?: ComponentType | undefined;\n ThreadWelcome?: ComponentType | undefined;\n }\n | undefined;\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 hasAssistant = !!useAssistantRuntime({ 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 (hasAssistant) {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAOO;AAKP,qBAAyC;AAEzC,8BAAoC;AAiL9B;AA3CN,IAAM,0BAAsB,4BAA4B,CAAC,CAAC;AA2BnD,IAAM,kBAAkB,MAAqC;AAClE,aAAO,yBAAW,mBAAmB;AACvC;AAMO,IAAM,uBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,eAAe,CAAC,KAAC,6CAAoB,EAAE,UAAU,KAAK,CAAC;AAE7D,QAAM,iBACJ,UAAU,OAAO,KAAK,UAAU,CAAC,CAAC,EAAE,SAAS,IAC3C,4CAAC,oBAAoB,UAApB,EAA6B,OAAO,QAClC,UACH,IAEA,2EAAG,UAAS;AAEhB,MAAI,CAAC,QAAQ,QAAS,QAAO;AAE7B,MAAI,cAAc;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SACE,4CAAC,2CAAyB,SAAS,OAAO,SACvC,0BACH;AAEJ;AAEA,qBAAqB,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/ui/thread-config.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ComponentType,\n FC,\n PropsWithChildren,\n ReactNode,\n createContext,\n useContext,\n} from \"react\";\n\nimport { AssistantRuntime } from \"../api/AssistantRuntime\";\nimport { AvatarProps } from \"./base/avatar\";\nimport { TextContentPartComponent, ToolCallContentPartProps } from \"../types\";\nimport { AssistantRuntimeProvider } from \"../context\";\nimport { AssistantToolUI } from \"../model-config\";\nimport { useAssistantRuntime } from \"../context/react/AssistantContext\";\n\nexport type SuggestionConfig = {\n text?: ReactNode | undefined;\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 allowSpeak?: boolean | undefined;\n allowFeedbackPositive?: boolean | undefined;\n allowFeedbackNegative?: boolean | undefined;\n components?:\n | {\n Text?: TextContentPartComponent | undefined;\n ToolFallback?: ComponentType<ToolCallContentPartProps> | undefined;\n }\n | undefined;\n};\n\nexport type BranchPickerConfig = {\n allowBranchPicker?: boolean | undefined;\n};\n\nexport type ComposerConfig = {\n allowAttachments?: 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 welcome?: {\n message?: string | undefined;\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 speak?: {\n tooltip?: string | undefined;\n stop?: {\n tooltip?: string | undefined;\n };\n };\n feedback?: {\n positive?: {\n tooltip?: string | undefined;\n };\n negative?: {\n tooltip?: string | undefined;\n };\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 addAttachment?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n removeAttachment?: {\n tooltip?: string | undefined;\n };\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 | undefined;\n\n assistantAvatar?: AvatarProps | undefined;\n\n welcome?: ThreadWelcomeConfig | undefined;\n assistantMessage?: AssistantMessageConfig | undefined;\n userMessage?: UserMessageConfig | undefined;\n\n branchPicker?: BranchPickerConfig | undefined;\n\n composer?: ComposerConfig | undefined;\n\n strings?: StringsConfig | undefined;\n\n tools?: AssistantToolUI[] | undefined; // TODO add AssistantTool support\n\n components?:\n | {\n UserMessage?: ComponentType | undefined;\n AssistantMessage?: ComponentType | undefined;\n EditComposer?: ComponentType | undefined;\n Composer?: ComponentType | undefined;\n ThreadWelcome?: ComponentType | undefined;\n }\n | undefined;\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 hasAssistant = !!useAssistantRuntime({ 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 (hasAssistant) {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAOO;AAKP,qBAAyC;AAEzC,8BAAoC;AAoL9B;AA9CN,IAAM,0BAAsB,4BAA4B,CAAC,CAAC;AA8BnD,IAAM,kBAAkB,MAAqC;AAClE,aAAO,yBAAW,mBAAmB;AACvC;AAMO,IAAM,uBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,eAAe,CAAC,KAAC,6CAAoB,EAAE,UAAU,KAAK,CAAC;AAE7D,QAAM,iBACJ,UAAU,OAAO,KAAK,UAAU,CAAC,CAAC,EAAE,SAAS,IAC3C,4CAAC,oBAAoB,UAApB,EAA6B,OAAO,QAClC,UACH,IAEA,2EAAG,UAAS;AAEhB,MAAI,CAAC,QAAQ,QAAS,QAAO;AAE7B,MAAI,cAAc;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SACE,4CAAC,2CAAyB,SAAS,OAAO,SACvC,0BACH;AAEJ;AAEA,qBAAqB,cAAc;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ui/thread-config.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ComponentType,\n FC,\n PropsWithChildren,\n ReactNode,\n createContext,\n useContext,\n} from \"react\";\n\nimport { AssistantRuntime } from \"../api/AssistantRuntime\";\nimport { AvatarProps } from \"./base/avatar\";\nimport { TextContentPartComponent, ToolCallContentPartProps } from \"../types\";\nimport { AssistantRuntimeProvider } from \"../context\";\nimport { AssistantToolUI } from \"../model-config\";\nimport { useAssistantRuntime } from \"../context/react/AssistantContext\";\n\nexport type SuggestionConfig = {\n text?: ReactNode | undefined;\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 allowSpeak?: boolean | undefined;\n allowFeedbackPositive?: boolean | undefined;\n allowFeedbackNegative?: boolean | undefined;\n components?:\n | {\n Text?: TextContentPartComponent | undefined;\n ToolFallback?: ComponentType<ToolCallContentPartProps> | undefined;\n }\n | undefined;\n};\n\nexport type BranchPickerConfig = {\n allowBranchPicker?: boolean | undefined;\n};\n\nexport type ComposerConfig = {\n allowAttachments?: 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 welcome?: {\n message?: string | undefined;\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 speak?: {\n tooltip?: string | undefined;\n stop?: {\n tooltip?: string | undefined;\n };\n };\n feedback?: {\n positive?: {\n tooltip?: string | undefined;\n };\n negative?: {\n tooltip?: string | undefined;\n };\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 addAttachment?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n removeAttachment?: {\n tooltip?: string | undefined;\n };\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 | undefined;\n\n assistantAvatar?: AvatarProps | undefined;\n\n welcome?: ThreadWelcomeConfig | undefined;\n assistantMessage?: AssistantMessageConfig | undefined;\n userMessage?: UserMessageConfig | undefined;\n\n branchPicker?: BranchPickerConfig | undefined;\n\n composer?: ComposerConfig | undefined;\n\n strings?: StringsConfig | undefined;\n\n tools?: AssistantToolUI[] | undefined; // TODO add AssistantTool support\n\n components?:\n | {\n Composer?: ComponentType | undefined;\n ThreadWelcome?: ComponentType | undefined;\n }\n | undefined;\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 hasAssistant = !!useAssistantRuntime({ 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 (hasAssistant) {\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"],"mappings":";;;AAEA;AAAA,EAKE;AAAA,EACA;AAAA,OACK;AAKP,SAAS,gCAAgC;AAEzC,SAAS,2BAA2B;AAiL9B,SAIA,UAJA;AA3CN,IAAM,sBAAsB,cAA4B,CAAC,CAAC;AA2BnD,IAAM,kBAAkB,MAAqC;AAClE,SAAO,WAAW,mBAAmB;AACvC;AAMO,IAAM,uBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,eAAe,CAAC,CAAC,oBAAoB,EAAE,UAAU,KAAK,CAAC;AAE7D,QAAM,iBACJ,UAAU,OAAO,KAAK,UAAU,CAAC,CAAC,EAAE,SAAS,IAC3C,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,QAClC,UACH,IAEA,gCAAG,UAAS;AAEhB,MAAI,CAAC,QAAQ,QAAS,QAAO;AAE7B,MAAI,cAAc;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SACE,oBAAC,4BAAyB,SAAS,OAAO,SACvC,0BACH;AAEJ;AAEA,qBAAqB,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/ui/thread-config.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ComponentType,\n FC,\n PropsWithChildren,\n ReactNode,\n createContext,\n useContext,\n} from \"react\";\n\nimport { AssistantRuntime } from \"../api/AssistantRuntime\";\nimport { AvatarProps } from \"./base/avatar\";\nimport { TextContentPartComponent, ToolCallContentPartProps } from \"../types\";\nimport { AssistantRuntimeProvider } from \"../context\";\nimport { AssistantToolUI } from \"../model-config\";\nimport { useAssistantRuntime } from \"../context/react/AssistantContext\";\n\nexport type SuggestionConfig = {\n text?: ReactNode | undefined;\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 allowSpeak?: boolean | undefined;\n allowFeedbackPositive?: boolean | undefined;\n allowFeedbackNegative?: boolean | undefined;\n components?:\n | {\n Text?: TextContentPartComponent | undefined;\n ToolFallback?: ComponentType<ToolCallContentPartProps> | undefined;\n }\n | undefined;\n};\n\nexport type BranchPickerConfig = {\n allowBranchPicker?: boolean | undefined;\n};\n\nexport type ComposerConfig = {\n allowAttachments?: 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 welcome?: {\n message?: string | undefined;\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 speak?: {\n tooltip?: string | undefined;\n stop?: {\n tooltip?: string | undefined;\n };\n };\n feedback?: {\n positive?: {\n tooltip?: string | undefined;\n };\n negative?: {\n tooltip?: string | undefined;\n };\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 addAttachment?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n removeAttachment?: {\n tooltip?: string | undefined;\n };\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 | undefined;\n\n assistantAvatar?: AvatarProps | undefined;\n\n welcome?: ThreadWelcomeConfig | undefined;\n assistantMessage?: AssistantMessageConfig | undefined;\n userMessage?: UserMessageConfig | undefined;\n\n branchPicker?: BranchPickerConfig | undefined;\n\n composer?: ComposerConfig | undefined;\n\n strings?: StringsConfig | undefined;\n\n tools?: AssistantToolUI[] | undefined; // TODO add AssistantTool support\n\n components?:\n | {\n UserMessage?: ComponentType | undefined;\n AssistantMessage?: ComponentType | undefined;\n EditComposer?: ComponentType | undefined;\n Composer?: ComponentType | undefined;\n ThreadWelcome?: ComponentType | undefined;\n }\n | undefined;\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 hasAssistant = !!useAssistantRuntime({ 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 (hasAssistant) {\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"],"mappings":";;;AAEA;AAAA,EAKE;AAAA,EACA;AAAA,OACK;AAKP,SAAS,gCAAgC;AAEzC,SAAS,2BAA2B;AAoL9B,SAIA,UAJA;AA9CN,IAAM,sBAAsB,cAA4B,CAAC,CAAC;AA8BnD,IAAM,kBAAkB,MAAqC;AAClE,SAAO,WAAW,mBAAmB;AACvC;AAMO,IAAM,uBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,eAAe,CAAC,CAAC,oBAAoB,EAAE,UAAU,KAAK,CAAC;AAE7D,QAAM,iBACJ,UAAU,OAAO,KAAK,UAAU,CAAC,CAAC,EAAE,SAAS,IAC3C,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,QAClC,UACH,IAEA,gCAAG,UAAS;AAEhB,MAAI,CAAC,QAAQ,QAAS,QAAO;AAE7B,MAAI,cAAc;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SACE,oBAAC,4BAAyB,SAAS,OAAO,SACvC,0BACH;AAEJ;AAEA,qBAAqB,cAAc;","names":[]}
@@ -1,6 +1,7 @@
1
- import { ComponentType, type FC } from "react";
1
+ import { type FC } from "react";
2
2
  import { TooltipIconButtonProps } from "./base/tooltip-icon-button";
3
3
  import { ThreadConfig } from "./thread-config";
4
+ import { ThreadPrimitive } from "../primitives";
4
5
  declare const Thread: FC<ThreadConfig>;
5
6
  declare const exports: {
6
7
  Root: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
@@ -19,12 +20,7 @@ declare const exports: {
19
20
  }, "ref"> & import("../primitive-hooks/thread/useThreadViewportAutoScroll").UseThreadViewportAutoScrollProps & import("react").RefAttributes<HTMLDivElement>, "ref">> & import("react").RefAttributes<HTMLDivElement>>;
20
21
  Messages: FC<{
21
22
  unstable_flexGrowDiv?: boolean;
22
- components?: {
23
- UserMessage?: ComponentType | undefined;
24
- EditComposer?: ComponentType | undefined;
25
- AssistantMessage?: ComponentType | undefined;
26
- SystemMessage?: ComponentType | undefined;
27
- };
23
+ components?: Partial<ThreadPrimitive.Messages.Props["components"]>;
28
24
  }>;
29
25
  FollowupSuggestions: FC;
30
26
  ScrollToBottom: import("react").ForwardRefExoticComponent<Partial<TooltipIconButtonProps> & import("react").RefAttributes<HTMLButtonElement>>;
@@ -1 +1 @@
1
- {"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../../src/ui/thread.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAc,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAM3D,OAAO,EAEL,sBAAsB,EACvB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EACL,YAAY,EAIb,MAAM,iBAAiB,CAAC;AAIzB,QAAA,MAAM,MAAM,EAAE,EAAE,CAAC,YAAY,CAoB5B,CAAC;AAwHF,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;+BAlFY,OAAO;qBACjB;YACX,WAAW,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;YACxC,YAAY,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;YACzC,gBAAgB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;YAC7C,aAAa,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;SAC3C;;;;;CAmFF,CAAC;wBAE+C,OAAO,MAAM,GAAG,OAAO,OAAO;AAA/E,wBAAgF"}
1
+ {"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../../src/ui/thread.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAM5C,OAAO,EAEL,sBAAsB,EACvB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EACL,YAAY,EAIb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD,QAAA,MAAM,MAAM,EAAE,EAAE,CAAC,YAAY,CAqB5B,CAAC;AAiHF,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;+BA7EY,OAAO;qBACjB,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;;;;;CAmFnE,CAAC;wBAE+C,OAAO,MAAM,GAAG,OAAO,OAAO;AAA/E,wBAAgF"}
package/dist/ui/thread.js CHANGED
@@ -51,12 +51,13 @@ var Thread = (config) => {
51
51
  const {
52
52
  components: {
53
53
  Composer: ComposerComponent = import_composer.default,
54
- ThreadWelcome: ThreadWelcomeComponent = import_thread_welcome.default
54
+ ThreadWelcome: ThreadWelcomeComponent = import_thread_welcome.default,
55
+ ...messageComponents
55
56
  } = {}
56
57
  } = config;
57
58
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThreadRoot, { config, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ThreadViewport, { children: [
58
59
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThreadWelcomeComponent, {}),
59
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThreadMessages, {}),
60
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThreadMessages, { components: messageComponents }),
60
61
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThreadFollowupSuggestions, {}),
61
62
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ThreadViewportFooter, { children: [
62
63
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThreadScrollToBottom, {}),
@@ -81,17 +82,16 @@ var ThreadViewportFooter = (0, import_withDefaults.withDefaults)("div", {
81
82
  className: "aui-thread-viewport-footer"
82
83
  });
83
84
  ThreadViewportFooter.displayName = "ThreadViewportFooter";
84
- var SystemMessage = () => null;
85
85
  var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ...rest }) => {
86
86
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
87
87
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
88
88
  import_primitives.ThreadPrimitive.Messages,
89
89
  {
90
90
  components: {
91
+ ...components,
91
92
  UserMessage: components?.UserMessage ?? import_user_message.default,
92
- EditComposer: components?.EditComposer ?? import_edit_composer.default,
93
93
  AssistantMessage: components?.AssistantMessage ?? import_assistant_message.default,
94
- SystemMessage: components?.SystemMessage ?? SystemMessage
94
+ EditComposer: components?.EditComposer ?? import_edit_composer.default
95
95
  },
96
96
  ...rest
97
97
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ui/thread.tsx"],"sourcesContent":["\"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 } from \"../primitives\";\nimport { useThread } from \"../context\";\n\nconst Thread: FC<ThreadConfig> = (config) => {\n const {\n components: {\n Composer: ComposerComponent = Composer,\n ThreadWelcome: ThreadWelcomeComponent = ThreadWelcome,\n } = {},\n } = config;\n return (\n <ThreadRoot config={config}>\n <ThreadViewport>\n <ThreadWelcomeComponent />\n <ThreadMessages />\n <ThreadFollowupSuggestions />\n <ThreadViewportFooter>\n <ThreadScrollToBottom />\n <ComposerComponent />\n </ThreadViewportFooter>\n </ThreadViewport>\n </ThreadRoot>\n );\n};\n\nnamespace ThreadRoot {\n export type Element = HTMLDivElement;\n export type Props = ThreadPrimitive.Root.Props & ThreadConfigProviderProps;\n}\n\nconst ThreadRootStyled = withDefaults(ThreadPrimitive.Root, {\n className: \"aui-root aui-thread-root\",\n});\n\nconst ThreadRoot = forwardRef<ThreadRoot.Element, ThreadRoot.Props>(\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 unstable_flexGrowDiv?: boolean;\n components?: {\n UserMessage?: ComponentType | undefined;\n EditComposer?: ComponentType | undefined;\n AssistantMessage?: ComponentType | undefined;\n SystemMessage?: ComponentType | undefined;\n };\n}> = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ...rest }) => {\n return (\n <>\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 {flexGrowDiv && (\n <ThreadPrimitive.If empty={false}>\n <div style={{ flexGrow: 1 }} />\n </ThreadPrimitive.If>\n )}\n </>\n );\n};\n\nThreadMessages.displayName = \"ThreadMessages\";\n\nconst ThreadFollowupSuggestions: FC = () => {\n const suggestions = useThread((t) => t.suggestions);\n\n return (\n <ThreadPrimitive.If empty={false} running={false}>\n <div className=\"aui-thread-followup-suggestions\">\n {suggestions?.map((suggestion, idx) => (\n <ThreadPrimitive.Suggestion\n key={idx}\n className=\"aui-thread-followup-suggestion\"\n prompt={suggestion.prompt}\n method=\"replace\"\n autoSend\n >\n {suggestion.prompt}\n </ThreadPrimitive.Suggestion>\n ))}\n </div>\n </ThreadPrimitive.If>\n );\n};\n\nconst ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {\n variant: \"outline\",\n className: \"aui-thread-scroll-to-bottom\",\n});\n\nnamespace ThreadScrollToBottom {\n export type Element = HTMLButtonElement;\n export type Props = Partial<TooltipIconButtonProps>;\n}\n\nconst ThreadScrollToBottom = forwardRef<\n ThreadScrollToBottom.Element,\n ThreadScrollToBottom.Props\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 FollowupSuggestions: ThreadFollowupSuggestions,\n ScrollToBottom: ThreadScrollToBottom,\n ViewportFooter: ThreadViewportFooter,\n};\n\nexport default Object.assign(Thread, exports) as typeof Thread & typeof exports;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAmD;AACnD,0BAA8B;AAE9B,0BAA6B;AAC7B,sBAAqB;AACrB,4BAA0B;AAC1B,iCAGO;AACP,+BAA6B;AAC7B,0BAAwB;AACxB,2BAAyB;AACzB,2BAKO;AACP,wBAAgC;AAChC,qBAA0B;AAYlB;AAVR,IAAM,SAA2B,CAAC,WAAW;AAC3C,QAAM;AAAA,IACJ,YAAY;AAAA,MACV,UAAU,oBAAoB,gBAAAA;AAAA,MAC9B,eAAe,yBAAyB,sBAAAC;AAAA,IAC1C,IAAI,CAAC;AAAA,EACP,IAAI;AACJ,SACE,4CAAC,cAAW,QACV,uDAAC,kBACC;AAAA,gDAAC,0BAAuB;AAAA,IACxB,4CAAC,kBAAe;AA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,OACzC,sDAAC,SAAI,WAAU,mCACZ,uBAAa,IAAI,CAAC,YAAY,QAC7B;AAAA,IAAC,kCAAgB;AAAA,IAAhB;AAAA,MAEC,WAAU;AAAA,MACV,QAAQ,WAAW;AAAA,MACnB,QAAO;AAAA,MACP,UAAQ;AAAA,MAEP,qBAAW;AAAA;AAAA,IANP;AAAA,EAOP,CACD,GACH,GACF;AAEJ;AAEA,IAAM,qCAAiC,kCAAa,8CAAmB;AAAA,EACrE,SAAS;AAAA,EACT,WAAW;AACb,CAAC;AAOD,IAAM,2BAAuB,yBAG3B,CAAC,OAAO,QAAQ;AAChB,QAAM;AAAA,IACJ,SAAS;AAAA,MACP,QAAQ,EAAE,gBAAgB,EAAE,UAAU,mBAAmB,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,IACvE,IAAI,CAAC;AAAA,EACP,QAAI,sCAAgB;AACpB,SACE,4CAAC,kCAAgB,gBAAhB,EAA+B,SAAO,MACrC,sDAAC,kCAA+B,SAAmB,GAAG,OAAO,KAC1D,gBAAM,YAAY,4CAAC,qCAAc,GACpC,GACF;AAEJ,CAAC;AAED,qBAAqB,cAAc;AAEnC,IAAMC,WAAU;AAAA,EACd,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AAAA,EACV,qBAAqB;AAAA,EACrB,gBAAgB;AAAA,EAChB,gBAAgB;AAClB;AAEA,IAAO,iBAAQ,OAAO,OAAO,QAAQA,QAAO;","names":["Composer","ThreadWelcome","UserMessage","EditComposer","AssistantMessage","exports"]}
1
+ {"version":3,"sources":["../../src/ui/thread.tsx"],"sourcesContent":["\"use client\";\n\nimport { 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 } from \"../primitives\";\nimport { useThread } from \"../context\";\n\nconst Thread: FC<ThreadConfig> = (config) => {\n const {\n components: {\n Composer: ComposerComponent = Composer,\n ThreadWelcome: ThreadWelcomeComponent = ThreadWelcome,\n ...messageComponents\n } = {},\n } = config;\n return (\n <ThreadRoot config={config}>\n <ThreadViewport>\n <ThreadWelcomeComponent />\n <ThreadMessages components={messageComponents} />\n <ThreadFollowupSuggestions />\n <ThreadViewportFooter>\n <ThreadScrollToBottom />\n <ComposerComponent />\n </ThreadViewportFooter>\n </ThreadViewport>\n </ThreadRoot>\n );\n};\n\nnamespace ThreadRoot {\n export type Element = HTMLDivElement;\n export type Props = ThreadPrimitive.Root.Props & ThreadConfigProviderProps;\n}\n\nconst ThreadRootStyled = withDefaults(ThreadPrimitive.Root, {\n className: \"aui-root aui-thread-root\",\n});\n\nconst ThreadRoot = forwardRef<ThreadRoot.Element, ThreadRoot.Props>(\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 ThreadMessages: FC<{\n unstable_flexGrowDiv?: boolean;\n components?: Partial<ThreadPrimitive.Messages.Props[\"components\"]>;\n}> = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ...rest }) => {\n return (\n <>\n <ThreadPrimitive.Messages\n components={{\n ...components,\n UserMessage: components?.UserMessage ?? UserMessage,\n AssistantMessage: components?.AssistantMessage ?? AssistantMessage,\n EditComposer: components?.EditComposer ?? EditComposer,\n }}\n {...rest}\n />\n {flexGrowDiv && (\n <ThreadPrimitive.If empty={false}>\n <div style={{ flexGrow: 1 }} />\n </ThreadPrimitive.If>\n )}\n </>\n );\n};\n\nThreadMessages.displayName = \"ThreadMessages\";\n\nconst ThreadFollowupSuggestions: FC = () => {\n const suggestions = useThread((t) => t.suggestions);\n\n return (\n <ThreadPrimitive.If empty={false} running={false}>\n <div className=\"aui-thread-followup-suggestions\">\n {suggestions?.map((suggestion, idx) => (\n <ThreadPrimitive.Suggestion\n key={idx}\n className=\"aui-thread-followup-suggestion\"\n prompt={suggestion.prompt}\n method=\"replace\"\n autoSend\n >\n {suggestion.prompt}\n </ThreadPrimitive.Suggestion>\n ))}\n </div>\n </ThreadPrimitive.If>\n );\n};\n\nconst ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {\n variant: \"outline\",\n className: \"aui-thread-scroll-to-bottom\",\n});\n\nnamespace ThreadScrollToBottom {\n export type Element = HTMLButtonElement;\n export type Props = Partial<TooltipIconButtonProps>;\n}\n\nconst ThreadScrollToBottom = forwardRef<\n ThreadScrollToBottom.Element,\n ThreadScrollToBottom.Props\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 FollowupSuggestions: ThreadFollowupSuggestions,\n ScrollToBottom: ThreadScrollToBottom,\n ViewportFooter: ThreadViewportFooter,\n};\n\nexport default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AAED,qBAAqB,cAAc;AAEnC,IAAMC,WAAU;AAAA,EACd,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AAAA,EACV,qBAAqB;AAAA,EACrB,gBAAgB;AAAA,EAChB,gBAAgB;AAClB;AAEA,IAAO,iBAAQ,OAAO,OAAO,QAAQA,QAAO;","names":["Composer","ThreadWelcome","UserMessage","AssistantMessage","EditComposer","exports"]}
@@ -23,12 +23,13 @@ var Thread = (config) => {
23
23
  const {
24
24
  components: {
25
25
  Composer: ComposerComponent = Composer,
26
- ThreadWelcome: ThreadWelcomeComponent = ThreadWelcome
26
+ ThreadWelcome: ThreadWelcomeComponent = ThreadWelcome,
27
+ ...messageComponents
27
28
  } = {}
28
29
  } = config;
29
30
  return /* @__PURE__ */ jsx(ThreadRoot, { config, children: /* @__PURE__ */ jsxs(ThreadViewport, { children: [
30
31
  /* @__PURE__ */ jsx(ThreadWelcomeComponent, {}),
31
- /* @__PURE__ */ jsx(ThreadMessages, {}),
32
+ /* @__PURE__ */ jsx(ThreadMessages, { components: messageComponents }),
32
33
  /* @__PURE__ */ jsx(ThreadFollowupSuggestions, {}),
33
34
  /* @__PURE__ */ jsxs(ThreadViewportFooter, { children: [
34
35
  /* @__PURE__ */ jsx(ThreadScrollToBottom, {}),
@@ -53,17 +54,16 @@ var ThreadViewportFooter = withDefaults("div", {
53
54
  className: "aui-thread-viewport-footer"
54
55
  });
55
56
  ThreadViewportFooter.displayName = "ThreadViewportFooter";
56
- var SystemMessage = () => null;
57
57
  var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ...rest }) => {
58
58
  return /* @__PURE__ */ jsxs(Fragment, { children: [
59
59
  /* @__PURE__ */ jsx(
60
60
  ThreadPrimitive.Messages,
61
61
  {
62
62
  components: {
63
+ ...components,
63
64
  UserMessage: components?.UserMessage ?? UserMessage,
64
- EditComposer: components?.EditComposer ?? EditComposer,
65
65
  AssistantMessage: components?.AssistantMessage ?? AssistantMessage,
66
- SystemMessage: components?.SystemMessage ?? SystemMessage
66
+ EditComposer: components?.EditComposer ?? EditComposer
67
67
  },
68
68
  ...rest
69
69
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ui/thread.tsx"],"sourcesContent":["\"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 } from \"../primitives\";\nimport { useThread } from \"../context\";\n\nconst Thread: FC<ThreadConfig> = (config) => {\n const {\n components: {\n Composer: ComposerComponent = Composer,\n ThreadWelcome: ThreadWelcomeComponent = ThreadWelcome,\n } = {},\n } = config;\n return (\n <ThreadRoot config={config}>\n <ThreadViewport>\n <ThreadWelcomeComponent />\n <ThreadMessages />\n <ThreadFollowupSuggestions />\n <ThreadViewportFooter>\n <ThreadScrollToBottom />\n <ComposerComponent />\n </ThreadViewportFooter>\n </ThreadViewport>\n </ThreadRoot>\n );\n};\n\nnamespace ThreadRoot {\n export type Element = HTMLDivElement;\n export type Props = ThreadPrimitive.Root.Props & ThreadConfigProviderProps;\n}\n\nconst ThreadRootStyled = withDefaults(ThreadPrimitive.Root, {\n className: \"aui-root aui-thread-root\",\n});\n\nconst ThreadRoot = forwardRef<ThreadRoot.Element, ThreadRoot.Props>(\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 unstable_flexGrowDiv?: boolean;\n components?: {\n UserMessage?: ComponentType | undefined;\n EditComposer?: ComponentType | undefined;\n AssistantMessage?: ComponentType | undefined;\n SystemMessage?: ComponentType | undefined;\n };\n}> = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ...rest }) => {\n return (\n <>\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 {flexGrowDiv && (\n <ThreadPrimitive.If empty={false}>\n <div style={{ flexGrow: 1 }} />\n </ThreadPrimitive.If>\n )}\n </>\n );\n};\n\nThreadMessages.displayName = \"ThreadMessages\";\n\nconst ThreadFollowupSuggestions: FC = () => {\n const suggestions = useThread((t) => t.suggestions);\n\n return (\n <ThreadPrimitive.If empty={false} running={false}>\n <div className=\"aui-thread-followup-suggestions\">\n {suggestions?.map((suggestion, idx) => (\n <ThreadPrimitive.Suggestion\n key={idx}\n className=\"aui-thread-followup-suggestion\"\n prompt={suggestion.prompt}\n method=\"replace\"\n autoSend\n >\n {suggestion.prompt}\n </ThreadPrimitive.Suggestion>\n ))}\n </div>\n </ThreadPrimitive.If>\n );\n};\n\nconst ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {\n variant: \"outline\",\n className: \"aui-thread-scroll-to-bottom\",\n});\n\nnamespace ThreadScrollToBottom {\n export type Element = HTMLButtonElement;\n export type Props = Partial<TooltipIconButtonProps>;\n}\n\nconst ThreadScrollToBottom = forwardRef<\n ThreadScrollToBottom.Element,\n ThreadScrollToBottom.Props\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 FollowupSuggestions: ThreadFollowupSuggestions,\n ScrollToBottom: ThreadScrollToBottom,\n ViewportFooter: ThreadViewportFooter,\n};\n\nexport default Object.assign(Thread, exports) as typeof Thread & typeof exports;\n"],"mappings":";;;AAEA,SAAwB,kBAA2B;AACnD,SAAS,qBAAqB;AAE9B,SAAS,oBAAoB;AAC7B,OAAO,cAAc;AACrB,OAAO,mBAAmB;AAC1B;AAAA,EACE;AAAA,OAEK;AACP,OAAO,sBAAsB;AAC7B,OAAO,iBAAiB;AACxB,OAAO,kBAAkB;AACzB;AAAA,EAEE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAYlB,SAyDJ,UAzDI,KAGA,YAHA;AAVR,IAAM,SAA2B,CAAC,WAAW;AAC3C,QAAM;AAAA,IACJ,YAAY;AAAA,MACV,UAAU,oBAAoB;AAAA,MAC9B,eAAe,yBAAyB;AAAA,IAC1C,IAAI,CAAC;AAAA,EACP,IAAI;AACJ,SACE,oBAAC,cAAW,QACV,+BAAC,kBACC;AAAA,wBAAC,0BAAuB;AAAA,IACxB,oBAAC,kBAAe;AAAA,IAChB,oBAAC,6BAA0B;AAAA,IAC3B,qBAAC,wBACC;AAAA,0BAAC,wBAAqB;AAAA,MACtB,oBAAC,qBAAkB;AAAA,OACrB;AAAA,KACF,GACF;AAEJ;A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,UAAQ;AAAA,MAEP,qBAAW;AAAA;AAAA,IANP;AAAA,EAOP,CACD,GACH,GACF;AAEJ;AAEA,IAAM,iCAAiC,aAAa,mBAAmB;AAAA,EACrE,SAAS;AAAA,EACT,WAAW;AACb,CAAC;AAOD,IAAM,uBAAuB,WAG3B,CAAC,OAAO,QAAQ;AAChB,QAAM;AAAA,IACJ,SAAS;AAAA,MACP,QAAQ,EAAE,gBAAgB,EAAE,UAAU,mBAAmB,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,IACvE,IAAI,CAAC;AAAA,EACP,IAAI,gBAAgB;AACpB,SACE,oBAAC,gBAAgB,gBAAhB,EAA+B,SAAO,MACrC,8BAAC,kCAA+B,SAAmB,GAAG,OAAO,KAC1D,gBAAM,YAAY,oBAAC,iBAAc,GACpC,GACF;AAEJ,CAAC;AAED,qBAAqB,cAAc;AAEnC,IAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AAAA,EACV,qBAAqB;AAAA,EACrB,gBAAgB;AAAA,EAChB,gBAAgB;AAClB;AAEA,IAAO,iBAAQ,OAAO,OAAO,QAAQ,OAAO;","names":[]}
1
+ {"version":3,"sources":["../../src/ui/thread.tsx"],"sourcesContent":["\"use client\";\n\nimport { 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 } from \"../primitives\";\nimport { useThread } from \"../context\";\n\nconst Thread: FC<ThreadConfig> = (config) => {\n const {\n components: {\n Composer: ComposerComponent = Composer,\n ThreadWelcome: ThreadWelcomeComponent = ThreadWelcome,\n ...messageComponents\n } = {},\n } = config;\n return (\n <ThreadRoot config={config}>\n <ThreadViewport>\n <ThreadWelcomeComponent />\n <ThreadMessages components={messageComponents} />\n <ThreadFollowupSuggestions />\n <ThreadViewportFooter>\n <ThreadScrollToBottom />\n <ComposerComponent />\n </ThreadViewportFooter>\n </ThreadViewport>\n </ThreadRoot>\n );\n};\n\nnamespace ThreadRoot {\n export type Element = HTMLDivElement;\n export type Props = ThreadPrimitive.Root.Props & ThreadConfigProviderProps;\n}\n\nconst ThreadRootStyled = withDefaults(ThreadPrimitive.Root, {\n className: \"aui-root aui-thread-root\",\n});\n\nconst ThreadRoot = forwardRef<ThreadRoot.Element, ThreadRoot.Props>(\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 ThreadMessages: FC<{\n unstable_flexGrowDiv?: boolean;\n components?: Partial<ThreadPrimitive.Messages.Props[\"components\"]>;\n}> = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ...rest }) => {\n return (\n <>\n <ThreadPrimitive.Messages\n components={{\n ...components,\n UserMessage: components?.UserMessage ?? UserMessage,\n AssistantMessage: components?.AssistantMessage ?? AssistantMessage,\n EditComposer: components?.EditComposer ?? EditComposer,\n }}\n {...rest}\n />\n {flexGrowDiv && (\n <ThreadPrimitive.If empty={false}>\n <div style={{ flexGrow: 1 }} />\n </ThreadPrimitive.If>\n )}\n </>\n );\n};\n\nThreadMessages.displayName = \"ThreadMessages\";\n\nconst ThreadFollowupSuggestions: FC = () => {\n const suggestions = useThread((t) => t.suggestions);\n\n return (\n <ThreadPrimitive.If empty={false} running={false}>\n <div className=\"aui-thread-followup-suggestions\">\n {suggestions?.map((suggestion, idx) => (\n <ThreadPrimitive.Suggestion\n key={idx}\n className=\"aui-thread-followup-suggestion\"\n prompt={suggestion.prompt}\n method=\"replace\"\n autoSend\n >\n {suggestion.prompt}\n </ThreadPrimitive.Suggestion>\n ))}\n </div>\n </ThreadPrimitive.If>\n );\n};\n\nconst ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {\n variant: \"outline\",\n className: \"aui-thread-scroll-to-bottom\",\n});\n\nnamespace ThreadScrollToBottom {\n export type Element = HTMLButtonElement;\n export type Props = Partial<TooltipIconButtonProps>;\n}\n\nconst ThreadScrollToBottom = forwardRef<\n ThreadScrollToBottom.Element,\n ThreadScrollToBottom.Props\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 FollowupSuggestions: ThreadFollowupSuggestions,\n ScrollToBottom: ThreadScrollToBottom,\n ViewportFooter: ThreadViewportFooter,\n};\n\nexport default Object.assign(Thread, exports) as typeof Thread & typeof exports;\n"],"mappings":";;;AAEA,SAAS,kBAA2B;AACpC,SAAS,qBAAqB;AAE9B,SAAS,oBAAoB;AAC7B,OAAO,cAAc;AACrB,OAAO,mBAAmB;AAC1B;AAAA,EACE;AAAA,OAEK;AACP,OAAO,sBAAsB;AAC7B,OAAO,iBAA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":[]}
package/package.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "conversational-ui",
30
30
  "conversational-ai"
31
31
  ],
32
- "version": "0.7.3",
32
+ "version": "0.7.4",
33
33
  "license": "MIT",
34
34
  "exports": {
35
35
  ".": {
@@ -169,6 +169,9 @@ export type ThreadConfig = {
169
169
 
170
170
  components?:
171
171
  | {
172
+ UserMessage?: ComponentType | undefined;
173
+ AssistantMessage?: ComponentType | undefined;
174
+ EditComposer?: ComponentType | undefined;
172
175
  Composer?: ComponentType | undefined;
173
176
  ThreadWelcome?: ComponentType | undefined;
174
177
  }
package/src/ui/thread.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { ComponentType, forwardRef, type FC } from "react";
3
+ import { forwardRef, type FC } from "react";
4
4
  import { ArrowDownIcon } from "lucide-react";
5
5
 
6
6
  import { withDefaults } from "./utils/withDefaults";
@@ -27,13 +27,14 @@ const Thread: FC<ThreadConfig> = (config) => {
27
27
  components: {
28
28
  Composer: ComposerComponent = Composer,
29
29
  ThreadWelcome: ThreadWelcomeComponent = ThreadWelcome,
30
+ ...messageComponents
30
31
  } = {},
31
32
  } = config;
32
33
  return (
33
34
  <ThreadRoot config={config}>
34
35
  <ThreadViewport>
35
36
  <ThreadWelcomeComponent />
36
- <ThreadMessages />
37
+ <ThreadMessages components={messageComponents} />
37
38
  <ThreadFollowupSuggestions />
38
39
  <ThreadViewportFooter>
39
40
  <ThreadScrollToBottom />
@@ -77,25 +78,18 @@ const ThreadViewportFooter = withDefaults("div", {
77
78
 
78
79
  ThreadViewportFooter.displayName = "ThreadViewportFooter";
79
80
 
80
- const SystemMessage = () => null;
81
-
82
81
  const ThreadMessages: FC<{
83
82
  unstable_flexGrowDiv?: boolean;
84
- components?: {
85
- UserMessage?: ComponentType | undefined;
86
- EditComposer?: ComponentType | undefined;
87
- AssistantMessage?: ComponentType | undefined;
88
- SystemMessage?: ComponentType | undefined;
89
- };
83
+ components?: Partial<ThreadPrimitive.Messages.Props["components"]>;
90
84
  }> = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ...rest }) => {
91
85
  return (
92
86
  <>
93
87
  <ThreadPrimitive.Messages
94
88
  components={{
89
+ ...components,
95
90
  UserMessage: components?.UserMessage ?? UserMessage,
96
- EditComposer: components?.EditComposer ?? EditComposer,
97
91
  AssistantMessage: components?.AssistantMessage ?? AssistantMessage,
98
- SystemMessage: components?.SystemMessage ?? SystemMessage,
92
+ EditComposer: components?.EditComposer ?? EditComposer,
99
93
  }}
100
94
  {...rest}
101
95
  />