@copilotkit/react-core 1.4.2-tyler-reset-chat.0 → 1.4.2

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 (87) hide show
  1. package/CHANGELOG.md +5 -4
  2. package/dist/{chunk-SEPYQHH7.mjs → chunk-A5ZAEL2W.mjs} +22 -33
  3. package/dist/chunk-A5ZAEL2W.mjs.map +1 -0
  4. package/dist/{chunk-CZMEZR6F.mjs → chunk-BUWNIMNK.mjs} +12 -37
  5. package/dist/chunk-BUWNIMNK.mjs.map +1 -0
  6. package/dist/{chunk-XUPO37VH.mjs → chunk-H4VZMKR6.mjs} +2 -2
  7. package/dist/{chunk-6EN7J4V2.mjs → chunk-HZIY4NDC.mjs} +17 -38
  8. package/dist/chunk-HZIY4NDC.mjs.map +1 -0
  9. package/dist/{chunk-JR55I3FL.mjs → chunk-LMFSB5D5.mjs} +2 -2
  10. package/dist/{chunk-2JP64U3A.mjs → chunk-LODRWFMB.mjs} +2 -10
  11. package/dist/{chunk-2JP64U3A.mjs.map → chunk-LODRWFMB.mjs.map} +1 -1
  12. package/dist/{chunk-3R4J2TPH.mjs → chunk-MWZO6TUR.mjs} +2 -2
  13. package/dist/{chunk-6QKA3SNN.mjs → chunk-P6VS7ST4.mjs} +3 -12
  14. package/dist/{chunk-6QKA3SNN.mjs.map → chunk-P6VS7ST4.mjs.map} +1 -1
  15. package/dist/{chunk-USL3EHJB.mjs → chunk-QDGDXRRJ.mjs} +2 -2
  16. package/dist/{chunk-3AYELZJS.mjs → chunk-XINZBP3J.mjs} +2 -2
  17. package/dist/components/copilot-provider/copilotkit.js +2 -19
  18. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  19. package/dist/components/copilot-provider/copilotkit.mjs +2 -2
  20. package/dist/components/copilot-provider/index.js +2 -19
  21. package/dist/components/copilot-provider/index.js.map +1 -1
  22. package/dist/components/copilot-provider/index.mjs +2 -2
  23. package/dist/components/index.js +2 -19
  24. package/dist/components/index.js.map +1 -1
  25. package/dist/components/index.mjs +2 -2
  26. package/dist/context/copilot-context.d.ts +0 -6
  27. package/dist/context/copilot-context.js +1 -9
  28. package/dist/context/copilot-context.js.map +1 -1
  29. package/dist/context/copilot-context.mjs +1 -1
  30. package/dist/context/index.js +1 -9
  31. package/dist/context/index.js.map +1 -1
  32. package/dist/context/index.mjs +1 -1
  33. package/dist/hooks/index.d.ts +1 -2
  34. package/dist/hooks/index.js +43 -111
  35. package/dist/hooks/index.js.map +1 -1
  36. package/dist/hooks/index.mjs +9 -15
  37. package/dist/hooks/use-chat.d.ts +4 -20
  38. package/dist/hooks/use-chat.js +16 -37
  39. package/dist/hooks/use-chat.js.map +1 -1
  40. package/dist/hooks/use-chat.mjs +1 -1
  41. package/dist/hooks/use-coagent-state-render.js +1 -9
  42. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  43. package/dist/hooks/use-coagent-state-render.mjs +2 -2
  44. package/dist/hooks/use-coagent.d.ts +1 -14
  45. package/dist/hooks/use-coagent.js +43 -111
  46. package/dist/hooks/use-coagent.js.map +1 -1
  47. package/dist/hooks/use-coagent.mjs +5 -11
  48. package/dist/hooks/use-copilot-action.js +1 -9
  49. package/dist/hooks/use-copilot-action.js.map +1 -1
  50. package/dist/hooks/use-copilot-action.mjs +2 -2
  51. package/dist/hooks/use-copilot-chat.d.ts +1 -1
  52. package/dist/hooks/use-copilot-chat.js +25 -79
  53. package/dist/hooks/use-copilot-chat.js.map +1 -1
  54. package/dist/hooks/use-copilot-chat.mjs +4 -4
  55. package/dist/hooks/use-copilot-readable.js +1 -9
  56. package/dist/hooks/use-copilot-readable.js.map +1 -1
  57. package/dist/hooks/use-copilot-readable.mjs +2 -2
  58. package/dist/hooks/use-make-copilot-document-readable.js +1 -9
  59. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  60. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  61. package/dist/index.d.ts +1 -1
  62. package/dist/index.js +44 -121
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +10 -16
  65. package/dist/lib/copilot-task.js.map +1 -1
  66. package/dist/lib/copilot-task.mjs +3 -3
  67. package/dist/lib/index.js.map +1 -1
  68. package/dist/lib/index.mjs +3 -3
  69. package/dist/utils/extract.js.map +1 -1
  70. package/dist/utils/extract.mjs +2 -2
  71. package/dist/utils/index.js.map +1 -1
  72. package/dist/utils/index.mjs +2 -2
  73. package/package.json +5 -5
  74. package/src/components/copilot-provider/copilotkit.tsx +0 -10
  75. package/src/context/copilot-context.tsx +0 -22
  76. package/src/hooks/index.ts +1 -1
  77. package/src/hooks/use-chat.ts +19 -56
  78. package/src/hooks/use-coagent.ts +26 -35
  79. package/src/hooks/use-copilot-chat.ts +10 -37
  80. package/dist/chunk-6EN7J4V2.mjs.map +0 -1
  81. package/dist/chunk-CZMEZR6F.mjs.map +0 -1
  82. package/dist/chunk-SEPYQHH7.mjs.map +0 -1
  83. /package/dist/{chunk-XUPO37VH.mjs.map → chunk-H4VZMKR6.mjs.map} +0 -0
  84. /package/dist/{chunk-JR55I3FL.mjs.map → chunk-LMFSB5D5.mjs.map} +0 -0
  85. /package/dist/{chunk-3R4J2TPH.mjs.map → chunk-MWZO6TUR.mjs.map} +0 -0
  86. /package/dist/{chunk-USL3EHJB.mjs.map → chunk-QDGDXRRJ.mjs.map} +0 -0
  87. /package/dist/{chunk-3AYELZJS.mjs.map → chunk-XINZBP3J.mjs.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  useCopilotReadable
3
- } from "../chunk-USL3EHJB.mjs";
4
- import "../chunk-2JP64U3A.mjs";
3
+ } from "../chunk-QDGDXRRJ.mjs";
4
+ import "../chunk-LODRWFMB.mjs";
5
5
  import "../chunk-SKC7AJIV.mjs";
6
6
  export {
7
7
  useCopilotReadable
@@ -106,15 +106,7 @@ var emptyCopilotContext = {
106
106
  },
107
107
  agentSession: null,
108
108
  setAgentSession: () => {
109
- },
110
- agentLock: null,
111
- threadId: null,
112
- setThreadId: () => {
113
- },
114
- runId: null,
115
- setRunId: () => {
116
- },
117
- chatAbortControllerRef: { current: null }
109
+ }
118
110
  };
119
111
  var CopilotContext = import_react.default.createContext(emptyCopilotContext);
120
112
  function useCopilotContext() {
@@ -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 { CopilotCloudConfig, FunctionCallHandler } from \"@copilotkit/shared\";\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 { CoAgentStateRender, CoAgentStateRenderProps } from \"../types/coagent-action\";\nimport { CoagentState } from \"../types/coagent-state\";\nimport { CopilotRuntimeClient } from \"@copilotkit/runtime-client-gql\";\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: 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 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 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 // 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 agentLock: string | null;\n\n threadId: string | null;\n setThreadId: React.Dispatch<React.SetStateAction<string | null>>;\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\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\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\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 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: \"auto\",\n coagentStates: {},\n setCoagentStates: () => {},\n\n agentSession: null,\n setAgentSession: () => {},\n\n agentLock: null,\n\n threadId: null,\n setThreadId: () => {},\n\n runId: null,\n setRunId: () => {},\n\n chatAbortControllerRef: { current: null },\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,IAAAA,gBAAkC;;;ACElC,mBAAkB;AAuJlB,IAAM,sBAA4C;AAAA,EAChD,SAAS,CAAC;AAAA,EACV,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB,cAAc,MAAM;AAAA,EAAC;AAAA,EAErB,qBAAqB,CAAC;AAAA,EACtB,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAC9B,0BAA0B,MAAM;AAAA,EAAC;AAAA,EAEjC,qBAAqB,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,qBAAqB,CAAC,EAAE,EAAE;AAAA,EACzE,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,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,EAC9B,eAAe,CAAC;AAAA,EAEhB,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;AAAA,EAExB,WAAW;AAAA,EAEX,UAAU;AAAA,EACV,aAAa,MAAM;AAAA,EAAC;AAAA,EAEpB,OAAO;AAAA,EACP,UAAU,MAAM;AAAA,EAAC;AAAA,EAEjB,wBAAwB,EAAE,SAAS,KAAK;AAC1C;AAEO,IAAM,iBAAiB,aAAAC,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;;;ADzNO,SAAS,+BACd,UACA,YACA,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
+ {"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 { CopilotCloudConfig, FunctionCallHandler } from \"@copilotkit/shared\";\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 { CoAgentStateRender, CoAgentStateRenderProps } from \"../types/coagent-action\";\nimport { CoagentState } from \"../types/coagent-state\";\nimport { CopilotRuntimeClient } from \"@copilotkit/runtime-client-gql\";\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: 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 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 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 // 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 // runtime\n runtimeClient: CopilotRuntimeClient;\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\n getFunctionCallHandler: () => returnAndThrowInDebug(async () => {}),\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 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: \"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,IAAAA,gBAAkC;;;ACElC,mBAAkB;AA2IlB,IAAM,sBAA4C;AAAA,EAChD,SAAS,CAAC;AAAA,EACV,WAAW,MAAM;AAAA,EAAC;AAAA,EAClB,cAAc,MAAM;AAAA,EAAC;AAAA,EAErB,qBAAqB,CAAC;AAAA,EACtB,uBAAuB,MAAM;AAAA,EAAC;AAAA,EAC9B,0BAA0B,MAAM;AAAA,EAAC;AAAA,EAEjC,qBAAqB,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,qBAAqB,CAAC,EAAE,EAAE;AAAA,EACzE,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,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,EAC9B,eAAe,CAAC;AAAA,EAEhB,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,aAAAC,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;;;ADnMO,SAAS,+BACd,UACA,YACA,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-XUPO37VH.mjs";
4
- import "../chunk-2JP64U3A.mjs";
3
+ } from "../chunk-H4VZMKR6.mjs";
4
+ import "../chunk-LODRWFMB.mjs";
5
5
  import "../chunk-SKC7AJIV.mjs";
6
6
  export {
7
7
  useMakeCopilotDocumentReadable
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export { useCoAgentStateRender } from './hooks/use-coagent-state-render.js';
8
8
  export { useMakeCopilotDocumentReadable } from './hooks/use-make-copilot-document-readable.js';
9
9
  export { UseChatHelpers } from './hooks/use-chat.js';
10
10
  export { useCopilotReadable } from './hooks/use-copilot-readable.js';
11
- export { HintFunction, runAgent, startAgent, stopAgent, useCoAgent } from './hooks/use-coagent.js';
11
+ export { useCoAgent } from './hooks/use-coagent.js';
12
12
  export { useCopilotRuntimeClient } from './hooks/use-copilot-runtime-client.js';
13
13
  export { DocumentPointer } from './types/document-pointer.js';
14
14
  export { SystemMessageFunction } from './types/system-message.js';
package/dist/index.js CHANGED
@@ -87,10 +87,7 @@ __export(src_exports, {
87
87
  CopilotTask: () => CopilotTask,
88
88
  defaultCopilotContextCategories: () => defaultCopilotContextCategories,
89
89
  extract: () => extract,
90
- runAgent: () => runAgent,
91
90
  shouldShowDevConsole: () => shouldShowDevConsole,
92
- startAgent: () => startAgent,
93
- stopAgent: () => stopAgent,
94
91
  useCoAgent: () => useCoAgent,
95
92
  useCoAgentStateRender: () => useCoAgentStateRender,
96
93
  useCopilotAction: () => useCopilotAction,
@@ -157,15 +154,7 @@ var emptyCopilotContext = {
157
154
  },
158
155
  agentSession: null,
159
156
  setAgentSession: () => {
160
- },
161
- agentLock: null,
162
- threadId: null,
163
- setThreadId: () => {
164
- },
165
- runId: null,
166
- setRunId: () => {
167
- },
168
- chatAbortControllerRef: { current: null }
157
+ }
169
158
  };
170
159
  var CopilotContext = import_react.default.createContext(emptyCopilotContext);
171
160
  function useCopilotContext() {
@@ -964,9 +953,6 @@ ${nonDocumentStrings}`;
964
953
  };
965
954
  }
966
955
  const [agentSession, setAgentSession] = (0, import_react8.useState)(initialAgentSession);
967
- const [threadId, setThreadId] = (0, import_react8.useState)(null);
968
- const [runId, setRunId] = (0, import_react8.useState)(null);
969
- const chatAbortControllerRef = (0, import_react8.useRef)(null);
970
956
  const showDevConsole = props.showDevConsole === void 0 ? "auto" : props.showDevConsole;
971
957
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
972
958
  CopilotContext.Provider,
@@ -999,13 +985,7 @@ ${nonDocumentStrings}`;
999
985
  setCoagentStates,
1000
986
  agentSession,
1001
987
  setAgentSession,
1002
- runtimeClient,
1003
- agentLock: props.agent || null,
1004
- threadId,
1005
- setThreadId,
1006
- runId,
1007
- setRunId,
1008
- chatAbortControllerRef
988
+ runtimeClient
1009
989
  },
1010
990
  children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CopilotMessages, { children })
1011
991
  }
@@ -1061,25 +1041,17 @@ function useChat(options) {
1061
1041
  setCoagentStates,
1062
1042
  coagentStates,
1063
1043
  agentSession,
1064
- setAgentSession,
1065
- threadId,
1066
- setThreadId,
1067
- runId,
1068
- setRunId,
1069
- chatAbortControllerRef
1044
+ setAgentSession
1070
1045
  } = options;
1071
- const abortController = new AbortController();
1072
- chatAbortControllerRef.current = abortController;
1046
+ const abortControllerRef = (0, import_react9.useRef)();
1047
+ const threadIdRef = (0, import_react9.useRef)(null);
1048
+ const runIdRef = (0, import_react9.useRef)(null);
1073
1049
  const { addGraphQLErrorsToast } = useToast();
1074
1050
  const runChatCompletionRef = (0, import_react9.useRef)();
1075
1051
  const coagentStatesRef = (0, import_react9.useRef)(coagentStates);
1076
1052
  coagentStatesRef.current = coagentStates;
1077
1053
  const agentSessionRef = (0, import_react9.useRef)(agentSession);
1078
1054
  agentSessionRef.current = agentSession;
1079
- const threadIdRef = (0, import_react9.useRef)(threadId);
1080
- threadIdRef.current = threadId;
1081
- const runIdRef = (0, import_react9.useRef)(runId);
1082
- runIdRef.current = runId;
1083
1055
  const publicApiKey = copilotConfig.publicApiKey;
1084
1056
  const headers = __spreadValues(__spreadValues({}, copilotConfig.headers || {}), publicApiKey ? { [import_shared5.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
1085
1057
  const runtimeClient = useCopilotRuntimeClient({
@@ -1097,7 +1069,8 @@ function useChat(options) {
1097
1069
  role: import_runtime_client_gql4.Role.Assistant
1098
1070
  })
1099
1071
  ];
1100
- chatAbortControllerRef.current = new AbortController();
1072
+ const abortController = new AbortController();
1073
+ abortControllerRef.current = abortController;
1101
1074
  setMessages([...previousMessages, ...newMessages]);
1102
1075
  const systemMessage = makeSystemMessageCallback();
1103
1076
  const messagesWithContext = [systemMessage, ...initialMessages || [], ...previousMessages];
@@ -1150,7 +1123,7 @@ function useChat(options) {
1150
1123
  }))
1151
1124
  }),
1152
1125
  properties: copilotConfig.properties,
1153
- signal: (_d = chatAbortControllerRef.current) == null ? void 0 : _d.signal
1126
+ signal: (_d = abortControllerRef.current) == null ? void 0 : _d.signal
1154
1127
  })
1155
1128
  );
1156
1129
  const guardrailsEnabled = ((_g = (_f = (_e = copilotConfig.cloud) == null ? void 0 : _e.guardrails) == null ? void 0 : _f.input) == null ? void 0 : _g.restrictToTopic.enabled) || false;
@@ -1169,9 +1142,6 @@ function useChat(options) {
1169
1142
  break;
1170
1143
  }
1171
1144
  if (done) {
1172
- if (chatAbortControllerRef.current.signal.aborted) {
1173
- return newMessages.slice();
1174
- }
1175
1145
  break;
1176
1146
  }
1177
1147
  if (!(value == null ? void 0 : value.generateCopilotResponse)) {
@@ -1179,8 +1149,6 @@ function useChat(options) {
1179
1149
  }
1180
1150
  threadIdRef.current = value.generateCopilotResponse.threadId || null;
1181
1151
  runIdRef.current = value.generateCopilotResponse.runId || null;
1182
- setThreadId(threadIdRef.current);
1183
- setRunId(runIdRef.current);
1184
1152
  const messages2 = (0, import_runtime_client_gql4.convertGqlOutputToMessages)(
1185
1153
  (0, import_runtime_client_gql4.filterAdjacentAgentStateMessages)(value.generateCopilotResponse.messages)
1186
1154
  );
@@ -1209,22 +1177,12 @@ function useChat(options) {
1209
1177
  if (action) {
1210
1178
  followUp = action.followUp;
1211
1179
  }
1212
- const result = yield Promise.race([
1213
- onFunctionCall({
1214
- messages: previousMessages,
1215
- name: message.name,
1216
- args: message.arguments
1217
- }),
1218
- new Promise((_, reject) => {
1219
- var _a2;
1220
- return (_a2 = chatAbortControllerRef.current) == null ? void 0 : _a2.signal.addEventListener("abort", () => reject(new Error("Operation was aborted")));
1221
- })
1222
- ]);
1223
- if (chatAbortControllerRef.current.signal.aborted) {
1224
- actionResults[message.id] = "";
1225
- } else {
1226
- actionResults[message.id] = result;
1227
- }
1180
+ const result = yield onFunctionCall({
1181
+ messages: previousMessages,
1182
+ name: message.name,
1183
+ args: message.arguments
1184
+ });
1185
+ actionResults[message.id] = result;
1228
1186
  } catch (e) {
1229
1187
  actionResults[message.id] = `Failed to execute action ${message.name}`;
1230
1188
  console.error(`Failed to execute action ${message.name}: ${e}`);
@@ -1319,12 +1277,13 @@ function useChat(options) {
1319
1277
  });
1320
1278
  const stop = () => {
1321
1279
  var _a;
1322
- (_a = chatAbortControllerRef.current) == null ? void 0 : _a.abort("Stop was called");
1280
+ (_a = abortControllerRef.current) == null ? void 0 : _a.abort();
1323
1281
  };
1324
1282
  return {
1325
1283
  append,
1326
1284
  reload,
1327
- stop
1285
+ stop,
1286
+ runChatCompletion: () => runChatCompletionRef.current(messages)
1328
1287
  };
1329
1288
  }
1330
1289
 
@@ -1347,13 +1306,7 @@ function useCopilotChat(_a = {}) {
1347
1306
  setCoagentStates,
1348
1307
  coAgentStateRenders,
1349
1308
  agentSession,
1350
- setAgentSession,
1351
- agentLock,
1352
- threadId,
1353
- setThreadId,
1354
- runId,
1355
- setRunId,
1356
- chatAbortControllerRef
1309
+ setAgentSession
1357
1310
  } = useCopilotContext();
1358
1311
  const { messages, setMessages } = useCopilotMessagesContext();
1359
1312
  const latestGetContextString = useUpdatedRef(getContextString);
@@ -1389,7 +1342,7 @@ function useCopilotChat(_a = {}) {
1389
1342
  }),
1390
1343
  [coAgentStateRenders]
1391
1344
  );
1392
- const { append, reload, stop } = useChat(__spreadProps(__spreadValues({}, options), {
1345
+ const { append, reload, stop, runChatCompletion } = useChat(__spreadProps(__spreadValues({}, options), {
1393
1346
  actions: Object.values(actions),
1394
1347
  copilotConfig: copilotApiConfig,
1395
1348
  initialMessages: options.initialMessages || [],
@@ -1403,12 +1356,7 @@ function useCopilotChat(_a = {}) {
1403
1356
  coagentStates,
1404
1357
  setCoagentStates,
1405
1358
  agentSession,
1406
- setAgentSession,
1407
- threadId,
1408
- setThreadId,
1409
- runId,
1410
- setRunId,
1411
- chatAbortControllerRef
1359
+ setAgentSession
1412
1360
  }));
1413
1361
  const latestAppend = useUpdatedRef(append);
1414
1362
  const latestAppendFunc = (0, import_react10.useCallback)(
@@ -1439,32 +1387,18 @@ function useCopilotChat(_a = {}) {
1439
1387
  },
1440
1388
  [latestSetMessages]
1441
1389
  );
1442
- const reset = (0, import_react10.useCallback)(() => {
1443
- latestStopFunc();
1444
- setMessages([]);
1445
- setThreadId(null);
1446
- setRunId(null);
1447
- setCoagentStates({});
1448
- let initialAgentSession = null;
1449
- if (agentLock) {
1450
- initialAgentSession = {
1451
- agentName: agentLock
1452
- };
1453
- }
1454
- setAgentSession(initialAgentSession);
1455
- }, [latestStopFunc, setMessages, setThreadId, setCoagentStates, setAgentSession, agentLock]);
1456
- const latestReset = useUpdatedRef(reset);
1457
- const latestResetFunc = (0, import_react10.useCallback)(() => {
1458
- return latestReset.current();
1459
- }, [latestReset]);
1390
+ const latestRunChatCompletion = useUpdatedRef(runChatCompletion);
1391
+ const latestRunChatCompletionFunc = (0, import_react10.useCallback)(() => {
1392
+ return latestRunChatCompletion.current();
1393
+ }, [latestRunChatCompletion]);
1460
1394
  return {
1461
1395
  visibleMessages: messages,
1462
1396
  appendMessage: latestAppendFunc,
1463
1397
  setMessages: latestSetMessagesFunc,
1464
1398
  reloadMessages: latestReloadFunc,
1465
1399
  stopGeneration: latestStopFunc,
1466
- reset: latestResetFunc,
1467
1400
  deleteMessage: latestDeleteFunc,
1401
+ runChatCompletion: latestRunChatCompletionFunc,
1468
1402
  isLoading
1469
1403
  };
1470
1404
  }
@@ -1656,6 +1590,7 @@ function useCopilotReadable({ description, value, parentId, categories, convert
1656
1590
 
1657
1591
  // src/hooks/use-coagent.ts
1658
1592
  var import_react15 = require("react");
1593
+ var import_react_dom2 = require("react-dom");
1659
1594
  function useCoAgent(options) {
1660
1595
  const isExternalStateManagement = (options2) => {
1661
1596
  return "state" in options2 && "setState" in options2;
@@ -1668,7 +1603,7 @@ function useCoAgent(options) {
1668
1603
  const messagesContext = useCopilotMessagesContext();
1669
1604
  const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
1670
1605
  const { coagentStates, setCoagentStates } = context;
1671
- const { appendMessage } = useCopilotChat();
1606
+ const { appendMessage, runChatCompletion } = useCopilotChat();
1672
1607
  const getCoagentState = (coagentStates2, name2) => {
1673
1608
  if (coagentStates2[name2]) {
1674
1609
  return coagentStates2[name2];
@@ -1685,13 +1620,15 @@ function useCoAgent(options) {
1685
1620
  }
1686
1621
  };
1687
1622
  const setState = (newState) => {
1688
- setCoagentStates((prevAgentStates) => {
1689
- let coagentState2 = getCoagentState(prevAgentStates, name);
1690
- const updatedState = typeof newState === "function" ? newState(coagentState2.state) : newState;
1691
- return __spreadProps(__spreadValues({}, prevAgentStates), {
1692
- [name]: __spreadProps(__spreadValues({}, coagentState2), {
1693
- state: updatedState
1694
- })
1623
+ (0, import_react_dom2.flushSync)(() => {
1624
+ setCoagentStates((prevAgentStates) => {
1625
+ let coagentState2 = getCoagentState(prevAgentStates, name);
1626
+ const updatedState = typeof newState === "function" ? newState(coagentState2.state) : newState;
1627
+ return __spreadProps(__spreadValues({}, prevAgentStates), {
1628
+ [name]: __spreadProps(__spreadValues({}, coagentState2), {
1629
+ state: updatedState
1630
+ })
1631
+ });
1695
1632
  });
1696
1633
  });
1697
1634
  };
@@ -1703,11 +1640,7 @@ function useCoAgent(options) {
1703
1640
  } else if (coagentStates[name] === void 0) {
1704
1641
  setState(options.initialState === void 0 ? {} : options.initialState);
1705
1642
  }
1706
- }, [
1707
- isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0,
1708
- // reset initialstate on reset
1709
- coagentStates === void 0
1710
- ]);
1643
+ }, [isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0]);
1711
1644
  return {
1712
1645
  name,
1713
1646
  nodeName: coagentState.nodeName,
@@ -1721,7 +1654,7 @@ function useCoAgent(options) {
1721
1654
  stopAgent(name, context);
1722
1655
  },
1723
1656
  run: (hint) => {
1724
- return runAgent(name, context, appendMessage, hint);
1657
+ return runAgent(name, context, appendMessage, runChatCompletion, hint);
1725
1658
  }
1726
1659
  };
1727
1660
  }
@@ -1735,22 +1668,11 @@ function stopAgent(name, context) {
1735
1668
  const { agentSession, setAgentSession } = context;
1736
1669
  if (agentSession && agentSession.agentName === name) {
1737
1670
  setAgentSession(null);
1738
- context.setCoagentStates((prevAgentStates) => {
1739
- return __spreadProps(__spreadValues({}, prevAgentStates), {
1740
- [name]: __spreadProps(__spreadValues({}, prevAgentStates[name]), {
1741
- running: false,
1742
- active: false,
1743
- threadId: void 0,
1744
- nodeName: void 0,
1745
- runId: void 0
1746
- })
1747
- });
1748
- });
1749
1671
  } else {
1750
1672
  console.warn(`No agent session found for ${name}`);
1751
1673
  }
1752
1674
  }
1753
- function runAgent(name, context, appendMessage, hint) {
1675
+ function runAgent(name, context, appendMessage, runChatCompletion, hint) {
1754
1676
  return __async(this, null, function* () {
1755
1677
  var _a, _b;
1756
1678
  const { agentSession, setAgentSession } = context;
@@ -1771,7 +1693,11 @@ function runAgent(name, context, appendMessage, hint) {
1771
1693
  const hintMessage = hint({ previousState, currentState: state });
1772
1694
  if (hintMessage) {
1773
1695
  yield appendMessage(hintMessage);
1696
+ } else {
1697
+ yield runChatCompletion();
1774
1698
  }
1699
+ } else {
1700
+ yield runChatCompletion();
1775
1701
  }
1776
1702
  });
1777
1703
  }
@@ -1883,10 +1809,7 @@ ${instructions}
1883
1809
  CopilotTask,
1884
1810
  defaultCopilotContextCategories,
1885
1811
  extract,
1886
- runAgent,
1887
1812
  shouldShowDevConsole,
1888
- startAgent,
1889
- stopAgent,
1890
1813
  useCoAgent,
1891
1814
  useCoAgentStateRender,
1892
1815
  useCopilotAction,