@copilotkit/react-core 1.10.5-next.6 → 1.10.5-next.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 (153) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/{chunk-ZRDV3MVW.mjs → chunk-3A2AZCAV.mjs} +30 -23
  3. package/dist/chunk-3A2AZCAV.mjs.map +1 -0
  4. package/dist/{chunk-TM5MFTHG.mjs → chunk-7H4ANZIC.mjs} +11 -5
  5. package/dist/chunk-7H4ANZIC.mjs.map +1 -0
  6. package/dist/{chunk-CXDK6XA5.mjs → chunk-BBUQMG45.mjs} +2 -2
  7. package/dist/{chunk-2MGJO3FY.mjs → chunk-C6IANC2R.mjs} +2 -2
  8. package/dist/{chunk-FRXYSJGZ.mjs → chunk-DXEQPN43.mjs} +3 -3
  9. package/dist/{chunk-YHT6CWIY.mjs → chunk-EUX2P2E7.mjs} +5 -3
  10. package/dist/{chunk-YHT6CWIY.mjs.map → chunk-EUX2P2E7.mjs.map} +1 -1
  11. package/dist/{chunk-IF4OYMFZ.mjs → chunk-GFCDU2YP.mjs} +4 -4
  12. package/dist/chunk-GFCDU2YP.mjs.map +1 -0
  13. package/dist/{chunk-2QZSAQTX.mjs → chunk-GT5WI3AF.mjs} +2 -2
  14. package/dist/{chunk-AGBNJCIM.mjs → chunk-H4VS6T4E.mjs} +2 -2
  15. package/dist/{chunk-36FJAVOF.mjs → chunk-HDOG2RTM.mjs} +2 -2
  16. package/dist/{chunk-BKI4I4S2.mjs → chunk-J4GESU5K.mjs} +5 -5
  17. package/dist/{chunk-MZ37BAAE.mjs → chunk-MGWRDFBE.mjs} +2 -2
  18. package/dist/{chunk-DSDAZA3B.mjs → chunk-OKCYPO4I.mjs} +2 -2
  19. package/dist/{chunk-Y5ZF7AZ3.mjs → chunk-QQUV6DDO.mjs} +4 -4
  20. package/dist/{chunk-UPQPBCUW.mjs → chunk-QS7M5VZM.mjs} +2 -2
  21. package/dist/{chunk-FCRPPUZA.mjs → chunk-RLGKX6OP.mjs} +3 -3
  22. package/dist/{chunk-JEMBA7PE.mjs → chunk-T3376SZS.mjs} +2 -2
  23. package/dist/{chunk-KWS75AOU.mjs → chunk-U7QULEVO.mjs} +3 -3
  24. package/dist/{chunk-QF3Q5LUN.mjs → chunk-ZVOLWJCY.mjs} +5 -5
  25. package/dist/chunk-ZVOLWJCY.mjs.map +1 -0
  26. package/dist/components/copilot-provider/copilot-messages.js +4 -2
  27. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  28. package/dist/components/copilot-provider/copilot-messages.mjs +2 -2
  29. package/dist/components/copilot-provider/copilotkit-props.d.ts +1 -1
  30. package/dist/components/copilot-provider/copilotkit.d.ts +1 -1
  31. package/dist/components/copilot-provider/copilotkit.js +30 -21
  32. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  33. package/dist/components/copilot-provider/copilotkit.mjs +5 -5
  34. package/dist/components/copilot-provider/index.d.ts +1 -1
  35. package/dist/components/copilot-provider/index.js +30 -21
  36. package/dist/components/copilot-provider/index.js.map +1 -1
  37. package/dist/components/copilot-provider/index.mjs +5 -5
  38. package/dist/components/dev-console/console-trigger.js +4 -2
  39. package/dist/components/dev-console/console-trigger.js.map +1 -1
  40. package/dist/components/dev-console/console-trigger.mjs +3 -3
  41. package/dist/components/dev-console/developer-console-modal.js +4 -2
  42. package/dist/components/dev-console/developer-console-modal.js.map +1 -1
  43. package/dist/components/dev-console/developer-console-modal.mjs +2 -2
  44. package/dist/components/index.d.ts +1 -1
  45. package/dist/components/index.js +30 -21
  46. package/dist/components/index.js.map +1 -1
  47. package/dist/components/index.mjs +5 -5
  48. package/dist/context/copilot-context.d.ts +1 -1
  49. package/dist/context/copilot-context.js +4 -2
  50. package/dist/context/copilot-context.js.map +1 -1
  51. package/dist/context/copilot-context.mjs +1 -1
  52. package/dist/context/copilot-messages-context.d.ts +2 -2
  53. package/dist/context/index.d.ts +2 -2
  54. package/dist/context/index.js +4 -2
  55. package/dist/context/index.js.map +1 -1
  56. package/dist/context/index.mjs +1 -1
  57. package/dist/{copilot-context-59740e82.d.ts → copilot-context-cf9de848.d.ts} +2 -2
  58. package/dist/hooks/index.d.ts +2 -2
  59. package/dist/hooks/index.js +17 -9
  60. package/dist/hooks/index.js.map +1 -1
  61. package/dist/hooks/index.mjs +18 -18
  62. package/dist/hooks/use-chat.d.ts +1 -1
  63. package/dist/hooks/use-chat.js +6 -4
  64. package/dist/hooks/use-chat.js.map +1 -1
  65. package/dist/hooks/use-chat.mjs +2 -2
  66. package/dist/hooks/use-coagent-state-render.js +4 -2
  67. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  68. package/dist/hooks/use-coagent-state-render.mjs +2 -2
  69. package/dist/hooks/use-coagent.d.ts +1 -1
  70. package/dist/hooks/use-coagent.js +9 -7
  71. package/dist/hooks/use-coagent.js.map +1 -1
  72. package/dist/hooks/use-coagent.mjs +9 -9
  73. package/dist/hooks/use-copilot-action.js +4 -2
  74. package/dist/hooks/use-copilot-action.js.map +1 -1
  75. package/dist/hooks/use-copilot-action.mjs +2 -2
  76. package/dist/hooks/use-copilot-additional-instructions.js +4 -2
  77. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  78. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  79. package/dist/hooks/use-copilot-authenticated-action.js +4 -2
  80. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  81. package/dist/hooks/use-copilot-authenticated-action.mjs +3 -3
  82. package/dist/hooks/use-copilot-chat-headless_c.d.ts +2 -2
  83. package/dist/hooks/use-copilot-chat-headless_c.js +9 -7
  84. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
  85. package/dist/hooks/use-copilot-chat-headless_c.mjs +9 -9
  86. package/dist/hooks/use-copilot-chat.d.ts +2 -2
  87. package/dist/hooks/use-copilot-chat.js +9 -7
  88. package/dist/hooks/use-copilot-chat.js.map +1 -1
  89. package/dist/hooks/use-copilot-chat.mjs +9 -9
  90. package/dist/hooks/use-copilot-chat_internal.d.ts +2 -2
  91. package/dist/hooks/use-copilot-chat_internal.js +9 -7
  92. package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
  93. package/dist/hooks/use-copilot-chat_internal.mjs +8 -8
  94. package/dist/hooks/use-copilot-readable.js +4 -2
  95. package/dist/hooks/use-copilot-readable.js.map +1 -1
  96. package/dist/hooks/use-copilot-readable.mjs +2 -2
  97. package/dist/hooks/use-langgraph-interrupt-render.js +7 -5
  98. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  99. package/dist/hooks/use-langgraph-interrupt-render.mjs +2 -2
  100. package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
  101. package/dist/hooks/use-langgraph-interrupt.js +17 -9
  102. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  103. package/dist/hooks/use-langgraph-interrupt.mjs +9 -9
  104. package/dist/hooks/use-make-copilot-document-readable.js +4 -2
  105. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  106. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  107. package/dist/{index-d1743abe.d.ts → index-1f5b66ac.d.ts} +1 -1
  108. package/dist/index.d.ts +2 -2
  109. package/dist/index.js +43 -28
  110. package/dist/index.js.map +1 -1
  111. package/dist/index.mjs +19 -19
  112. package/dist/lib/copilot-task.d.ts +1 -1
  113. package/dist/lib/copilot-task.js.map +1 -1
  114. package/dist/lib/copilot-task.mjs +6 -6
  115. package/dist/lib/index.d.ts +1 -1
  116. package/dist/lib/index.js.map +1 -1
  117. package/dist/lib/index.mjs +6 -6
  118. package/dist/types/interrupt-action.d.ts +1 -1
  119. package/dist/types/interrupt-action.js.map +1 -1
  120. package/dist/utils/extract.d.ts +2 -2
  121. package/dist/utils/extract.js.map +1 -1
  122. package/dist/utils/extract.mjs +5 -5
  123. package/dist/utils/index.d.ts +2 -2
  124. package/dist/utils/index.js.map +1 -1
  125. package/dist/utils/index.mjs +5 -5
  126. package/dist/utils/suggestions.d.ts +2 -2
  127. package/dist/utils/suggestions.js.map +1 -1
  128. package/dist/utils/suggestions.mjs +5 -5
  129. package/package.json +3 -3
  130. package/src/components/copilot-provider/copilotkit.tsx +27 -17
  131. package/src/context/copilot-context.tsx +3 -3
  132. package/src/hooks/use-chat.ts +2 -2
  133. package/src/hooks/use-langgraph-interrupt-render.ts +4 -3
  134. package/src/hooks/use-langgraph-interrupt.ts +8 -3
  135. package/src/types/interrupt-action.ts +4 -1
  136. package/dist/chunk-IF4OYMFZ.mjs.map +0 -1
  137. package/dist/chunk-QF3Q5LUN.mjs.map +0 -1
  138. package/dist/chunk-TM5MFTHG.mjs.map +0 -1
  139. package/dist/chunk-ZRDV3MVW.mjs.map +0 -1
  140. /package/dist/{chunk-CXDK6XA5.mjs.map → chunk-BBUQMG45.mjs.map} +0 -0
  141. /package/dist/{chunk-2MGJO3FY.mjs.map → chunk-C6IANC2R.mjs.map} +0 -0
  142. /package/dist/{chunk-FRXYSJGZ.mjs.map → chunk-DXEQPN43.mjs.map} +0 -0
  143. /package/dist/{chunk-2QZSAQTX.mjs.map → chunk-GT5WI3AF.mjs.map} +0 -0
  144. /package/dist/{chunk-AGBNJCIM.mjs.map → chunk-H4VS6T4E.mjs.map} +0 -0
  145. /package/dist/{chunk-36FJAVOF.mjs.map → chunk-HDOG2RTM.mjs.map} +0 -0
  146. /package/dist/{chunk-BKI4I4S2.mjs.map → chunk-J4GESU5K.mjs.map} +0 -0
  147. /package/dist/{chunk-MZ37BAAE.mjs.map → chunk-MGWRDFBE.mjs.map} +0 -0
  148. /package/dist/{chunk-DSDAZA3B.mjs.map → chunk-OKCYPO4I.mjs.map} +0 -0
  149. /package/dist/{chunk-Y5ZF7AZ3.mjs.map → chunk-QQUV6DDO.mjs.map} +0 -0
  150. /package/dist/{chunk-UPQPBCUW.mjs.map → chunk-QS7M5VZM.mjs.map} +0 -0
  151. /package/dist/{chunk-FCRPPUZA.mjs.map → chunk-RLGKX6OP.mjs.map} +0 -0
  152. /package/dist/{chunk-JEMBA7PE.mjs.map → chunk-T3376SZS.mjs.map} +0 -0
  153. /package/dist/{chunk-KWS75AOU.mjs.map → chunk-U7QULEVO.mjs.map} +0 -0
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  useLangGraphInterrupt
3
- } from "../chunk-TM5MFTHG.mjs";
4
- import "../chunk-BKI4I4S2.mjs";
5
- import "../chunk-QF3Q5LUN.mjs";
6
- import "../chunk-IF4OYMFZ.mjs";
3
+ } from "../chunk-7H4ANZIC.mjs";
4
+ import "../chunk-J4GESU5K.mjs";
5
+ import "../chunk-ZVOLWJCY.mjs";
6
+ import "../chunk-GFCDU2YP.mjs";
7
7
  import "../chunk-4CEQJ2X6.mjs";
8
- import "../chunk-ZRDV3MVW.mjs";
8
+ import "../chunk-3A2AZCAV.mjs";
9
9
  import "../chunk-N4VN2B5S.mjs";
10
- import "../chunk-2MGJO3FY.mjs";
11
- import "../chunk-FRXYSJGZ.mjs";
12
- import "../chunk-DSDAZA3B.mjs";
10
+ import "../chunk-C6IANC2R.mjs";
11
+ import "../chunk-DXEQPN43.mjs";
12
+ import "../chunk-OKCYPO4I.mjs";
13
13
  import "../chunk-PIF5KJYI.mjs";
14
14
  import "../chunk-2IDV5OHF.mjs";
15
15
  import "../chunk-PMAFHQ7P.mjs";
@@ -22,7 +22,7 @@ import "../chunk-O7ARI5CV.mjs";
22
22
  import "../chunk-EFL5OBKN.mjs";
23
23
  import "../chunk-6ZLPNY7X.mjs";
24
24
  import "../chunk-YPSGKPDA.mjs";
25
- import "../chunk-YHT6CWIY.mjs";
25
+ import "../chunk-EUX2P2E7.mjs";
26
26
  import "../chunk-ZLQVRPDS.mjs";
27
27
  import "../chunk-SKC7AJIV.mjs";
28
28
  export {
@@ -127,8 +127,10 @@ var emptyCopilotContext = {
127
127
  setExtensions: () => {
128
128
  },
129
129
  langGraphInterruptAction: null,
130
- setLangGraphInterruptAction: () => null,
131
- removeLangGraphInterruptAction: () => null,
130
+ setLangGraphInterruptAction: () => {
131
+ },
132
+ removeLangGraphInterruptAction: () => {
133
+ },
132
134
  onError: () => {
133
135
  },
134
136
  bannerError: null,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/use-make-copilot-document-readable.ts","../../src/context/copilot-context.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { useCopilotContext } from \"../context/copilot-context\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Makes a document readable by Copilot.\n * @param document The document to make readable.\n * @param categories The categories to associate with the document.\n * @param dependencies The dependencies to use for the effect.\n * @returns The id of the document.\n */\nexport function useMakeCopilotDocumentReadable(\n document: DocumentPointer,\n categories?: string[],\n dependencies: any[] = [],\n): string | undefined {\n const { addDocumentContext, removeDocumentContext } = useCopilotContext();\n const idRef = useRef<string>();\n\n useEffect(() => {\n const id = addDocumentContext(document, categories);\n idRef.current = id;\n\n return () => {\n removeDocumentContext(id);\n };\n }, [addDocumentContext, removeDocumentContext, ...dependencies]);\n\n return idRef.current;\n}\n","import {\n CopilotCloudConfig,\n FunctionCallHandler,\n CopilotErrorHandler,\n CopilotKitError,\n} from \"@copilotkit/shared\";\nimport {\n ActionRenderProps,\n CatchAllActionRenderProps,\n FrontendAction,\n} from \"../types/frontend-action\";\nimport React from \"react\";\nimport { TreeNodeId, Tree } from \"../hooks/use-tree\";\nimport { DocumentPointer } from \"../types\";\nimport { CopilotChatSuggestionConfiguration } from \"../types/chat-suggestion-configuration\";\nimport { CoAgentStateRender, CoAgentStateRenderProps } from \"../types/coagent-action\";\nimport { CoagentState } from \"../types/coagent-state\";\nimport {\n CopilotRuntimeClient,\n ExtensionsInput,\n ForwardedParametersInput,\n} from \"@copilotkit/runtime-client-gql\";\nimport { Agent } from \"@copilotkit/runtime-client-gql\";\nimport {\n LangGraphInterruptAction,\n LangGraphInterruptActionSetter,\n} from \"../types/interrupt-action\";\nimport { SuggestionItem } from \"../utils/suggestions\";\n\n/**\n * Interface for the configuration of the Copilot API.\n */\nexport interface CopilotApiConfig {\n /**\n * The public API key for Copilot Cloud.\n */\n publicApiKey?: string;\n\n /**\n * The configuration for Copilot Cloud.\n */\n cloud?: CopilotCloudConfig;\n\n /**\n * The endpoint for the chat API.\n */\n chatApiEndpoint: string;\n\n /**\n * The endpoint for the Copilot transcribe audio service.\n */\n transcribeAudioUrl?: string;\n\n /**\n * The endpoint for the Copilot text to speech service.\n */\n textToSpeechUrl?: string;\n\n /**\n * additional headers to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'Authorization': 'Bearer your_token_here'\n * }\n * ```\n */\n headers: Record<string, string>;\n\n /**\n * Custom properties to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'user_id': 'user_id'\n * }\n * ```\n */\n properties?: Record<string, any>;\n\n /**\n * Indicates whether the user agent should send or receive cookies from the other domain\n * in the case of cross-origin requests.\n */\n credentials?: RequestCredentials;\n\n /**\n * Optional configuration for connecting to Model Context Protocol (MCP) servers.\n * This is typically derived from the CopilotKitProps and used internally.\n * @experimental\n */\n mcpServers?: Array<{ endpoint: string; apiKey?: string }>;\n}\n\nexport type InChatRenderFunction<TProps = ActionRenderProps<any> | CatchAllActionRenderProps<any>> =\n (props: TProps) => string | JSX.Element;\nexport type CoagentInChatRenderFunction = (\n props: CoAgentStateRenderProps<any>,\n) => string | JSX.Element | undefined | null;\n\nexport interface ChatComponentsCache {\n actions: Record<string, InChatRenderFunction | string>;\n coAgentStateRenders: Record<string, CoagentInChatRenderFunction | string>;\n}\n\nexport interface AgentSession {\n agentName: string;\n threadId?: string;\n nodeName?: string;\n}\n\nexport interface AuthState {\n status: \"authenticated\" | \"unauthenticated\";\n authHeaders: Record<string, string>;\n userId?: string;\n metadata?: Record<string, any>;\n}\n\nexport type ActionName = string;\nexport type ContextTree = Tree;\n\nexport interface CopilotContextParams {\n // function-calling\n actions: Record<string, FrontendAction<any>>;\n setAction: (id: string, action: FrontendAction<any>) => void;\n removeAction: (id: string) => void;\n\n // coagent actions\n coAgentStateRenders: Record<string, CoAgentStateRender<any>>;\n setCoAgentStateRender: (id: string, stateRender: CoAgentStateRender<any>) => void;\n removeCoAgentStateRender: (id: string) => void;\n\n chatComponentsCache: React.RefObject<ChatComponentsCache>;\n\n getFunctionCallHandler: (\n customEntryPoints?: Record<string, FrontendAction<any>>,\n ) => FunctionCallHandler;\n\n // text context\n addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n getAllContext: () => Tree;\n getContextString: (documents: DocumentPointer[], categories: string[]) => string;\n\n // document context\n addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n getDocumentsContext: (categories: string[]) => DocumentPointer[];\n\n isLoading: boolean;\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;\n\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration };\n addChatSuggestionConfiguration: (\n id: string,\n suggestion: CopilotChatSuggestionConfiguration,\n ) => void;\n removeChatSuggestionConfiguration: (id: string) => void;\n\n chatInstructions: string;\n setChatInstructions: React.Dispatch<React.SetStateAction<string>>;\n\n additionalInstructions?: string[];\n setAdditionalInstructions: React.Dispatch<React.SetStateAction<string[]>>;\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n\n showDevConsole: boolean;\n\n // agents\n coagentStates: Record<string, CoagentState>;\n setCoagentStates: React.Dispatch<React.SetStateAction<Record<string, CoagentState>>>;\n coagentStatesRef: React.RefObject<Record<string, CoagentState>>;\n setCoagentStatesWithRef: (\n value:\n | Record<string, CoagentState>\n | ((prev: Record<string, CoagentState>) => Record<string, CoagentState>),\n ) => void;\n\n agentSession: AgentSession | null;\n setAgentSession: React.Dispatch<React.SetStateAction<AgentSession | null>>;\n\n agentLock: string | null;\n\n threadId: string;\n setThreadId: React.Dispatch<React.SetStateAction<string>>;\n\n runId: string | null;\n setRunId: React.Dispatch<React.SetStateAction<string | null>>;\n\n // The chat abort controller can be used to stop generation globally,\n // i.e. when using `stop()` from `useChat`\n chatAbortControllerRef: React.MutableRefObject<AbortController | null>;\n\n // runtime\n runtimeClient: CopilotRuntimeClient;\n\n /**\n * The forwarded parameters to use for the task.\n */\n forwardedParameters?: Partial<Pick<ForwardedParametersInput, \"temperature\">>;\n availableAgents: Agent[];\n\n /**\n * The auth states for the CopilotKit.\n */\n authStates_c?: Record<ActionName, AuthState>;\n setAuthStates_c?: React.Dispatch<React.SetStateAction<Record<ActionName, AuthState>>>;\n\n /**\n * The auth config for the CopilotKit.\n */\n authConfig_c?: {\n SignInComponent: React.ComponentType<{\n onSignInComplete: (authState: AuthState) => void;\n }>;\n };\n\n extensions: ExtensionsInput;\n setExtensions: React.Dispatch<React.SetStateAction<ExtensionsInput>>;\n langGraphInterruptAction: LangGraphInterruptAction | null;\n setLangGraphInterruptAction: LangGraphInterruptActionSetter;\n removeLangGraphInterruptAction: () => void;\n\n /**\n * Optional trace handler for comprehensive debugging and observability.\n */\n onError: CopilotErrorHandler;\n\n // banner error state\n bannerError: CopilotKitError | null;\n setBannerError: React.Dispatch<React.SetStateAction<CopilotKitError | null>>;\n // Internal error handlers\n // These are used to handle errors that occur during the execution of the chat.\n // They are not intended for use by the developer. A component can register itself an error listener to be activated somewhere else as needed\n internalErrorHandlers: Record<string, CopilotErrorHandler>;\n setInternalErrorHandler: (handler: Record<string, CopilotErrorHandler>) => void;\n removeInternalErrorHandler: (id: string) => void;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n actions: {},\n setAction: () => {},\n removeAction: () => {},\n\n coAgentStateRenders: {},\n setCoAgentStateRender: () => {},\n removeCoAgentStateRender: () => {},\n\n chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },\n getContextString: (documents: DocumentPointer[], categories: string[]) =>\n returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n getAllContext: () => [],\n\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n isLoading: false,\n setIsLoading: () => returnAndThrowInDebug(false),\n\n chatInstructions: \"\",\n setChatInstructions: () => returnAndThrowInDebug(\"\"),\n\n additionalInstructions: [],\n setAdditionalInstructions: () => returnAndThrowInDebug([]),\n\n getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\n runtimeClient: {} as any,\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n\n get headers(): Record<string, string> {\n return {};\n }\n get body(): Record<string, any> {\n return {};\n }\n })(),\n\n chatSuggestionConfiguration: {},\n addChatSuggestionConfiguration: () => {},\n removeChatSuggestionConfiguration: () => {},\n showDevConsole: false,\n coagentStates: {},\n setCoagentStates: () => {},\n coagentStatesRef: { current: {} },\n setCoagentStatesWithRef: () => {},\n agentSession: null,\n setAgentSession: () => {},\n forwardedParameters: {},\n agentLock: null,\n threadId: \"\",\n setThreadId: () => {},\n runId: null,\n setRunId: () => {},\n chatAbortControllerRef: { current: null },\n availableAgents: [],\n extensions: {},\n setExtensions: () => {},\n langGraphInterruptAction: null,\n setLangGraphInterruptAction: () => null,\n removeLangGraphInterruptAction: () => null,\n onError: () => {},\n bannerError: null,\n setBannerError: () => {},\n internalErrorHandlers: {},\n setInternalErrorHandler: () => {},\n removeInternalErrorHandler: () => {},\n};\n\nexport const CopilotContext = React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nexport function useCopilotContext(): CopilotContextParams {\n const context = React.useContext(CopilotContext);\n if (context === emptyCopilotContext) {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n return context;\n}\n\nfunction returnAndThrowInDebug<T>(_value: T): T {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA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,KAAK,mBAAmB,UAAU,UAAU;AAClD,UAAM,UAAU;AAEhB,WAAO,MAAM;AACX,4BAAsB,EAAE;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,oBAAoB,uBAAuB,GAAG,YAAY,CAAC;AAE/D,SAAO,MAAM;AACf;","names":["import_react","React"]}
1
+ {"version":3,"sources":["../../src/hooks/use-make-copilot-document-readable.ts","../../src/context/copilot-context.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { useCopilotContext } from \"../context/copilot-context\";\nimport { DocumentPointer } from \"../types\";\n\n/**\n * Makes a document readable by Copilot.\n * @param document The document to make readable.\n * @param categories The categories to associate with the document.\n * @param dependencies The dependencies to use for the effect.\n * @returns The id of the document.\n */\nexport function useMakeCopilotDocumentReadable(\n document: DocumentPointer,\n categories?: string[],\n dependencies: any[] = [],\n): string | undefined {\n const { addDocumentContext, removeDocumentContext } = useCopilotContext();\n const idRef = useRef<string>();\n\n useEffect(() => {\n const id = addDocumentContext(document, categories);\n idRef.current = id;\n\n return () => {\n removeDocumentContext(id);\n };\n }, [addDocumentContext, removeDocumentContext, ...dependencies]);\n\n return idRef.current;\n}\n","import {\n CopilotCloudConfig,\n FunctionCallHandler,\n CopilotErrorHandler,\n CopilotKitError,\n} from \"@copilotkit/shared\";\nimport {\n ActionRenderProps,\n CatchAllActionRenderProps,\n FrontendAction,\n} from \"../types/frontend-action\";\nimport React from \"react\";\nimport { TreeNodeId, Tree } from \"../hooks/use-tree\";\nimport { DocumentPointer } from \"../types\";\nimport { CopilotChatSuggestionConfiguration } from \"../types/chat-suggestion-configuration\";\nimport { CoAgentStateRender, CoAgentStateRenderProps } from \"../types/coagent-action\";\nimport { CoagentState } from \"../types/coagent-state\";\nimport {\n CopilotRuntimeClient,\n ExtensionsInput,\n ForwardedParametersInput,\n} from \"@copilotkit/runtime-client-gql\";\nimport { Agent } from \"@copilotkit/runtime-client-gql\";\nimport {\n LangGraphInterruptAction,\n LangGraphInterruptActionSetter,\n} from \"../types/interrupt-action\";\nimport { SuggestionItem } from \"../utils/suggestions\";\n\n/**\n * Interface for the configuration of the Copilot API.\n */\nexport interface CopilotApiConfig {\n /**\n * The public API key for Copilot Cloud.\n */\n publicApiKey?: string;\n\n /**\n * The configuration for Copilot Cloud.\n */\n cloud?: CopilotCloudConfig;\n\n /**\n * The endpoint for the chat API.\n */\n chatApiEndpoint: string;\n\n /**\n * The endpoint for the Copilot transcribe audio service.\n */\n transcribeAudioUrl?: string;\n\n /**\n * The endpoint for the Copilot text to speech service.\n */\n textToSpeechUrl?: string;\n\n /**\n * additional headers to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'Authorization': 'Bearer your_token_here'\n * }\n * ```\n */\n headers: Record<string, string>;\n\n /**\n * Custom properties to be sent with the request\n * @default {}\n * @example\n * ```\n * {\n * 'user_id': 'user_id'\n * }\n * ```\n */\n properties?: Record<string, any>;\n\n /**\n * Indicates whether the user agent should send or receive cookies from the other domain\n * in the case of cross-origin requests.\n */\n credentials?: RequestCredentials;\n\n /**\n * Optional configuration for connecting to Model Context Protocol (MCP) servers.\n * This is typically derived from the CopilotKitProps and used internally.\n * @experimental\n */\n mcpServers?: Array<{ endpoint: string; apiKey?: string }>;\n}\n\nexport type InChatRenderFunction<TProps = ActionRenderProps<any> | CatchAllActionRenderProps<any>> =\n (props: TProps) => string | JSX.Element;\nexport type CoagentInChatRenderFunction = (\n props: CoAgentStateRenderProps<any>,\n) => string | JSX.Element | undefined | null;\n\nexport interface ChatComponentsCache {\n actions: Record<string, InChatRenderFunction | string>;\n coAgentStateRenders: Record<string, CoagentInChatRenderFunction | string>;\n}\n\nexport interface AgentSession {\n agentName: string;\n threadId?: string;\n nodeName?: string;\n}\n\nexport interface AuthState {\n status: \"authenticated\" | \"unauthenticated\";\n authHeaders: Record<string, string>;\n userId?: string;\n metadata?: Record<string, any>;\n}\n\nexport type ActionName = string;\nexport type ContextTree = Tree;\n\nexport interface CopilotContextParams {\n // function-calling\n actions: Record<string, FrontendAction<any>>;\n setAction: (id: string, action: FrontendAction<any>) => void;\n removeAction: (id: string) => void;\n\n // coagent actions\n coAgentStateRenders: Record<string, CoAgentStateRender<any>>;\n setCoAgentStateRender: (id: string, stateRender: CoAgentStateRender<any>) => void;\n removeCoAgentStateRender: (id: string) => void;\n\n chatComponentsCache: React.RefObject<ChatComponentsCache>;\n\n getFunctionCallHandler: (\n customEntryPoints?: Record<string, FrontendAction<any>>,\n ) => FunctionCallHandler;\n\n // text context\n addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;\n removeContext: (id: TreeNodeId) => void;\n getAllContext: () => Tree;\n getContextString: (documents: DocumentPointer[], categories: string[]) => string;\n\n // document context\n addDocumentContext: (documentPointer: DocumentPointer, categories?: string[]) => TreeNodeId;\n removeDocumentContext: (documentId: string) => void;\n getDocumentsContext: (categories: string[]) => DocumentPointer[];\n\n isLoading: boolean;\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;\n\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration };\n addChatSuggestionConfiguration: (\n id: string,\n suggestion: CopilotChatSuggestionConfiguration,\n ) => void;\n removeChatSuggestionConfiguration: (id: string) => void;\n\n chatInstructions: string;\n setChatInstructions: React.Dispatch<React.SetStateAction<string>>;\n\n additionalInstructions?: string[];\n setAdditionalInstructions: React.Dispatch<React.SetStateAction<string[]>>;\n\n // api endpoints\n copilotApiConfig: CopilotApiConfig;\n\n showDevConsole: boolean;\n\n // agents\n coagentStates: Record<string, CoagentState>;\n setCoagentStates: React.Dispatch<React.SetStateAction<Record<string, CoagentState>>>;\n coagentStatesRef: React.RefObject<Record<string, CoagentState>>;\n setCoagentStatesWithRef: (\n value:\n | Record<string, CoagentState>\n | ((prev: Record<string, CoagentState>) => Record<string, CoagentState>),\n ) => void;\n\n agentSession: AgentSession | null;\n setAgentSession: React.Dispatch<React.SetStateAction<AgentSession | null>>;\n\n agentLock: string | null;\n\n threadId: string;\n setThreadId: React.Dispatch<React.SetStateAction<string>>;\n\n runId: string | null;\n setRunId: React.Dispatch<React.SetStateAction<string | null>>;\n\n // The chat abort controller can be used to stop generation globally,\n // i.e. when using `stop()` from `useChat`\n chatAbortControllerRef: React.MutableRefObject<AbortController | null>;\n\n // runtime\n runtimeClient: CopilotRuntimeClient;\n\n /**\n * The forwarded parameters to use for the task.\n */\n forwardedParameters?: Partial<Pick<ForwardedParametersInput, \"temperature\">>;\n availableAgents: Agent[];\n\n /**\n * The auth states for the CopilotKit.\n */\n authStates_c?: Record<ActionName, AuthState>;\n setAuthStates_c?: React.Dispatch<React.SetStateAction<Record<ActionName, AuthState>>>;\n\n /**\n * The auth config for the CopilotKit.\n */\n authConfig_c?: {\n SignInComponent: React.ComponentType<{\n onSignInComplete: (authState: AuthState) => void;\n }>;\n };\n\n extensions: ExtensionsInput;\n setExtensions: React.Dispatch<React.SetStateAction<ExtensionsInput>>;\n langGraphInterruptAction: LangGraphInterruptAction | null;\n setLangGraphInterruptAction: LangGraphInterruptActionSetter;\n removeLangGraphInterruptAction: (threadId: string) => void;\n\n /**\n * Optional trace handler for comprehensive debugging and observability.\n */\n onError: CopilotErrorHandler;\n\n // banner error state\n bannerError: CopilotKitError | null;\n setBannerError: React.Dispatch<React.SetStateAction<CopilotKitError | null>>;\n // Internal error handlers\n // These are used to handle errors that occur during the execution of the chat.\n // They are not intended for use by the developer. A component can register itself an error listener to be activated somewhere else as needed\n internalErrorHandlers: Record<string, CopilotErrorHandler>;\n setInternalErrorHandler: (handler: Record<string, CopilotErrorHandler>) => void;\n removeInternalErrorHandler: (id: string) => void;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n actions: {},\n setAction: () => {},\n removeAction: () => {},\n\n coAgentStateRenders: {},\n setCoAgentStateRender: () => {},\n removeCoAgentStateRender: () => {},\n\n chatComponentsCache: { current: { actions: {}, coAgentStateRenders: {} } },\n getContextString: (documents: DocumentPointer[], categories: string[]) =>\n returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n getAllContext: () => [],\n\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n isLoading: false,\n setIsLoading: () => returnAndThrowInDebug(false),\n\n chatInstructions: \"\",\n setChatInstructions: () => returnAndThrowInDebug(\"\"),\n\n additionalInstructions: [],\n setAdditionalInstructions: () => returnAndThrowInDebug([]),\n\n getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\n runtimeClient: {} as any,\n\n copilotApiConfig: new (class implements CopilotApiConfig {\n get chatApiEndpoint(): string {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n\n get headers(): Record<string, string> {\n return {};\n }\n get body(): Record<string, any> {\n return {};\n }\n })(),\n\n chatSuggestionConfiguration: {},\n addChatSuggestionConfiguration: () => {},\n removeChatSuggestionConfiguration: () => {},\n showDevConsole: false,\n coagentStates: {},\n setCoagentStates: () => {},\n coagentStatesRef: { current: {} },\n setCoagentStatesWithRef: () => {},\n agentSession: null,\n setAgentSession: () => {},\n forwardedParameters: {},\n agentLock: null,\n threadId: \"\",\n setThreadId: () => {},\n runId: null,\n setRunId: () => {},\n chatAbortControllerRef: { current: null },\n availableAgents: [],\n extensions: {},\n setExtensions: () => {},\n langGraphInterruptAction: null,\n setLangGraphInterruptAction: () => {},\n removeLangGraphInterruptAction: () => {},\n onError: () => {},\n bannerError: null,\n setBannerError: () => {},\n internalErrorHandlers: {},\n setInternalErrorHandler: () => {},\n removeInternalErrorHandler: () => {},\n};\n\nexport const CopilotContext = React.createContext<CopilotContextParams>(emptyCopilotContext);\n\nexport function useCopilotContext(): CopilotContextParams {\n const context = React.useContext(CopilotContext);\n if (context === emptyCopilotContext) {\n throw new Error(\"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!\");\n }\n return context;\n}\n\nfunction returnAndThrowInDebug<T>(_value: T): T {\n throw new Error(\"Remember to wrap your app in a `<Copil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ACA,eAAsB,CAAC,GACH;AACpB,QAAM,EAAE,oBAAoB,sBAAsB,IAAI,kBAAkB;AACxE,QAAM,YAAQ,sBAAe;AAE7B,+BAAU,MAAM;AACd,UAAM,KAAK,mBAAmB,UAAU,UAAU;AAClD,UAAM,UAAU;AAEhB,WAAO,MAAM;AACX,4BAAsB,EAAE;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,oBAAoB,uBAAuB,GAAG,YAAY,CAAC;AAE/D,SAAO,MAAM;AACf;","names":["import_react","React"]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  useMakeCopilotDocumentReadable
3
- } from "../chunk-CXDK6XA5.mjs";
4
- import "../chunk-YHT6CWIY.mjs";
3
+ } from "../chunk-BBUQMG45.mjs";
4
+ import "../chunk-EUX2P2E7.mjs";
5
5
  import "../chunk-SKC7AJIV.mjs";
6
6
  export {
7
7
  useMakeCopilotDocumentReadable
@@ -1,4 +1,4 @@
1
- import { a as CopilotContextParams } from './copilot-context-59740e82.js';
1
+ import { a as CopilotContextParams } from './copilot-context-cf9de848.js';
2
2
  import { Message } from '@copilotkit/runtime-client-gql';
3
3
  import React$1 from 'react';
4
4
  import { CopilotChatSuggestionConfiguration } from './types/chat-suggestion-configuration.js';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { CopilotKit, defaultCopilotContextCategories } from './components/copilot-provider/copilotkit.js';
2
2
  export { CopilotKitProps } from './components/copilot-provider/copilotkit-props.js';
3
- export { b as CoagentInChatRenderFunction, c as CopilotApiConfig, C as CopilotContext, a as CopilotContextParams, u as useCopilotContext } from './copilot-context-59740e82.js';
4
- export { C as CopilotMessagesContext, a as CopilotMessagesContextParams, S as SuggestionItem, r as reloadSuggestions, u as useCopilotMessagesContext } from './index-d1743abe.js';
3
+ export { b as CoagentInChatRenderFunction, c as CopilotApiConfig, C as CopilotContext, a as CopilotContextParams, u as useCopilotContext } from './copilot-context-cf9de848.js';
4
+ export { C as CopilotMessagesContext, a as CopilotMessagesContextParams, S as SuggestionItem, r as reloadSuggestions, u as useCopilotMessagesContext } from './index-1f5b66ac.js';
5
5
  export { UseCopilotChatReturn, useCopilotChat } from './hooks/use-copilot-chat.js';
6
6
  export { UseCopilotChatOptions, UseCopilotChatOptions as UseCopilotChatOptions_c, UseCopilotChatReturn as UseCopilotChatReturn_c, useCopilotChat as useCopilotChatInternal } from './hooks/use-copilot-chat_internal.js';
7
7
  export { useCopilotChatHeadless_c } from './hooks/use-copilot-chat-headless_c.js';
package/dist/index.js CHANGED
@@ -186,8 +186,10 @@ var emptyCopilotContext = {
186
186
  setExtensions: () => {
187
187
  },
188
188
  langGraphInterruptAction: null,
189
- setLangGraphInterruptAction: () => null,
190
- removeLangGraphInterruptAction: () => null,
189
+ setLangGraphInterruptAction: () => {
190
+ },
191
+ removeLangGraphInterruptAction: () => {
192
+ },
191
193
  onError: () => {
192
194
  },
193
195
  bannerError: null,
@@ -2789,6 +2791,7 @@ function CopilotKit(_a) {
2789
2791
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ToastProvider, { enabled, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CopilotErrorBoundary, { publicApiKey, showUsageBanner: enabled, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children })) }) });
2790
2792
  }
2791
2793
  function CopilotKitInternal(cpkProps) {
2794
+ var _b;
2792
2795
  const _a = cpkProps, { children } = _a, props = __objRest(_a, ["children"]);
2793
2796
  validateProps(cpkProps);
2794
2797
  const publicApiKey = props.publicLicenseKey || props.publicApiKey;
@@ -2891,7 +2894,7 @@ ${nonDocumentStrings}`;
2891
2894
  [removeDocument]
2892
2895
  );
2893
2896
  const copilotApiConfig = (0, import_react12.useMemo)(() => {
2894
- var _a2, _b;
2897
+ var _a2, _b2;
2895
2898
  let cloud = void 0;
2896
2899
  if (publicApiKey) {
2897
2900
  cloud = {
@@ -2900,7 +2903,7 @@ ${nonDocumentStrings}`;
2900
2903
  restrictToTopic: {
2901
2904
  enabled: Boolean(props.guardrails_c),
2902
2905
  validTopics: ((_a2 = props.guardrails_c) == null ? void 0 : _a2.validTopics) || [],
2903
- invalidTopics: ((_b = props.guardrails_c) == null ? void 0 : _b.invalidTopics) || []
2906
+ invalidTopics: ((_b2 = props.guardrails_c) == null ? void 0 : _b2.invalidTopics) || []
2904
2907
  }
2905
2908
  }
2906
2909
  }
@@ -3063,22 +3066,28 @@ ${nonDocumentStrings}`;
3063
3066
  const [runId, setRunId] = (0, import_react12.useState)(null);
3064
3067
  const chatAbortControllerRef = (0, import_react12.useRef)(null);
3065
3068
  const showDevConsole = shouldShowDevConsole(props.showDevConsole);
3066
- const [langGraphInterruptAction, _setLangGraphInterruptAction] = (0, import_react12.useState)(null);
3067
- const setLangGraphInterruptAction = (0, import_react12.useCallback)((action) => {
3068
- _setLangGraphInterruptAction((prev) => {
3069
- if (prev == null)
3070
- return action;
3071
- if (action == null)
3072
- return null;
3073
- let event = prev.event;
3074
- if (action.event) {
3075
- event = __spreadValues(__spreadValues({}, prev.event), action.event);
3076
- }
3077
- return __spreadProps(__spreadValues(__spreadValues({}, prev), action), { event });
3078
- });
3079
- }, []);
3080
- const removeLangGraphInterruptAction = (0, import_react12.useCallback)(() => {
3081
- setLangGraphInterruptAction(null);
3069
+ const [langGraphInterruptActions, _setLangGraphInterruptAction] = (0, import_react12.useState)({});
3070
+ const setLangGraphInterruptAction = (0, import_react12.useCallback)(
3071
+ (threadId, action) => {
3072
+ _setLangGraphInterruptAction((prev) => {
3073
+ var _a2, _b2, _c;
3074
+ if (action == null)
3075
+ return __spreadProps(__spreadValues({}, prev), {
3076
+ [threadId]: null
3077
+ });
3078
+ let event = (_a2 = prev[threadId]) == null ? void 0 : _a2.event;
3079
+ if (action.event) {
3080
+ event = __spreadValues(__spreadValues({}, ((_b2 = prev[threadId]) == null ? void 0 : _b2.event) || {}), action.event);
3081
+ }
3082
+ return __spreadProps(__spreadValues({}, prev), {
3083
+ [threadId]: __spreadProps(__spreadValues(__spreadValues({}, (_c = prev[threadId]) != null ? _c : {}), action), { event })
3084
+ });
3085
+ });
3086
+ },
3087
+ []
3088
+ );
3089
+ const removeLangGraphInterruptAction = (0, import_react12.useCallback)((threadId) => {
3090
+ setLangGraphInterruptAction(threadId, null);
3082
3091
  }, []);
3083
3092
  const memoizedChildren = (0, import_react12.useMemo)(() => children, [children]);
3084
3093
  const [bannerError, setBannerError] = (0, import_react12.useState)(null);
@@ -3167,7 +3176,7 @@ ${nonDocumentStrings}`;
3167
3176
  setAuthStates_c: updateAuthStates,
3168
3177
  extensions,
3169
3178
  setExtensions: updateExtensions,
3170
- langGraphInterruptAction,
3179
+ langGraphInterruptAction: (_b = langGraphInterruptActions[internalThreadId]) != null ? _b : null,
3171
3180
  setLangGraphInterruptAction,
3172
3181
  removeLangGraphInterruptAction,
3173
3182
  bannerError,
@@ -3475,7 +3484,7 @@ function useChat(options) {
3475
3484
  if (ev.name === import_runtime_client_gql7.MetaEventName.LangGraphInterruptEvent) {
3476
3485
  let eventValue = (0, import_runtime_client_gql7.langGraphInterruptEvent)(ev).value;
3477
3486
  eventValue = (0, import_shared14.parseJson)(eventValue, eventValue);
3478
- setLangGraphInterruptAction({
3487
+ setLangGraphInterruptAction(threadId, {
3479
3488
  event: __spreadProps(__spreadValues({}, (0, import_runtime_client_gql7.langGraphInterruptEvent)(ev)), {
3480
3489
  value: eventValue
3481
3490
  })
@@ -3773,7 +3782,7 @@ function useChat(options) {
3773
3782
  switch (event.name) {
3774
3783
  case import_runtime_client_gql7.MetaEventName.LangGraphInterruptEvent:
3775
3784
  if (event.response) {
3776
- setLangGraphInterruptAction(null);
3785
+ setLangGraphInterruptAction(threadId, null);
3777
3786
  const value = event.value;
3778
3787
  return [
3779
3788
  ...acc,
@@ -3953,16 +3962,16 @@ var InterruptRenderer = ({ event, result, render, resolve }) => {
3953
3962
  return render({ event, result, resolve });
3954
3963
  };
3955
3964
  function useLangGraphInterruptRender() {
3956
- const { langGraphInterruptAction, setLangGraphInterruptAction, agentSession } = useCopilotContext();
3965
+ const { langGraphInterruptAction, setLangGraphInterruptAction, agentSession, threadId } = useCopilotContext();
3957
3966
  const responseRef = import_react14.default.useRef();
3958
3967
  const resolveInterrupt = (0, import_react14.useCallback)(
3959
3968
  (response) => {
3960
3969
  responseRef.current = response;
3961
3970
  setTimeout(() => {
3962
- setLangGraphInterruptAction({ event: { response } });
3971
+ setLangGraphInterruptAction(threadId, { event: { response } });
3963
3972
  }, 0);
3964
3973
  },
3965
- [setLangGraphInterruptAction]
3974
+ [setLangGraphInterruptAction, threadId]
3966
3975
  );
3967
3976
  if (!langGraphInterruptAction || !langGraphInterruptAction.event || !langGraphInterruptAction.render)
3968
3977
  return null;
@@ -4873,7 +4882,12 @@ var import_react24 = require("react");
4873
4882
  var import_shared19 = require("@copilotkit/shared");
4874
4883
  function useLangGraphInterrupt(action, dependencies) {
4875
4884
  var _a;
4876
- const { setLangGraphInterruptAction, removeLangGraphInterruptAction, langGraphInterruptAction } = (0, import_react24.useContext)(CopilotContext);
4885
+ const {
4886
+ setLangGraphInterruptAction,
4887
+ removeLangGraphInterruptAction,
4888
+ langGraphInterruptAction,
4889
+ threadId
4890
+ } = (0, import_react24.useContext)(CopilotContext);
4877
4891
  const { runChatCompletion } = useCopilotChat();
4878
4892
  const { addToast } = useToast();
4879
4893
  const actionId = (0, import_shared19.dataToUUID)(JSON.stringify(action), "lgAction");
@@ -4904,13 +4918,14 @@ function useLangGraphInterrupt(action, dependencies) {
4904
4918
  if (hasAction && isCurrentAction) {
4905
4919
  return;
4906
4920
  }
4907
- setLangGraphInterruptAction(__spreadProps(__spreadValues({}, action), { id: actionId }));
4921
+ setLangGraphInterruptAction(threadId, __spreadProps(__spreadValues({}, action), { id: actionId }));
4908
4922
  }, [
4909
4923
  action,
4910
4924
  hasAction,
4911
4925
  isCurrentAction,
4912
4926
  setLangGraphInterruptAction,
4913
4927
  removeLangGraphInterruptAction,
4928
+ threadId,
4914
4929
  ...dependencies || []
4915
4930
  ]);
4916
4931
  }