@copilotkit/react-core 1.1.1-feat-runtime-remote-actions.4 → 1.1.1-feat-runtime-remote-actions.5
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-2MQX7BJL.mjs → chunk-6GOM3DN7.mjs} +2 -2
- package/dist/{chunk-IF6P5ZXR.mjs → chunk-6UNB66M3.mjs} +38 -10
- package/dist/chunk-6UNB66M3.mjs.map +1 -0
- package/dist/{chunk-73KBO5JG.mjs → chunk-73YBF52D.mjs} +2 -2
- package/dist/chunk-BWYAGPEF.mjs +1 -0
- package/dist/{chunk-DZH3HSXW.mjs → chunk-CHOQ5C7K.mjs} +35 -8
- package/dist/chunk-CHOQ5C7K.mjs.map +1 -0
- package/dist/{chunk-33ERMMNX.mjs → chunk-DU7PVINC.mjs} +2 -2
- package/dist/chunk-IQH77T4S.mjs +44 -0
- package/dist/chunk-IQH77T4S.mjs.map +1 -0
- package/dist/{chunk-DB4VWZ5Q.mjs → chunk-LTA2O5WH.mjs} +11 -6
- package/dist/chunk-LTA2O5WH.mjs.map +1 -0
- package/dist/chunk-MTOHRBPJ.mjs +87 -0
- package/dist/chunk-MTOHRBPJ.mjs.map +1 -0
- package/dist/{chunk-52M7642J.mjs → chunk-PPYZB3IY.mjs} +52 -31
- package/dist/chunk-PPYZB3IY.mjs.map +1 -0
- package/dist/{chunk-H4XENJME.mjs → chunk-SYJIZLOI.mjs} +2 -2
- package/dist/{chunk-3K7JAFGM.mjs → chunk-TFSMXQYS.mjs} +2 -2
- package/dist/components/copilot-provider/copilotkit-props.d.ts +4 -0
- package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.js +46 -13
- 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 +46 -13
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +2 -2
- package/dist/components/index.js +46 -13
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/context/copilot-context.d.ts +18 -8
- package/dist/context/copilot-context.js +10 -5
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/index.d.ts +2 -1
- package/dist/context/index.js +10 -5
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/hooks/index.d.ts +4 -2
- package/dist/hooks/index.js +205 -89
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +17 -17
- package/dist/hooks/use-chat.d.ts +24 -7
- package/dist/hooks/use-chat.js +51 -30
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +1 -1
- package/dist/hooks/use-coagent-action.d.ts +5 -0
- package/dist/hooks/{use-copilot-chat-ui.js → use-coagent-action.js} +48 -22
- package/dist/hooks/use-coagent-action.js.map +1 -0
- package/dist/hooks/use-coagent-action.mjs +9 -0
- package/dist/hooks/use-coagent.d.ts +14 -18
- package/dist/hooks/use-coagent.js +184 -17
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +6 -20
- package/dist/hooks/use-coagent.mjs.map +1 -1
- package/dist/hooks/use-copilot-action.js +10 -5
- 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.js +89 -37
- 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 +10 -5
- 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 +10 -5
- 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.d.ts +4 -2
- package/dist/index.js +263 -119
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -21
- package/dist/lib/copilot-task.d.ts +2 -1
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +3 -3
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +3 -3
- package/dist/types/coagent-action.d.ts +17 -0
- package/dist/types/coagent-action.js +19 -0
- package/dist/types/coagent-action.js.map +1 -0
- package/dist/types/coagent-action.mjs +1 -0
- package/dist/types/coagent-state.d.ts +11 -0
- package/dist/types/coagent-state.js +19 -0
- package/dist/types/coagent-state.js.map +1 -0
- package/dist/types/coagent-state.mjs +1 -0
- package/dist/types/coagent-state.mjs.map +1 -0
- package/dist/utils/extract.d.ts +2 -1
- package/dist/utils/extract.js.map +1 -1
- package/dist/utils/extract.mjs +3 -3
- package/dist/utils/index.d.ts +2 -1
- 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-props.tsx +5 -0
- package/src/components/copilot-provider/copilotkit.tsx +41 -9
- package/src/context/copilot-context.tsx +34 -15
- package/src/hooks/index.ts +2 -2
- package/src/hooks/use-chat.ts +88 -38
- package/src/hooks/use-coagent-action.ts +44 -0
- package/src/hooks/use-coagent.ts +111 -38
- package/src/hooks/use-copilot-chat.ts +29 -2
- package/src/types/coagent-action.ts +17 -0
- package/src/types/coagent-state.ts +9 -0
- package/dist/chunk-52M7642J.mjs.map +0 -1
- package/dist/chunk-6YOQY4WD.mjs +0 -20
- package/dist/chunk-6YOQY4WD.mjs.map +0 -1
- package/dist/chunk-A47L32JN.mjs +0 -52
- package/dist/chunk-A47L32JN.mjs.map +0 -1
- package/dist/chunk-AIWDXM7L.mjs +0 -1
- package/dist/chunk-DB4VWZ5Q.mjs.map +0 -1
- package/dist/chunk-DZH3HSXW.mjs.map +0 -1
- package/dist/chunk-IF6P5ZXR.mjs.map +0 -1
- package/dist/hooks/use-agent-state.d.ts +0 -12
- package/dist/hooks/use-agent-state.js +0 -499
- package/dist/hooks/use-agent-state.js.map +0 -1
- package/dist/hooks/use-agent-state.mjs +0 -19
- package/dist/hooks/use-copilot-chat-ui.d.ts +0 -13
- package/dist/hooks/use-copilot-chat-ui.js.map +0 -1
- package/dist/hooks/use-copilot-chat-ui.mjs +0 -10
- package/src/hooks/use-agent-state.ts +0 -63
- package/src/hooks/use-copilot-chat-ui.ts +0 -26
- /package/dist/{chunk-2MQX7BJL.mjs.map → chunk-6GOM3DN7.mjs.map} +0 -0
- /package/dist/{chunk-73KBO5JG.mjs.map → chunk-73YBF52D.mjs.map} +0 -0
- /package/dist/{chunk-AIWDXM7L.mjs.map → chunk-BWYAGPEF.mjs.map} +0 -0
- /package/dist/{chunk-33ERMMNX.mjs.map → chunk-DU7PVINC.mjs.map} +0 -0
- /package/dist/{chunk-H4XENJME.mjs.map → chunk-SYJIZLOI.mjs.map} +0 -0
- /package/dist/{chunk-3K7JAFGM.mjs.map → chunk-TFSMXQYS.mjs.map} +0 -0
- /package/dist/hooks/{use-agent-state.mjs.map → use-coagent-action.mjs.map} +0 -0
- /package/dist/{hooks/use-copilot-chat-ui.mjs.map → types/coagent-action.mjs.map} +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { CopilotCloudConfig, FunctionCallHandler } from '@copilotkit/shared';
|
|
2
|
-
import { Message
|
|
2
|
+
import { Message } from '@copilotkit/runtime-client-gql';
|
|
3
3
|
import { ActionRenderProps, FrontendAction } from '../types/frontend-action.js';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { TreeNodeId } from '../hooks/use-tree.js';
|
|
6
6
|
import { DocumentPointer } from '../types/document-pointer.js';
|
|
7
7
|
import { CopilotChatSuggestionConfiguration } from '../types/chat-suggestion-configuration.js';
|
|
8
|
-
import {
|
|
8
|
+
import { CoagentActionRenderProps, CoagentAction } from '../types/coagent-action.js';
|
|
9
|
+
import { CoagentState } from '../types/coagent-state.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Interface for the configuration of the Copilot API.
|
|
@@ -60,14 +61,23 @@ interface CopilotApiConfig {
|
|
|
60
61
|
credentials?: RequestCredentials;
|
|
61
62
|
}
|
|
62
63
|
type InChatRenderFunction = (props: ActionRenderProps<any>) => string | JSX.Element;
|
|
64
|
+
type CoagentInChatRenderFunction = (props: CoagentActionRenderProps<any>) => string | JSX.Element;
|
|
63
65
|
interface ChatComponentsCache {
|
|
64
66
|
actions: Record<string, InChatRenderFunction | string>;
|
|
65
|
-
|
|
67
|
+
coagentActions: Record<string, CoagentInChatRenderFunction | string>;
|
|
68
|
+
}
|
|
69
|
+
interface AgentSession {
|
|
70
|
+
agentName: string;
|
|
71
|
+
threadId?: string;
|
|
72
|
+
nodeName?: string;
|
|
66
73
|
}
|
|
67
74
|
interface CopilotContextParams {
|
|
68
75
|
actions: Record<string, FrontendAction<any>>;
|
|
69
76
|
setAction: (id: string, action: FrontendAction<any>) => void;
|
|
70
77
|
removeAction: (id: string) => void;
|
|
78
|
+
coagentActions: Record<string, CoagentAction<any>>;
|
|
79
|
+
setCoagentAction: (id: string, action: CoagentAction<any>) => void;
|
|
80
|
+
removeCoagentAction: (id: string) => void;
|
|
71
81
|
chatComponentsCache: React.RefObject<ChatComponentsCache>;
|
|
72
82
|
getFunctionCallHandler: (customEntryPoints?: Record<string, FrontendAction<any>>) => FunctionCallHandler;
|
|
73
83
|
addContext: (context: string, parentId?: string, categories?: string[]) => TreeNodeId;
|
|
@@ -89,12 +99,12 @@ interface CopilotContextParams {
|
|
|
89
99
|
setChatInstructions: React.Dispatch<React.SetStateAction<string>>;
|
|
90
100
|
copilotApiConfig: CopilotApiConfig;
|
|
91
101
|
showDevConsole: boolean | "auto";
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
102
|
+
coagentStates: Record<string, CoagentState>;
|
|
103
|
+
setCoagentStates: React.Dispatch<React.SetStateAction<Record<string, CoagentState>>>;
|
|
104
|
+
agentSession: AgentSession | null;
|
|
105
|
+
setAgentSession: React.Dispatch<React.SetStateAction<AgentSession | null>>;
|
|
96
106
|
}
|
|
97
107
|
declare const CopilotContext: React.Context<CopilotContextParams>;
|
|
98
108
|
declare function useCopilotContext(): CopilotContextParams;
|
|
99
109
|
|
|
100
|
-
export { ChatComponentsCache, CopilotApiConfig, CopilotContext, CopilotContextParams, InChatRenderFunction, useCopilotContext };
|
|
110
|
+
export { AgentSession, ChatComponentsCache, CoagentInChatRenderFunction, CopilotApiConfig, CopilotContext, CopilotContextParams, InChatRenderFunction, useCopilotContext };
|
|
@@ -61,7 +61,12 @@ var emptyCopilotContext = {
|
|
|
61
61
|
},
|
|
62
62
|
removeAction: () => {
|
|
63
63
|
},
|
|
64
|
-
|
|
64
|
+
coagentActions: {},
|
|
65
|
+
setCoagentAction: () => {
|
|
66
|
+
},
|
|
67
|
+
removeCoagentAction: () => {
|
|
68
|
+
},
|
|
69
|
+
chatComponentsCache: { current: { actions: {}, coagentActions: {} } },
|
|
65
70
|
getContextString: (documents, categories) => returnAndThrowInDebug(""),
|
|
66
71
|
addContext: () => "",
|
|
67
72
|
removeContext: () => {
|
|
@@ -95,11 +100,11 @@ var emptyCopilotContext = {
|
|
|
95
100
|
removeChatSuggestionConfiguration: () => {
|
|
96
101
|
},
|
|
97
102
|
showDevConsole: "auto",
|
|
98
|
-
|
|
99
|
-
|
|
103
|
+
coagentStates: {},
|
|
104
|
+
setCoagentStates: () => {
|
|
100
105
|
},
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
agentSession: null,
|
|
107
|
+
setAgentSession: () => {
|
|
103
108
|
}
|
|
104
109
|
};
|
|
105
110
|
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/copilot-context.tsx"],"sourcesContent":["import { CopilotCloudConfig, FunctionCallHandler } from \"@copilotkit/shared\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/context/copilot-context.tsx"],"sourcesContent":["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 return React.useContext(CopilotContext);\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;AAGA,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,SAAO,aAAAA,QAAM,WAAW,cAAc;AACxC;AAEA,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI,MAAM,uEAAuE;AACvF,SAAO;AACT;","names":["React"]}
|
package/dist/context/index.d.ts
CHANGED
package/dist/context/index.js
CHANGED
|
@@ -63,7 +63,12 @@ var emptyCopilotContext = {
|
|
|
63
63
|
},
|
|
64
64
|
removeAction: () => {
|
|
65
65
|
},
|
|
66
|
-
|
|
66
|
+
coagentActions: {},
|
|
67
|
+
setCoagentAction: () => {
|
|
68
|
+
},
|
|
69
|
+
removeCoagentAction: () => {
|
|
70
|
+
},
|
|
71
|
+
chatComponentsCache: { current: { actions: {}, coagentActions: {} } },
|
|
67
72
|
getContextString: (documents, categories) => returnAndThrowInDebug(""),
|
|
68
73
|
addContext: () => "",
|
|
69
74
|
removeContext: () => {
|
|
@@ -97,11 +102,11 @@ var emptyCopilotContext = {
|
|
|
97
102
|
removeChatSuggestionConfiguration: () => {
|
|
98
103
|
},
|
|
99
104
|
showDevConsole: "auto",
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
coagentStates: {},
|
|
106
|
+
setCoagentStates: () => {
|
|
102
107
|
},
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
agentSession: null,
|
|
109
|
+
setAgentSession: () => {
|
|
105
110
|
}
|
|
106
111
|
};
|
|
107
112
|
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
@@ -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 {
|
|
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 return React.useContext(CopilotContext);\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,SAAO,aAAAA,QAAM,WAAW,cAAc;AACxC;AAEA,SAAS,sBAAyB,OAAa;AAC7C,QAAM,IAAI,MAAM,uEAAuE;AACvF,SAAO;AACT;","names":["React"]}
|
package/dist/context/index.mjs
CHANGED
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
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';
|
|
3
4
|
export { useMakeCopilotDocumentReadable } from './use-make-copilot-document-readable.js';
|
|
4
5
|
export { UseChatHelpers } from './use-chat.js';
|
|
5
6
|
export { useCopilotReadable } from './use-copilot-readable.js';
|
|
6
|
-
export {
|
|
7
|
-
export { useCopilotChatUI } from './use-copilot-chat-ui.js';
|
|
7
|
+
export { useCoagent } from './use-coagent.js';
|
|
8
8
|
import '@copilotkit/runtime-client-gql';
|
|
9
9
|
import '../types/system-message.js';
|
|
10
10
|
import '../types/frontend-action.js';
|
|
11
11
|
import '@copilotkit/shared';
|
|
12
12
|
import 'react';
|
|
13
|
+
import '../types/coagent-action.js';
|
|
13
14
|
import '../types/document-pointer.js';
|
|
14
15
|
import '../context/copilot-context.js';
|
|
15
16
|
import './use-tree.js';
|
|
16
17
|
import '../types/chat-suggestion-configuration.js';
|
|
18
|
+
import '../types/coagent-state.js';
|