@copilotkit/react-core 1.1.3-feat-runtime-remote-actions.2 → 1.2.0

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 (126) hide show
  1. package/CHANGELOG.md +6 -21
  2. package/dist/chunk-5JB4B2SV.mjs +1 -0
  3. package/dist/{chunk-VCEOT4GG.mjs → chunk-AIW2RAN2.mjs} +6 -35
  4. package/dist/chunk-AIW2RAN2.mjs.map +1 -0
  5. package/dist/{chunk-RBNULK3U.mjs → chunk-CFCRJA63.mjs} +5 -39
  6. package/dist/chunk-CFCRJA63.mjs.map +1 -0
  7. package/dist/{chunk-3U22BXKC.mjs → chunk-EVK5346D.mjs} +3 -4
  8. package/dist/chunk-EVK5346D.mjs.map +1 -0
  9. package/dist/{chunk-A37GANOW.mjs → chunk-GSL4ZHUB.mjs} +4 -4
  10. package/dist/chunk-GSL4ZHUB.mjs.map +1 -0
  11. package/dist/{chunk-TCZBK3HZ.mjs → chunk-HUC6EZVP.mjs} +4 -7
  12. package/dist/chunk-HUC6EZVP.mjs.map +1 -0
  13. package/dist/{chunk-CODXG6KU.mjs → chunk-LB53QWLY.mjs} +2 -2
  14. package/dist/{chunk-J2YXDQHR.mjs → chunk-LB7ULLSU.mjs} +3 -14
  15. package/dist/chunk-LB7ULLSU.mjs.map +1 -0
  16. package/dist/{chunk-RWPGGPW5.mjs → chunk-PZOEBYWP.mjs} +11 -63
  17. package/dist/chunk-PZOEBYWP.mjs.map +1 -0
  18. package/dist/{chunk-326LK7LX.mjs → chunk-QR4XKQOA.mjs} +2 -2
  19. package/dist/components/copilot-provider/copilotkit-props.d.ts +0 -4
  20. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  21. package/dist/components/copilot-provider/copilotkit.js +5 -50
  22. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  23. package/dist/components/copilot-provider/copilotkit.mjs +2 -2
  24. package/dist/components/copilot-provider/index.js +5 -50
  25. package/dist/components/copilot-provider/index.js.map +1 -1
  26. package/dist/components/copilot-provider/index.mjs +2 -2
  27. package/dist/components/index.js +5 -50
  28. package/dist/components/index.js.map +1 -1
  29. package/dist/components/index.mjs +2 -2
  30. package/dist/context/copilot-context.d.ts +2 -21
  31. package/dist/context/copilot-context.js +2 -13
  32. package/dist/context/copilot-context.js.map +1 -1
  33. package/dist/context/copilot-context.mjs +1 -1
  34. package/dist/context/index.d.ts +0 -2
  35. package/dist/context/index.js +2 -13
  36. package/dist/context/index.js.map +1 -1
  37. package/dist/context/index.mjs +1 -1
  38. package/dist/hooks/index.d.ts +0 -4
  39. package/dist/hooks/index.js +21 -224
  40. package/dist/hooks/index.js.map +1 -1
  41. package/dist/hooks/index.mjs +8 -17
  42. package/dist/hooks/use-chat.d.ts +4 -26
  43. package/dist/hooks/use-chat.js +9 -58
  44. package/dist/hooks/use-chat.js.map +1 -1
  45. package/dist/hooks/use-chat.mjs +1 -1
  46. package/dist/hooks/use-copilot-action.js +4 -15
  47. package/dist/hooks/use-copilot-action.js.map +1 -1
  48. package/dist/hooks/use-copilot-action.mjs +2 -2
  49. package/dist/hooks/use-copilot-chat.js +13 -101
  50. package/dist/hooks/use-copilot-chat.js.map +1 -1
  51. package/dist/hooks/use-copilot-chat.mjs +4 -4
  52. package/dist/hooks/use-copilot-readable.js +2 -13
  53. package/dist/hooks/use-copilot-readable.js.map +1 -1
  54. package/dist/hooks/use-copilot-readable.mjs +2 -2
  55. package/dist/hooks/use-make-copilot-document-readable.js +2 -13
  56. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  57. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  58. package/dist/index.d.ts +0 -4
  59. package/dist/index.js +31 -268
  60. package/dist/index.js.map +1 -1
  61. package/dist/index.mjs +12 -20
  62. package/dist/lib/copilot-task.d.ts +0 -2
  63. package/dist/lib/copilot-task.js +1 -1
  64. package/dist/lib/copilot-task.js.map +1 -1
  65. package/dist/lib/copilot-task.mjs +3 -3
  66. package/dist/lib/index.d.ts +0 -2
  67. package/dist/lib/index.js +1 -1
  68. package/dist/lib/index.js.map +1 -1
  69. package/dist/lib/index.mjs +3 -3
  70. package/dist/utils/extract.d.ts +0 -2
  71. package/dist/utils/extract.js +1 -1
  72. package/dist/utils/extract.js.map +1 -1
  73. package/dist/utils/extract.mjs +3 -3
  74. package/dist/utils/index.d.ts +0 -2
  75. package/dist/utils/index.js +1 -1
  76. package/dist/utils/index.js.map +1 -1
  77. package/dist/utils/index.mjs +3 -3
  78. package/package.json +5 -5
  79. package/src/components/copilot-provider/copilotkit-props.tsx +0 -5
  80. package/src/components/copilot-provider/copilotkit.tsx +3 -45
  81. package/src/context/copilot-context.tsx +2 -39
  82. package/src/hooks/index.ts +0 -2
  83. package/src/hooks/use-chat.ts +11 -111
  84. package/src/hooks/use-copilot-action.ts +2 -2
  85. package/src/hooks/use-copilot-chat.ts +0 -31
  86. package/src/lib/copilot-task.ts +1 -2
  87. package/src/utils/extract.ts +2 -7
  88. package/dist/chunk-3U22BXKC.mjs.map +0 -1
  89. package/dist/chunk-A37GANOW.mjs.map +0 -1
  90. package/dist/chunk-BWYAGPEF.mjs +0 -1
  91. package/dist/chunk-J2YXDQHR.mjs.map +0 -1
  92. package/dist/chunk-Q4TTTAXQ.mjs +0 -87
  93. package/dist/chunk-Q4TTTAXQ.mjs.map +0 -1
  94. package/dist/chunk-RBNULK3U.mjs.map +0 -1
  95. package/dist/chunk-RWPGGPW5.mjs.map +0 -1
  96. package/dist/chunk-STUXJ3BN.mjs +0 -44
  97. package/dist/chunk-STUXJ3BN.mjs.map +0 -1
  98. package/dist/chunk-TCZBK3HZ.mjs.map +0 -1
  99. package/dist/chunk-VCEOT4GG.mjs.map +0 -1
  100. package/dist/hooks/use-coagent-action.d.ts +0 -5
  101. package/dist/hooks/use-coagent-action.js +0 -156
  102. package/dist/hooks/use-coagent-action.js.map +0 -1
  103. package/dist/hooks/use-coagent-action.mjs +0 -9
  104. package/dist/hooks/use-coagent-action.mjs.map +0 -1
  105. package/dist/hooks/use-coagent.d.ts +0 -27
  106. package/dist/hooks/use-coagent.js +0 -219
  107. package/dist/hooks/use-coagent.js.map +0 -1
  108. package/dist/hooks/use-coagent.mjs +0 -10
  109. package/dist/hooks/use-coagent.mjs.map +0 -1
  110. package/dist/types/coagent-action.d.ts +0 -17
  111. package/dist/types/coagent-action.js +0 -19
  112. package/dist/types/coagent-action.js.map +0 -1
  113. package/dist/types/coagent-action.mjs +0 -1
  114. package/dist/types/coagent-action.mjs.map +0 -1
  115. package/dist/types/coagent-state.d.ts +0 -11
  116. package/dist/types/coagent-state.js +0 -19
  117. package/dist/types/coagent-state.js.map +0 -1
  118. package/dist/types/coagent-state.mjs +0 -1
  119. package/dist/types/coagent-state.mjs.map +0 -1
  120. package/src/hooks/use-coagent-action.ts +0 -44
  121. package/src/hooks/use-coagent.ts +0 -133
  122. package/src/types/coagent-action.ts +0 -17
  123. package/src/types/coagent-state.ts +0 -9
  124. /package/dist/{chunk-BWYAGPEF.mjs.map → chunk-5JB4B2SV.mjs.map} +0 -0
  125. /package/dist/{chunk-CODXG6KU.mjs.map → chunk-LB53QWLY.mjs.map} +0 -0
  126. /package/dist/{chunk-326LK7LX.mjs.map → chunk-QR4XKQOA.mjs.map} +0 -0
@@ -63,12 +63,7 @@ var emptyCopilotContext = {
63
63
  },
64
64
  removeAction: () => {
65
65
  },
66
- coagentActions: {},
67
- setCoagentAction: () => {
68
- },
69
- removeCoagentAction: () => {
70
- },
71
- chatComponentsCache: { current: { actions: {}, coagentActions: {} } },
66
+ chatComponentsCache: { current: {} },
72
67
  getContextString: (documents, categories) => returnAndThrowInDebug(""),
73
68
  addContext: () => "",
74
69
  removeContext: () => {
@@ -101,13 +96,7 @@ var emptyCopilotContext = {
101
96
  },
102
97
  removeChatSuggestionConfiguration: () => {
103
98
  },
104
- showDevConsole: "auto",
105
- coagentStates: {},
106
- setCoagentStates: () => {
107
- },
108
- agentSession: null,
109
- setAgentSession: () => {
110
- }
99
+ showDevConsole: "auto"
111
100
  };
112
101
  var CopilotContext = import_react.default.createContext(emptyCopilotContext);
113
102
  function useCopilotContext() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/context/index.ts","../../src/context/copilot-context.tsx"],"sourcesContent":["export { CopilotContext, useCopilotContext } from \"./copilot-context\";\nexport type { CopilotContextParams } from \"./copilot-context\";\nexport type { CopilotApiConfig } from \"./copilot-context\";\n","import { CopilotCloudConfig, FunctionCallHandler } from \"@copilotkit/shared\";\nimport { Message } from \"@copilotkit/runtime-client-gql\";\nimport { ActionRenderProps, FrontendAction } from \"../types/frontend-action\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { DocumentPointer } from \"../types\";\nimport { CopilotChatSuggestionConfiguration } from \"../types/chat-suggestion-configuration\";\nimport { CoagentAction, CoagentActionRenderProps } from \"../types/coagent-action\";\nimport { CoagentState } from \"../types/coagent-state\";\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\nexport type InChatRenderFunction = (props: ActionRenderProps<any>) => string | JSX.Element;\nexport type CoagentInChatRenderFunction = (\n props: CoagentActionRenderProps<any>,\n) => string | JSX.Element;\n\nexport interface ChatComponentsCache {\n actions: Record<string, InChatRenderFunction | string>;\n coagentActions: Record<string, CoagentInChatRenderFunction | string>;\n}\n\nexport interface AgentSession {\n agentName: string;\n threadId?: string;\n nodeName?: string;\n}\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 coagentActions: Record<string, CoagentAction<any>>;\n setCoagentAction: (id: string, action: CoagentAction<any>) => void;\n removeCoagentAction: (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 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 // chat\n messages: Message[];\n setMessages: React.Dispatch<React.SetStateAction<Message[]>>;\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 // api endpoints\n copilotApiConfig: CopilotApiConfig;\n\n showDevConsole: boolean | \"auto\";\n\n // agents\n coagentStates: Record<string, CoagentState>;\n setCoagentStates: React.Dispatch<React.SetStateAction<Record<string, CoagentState>>>;\n agentSession: AgentSession | null;\n setAgentSession: React.Dispatch<React.SetStateAction<AgentSession | null>>;\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n actions: {},\n setAction: () => {},\n removeAction: () => {},\n\n coagentActions: {},\n setCoagentAction: () => {},\n removeCoagentAction: () => {},\n\n chatComponentsCache: { current: { actions: {}, coagentActions: {} } },\n getContextString: (documents: DocumentPointer[], categories: string[]) =>\n returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n messages: [],\n setMessages: () => returnAndThrowInDebug([]),\n\n isLoading: false,\n setIsLoading: () => returnAndThrowInDebug(false),\n\n chatInstructions: \"\",\n setChatInstructions: () => returnAndThrowInDebug(\"\"),\n\n getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\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: \"auto\",\n coagentStates: {},\n setCoagentStates: () => {},\n\n agentSession: null,\n setAgentSession: () => {},\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 return value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,mBAAkB;AA2IlB,IAAM,sBAA4C;AAAA,EAChD,SAAS,CAAC;AAAA,EACV,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB,cAAc,MAAM;AAAA,EAAC;AAAA,EAErB,gBAAgB,CAAC;AAAA,EACjB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,qBAAqB,MAAM;AAAA,EAAC;AAAA,EAE5B,qBAAqB,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,gBAAgB,CAAC,EAAE,EAAE;AAAA,EACpE,kBAAkB,CAAC,WAA8B,eAC/C,sBAAsB,EAAE;AAAA,EAC1B,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,EAEtB,wBAAwB,MAAM,sBAAsB,MAAY;AAAA,EAAC,EAAC;AAAA,EAElE,UAAU,CAAC;AAAA,EACX,aAAa,MAAM,sBAAsB,CAAC,CAAC;AAAA,EAE3C,WAAW;AAAA,EACX,cAAc,MAAM,sBAAsB,KAAK;AAAA,EAE/C,kBAAkB;AAAA,EAClB,qBAAqB,MAAM,sBAAsB,EAAE;AAAA,EAEnD,qBAAqB,CAAC,eAAyB,sBAAsB,CAAC,CAAC;AAAA,EACvE,oBAAoB,MAAM,sBAAsB,EAAE;AAAA,EAClD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAE9B,kBAAkB,IAAK,MAAkC;AAAA,IACvD,IAAI,kBAA0B;AAC5B,YAAM,IAAI,MAAM,uEAAuE;AAAA,IACzF;AAAA,IAEA,IAAI,UAAkC;AACpC,aAAO,CAAC;AAAA,IACV;AAAA,IACA,IAAI,OAA4B;AAC9B,aAAO,CAAC;AAAA,IACV;AAAA,EACF,EAAG;AAAA,EAEH,6BAA6B,CAAC;AAAA,EAC9B,gCAAgC,MAAM;AAAA,EAAC;AAAA,EACvC,mCAAmC,MAAM;AAAA,EAAC;AAAA,EAC1C,gBAAgB;AAAA,EAChB,eAAe,CAAC;AAAA,EAChB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EAEzB,cAAc;AAAA,EACd,iBAAiB,MAAM;AAAA,EAAC;AAC1B;AAEO,IAAM,iBAAiB,aAAAA,QAAM,cAAoC,mBAAmB;AAEpF,SAAS,oBAA0C;AACxD,QAAM,UAAU,aAAAA,QAAM,WAAW,cAAc;AAC/C,MAAI,YAAY,qBAAqB;AACnC,UAAM,IAAI,MAAM,uEAAuE;AAAA,EACzF;AACA,SAAO;AACT;AAEA,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI,MAAM,uEAAuE;AACvF,SAAO;AACT;","names":["React"]}
1
+ {"version":3,"sources":["../../src/context/index.ts","../../src/context/copilot-context.tsx"],"sourcesContent":["export { CopilotContext, useCopilotContext } from \"./copilot-context\";\nexport type { CopilotContextParams } from \"./copilot-context\";\nexport type { CopilotApiConfig } from \"./copilot-context\";\n","import { CopilotCloudConfig, FunctionCallHandler } from \"@copilotkit/shared\";\nimport { Message } from \"@copilotkit/runtime-client-gql\";\nimport { ActionRenderProps, FrontendAction } from \"../types/frontend-action\";\nimport React from \"react\";\nimport { TreeNodeId } from \"../hooks/use-tree\";\nimport { DocumentPointer } from \"../types\";\nimport { CopilotChatSuggestionConfiguration } from \"../types/chat-suggestion-configuration\";\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\nexport type InChatRenderFunction = (props: ActionRenderProps<any>) => string | JSX.Element;\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 chatComponentsCache: React.RefObject<Record<string, InChatRenderFunction | string>>;\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 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 // chat\n messages: Message[];\n setMessages: React.Dispatch<React.SetStateAction<Message[]>>;\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 // api endpoints\n copilotApiConfig: CopilotApiConfig;\n\n showDevConsole: boolean | \"auto\";\n}\n\nconst emptyCopilotContext: CopilotContextParams = {\n actions: {},\n setAction: () => {},\n removeAction: () => {},\n\n chatComponentsCache: { current: {} },\n getContextString: (documents: DocumentPointer[], categories: string[]) =>\n returnAndThrowInDebug(\"\"),\n addContext: () => \"\",\n removeContext: () => {},\n\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\n\n messages: [],\n setMessages: () => returnAndThrowInDebug([]),\n\n isLoading: false,\n setIsLoading: () => returnAndThrowInDebug(false),\n\n chatInstructions: \"\",\n setChatInstructions: () => returnAndThrowInDebug(\"\"),\n\n getDocumentsContext: (categories: string[]) => returnAndThrowInDebug([]),\n addDocumentContext: () => returnAndThrowInDebug(\"\"),\n removeDocumentContext: () => {},\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: \"auto\",\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 return value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,mBAAkB;AA+GlB,IAAM,sBAA4C;AAAA,EAChD,SAAS,CAAC;AAAA,EACV,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB,cAAc,MAAM;AAAA,EAAC;AAAA,EAErB,qBAAqB,EAAE,SAAS,CAAC,EAAE;AAAA,EACnC,kBAAkB,CAAC,WAA8B,eAC/C,sBAAsB,EAAE;AAAA,EAC1B,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AAAA,EAAC;AAAA,EAEtB,wBAAwB,MAAM,sBAAsB,MAAY;AAAA,EAAC,EAAC;AAAA,EAElE,UAAU,CAAC;AAAA,EACX,aAAa,MAAM,sBAAsB,CAAC,CAAC;AAAA,EAE3C,WAAW;AAAA,EACX,cAAc,MAAM,sBAAsB,KAAK;AAAA,EAE/C,kBAAkB;AAAA,EAClB,qBAAqB,MAAM,sBAAsB,EAAE;AAAA,EAEnD,qBAAqB,CAAC,eAAyB,sBAAsB,CAAC,CAAC;AAAA,EACvE,oBAAoB,MAAM,sBAAsB,EAAE;AAAA,EAClD,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAE9B,kBAAkB,IAAK,MAAkC;AAAA,IACvD,IAAI,kBAA0B;AAC5B,YAAM,IAAI,MAAM,uEAAuE;AAAA,IACzF;AAAA,IAEA,IAAI,UAAkC;AACpC,aAAO,CAAC;AAAA,IACV;AAAA,IACA,IAAI,OAA4B;AAC9B,aAAO,CAAC;AAAA,IACV;AAAA,EACF,EAAG;AAAA,EAEH,6BAA6B,CAAC;AAAA,EAC9B,gCAAgC,MAAM;AAAA,EAAC;AAAA,EACvC,mCAAmC,MAAM;AAAA,EAAC;AAAA,EAC1C,gBAAgB;AAClB;AAEO,IAAM,iBAAiB,aAAAA,QAAM,cAAoC,mBAAmB;AAEpF,SAAS,oBAA0C;AACxD,QAAM,UAAU,aAAAA,QAAM,WAAW,cAAc;AAC/C,MAAI,YAAY,qBAAqB;AACnC,UAAM,IAAI,MAAM,uEAAuE;AAAA,EACzF;AACA,SAAO;AACT;AAEA,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI,MAAM,uEAAuE;AACvF,SAAO;AACT;","names":["React"]}
@@ -2,7 +2,7 @@ import "../chunk-VNRDQJXW.mjs";
2
2
  import {
3
3
  CopilotContext,
4
4
  useCopilotContext
5
- } from "../chunk-J2YXDQHR.mjs";
5
+ } from "../chunk-LB7ULLSU.mjs";
6
6
  import "../chunk-SKC7AJIV.mjs";
7
7
  export {
8
8
  CopilotContext,
@@ -1,18 +1,14 @@
1
1
  export { UseCopilotChatOptions, UseCopilotChatReturn, useCopilotChat } from './use-copilot-chat.js';
2
2
  export { useCopilotAction } from './use-copilot-action.js';
3
- export { useCoAgentAction } from './use-coagent-action.js';
4
3
  export { useMakeCopilotDocumentReadable } from './use-make-copilot-document-readable.js';
5
4
  export { UseChatHelpers } from './use-chat.js';
6
5
  export { useCopilotReadable } from './use-copilot-readable.js';
7
- export { useCoAgent } from './use-coagent.js';
8
6
  import '@copilotkit/runtime-client-gql';
9
7
  import '../types/system-message.js';
10
8
  import '../types/frontend-action.js';
11
9
  import '@copilotkit/shared';
12
10
  import 'react';
13
- import '../types/coagent-action.js';
14
11
  import '../types/document-pointer.js';
15
12
  import '../context/copilot-context.js';
16
13
  import './use-tree.js';
17
14
  import '../types/chat-suggestion-configuration.js';
18
- import '../types/coagent-state.js';
@@ -79,8 +79,6 @@ var __async = (__this, __arguments, generator) => {
79
79
  // src/hooks/index.ts
80
80
  var hooks_exports = {};
81
81
  __export(hooks_exports, {
82
- useCoAgent: () => useCoAgent,
83
- useCoAgentAction: () => useCoAgentAction,
84
82
  useCopilotAction: () => useCopilotAction,
85
83
  useCopilotChat: () => useCopilotChat,
86
84
  useCopilotReadable: () => useCopilotReadable,
@@ -99,12 +97,7 @@ var emptyCopilotContext = {
99
97
  },
100
98
  removeAction: () => {
101
99
  },
102
- coagentActions: {},
103
- setCoagentAction: () => {
104
- },
105
- removeCoagentAction: () => {
106
- },
107
- chatComponentsCache: { current: { actions: {}, coagentActions: {} } },
100
+ chatComponentsCache: { current: {} },
108
101
  getContextString: (documents, categories) => returnAndThrowInDebug(""),
109
102
  addContext: () => "",
110
103
  removeContext: () => {
@@ -137,13 +130,7 @@ var emptyCopilotContext = {
137
130
  },
138
131
  removeChatSuggestionConfiguration: () => {
139
132
  },
140
- showDevConsole: "auto",
141
- coagentStates: {},
142
- setCoagentStates: () => {
143
- },
144
- agentSession: null,
145
- setAgentSession: () => {
146
- }
133
+ showDevConsole: "auto"
147
134
  };
148
135
  var CopilotContext = import_react.default.createContext(emptyCopilotContext);
149
136
  function useCopilotContext() {
@@ -175,12 +162,7 @@ function useChat(options) {
175
162
  initialMessages,
176
163
  isLoading,
177
164
  actions,
178
- onFunctionCall,
179
- onCoagentAction,
180
- setCoagentStates,
181
- coagentStates,
182
- agentSession,
183
- setAgentSession
165
+ onFunctionCall
184
166
  } = options;
185
167
  const abortControllerRef = (0, import_react2.useRef)();
186
168
  const threadIdRef = (0, import_react2.useRef)(null);
@@ -209,7 +191,7 @@ function useChat(options) {
209
191
  const messagesWithContext = [systemMessage, ...initialMessages || [], ...previousMessages];
210
192
  const stream = import_runtime_client_gql.CopilotRuntimeClient.asStream(
211
193
  runtimeClient.generateCopilotResponse({
212
- data: __spreadProps(__spreadValues(__spreadProps(__spreadValues({
194
+ data: __spreadProps(__spreadValues({
213
195
  frontend: {
214
196
  actions: actions.map((action) => ({
215
197
  name: action.name,
@@ -220,7 +202,7 @@ function useChat(options) {
220
202
  },
221
203
  threadId: threadIdRef.current,
222
204
  runId: runIdRef.current,
223
- messages: (0, import_runtime_client_gql.convertMessagesToGqlInput)((0, import_runtime_client_gql.filterAgentStateMessages)(messagesWithContext))
205
+ messages: (0, import_runtime_client_gql.convertMessagesToGqlInput)(messagesWithContext)
224
206
  }, copilotConfig.cloud ? {
225
207
  cloud: __spreadValues({}, ((_c = (_b = (_a = copilotConfig.cloud.guardrails) == null ? void 0 : _a.input) == null ? void 0 : _b.restrictToTopic) == null ? void 0 : _c.enabled) ? {
226
208
  guardrails: {
@@ -234,13 +216,6 @@ function useChat(options) {
234
216
  metadata: {
235
217
  requestType: import_runtime_client_gql.CopilotRequestType.Chat
236
218
  }
237
- }), agentSession ? {
238
- agentSession
239
- } : {}), {
240
- agentStates: Object.values(coagentStates).map((state) => ({
241
- agentName: state.name,
242
- state: JSON.stringify(state.state)
243
- }))
244
219
  }),
245
220
  properties: copilotConfig.properties,
246
221
  signal: (_d = abortControllerRef.current) == null ? void 0 : _d.signal
@@ -248,8 +223,7 @@ function useChat(options) {
248
223
  );
249
224
  const guardrailsEnabled = ((_g = (_f = (_e = copilotConfig.cloud) == null ? void 0 : _e.guardrails) == null ? void 0 : _f.input) == null ? void 0 : _g.restrictToTopic.enabled) || false;
250
225
  const reader = stream.getReader();
251
- let actionResults = {};
252
- let executedCoagentActions = [];
226
+ let results = {};
253
227
  try {
254
228
  while (true) {
255
229
  const { done, value } = yield reader.read();
@@ -261,9 +235,7 @@ function useChat(options) {
261
235
  }
262
236
  threadIdRef.current = value.generateCopilotResponse.threadId || null;
263
237
  runIdRef.current = value.generateCopilotResponse.runId || null;
264
- const messages2 = (0, import_runtime_client_gql.convertGqlOutputToMessages)(
265
- (0, import_runtime_client_gql.filterAdjacentAgentStateMessages)(value.generateCopilotResponse.messages)
266
- );
238
+ const messages2 = (0, import_runtime_client_gql.convertGqlOutputToMessages)(value.generateCopilotResponse.messages);
267
239
  if (messages2.length === 0) {
268
240
  continue;
269
241
  }
@@ -279,7 +251,7 @@ function useChat(options) {
279
251
  for (const message of messages2) {
280
252
  newMessages.push(message);
281
253
  if (message instanceof import_runtime_client_gql.ActionExecutionMessage && message.status.code !== import_runtime_client_gql.MessageStatusCode.Pending && message.scope === "client" && onFunctionCall) {
282
- if (!(message.id in actionResults)) {
254
+ if (!(message.id in results)) {
283
255
  if (guardrailsEnabled && value.generateCopilotResponse.status === void 0) {
284
256
  break;
285
257
  }
@@ -288,50 +260,16 @@ function useChat(options) {
288
260
  name: message.name,
289
261
  args: message.arguments
290
262
  });
291
- actionResults[message.id] = result;
263
+ results[message.id] = result;
292
264
  }
293
265
  newMessages.push(
294
266
  new import_runtime_client_gql.ResultMessage({
295
- result: import_runtime_client_gql.ResultMessage.encodeResult(actionResults[message.id]),
267
+ result: import_runtime_client_gql.ResultMessage.encodeResult(results[message.id]),
296
268
  actionExecutionId: message.id,
297
269
  actionName: message.name
298
270
  })
299
271
  );
300
272
  }
301
- if (message instanceof import_runtime_client_gql.AgentStateMessage && !message.active && !executedCoagentActions.includes(message.id) && onCoagentAction) {
302
- if (guardrailsEnabled && value.generateCopilotResponse.status === void 0) {
303
- break;
304
- }
305
- yield onCoagentAction({
306
- name: message.agentName,
307
- nodeName: message.nodeName,
308
- state: message.state
309
- });
310
- executedCoagentActions.push(message.id);
311
- }
312
- }
313
- const lastAgentStateMessage = [...messages2].reverse().find((message) => message instanceof import_runtime_client_gql.AgentStateMessage);
314
- if (lastAgentStateMessage) {
315
- if (lastAgentStateMessage.running) {
316
- setCoagentStates((prevAgentStates) => __spreadProps(__spreadValues({}, prevAgentStates), {
317
- [lastAgentStateMessage.agentName]: {
318
- name: lastAgentStateMessage.agentName,
319
- state: lastAgentStateMessage.state,
320
- running: lastAgentStateMessage.running,
321
- active: lastAgentStateMessage.active,
322
- threadId: lastAgentStateMessage.threadId,
323
- nodeName: lastAgentStateMessage.nodeName,
324
- runId: lastAgentStateMessage.runId
325
- }
326
- }));
327
- setAgentSession({
328
- threadId: lastAgentStateMessage.threadId,
329
- agentName: lastAgentStateMessage.agentName,
330
- nodeName: lastAgentStateMessage.nodeName
331
- });
332
- } else {
333
- setAgentSession(null);
334
- }
335
273
  }
336
274
  }
337
275
  if (newMessages.length > 0) {
@@ -340,7 +278,7 @@ function useChat(options) {
340
278
  }
341
279
  if (
342
280
  // if we have client side results
343
- Object.values(actionResults).length || // or the last message we received is a result
281
+ Object.values(results).length || // or the last message we received is a result
344
282
  newMessages.length && newMessages[newMessages.length - 1] instanceof import_runtime_client_gql.ResultMessage
345
283
  ) {
346
284
  yield new Promise((resolve) => setTimeout(resolve, 10));
@@ -409,12 +347,7 @@ function useCopilotChat(_a = {}) {
409
347
  isLoading,
410
348
  setIsLoading,
411
349
  chatInstructions,
412
- actions,
413
- coagentStates,
414
- setCoagentStates,
415
- coagentActions,
416
- agentSession,
417
- setAgentSession
350
+ actions
418
351
  } = useCopilotContext();
419
352
  const latestGetContextString = useUpdatedRef(getContextString);
420
353
  const deleteMessage = (0, import_react4.useCallback)(
@@ -431,39 +364,16 @@ function useCopilotChat(_a = {}) {
431
364
  role: import_runtime_client_gql2.Role.System
432
365
  });
433
366
  }, [getContextString, makeSystemMessage, chatInstructions]);
434
- const onCoagentAction = (0, import_react4.useCallback)(
435
- (args) => __async(this, null, function* () {
436
- var _a2;
437
- const { name, nodeName, state } = args;
438
- let action = Object.values(coagentActions).find(
439
- (action2) => action2.name === name && action2.nodeName === nodeName
440
- );
441
- if (!action) {
442
- action = Object.values(coagentActions).find(
443
- (action2) => action2.name === name && !action2.nodeName
444
- );
445
- }
446
- if (action) {
447
- yield (_a2 = action.handler) == null ? void 0 : _a2.call(action, { state, nodeName });
448
- }
449
- }),
450
- [coagentActions]
451
- );
452
367
  const { append, reload, stop } = useChat(__spreadProps(__spreadValues({}, options), {
453
368
  actions: Object.values(actions),
454
369
  copilotConfig: copilotApiConfig,
455
370
  initialMessages: options.initialMessages || [],
456
371
  onFunctionCall: getFunctionCallHandler(),
457
- onCoagentAction,
458
372
  messages,
459
373
  setMessages,
460
374
  makeSystemMessageCallback,
461
375
  isLoading,
462
- setIsLoading,
463
- coagentStates,
464
- setCoagentStates,
465
- agentSession,
466
- setAgentSession
376
+ setIsLoading
467
377
  }));
468
378
  const latestAppend = useUpdatedRef(append);
469
379
  const latestAppendFunc = (0, import_react4.useCallback)(
@@ -546,7 +456,7 @@ function useCopilotAction(action, dependencies) {
546
456
  actions[idRef.current].handler = action.handler;
547
457
  if (typeof action.render === "function") {
548
458
  if (chatComponentsCache.current !== null) {
549
- chatComponentsCache.current.actions[action.name] = action.render;
459
+ chatComponentsCache.current[action.name] = action.render;
550
460
  }
551
461
  }
552
462
  }
@@ -557,7 +467,7 @@ function useCopilotAction(action, dependencies) {
557
467
  }
558
468
  setAction(idRef.current, action);
559
469
  if (chatComponentsCache.current !== null && action.render !== void 0) {
560
- chatComponentsCache.current.actions[action.name] = action.render;
470
+ chatComponentsCache.current[action.name] = action.render;
561
471
  }
562
472
  return () => {
563
473
  removeAction(idRef.current);
@@ -578,48 +488,12 @@ function useCopilotAction(action, dependencies) {
578
488
  ]);
579
489
  }
580
490
 
581
- // src/hooks/use-coagent-action.ts
582
- var import_react6 = require("react");
583
- var import_shared4 = require("@copilotkit/shared");
584
- function useCoAgentAction(action, dependencies) {
585
- const { setCoagentAction, removeCoagentAction, coagentActions, chatComponentsCache } = (0, import_react6.useContext)(CopilotContext);
586
- const idRef = (0, import_react6.useRef)((0, import_shared4.randomId)());
587
- const key = `${action.name}-${action.nodeName || "global"}`;
588
- if (dependencies === void 0) {
589
- if (coagentActions[idRef.current]) {
590
- coagentActions[idRef.current].handler = action.handler;
591
- if (typeof action.render === "function") {
592
- if (chatComponentsCache.current !== null) {
593
- chatComponentsCache.current.coagentActions[key] = action.render;
594
- }
595
- }
596
- }
597
- }
598
- (0, import_react6.useEffect)(() => {
599
- setCoagentAction(idRef.current, action);
600
- if (chatComponentsCache.current !== null && action.render !== void 0) {
601
- chatComponentsCache.current.coagentActions[key] = action.render;
602
- }
603
- return () => {
604
- removeCoagentAction(idRef.current);
605
- };
606
- }, [
607
- setCoagentAction,
608
- removeCoagentAction,
609
- action.name,
610
- // include render only if it's a string
611
- typeof action.render === "string" ? action.render : void 0,
612
- // dependencies set by the developer
613
- ...dependencies || []
614
- ]);
615
- }
616
-
617
491
  // src/hooks/use-make-copilot-document-readable.ts
618
- var import_react7 = require("react");
492
+ var import_react6 = require("react");
619
493
  function useMakeCopilotDocumentReadable(document, categories, dependencies = []) {
620
494
  const { addDocumentContext, removeDocumentContext } = useCopilotContext();
621
- const idRef = (0, import_react7.useRef)();
622
- (0, import_react7.useEffect)(() => {
495
+ const idRef = (0, import_react6.useRef)();
496
+ (0, import_react6.useEffect)(() => {
623
497
  const id = addDocumentContext(document, categories);
624
498
  idRef.current = id;
625
499
  return () => {
@@ -630,16 +504,16 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
630
504
  }
631
505
 
632
506
  // src/hooks/use-copilot-readable.ts
633
- var import_react8 = require("react");
507
+ var import_react7 = require("react");
634
508
  function convertToJSON(description, value) {
635
509
  return `${description}: ${typeof value === "string" ? value : JSON.stringify(value)}`;
636
510
  }
637
511
  function useCopilotReadable({ description, value, parentId, categories, convert }, dependencies) {
638
512
  const { addContext, removeContext } = useCopilotContext();
639
- const idRef = (0, import_react8.useRef)();
513
+ const idRef = (0, import_react7.useRef)();
640
514
  convert = convert || convertToJSON;
641
515
  const information = convert(description, value);
642
- (0, import_react8.useEffect)(() => {
516
+ (0, import_react7.useEffect)(() => {
643
517
  const id = addContext(information, parentId, categories);
644
518
  idRef.current = id;
645
519
  return () => {
@@ -648,85 +522,8 @@ function useCopilotReadable({ description, value, parentId, categories, convert
648
522
  }, [information, parentId, addContext, removeContext, ...dependencies || []]);
649
523
  return idRef.current;
650
524
  }
651
-
652
- // src/hooks/use-coagent.ts
653
- var import_react9 = require("react");
654
- function useCoAgent(options) {
655
- const isExternalStateManagement = (options2) => {
656
- return "state" in options2 && "setState" in options2;
657
- };
658
- const { name } = options;
659
- const isInternalStateManagementWithInitial = (options2) => {
660
- return "initialState" in options2;
661
- };
662
- const { coagentStates, setCoagentStates } = useCopilotContext();
663
- const getCoagentState = (coagentStates2, name2) => {
664
- if (coagentStates2[name2]) {
665
- return coagentStates2[name2];
666
- } else {
667
- return {
668
- name: name2,
669
- state: isInternalStateManagementWithInitial(options) ? options.initialState : {},
670
- running: false,
671
- active: false,
672
- threadId: void 0,
673
- nodeName: void 0,
674
- runId: void 0
675
- };
676
- }
677
- };
678
- const setState = (newState) => {
679
- setCoagentStates((prevAgentStates) => {
680
- let coagentState2 = getCoagentState(prevAgentStates, name);
681
- const updatedState = typeof newState === "function" ? newState(coagentState2.state) : newState;
682
- return __spreadProps(__spreadValues({}, prevAgentStates), {
683
- [name]: __spreadProps(__spreadValues({}, coagentState2), {
684
- state: updatedState
685
- })
686
- });
687
- });
688
- };
689
- const coagentState = getCoagentState(coagentStates, name);
690
- const state = isExternalStateManagement(options) ? options.state : coagentState.state;
691
- (0, import_react9.useEffect)(() => {
692
- if (isExternalStateManagement(options)) {
693
- setState(options.state);
694
- } else if (coagentStates[name] === void 0) {
695
- setState(options.initialState === void 0 ? {} : options.initialState);
696
- }
697
- }, [isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0]);
698
- return {
699
- name,
700
- nodeName: coagentState.nodeName,
701
- state,
702
- setState,
703
- running: coagentState.running,
704
- start: () => {
705
- startAgent(name);
706
- },
707
- stop: () => {
708
- stopAgent(name);
709
- }
710
- };
711
- }
712
- function startAgent(name) {
713
- const { setAgentSession } = useCopilotContext();
714
- setAgentSession({
715
- agentName: name
716
- });
717
- }
718
- function stopAgent(name) {
719
- const { agentSession, setAgentSession } = useCopilotContext();
720
- if (agentSession && agentSession.agentName === name) {
721
- setAgentSession(null);
722
- } else {
723
- console.warn(`No agent session found for ${name}`);
724
- }
725
- }
726
525
  // Annotate the CommonJS export names for ESM import in node:
727
526
  0 && (module.exports = {
728
- useCoAgent,
729
- useCoAgentAction,
730
527
  useCopilotAction,
731
528
  useCopilotChat,
732
529
  useCopilotReadable,