@copilotkit/react-core 1.3.16-mme-reset-chat.2 → 1.3.16-mme-reset-chat.3
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.
- package/CHANGELOG.md +9 -0
- package/dist/{chunk-ZAD6WM7G.mjs → chunk-3LGVOOTH.mjs} +3 -3
- package/dist/{chunk-TYU5DU3I.mjs → chunk-7PBUNYGJ.mjs} +9 -3
- package/dist/{chunk-TYU5DU3I.mjs.map → chunk-7PBUNYGJ.mjs.map} +1 -1
- package/dist/{chunk-R4JPL7WM.mjs → chunk-AB6GYTGE.mjs} +2 -2
- package/dist/{chunk-5AUYYTMA.mjs → chunk-DA2PE4TI.mjs} +2 -2
- package/dist/{chunk-IRJTPUAM.mjs → chunk-IQ32YPV5.mjs} +2 -2
- package/dist/{chunk-IR6Y65ES.mjs → chunk-KEUH7BJV.mjs} +2 -2
- package/dist/{chunk-2ETVGRN4.mjs → chunk-NTADUCPY.mjs} +13 -10
- package/dist/chunk-NTADUCPY.mjs.map +1 -0
- package/dist/{chunk-27TUZNGL.mjs → chunk-NV6FEDPI.mjs} +2 -2
- package/dist/{chunk-DD32VY2D.mjs → chunk-P4BUM2FG.mjs} +16 -9
- package/dist/chunk-P4BUM2FG.mjs.map +1 -0
- package/dist/{chunk-6SCUTPKA.mjs → chunk-UO527OAF.mjs} +8 -2
- package/dist/{chunk-6SCUTPKA.mjs.map → chunk-UO527OAF.mjs.map} +1 -1
- package/dist/{chunk-GBJRZGT7.mjs → chunk-YEBQV2YJ.mjs} +2 -2
- package/dist/components/copilot-provider/copilotkit.js +14 -2
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +2 -2
- package/dist/components/copilot-provider/index.js +14 -2
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +2 -2
- package/dist/components/index.js +14 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/context/copilot-context.d.ts +4 -0
- package/dist/context/copilot-context.js +7 -1
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/index.js +7 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/hooks/index.js +31 -15
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +9 -9
- package/dist/hooks/use-chat.d.ts +16 -8
- package/dist/hooks/use-chat.js +12 -9
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +1 -1
- package/dist/hooks/use-coagent-state-render.js +7 -1
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +2 -2
- package/dist/hooks/use-coagent.js +31 -15
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +5 -5
- package/dist/hooks/use-copilot-action.js +7 -1
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +2 -2
- package/dist/hooks/use-copilot-chat.d.ts +0 -1
- package/dist/hooks/use-copilot-chat.js +31 -15
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +4 -4
- package/dist/hooks/use-copilot-readable.js +7 -1
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +2 -2
- package/dist/hooks/use-make-copilot-document-readable.js +7 -1
- package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
- package/dist/index.js +38 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -11
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +3 -3
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +3 -3
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +3 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +3 -3
- package/package.json +5 -5
- package/src/components/copilot-provider/copilotkit.tsx +6 -0
- package/src/context/copilot-context.tsx +12 -0
- package/src/hooks/use-chat.ts +31 -18
- package/src/hooks/use-copilot-chat.ts +11 -5
- package/dist/chunk-2ETVGRN4.mjs.map +0 -1
- package/dist/chunk-DD32VY2D.mjs.map +0 -1
- /package/dist/{chunk-ZAD6WM7G.mjs.map → chunk-3LGVOOTH.mjs.map} +0 -0
- /package/dist/{chunk-R4JPL7WM.mjs.map → chunk-AB6GYTGE.mjs.map} +0 -0
- /package/dist/{chunk-5AUYYTMA.mjs.map → chunk-DA2PE4TI.mjs.map} +0 -0
- /package/dist/{chunk-IRJTPUAM.mjs.map → chunk-IQ32YPV5.mjs.map} +0 -0
- /package/dist/{chunk-IR6Y65ES.mjs.map → chunk-KEUH7BJV.mjs.map} +0 -0
- /package/dist/{chunk-27TUZNGL.mjs.map → chunk-NV6FEDPI.mjs.map} +0 -0
- /package/dist/{chunk-GBJRZGT7.mjs.map → chunk-YEBQV2YJ.mjs.map} +0 -0
|
@@ -106,7 +106,13 @@ var emptyCopilotContext = {
|
|
|
106
106
|
agentSession: null,
|
|
107
107
|
setAgentSession: () => {
|
|
108
108
|
},
|
|
109
|
-
agentLock: null
|
|
109
|
+
agentLock: null,
|
|
110
|
+
threadId: null,
|
|
111
|
+
setThreadId: () => {
|
|
112
|
+
},
|
|
113
|
+
runId: null,
|
|
114
|
+
setRunId: () => {
|
|
115
|
+
}
|
|
110
116
|
};
|
|
111
117
|
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
112
118
|
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\";\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\n agentLock: string | null;\n setAgentSession: React.Dispatch<React.SetStateAction<AgentSession | null>>;\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\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 agentLock: 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;
|
|
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\";\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\n agentLock: string | null;\n setAgentSession: React.Dispatch<React.SetStateAction<AgentSession | 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\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\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 agentLock: null,\n\n threadId: null,\n setThreadId: () => {},\n\n runId: null,\n setRunId: () => {},\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;AA+IlB,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,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;AAAA,EACxB,WAAW;AAAA,EAEX,UAAU;AAAA,EACV,aAAa,MAAM;AAAA,EAAC;AAAA,EAEpB,OAAO;AAAA,EACP,UAAU,MAAM;AAAA,EAAC;AACnB;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;;;AD7MO,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"]}
|
package/dist/index.js
CHANGED
|
@@ -152,7 +152,13 @@ var emptyCopilotContext = {
|
|
|
152
152
|
agentSession: null,
|
|
153
153
|
setAgentSession: () => {
|
|
154
154
|
},
|
|
155
|
-
agentLock: null
|
|
155
|
+
agentLock: null,
|
|
156
|
+
threadId: null,
|
|
157
|
+
setThreadId: () => {
|
|
158
|
+
},
|
|
159
|
+
runId: null,
|
|
160
|
+
setRunId: () => {
|
|
161
|
+
}
|
|
156
162
|
};
|
|
157
163
|
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
158
164
|
function useCopilotContext() {
|
|
@@ -566,6 +572,8 @@ ${nonDocumentStrings}`;
|
|
|
566
572
|
};
|
|
567
573
|
}
|
|
568
574
|
const [agentSession, setAgentSession] = (0, import_react6.useState)(initialAgentSession);
|
|
575
|
+
const [threadId, setThreadId] = (0, import_react6.useState)(null);
|
|
576
|
+
const [runId, setRunId] = (0, import_react6.useState)(null);
|
|
569
577
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
570
578
|
CopilotContext.Provider,
|
|
571
579
|
{
|
|
@@ -597,7 +605,11 @@ ${nonDocumentStrings}`;
|
|
|
597
605
|
setCoagentStates,
|
|
598
606
|
agentSession,
|
|
599
607
|
setAgentSession,
|
|
600
|
-
agentLock: props.agent || null
|
|
608
|
+
agentLock: props.agent || null,
|
|
609
|
+
threadId,
|
|
610
|
+
setThreadId,
|
|
611
|
+
runId,
|
|
612
|
+
setRunId
|
|
601
613
|
},
|
|
602
614
|
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CopilotMessages, { children })
|
|
603
615
|
}
|
|
@@ -653,19 +665,22 @@ function useChat(options) {
|
|
|
653
665
|
setCoagentStates,
|
|
654
666
|
coagentStates,
|
|
655
667
|
agentSession,
|
|
656
|
-
setAgentSession
|
|
668
|
+
setAgentSession,
|
|
669
|
+
threadId,
|
|
670
|
+
setThreadId,
|
|
671
|
+
runId,
|
|
672
|
+
setRunId
|
|
657
673
|
} = options;
|
|
658
674
|
const abortControllerRef = (0, import_react7.useRef)();
|
|
659
|
-
const threadIdRef = (0, import_react7.useRef)(null);
|
|
660
|
-
const runIdRef = (0, import_react7.useRef)(null);
|
|
661
|
-
const setThreadId = (threadId) => {
|
|
662
|
-
threadIdRef.current = threadId;
|
|
663
|
-
};
|
|
664
675
|
const runChatCompletionRef = (0, import_react7.useRef)();
|
|
665
676
|
const coagentStatesRef = (0, import_react7.useRef)(coagentStates);
|
|
666
677
|
coagentStatesRef.current = coagentStates;
|
|
667
678
|
const agentSessionRef = (0, import_react7.useRef)(agentSession);
|
|
668
679
|
agentSessionRef.current = agentSession;
|
|
680
|
+
const threadIdRef = (0, import_react7.useRef)(threadId);
|
|
681
|
+
threadIdRef.current = threadId;
|
|
682
|
+
const runIdRef = (0, import_react7.useRef)(runId);
|
|
683
|
+
runIdRef.current = runId;
|
|
669
684
|
const publicApiKey = copilotConfig.publicApiKey;
|
|
670
685
|
const headers = __spreadValues(__spreadValues({}, copilotConfig.headers || {}), publicApiKey ? { [import_shared4.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
|
|
671
686
|
const runtimeClient = new import_runtime_client_gql.CopilotRuntimeClient({
|
|
@@ -743,6 +758,8 @@ function useChat(options) {
|
|
|
743
758
|
}
|
|
744
759
|
threadIdRef.current = value.generateCopilotResponse.threadId || null;
|
|
745
760
|
runIdRef.current = value.generateCopilotResponse.runId || null;
|
|
761
|
+
setThreadId(threadIdRef.current);
|
|
762
|
+
setRunId(runIdRef.current);
|
|
746
763
|
const messages2 = (0, import_runtime_client_gql.convertGqlOutputToMessages)(
|
|
747
764
|
(0, import_runtime_client_gql.filterAdjacentAgentStateMessages)(value.generateCopilotResponse.messages)
|
|
748
765
|
);
|
|
@@ -876,9 +893,7 @@ function useChat(options) {
|
|
|
876
893
|
return {
|
|
877
894
|
append,
|
|
878
895
|
reload,
|
|
879
|
-
stop
|
|
880
|
-
setThreadId,
|
|
881
|
-
threadId: threadIdRef.current
|
|
896
|
+
stop
|
|
882
897
|
};
|
|
883
898
|
}
|
|
884
899
|
|
|
@@ -902,7 +917,11 @@ function useCopilotChat(_a = {}) {
|
|
|
902
917
|
coAgentStateRenders,
|
|
903
918
|
agentSession,
|
|
904
919
|
setAgentSession,
|
|
905
|
-
agentLock
|
|
920
|
+
agentLock,
|
|
921
|
+
threadId,
|
|
922
|
+
setThreadId,
|
|
923
|
+
runId,
|
|
924
|
+
setRunId
|
|
906
925
|
} = useCopilotContext();
|
|
907
926
|
const { messages, setMessages } = useCopilotMessagesContext();
|
|
908
927
|
const latestGetContextString = useUpdatedRef(getContextString);
|
|
@@ -938,7 +957,7 @@ function useCopilotChat(_a = {}) {
|
|
|
938
957
|
}),
|
|
939
958
|
[coAgentStateRenders]
|
|
940
959
|
);
|
|
941
|
-
const { append, reload, stop
|
|
960
|
+
const { append, reload, stop } = useChat(__spreadProps(__spreadValues({}, options), {
|
|
942
961
|
actions: Object.values(actions),
|
|
943
962
|
copilotConfig: copilotApiConfig,
|
|
944
963
|
initialMessages: options.initialMessages || [],
|
|
@@ -952,7 +971,11 @@ function useCopilotChat(_a = {}) {
|
|
|
952
971
|
coagentStates,
|
|
953
972
|
setCoagentStates,
|
|
954
973
|
agentSession,
|
|
955
|
-
setAgentSession
|
|
974
|
+
setAgentSession,
|
|
975
|
+
threadId,
|
|
976
|
+
setThreadId,
|
|
977
|
+
runId,
|
|
978
|
+
setRunId
|
|
956
979
|
}));
|
|
957
980
|
const latestAppend = useUpdatedRef(append);
|
|
958
981
|
const latestAppendFunc = (0, import_react8.useCallback)(
|
|
@@ -1008,8 +1031,7 @@ function useCopilotChat(_a = {}) {
|
|
|
1008
1031
|
stopGeneration: latestStopFunc,
|
|
1009
1032
|
deleteMessage: latestDeleteFunc,
|
|
1010
1033
|
reset: latestResetFunc,
|
|
1011
|
-
isLoading
|
|
1012
|
-
threadId
|
|
1034
|
+
isLoading
|
|
1013
1035
|
};
|
|
1014
1036
|
}
|
|
1015
1037
|
function useUpdatedRef(value) {
|