@assistant-ui/react 0.7.2 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/ContentPartRuntime.d.ts +5 -1
- package/dist/api/ContentPartRuntime.d.ts.map +1 -1
- package/dist/api/ContentPartRuntime.js.map +1 -1
- package/dist/api/ContentPartRuntime.mjs.map +1 -1
- package/dist/api/RuntimePathTypes.d.ts +0 -3
- package/dist/api/RuntimePathTypes.d.ts.map +1 -1
- package/dist/api/RuntimePathTypes.js.map +1 -1
- package/dist/api/ThreadListRuntime.d.ts +0 -5
- package/dist/api/ThreadListRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListRuntime.js +4 -10
- package/dist/api/ThreadListRuntime.js.map +1 -1
- package/dist/api/ThreadListRuntime.mjs +4 -10
- package/dist/api/ThreadListRuntime.mjs.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.d.ts.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.js +3 -2
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.mjs +3 -2
- package/dist/runtimes/edge/converters/fromLanguageModelMessages.mjs.map +1 -1
- package/dist/types/AssistantTypes.d.ts +57 -57
- package/dist/types/AssistantTypes.d.ts.map +1 -1
- package/dist/types/AssistantTypes.js.map +1 -1
- package/dist/ui/{attachment.d.ts → attachment-ui.d.ts} +3 -3
- package/dist/ui/attachment-ui.d.ts.map +1 -0
- package/dist/ui/{attachment.js → attachment-ui.js} +9 -9
- package/dist/ui/attachment-ui.js.map +1 -0
- package/dist/ui/{attachment.mjs → attachment-ui.mjs} +6 -6
- package/dist/ui/attachment-ui.mjs.map +1 -0
- package/dist/ui/composer.js +2 -2
- package/dist/ui/composer.js.map +1 -1
- package/dist/ui/composer.mjs +1 -1
- package/dist/ui/composer.mjs.map +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +2 -2
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +1 -1
- package/dist/ui/index.mjs.map +1 -1
- package/dist/ui/thread-config.d.ts +3 -0
- package/dist/ui/thread-config.d.ts.map +1 -1
- package/dist/ui/thread-config.js.map +1 -1
- package/dist/ui/thread-config.mjs.map +1 -1
- package/dist/ui/thread.d.ts +3 -7
- package/dist/ui/thread.d.ts.map +1 -1
- package/dist/ui/thread.js +5 -5
- package/dist/ui/thread.js.map +1 -1
- package/dist/ui/thread.mjs +5 -5
- package/dist/ui/thread.mjs.map +1 -1
- package/dist/ui/user-message.js +2 -2
- package/dist/ui/user-message.js.map +1 -1
- package/dist/ui/user-message.mjs +1 -1
- package/dist/ui/user-message.mjs.map +1 -1
- package/dist/utils/smooth/SmoothContext.d.ts +42 -42
- package/package.json +3 -3
- package/src/api/ContentPartRuntime.ts +6 -2
- package/src/api/RuntimePathTypes.ts +0 -4
- package/src/api/ThreadListRuntime.ts +4 -16
- package/src/runtimes/edge/converters/fromLanguageModelMessages.ts +5 -2
- package/src/types/AssistantTypes.ts +62 -57
- package/src/ui/{attachment.tsx → attachment-ui.tsx} +3 -3
- package/src/ui/composer.tsx +1 -1
- package/src/ui/index.ts +1 -1
- package/src/ui/thread-config.tsx +3 -0
- package/src/ui/thread.tsx +6 -12
- package/src/ui/user-message.tsx +1 -1
- package/dist/ui/attachment.d.ts.map +0 -1
- package/dist/ui/attachment.js.map +0 -1
- package/dist/ui/attachment.mjs.map +0 -1
package/dist/ui/thread.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/ui/thread.tsx"],"sourcesContent":["\"use client\";\n\nimport {
|
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":"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","names":[]}
|
package/dist/ui/user-message.js
CHANGED
@@ -40,7 +40,7 @@ var import_withDefaults = require("./utils/withDefaults.cjs");
|
|
40
40
|
var import_user_action_bar = __toESM(require("./user-action-bar.cjs"));
|
41
41
|
var import_content_part = __toESM(require("./content-part.cjs"));
|
42
42
|
var import_primitives = require("../primitives/index.cjs");
|
43
|
-
var
|
43
|
+
var import_attachment_ui = __toESM(require("./attachment-ui.cjs"));
|
44
44
|
var import_jsx_runtime = require("react/jsx-runtime");
|
45
45
|
var UserMessage = () => {
|
46
46
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(UserMessageRoot, { children: [
|
@@ -83,7 +83,7 @@ var UserMessageAttachments = ({
|
|
83
83
|
{
|
84
84
|
components: {
|
85
85
|
...components,
|
86
|
-
Attachment: components?.Attachment ??
|
86
|
+
Attachment: components?.Attachment ?? import_attachment_ui.default
|
87
87
|
}
|
88
88
|
}
|
89
89
|
) }) });
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/ui/user-message.tsx"],"sourcesContent":["\"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 } from \"../primitives\";\nimport Attachment from \"./attachment\";\n\nconst UserMessage: FC = () => {\n return (\n <UserMessageRoot>\n <UserMessageAttachments />\n {/* TODO this is temporary until we place the UserActionBar in a better place */}\n <MessagePrimitive.If hasContent>\n <UserActionBar />\n <UserMessageContent />\n </MessagePrimitive.If>\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\nnamespace UserMessageContent {\n export type Element = HTMLDivElement;\n export type Props = MessagePrimitive.Content.Props &\n ComponentPropsWithoutRef<\"div\">;\n}\n\nconst UserMessageContent = forwardRef<\n UserMessageContent.Element,\n UserMessageContent.Props\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\nUserMessageContent.displayName = \"UserMessageContent\";\n\nconst UserMessageAttachmentsContainer = withDefaults(\"div\", {\n className: \"aui-user-message-attachments\",\n});\n\nnamespace UserMessageAttachments {\n export type Props = Partial<MessagePrimitive.Attachments.Props>;\n}\n\nconst UserMessageAttachments: FC<UserMessageAttachments.Props> = ({\n components,\n}) => {\n return (\n <MessagePrimitive.If hasAttachments>\n <UserMessageAttachmentsContainer>\n <MessagePrimitive.Attachments\n components={{\n ...components,\n Attachment: components?.Attachment ?? Attachment,\n }}\n />\n </UserMessageAttachmentsContainer>\n </MessagePrimitive.If>\n );\n};\n\nconst exports = {\n Root: UserMessageRoot,\n Content: UserMessageContent,\n Attachments: UserMessageAttachments,\n};\n\nexport default Object.assign(UserMessage, exports) as typeof UserMessage &\n typeof exports;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA8D;AAE9D,2BAAyB;AACzB,0BAA6B;AAC7B,6BAA0B;AAC1B,0BAAwB;AACxB,wBAAiC;AACjC,
|
1
|
+
{"version":3,"sources":["../../src/ui/user-message.tsx"],"sourcesContent":["\"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 } from \"../primitives\";\nimport Attachment from \"./attachment-ui\";\n\nconst UserMessage: FC = () => {\n return (\n <UserMessageRoot>\n <UserMessageAttachments />\n {/* TODO this is temporary until we place the UserActionBar in a better place */}\n <MessagePrimitive.If hasContent>\n <UserActionBar />\n <UserMessageContent />\n </MessagePrimitive.If>\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\nnamespace UserMessageContent {\n export type Element = HTMLDivElement;\n export type Props = MessagePrimitive.Content.Props &\n ComponentPropsWithoutRef<\"div\">;\n}\n\nconst UserMessageContent = forwardRef<\n UserMessageContent.Element,\n UserMessageContent.Props\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\nUserMessageContent.displayName = \"UserMessageContent\";\n\nconst UserMessageAttachmentsContainer = withDefaults(\"div\", {\n className: \"aui-user-message-attachments\",\n});\n\nnamespace UserMessageAttachments {\n export type Props = Partial<MessagePrimitive.Attachments.Props>;\n}\n\nconst UserMessageAttachments: FC<UserMessageAttachments.Props> = ({\n components,\n}) => {\n return (\n <MessagePrimitive.If hasAttachments>\n <UserMessageAttachmentsContainer>\n <MessagePrimitive.Attachments\n components={{\n ...components,\n Attachment: components?.Attachment ?? Attachment,\n }}\n />\n </UserMessageAttachmentsContainer>\n </MessagePrimitive.If>\n );\n};\n\nconst exports = {\n Root: UserMessageRoot,\n Content: UserMessageContent,\n Attachments: UserMessageAttachments,\n};\n\nexport default Object.assign(UserMessage, exports) as typeof UserMessage &\n typeof exports;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA8D;AAE9D,2BAAyB;AACzB,0BAA6B;AAC7B,6BAA0B;AAC1B,0BAAwB;AACxB,wBAAiC;AACjC,2BAAuB;AAKjB;AAHN,IAAM,cAAkB,MAAM;AAC5B,SACE,6CAAC,mBACC;AAAA,gDAAC,0BAAuB;AAAA,IAExB,6CAAC,mCAAiB,IAAjB,EAAoB,YAAU,MAC7B;AAAA,kDAAC,uBAAAA,SAAA,EAAc;AAAA,MACf,4CAAC,sBAAmB;AAAA,OACtB;AAAA,IACA,4CAAC,qBAAAC,SAAA,EAAa;AAAA,KAChB;AAEJ;AAEA,YAAY,cAAc;AAE1B,IAAM,sBAAkB,kCAAa,mCAAiB,MAAM;AAAA,EAC1D,WAAW;AACb,CAAC;AAED,gBAAgB,cAAc;AAE9B,IAAM,gCAA4B,kCAAa,OAAO;AAAA,EACpD,WAAW;AACb,CAAC;AAQD,IAAM,yBAAqB,yBAGzB,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,QAAQ;AACnC,SACE,4CAAC,6BAA2B,GAAG,OAAO,KACpC;AAAA,IAAC,mCAAiB;AAAA,IAAjB;AAAA,MACC,YAAY;AAAA,QACV,GAAG;AAAA,QACH,MAAM,YAAY,QAAQ,oBAAAC,QAAY;AAAA,MACxC;AAAA;AAAA,EACF,GACF;AAEJ,CAAC;AAED,mBAAmB,cAAc;AAEjC,IAAM,sCAAkC,kCAAa,OAAO;AAAA,EAC1D,WAAW;AACb,CAAC;AAMD,IAAM,yBAA2D,CAAC;AAAA,EAChE;AACF,MAAM;AACJ,SACE,4CAAC,mCAAiB,IAAjB,EAAoB,gBAAc,MACjC,sDAAC,mCACC;AAAA,IAAC,mCAAiB;AAAA,IAAjB;AAAA,MACC,YAAY;AAAA,QACV,GAAG;AAAA,QACH,YAAY,YAAY,cAAc,qBAAAC;AAAA,MACxC;AAAA;AAAA,EACF,GACF,GACF;AAEJ;AAEA,IAAMC,WAAU;AAAA,EACd,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AACf;AAEA,IAAO,uBAAQ,OAAO,OAAO,aAAaA,QAAO;","names":["UserActionBar","BranchPicker","ContentPart","Attachment","exports"]}
|
package/dist/ui/user-message.mjs
CHANGED
@@ -7,7 +7,7 @@ import { withDefaults } from "./utils/withDefaults.mjs";
|
|
7
7
|
import UserActionBar from "./user-action-bar.mjs";
|
8
8
|
import ContentPart from "./content-part.mjs";
|
9
9
|
import { MessagePrimitive } from "../primitives/index.mjs";
|
10
|
-
import Attachment from "./attachment.mjs";
|
10
|
+
import Attachment from "./attachment-ui.mjs";
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
12
12
|
var UserMessage = () => {
|
13
13
|
return /* @__PURE__ */ jsxs(UserMessageRoot, { children: [
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/ui/user-message.tsx"],"sourcesContent":["\"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 } from \"../primitives\";\nimport Attachment from \"./attachment\";\n\nconst UserMessage: FC = () => {\n return (\n <UserMessageRoot>\n <UserMessageAttachments />\n {/* TODO this is temporary until we place the UserActionBar in a better place */}\n <MessagePrimitive.If hasContent>\n <UserActionBar />\n <UserMessageContent />\n </MessagePrimitive.If>\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\nnamespace UserMessageContent {\n export type Element = HTMLDivElement;\n export type Props = MessagePrimitive.Content.Props &\n ComponentPropsWithoutRef<\"div\">;\n}\n\nconst UserMessageContent = forwardRef<\n UserMessageContent.Element,\n UserMessageContent.Props\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\nUserMessageContent.displayName = \"UserMessageContent\";\n\nconst UserMessageAttachmentsContainer = withDefaults(\"div\", {\n className: \"aui-user-message-attachments\",\n});\n\nnamespace UserMessageAttachments {\n export type Props = Partial<MessagePrimitive.Attachments.Props>;\n}\n\nconst UserMessageAttachments: FC<UserMessageAttachments.Props> = ({\n components,\n}) => {\n return (\n <MessagePrimitive.If hasAttachments>\n <UserMessageAttachmentsContainer>\n <MessagePrimitive.Attachments\n components={{\n ...components,\n Attachment: components?.Attachment ?? Attachment,\n }}\n />\n </UserMessageAttachmentsContainer>\n </MessagePrimitive.If>\n );\n};\n\nconst exports = {\n Root: UserMessageRoot,\n Content: UserMessageContent,\n Attachments: UserMessageAttachments,\n};\n\nexport default Object.assign(UserMessage, exports) as typeof UserMessage &\n typeof exports;\n"],"mappings":";;;AAEA,SAAmC,kBAA2B;AAE9D,OAAO,kBAAkB;AACzB,SAAS,oBAAoB;AAC7B,OAAO,mBAAmB;AAC1B,OAAO,iBAAiB;AACxB,SAAS,wBAAwB;AACjC,OAAO,gBAAgB;AAKjB,cAEA,YAFA;AAHN,IAAM,cAAkB,MAAM;AAC5B,SACE,qBAAC,mBACC;AAAA,wBAAC,0BAAuB;AAAA,IAExB,qBAAC,iBAAiB,IAAjB,EAAoB,YAAU,MAC7B;AAAA,0BAAC,iBAAc;AAAA,MACf,oBAAC,sBAAmB;AAAA,OACtB;AAAA,IACA,oBAAC,gBAAa;AAAA,KAChB;AAEJ;AAEA,YAAY,cAAc;AAE1B,IAAM,kBAAkB,aAAa,iBAAiB,MAAM;AAAA,EAC1D,WAAW;AACb,CAAC;AAED,gBAAgB,cAAc;AAE9B,IAAM,4BAA4B,aAAa,OAAO;AAAA,EACpD,WAAW;AACb,CAAC;AAQD,IAAM,qBAAqB,WAGzB,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,QAAQ;AACnC,SACE,oBAAC,6BAA2B,GAAG,OAAO,KACpC;AAAA,IAAC,iBAAiB;AAAA,IAAjB;AAAA,MACC,YAAY;AAAA,QACV,GAAG;AAAA,QACH,MAAM,YAAY,QAAQ,YAAY;AAAA,MACxC;AAAA;AAAA,EACF,GACF;AAEJ,CAAC;AAED,mBAAmB,cAAc;AAEjC,IAAM,kCAAkC,aAAa,OAAO;AAAA,EAC1D,WAAW;AACb,CAAC;AAMD,IAAM,yBAA2D,CAAC;AAAA,EAChE;AACF,MAAM;AACJ,SACE,oBAAC,iBAAiB,IAAjB,EAAoB,gBAAc,MACjC,8BAAC,mCACC;AAAA,IAAC,iBAAiB;AAAA,IAAjB;AAAA,MACC,YAAY;AAAA,QACV,GAAG;AAAA,QACH,YAAY,YAAY,cAAc;AAAA,MACxC;AAAA;AAAA,EACF,GACF,GACF;AAEJ;AAEA,IAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AACf;AAEA,IAAO,uBAAQ,OAAO,OAAO,aAAa,OAAO;","names":[]}
|
1
|
+
{"version":3,"sources":["../../src/ui/user-message.tsx"],"sourcesContent":["\"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 } from \"../primitives\";\nimport Attachment from \"./attachment-ui\";\n\nconst UserMessage: FC = () => {\n return (\n <UserMessageRoot>\n <UserMessageAttachments />\n {/* TODO this is temporary until we place the UserActionBar in a better place */}\n <MessagePrimitive.If hasContent>\n <UserActionBar />\n <UserMessageContent />\n </MessagePrimitive.If>\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\nnamespace UserMessageContent {\n export type Element = HTMLDivElement;\n export type Props = MessagePrimitive.Content.Props &\n ComponentPropsWithoutRef<\"div\">;\n}\n\nconst UserMessageContent = forwardRef<\n UserMessageContent.Element,\n UserMessageContent.Props\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\nUserMessageContent.displayName = \"UserMessageContent\";\n\nconst UserMessageAttachmentsContainer = withDefaults(\"div\", {\n className: \"aui-user-message-attachments\",\n});\n\nnamespace UserMessageAttachments {\n export type Props = Partial<MessagePrimitive.Attachments.Props>;\n}\n\nconst UserMessageAttachments: FC<UserMessageAttachments.Props> = ({\n components,\n}) => {\n return (\n <MessagePrimitive.If hasAttachments>\n <UserMessageAttachmentsContainer>\n <MessagePrimitive.Attachments\n components={{\n ...components,\n Attachment: components?.Attachment ?? Attachment,\n }}\n />\n </UserMessageAttachmentsContainer>\n </MessagePrimitive.If>\n );\n};\n\nconst exports = {\n Root: UserMessageRoot,\n Content: UserMessageContent,\n Attachments: UserMessageAttachments,\n};\n\nexport default Object.assign(UserMessage, exports) as typeof UserMessage &\n typeof exports;\n"],"mappings":";;;AAEA,SAAmC,kBAA2B;AAE9D,OAAO,kBAAkB;AACzB,SAAS,oBAAoB;AAC7B,OAAO,mBAAmB;AAC1B,OAAO,iBAAiB;AACxB,SAAS,wBAAwB;AACjC,OAAO,gBAAgB;AAKjB,cAEA,YAFA;AAHN,IAAM,cAAkB,MAAM;AAC5B,SACE,qBAAC,mBACC;AAAA,wBAAC,0BAAuB;AAAA,IAExB,qBAAC,iBAAiB,IAAjB,EAAoB,YAAU,MAC7B;AAAA,0BAAC,iBAAc;AAAA,MACf,oBAAC,sBAAmB;AAAA,OACtB;AAAA,IACA,oBAAC,gBAAa;AAAA,KAChB;AAEJ;AAEA,YAAY,cAAc;AAE1B,IAAM,kBAAkB,aAAa,iBAAiB,MAAM;AAAA,EAC1D,WAAW;AACb,CAAC;AAED,gBAAgB,cAAc;AAE9B,IAAM,4BAA4B,aAAa,OAAO;AAAA,EACpD,WAAW;AACb,CAAC;AAQD,IAAM,qBAAqB,WAGzB,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,QAAQ;AACnC,SACE,oBAAC,6BAA2B,GAAG,OAAO,KACpC;AAAA,IAAC,iBAAiB;AAAA,IAAjB;AAAA,MACC,YAAY;AAAA,QACV,GAAG;AAAA,QACH,MAAM,YAAY,QAAQ,YAAY;AAAA,MACxC;AAAA;AAAA,EACF,GACF;AAEJ,CAAC;AAED,mBAAmB,cAAc;AAEjC,IAAM,kCAAkC,aAAa,OAAO;AAAA,EAC1D,WAAW;AACb,CAAC;AAMD,IAAM,yBAA2D,CAAC;AAAA,EAChE;AACF,MAAM;AACJ,SACE,oBAAC,iBAAiB,IAAjB,EAAoB,gBAAc,MACjC,8BAAC,mCACC;AAAA,IAAC,iBAAiB;AAAA,IAAjB;AAAA,MACC,YAAY;AAAA,QACV,GAAG;AAAA,QACH,YAAY,YAAY,cAAc;AAAA,MACxC;AAAA;AAAA,EACF,GACF,GACF;AAEJ;AAEA,IAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AACf;AAEA,IAAO,uBAAQ,OAAO,OAAO,aAAa,OAAO;","names":[]}
|
@@ -4,84 +4,84 @@ export declare const SmoothContextProvider: FC<PropsWithChildren>;
|
|
4
4
|
export declare const withSmoothContextProvider: <C extends ComponentType<any>>(Component: C) => C;
|
5
5
|
export declare const useSmoothStatus: {
|
6
6
|
(): {
|
7
|
-
type: "running";
|
7
|
+
readonly type: "running";
|
8
8
|
} | {
|
9
|
-
type: "complete";
|
9
|
+
readonly type: "complete";
|
10
10
|
} | {
|
11
|
-
type: "incomplete";
|
12
|
-
reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
13
|
-
error?: unknown;
|
11
|
+
readonly type: "incomplete";
|
12
|
+
readonly reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
13
|
+
readonly error?: unknown;
|
14
14
|
} | {
|
15
|
-
type: "requires-action";
|
16
|
-
reason: "tool-calls";
|
15
|
+
readonly type: "requires-action";
|
16
|
+
readonly reason: "tool-calls";
|
17
17
|
};
|
18
18
|
<TSelected>(selector: (state: {
|
19
|
-
type: "running";
|
19
|
+
readonly type: "running";
|
20
20
|
} | {
|
21
|
-
type: "complete";
|
21
|
+
readonly type: "complete";
|
22
22
|
} | {
|
23
|
-
type: "incomplete";
|
24
|
-
reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
25
|
-
error?: unknown;
|
23
|
+
readonly type: "incomplete";
|
24
|
+
readonly reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
25
|
+
readonly error?: unknown;
|
26
26
|
} | {
|
27
|
-
type: "requires-action";
|
28
|
-
reason: "tool-calls";
|
27
|
+
readonly type: "requires-action";
|
28
|
+
readonly reason: "tool-calls";
|
29
29
|
}) => TSelected): TSelected;
|
30
30
|
(options: {
|
31
31
|
optional: true;
|
32
32
|
}): {
|
33
|
-
type: "running";
|
33
|
+
readonly type: "running";
|
34
34
|
} | {
|
35
|
-
type: "complete";
|
35
|
+
readonly type: "complete";
|
36
36
|
} | {
|
37
|
-
type: "incomplete";
|
38
|
-
reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
39
|
-
error?: unknown;
|
37
|
+
readonly type: "incomplete";
|
38
|
+
readonly reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
39
|
+
readonly error?: unknown;
|
40
40
|
} | {
|
41
|
-
type: "requires-action";
|
42
|
-
reason: "tool-calls";
|
41
|
+
readonly type: "requires-action";
|
42
|
+
readonly reason: "tool-calls";
|
43
43
|
} | null;
|
44
44
|
<TSelected>(options: {
|
45
45
|
optional: true;
|
46
46
|
selector?: (state: {
|
47
|
-
type: "running";
|
47
|
+
readonly type: "running";
|
48
48
|
} | {
|
49
|
-
type: "complete";
|
49
|
+
readonly type: "complete";
|
50
50
|
} | {
|
51
|
-
type: "incomplete";
|
52
|
-
reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
53
|
-
error?: unknown;
|
51
|
+
readonly type: "incomplete";
|
52
|
+
readonly reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
53
|
+
readonly error?: unknown;
|
54
54
|
} | {
|
55
|
-
type: "requires-action";
|
56
|
-
reason: "tool-calls";
|
55
|
+
readonly type: "requires-action";
|
56
|
+
readonly reason: "tool-calls";
|
57
57
|
}) => TSelected;
|
58
58
|
}): TSelected | null;
|
59
59
|
}, useSmoothStatusStore: {
|
60
60
|
(): ReadonlyStore<{
|
61
|
-
type: "running";
|
61
|
+
readonly type: "running";
|
62
62
|
} | {
|
63
|
-
type: "complete";
|
63
|
+
readonly type: "complete";
|
64
64
|
} | {
|
65
|
-
type: "incomplete";
|
66
|
-
reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
67
|
-
error?: unknown;
|
65
|
+
readonly type: "incomplete";
|
66
|
+
readonly reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
67
|
+
readonly error?: unknown;
|
68
68
|
} | {
|
69
|
-
type: "requires-action";
|
70
|
-
reason: "tool-calls";
|
69
|
+
readonly type: "requires-action";
|
70
|
+
readonly reason: "tool-calls";
|
71
71
|
}>;
|
72
72
|
(options: {
|
73
73
|
optional: true;
|
74
74
|
}): ReadonlyStore<{
|
75
|
-
type: "running";
|
75
|
+
readonly type: "running";
|
76
76
|
} | {
|
77
|
-
type: "complete";
|
77
|
+
readonly type: "complete";
|
78
78
|
} | {
|
79
|
-
type: "incomplete";
|
80
|
-
reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
81
|
-
error?: unknown;
|
79
|
+
readonly type: "incomplete";
|
80
|
+
readonly reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
81
|
+
readonly error?: unknown;
|
82
82
|
} | {
|
83
|
-
type: "requires-action";
|
84
|
-
reason: "tool-calls";
|
83
|
+
readonly type: "requires-action";
|
84
|
+
readonly reason: "tool-calls";
|
85
85
|
}> | null;
|
86
86
|
};
|
87
87
|
//# sourceMappingURL=SmoothContext.d.ts.map
|
package/package.json
CHANGED
@@ -29,7 +29,7 @@
|
|
29
29
|
"conversational-ui",
|
30
30
|
"conversational-ai"
|
31
31
|
],
|
32
|
-
"version": "0.7.
|
32
|
+
"version": "0.7.4",
|
33
33
|
"license": "MIT",
|
34
34
|
"exports": {
|
35
35
|
".": {
|
@@ -120,9 +120,9 @@
|
|
120
120
|
"tailwindcss-animate": "^1.0.7",
|
121
121
|
"tsup": "8.3.5",
|
122
122
|
"tsx": "^4.19.2",
|
123
|
+
"@assistant-ui/tailwindcss-transformer": "0.1.0",
|
123
124
|
"@assistant-ui/tsbuildutils": "^0.0.0",
|
124
|
-
"@assistant-ui/tsconfig": "0.0.0"
|
125
|
-
"@assistant-ui/tailwindcss-transformer": "0.1.0"
|
125
|
+
"@assistant-ui/tsconfig": "0.0.0"
|
126
126
|
},
|
127
127
|
"publishConfig": {
|
128
128
|
"access": "public",
|
@@ -23,10 +23,14 @@ type ContentPartSnapshotBinding = SubscribableWithState<
|
|
23
23
|
>;
|
24
24
|
|
25
25
|
export type ContentPartRuntime = {
|
26
|
-
|
26
|
+
/**
|
27
|
+
* Add tool result to a tool call content part that has no tool result yet.
|
28
|
+
* This is useful when you are collecting a tool result via user input ("human tool calls").
|
29
|
+
*/
|
30
|
+
addToolResult(result: any): void;
|
27
31
|
|
32
|
+
readonly path: ContentPartRuntimePath;
|
28
33
|
getState(): ContentPartState;
|
29
|
-
addToolResult(result: any): void;
|
30
34
|
subscribe(callback: () => void): Unsubscribe;
|
31
35
|
};
|
32
36
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import { LazyMemoizeSubject } from "./subscribable/LazyMemoizeSubject";
|
2
2
|
import { ThreadListRuntimeCore } from "../runtimes/core/ThreadListRuntimeCore";
|
3
3
|
import { Unsubscribe } from "../types";
|
4
|
-
import { ThreadListRuntimePath } from "./RuntimePathTypes";
|
5
4
|
import {
|
6
5
|
ThreadListItemRuntime,
|
7
6
|
ThreadListItemRuntimeImpl,
|
@@ -18,7 +17,6 @@ export type ThreadListState = {
|
|
18
17
|
};
|
19
18
|
|
20
19
|
export type ThreadListRuntime = {
|
21
|
-
readonly path: ThreadListRuntimePath;
|
22
20
|
getState(): ThreadListState;
|
23
21
|
|
24
22
|
subscribe(callback: () => void): Unsubscribe;
|
@@ -55,21 +53,13 @@ const getThreadListItemState = (
|
|
55
53
|
};
|
56
54
|
};
|
57
55
|
|
58
|
-
const THREAD_MANAGER_PATH = {
|
59
|
-
ref: "ThreadList",
|
60
|
-
};
|
61
|
-
|
62
56
|
export type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;
|
63
57
|
|
64
58
|
export class ThreadListRuntimeImpl implements ThreadListRuntime {
|
65
|
-
public get path() {
|
66
|
-
return THREAD_MANAGER_PATH;
|
67
|
-
}
|
68
|
-
|
69
59
|
private _getState;
|
70
60
|
constructor(private _core: ThreadListRuntimeCoreBinding) {
|
71
61
|
const stateBinding = new LazyMemoizeSubject({
|
72
|
-
path:
|
62
|
+
path: {},
|
73
63
|
getState: () => getThreadListState(_core),
|
74
64
|
subscribe: (callback) => _core.subscribe(callback),
|
75
65
|
});
|
@@ -89,7 +79,7 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
|
|
89
79
|
return new ThreadListItemRuntimeImpl(
|
90
80
|
new ShallowMemoizeSubject({
|
91
81
|
path: {
|
92
|
-
ref:
|
82
|
+
ref: `threadItems[${idx}]`,
|
93
83
|
threadSelector: { type: "index", index: idx },
|
94
84
|
},
|
95
85
|
getState: () => {
|
@@ -105,7 +95,7 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
|
|
105
95
|
return new ThreadListItemRuntimeImpl(
|
106
96
|
new ShallowMemoizeSubject({
|
107
97
|
path: {
|
108
|
-
ref:
|
98
|
+
ref: `archivedThreadItems[${idx}]`,
|
109
99
|
threadSelector: { type: "archiveIndex", index: idx },
|
110
100
|
},
|
111
101
|
getState: () => {
|
@@ -124,9 +114,7 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
|
|
124
114
|
return new ThreadListItemRuntimeImpl(
|
125
115
|
new ShallowMemoizeSubject({
|
126
116
|
path: {
|
127
|
-
ref:
|
128
|
-
this.path.ref +
|
129
|
-
`${this.path.ref}.threadItems[threadId=${threadId}]`,
|
117
|
+
ref: `threadItems[threadId=${threadId}]`,
|
130
118
|
threadSelector: { type: "threadId", threadId },
|
131
119
|
},
|
132
120
|
getState: () => {
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { LanguageModelV1Message } from "@ai-sdk/provider";
|
2
2
|
import { CoreMessage, ToolCallContentPart } from "../../../types";
|
3
|
+
import { Writable } from "stream";
|
3
4
|
|
4
5
|
type fromLanguageModelMessagesOptions = {
|
5
6
|
mergeSteps: boolean;
|
@@ -105,9 +106,11 @@ export const fromLanguageModelMessages = (
|
|
105
106
|
if (toolCall.toolName !== tool.toolName)
|
106
107
|
throw new Error("Tool call name mismatch.");
|
107
108
|
|
108
|
-
|
109
|
+
type Writable<T> = { -readonly [P in keyof T]: T[P] };
|
110
|
+
const writable = toolCall as Writable<ToolCallContentPart>;
|
111
|
+
writable.result = tool.result;
|
109
112
|
if (tool.isError) {
|
110
|
-
|
113
|
+
writable.isError = true;
|
111
114
|
}
|
112
115
|
}
|
113
116
|
|
@@ -4,45 +4,45 @@ import { CompleteAttachment } from "./AttachmentTypes";
|
|
4
4
|
export type MessageRole = "user" | "assistant" | "system";
|
5
5
|
|
6
6
|
export type TextContentPart = {
|
7
|
-
type: "text";
|
8
|
-
text: string;
|
7
|
+
readonly type: "text";
|
8
|
+
readonly text: string;
|
9
9
|
};
|
10
10
|
|
11
11
|
export type ImageContentPart = {
|
12
|
-
type: "image";
|
13
|
-
image: string;
|
12
|
+
readonly type: "image";
|
13
|
+
readonly image: string;
|
14
14
|
};
|
15
15
|
|
16
16
|
export type Unstable_AudioContentPart = {
|
17
|
-
type: "audio";
|
18
|
-
audio: {
|
19
|
-
data: string;
|
20
|
-
format: "mp3" | "wav";
|
17
|
+
readonly type: "audio";
|
18
|
+
readonly audio: {
|
19
|
+
readonly data: string;
|
20
|
+
readonly format: "mp3" | "wav";
|
21
21
|
};
|
22
22
|
};
|
23
23
|
|
24
24
|
export type UIContentPart = {
|
25
|
-
type: "ui";
|
26
|
-
display: ReactNode;
|
25
|
+
readonly type: "ui";
|
26
|
+
readonly display: ReactNode;
|
27
27
|
};
|
28
28
|
|
29
29
|
export type CoreToolCallContentPart<
|
30
30
|
TArgs extends Record<string, unknown> = Record<string | number, unknown>,
|
31
31
|
TResult = unknown,
|
32
32
|
> = {
|
33
|
-
type: "tool-call";
|
34
|
-
toolCallId: string;
|
35
|
-
toolName: string;
|
36
|
-
args: TArgs;
|
37
|
-
result?: TResult | undefined;
|
38
|
-
isError?: boolean | undefined;
|
33
|
+
readonly type: "tool-call";
|
34
|
+
readonly toolCallId: string;
|
35
|
+
readonly toolName: string;
|
36
|
+
readonly args: TArgs;
|
37
|
+
readonly result?: TResult | undefined;
|
38
|
+
readonly isError?: boolean | undefined;
|
39
39
|
};
|
40
40
|
|
41
41
|
export type ToolCallContentPart<
|
42
42
|
TArgs extends Record<string, unknown> = Record<string | number, unknown>,
|
43
43
|
TResult = unknown,
|
44
44
|
> = CoreToolCallContentPart<TArgs, TResult> & {
|
45
|
-
argsText: string;
|
45
|
+
readonly argsText: string;
|
46
46
|
};
|
47
47
|
|
48
48
|
export type ThreadUserContentPart =
|
@@ -57,87 +57,92 @@ export type ThreadAssistantContentPart =
|
|
57
57
|
| UIContentPart;
|
58
58
|
|
59
59
|
type MessageCommonProps = {
|
60
|
-
id: string;
|
61
|
-
createdAt: Date;
|
60
|
+
readonly id: string;
|
61
|
+
readonly createdAt: Date;
|
62
62
|
};
|
63
63
|
|
64
64
|
export type ThreadStep = {
|
65
|
-
usage?:
|
65
|
+
readonly usage?:
|
66
66
|
| {
|
67
|
-
promptTokens: number;
|
68
|
-
completionTokens: number;
|
67
|
+
readonly promptTokens: number;
|
68
|
+
readonly completionTokens: number;
|
69
69
|
}
|
70
70
|
| undefined;
|
71
71
|
};
|
72
72
|
|
73
73
|
export type ContentPartStatus =
|
74
74
|
| {
|
75
|
-
type: "running";
|
75
|
+
readonly type: "running";
|
76
76
|
}
|
77
77
|
| {
|
78
|
-
type: "complete";
|
78
|
+
readonly type: "complete";
|
79
79
|
}
|
80
80
|
| {
|
81
|
-
type: "incomplete";
|
82
|
-
reason:
|
83
|
-
|
81
|
+
readonly type: "incomplete";
|
82
|
+
readonly reason:
|
83
|
+
| "cancelled"
|
84
|
+
| "length"
|
85
|
+
| "content-filter"
|
86
|
+
| "other"
|
87
|
+
| "error";
|
88
|
+
readonly error?: unknown;
|
84
89
|
};
|
85
90
|
|
86
91
|
export type ToolCallContentPartStatus =
|
87
92
|
| {
|
88
|
-
type: "requires-action";
|
89
|
-
reason: "tool-calls";
|
93
|
+
readonly type: "requires-action";
|
94
|
+
readonly reason: "tool-calls";
|
90
95
|
}
|
91
96
|
| ContentPartStatus;
|
92
97
|
|
93
98
|
export type MessageStatus =
|
94
99
|
| {
|
95
|
-
type: "running";
|
100
|
+
readonly type: "running";
|
96
101
|
}
|
97
102
|
| {
|
98
|
-
type: "requires-action";
|
99
|
-
reason: "tool-calls";
|
103
|
+
readonly type: "requires-action";
|
104
|
+
readonly reason: "tool-calls";
|
100
105
|
}
|
101
106
|
| {
|
102
|
-
type: "complete";
|
103
|
-
reason: "stop" | "unknown";
|
107
|
+
readonly type: "complete";
|
108
|
+
readonly reason: "stop" | "unknown";
|
104
109
|
}
|
105
110
|
| {
|
106
|
-
type: "incomplete";
|
107
|
-
reason:
|
111
|
+
readonly type: "incomplete";
|
112
|
+
readonly reason:
|
108
113
|
| "cancelled"
|
109
114
|
| "tool-calls"
|
110
115
|
| "length"
|
111
116
|
| "content-filter"
|
112
117
|
| "other"
|
113
118
|
| "error";
|
114
|
-
error?: unknown;
|
119
|
+
readonly error?: unknown;
|
115
120
|
};
|
116
121
|
|
117
122
|
export type ThreadSystemMessage = MessageCommonProps & {
|
118
|
-
role: "system";
|
119
|
-
content: [TextContentPart];
|
120
|
-
metadata: {
|
121
|
-
custom: Record<string, unknown>;
|
123
|
+
readonly role: "system";
|
124
|
+
readonly content: [TextContentPart];
|
125
|
+
readonly metadata: {
|
126
|
+
readonly custom: Record<string, unknown>;
|
122
127
|
};
|
123
128
|
};
|
124
129
|
|
125
130
|
export type ThreadUserMessage = MessageCommonProps & {
|
126
|
-
role: "user";
|
127
|
-
content: ThreadUserContentPart[];
|
128
|
-
attachments: readonly CompleteAttachment[];
|
129
|
-
metadata: {
|
130
|
-
custom: Record<string, unknown>;
|
131
|
+
readonly role: "user";
|
132
|
+
readonly content: ThreadUserContentPart[];
|
133
|
+
readonly attachments: readonly CompleteAttachment[];
|
134
|
+
readonly metadata: {
|
135
|
+
readonly custom: Record<string, unknown>;
|
131
136
|
};
|
132
137
|
};
|
133
138
|
|
134
139
|
export type ThreadAssistantMessage = MessageCommonProps & {
|
135
|
-
role: "assistant";
|
136
|
-
content: ThreadAssistantContentPart[];
|
137
|
-
status: MessageStatus;
|
138
|
-
metadata: {
|
139
|
-
steps: ThreadStep[];
|
140
|
-
custom: Record<string, unknown>;
|
140
|
+
readonly role: "assistant";
|
141
|
+
readonly content: ThreadAssistantContentPart[];
|
142
|
+
readonly status: MessageStatus;
|
143
|
+
readonly metadata: {
|
144
|
+
readonly steps: ThreadStep[];
|
145
|
+
readonly custom: Record<string, unknown>;
|
141
146
|
};
|
142
147
|
};
|
143
148
|
|
@@ -148,12 +153,12 @@ export type AppendMessage = CoreMessage & {
|
|
148
153
|
};
|
149
154
|
|
150
155
|
type BaseThreadMessage = {
|
151
|
-
status?: ThreadAssistantMessage["status"];
|
152
|
-
metadata: {
|
153
|
-
steps?: ThreadStep[];
|
154
|
-
custom: Record<string, unknown>;
|
156
|
+
readonly status?: ThreadAssistantMessage["status"];
|
157
|
+
readonly metadata: {
|
158
|
+
readonly steps?: ThreadStep[];
|
159
|
+
readonly custom: Record<string, unknown>;
|
155
160
|
};
|
156
|
-
attachments?: ThreadUserMessage["attachments"];
|
161
|
+
readonly attachments?: ThreadUserMessage["attachments"];
|
157
162
|
};
|
158
163
|
|
159
164
|
export type ThreadMessage = BaseThreadMessage &
|
@@ -126,7 +126,7 @@ const AttachmentThumb: FC = () => {
|
|
126
126
|
);
|
127
127
|
};
|
128
128
|
|
129
|
-
const
|
129
|
+
const AttachmentUI: FC = () => {
|
130
130
|
const canRemove = useAttachment((a) => a.source !== "message");
|
131
131
|
const typeLabel = useAttachment((a) => {
|
132
132
|
const type = a.type;
|
@@ -165,7 +165,7 @@ const Attachment: FC = () => {
|
|
165
165
|
);
|
166
166
|
};
|
167
167
|
|
168
|
-
|
168
|
+
AttachmentUI.displayName = "Attachment";
|
169
169
|
|
170
170
|
namespace AttachmentRemove {
|
171
171
|
export type Element = HTMLButtonElement;
|
@@ -204,5 +204,5 @@ const exports = {
|
|
204
204
|
Remove: AttachmentRemove,
|
205
205
|
};
|
206
206
|
|
207
|
-
export default Object.assign(
|
207
|
+
export default Object.assign(AttachmentUI, exports) as typeof AttachmentUI &
|
208
208
|
typeof exports;
|
package/src/ui/composer.tsx
CHANGED
@@ -12,7 +12,7 @@ import {
|
|
12
12
|
import { CircleStopIcon } from "./base/CircleStopIcon";
|
13
13
|
import { ComposerPrimitive, ThreadPrimitive } from "../primitives";
|
14
14
|
import { useThread } from "../context/react/ThreadContext";
|
15
|
-
import Attachment from "./attachment";
|
15
|
+
import Attachment from "./attachment-ui";
|
16
16
|
|
17
17
|
const useAllowAttachments = (ensureCapability = false) => {
|
18
18
|
const { composer: { allowAttachments = true } = {} } = useThreadConfig();
|
package/src/ui/index.ts
CHANGED
package/src/ui/thread-config.tsx
CHANGED
@@ -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
|
}
|