@copilotkit/react-core 1.50.0-beta.6 → 1.50.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/{chunk-PQPWQ6GH.mjs → chunk-BLDHD6Q2.mjs} +2 -2
  3. package/dist/{chunk-ZCV3A2FP.mjs → chunk-EKDPRKZT.mjs} +7 -9
  4. package/dist/chunk-EKDPRKZT.mjs.map +1 -0
  5. package/dist/{chunk-OX2QTNTD.mjs → chunk-KYY2WZSR.mjs} +2 -2
  6. package/dist/chunk-RQ6LWR6S.mjs +37 -0
  7. package/dist/chunk-RQ6LWR6S.mjs.map +1 -0
  8. package/dist/hooks/index.js +64 -43
  9. package/dist/hooks/index.js.map +1 -1
  10. package/dist/hooks/index.mjs +4 -4
  11. package/dist/hooks/use-copilot-chat-headless_c.js +6 -8
  12. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
  13. package/dist/hooks/use-copilot-chat-headless_c.mjs +2 -2
  14. package/dist/hooks/use-copilot-chat.js +6 -8
  15. package/dist/hooks/use-copilot-chat.js.map +1 -1
  16. package/dist/hooks/use-copilot-chat.mjs +2 -2
  17. package/dist/hooks/use-copilot-chat_internal.js +6 -8
  18. package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
  19. package/dist/hooks/use-copilot-chat_internal.mjs +1 -1
  20. package/dist/hooks/use-copilot-readable.d.ts +4 -3
  21. package/dist/hooks/use-copilot-readable.js +29 -6
  22. package/dist/hooks/use-copilot-readable.js.map +1 -1
  23. package/dist/hooks/use-copilot-readable.mjs +1 -1
  24. package/dist/index.js +64 -43
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +4 -4
  27. package/package.json +7 -7
  28. package/src/hooks/use-copilot-readable.ts +34 -15
  29. package/dist/chunk-2CYJN455.mjs +0 -14
  30. package/dist/chunk-2CYJN455.mjs.map +0 -1
  31. package/dist/chunk-ZCV3A2FP.mjs.map +0 -1
  32. /package/dist/{chunk-PQPWQ6GH.mjs.map → chunk-BLDHD6Q2.mjs.map} +0 -0
  33. /package/dist/{chunk-OX2QTNTD.mjs.map → chunk-KYY2WZSR.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # ui
2
2
 
3
+ ## 1.50.0-beta.8
4
+
5
+ ### Patch Changes
6
+
7
+ - @copilotkit/runtime-client-gql@1.50.0-beta.8
8
+ - @copilotkit/shared@1.50.0-beta.8
9
+
10
+ ## 1.50.0-beta.7
11
+
12
+ ### Patch Changes
13
+
14
+ - 6ce0edc: - fix: refrain from re-setting context infinitely if it hasnt changed
15
+ - fix: pass only strings to context value
16
+ - fix: allow custom convert and availability setup
17
+ - @copilotkit/runtime-client-gql@1.50.0-beta.7
18
+ - @copilotkit/shared@1.50.0-beta.7
19
+
3
20
  ## 1.50.0-beta.6
4
21
 
5
22
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotChatInternal
3
- } from "./chunk-ZCV3A2FP.mjs";
3
+ } from "./chunk-EKDPRKZT.mjs";
4
4
 
5
5
  // src/hooks/use-copilot-chat.ts
6
6
  function useCopilotChat(options = {}) {
@@ -33,4 +33,4 @@ function useCopilotChat(options = {}) {
33
33
  export {
34
34
  useCopilotChat
35
35
  };
36
- //# sourceMappingURL=chunk-PQPWQ6GH.mjs.map
36
+ //# sourceMappingURL=chunk-BLDHD6Q2.mjs.map
@@ -33,7 +33,7 @@ import {
33
33
  useSuggestions
34
34
  } from "@copilotkitnext/react";
35
35
 
36
- // ../../node_modules/.pnpm/@ag-ui+core@0.0.42-alpha.1/node_modules/@ag-ui/core/dist/index.mjs
36
+ // ../../node_modules/.pnpm/@ag-ui+core@0.0.42/node_modules/@ag-ui/core/dist/index.mjs
37
37
  import { z } from "zod";
38
38
  import { z as z2 } from "zod";
39
39
  var FunctionCallSchema = z.object({
@@ -576,16 +576,15 @@ function useCopilotChatInternal({
576
576
  }),
577
577
  [latestSendMessageFunc]
578
578
  );
579
- const latestSetMessages = useUpdatedRef(agent == null ? void 0 : agent.setMessages);
580
579
  const latestSetMessagesFunc = useCallback(
581
580
  (messages) => {
582
581
  var _a2, _b2;
583
582
  if (messages.every((message) => message instanceof DeprecatedGqlMessage)) {
584
- return (_a2 = latestSetMessages.current) == null ? void 0 : _a2.call(latestSetMessages, gqlToAGUI(messages));
583
+ return (_a2 = agent == null ? void 0 : agent.setMessages) == null ? void 0 : _a2.call(agent, gqlToAGUI(messages));
585
584
  }
586
- return (_b2 = latestSetMessages.current) == null ? void 0 : _b2.call(latestSetMessages, messages);
585
+ return (_b2 = agent == null ? void 0 : agent.setMessages) == null ? void 0 : _b2.call(agent, messages);
587
586
  },
588
- [latestSetMessages, agent]
587
+ [agent == null ? void 0 : agent.setMessages, agent]
589
588
  );
590
589
  const latestReload = useUpdatedRef(reload);
591
590
  const latestReloadFunc = useAsyncCallback(
@@ -594,11 +593,10 @@ function useCopilotChatInternal({
594
593
  }),
595
594
  [latestReload]
596
595
  );
597
- const latestStop = useUpdatedRef(agent == null ? void 0 : agent.abortRun);
598
596
  const latestStopFunc = useCallback(() => {
599
597
  var _a2;
600
- return (_a2 = latestStop.current) == null ? void 0 : _a2.call(latestStop);
601
- }, [latestStop]);
598
+ return (_a2 = agent == null ? void 0 : agent.abortRun) == null ? void 0 : _a2.call(agent);
599
+ }, [agent == null ? void 0 : agent.abortRun]);
602
600
  const latestReset = useUpdatedRef(reset);
603
601
  const latestResetFunc = useCallback(() => {
604
602
  return latestReset.current();
@@ -745,4 +743,4 @@ export {
745
743
  useCopilotChatInternal,
746
744
  defaultSystemMessage
747
745
  };
748
- //# sourceMappingURL=chunk-ZCV3A2FP.mjs.map
746
+ //# sourceMappingURL=chunk-EKDPRKZT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-copilot-chat_internal.ts","../../../node_modules/.pnpm/@ag-ui+core@0.0.42/node_modules/@ag-ui/core/src/types.ts","../../../node_modules/.pnpm/@ag-ui+core@0.0.42/node_modules/@ag-ui/core/src/events.ts"],"sourcesContent":["import { useRef, useEffect, useCallback, useMemo, useState, createElement } from \"react\";\nimport { useCopilotContext } from \"../context/copilot-context\";\nimport { SystemMessageFunction } from \"../types\";\nimport { useAsyncCallback } from \"../components/error-boundary/error-utils\";\nimport { Message } from \"@copilotkit/shared\";\nimport { gqlToAGUI, Message as DeprecatedGqlMessage } from \"@copilotkit/runtime-client-gql\";\nimport { useLangGraphInterruptRender } from \"./use-langgraph-interrupt-render\";\nimport {\n useAgent,\n useCopilotChatConfiguration,\n useCopilotKit,\n useRenderCustomMessages,\n useSuggestions,\n} from \"@copilotkitnext/react\";\nimport { Suggestion } from \"@copilotkitnext/core\";\nimport { useLazyToolRenderer } from \"./use-lazy-tool-renderer\";\nimport {\n useConfigureChatSuggestions,\n UseCopilotChatSuggestionsConfiguration,\n} from \"./use-configure-chat-suggestions\";\nimport { AbstractAgent, AGUIConnectNotImplementedError } from \"@ag-ui/client\";\nimport {\n CoAgentStateRenderBridge,\n type CoAgentStateRenderBridgeProps,\n} from \"./use-coagent-state-render-bridge\";\n\n/**\n * The type of suggestions to use in the chat.\n *\n * `auto` - Suggestions are generated automatically.\n * `manual` - Suggestions are controlled programmatically.\n * `SuggestionItem[]` - Static suggestions array.\n */\nexport type ChatSuggestions = \"auto\" | \"manual\" | Omit<Suggestion, \"isLoading\">[];\n\nexport interface AppendMessageOptions {\n /**\n * Whether to run the chat completion after appending the message. Defaults to `true`.\n */\n followUp?: boolean;\n /**\n * Whether to clear the suggestions after appending the message. Defaults to `true`.\n */\n clearSuggestions?: boolean;\n}\n\nexport interface UseCopilotChatOptions {\n /**\n * A unique identifier for the chat. If not provided, a random one will be\n * generated. When provided, the `useChat` hook with the same `id` will\n * have shared states across components.\n */\n id?: string;\n\n /**\n * HTTP headers to be sent with the API request.\n */\n headers?: Record<string, string> | Headers;\n\n /**\n * Initial messages to populate the chat with.\n */\n initialMessages?: Message[];\n\n /**\n * A function to generate the system message. Defaults to `defaultSystemMessage`.\n */\n makeSystemMessage?: SystemMessageFunction;\n\n /**\n * Disables inclusion of CopilotKit’s default system message. When true, no system message is sent (this also suppresses any custom message from <code>makeSystemMessage</code>).\n */\n disableSystemMessage?: boolean;\n\n suggestions?: ChatSuggestions;\n}\n\nexport interface MCPServerConfig {\n endpoint: string;\n apiKey?: string;\n}\n\n// Old suggestion item interface, for returning from useCopilotChatInternal\ninterface SuggestionItem {\n title: string;\n message: string;\n partial?: boolean;\n className?: string;\n}\n\nexport interface UseCopilotChatReturn {\n /**\n * @deprecated use `messages` instead, this is an old non ag-ui version of the messages\n * Array of messages currently visible in the chat interface\n *\n * This is the visible messages, not the raw messages from the runtime client.\n */\n visibleMessages: DeprecatedGqlMessage[];\n\n /**\n * The messages that are currently in the chat in AG-UI format.\n */\n messages: Message[];\n\n /** @deprecated use `sendMessage` in `useCopilotChatHeadless_c` instead. This will be removed in a future major version. */\n appendMessage: (message: DeprecatedGqlMessage, options?: AppendMessageOptions) => Promise<void>;\n\n /**\n * Send a new message to the chat\n *\n * ```tsx\n * await sendMessage({\n * id: \"123\",\n * role: \"user\",\n * content: \"Hello, process this request\",\n * });\n * ```\n */\n sendMessage: (message: Message, options?: AppendMessageOptions) => Promise<void>;\n\n /**\n * Replace all messages in the chat\n *\n * ```tsx\n * setMessages([\n * { id: \"123\", role: \"user\", content: \"Hello, process this request\" },\n * { id: \"456\", role: \"assistant\", content: \"Hello, I'm the assistant\" },\n * ]);\n * ```\n *\n * **Deprecated** non-ag-ui version:\n *\n * ```tsx\n * setMessages([\n * new TextMessage({\n * content: \"Hello, process this request\",\n * role: gqlRole.User,\n * }),\n * new TextMessage({\n * content: \"Hello, I'm the assistant\",\n * role: gqlRole.Assistant,\n * ]);\n * ```\n *\n */\n setMessages: (messages: Message[] | DeprecatedGqlMessage[]) => void;\n\n /**\n * Remove a specific message by ID\n *\n * ```tsx\n * deleteMessage(\"123\");\n * ```\n */\n deleteMessage: (messageId: string) => void;\n\n /**\n * Regenerate the response for a specific message\n *\n * ```tsx\n * reloadMessages(\"123\");\n * ```\n */\n reloadMessages: (messageId: string) => Promise<void>;\n\n /**\n * Stop the current message generation\n *\n * ```tsx\n * if (isLoading) {\n * stopGeneration();\n * }\n * ```\n */\n stopGeneration: () => void;\n\n /**\n * Clear all messages and reset chat state\n *\n * ```tsx\n * reset();\n * console.log(messages); // []\n * ```\n */\n reset: () => void;\n\n /**\n * Whether the chat is currently generating a response\n *\n * ```tsx\n * if (isLoading) {\n * console.log(\"Loading...\");\n * } else {\n * console.log(\"Not loading\");\n * }\n */\n isLoading: boolean;\n\n /**\n * Whether the chat agent is available to generate responses\n *\n * ```tsx\n * if (isAvailable) {\n * console.log(\"Loading...\");\n * } else {\n * console.log(\"Not loading\");\n * }\n */\n isAvailable: boolean;\n\n /** Manually trigger chat completion (advanced usage) */\n runChatCompletion: () => Promise<Message[]>;\n\n /** MCP (Model Context Protocol) server configurations */\n mcpServers: MCPServerConfig[];\n\n /** Update MCP server configurations */\n setMcpServers: (mcpServers: MCPServerConfig[]) => void;\n\n /**\n * Current suggestions array\n * Use this to read the current suggestions or in conjunction with setSuggestions for manual control\n */\n suggestions: Suggestion[];\n\n /**\n * Manually set suggestions\n * Useful for manual mode or custom suggestion workflows\n */\n setSuggestions: (suggestions: Omit<Suggestion, \"isLoading\">[]) => void;\n\n /**\n * Trigger AI-powered suggestion generation\n * Uses configurations from useCopilotChatSuggestions hooks\n * Respects global debouncing - only one generation can run at a time\n *\n * ```tsx\n * generateSuggestions();\n * console.log(suggestions); // [suggestion1, suggestion2, suggestion3]\n * ```\n */\n generateSuggestions: () => Promise<void>;\n\n /**\n * Clear all current suggestions\n * Also resets suggestion generation state\n */\n resetSuggestions: () => void;\n\n /** Whether suggestions are currently being generated */\n isLoadingSuggestions: boolean;\n\n /** Interrupt content for human-in-the-loop workflows */\n interrupt: string | React.ReactElement | null;\n\n agent?: ReturnType<typeof useAgent>[\"agent\"];\n\n threadId?: string;\n}\n\nfunction useConfigureSuggestions(suggestions?: UseCopilotChatOptions[\"suggestions\"]) {\n let suggestionsConfig: UseCopilotChatSuggestionsConfiguration;\n\n if (Array.isArray(suggestions)) {\n suggestionsConfig = {\n suggestions,\n available: \"always\",\n };\n } else if (suggestions === \"auto\") {\n suggestionsConfig = {\n available: suggestions === \"auto\" ? \"always\" : \"disabled\",\n instructions:\n \"Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls.\",\n };\n } else {\n suggestionsConfig = { available: \"disabled\" } as UseCopilotChatSuggestionsConfiguration;\n }\n\n useConfigureChatSuggestions(suggestionsConfig);\n}\n\nexport function useCopilotChatInternal({\n suggestions,\n}: UseCopilotChatOptions = {}): UseCopilotChatReturn {\n const { copilotkit } = useCopilotKit();\n const { threadId, agentSession } = useCopilotContext();\n const existingConfig = useCopilotChatConfiguration();\n const [agentAvailable, setAgentAvailable] = useState(false);\n useConfigureSuggestions(suggestions);\n\n // Apply priority: props > existing config > defaults\n const resolvedAgentId = existingConfig?.agentId ?? \"default\";\n const { agent } = useAgent({ agentId: resolvedAgentId });\n\n useEffect(() => {\n const connect = async (agent: AbstractAgent) => {\n setAgentAvailable(false);\n try {\n await copilotkit.connectAgent({ agent });\n setAgentAvailable(true);\n } catch (error) {\n if (error instanceof AGUIConnectNotImplementedError) {\n // connect not implemented, ignore\n } else {\n throw error;\n }\n }\n };\n if (agent && existingConfig?.threadId && agent.threadId !== existingConfig.threadId) {\n agent.threadId = existingConfig.threadId;\n connect(agent);\n }\n return () => {};\n }, [existingConfig?.threadId, agent, copilotkit, resolvedAgentId]);\n\n const interrupt = useLangGraphInterruptRender(agent);\n\n const reset = () => {\n agent?.setMessages([]);\n agent?.setState(null);\n };\n\n const deleteMessage = useCallback(\n (messageId: string) => {\n const filteredMessages = (agent?.messages ?? []).filter(\n (message) => message.id !== messageId,\n );\n agent?.setMessages(filteredMessages);\n },\n [agent?.setMessages, agent?.messages],\n );\n\n const latestDelete = useUpdatedRef(deleteMessage);\n const latestDeleteFunc = useCallback(\n (messageId: string) => {\n return latestDelete.current(messageId);\n },\n [latestDelete],\n );\n\n const currentSuggestions = useSuggestions({ agentId: resolvedAgentId });\n\n const reload = useAsyncCallback(\n async (reloadMessageId: string): Promise<void> => {\n const messages = agent?.messages ?? [];\n // TODO: get isLoading\n const isLoading = false;\n if (isLoading || messages.length === 0) {\n return;\n }\n\n const reloadMessageIndex = messages.findIndex((msg) => msg.id === reloadMessageId);\n if (reloadMessageIndex === -1) {\n console.warn(`Message with id ${reloadMessageId} not found`);\n return;\n }\n\n const reloadMessageRole = messages[reloadMessageIndex].role;\n if (reloadMessageRole !== \"assistant\") {\n console.warn(`Regenerate cannot be performed on ${reloadMessageRole} role`);\n return;\n }\n let historyCutoff: Message[] = [messages[0]];\n\n if (messages.length > 2 && reloadMessageIndex !== 0) {\n // message to regenerate from is now first.\n // Work backwards to find the first the closest user message\n const lastUserMessageBeforeRegenerate = messages\n .slice(0, reloadMessageIndex)\n .reverse()\n .find((msg) => msg.role === \"user\");\n\n if (!lastUserMessageBeforeRegenerate) {\n historyCutoff = [messages[0]];\n } else {\n const indexOfLastUserMessageBeforeRegenerate = messages.findIndex(\n (msg) => msg.id === lastUserMessageBeforeRegenerate.id,\n );\n // Include the user message, remove everything after it\n historyCutoff = messages.slice(0, indexOfLastUserMessageBeforeRegenerate + 1);\n }\n } else if (messages.length > 2 && reloadMessageIndex === 0) {\n historyCutoff = [messages[0], messages[1]];\n }\n\n agent?.setMessages(historyCutoff);\n\n if (agent) {\n copilotkit.runAgent({ agent });\n }\n return;\n },\n [agent?.setMessages, copilotkit?.runAgent],\n );\n\n const latestSendMessageFunc = useAsyncCallback(\n async (message: Message, options?: AppendMessageOptions) => {\n if (!agent) return;\n const followUp = options?.followUp ?? true;\n if (options?.clearSuggestions) {\n copilotkit.clearSuggestions(resolvedAgentId);\n }\n agent?.addMessage(message);\n if (followUp) {\n try {\n await copilotkit.runAgent({ agent });\n } catch (error) {\n console.error(\"CopilotChat: runAgent failed\", error);\n }\n }\n },\n [agent, copilotkit, resolvedAgentId],\n );\n\n const latestAppendFunc = useAsyncCallback(\n async (message: DeprecatedGqlMessage, options?: AppendMessageOptions) => {\n return latestSendMessageFunc(gqlToAGUI([message])[0], options);\n },\n [latestSendMessageFunc],\n );\n\n const latestSetMessagesFunc = useCallback(\n (messages: Message[] | DeprecatedGqlMessage[]) => {\n if (messages.every((message) => message instanceof DeprecatedGqlMessage)) {\n return agent?.setMessages?.(gqlToAGUI(messages));\n }\n return agent?.setMessages?.(messages);\n },\n [agent?.setMessages, agent],\n );\n\n const latestReload = useUpdatedRef(reload);\n const latestReloadFunc = useAsyncCallback(\n async (messageId: string) => {\n return await latestReload.current(messageId);\n },\n [latestReload],\n );\n\n const latestStopFunc = useCallback(() => {\n return agent?.abortRun?.();\n }, [agent?.abortRun]);\n\n const latestReset = useUpdatedRef(reset);\n const latestResetFunc = useCallback(() => {\n return latestReset.current();\n }, [latestReset]);\n\n const lazyToolRendered = useLazyToolRenderer();\n const renderCustomMessage = useRenderCustomMessages();\n const legacyCustomMessageRenderer = useLegacyCoagentRenderer({\n copilotkit,\n agent,\n agentId: resolvedAgentId,\n threadId: existingConfig?.threadId ?? threadId,\n });\n const allMessages = agent?.messages ?? [];\n const resolvedMessages = useMemo(() => {\n let processedMessages = allMessages.map((message) => {\n if (message.role !== \"assistant\") {\n return message;\n }\n\n const lazyRendered = lazyToolRendered(message, allMessages);\n if (lazyRendered) {\n const renderedGenUi = lazyRendered();\n if (renderedGenUi) {\n return { ...message, generativeUI: () => renderedGenUi };\n }\n }\n\n const bridgeRenderer =\n legacyCustomMessageRenderer || renderCustomMessage\n ? () => {\n const customRender = renderCustomMessage?.({\n message,\n position: \"before\",\n });\n if (customRender) {\n return customRender;\n }\n return legacyCustomMessageRenderer?.({ message, position: \"before\" });\n }\n : null;\n\n if (bridgeRenderer) {\n return { ...message, generativeUI: bridgeRenderer };\n }\n return message;\n });\n\n const hasAssistantMessages = processedMessages.some((msg) => msg.role === \"assistant\");\n\n // TODO: what is this?\n // if (legacyCustomMessageRenderer && !hasAssistantMessages) {\n // const placeholderId = `coagent-state-render-${resolvedAgentId}`;\n // const placeholderMessage: Message = {\n // id: placeholderId,\n // role: \"assistant\",\n // content: \"\",\n // name: \"coagent-state-render\",\n // };\n // processedMessages = [\n // ...processedMessages,\n // {\n // ...placeholderMessage,\n // generativeUI: () =>\n // legacyCustomMessageRenderer({\n // message: placeholderMessage,\n // position: \"before\",\n // }),\n // } as Message,\n // ];\n // }\n\n return processedMessages;\n }, [\n agent?.messages,\n lazyToolRendered,\n allMessages,\n renderCustomMessage,\n // legacyCustomMessageRenderer,\n resolvedAgentId,\n ]);\n\n // @ts-ignore\n return {\n messages: resolvedMessages,\n sendMessage: latestSendMessageFunc,\n appendMessage: latestAppendFunc,\n setMessages: latestSetMessagesFunc,\n reloadMessages: latestReloadFunc,\n stopGeneration: latestStopFunc,\n reset: latestResetFunc,\n deleteMessage: latestDeleteFunc,\n isAvailable: agentAvailable,\n isLoading: Boolean(agent?.isRunning),\n // mcpServers,\n // setMcpServers,\n suggestions: currentSuggestions.suggestions,\n setSuggestions: (suggestions: Omit<Suggestion, \"isLoading\">[]) =>\n copilotkit.addSuggestionsConfig({ suggestions }),\n generateSuggestions: async () => copilotkit.reloadSuggestions(resolvedAgentId),\n resetSuggestions: () => copilotkit.clearSuggestions(resolvedAgentId),\n isLoadingSuggestions: currentSuggestions.isLoading,\n interrupt,\n agent,\n threadId,\n };\n}\n\n// store `value` in a ref and update\n// it whenever it changes.\nfunction useUpdatedRef<T>(value: T) {\n const ref = useRef(value);\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref;\n}\n\ntype LegacyRenderParams = {\n message: Message;\n position: \"before\" | \"after\";\n};\n\ntype LegacyRenderer = ((args: LegacyRenderParams) => any) | null;\n\nfunction useLegacyCoagentRenderer({\n copilotkit,\n agent,\n agentId,\n threadId,\n}: {\n copilotkit: ReturnType<typeof useCopilotKit>[\"copilotkit\"];\n agent?: AbstractAgent;\n agentId: string;\n threadId?: string;\n}): LegacyRenderer {\n return useMemo(() => {\n if (!copilotkit || !agent) {\n return null;\n }\n\n return ({ message, position }: LegacyRenderParams) => {\n const effectiveThreadId = threadId ?? agent.threadId ?? \"default\";\n const existingRunId = copilotkit.getRunIdForMessage(agentId, effectiveThreadId, message.id);\n const runId = existingRunId || `pending:${message.id}`;\n const messageIndex = Math.max(\n agent.messages.findIndex((msg) => msg.id === message.id),\n 0,\n );\n\n const bridgeProps: CoAgentStateRenderBridgeProps = {\n message: message as any,\n position,\n runId,\n messageIndex,\n messageIndexInRun: 0,\n numberOfMessagesInRun: 1,\n agentId,\n stateSnapshot: (message as any).state,\n };\n\n return createElement(CoAgentStateRenderBridge, bridgeProps) as any;\n };\n }, [agent, agentId, copilotkit, threadId]);\n}\n\nexport function defaultSystemMessage(\n contextString: string,\n additionalInstructions?: string,\n): string {\n return (\n `\nPlease act as an efficient, competent, conscientious, and industrious professional assistant.\n\nHelp the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.\nAlways be polite and respectful, and prefer brevity over verbosity.\n\nThe user has provided you with the following context:\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThey have also provided you with functions you can call to initiate actions on their behalf, or functions you can call to receive more information.\n\nPlease assist them as best you can.\n\nYou can ask them for clarifying questions if needed, but don't be annoying about it. If you can reasonably 'fill in the blanks' yourself, do so.\n\nIf you would like to call a function, call it without saying anything else.\nIn case of a function error:\n- If this error stems from incorrect function parameters or syntax, you may retry with corrected arguments.\n- If the error's source is unclear or seems unrelated to your input, do not attempt further retries.\n` + (additionalInstructions ? `\\n\\n${additionalInstructions}` : \"\")\n );\n}\n","import { z } from \"zod\";\n\nexport const FunctionCallSchema = z.object({\n name: z.string(),\n arguments: z.string(),\n});\n\nexport const ToolCallSchema = z.object({\n id: z.string(),\n type: z.literal(\"function\"),\n function: FunctionCallSchema,\n});\n\nexport const BaseMessageSchema = z.object({\n id: z.string(),\n role: z.string(),\n content: z.string().optional(),\n name: z.string().optional(),\n});\n\nexport const TextInputContentSchema = z.object({\n type: z.literal(\"text\"),\n text: z.string(),\n});\n\nconst BinaryInputContentObjectSchema = z.object({\n type: z.literal(\"binary\"),\n mimeType: z.string(),\n id: z.string().optional(),\n url: z.string().optional(),\n data: z.string().optional(),\n filename: z.string().optional(),\n});\n\nconst ensureBinaryPayload = (\n value: { id?: string; url?: string; data?: string },\n ctx: z.RefinementCtx,\n) => {\n if (!value.id && !value.url && !value.data) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: \"BinaryInputContent requires at least one of id, url, or data.\",\n path: [\"id\"],\n });\n }\n};\n\nexport const BinaryInputContentSchema = BinaryInputContentObjectSchema.superRefine((value, ctx) => {\n ensureBinaryPayload(value, ctx);\n});\n\nconst InputContentBaseSchema = z.discriminatedUnion(\"type\", [\n TextInputContentSchema,\n BinaryInputContentObjectSchema,\n]);\n\nexport const InputContentSchema = InputContentBaseSchema.superRefine((value, ctx) => {\n if (value.type === \"binary\") {\n ensureBinaryPayload(value, ctx);\n }\n});\n\nexport const DeveloperMessageSchema = BaseMessageSchema.extend({\n role: z.literal(\"developer\"),\n content: z.string(),\n});\n\nexport const SystemMessageSchema = BaseMessageSchema.extend({\n role: z.literal(\"system\"),\n content: z.string(),\n});\n\nexport const AssistantMessageSchema = BaseMessageSchema.extend({\n role: z.literal(\"assistant\"),\n content: z.string().optional(),\n toolCalls: z.array(ToolCallSchema).optional(),\n});\n\nexport const UserMessageSchema = BaseMessageSchema.extend({\n role: z.literal(\"user\"),\n content: z.union([z.string(), z.array(InputContentSchema)]),\n});\n\nexport const ToolMessageSchema = z.object({\n id: z.string(),\n content: z.string(),\n role: z.literal(\"tool\"),\n toolCallId: z.string(),\n error: z.string().optional(),\n});\n\nexport const ActivityMessageSchema = z.object({\n id: z.string(),\n role: z.literal(\"activity\"),\n activityType: z.string(),\n content: z.record(z.any()),\n});\n\nexport const MessageSchema = z.discriminatedUnion(\"role\", [\n DeveloperMessageSchema,\n SystemMessageSchema,\n AssistantMessageSchema,\n UserMessageSchema,\n ToolMessageSchema,\n ActivityMessageSchema,\n]);\n\nexport const RoleSchema = z.union([\n z.literal(\"developer\"),\n z.literal(\"system\"),\n z.literal(\"assistant\"),\n z.literal(\"user\"),\n z.literal(\"tool\"),\n z.literal(\"activity\"),\n]);\n\nexport const ContextSchema = z.object({\n description: z.string(),\n value: z.string(),\n});\n\nexport const ToolSchema = z.object({\n name: z.string(),\n description: z.string(),\n parameters: z.any(), // JSON Schema for the tool parameters\n});\n\nexport const RunAgentInputSchema = z.object({\n threadId: z.string(),\n runId: z.string(),\n parentRunId: z.string().optional(),\n state: z.any(),\n messages: z.array(MessageSchema),\n tools: z.array(ToolSchema),\n context: z.array(ContextSchema),\n forwardedProps: z.any(),\n});\n\nexport const StateSchema = z.any();\n\nexport type ToolCall = z.infer<typeof ToolCallSchema>;\nexport type FunctionCall = z.infer<typeof FunctionCallSchema>;\nexport type TextInputContent = z.infer<typeof TextInputContentSchema>;\nexport type BinaryInputContent = z.infer<typeof BinaryInputContentSchema>;\nexport type InputContent = z.infer<typeof InputContentSchema>;\nexport type DeveloperMessage = z.infer<typeof DeveloperMessageSchema>;\nexport type SystemMessage = z.infer<typeof SystemMessageSchema>;\nexport type AssistantMessage = z.infer<typeof AssistantMessageSchema>;\nexport type UserMessage = z.infer<typeof UserMessageSchema>;\nexport type ToolMessage = z.infer<typeof ToolMessageSchema>;\nexport type ActivityMessage = z.infer<typeof ActivityMessageSchema>;\nexport type Message = z.infer<typeof MessageSchema>;\nexport type Context = z.infer<typeof ContextSchema>;\nexport type Tool = z.infer<typeof ToolSchema>;\nexport type RunAgentInput = z.infer<typeof RunAgentInputSchema>;\nexport type State = z.infer<typeof StateSchema>;\nexport type Role = z.infer<typeof RoleSchema>;\n\nexport class AGUIError extends Error {\n constructor(message: string) {\n super(message);\n }\n}\n\nexport class AGUIConnectNotImplementedError extends AGUIError {\n constructor() {\n super(\"Connect not implemented. This method is not supported by the current agent.\");\n }\n}\n","import { z } from \"zod\";\nimport { MessageSchema, StateSchema, RunAgentInputSchema } from \"./types\";\n\n// Text messages can have any role except \"tool\"\nconst TextMessageRoleSchema = z.union([\n z.literal(\"developer\"),\n z.literal(\"system\"),\n z.literal(\"assistant\"),\n z.literal(\"user\"),\n]);\n\nexport enum EventType {\n TEXT_MESSAGE_START = \"TEXT_MESSAGE_START\",\n TEXT_MESSAGE_CONTENT = \"TEXT_MESSAGE_CONTENT\",\n TEXT_MESSAGE_END = \"TEXT_MESSAGE_END\",\n TEXT_MESSAGE_CHUNK = \"TEXT_MESSAGE_CHUNK\",\n THINKING_TEXT_MESSAGE_START = \"THINKING_TEXT_MESSAGE_START\",\n THINKING_TEXT_MESSAGE_CONTENT = \"THINKING_TEXT_MESSAGE_CONTENT\",\n THINKING_TEXT_MESSAGE_END = \"THINKING_TEXT_MESSAGE_END\",\n TOOL_CALL_START = \"TOOL_CALL_START\",\n TOOL_CALL_ARGS = \"TOOL_CALL_ARGS\",\n TOOL_CALL_END = \"TOOL_CALL_END\",\n TOOL_CALL_CHUNK = \"TOOL_CALL_CHUNK\",\n TOOL_CALL_RESULT = \"TOOL_CALL_RESULT\",\n THINKING_START = \"THINKING_START\",\n THINKING_END = \"THINKING_END\",\n STATE_SNAPSHOT = \"STATE_SNAPSHOT\",\n STATE_DELTA = \"STATE_DELTA\",\n MESSAGES_SNAPSHOT = \"MESSAGES_SNAPSHOT\",\n ACTIVITY_SNAPSHOT = \"ACTIVITY_SNAPSHOT\",\n ACTIVITY_DELTA = \"ACTIVITY_DELTA\",\n RAW = \"RAW\",\n CUSTOM = \"CUSTOM\",\n RUN_STARTED = \"RUN_STARTED\",\n RUN_FINISHED = \"RUN_FINISHED\",\n RUN_ERROR = \"RUN_ERROR\",\n STEP_STARTED = \"STEP_STARTED\",\n STEP_FINISHED = \"STEP_FINISHED\",\n}\n\nexport const BaseEventSchema = z.object({\n type: z.nativeEnum(EventType),\n timestamp: z.number().optional(),\n rawEvent: z.any().optional(),\n});\n\nexport const TextMessageStartEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TEXT_MESSAGE_START),\n messageId: z.string(),\n role: TextMessageRoleSchema.default(\"assistant\"),\n});\n\nexport const TextMessageContentEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TEXT_MESSAGE_CONTENT),\n messageId: z.string(),\n delta: z.string().refine((s) => s.length > 0, \"Delta must not be an empty string\"),\n});\n\nexport const TextMessageEndEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TEXT_MESSAGE_END),\n messageId: z.string(),\n});\n\nexport const TextMessageChunkEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TEXT_MESSAGE_CHUNK),\n messageId: z.string().optional(),\n role: TextMessageRoleSchema.optional(),\n delta: z.string().optional(),\n});\n\nexport const ThinkingTextMessageStartEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.THINKING_TEXT_MESSAGE_START),\n});\n\nexport const ThinkingTextMessageContentEventSchema = TextMessageContentEventSchema.omit({\n messageId: true,\n type: true,\n}).extend({\n type: z.literal(EventType.THINKING_TEXT_MESSAGE_CONTENT),\n});\n\nexport const ThinkingTextMessageEndEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.THINKING_TEXT_MESSAGE_END),\n});\n\nexport const ToolCallStartEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TOOL_CALL_START),\n toolCallId: z.string(),\n toolCallName: z.string(),\n parentMessageId: z.string().optional(),\n});\n\nexport const ToolCallArgsEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TOOL_CALL_ARGS),\n toolCallId: z.string(),\n delta: z.string(),\n});\n\nexport const ToolCallEndEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TOOL_CALL_END),\n toolCallId: z.string(),\n});\n\nexport const ToolCallResultEventSchema = BaseEventSchema.extend({\n messageId: z.string(),\n type: z.literal(EventType.TOOL_CALL_RESULT),\n toolCallId: z.string(),\n content: z.string(),\n role: z.literal(\"tool\").optional(),\n});\n\nexport const ToolCallChunkEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TOOL_CALL_CHUNK),\n toolCallId: z.string().optional(),\n toolCallName: z.string().optional(),\n parentMessageId: z.string().optional(),\n delta: z.string().optional(),\n});\n\nexport const ThinkingStartEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.THINKING_START),\n title: z.string().optional(),\n});\n\nexport const ThinkingEndEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.THINKING_END),\n});\n\nexport const StateSnapshotEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.STATE_SNAPSHOT),\n snapshot: StateSchema,\n});\n\nexport const StateDeltaEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.STATE_DELTA),\n delta: z.array(z.any()), // JSON Patch (RFC 6902)\n});\n\nexport const MessagesSnapshotEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.MESSAGES_SNAPSHOT),\n messages: z.array(MessageSchema),\n});\n\nexport const ActivitySnapshotEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.ACTIVITY_SNAPSHOT),\n messageId: z.string(),\n activityType: z.string(),\n content: z.record(z.any()),\n replace: z.boolean().optional().default(true),\n});\n\nexport const ActivityDeltaEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.ACTIVITY_DELTA),\n messageId: z.string(),\n activityType: z.string(),\n patch: z.array(z.any()),\n});\n\nexport const RawEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.RAW),\n event: z.any(),\n source: z.string().optional(),\n});\n\nexport const CustomEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.CUSTOM),\n name: z.string(),\n value: z.any(),\n});\n\nexport const RunStartedEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.RUN_STARTED),\n threadId: z.string(),\n runId: z.string(),\n parentRunId: z.string().optional(),\n input: RunAgentInputSchema.optional(),\n});\n\nexport const RunFinishedEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.RUN_FINISHED),\n threadId: z.string(),\n runId: z.string(),\n result: z.any().optional(),\n});\n\nexport const RunErrorEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.RUN_ERROR),\n message: z.string(),\n code: z.string().optional(),\n});\n\nexport const StepStartedEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.STEP_STARTED),\n stepName: z.string(),\n});\n\nexport const StepFinishedEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.STEP_FINISHED),\n stepName: z.string(),\n});\n\nexport const EventSchemas = z.discriminatedUnion(\"type\", [\n TextMessageStartEventSchema,\n TextMessageContentEventSchema,\n TextMessageEndEventSchema,\n TextMessageChunkEventSchema,\n ThinkingStartEventSchema,\n ThinkingEndEventSchema,\n ThinkingTextMessageStartEventSchema,\n ThinkingTextMessageContentEventSchema,\n ThinkingTextMessageEndEventSchema,\n ToolCallStartEventSchema,\n ToolCallArgsEventSchema,\n ToolCallEndEventSchema,\n ToolCallChunkEventSchema,\n ToolCallResultEventSchema,\n StateSnapshotEventSchema,\n StateDeltaEventSchema,\n MessagesSnapshotEventSchema,\n ActivitySnapshotEventSchema,\n ActivityDeltaEventSchema,\n RawEventSchema,\n CustomEventSchema,\n RunStartedEventSchema,\n RunFinishedEventSchema,\n RunErrorEventSchema,\n StepStartedEventSchema,\n StepFinishedEventSchema,\n]);\n\nexport type BaseEvent = z.infer<typeof BaseEventSchema>;\nexport type TextMessageStartEvent = z.infer<typeof TextMessageStartEventSchema>;\nexport type TextMessageContentEvent = z.infer<typeof TextMessageContentEventSchema>;\nexport type TextMessageEndEvent = z.infer<typeof TextMessageEndEventSchema>;\nexport type TextMessageChunkEvent = z.infer<typeof TextMessageChunkEventSchema>;\nexport type ThinkingTextMessageStartEvent = z.infer<typeof ThinkingTextMessageStartEventSchema>;\nexport type ThinkingTextMessageContentEvent = z.infer<typeof ThinkingTextMessageContentEventSchema>;\nexport type ThinkingTextMessageEndEvent = z.infer<typeof ThinkingTextMessageEndEventSchema>;\nexport type ToolCallStartEvent = z.infer<typeof ToolCallStartEventSchema>;\nexport type ToolCallArgsEvent = z.infer<typeof ToolCallArgsEventSchema>;\nexport type ToolCallEndEvent = z.infer<typeof ToolCallEndEventSchema>;\nexport type ToolCallChunkEvent = z.infer<typeof ToolCallChunkEventSchema>;\nexport type ToolCallResultEvent = z.infer<typeof ToolCallResultEventSchema>;\nexport type ThinkingStartEvent = z.infer<typeof ThinkingStartEventSchema>;\nexport type ThinkingEndEvent = z.infer<typeof ThinkingEndEventSchema>;\nexport type StateSnapshotEvent = z.infer<typeof StateSnapshotEventSchema>;\nexport type StateDeltaEvent = z.infer<typeof StateDeltaEventSchema>;\nexport type MessagesSnapshotEvent = z.infer<typeof MessagesSnapshotEventSchema>;\nexport type ActivitySnapshotEvent = z.infer<typeof ActivitySnapshotEventSchema>;\nexport type ActivityDeltaEvent = z.infer<typeof ActivityDeltaEventSchema>;\nexport type RawEvent = z.infer<typeof RawEventSchema>;\nexport type CustomEvent = z.infer<typeof CustomEventSchema>;\nexport type RunStartedEvent = z.infer<typeof RunStartedEventSchema>;\nexport type RunFinishedEvent = z.infer<typeof RunFinishedEventSchema>;\nexport type RunErrorEvent = z.infer<typeof RunErrorEventSchema>;\nexport type StepStartedEvent = z.infer<typeof StepStartedEventSchema>;\nexport type StepFinishedEvent = z.infer<typeof StepFinishedEventSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,QAAQ,WAAW,aAAa,SAAS,UAAU,qBAAqB;AAKjF,SAAS,WAAW,WAAW,4BAA4B;AAE3D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACbP,SAAS,SAAS;ACAlB,SAAS,KAAAA,UAAS;ADEX,IAAM,qBAAqB,EAAE,OAAO;EACzC,MAAM,EAAE,OAAO;EACf,WAAW,EAAE,OAAO;AACtB,CAAC;AAEM,IAAM,iBAAiB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A;AAAA;AAAA,KAaG,yBAAyB;AAAA;AAAA,EAAO,2BAA2B;AAEhE;","names":["z","EventType","agent","_a","_b","suggestions"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCopilotChatInternal
3
- } from "./chunk-ZCV3A2FP.mjs";
3
+ } from "./chunk-EKDPRKZT.mjs";
4
4
  import {
5
5
  useCopilotContext
6
6
  } from "./chunk-AFNWX62Q.mjs";
@@ -83,4 +83,4 @@ function useCopilotChatHeadless_c(options = {}) {
83
83
  export {
84
84
  useCopilotChatHeadless_c
85
85
  };
86
- //# sourceMappingURL=chunk-OX2QTNTD.mjs.map
86
+ //# sourceMappingURL=chunk-KYY2WZSR.mjs.map
@@ -0,0 +1,37 @@
1
+ // src/hooks/use-copilot-readable.ts
2
+ import { useCopilotKit } from "@copilotkitnext/react";
3
+ import { useEffect, useRef } from "react";
4
+ function useCopilotReadable({ description, value, convert, available }, dependencies) {
5
+ const { copilotkit } = useCopilotKit();
6
+ const ctxIdRef = useRef(void 0);
7
+ useEffect(() => {
8
+ if (!copilotkit)
9
+ return;
10
+ const found = Object.entries(copilotkit.context).find(([id, ctxItem]) => {
11
+ return JSON.stringify({ description, value }) == JSON.stringify(ctxItem);
12
+ });
13
+ if (found) {
14
+ ctxIdRef.current = found[0];
15
+ if (available === "disabled")
16
+ copilotkit.removeContext(ctxIdRef.current);
17
+ return;
18
+ }
19
+ if (!found && available === "disabled")
20
+ return;
21
+ ctxIdRef.current = copilotkit.addContext({
22
+ description,
23
+ value: (convert != null ? convert : JSON.stringify)(value)
24
+ });
25
+ return () => {
26
+ if (!ctxIdRef.current)
27
+ return;
28
+ copilotkit.removeContext(ctxIdRef.current);
29
+ };
30
+ }, [description, value, convert]);
31
+ return ctxIdRef.current;
32
+ }
33
+
34
+ export {
35
+ useCopilotReadable
36
+ };
37
+ //# sourceMappingURL=chunk-RQ6LWR6S.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-copilot-readable.ts"],"sourcesContent":["/**\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * ## Usage\n *\n * ### Simple Usage\n *\n * In its most basic usage, useCopilotReadable accepts a single string argument\n * representing any piece of app state, making it available for the Copilot to use\n * as context when responding to user input.\n *\n * ```tsx\n * import { useCopilotReadable } from \"@copilotkit/react-core\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotReadable({\n * description: \"The list of employees\",\n * value: employees,\n * });\n * }\n * ```\n *\n * ### Nested Components\n *\n * Optionally, you can maintain the hierarchical structure of information by passing\n * `parentId`. This allows you to use `useCopilotReadable` in nested components:\n *\n * ```tsx /employeeContextId/1 {17,23}\n * import { useCopilotReadable } from \"@copilotkit/react-core\";\n *\n * function Employee(props: EmployeeProps) {\n * const { employeeName, workProfile, metadata } = props;\n *\n * // propagate any information to copilot\n * const employeeContextId = useCopilotReadable({\n * description: \"Employee name\",\n * value: employeeName\n * });\n *\n * // Pass a parentID to maintain a hierarchical structure.\n * // Especially useful with child React components, list elements, etc.\n * useCopilotReadable({\n * description: \"Work profile\",\n * value: workProfile.description(),\n * parentId: employeeContextId\n * });\n *\n * useCopilotReadable({\n * description: \"Employee metadata\",\n * value: metadata.description(),\n * parentId: employeeContextId\n * });\n *\n * return (\n * // Render as usual...\n * );\n * }\n * ```\n */\nimport { useCopilotKit } from \"@copilotkitnext/react\";\nimport { useEffect, useRef } from \"react\";\n\ntype DataType = object | number | string | boolean | null | undefined;\n\n/**\n * Options for the useCopilotReadable hook.\n */\nexport interface UseCopilotReadableOptions {\n /**\n * The description of the information to be added to the Copilot context.\n */\n description: string;\n /**\n * The value to be added to the Copilot context. Object values are automatically stringified.\n */\n value: DataType | Record<string, any> | DataType[];\n /**\n * The ID of the parent context, if any.\n */\n parentId?: string;\n /**\n * An array of categories to control which context are visible where. Particularly useful\n * with CopilotTextarea (see `useMakeAutosuggestionFunction`)\n */\n categories?: string[];\n\n /**\n * Whether the context is available to the Copilot.\n */\n available?: \"enabled\" | \"disabled\";\n\n /**\n * A custom conversion function to use to serialize the value to a string. If not provided, the value\n * will be serialized using `JSON.stringify`.\n */\n convert?: (value: any) => string;\n}\n\n/**\n * Adds the given information to the Copilot context to make it readable by Copilot.\n */\nexport function useCopilotReadable(\n { description, value, convert, available }: UseCopilotReadableOptions,\n dependencies?: any[],\n): string | undefined {\n const { copilotkit } = useCopilotKit();\n const ctxIdRef = useRef<string | undefined>(undefined);\n useEffect(() => {\n if (!copilotkit) return;\n\n const found = Object.entries(copilotkit.context).find(([id, ctxItem]) => {\n return JSON.stringify({ description, value }) == JSON.stringify(ctxItem);\n });\n if (found) {\n ctxIdRef.current = found[0];\n if (available === \"disabled\") copilotkit.removeContext(ctxIdRef.current);\n return;\n }\n if (!found && available === \"disabled\") return;\n\n ctxIdRef.current = copilotkit.addContext({\n description,\n value: (convert ?? JSON.stringify)(value),\n });\n\n return () => {\n if (!ctxIdRef.current) return;\n copilotkit.removeContext(ctxIdRef.current);\n };\n }, [description, value, convert]);\n\n return ctxIdRef.current;\n}\n"],"mappings":";AA+DA,SAAS,qBAAqB;AAC9B,SAAS,WAAW,cAAc;AAyC3B,SAAS,mBACd,EAAE,aAAa,OAAO,SAAS,UAAU,GACzC,cACoB;AACpB,QAAM,EAAE,WAAW,IAAI,cAAc;AACrC,QAAM,WAAW,OAA2B,MAAS;AACrD,YAAU,MAAM;AACd,QAAI,CAAC;AAAY;AAEjB,UAAM,QAAQ,OAAO,QAAQ,WAAW,OAAO,EAAE,KAAK,CAAC,CAAC,IAAI,OAAO,MAAM;AACvE,aAAO,KAAK,UAAU,EAAE,aAAa,MAAM,CAAC,KAAK,KAAK,UAAU,OAAO;AAAA,IACzE,CAAC;AACD,QAAI,OAAO;AACT,eAAS,UAAU,MAAM,CAAC;AAC1B,UAAI,cAAc;AAAY,mBAAW,cAAc,SAAS,OAAO;AACvE;AAAA,IACF;AACA,QAAI,CAAC,SAAS,cAAc;AAAY;AAExC,aAAS,UAAU,WAAW,WAAW;AAAA,MACvC;AAAA,MACA,QAAQ,4BAAW,KAAK,WAAW,KAAK;AAAA,IAC1C,CAAC;AAED,WAAO,MAAM;AACX,UAAI,CAAC,SAAS;AAAS;AACvB,iBAAW,cAAc,SAAS,OAAO;AAAA,IAC3C;AAAA,EACF,GAAG,CAAC,aAAa,OAAO,OAAO,CAAC;AAEhC,SAAO,SAAS;AAClB;","names":[]}
@@ -552,7 +552,7 @@ function useConfigureChatSuggestions(config, dependencies = []) {
552
552
  return result;
553
553
  }
554
554
 
555
- // ../../node_modules/.pnpm/@ag-ui+core@0.0.42-alpha.1/node_modules/@ag-ui/core/dist/index.mjs
555
+ // ../../node_modules/.pnpm/@ag-ui+core@0.0.42/node_modules/@ag-ui/core/dist/index.mjs
556
556
  var import_zod = require("zod");
557
557
  var import_zod2 = require("zod");
558
558
  var FunctionCallSchema = import_zod.z.object({
@@ -1249,16 +1249,15 @@ function useCopilotChatInternal({
1249
1249
  }),
1250
1250
  [latestSendMessageFunc]
1251
1251
  );
1252
- const latestSetMessages = useUpdatedRef(agent == null ? void 0 : agent.setMessages);
1253
1252
  const latestSetMessagesFunc = (0, import_react15.useCallback)(
1254
1253
  (messages) => {
1255
1254
  var _a2, _b2;
1256
1255
  if (messages.every((message) => message instanceof import_runtime_client_gql2.Message)) {
1257
- return (_a2 = latestSetMessages.current) == null ? void 0 : _a2.call(latestSetMessages, (0, import_runtime_client_gql2.gqlToAGUI)(messages));
1256
+ return (_a2 = agent == null ? void 0 : agent.setMessages) == null ? void 0 : _a2.call(agent, (0, import_runtime_client_gql2.gqlToAGUI)(messages));
1258
1257
  }
1259
- return (_b2 = latestSetMessages.current) == null ? void 0 : _b2.call(latestSetMessages, messages);
1258
+ return (_b2 = agent == null ? void 0 : agent.setMessages) == null ? void 0 : _b2.call(agent, messages);
1260
1259
  },
1261
- [latestSetMessages, agent]
1260
+ [agent == null ? void 0 : agent.setMessages, agent]
1262
1261
  );
1263
1262
  const latestReload = useUpdatedRef(reload);
1264
1263
  const latestReloadFunc = useAsyncCallback(
@@ -1267,11 +1266,10 @@ function useCopilotChatInternal({
1267
1266
  }),
1268
1267
  [latestReload]
1269
1268
  );
1270
- const latestStop = useUpdatedRef(agent == null ? void 0 : agent.abortRun);
1271
1269
  const latestStopFunc = (0, import_react15.useCallback)(() => {
1272
1270
  var _a2;
1273
- return (_a2 = latestStop.current) == null ? void 0 : _a2.call(latestStop);
1274
- }, [latestStop]);
1271
+ return (_a2 = agent == null ? void 0 : agent.abortRun) == null ? void 0 : _a2.call(agent);
1272
+ }, [agent == null ? void 0 : agent.abortRun]);
1275
1273
  const latestReset = useUpdatedRef(reset);
1276
1274
  const latestResetFunc = (0, import_react15.useCallback)(() => {
1277
1275
  return latestReset.current();
@@ -1791,22 +1789,45 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
1791
1789
 
1792
1790
  // src/hooks/use-copilot-readable.ts
1793
1791
  var import_react27 = require("@copilotkitnext/react");
1794
- function useCopilotReadable({ description, value }, dependencies) {
1795
- (0, import_react27.useAgentContext)({
1796
- description,
1797
- value
1798
- });
1799
- return;
1792
+ var import_react28 = require("react");
1793
+ function useCopilotReadable({ description, value, convert, available }, dependencies) {
1794
+ const { copilotkit } = (0, import_react27.useCopilotKit)();
1795
+ const ctxIdRef = (0, import_react28.useRef)(void 0);
1796
+ (0, import_react28.useEffect)(() => {
1797
+ if (!copilotkit)
1798
+ return;
1799
+ const found = Object.entries(copilotkit.context).find(([id, ctxItem]) => {
1800
+ return JSON.stringify({ description, value }) == JSON.stringify(ctxItem);
1801
+ });
1802
+ if (found) {
1803
+ ctxIdRef.current = found[0];
1804
+ if (available === "disabled")
1805
+ copilotkit.removeContext(ctxIdRef.current);
1806
+ return;
1807
+ }
1808
+ if (!found && available === "disabled")
1809
+ return;
1810
+ ctxIdRef.current = copilotkit.addContext({
1811
+ description,
1812
+ value: (convert != null ? convert : JSON.stringify)(value)
1813
+ });
1814
+ return () => {
1815
+ if (!ctxIdRef.current)
1816
+ return;
1817
+ copilotkit.removeContext(ctxIdRef.current);
1818
+ };
1819
+ }, [description, value, convert]);
1820
+ return ctxIdRef.current;
1800
1821
  }
1801
1822
 
1802
1823
  // src/hooks/use-coagent.ts
1803
- var import_react28 = require("react");
1804
- var import_react29 = require("@copilotkitnext/react");
1824
+ var import_react29 = require("react");
1825
+ var import_react30 = require("@copilotkitnext/react");
1805
1826
  function useCoAgent(options) {
1806
- const { agent } = (0, import_react29.useAgent)({ agentId: options.name });
1807
- const { copilotkit } = (0, import_react29.useCopilotKit)();
1827
+ const { agent } = (0, import_react30.useAgent)({ agentId: options.name });
1828
+ const { copilotkit } = (0, import_react30.useCopilotKit)();
1808
1829
  const nodeName = useAgentNodeName(options.name);
1809
- const handleStateUpdate = (0, import_react28.useCallback)(
1830
+ const handleStateUpdate = (0, import_react29.useCallback)(
1810
1831
  (newState) => {
1811
1832
  if (!agent)
1812
1833
  return;
@@ -1819,7 +1840,7 @@ function useCoAgent(options) {
1819
1840
  },
1820
1841
  [agent == null ? void 0 : agent.state, agent == null ? void 0 : agent.setState]
1821
1842
  );
1822
- (0, import_react28.useEffect)(() => {
1843
+ (0, import_react29.useEffect)(() => {
1823
1844
  var _a;
1824
1845
  if (!options.config && !options.configurable)
1825
1846
  return;
@@ -1831,22 +1852,22 @@ function useCoAgent(options) {
1831
1852
  }
1832
1853
  copilotkit.setProperties(config);
1833
1854
  }, [options.config, options.configurable]);
1834
- const externalStateStr = (0, import_react28.useMemo)(
1855
+ const externalStateStr = (0, import_react29.useMemo)(
1835
1856
  () => isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0,
1836
1857
  [isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0]
1837
1858
  );
1838
- (0, import_react28.useEffect)(() => {
1859
+ (0, import_react29.useEffect)(() => {
1839
1860
  if ((agent == null ? void 0 : agent.state) && isExternalStateManagement(options) && JSON.stringify(options.state) !== JSON.stringify(agent.state)) {
1840
1861
  handleStateUpdate(options.state);
1841
1862
  }
1842
1863
  }, [agent, externalStateStr, handleStateUpdate]);
1843
- const hasStateValues = (0, import_react28.useCallback)((value) => {
1864
+ const hasStateValues = (0, import_react29.useCallback)((value) => {
1844
1865
  return Boolean(value && Object.keys(value).length);
1845
1866
  }, []);
1846
- const initialStateRef = (0, import_react28.useRef)(
1867
+ const initialStateRef = (0, import_react29.useRef)(
1847
1868
  isExternalStateManagement(options) ? options.state : "initialState" in options ? options.initialState : void 0
1848
1869
  );
1849
- (0, import_react28.useEffect)(() => {
1870
+ (0, import_react29.useEffect)(() => {
1850
1871
  if (isExternalStateManagement(options)) {
1851
1872
  initialStateRef.current = options.state;
1852
1873
  } else if ("initialState" in options) {
@@ -1855,7 +1876,7 @@ function useCoAgent(options) {
1855
1876
  }, [
1856
1877
  isExternalStateManagement(options) ? JSON.stringify(options.state) : "initialState" in options ? JSON.stringify(options.initialState) : void 0
1857
1878
  ]);
1858
- (0, import_react28.useEffect)(() => {
1879
+ (0, import_react29.useEffect)(() => {
1859
1880
  if (!agent)
1860
1881
  return;
1861
1882
  const subscriber = {
@@ -1883,7 +1904,7 @@ function useCoAgent(options) {
1883
1904
  subscription.unsubscribe();
1884
1905
  };
1885
1906
  }, [agent, handleStateUpdate, hasStateValues]);
1886
- return (0, import_react28.useMemo)(() => {
1907
+ return (0, import_react29.useMemo)(() => {
1887
1908
  var _a, _b, _c;
1888
1909
  if (!agent) {
1889
1910
  const noop = () => {
@@ -1939,12 +1960,12 @@ var isExternalStateManagement = (options) => {
1939
1960
 
1940
1961
  // src/hooks/use-copilot-runtime-client.ts
1941
1962
  var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
1942
- var import_react30 = require("react");
1963
+ var import_react31 = require("react");
1943
1964
  var import_shared11 = require("@copilotkit/shared");
1944
1965
  var useCopilotRuntimeClient = (options) => {
1945
1966
  const { setBannerError } = useToast();
1946
1967
  const _a = options, { showDevConsole, onError } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onError"]);
1947
- const lastStructuredErrorRef = (0, import_react30.useRef)(null);
1968
+ const lastStructuredErrorRef = (0, import_react31.useRef)(null);
1948
1969
  const traceUIError = (error, originalError) => __async(void 0, null, function* () {
1949
1970
  try {
1950
1971
  const errorEvent = {
@@ -1970,7 +1991,7 @@ var useCopilotRuntimeClient = (options) => {
1970
1991
  console.error("Error in onError handler:", error2);
1971
1992
  }
1972
1993
  });
1973
- const runtimeClient = (0, import_react30.useMemo)(() => {
1994
+ const runtimeClient = (0, import_react31.useMemo)(() => {
1974
1995
  return new import_runtime_client_gql3.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
1975
1996
  handleGQLErrors: (error) => {
1976
1997
  var _a2;
@@ -2049,28 +2070,28 @@ function createStructuredError(gqlError) {
2049
2070
  }
2050
2071
 
2051
2072
  // src/hooks/use-copilot-authenticated-action.ts
2052
- var import_react31 = require("react");
2053
- var import_react32 = __toESM(require("react"));
2073
+ var import_react32 = require("react");
2074
+ var import_react33 = __toESM(require("react"));
2054
2075
  function useCopilotAuthenticatedAction_c(action, dependencies) {
2055
2076
  const { authConfig_c, authStates_c, setAuthStates_c } = useCopilotContext();
2056
- const pendingActionRef = (0, import_react31.useRef)(null);
2057
- const executeAction = (0, import_react31.useCallback)(
2077
+ const pendingActionRef = (0, import_react32.useRef)(null);
2078
+ const executeAction = (0, import_react32.useCallback)(
2058
2079
  (props) => {
2059
2080
  if (typeof action.render === "function") {
2060
2081
  return action.render(props);
2061
2082
  }
2062
- return action.render || import_react32.default.createElement(import_react31.Fragment);
2083
+ return action.render || import_react33.default.createElement(import_react32.Fragment);
2063
2084
  },
2064
2085
  [action]
2065
2086
  );
2066
- const wrappedRender = (0, import_react31.useCallback)(
2087
+ const wrappedRender = (0, import_react32.useCallback)(
2067
2088
  (props) => {
2068
2089
  const isAuthenticated = Object.values(authStates_c || {}).some(
2069
2090
  (state) => state.status === "authenticated"
2070
2091
  );
2071
2092
  if (!isAuthenticated) {
2072
2093
  pendingActionRef.current = props;
2073
- return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ? import_react32.default.createElement(authConfig_c.SignInComponent, {
2094
+ return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ? import_react33.default.createElement(authConfig_c.SignInComponent, {
2074
2095
  onSignInComplete: (authState) => {
2075
2096
  setAuthStates_c == null ? void 0 : setAuthStates_c((prev) => __spreadProps(__spreadValues({}, prev), { [action.name]: authState }));
2076
2097
  if (pendingActionRef.current) {
@@ -2078,7 +2099,7 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
2078
2099
  pendingActionRef.current = null;
2079
2100
  }
2080
2101
  }
2081
- }) : import_react32.default.createElement(import_react31.Fragment);
2102
+ }) : import_react33.default.createElement(import_react32.Fragment);
2082
2103
  }
2083
2104
  return executeAction(props);
2084
2105
  },
@@ -2093,13 +2114,13 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
2093
2114
  }
2094
2115
 
2095
2116
  // src/hooks/use-langgraph-interrupt.ts
2096
- var import_react33 = require("react");
2117
+ var import_react34 = require("react");
2097
2118
  var import_shared12 = require("@copilotkit/shared");
2098
2119
  function useLangGraphInterrupt(action, dependencies) {
2099
- const { setInterruptAction, removeInterruptAction, interruptActions, threadId } = (0, import_react33.useContext)(CopilotContext);
2120
+ const { setInterruptAction, removeInterruptAction, interruptActions, threadId } = (0, import_react34.useContext)(CopilotContext);
2100
2121
  const { addToast } = useToast();
2101
2122
  const actionId = (0, import_shared12.dataToUUID)(action, "lgAction");
2102
- (0, import_react33.useEffect)(() => {
2123
+ (0, import_react34.useEffect)(() => {
2103
2124
  if (!action)
2104
2125
  return;
2105
2126
  setInterruptAction(__spreadProps(__spreadValues({}, action), { id: actionId }));
@@ -2110,10 +2131,10 @@ function useLangGraphInterrupt(action, dependencies) {
2110
2131
  }
2111
2132
 
2112
2133
  // src/hooks/use-copilot-additional-instructions.ts
2113
- var import_react34 = require("react");
2134
+ var import_react35 = require("react");
2114
2135
  function useCopilotAdditionalInstructions({ instructions, available = "enabled" }, dependencies) {
2115
2136
  const { setAdditionalInstructions } = useCopilotContext();
2116
- (0, import_react34.useEffect)(() => {
2137
+ (0, import_react35.useEffect)(() => {
2117
2138
  if (available === "disabled")
2118
2139
  return;
2119
2140
  setAdditionalInstructions((prevInstructions) => [...prevInstructions || [], instructions]);