The Open Standard for Generative UI
Documentation Revamp #1 (#81)
Hrijul Bhatnagarc2aa9f0b6680
diff --git a/docs/custom/plugins/inject-custom-docs.mjs b/docs/custom/plugins/inject-custom-docs.mjsnew file mode 100644index 000000000..913d9cf0f--- /dev/null+++ b/docs/custom/plugins/inject-custom-docs.mjs@@ -0,0 +1,21 @@+// @ts-check+import path from "path";+import fs from "fs";++/**+ * @param app {import('typedoc-plugin-markdown').MarkdownApplication} app+ */+export function load(app) {+ app.renderer.markdownHooks.on("page.begin", (page) => {+ const dirname = path.dirname(new URL(import.meta.url).pathname);+ const customFilePath = page.page.filename.split("/").slice(-5).join("/"); // -5 because we want the path starting from the reference directory+ const filePath = path.resolve(+ dirname,+ "..",+ customFilePath+ );+ if (fs.existsSync(filePath)) {+ return fs.readFileSync(filePath, "utf-8");+ }+ });+}diff --git a/docs/docs/guides/005-ui-customization.md b/docs/docs/guides/005-ui-customization.mddeleted file mode 100644index 0ad5bd8c9..000000000--- a/docs/docs/guides/005-ui-customization.md+++ /dev/null@@ -1 +0,0 @@-# UI Customizationdiff --git a/docs/docs/guides/006-getting-started.mdx b/docs/docs/guides/006-getting-started.mdxnew file mode 100644index 000000000..189955d7d--- /dev/null+++ b/docs/docs/guides/006-getting-started.mdx@@ -0,0 +1,126 @@+import Tabs from '@theme/Tabs';+import TabItem from '@theme/TabItem';++# Getting Started with Crayon++Crayon provides a `CrayonChat` component, which does most of the heavy lifting for both logic and UI. Using the CrayonChat component is as simple as implementing a `processMessage` function, and providing the `responseTemplates` you wish to use.++## Step 1: Implementing `processMessage`++The `processMessage` function is the core of your chat implementation. It receives three parameters:+- `threadId`: A unique identifier for the chat conversation+- `messages`: An array containing all messages in the conversation, including the new one+- `abortController`: Used to cancel the request if needed++This function should make an API call to your backend and return a response following the <ins>[Streaming Protocol](../concepts/003-data-format.mdx)</ins>. Here's a basic example that calls a `/api/chat` endpoint:++<Tabs groupId="frontend-lang">+<TabItem value="ts" label="TypeScript">+```tsx+const processMessage = async ({+ threadId,+ messages,+ abortController,+}: {+ threadId: string;+ messages: Message[];+ abortController: AbortController;+}) => {+ const response = await fetch("/api/chat", {+ method: "POST",+ body: JSON.stringify({ threadId, messages }),+ headers: {+ "Content-Type": "application/json",+ Accept: "text/event-stream",+ },+ signal: abortController.signal,+ });+ return response;+};+```+</TabItem>+<TabItem value="js" label="JavaScript">+```jsx+const processMessage = async ({+ threadId,+ messages,+ abortController,+}) => {+ const response = await fetch("/api/chat", {+ method: "POST",+ body: JSON.stringify({ threadId, messages }),+ headers: {+ "Content-Type": "application/json",+ Accept: "text/event-stream",+ },+ signal: abortController.signal,+ });+ return response;+};+```+</TabItem>+</Tabs>++## Step 2: Implementing a response template component++Response templates are React components that define how different types of chat responses should be displayed. For example, you might have different templates for text messages, code blocks, or rich media content. For detailed information, see <ins>[Creating Response Templates](./customization/007-response-templates.mdx)</ins>.++Here's a simple example that renders text in red:++<Tabs groupId="frontend-lang">+<TabItem value="ts" label="TypeScript">+```tsx+export const TextTemplate: React.FC<{ children: React.ReactNode }> = ({+ children,+}) => {+ return <div style={{color: 'red'}}>{children}</div>;+};+```+</TabItem>+<TabItem value="js" label="JavaScript">+```jsx+export const TextTemplate = ({ children }) => {+ return <div style={{color: 'red'}}>{children}</div>;+};+```+</TabItem>+</Tabs>++## Step 3: Putting it all together++Now we can combine everything into a working chat interface. The `CrayonChat` component will handle:+- Rendering the chat UI+- Managing message threads+- Making API calls+- Displaying responses using your templates++Here's how to set it up:++<Tabs groupId="frontend-lang">+<TabItem value="ts" label="TypeScript">+```tsx+<CrayonChat+ processMessage={processMessage}+ responseTemplates={[+ {+ name: "text",+ Component: TextTemplate,+ },+ ]}+/>+```+</TabItem>+<TabItem value="js" label="JavaScript">+```jsx+<CrayonChat+ processMessage={processMessage}+ responseTemplates={[+ {+ name: "text",+ Component: TextTemplate,+ },+ ]}+/>+```+</TabItem>+</Tabs>diff --git a/docs/docs/guides/customization/007-response-templates.mdx b/docs/docs/guides/customization/007-response-templates.mdxnew file mode 100644index 000000000..fbaafabe8--- /dev/null+++ b/docs/docs/guides/customization/007-response-templates.mdx@@ -0,0 +1,204 @@+import Tabs from '@theme/Tabs';+import TabItem from '@theme/TabItem';++# Creating Response Templates++Response templates are a powerful feature in Crayon that allow you to control how AI responses are structured and displayed. They combine a React component for visualization with a schema that tells the LLM exactly how to format its response. This guide will show you how to create custom response templates using a recipe card example.++For Crayon, a response template is a React component. Something as simple as this:+```tsx+const responseTemplate = {+ name: "recipe", // Unique identifier for this template+ Component: RecipeTemplate // React component that renders the response+}+```++The frontend can send a list of such templates, and the backend can tell the LLM which template to choose for which situation. Crayon automatically handles the rest.+For example, if you wanted to create an agent that helps the users with cooking recipes, you could do so in 3 simple steps:++## Step 1: Creating a `RecipeTemplate` component++For the purpose of this guide, let's create a simple card that renders a cooking recipe. You can either manually create a card or design a simple card on the+<ins>[Thesys Canvas](https://app.thesys.dev/home?redirect_uri=/)</ins> and use the CodeGen feature to generate the React code.++<Tabs groupId="frontend-lang">+<TabItem value="ts" label="TypeScript">+```tsx+import { Card, CardHeader, Tag, TagBlock } from "@crayonai/react-ui";+import { FlaskConical as FlaskConicalIcon } from "lucide-react";+import { StepsItem, Steps } from "@crayonai/react-ui/Steps";++interface RecipeTemplateProps {+ title: string; // Name of the recipe+ ingredients: string[]; // List of required ingredients+ steps: string[]; // Step-by-step cooking instructions+}++export default function RecipeTemplate(props: RecipeTemplateProps) {+ return (+ <Card variant="card" width="standard">+ <CardHeader+ title={<p style={{ textAlign: "left" }}>{props.title}</p>}+ icon={<FlaskConicalIcon size={"1em"} />}+ />+ <TagBlock>+ {props.ingredients.map((ingredient) => (+ <Tag text={<p style={{ textAlign: "left" }}>{ingredient}</p>} />+ ))}+ </TagBlock>+ <Steps>+ {props.steps.map((step) => (+ <StepsItem key={step}><p>{step}</p></StepsItem>+ ))}+ </Steps>+ </Card>+ );+}+```++</TabItem>+<TabItem value="js" label="JavaScript">+```jsx+import { Card, CardHeader, Tag, TagBlock } from "@crayonai/react-ui";+import { FlaskConical as FlaskConicalIcon } from "lucide-react";+import { StepsItem, Steps } from "@crayonai/react-ui/Steps";++export default function RecipeTemplate(props) {+ return (+ <Card variant="card" width="standard">+ <CardHeader+ title={<p style={{ textAlign: "left" }}>{props.title}</p>}+ icon={<FlaskConicalIcon size={"1em"} />}+ />+ <TagBlock>+ {props.ingredients.map((ingredient) => (+ <Tag text={<p style={{ textAlign: "left" }}>{ingredient}</p>} />+ ))}+ </TagBlock>+ <Steps>+ {props.steps.map((step) => (+ <StepsItem key={step}><p>{step}</p></StepsItem>+ ))}+ </Steps>+ </Card>+ );+}+```+</TabItem>+</Tabs>+++## Step 2: Creating a schema for the response template++We need to tell the LLM about the structure in which it needs to respond in order to be compatible with our response template component. For this, we define a zod schema:++```ts+import { z } from "zod";++export const RecipeTemplateSchema = z.object({+ title: z.string(),+ ingredients: z.array(z.string()),+ steps: z+ .array(z.string())+ .describe(+ "The instructions to cook the recipe. Do not prefix it with numbers or use markdown, just the instructions."+ ),+});+```++## Step 3: Creating a backend endpoint to tell the LLM about the schema++Now that we have our template and its schema ready, we need a backend endpoint that our frontend will call to get the agent's response. This endpoint will be responsible for telling the LLM about the template. Crayon provides some handy utility functions through `crayon/stream` to help with this.++<Tabs groupId="frontend-lang">+<TabItem value='ts' label="TypeScript">+```tsx+import { NextRequest } from "next/server";+import OpenAI from "openai";+import {+ fromOpenAICompletion,+ toOpenAIMessages,+ templatesToResponseFormat,+} from "@crayonai/stream";+import { Message } from "@crayonai/react-core";+import { RecipeTemplateSchema } from "@/types/recipe";++export async function POST(req: NextRequest) {+ const { messages } = (await req.json()) as { messages: Message[] };+ const client = new OpenAI();+ const responseFormat = templatesToResponseFormat({+ schema: RecipeTemplateSchema,+ name: "recipe",+ description: "Use this template to generate a recipe",+ });+ const llmStream = await client.chat.completions.create({+ model: "gpt-4o",+ messages: toOpenAIMessages(+ messages+ ) as OpenAI.Chat.ChatCompletionMessageParam[],+ stream: true,+ response_format: responseFormat,+ });+ const responseStream = fromOpenAICompletion(llmStream);+ return new Response(responseStream as unknown as ReadableStream<Uint8Array>, {+ headers: {+ "Content-Type": "text/event-stream",+ "Cache-Control": "no-cache, no-transform",+ Connection: "keep-alive",+ },+ });+}+```+</TabItem>++<TabItem value='js' label="JavaScript">+```jsx+import { NextRequest } from "next/server";+import OpenAI from "openai";+import {+ fromOpenAICompletion,+ toOpenAIMessages,+ templatesToResponseFormat,+} from "@crayonai/stream";+import { Message } from "@crayonai/react-core";+import { RecipeTemplateSchema } from "@/types/recipe";++export async function POST(req) {+ const { messages } = await req.json();+ const client = new OpenAI();+ const responseFormat = templatesToResponseFormat({+ schema: RecipeTemplateSchema,+ name: "recipe",+ description: "Use this template to generate a recipe",+ });+ const llmStream = await client.chat.completions.create({+ model: "gpt-4o",+ messages: toOpenAIMessages(messages),+ stream: true,+ response_format: responseFormat,+ });+ const responseStream = fromOpenAICompletion(llmStream);+ return new Response(responseStream, {+ headers: {+ "Content-Type": "text/event-stream",+ "Cache-Control": "no-cache, no-transform",+ Connection: "keep-alive",+ },+ });+}+```+</TabItem>+</Tabs>++This API can then be used in the `processMessage` method as shown in <ins>[Getting started with Crayon](../006-getting-started.mdx)</ins>, and this response template can be passed to `CrayonChat` as follows:+```tsx+<CrayonChat+ processMessage={processMessage}+ responseTemplates={[+ {+ name: "text",+ Component: TextTemplate,+ },+ ]}+/>+```diff --git a/docs/docs/guides/customization/008-connecting-to-backend.mdx b/docs/docs/guides/customization/008-connecting-to-backend.mdxnew file mode 100644index 000000000..27110957f--- /dev/null+++ b/docs/docs/guides/customization/008-connecting-to-backend.mdx@@ -0,0 +1,198 @@+import Tabs from '@theme/Tabs';+import TabItem from '@theme/TabItem';++# Connecting to Backend++Crayon is highly customizable in terms of UI, data and logic. If you are building an agent, chances are you would like to persist the threads that a user creates across sessions. Crayon exposes hooks that enable you to connect your backend APIs to list threads and their content.++Detailed explanations of all of the hooks mentioned in this guide is available in the <ins>[API Reference](../../reference/js/react-core).</ins>++## Managing the list of threads++The `useThreadListManager` hook takes multiple functions that let you control every action on the theads list. Here is one example of how it can be used to control the actions and sync with your backend++<Tabs groupId="frontend-lang">+<TabItem value="ts" label="TypeScript">+```tsx+ const threadListManager = useThreadListManager({+ fetchThreadList: async () => {+ const response = await fetch("/api/threads");+ const data = await response.json();+ return data.threads.map((thread: Thread) => ({+ threadId: +thread.threadId,+ title: thread.title,+ createdAt: new Date(thread.createdAt),+ isRunning: false,+ }));+ },+ createThread: (firstMessage) => {+ return fetch("/api/threads", {+ method: "POST",+ body: JSON.stringify({+ title: firstMessage.message!,+ }),+ }).then((res) => res.json());+ },+ deleteThread: async () => {}, // Called when the user deletes a thread. Use your delete thread API here+ updateThread: async (t) => t, // Called when the user makes changes to an existing thread. Use your update thread API here+ onSwitchToNew: () => {}, // Called when the user switches to a new thread.+ onSelectThread: () => {}, // Called when the user selects an existing thread.+ });+```+</TabItem>+<TabItem value="js" label="JavaScript">+```jsx+ const threadListManager = useThreadListManager({+ fetchThreadList: async () => {+ const response = await fetch("/api/threads");+ const data = await response.json();+ return data.threads.map((thread) => ({+ threadId: Number(thread.threadId),+ title: thread.title,+ createdAt: new Date(thread.createdAt),+ isRunning: false,+ }));+ },+ createThread: (firstMessage) => {+ return fetch("/api/threads", {+ method: "POST",+ body: JSON.stringify({+ title: firstMessage.message,+ }),+ }).then((res) => res.json());+ },+ deleteThread: async () => {}, // Called when the user deletes a thread. Use your delete API here+ updateThread: async (t) => t, // Called when the user makes changes to an existing thread. Use your update thread API here+ onSwitchToNew: () => {}, // Called when the user switches threads. This can be used to clear the chat when switching between threads+ onSelectThread: () => {}, // Called when the user selects an existing thread.+ });+```+</TabItem>+</Tabs>++## Managing data inside a thread++The `useThreadManager` hook lets you handle the data and events inside a thread. Here's an example of how you can manage the selected thread. The `threadListManager` returned by `useThreadListManager` makes things easier by providing a few things you might need.++<Tabs groupId="frontend-lang">+<TabItem value="ts" label="TypeScript">+```tsx+ const threadManager = useThreadManager({+ threadId: threadListManager.selectedThreadId,+ shouldResetThreadState: threadListManager.shouldResetThreadState,+ loadThread: async () => {+ // Called to load the data for this specific thread. In this case, you would use your backend API that returns the selected thread's messages+ const response = await fetch(+ `/api/messages?threadId=${threadListManager.selectedThreadId}`+ );+ const data = await response.json();+ return data.messages;+ },+ onProcessMessage: async ({ message, threadManager, abortController }) => {+ // This is called when the user posts a message. Here, you might want to call your backend API that pushes messages inside the selected thread.+ threadManager.appendMessages({+ id: crypto.randomUUID(),+ role: "user",+ type: "prompt",+ message: message.message as string,+ });++ let threadId = threadListManager.selectedThreadId;+ // If this is a new thread that currently has not been created on the backend, create a thread, otherwise push message to an existing thread+ if (!threadId) {+ const thread = await threadListManager.createThread(+ message as UserMessage+ );+ threadListManager.selectThread(thread.threadId!, false);+ threadId = thread.threadId;+ }+ const response = await fetch("/api/ask", {+ method: "POST",+ body: JSON.stringify({ threadId, ...message }),+ headers: {+ "Content-Type": "application/json",+ Accept: "text/event-stream",+ },+ signal: abortController.signal,+ });++ // This is a utility function provided by crayon to make handling streamed messages more convenient.+ await processStreamedMessage({+ response,+ createMessage: threadManager.appendMessages,+ updateMessage: threadManager.updateMessage,+ deleteMessage: (messageId) => {+ const newMessages = threadManager.messages.filter(+ (message) => message.id !== messageId+ );+ threadManager.setMessages(newMessages);+ },+ });+ return [];+ },+ responseTemplates: templates,+ });+```+</TabItem>+<TabItem value="js" label="JavaScript">+```jsx+ const threadManager = useThreadManager({+ threadId: threadListManager.selectedThreadId,+ shouldResetThreadState: threadListManager.shouldResetThreadState,+ loadThread: async () => {+ // Called to load the data for this specific thread. In this case, you would use your backend API that returns the selected thread's messages+ const response = await fetch(+ `/api/messages?threadId=${threadListManager.selectedThreadId}`+ );+ const data = await response.json();+ return data.messages;+ },+ onProcessMessage: async ({ message, threadManager, abortController }) => {+ // This is called when the user posts a message. Here, you might want to call your backend API that pushes messages inside the selected thread.+ threadManager.appendMessages({+ id: crypto.randomUUID(),+ role: "user",+ type: "prompt",+ message: message.message,+ });++ let threadId = threadListManager.selectedThreadId;+ // If this is a new thread that currently has not been created on the backend, create a thread, otherwise push message to an existing thread+ if (!threadId) {+ const thread = await threadListManager.createThread(message);+ threadListManager.selectThread(thread.threadId, false);+ threadId = thread.threadId;+ }+ const response = await fetch("/api/ask", {+ method: "POST",+ body: JSON.stringify({ threadId, ...message }),+ headers: {+ "Content-Type": "application/json",+ Accept: "text/event-stream",+ },+ signal: abortController.signal,+ });++ // This is a utility function provided by crayon to make handling streamed messages more convenient.+ await processStreamedMessage({+ response,+ createMessage: threadManager.appendMessages,+ updateMessage: threadManager.updateMessage,+ deleteMessage: (messageId) => {+ const newMessages = threadManager.messages.filter(+ (message) => message.id !== messageId+ );+ threadManager.setMessages(newMessages);+ },+ });+ return [];+ },+ responseTemplates: templates,+ });+```+</TabItem>+</Tabs>++---++The `threadListManager` and `threadManager` can then be passed to multiple crayon components such as the `ChatProvider` and `CrayonChat` to customize them to your needs. This enables usage of the Crayon UI with any type of backend.diff --git a/docs/docs/guides/customization/009-customizing-ui.mdx b/docs/docs/guides/customization/009-customizing-ui.mdxnew file mode 100644index 000000000..857acdd45--- /dev/null+++ b/docs/docs/guides/customization/009-customizing-ui.mdx@@ -0,0 +1,124 @@+# Customizing Crayon UI++For simple use cases, the `CrayonChat` component is sufficient and gives you a ready-to-use UI. However, for more complex use cases, you might want to customize the UI.+Crayon exposes all components used in the `CrayonChat` component individually, so you can customize them by passing props and by mixing your own custom components with them.++The following JSX would create the same UI as the `CrayonChat` component but with individual components that you can customize as necessary:++```tsx+import {+ ChatProvider,+ useThreadListManager,+ useThreadManager,+} from "@crayonai/react-core";+import {+ Container,+ SidebarContainer,+ SidebarHeader,+ SidebarContent,+ SidebarSeparator,+ ThreadList,+ ThreadContainer,+ MobileHeader,+ ScrollArea,+ Messages,+ Composer,+ NewChatButton,+} from "@crayonai/react-ui/Shell";+import { ThemeProvider } from "@crayonai/react-ui/ThemeProvider";++const YourComponent = () => {+ const threadListManager = useThreadListManager({+ // /implement as necessary+ });+ const threadManager = useThreadManager({+ // implement as necessary+ });++ const logoUrl = ""; // URL to the agent logo++ return (+ <ThemeProvider>+ <ChatProvider+ threadListManager={threadListManager}+ threadManager={threadManager}+ >+ <Container logoUrl={logoUrl} agentName="Crayon">+ <SidebarContainer>+ <SidebarHeader />+ <SidebarContent>+ <NewChatButton />+ <SidebarSeparator />+ <ThreadList />+ </SidebarContent>+ </SidebarContainer>+ <ThreadContainer>+ <MobileHeader />+ <ScrollArea>+ <Messages />+ </ScrollArea>+ <Composer />+ </ThreadContainer>+ </Container>+ </ChatProvider>+ </ThemeProvider>+ );+};+```++You could then customize the UI to fit your needs. For example, if you wanted to get rid of the existing sidebar and implement your own, you could do so by just replacing+the `SidebarContainer` component with your own `CustomSidebar` component.++```tsx+<ThemeProvider>+ <ChatProvider+ threadListManager={threadListManager}+ threadManager={threadManager}+ >+ <Container logoUrl={logoUrl} agentName="Crayon">+ <CustomSidebar />+ <ThreadContainer>+ <MobileHeader />+ <ScrollArea>+ <Messages />+ </ScrollArea>+ <Composer />+ </ThreadContainer>+ </Container>+ </ChatProvider>+</ThemeProvider>+```++## Customizing the styling++There are 2 ways to customize the existing Crayon components:++1. By passing custom classes to the components that support them.+2. By providing a custom theme to the `ThemeProvider` component.++### Passing custom classes++Many of the components in the Crayon UI library support a `className` prop. This prop can be used to pass custom classes to the component, which can then be used to style the component using CSS.+For example, you could style the thread list in the sidebar to stand out more by passing custom classes that add a background color and some padding:++```tsx+<SidebarContainer>+ <SidebarHeader />+ <SidebarContent>+ <NewChatButton />+ <SidebarSeparator />+ <ThreadList className="rounded-md p-2 bg-gray-100" />+ </SidebarContent>+</SidebarContainer>+```++### Providing a custom theme++The second way to customize the Crayon components is by providing a custom theme to the `ThemeProvider` component. This allows you to customize the styling of the UI globally.+For example, if you wanted all the components to be rendered in their dark mode variant, and change the background of the UI to black, you could do something like this:++```tsx+<ThemeProvider mode="dark" theme={{ backgroundFills: "#000" }}>+ {/* Rest of the crayon components you wish to include in the UI */}+</ThemeProvider>+```diff --git a/docs/docs/guides/customization/index.md b/docs/docs/guides/customization/index.mdnew file mode 100644index 000000000..90570e953--- /dev/null+++ b/docs/docs/guides/customization/index.md@@ -0,0 +1 @@+# Customizationdiff --git a/docs/docs/reference/js/index.md b/docs/docs/reference/js/index.mddeleted file mode 100644index e81bd64b8..000000000--- a/docs/docs/reference/js/index.md+++ /dev/null@@ -1,5 +0,0 @@-# API Reference--## Packages--- [@clay/react-core](./react-core)diff --git a/docs/docs/reference/js/react-core/functions/ChatProvider.md b/docs/docs/reference/js/react-core/functions/ChatProvider.mdindex d9a075b26..26a4d2f91 100644--- a/docs/docs/reference/js/react-core/functions/ChatProvider.md+++ b/docs/docs/reference/js/react-core/functions/ChatProvider.md@@ -1,38 +1,19 @@```ts-function ChatProvider(props: PropsWithChildren<ChatManager>): ReactNode | Promise<ReactNode>+function ChatProvider(+ props: PropsWithChildren<ChatManager>,+): ReactNode | Promise<ReactNode>;```-## Parameters--<table>-<thead>-<tr>-<th>Parameter</th>-<th>Type</th>-<th>Description</th>-</tr>-</thead>-<tbody>-<tr>-<td>+Defined in: [packages/react-core/src/ChatProvider.tsx:30](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/ChatProvider.tsx#L30)-`props`+## Parameters-</td>-<td>+### props`PropsWithChildren`\<[`ChatManager`](../type-aliases/ChatManager.md)\>-</td>-<td>-The component props-</td>-</tr>-</tbody>-</table>-## Returns`ReactNode` \| `Promise`\<`ReactNode`\>@@ -54,7 +35,3 @@ It serves as the top-level provider for thread and thread list management functi<App /></ChatProvider>```--## Defined in--[packages/react-core/src/ChatProvider.tsx:30](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/ChatProvider.tsx#L30)diff --git a/docs/docs/reference/js/react-core/functions/MessageContext.md b/docs/docs/reference/js/react-core/functions/MessageContext.mdnew file mode 100644index 000000000..d6d37c555--- /dev/null+++ b/docs/docs/reference/js/react-core/functions/MessageContext.md@@ -0,0 +1,23 @@+```ts+function MessageContext(+ props: ProviderProps<null | {+ message: Message;+ }>,+): ReactNode;+```++Defined in: [packages/react-core/src/hooks/useMessage.tsx:8](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/hooks/useMessage.tsx#L8)++## Parameters++### props++`ProviderProps`\<+\| `null`+\| \{+`message`: [`Message`](../type-aliases/Message.md);+\}\>++## Returns++`ReactNode`diff --git a/docs/docs/reference/js/react-core/functions/MessageProvider.md b/docs/docs/reference/js/react-core/functions/MessageProvider.mdnew file mode 100644index 000000000..2a3aadca6--- /dev/null+++ b/docs/docs/reference/js/react-core/functions/MessageProvider.md@@ -0,0 +1,24 @@+```ts+function MessageProvider(__namedParameters: {+ children: ReactNode;+ message: Message;+}): Element;+```++Defined in: [packages/react-core/src/hooks/useMessage.tsx:25](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/hooks/useMessage.tsx#L25)++## Parameters++### \_\_namedParameters++#### children++`ReactNode`++#### message++[`Message`](../type-aliases/Message.md)++## Returns++`Element`diff --git a/docs/docs/reference/js/react-core/functions/processStreamedMessage.md b/docs/docs/reference/js/react-core/functions/processStreamedMessage.mdnew file mode 100644index 000000000..e9b0b575b--- /dev/null+++ b/docs/docs/reference/js/react-core/functions/processStreamedMessage.md@@ -0,0 +1,34 @@+```ts+function processStreamedMessage(__namedParameters: {+ createMessage: (message: AssistantMessage) => void;+ deleteMessage: (messageId: string) => void;+ response: Response;+ updateMessage: (message: AssistantMessage) => void;+}): Promise<void>;+```++Defined in: [packages/react-core/src/stream/processStreamedMessage.ts:16](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/stream/processStreamedMessage.ts#L16)++## Parameters++### \_\_namedParameters++#### createMessage++(`message`: [`AssistantMessage`](../type-aliases/AssistantMessage.md)) => `void`++#### deleteMessage++(`messageId`: `string`) => `void`++#### response++`Response`++#### updateMessage++(`message`: [`AssistantMessage`](../type-aliases/AssistantMessage.md)) => `void`++## Returns++`Promise`\<`void`\>diff --git a/docs/docs/reference/js/react-core/functions/useMessage.md b/docs/docs/reference/js/react-core/functions/useMessage.mdnew file mode 100644index 000000000..6c1d0990d--- /dev/null+++ b/docs/docs/reference/js/react-core/functions/useMessage.md@@ -0,0 +1,23 @@+```ts+function useMessage(): {+ message: Message;+};+```++Defined in: [packages/react-core/src/hooks/useMessage.tsx:14](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/hooks/useMessage.tsx#L14)++## Returns++```ts+{+ message: Message;+}+```++The current message. See [Message](../type-aliases/Message.md) for more information.++### message++```ts+message: Message;+```diff --git a/docs/docs/reference/js/react-core/functions/useThreadActions.md b/docs/docs/reference/js/react-core/functions/useThreadActions.mdindex 58f180151..694249dc6 100644--- a/docs/docs/reference/js/react-core/functions/useThreadActions.md+++ b/docs/docs/reference/js/react-core/functions/useThreadActions.md@@ -1,15 +1,9 @@```ts-function useThreadActions(): ThreadActions+function useThreadActions(): ThreadActions;```+Defined in: [packages/react-core/src/hooks/useThreadActions.ts:8](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/hooks/useThreadActions.ts#L8)+## Returns[`ThreadActions`](../type-aliases/ThreadActions.md)--## Remarks--useThreadActions--## Defined in--[packages/react-core/src/hooks/useThreadActions.ts:11](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/hooks/useThreadActions.ts#L11)diff --git a/docs/docs/reference/js/react-core/functions/useThreadListActions.md b/docs/docs/reference/js/react-core/functions/useThreadListActions.mdindex ef70f633d..f90a6c96e 100644--- a/docs/docs/reference/js/react-core/functions/useThreadListActions.md+++ b/docs/docs/reference/js/react-core/functions/useThreadListActions.md@@ -1,7 +1,9 @@```ts-function useThreadListActions(): ThreadListActions+function useThreadListActions(): ThreadListActions;```+Defined in: [packages/react-core/src/hooks/useThreadListActions.ts:11](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/hooks/useThreadListActions.ts#L11)+## Returns[`ThreadListActions`](../type-aliases/ThreadListActions.md)@@ -9,7 +11,3 @@ function useThreadListActions(): ThreadListActions## RemarksuseThreadListActions--## Defined in--[packages/react-core/src/hooks/useThreadListActions.ts:11](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/hooks/useThreadListActions.ts#L11)diff --git a/docs/docs/reference/js/react-core/functions/useThreadListManager.md b/docs/docs/reference/js/react-core/functions/useThreadListManager.mdindex f5f78d17e..9cb3a015f 100644--- a/docs/docs/reference/js/react-core/functions/useThreadListManager.md+++ b/docs/docs/reference/js/react-core/functions/useThreadListManager.md@@ -1,36 +1,50 @@```ts-function useThreadListManager(props: Props): ThreadListManager+function useThreadListManager(params: {+ createThread: (firstMessage: UserMessage) => Promise<Thread>;+ deleteThread: (id: string) => Promise<void>;+ fetchThreadList: () => Promise<Thread[]>;+ onSelectThread: (threadId: string) => void;+ onSwitchToNew: () => void;+ updateThread: (updated: Thread) => Promise<Thread>;+}): ThreadListManager;```+Defined in: [packages/react-core/src/useThreadListManager.ts:28](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/useThreadListManager.ts#L28)+## Parameters-<table>-<thead>-<tr>-<th>Parameter</th>-<th>Type</th>-</tr>-</thead>-<tbody>-<tr>-<td>+### params++#### createThread++(`firstMessage`: [`UserMessage`](../type-aliases/UserMessage.md)) => `Promise`\<[`Thread`](../type-aliases/Thread.md)\>++Creates a new thread when user sends the first message++#### deleteThread++(`id`: `string`) => `Promise`\<`void`\>-`props`+#### fetchThreadList-</td>-<td>+() => `Promise`\<[`Thread`](../type-aliases/Thread.md)[]\>-`Props`+#### onSelectThread-</td>-</tr>-</tbody>-</table>+(`threadId`: `string`) => `void`++#### onSwitchToNew++() => `void`++Allows user to clear chat state when switched to new thread++#### updateThread++(`updated`: [`Thread`](../type-aliases/Thread.md)) => `Promise`\<[`Thread`](../type-aliases/Thread.md)\>## Returns[`ThreadListManager`](../type-aliases/ThreadListManager.md)-## Defined in--[packages/react-core/src/useThreadListManager.ts:16](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/useThreadListManager.ts#L16)+A ThreadListManager instancediff --git a/docs/docs/reference/js/react-core/functions/useThreadListState.md b/docs/docs/reference/js/react-core/functions/useThreadListState.mdindex 0f0112366..c122295ea 100644--- a/docs/docs/reference/js/react-core/functions/useThreadListState.md+++ b/docs/docs/reference/js/react-core/functions/useThreadListState.md@@ -1,7 +1,9 @@```ts-function useThreadListState(): ThreadListState+function useThreadListState(): ThreadListState;```+Defined in: [packages/react-core/src/hooks/useThreadListState.ts:11](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/hooks/useThreadListState.ts#L11)+## Returns[`ThreadListState`](../type-aliases/ThreadListState.md)@@ -9,7 +11,3 @@ function useThreadListState(): ThreadListState## RemarksuseThreadListState--## Defined in--[packages/react-core/src/hooks/useThreadListState.ts:11](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/hooks/useThreadListState.ts#L11)diff --git a/docs/docs/reference/js/react-core/functions/useThreadManager.md b/docs/docs/reference/js/react-core/functions/useThreadManager.mdindex 2248c4929..6d29d1d1e 100644--- a/docs/docs/reference/js/react-core/functions/useThreadManager.md+++ b/docs/docs/reference/js/react-core/functions/useThreadManager.md@@ -1,36 +1,17 @@```ts-function useThreadManager(props: Props): ThreadManager+function useThreadManager(params: UseThreadManagerParams): ThreadManager;```-## Parameters--<table>-<thead>-<tr>-<th>Parameter</th>-<th>Type</th>-</tr>-</thead>-<tbody>-<tr>-<td>--`props`+Defined in: [packages/react-core/src/useThreadManager.ts:26](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/useThreadManager.ts#L26)-</td>-<td>+## Parameters-`Props`+### params-</td>-</tr>-</tbody>-</table>+[`UseThreadManagerParams`](../type-aliases/UseThreadManagerParams.md)## Returns[`ThreadManager`](../type-aliases/ThreadManager.md)-## Defined in--[packages/react-core/src/useThreadManager.ts:16](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/useThreadManager.ts#L16)+The thread managerdiff --git a/docs/docs/reference/js/react-core/functions/useThreadManagerSelector.md b/docs/docs/reference/js/react-core/functions/useThreadManagerSelector.mdindex c2cd151de..f1208eedf 100644--- a/docs/docs/reference/js/react-core/functions/useThreadManagerSelector.md+++ b/docs/docs/reference/js/react-core/functions/useThreadManagerSelector.md@@ -1,51 +1,19 @@```ts-function useThreadManagerSelector<R>(accessor: AtomicAccessor<R>): R+function useThreadManagerSelector<R>(accessor: AtomicAccessor<R>): R;```-## Type Parameters--<table>-<thead>-<tr>-<th>Type Parameter</th>-</tr>-</thead>-<tbody>-<tr>-<td>+Defined in: [packages/react-core/src/hooks/useThreadManagerSelector.ts:13](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/hooks/useThreadManagerSelector.ts#L13)-`R`+## Type Parameters-</td>-</tr>-</tbody>-</table>+• **R**## Parameters-<table>-<thead>-<tr>-<th>Parameter</th>-<th>Type</th>-</tr>-</thead>-<tbody>-<tr>-<td>--`accessor`--</td>-<td>+### accessor`AtomicAccessor`\<`R`\>-</td>-</tr>-</tbody>-</table>-## Returns`R`@@ -53,7 +21,3 @@ function useThreadManagerSelector<R>(accessor: AtomicAccessor<R>): R## RemarksuseThreadManager--## Defined in--[packages/react-core/src/hooks/useThreadManagerSelector.ts:13](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/hooks/useThreadManagerSelector.ts#L13)diff --git a/docs/docs/reference/js/react-core/functions/useThreadState.md b/docs/docs/reference/js/react-core/functions/useThreadState.mdindex 6b582b634..0b1983e44 100644--- a/docs/docs/reference/js/react-core/functions/useThreadState.md+++ b/docs/docs/reference/js/react-core/functions/useThreadState.md@@ -1,7 +1,9 @@```ts-function useThreadState(): ThreadState+function useThreadState(): ThreadState;```+Defined in: [packages/react-core/src/hooks/useThreadState.ts:11](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/hooks/useThreadState.ts#L11)+## Returns[`ThreadState`](../type-aliases/ThreadState.md)@@ -9,7 +11,3 @@ function useThreadState(): ThreadState## RemarksuseThreadState--## Defined in--[packages/react-core/src/hooks/useThreadState.ts:11](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/hooks/useThreadState.ts#L11)diff --git a/docs/docs/reference/js/react-core/globals.md b/docs/docs/reference/js/react-core/globals.mddeleted file mode 100644index a39126fe8..000000000--- a/docs/docs/reference/js/react-core/globals.md+++ /dev/null@@ -1,29 +0,0 @@-## Components--- [ChatProvider](functions/ChatProvider.md)--## Hooks--- [useThreadActions](functions/useThreadActions.md)-- [useThreadListActions](functions/useThreadListActions.md)-- [useThreadListState](functions/useThreadListState.md)-- [useThreadManagerSelector](functions/useThreadManagerSelector.md)-- [useThreadState](functions/useThreadState.md)--## Other--- [ResponseTemplate](interfaces/ResponseTemplate.md)-- [AssistantMessage](type-aliases/AssistantMessage.md)-- [ChatManager](type-aliases/ChatManager.md)-- [CreateMessage](type-aliases/CreateMessage.md)-- [Message](type-aliases/Message.md)-- [Thread](type-aliases/Thread.md)-- [ThreadActions](type-aliases/ThreadActions.md)-- [ThreadListActions](type-aliases/ThreadListActions.md)-- [ThreadListManager](type-aliases/ThreadListManager.md)-- [ThreadListState](type-aliases/ThreadListState.md)-- [ThreadManager](type-aliases/ThreadManager.md)-- [ThreadState](type-aliases/ThreadState.md)-- [UserMessage](type-aliases/UserMessage.md)-- [useThreadListManager](functions/useThreadListManager.md)-- [useThreadManager](functions/useThreadManager.md)diff --git a/docs/docs/reference/js/react-core/index.md b/docs/docs/reference/js/react-core/index.mdindex 2311487e5..2058d1aa3 100644--- a/docs/docs/reference/js/react-core/index.md+++ b/docs/docs/reference/js/react-core/index.md@@ -1 +1,422 @@-## Core Framework+# Core Framework (`react-core`)++This package provides the core framework and hooks for managing state and agents.++## Components++<table>+<thead>+<tr>+<th>Function</th>+<th>Description</th>+</tr>+</thead>+<tbody>+<tr>+<td>++[ChatProvider](functions/ChatProvider.md)++</td>+<td>++**Remarks**++ChatProvider is a React component that provides chat management context to its children.+It serves as the top-level provider for thread and thread list management functionality.++**Example**++```tsx+<ChatProvider+ threadManager={myThreadManager}+ threadListManager={myThreadListManager}+>+ <App />+</ChatProvider>+```++</td>+</tr>+<tr>+<td>++[MessageProvider](functions/MessageProvider.md)++</td>+<td>++‐++</td>+</tr>+</tbody>+</table>++## Contexts++<table>+<thead>+<tr>+<th>Function</th>+<th>Description</th>+</tr>+</thead>+<tbody>+<tr>+<td>++[MessageContext](functions/MessageContext.md)++</td>+<td>++‐++</td>+</tr>+</tbody>+</table>++## Hooks++<table>+<thead>+<tr>+<th>Function</th>+<th>Description</th>+</tr>+</thead>+<tbody>+<tr>+<td>++[useMessage](functions/useMessage.md)++</td>+<td>++‐++</td>+</tr>+<tr>+<td>++[useThreadActions](functions/useThreadActions.md)++</td>+<td>++‐++</td>+</tr>+<tr>+<td>++[useThreadListActions](functions/useThreadListActions.md)++</td>+<td>++**Remarks**++useThreadListActions++</td>+</tr>+<tr>+<td>++[useThreadListManager](functions/useThreadListManager.md)++</td>+<td>++‐++</td>+</tr>+<tr>+<td>++[useThreadListState](functions/useThreadListState.md)++</td>+<td>++**Remarks**++useThreadListState++</td>+</tr>+<tr>+<td>++[useThreadManager](functions/useThreadManager.md)++</td>+<td>++‐++</td>+</tr>+<tr>+<td>++[useThreadManagerSelector](functions/useThreadManagerSelector.md)++</td>+<td>++**Remarks**++useThreadManager++</td>+</tr>+<tr>+<td>++[useThreadState](functions/useThreadState.md)++</td>+<td>++**Remarks**++useThreadState++</td>+</tr>+</tbody>+</table>++## Types++<table>+<thead>+<tr>+<th>Name</th>+<th>Description</th>+</tr>+</thead>+<tbody>+<tr>+<td>++[ResponseTemplate](interfaces/ResponseTemplate.md)++</td>+<td>++‐++</td>+</tr>+<tr>+<td>++[AssistantMessage](type-aliases/AssistantMessage.md)++</td>+<td>++‐++</td>+</tr>+<tr>+<td>++[ChatManager](type-aliases/ChatManager.md)++</td>+<td>++Main chat manager combining thread and thread list management++</td>+</tr>+<tr>+<td>++[CreateMessage](type-aliases/CreateMessage.md)++</td>+<td>++Represents a message being created, with an optional ID++</td>+</tr>+<tr>+<td>++[Message](type-aliases/Message.md)++</td>+<td>++See [UserMessage](type-aliases/UserMessage.md) and [AssistantMessage](type-aliases/AssistantMessage.md) for more information.++</td>+</tr>+<tr>+<td>++[Thread](type-aliases/Thread.md)++</td>+<td>++Represents a chat thread++</td>+</tr>+<tr>+<td>++[ThreadActions](type-aliases/ThreadActions.md)++</td>+<td>++Actions available for managing a thread++**Template**++The message type used in the thread++</td>+</tr>+<tr>+<td>++[ThreadListActions](type-aliases/ThreadListActions.md)++</td>+<td>++Actions available for managing the thread list++</td>+</tr>+<tr>+<td>++[ThreadListManager](type-aliases/ThreadListManager.md)++</td>+<td>++Combines thread list state and actions++</td>+</tr>+<tr>+<td>++[ThreadListState](type-aliases/ThreadListState.md)++</td>+<td>++Represents the state of the thread list++</td>+</tr>+<tr>+<td>++[ThreadManager](type-aliases/ThreadManager.md)++</td>+<td>++Combines thread state and actions++**Template**++The message type used in the thread++</td>+</tr>+<tr>+<td>++[ThreadState](type-aliases/ThreadState.md)++</td>+<td>++Represents the state of a thread++</td>+</tr>+<tr>+<td>++[UserMessage](type-aliases/UserMessage.md)++</td>+<td>++‐++</td>+</tr>+<tr>+<td>++[UseThreadListManagerParams](type-aliases/UseThreadListManagerParams.md)++</td>+<td>++Parameters to be passed to the [useThreadListManager](functions/useThreadListManager.md) hook++</td>+</tr>+<tr>+<td>++[UseThreadManagerParams](type-aliases/UseThreadManagerParams.md)++</td>+<td>++Parameters to be passed to the [useThreadManager](functions/useThreadManager.md) hook++</td>+</tr>+</tbody>+</table>++## Utilities++<table>+<thead>+<tr>+<th>Function</th>+<th>Description</th>+</tr>+</thead>+<tbody>+<tr>+<td>++[processStreamedMessage](functions/processStreamedMessage.md)++</td>+<td>++‐++</td>+</tr>+</tbody>+</table>diff --git a/docs/docs/reference/js/react-core/interfaces/ResponseTemplate.md b/docs/docs/reference/js/react-core/interfaces/ResponseTemplate.mdindex 1673c46d8..ed752a67a 100644--- a/docs/docs/reference/js/react-core/interfaces/ResponseTemplate.md+++ b/docs/docs/reference/js/react-core/interfaces/ResponseTemplate.md@@ -1,7 +1,8 @@+Defined in: [packages/react-core/src/types/responseTemplate.ts:4](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/responseTemplate.ts#L4)+## Properties-| Property | Type | Defined in |-| ------ | ------ | ------ |-| `Component` | `ComponentType`\<\{\}\> | [packages/react-core/src/types/responseTemplate.ts:3](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/responseTemplate.ts#L3) |-| `name` | `string` | [packages/react-core/src/types/responseTemplate.ts:2](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/responseTemplate.ts#L2) |-| `renderWithoutMessageContainer?` | `boolean` | [packages/react-core/src/types/responseTemplate.ts:4](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/responseTemplate.ts#L4) |+| Property | Type | Defined in |+| ---------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |+| <a id="component"></a> `Component` | `ComponentType`\<`any`\> | [packages/react-core/src/types/responseTemplate.ts:6](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/responseTemplate.ts#L6) |+| <a id="name"></a> `name` | `string` | [packages/react-core/src/types/responseTemplate.ts:5](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/responseTemplate.ts#L5) |diff --git a/docs/docs/reference/js/react-core/type-aliases/AssistantMessage.md b/docs/docs/reference/js/react-core/type-aliases/AssistantMessage.mdindex d474997a0..58a859821 100644--- a/docs/docs/reference/js/react-core/type-aliases/AssistantMessage.md+++ b/docs/docs/reference/js/react-core/type-aliases/AssistantMessage.md@@ -1,104 +1,65 @@```ts-type AssistantMessage = common & {- context: {- uiState: Record<string, any>;- };- message: string;- responseTemplate: {- name: string;- templateProps: any;- };+type AssistantMessage = {+ id: string;+ isVisuallyHidden: boolean;+} & {+ context: JSONValue[];+ message: (+ | {+ text: string;+ type: "text";+ }+ | {+ name: string;+ templateProps: any;+ type: "template";+ }+ )[];role: "assistant";};```-## Type declaration--<table>-<thead>-<tr>-<th>Name</th>-<th>Type</th>-<th>Defined in</th>-</tr>-</thead>-<tbody>-<tr>-<td>--`context`?--</td>-<td>--\{- `uiState`: `Record`\<`string`, `any`\>;- \}--</td>-<td>--[packages/react-core/src/types/message.ts:25](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/message.ts#L25)--</td>-</tr>-<tr>-<td>--`message`?--</td>-<td>--`string`--</td>-<td>--[packages/react-core/src/types/message.ts:28](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/message.ts#L28)--</td>-</tr>-<tr>-<td>+Defined in: [packages/react-core/src/types/message.ts:25](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/message.ts#L25)-`responseTemplate`?--</td>-<td>--\{- `name`: `string`;- `templateProps`: `any`;- \}+## Type declaration-</td>-<td>+### id-[packages/react-core/src/types/message.ts:29](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/message.ts#L29)+```ts+id: string;+```-</td>-</tr>-<tr>-<td>+### isVisuallyHidden?-`role`+```ts+optional isVisuallyHidden: boolean;+```-</td>-<td>+## Type declaration-`"assistant"`+### context?-</td>-<td>+```ts+optional context: JSONValue[];+```-[packages/react-core/src/types/message.ts:24](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/message.ts#L24)+### message?-</td>-</tr>-</tbody>-</table>+```ts+optional message: (+ | {+ text: string;+ type: "text";+ }+ | {+ name: string;+ templateProps: any;+ type: "template";+ })[];+```-## Defined in+### role-[packages/react-core/src/types/message.ts:23](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/message.ts#L23)+```ts+role: "assistant";+```diff --git a/docs/docs/reference/js/react-core/type-aliases/ChatManager.md b/docs/docs/reference/js/react-core/type-aliases/ChatManager.mdindex 826f9d17e..2e89957cc 100644--- a/docs/docs/reference/js/react-core/type-aliases/ChatManager.md+++ b/docs/docs/reference/js/react-core/type-aliases/ChatManager.md@@ -5,56 +5,20 @@ type ChatManager = {};```+Defined in: [packages/react-core/src/types/chatManager.ts:98](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/chatManager.ts#L98)+Main chat manager combining thread and thread list management## Type declaration-<table>-<thead>-<tr>-<th>Name</th>-<th>Type</th>-<th>Defined in</th>-</tr>-</thead>-<tbody>-<tr>-<td>--`threadListManager`--</td>-<td>--[`ThreadListManager`](ThreadListManager.md)--</td>-<td>--[packages/react-core/src/types/chatManager.ts:81](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L81)--</td>-</tr>-<tr>-<td>--`threadManager`+### threadListManager-</td>-<td>--[`ThreadManager`](ThreadManager.md)--</td>-<td>--[packages/react-core/src/types/chatManager.ts:82](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L82)--</td>-</tr>-</tbody>-</table>+```ts+threadListManager: ThreadListManager;+```-## Defined in+### threadManager-[packages/react-core/src/types/chatManager.ts:80](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L80)+```ts+threadManager: ThreadManager;+```diff --git a/docs/docs/reference/js/react-core/type-aliases/CreateMessage.md b/docs/docs/reference/js/react-core/type-aliases/CreateMessage.mdindex a696b216a..6dcac47aa 100644--- a/docs/docs/reference/js/react-core/type-aliases/CreateMessage.md+++ b/docs/docs/reference/js/react-core/type-aliases/CreateMessage.md@@ -1,9 +1,7 @@```ts-type CreateMessage = Omit<Message, "id">;+type CreateMessage = Omit<UserMessage, "id">;```-Represents a message being created, with an optional ID--## Defined in+Defined in: [packages/react-core/src/types/message.ts:54](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/message.ts#L54)-[packages/react-core/src/types/message.ts:41](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/message.ts#L41)+Represents a message being created, with an optional IDdiff --git a/docs/docs/reference/js/react-core/type-aliases/Message.md b/docs/docs/reference/js/react-core/type-aliases/Message.mdindex bc5bd8bb8..69695d094 100644--- a/docs/docs/reference/js/react-core/type-aliases/Message.md+++ b/docs/docs/reference/js/react-core/type-aliases/Message.md@@ -1,9 +1,7 @@```ts-type Message =- | UserMessage- | AssistantMessage;+type Message = UserMessage | AssistantMessage;```-## Defined in+Defined in: [packages/react-core/src/types/message.ts:46](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/message.ts#L46)-[packages/react-core/src/types/message.ts:35](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/message.ts#L35)+See [UserMessage](UserMessage.md) and [AssistantMessage](AssistantMessage.md) for more information.diff --git a/docs/docs/reference/js/react-core/type-aliases/Thread.md b/docs/docs/reference/js/react-core/type-aliases/Thread.mdindex 15f607dde..2ad4b38e0 100644--- a/docs/docs/reference/js/react-core/type-aliases/Thread.md+++ b/docs/docs/reference/js/react-core/type-aliases/Thread.md@@ -7,111 +7,40 @@ type Thread = {};```+Defined in: [packages/react-core/src/types/chatManager.ts:9](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/chatManager.ts#L9)+Represents a chat thread## Type declaration-<table>-<thead>-<tr>-<th>Name</th>-<th>Type</th>-<th>Description</th>-<th>Defined in</th>-</tr>-</thead>-<tbody>-<tr>-<td>--`createdAt`--</td>-<td>--`Date`+### createdAt-</td>-<td>+```ts+createdAt: Date;+```Creation timestamp-</td>-<td>--[packages/react-core/src/types/chatManager.ts:13](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L13)--</td>-</tr>-<tr>-<td>+### isRunning?-`isRunning`?--</td>-<td>--`boolean`--</td>-<td>+```ts+optional isRunning: boolean;+```Indicates if the thread is currently processing-</td>-<td>--[packages/react-core/src/types/chatManager.ts:15](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L15)--</td>-</tr>-<tr>-<td>--`threadId`+### threadId-</td>-<td>--`string`--</td>-<td>+```ts+threadId: string;+```Unique identifier for the thread-</td>-<td>--[packages/react-core/src/types/chatManager.ts:9](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L9)--</td>-</tr>-<tr>-<td>--`title`--</td>-<td>+### title-`string`--</td>-<td>+```ts+title: string;+```Title of the thread--</td>-<td>--[packages/react-core/src/types/chatManager.ts:11](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L11)--</td>-</tr>-</tbody>-</table>--## Defined in--[packages/react-core/src/types/chatManager.ts:7](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L7)diff --git a/docs/docs/reference/js/react-core/type-aliases/ThreadActions.md b/docs/docs/reference/js/react-core/type-aliases/ThreadActions.mdindex 9561713b4..1b1ff3bc0 100644--- a/docs/docs/reference/js/react-core/type-aliases/ThreadActions.md+++ b/docs/docs/reference/js/react-core/type-aliases/ThreadActions.md@@ -8,111 +8,42 @@ type ThreadActions = {};```+Defined in: [packages/react-core/src/types/chatManager.ts:26](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/chatManager.ts#L26)+Actions available for managing a thread## Type declaration-<table>-<thead>-<tr>-<th>Name</th>-<th>Type</th>-<th>Defined in</th>-</tr>-</thead>-<tbody>-<tr>-<td>--`appendMessages`--</td>-<td>--(...`messages`: [`Message`](Message.md)[]) => `void`--</td>-<td>--[packages/react-core/src/types/chatManager.ts:24](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L24)--</td>-</tr>-<tr>-<td>--`onCancel`--</td>-<td>--() => `void`--</td>-<td>--[packages/react-core/src/types/chatManager.ts:26](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L26)--</td>-</tr>-<tr>-<td>--`processMessage`--</td>-<td>--(`message`: [`CreateMessage`](CreateMessage.md)) => `Promise`\<`void`\>--</td>-<td>+### appendMessages()-[packages/react-core/src/types/chatManager.ts:23](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L23)--</td>-</tr>-<tr>-<td>--`setMessages`--</td>-<td>--(`messages`: [`Message`](Message.md)[]) => `void`--</td>-<td>+```ts+(...messages: Message[]) => void+```-[packages/react-core/src/types/chatManager.ts:27](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L27)+### onCancel()-</td>-</tr>-<tr>-<td>+```ts+() => void+```-`updateMessage`+### processMessage()-</td>-<td>+```ts+(message: CreateMessage) => Promise<void>;+```-(`message`: [`Message`](Message.md)) => `void`+### setMessages()-</td>-<td>+```ts+(messages: Message[]) => void+```-[packages/react-core/src/types/chatManager.ts:25](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L25)+### updateMessage()-</td>-</tr>-</tbody>-</table>+```ts+(message: Message) => void+```## TemplateThe message type used in the thread--## Defined in--[packages/react-core/src/types/chatManager.ts:22](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L22)diff --git a/docs/docs/reference/js/react-core/type-aliases/ThreadListActions.md b/docs/docs/reference/js/react-core/type-aliases/ThreadListActions.mdindex c8c6b1c88..baf48e9f8 100644--- a/docs/docs/reference/js/react-core/type-aliases/ThreadListActions.md+++ b/docs/docs/reference/js/react-core/type-aliases/ThreadListActions.md@@ -1,132 +1,52 @@```tstype ThreadListActions = {+ createThread: (firstMessage: UserMessage) => Promise<Thread>;deleteThread: (threadId: string) => void;load: () => void;- loadMore: () => void;- selectThread: (threadId: string) => void;+ selectThread: (threadId: string, shouldResetThreadState?: boolean) => void;switchToNewThread: () => void;updateThread: (thread: Thread) => void;};```+Defined in: [packages/react-core/src/types/chatManager.ts:77](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/chatManager.ts#L77)+Actions available for managing the thread list## Type declaration-<table>-<thead>-<tr>-<th>Name</th>-<th>Type</th>-<th>Defined in</th>-</tr>-</thead>-<tbody>-<tr>-<td>--`deleteThread`--</td>-<td>--(`threadId`: `string`) => `void`--</td>-<td>--[packages/react-core/src/types/chatManager.ts:69](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L69)--</td>-</tr>-<tr>-<td>--`load`--</td>-<td>--() => `void`--</td>-<td>--[packages/react-core/src/types/chatManager.ts:63](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L63)--</td>-</tr>-<tr>-<td>--`loadMore`--</td>-<td>--() => `void`--</td>-<td>--[packages/react-core/src/types/chatManager.ts:65](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L65)--</td>-</tr>-<tr>-<td>--`selectThread`+### createThread()-</td>-<td>--(`threadId`: `string`) => `void`--</td>-<td>--[packages/react-core/src/types/chatManager.ts:67](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L67)--</td>-</tr>-<tr>-<td>--`switchToNewThread`--</td>-<td>--() => `void`--</td>-<td>+```ts+(firstMessage: UserMessage) => Promise<Thread>;+```-[packages/react-core/src/types/chatManager.ts:66](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L66)+### deleteThread()-</td>-</tr>-<tr>-<td>+```ts+(threadId: string) => void+```-`updateThread`+### load()-</td>-<td>+```ts+() => void+```-(`thread`: [`Thread`](Thread.md)) => `void`+### selectThread()-</td>-<td>+```ts+(threadId: string, shouldResetThreadState?: boolean) => void+```-[packages/react-core/src/types/chatManager.ts:68](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L68)+### switchToNewThread()-</td>-</tr>-</tbody>-</table>+```ts+() => void+```-## Defined in+### updateThread()-[packages/react-core/src/types/chatManager.ts:62](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L62)+```ts+(thread: Thread) => void+```diff --git a/docs/docs/reference/js/react-core/type-aliases/ThreadListManager.md b/docs/docs/reference/js/react-core/type-aliases/ThreadListManager.mdindex a54a57ef9..69c370726 100644--- a/docs/docs/reference/js/react-core/type-aliases/ThreadListManager.md+++ b/docs/docs/reference/js/react-core/type-aliases/ThreadListManager.md@@ -2,8 +2,6 @@type ThreadListManager = ThreadListState & ThreadListActions;```-Combines thread list state and actions--## Defined in+Defined in: [packages/react-core/src/types/chatManager.ts:91](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/chatManager.ts#L91)-[packages/react-core/src/types/chatManager.ts:75](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L75)+Combines thread list state and actionsdiff --git a/docs/docs/reference/js/react-core/type-aliases/ThreadListState.md b/docs/docs/reference/js/react-core/type-aliases/ThreadListState.mdindex 48c6e699c..a7557f455 100644--- a/docs/docs/reference/js/react-core/type-aliases/ThreadListState.md+++ b/docs/docs/reference/js/react-core/type-aliases/ThreadListState.md@@ -3,94 +3,43 @@ type ThreadListState = {error: Error | null | undefined;isLoading: boolean;selectedThreadId: string | null;+ shouldResetThreadState: boolean;threads: Thread[];};```+Defined in: [packages/react-core/src/types/chatManager.ts:64](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/chatManager.ts#L64)+Represents the state of the thread list## Type declaration-<table>-<thead>-<tr>-<th>Name</th>-<th>Type</th>-<th>Defined in</th>-</tr>-</thead>-<tbody>-<tr>-<td>--`error`--</td>-<td>--`Error` \| `null` \| `undefined`--</td>-<td>--[packages/react-core/src/types/chatManager.ts:55](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L55)--</td>-</tr>-<tr>-<td>--`isLoading`--</td>-<td>--`boolean`--</td>-<td>--[packages/react-core/src/types/chatManager.ts:54](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L54)--</td>-</tr>-<tr>-<td>--`selectedThreadId`+### error-</td>-<td>--`string` \| `null`--</td>-<td>--[packages/react-core/src/types/chatManager.ts:56](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L56)--</td>-</tr>-<tr>-<td>+```ts+error: Error | null | undefined;+```-`threads`+### isLoading-</td>-<td>+```ts+isLoading: boolean;+```-[`Thread`](Thread.md)[]+### selectedThreadId-</td>-<td>+```ts+selectedThreadId: string | null;+```-[packages/react-core/src/types/chatManager.ts:53](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L53)+### shouldResetThreadState-</td>-</tr>-</tbody>-</table>+```ts+shouldResetThreadState: boolean;+```-## Defined in+### threads-[packages/react-core/src/types/chatManager.ts:52](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L52)+```ts+threads: Thread[];+```diff --git a/docs/docs/reference/js/react-core/type-aliases/ThreadManager.md b/docs/docs/reference/js/react-core/type-aliases/ThreadManager.mdindex d40cf7806..a7649d77b 100644--- a/docs/docs/reference/js/react-core/type-aliases/ThreadManager.md+++ b/docs/docs/reference/js/react-core/type-aliases/ThreadManager.md@@ -2,12 +2,10 @@type ThreadManager = ThreadState & ThreadActions;```+Defined in: [packages/react-core/src/types/chatManager.ts:57](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/chatManager.ts#L57)+Combines thread state and actions## TemplateThe message type used in the thread--## Defined in--[packages/react-core/src/types/chatManager.ts:47](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L47)diff --git a/docs/docs/reference/js/react-core/type-aliases/ThreadState.md b/docs/docs/reference/js/react-core/type-aliases/ThreadState.mdindex 6c0e0d1a3..ca9705033 100644--- a/docs/docs/reference/js/react-core/type-aliases/ThreadState.md+++ b/docs/docs/reference/js/react-core/type-aliases/ThreadState.md@@ -1,117 +1,50 @@```tstype ThreadState = {error: Error | null | undefined;+ isLoadingMessages: boolean | undefined;isRunning: boolean;messages: Message[];responseTemplates: {};};```+Defined in: [packages/react-core/src/types/chatManager.ts:39](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/chatManager.ts#L39)+Represents the state of a thread## Type declaration-<table>-<thead>-<tr>-<th>Name</th>-<th>Type</th>-<th>Description</th>-<th>Defined in</th>-</tr>-</thead>-<tbody>-<tr>-<td>--`error`--</td>-<td>--`Error` \| `null` \| `undefined`--</td>-<td>+### error-‐--</td>-<td>--[packages/react-core/src/types/chatManager.ts:37](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L37)+```ts+error: Error | null | undefined;+```-</td>-</tr>-<tr>-<td>+### isLoadingMessages-`isRunning`?+```ts+isLoadingMessages: boolean | undefined;+```-</td>-<td>+Indicates if the messages are currently loading-`boolean`+### isRunning?-</td>-<td>+```ts+optional isRunning: boolean;+```Indicates if the thread is currently processing and controls should be disabled-</td>-<td>--[packages/react-core/src/types/chatManager.ts:35](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L35)--</td>-</tr>-<tr>-<td>--`messages`--</td>-<td>+### messages-[`Message`](Message.md)[]--</td>-<td>--‐--</td>-<td>--[packages/react-core/src/types/chatManager.ts:36](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L36)--</td>-</tr>-<tr>-<td>--`responseTemplates`--</td>-<td>--\{\}--</td>-<td>--‐--</td>-<td>--[packages/react-core/src/types/chatManager.ts:38](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L38)--</td>-</tr>-</tbody>-</table>+```ts+messages: Message[];+```-## Defined in+### responseTemplates-[packages/react-core/src/types/chatManager.ts:33](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/chatManager.ts#L33)+```ts+{+}+```diff --git a/docs/docs/reference/js/react-core/type-aliases/UseThreadListManagerParams.md b/docs/docs/reference/js/react-core/type-aliases/UseThreadListManagerParams.mdnew file mode 100644index 000000000..aad80d987--- /dev/null+++ b/docs/docs/reference/js/react-core/type-aliases/UseThreadListManagerParams.md@@ -0,0 +1,56 @@+```ts+type UseThreadListManagerParams = {+ createThread: (firstMessage: UserMessage) => Promise<Thread>;+ deleteThread: (id: string) => Promise<void>;+ fetchThreadList: () => Promise<Thread[]>;+ onSelectThread: (threadId: string) => void;+ onSwitchToNew: () => void;+ updateThread: (updated: Thread) => Promise<Thread>;+};+```++Defined in: [packages/react-core/src/useThreadListManager.ts:11](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/useThreadListManager.ts#L11)++Parameters to be passed to the [useThreadListManager](../functions/useThreadListManager.md) hook++## Type declaration++### createThread()++```ts+(firstMessage: UserMessage) => Promise<Thread>;+```++Creates a new thread when user sends the first message++### deleteThread()++```ts+(id: string) => Promise<void>;+```++### fetchThreadList()++```ts+() => Promise<Thread[]>;+```++### onSelectThread()++```ts+(threadId: string) => void+```++### onSwitchToNew()++```ts+() => void+```++Allows user to clear chat state when switched to new thread++### updateThread()++```ts+(updated: Thread) => Promise<Thread>;+```diff --git a/docs/docs/reference/js/react-core/type-aliases/UseThreadManagerParams.md b/docs/docs/reference/js/react-core/type-aliases/UseThreadManagerParams.mdnew file mode 100644index 000000000..4ffe6d810--- /dev/null+++ b/docs/docs/reference/js/react-core/type-aliases/UseThreadManagerParams.md@@ -0,0 +1,53 @@+```ts+type UseThreadManagerParams = {+ loadThread: (threadId: string) => Promise<Message[]>;+ onProcessMessage: (props: {+ abortController: AbortController;+ message: CreateMessage;+ threadManager: ThreadManager;+ }) => Promise<Message[]>;+ responseTemplates: ResponseTemplate[];+ shouldResetThreadState: boolean;+ threadId: string | null;+};+```++Defined in: [packages/react-core/src/useThreadManager.ts:10](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/useThreadManager.ts#L10)++Parameters to be passed to the [useThreadManager](../functions/useThreadManager.md) hook++## Type declaration++### loadThread()++```ts+(threadId: string) => Promise<Message[]>;+```++### onProcessMessage()++```ts+(props: {+ abortController: AbortController;+ message: CreateMessage;+ threadManager: ThreadManager;+}) => Promise<Message[]>;+```++### responseTemplates++```ts+responseTemplates: ResponseTemplate[];+```++### shouldResetThreadState?++```ts+optional shouldResetThreadState: boolean;+```++### threadId++```ts+threadId: string | null;+```diff --git a/docs/docs/reference/js/react-core/type-aliases/UserMessage.md b/docs/docs/reference/js/react-core/type-aliases/UserMessage.mdindex d3eb582b9..0ee1193e9 100644--- a/docs/docs/reference/js/react-core/type-aliases/UserMessage.md+++ b/docs/docs/reference/js/react-core/type-aliases/UserMessage.md@@ -1,52 +1,56 @@```ts-type UserMessage = common & {+type UserMessage = {+ id: string;+ isVisuallyHidden: boolean;+} & {role: "user";- } &- | {+} & {+ context: JSONValue[];message: string;type: "prompt";- }- | {- actionDetails: string;- context: {- formState: Record<string, any>;- };- message: string;- type: "action";};```+Defined in: [packages/react-core/src/types/message.ts:14](https://github.com/thesysdev/crayon/blob/764dfdfef65ac5751288cdbd014d2017f4c5dc0d/js/packages/react-core/src/types/message.ts#L14)+## Type declaration-<table>-<thead>-<tr>-<th>Name</th>-<th>Type</th>-<th>Defined in</th>-</tr>-</thead>-<tbody>-<tr>-<td>+### id-`role`+```ts+id: string;+```-</td>-<td>+### isVisuallyHidden?-`"user"`+```ts+optional isVisuallyHidden: boolean;+```-</td>-<td>+## Type declaration-[packages/react-core/src/types/message.ts:7](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/message.ts#L7)+### role-</td>-</tr>-</tbody>-</table>+```ts+role: "user";+```++## Type declaration-## Defined in+### context?-[packages/react-core/src/types/message.ts:6](https://github.com/thesysdev/crayonai/blob/868f459d859250eef3283635b1127c3c68c35546/js/packages/react-core/src/types/message.ts#L6)+```ts+optional context: JSONValue[];+```++### message?++```ts+optional message: string;+```++### type++```ts+type: "prompt";+```diff --git a/docs/docs/reference/js/react-core/typedoc-sidebar.cjs b/docs/docs/reference/js/react-core/typedoc-sidebar.cjsnew file mode 100644index 000000000..aa7a3cf6e--- /dev/null+++ b/docs/docs/reference/js/react-core/typedoc-sidebar.cjs@@ -0,0 +1,170 @@+// @ts-check+/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */+const typedocSidebar = { items: [+ {+ "type": "category",+ "label": "Components",+ "items": [+ {+ "type": "doc",+ "id": "reference/js/react-core/functions/ChatProvider",+ "label": "ChatProvider"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/functions/MessageProvider",+ "label": "MessageProvider"+ }+ ]+ },+ {+ "type": "category",+ "label": "Contexts",+ "items": [+ {+ "type": "doc",+ "id": "reference/js/react-core/functions/MessageContext",+ "label": "MessageContext"+ }+ ]+ },+ {+ "type": "category",+ "label": "Hooks",+ "items": [+ {+ "type": "doc",+ "id": "reference/js/react-core/functions/useMessage",+ "label": "useMessage"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/functions/useThreadActions",+ "label": "useThreadActions"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/functions/useThreadListActions",+ "label": "useThreadListActions"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/functions/useThreadListManager",+ "label": "useThreadListManager"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/functions/useThreadListState",+ "label": "useThreadListState"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/functions/useThreadManager",+ "label": "useThreadManager"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/functions/useThreadManagerSelector",+ "label": "useThreadManagerSelector"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/functions/useThreadState",+ "label": "useThreadState"+ }+ ]+ },+ {+ "type": "category",+ "label": "Types",+ "items": [+ {+ "type": "doc",+ "id": "reference/js/react-core/interfaces/ResponseTemplate",+ "label": "ResponseTemplate"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/type-aliases/AssistantMessage",+ "label": "AssistantMessage"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/type-aliases/ChatManager",+ "label": "ChatManager"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/type-aliases/CreateMessage",+ "label": "CreateMessage"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/type-aliases/Message",+ "label": "Message"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/type-aliases/Thread",+ "label": "Thread"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/type-aliases/ThreadActions",+ "label": "ThreadActions"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/type-aliases/ThreadListActions",+ "label": "ThreadListActions"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/type-aliases/ThreadListManager",+ "label": "ThreadListManager"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/type-aliases/ThreadListState",+ "label": "ThreadListState"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/type-aliases/ThreadManager",+ "label": "ThreadManager"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/type-aliases/ThreadState",+ "label": "ThreadState"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/type-aliases/UserMessage",+ "label": "UserMessage"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/type-aliases/UseThreadListManagerParams",+ "label": "UseThreadListManagerParams"+ },+ {+ "type": "doc",+ "id": "reference/js/react-core/type-aliases/UseThreadManagerParams",+ "label": "UseThreadManagerParams"+ }+ ]+ },+ {+ "type": "category",+ "label": "Utilities",+ "items": [+ {+ "type": "doc",+ "id": "reference/js/react-core/functions/processStreamedMessage",+ "label": "processStreamedMessage"+ }+ ]+ }+]};+module.exports = typedocSidebar.items;\ No newline at end of filediff --git a/docs/docusaurus.config.ts b/docs/docusaurus.config.tsindex 673def339..d50f823f4 100644--- a/docs/docusaurus.config.ts+++ b/docs/docusaurus.config.ts@@ -5,24 +5,29 @@ import type * as Preset from "@docusaurus/preset-classic";// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)const typeDocConfig = {- sidebar: {- autoConfiguration: false,- },+ sidebar: { pretty: true },- parametersFormat: "htmlTable",+ indexFormat: "htmlTable",+ parametersFormat: "list",interfacePropertiesFormat: "htmlTable",classPropertiesFormat: "htmlTable",propertyMembersFormat: "htmlTable",- typeDeclarationFormat: "htmlTable",+ typeDeclarationFormat: "list",typeDeclarationVisibility: "compact",useCodeBlocks: true,hidePageHeader: true,hidePageTitle: true,expandObjects: true,expandParameters: true,+ mergeReadme: true,+ formatWithPrettier: true,+ watch: process.env.TYPEDOC_WATCH,// typedoc options- plugin: ["typedoc-plugin-markdown"],+ plugin: [+ "typedoc-plugin-markdown",+ "./custom/plugins/inject-custom-docs.mjs",+ ],};const config: Config = {@@ -168,8 +173,8 @@ const config: Config = {copyright: `Copyright © ${new Date().getFullYear()} <a href="https://www.thesys.dev">Thesys, Inc.</a>`,},prism: {- theme: prismThemes.github,- darkTheme: prismThemes.dracula,+ theme: prismThemes.nightOwlLight,+ darkTheme: prismThemes.nightOwl,},} satisfies Preset.ThemeConfig,plugins: [@@ -178,22 +183,11 @@ const config: Config = {{id: "react-core",entryPoints: ["../js/packages/react-core/src/index.ts"],- tsconfig: "../js/tsconfig.json",+ tsconfig: "../js/packages/react-core/tsconfig.json",out: "./docs/reference/js/react-core",...typeDocConfig,},],-- // [- // "docusaurus-plugin-typedoc",- // {- // id: "react-ui",- // entryPoints: ["../js/packages/react-ui/src/index.ts"],- // tsconfig: "../js/tsconfig.json",- // out: "./docs/reference/js/react-ui",- // ...typeDocConfig,- // },- // ],],};diff --git a/docs/package.json b/docs/package.jsonindex b49a75f2f..340d72435 100644--- a/docs/package.json+++ b/docs/package.json@@ -4,7 +4,7 @@"private": true,"scripts": {"docusaurus": "docusaurus",- "start": "docusaurus start -p 3003",+ "start": "TYPEDOC_WATCH=true docusaurus start -p 3003","build": "cd ../js/packages/react-ui && pnpm run build:storybook && cd ../../../docs && docusaurus build","swizzle": "docusaurus swizzle","deploy": "docusaurus deploy",@@ -26,6 +26,9 @@"react": "^18.0.0","react-dom": "^18.0.0"},+ "peerDependencies": {+ "@crayonai/stream": "file:../js/packages/stream"+ },"devDependencies": {"@docusaurus/module-type-aliases": "3.6.3","@docusaurus/tsconfig": "3.6.3",@@ -34,10 +37,11 @@"@types/react": "^19.0.8","@types/react-dom": "^19.0.3","docusaurus-plugin-react-docgen-typescript": "^1.2.1",- "docusaurus-plugin-typedoc": "^1.1.1",+ "docusaurus-plugin-typedoc": "^1.2.3",+ "prettier": "^3.5.3","react-docgen-typescript": "^2.2.2","typedoc": "^0.27.5",- "typedoc-plugin-markdown": "^4.3.3",+ "typedoc-plugin-markdown": "^4.4.2","typescript": "~5.6.2"},"browserslist": {diff --git a/docs/pnpm-lock.yaml b/docs/pnpm-lock.yamlindex b407015c8..15eb2c3ff 100644--- a/docs/pnpm-lock.yaml+++ b/docs/pnpm-lock.yaml@@ -10,10 +10,13 @@ importers:dependencies:'@crayonai/react-core':specifier: file:../js/packages/react-core- version: file:../js/packages/react-core([email protected]([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected])))+ version: file:../js/packages/react-core(@crayonai/stream@file:../js/packages/stream([email protected]([email protected]))([email protected]))([email protected]([email protected])([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected])))'@crayonai/react-ui':specifier: file:../js/packages/react-ui- version: file:../js/packages/react-ui(@crayonai/react-core@file:../js/packages/react-core([email protected]([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected]))))(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected])))+ version: file:../js/packages/react-ui(@crayonai/react-core@file:../js/packages/react-core(@crayonai/stream@file:../js/packages/stream([email protected]([email protected]))([email protected]))([email protected]([email protected])([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected]))))(@crayonai/stream@file:../js/packages/stream([email protected]([email protected]))([email protected]))(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected])))+ '@crayonai/stream':+ specifier: file:../js/packages/stream'@docusaurus/core':specifier: 3.6.3version: 3.6.3(@mdx-js/[email protected](@types/[email protected])([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected])@@ -61,8 +64,11 @@ importers:specifier: ^1.2.1docusaurus-plugin-typedoc:- specifier: ^1.1.1+ specifier: ^1.2.3+ prettier:+ specifier: ^3.5.3+ version: 3.5.3react-docgen-typescript:specifier: ^2.2.2version: 2.2.2([email protected])@@ -70,8 +76,8 @@ importers:specifier: ^0.27.5version: 0.27.5([email protected])typedoc-plugin-markdown:- specifier: ^4.3.3- version: 4.3.3([email protected]([email protected]))+ specifier: ^4.4.2+ version: 4.4.2([email protected]([email protected]))typescript:specifier: ~5.6.2version: 5.6.3@@ -807,7 +813,9 @@ packages:'@crayonai/react-core@file:../js/packages/react-core':resolution: {directory: ../js/packages/react-core, type: directory}peerDependencies:+ '@crayonai/stream': workspace:*ai: ^4.0.3+ eventsource-parser: ^3.0.0react: '>=18.0.0'react-dom: '>=18.0.0'tailwind-merge: ^2.5.4@@ -819,6 +827,7 @@ packages:resolution: {directory: ../js/packages/react-ui, type: directory}peerDependencies:'@crayonai/react-core': workspace:*+ '@crayonai/stream': workspace:*react: '>=18.0.0'react-dom: '>=18.0.0'tailwind-merge: ^2.5.4@@ -827,6 +836,12 @@ packages:tiny-invariant: ^1.3.3zustand: ^5.0.2+ '@crayonai/stream@file:../js/packages/stream':+ resolution: {directory: ../js/packages/stream, type: directory}+ peerDependencies:+ zod: ^3.24.1+ zod-to-json-schema: ^3.24.3+'@csstools/[email protected]':resolution: {integrity: sha512-7DFHlPuIxviKYZrOiwVU/PiHLm3lLUR23OMuEEtfEOQTOp9hzQ2JjdY6X5H18RVuUPJqSCI+qNnD5iOLMVE0bA==}engines: {node: '>=18'}@@ -2626,6 +2641,9 @@ packages:resolution: {integrity: sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==}+ resolution: {integrity: sha512-O3LfmiLJ5UQOGqrrl6ynCdfDgK50cd0nxy0JacFZ7ARhfhjdksTfScHAJ0580RNgNejLjRvu/7Yj9znY0sqeFA==}+resolution: {integrity: sha512-aVNobHnJqLiUelTaHat9DZ1qM2w0C0Eym4LPI/3JxOnSokGVdsl1T1kN7TFvsEAD8G47A6VKQ0TVHqbBnYMJlQ==}engines: {node: '>=12.0.0'}@@ -3236,10 +3254,10 @@ packages:react: '>=16.8.0'react-docgen-typescript: ^2.0.0- resolution: {integrity: sha512-jaSHPA2iQVE60Mugr/pbHzIWVR/7tp77A+e9+oYvZylupdNCwZ/5BadqcqZHdLQCsUZSvu4SlE3ob/ynN6aUAw==}+ resolution: {integrity: sha512-u1l2VlNRDK49A8G3iZW8iRt3LCmE6aeYnkG+nNqQBMVMqiv8Ifwe7gjsoQXTJXDxbMqUiTWWhqOLElP8B9s3fg==}peerDependencies:- typedoc-plugin-markdown: '>=4.3.0'+ typedoc-plugin-markdown: '>=4.4.0'resolution: {integrity: sha512-gd3ypIPfOMr9h5jIKq8E3sHOTCjeirnl0WK5ZdS1AW0Odt0b1PaWaHdJ4Qk4klv+YB9aJBS7mESXjFoDQPu6DA==}@@ -3453,6 +3471,10 @@ packages:resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==}engines: {node: '>=0.8.x'}+ resolution: {integrity: sha512-57iFiUzq6/LZSrY1vuE8pdko9ip7/gpX6zfpT16r70fyrqAWwtMHhKKPbxoJJN5E9XfG4hJBi44U3/MSj8TD5Q==}+ engines: {node: '>=18.0.0'}+resolution: {integrity: sha512-T1C0XCUimhxVQzW4zFipdx0SficT651NnkR0ZSH3yQwh+mFMdLfgjABVi4YtMTtaL4s168593DaoaRLMqryavA==}engines: {node: '>=18.0.0'}@@ -5259,6 +5281,11 @@ packages:resolution: {integrity: sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==}engines: {node: ^10 || ^12 || >=14}+ resolution: {integrity: sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==}+ engines: {node: '>=14'}+ hasBin: true+resolution: {integrity: sha512-AoJ5YMAcXKYxKhuJGdcvse+Voc6v1RgnsR3nWcYU7q4t6z0Q6T86sv5Zq8VIRbOWWFpvdGE83LtdSMNd+6Y0xw==}@@ -6081,8 +6108,8 @@ packages:resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==}- resolution: {integrity: sha512-kESCcNRzOcFJATLML2FoCfaTF9c0ujmbZ+UXsJvmNlFLS3v8tDKfDifreJXvXWa9d8gUcetZqOqFcZ/7+Ba34Q==}+ resolution: {integrity: sha512-kJVkU2Wd+AXQpyL6DlYXXRrfNrHrEIUgiABWH8Z+2Lz5Sq6an4dQ/hfvP75bbokjNDUskOdFlEEm/0fSVyC7eg==}engines: {node: '>= 18'}peerDependencies:typedoc: 0.27.x@@ -7408,9 +7435,11 @@ snapshots:'@colors/[email protected]':optional: true- '@crayonai/react-core@file:../js/packages/react-core([email protected]([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected])))':+ '@crayonai/react-core@file:../js/packages/react-core(@crayonai/stream@file:../js/packages/stream([email protected]([email protected]))([email protected]))([email protected]([email protected])([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected])))':dependencies:+ '@crayonai/stream': file:../js/packages/stream([email protected]([email protected]))([email protected])ai: 4.1.7([email protected])([email protected])+ eventsource-parser: 3.0.0react: 18.3.1react-dom: 18.3.1([email protected])tailwind-merge: 2.6.0@@ -7419,9 +7448,10 @@ snapshots:zod: 3.24.1zustand: 5.0.3(@types/[email protected])([email protected])([email protected])([email protected]([email protected]))- '@crayonai/react-ui@file:../js/packages/react-ui(@crayonai/react-core@file:../js/packages/react-core([email protected]([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected]))))(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected])))':+ '@crayonai/react-ui@file:../js/packages/react-ui(@crayonai/react-core@file:../js/packages/react-core(@crayonai/stream@file:../js/packages/stream([email protected]([email protected]))([email protected]))([email protected]([email protected])([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected]))))(@crayonai/stream@file:../js/packages/stream([email protected]([email protected]))([email protected]))(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected])))':dependencies:- '@crayonai/react-core': file:../js/packages/react-core([email protected]([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected])))+ '@crayonai/react-core': file:../js/packages/react-core(@crayonai/stream@file:../js/packages/stream([email protected]([email protected]))([email protected]))([email protected]([email protected])([email protected]))([email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected])))+ '@crayonai/stream': file:../js/packages/stream([email protected]([email protected]))([email protected])'@radix-ui/react-accordion': 1.2.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-aspect-ratio': 1.1.1(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])@@ -7432,10 +7462,10 @@ snapshots:'@radix-ui/react-slider': 1.2.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-switch': 1.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])'@radix-ui/react-tabs': 1.1.2(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])- '@storybook/addon-styling-webpack': 1.0.1([email protected])([email protected]([email protected]))- '@storybook/core-events': 8.5.8([email protected])- '@storybook/manager-api': 8.5.3([email protected])- '@storybook/theming': 8.5.3([email protected])+ '@storybook/addon-styling-webpack': 1.0.1([email protected]([email protected]))([email protected]([email protected]))+ '@storybook/core-events': 8.5.8([email protected]([email protected]))+ '@storybook/manager-api': 8.5.3([email protected]([email protected]))+ '@storybook/theming': 8.5.3([email protected]([email protected]))clsx: 2.1.1date-fns: 4.1.0lodash-es: 4.17.21@@ -7456,6 +7486,14 @@ snapshots:- storybook- webpack+ '@crayonai/stream@file:../js/packages/stream([email protected]([email protected]))([email protected])':+ dependencies:+ best-effort-json-parser: 1.1.3+ eventsource-encoder: 1.0.1+ tiny-invariant: 1.3.3+ zod: 3.24.1+ zod-to-json-schema: 3.24.1([email protected])+'@csstools/[email protected](@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])':dependencies:'@csstools/css-parser-algorithms': 3.0.4(@csstools/[email protected])@@ -9224,18 +9262,18 @@ snapshots:micromark-util-character: 1.2.0micromark-util-symbol: 1.1.0+ '@storybook/[email protected]([email protected]([email protected]))([email protected]([email protected]))':dependencies:- '@storybook/node-logger': 8.5.2([email protected])+ '@storybook/node-logger': 8.5.2([email protected]([email protected]))webpack: 5.97.1([email protected])transitivePeerDependencies:- storybook- '@storybook/[email protected]([email protected])':dependencies:- storybook: 8.5.2+ storybook: 8.5.2([email protected])- '@storybook/[email protected]':+ '@storybook/[email protected]([email protected])':dependencies:'@storybook/csf': 0.1.12better-opn: 3.0.2@@ -9248,6 +9286,8 @@ snapshots:semver: 7.6.3util: 0.12.5ws: 8.18.0+ optionalDependencies:+ prettier: 3.5.3transitivePeerDependencies:- bufferutil- supports-color@@ -9257,17 +9297,17 @@ snapshots:dependencies:type-fest: 2.19.0- '@storybook/[email protected]([email protected])':dependencies:- storybook: 8.5.2+ storybook: 8.5.2([email protected])- '@storybook/[email protected]([email protected])':dependencies:- storybook: 8.5.2+ storybook: 8.5.2([email protected])- '@storybook/[email protected]([email protected])':dependencies:- storybook: 8.5.2+ storybook: 8.5.2([email protected])'@svgr/[email protected](@babel/[email protected])':dependencies:@@ -9891,6 +9931,8 @@ snapshots:+ [email protected]: {}+dependencies:open: 8.4.2@@ -10521,9 +10563,9 @@ snapshots:react: 18.3.1react-docgen-typescript: 2.2.2([email protected])dependencies:- typedoc-plugin-markdown: 4.3.3([email protected]([email protected]))+ typedoc-plugin-markdown: 4.4.2([email protected]([email protected]))dependencies:@@ -10756,6 +10798,8 @@ snapshots:+ [email protected]: {}+@@ -12937,6 +12981,8 @@ snapshots:picocolors: 1.1.1source-map-js: 1.2.1+ [email protected]: {}+dependencies:lodash: 4.17.21@@ -13715,9 +13761,11 @@ snapshots:dependencies:- '@storybook/core': 8.5.2+ '@storybook/core': 8.5.2([email protected])+ optionalDependencies:+ prettier: 3.5.3transitivePeerDependencies:- bufferutil- supports-color@@ -13928,7 +13976,7 @@ snapshots:dependencies:is-typedarray: 1.0.0dependencies:typedoc: 0.27.5([email protected])diff --git a/docs/sidebars.ts b/docs/sidebars.tsindex 361e60a45..735efa82d 100644--- a/docs/sidebars.ts+++ b/docs/sidebars.ts@@ -1,4 +1,5 @@import type { SidebarsConfig } from "@docusaurus/plugin-content-docs";+import typedocSidebar from "./docs/reference/js/react-core/typedoc-sidebar.cjs";// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)@@ -41,12 +42,11 @@ const sidebars: SidebarsConfig = {{type: "category",label: "JS API Reference",- items: [- {- type: "autogenerated",- dirName: "reference/js",- },- ],+ link: {+ type: "doc",+ id: "reference/js/react-core/index",+ },+ items: typedocSidebar,},],};diff --git a/docs/tsconfig.json b/docs/tsconfig.jsonindex 920d7a652..8cac85362 100644--- a/docs/tsconfig.json+++ b/docs/tsconfig.json@@ -2,7 +2,7 @@// This file is not used in compilation. It is here just for a nice editor experience."extends": "@docusaurus/tsconfig","compilerOptions": {- "baseUrl": "."+ "baseUrl": ".",},"exclude": [".docusaurus", "build"]}diff --git a/js/packages/react-core/README.md b/js/packages/react-core/README.mdindex 2311487e5..b7095fb5b 100644--- a/js/packages/react-core/README.md+++ b/js/packages/react-core/README.md@@ -1 +1,3 @@-## Core Framework+# Core Framework (`react-core`)++This package provides the core framework and hooks for managing state and agents.diff --git a/js/packages/react-core/src/hooks/useMessage.tsx b/js/packages/react-core/src/hooks/useMessage.tsxindex c560254f0..f0c4e229c 100644--- a/js/packages/react-core/src/hooks/useMessage.tsx+++ b/js/packages/react-core/src/hooks/useMessage.tsx@@ -2,8 +2,15 @@ import { createContext, useContext } from "react";import { useShallow } from "zustand/shallow";import { Message } from "../types";+/**+ * @category Contexts+ */export const MessageContext = createContext<{ message: Message } | null>(null);+/**+ * @category Hooks+ * @returns The current message. See {@link Message} for more information.+ */export const useMessage = () => {const context = useContext(MessageContext);if (!context) {@@ -12,6 +19,9 @@ export const useMessage = () => {return context;};+/**+ * @category Components+ */export const MessageProvider = ({message,children,diff --git a/js/packages/react-core/src/hooks/useThreadActions.ts b/js/packages/react-core/src/hooks/useThreadActions.tsindex 7fd219067..61e81c959 100644--- a/js/packages/react-core/src/hooks/useThreadActions.ts+++ b/js/packages/react-core/src/hooks/useThreadActions.ts@@ -4,9 +4,6 @@ import { ThreadActions } from "../types";/*** @category Hooks- *- * @remarks- * useThreadActions*/export const useThreadActions = (): ThreadActions => {const { threadManager } = useChatContext();diff --git a/js/packages/react-core/src/index.ts b/js/packages/react-core/src/index.tsindex b47ce14a6..99a2d33b9 100644--- a/js/packages/react-core/src/index.ts+++ b/js/packages/react-core/src/index.ts@@ -7,7 +7,7 @@ export { useThreadListState } from "./hooks/useThreadListState";export { useThreadManagerSelector } from "./hooks/useThreadManagerSelector";export { useThreadState } from "./hooks/useThreadState";export { processStreamedMessage } from "./stream/processStreamedMessage";-export { useThreadListManager } from "./useThreadListManager";-export { useThreadManager } from "./useThreadManager";+export { UseThreadListManagerParams, useThreadListManager } from "./useThreadListManager";+export { UseThreadManagerParams, useThreadManager } from "./useThreadManager";export * from "./types";diff --git a/js/packages/react-core/src/stream/processStreamedMessage.ts b/js/packages/react-core/src/stream/processStreamedMessage.tsindex ba7e749ff..91d1914ef 100644--- a/js/packages/react-core/src/stream/processStreamedMessage.ts+++ b/js/packages/react-core/src/stream/processStreamedMessage.ts@@ -10,6 +10,9 @@ import { createParser } from "eventsource-parser";import invariant from "tiny-invariant";import { AssistantMessage } from "../types";+/**+ * @category Utilities+ */export const processStreamedMessage = async ({response,createMessage,diff --git a/js/packages/react-core/src/types/chatManager.ts b/js/packages/react-core/src/types/chatManager.tsindex 5b7af9a51..eb52cea66 100644--- a/js/packages/react-core/src/types/chatManager.ts+++ b/js/packages/react-core/src/types/chatManager.ts@@ -3,6 +3,8 @@ import { ResponseTemplate } from "./responseTemplate";/*** Represents a chat thread+ *+ * @category Types*/export type Thread = {/** Unique identifier for the thread */@@ -18,6 +20,8 @@ export type Thread = {/*** Actions available for managing a thread* @template T - The message type used in the thread+ *+ * @category Types*/export type ThreadActions = {processMessage: (message: CreateMessage) => Promise<void>;@@ -29,6 +33,8 @@ export type ThreadActions = {/*** Represents the state of a thread+ *+ * @category Types*/export type ThreadState = {/** Indicates if the thread is currently processing and controls should be disabled */@@ -45,11 +51,15 @@ export type ThreadState = {/*** Combines thread state and actions* @template T - The message type used in the thread+ *+ * @category Types*/export type ThreadManager = ThreadState & ThreadActions;/*** Represents the state of the thread list+ *+ * @category Types*/export type ThreadListState = {threads: Thread[];@@ -61,6 +71,8 @@ export type ThreadListState = {/*** Actions available for managing the thread list+ *+ * @category Types*/export type ThreadListActions = {load: () => void;@@ -73,11 +85,15 @@ export type ThreadListActions = {/*** Combines thread list state and actions+ *+ * @category Types*/export type ThreadListManager = ThreadListState & ThreadListActions;/*** Main chat manager combining thread and thread list management+ *+ * @category Types*/export type ChatManager = {threadListManager: ThreadListManager;diff --git a/js/packages/react-core/src/types/message.ts b/js/packages/react-core/src/types/message.tsindex c9143797d..b2b846f12 100644--- a/js/packages/react-core/src/types/message.ts+++ b/js/packages/react-core/src/types/message.ts@@ -1,11 +1,17 @@import { JSONValue } from "@crayonai/stream";-type common = {+/**+ * @inline+ */+type Common = {id: string;isVisuallyHidden?: boolean;};-export type UserMessage = common & {+/**+ * @category Types+ */+export type UserMessage = Common & {role: "user";} & {type: "prompt";@@ -13,7 +19,10 @@ export type UserMessage = common & {context?: JSONValue[];};-export type AssistantMessage = common & {+/**+ * @category Types+ */+export type AssistantMessage = Common & {role: "assistant";context?: JSONValue[];message?: (@@ -29,10 +38,17 @@ export type AssistantMessage = common & {)[];};+/**+ * See {@link UserMessage} and {@link AssistantMessage} for more information.+ *+ * @category Types+ */export type Message = UserMessage | AssistantMessage;/*** Represents a message being created, with an optional ID* @extends Omit<Message, "id">+ *+ * @category Types*/export type CreateMessage = Omit<UserMessage, "id">;diff --git a/js/packages/react-core/src/types/responseTemplate.ts b/js/packages/react-core/src/types/responseTemplate.tsindex e741f8ddd..27722f4ff 100644--- a/js/packages/react-core/src/types/responseTemplate.ts+++ b/js/packages/react-core/src/types/responseTemplate.ts@@ -1,3 +1,6 @@+/**+ * @category Types+ */export interface ResponseTemplate {name: string;Component: React.ComponentType<any>;diff --git a/js/packages/react-core/src/useThreadListManager.ts b/js/packages/react-core/src/useThreadListManager.tsindex 672172c55..f7503a1ca 100644--- a/js/packages/react-core/src/useThreadListManager.ts+++ b/js/packages/react-core/src/useThreadListManager.ts@@ -2,21 +2,32 @@ import { useMemo, useRef } from "react";import { createStore, useStore } from "zustand";import { Thread, ThreadListManager, UserMessage } from "./types";-type Props = {+/**+ * Parameters to be passed to the {@link useThreadListManager} hook+ *+ * @inline+ * @category Types+ */+export type UseThreadListManagerParams = {fetchThreadList: () => Promise<Thread[]>;deleteThread: (id: string) => Promise<void>;updateThread: (updated: Thread) => Promise<Thread>;- // allows user to clear chat state when switched to new thread+ /** Allows user to clear chat state when switched to new thread */onSwitchToNew: () => void;onSelectThread: (threadId: string) => void;+ /** Creates a new thread when user sends the first message */createThread: (firstMessage: UserMessage) => Promise<Thread>;};type DefaultManager = ThreadListManager;-export const useThreadListManager = (props: Props): DefaultManager => {- const propsRef = useRef(props);- propsRef.current = props;+/**+ * @category Hooks+ * @returns A ThreadListManager instance+ */+export const useThreadListManager = (params: UseThreadListManagerParams): DefaultManager => {+ const propsRef = useRef(params);+ propsRef.current = params;const store = useMemo(() => {return createStore<DefaultManager>((set) => {diff --git a/js/packages/react-core/src/useThreadManager.ts b/js/packages/react-core/src/useThreadManager.tsindex 22a68aea1..48d0e6c69 100644--- a/js/packages/react-core/src/useThreadManager.ts+++ b/js/packages/react-core/src/useThreadManager.ts@@ -2,7 +2,12 @@ import { useEffect, useMemo, useRef } from "react";import { createStore, useStore } from "zustand";import { CreateMessage, Message, ResponseTemplate, ThreadManager } from "./types";-type Props = {+/**+ * Parameters to be passed to the {@link useThreadManager} hook+ *+ * @category Types+ */+export type UseThreadManagerParams = {threadId: string | null;shouldResetThreadState?: boolean;loadThread: (threadId: string) => Promise<Message[]>;@@ -14,9 +19,13 @@ type Props = {responseTemplates: ResponseTemplate[];};-export const useThreadManager = (props: Props): ThreadManager => {- const propsRef = useRef(props);- propsRef.current = props;+/**+ * @category Hooks+ * @returns The thread manager+ */+export const useThreadManager = (params: UseThreadManagerParams): ThreadManager => {+ const propsRef = useRef(params);+ propsRef.current = params;const store = useMemo(() => {return createStore<@@ -87,11 +96,11 @@ export const useThreadManager = (props: Props): ThreadManager => {}, [propsRef]);useEffect(() => {- if (!props.shouldResetThreadState) {+ if (!params.shouldResetThreadState) {return;}- const threadId = props.threadId;+ const threadId = params.threadId;// cancel any previous requestsstore.getState().onCancel();@@ -99,7 +108,7 @@ export const useThreadManager = (props: Props): ThreadManager => {if (threadId) {store.setState({ isLoadingMessages: true });- props+ params.loadThread(threadId).then((messages) => {store.setState({ messages });@@ -111,7 +120,7 @@ export const useThreadManager = (props: Props): ThreadManager => {store.setState({ isLoadingMessages: false });});}- }, [props.threadId, props.shouldResetThreadState]);+ }, [params.threadId, params.shouldResetThreadState]);return useStore(store);};